Resolves#1601. Does not include the project JSON since that would require knowledge of a project ID, which the VM has not been responsible for so far.
For now, it is the responsibility of the consumer to determine if these assets should be saved or not. Otherwise the VM would need to be responsible for saving, which has been out of its scope.
Threads are now removed after every "inner" step. Any thread that
reaches its DONE conditions is immediately removed instead of requiring
an extra step to remove it. As such tests that check the number of
threads have been updated to consider this.
Use getProcedureParamNamesIdsAndDefaults to get the defaults along with
names and ids so defaults may be set for a procedure call if the
parameter is not provided.
The `switch costume` block accepts special values like "next costume" and
"previous costume". If you create a costume with these names, these take
priority over the special values. However, the `switch backdrop` block
keeps these special values for values like "next backdrop", "previous
backdrop", "random backdrop". It is impossible to navigate to such a
backdrop by name via block. This commit also modifies tests to allow for
this.
BREAKING CHANGE: specially-named backdrops can now be navigated
* Beginning refactor: renaming 'device' to 'peripheral', shortening function names, reordering functions, etc.
* Continuing refactoring: renaming some functions to be more verbose in the runtime, adding JSDocs, etc.
* Changing 'device' to 'peripheral', etc.
* Changing 'session' to 'socket'.
* Fixing EV3 menus and menu arg validation, reordering functions, etc.
* Add _send, add some references to documentation, etc.
* Factored out _outputCommand and _inputCommand, renamed some enums, etc.
* Fixed _outputCommand, some other minor cleanup.
* Make _outputCommand and _inputCommand public.
* Added TODO.
* Renamed BLE UUID enums to be clearer.
* Change WeDo2 in comments to WeDo 2.0, etc.
* Changed some WeDo2Motor command names, cleaned up some JSDocs.
* Beginning a major EV3 refactor.
* WeDo2 formatting and comment changes.
* Motor refactoring in EV3: motorTurnClockwise and motorTurnCounterClockwise initial working state.
* Add reminders to possibly cast motor menu args in WeDo2.
* Continue to move motor commands in EV3 to EV3Motor class, don't create new EV3Motor on every poll cycle, etc.
* Factoring EV3 polling value commands, etc.
* Fixing EV3 motor power, position and button pressed, and some commenting, etc.
* Move EV3 motor position parsing to EV3Motor class, move directCommand and directCompoundCommand functions, some commenting, etc.
* Changed WeDo2 motor label enum name.
* Removed some EV3 motor functions that aren't needed, changed menu label enum names, moved some opcodes up to enums.
* Fixing comments and documentation.
* Some commenting.
* Adding further documentation and references to PDFs, changed reply check to be safer, etc.
* Some comment changes.
* Moving some functions around in EV3 and WeDo2 to match.
* Commenting, etc.
* Some renaming of session, etc.
* Fix stopAllMotors in EV3.
* Fixing clearing of motors in EV3.
* Some comment changes.
* Change runtime .extensions/registerExtension to .peripheralExtensions/registerPeripheralExtension.
* Renaming outputCommand/inputCommand to generateOutputCommand/generateInputCommand, etc.
* Moved motorCommandIDs to EV3Motor class, renamed directCommand to generateCommand, etc.
* Adding a reminder to rename something.
* JSDoc fix in EV3Motor class.
* Fixing microbit function name.
* Adding a todo item.
* Changing Ev3 menu formats to be backwards compatible, moving a BLE function up.
* Fixing EV3 ports again, and button pressed returning a boolean.
* Fixing menu value to be a string in EV3.
* Initial version of token bucket
* Add rateLimiter util
* Remove check for motor.isOn in stopAllMotors
* Fix unit test
* Fix unit test with stubbed timer, and cleanup
* Add comment
* Reduce WeDo rate limit to 20 sends/sec
* Move rate limit into a constant
* Stop button stops motors and tone even if rate limit exceeded
* First microbit gui tests
* Fixed JSONRPC inheritance. Renamed ScratchBLE/ScratchBT files. Removed ScratchBT test code from Microbit extension. Renamed addLine to log.
* Fixed log comments. Removed addLine from Microbit.
* Adding auto-connect to Microbit at extension loading. Adding hack for displayText block to Scratch-Link.
* Resolved merge conflicts and brought in latest microbit extension example code.
* Updated microbit write tests for displayText and displaySymbol blocks. Some linting.
* Some linting and adding of BLE Characteristic consts.
* Linting fixes.
* Moving micro:bit device connection code all to the MicroBit class, decoupling Scratch3MicroBitBlocks from connection code.
* Removing old disconenct handlers from MicroBit class. Moved service into new BLEUUID data structure.
* Renamed _write to _send. Moved all BLE encoding concerns to the _send method.
* Using the util log. Some linting.
* Added _read method to MicroBit class. Renamed _send to _write.
* Some linting and formatting comments.
* First pass at peripheral chooser pattern for ScratchBLE.
* Testing characteristicDidChange events, and some changes to ScratchBLE on ready events.
* Refactoring work on PeripheralChooser and ScratchBLE.
* Some variable renaming and method signature stubs.
* Peripheral chooser method signatures.
* Moved base64 encoding/decoding to util. Some method signature formatting.
* Adding test stubs for new util and io classes.
* Adding test stub for MicroBit extension.
* Clean up for PR.
* Clean up for PR.
* Final cleanup for PR.
* Removed logging to console.
* Adding 'btoa' and 'atob' node modules and using them in Base64Util.
Turn the reporter tree execute walks into a sequence of block
functions. After calling a block function store the reported value in
the arguments object its depending block will use.
- Set the reported value on the thread. There is only ever one "just"
reported value, which is read and stored elsewhere after being
reported.
This involves adding a new opcode, event_whenstageclicked, and adding a
method to the blocks container to update the opcode pair depending on
whether the target is the stage. This method is then called in two
places: first after the sb2 import parses the blocks (not done in the
sb2 parsing itself because no other blocks are target specific) and then
again when blocks are shared between targets.
Also added tests for the block container method, and a fixture project
that tests the opcode splitting on sb2 import.
Towards fixing #865. This adds an IO class for detecting the mouse wheel
being scrolled. Basic tests are included; they mock the runtime to see
what blocks are activated by scrolling.
Store the thread's blocks at blockContainer letting execute quickly
determine the block source. Monitor threads are a monitor thread. They
do not become a target thread suddenly.
- Add stackFrame.justReported
Report the block result to a known key `justReported` instead of a
dynamic key on `reported`. Assuming blocks with a promised value are
relatively infrequent the most common recursive input flow immediately
reads the value "just" reported. In the assumed uncommon case of a
promised thread status, empty the already argValues assigned values
onto the currentStackFrame's reported member. In the next execute call
on this stackFrame, values assigned to reported are read back off onto
argValues, and execute will returned to the assumed common case. This
is a safe assumption since a thread in the promise state will not exit
that state until the next frame when javascript has a chance to call
the resolve handle, setting the thread's state back to another
executable state.
Using direct assignment to `justReported` saves building an object
dynamically. Instead of always building `reported` and `argValues` only
`argValues` is built until a promised state is reached. This also gives
a known time when `reported` is used, allowing cleanup of a
stackFrame's reported to only happen when it was used to persist
already reported values.
* Move drums into their own folder
* Load instrument samples
* Play notes
* Concurrency limit is shared across drums and instruments
* Increase MIDI note range
* Set instrument directly on musicState object
* JSDoc
* Clean up the play note functions and add comments
* Cleanup
* Check for audioEngine in playDrumNum
* JSDoc and comments
* Round the instrument number
* Fix unit test for set instrument
* Comment fixes
* Nit (condense onto single line)