Commit Graph
938 Commits
Author SHA1 Message Date
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
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
GarboMuffin ec1f7dea0c Add vm.exports.i_will_not_ask_for_help_when_these_break() (#181) 2024-01-28 16:30:48 -06:00
Muffin bb246c218f Fix typo in comment 2024-01-11 12:44:52 -06:00
Muffin b7e9016c56 Apply new TurboWarp/scratch-blocks extensions 2024-01-11 02:41:28 -06:00
Muffin e4e461ac84 Reset runtime's extension storage when loading a new project 2024-01-03 03:35:39 -06:00
GarboMuffin 8297dd4cc9 Add native loading progress tracking (#180) 2024-01-03 00:56:54 -06:00
GarboMuffin dd848dbbf6 Extension storage (#179) 2024-01-02 23:19:51 -06:00
LilyMakesThingsandMuffin 7f9c8f759c Add per-block extensions and colors (#177)
Co-authored-by: Muffin <muffin@mailbox.org>
2023-12-31 02:24:31 -06:00
CubesterandMuffin b27142a012 Allow removing loop icon using branchIconURI (#176)
Co-authored-by: Muffin <muffin@mailbox.org>
2023-12-31 01:32:22 -06:00
Muffin c309c42894 Use media:// for default loop icon (requires scratch-blocks change)
They have always been subtly broken, but the high contrast changes finally the old path for good.
https://github.com/TurboWarp/scratch-blocks/commit/7413542d3731b58381e05fddf6913fbc494f9cd9
2023-12-31 00:24:20 -06:00
Muffin 9f26069ad6 merge-upstream: Fix ESLint errors 2023-12-22 17:56:40 -06:00
Muffin 81a0382e0f merge-upstream: initial merge of upstream/develop
installs & compiles but has test errors

aside from expected merge conflicts, notable changes from upstream:
 - removed husky, commitlint, etc.
 - removed semantic-release etc.
2023-12-22 17:25:21 -06:00
CubesterandMuffin bd0cf91d85 Add branchIconURI (#174)
Co-authored-by: Muffin <muffin@mailbox.org>
2023-12-22 16:47:48 -06:00
Muffin d386082d5b Allow BOOLEAN blocks to be monitors
This will cause issues if the booleans have side-effects.

Closes https://github.com/TurboWarp/extensions/issues/201
2023-08-28 14:13:49 -05:00
Muffin 1decd331ad Alow LOOP and CONDITION blocks to use startBranch in interpreter and remove rounding 2023-08-23 14:50:42 -05:00
Muffin e9f0a3686c Implement LOOP blocks in interpreter 2023-08-22 16:34:47 -05:00
Muffin 87119eadb7 Implement CONDITIONAL blocks in interpreter 2023-08-22 16:34:47 -05:00
Muffin b9e84b7db2 Implement custom font manager 2023-08-16 10:34:06 -05:00
Muffin 49d1785496 Improve interpreter's hat block implementation
Improve handling of promises and stackClick with predicate-based hats
2023-08-13 16:53:25 -05:00
Muffin ff41d1dcf8 Fix compiler's hat implementation
Now supports edge-activated and predicate-based hats
2023-08-13 16:53:25 -05:00
GarboMuffin 461ef267da Merge pull request #144 from TurboWarp/xml-blocktype
BlockType.XML
2023-08-06 22:08:30 -05:00
GarboMuffin 7115abb56d BlockType.XML 2023-08-06 21:46:59 -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
Muffin d3d3cfe6e3 Allow controlling addon block return shape 2023-07-26 20:39:23 -05:00
Muffin 0d857e4019 Make arguments optional in addAddonBlock 2023-07-26 20:12:13 -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 40e053daf4 Export internal block being executed on StackFrame 2023-07-14 18:43:07 -05:00
GarboMuffin 6b8f443680 Implement procedure returns in interpreter 2023-07-10 21:46:15 -05:00
GarboMuffin 33439939d2 Add API for extension block to be dropped anywhere 2023-07-07 19:32:56 -05:00
GarboMuffin c4561c2f1c Support custom buttons in extensions (#137) 2023-05-26 20:52:52 -05:00
GarboMuffin 584e3452a3 Add BEFORE_EXECUTE and AFTER_EXECUTE events in _step
These are for extensions.
2023-05-22 20:00:22 -05:00
True FantømandGarboMuffin 8a7ae3f774 Add LABEL BlockType (#132)
Co-authored-by: GarboMuffin <muffin@mailbox.org>
2023-05-17 23:54:03 -05:00
GarboMuffin 6124ba8b1e Allow name of addon blocks category to be translated
A bit overdue
2023-03-26 02:13:05 -05:00
GarboMuffin 50b42f9415 Update tw.blocks.openDocs message
Our l10n scripts now parse this dynamically
2023-03-26 02:12:04 -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 92a91f156a Consistently escape attributes in extension and block XML
While this is not believed to cause security bugs as this is not
interpeted as HTML, the inconsistent/no escaping causes bugs such as:
https://github.com/TurboWarp/extensions/issues/241

To resolve this, we now fully escape (hopefully) every value from
extensions that makes its way into XML, so now the characters:
    " ' < > &
can be used anywhere in extensions without issues, even opcodes,
argument names, field names, etc. Just not the extension ID.

Some parts of Scratch such as ExtensionManager._sanitizeID and
Runtime._convertPlaceholders tried to explicitly remove XML characters,
however the code was broken (they only removed the first occurrence) and
this seems like the wrong fix anyways. We can use XML characters, they just
need to be escaped.

Also includes a very comprehensive test.
2023-03-08 20:02:08 -06:00
GarboMuffin 6044a05139 Silence ESLint warning in runtime.js 2023-02-11 16:11:59 -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 905f9b5434 Add proper icon for addon blocks 2022-12-04 12:18:55 -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 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 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 ab6d10f929 Remove tw-experimental-audio-optimizations
This now lives in TurboWarp/scratch-audio
2022-09-17 18:53:19 -05:00
GarboMuffin eb600cfcf8 Replace local extended JSON parser with @turbowarp/json 2022-08-14 19:45:30 -05:00