Commit Graph
980 Commits
Author SHA1 Message Date
Thomas Weber 44e2589e65 Fix https://github.com/TurboWarp/scratch-vm/issues/277
Need to clear the state before analyzing the condition as the condition
may be re-evaluated after yielding.
2025-09-22 18:40:34 -05:00
Tacodiva 749e923378 Fix #272 (thanks @Geotale) 2025-09-21 23:10:50 +10:00
Tacodiva c16be25178 Fix #273 2025-09-21 22:59:56 +10:00
Tacodiva cc96ee8c70 Fix -0 being turned into 0 in the type matrix test 2025-09-21 22:59:06 +10:00
Thomas Weber cd353ca31e Merge pull request #268 from TurboWarp/fix-analyzeLoopedBlock-infinite-loop
Give up analyzing looped stack after 10000 iterations
2025-09-20 13:57:52 -05:00
Thomas Weber fa035541da Give up analyzing looped stack after 10000 iterations
Temporary fix for an infinite loop, to be properly fixed later
2025-09-20 13:53:41 -05:00
Thomas Weber 5b027b995e Fix motion_turnleft and motion_turnright missing type casts 2025-09-15 18:01:45 -05:00
Tacodiva 7cc8f580b3 Fix yielding loop arguments not re-analyzing 2025-09-08 17:08:23 +10:00
Tacodiva d8c73c71d2 Account for stop this script in type analysis and add test 2025-09-08 15:28:11 +10:00
Tacodiva fbca1bf49b Fixed NaN = 0 wrongly reporting true, and add a test 2025-09-08 11:48:55 +10:00
Tacodiva b8defadedb Merge remote-tracking branch 'origin/develop' into HEAD 2025-09-07 11:56:25 +10:00
ghost 5bc497aabb Add blockShape option to extensions (#210) 2025-05-20 21:48:52 -05:00
Thomas Weber f957e1c6c1 Fix Mouse.postData error if called before project loads 2025-05-20 13:29:44 -05:00
Thomas Weber ba9ae068ca Don't compress formats that are already compressed (#258)
Closes https://github.com/TurboWarp/scratch-vm/issues/253
2025-05-13 21:45:21 -05:00
Thomas Weber b8520ccd9a Fix visual report error when thread target does not match editing target
Fixes #252
2025-03-27 13:34:21 -05:00
Thomas Weber 7ef5e29c16 interpreter: fix skipped blocks in recursive procedures using "stop this script"
Closes https://github.com/TurboWarp/scratch-vm/issues/249
Regression from 20f25f252c
2025-03-07 01:21:08 -06:00
Thomas Weber 2d29cdc63a Quit VM when execute test times out
A future test project will be designed such that failing to
quit the VM after timing out would severely inhibit the
performance of the other tests.
2025-03-07 01:11:17 -06:00
Muffin cd63c87f07 js: reset variable types after compatibility layer call
Fixes https://github.com/TurboWarp/scratch-vm/issues/245
2025-02-11 00:49:36 -06:00
Thomas Weber af3b7513a4 ir: Match vanilla quirks when handling variable or list fields with null ID 2025-01-18 00:29:09 -06:00
Thomas Weber 2c9d301da2 ir: Fix variable cache collision when variable or list field has null ID
Fixes https://github.com/TurboWarp/scratch-vm/issues/239
2025-01-18 00:09:09 -06:00
Thomas Weber c3b60f6fb6 Add Scratch.download API 2024-12-22 17:46:17 -06:00
Thomas Weber fdd954c012 Add URL argument to Scratch.canDownload
This lets us filter out javascript: URLs
2024-12-22 17:46:09 -06:00
Thomas Weber 1a578aa44e Add canDownload API
https://github.com/TurboWarp/scratch-gui/issues/969
2024-12-22 11:51:26 -06:00
Muffin 9e6993de27 Add restricted fonts and case insensitivity to font manager (#231) 2024-11-02 21:39:44 -05:00
Tacodiva df65b01cde Merge branch 'origin/develop' into next-next 2024-09-26 11:50:09 +10:00
Muffin 179030ad49 Don't eagerly cast boolean arguments to boolean (#223)
Fixes https://github.com/TurboWarp/scratch-vm/issues/222
2024-09-08 11:56:47 -05:00
Muffin 99ff662f7f Don't emit STAGE_SIZE_CHANGED if stage size didn't change
and also fix the other STAGE_SIZE_CHANGED event test to
actually test that it is being fired when there is a change
2024-07-31 15:16:44 -05:00
Tacodiva 59cc74c10b Fix imports :c 2024-07-28 20:31:07 +10:00
Muffin 658ef8aba7 Add test for sb3 creation being deterministic over time 2024-07-18 12:44:49 -05:00
Tacodiva 1dc9aadf3f Fix issue when setting variables to InputType.ANY and add test 2024-06-25 18:25:47 +10:00
Tacodiva 02806b654a Linty linty code 2024-06-17 10:37:37 +10:00
Tacodiva 41e8167573 Fix snapshot tests falling back to "script" instead of the procedure variant 2024-06-17 10:06:33 +10:00
Tacodiva 71b75aad51 Add type assertion checking 2024-06-16 13:50:39 +10:00
Tacodiva 9d28fccb99 Add operator type testing 2024-06-16 13:50:30 +10:00
Tacodiva fffb72b09d Upgraded Type Analysis 2024-06-16 13:10:14 +10:00
Muffin 30a614dfc4 Expose compatibility layer stack frame on thread
For https://github.com/TurboWarp/scratch-vm/issues/212
2024-06-14 14:32:35 -05:00
Muffin 16415ba5cd Use procedure variant in snapshots instead of just procedure code 2024-05-23 14:22:43 -05:00
Muffin 6ce931b60a Add test for behavior of self-restarting scripts
The behavior is non-trivial as it will keep running the old thread
unti it yields.

I briefly tested putting `thread.status = 4` at the start of _restartThread
and all the old execution tests still passed, so let's just add a bit more
coverage. This was nearly regressed by f548d1b33c.
2024-05-23 14:16:57 -05:00
Muffin d39a30fb23 Replace wrapAssetRequest promise argument with a callback
The flexibility may be useful later
2024-05-22 20:36:25 -05:00
Muffin d69256aa2d Replace jszip with @turbowarp/jszip 2024-05-19 21:58:36 -05:00
Muffin f548d1b33c Fix stopping a thread from inside of its blocks
Works in command or reporter after yielding or not.
These snippets are covered by the tests:
thread.status = Thread.STATUS_DONE;
thread.status = 4; (indirectly)
sequencer.retireThread(thread);
2024-05-15 14:46:23 -05:00
KyleKartandMuffin ce04eafec0 Add boolean argument support to ScratchX compatibility layer (#208)
Co-authored-by: Muffin <muffin@muffin.ink>
2024-05-09 00:46:18 -05:00
Muffin 0593628e24 Fix rejected promise behavior in interpreter and compiler
Before this command:
- Interpreter would popStack() and continue. Inside a loop this was like JS continue, outside it was like return
- Compiler would return literal undefined and keep going.

After this commit:
Both return the error as a string and then continue as normal.
This has several benefits:
- Users can actually see the error messages
- Logical execution flow
- Consistent behavior
- Blocks aren't even supposed to return rejected promises anyways
- No vanilla blocks return rejected promises so no compatibility concerns

Supersedes https://github.com/TurboWarp/scratch-vm/pull/207
2024-05-09 00:18:18 -05:00
JeremyGamer13andMuffin 31c9eba1aa Add platform info (#205)
- Platform info is now stored in project.json.
- Available to extensions on vm.runtime.platform.
- When loading a project with a different platform, emit an event and wait for callbacks before continuing.

Co-authored-by: Muffin <muffin@muffin.ink>
2024-05-08 23:01:26 -05:00
Muffin 11eec6604d Allow scratch-gui (and others) to extend unsandboxed extension APIs 2024-04-06 16:01:31 -05:00
GarboMuffin 20f25f252c interpreter: Do not re-evaluate procedure arguments after stop this script or return (#202)
"stop this script" and "return" would previously cause all the procedure
arguments to be re-evaluated and then discarded. In vanilla Scratch the
worst case is a performance penalty, but with our custom reporters it
can cause infinite loops.

Fixes https://github.com/TurboWarp/scratch-vm/issues/201
2024-03-30 17:53:13 -05:00
Muffin 9657efb1d4 Shorten Base64Util test cases
1000000 items is very slow; the tests take about 4 seconds on my machine.
2024-02-10 01:42:16 -06:00
tpsntandMuffin 845c374f72 Fix WeDo2.send sends empty message (#192)
* Fix WeDo2.send sends empty message

WeDo2.send invokes Base64Util.uint8ArrayToBase64(message). However message.arrayLength === undefined. This causes Base64Util.uint8ArrayToBase64 always returning empty string ''.

* Move the fix to base64-util instead

---------

Co-authored-by: Muffin <muffin@mailbox.org>
2024-02-10 01:40:36 -06:00
Muffin 96225163c1 Fix tests in Node 21 and later 2024-02-02 21:25:58 -06:00
Muffin a15c069ac6 Improve promise-like extension block test
notably, fail on compiler errors, and run the test block several times
2024-01-26 20:39:05 -06:00