Commit Graph
5546 Commits
Author SHA1 Message Date
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 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 cda4e21f41 Merge pull request #116 from TurboWarp/better-cast-whitespace
Fix handling of whitespace to match scratch-www and make it faster
2023-01-17 14:01:58 -06:00
GarboMuffin 9453bb45f7 Add more test cases 2023-01-17 13:57:27 -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 577217f64f Merge pull request #113 from TurboWarp/more-sb3-saving-methods-and-tests
More sb3 saving methods and tests
2023-01-05 20:39:39 -06:00
GarboMuffin b020a60739 Add saveProjectSb3Stream 2023-01-05 16:34:45 -06:00
GarboMuffin 451d9c1d0c Add tests for saveProjectSb3DontZip 2023-01-05 16:33:19 -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 48b3a58513 CI update (#109)
* Run CI on all pushes and pull requests

* Update CI workflow
2022-12-19 17:12:19 -06:00
GarboMuffin 1619bbf795 Merge pull request #107 from TurboWarp/fix-btoa-error
Use URI encoding instead of base64 for addon blocks icon
2022-12-11 17:06:12 -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 f1b867e869 Merge pull request #105 from TurboWarp/fix-trig-random-nan
js: Mark sin, cos, tan, and random as NaN-able
2022-12-10 12:43:40 -06:00
GarboMuffin f917741104 js: Mark sin, cos, tan, and random as NaN-able 2022-12-07 19:39:50 -06:00
GarboMuffin 5392754875 Merge pull request #104 from TurboWarp/snapshot-testing-warp-timer
Add snapshot tests with warp timer enabled
2022-12-07 10:42:59 -06:00
GarboMuffin 61af8a9fa2 Update tests 2022-12-07 10:41:07 -06:00
GarboMuffin e8fc44e92a Add snapshot tests with warp timer enabled 2022-12-07 10:26:20 -06:00
GarboMuffin ae69c61d9a Fix typos 2022-12-06 20:55:58 -06:00
GarboMuffin 25283fe191 Merge pull request #99 from TurboWarp/move-snapshots
More snapshot testing things
2022-12-06 20:54:21 -06:00
GarboMuffin 971219fd0c Differentiate modified input and unexpected output errors in snapshot tests 2022-12-06 20:46:28 -06:00
GarboMuffin 8829c62dc9 Update snapshot testing documentation 2022-12-06 20:46:23 -06:00
GarboMuffin 1ca4ce5cc8 Move snapshot tests to test/snapshot 2022-12-06 20:24:01 -06:00
GarboMuffin 6cc0b68c8f Merge pull request #96 from TurboWarp/snapshot-testing
Implement compiler output snapshot testing
2022-12-06 20:17:26 -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 5b573723e9 Update @turbowarp/json to 0.1.2
Minor optimization
2022-11-12 20:40:19 -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