Commit Graph
602 Commits
Author SHA1 Message Date
Muffin 6399562b90 Revert running unsandboxed extensions with fetch() and new AsyncFunction instead of <script>
It causes other issues:
 - It *will* break projects
 - Stack traces from errors in extensions are unusable
 - We do not even get some of the originally intended benefits like parallel loading
2023-08-22 11:24:20 -05:00
GarboMuffin 9caca1c510 Merge pull request #157 from TurboWarp/modernize-loading
Use fetch() and AsyncFunction instead of `<script>` for unsandboxed extensions
2023-08-22 10:48:54 -05:00
Muffin 683620994f Fix tests 2023-08-22 10:43:04 -05:00
Muffin 55cda8242c Run unsandboxed extensions with fetch() and new AsyncFunction instead of <script>
Benefits:
 - IIFE no longer needed
 - Extensions can await
 - Better error messages
Downsides:
 - CORS now required to load extensions
2023-08-22 10:00:36 -05:00
Muffin b23fb1e8be Refactor ScratchX compatibility layer 2023-08-16 16:39:09 -05:00
Muffin b9e84b7db2 Implement custom font manager 2023-08-16 10:34:06 -05:00
GarboMuffin fbc62badf6 Merge pull request #150 from TurboWarp/return
Allow custom blocks to return values - VM part
2023-07-29 09:56:57 -05:00
GarboMuffin 9329427fb5 Export the internal copy of JSZip for extensions 2023-07-16 21:02:38 -05:00
GarboMuffin 5ff2a56bdc Add Scratch.canGeolocate() extension API 2023-07-16 09:38:46 -05:00
GarboMuffin f033067b6f Non-warp recursion should yield in interpreter
Matches normal procedure blocks. Already worked in compiler.
2023-07-14 19:28:13 -05:00
GarboMuffin a515991c37 Return original message if translation request fails
For games that put their entire interface through translate blocks, this
allows them to be more usable when no internet connection is present.

Has convenient side effect of breaking some online detectors.
2023-07-07 19:49:11 -05:00
GarboMuffin 19c9e8f591 Fix Scratch.translate in unsandboxed custom extensions 2023-05-29 01:16:04 -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 227dec235a Add canRecordAudio, canRecordVideo, canReadClipboard, canNotify 2023-05-26 20:17:09 -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
GarboMuffin c73f821abf Add ArgumentType.COSTUME and ArgumentType.SOUND 2023-03-25 14:33:57 -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 cd8f28fbba Restore test that checks compressed IDs do not conflict with uncompressed 2023-02-17 18:19:02 -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 53af7244ca Update compressed ID uniqueness test 2023-02-17 17:42:02 -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 354e9411a5 Fix ESLint warning in engine_runtime.js
We used to add some more tests to this file, then we moved them
to a separate file, which is probably when this newline was introduced
2023-02-11 16:00:16 -06:00
GarboMuffin 747ff72e7e Fix ESLint warnings in tw_compress.js 2023-02-11 15:59:19 -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 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 e941bb0f04 Export Cast to custom extensions (#110) 2022-12-19 21:09:54 -06:00
GarboMuffin 61af8a9fa2 Update tests 2022-12-07 10:41:07 -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 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 dcc0d961d7 Automatically load custom extensions saved in project
Requires disabled-by-default security manager configuration
2022-10-22 22:02:30 -05:00
GarboMuffin bede390599 Refactor extension manager's builtin extension check 2022-10-22 21:30:08 -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 d8984c80a2 Ignore error in performance.measure() if browser garbage collects a mark 2022-08-27 22:20: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