Commit Graph
3536 Commits
Author SHA1 Message Date
GarboMuffin 33439939d2 Add API for extension block to be dropped anywhere 2023-07-07 19:32:56 -05:00
GarboMuffin 19c9e8f591 Fix Scratch.translate in unsandboxed custom extensions 2023-05-29 01:16:04 -05:00
GarboMuffin f6ab22e280 Merge pull request #135 from TurboWarp/default-extension-urls
Add default extension URL for compatibility with Scratch Lab animated text projects
2023-05-28 23:57:08 -05:00
GarboMuffin 21915f4565 Export some internal classes for extensions
This is similar to what we do in TW/scratch-render
2023-05-28 22:48:38 -05:00
GarboMuffin ea81f29955 Always force noreferrer when opening new windows 2023-05-26 22:32:03 -05:00
GarboMuffin c4561c2f1c Support custom buttons in extensions (#137) 2023-05-26 20:52:52 -05:00
GarboMuffin 227dec235a Add canRecordAudio, canRecordVideo, canReadClipboard, canNotify 2023-05-26 20:17:09 -05:00
GarboMuffin 7e29bbef17 Add default extension URL for compatibility with Scratch Lab animated text projects 2023-05-22 20:09:08 -05:00
GarboMuffin eed07ed3a4 Fix incorrect JSDoc 2023-05-22 20:00:22 -05:00
GarboMuffin 584e3452a3 Add BEFORE_EXECUTE and AFTER_EXECUTE events in _step
These are for extensions.
2023-05-22 20:00:22 -05:00
GarboMuffin d4bc61714e Fix serializing extensions used only by monitors 2023-05-18 00:58:25 -05:00
GarboMuffin 398892c6f2 Extension L10N - VM part (#133)
Sandboxed extensions will use navigator.language
Unsandboxed extensions will use the language set by setLocale
2023-05-18 00:00:59 -05:00
True FantømandGarboMuffin 8a7ae3f774 Add LABEL BlockType (#132)
Co-authored-by: GarboMuffin <muffin@mailbox.org>
2023-05-17 23:54:03 -05:00
GarboMuffin 6124ba8b1e Allow name of addon blocks category to be translated
A bit overdue
2023-03-26 02:13:05 -05:00
GarboMuffin 50b42f9415 Update tw.blocks.openDocs message
Our l10n scripts now parse this dynamically
2023-03-26 02:12:04 -05:00
GarboMuffin c73f821abf Add ArgumentType.COSTUME and ArgumentType.SOUND 2023-03-25 14:33:57 -05:00
GarboMuffin c6a81eb845 Fix refreshBlocks error log
Stringification is more likely to produce a helpful output than
JSON.stringify on error objects.

Old message:
Failed to refresh built-in extension primitives: {}
New message:
Failed to refresh built-in extension primitives: TypeError: Cannot destructure property 'provider' of ...
2023-03-25 14:31:46 -05:00
GarboMuffin 1ab111b7ca Fix using empty defaultValue for NUMBER arguments
Closes https://github.com/TurboWarp/extensions/issues/119
2023-03-25 13:54:44 -05:00
GarboMuffin 47adea8107 Add Scratch.fetch, Scratch.openWindow, and Scratch.redirect stubs in sandboxed extensions
Also includes the appropriate can[Fetch|OpenWindow|Redirect] methods.
Fetching is always allowed. The other methods are always rejected.
The Worker-based sandbox does not have a window.open method and the
iframe-based sandbox has a feature policy that should prevent them from
opening windows already.
2023-03-18 13:15:05 -05:00
GarboMuffin 92a91f156a Consistently escape attributes in extension and block XML
While this is not believed to cause security bugs as this is not
interpeted as HTML, the inconsistent/no escaping causes bugs such as:
https://github.com/TurboWarp/extensions/issues/241

To resolve this, we now fully escape (hopefully) every value from
extensions that makes its way into XML, so now the characters:
    " ' < > &
can be used anywhere in extensions without issues, even opcodes,
argument names, field names, etc. Just not the extension ID.

Some parts of Scratch such as ExtensionManager._sanitizeID and
Runtime._convertPlaceholders tried to explicitly remove XML characters,
however the code was broken (they only removed the first occurrence) and
this seems like the wrong fix anyways. We can use XML characters, they just
need to be escaped.

Also includes a very comprehensive test.
2023-03-08 20:02:08 -06:00
GarboMuffin 750cd7adb1 Fix sb3 compression breaking execution order at random
The bug was that property keys that look like array indexes are always
enumerated by JS before other keys regardless of creation time. For now,
we will avoid using numbers when compressing projects.

This does negligibly increase the size of project.json.
Appel v1.4 went from 2257234 to 2260628 bytes, a 0.15% increase.
2023-02-17 17:42:09 -06:00
GarboMuffin acd1144b25 Never follow redirects in Scratch.fetch
This is unfortunate. Ideally we would add some manual logic to follow
redirects ourselves, but it turns out fetch's redirect: 'manual' is
actually useless.
2023-02-12 14:22:23 -06:00
GarboMuffin 2a002f62eb Add Scratch.fetch, Scratch.openWindow, Scratch.redirect 2023-02-12 02:45:25 -06:00
GarboMuffin 07597d8a93 Fix default security manager 2023-02-11 20:52:27 -06:00
GarboMuffin e5bc69c0ab Merge pull request #117 from TurboWarp/extension-permissions
Add Scratch.canFetch, Scratch.canOpenWindow, Scratch.canRedirect extension APIs
2023-02-11 18:28:10 -06:00
GarboMuffin 5ccaee81d3 Scratch.canFetchResource -> Scratch.canFetch 2023-02-11 18:15:59 -06:00
GarboMuffin 795ceb1fb3 Add Scratch.canOpenWindow and Scratch.canRedirect 2023-02-11 18:12:11 -06:00
GarboMuffin 58d7bc269c Add Scratch.canFetchResource API 2023-02-11 17:25:09 -06:00
GarboMuffin 23cab6b8cc Fix ESLint warning in worker-dispatch.js 2023-02-11 16:11:59 -06:00
GarboMuffin 6044a05139 Silence ESLint warning in runtime.js 2023-02-11 16:11:59 -06:00
GarboMuffin aa3edc7be5 Fix ESLint warning in cli/index.js 2023-02-11 16:11:59 -06:00
GarboMuffin 162bc0280a Remove unused import from scratch3_pen/index.js 2023-02-11 16:11:59 -06:00
GarboMuffin fd6f4e6597 Remove unused import from scratch3_looks.js 2023-02-11 16:11:56 -06:00
GarboMuffin 8995c6a8f2 Fix ESLint warning in tw-compress-sb3.js 2023-02-11 16:07:48 -06:00
GarboMuffin 20c60193c1 Fix CJK characters in <iframe> extension sandbox
Closes https://github.com/TurboWarp/scratch-vm/issues/112
2023-01-17 14:19:16 -06:00
GarboMuffin 4fd7b3728a Fix handling of tab characters in comparison functions to match scratch-www
Closes https://github.com/TurboWarp/scratch-vm/issues/115
2023-01-14 22:36:57 -06:00
GarboMuffin 4aa167e523 Replace isWhiteSpace with something faster
isWhiteSpace works by trimming the entire string. This works, but in the
context we use it, this is a lot of unnecessary work.
At this point we know that `+x === 0` and we want to know if that's
because x is empty or because it actually contains 0, hence we can use
a loop that just checks for a 0 existing in the string. This relies on
the assumption that there is no x such that:
+x === 0 && x.trim().length !== 0 && !x.includes('0')

In a very biased microbenchmark (https://scratch.mit.edu/projects/788352711)
this results in a 10% performance improvement.

This also will allow us to resolve https://github.com/TurboWarp/scratch-vm/issues/115
in a later commit.
2023-01-14 22:06:26 -06:00
GarboMuffin cb2eba9eb3 Document and test that saveProjectSb3DontZip does not copy asset buffers 2023-01-12 03:56:06 -06:00
GarboMuffin 20f53fa4d7 Fix TurboWarp Blocks tertiary color 2023-01-10 00:25:23 -06:00
GarboMuffin 6049dd58fc Merge pull request #97 from TurboWarp/dont-load-existing-extensions
Don't duplicate loaded extensions in loadExtensionURL
2023-01-09 22:24:39 -06:00
GarboMuffin b020a60739 Add saveProjectSb3Stream 2023-01-05 16:34:45 -06:00
GarboMuffin b1313e1ce2 Add type option to saveProjectSb3 2023-01-05 16:33:03 -06:00
GarboMuffin 3c5ba8bb55 Fix typo in comment 2023-01-05 16:31:41 -06:00
GarboMuffin e941bb0f04 Export Cast to custom extensions (#110) 2022-12-19 21:09:54 -06:00
GarboMuffin 4d4bea83e8 Use URI encoding instead of base64 for addon blocks icon
Fixes test errors as Node.js does not have btoa()
2022-12-11 17:05:20 -06:00
GarboMuffin 095d9415e5 Merge pull request #106 from TurboWarp/addons-29-related
Add icon for TurboWarp Blocks and addon blocks
2022-12-11 16:58:06 -06:00
GarboMuffin c7f563e998 Add proper icon for TurboWarp Blocks 2022-12-11 16:57:51 -06:00
GarboMuffin ad532eb651 Simplify isExtensionURLLoaded 2022-12-10 17:35:32 -06:00
GarboMuffin f917741104 js: Mark sin, cos, tan, and random as NaN-able 2022-12-07 19:39:50 -06:00
GarboMuffin 905f9b5434 Add proper icon for addon blocks 2022-12-04 12:18:55 -06:00