Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into large-block-text-…
Browse files Browse the repository at this point in the history
…setting
  • Loading branch information
DNin01 committed Jul 30, 2023
2 parents d68eb68 + 2f20ba0 commit f658ffa
Show file tree
Hide file tree
Showing 266 changed files with 2,679 additions and 1,235 deletions.
13 changes: 12 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"root": true,
"ignorePatterns": ["node_modules/*", "_locales/*", ".github/*", "addons-l10n/*", "libraries/thirdparty/*"],
"ignorePatterns": ["node_modules/*", "_locales/*", ".github/workflows/*", "addons-l10n/*", "libraries/thirdparty/*"],
"parserOptions": {
"sourceType": "module"
},
Expand Down Expand Up @@ -98,6 +98,17 @@
}
]
}
},
{
// The addon uses static fields, only specified in ES13 (2022-)
// yet supported by older browsers.
// We use ES11 (2020) as everything in that version can be used by
// the minimum supported browser (Chrome 80, Firefox 86).
// To properly lint the file, add exception to the parser version.
"files": ["addons/middle-click-popup/*.js"],
"parserOptions": {
"ecmaVersion": 13
}
}
]
}
15 changes: 14 additions & 1 deletion .github/gen-manifest.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
const PERMISSIONS_IGNORED_IN_CHROME = ["clipboardWrite"];
const PERMISSIONS_IGNORED_IN_FIREFOX = ["declarativeNetRequestWithHostAccess"];
// Previously included declarativeNetRequestWithHostAccess.
const PERMISSIONS_IGNORED_IN_FIREFOX = [];
// These should be removed during production manifest gen.
const PERMISSIONS_ALWAYS_IGNORED = [
"https://scratchfoundation.github.io/scratch-gui/*",
"http://localhost:8333/*",
"http://localhost:8601/*",
];

/**
* Generates a manifest for specific browsers.
Expand All @@ -14,6 +21,12 @@ export default (env, manifest) => {
manifest.icons["1024"] = "images/icon.png";
manifest.icons["32"] = "images/icon-32.png";
manifest.icons["16"] = "images/icon-16.png";
manifest.permissions = manifest.permissions.filter((permission) => !PERMISSIONS_ALWAYS_IGNORED.includes(permission));
manifest.content_scripts.forEach((content_script) => {
content_script.matches = content_script.matches.filter(
(permission) => !PERMISSIONS_ALWAYS_IGNORED.includes(permission)
);
});
switch (env) {
case "chrome": {
delete manifest.browser_specific_settings;
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ _locales/*/messages.json
!_locales/en/messages.json

.github/*
!.github/*.mjs
3 changes: 2 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"printWidth": 120,
"endOfLine": "lf"
"endOfLine": "lf",
"trailingComma": "es5"
}
35 changes: 35 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"search.exclude": {
"libraries/thirdparty/**": true,
"libraries/licenses/**": true,

// All languages but English
"_locales/[abcdfghijklmnopqrstuvwxyz]*": true,
"_locales/[abcdefghijklmnopqrstuvwxyz][abcdefghijklmopqrstuvwxyz]*": true,
// All languages but English
"addons-l10n/[abcdfghijklmnopqrstuvwxyz]*": true,
"addons-l10n/[abcdefghijklmnopqrstuvwxyz][abcdefghijklmopqrstuvwxyz]*": true
},

"json.schemas": [
{
"fileMatch": ["/addons/*/addon.json"],
"url": "https://raw.githubusercontent.com/ScratchAddons/manifest-schema/dist/schema.json"
},
{
"fileMatch": ["/manifest.json"],
"url": "https://json.schemastore.org/chrome-manifest.json"
},
{
"fileMatch": ["/addons/addons.json"],
"schema": {
"type": "array",
"uniqueItems": true,
"items": {
"type": "string",
"pattern": "^([a-zA-Z0-9-]+|//.+)$"
}
}
}
]
}
2 changes: 1 addition & 1 deletion _locales/pt_BR/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _locales/pt_PT/messages.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion _locales/th/messages.json

Large diffs are not rendered by default.

23 changes: 0 additions & 23 deletions addon-api/content-script/Account.js

This file was deleted.

3 changes: 0 additions & 3 deletions addon-api/content-script/Addon.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import Addon from "../common/Addon.js";
import Tab from "./Tab.js";
import Auth from "./Auth.js";
import Account from "./Account.js";

/**
* An addon that loads as a userscript.
* @extends Addon
* @property {Tab} tab
* @property {Auth} auth
* @property {Account} account
*/
export default class UserscriptAddon extends Addon {
constructor(info) {
Expand All @@ -18,7 +16,6 @@ export default class UserscriptAddon extends Addon {
this.tab = new Tab(info);
this.auth.dispose();
this.auth = new Auth(this);
this.account = new Account(this);
this.self.disabled = false;
this.self.enabledLate = info.enabledLate;
}
Expand Down
7 changes: 6 additions & 1 deletion addon-api/content-script/Tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ export default class Tab extends Listenable {
* @type {?string}
*/
get editorMode() {
if (location.origin === "https://scratchfoundation.github.io" || location.port === "8601") {
// Note that scratch-gui does not change the URL when going fullscreen.
if (this.redux.state?.scratchGui?.mode?.isFullScreen) return "fullscreen";
return "editor";
}
const pathname = location.pathname.toLowerCase();
const split = pathname.split("/").filter(Boolean);
if (!split[0] || split[0] !== "projects") return null;
Expand Down Expand Up @@ -354,7 +359,7 @@ export default class Tab extends Listenable {
* @type {string}
*/
get direction() {
// https://github.com/LLK/scratch-l10n/blob/master/src/supported-locales.js
// https://github.com/scratchfoundation/scratch-l10n/blob/master/src/supported-locales.js
const rtlLocales = ["ar", "ckb", "fa", "he"];
const lang = scratchAddons.globalState.auth.scratchLang.split("-")[0];
return rtlLocales.includes(lang) ? "rtl" : "ltr";
Expand Down
2 changes: 1 addition & 1 deletion addon-api/content-script/Trap.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default class Trap extends Listenable {
const editorMode = this._getEditorMode();
if (!editorMode || editorMode === "embed") throw new Error("Cannot access paper on this page");
// We can access paper through .tool on tools, for example:
// https://github.com/LLK/scratch-paint/blob/develop/src/containers/bit-brush-mode.jsx#L60-L62
// https://github.com/scratchfoundation/scratch-paint/blob/develop/src/containers/bit-brush-mode.jsx#L60-L62
// It happens that paper's Tool objects contain a reference to the entirety of paper's scope.
const modeSelector = await this._waitForElement("[class*='paint-editor_mode-selector']", {
reduxCondition: (state) => state.scratchGui.editorTab.activeTabIndex === 1 && !state.scratchGui.mode.isPlayerOnly,
Expand Down
10 changes: 5 additions & 5 deletions addon-api/content-script/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const getNamesIdsDefaults = (blockData) => [
];

// This needs to function exactly as Scratch does:
// https://github.com/LLK/scratch-blocks/blob/abbfe93136fef57fdfb9a077198b0bc64726f012/blocks_vertical/procedures.js#L207-L215
// https://github.com/scratchfoundation/scratch-blocks/blob/abbfe93136fef57fdfb9a077198b0bc64726f012/blocks_vertical/procedures.js#L207-L215
// Returns a list like ["%s", "%d"]
const parseArguments = (code) =>
code
Expand Down Expand Up @@ -158,8 +158,8 @@ const injectWorkspace = (ScratchBlocks) => {
};

// We use Scratch's extension category mechanism to create a new category.
// https://github.com/LLK/scratch-gui/blob/ddd2fa06f2afa140a46ec03be91796ded861e65c/src/containers/blocks.jsx#L344
// https://github.com/LLK/scratch-vm/blob/a0c11d6d8664a4f2d55632e70630d09ec6e9ae28/src/engine/runtime.js#L1381
// https://github.com/scratchfoundation/scratch-gui/blob/ddd2fa06f2afa140a46ec03be91796ded861e65c/src/containers/blocks.jsx#L344
// https://github.com/scratchfoundation/scratch-vm/blob/a0c11d6d8664a4f2d55632e70630d09ec6e9ae28/src/engine/runtime.js#L1381
const originalGetBlocksXML = vm.runtime.getBlocksXML;
vm.runtime.getBlocksXML = function (target) {
const result = originalGetBlocksXML.call(this, target);
Expand All @@ -179,8 +179,8 @@ const injectWorkspace = (ScratchBlocks) => {

// Trick Scratch into thinking addon blocks are defined somewhere.
// This makes Scratch's "is this procedure used anywhere" check work when addon blocks exist.
// getDefineBlock is used in https://github.com/LLK/scratch-blocks/blob/37f12ae3e342480f4d8e7b6ba783c46e29e77988/core/block_dragger.js#L275-L297
// and https://github.com/LLK/scratch-blocks/blob/develop/core/procedures.js
// getDefineBlock is used in https://github.com/scratchfoundation/scratch-blocks/blob/37f12ae3e342480f4d8e7b6ba783c46e29e77988/core/block_dragger.js#L275-L297
// and https://github.com/scratchfoundation/scratch-blocks/blob/develop/core/procedures.js
// Only block_dragger.js should be able to reference addon blocks, but if procedures.js does
// somehow, we shim enough of the API that things shouldn't break.
const originalGetDefineBlock = ScratchBlocks.Procedures.getDefineBlock;
Expand Down
2 changes: 1 addition & 1 deletion addon-api/content-script/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const createEditorModal = (tab, title, { isOpen = false } = {}) => {
closeButton.appendChild(
Object.assign(document.createElement("img"), {
className: tab.scratchClass("close-button_close-icon"),
src: "/static/assets/cb666b99d3528f91b52f985dfb102afa.svg",
src: import.meta.url + "/../../../images/cs/close-s3.svg",
})
);
const content = Object.assign(document.createElement("div"), {
Expand Down
2 changes: 1 addition & 1 deletion addons-l10n/de/60fps.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"60fps/@name":"60FPS-Projektplayermodus","60fps/@description":"Alt+Klick auf der grünen Flagge, um den 60FPS-Modus umzuschalten.","60fps/@info-projectRunsFasterNotice":"Projekte werden bei 60FPS mit doppelter Geschwindigkeit ausgeführt, da sie normalerweise mit 30FPS laufen.","60fps/@settings-name-framerate":"Alt+GrüneFlagge FPS"}
{"60fps/@name":"60FPS-Projektplayermodus","60fps/@description":"Alt+Klick auf der grünen Flagge, um den 60FPS-Modus umzuschalten.","60fps/@info-projectRunsFasterNotice":"Die meisten Projekte werden sich mit 60FPS nicht richtig verhalten, weil durch erhöhen der Framefrequenz die Skripte dadurch schneller ausgeführt werden. Dies sollte nur auf Projekten angewendet werden, die es unterstützen.","60fps/@settings-name-framerate":"Alt+GrüneFlagge FPS"}
2 changes: 1 addition & 1 deletion addons-l10n/de/dark-www.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"dark-www/@name":"Dunkler Modus und benutzerdefinierte Farben auf der Website","dark-www/@description":"Passe die von der Scratch-Website verwendeten Farben an. Mehere Designs von verschiedenen Autoren verfügbar. Falls du den Dunklen Modus nicht brauchst, aber die Standardfarben ändern willst, kannst du die \"Scratch-Standardfarben\"-Vorlage auswählen und sie optimieren.","dark-www/@update":"Die Voreinstellungen von diesem Addon wurden mit der neuen lilanen Akzentfarbe aktualisiert. Voreinstellungen, die blau nutzen, sind weiterhin verfügbar.","dark-www/@preset-name-darkWww":"Dunkles WWW","dark-www/@preset-description-darkWww":"Ein dunkles Design von Ucrash","dark-www/@credits-addon":"Addon, \"Experimentell\" Dunkel","dark-www/@credits-darkwww":"Dunkles WWW","dark-www/@settings-name-page":"Seitenhintergrund","dark-www/@settings-name-navbar":"Hintergrund der Navigationsleiste","dark-www/@settings-name-box":"Hintergrund von Inhalten","dark-www/@settings-name-gray":"Grauer Hintergrund","dark-www/@settings-name-blue":"Blauer Hintergrund","dark-www/@settings-name-input":"Hintergrund von Eingabefeldern","dark-www/@settings-name-button":"Markierungsfarbe","dark-www/@settings-name-link":"Linkfarbe","dark-www/@settings-name-footer":"Hintergrund der Fußleiste","dark-www/@settings-name-border":"Randfarbe","dark-www/@settings-name-darkBanners":"Farbige Bereiche","dark-www/@settings-select-darkBanners-off":"Standard","dark-www/@settings-select-darkBanners-darker":"Dunkler","dark-www/@settings-select-darkBanners-desaturated":"Dunkler und entsättigt","dark-www/@settings-name-darkForumCode":"Dunkle Codeblöcke in Foren"}
{"dark-www/@name":"Dunkler Modus und benutzerdefinierte Farben auf der Website","dark-www/@description":"Passe die von der Scratch-Website verwendeten Farben an. Mehere Designs von verschiedenen Autoren verfügbar. Falls du den Dunklen Modus nicht brauchst, aber die Standardfarben ändern willst, kannst du die \"Scratch-Standardfarben\"-Vorlage auswählen und sie optimieren.","dark-www/@preset-name-experimentalDark":"\"Experimentell\" Dunkel","dark-www/@preset-description-experimentalDark":"Ein auf einem Userstyle basierendes dunkles Design von Maximouse. Nicht experimentell","dark-www/@preset-name-experimentalDark-blue":"\"Experimentell\" Dunkel (blau)","dark-www/@preset-description-experimentalDark-blue":"\"Experimentell\" Dunkel mit einer blauen Akzentfarbe","dark-www/@preset-name-darkWww":"Dunkles WWW","dark-www/@preset-description-darkWww":"Ein dunkles Design von Ucrash","dark-www/@preset-name-scratch":"Scratch's Standardfarben","dark-www/@preset-description-scratch":"Die normalen von Scratch verwendeten Farben","dark-www/@preset-name-scratch-blue":"Scratch's Standardfarben (blau)","dark-www/@preset-description-scratch-blue":"Die von Scratch original verwendeten Farben","dark-www/@credits-addon":"Addon, \"Experimentell\" Dunkel","dark-www/@credits-darkwww":"Dunkles WWW","dark-www/@settings-name-page":"Seitenhintergrund","dark-www/@settings-name-navbar":"Hintergrund der Navigationsleiste","dark-www/@settings-name-box":"Hintergrund von Inhalten","dark-www/@settings-name-gray":"Grauer Hintergrund","dark-www/@settings-name-blue":"Blauer Hintergrund","dark-www/@settings-name-input":"Hintergrund von Eingabefeldern","dark-www/@settings-name-button":"Markierungsfarbe","dark-www/@settings-name-link":"Linkfarbe","dark-www/@settings-name-footer":"Hintergrund der Fußleiste","dark-www/@settings-name-border":"Randfarbe","dark-www/@settings-name-messageIndicatorColor":"Nachrichtenzähler in der Navigationsleiste","dark-www/@settings-name-messageIndicatorOnMessagesPage":"Nachrichtenzähler auf der Nachrichtenseite","dark-www/@settings-name-darkBanners":"Farbige Bereiche","dark-www/@settings-select-darkBanners-off":"Standard","dark-www/@settings-select-darkBanners-darker":"Dunkler","dark-www/@settings-select-darkBanners-desaturated":"Dunkler und entsättigt","dark-www/@settings-name-darkForumCode":"Dunkle Codeblöcke in Foren"}
Loading

0 comments on commit f658ffa

Please sign in to comment.