Commit Graph
3514 Commits
Author SHA1 Message Date
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
GarboMuffin 6f5e70a240 Explicitly set TurboWarp blocks tertiary color 2022-12-03 18:01:33 -06:00
GarboMuffin bd0a38246d Don't duplicate loaded extensions in loadExtensionURL
If the URL is already loaded, resolve immediately.
Fixes https://github.com/TurboWarp/scratch-gui/issues/637
Caused by TWStateManager repeatedly calling loadExtensionURL on locale
change.
This could be fixed in GUI, but fixing it in VM is easier and loading
multiple instances of the same extension doesn't make sense anyways.
2022-12-03 14:25:17 -06:00
GarboMuffin 72fc858064 Remove loadExtensionURL return value
Never used anywhere and will make a follow-up commit more complicated
2022-12-03 14:09:44 -06:00
GarboMuffin 2e4e67b1f0 Implement primitive compiler output snapshot testing
If the compiler's type analysis becomes smarter, being able to show that
its output matches what is expected will become more important. Snapshot
testing is how we will solve that.
2022-12-03 02:16:36 -06:00
GarboMuffin ef871f794c Fix compiled color pickers returning number instead of hex code
Hacked blocks and custom extensions expect colour_picker to return
a hex color code (#123abc) instead of the parsed number (1194684).
2022-11-22 21:22:12 -06:00
GarboMuffin bc24d05d0b Parse saved extension in ScratchX (.sbx) projects
They are treated the same as the list we store in .sb3 projects
2022-11-21 22:54:13 -06:00
GarboMuffin c288c49837 No-op privacy enforcement if using a vanilla renderer
also fixes tests
2022-11-16 21:00:24 -06:00
GarboMuffin 2b265e55a0 Disable private skin access when cloud variables or custom extensions are used
This is a breaking change.
Replaces logic that was previously in our scratch-gui fork.
Upstream does the opposite; they disable cloud variables when video
sensing is used. We can't do the same because of custom extensions.
Disabling all custom extensions when video sensing is used would be too
limiting. The concern with custom extensions is not that they will steal
private skins, but that a project could use their blocks to fetch()
color information to a remote server similar to cloud variables.
The end result is not dissimilar: Cloud variables and video sensing
shouldn't be used together.
2022-11-16 20:52:31 -06:00
GarboMuffin 83d72053a7 Fix repeated util.yield() in interpreted addon blocks 2022-11-12 11:33:44 -06:00
GarboMuffin 30a47a2b39 Allow addon blocks to be hidden 2022-11-12 01:09:25 -06:00
GarboMuffin c7309b96ab Remove addon block color parameters
The parameters didn't work in the way that you would expect. Only the
values provided in the first call to addAddonBlock would do anything,
and this gives a false impression that this will color the blocks in the
editor. Color options may be re-added in the future as part of a more
significant API update.
2022-11-12 01:08:09 -06:00
GarboMuffin 0fd98a6ac5 Allow addon block callback to return a Promise 2022-11-12 01:08:09 -06:00
GarboMuffin 4eafaf573b Reimplement addon blocks with the compatibility layer
callAddonBlock is removed. executeInCompatibilityLayer is used instead.
Notably this makes all the block utility control flow work in the compiler.
2022-11-12 01:08:09 -06:00
GarboMuffin f2927bf1a5 Fix thread.status = STATUS_PROMISE_WAIT in compatibility layer
Promises worked fine, but if the block set status to STATUS_PROMISE_WAIT
without returning a promise (as some addon blocks do), the compatibility
layer would do the wrong thing. This doesn't matter right now, but it
will in a follow-up commit.
2022-11-12 01:07:22 -06:00
GarboMuffin 015e5ebd63 Extract isPromise out of executeInCompatibilityLayer and clarify some jsdoc 2022-11-12 00:24:00 -06:00
GarboMuffin a1904b022b Replace addAddonBlock callback 2nd argument with BlockUtility
Documentation says it should be BlockUtility but in reality it was
something that mimicked a Thread.
This is a breaking change.
2022-11-12 00:07:17 -06:00
GarboMuffin ceed27f30a Allow using ScratchX extensions in unsandboxed mode 2022-11-06 12:38:13 -06:00
GarboMuffin 40394f0c43 Revert "Move allAsyncExtensionsLoaded call from installTargets to _loadExtensions"
The async extensions loading counter is not the most reliable thing,
so let's not break block sharing if something went wrong.

This reverts commit 042f979d59.
2022-11-05 21:47:37 -05:00
GarboMuffin cd40f38f76 Make global.Scratch actually unique per extension
and add some tests for unsandboxed extensions
2022-11-05 20:28:53 -05:00
GarboMuffin badf74d28d Remove unnecessary duplicate ArgumentType set 2022-11-05 20:25:27 -05:00
GarboMuffin bffa0ac77c Allow loading custom extensions from file:
Regression from the unsandboxed extension changes. This matters in eg. the packager.
2022-11-05 19:12:05 -05:00
GarboMuffin 042f979d59 Move allAsyncExtensionsLoaded call from installTargets to _loadExtensions 2022-11-05 19:10:57 -05:00