Merge remote-tracking branch 'LLK/develop' into develop
# Conflicts: # src/engine/runtime.js
This commit is contained in:
commit
d121a4c6fa
22 files changed
+3155
-3044
No files matched your search
@@ -11,6 +11,7 @@ npm install https://github.com/LLK/scratch-vm.git
|
||||
```
|
||||
|
||||
## Setup
|
||||
For an extended setup example, check out the /playground directory, which includes a fully running VM instance.
|
||||
```js
|
||||
var VirtualMachine = require('scratch-vm');
|
||||
var vm = new VirtualMachine();
|
||||
@@ -23,6 +24,16 @@ flyoutWorkspace.addChangeListener(vm.flyoutBlockListener);
|
||||
// Run threads
|
||||
vm.runtime.start();
|
||||
```
|
||||
## Development Server and Playground
|
||||
For convenience, we've included a development server with the VM. This is useful because the VM can take advantage of executing in a WebWorker, which is not permitted in a local file. To start the server, run:
|
||||
|
||||
```bash
|
||||
make serve
|
||||
```
|
||||
and go to [http://localhost:8080/](http://localhost:8080/) - you will be redirected to the playground, which demonstrates various tools and internal state.
|
||||
|
||||

|
||||
|
||||
|
||||
## Standalone Build
|
||||
```bash
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
"json-loader": "0.5.4",
|
||||
"scratch-blocks": "git+https://git@github.com/LLK/scratch-blocks.git",
|
||||
"scratch-render": "git+https://git@github.com/LLK/scratch-render.git",
|
||||
"stats.js": "0.16.0",
|
||||
"tap": "5.7.1",
|
||||
"webpack": "1.13.0",
|
||||
"webpack-dev-server": "1.14.1"
|
||||
|
||||
@@ -796,7 +796,8 @@
|
||||
</category>
|
||||
<category name="More Blocks" colour="#FF6680"></category>
|
||||
</xml>
|
||||
|
||||
<!-- FPS counter -->
|
||||
<script src="../node_modules/stats.js/build/stats.min.js"></script>
|
||||
<!-- Syntax highlighter -->
|
||||
<script src="../node_modules/highlightjs/highlight.pack.min.js"></script>
|
||||
<!-- Scratch Blocks -->
|
||||
|
||||
@@ -29,6 +29,12 @@ window.onload = function() {
|
||||
});
|
||||
window.workspace = workspace;
|
||||
|
||||
// FPS counter.
|
||||
var stats = new window.Stats();
|
||||
document.getElementById('tab-renderexplorer').appendChild(stats.dom);
|
||||
stats.dom.style.position = 'relative';
|
||||
stats.begin();
|
||||
|
||||
// Block events.
|
||||
// @todo: Re-enable flyout listening after fixing GH-69.
|
||||
workspace.addChangeListener(vm.blockListener);
|
||||
@@ -82,11 +88,31 @@ window.onload = function() {
|
||||
workspace.reportValue(data.id, data.value);
|
||||
});
|
||||
|
||||
// Feed mouse events as VM I/O events.
|
||||
document.addEventListener('mousemove', function (e) {
|
||||
var rect = canvas.getBoundingClientRect();
|
||||
var coordinates = {
|
||||
x: e.clientX - rect.left - rect.width / 2,
|
||||
y: e.clientY - rect.top - rect.height / 2
|
||||
};
|
||||
window.vm.postIOData('mouse', coordinates);
|
||||
});
|
||||
canvas.addEventListener('mousedown', function (e) {
|
||||
window.vm.postIOData('mouse', {isDown: true});
|
||||
e.preventDefault();
|
||||
});
|
||||
canvas.addEventListener('mouseup', function (e) {
|
||||
window.vm.postIOData('mouse', {isDown: false});
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
// Run threads
|
||||
vm.start();
|
||||
|
||||
// Inform VM of animation frames.
|
||||
var animate = function() {
|
||||
stats.end();
|
||||
stats.begin();
|
||||
window.vm.animationFrame();
|
||||
requestAnimationFrame(animate);
|
||||
};
|
||||
|
||||
@@ -30,15 +30,15 @@ Scratch3ControlBlocks.prototype.repeat = function(args, util) {
|
||||
util.stackFrame.loopCounter = parseInt(args.TIMES);
|
||||
}
|
||||
// Only execute once per frame.
|
||||
// When the substack finishes, `repeat` will be executed again and
|
||||
// When the branch finishes, `repeat` will be executed again and
|
||||
// the second branch will be taken, yielding for the rest of the frame.
|
||||
if (!util.stackFrame.executedInFrame) {
|
||||
util.stackFrame.executedInFrame = true;
|
||||
// Decrease counter
|
||||
util.stackFrame.loopCounter--;
|
||||
// If we still have some left, start the substack
|
||||
// If we still have some left, start the branch.
|
||||
if (util.stackFrame.loopCounter >= 0) {
|
||||
util.startSubstack();
|
||||
util.startBranch();
|
||||
}
|
||||
} else {
|
||||
util.stackFrame.executedInFrame = false;
|
||||
@@ -48,13 +48,13 @@ Scratch3ControlBlocks.prototype.repeat = function(args, util) {
|
||||
|
||||
Scratch3ControlBlocks.prototype.repeatUntil = function(args, util) {
|
||||
// Only execute once per frame.
|
||||
// When the substack finishes, `repeat` will be executed again and
|
||||
// When the branch finishes, `repeat` will be executed again and
|
||||
// the second branch will be taken, yielding for the rest of the frame.
|
||||
if (!util.stackFrame.executedInFrame) {
|
||||
util.stackFrame.executedInFrame = true;
|
||||
// If the condition is true, start the substack.
|
||||
// If the condition is true, start the branch.
|
||||
if (!args.CONDITION) {
|
||||
util.startSubstack();
|
||||
util.startBranch();
|
||||
}
|
||||
} else {
|
||||
util.stackFrame.executedInFrame = false;
|
||||
@@ -64,11 +64,11 @@ Scratch3ControlBlocks.prototype.repeatUntil = function(args, util) {
|
||||
|
||||
Scratch3ControlBlocks.prototype.forever = function(args, util) {
|
||||
// Only execute once per frame.
|
||||
// When the substack finishes, `forever` will be executed again and
|
||||
// When the branch finishes, `forever` will be executed again and
|
||||
// the second branch will be taken, yielding for the rest of the frame.
|
||||
if (!util.stackFrame.executedInFrame) {
|
||||
util.stackFrame.executedInFrame = true;
|
||||
util.startSubstack();
|
||||
util.startBranch();
|
||||
} else {
|
||||
util.stackFrame.executedInFrame = false;
|
||||
util.yieldFrame();
|
||||
@@ -85,24 +85,24 @@ Scratch3ControlBlocks.prototype.wait = function(args) {
|
||||
|
||||
Scratch3ControlBlocks.prototype.if = function(args, util) {
|
||||
// Only execute one time. `if` will be returned to
|
||||
// when the substack finishes, but it shouldn't execute again.
|
||||
// when the branch finishes, but it shouldn't execute again.
|
||||
if (util.stackFrame.executedInFrame === undefined) {
|
||||
util.stackFrame.executedInFrame = true;
|
||||
if (args.CONDITION) {
|
||||
util.startSubstack();
|
||||
util.startBranch();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Scratch3ControlBlocks.prototype.ifElse = function(args, util) {
|
||||
// Only execute one time. `ifElse` will be returned to
|
||||
// when the substack finishes, but it shouldn't execute again.
|
||||
// when the branch finishes, but it shouldn't execute again.
|
||||
if (util.stackFrame.executedInFrame === undefined) {
|
||||
util.stackFrame.executedInFrame = true;
|
||||
if (args.CONDITION) {
|
||||
util.startSubstack(1);
|
||||
util.startBranch(1);
|
||||
} else {
|
||||
util.startSubstack(2);
|
||||
util.startBranch(2);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
var Cast = require('../util/cast.js');
|
||||
|
||||
function Scratch3OperatorsBlocks(runtime) {
|
||||
/**
|
||||
* The runtime instantiating this block package.
|
||||
@@ -27,61 +29,63 @@ Scratch3OperatorsBlocks.prototype.getPrimitives = function() {
|
||||
'operator_and': this.and,
|
||||
'operator_or': this.or,
|
||||
'operator_not': this.not,
|
||||
'operator_random': this.random
|
||||
'operator_random': this.random,
|
||||
'operator_join': this.join,
|
||||
'operator_letter_of': this.letterOf,
|
||||
'operator_length': this.length,
|
||||
'operator_mod': this.mod,
|
||||
'operator_round': this.round,
|
||||
'operator_mathop_menu': this.mathopMenu,
|
||||
'operator_mathop': this.mathop
|
||||
};
|
||||
};
|
||||
|
||||
Scratch3OperatorsBlocks.prototype.number = function (args) {
|
||||
var num = Number(args.NUM);
|
||||
if (num !== num) {
|
||||
// NaN
|
||||
return 0;
|
||||
}
|
||||
return num;
|
||||
return Cast.toNumber(args.NUM);
|
||||
};
|
||||
|
||||
Scratch3OperatorsBlocks.prototype.text = function (args) {
|
||||
return String(args.TEXT);
|
||||
return Cast.toString(args.TEXT);
|
||||
};
|
||||
|
||||
Scratch3OperatorsBlocks.prototype.add = function (args) {
|
||||
return args.NUM1 + args.NUM2;
|
||||
return Cast.toNumber(args.NUM1) + Cast.toNumber(args.NUM2);
|
||||
};
|
||||
|
||||
Scratch3OperatorsBlocks.prototype.subtract = function (args) {
|
||||
return args.NUM1 - args.NUM2;
|
||||
return Cast.toNumber(args.NUM1) - Cast.toNumber(args.NUM2);
|
||||
};
|
||||
|
||||
Scratch3OperatorsBlocks.prototype.multiply = function (args) {
|
||||
return args.NUM1 * args.NUM2;
|
||||
return Cast.toNumber(args.NUM1) * Cast.toNumber(args.NUM2);
|
||||
};
|
||||
|
||||
Scratch3OperatorsBlocks.prototype.divide = function (args) {
|
||||
return args.NUM1 / args.NUM2;
|
||||
return Cast.toNumber(args.NUM1) / Cast.toNumber(args.NUM2);
|
||||
};
|
||||
|
||||
Scratch3OperatorsBlocks.prototype.lt = function (args) {
|
||||
return Boolean(args.OPERAND1 < args.OPERAND2);
|
||||
return Cast.compare(args.OPERAND1, args.OPERAND2) < 0;
|
||||
};
|
||||
|
||||
Scratch3OperatorsBlocks.prototype.equals = function (args) {
|
||||
return Boolean(args.OPERAND1 == args.OPERAND2);
|
||||
return Cast.compare(args.OPERAND1, args.OPERAND2) == 0;
|
||||
};
|
||||
|
||||
Scratch3OperatorsBlocks.prototype.gt = function (args) {
|
||||
return Boolean(args.OPERAND1 > args.OPERAND2);
|
||||
return Cast.compare(args.OPERAND1, args.OPERAND2) > 0;
|
||||
};
|
||||
|
||||
Scratch3OperatorsBlocks.prototype.and = function (args) {
|
||||
return Boolean(args.OPERAND1 && args.OPERAND2);
|
||||
return Cast.toBoolean(args.OPERAND1 && args.OPERAND2);
|
||||
};
|
||||
|
||||
Scratch3OperatorsBlocks.prototype.or = function (args) {
|
||||
return Boolean(args.OPERAND1 || args.OPERAND2);
|
||||
return Cast.toBoolean(args.OPERAND1 || args.OPERAND2);
|
||||
};
|
||||
|
||||
Scratch3OperatorsBlocks.prototype.not = function (args) {
|
||||
return Boolean(!args.OPERAND);
|
||||
return Cast.toBoolean(!args.OPERAND);
|
||||
};
|
||||
|
||||
Scratch3OperatorsBlocks.prototype.random = function (args) {
|
||||
@@ -97,4 +101,61 @@ Scratch3OperatorsBlocks.prototype.random = function (args) {
|
||||
return (Math.random() * (high - low)) + low;
|
||||
};
|
||||
|
||||
Scratch3OperatorsBlocks.prototype.join = function (args) {
|
||||
return Cast.toString(args.STRING1) + Cast.toString(args.STRING2);
|
||||
};
|
||||
|
||||
Scratch3OperatorsBlocks.prototype.letterOf = function (args) {
|
||||
var index = Cast.toNumber(args.LETTER) - 1;
|
||||
var str = Cast.toString(args.STRING);
|
||||
// Out of bounds?
|
||||
if (index < 0 || index >= str.length) {
|
||||
return '';
|
||||
}
|
||||
return str.charAt(index);
|
||||
};
|
||||
|
||||
Scratch3OperatorsBlocks.prototype.length = function (args) {
|
||||
return Cast.toString(args.STRING).length;
|
||||
};
|
||||
|
||||
Scratch3OperatorsBlocks.prototype.mod = function (args) {
|
||||
var n = Cast.toNumber(args.NUM1);
|
||||
var modulus = Cast.toNumber(args.NUM2);
|
||||
var result = n % modulus;
|
||||
// Scratch mod is kept positive.
|
||||
if (result / modulus < 0) result += modulus;
|
||||
return result;
|
||||
};
|
||||
|
||||
Scratch3OperatorsBlocks.prototype.round = function (args) {
|
||||
return Math.round(Cast.toNumber(args.NUM));
|
||||
};
|
||||
|
||||
Scratch3OperatorsBlocks.prototype.mathopMenu = function (args) {
|
||||
return args.OPERATOR;
|
||||
};
|
||||
|
||||
Scratch3OperatorsBlocks.prototype.mathop = function (args) {
|
||||
var operator = Cast.toString(args.OPERATOR).toLowerCase();
|
||||
var n = Cast.toNumber(args.NUM);
|
||||
switch (operator) {
|
||||
case 'abs': return Math.abs(n);
|
||||
case 'floor': return Math.floor(n);
|
||||
case 'ceiling': return Math.ceil(n);
|
||||
case 'sqrt': return Math.sqrt(n);
|
||||
case 'sin': return Math.sin((Math.PI * n) / 180);
|
||||
case 'cos': return Math.cos((Math.PI * n) / 180);
|
||||
case 'tan': return Math.tan((Math.PI * n) / 180);
|
||||
case 'asin': return (Math.asin(n) * 180) / Math.PI;
|
||||
case 'acos': return (Math.acos(n) * 180) / Math.PI;
|
||||
case 'atan': return (Math.atan(n) * 180) / Math.PI;
|
||||
case 'ln': return Math.log(n);
|
||||
case 'log': return Math.log(n) / Math.LN10;
|
||||
case 'e ^': return Math.exp(n);
|
||||
case '10 ^': return Math.pow(10, n);
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
module.exports = Scratch3OperatorsBlocks;
|
||||
@@ -0,0 +1,43 @@
|
||||
function Scratch3SensingBlocks(runtime) {
|
||||
/**
|
||||
* The runtime instantiating this block package.
|
||||
* @type {Runtime}
|
||||
*/
|
||||
this.runtime = runtime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the block primitives implemented by this package.
|
||||
* @return {Object.<string, Function>} Mapping of opcode to Function.
|
||||
*/
|
||||
Scratch3SensingBlocks.prototype.getPrimitives = function() {
|
||||
return {
|
||||
'sensing_timer': this.getTimer,
|
||||
'sensing_resettimer': this.resetTimer,
|
||||
'sensing_mousex': this.getMouseX,
|
||||
'sensing_mousey': this.getMouseY,
|
||||
'sensing_mousedown': this.getMouseDown
|
||||
};
|
||||
};
|
||||
|
||||
Scratch3SensingBlocks.prototype.getTimer = function (args, util) {
|
||||
return util.ioQuery('clock', 'projectTimer');
|
||||
};
|
||||
|
||||
Scratch3SensingBlocks.prototype.resetTimer = function (args, util) {
|
||||
util.ioQuery('clock', 'resetProjectTimer');
|
||||
};
|
||||
|
||||
Scratch3SensingBlocks.prototype.getMouseX = function (args, util) {
|
||||
return util.ioQuery('mouse', 'getX');
|
||||
};
|
||||
|
||||
Scratch3SensingBlocks.prototype.getMouseY = function (args, util) {
|
||||
return util.ioQuery('mouse', 'getY');
|
||||
};
|
||||
|
||||
Scratch3SensingBlocks.prototype.getMouseDown = function (args, util) {
|
||||
return util.ioQuery('mouse', 'getIsDown');
|
||||
};
|
||||
|
||||
module.exports = Scratch3SensingBlocks;
|
||||
+50
-50
@@ -15,19 +15,19 @@ function Blocks () {
|
||||
this._blocks = {};
|
||||
|
||||
/**
|
||||
* All stacks in the workspace.
|
||||
* A list of block IDs that represent stacks (first block in stack).
|
||||
* All top-level scripts in the workspace.
|
||||
* A list of block IDs that represent scripts (i.e., first block in script).
|
||||
* @type {Array.<String>}
|
||||
*/
|
||||
this._stacks = [];
|
||||
this._scripts = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Blockly inputs that represent statements/substacks
|
||||
* Blockly inputs that represent statements/branch.
|
||||
* are prefixed with this string.
|
||||
* @const{string}
|
||||
*/
|
||||
Blocks.SUBSTACK_INPUT_PREFIX = 'SUBSTACK';
|
||||
Blocks.BRANCH_INPUT_PREFIX = 'SUBSTACK';
|
||||
|
||||
/**
|
||||
* Provide an object with metadata for the requested block ID.
|
||||
@@ -39,11 +39,11 @@ Blocks.prototype.getBlock = function (blockId) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Get all known top-level blocks that start stacks.
|
||||
* Get all known top-level blocks that start scripts.
|
||||
* @return {Array.<string>} List of block IDs.
|
||||
*/
|
||||
Blocks.prototype.getStacks = function () {
|
||||
return this._stacks;
|
||||
Blocks.prototype.getScripts = function () {
|
||||
return this._scripts;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -57,19 +57,19 @@ Blocks.prototype.getNextBlock = function (id) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the substack for a particular C-shaped block
|
||||
* @param {?string} id ID for block to get the substack for
|
||||
* @param {?number} substackNum Which substack to select (e.g. for if-else)
|
||||
* @return {?string} ID of block in the substack
|
||||
* Get the branch for a particular C-shaped block.
|
||||
* @param {?string} id ID for block to get the branch for.
|
||||
* @param {?number} branchNum Which branch to select (e.g. for if-else).
|
||||
* @return {?string} ID of block in the branch.
|
||||
*/
|
||||
Blocks.prototype.getSubstack = function (id, substackNum) {
|
||||
Blocks.prototype.getBranch = function (id, branchNum) {
|
||||
var block = this._blocks[id];
|
||||
if (typeof block === 'undefined') return null;
|
||||
if (!substackNum) substackNum = 1;
|
||||
if (!branchNum) branchNum = 1;
|
||||
|
||||
var inputName = Blocks.SUBSTACK_INPUT_PREFIX;
|
||||
if (substackNum > 1) {
|
||||
inputName += substackNum;
|
||||
var inputName = Blocks.BRANCH_INPUT_PREFIX;
|
||||
if (branchNum > 1) {
|
||||
inputName += branchNum;
|
||||
}
|
||||
|
||||
// Empty C-block?
|
||||
@@ -98,17 +98,17 @@ Blocks.prototype.getFields = function (id) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Get all non-substack inputs for a block.
|
||||
* Get all non-branch inputs for a block.
|
||||
* @param {?string} id ID of block to query.
|
||||
* @return {!Object} All non-substack inputs and their associated blocks.
|
||||
* @return {!Object} All non-branch inputs and their associated blocks.
|
||||
*/
|
||||
Blocks.prototype.getInputs = function (id) {
|
||||
if (typeof this._blocks[id] === 'undefined') return null;
|
||||
var inputs = {};
|
||||
for (var input in this._blocks[id].inputs) {
|
||||
// Ignore blocks prefixed with substack prefix.
|
||||
if (input.substring(0, Blocks.SUBSTACK_INPUT_PREFIX.length)
|
||||
!= Blocks.SUBSTACK_INPUT_PREFIX) {
|
||||
// Ignore blocks prefixed with branch prefix.
|
||||
if (input.substring(0, Blocks.BRANCH_INPUT_PREFIX.length)
|
||||
!= Blocks.BRANCH_INPUT_PREFIX) {
|
||||
inputs[input] = this._blocks[id].inputs[input];
|
||||
}
|
||||
}
|
||||
@@ -136,10 +136,10 @@ Blocks.prototype.generateBlockListener = function (isFlyout, opt_runtime) {
|
||||
if (typeof e !== 'object') return;
|
||||
if (typeof e.blockId !== 'string') return;
|
||||
|
||||
// UI event: clicked stacks toggle in the runtime.
|
||||
// UI event: clicked scripts toggle in the runtime.
|
||||
if (e.element === 'stackclick') {
|
||||
if (opt_runtime) {
|
||||
opt_runtime.toggleStack(e.blockId);
|
||||
opt_runtime.toggleScript(e.blockId);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -182,7 +182,7 @@ Blocks.prototype.generateBlockListener = function (isFlyout, opt_runtime) {
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Block management: create blocks and stacks from a `create` event
|
||||
* Block management: create blocks and scripts from a `create` event
|
||||
* @param {!Object} block Blockly create event to be processed
|
||||
* @param {boolean} opt_isFlyoutBlock Whether the block is in the flyout.
|
||||
*/
|
||||
@@ -190,12 +190,12 @@ Blocks.prototype.createBlock = function (block, opt_isFlyoutBlock) {
|
||||
// Create new block
|
||||
this._blocks[block.id] = block;
|
||||
|
||||
// Push block id to stacks array.
|
||||
// Push block id to scripts array.
|
||||
// Blocks are added as a top-level stack if they are marked as a top-block
|
||||
// (if they were top-level XML in the event) and if they are not
|
||||
// flyout blocks.
|
||||
if (!opt_isFlyoutBlock && block.topLevel) {
|
||||
this._addStack(block.id);
|
||||
this._addScript(block.id);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -233,10 +233,10 @@ Blocks.prototype.moveBlock = function (e) {
|
||||
|
||||
// Has the block become a top-level block?
|
||||
if (e.newParent === undefined) {
|
||||
this._addStack(e.id);
|
||||
this._addScript(e.id);
|
||||
} else {
|
||||
// Remove stack, if one exists.
|
||||
this._deleteStack(e.id);
|
||||
// Remove script, if one exists.
|
||||
this._deleteScript(e.id);
|
||||
// Otherwise, try to connect it in its new place.
|
||||
if (e.newInput !== undefined) {
|
||||
// Moved to the new parent's input.
|
||||
@@ -252,11 +252,11 @@ Blocks.prototype.moveBlock = function (e) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Block management: delete blocks and their associated stacks
|
||||
* @param {!Object} e Blockly delete event to be processed
|
||||
* Block management: delete blocks and their associated scripts.
|
||||
* @param {!Object} e Blockly delete event to be processed.
|
||||
*/
|
||||
Blocks.prototype.deleteBlock = function (e) {
|
||||
// @todo In runtime, stop threads running on this stack
|
||||
// @todo In runtime, stop threads running on this script.
|
||||
|
||||
// Get block
|
||||
var block = this._blocks[e.id];
|
||||
@@ -266,7 +266,7 @@ Blocks.prototype.deleteBlock = function (e) {
|
||||
this.deleteBlock({id: block.next});
|
||||
}
|
||||
|
||||
// Delete inputs (including substacks)
|
||||
// Delete inputs (including branches)
|
||||
for (var input in block.inputs) {
|
||||
// If it's null, the block in this input moved away.
|
||||
if (block.inputs[input].block !== null) {
|
||||
@@ -274,36 +274,36 @@ Blocks.prototype.deleteBlock = function (e) {
|
||||
}
|
||||
}
|
||||
|
||||
// Delete stack
|
||||
this._deleteStack(e.id);
|
||||
// Delete any script starting with this block.
|
||||
this._deleteScript(e.id);
|
||||
|
||||
// Delete block
|
||||
// Delete block itself.
|
||||
delete this._blocks[e.id];
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Helper to add a stack to `this._stacks`
|
||||
* @param {?string} id ID of block that starts the stack
|
||||
* Helper to add a stack to `this._scripts`.
|
||||
* @param {?string} topBlockId ID of block that starts the script.
|
||||
*/
|
||||
Blocks.prototype._addStack = function (id) {
|
||||
var i = this._stacks.indexOf(id);
|
||||
if (i > -1) return; // Already in stacks.
|
||||
this._stacks.push(id);
|
||||
Blocks.prototype._addScript = function (topBlockId) {
|
||||
var i = this._scripts.indexOf(topBlockId);
|
||||
if (i > -1) return; // Already in scripts.
|
||||
this._scripts.push(topBlockId);
|
||||
// Update `topLevel` property on the top block.
|
||||
this._blocks[id].topLevel = true;
|
||||
this._blocks[topBlockId].topLevel = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper to remove a stack from `this._stacks`
|
||||
* @param {?string} id ID of block that starts the stack
|
||||
* Helper to remove a script from `this._scripts`.
|
||||
* @param {?string} topBlockId ID of block that starts the script.
|
||||
*/
|
||||
Blocks.prototype._deleteStack = function (id) {
|
||||
var i = this._stacks.indexOf(id);
|
||||
if (i > -1) this._stacks.splice(i, 1);
|
||||
Blocks.prototype._deleteScript = function (topBlockId) {
|
||||
var i = this._scripts.indexOf(topBlockId);
|
||||
if (i > -1) this._scripts.splice(i, 1);
|
||||
// Update `topLevel` property on the top block.
|
||||
if (this._blocks[id]) this._blocks[id].topLevel = false;
|
||||
if (this._blocks[topBlockId]) this._blocks[topBlockId].topLevel = false;
|
||||
};
|
||||
|
||||
module.exports = Blocks;
|
||||
+11
-4
@@ -58,7 +58,7 @@ var execute = function (sequencer, thread) {
|
||||
// If we've gotten this far, all of the input blocks are evaluated,
|
||||
// and `argValues` is fully populated. So, execute the block primitive.
|
||||
// First, clear `currentStackFrame.reported`, so any subsequent execution
|
||||
// (e.g., on return from a substack) gets fresh inputs.
|
||||
// (e.g., on return from a branch) gets fresh inputs.
|
||||
currentStackFrame.reported = {};
|
||||
|
||||
var primitiveReportedValue = null;
|
||||
@@ -74,10 +74,17 @@ var execute = function (sequencer, thread) {
|
||||
sequencer.proceedThread(thread);
|
||||
},
|
||||
stackFrame: currentStackFrame.executionContext,
|
||||
startSubstack: function (substackNum) {
|
||||
sequencer.stepToSubstack(thread, substackNum);
|
||||
startBranch: function (branchNum) {
|
||||
sequencer.stepToBranch(thread, branchNum);
|
||||
},
|
||||
target: target
|
||||
target: target,
|
||||
ioQuery: function (device, func, args) {
|
||||
// Find the I/O device and execute the query/function call.
|
||||
if (runtime.ioDevices[device] && runtime.ioDevices[device][func]) {
|
||||
var devObject = runtime.ioDevices[device];
|
||||
return devObject[func].call(devObject, args);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Deal with any reported value.
|
||||
|
||||
+25
-15
@@ -3,17 +3,22 @@ var Sequencer = require('./sequencer');
|
||||
var Thread = require('./thread');
|
||||
var util = require('util');
|
||||
|
||||
// Virtual I/O devices.
|
||||
var Clock = require('../io/clock');
|
||||
var Mouse = require('../io/mouse');
|
||||
|
||||
var defaultBlockPackages = {
|
||||
'scratch3_control': require('../blocks/scratch3_control'),
|
||||
'scratch3_event': require('../blocks/scratch3_event'),
|
||||
'scratch3_looks': require('../blocks/scratch3_looks'),
|
||||
'scratch3_motion': require('../blocks/scratch3_motion'),
|
||||
'scratch3_operators': require('../blocks/scratch3_operators'),
|
||||
'scratch3_sound': require('../blocks/scratch3_sound')
|
||||
'scratch3_sound': require('../blocks/scratch3_sound'),
|
||||
'scratch3_sensing': require('../blocks/scratch3_sensing')
|
||||
};
|
||||
|
||||
/**
|
||||
* Manages targets, stacks, and the sequencer.
|
||||
* Manages targets, scripts, and the sequencer.
|
||||
* @param {!Array.<Target>} targets List of targets for this runtime.
|
||||
*/
|
||||
function Runtime (targets) {
|
||||
@@ -44,6 +49,11 @@ function Runtime (targets) {
|
||||
*/
|
||||
this._primitives = {};
|
||||
this._registerBlockPackages();
|
||||
|
||||
this.ioDevices = {
|
||||
'clock': new Clock(),
|
||||
'mouse': new Mouse()
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,39 +157,39 @@ Runtime.prototype._removeThread = function (thread) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Toggle a stack
|
||||
* @param {!string} stackId ID of block that starts the stack
|
||||
* Toggle a script.
|
||||
* @param {!string} topBlockId ID of block that starts the script.
|
||||
*/
|
||||
Runtime.prototype.toggleStack = function (stackId) {
|
||||
// Remove any existing thread
|
||||
Runtime.prototype.toggleScript = function (topBlockId) {
|
||||
// Remove any existing thread.
|
||||
for (var i = 0; i < this.threads.length; i++) {
|
||||
if (this.threads[i].topBlock == stackId) {
|
||||
if (this.threads[i].topBlock == topBlockId) {
|
||||
this._removeThread(this.threads[i]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Otherwise add it
|
||||
this._pushThread(stackId);
|
||||
// Otherwise add it.
|
||||
this._pushThread(topBlockId);
|
||||
};
|
||||
|
||||
/**
|
||||
* Green flag, which stops currently running threads
|
||||
* and adds all top-level stacks that start with the green flag
|
||||
* and adds all top-level scripts that start with the green flag
|
||||
*/
|
||||
Runtime.prototype.greenFlag = function () {
|
||||
// Remove all existing threads
|
||||
for (var i = 0; i < this.threads.length; i++) {
|
||||
this._removeThread(this.threads[i]);
|
||||
}
|
||||
// Add all top stacks with green flag
|
||||
// Add all top scripts with green flag
|
||||
for (var t = 0; t < this.targets.length; t++) {
|
||||
var target = this.targets[t];
|
||||
var stacks = target.blocks.getStacks();
|
||||
for (var j = 0; j < stacks.length; j++) {
|
||||
var topBlock = stacks[j];
|
||||
var scripts = target.blocks.getScripts();
|
||||
for (var j = 0; j < scripts.length; j++) {
|
||||
var topBlock = scripts[j];
|
||||
if (target.blocks.getBlock(topBlock).opcode ===
|
||||
'event_whenflagclicked') {
|
||||
this._pushThread(stacks[j]);
|
||||
this._pushThread(scripts[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-12
@@ -85,7 +85,7 @@ Sequencer.prototype.stepThreads = function (threads) {
|
||||
Sequencer.prototype.startThread = function (thread) {
|
||||
var currentBlockId = thread.peekStack();
|
||||
if (!currentBlockId) {
|
||||
// A "null block" - empty substack.
|
||||
// A "null block" - empty branch.
|
||||
// Yield for the frame.
|
||||
thread.popStack();
|
||||
thread.setStatus(Thread.STATUS_YIELD_FRAME);
|
||||
@@ -102,22 +102,22 @@ Sequencer.prototype.startThread = function (thread) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Step a thread into a block's substack.
|
||||
* @param {!Thread} thread Thread object to step to substack.
|
||||
* @param {Number} substackNum Which substack to step to (i.e., 1, 2).
|
||||
* Step a thread into a block's branch.
|
||||
* @param {!Thread} thread Thread object to step to branch.
|
||||
* @param {Number} branchNum Which branch to step to (i.e., 1, 2).
|
||||
*/
|
||||
Sequencer.prototype.stepToSubstack = function (thread, substackNum) {
|
||||
if (!substackNum) {
|
||||
substackNum = 1;
|
||||
Sequencer.prototype.stepToBranch = function (thread, branchNum) {
|
||||
if (!branchNum) {
|
||||
branchNum = 1;
|
||||
}
|
||||
var currentBlockId = thread.peekStack();
|
||||
var substackId = this.runtime.targetForThread(thread).blocks.getSubstack(
|
||||
var branchId = this.runtime.targetForThread(thread).blocks.getBranch(
|
||||
currentBlockId,
|
||||
substackNum
|
||||
branchNum
|
||||
);
|
||||
if (substackId) {
|
||||
// Push substack ID to the thread's stack.
|
||||
thread.pushStack(substackId);
|
||||
if (branchId) {
|
||||
// Push branch ID to the thread's stack.
|
||||
thread.pushStack(branchId);
|
||||
} else {
|
||||
// Push null, so we come back to the current block.
|
||||
thread.pushStack(null);
|
||||
|
||||
@@ -101,6 +101,17 @@ VirtualMachine.prototype.animationFrame = function () {
|
||||
this.runtime.animationFrame();
|
||||
};
|
||||
|
||||
/**
|
||||
* Post I/O data to the virtual devices.
|
||||
* @param {?string} device Name of virtual I/O device.
|
||||
* @param {Object} data Any data object to post to the I/O device.
|
||||
*/
|
||||
VirtualMachine.prototype.postIOData = function (device, data) {
|
||||
if (this.runtime.ioDevices[device]) {
|
||||
this.runtime.ioDevices[device].postData(data);
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Worker handlers: for all public methods available above,
|
||||
* we must also provide a message handler in case the VM is run
|
||||
@@ -140,6 +151,9 @@ if (ENV_WORKER) {
|
||||
case 'animationFrame':
|
||||
self.vmInstance.animationFrame();
|
||||
break;
|
||||
case 'postIOData':
|
||||
self.vmInstance.postIOData(messageData.device, messageData.data);
|
||||
break;
|
||||
default:
|
||||
if (e.data.id == 'RendererConnected') {
|
||||
//initRenderWorker();
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
var Timer = require('../util/timer');
|
||||
|
||||
function Clock () {
|
||||
this._projectTimer = new Timer();
|
||||
this._projectTimer.start();
|
||||
}
|
||||
|
||||
Clock.prototype.projectTimer = function () {
|
||||
return this._projectTimer.timeElapsed() / 1000;
|
||||
};
|
||||
|
||||
Clock.prototype.resetProjectTimer = function () {
|
||||
this._projectTimer.start();
|
||||
};
|
||||
|
||||
module.exports = Clock;
|
||||
@@ -0,0 +1,33 @@
|
||||
var MathUtil = require('../util/math-util');
|
||||
|
||||
function Mouse () {
|
||||
this._x = 0;
|
||||
this._y = 0;
|
||||
this._isDown = false;
|
||||
}
|
||||
|
||||
Mouse.prototype.postData = function(data) {
|
||||
if (data.x) {
|
||||
this._x = data.x;
|
||||
}
|
||||
if (data.y) {
|
||||
this._y = data.y;
|
||||
}
|
||||
if (typeof data.isDown !== 'undefined') {
|
||||
this._isDown = data.isDown;
|
||||
}
|
||||
};
|
||||
|
||||
Mouse.prototype.getX = function () {
|
||||
return MathUtil.clamp(this._x, -240, 240);
|
||||
};
|
||||
|
||||
Mouse.prototype.getY = function () {
|
||||
return MathUtil.clamp(-this._y, -180, 180);
|
||||
};
|
||||
|
||||
Mouse.prototype.getIsDown = function () {
|
||||
return this._isDown;
|
||||
};
|
||||
|
||||
module.exports = Mouse;
|
||||
@@ -0,0 +1,88 @@
|
||||
function Cast () {}
|
||||
|
||||
/**
|
||||
* @fileoverview
|
||||
* Utilities for casting and comparing Scratch data-types.
|
||||
* Scratch behaves slightly differently from JavaScript in many respects,
|
||||
* and these differences should be encapsulated below.
|
||||
* For example, in Scratch, add(1, join("hello", world")) -> 1.
|
||||
* This is because "hello world" is cast to 0.
|
||||
* In JavaScript, 1 + Number("hello" + "world") would give you NaN.
|
||||
* Use when coercing a value before computation.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Scratch cast to number.
|
||||
* Treats NaN as 0.
|
||||
* In Scratch 2.0, this is captured by `interp.numArg.`
|
||||
* @param {*} value Value to cast to number.
|
||||
* @return {number} The Scratch-casted number value.
|
||||
*/
|
||||
Cast.toNumber = function (value) {
|
||||
var n = Number(value);
|
||||
if (isNaN(n)) {
|
||||
// Scratch treats NaN as 0, when needed as a number.
|
||||
// E.g., 0 + NaN -> 0.
|
||||
return 0;
|
||||
}
|
||||
return n;
|
||||
};
|
||||
|
||||
/**
|
||||
* Scratch cast to boolean.
|
||||
* In Scratch 2.0, this is captured by `interp.boolArg.`
|
||||
* Treats some string values differently from JavaScript.
|
||||
* @param {*} value Value to cast to boolean.
|
||||
* @return {boolean} The Scratch-casted boolean value.
|
||||
*/
|
||||
Cast.toBoolean = function (value) {
|
||||
// Already a boolean?
|
||||
if (typeof value === 'boolean') {
|
||||
return value;
|
||||
}
|
||||
if (typeof value === 'string') {
|
||||
// These specific strings are treated as false in Scratch.
|
||||
if ((value == '') ||
|
||||
(value == '0') ||
|
||||
(value.toLowerCase() == 'false')) {
|
||||
return false;
|
||||
}
|
||||
// All other strings treated as true.
|
||||
return true;
|
||||
}
|
||||
// Coerce other values and numbers.
|
||||
return Boolean(value);
|
||||
};
|
||||
|
||||
/**
|
||||
* Scratch cast to string.
|
||||
* @param {*} value Value to cast to string.
|
||||
* @return {string} The Scratch-casted string value.
|
||||
*/
|
||||
Cast.toString = function (value) {
|
||||
return String(value);
|
||||
};
|
||||
|
||||
/**
|
||||
* Compare two values, using Scratch cast, case-insensitive string compare, etc.
|
||||
* In Scratch 2.0, this is captured by `interp.compare.`
|
||||
* @param {*} v1 First value to compare.
|
||||
* @param {*} v2 Second value to compare.
|
||||
* @returns {Number} Negative number if v1 < v2; 0 if equal; positive otherwise.
|
||||
*/
|
||||
Cast.compare = function (v1, v2) {
|
||||
var n1 = Number(v1);
|
||||
var n2 = Number(v2);
|
||||
if (isNaN(n1) || isNaN(n2)) {
|
||||
// At least one argument can't be converted to a number.
|
||||
// Scratch compares strings as case insensitive.
|
||||
var s1 = String(v1).toLowerCase();
|
||||
var s2 = String(v2).toLowerCase();
|
||||
return s1.localeCompare(s2);
|
||||
} else {
|
||||
// Compare as numbers.
|
||||
return n1 - n2;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = Cast;
|
||||
@@ -231,6 +231,14 @@ VirtualMachine.prototype.getPlaygroundData = function () {
|
||||
this.vmWorker.postMessage({method: 'getPlaygroundData'});
|
||||
};
|
||||
|
||||
VirtualMachine.prototype.postIOData = function (device, data) {
|
||||
this.vmWorker.postMessage({
|
||||
method: 'postIOData',
|
||||
device: device,
|
||||
data: data
|
||||
});
|
||||
};
|
||||
|
||||
VirtualMachine.prototype.start = function () {
|
||||
this.vmWorker.postMessage({method: 'start'});
|
||||
};
|
||||
|
||||
Vendored
+2
-2
@@ -12,13 +12,13 @@
|
||||
"!6Ahqg4f}Ljl}X5Hws?Z"
|
||||
]
|
||||
},
|
||||
"createsubstack": {
|
||||
"createbranch": {
|
||||
"name": "block",
|
||||
"xml": {
|
||||
"outerHTML": "<block type=\"control_forever\" id=\"r9`RpL74T6*SXPKv7}Dq\" x=\"61\" y=\"90\"><statement name=\"SUBSTACK\"><block type=\"control_wait\" id=\"{Rwt[LFtD1-JPAi-qf:.\"><value name=\"DURATION\"><shadow type=\"math_number\" id=\"VMDxt_9SYe5{*eNRe5dZ\"><field name=\"NUM\">1</field></shadow></value></block></statement></block>"
|
||||
}
|
||||
},
|
||||
"createtwosubstacks": {
|
||||
"createtwobranches": {
|
||||
"name": "block",
|
||||
"xml": {
|
||||
"outerHTML": "<block type=\"control_if_else\" id=\"8W?lmIY!Tgnh)~0!G#9-\" x=\"87\" y=\"159\"><statement name=\"SUBSTACK\"><block type=\"event_broadcast\" id=\"lgU2GGtwlREuasCB02Vr\"></block></statement><statement name=\"SUBSTACK2\"><block type=\"event_broadcast\" id=\"Gb]N,2P;|J%F?pxSwz(2\"></block></statement></block>"
|
||||
|
||||
+26
-26
@@ -43,8 +43,8 @@ test('create event', function (t) {
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('create with substack', function (t) {
|
||||
var result = adapter(events.createsubstack);
|
||||
test('create with branch', function (t) {
|
||||
var result = adapter(events.createbranch);
|
||||
// Outer block
|
||||
t.type(result[0].id, 'string');
|
||||
t.type(result[0].opcode, 'string');
|
||||
@@ -53,22 +53,22 @@ test('create with substack', function (t) {
|
||||
t.type(result[0].inputs['SUBSTACK'], 'object');
|
||||
t.type(result[0].topLevel, 'boolean');
|
||||
t.equal(result[0].topLevel, true);
|
||||
// In substack
|
||||
var substackBlockId = result[0].inputs['SUBSTACK']['block'];
|
||||
t.type(substackBlockId, 'string');
|
||||
// Find actual substack block
|
||||
var substackBlock = null;
|
||||
// In branch
|
||||
var branchBlockId = result[0].inputs['SUBSTACK']['block'];
|
||||
t.type(branchBlockId, 'string');
|
||||
// Find actual branch block
|
||||
var branchBlock = null;
|
||||
for (var i = 0; i < result.length; i++) {
|
||||
if (result[i].id == substackBlockId) {
|
||||
substackBlock = result[i];
|
||||
if (result[i].id == branchBlockId) {
|
||||
branchBlock = result[i];
|
||||
}
|
||||
}
|
||||
t.type(substackBlock, 'object');
|
||||
t.type(branchBlock, 'object');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('create with two substacks', function (t) {
|
||||
var result = adapter(events.createtwosubstacks);
|
||||
test('create with two branches', function (t) {
|
||||
var result = adapter(events.createtwobranches);
|
||||
// Outer block
|
||||
t.type(result[0].id, 'string');
|
||||
t.type(result[0].opcode, 'string');
|
||||
@@ -78,24 +78,24 @@ test('create with two substacks', function (t) {
|
||||
t.type(result[0].inputs['SUBSTACK2'], 'object');
|
||||
t.type(result[0].topLevel, 'boolean');
|
||||
t.equal(result[0].topLevel, true);
|
||||
// In substacks
|
||||
var firstSubstackBlockId = result[0].inputs['SUBSTACK']['block'];
|
||||
var secondSubstackBlockId = result[0].inputs['SUBSTACK2']['block'];
|
||||
t.type(firstSubstackBlockId, 'string');
|
||||
t.type(secondSubstackBlockId, 'string');
|
||||
// Find actual substack blocks
|
||||
var firstSubstackBlock = null;
|
||||
var secondSubstackBlock = null;
|
||||
// In branchs
|
||||
var firstBranchBlockId = result[0].inputs['SUBSTACK']['block'];
|
||||
var secondBranchBlockId = result[0].inputs['SUBSTACK2']['block'];
|
||||
t.type(firstBranchBlockId, 'string');
|
||||
t.type(secondBranchBlockId, 'string');
|
||||
// Find actual branch blocks
|
||||
var firstBranchBlock = null;
|
||||
var secondBranchBlock = null;
|
||||
for (var i = 0; i < result.length; i++) {
|
||||
if (result[i].id == firstSubstackBlockId) {
|
||||
firstSubstackBlock = result[i];
|
||||
if (result[i].id == firstBranchBlockId) {
|
||||
firstBranchBlock = result[i];
|
||||
}
|
||||
if (result[i].id == secondSubstackBlockId) {
|
||||
secondSubstackBlock = result[i];
|
||||
if (result[i].id == secondBranchBlockId) {
|
||||
secondBranchBlock = result[i];
|
||||
}
|
||||
}
|
||||
t.type(firstSubstackBlock, 'object');
|
||||
t.type(secondSubstackBlock, 'object');
|
||||
t.type(firstBranchBlock, 'object');
|
||||
t.type(secondBranchBlock, 'object');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
+37
-37
@@ -9,17 +9,17 @@ test('spec', function (t) {
|
||||
t.ok(b instanceof Blocks);
|
||||
|
||||
t.type(b._blocks, 'object');
|
||||
t.type(b._stacks, 'object');
|
||||
t.ok(Array.isArray(b._stacks));
|
||||
t.type(b._scripts, 'object');
|
||||
t.ok(Array.isArray(b._scripts));
|
||||
|
||||
t.type(b.createBlock, 'function');
|
||||
t.type(b.moveBlock, 'function');
|
||||
t.type(b.changeBlock, 'function');
|
||||
t.type(b.deleteBlock, 'function');
|
||||
t.type(b.getBlock, 'function');
|
||||
t.type(b.getStacks, 'function');
|
||||
t.type(b.getScripts, 'function');
|
||||
t.type(b.getNextBlock, 'function');
|
||||
t.type(b.getSubstack, 'function');
|
||||
t.type(b.getBranch, 'function');
|
||||
t.type(b.getOpcode, 'function');
|
||||
|
||||
|
||||
@@ -44,11 +44,11 @@ test('getBlock', function (t) {
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('getStacks', function (t) {
|
||||
test('getScripts', function (t) {
|
||||
var b = new Blocks();
|
||||
var stacks = b.getStacks();
|
||||
t.type(stacks, 'object');
|
||||
t.equals(stacks.length, 0);
|
||||
var scripts = b.getScripts();
|
||||
t.type(scripts, 'object');
|
||||
t.equals(scripts.length, 0);
|
||||
// Create two top-level blocks and one not.
|
||||
b.createBlock({
|
||||
id: 'foo',
|
||||
@@ -75,12 +75,12 @@ test('getStacks', function (t) {
|
||||
topLevel: false
|
||||
});
|
||||
|
||||
stacks = b.getStacks();
|
||||
t.type(stacks, 'object');
|
||||
t.equals(stacks.length, 2);
|
||||
t.ok(stacks.indexOf('foo') > -1);
|
||||
t.ok(stacks.indexOf('foo2') > -1);
|
||||
t.equals(stacks.indexOf('foo3'), -1);
|
||||
scripts = b.getScripts();
|
||||
t.type(scripts, 'object');
|
||||
t.equals(scripts.length, 2);
|
||||
t.ok(scripts.indexOf('foo') > -1);
|
||||
t.ok(scripts.indexOf('foo2') > -1);
|
||||
t.equals(scripts.indexOf('foo3'), -1);
|
||||
t.end();
|
||||
|
||||
});
|
||||
@@ -119,9 +119,9 @@ test('getNextBlock', function (t) {
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('getSubstack', function (t) {
|
||||
test('getBranch', function (t) {
|
||||
var b = new Blocks();
|
||||
// Single substack
|
||||
// Single branch
|
||||
b.createBlock({
|
||||
id: 'foo',
|
||||
opcode: 'TEST_BLOCK',
|
||||
@@ -144,18 +144,18 @@ test('getSubstack', function (t) {
|
||||
topLevel: false
|
||||
});
|
||||
|
||||
var substack = b.getSubstack('foo');
|
||||
t.equals(substack, 'foo2');
|
||||
var branch = b.getBranch('foo');
|
||||
t.equals(branch, 'foo2');
|
||||
|
||||
var notSubstack = b.getSubstack('?');
|
||||
t.equals(notSubstack, null);
|
||||
var notBranch = b.getBranch('?');
|
||||
t.equals(notBranch, null);
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('getSubstack2', function (t) {
|
||||
test('getBranch2', function (t) {
|
||||
var b = new Blocks();
|
||||
// Second substack
|
||||
// Second branch
|
||||
b.createBlock({
|
||||
id: 'foo',
|
||||
opcode: 'TEST_BLOCK',
|
||||
@@ -190,15 +190,15 @@ test('getSubstack2', function (t) {
|
||||
topLevel: false
|
||||
});
|
||||
|
||||
var substack1 = b.getSubstack('foo', 1);
|
||||
var substack2 = b.getSubstack('foo', 2);
|
||||
t.equals(substack1, 'foo2');
|
||||
t.equals(substack2, 'foo3');
|
||||
var branch1 = b.getBranch('foo', 1);
|
||||
var branch2 = b.getBranch('foo', 2);
|
||||
t.equals(branch1, 'foo2');
|
||||
t.equals(branch2, 'foo3');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('getSubstack with none', function (t) {
|
||||
test('getBranch with none', function (t) {
|
||||
var b = new Blocks();
|
||||
b.createBlock({
|
||||
id: 'foo',
|
||||
@@ -208,8 +208,8 @@ test('getSubstack with none', function (t) {
|
||||
inputs: {},
|
||||
topLevel: true
|
||||
});
|
||||
var noSubstack = b.getSubstack('foo');
|
||||
t.equals(noSubstack, null);
|
||||
var noBranch = b.getBranch('foo');
|
||||
t.equals(noBranch, null);
|
||||
t.end();
|
||||
});
|
||||
|
||||
@@ -244,7 +244,7 @@ test('create', function (t) {
|
||||
|
||||
t.type(b._blocks['foo'], 'object');
|
||||
t.equal(b._blocks['foo'].opcode, 'TEST_BLOCK');
|
||||
t.notEqual(b._stacks.indexOf('foo'), -1);
|
||||
t.notEqual(b._scripts.indexOf('foo'), -1);
|
||||
t.end();
|
||||
});
|
||||
|
||||
@@ -272,7 +272,7 @@ test('move', function (t) {
|
||||
id: 'bar',
|
||||
newParent: 'foo'
|
||||
});
|
||||
t.equal(b._stacks.length, 1);
|
||||
t.equal(b._scripts.length, 1);
|
||||
t.equal(Object.keys(b._blocks).length, 2);
|
||||
t.equal(b._blocks['foo'].next, 'bar');
|
||||
|
||||
@@ -281,7 +281,7 @@ test('move', function (t) {
|
||||
id: 'bar',
|
||||
oldParent: 'foo'
|
||||
});
|
||||
t.equal(b._stacks.length, 2);
|
||||
t.equal(b._scripts.length, 2);
|
||||
t.equal(Object.keys(b._blocks).length, 2);
|
||||
t.equal(b._blocks['foo'].next, null);
|
||||
|
||||
@@ -360,7 +360,7 @@ test('delete', function (t) {
|
||||
});
|
||||
|
||||
t.type(b._blocks['foo'], 'undefined');
|
||||
t.equal(b._stacks.indexOf('foo'), -1);
|
||||
t.equal(b._scripts.indexOf('foo'), -1);
|
||||
t.end();
|
||||
});
|
||||
|
||||
@@ -398,9 +398,9 @@ test('delete chain', function (t) {
|
||||
t.type(b._blocks['foo'], 'undefined');
|
||||
t.type(b._blocks['foo2'], 'undefined');
|
||||
t.type(b._blocks['foo3'], 'undefined');
|
||||
t.equal(b._stacks.indexOf('foo'), -1);
|
||||
t.equal(b._scripts.indexOf('foo'), -1);
|
||||
t.equal(Object.keys(b._blocks).length, 0);
|
||||
t.equal(b._stacks.length, 0);
|
||||
t.equal(b._scripts.length, 0);
|
||||
t.end();
|
||||
});
|
||||
|
||||
@@ -461,8 +461,8 @@ test('delete inputs', function (t) {
|
||||
t.type(b._blocks['foo2'], 'undefined');
|
||||
t.type(b._blocks['foo3'], 'undefined');
|
||||
t.type(b._blocks['foo4'], 'undefined');
|
||||
t.equal(b._stacks.indexOf('foo'), -1);
|
||||
t.equal(b._scripts.indexOf('foo'), -1);
|
||||
t.equal(Object.keys(b._blocks).length, 0);
|
||||
t.equal(b._stacks.length, 0);
|
||||
t.equal(b._scripts.length, 0);
|
||||
t.end();
|
||||
});
|
||||
@@ -1,11 +1,11 @@
|
||||
!function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){function n(){var t=this;i.call(t),t.blocks=new s,t.runtime=new a(t.blocks),t.blockListener=t.blocks.generateBlockListener(!1,t.runtime),t.flyoutBlockListener=t.blocks.generateBlockListener(!0,t.runtime)}var i=r(1),o=r(2),s=r(6),a=r(118);o.inherits(n,i),t.exports=n,"undefined"!=typeof window&&(window.VirtualMachine=t.exports)},function(t,e){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function n(t){return"function"==typeof t}function i(t){return"number"==typeof t}function o(t){return"object"==typeof t&&null!==t}function s(t){return void 0===t}t.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(t){if(!i(t)||0>t||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},r.prototype.emit=function(t){var e,r,i,a,c,u;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;throw TypeError('Uncaught, unspecified "error" event.')}if(r=this._events[t],s(r))return!1;if(n(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),r.apply(this,a)}else if(o(r))for(a=Array.prototype.slice.call(arguments,1),u=r.slice(),i=u.length,c=0;i>c;c++)u[c].apply(this,a);return!0},r.prototype.addListener=function(t,e){var i;if(!n(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,n(e.listener)?e.listener:e),this._events[t]?o(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,o(this._events[t])&&!this._events[t].warned&&(i=s(this._maxListeners)?r.defaultMaxListeners:this._maxListeners,i&&i>0&&this._events[t].length>i&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(t,e){function r(){this.removeListener(t,r),i||(i=!0,e.apply(this,arguments))}if(!n(e))throw TypeError("listener must be a function");var i=!1;return r.listener=e,this.on(t,r),this},r.prototype.removeListener=function(t,e){var r,i,s,a;if(!n(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],s=r.length,i=-1,r===e||n(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(r)){for(a=s;a-- >0;)if(r[a]===e||r[a].listener&&r[a].listener===e){i=a;break}if(0>i)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(i,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},r.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],n(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},r.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?n(this._events[t])?[this._events[t]]:this._events[t].slice():[]},r.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(n(e))return 1;if(e)return e.length}return 0},r.listenerCount=function(t,e){return t.listenerCount(e)}},function(t,e,r){(function(t,n){function i(t,r){var n={seen:[],stylize:s};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),g(r)?n.showHidden=r:r&&e._extend(n,r),w(n.showHidden)&&(n.showHidden=!1),w(n.depth)&&(n.depth=2),w(n.colors)&&(n.colors=!1),w(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=o),c(n,t,n.depth)}function o(t,e){var r=i.styles[e];return r?"["+i.colors[r][0]+"m"+t+"["+i.colors[r][1]+"m":t}function s(t,e){return t}function a(t){var e={};return t.forEach(function(t,r){e[t]=!0}),e}function c(t,r,n){if(t.customInspect&&r&&T(r.inspect)&&r.inspect!==e.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,t);return y(i)||(i=c(t,i,n)),i}var o=u(t,r);if(o)return o;var s=Object.keys(r),g=a(s);if(t.showHidden&&(s=Object.getOwnPropertyNames(r)),k(r)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return l(r);iLine truncated
|
||||
this._index++}this._cleanup()},a.prototype.pause=function(){this._running=!1},a.prototype.resume=function(){this._running=!0,this._index<this._buffer.length&&this._parse(),this._ended&&this._finish()},a.prototype.end=function(t){this._ended&&this._cbs.onerror(Error(".end() after done!")),t&&this.write(t),this._ended=!0,this._running&&this._finish()},a.prototype._finish=function(){this._sectionStart<this._index&&this._handleTrailingData(),this._cbs.onend()},a.prototype._handleTrailingData=function(){var t=this._buffer.substr(this._sectionStart);this._state===M||this._state===F||this._state===z?this._cbs.oncdata(t):this._state===I||this._state===B||this._state===D?this._cbs.oncomment(t):this._state!==ht||this._xmlMode?this._state!==ft||this._xmlMode?this._state!==pt||this._xmlMode?this._state!==g&&this._state!==v&&this._state!==x&&this._state!==S&&this._state!==w&&this._state!==k&&this._state!==E&&this._state!==T&&this._state!==b&&this._cbs.ontext(t):(this._decodeNumericEntity(3,16),this._sectionStart<this._index&&(this._state=this._baseState,this._handleTrailingData())):(this._decodeNumericEntity(2,10),this._sectionStart<this._index&&(this._state=this._baseState,this._handleTrailingData())):(this._parseLegacyEntity(),this._sectionStart<this._index&&(this._state=this._baseState,this._handleTrailingData()))},a.prototype.reset=function(){a.call(this,{xmlMode:this._xmlMode,decodeEntities:this._decodeEntities},this._cbs)},a.prototype.getAbsoluteIndex=function(){return this._bufferOffset+this._index},a.prototype._getSection=function(){return this._buffer.substring(this._sectionStart,this._index)},a.prototype._emitToken=function(t){this._cbs[t](this._getSection()),this._sectionStart=-1},a.prototype._emitPartial=function(t){this._baseState!==p?this._cbs.onattribdata(t):this._cbs.ontext(t)}},function(t,e,r){function n(t){if(t>=55296&&57343>=t||t>1114111)return"�";t in i&&(t=i[t]);var e="";return t>65535&&(t-=65536,e+=String.fromCharCode(t>>>10&1023|55296),t=56320|1023&t),e+=String.fromCharCode(t)}var i=r(12);t.exports=n},function(t,e){t.exports={0:65533,128:8364,130:8218,131:402,132:8222,133:8230,134:8224,135:8225,136:710,137:8240,138:352,139:8249,140:338,142:381,145:8216,146:8217,147:8220,148:8221,149:8226,150:8211,151:8212,152:732,153:8482,154:353,155:8250,156:339,158:382,159:376}},function(t,e){t.exports={Aacute:"Á",aacute:"á",Abreve:"Ă",abreve:"ă",ac:"∾",acd:"∿",acE:"∾̳",Acirc:"Â",acirc:"â",acute:"´",Acy:"А",acy:"а",AElig:"Æ",aelig:"æ",af:"",Afr:"𝔄",afr:"𝔞",Agrave:"À",agrave:"à",alefsym:"ℵ",aleph:"ℵ",Alpha:"Α",alpha:"α",Amacr:"Ā",amacr:"ā",amalg:"⨿",amp:"&",AMP:"&",andand:"⩕",And:"⩓",and:"∧",andd:"⩜",andslope:"⩘",andv:"⩚",ang:"∠",ange:"⦤",angle:"∠",angmsdaa:"⦨",angmsdab:"⦩",angmsdac:"⦪",angmsdad:"⦫",angmsdae:"⦬",angmsdaf:"⦭",angmsdag:"⦮",angmsdah:"⦯",angmsd:"∡",angrt:"∟",angrtvb:"⊾",angrtvbd:"⦝",angsph:"∢",angst:"Å",angzarr:"⍼",Aogon:"Ą",aogon:"ą",Aopf:"𝔸",aopf:"𝕒",apacir:"⩯",ap:"≈",apE:"⩰",ape:"≊",apid:"≋",apos:"'",ApplyFunction:"",approx:"≈",approxeq:"≊",Aring:"Å",aring:"å",Ascr:"𝒜",ascr:"𝒶",Assign:"≔",ast:"*",asymp:"≈",asympeq:"≍",Atilde:"Ã",atilde:"ã",Auml:"Ä",auml:"ä",awconint:"∳",awint:"⨑",backcong:"≌",backepsilon:"϶",backprime:"‵",backsim:"∽",backsimeq:"⋍",Backslash:"∖",Barv:"⫧",barvee:"⊽",barwed:"⌅",Barwed:"⌆",barwedge:"⌅",bbrk:"⎵",bbrktbrk:"⎶",bcong:"≌",Bcy:"Б",bcy:"б",bdquo:"„",becaus:"∵",because:"∵",Because:"∵",bemptyv:"⦰",bepsi:"϶",bernou:"ℬ",Bernoullis:"ℬ",Beta:"Β",beta:"β",beth:"ℶ",between:"≬",Bfr:"𝔅",bfr:"𝔟",bigcap:"⋂",bigcirc:"◯",bigcup:"⋃",bigodot:"⨀",bigoplus:"⨁",bigotimes:"⨂",bigsqcup:"⨆",bigstar:"★",bigtriangledown:"▽",bigtriangleup:"△",biguplus:"⨄",bigvee:"⋁",bigwedge:"⋀",bkarow:"⤍",blacklozenge:"⧫",blacksquare:"▪",blacktriangle:"▴",blacktriangledown:"▾",blacktriangleleft:"◂",blacktriangleright:"▸",blank:"␣",blk12:"▒",blk14:"░",blk34:"▓",block:"█",bne:"=⃥",bnequiv:"≡⃥",bNot:"⫭",bnot:"⌐",Bopf:"𝔹",bopf:"𝕓",bot:"⊥",bottom:"⊥",bowtie:"⋈",boxbox:"⧉",boxdl:"┐",boxdL:"╕",boxDl:"╖",boxDL:"╗",boxdr:"┌",boxdR:"╒",boxDr:"╓",boxDR:"╔",boxh:"─",boxH:"═",boxhd:"┬",boxHd:"╤",boxhD:"╥",boxHD:"╦",boxhu:"┴",boxHu:"╧",boxhU:"╨",boxHU:"╩",boxminus:"⊟",boxplus:"⊞",boxtimes:"⊠",boxul:"┘",boxuL:"╛",boxUl:"╜",boxUL:"╝",boxur:"└",boxuR:"╘",boxUr:"╙",boxUR:"╚",boxv:"│",boxV:"║",boxvh:"┼",boxvH:"╪",boxVh:"╫",boxVH:"╬",boxvl:"┤",boxvL:"╡",boxVl:"╢",boxVL:"╣",boxvr:"├",boxvR:"╞",boxVr:"╟",boxVR:"╠",bprime:"‵",breve:"˘",Breve:"˘",brvbar:"¦",bscr:"𝒷",Bscr:"ℬ",bsemi:"⁏",bsim:"∽",bsime:"⋍",bsolb:"⧅",bsol:"\\",bsolhsub:"⟈",bull:"•",bullet:"•",bump:"≎",bumpE:"⪮",bumpe:"≏",Bumpeq:"≎",bumpeq:"≏",Cacute:"Ć",cacute:"ć",capand:"⩄",capbrcup:"⩉",capLine truncated
|
||||
return"rss"===t||"feed"===t||"rdf:RDF"===t};n.prototype.onend=function(){var t,e,r={},n=o(h,this.dom);n&&("feed"===n.name?(e=n.children,r.type="atom",a(r,"id","id",e),a(r,"title","title",e),(t=o("link",e))&&(t=t.attribs)&&(t=t.href)&&(r.link=t),a(r,"description","subtitle",e),(t=s("updated",e))&&(r.updated=new Date(t)),a(r,"author","email",e,!0),r.items=i("entry",e).map(function(t){var e,r={};return t=t.children,a(r,"id","id",t),a(r,"title","title",t),(e=o("link",t))&&(e=e.attribs)&&(e=e.href)&&(r.link=e),(e=s("summary",t)||s("content",t))&&(r.description=e),(e=s("updated",t))&&(r.pubDate=new Date(e)),r})):(e=o("channel",n.children).children,r.type=n.name.substr(0,3),r.id="",a(r,"title","title",e),a(r,"link","link",e),a(r,"description","description",e),(t=s("lastBuildDate",e))&&(r.updated=new Date(t)),a(r,"author","managingEditor",e,!0),r.items=i("item",n.children).map(function(t){var e,r={};return t=t.children,a(r,"id","guid",t),a(r,"title","title",t),a(r,"link","link",t),a(r,"description","description",t),(e=s("pubDate",t))&&(r.pubDate=new Date(e)),r}))),this.dom=r,u.prototype._handleCallback.call(this,n?null:Error("couldn't find root of feed"))},t.exports=n},function(t,e,r){function n(t){o.call(this,new i(this),t)}function i(t){this.scope=t}t.exports=n;var o=r(22);r(2).inherits(n,o),n.prototype.readable=!0;var s=r(8).EVENTS;Object.keys(s).forEach(function(t){if(0===s[t])i.prototype["on"+t]=function(){this.scope.emit(t)};else if(1===s[t])i.prototype["on"+t]=function(e){this.scope.emit(t,e)};else{if(2!==s[t])throw Error("wrong number of arguments!");i.prototype["on"+t]=function(e,r){this.scope.emit(t,e,r)}}})},function(t,e,r){function n(t,e){var r=this._parser=new i(t,e);o.call(this,{decodeStrings:!1}),this.once("finish",function(){r.end()})}t.exports=n;var i=r(9),o=r(23).Writable||r(42).Writable;r(2).inherits(n,o),o.prototype._write=function(t,e,r){this._parser.write(t),r()}},function(t,e,r){function n(){i.call(this)}t.exports=n;var i=r(1).EventEmitter,o=r(5);o(n,i),n.Readable=r(24),n.Writable=r(38),n.Duplex=r(39),n.Transform=r(40),n.PassThrough=r(41),n.Stream=n,n.prototype.pipe=function(t,e){function r(e){t.writable&&!1===t.write(e)&&u.pause&&u.pause()}function n(){u.readable&&u.resume&&u.resume()}function o(){l||(l=!0,t.end())}function s(){l||(l=!0,"function"==typeof t.destroy&&t.destroy())}function a(t){if(c(),0===i.listenerCount(this,"error"))throw t}function c(){u.removeListener("data",r),t.removeListener("drain",n),u.removeListener("end",o),u.removeListener("close",s),u.removeListener("error",a),t.removeListener("error",a),u.removeListener("end",c),u.removeListener("close",c),t.removeListener("close",c)}var u=this;u.on("data",r),t.on("drain",n),t._isStdio||e&&e.end===!1||(u.on("end",o),u.on("close",s));var l=!1;return u.on("error",a),t.on("error",a),u.on("end",c),u.on("close",c),t.on("close",c),t.emit("pipe",u),t}},function(t,e,r){(function(n){e=t.exports=r(25),e.Stream=r(23),e.Readable=e,e.Writable=r(34),e.Duplex=r(33),e.Transform=r(36),e.PassThrough=r(37),n.browser||"disable"!==n.env.READABLE_STREAM||(t.exports=r(23))}).call(e,r(3))},function(t,e,r){(function(e){function n(t,e){var n=r(33);t=t||{};var i=t.highWaterMark,o=t.objectMode?16:16384;this.highWaterMark=i||0===i?i:o,this.highWaterMark=~~this.highWaterMark,this.buffer=[],this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.objectMode=!!t.objectMode,e instanceof n&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.defaultEncoding=t.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(L||(L=r(35).StringDecoder),this.decoder=new L(t.encoding),this.encoding=t.encoding)}function i(t){r(33);return this instanceof i?(this._readableState=new n(t,this),this.readable=!0,void T.call(this)):new i(t)}function o(t,e,r,n,i){var o=u(e,r);if(o)t.emit("error",o);else if(A.isNullOrUndefined(r))e.reading=!1,e.ended||l(t,e);else if(e.objectMode||r&&r.length>0)if(e.ended&&!i){var a=new Error("stream.push() after EOF");t.emit("error",a)}else if(e.endEmitted&&i){var a=new Error("stream.unshift() after end event");t.emit("error",a)}else!e.decoder||i||n||(r=e.decoder.write(r)),i||(e.reading=!1),e.flowing&&0===e.length&&!e.sync?(t.emit("data",r),t.read(0)):(e.length+=e.objectMode?1:r.length,i?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&h(t)),p(t,e);else i||(e.reading=!1);return s(e)}function s(t){return!t.ended&&(t.needReadable||t.length<t.highWaterMark||0===t.length)}function a(t){if(t>=C)t=C;else{t--;for(var e=1;32>e;e<<=1)t|=t>>e;t++}return t}function c(t,e){return 0===e.length&&e.ended?0:e.objectMode?0===t?0:1:isNaN(t)||A.isNull(t)?e.flowing&&e.buffer.length?e.buffer[0].length:e.length:0>=t?0:(t>e.highWaterMark&&(e.highWaterMark=a(t)),t>e.length?e.ended?e.length:(e.needReadable=!0,0):t)}function u(t,e){var r=null;returnLine truncated
|
||||
!function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){function n(){var t=this;i.call(t);var e=new s;e.createClone();var r=[e.clones[0]];t.exampleSprite=e,t.runtime=new a(r),t.blockListener=e.blocks.generateBlockListener(!1,t.runtime),t.flyoutBlockListener=e.blocks.generateBlockListener(!0,t.runtime),t.runtime.on(a.STACK_GLOW_ON,function(e){t.emit(a.STACK_GLOW_ON,{id:e})}),t.runtime.on(a.STACK_GLOW_OFF,function(e){t.emit(a.STACK_GLOW_OFF,{id:e})}),t.runtime.on(a.BLOCK_GLOW_ON,function(e){t.emit(a.BLOCK_GLOW_ON,{id:e})}),t.runtime.on(a.BLOCK_GLOW_OFF,function(e){t.emit(a.BLOCK_GLOW_OFF,{id:e})}),t.runtime.on(a.VISUAL_REPORT,function(e,r){t.emit(a.VISUAL_REPORT,{id:e,value:r})})}var i=r(1),o=r(2),s=r(6),a=r(61),c="function"==typeof importScripts;o.inherits(n,i),n.prototype.start=function(){this.runtime.start()},n.prototype.greenFlag=function(){this.runtime.greenFlag()},n.prototype.stopAll=function(){this.runtime.stopAll()},n.prototype.getPlaygroundData=function(){this.emit("playgroundData",{blocks:this.exampleSprite.blocks,threads:this.runtime.threads})},n.prototype.animationFrame=function(){this.runtime.animationFrame()},n.prototype.postIOData=function(t,e){this.runtime.ioDevices[t]&&this.runtime.ioDevices[t].postData(e)},c&&(self.importScripts("./node_modules/scratch-render/render-worker.js"),self.renderer=new self.RenderWebGLWorker,self.vmInstance=new n,self.onmessage=function(t){var e=t.data;switch(e.method){case"start":self.vmInstance.runtime.start();break;case"greenFlag":self.vmInstance.runtime.greenFlag();break;case"stopAll":self.vmInstance.runtime.stopAll();break;case"blockListener":self.vmInstance.blockListener(e.args);break;case"flyoutBlockListener":self.vmInstance.flyoutBlockListener(e.args);break;case"getPlaygroundData":self.postMessage({method:"playgroundData",blocks:self.vmInstance.exampleSprite.blocks,threads:self.vmInstance.runtime.threads});break;case"animationFrame":self.vmInstance.animationFrame();break;case"postIOData":self.vmInstance.postIOData(e.device,e.data);break;default:"RendererConnected"==t.data.id,self.renderer.onmessage(t)}},self.vmInstance.runtime.on(a.STACK_GLOW_ON,function(t){self.postMessage({method:a.STACK_GLOW_ON,id:t})}),self.vmInstance.runtime.on(a.STACK_GLOW_OFF,function(t){self.postMessage({method:a.STACK_GLOW_OFF,id:t})}),self.vmInstance.runtime.on(a.BLOCK_GLOW_ON,function(t){self.postMessage({method:a.BLOCK_GLOW_ON,id:t})}),self.vmInstance.runtime.on(a.BLOCK_GLOW_OFF,function(t){self.postMessage({method:a.BLOCK_GLOW_OFF,id:t})}),self.vmInstance.runtime.on(a.VISUAL_REPORT,function(t,e){self.postMessage({method:a.VISUAL_REPORT,id:t,value:e})})),t.exports=n,"undefined"!=typeof window&&(window.VirtualMachine=t.exports)},function(t,e){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function n(t){return"function"==typeof t}function i(t){return"number"==typeof t}function o(t){return"object"==typeof t&&null!==t}function s(t){return void 0===t}t.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(t){if(!i(t)||0>t||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},r.prototype.emit=function(t){var e,r,i,a,c,u;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;throw TypeError('Uncaught, unspecified "error" event.')}if(r=this._events[t],s(r))return!1;if(n(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),r.apply(this,a)}else if(o(r))for(a=Array.prototype.slice.call(arguments,1),u=r.slice(),i=u.length,c=0;i>c;c++)u[c].apply(this,a);return!0},r.prototype.addListener=function(t,e){var i;if(!n(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,n(e.listener)?e.listener:e),this._events[t]?o(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,o(this._events[t])&&!this._events[t].warned&&(i=s(this._maxListeners)?r.defaultMaxListeners:this._maxListeners,i&&i>0&&this._events[t].length>i&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(t,e){function r(){this.removeListener(t,r),i||(i=!0,e.apply(this,arguments))}if(!n(e))throw TypeError("listener must be a function");var i=!1;return r.listener=e,this.on(t,rLine truncated
|
||||
this._index--)},a.prototype._stateBeforeSpecialEnd=function(t){this._special!==_t||"c"!==t&&"C"!==t?this._special!==mt||"t"!==t&&"T"!==t?this._state=f:this._state=ot:this._state=J},a.prototype._stateBeforeScript1=s("R",H),a.prototype._stateBeforeScript2=s("I",W),a.prototype._stateBeforeScript3=s("P",X),a.prototype._stateBeforeScript4=s("T",K),a.prototype._stateBeforeScript5=function(t){("/"===t||">"===t||n(t))&&(this._special=_t),this._state=g,this._index--},a.prototype._stateAfterScript1=o("R",Q,f),a.prototype._stateAfterScript2=o("I",Z,f),a.prototype._stateAfterScript3=o("P",$,f),a.prototype._stateAfterScript4=o("T",tt,f),a.prototype._stateAfterScript5=function(t){">"===t||n(t)?(this._special=gt,this._state=b,this._sectionStart=this._index-6,this._index--):this._state=f},a.prototype._stateBeforeStyle1=s("Y",rt),a.prototype._stateBeforeStyle2=s("L",nt),a.prototype._stateBeforeStyle3=s("E",it),a.prototype._stateBeforeStyle4=function(t){("/"===t||">"===t||n(t))&&(this._special=mt),this._state=g,this._index--},a.prototype._stateAfterStyle1=o("Y",st,f),a.prototype._stateAfterStyle2=o("L",at,f),a.prototype._stateAfterStyle3=o("E",ct,f),a.prototype._stateAfterStyle4=function(t){">"===t||n(t)?(this._special=gt,this._state=b,this._sectionStart=this._index-5,this._index--):this._state=f},a.prototype._stateBeforeEntity=o("#",ht,lt),a.prototype._stateBeforeNumericEntity=o("X",ft,pt),a.prototype._parseNamedEntityStrict=function(){if(this._sectionStart+1<this._index){var t=this._buffer.substring(this._sectionStart+1,this._index),e=this._xmlMode?l:u;e.hasOwnProperty(t)&&(this._emitPartial(e[t]),this._sectionStart=this._index+1)}},a.prototype._parseLegacyEntity=function(){var t=this._sectionStart+1,e=this._index-t;for(e>6&&(e=6);e>=2;){var r=this._buffer.substr(t,e);if(h.hasOwnProperty(r))return this._emitPartial(h[r]),void(this._sectionStart+=e+1);e--}},a.prototype._stateInNamedEntity=function(t){";"===t?(this._parseNamedEntityStrict(),this._sectionStart+1<this._index&&!this._xmlMode&&this._parseLegacyEntity(),this._state=this._baseState):("a">t||t>"z")&&("A">t||t>"Z")&&("0">t||t>"9")&&(this._xmlMode||this._sectionStart+1===this._index||(this._baseState!==f?"="!==t&&this._parseNamedEntityStrict():this._parseLegacyEntity()),this._state=this._baseState,this._index--)},a.prototype._decodeNumericEntity=function(t,e){var r=this._sectionStart+t;if(r!==this._index){var n=this._buffer.substring(r,this._index),i=parseInt(n,e);this._emitPartial(c(i)),this._sectionStart=this._index}else this._sectionStart--;this._state=this._baseState},a.prototype._stateInNumericEntity=function(t){";"===t?(this._decodeNumericEntity(2,10),this._sectionStart++):("0">t||t>"9")&&(this._xmlMode?this._state=this._baseState:this._decodeNumericEntity(2,10),this._index--)},a.prototype._stateInHexEntity=function(t){";"===t?(this._decodeNumericEntity(3,16),this._sectionStart++):("a">t||t>"f")&&("A">t||t>"F")&&("0">t||t>"9")&&(this._xmlMode?this._state=this._baseState:this._decodeNumericEntity(3,16),this._index--)},a.prototype._cleanup=function(){this._sectionStart<0?(this._buffer="",this._index=0,this._bufferOffset+=this._index):this._running&&(this._state===f?(this._sectionStart!==this._index&&this._cbs.ontext(this._buffer.substr(this._sectionStart)),this._buffer="",this._index=0,this._bufferOffset+=this._index):this._sectionStart===this._index?(this._buffer="",this._index=0,this._bufferOffset+=this._index):(this._buffer=this._buffer.substr(this._sectionStart),this._index-=this._sectionStart,this._bufferOffset+=this._sectionStart),this._sectionStart=0)},a.prototype.write=function(t){this._ended&&this._cbs.onerror(Error(".write() after done!")),this._buffer+=t,this._parse()},a.prototype._parse=function(){for(;this._index<this._buffer.length&&this._running;){var t=this._buffer.charAt(this._index);this._state===f?this._stateText(t):this._state===d?this._stateBeforeTagName(t):this._state===g?this._stateInTagName(t):this._state===m?this._stateBeforeCloseingTagName(t):this._state===b?this._stateInCloseingTagName(t):this._state===y?this._stateAfterCloseingTagName(t):this._state===_?this._stateInSelfClosingTag(t):this._state===v?this._stateBeforeAttributeName(t):this._state===w?this._stateInAttributeName(t):this._state===S?this._stateAfterAttributeName(t):this._state===E?this._stateBeforeAttributeValue(t):this._state===k?this._stateInAttributeValueDoubleQuotes(t):this._state===x?this._stateInAttributeValueSingleQuotes(t):this._state===T?this._stateInAttributeValueNoQuotes(t):this._state===A?this._stateBeforeDeclaration(t):this._state===L?this._stateInDeclaration(t):this._state===I?this._stateInProcessingInstruction(t):this._state===D?this._stateBeforeComment(t):this._state===R?this._stateInComment(t):this._state===N?this._stateAfterComment1(t):this._state===O?this._stateAfterComment2(t):this._state===B?this._stateBeforeCdata1(t):this._state===C?this._stateBeforeCdata2(t):this._state===M?this._stateBeforeCdata3(t):this._state===q?this._stateBeforeCdata4(t):this._stLine truncated
|
||||
varepsilon:"ϵ",varkappa:"ϰ",varnothing:"∅",varphi:"ϕ",varpi:"ϖ",varpropto:"∝",varr:"↕",vArr:"⇕",varrho:"ϱ",varsigma:"ς",varsubsetneq:"⊊︀",varsubsetneqq:"⫋︀",varsupsetneq:"⊋︀",varsupsetneqq:"⫌︀",vartheta:"ϑ",vartriangleleft:"⊲",vartriangleright:"⊳",vBar:"⫨",Vbar:"⫫",vBarv:"⫩",Vcy:"В",vcy:"в",vdash:"⊢",vDash:"⊨",Vdash:"⊩",VDash:"⊫",Vdashl:"⫦",veebar:"⊻",vee:"∨",Vee:"⋁",veeeq:"≚",vellip:"⋮",verbar:"|",Verbar:"‖",vert:"|",Vert:"‖",VerticalBar:"∣",VerticalLine:"|",VerticalSeparator:"❘",VerticalTilde:"≀",VeryThinSpace:" ",Vfr:"𝔙",vfr:"𝔳",vltri:"⊲",vnsub:"⊂⃒",vnsup:"⊃⃒",Vopf:"𝕍",vopf:"𝕧",vprop:"∝",vrtri:"⊳",Vscr:"𝒱",vscr:"𝓋",vsubnE:"⫋︀",vsubne:"⊊︀",vsupnE:"⫌︀",vsupne:"⊋︀",Vvdash:"⊪",vzigzag:"⦚",Wcirc:"Ŵ",wcirc:"ŵ",wedbar:"⩟",wedge:"∧",Wedge:"⋀",wedgeq:"≙",weierp:"℘",Wfr:"𝔚",wfr:"𝔴",Wopf:"𝕎",wopf:"𝕨",wp:"℘",wr:"≀",wreath:"≀",Wscr:"𝒲",wscr:"𝓌",xcap:"⋂",xcirc:"◯",xcup:"⋃",xdtri:"▽",Xfr:"𝔛",xfr:"𝔵",xharr:"⟷",xhArr:"⟺",Xi:"Ξ",xi:"ξ",xlarr:"⟵",xlArr:"⟸",xmap:"⟼",xnis:"⋻",xodot:"⨀",Xopf:"𝕏",xopf:"𝕩",xoplus:"⨁",xotime:"⨂",xrarr:"⟶",xrArr:"⟹",Xscr:"𝒳",xscr:"𝓍",xsqcup:"⨆",xuplus:"⨄",xutri:"△",xvee:"⋁",xwedge:"⋀",Yacute:"Ý",yacute:"ý",YAcy:"Я",yacy:"я",Ycirc:"Ŷ",ycirc:"ŷ",Ycy:"Ы",ycy:"ы",yen:"¥",Yfr:"𝔜",yfr:"𝔶",YIcy:"Ї",yicy:"ї",Yopf:"𝕐",yopf:"𝕪",Yscr:"𝒴",yscr:"𝓎",YUcy:"Ю",yucy:"ю",yuml:"ÿ",Yuml:"Ÿ",Zacute:"Ź",zacute:"ź",Zcaron:"Ž",zcaron:"ž",Zcy:"З",zcy:"з",Zdot:"Ż",zdot:"ż",zeetrf:"ℨ",ZeroWidthSpace:"",Zeta:"Ζ",zeta:"ζ",zfr:"𝔷",Zfr:"ℨ",ZHcy:"Ж",zhcy:"ж",zigrarr:"⇝",zopf:"𝕫",Zopf:"ℤ",Zscr:"𝒵",zscr:"𝓏",zwj:"",zwnj:""}},function(t,e){t.exports={Aacute:"Á",aacute:"á",Acirc:"Â",acirc:"â",acute:"´",AElig:"Æ",aelig:"æ",Agrave:"À",agrave:"à",amp:"&",AMP:"&",Aring:"Å",aring:"å",Atilde:"Ã",atilde:"ã",Auml:"Ä",auml:"ä",brvbar:"¦",Ccedil:"Ç",ccedil:"ç",cedil:"¸",cent:"¢",copy:"©",COPY:"©",curren:"¤",deg:"°",divide:"÷",Eacute:"É",eacute:"é",Ecirc:"Ê",ecirc:"ê",Egrave:"È",egrave:"è",ETH:"Ð",eth:"ð",Euml:"Ë",euml:"ë",frac12:"½",frac14:"¼",frac34:"¾",gt:">",GT:">",Iacute:"Í",iacute:"í",Icirc:"Î",icirc:"î",iexcl:"¡",Igrave:"Ì",igrave:"ì",iquest:"¿",Iuml:"Ï",iuml:"ï",laquo:"«",lt:"<",LT:"<",macr:"¯",micro:"µ",middot:"·",nbsp:" ",not:"¬",Ntilde:"Ñ",ntilde:"ñ",Oacute:"Ó",oacute:"ó",Ocirc:"Ô",ocirc:"ô",Ograve:"Ò",ograve:"ò",ordf:"ª",ordm:"º",Oslash:"Ø",oslash:"ø",Otilde:"Õ",otilde:"õ",Ouml:"Ö",ouml:"ö",para:"¶",plusmn:"±",pound:"£",quot:'"',QUOT:'"',raquo:"»",reg:"®",REG:"®",sect:"§",shy:"",sup1:"¹",sup2:"²",sup3:"³",szlig:"ß",THORN:"Þ",thorn:"þ",times:"×",Uacute:"Ú",uacute:"ú",Ucirc:"Û",ucirc:"û",Ugrave:"Ù",ugrave:"ù",uml:"¨",Uuml:"Ü",uuml:"ü",Yacute:"Ý",yacute:"ý",yen:"¥",yuml:"ÿ"}},function(t,e){t.exports={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'}},function(t,e,r){function n(t,e,r){"object"==typeof t?(r=e,e=t,t=null):"function"==typeof e&&(r=e,e=c),this._callback=t,this._options=e||c,this._elementCB=r,this.dom=[],this._done=!1,this._tagStack=[],this._parser=this._parser||null}var i=r(21),o=/\s+/g,s=r(22),a=r(23),c={normalizeWhitespace:!1,withStartIndices:!1};n.prototype.onparserinit=function(t){this._parser=t},n.prototype.onreset=function(){n.call(this,this._callback,this._options,this._elementCB)},n.prototype.onend=function(){this._done||(this._done=!0,this._parser=null,this._handleCallback(null))},n.prototype._handleCallback=n.prototype.onerror=function(t){if("function"==typeof this._callback)this._callback(t,this.dom);else if(t)throw t},n.prototype.onclosetag=function(){var t=this._tagStack.pop();this._elementCB&&this._elementCB(t)},n.prototype._addDomElement=function(t){var e=this._tagStack[this._tagStack.length-1],r=e?e.children:this.dom,n=r[r.length-1];t.next=null,this._options.withStartIndices&&(t.startIndex=this._parser.startIndex),this._options.withDomLvl1&&(t.__proto__="tag"===t.type?a:s),n?(t.prev=n,n.next=t):t.prev=null,r.push(t),t.parent=e||null},n.prototype.onopentag=function(t,e){var r={type:"script"===t?i.Script:"style"===t?i.Style:i.Tag,name:t,attribs:e,children:[]};this._addDomElement(r),this._tagStack.push(r)},n.prototype.ontext=function(t){var e,r=this._options.normalizeWhitespace||this._options.ignoreWhitespace;!this._tagStack.length&&this.dom.length&&(e=this.dom[this.dom.length-1]).type===i.Text?r?e.data=(e.data+t).replace(o," "):e.data+=t:this._tagStack.length&&(e=this._tagStack[this._tagStack.length-1])&&(e=e.children[e.children.length-1])&&e.type===i.Text?r?e.data=(e.data+t).replace(o," "):e.data+=t:(r&&(t=t.replace(o," ")),this._addDomElement({data:t,type:i.Text}))},n.prototype.oncomment=function(t){var e=this._tagStack[this._tagStack.length-1];if(e&&e.type===i.Comment)return void(e.data+=t);var r={data:t,type:i.Comment};this.Line truncated
|
||||
* The buffer module from node.js, for the browser.
|
||||
*
|
||||
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
|
||||
* @license MIT
|
||||
*/
|
||||
"use strict";function i(){function t(){}try{var e=new Uint8Array(1);return e.foo=function(){return 42},e.constructor=t,42===e.foo()&&e.constructor===t&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(r){return!1}}function o(){return t.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function t(e){return this instanceof t?(t.TYPED_ARRAY_SUPPORT||(this.length=0,this.parent=void 0),"number"==typeof e?s(this,e):"string"==typeof e?a(this,e,arguments.length>1?arguments[1]:"utf8"):c(this,e)):arguments.length>1?new t(e,arguments[1]):new t(e)}function s(e,r){if(e=g(e,0>r?0:0|_(r)),!t.TYPED_ARRAY_SUPPORT)for(var n=0;r>n;n++)e[n]=0;return e}function a(t,e,r){"string"==typeof r&&""!==r||(r="utf8");var n=0|b(e,r);return t=g(t,n),t.write(e,r),t}function c(e,r){if(t.isBuffer(r))return u(e,r);if(X(r))return l(e,r);if(null==r)throw new TypeError("must start with number, buffer, array or string");if("undefined"!=typeof ArrayBuffer){if(r.buffer instanceof ArrayBuffer)return h(e,r);if(r instanceof ArrayBuffer)return f(e,r)}return r.length?p(e,r):d(e,r)}function u(t,e){var r=0|_(e.length);return t=g(t,r),e.copy(t,0,0,r),t}function l(t,e){var r=0|_(e.length);t=g(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function h(t,e){var r=0|_(e.length);t=g(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function f(e,r){return t.TYPED_ARRAY_SUPPORT?(r.byteLength,e=t._augment(new Uint8Array(r))):e=h(e,new Uint8Array(r)),e}function p(t,e){var r=0|_(e.length);t=g(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function d(t,e){var r,n=0;"Buffer"===e.type&&X(e.data)&&(r=e.data,n=0|_(r.length)),t=g(t,n);for(var i=0;n>i;i+=1)t[i]=255&r[i];return t}function g(e,r){t.TYPED_ARRAY_SUPPORT?(e=t._augment(new Uint8Array(r)),e.__proto__=t.prototype):(e.length=r,e._isBuffer=!0);var n=0!==r&&r<=t.poolSize>>>1;return n&&(e.parent=Q),e}function _(t){if(t>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function m(e,r){if(!(this instanceof m))return new m(e,r);var n=new t(e,r);return delete n.parent,n}function b(t,e){"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"binary":case"raw":case"raws":return r;case"utf8":case"utf-8":return H(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Y(t).length;default:if(n)return H(t).length;e=(""+e).toLowerCase(),n=!0}}function y(t,e,r){var n=!1;if(e=0|e,r=void 0===r||r===1/0?this.length:0|r,t||(t="utf8"),0>e&&(e=0),r>this.length&&(r=this.length),e>=r)return"";for(;;)switch(t){case"hex":return I(this,e,r);case"utf8":case"utf-8":return A(this,e,r);case"ascii":return O(this,e,r);case"binary":return C(this,e,r);case"base64":return T(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function v(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var o=e.length;if(o%2!==0)throw new Error("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;n>s;s++){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))throw new Error("Invalid hex string");t[r+s]=a}return s}function w(t,e,r,n){return W(H(e,t.length-r),t,r,n)}function S(t,e,r,n){return W(V(e),t,r,n)}function x(t,e,r,n){return S(t,e,r,n)}function E(t,e,r,n){return W(Y(e),t,r,n)}function k(t,e,r,n){return W(G(e,t.length-r),t,r,n)}function T(t,e,r){return 0===e&&r===t.length?K.fromByteArray(t):K.fromByteArray(t.slice(e,r))}function A(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;r>i;){var o=t[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(r>=i+a){var c,u,l,h;switch(a){case 1:128>o&&(s=o);break;case 2:c=t[i+1],128===(192&c)&&(h=(31&o)<<6|63&c,h>127&&(s=h));break;case 3:c=t[i+1],u=t[i+2],128===(192&c)&&128===(192&u)&&(h=(15&o)<<12|(63&c)<<6|63&u,h>2047&&(55296>h||h>57343)&&(s=h));break;case 4:c=t[i+1],u=t[i+2],l=t[i+3],128===(192&c)&&128===(192&u)&&128===(192&l)&&(h=(15&o)<<18|(63&c)<<12|(63&u)<<6|63&l,h>65535&&1114112>h&&(s=h))}}null===s?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),i+=a}return L(n)}function L(t){var e=t.length;if(Z>=e)return String.fromCharCode.apply(String,t);for(var r="",n=0;e>n;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Z));return r}function O(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(127&t[i]);return n}function C(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(t[i]);return n}function I(t,e,r){var n=t.length;(!e||0>e)&&(e=0),(!r||0>r||r>n)&&(r=n);for(var i="",o=e;r>o;o++)i+=z(t[o]);return i}function B(t,e,r){for(var n=t.slice(e,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function D(t,e,r){if(t%1!==0||0>t)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function N(e,r,n,i,o,s){if(!t.isBuffer(e))throw new TypeError("buffer muLine truncated
|
||||
}},function(t,e,r){function n(t,e){if(t){var r,n="";for(var i in t)r=t[i],n&&(n+=" "),n+=!r&&h[i]?i:i+'="'+(e.decodeEntities?l.encodeXML(r):r)+'"';return n}}function i(t,e){"svg"===t.name&&(e={decodeEntities:e.decodeEntities,xmlMode:!0});var r="<"+t.name,i=n(t.attribs,e);return i&&(r+=" "+i),!e.xmlMode||t.children&&0!==t.children.length?(r+=">",t.children&&(r+=d(t.children,e)),p[t.name]&&!e.xmlMode||(r+="</"+t.name+">")):r+="/>",r}function o(t){return"<"+t.data+">"}function s(t,e){var r=t.data||"";return!e.decodeEntities||t.parent&&t.parent.name in f||(r=l.encodeXML(r)),r}function a(t){return"<![CDATA["+t.children[0].data+"]]>"}function c(t){return"<!--"+t.data+"-->"}var u=r(47),l=r(48),h={__proto__:null,allowfullscreen:!0,async:!0,autofocus:!0,autoplay:!0,checked:!0,controls:!0,"default":!0,defer:!0,disabled:!0,hidden:!0,ismap:!0,loop:!0,multiple:!0,muted:!0,open:!0,readonly:!0,required:!0,reversed:!0,scoped:!0,seamless:!0,selected:!0,typemustmatch:!0},f={__proto__:null,style:!0,script:!0,xmp:!0,iframe:!0,noembed:!0,noframes:!0,plaintext:!0,noscript:!0},p={__proto__:null,area:!0,base:!0,basefont:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,isindex:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},d=t.exports=function(t,e){Array.isArray(t)||t.cheerio||(t=[t]),e=e||{};for(var r="",n=0;n<t.length;n++){var l=t[n];r+="root"===l.type?d(l.children,e):u.isTag(l)?i(l,e):l.type===u.Directive?o(l):l.type===u.Comment?c(l):l.type===u.CDATA?a(l):s(l,e)}return r}},function(t,e){t.exports={Text:"text",Directive:"directive",Comment:"comment",Script:"script",Style:"style",Tag:"tag",CDATA:"cdata",isTag:function(t){return"tag"===t.type||"script"===t.type||"style"===t.type}}},function(t,e,r){var n=r(49),i=r(50);e.decode=function(t,e){return(!e||0>=e?i.XML:i.HTML)(t)},e.decodeStrict=function(t,e){return(!e||0>=e?i.XML:i.HTMLStrict)(t)},e.encode=function(t,e){return(!e||0>=e?n.XML:n.HTML)(t)},e.encodeXML=n.XML,e.encodeHTML4=e.encodeHTML5=e.encodeHTML=n.HTML,e.decodeXML=e.decodeXMLStrict=i.XML,e.decodeHTML4=e.decodeHTML5=e.decodeHTML=i.HTML,e.decodeHTML4Strict=e.decodeHTML5Strict=e.decodeHTMLStrict=i.HTMLStrict,e.escape=n.escape},function(t,e,r){function n(t){return Object.keys(t).sort().reduce(function(e,r){return e[t[r]]="&"+r+";",e},{})}function i(t){var e=[],r=[];return Object.keys(t).forEach(function(t){1===t.length?e.push("\\"+t):r.push(t)}),r.unshift("["+e.join("")+"]"),new RegExp(r.join("|"),"g")}function o(t){return"&#x"+t.charCodeAt(0).toString(16).toUpperCase()+";"}function s(t){var e=t.charCodeAt(0),r=t.charCodeAt(1),n=1024*(e-55296)+r-56320+65536;return"&#x"+n.toString(16).toUpperCase()+";"}function a(t,e){function r(e){return t[e]}return function(t){return t.replace(e,r).replace(d,s).replace(p,o)}}function c(t){return t.replace(g,o).replace(d,s).replace(p,o)}var u=n(r(15)),l=i(u);e.XML=a(u,l);var h=n(r(13)),f=i(h);e.HTML=a(h,f);var p=/[^\0-\x7F]/g,d=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,g=i(u);e.escape=c},function(t,e,r){function n(t){var e=Object.keys(t).join("|"),r=o(t);e+="|#[xX][\\da-fA-F]+|#\\d+";var n=new RegExp("&(?:"+e+");","g");return function(t){return String(t).replace(n,r)}}function i(t,e){return e>t?1:-1}function o(t){return function(e){return"#"===e.charAt(1)?u("X"===e.charAt(2)||"x"===e.charAt(2)?parseInt(e.substr(3),16):parseInt(e.substr(2),10)):t[e.slice(1,-1)]}}var s=r(13),a=r(14),c=r(15),u=r(11),l=n(c),h=n(s),f=function(){function t(t){return";"!==t.substr(-1)&&(t+=";"),l(t)}for(var e=Object.keys(a).sort(i),r=Object.keys(s).sort(i),n=0,c=0;n<r.length;n++)e[c]===r[n]?(r[n]+=";?",c++):r[n]+=";";var u=new RegExp("&(?:"+r.join("|")+"|#[xX][\\da-fA-F]+;?|#\\d+;?)","g"),l=o(s);return function(e){return String(e).replace(u,t)}}();t.exports={XML:l,HTML:f,HTMLStrict:h}},function(t,e){var r=e.getChildren=function(t){return t.children},n=e.getParent=function(t){return t.parent};e.getSiblings=function(t){var e=n(t);return e?r(e):[t]},e.getAttributeValue=function(t,e){return t.attribs&&t.attribs[e]},e.hasAttrib=function(t,e){return!!t.attribs&&hasOwnProperty.call(t.attribs,e)},e.getName=function(t){return t.name}},function(t,e){e.removeElement=function(t){if(t.prev&&(t.prev.next=t.next),t.next&&(t.next.prev=t.prev),t.parent){var e=t.parent.children;e.splice(e.lastIndexOf(t),1)}},e.replaceElement=function(t,e){var r=e.prev=t.prev;r&&(r.next=e);var n=e.next=t.next;n&&(n.prev=e);var i=e.parent=t.parent;if(i){var o=i.children;o[o.lastIndexOf(t)]=e}},e.appendChild=function(t,e){if(e.parent=t,1!==t.children.push(e)){var r=t.children[t.children.length-2];r.next=e,e.prev=r,e.next=null}},e.append=function(t,e){var r=t.parent,n=t.next;if(e.next=n,e.prev=t,t.next=e,e.parent=r,n){if(n.prev=e,r){var i=r.children;i.splice(i.lastIndexOf(n),0,e)}}else r&&r.children.push(e)},e.prepend=function(t,e){var r=t.parent;if(r){var n=r.children;n.splice(n.lastIndexOf(t),0,e)}t.prev&&(t.prev.next=e),e.parent=r,e.prev=t.prev,e.next=t,t.prev=e}},function(t,e,r){function n(t,e,r,n){return Array.isArray(e)|Line truncated
|
||||
n.STACK_GLOW_OFF="STACK_GLOW_OFF",n.BLOCK_GLOW_ON="BLOCK_GLOW_ON",n.BLOCK_GLOW_OFF="BLOCK_GLOW_OFF",a.inherits(n,i),n.THREAD_STEP_INTERVAL=1e3/30,n.prototype._registerBlockPackages=function(){for(var t in c)if(c.hasOwnProperty(t)){var e=new c[t](this),r=e.getPrimitives();for(var n in r)r.hasOwnProperty(n)&&(this._primitives[n]=r[n].bind(e))}},n.prototype.getOpcodeFunction=function(t){return this._primitives[t]},n.prototype._pushThread=function(t){this.emit(n.STACK_GLOW_ON,t);var e=new s(t);this.threads.push(e)},n.prototype._removeThread=function(t){var e=this.threads.indexOf(t);e>-1&&(this.emit(n.STACK_GLOW_OFF,t.topBlock),this.threads.splice(e,1))},n.prototype.toggleStack=function(t){for(var e=0;e<this.threads.length;e++)if(this.threads[e].topBlock==t)return void this._removeThread(this.threads[e]);this._pushThread(t)},n.prototype.greenFlag=function(){for(var t=0;t<this.threads.length;t++)this._removeThread(this.threads[t]);for(var e=this.blocks.getStacks(),r=0;r<e.length;r++){var n=e[r];"event_whenflagclicked"===this.blocks.getBlock(n).opcode&&this._pushThread(e[r])}},n.prototype.startDistanceSensors=function(){for(var t=this.blocks.getStacks(),e=0;e<t.length;e++){var r=t[e];if("wedo_whendistanceclose"===this.blocks.getBlock(r).opcode){for(var n=!1,i=0;i<this.threads.length;i++)this.threads[i].topBlock===r&&(n=!0);n||this._pushThread(t[e])}}},n.prototype.stopAll=function(){for(var t=this.threads.slice();t.length>0;){for(var e=t.pop(),r=0;r<e.stack.length;r++)this.glowBlock(e.stack[r],!1);this._removeThread(e)}window["native"]&&window["native"].motorStop()},n.prototype._step=function(){for(var t=this.sequencer.stepThreads(this.threads),e=0;e<t.length;e++)this._removeThread(t[e])},n.prototype.glowBlock=function(t,e){e?this.emit(n.BLOCK_GLOW_ON,t):this.emit(n.BLOCK_GLOW_OFF,t)},n.prototype.start=function(){window.setInterval&&window.setInterval(function(){this._step()}.bind(this),n.THREAD_STEP_INTERVAL)},t.exports=n},function(t,e,r){function n(t){this.timer=new i,this.runtime=t}var i=r(120),o=r(121),s=r(122);n.WORK_TIME=10,n.DEBUG_BLOCK_CALLS=!0,n.prototype.stepThreads=function(t){this.timer.start();for(var e=[],r=0;t.length>0&&t.length>r&&this.timer.timeElapsed()<n.WORK_TIME;){for(var i=[],a=0;a<t.length;a++){var c=t[a];c.status===o.STATUS_RUNNING?this.stepThread(c):c.status===o.STATUS_YIELD?(s.resolve(c.yieldTimerId),r++):c.status===o.STATUS_DONE&&(c.status=o.STATUS_RUNNING),c.stack.length>0&&null===c.nextBlock&&c.status===o.STATUS_DONE&&(c.nextBlock=c.stack.pop(),null!==c.nextBlock&&c.status===o.STATUS_RUNNING),null===c.nextBlock&&c.status===o.STATUS_DONE?e.push(c):i.push(c)}t=i}return e},n.prototype.stepThread=function(t){var e=s.timerId,r=t.nextBlock;if(!r||!this.runtime.blocks.getBlock(r))return void(t.status=o.STATUS_DONE);t.nextBlock=this.runtime.blocks.getNextBlock(r);var i=this.runtime.blocks.getOpcode(r);t.stack.push(r),t.stack.length>t.stackFrames.length&&t.stackFrames.push({});var a=t.stackFrames[t.stackFrames.length-1],c=function(){t.status=o.STATUS_YIELD},u=this,l=function(){t.status=o.STATUS_DONE,t.nextBlock=u.runtime.blocks.getNextBlock(r),t.stack.pop(),t.stackFrames.pop(),u.runtime.glowBlock(r,!1)},h=function(t){for(var e=u.runtime.blocks.getStacks(),r=0;r<e.length;r++){var n=e[r],i=u.runtime.blocks.getBlock(n),o=t(i);if(o){for(var s=!1,a=0;a<u.runtime.threads.length;a++)if(u.runtime.threads[a].topBlock==n){s=!0;break}s||u.runtime._pushThread(n)}}},f=!1,p=function(){var e=u.runtime.blocks.getSubstack(r);e&&e.value?t.nextBlock=e.value:t.nextBlock=null,f=!0},d=[],g=this.runtime.blocks.getBlock(r).fields;for(var _ in g){var m=g[_];for(var b in m.blocks){var y=m.blocks[b],v=y.fields;for(var w in v){var S=v[w];d.push(S.value)}}}if(this.runtime.glowBlock(r,!0),i){var x=this.runtime.getOpcodeFunction(i);if(x){n.DEBUG_BLOCK_CALLS&&(console.groupCollapsed("Executing: "+i),console.log("with arguments: ",d),console.log("and stack frame: ",a));var E=null;try{E=x(d,{"yield":c,done:l,timeout:s.timeout,stackFrame:a,startSubstack:p,startHats:h})}catch(k){console.error("Exception calling block function for opcode: "+i+"\n"+k)}finally{s.timerId>e&&(t.yieldTimerId=s.timerId),t.status!==o.STATUS_RUNNING||f||l(),n.DEBUG_BLOCK_CALLS&&(console.log("ending stack frame: ",a),console.log("returned: ",E),console.groupEnd())}}else console.warn("Could not get implementation for opcode: "+i)}else console.warn("Could not get opcode for block: "+r)},t.exports=n},function(t,e){function r(){this.startTime=0}r.prototype.time=function(){return Date.now()},r.prototype.start=function(){this.startTime=this.time()},r.prototype.timeElapsed=function(){return this.time()-this.startTime},t.exports=r},function(t,e){function r(t){this.topBlock=t,this.nextBlock=t,this.stack=[],this.stackFrames=[],this.status=0,this.yieldTimerId=-1}r.STATUS_RUNNING=0,r.STATUS_YIELD=1,r.STATUS_DONE=2,t.exports=r},function(t,e,r){function n(){}var i=r(120);n.timers={},n.timerId=0,n.globalTimer=new i,n.timeout=function(t,e){var r=++n.timerId;return n.timerLine truncated
|
||||
"use strict";function i(){function t(){}try{var e=new Uint8Array(1);return e.foo=function(){return 42},e.constructor=t,42===e.foo()&&e.constructor===t&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(r){return!1}}function o(){return t.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function t(e){return this instanceof t?(t.TYPED_ARRAY_SUPPORT||(this.length=0,this.parent=void 0),"number"==typeof e?s(this,e):"string"==typeof e?a(this,e,arguments.length>1?arguments[1]:"utf8"):c(this,e)):arguments.length>1?new t(e,arguments[1]):new t(e)}function s(e,r){if(e=g(e,0>r?0:0|_(r)),!t.TYPED_ARRAY_SUPPORT)for(var n=0;r>n;n++)e[n]=0;return e}function a(t,e,r){"string"==typeof r&&""!==r||(r="utf8");var n=0|b(e,r);return t=g(t,n),t.write(e,r),t}function c(e,r){if(t.isBuffer(r))return u(e,r);if(J(r))return h(e,r);if(null==r)throw new TypeError("must start with number, buffer, array or string");if("undefined"!=typeof ArrayBuffer){if(r.buffer instanceof ArrayBuffer)return l(e,r);if(r instanceof ArrayBuffer)return p(e,r)}return r.length?f(e,r):d(e,r)}function u(t,e){var r=0|_(e.length);return t=g(t,r),e.copy(t,0,0,r),t}function h(t,e){var r=0|_(e.length);t=g(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function l(t,e){var r=0|_(e.length);t=g(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function p(e,r){return t.TYPED_ARRAY_SUPPORT?(r.byteLength,e=t._augment(new Uint8Array(r))):e=l(e,new Uint8Array(r)),e}function f(t,e){var r=0|_(e.length);t=g(t,r);for(var n=0;r>n;n+=1)t[n]=255&e[n];return t}function d(t,e){var r,n=0;"Buffer"===e.type&&J(e.data)&&(r=e.data,n=0|_(r.length)),t=g(t,n);for(var i=0;n>i;i+=1)t[i]=255&r[i];return t}function g(e,r){t.TYPED_ARRAY_SUPPORT?(e=t._augment(new Uint8Array(r)),e.__proto__=t.prototype):(e.length=r,e._isBuffer=!0);var n=0!==r&&r<=t.poolSize>>>1;return n&&(e.parent=Q),e}function _(t){if(t>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function m(e,r){if(!(this instanceof m))return new m(e,r);var n=new t(e,r);return delete n.parent,n}function b(t,e){"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"binary":case"raw":case"raws":return r;case"utf8":case"utf-8":return Y(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return H(t).length;default:if(n)return Y(t).length;e=(""+e).toLowerCase(),n=!0}}function y(t,e,r){var n=!1;if(e=0|e,r=void 0===r||r===1/0?this.length:0|r,t||(t="utf8"),0>e&&(e=0),r>this.length&&(r=this.length),e>=r)return"";for(;;)switch(t){case"hex":return R(this,e,r);case"utf8":case"utf-8":return A(this,e,r);case"ascii":return I(this,e,r);case"binary":return D(this,e,r);case"base64":return T(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function v(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var o=e.length;if(o%2!==0)throw new Error("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;n>s;s++){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))throw new Error("Invalid hex string");t[r+s]=a}return s}function w(t,e,r,n){return W(Y(e,t.length-r),t,r,n)}function S(t,e,r,n){return W(V(e),t,r,n)}function E(t,e,r,n){return S(t,e,r,n)}function k(t,e,r,n){return W(H(e),t,r,n)}function x(t,e,r,n){return W(z(e,t.length-r),t,r,n)}function T(t,e,r){return 0===e&&r===t.length?X.fromByteArray(t):X.fromByteArray(t.slice(e,r))}function A(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;r>i;){var o=t[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(r>=i+a){var c,u,h,l;switch(a){case 1:128>o&&(s=o);break;case 2:c=t[i+1],128===(192&c)&&(l=(31&o)<<6|63&c,l>127&&(s=l));break;case 3:c=t[i+1],u=t[i+2],128===(192&c)&&128===(192&u)&&(l=(15&o)<<12|(63&c)<<6|63&u,l>2047&&(55296>l||l>57343)&&(s=l));break;case 4:c=t[i+1],u=t[i+2],h=t[i+3],128===(192&c)&&128===(192&u)&&128===(192&h)&&(l=(15&o)<<18|(63&c)<<12|(63&u)<<6|63&h,l>65535&&1114112>l&&(s=l))}}null===s?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),i+=a}return L(n)}function L(t){var e=t.length;if(Z>=e)return String.fromCharCode.apply(String,t);for(var r="",n=0;e>n;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Z));return r}function I(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(127&t[i]);return n}function D(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(t[i]);return n}function R(t,e,r){var n=t.length;(!e||0>e)&&(e=0),(!r||0>r||r>n)&&(r=n);for(var i="",o=e;r>o;o++)i+=G(t[o]);return i}function N(t,e,r){for(var n=t.slice(e,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function O(t,e,r){if(t%1!==0||0>t)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function B(e,r,n,i,o,s){if(!t.isBuffer(e))throw new TypeError("buffer muLine truncated
|
||||
}},function(t,e,r){function n(t,e){if(t){var r,n="";for(var i in t)r=t[i],n&&(n+=" "),n+=!r&&l[i]?i:i+'="'+(e.decodeEntities?h.encodeXML(r):r)+'"';return n}}function i(t,e){"svg"===t.name&&(e={decodeEntities:e.decodeEntities,xmlMode:!0});var r="<"+t.name,i=n(t.attribs,e);return i&&(r+=" "+i),!e.xmlMode||t.children&&0!==t.children.length?(r+=">",t.children&&(r+=d(t.children,e)),f[t.name]&&!e.xmlMode||(r+="</"+t.name+">")):r+="/>",r}function o(t){return"<"+t.data+">"}function s(t,e){var r=t.data||"";return!e.decodeEntities||t.parent&&t.parent.name in p||(r=h.encodeXML(r)),r}function a(t){return"<![CDATA["+t.children[0].data+"]]>"}function c(t){return"<!--"+t.data+"-->"}var u=r(51),h=r(52),l={__proto__:null,allowfullscreen:!0,async:!0,autofocus:!0,autoplay:!0,checked:!0,controls:!0,"default":!0,defer:!0,disabled:!0,hidden:!0,ismap:!0,loop:!0,multiple:!0,muted:!0,open:!0,readonly:!0,required:!0,reversed:!0,scoped:!0,seamless:!0,selected:!0,typemustmatch:!0},p={__proto__:null,style:!0,script:!0,xmp:!0,iframe:!0,noembed:!0,noframes:!0,plaintext:!0,noscript:!0},f={__proto__:null,area:!0,base:!0,basefont:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,isindex:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},d=t.exports=function(t,e){Array.isArray(t)||t.cheerio||(t=[t]),e=e||{};for(var r="",n=0;n<t.length;n++){var h=t[n];r+="root"===h.type?d(h.children,e):u.isTag(h)?i(h,e):h.type===u.Directive?o(h):h.type===u.Comment?c(h):h.type===u.CDATA?a(h):s(h,e)}return r}},function(t,e){t.exports={Text:"text",Directive:"directive",Comment:"comment",Script:"script",Style:"style",Tag:"tag",CDATA:"cdata",isTag:function(t){return"tag"===t.type||"script"===t.type||"style"===t.type}}},function(t,e,r){var n=r(53),i=r(54);e.decode=function(t,e){return(!e||0>=e?i.XML:i.HTML)(t)},e.decodeStrict=function(t,e){return(!e||0>=e?i.XML:i.HTMLStrict)(t)},e.encode=function(t,e){return(!e||0>=e?n.XML:n.HTML)(t)},e.encodeXML=n.XML,e.encodeHTML4=e.encodeHTML5=e.encodeHTML=n.HTML,e.decodeXML=e.decodeXMLStrict=i.XML,e.decodeHTML4=e.decodeHTML5=e.decodeHTML=i.HTML,e.decodeHTML4Strict=e.decodeHTML5Strict=e.decodeHTMLStrict=i.HTMLStrict,e.escape=n.escape},function(t,e,r){function n(t){return Object.keys(t).sort().reduce(function(e,r){return e[t[r]]="&"+r+";",e},{})}function i(t){var e=[],r=[];return Object.keys(t).forEach(function(t){1===t.length?e.push("\\"+t):r.push(t)}),r.unshift("["+e.join("")+"]"),new RegExp(r.join("|"),"g")}function o(t){return"&#x"+t.charCodeAt(0).toString(16).toUpperCase()+";"}function s(t){var e=t.charCodeAt(0),r=t.charCodeAt(1),n=1024*(e-55296)+r-56320+65536;return"&#x"+n.toString(16).toUpperCase()+";"}function a(t,e){function r(e){return t[e]}return function(t){return t.replace(e,r).replace(d,s).replace(f,o)}}function c(t){return t.replace(g,o).replace(d,s).replace(f,o)}var u=n(r(19)),h=i(u);e.XML=a(u,h);var l=n(r(17)),p=i(l);e.HTML=a(l,p);var f=/[^\0-\x7F]/g,d=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,g=i(u);e.escape=c},function(t,e,r){function n(t){var e=Object.keys(t).join("|"),r=o(t);e+="|#[xX][\\da-fA-F]+|#\\d+";var n=new RegExp("&(?:"+e+");","g");return function(t){return String(t).replace(n,r)}}function i(t,e){return e>t?1:-1}function o(t){return function(e){return"#"===e.charAt(1)?u("X"===e.charAt(2)||"x"===e.charAt(2)?parseInt(e.substr(3),16):parseInt(e.substr(2),10)):t[e.slice(1,-1)]}}var s=r(17),a=r(18),c=r(19),u=r(15),h=n(c),l=n(s),p=function(){function t(t){return";"!==t.substr(-1)&&(t+=";"),h(t)}for(var e=Object.keys(a).sort(i),r=Object.keys(s).sort(i),n=0,c=0;n<r.length;n++)e[c]===r[n]?(r[n]+=";?",c++):r[n]+=";";var u=new RegExp("&(?:"+r.join("|")+"|#[xX][\\da-fA-F]+;?|#\\d+;?)","g"),h=o(s);return function(e){return String(e).replace(u,t)}}();t.exports={XML:h,HTML:p,HTMLStrict:l}},function(t,e){var r=e.getChildren=function(t){return t.children},n=e.getParent=function(t){return t.parent};e.getSiblings=function(t){var e=n(t);return e?r(e):[t]},e.getAttributeValue=function(t,e){return t.attribs&&t.attribs[e]},e.hasAttrib=function(t,e){return!!t.attribs&&hasOwnProperty.call(t.attribs,e)},e.getName=function(t){return t.name}},function(t,e){e.removeElement=function(t){if(t.prev&&(t.prev.next=t.next),t.next&&(t.next.prev=t.prev),t.parent){var e=t.parent.children;e.splice(e.lastIndexOf(t),1)}},e.replaceElement=function(t,e){var r=e.prev=t.prev;r&&(r.next=e);var n=e.next=t.next;n&&(n.prev=e);var i=e.parent=t.parent;if(i){var o=i.children;o[o.lastIndexOf(t)]=e}},e.appendChild=function(t,e){if(e.parent=t,1!==t.children.push(e)){var r=t.children[t.children.length-2];r.next=e,e.prev=r,e.next=null}},e.append=function(t,e){var r=t.parent,n=t.next;if(e.next=n,e.prev=t,t.next=e,e.parent=r,n){if(n.prev=e,r){var i=r.children;i.splice(i.lastIndexOf(n),0,e)}}else r&&r.children.push(e)},e.prepend=function(t,e){var r=t.parent;if(r){var n=r.children;n.splice(n.lastIndexOf(t),0,e)}t.prev&&(t.prev.next=e),e.parent=r,e.prev=t.prev,e.next=t,t.prev=e}},function(t,e,r){function n(t,e,r,n){return Array.isArray(e)|Line truncated
|
||||
return e.ioQuery("mouse","getY")},r.prototype.getMouseDown=function(t,e){return e.ioQuery("mouse","getIsDown")},t.exports=r}]);
|
||||
@@ -97,6 +97,14 @@
|
||||
this.vmWorker.postMessage({method: 'getPlaygroundData'});
|
||||
};
|
||||
|
||||
VirtualMachine.prototype.postIOData = function (device, data) {
|
||||
this.vmWorker.postMessage({
|
||||
method: 'postIOData',
|
||||
device: device,
|
||||
data: data
|
||||
});
|
||||
};
|
||||
|
||||
VirtualMachine.prototype.start = function () {
|
||||
this.vmWorker.postMessage({method: 'start'});
|
||||
};
|
||||
@@ -109,6 +117,10 @@
|
||||
this.vmWorker.postMessage({method: 'stopAll'});
|
||||
};
|
||||
|
||||
VirtualMachine.prototype.animationFrame = function () {
|
||||
this.vmWorker.postMessage({method: 'animationFrame'});
|
||||
};
|
||||
|
||||
/**
|
||||
* Export and bind to `window`
|
||||
*/
|
||||
@@ -1026,6 +1038,9 @@
|
||||
var queueIndex = -1;
|
||||
|
||||
function cleanUpNextTick() {
|
||||
if (!draining || !currentQueue) {
|
||||
return;
|
||||
}
|
||||
draining = false;
|
||||
if (currentQueue.length) {
|
||||
queue = currentQueue.concat(queue);
|
||||
|
||||
Reference in new issue
Block a user