Commit graph

715 commits

Author SHA1 Message Date
Michael "Z" Goddard
2ffa8eb333
update runtime thread tests
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.
2018-10-31 17:56:12 -04:00
Karishma Chadha
1df6743a5f Refactor cloud data manager to break out cloud data limit check vs. limit update. 2018-10-31 13:40:05 -04:00
Karishma Chadha
848deaff30 Track whether a project has cloud data and enforce a cloud data limit on projects being loaded into the runtime. 2018-10-30 18:53:57 -04:00
Katie Broida
6ef600dc2c
Add runtime event for when the project is loaded (#1669) 2018-10-30 15:26:22 -04:00
Karishma Chadha
4959ab9ff3 Create a new cloud io device 2018-10-29 00:58:30 -04:00
Michael "Z" Goddard
fcafcbdd0a
return 0 from parameters outside of their procedure 2018-10-23 15:14:31 -04:00
Michael "Z" Goddard
ef4045aaf1
Merge pull request #1642 from mzgoddard/set-procedure-param-defaults
Set procedure param defaults
2018-10-23 15:13:16 -04:00
Michael "Z" Goddard
b833ef8d24
remove finished threads every loop of all threads
When all threads are looped, finished threads must be removed so
threads that are waiting for those to complete and be removed may
continue executing. This effects broadcast and wait for example. The
threads created by broadcast and wait can finish in the same tick and
must be removed from the list of threads so that broadcast and wait
knows to stop waiting.
2018-10-19 16:43:36 -04:00
DD
91e2f3a935 Revert 1643 Confirm extension in use in sb2 serialization 2018-10-18 11:06:13 -04:00
Evelyn Eastmond
2564b24d71 Differentiate peripheral errors: request vs. disconnect (#1654)
* Beginning to add differentiation for hardware disconnect alerts.

* Set connected status after error is sent.
2018-10-17 15:48:07 -04:00
Katie Broida
899ce56214
Confirm extension in use in sb2 serialization (#1643)
Add a check when serializing sb2 projects to see whether an extension is actually in use in a block or a visible monitor.
2018-10-17 10:49:08 -04:00
Michael "Z" Goddard
2b257dde57
add getProcedureParamNamesIdsAndDefaults
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.
2018-10-16 16:31:45 -04:00
Andrew Sliwinski
23f6346045
Merge pull request #1631 from mzgoddard/stop-other-asks
Stop other asks
2018-10-15 13:16:49 -04:00
Michael "Z" Goddard
56ec22df77
add Runtime.executableTargets
executableTargets is a list of the targets in the reverse order of
their execution. This order matches the draw list's order in the
renderer.
2018-10-04 00:42:05 -04:00
Michael "Z" Goddard
574749bbba
add STOP_FOR_TARGET runtime event and respond for ask blocks
Remove questions for targets that are individually stopping and
progress the asked question if it is from a stopping target.
2018-10-03 10:38:14 -04:00
Eric Rosenbaum
f5edcfa3bb Update event name to MIC_LISTENING 2018-09-20 12:06:31 -04:00
Eric Rosenbaum
e44eff48e3 Add mic indicator update event for speech2text 2018-09-18 10:58:49 -04:00
Chris Willis-Ford
8977ce1e93
Merge pull request #1565 from cwillisf/extension-monitors
Extension monitors
2018-09-12 18:10:12 -04:00
Christopher Willis-Ford
346e1383ed Split extended opcode with splitFirst instead of split 2018-09-12 17:02:18 -04:00
Evelyn Eastmond
ec432e3b2f Refactor for hardware extensions (#1555)
* 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.
2018-09-07 17:01:23 -04:00
Christopher Willis-Ford
8602d5798a Allow extension reporter only if no block args 2018-09-07 12:16:48 -07:00
Christopher Willis-Ford
f5182a231e Add getLabelForOpcode for use by monitors 2018-09-07 12:01:13 -07:00
Christopher Willis-Ford
701fb6c1c5 Enable extension monitors, add flag to disable
Extension reporters now offer a monitor checkbox by default, unless the
`disableMonitor` flag is set in the extension block metadata.
2018-09-07 11:13:13 -07:00
Karishma Chadha
62bf790d8f Fix stack glows so that stacks glow as soon as the first block in the stack starts running as opposed to after the first block has finished. Make sure that monitored reporters in the flyout are not glowing. 2018-08-22 14:44:06 -04:00
Ray Schamp
4b5cf6505a
Merge pull request #1398 from paulkaplan/publish-docs
Publish jsdoc to gh-pages
2018-08-08 16:46:48 -04:00
Karishma Chadha
d91788406c Don't generate new IDs for variables when making a sprite clone. 2018-08-07 16:24:02 -04:00
Karishma Chadha
337c1f464d Fix duplication of variables and re-write variable ids in referencing fields. 2018-08-07 00:30:03 -04:00
Paul Kaplan
79ab2fcb72 Add turbo mode events 2018-08-02 10:00:21 -04:00
Paul Kaplan
138d7136af Fix various jsdoc issues preventing the docs from building 2018-07-31 11:22:42 -04:00
Paul Kaplan
6d4c6df692 Add UserData ioDevice for setting and getting username from blocks 2018-07-23 09:38:58 -04:00
Paul Kaplan
7aa45ddb38 Update the category info name when the extension is refreshed.
Fixes an issue where changing languages did not update the name in the category menu.
2018-07-18 15:01:22 -04:00
Paul Kaplan
c428e2ec02
Merge pull request #1341 from mzgoddard/fix-report
fix unnecessary stackClick report from nested promise reporters
2018-07-18 09:58:47 -04:00
kchadha
5f5ea5ec24
Merge pull request #1361 from kchadha/sprite-upload-global-local-fix
Fix sprite upload variable conflict
2018-07-18 09:56:47 -04:00
Karishma Chadha
37b276935e Update fields of blocks to reference new variable names for renamed global so that the VM always has up-to-date and accurate information about the blocks. 2018-07-17 16:27:00 -04:00
Evelyn Eastmond
c4ee7065a2 EV3/Microbit critical fixes for code freeze (#1354)
* Resolves - BLESession and BTSession should emit PERIPHERAL_SCAN_TIMEOUT #1348.

* Resolves - BLESession should handle 'could not find service' error #1350.

* Resolves - BTSession should handle 'no peripheral connected' error #1351.

* Fixing a typo that caused device scan timeout bugs.

* Resolves - Add casting and clamping throughout the EV3 extension #1352.

* Fixing a linting error.

* Further fixes for issue #1351.
2018-07-17 16:03:05 -04:00
Karishma Chadha
99c1ce9286 Fix variable conflict that arises during sprite upload where the sprite may reference a global variable that conflicts with the name of a local variable on a different sprite in the project. 2018-07-17 15:37:28 -04:00
Karishma Chadha
ee9a99b928 Fix variable deletion bug. 2018-07-15 19:00:55 -04:00
Karishma Chadha
a8fc399746 Fix var rename bug where variable would go back to old name after switching sprites. 2018-07-15 18:58:56 -04:00
Karishma Chadha
2b2fc2e561 Code cleanup, refactor, abstraction 2018-07-13 12:58:45 -04:00
Michael "Z" Goddard
fee3c4cc04
fix unnecessary stackClick report from nested promise reporters
Check that a reporting block is the last operation as part of some
parent block. The last operation is the block itself which may report
values for stack clicks and monitor updates if it meets other
requirements.
2018-07-13 10:23:42 -04:00
Karishma Chadha
406e59fc18 Fix variable conflicts that arise when sharing the love of a sprite-local variable with the stage. 2018-07-13 09:36:43 -04:00
Paul Kaplan
b33d9ba4e0
Merge pull request #1335 from mzgoddard/fix-execute
fix asynchronous block execution
2018-07-13 08:32:20 -04:00
Paul Kaplan
e463781bc1
Merge pull request #1330 from paulkaplan/glow-on-stack-click
Always glow threads that come from stack clicks
2018-07-13 07:53:05 -04:00
Michael "Z" Goddard
d2c637a621
fix asynchronous block execution
Freeze promise waiting blocks into an array of reported values. Thaw
those reported values into parent values of matching blocks by id. If
the reporting block was waiting on a promise and reported a value
assign it to its parent value at that future time.
2018-07-13 00:04:49 -04:00
DD Liu
004f38190a Merge branch 'develop' into loadCostume 2018-07-12 15:16:17 -04:00
Paul Kaplan
9dbb362b36 Remove log line 2018-07-12 14:40:13 -04:00
Paul Kaplan
bcd76c995e Always glow threads that come from stack clicks 2018-07-12 11:24:06 -04:00
Kreg Hanning
06c4e5516f Add micro:bit matrix field block (#1314)
* Add micro:bit matrix field block

* Remove debug logs

* Remove rowcol menu

* Fix lint errors
2018-07-11 16:13:49 -04:00
DD Liu
6aefd13af6 Break load costume into more functions, and update how bitmaps are loaded 2018-07-10 10:30:38 -04:00
Ray Schamp
55944bc4b6
Merge pull request #1285 from LLK/feature/device-connection
Device connection update for micro:bit and EV3 extensions
2018-07-09 14:26:06 -04:00
Eric Rosenbaum
6f5ff31eb3 Add disconnectExtensionSession and getPeripheralIsConnected 2018-07-09 13:49:41 -04:00
Evelyn Eastmond
4332725d33 Adding more errors based on web socket onerror and onclose. Moved extension runtime mapping of devices back to MicroBit class. 2018-07-09 13:41:57 -04:00
Evelyn Eastmond
9d66c54f8a Adding error reporting to runtime from BLESession. 2018-07-09 13:41:57 -04:00
Evelyn Eastmond
730b798686 Extension/runtime protocol refactoring. 2018-07-09 13:41:57 -04:00
Eric Rosenbaum
d778ddf00e wip 2018-07-09 13:41:57 -04:00
Paul Kaplan
665bf9a322
Merge pull request #1305 from paulkaplan/fix-broadcast-wait
Fix tick yielding threads
2018-07-09 13:41:55 -04:00
kchadha
6c118cf8e0
Merge pull request #1301 from kchadha/variable-scope
Variable scope
2018-07-06 14:39:56 -04:00
Karishma Chadha
a0a11f2f19 Add 'islocal' flag to XML serialization for variables. 2018-07-06 13:02:23 -04:00
Paul Kaplan
24355c6e6d Fix tick yielding threads 2018-07-05 14:56:00 -04:00
Karishma Chadha
ed608ffe6f Refactor to fix issue with global var not checking for name conflicts on all sprites. 2018-07-03 23:20:49 -04:00
Ray Schamp
4525139d59
Merge pull request #1212 from mzgoddard/unwrapped
execute optimization by unwrapping recursion
2018-07-02 11:20:01 -04:00
Andrew Sliwinski
840510c733 Update colors for extensions. Resolves GH-1275 2018-06-27 18:10:51 -04:00
Karishma Chadha
92dfebdae6 Add variables from var_create events to appropriate target based on isLocal flag. 2018-06-27 16:32:10 -04:00
Eric Rosenbaum
aa400ea15b
Show extension status button via XML attr not button (#1270) 2018-06-27 15:53:18 -04:00
Karishma Chadha
f06b8a3943 Clean up calls to fixUpVariableReferences 2018-06-25 09:11:48 -04:00
Karishma Chadha
889443fcef fixUpVariableReferences should handle conflicting local variables that don't have blocks referencing them. Add unit tests for the function. 2018-06-20 12:07:42 -04:00
Karishma Chadha
9646e3d11e Refactor and move variable reference fixup function into target. 2018-06-19 15:31:08 -04:00
Karishma Chadha
f2aacbc79c Fix up variable references after deserializing a .sprite2 or .sprite3 to avoid conflicts with pre-existing variables. 2018-06-19 14:02:54 -04:00
Karishma Chadha
76b423e481 Make sure to set comment property of block when creating a new block via XML using the adapter. Update unit tests. 2018-06-15 13:58:03 -04:00
kchadha
529d271186
Merge pull request #1235 from kchadha/xml-escape-comments
XML escape comment text.
2018-06-14 14:46:02 -04:00
Eric Rosenbaum
8c748cebb4
Merge pull request #1233 from ericrosenbaum/feature/extension-status-button
Add extension status button
2018-06-14 11:51:32 -04:00
Karishma Chadha
0d403d8e83 XML escape comment text. 2018-06-14 11:39:03 -04:00
Ray Schamp
f5234c777a
Merge pull request #1211 from mzgoddard/broadcast-and-wait-promise
yield a tick if broadcastandwait is waiting on threads waiting for a future tick
2018-06-13 15:58:37 -04:00
Eric Rosenbaum
7d0c45546c Add extension status button XML 2018-06-13 15:52:51 -04:00
Karishma Chadha
5086eced15 Position for block comments imported from 2.0 should be updated when receiving a create event from scratch-blocks. 2018-06-12 17:10:16 -04:00
Michael "Z" Goddard
728769ea24
do not enumerate Blocks._cache
Do not stringify or enumerate Blocks._cache items.
2018-06-12 14:21:40 -04:00
Michael "Z" Goddard
05291aa254
turn reporter tree into instruction sequence
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.
2018-06-12 14:21:40 -04:00
Michael "Z" Goddard
e0ec1ad08f
add id to block execute cache data 2018-06-12 10:05:54 -04:00
Connor Hudson
244ffb38c4
Merge pull request #1218 from technoboy10/bugfix/gh-1165-monitor-import
Fix importing hidden monitors from Scratch 2 projects
2018-06-11 10:27:45 -04:00
Connor Hudson
38756e1022 Update code comments to address PR feedback 2018-06-11 08:37:25 -04:00
Connor Hudson
78da15c09c Remove blocks.mode reference 2018-06-08 17:04:52 -04:00
Connor Hudson
a6629628cd Use monitor show/hide monitor functions, remove incorrect block property references 2018-06-08 16:00:12 -04:00
Connor Hudson
0e394fc873 Add monitor show/hide functions, changed remove monitor to delete state 2018-06-08 15:59:35 -04:00
Connor Hudson
2cb276c476 Consolidate some logic in requestAddMonitor and requestUpdateMonitor 2018-06-07 15:18:45 -04:00
Connor Hudson
99dc46ba80 Add x, y to changeBlock function again after change to merge logic 2018-06-07 11:27:10 -04:00
Connor Hudson
833c27ef21 Remove debug comments, tweak logic for monitor data merging 2018-06-07 11:24:55 -04:00
Karishma Chadha
6bc04c4bef Let comment change event handler multitask. 2018-06-07 11:04:03 -04:00
Karishma Chadha
7b55d8e7ab Undo change that moves block comment relative to block move. 2018-06-07 10:18:34 -04:00
Connor Hudson
13bf932fbb Remove unnecessary arguments to requestAddMonitor 2018-06-07 10:11:15 -04:00
Karishma Chadha
d99a082952 CommentChange events now store text changes in an object with property text, instead of just a string. 2018-06-07 10:09:38 -04:00
Connor Hudson
77dda04228 Set visible: false instead of deleting state in requestRemoveMonitor
This potentially has performance implications, to be investigated later.
2018-06-06 17:14:09 -04:00
Connor Hudson
0d0543810f Properly capture all variable monitor values on add 2018-06-06 16:00:59 -04:00
Connor Hudson
18640d7ddc use mergeWith in requestAddMonitor, requestUpdateMonitor
So undefined values don't overwrite defined ones
2018-06-06 15:54:12 -04:00
Michael "Z" Goddard
0a006dc981
add Runtime.isWaitingThread
Add a Runtime Thread helper to check if a thread is in a state where it
will not change at least until next frame. This includes any state
where the thread is done, as that will not change either.
2018-06-06 10:16:05 -04:00
Michael "Z" Goddard
9311a274d5
add BlockUtility.yieldTick 2018-06-06 10:16:05 -04:00
kchadha
1f209ad4e0
Merge pull request #1191 from kchadha/comment-events
Persist comment state.
2018-06-05 16:53:57 -04:00
Karishma Chadha
644fab0135 Track block comment movement when block moves. 2018-06-05 15:40:19 -04:00
Karishma Chadha
7c5a2ae8e0 Add check that block associated with comment actually exists. 2018-06-05 15:17:28 -04:00
Karishma Chadha
d58bb8bcfb Clean up optRuntime checks in blocklyListen 2018-06-05 15:13:03 -04:00
Karishma Chadha
2171cb69d0 No need to floor workspace coordinates in vm runtime. 2018-06-05 15:12:25 -04:00
Paul Kaplan
7b2f606316 Fix an issue where variable lookup would error if stage did not exist. 2018-06-05 10:45:51 -04:00
Karishma Chadha
522706ccf8 Persist comment state. 2018-06-01 18:10:25 -04:00
Karishma Chadha
537dc9bcd5 Addressing PR comments. 2018-05-31 16:33:42 -04:00
Karishma Chadha
acd728dc2b No more xml differentiation for 'scratch' type of comments. 2018-05-30 21:18:45 -04:00
Karishma Chadha
f079eb4bbd Don't serialize x and y for sb2 comments so that they can be auto positioned. 2018-05-30 21:18:45 -04:00
Karishma Chadha
b0aa288916 Add info about minimized state to comment xml. 2018-05-30 21:18:45 -04:00
Karishma Chadha
1639444a4d Fix lint and tests. 2018-05-30 21:18:45 -04:00
Karishma Chadha
1401d54add Parse SB2 comments and attach block comments to the blocks they belong to. Send comment xml on workspace update so they can be rendered. 2018-05-30 21:15:14 -04:00
kchadha
a85f641d25
Merge pull request #1148 from kchadha/stage-layering
Layer group ordering.
2018-05-25 09:10:05 -04:00
Chris Willis-Ford
b3db00fab7
Merge pull request #1154 from vincentbriglia/issue1552
Allow override of icons per block
2018-05-25 01:10:57 -07:00
Karishma Chadha
5e40bfb7ee No more explicit layer groups, and separate extension into video and pen. 2018-05-20 22:30:20 -04:00
Karishma Chadha
38875bc65c Bubbles should be in the same layer as sprites. Other cleanup. 2018-05-20 19:49:42 -04:00
Vincent Briglia
0c8662bc23 Allow override of icons per block 2018-05-17 15:27:24 +02:00
Vincent Briglia
76ce7d6fe6 add option to override colours 2018-05-17 15:25:20 +02:00
Karishma Chadha
67b114b9c9 Layer group ordering. 2018-05-15 22:22:44 -04:00
Eric Rosenbaum
bdda3bc2c9 Add extension id to toolbox category XML 2018-05-10 15:41:44 -04:00
DD Liu
5c003641f9
Merge pull request #1126 from fsih/fixQuirksOnLoadCostume
Run quirks mode fixes on costumes loaded from sb2s
2018-05-10 13:42:48 -04:00
DD
589dd7d5e0 Attach the svg renderer instead of providing it in order to fix VM tests 2018-05-10 12:03:38 -04:00
Paul Kaplan
f3404f4275
Merge pull request #1128 from paulkaplan/sb2-monitors
Import monitors from sb2 files.
2018-05-09 13:52:29 -04:00
Paul Kaplan
6793349898 Do not stringify reported monitor values.
Consulted @fsih, should be fine since formatting is being handled in the GUI anyway.
2018-05-09 11:39:14 -04:00
Paul Kaplan
cc1314d289 Clear out monitor state on vm.clear
Fixes https://github.com/LLK/scratch-gui/issues/1848
2018-05-09 11:34:01 -04:00
Paul Kaplan
13dfef553e Fix default value for monitor record 2018-05-08 17:30:39 -04:00
Paul Kaplan
4713f47fb7 Import monitors from sb2 files.
Paired with @kchadha on all of this.
2018-05-08 17:06:19 -04:00
Ray Schamp
22852aeab4
Merge pull request #1119 from mzgoddard/recycle-args
Recycle block args
2018-05-08 12:00:29 -04:00
Michael "Z" Goddard
8107349bec
Comment BlockCached 2018-05-07 15:32:31 -04:00
Michael "Z" Goddard
2db2287d12
BlockCached instances are always initialized 2018-05-07 15:32:30 -04:00
Michael "Z" Goddard
5fd749918f
Reuse argValues
Block args set by fields are static and never change. Inputs that do
change are always set onto args. With these two assumptions we can
reuse the same objects for each execution of the same block instead of
constantly creating them and letting them be garbage collected.
2018-05-07 15:32:30 -04:00
Michael "Z" Goddard
9b82530f51
Use a constructor to create the execute cache objects 2018-05-07 15:32:30 -04:00
Michael "Z" Goddard
0634e962a8
Add Thread.StackFrame class
Use a private StackFrame class to help internally manage use of Stack
Frame values and memory. Create params, reported, and executionContext
on demand.
2018-05-07 11:20:26 -04:00
Ray Schamp
23e72525bf
Merge pull request #1065 from mzgoddard/push-reported-again
Push reported again. Now with empty boolean support!
2018-04-30 09:36:32 -04:00
Michael "Z" Goddard
1c68b543df
Comment execute's BlocksExecuteCache usage
Explain how BlocksExecuteCache helps speed up execute by storing values from
Blocks and one-time derived values on an object that is released when Blocks is
edited in the editor. The one time created cache object for a block then
simplifies the complexity of later javascript operations to use these stored
values.
2018-04-24 19:05:44 -04:00
Michael "Z" Goddard
02dd9a8c22
Unset justReported after reading its value
Avoid justReported values leaking to other argValues by setting back to the
default null value.
2018-04-24 19:05:20 -04:00
Andrew Sliwinski
f86cad3305 Replace extension delimeter with '_' 2018-04-20 07:54:02 -04:00
Michael "Z" Goddard
d04d6b2c6a
Revert "Revert "Push reported""
This reverts commit 107adad647.
2018-04-16 13:21:53 -04:00
Michael "Z" Goddard
044370790c
Merge pull request #1016 from gnarf/io-video
Video IO Device Implementation
2018-04-11 10:14:56 -04:00
Corey Frang
eef88f6c2d
First draft of video IO device 2018-04-10 13:57:53 -04:00
Christopher Willis-Ford
53b5ba93f5 Add tests for converting extension metadata
These tests convert some extension metadata into scratch-blocks JSON and
XML, then verify that the JSON and XML are as expected.
2018-04-09 15:37:08 -07:00
Christopher Willis-Ford
f8db6c3f02 Support extension translation
The new `maybeFormatMessage` function detects whether its argument
looks like a message descriptor object and, if so, will call
`formatMessage` on it. This is now used for all user-visible text fields
in extensions.

Also, messages may use "select" to check the target type with a message
like this: '{targetType, select, stage {text for stage} sprite {text for
sprite} other {text for other}'. Note that the "other" clause is
required by `formatMessage`.
2018-04-05 12:17:05 -07:00
Christopher Willis-Ford
de9e2be265 Add EVENT extension block type
An EVENT block is like a HAT block but it has no implementation
function. Its stack runs when the VM emits the corresponding event.
2018-04-04 23:44:59 -07:00
Christopher Willis-Ford
af058b8146 Support LOOP and CONDITIONAL blocks in extensions
A LOOP block is like a conditional, but the LOOP block will be
re-evaluated after any child branch runs.

Also:
- Support using '---' as a block separator
- Refactor common code from `_registerExtensionPrimitives` and
  `_refreshExtensionPrimitives` into new `_fillExtensionCategory`
- Improve error reporting during block conversion
2018-04-04 22:19:48 -07:00
Paul Kaplan
140094a7ad Make "when clicked" blocks target dependent.
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.
2018-03-20 10:41:50 -04:00
Christopher Willis-Ford
4210c6dd4c Fix stack check in stepThread
The previous logic seemed to be expecting `peekStack` to return 0 when
the stack was empty, but its return type is `?string` and it returns
`undefined` when the stack is empty. The `!== 0` check would never pass,
then, leading to problems with (for example) the "say/think and wait"
blocks.
2018-03-14 16:17:29 -07:00
Chris Willis-Ford
219f083a29
Merge pull request #934 from picklesrus/extensions-dynamic-menu
Extensions dynamic menu
2018-03-06 16:33:26 -05:00
picklesrus
026b9dc282 Stop wrapping function for no reason. 2018-03-02 11:02:56 -08:00
Ray Schamp
4e933eed81
Merge pull request #878 from davidaylaian/reduce-peekstack-calls
Optimize stepThread by reducing the number of calls to peekStack
2018-02-28 16:50:20 -05:00
DD
0a5ccbf42f Use existing UID util 2018-02-23 12:07:07 -05:00
DD
8355dd662f Switch to sending end drag event to be handled by gui 2018-02-23 11:57:19 -05:00
DD
2545d1955d Repopulate blocks with ids 2018-02-20 16:09:08 -05:00
DD
31def7d03d Track hovered sprite. End drag may transfer blocks from one sprite to another. 2018-02-20 16:09:08 -05:00
DD
fe4b3d3c01 Pass through block drag event 2018-02-20 16:09:08 -05:00
Chris Willis-Ford
8e1719b716
Merge pull request #920 from towerofnix/scroll-detection
Scroll wheel detection for "when key (up/down) pressed" blocks
2018-02-16 12:21:27 -08:00
picklesrus
1910968b13 Fix lint errors. 2018-02-16 10:49:26 -08:00
Eric Rosenbaum
22038c947c When getting sprite by name, skip the stage 2018-02-12 15:33:27 -05:00
Karishma Chadha
f5813b1845 Update sprite names, plus some code cleanup. 2018-02-05 16:54:58 -05:00
Karishma Chadha
7faeed7128 Update blocks after sound/costume rename. 2018-02-05 14:35:52 -05:00
kchadha
107adad647
Revert "Push reported" 2018-02-02 12:42:09 -05:00
kchadha
490248f652
Merge pull request #914 from kchadha/bugfix-909
Keep block xml up-to-date after renaming a variable.
2018-01-29 09:30:10 -05:00
picklesrus
b6bb92d8f6 Adding support for dynamic menus in extensions. 2018-01-26 14:36:36 -08:00
Karishma Chadha
0b2eaa9e19 Moving block updating code into blocks instead of runtime. 2018-01-26 16:58:45 -05:00
Florrie
be83c0ee74 Mouse wheel IO system
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.
2018-01-26 17:13:01 -04:00
Michael "Z" Goddard
10acf3c4f5
Add BlocksExecuteCache
Add a Blocks cache available only to execute. This cache lets execute
get a blocks inputs, fields, opcode, and mutation in one request and an
object execute can further modify to store derivative values it use
this and every later execute iteration to perform its duties quicker.
2018-01-24 17:00:42 -05:00
Michael "Z" Goddard
41d6a8f925
Check if a thread's target is null in sequencer
Before calling execute, if a thread's target is null, retire that
thread.

This saves repeatedly checking if the thread's target is null in
recursive calls where even if scratch-gui or blocks, or some other
related library set the target to null, that will not happen during
block execution. It will happen at some time outside of the sequencer
letting the sequencer check once instead of execute checking at every
recursive level.
2018-01-24 17:00:37 -05:00
Michael "Z" Goddard
4286e3e982
Add Thread.blockContainer
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.
2018-01-24 17:00:35 -05:00
Michael "Z" Goddard
ab8d8e5f34
Add optional recursiveCall argument to execute
When execute calls itself to step into the next stack level, pass
RECURSIVE to the recursiveCall level. This argument provides
opportunity to recursed calls in execute to reduce the time needed for
some checks.

- Reduce time for checking around setting
  thread.requestScriptGlowInFrame
- Call thread.pushReportedValue at end of execute when in a recursive
  call

A boolean check is faster than a type lookup, command blocks will only
be executed in non-recursive calls. This saves a minor amount of time
for any result reporting blocks like blocks that get variables or add
two inputs together.

If the block is not returning a promise and execute is a recursed call,
that implies that the block is neither a hat or that the thread is not
at the top. That reduces handleReport to pushReportedValue. Using the
recursiveCall argument the final block calling handleReport can
shortcut the extra work in handleReport and reduce it to immediately
calling pushReportedValue.
2018-01-24 17:00:24 -05:00
Michael "Z" Goddard
6b7582f1c7
Report block result to stackFrame.justReported
- 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.
2018-01-24 17:00:12 -05:00
Karishma Chadha
784341909b Update block xml for all blocks that use a variable that was just renamed. 2018-01-22 15:14:43 -05:00
DD
fce83dc2c3 make it work for non-droppable inputs 2018-01-10 17:50:48 -05:00
DD
db662b8584 fix lint 2018-01-09 14:55:46 -05:00
DD Liu
0b6d7adf3e Update monitor on dropdown change 2018-01-08 20:22:18 -05:00
David Aylaian
a22879631f Optimize stepThread by reducing the number of calls to peekStack 2017-12-27 19:44:49 -05:00
Karishma Chadha
c0e4ae455c Streamlining broadcast block execution. When arg information is provided to execute function, corresponding broadcast message is looked up by id, if provided, or if not, then name. If neither id nor name is provided, we can't look up the broadcast message and something is wrong, so an error is logged. We no longer need to differentiate between the shadow menu vs. plugged in input cases via the argValue name (e.g. 'BROADCAST_OPTION' vs. 'BROADCAST_INPUT'). This refactor also helps with sb2 import, coming in the next commit. 2017-12-21 19:06:11 -05:00
Karishma Chadha
413d113dda Adding support for blocks to be plugged into the input of broadcast blocks. SB2 Import to come. 2017-12-21 19:06:11 -05:00
Eric Rosenbaum
2d6e91fa59
Merge branch 'develop' into feature/extension-category-icons 2017-12-19 15:39:00 -05:00
Eric Rosenbaum
9613046b2f Add optional menuIcon for extension blocks 2017-12-19 14:47:11 -05:00
Eric Rosenbaum
7c853ab7f3
Merge pull request #869 from ericrosenbaum/feature/add-extension-separator
Add separator to extension block definition
2017-12-19 13:58:28 -05:00
Eric Rosenbaum
00d6e9e8e7
Merge pull request #863 from ericrosenbaum/feature/blockly-extension-for-scratch-extensions
Add blockly extension for scratch extensions
2017-12-15 15:27:26 -05:00
Eric Rosenbaum
5cb0f5d76d Add separator to extension block definition 2017-12-15 14:09:29 -05:00
Eric Rosenbaum
5e6187bee7 Add blockly extension for scratch extensions 2017-12-14 14:37:08 -05:00
Paul Kaplan
0f82e2a84d Be more cautious about parsing json. 2017-12-14 14:23:16 -05:00
Paul Kaplan
256d7b3d6c Parse the warp property from the mutation instead of using directly. 2017-12-13 15:53:55 -05:00
Eric Rosenbaum
25ded4cff7 Fix spelling of coloUrTertiary 2017-12-11 17:01:23 -05:00
chrisgarrity
f51cf9877e
Preliminary localization (#777)
* localize the block and menu strings in the pen extension
* adds .tx/config to be able to push translations to transifex
* includes format-message to localize strings and extracting them.
* add setLocale function to VM to allow GUI to pass in locale data.
* refresh block definitions when the locale changes.

### Still to be decided
For now just extracting messages from the pen extension into their own file. We’ll need to decide if each category gets its own file, or group all the strings into one resource.
2017-12-11 15:41:45 -05:00
Chris Willis-Ford
e7bbad60e8
Merge pull request #793 from cwillisf/remove-threads-safely
Make _removeThread safe during thread iteration
2017-12-06 17:18:10 -08:00
Paul Kaplan
e6bd474720
Merge pull request #845 from kchadha/broadcast-msg-extra-create-bugfix
Broadcast Msg Bugfix
2017-12-05 15:38:12 -05:00
Paul Kaplan
bb69d157cd
Merge pull request #832 from paulkaplan/custom-procedure-updates
Updates for editable custom procedures
2017-12-05 15:37:56 -05:00
Karishma Chadha
34b0aff637 Bugfix for scratch-gui issue #994, where executing a broadcast block from the flyout was creating a conflicting variable, causing a fatal error. 2017-12-04 18:01:29 -05:00
sjhuang26
eede8105d1 Clear answer on green flag 2017-12-01 20:06:55 -05:00
Paul Kaplan
a9e95f3b01
Merge pull request #829 from kchadha/broadcast-message-typed-variable
Broadcast message functionality
2017-12-01 11:51:38 -05:00
Paul Kaplan
5a53323715 Update to use explicit procedure names and ids 2017-11-29 12:00:00 -05:00
Karishma Chadha
e5378d323d Adding unit tests for new lookupOrCreate funciton, fixing a bug that came up during testing (using lookupVariableById on a null target). Skipping integration tests that do not work right now because SB2 import of broadcast message blocks has not been implemented yet. 2017-11-29 10:43:07 -05:00
Paul Kaplan
80b4dab104 Decode the encoded argument information 2017-11-29 10:34:59 -05:00
Karishma Chadha
b674a0c047 Code cleanup and refactoring, and getting scratch3_event broadcast functionality to look up the variable name instead of getting it ad-hoc. 2017-11-28 22:33:27 -05:00
Karishma Chadha
0a15190b85 Broadcast message functionality (works with creating new messages, and switching back and forth between them as well). This commit includes a temporary workaround for the issue where the default broadcast message, 'message1' wasn't triggering a var_create event (filed in LLK/scratch-blocks#1258). 2017-11-21 16:48:48 -05:00
DD Liu
58dd57fe48
Merge pull request #784 from fsih/perSpriteMonitors
Execute monitors on a given target ID when block is sprite-specific
2017-11-21 10:23:53 -05:00
DD
ec9d8094bd fix review comments 2017-11-20 17:23:59 -05:00
DD
6d26023104 revert unnecessary changes'
:
2017-11-20 13:00:37 -05:00
griffpatch
6ed2ca6caa Cache Block Inputs & Procedure Definitions
* Cache Block Inputs & Procedure Definitions

* @mzgoddard requested changes on this pull request

* Move all caching into a single reusable field _cache.
* Invalidate 'all' caches on any change.
* Use 'typeof' instead of hasOwnProperty.
* Take caching out of Block and use lookup instead.
2017-11-20 10:22:51 -05:00
Christopher Willis-Ford
b19af399fa Make _removeThread safe during thread iteration
Before: `_removeThread` stops a thread and immediately removes it from
the runtime's thread array. If this happens while iterating over the
thread array, such as in the case of clone deletion, some elements of
the array can be missed.

After: `_removeThread` has been renamed to `_stopThread`. It still stops
the thread immediately but it no longer removes the thread from the
runtime's thread array. Instead, `_stopThread` marks the thread for
later removal. Such threads are removed at the top of the next `_step`.
2017-11-17 12:56:25 -08:00
DD Liu
2d9722e69c
Merge pull request #787 from fsih/deleteMonitorBlocks
Delete monitor block when variable is deleted
2017-11-16 17:20:26 -05:00
DD
255e160ebb Change it so we dont have to do string manipulation on IDs to get data out of events 2017-11-16 17:19:51 -05:00