Commit Graph
829 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 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 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 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 e941bb0f04 Export Cast to custom extensions (#110) 2022-12-19 21:09:54 -06:00
GarboMuffin f917741104 js: Mark sin, cos, tan, and random as NaN-able 2022-12-07 19:39:50 -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 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 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 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 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 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 688b257f7c Add tests for addAddonBlock 2022-11-11 23:33:43 -06:00
GarboMuffin 43128ccc0d Add more unsandboxed extension tests 2022-11-06 12:55:30 -06: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 10f07fc8c7 Fix test broken by incomplete extension manager mock 2022-11-05 19:25:10 -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 ae7526f156 Merge branch 'extensions-update' into develop
This adds a new mode of custom extension that runs outside of any
sandbox -- they're just <script> tags. This is disabled by default and
needs explicit opt-in. Documentation will be written later.

This also will save the URLs of the loaded custom extensions to
project.json when serializing a project. When deserializing a project,
this list can be read to automatically load the extensions. This, again,
is disabled by default and requires explicit opt-in.

A new mechanism called the SecurityManager was added to the extension
manager to facilitate these new features. This replaces workerMode and
is a breaking change.

Various other custom extension related changes were also added:
 - Reject invalid URLs in loadExtensionURL
 - Various cleanup and refactoring
2022-10-29 22:55:08 -05:00
GarboMuffin dcc0d961d7 Automatically load custom extensions saved in project
Requires disabled-by-default security manager configuration
2022-10-22 22:02:30 -05:00
GarboMuffin 1e35432db0 Update format for saving custom extensions
Use a dictionary instead. Lets the VM that loads it possibly do some clever things.
Also added a test case.
2022-10-22 21:38:06 -05:00
GarboMuffin bede390599 Refactor extension manager's builtin extension check 2022-10-22 21:30:08 -05:00
GarboMuffin b31ca10082 Don't serialize hidden monitors from extensions
Replace our specific tw_getLastKeyPressed hack with a general solution
https://github.com/LLK/scratch-vm/issues/2331
2022-10-22 18:51:16 -05:00
GarboMuffin 3d75f4759a Fix incorrect mouse position when clientX or clientY is 0
https://github.com/TurboWarp/packager/issues/494
2022-10-21 22:10:22 -05:00
GarboMuffin 46f6d89b8d Import another test from https://github.com/forkphorus/forkphorus/pull/515 2022-08-28 12:58:33 -05:00
GarboMuffin d8984c80a2 Ignore error in performance.measure() if browser garbage collects a mark 2022-08-27 22:20:42 -05:00
GarboMuffin 4943602646 Import some tests from https://github.com/forkphorus/forkphorus/pull/515 2022-08-27 17:53:30 -05:00
GarboMuffin 135fa04259 Fix tangent of perfect multiplies of 90
Previously they would return very large or very small numbers when they should instead be returning Infinity or -Infinity
2022-08-27 17:49:42 -05:00
GarboMuffin eb600cfcf8 Replace local extended JSON parser with @turbowarp/json 2022-08-14 19:45:30 -05:00
GarboMuffin dc9b3f6055 Fix error in uint8ArrayToBase64 when input is too large 2022-08-13 14:45:33 -05:00
GarboMuffin b2e042fde6 Add tests to util_base64.js 2022-08-13 14:40:21 -05:00
GarboMuffin 6db9599f2e Do not use md5 to generate asset IDs in packaged runtime mode
md5 unnecessary in this mode and slows project load by ~10%.
2022-08-05 00:18:09 -05:00
GarboMuffin 1bfc83e666 Use storage.createAsset instead of new storage.Asset in tests 2022-08-05 00:17:53 -05:00