Skip to content
This repository was archived by the owner on Oct 2, 2024. It is now read-only.

Commit f4ab541

Browse files
committed
Update DevTools extension
1 parent b02c169 commit f4ab541

21 files changed

+53
-38
lines changed

_locales/pt-br/messages.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"extensionName":{"message":"Ferramentas de Desenvolvedor do Scratch 3"},"extensionDescription":{"message":"Ferramentas de Desenvolvedor do Scratch 3 para melhorar sua experiência de edição em https://scratch.mit.edu"}}

addon/DevTools.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -643,11 +643,7 @@ export default class DevTools {
643643
continue;
644644
}
645645

646-
// blocks._blocks is not iterable, have to do it using an 'in'
647-
for (const id in blocks._blocks) {
648-
if (!blocks._blocks.hasOwnProperty(id)) {
649-
continue;
650-
}
646+
for (const id of Object.keys(blocks._blocks)) {
651647
const block = blocks._blocks[id];
652648
// To find event broadcaster blocks, we look for the nested "event_broadcast_menu" blocks first that match the event name
653649
if (block.opcode === "event_broadcast_menu" && block.fields.BROADCAST_OPTION.value === name) {

addon/blockly/BlockFlasher.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default class BlockFlasher {
2222
* @private
2323
*/
2424
function _flash() {
25-
myFlash.block.setColour(flashOn ? "#ffff80" : myFlash.colour);
25+
myFlash.block.svgPath_.style.fill = flashOn ? "#ffff80" : myFlash.colour;
2626
flashOn = !flashOn;
2727
count--;
2828
if (count > 0) {

addon/blockly/Utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export default class Utils {
4747
const currentWorkspace = Blockly.getMainWorkspace();
4848
if (currentWorkspace.getToolbox()) {
4949
// Sadly get get workspace does not always return the 'real' workspace... Not sure how to get that at the moment,
50-
// but we can work out whether it's the right one by whether it hsa a toolbox.
50+
// but we can work out whether it's the right one by whether it has a toolbox.
5151
this._workspace = currentWorkspace;
5252
}
5353
return this._workspace;

addon/userscript.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default async function ({ addon, global, console, msg, safeMsg: m }) {
88
}
99

1010
// 0-indexed 6 = July
11-
const releaseDate = new Date(2021, 1, 8);
11+
const releaseDate = new Date(2021, 1, 22);
1212
const releaseDateLocalized = new Intl.DateTimeFormat(msg.locale).format(releaseDate);
1313

1414
const helpHTML = `
@@ -28,7 +28,7 @@ export default async function ({ addon, global, console, msg, safeMsg: m }) {
2828
</div>
2929
<div id="s3devHelpContent">
3030
<p>${m("version", {
31-
version: "1.9.0",
31+
version: "1.10.0",
3232
date: releaseDateLocalized,
3333
ndash: "&ndash;",
3434
url: '<a target="_blank" rel="noreferrer noopener" href="https://www.youtube.com/griffpatch">Griffpatch</a>',

inject/run-addon.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Localization from "./l10n.js";
22

3-
// Make sure SA lower than v1.9.0 doesn't run editor-devtools
3+
// Make sure SA doesn't run editor-devtools
44
window.initGUI = true;
55

66
const MAIN_JS = "userscript.js";
@@ -77,6 +77,9 @@ const langCode = `; ${document.cookie}`.split("; scratchlanguage=").pop().split(
7777
function getL10NURLs() {
7878
// Note: not identical to Scratch Addons function
7979
const urls = [getURL(`l10n/${langCode}`)];
80+
if (langCode === "pt") {
81+
urls.push(getURL(`addons-l10n/pt-br`));
82+
}
8083
if (langCode.includes("-")) {
8184
urls.push(getURL(`l10n/${langCode.split("-")[0]}`));
8285
}
@@ -89,6 +92,12 @@ const l10nObject = new Localization(getL10NURLs());
8992
const msg = (key, placeholders) => l10nObject.get(`editor-devtools/${key}`, placeholders);
9093
msg.locale = langCode;
9194

95+
const isPageReady = () =>
96+
// Make sure <title> element exists to make sure Scratch <style>s were injected,
97+
// which are necessary for addon.tab.scratchClass() calls.
98+
// We also need the stage element to be there to get the VM object.
99+
document.querySelector("title") && document.querySelector('div[class^="stage-wrapper_stage-wrapper_"]');
100+
92101
l10nObject.loadByAddonId("editor-devtools").then(() =>
93102
import(scriptUrl).then((module) => {
94103
const loaded = () => {
@@ -105,7 +114,18 @@ l10nObject.loadByAddonId("editor-devtools").then(() =>
105114
safeMsg: (key, placeholders) => l10nObject.escaped(`editor-devtools/${key}`, placeholders),
106115
});
107116
};
108-
if (document.readyState === "complete") loaded();
109-
else window.addEventListener("load", () => loaded(), { once: true });
117+
if (isPageReady()) {
118+
if (document.readyState === "complete") loaded();
119+
else window.addEventListener("load", () => loaded(), { once: true });
120+
} else {
121+
const observer = new MutationObserver(() => {
122+
if (isPageReady()) {
123+
if (document.readyState === "complete") loaded();
124+
else window.addEventListener("load", () => loaded(), { once: true });
125+
observer.disconnect();
126+
}
127+
});
128+
observer.observe(document.documentElement, { childList: true, subtree: true });
129+
}
110130
})
111131
);

l10n/de/_general.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"_locale":"de","_locale_name":"Deutsch"}
1+
{"_locale":"de","_locale_name":"Deutsch","thumb-success":"Thumbnail hochgeladen.","thumb-error":"Fehler beim Hochladen des Thumbnails.","thumb-error-413":"Die Datei ist zu groß.","thumb-error-503":"Der Thumbnail-Server hat ein Problem. Bitte versuche es später erneut."}

l10n/en/_general.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
{
22
"_locale": "en",
3-
"_locale_name": "English"
3+
"_locale_name": "English",
4+
"thumb-success": "Thumbnail uploaded.",
5+
"thumb-error": "Failed to upload thumbnail.",
6+
"thumb-error-413": "The file is too big.",
7+
"thumb-error-503": "Thumbnail server is having a problem. Please wait and try again."
48
}

l10n/es/_general.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"_locale":"es","_locale_name":"español"}
1+
{"_locale":"es","_locale_name":"español","thumb-success":"Miniatura subida.","thumb-error":"No se pudo subir la miniatura.","thumb-error-413":"El archivo es muy grande.","thumb-error-503":"El servidor de miniaturas está teniendo un problema. Por favor espere e intente de nuevo."}

l10n/fr/_general.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"_locale":"fr","_locale_name":"français"}
1+
{"_locale":"fr","_locale_name":"français","thumb-success":"Miniature définie.","thumb-error":"Echec lors du téléchargement de la miniature.","thumb-error-413":"Le fichier est trop lourd.","thumb-error-503":"Le serveur des miniatures a un problème. Veuillez réessayer dans quelques minutes"}

0 commit comments

Comments
 (0)