@scratch/scratch-vm 11.0.0-UEPR-176

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/LICENSE +12 -0
  2. package/README.md +120 -0
  3. package/dist/node/extension-worker.js +2 -0
  4. package/dist/node/extension-worker.js.map +1 -0
  5. package/dist/node/scratch-vm.js +3 -0
  6. package/dist/node/scratch-vm.js.LICENSE.txt +205 -0
  7. package/dist/node/scratch-vm.js.map +1 -0
  8. package/dist/web/extension-worker.js +2 -0
  9. package/dist/web/extension-worker.js.map +1 -0
  10. package/dist/web/scratch-vm.js +3 -0
  11. package/dist/web/scratch-vm.js.LICENSE.txt +42 -0
  12. package/dist/web/scratch-vm.js.map +1 -0
  13. package/package.json +108 -0
  14. package/src/.eslintrc.js +7 -0
  15. package/src/blocks/scratch3_control.js +206 -0
  16. package/src/blocks/scratch3_core_example.js +69 -0
  17. package/src/blocks/scratch3_data.js +257 -0
  18. package/src/blocks/scratch3_event.js +137 -0
  19. package/src/blocks/scratch3_looks.js +612 -0
  20. package/src/blocks/scratch3_motion.js +288 -0
  21. package/src/blocks/scratch3_operators.js +154 -0
  22. package/src/blocks/scratch3_procedures.js +79 -0
  23. package/src/blocks/scratch3_sensing.js +336 -0
  24. package/src/blocks/scratch3_sound.js +350 -0
  25. package/src/dispatch/central-dispatch.js +143 -0
  26. package/src/dispatch/shared-dispatch.js +235 -0
  27. package/src/dispatch/worker-dispatch.js +110 -0
  28. package/src/engine/adapter.js +176 -0
  29. package/src/engine/block-utility.js +242 -0
  30. package/src/engine/blocks-execute-cache.js +19 -0
  31. package/src/engine/blocks-runtime-cache.js +78 -0
  32. package/src/engine/blocks.js +1299 -0
  33. package/src/engine/comment.js +56 -0
  34. package/src/engine/execute.js +580 -0
  35. package/src/engine/monitor-record.js +23 -0
  36. package/src/engine/mutation-adapter.js +48 -0
  37. package/src/engine/profiler.js +390 -0
  38. package/src/engine/runtime.js +2686 -0
  39. package/src/engine/scratch-blocks-constants.js +27 -0
  40. package/src/engine/sequencer.js +361 -0
  41. package/src/engine/stage-layering.js +29 -0
  42. package/src/engine/target.js +799 -0
  43. package/src/engine/thread.js +404 -0
  44. package/src/engine/variable.js +70 -0
  45. package/src/extension-support/argument-type.js +47 -0
  46. package/src/extension-support/block-type.js +50 -0
  47. package/src/extension-support/define-messages.js +18 -0
  48. package/src/extension-support/extension-manager.js +440 -0
  49. package/src/extension-support/extension-metadata.js +64 -0
  50. package/src/extension-support/extension-worker.js +59 -0
  51. package/src/extension-support/reporter-scope.js +18 -0
  52. package/src/extension-support/target-type.js +17 -0
  53. package/src/extensions/scratch3_boost/index.js +2113 -0
  54. package/src/extensions/scratch3_ev3/index.js +1355 -0
  55. package/src/extensions/scratch3_gdx_for/index.js +981 -0
  56. package/src/extensions/scratch3_gdx_for/scratch-link-device-adapter.js +44 -0
  57. package/src/extensions/scratch3_makeymakey/index.js +396 -0
  58. package/src/extensions/scratch3_microbit/index.js +984 -0
  59. package/src/extensions/scratch3_music/assets/drums/1-snare.mp3 +0 -0
  60. package/src/extensions/scratch3_music/assets/drums/10-wood-block.mp3 +0 -0
  61. package/src/extensions/scratch3_music/assets/drums/11-cowbell.mp3 +0 -0
  62. package/src/extensions/scratch3_music/assets/drums/12-triangle.mp3 +0 -0
  63. package/src/extensions/scratch3_music/assets/drums/13-bongo.mp3 +0 -0
  64. package/src/extensions/scratch3_music/assets/drums/14-conga.mp3 +0 -0
  65. package/src/extensions/scratch3_music/assets/drums/15-cabasa.mp3 +0 -0
  66. package/src/extensions/scratch3_music/assets/drums/16-guiro.mp3 +0 -0
  67. package/src/extensions/scratch3_music/assets/drums/17-vibraslap.mp3 +0 -0
  68. package/src/extensions/scratch3_music/assets/drums/18-cuica.mp3 +0 -0
  69. package/src/extensions/scratch3_music/assets/drums/2-bass-drum.mp3 +0 -0
  70. package/src/extensions/scratch3_music/assets/drums/3-side-stick.mp3 +0 -0
  71. package/src/extensions/scratch3_music/assets/drums/4-crash-cymbal.mp3 +0 -0
  72. package/src/extensions/scratch3_music/assets/drums/5-open-hi-hat.mp3 +0 -0
  73. package/src/extensions/scratch3_music/assets/drums/6-closed-hi-hat.mp3 +0 -0
  74. package/src/extensions/scratch3_music/assets/drums/7-tambourine.mp3 +0 -0
  75. package/src/extensions/scratch3_music/assets/drums/8-hand-clap.mp3 +0 -0
  76. package/src/extensions/scratch3_music/assets/drums/9-claves.mp3 +0 -0
  77. package/src/extensions/scratch3_music/assets/instruments/1-piano/108.mp3 +0 -0
  78. package/src/extensions/scratch3_music/assets/instruments/1-piano/24.mp3 +0 -0
  79. package/src/extensions/scratch3_music/assets/instruments/1-piano/36.mp3 +0 -0
  80. package/src/extensions/scratch3_music/assets/instruments/1-piano/48.mp3 +0 -0
  81. package/src/extensions/scratch3_music/assets/instruments/1-piano/60.mp3 +0 -0
  82. package/src/extensions/scratch3_music/assets/instruments/1-piano/72.mp3 +0 -0
  83. package/src/extensions/scratch3_music/assets/instruments/1-piano/84.mp3 +0 -0
  84. package/src/extensions/scratch3_music/assets/instruments/1-piano/96.mp3 +0 -0
  85. package/src/extensions/scratch3_music/assets/instruments/10-clarinet/48.mp3 +0 -0
  86. package/src/extensions/scratch3_music/assets/instruments/10-clarinet/60.mp3 +0 -0
  87. package/src/extensions/scratch3_music/assets/instruments/11-saxophone/36.mp3 +0 -0
  88. package/src/extensions/scratch3_music/assets/instruments/11-saxophone/60.mp3 +0 -0
  89. package/src/extensions/scratch3_music/assets/instruments/11-saxophone/84.mp3 +0 -0
  90. package/src/extensions/scratch3_music/assets/instruments/12-flute/60.mp3 +0 -0
  91. package/src/extensions/scratch3_music/assets/instruments/12-flute/72.mp3 +0 -0
  92. package/src/extensions/scratch3_music/assets/instruments/13-wooden-flute/60.mp3 +0 -0
  93. package/src/extensions/scratch3_music/assets/instruments/13-wooden-flute/72.mp3 +0 -0
  94. package/src/extensions/scratch3_music/assets/instruments/14-bassoon/36.mp3 +0 -0
  95. package/src/extensions/scratch3_music/assets/instruments/14-bassoon/48.mp3 +0 -0
  96. package/src/extensions/scratch3_music/assets/instruments/14-bassoon/60.mp3 +0 -0
  97. package/src/extensions/scratch3_music/assets/instruments/15-choir/48.mp3 +0 -0
  98. package/src/extensions/scratch3_music/assets/instruments/15-choir/60.mp3 +0 -0
  99. package/src/extensions/scratch3_music/assets/instruments/15-choir/72.mp3 +0 -0
  100. package/src/extensions/scratch3_music/assets/instruments/16-vibraphone/60.mp3 +0 -0
  101. package/src/extensions/scratch3_music/assets/instruments/16-vibraphone/72.mp3 +0 -0
  102. package/src/extensions/scratch3_music/assets/instruments/17-music-box/60.mp3 +0 -0
  103. package/src/extensions/scratch3_music/assets/instruments/18-steel-drum/60.mp3 +0 -0
  104. package/src/extensions/scratch3_music/assets/instruments/19-marimba/60.mp3 +0 -0
  105. package/src/extensions/scratch3_music/assets/instruments/2-electric-piano/60.mp3 +0 -0
  106. package/src/extensions/scratch3_music/assets/instruments/20-synth-lead/60.mp3 +0 -0
  107. package/src/extensions/scratch3_music/assets/instruments/21-synth-pad/60.mp3 +0 -0
  108. package/src/extensions/scratch3_music/assets/instruments/3-organ/60.mp3 +0 -0
  109. package/src/extensions/scratch3_music/assets/instruments/4-guitar/60.mp3 +0 -0
  110. package/src/extensions/scratch3_music/assets/instruments/5-electric-guitar/60.mp3 +0 -0
  111. package/src/extensions/scratch3_music/assets/instruments/6-bass/36.mp3 +0 -0
  112. package/src/extensions/scratch3_music/assets/instruments/6-bass/48.mp3 +0 -0
  113. package/src/extensions/scratch3_music/assets/instruments/7-pizzicato/60.mp3 +0 -0
  114. package/src/extensions/scratch3_music/assets/instruments/8-cello/36.mp3 +0 -0
  115. package/src/extensions/scratch3_music/assets/instruments/8-cello/48.mp3 +0 -0
  116. package/src/extensions/scratch3_music/assets/instruments/8-cello/60.mp3 +0 -0
  117. package/src/extensions/scratch3_music/assets/instruments/9-trombone/36.mp3 +0 -0
  118. package/src/extensions/scratch3_music/assets/instruments/9-trombone/48.mp3 +0 -0
  119. package/src/extensions/scratch3_music/assets/instruments/9-trombone/60.mp3 +0 -0
  120. package/src/extensions/scratch3_music/index.js +1333 -0
  121. package/src/extensions/scratch3_music/manifest.js +63 -0
  122. package/src/extensions/scratch3_pen/index.js +770 -0
  123. package/src/extensions/scratch3_speech2text/index.js +700 -0
  124. package/src/extensions/scratch3_text2speech/index.js +766 -0
  125. package/src/extensions/scratch3_translate/index.js +286 -0
  126. package/src/extensions/scratch3_video_sensing/debug.js +13 -0
  127. package/src/extensions/scratch3_video_sensing/index.js +594 -0
  128. package/src/extensions/scratch3_video_sensing/library.js +384 -0
  129. package/src/extensions/scratch3_video_sensing/math.js +76 -0
  130. package/src/extensions/scratch3_video_sensing/view.js +509 -0
  131. package/src/extensions/scratch3_wedo2/index.js +1616 -0
  132. package/src/import/load-costume.js +416 -0
  133. package/src/import/load-sound.js +116 -0
  134. package/src/index.js +10 -0
  135. package/src/io/ble.js +256 -0
  136. package/src/io/bt.js +202 -0
  137. package/src/io/clock.js +39 -0
  138. package/src/io/cloud.js +169 -0
  139. package/src/io/keyboard.js +146 -0
  140. package/src/io/mouse.js +145 -0
  141. package/src/io/mouseWheel.js +28 -0
  142. package/src/io/userData.js +24 -0
  143. package/src/io/video.js +210 -0
  144. package/src/playground/benchmark.css +83 -0
  145. package/src/playground/benchmark.js +753 -0
  146. package/src/playground/index.html +111 -0
  147. package/src/playground/suite.css +78 -0
  148. package/src/playground/suite.html +25 -0
  149. package/src/playground/suite.js +544 -0
  150. package/src/playground/video-sensing.html +18 -0
  151. package/src/playground/video-sensing.js +133 -0
  152. package/src/serialization/deserialize-assets.js +178 -0
  153. package/src/serialization/sb2.js +1295 -0
  154. package/src/serialization/sb2_specmap.js +1818 -0
  155. package/src/serialization/sb3.js +1320 -0
  156. package/src/serialization/serialize-assets.js +60 -0
  157. package/src/sprites/rendered-target.js +1115 -0
  158. package/src/sprites/sprite.js +177 -0
  159. package/src/util/base64-util.js +48 -0
  160. package/src/util/cast.js +218 -0
  161. package/src/util/clone.js +17 -0
  162. package/src/util/color.js +204 -0
  163. package/src/util/fetch-with-timeout.js +53 -0
  164. package/src/util/get-monitor-id.js +33 -0
  165. package/src/util/jsonrpc.js +114 -0
  166. package/src/util/log.js +4 -0
  167. package/src/util/math-util.js +122 -0
  168. package/src/util/maybe-format-message.js +18 -0
  169. package/src/util/new-block-ids.js +33 -0
  170. package/src/util/rateLimiter.js +73 -0
  171. package/src/util/scratch-link-websocket.js +133 -0
  172. package/src/util/string-util.js +94 -0
  173. package/src/util/task-queue.js +203 -0
  174. package/src/util/timer.js +103 -0
  175. package/src/util/uid.js +29 -0
  176. package/src/util/variable-util.js +48 -0
  177. package/src/util/xml-escape.js +33 -0
  178. package/src/virtual-machine.js +1586 -0
package/LICENSE ADDED
@@ -0,0 +1,12 @@
1
+ Copyright (c) 2016, Massachusetts Institute of Technology
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
+
6
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
+
8
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
+
10
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11
+
12
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md ADDED
@@ -0,0 +1,120 @@
1
+ ## scratch-vm
2
+ #### Scratch VM is a library for representing, running, and maintaining the state of computer programs written using [Scratch Blocks](https://github.com/scratchfoundation/scratch-blocks).
3
+
4
+ [![CI/CD](https://github.com/scratchfoundation/scratch-vm/actions/workflows/ci-cd.yml/badge.svg)](https://github.com/scratchfoundation/scratch-vm/actions/workflows/ci-cd.yml)
5
+
6
+ ## Installation
7
+ This requires you to have Git and Node.js installed.
8
+
9
+ To install as a dependency for your own application:
10
+ ```bash
11
+ npm install scratch-vm
12
+ ```
13
+ To set up a development environment to edit scratch-vm yourself:
14
+ ```bash
15
+ git clone https://github.com/scratchfoundation/scratch-vm.git
16
+ cd scratch-vm
17
+ npm install
18
+ ```
19
+
20
+ ## Development Server
21
+ This requires Node.js to be installed.
22
+
23
+ For convenience, we've included a development server with the VM. This is sometimes useful when running in an environment that's loading remote resources (e.g., SVGs from the Scratch server). If you would like to use your modified VM with the full Scratch 3.0 GUI, [follow the instructions to link the VM to the GUI](https://github.com/scratchfoundation/scratch-gui/wiki/Getting-Started).
24
+
25
+ ## Running the Development Server
26
+ Open a Command Prompt or Terminal in the repository and run:
27
+ ```bash
28
+ npm start
29
+ ```
30
+
31
+ ## Playground
32
+ To view the Playground, make sure the dev server's running and go to [http://localhost:8073/playground/](http://localhost:8073/playground/) - you will be directed to the playground, which demonstrates various tools and internal state.
33
+
34
+ ![VM Playground Screenshot](https://i.imgur.com/nOCNqEc.gif)
35
+
36
+
37
+ ## Standalone Build
38
+ ```bash
39
+ npm run build
40
+ ```
41
+
42
+ ```html
43
+ <script src="/path/to/dist/web/scratch-vm.js"></script>
44
+ <script>
45
+ var vm = new window.VirtualMachine();
46
+ // do things
47
+ </script>
48
+ ```
49
+
50
+ ## How to include in a Node.js App
51
+ For an extended setup example, check out the /src/playground directory, which includes a fully running VM instance.
52
+ ```js
53
+ var VirtualMachine = require('@scratch/scratch-vm');
54
+ var vm = new VirtualMachine();
55
+
56
+ // Block events
57
+ Scratch.workspace.addChangeListener(vm.blockListener);
58
+
59
+ // Run threads
60
+ vm.start();
61
+ ```
62
+
63
+ ## Abstract Syntax Tree
64
+
65
+ #### Overview
66
+ The Virtual Machine constructs and maintains the state of an [Abstract Syntax Tree](https://en.wikipedia.org/wiki/Abstract_syntax_tree) (AST) by listening to events emitted by the [scratch-blocks](https://github.com/scratchfoundation/scratch-blocks) workspace via the `blockListener`. Each target (code-running object, for example, a sprite) keeps an AST for its blocks. At any time, the current state of an AST can be viewed by inspecting the `vm.runtime.targets[...].blocks` object.
67
+
68
+ #### Anatomy of a Block
69
+ The VM's block representation contains all the important information for execution and storage. Here's an example representing the "when key pressed" script on a workspace:
70
+ ```json
71
+ {
72
+ "_blocks": {
73
+ "Q]PK~yJ@BTV8Y~FfISeo": {
74
+ "id": "Q]PK~yJ@BTV8Y~FfISeo",
75
+ "opcode": "event_whenkeypressed",
76
+ "inputs": {
77
+ },
78
+ "fields": {
79
+ "KEY_OPTION": {
80
+ "name": "KEY_OPTION",
81
+ "value": "space"
82
+ }
83
+ },
84
+ "next": null,
85
+ "topLevel": true,
86
+ "parent": null,
87
+ "shadow": false,
88
+ "x": -69.333333333333,
89
+ "y": 174
90
+ }
91
+ },
92
+ "_scripts": [
93
+ "Q]PK~yJ@BTV8Y~FfISeo"
94
+ ]
95
+ }
96
+ ```
97
+
98
+ ## Testing
99
+ ```bash
100
+ npm test
101
+ ```
102
+
103
+ ```bash
104
+ npm run coverage
105
+ ```
106
+
107
+ ## Publishing to GitHub Pages
108
+ ```bash
109
+ npm run deploy
110
+ ```
111
+
112
+ This will push the currently built playground to the gh-pages branch of the
113
+ currently tracked remote. If you would like to change where to push to, add
114
+ a repo url argument:
115
+ ```bash
116
+ npm run deploy -- -r <your repo url>
117
+ ```
118
+
119
+ ## Donate
120
+ We provide [Scratch](https://scratch.mit.edu) free of charge, and want to keep it that way! Please consider making a [donation](https://secure.donationpay.org/scratchfoundation/) to support our continued engineering, design, community, and resource development efforts. Donations of any size are appreciated. Thank you!
@@ -0,0 +1,2 @@
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.VirtualMachine=t():e.VirtualMachine=t()}(global,(()=>(()=>{var e={303:(e,t,r)=>{var n=r(2491),o=r(6770).i;function i(){}n.mixin(i),i.prototype.write=function(e,t,r){var n;this.emit("item",(e?e+" ":"")+(t?o("- "+((4==(n=t.toUpperCase()).toString().length?" "+n:n)+" -"),{debug:"magenta",info:"cyan",warn:"yellow",error:"red"}[t])+" ":"")+r.join(" "))},e.exports=i},329:(e,t,r)=>{var n=r(2491),o=r(2216),i={debug:["cyan"],info:["purple"],warn:["yellow",!0],error:["red",!0]},s=new n;s.write=function(e,t,r){console.log;console[t]&&console[t].apply&&console[t].apply(console,["%c"+e+" %c"+t,o("gray"),o.apply(o,i[t])].concat(r))},s.pipe=function(){},e.exports=s},1280:(e,t,r)=>{var n=r(2491),o=r(6770).i;function i(){}function s(e){return e}n.mixin(i);var a={string:s,number:s,default:JSON.stringify.bind(JSON)};i.prototype.write=function(e,t,r){var n,s=function(){var e=Error.prepareStackTrace;Error.prepareStackTrace=function(e,t){return t};var t=new Error;Error.captureStackTrace(t,arguments.callee);var r=t.stack;return Error.prepareStackTrace=e,r}()[5],c=i.fullPath?s.getFileName():s.getFileName().replace(/^.*\/(.+)$/,"/$1");this.emit("item",(e?e+" ":"")+(t?o(4==(n=t).toString().length?" "+n:n,{debug:"magenta",info:"cyan",warn:"yellow",error:"red"}[t])+" ":"")+o(c+":"+s.getLineNumber(),"grey")+" "+function(e){return e.map((function(e){return(a[typeof e]||a.default)(e)}))}(r).join(" "))},i.fullPath=!0,e.exports=i},1920:e=>{function t(){this._events={}}t.prototype={on:function(e,t){this._events||(this._events={});var r=this._events;return(r[e]||(r[e]=[])).push(t),this},removeListener:function(e,t){var r,n=this._events[e]||[];for(r=n.length-1;r>=0&&n[r];r--)n[r]!==t&&n[r].cb!==t||n.splice(r,1)},removeAllListeners:function(e){e?this._events[e]&&(this._events[e]=[]):this._events={}},listeners:function(e){return this._events&&this._events[e]||[]},emit:function(e){this._events||(this._events={});var t,r=Array.prototype.slice.call(arguments,1),n=this._events[e]||[];for(t=n.length-1;t>=0&&n[t];t--)n[t].apply(this,r);return this},when:function(e,t){return this.once(e,t,!0)},once:function(e,t,r){if(!t)return this;function n(){r||this.removeListener(e,n),t.apply(this,arguments)&&r&&this.removeListener(e,n)}return n.cb=t,this.on(e,n),this}},t.mixin=function(e){var r,n=t.prototype;for(r in n)n.hasOwnProperty(r)&&(e.prototype[r]=n[r])},e.exports=t},2203:e=>{"use strict";e.exports=require("stream")},2216:e=>{var t={black:"#000",red:"#c23621",green:"#25bc26",yellow:"#bbbb00",blue:"#492ee1",magenta:"#d338d3",cyan:"#33bbc8",gray:"#808080",purple:"#708"};e.exports=function(e,r){return r?"color: #fff; background: "+t[e]+";":"color: "+t[e]+";"}},2391:(e,t,r)=>{var n=r(2491),o=r(6770).i,i=r(9023);function s(){}n.mixin(s),s.prototype.write=function(e,t,r){this.emit("item",(e?o(e+" ","grey"):"")+(t?o(t,{debug:"blue",info:"cyan",warn:"yellow",error:"red"}[t])+" ":"")+r.map((function(e){return"string"==typeof e?e:i.inspect(e,null,3,!0)})).join(" "))},e.exports=s},2491:(e,t,r)=>{function n(){}r(1920).mixin(n),n.prototype.write=function(e,t,r){this.emit("item",e,t,r)},n.prototype.end=function(){this.emit("end"),this.removeAllListeners()},n.prototype.pipe=function(e){var t=this;function r(){e.write.apply(e,Array.prototype.slice.call(arguments))}function n(){!e._isStdio&&e.end()}return t.emit("unpipe",e),e.emit("pipe",t),t.on("item",r),t.on("end",n),t.when("unpipe",(function(o){var i=o===e||void 0===o;return i&&(t.removeListener("item",r),t.removeListener("end",n),e.emit("unpipe")),i})),e},n.prototype.unpipe=function(e){return this.emit("unpipe",e),this},n.prototype.format=function(e){throw new Error(["Warning: .format() is deprecated in Minilog v2! Use .pipe() instead. For example:","var Minilog = require('minilog');","Minilog"," .pipe(Minilog.backends.console.formatClean)"," .pipe(Minilog.backends.console);"].join("\n"))},n.mixin=function(e){var t,r=n.prototype;for(t in r)r.hasOwnProperty(t)&&(e.prototype[t]=r[t])},e.exports=n},2589:(e,t,r)=>{const n=r(3707);e.exports=class{constructor(){this.callbacks=[],this.nextResponseId=0}call(e,t){for(var r=arguments.length,n=new Array(r>2?r-2:0),o=2;o<r;o++)n[o-2]=arguments[o];return this.transferCall(e,t,null,...n)}transferCall(e,t,r){try{const{provider:s,isRemote:a}=this._getServiceProvider(e);if(s){for(var n=arguments.length,o=new Array(n>3?n-3:0),i=3;i<n;i++)o[i-3]=arguments[i];if(a)return this._remoteTransferCall(s,e,t,r,...o);const c=s[t].apply(s,o);return Promise.resolve(c)}return Promise.reject(new Error("Service not found: ".concat(e)))}catch(e){return Promise.reject(e)}}_isRemoteService(e){return this._getServiceProvider(e).isRemote}_remoteCall(e,t,r){for(var n=arguments.length,o=new Array(n>3?n-3:0),i=3;i<n;i++)o[i-3]=arguments[i];return this._remoteTransferCall(e,t,r,null,...o)}_remoteTransferCall(e,t,r,n){for(var o=arguments.length,i=new Array(o>4?o-4:0),s=4;s<o;s++)i[s-4]=arguments[s];return new Promise(((o,s)=>{const a=this._storeCallbacks(o,s);i.length>0&&"function"==typeof i[i.length-1].yield&&i.pop(),n?e.postMessage({service:t,method:r,responseId:a,args:i},n):e.postMessage({service:t,method:r,responseId:a,args:i})}))}_storeCallbacks(e,t){const r=this.nextResponseId++;return this.callbacks[r]=[e,t],r}_deliverResponse(e,t){try{const[r,n]=this.callbacks[e];delete this.callbacks[e],t.error?n(t.error):r(t.result)}catch(e){n.error("Dispatch callback failed: ".concat(JSON.stringify(e)))}}_onMessage(e,t){const r=t.data;let o;r.args=r.args||[],r.service?o="dispatch"===r.service?this._onDispatchMessage(e,r):this.call(r.service,r.method,...r.args):void 0===r.responseId?n.error("Dispatch caught malformed message from a worker: ".concat(JSON.stringify(t))):this._deliverResponse(r.responseId,r),o&&(void 0===r.responseId?n.error("Dispatch message missing required response ID: ".concat(JSON.stringify(t))):o.then((t=>e.postMessage({responseId:r.responseId,result:t})),(t=>e.postMessage({responseId:r.responseId,error:t}))))}_getServiceProvider(e){throw new Error("Could not get provider for ".concat(e,": _getServiceProvider not implemented"))}_onDispatchMessage(e,t){throw new Error("Unimplemented dispatch message handler cannot handle ".concat(t.method," method"))}}},2859:(e,t,r)=>{function n(){}r(2491).mixin(n),n.prototype.write=function(){console.log.apply(console,arguments)};var o=new n;r(6770).R;o.filterEnv=function(){return console.error("Minilog.backends.console.filterEnv is deprecated in Minilog v2."),r(4932)},o.formatters=["formatClean","formatColor","formatNpm","formatLearnboost","formatMinilog","formatWithStack","formatTime"],o.formatClean=new(r(9713)),o.formatColor=new(r(303)),o.formatNpm=new(r(6093)),o.formatLearnboost=new(r(3195)),o.formatMinilog=new(r(2391)),o.formatWithStack=new(r(1280)),o.formatTime=new(r(6139)),e.exports=o},3195:(e,t,r)=>{var n=r(2491),o=r(6770).i;function i(){}n.mixin(i),i.prototype.write=function(e,t,r){this.emit("item",(e?o(e+" ","grey"):"")+(t?o(t,{debug:"grey",info:"cyan",warn:"yellow",error:"red"}[t])+" ":"")+r.join(" "))},e.exports=i},3260:(e,t,r)=>{const n=r(2589),o=r(3707);e.exports=new class extends n{constructor(){super(),this._connectionPromise=new Promise((e=>{this._onConnect=e})),this.services={},this._onMessage=this._onMessage.bind(this,self),"undefined"!=typeof self&&(self.onmessage=this._onMessage)}get waitForConnection(){return this._connectionPromise}setService(e,t){return Object.prototype.hasOwnProperty.call(this.services,e)&&o.warn("Worker dispatch replacing existing service provider for ".concat(e)),this.services[e]=t,this.waitForConnection.then((()=>this._remoteCall(self,"dispatch","setService",e)))}_getServiceProvider(e){const t=this.services[e];return{provider:t||self,isRemote:!t}}_onDispatchMessage(e,t){let r;switch(t.method){case"handshake":r=this._onConnect();break;case"terminate":setTimeout((()=>self.close()),0),r=Promise.resolve();break;default:o.error("Worker dispatch received message for unknown method: ".concat(t.method))}return r}}},3707:(e,t,r)=>{const n=r(7397);n.enable(),e.exports=n("vm")},4373:e=>{function t(e){this.client=e.client,this.key=e.key}t.prototype.write=function(e){this.client.rpush(this.key,e)},t.prototype.end=function(){},t.prototype.clear=function(e){this.client.del(this.key,e)},e.exports=t},4932:(e,t,r)=>{var n=r(2491),o=r(8589),i=new n,s=Array.prototype.slice;(t=e.exports=function(e){var r=function(){return i.write(e,void 0,s.call(arguments)),r};return r.debug=function(){return i.write(e,"debug",s.call(arguments)),r},r.info=function(){return i.write(e,"info",s.call(arguments)),r},r.warn=function(){return i.write(e,"warn",s.call(arguments)),r},r.error=function(){return i.write(e,"error",s.call(arguments)),r},r.log=r.debug,r.suggest=t.suggest,r.format=i.format,r}).defaultBackend=t.defaultFormatter=null,t.pipe=function(e){return i.pipe(e)},t.end=t.unpipe=t.disable=function(e){return i.unpipe(e)},t.Transform=n,t.Filter=o,t.suggest=new o,t.enable=function(){return t.defaultFormatter?i.pipe(t.suggest).pipe(t.defaultFormatter).pipe(t.defaultBackend):i.pipe(t.suggest).pipe(t.defaultBackend)}},6093:(e,t,r)=>{function n(){}r(2491).mixin(n),n.prototype.write=function(e,t,r){var n={debug:"debug ",info:"info ",warn:"WARN ",error:"ERR! "};this.emit("item",(e?""+e+" ":"")+(t&&n[t]?n[t]:"")+r.join(" "))},e.exports=n},6139:(e,t,r)=>{var n=r(2491),o=r(6770).i,i=r(9023);function s(){}n.mixin(s),s.prototype.write=function(e,t,r){var n;this.emit("item",o(("0"+(n=new Date).getDate()).slice(-2)+"-"+("0"+(n.getMonth()+1)).slice(-2)+"-"+n.getFullYear()+" "+("0"+n.getHours()).slice(-2)+":"+("0"+n.getMinutes()).slice(-2)+":"+("0"+n.getSeconds()).slice(-2)+"."+("00"+n.getMilliseconds()).slice(-3)+" ","grey")+(e?o(e+" ","grey"):"")+(t?o(t,{debug:"blue",info:"cyan",warn:"yellow",error:"red"}[t])+" ":"")+r.map((function(e){return"string"==typeof e?e:i.inspect(e,null,3,!0)})).join(" "))},e.exports=s},6342:e=>{e.exports={ANGLE:"angle",BOOLEAN:"Boolean",COLOR:"color",NUMBER:"number",STRING:"string",MATRIX:"matrix",NOTE:"note",IMAGE:"image"}},6770:(e,t)=>{var r={bold:["",""],italic:["",""],underline:["",""],inverse:["",""],white:["",""],grey:["",""],black:["",""],blue:["",""],cyan:["",""],green:["",""],magenta:["",""],red:["",""],yellow:["",""]};t.R={debug:1,info:2,warn:3,error:4},t.i=function(e,t){return r[t][0]+e+r[t][1]}},7397:(e,t,r)=>{e.exports=r(4932);var n=r(2859);"undefined"!=typeof window&&window.process&&"renderer"===window.process.type&&(n=r(9925).minilog),e.exports.Stringifier=r(9403);var o=e.exports.pipe;e.exports.pipe=function(t){return t instanceof r(2203)?o.call(e.exports,new e.exports.Stringifier).pipe(t):o.call(e.exports,t)},e.exports.defaultBackend=n,e.exports.defaultFormatter=n.formatMinilog,e.exports.backends={redis:r(4373),nodeConsole:n,console:n}},8589:(e,t,r)=>{var n=r(2491),o={debug:1,info:2,warn:3,error:4};function i(){this.enabled=!0,this.defaultResult=!0,this.clear()}function s(e,t){return e.n.test?e.n.test(t):e.n==t}n.mixin(i),i.prototype.allow=function(e,t){return this._white.push({n:e,l:o[t]}),this},i.prototype.deny=function(e,t){return this._black.push({n:e,l:o[t]}),this},i.prototype.clear=function(){return this._white=[],this._black=[],this},i.prototype.test=function(e,t){var r,n=Math.max(this._white.length,this._black.length);for(r=0;r<n;r++){if(this._white[r]&&s(this._white[r],e)&&o[t]>=this._white[r].l)return!0;if(this._black[r]&&s(this._black[r],e)&&o[t]<=this._black[r].l)return!1}return this.defaultResult},i.prototype.write=function(e,t,r){if(!this.enabled||this.test(e,t))return this.emit("item",e,t,r)},e.exports=i},8933:(e,t,r)=>{var n=r(2491),o=r(2216),i={debug:["gray"],info:["purple"],warn:["yellow",!0],error:["red",!0]},s=new n;s.write=function(e,t,r){var n=console.log;"debug"!=t&&console[t]&&(n=console[t]);var s=0;if("info"!=t){for(;s<r.length&&"string"==typeof r[s];s++);n.apply(console,["%c"+e+" "+r.slice(0,s).join(" "),o.apply(o,i[t])].concat(r.slice(s)))}else n.apply(console,["%c"+e,o.apply(o,i[t])].concat(r))},s.pipe=function(){},e.exports=s},9023:e=>{"use strict";e.exports=require("util")},9274:e=>{e.exports={BOOLEAN:"Boolean",BUTTON:"button",COMMAND:"command",CONDITIONAL:"conditional",EVENT:"event",HAT:"hat",LOOP:"loop",REPORTER:"reporter"}},9403:(e,t,r)=>{function n(){}r(2491).mixin(n),n.prototype.write=function(e,t,r){var n=[];e&&n.push(e),t&&n.push(t),n=n.concat(r);for(var o=0;o<n.length;o++)if(n[o]&&"object"==typeof n[o])if(n[o].constructor&&n[o].constructor.isBuffer)n[o]=n[o].toString();else try{n[o]=JSON.stringify(n[o])}catch(e){}else n[o]=n[o];this.emit("item",n.join(" ")+"\n")},e.exports=n},9432:e=>{e.exports={SPRITE:"sprite",STAGE:"stage"}},9713:(e,t,r)=>{function n(){}r(2491).mixin(n),n.prototype.write=function(e,t,r){this.emit("item",(e?e+" ":"")+(t?t+" ":"")+r.join(" "))},e.exports=n},9925:(e,t,r)=>{var n=r(2491),o=/\n+$/,i=new n;i.write=function(e,t,r){var n=r.length-1;if("undefined"!=typeof console&&console.log){if(console.log.apply)return console.log.apply(console,[e,t].concat(r));if(JSON&&JSON.stringify){r[n]&&"string"==typeof r[n]&&(r[n]=r[n].replace(o,""));try{for(n=0;n<r.length;n++)r[n]=JSON.stringify(r[n])}catch(e){}console.log(r.join(" "))}}},i.formatters=["color","minilog"],i.color=r(329),i.minilog=r(8933),e.exports=i}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}const n=r(6342),o=r(9274),i=r(3260),s=r(9432);global.Scratch=global.Scratch||{},global.Scratch.ArgumentType=n,global.Scratch.BlockType=o,global.Scratch.TargetType=s;const a=new class{constructor(){this.nextExtensionId=0,this.initialRegistrations=[],i.waitForConnection.then((()=>{i.call("extensions","allocateWorker").then((e=>{const[t,r]=e;this.workerId=t;try{importScripts(r);const e=this.initialRegistrations;this.initialRegistrations=null,Promise.all(e).then((()=>i.call("extensions","onWorkerInit",t)))}catch(e){i.call("extensions","onWorkerInit",t,e)}}))})),this.extensions=[]}register(e){const t=this.nextExtensionId++;this.extensions.push(e);const r="extension.".concat(this.workerId,".").concat(t),n=i.setService(r,e).then((()=>i.call("extensions","registerExtensionService",r)));return this.initialRegistrations&&this.initialRegistrations.push(n),n}};return global.Scratch.extensions={register:a.register.bind(a)},{}})()));
2
+ //# sourceMappingURL=extension-worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extension-worker.js","mappings":"AAAA","sources":["webpack://VirtualMachine/webpack/universalModuleDefinition"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"VirtualMachine\"] = factory();\n\telse\n\t\troot[\"VirtualMachine\"] = factory();\n})(global, () => {\nreturn "],"names":[],"sourceRoot":""}