mirror of
https://github.com/google/blockly.git
synced 2026-02-14 03:20:11 +01:00
Rebuild
This commit is contained in:
39
node_modules/@blockly/block-test/README.md
generated
vendored
Normal file
39
node_modules/@blockly/block-test/README.md
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
# @blockly/block-test [](https://github.com/google/blockly)
|
||||
|
||||
A set of [Blockly](https://www.npmjs.com/package/blockly) test blocks.
|
||||
|
||||
## Installation
|
||||
|
||||
### Yarn
|
||||
|
||||
```
|
||||
yarn add @blockly/block-test
|
||||
```
|
||||
|
||||
### npm
|
||||
|
||||
```
|
||||
npm install @blockly/block-test --save
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Import
|
||||
|
||||
```js
|
||||
import * as Blockly from 'blockly';
|
||||
import {toolboxTestBlocks, toolboxTestBlocksInit} from '@blockly/block-test';
|
||||
|
||||
// Configure the Blockly workspace to use the test block's toolbox.
|
||||
const workspace = Blockly.inject('blocklyDiv', {
|
||||
...options
|
||||
toolbox: toolboxTestBlocks,
|
||||
});
|
||||
|
||||
// Initalize the test block's toolbox.
|
||||
toolboxTestBlocksInit(workspace);
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
Apache 2.0
|
||||
3
node_modules/@blockly/block-test/dist/index.js
generated
vendored
Normal file
3
node_modules/@blockly/block-test/dist/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
17
node_modules/@blockly/block-test/dist/index.js.LICENSE.txt
generated
vendored
Normal file
17
node_modules/@blockly/block-test/dist/index.js.LICENSE.txt
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2020 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2021 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2024 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
1
node_modules/@blockly/block-test/dist/index.js.map
generated
vendored
Normal file
1
node_modules/@blockly/block-test/dist/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
55
node_modules/@blockly/block-test/package.json
generated
vendored
Normal file
55
node_modules/@blockly/block-test/package.json
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
{
|
||||
"name": "@blockly/block-test",
|
||||
"version": "6.0.8",
|
||||
"description": "A group of Blockly test blocks.",
|
||||
"scripts": {
|
||||
"audit:fix": "blockly-scripts auditFix",
|
||||
"build": "blockly-scripts build",
|
||||
"clean": "blockly-scripts clean",
|
||||
"lint": "eslint .",
|
||||
"prepublishOnly": "npm run clean && npm run build",
|
||||
"start": "blockly-scripts start"
|
||||
},
|
||||
"main": "./dist/index.js",
|
||||
"module": "./src/index.js",
|
||||
"unpkg": "./dist/index.js",
|
||||
"author": "Blockly Team",
|
||||
"keywords": [
|
||||
"blockly",
|
||||
"blockly-plugin",
|
||||
"blockly-block",
|
||||
"test"
|
||||
],
|
||||
"homepage": "https://github.com/google/blockly-samples/tree/master/plugins/block-test#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/google/blockly-samples/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/google/blockly-samples.git",
|
||||
"directory": "plugins/block-test"
|
||||
},
|
||||
"license": "Apache 2.0",
|
||||
"directories": {
|
||||
"dist": "dist",
|
||||
"src": "src"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"src"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@blockly/dev-scripts": "^4.0.5"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"blockly": "^11.0.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"registry": "https://wombat-dressing-room.appspot.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8.17.0"
|
||||
},
|
||||
"gitHead": "7d3e23fe66828ac9448e2ae64697574493549ee3"
|
||||
}
|
||||
109
node_modules/@blockly/block-test/src/align.js
generated
vendored
Normal file
109
node_modules/@blockly/block-test/src/align.js
generated
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2020 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @fileoverview Align test blocks.
|
||||
* @author samelh@google.com (Sam El-Husseini)
|
||||
*/
|
||||
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
Blockly.defineBlocksWithJsonArray([
|
||||
{
|
||||
type: 'test_align_dummy_right',
|
||||
message0: 'text right %1 long text right %2',
|
||||
args0: [
|
||||
{
|
||||
type: 'input_dummy',
|
||||
align: 'RIGHT',
|
||||
},
|
||||
{
|
||||
type: 'input_dummy',
|
||||
align: 'RIGHT',
|
||||
},
|
||||
],
|
||||
style: 'math_blocks',
|
||||
},
|
||||
{
|
||||
type: 'test_align_all',
|
||||
message0:
|
||||
'text %1 long text left %2 text centre %3 much longer text ' + 'right %4',
|
||||
args0: [
|
||||
{
|
||||
type: 'input_dummy',
|
||||
},
|
||||
{
|
||||
type: 'input_dummy',
|
||||
align: 'LEFT',
|
||||
},
|
||||
{
|
||||
type: 'input_dummy',
|
||||
align: 'CENTRE',
|
||||
},
|
||||
{
|
||||
type: 'input_dummy',
|
||||
align: 'RIGHT',
|
||||
},
|
||||
],
|
||||
style: 'math_blocks',
|
||||
},
|
||||
{
|
||||
type: 'test_align_with_external_input',
|
||||
message0:
|
||||
'text right %1 long text centre %2 text left %3 much longer ' + 'text %4',
|
||||
args0: [
|
||||
{
|
||||
type: 'input_dummy',
|
||||
align: 'RIGHT',
|
||||
},
|
||||
{
|
||||
type: 'input_dummy',
|
||||
align: 'CENTRE',
|
||||
},
|
||||
{
|
||||
type: 'input_dummy',
|
||||
align: 'LEFT',
|
||||
},
|
||||
{
|
||||
type: 'input_value',
|
||||
name: 'VALUE',
|
||||
},
|
||||
],
|
||||
inputsInline: false,
|
||||
style: 'math_blocks',
|
||||
},
|
||||
]);
|
||||
|
||||
/**
|
||||
* The Align category.
|
||||
*/
|
||||
export const category = {
|
||||
kind: 'CATEGORY',
|
||||
name: 'Align',
|
||||
contents: [
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_align_dummy_right',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_align_all',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_align_with_external_input',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize this toolbox category.
|
||||
* @param {!Blockly.WorkspaceSvg} workspace The Blockly workspace.
|
||||
*/
|
||||
export function onInit(workspace) {
|
||||
// NOP
|
||||
}
|
||||
219
node_modules/@blockly/block-test/src/basic.js
generated
vendored
Normal file
219
node_modules/@blockly/block-test/src/basic.js
generated
vendored
Normal file
@@ -0,0 +1,219 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2020 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @fileoverview Basic test blocks.
|
||||
* @author samelh@google.com (Sam El-Husseini)
|
||||
*/
|
||||
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
Blockly.defineBlocksWithJsonArray([
|
||||
{
|
||||
type: 'test_basic_empty',
|
||||
message0: '',
|
||||
args0: [],
|
||||
},
|
||||
{
|
||||
type: 'test_basic_stack',
|
||||
message0: 'stack block',
|
||||
previousStatement: null,
|
||||
nextStatement: null,
|
||||
colour: '120',
|
||||
},
|
||||
{
|
||||
type: 'test_basic_dummy',
|
||||
message0: 'dummy input %1',
|
||||
args0: [
|
||||
{
|
||||
type: 'input_dummy',
|
||||
},
|
||||
],
|
||||
style: 'math_blocks',
|
||||
},
|
||||
{
|
||||
type: 'test_basic_multiple_dummy',
|
||||
message0: 'first dummy %1 second dummy %2',
|
||||
args0: [
|
||||
{
|
||||
type: 'input_dummy',
|
||||
},
|
||||
{
|
||||
type: 'input_dummy',
|
||||
},
|
||||
],
|
||||
style: 'math_blocks',
|
||||
},
|
||||
{
|
||||
type: 'test_basic_row',
|
||||
message0: 'row block %1',
|
||||
args0: [
|
||||
{
|
||||
type: 'input_value',
|
||||
name: 'INPUT',
|
||||
},
|
||||
],
|
||||
output: null,
|
||||
style: 'math_blocks',
|
||||
},
|
||||
{
|
||||
type: 'test_basic_value_to_stack',
|
||||
message0: 'value to stack',
|
||||
nextStatement: null,
|
||||
output: null,
|
||||
style: 'math_blocks',
|
||||
},
|
||||
{
|
||||
type: 'test_basic_value_to_statement',
|
||||
message0: 'value to statement %1',
|
||||
args0: [
|
||||
{
|
||||
type: 'input_statement',
|
||||
name: 'STATEMENT',
|
||||
},
|
||||
],
|
||||
output: null,
|
||||
style: 'math_blocks',
|
||||
},
|
||||
{
|
||||
type: 'test_basic_limit_instances',
|
||||
message0: 'limit 3 instances %1 %2',
|
||||
args0: [
|
||||
{
|
||||
type: 'input_dummy',
|
||||
},
|
||||
{
|
||||
type: 'input_statement',
|
||||
name: 'STATEMENT',
|
||||
},
|
||||
],
|
||||
previousStatement: null,
|
||||
nextStatement: null,
|
||||
style: 'math_blocks',
|
||||
},
|
||||
{
|
||||
type: 'test_basic_tooltips',
|
||||
message0: '%1 %2 %3',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_label',
|
||||
name: 'NAME',
|
||||
text: 'field tooltip',
|
||||
tooltip: 'This is a JSON tooltip for the *field*.',
|
||||
},
|
||||
{
|
||||
type: 'input_dummy',
|
||||
},
|
||||
{
|
||||
type: 'field_label',
|
||||
name: 'NAME',
|
||||
text: 'block tooltip',
|
||||
},
|
||||
],
|
||||
tooltip: 'This is a JSON tooltip for the *block*.',
|
||||
style: 'math_blocks',
|
||||
},
|
||||
{
|
||||
type: 'test_basic_javascript',
|
||||
message0: 'function %1(%2) { %3 %4 return %5 }',
|
||||
args0: [
|
||||
'foo',
|
||||
'args',
|
||||
{
|
||||
type: 'input_dummy',
|
||||
},
|
||||
{
|
||||
type: 'input_statement',
|
||||
name: 'STACK',
|
||||
},
|
||||
{
|
||||
type: 'input_value',
|
||||
check: 'number',
|
||||
align: 'right',
|
||||
name: 'RETURN',
|
||||
},
|
||||
],
|
||||
inputsInline: true,
|
||||
colour: 200,
|
||||
tooltip: 'Hello world.',
|
||||
},
|
||||
]);
|
||||
|
||||
Blockly.Blocks['test_basic_empty_with_mutator'] = {
|
||||
init: function () {
|
||||
this.setMutator(new Blockly.icons.MutatorIcon(['math_number'], this));
|
||||
},
|
||||
|
||||
decompose: function (workspace) {
|
||||
const topBlock = workspace.newBlock('math_number');
|
||||
topBlock.initSvg();
|
||||
return topBlock;
|
||||
},
|
||||
compose: function () {},
|
||||
};
|
||||
|
||||
/**
|
||||
* The Basic Category.
|
||||
*/
|
||||
export const category = {
|
||||
kind: 'CATEGORY',
|
||||
name: 'Basic',
|
||||
contents: [
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_basic_empty',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_basic_empty_with_mutator',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_basic_dummy',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_basic_multiple_dummy',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_basic_stack',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_basic_row',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_basic_value_to_stack',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_basic_value_to_statement',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_basic_limit_instances',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_basic_tooltips',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_basic_javascript',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize this toolbox category.
|
||||
* @param {!Blockly.WorkspaceSvg} workspace The Blockly workspace.
|
||||
*/
|
||||
export function onInit(workspace) {
|
||||
// NOP
|
||||
}
|
||||
61
node_modules/@blockly/block-test/src/chameleon.js
generated
vendored
Normal file
61
node_modules/@blockly/block-test/src/chameleon.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2024 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @fileoverview Blocks that have both a previous connection and an output
|
||||
* connection while they are being dragged.
|
||||
*/
|
||||
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
Blockly.Blocks['test_chameleon'] = {
|
||||
hasOutput: true,
|
||||
hasPrevious: true,
|
||||
|
||||
init: function () {
|
||||
this.appendDummyInput().appendField('chameleon');
|
||||
this.setColour(120);
|
||||
this.updateShape();
|
||||
},
|
||||
|
||||
onchange: function (e) {
|
||||
if (e.type === Blockly.Events.BLOCK_DRAG) {
|
||||
console.log('got drag event');
|
||||
this.hasPrevious =
|
||||
!this.outputConnection || !this.outputConnection.targetBlock();
|
||||
this.hasOutput = !this.getPreviousBlock();
|
||||
this.updateShape();
|
||||
}
|
||||
},
|
||||
|
||||
updateShape: function () {
|
||||
this.setPreviousStatement(this.hasPrevious);
|
||||
this.setOutput(this.hasOutput);
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* The Chameleon Category.
|
||||
*/
|
||||
export const category = {
|
||||
kind: 'CATEGORY',
|
||||
name: 'Chameleon',
|
||||
contents: [
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_chameleon',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize this toolbox category.
|
||||
* @param {!Blockly.WorkspaceSvg} workspace The Blockly workspace.
|
||||
*/
|
||||
export function onInit(workspace) {
|
||||
// NOP
|
||||
}
|
||||
38
node_modules/@blockly/block-test/src/connections/index.js
generated
vendored
Normal file
38
node_modules/@blockly/block-test/src/connections/index.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2020 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @fileoverview Connection test blocks.
|
||||
* @author samelh@google.com (Sam El-Husseini)
|
||||
*/
|
||||
|
||||
import {category as rowCategory, onInit as initRow} from './row';
|
||||
import {category as stackCategory, onInit as initStack} from './stack';
|
||||
import {
|
||||
category as statementCategory,
|
||||
onInit as initStatement,
|
||||
} from './statement';
|
||||
|
||||
/**
|
||||
* The Connections category.
|
||||
*/
|
||||
export const category = {
|
||||
kind: 'CATEGORY',
|
||||
name: 'Connections',
|
||||
expanded: 'true',
|
||||
contents: [rowCategory, stackCategory, statementCategory],
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize this toolbox category.
|
||||
* @param {!Blockly.WorkspaceSvg} workspace The Blockly workspace.
|
||||
*/
|
||||
export function onInit(workspace) {
|
||||
initRow(workspace);
|
||||
initStack(workspace);
|
||||
initStatement(workspace);
|
||||
}
|
||||
290
node_modules/@blockly/block-test/src/connections/row.js
generated
vendored
Normal file
290
node_modules/@blockly/block-test/src/connections/row.js
generated
vendored
Normal file
@@ -0,0 +1,290 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2020 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @fileoverview Row connection test blocks.
|
||||
* @author samelh@google.com (Sam El-Husseini)
|
||||
*/
|
||||
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
Blockly.defineBlocksWithJsonArray([
|
||||
{
|
||||
type: 'test_connections_row_input',
|
||||
message0: '%1',
|
||||
args0: [
|
||||
{
|
||||
type: 'input_value',
|
||||
name: 'NAME',
|
||||
},
|
||||
],
|
||||
colour: '#aaaaaa',
|
||||
tooltip: 'No Checks\n' + 'Can connect to any output connection.',
|
||||
},
|
||||
{
|
||||
type: 'test_connections_row_blue',
|
||||
message0: '%1',
|
||||
args0: [
|
||||
{
|
||||
type: 'input_value',
|
||||
name: 'NAME',
|
||||
check: 'greenRel',
|
||||
},
|
||||
],
|
||||
output: 'noneOut',
|
||||
colour: 230,
|
||||
tooltip:
|
||||
'Output: noneOut\n' +
|
||||
'Input: greenRel\n' +
|
||||
'Input connection can accept yellow blocks but not red blocks.',
|
||||
},
|
||||
{
|
||||
type: 'test_connections_row_yellow',
|
||||
message0: '%1',
|
||||
args0: [
|
||||
{
|
||||
type: 'input_value',
|
||||
name: 'NAME',
|
||||
check: ['orangeRel', 'yellowRel'],
|
||||
},
|
||||
],
|
||||
output: ['yellowRel', 'greenRel'],
|
||||
colour: 60,
|
||||
tooltip:
|
||||
'Output: yellowRel, greenRel\n' +
|
||||
'Input: yellowRel, orangeRel\n' +
|
||||
'Output can connect to yellow blocks and blue blocks, but not red ' +
|
||||
'blocks.\n' +
|
||||
'Input can connect to yellow blocks and red blocks, but not blue ' +
|
||||
'blocks.',
|
||||
},
|
||||
{
|
||||
type: 'test_connections_row_red',
|
||||
message0: '%1',
|
||||
args0: [
|
||||
{
|
||||
type: 'input_value',
|
||||
name: 'NAME',
|
||||
check: 'noneIn',
|
||||
},
|
||||
],
|
||||
output: 'orangeRel',
|
||||
colour: 0,
|
||||
tooltip:
|
||||
'Output: orangeRel\n' +
|
||||
'Input: noneIn\n' +
|
||||
'Output can connect to yellow blocks, but not blue blocks.',
|
||||
},
|
||||
{
|
||||
type: 'test_connections_row_output',
|
||||
message0: '',
|
||||
output: null,
|
||||
colour: '#aaaaaa',
|
||||
tooltip: 'No Checks\n' + 'Can connect to any input connection.',
|
||||
},
|
||||
|
||||
{
|
||||
type: 'test_connections_multivalue_1valid',
|
||||
message0: 'none %1 both %2',
|
||||
args0: [
|
||||
{
|
||||
type: 'input_value',
|
||||
name: 'NAME1',
|
||||
align: 'RIGHT',
|
||||
check: 'noneIn',
|
||||
},
|
||||
{
|
||||
type: 'input_value',
|
||||
name: 'NAME2',
|
||||
align: 'RIGHT',
|
||||
check: ['yellowRel', 'orangeRel'],
|
||||
},
|
||||
],
|
||||
output: ['yellowRel', 'greenRel'],
|
||||
colour: 60,
|
||||
tooltip:
|
||||
'Output: yellowRel, greenRel\n' +
|
||||
'Input Top: noneIn\n' +
|
||||
'Input Bottom: yellowRel, orangeRel\n' +
|
||||
'Output can connect to yellow blocks and blue blocks, but not red' +
|
||||
' blocks.\n' +
|
||||
'Top Input can connect to nothing, except grey blocks.\n' +
|
||||
'Bottom Input can connect to yellow blocks and red blocks, but not' +
|
||||
' blue blocks.',
|
||||
},
|
||||
{
|
||||
type: 'test_connections_multivalue_2valid',
|
||||
message0: 'both %1 both %2',
|
||||
args0: [
|
||||
{
|
||||
type: 'input_value',
|
||||
name: 'NAME1',
|
||||
align: 'RIGHT',
|
||||
check: ['yellowRel', 'orangeRel'],
|
||||
},
|
||||
{
|
||||
type: 'input_value',
|
||||
name: 'NAME2',
|
||||
align: 'RIGHT',
|
||||
check: ['yellowRel', 'orangeRel'],
|
||||
},
|
||||
],
|
||||
output: ['yellowRel', 'greenRel'],
|
||||
colour: 60,
|
||||
tooltip:
|
||||
'Output: yellowRel, greenRel\n' +
|
||||
'Input Top: yellowRel, orangeRel\n' +
|
||||
'Input Bottom: yellowRel, orangeRel\n' +
|
||||
'Output can connect to yellow blocks and blue blocks, but not red' +
|
||||
' blocks.\n' +
|
||||
'Top Input can connect to yellow blocks and red blocks, but not blue' +
|
||||
' blocks.\n' +
|
||||
'Bottom Input can connect to yellow blocks and red blocks, but not' +
|
||||
' blue blocks.',
|
||||
},
|
||||
]);
|
||||
|
||||
/**
|
||||
* Handles "insert" button in the connection row test category. This will insert
|
||||
* a group of test blocks connected in a row.
|
||||
* @param {!Blockly.FlyoutButton} button The Flyout button.
|
||||
*/
|
||||
const insertConnectionRows = function (button) {
|
||||
const workspace = button.getTargetWorkspace();
|
||||
Blockly.Xml.domToWorkspace(
|
||||
Blockly.utils.xml.textToDom(
|
||||
'<xml xmlns="https://developers.google.com/blockly/xml">\n' +
|
||||
' <block type="test_connections_row_input">\n' +
|
||||
' <value name="NAME">\n' +
|
||||
' <block type="test_connections_row_blue">\n' +
|
||||
' <value name="NAME">\n' +
|
||||
' <block type="test_connections_row_yellow">\n' +
|
||||
' <value name="NAME">\n' +
|
||||
' <block type="test_connections_row_yellow">\n' +
|
||||
' <value name="NAME">\n' +
|
||||
' <block type="test_connections_row_red">\n' +
|
||||
' <value name="NAME">\n' +
|
||||
' <block type="test_connections_row_output"/>\n' +
|
||||
' </value>\n' +
|
||||
' </block>\n' +
|
||||
' </value>\n' +
|
||||
' </block>\n' +
|
||||
' </value>\n' +
|
||||
' </block>\n' +
|
||||
' </value>\n' +
|
||||
' </block>\n' +
|
||||
' </value>\n' +
|
||||
' </block>\n' +
|
||||
'</xml>',
|
||||
),
|
||||
workspace,
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* The Row connections category.
|
||||
*/
|
||||
export const category = {
|
||||
kind: 'CATEGORY',
|
||||
name: 'Row',
|
||||
contents: [
|
||||
{
|
||||
kind: 'LABEL',
|
||||
text: 'blocks have',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '-1',
|
||||
},
|
||||
{
|
||||
kind: 'LABEL',
|
||||
text: 'tooltips',
|
||||
},
|
||||
{
|
||||
kind: 'BUTTON',
|
||||
text: 'insert',
|
||||
callbackkey: 'insertConnectionRows',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '7',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_connections_row_input',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '7',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_connections_row_blue',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '7',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_connections_row_yellow',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '7',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_connections_row_red',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '7',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_connections_row_output',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
blockxml: `
|
||||
<block type="test_connections_row_yellow">
|
||||
<value name="NAME">
|
||||
<block type="test_connections_row_yellow" movable="false">
|
||||
</block>
|
||||
</value>
|
||||
</block>`,
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '7',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_connections_multivalue_1valid',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '7',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_connections_multivalue_2valid',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize this toolbox category.
|
||||
* @param {!Blockly.WorkspaceSvg} workspace The Blockly workspace.
|
||||
*/
|
||||
export function onInit(workspace) {
|
||||
workspace.registerButtonCallback(
|
||||
'insertConnectionRows',
|
||||
insertConnectionRows,
|
||||
);
|
||||
}
|
||||
190
node_modules/@blockly/block-test/src/connections/stack.js
generated
vendored
Normal file
190
node_modules/@blockly/block-test/src/connections/stack.js
generated
vendored
Normal file
@@ -0,0 +1,190 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2020 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @fileoverview Stack connection test blocks.
|
||||
* @author samelh@google.com (Sam El-Husseini)
|
||||
*/
|
||||
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
Blockly.defineBlocksWithJsonArray([
|
||||
{
|
||||
type: 'test_connections_stack_next',
|
||||
message0: '',
|
||||
nextStatement: null,
|
||||
colour: '#aaaaaa',
|
||||
tooltip: 'No Checks\n' + 'Can connect to any previous connection.',
|
||||
},
|
||||
{
|
||||
type: 'test_connections_stack_blue',
|
||||
message0: '',
|
||||
previousStatement: 'nonePrev',
|
||||
nextStatement: 'greenRel',
|
||||
colour: 230,
|
||||
tooltip:
|
||||
'Prev: nonePrev\n' +
|
||||
'Next: greenRel\n' +
|
||||
'Next connection can accept yellow blocks but not red blocks.',
|
||||
},
|
||||
{
|
||||
type: 'test_connections_stack_yellow',
|
||||
message0: '',
|
||||
previousStatement: ['greenRel', 'yellowRel'],
|
||||
nextStatement: ['yellowRel', 'orangeRel'],
|
||||
colour: 60,
|
||||
tooltip:
|
||||
'Prev: yellowRel, greenRel\n' +
|
||||
'Next: yellowRel, orangeRel\n' +
|
||||
'Prev can connect to yellow blocks and blue blocks, but not red' +
|
||||
' blocks.\n' +
|
||||
'Next can connect to yellow blocks and red blocks, but not blue' +
|
||||
' blocks.',
|
||||
},
|
||||
{
|
||||
type: 'test_connections_stack_red',
|
||||
message0: '',
|
||||
previousStatement: 'orangeRel',
|
||||
nextStatement: 'noneNext',
|
||||
colour: 0,
|
||||
tooltip:
|
||||
'Prev: orangeRel\n' +
|
||||
'Next: noneNext\n' +
|
||||
'Prev can connect to yellow blocks, but not blue blocks.',
|
||||
},
|
||||
{
|
||||
type: 'test_connections_stack_prev',
|
||||
message0: '',
|
||||
previousStatement: null,
|
||||
colour: '#aaaaaa',
|
||||
tooltip: 'No Checks\n' + 'Can connect to any input connection.',
|
||||
},
|
||||
]);
|
||||
|
||||
/**
|
||||
* Handles "insert" button in the connection stack test category. This will
|
||||
* insert a group of test blocks connected in a stack.
|
||||
* @param {!Blockly.FlyoutButton} button The flyout button.
|
||||
*/
|
||||
const insertConnectionStacks = function (button) {
|
||||
const workspace = button.getTargetWorkspace();
|
||||
Blockly.Xml.domToWorkspace(
|
||||
Blockly.utils.xml.textToDom(
|
||||
'<xml xmlns="https://developers.google.com/blockly/xml">\n' +
|
||||
' <block type="test_connections_stack_next">\n' +
|
||||
' <next>\n' +
|
||||
' <block type="test_connections_stack_blue">\n' +
|
||||
' <next>\n' +
|
||||
' <block type="test_connections_stack_yellow">\n' +
|
||||
' <next>\n' +
|
||||
' <block type="test_connections_stack_yellow">\n' +
|
||||
' <next>\n' +
|
||||
' <block type="test_connections_stack_red">\n' +
|
||||
' <next>\n' +
|
||||
' <block type="test_connections_stack_prev"/>\n' +
|
||||
' </next>\n' +
|
||||
' </block>\n' +
|
||||
' </next>\n' +
|
||||
' </block>\n' +
|
||||
' </next>\n' +
|
||||
' </block>\n' +
|
||||
' </next>\n' +
|
||||
' </block>\n' +
|
||||
' </next>\n' +
|
||||
' </block>\n' +
|
||||
'</xml>',
|
||||
),
|
||||
workspace,
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* The Stack connections category.
|
||||
*/
|
||||
export const category = {
|
||||
kind: 'CATEGORY',
|
||||
name: 'Stack',
|
||||
contents: [
|
||||
{
|
||||
kind: 'LABEL',
|
||||
text: 'blocks have',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '-1',
|
||||
},
|
||||
{
|
||||
kind: 'LABEL',
|
||||
text: 'tooltips',
|
||||
},
|
||||
{
|
||||
kind: 'BUTTON',
|
||||
text: 'insert',
|
||||
callbackkey: 'insertConnectionStacks',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '7',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_connections_stack_next',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '7',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_connections_stack_blue',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '7',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_connections_stack_yellow',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '7',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_connections_stack_red',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '7',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_connections_stack_prev',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
blockxml: `
|
||||
<block type="test_connections_stack_yellow">
|
||||
<next>
|
||||
<block type="test_connections_stack_yellow" movable="false"></block>
|
||||
</next>
|
||||
</block>`,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize this toolbox category.
|
||||
* @param {!Blockly.WorkspaceSvg} workspace The Blockly workspace.
|
||||
*/
|
||||
export function onInit(workspace) {
|
||||
workspace.registerButtonCallback(
|
||||
'insertConnectionStacks',
|
||||
insertConnectionStacks,
|
||||
);
|
||||
}
|
||||
267
node_modules/@blockly/block-test/src/connections/statement.js
generated
vendored
Normal file
267
node_modules/@blockly/block-test/src/connections/statement.js
generated
vendored
Normal file
@@ -0,0 +1,267 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2020 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @fileoverview Statement connection test blocks.
|
||||
* @author samelh@google.com (Sam El-Husseini)
|
||||
*/
|
||||
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
Blockly.defineBlocksWithJsonArray([
|
||||
{
|
||||
type: 'test_connections_statement_blue',
|
||||
message0: '%1',
|
||||
args0: [
|
||||
{
|
||||
type: 'input_statement',
|
||||
name: 'NAME',
|
||||
check: 'greenRel',
|
||||
},
|
||||
],
|
||||
previousStatement: 'nonePrev',
|
||||
nextStatement: 'greenRel',
|
||||
colour: 230,
|
||||
tooltip:
|
||||
'Prev: nonePrev\n' +
|
||||
'Next: greenRel\n' +
|
||||
'Statement: greenRel\n' +
|
||||
'Next connection can accept yellow blocks but not red blocks.\n' +
|
||||
'Statement connection can accept yellow blocks but not red blocks.',
|
||||
},
|
||||
{
|
||||
type: 'test_connections_statement_yellow',
|
||||
message0: '%1',
|
||||
args0: [
|
||||
{
|
||||
type: 'input_statement',
|
||||
name: 'NAME',
|
||||
check: ['yellowRel', 'orangeRel'],
|
||||
},
|
||||
],
|
||||
previousStatement: ['greenRel', 'yellowRel'],
|
||||
nextStatement: ['yellowRel', 'orangeRel'],
|
||||
colour: 60,
|
||||
tooltip:
|
||||
'Prev: yellowRel, greenRel\n' +
|
||||
'Next: yellowRel, orangeRel\n' +
|
||||
'Statement: orangeRel\n' +
|
||||
'Prev can connect to yellow blocks and blue blocks, but not red' +
|
||||
' blocks.\n' +
|
||||
'Next can connect to yellow blocks and red blocks, but not blue' +
|
||||
' blocks.\n' +
|
||||
'Statement connection can accept yellow blocks and red blocks but not' +
|
||||
' blue blocks.\n',
|
||||
},
|
||||
{
|
||||
type: 'test_connections_statement_red',
|
||||
message0: '%1',
|
||||
args0: [
|
||||
{
|
||||
type: 'input_statement',
|
||||
name: 'NAME',
|
||||
check: 'noneNext',
|
||||
},
|
||||
],
|
||||
previousStatement: 'orangeRel',
|
||||
nextStatement: 'noneNext',
|
||||
colour: 0,
|
||||
tooltip:
|
||||
'Prev: orangeRel\n' +
|
||||
'Next: noneNext\n' +
|
||||
'Statement: noneNext\n' +
|
||||
'Prev connection can accept yellow blocks but not blue blocks.\n' +
|
||||
'Statement connection accepts none.',
|
||||
},
|
||||
{
|
||||
type: 'test_connections_statement_nonext',
|
||||
message0: '%1',
|
||||
args0: [
|
||||
{
|
||||
type: 'input_statement',
|
||||
name: 'NAME',
|
||||
check: ['yellowRel', 'orangeRel'],
|
||||
},
|
||||
],
|
||||
previousStatement: ['greenRel', 'yellowRel'],
|
||||
colour: 60,
|
||||
tooltip:
|
||||
'Prev: yellowRel, greenRel\n' +
|
||||
'Next: yellowRel, orangeRel\n' +
|
||||
'Statement: orangeRel\n' +
|
||||
'Prev can connect to yellow blocks and blue blocks, but not red' +
|
||||
' blocks.\n' +
|
||||
'Statement connection can accept yellow blocks and red blocks but not' +
|
||||
' blue blocks.\n',
|
||||
},
|
||||
{
|
||||
type: 'test_connections_multistatement_1valid',
|
||||
message0: 'none %1 both %2',
|
||||
args0: [
|
||||
{
|
||||
type: 'input_statement',
|
||||
name: 'NAME',
|
||||
check: 'noneNext',
|
||||
},
|
||||
{
|
||||
type: 'input_statement',
|
||||
name: 'NAME',
|
||||
check: ['yellowRel', 'orangeRel'],
|
||||
},
|
||||
],
|
||||
previousStatement: ['greenRel', 'yellowRel'],
|
||||
colour: 60,
|
||||
tooltip:
|
||||
'Prev: yellowRel, greenRel\n' +
|
||||
'Next: yellowRel, orangeRel\n' +
|
||||
'Statement: orangeRel\n' +
|
||||
'Prev can connect to yellow blocks and blue blocks, but not red' +
|
||||
' blocks.\n' +
|
||||
'Top Statement cannot connect to anything, except grey blocks.\n' +
|
||||
'Bottom Statement connection can accept yellow blocks and red blocks' +
|
||||
' but not blue blocks.\n',
|
||||
},
|
||||
{
|
||||
type: 'test_connections_multistatement_2valid',
|
||||
message0: 'both %1 both %2',
|
||||
args0: [
|
||||
{
|
||||
type: 'input_statement',
|
||||
name: 'NAME',
|
||||
check: ['yellowRel', 'orangeRel'],
|
||||
},
|
||||
{
|
||||
type: 'input_statement',
|
||||
name: 'NAME',
|
||||
check: ['yellowRel', 'orangeRel'],
|
||||
},
|
||||
],
|
||||
previousStatement: ['greenRel', 'yellowRel'],
|
||||
colour: 60,
|
||||
tooltip:
|
||||
'Prev: yellowRel, greenRel\n' +
|
||||
'Next: yellowRel, orangeRel\n' +
|
||||
'Statement: orangeRel\n' +
|
||||
'Prev can connect to yellow blocks and blue blocks, but not red' +
|
||||
' blocks.\n' +
|
||||
'Top Statement connection can accept yellow blocks and red blocks but' +
|
||||
' not blue blocks.\n' +
|
||||
'Bottom Statement connection can accept yellow blocks and red blocks' +
|
||||
' but not blue blocks.\n',
|
||||
},
|
||||
]);
|
||||
|
||||
/**
|
||||
* Handles "insert" button in the connection statement test category. This will
|
||||
* insert a group of test blocks connected as statements.
|
||||
* @param {!Blockly.FlyoutButton} button The flyout button.
|
||||
*/
|
||||
const insertConnectionStatements = function (button) {
|
||||
const workspace = button.getTargetWorkspace();
|
||||
Blockly.Xml.domToWorkspace(
|
||||
Blockly.utils.xml.textToDom(
|
||||
'<xml xmlns="https://developers.google.com/blockly/xml">\n' +
|
||||
' <block type="test_connections_statement_blue">\n' +
|
||||
' <statement name="NAME">\n' +
|
||||
' <block type="test_connections_statement_yellow">\n' +
|
||||
' <statement name="NAME">\n' +
|
||||
' <block type="test_connections_statement_yellow">\n' +
|
||||
' <statement name="NAME">\n' +
|
||||
' <block type="test_connections_statement_red"/>\n' +
|
||||
' </statement>\n' +
|
||||
' </block>\n' +
|
||||
' </statement>\n' +
|
||||
' </block>\n' +
|
||||
' </statement>\n' +
|
||||
' </block>\n' +
|
||||
'</xml>',
|
||||
),
|
||||
workspace,
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* The Statement connections category.
|
||||
*/
|
||||
export const category = {
|
||||
kind: 'CATEGORY',
|
||||
name: 'Statement',
|
||||
contents: [
|
||||
{
|
||||
kind: 'LABEL',
|
||||
text: 'blocks have',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '-1',
|
||||
},
|
||||
{
|
||||
kind: 'LABEL',
|
||||
text: 'tooltips',
|
||||
},
|
||||
{
|
||||
kind: 'BUTTON',
|
||||
text: 'insert',
|
||||
callbackkey: 'insertConnectionStatements',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '7',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_connections_statement_blue',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '7',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_connections_statement_yellow',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '7',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_connections_statement_red',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_connections_statement_nonext',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '7',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_connections_multistatement_1valid',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '7',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_connections_multistatement_2valid',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize this toolbox category.
|
||||
* @param {!Blockly.WorkspaceSvg} workspace The Blockly workspace.
|
||||
*/
|
||||
export function onInit(workspace) {
|
||||
workspace.registerButtonCallback(
|
||||
'insertConnectionStatements',
|
||||
insertConnectionStatements,
|
||||
);
|
||||
}
|
||||
195
node_modules/@blockly/block-test/src/drag.js
generated
vendored
Normal file
195
node_modules/@blockly/block-test/src/drag.js
generated
vendored
Normal file
@@ -0,0 +1,195 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2020 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @fileoverview Drag test blocks.
|
||||
* @author samelh@google.com (Sam El-Husseini)
|
||||
*/
|
||||
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
/** Block that duplicates itself on drag. */
|
||||
Blockly.Blocks['drag_to_dupe'] = {
|
||||
init: function () {
|
||||
this.setOutput(true, null);
|
||||
this.appendDummyInput().appendField('drag to dupe');
|
||||
this.setDragStrategy(new DragToDupe(this));
|
||||
},
|
||||
};
|
||||
|
||||
/** Drag strategy that duplicates the block on drag. */
|
||||
class DragToDupe {
|
||||
constructor(block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
isMovable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
startDrag(e) {
|
||||
const data = this.block.toCopyData();
|
||||
this.copy = Blockly.clipboard.paste(data, this.block.workspace);
|
||||
this.baseStrat = new Blockly.dragging.BlockDragStrategy(this.copy);
|
||||
this.baseStrat.startDrag(e);
|
||||
}
|
||||
|
||||
drag(e) {
|
||||
this.baseStrat.drag(e);
|
||||
}
|
||||
|
||||
endDrag(e) {
|
||||
this.baseStrat.endDrag(e);
|
||||
}
|
||||
|
||||
revertDrag(e) {
|
||||
this.copy.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Drag category.
|
||||
*/
|
||||
export const category = {
|
||||
kind: 'CATEGORY',
|
||||
name: 'Drag',
|
||||
contents: [
|
||||
{
|
||||
kind: 'LABEL',
|
||||
text: 'Drag each to the workspace',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
blockxml: `
|
||||
<block type="text_print">
|
||||
<value name="TEXT">
|
||||
<block type="text">
|
||||
<field name="TEXT">Drag me by this child</field>
|
||||
</block>
|
||||
</value>
|
||||
</block>`,
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
blockxml: `
|
||||
<block type="text_print">
|
||||
<value name="TEXT">
|
||||
<shadow type="text">
|
||||
<field name="TEXT">Drag me by this shadow</field>
|
||||
</shadow>
|
||||
</value>
|
||||
</block>`,
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
blockxml: `
|
||||
<block type="text_print">
|
||||
<value name="TEXT">
|
||||
<shadow type="text">
|
||||
<field name="TEXT">Shadow value</field>
|
||||
</shadow>
|
||||
</value>
|
||||
<next>
|
||||
<shadow type="text_print">
|
||||
<value name="TEXT">
|
||||
<shadow type="text">
|
||||
<field name="TEXT">Shadow statement</field>
|
||||
</shadow>
|
||||
</value>
|
||||
</shadow>
|
||||
</next>
|
||||
</block>`,
|
||||
},
|
||||
{
|
||||
kind: 'LABEL',
|
||||
text: 'Multiple Variable Refs',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
blockxml: `
|
||||
<block type="text_print">
|
||||
<value name="TEXT">
|
||||
<block type="variables_get">
|
||||
<field name="VAR" id="item">item</field>
|
||||
</block>
|
||||
</value>
|
||||
<next>
|
||||
<block type="text_print">
|
||||
<value name="TEXT">
|
||||
<block type="variables_get">
|
||||
<field name="VAR" id="item">item</field>
|
||||
</block>
|
||||
</value>
|
||||
</block>
|
||||
</next>
|
||||
</block>`,
|
||||
},
|
||||
{
|
||||
kind: 'LABEL',
|
||||
text: 'Procedure Definitions',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
blockxml: `
|
||||
<block type="procedures_defnoreturn">
|
||||
<field name="NAME">without arguments</field>
|
||||
<statement name="STACK">
|
||||
<block type="text_print">
|
||||
<value name="TEXT">
|
||||
<shadow type="text">
|
||||
<field name="TEXT">No argument reference.</field>
|
||||
</shadow>
|
||||
</value>
|
||||
</block>
|
||||
</statement>
|
||||
</block>`,
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
blockxml: `
|
||||
<block type="procedures_defnoreturn">
|
||||
<mutation><arg name="fnArgument"></arg></mutation>
|
||||
<field name="NAME">with one argument</field>
|
||||
<statement name="STACK">
|
||||
<block type="text_print">
|
||||
<value name="TEXT">
|
||||
<shadow type="text">
|
||||
<field name="TEXT">Expected an argument reference here.</field>
|
||||
</shadow>
|
||||
<block type="variables_get">
|
||||
<field name="VAR">fnArgument</field>
|
||||
</block>
|
||||
</value>
|
||||
</block>
|
||||
</statement>
|
||||
</block>`,
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'drag_to_dupe',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'text_print',
|
||||
inputs: {
|
||||
TEXT: {
|
||||
shadow: {
|
||||
type: 'drag_to_dupe',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize this toolbox category.
|
||||
* @param {!Blockly.WorkspaceSvg} workspace The Blockly workspace.
|
||||
*/
|
||||
export function onInit(workspace) {
|
||||
// NOP
|
||||
}
|
||||
281
node_modules/@blockly/block-test/src/fields/defaults.js
generated
vendored
Normal file
281
node_modules/@blockly/block-test/src/fields/defaults.js
generated
vendored
Normal file
@@ -0,0 +1,281 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2020 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @fileoverview Default field test blocks.
|
||||
* @author samelh@google.com (Sam El-Husseini)
|
||||
*/
|
||||
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
Blockly.defineBlocksWithJsonArray([
|
||||
{
|
||||
type: 'test_fields_text_input',
|
||||
message0: 'text input %1',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_input',
|
||||
name: 'TEXT_INPUT',
|
||||
text: 'default',
|
||||
},
|
||||
],
|
||||
style: 'math_blocks',
|
||||
tooltip: '',
|
||||
helpUrl: '',
|
||||
},
|
||||
{
|
||||
type: 'test_fields_only_text_input',
|
||||
message0: '%1',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_input',
|
||||
name: 'TEXT_INPUT',
|
||||
text: 'default',
|
||||
},
|
||||
],
|
||||
style: 'textInput',
|
||||
tooltip: '',
|
||||
helpUrl: '',
|
||||
output: 'String',
|
||||
},
|
||||
{
|
||||
type: 'test_fields_checkbox',
|
||||
message0: 'checkbox %1',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_checkbox',
|
||||
name: 'CHECKBOX',
|
||||
checked: true,
|
||||
},
|
||||
],
|
||||
style: 'math_blocks',
|
||||
tooltip: '',
|
||||
helpUrl: '',
|
||||
},
|
||||
{
|
||||
type: 'test_fields_variable',
|
||||
message0: 'variable %1',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_variable',
|
||||
name: 'VARIABLE',
|
||||
variable: 'item',
|
||||
},
|
||||
],
|
||||
style: 'math_blocks',
|
||||
tooltip: '',
|
||||
helpUrl: '',
|
||||
},
|
||||
{
|
||||
type: 'test_fields_label_serializable',
|
||||
message0: 'label serializable %1',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_label_serializable',
|
||||
name: 'LABEL',
|
||||
text: 'default',
|
||||
},
|
||||
],
|
||||
style: 'math_blocks',
|
||||
tooltip: '',
|
||||
helpUrl: '',
|
||||
},
|
||||
{
|
||||
type: 'test_fields_image',
|
||||
message0: 'image %1',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_image',
|
||||
name: 'IMAGE',
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/a.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'A',
|
||||
},
|
||||
],
|
||||
colour: 230,
|
||||
},
|
||||
]);
|
||||
|
||||
/**
|
||||
* The Default fields category.
|
||||
*/
|
||||
export const category = {
|
||||
kind: 'CATEGORY',
|
||||
name: 'Defaults',
|
||||
contents: [
|
||||
{
|
||||
kind: 'BUTTON',
|
||||
text: 'add blocks to workspace',
|
||||
callbackkey: 'addAllBlocksToWorkspace',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '8',
|
||||
},
|
||||
{
|
||||
kind: 'BUTTON',
|
||||
text: 'set random style',
|
||||
callbackkey: 'setRandomStyle',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '8',
|
||||
},
|
||||
{
|
||||
kind: 'BUTTON',
|
||||
text: 'toggle enabled',
|
||||
callbackkey: 'toggleEnabled',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '8',
|
||||
},
|
||||
{
|
||||
kind: 'BUTTON',
|
||||
text: 'toggle shadow',
|
||||
callbackkey: 'toggleShadow',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '8',
|
||||
},
|
||||
{
|
||||
kind: 'BUTTON',
|
||||
text: 'toggle collapsed',
|
||||
callbackkey: 'toggleCollapsed',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_fields_checkbox',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_fields_text_input',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_fields_only_text_input',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_fields_variable',
|
||||
},
|
||||
{
|
||||
kind: 'BUTTON',
|
||||
text: 'randomize label text',
|
||||
callbackkey: 'randomizeLabelText',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '12',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_fields_label_serializable',
|
||||
},
|
||||
{
|
||||
kind: 'BUTTON',
|
||||
text: 'change image',
|
||||
callbackkey: 'changeImage',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '12',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_fields_image',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize this toolbox category.
|
||||
* @param {!Blockly.WorkspaceSvg} workspace The Blockly workspace.
|
||||
*/
|
||||
export function onInit(workspace) {
|
||||
const randomizeLabelText = function (button) {
|
||||
const blocks = button
|
||||
.getTargetWorkspace()
|
||||
.getBlocksByType('test_fields_label_serializable');
|
||||
const possible = 'AB';
|
||||
for (let i = 0, block; (block = blocks[i]); i++) {
|
||||
let text = '';
|
||||
for (let j = 0; j < 4; j++) {
|
||||
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
||||
}
|
||||
block.setFieldValue(text, 'LABEL');
|
||||
}
|
||||
};
|
||||
const setRandomStyle = function (button) {
|
||||
const blocks = button
|
||||
.getTargetWorkspace()
|
||||
.getFlyout()
|
||||
.getWorkspace()
|
||||
.getAllBlocks(false);
|
||||
const styles = Object.keys(
|
||||
workspace.getRenderer().getConstants().blockStyles,
|
||||
);
|
||||
styles.splice(styles.indexOf(blocks[0].getStyleName()), 1);
|
||||
const style = styles[Math.floor(Math.random() * styles.length)];
|
||||
for (let i = 0, block; (block = blocks[i]); i++) {
|
||||
block.setStyle(style);
|
||||
}
|
||||
};
|
||||
const toggleEnabled = function (button) {
|
||||
const blocks = button
|
||||
.getTargetWorkspace()
|
||||
.getFlyout()
|
||||
.getWorkspace()
|
||||
.getAllBlocks(false);
|
||||
for (let i = 0, block; (block = blocks[i]); i++) {
|
||||
block.setEnabled(!block.isEnabled());
|
||||
}
|
||||
};
|
||||
const toggleShadow = function (button) {
|
||||
const blocks = button
|
||||
.getTargetWorkspace()
|
||||
.getFlyout()
|
||||
.getWorkspace()
|
||||
.getAllBlocks(false);
|
||||
for (let i = 0, block; (block = blocks[i]); i++) {
|
||||
block.setShadow(!block.isShadow());
|
||||
}
|
||||
};
|
||||
const toggleCollapsed = function (button) {
|
||||
const blocks = button
|
||||
.getTargetWorkspace()
|
||||
.getFlyout()
|
||||
.getWorkspace()
|
||||
.getAllBlocks(false);
|
||||
for (let i = 0, block; (block = blocks[i]); i++) {
|
||||
block.setCollapsed(!block.isCollapsed());
|
||||
}
|
||||
};
|
||||
const changeImage = function (button) {
|
||||
const blocks = button
|
||||
.getTargetWorkspace()
|
||||
.getFlyout()
|
||||
.getWorkspace()
|
||||
.getBlocksByType('test_fields_image');
|
||||
const possible = 'abcdefghijklm';
|
||||
const image = possible.charAt(Math.floor(Math.random() * possible.length));
|
||||
const src =
|
||||
'https://blockly-demo.appspot.com/static/tests/media/' + image + '.png';
|
||||
for (let i = 0, block; (block = blocks[i]); i++) {
|
||||
const imageField = block.getField('IMAGE');
|
||||
imageField.setValue(src);
|
||||
}
|
||||
};
|
||||
workspace.registerButtonCallback('randomizeLabelText', randomizeLabelText);
|
||||
workspace.registerButtonCallback('setRandomStyle', setRandomStyle);
|
||||
workspace.registerButtonCallback('toggleEnabled', toggleEnabled);
|
||||
workspace.registerButtonCallback('toggleShadow', toggleShadow);
|
||||
workspace.registerButtonCallback('toggleCollapsed', toggleCollapsed);
|
||||
workspace.registerButtonCallback('changeImage', changeImage);
|
||||
}
|
||||
591
node_modules/@blockly/block-test/src/fields/dropdowns.js
generated
vendored
Normal file
591
node_modules/@blockly/block-test/src/fields/dropdowns.js
generated
vendored
Normal file
@@ -0,0 +1,591 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2020 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @fileoverview Dropdown fields test blocks.
|
||||
* @author samelh@google.com (Sam El-Husseini)
|
||||
*/
|
||||
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
Blockly.defineBlocksWithJsonArray([
|
||||
{
|
||||
type: 'test_dropdowns_long',
|
||||
message0: 'long: %1',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_dropdown',
|
||||
name: 'FIELDNAME',
|
||||
options: [
|
||||
['first item', 'ITEM1'],
|
||||
['second item', 'ITEM2'],
|
||||
['third item', 'ITEM3'],
|
||||
['fourth item', 'ITEM4'],
|
||||
['fifth item', 'ITEM5'],
|
||||
['sixth item', 'ITEM6'],
|
||||
['seventh item', 'ITEM7'],
|
||||
['eighth item', 'ITEM8'],
|
||||
['ninth item', 'ITEM9'],
|
||||
['tenth item', 'ITEM10'],
|
||||
['eleventh item', 'ITEM11'],
|
||||
['twelfth item', 'ITEM12'],
|
||||
['thirteenth item', 'ITEM13'],
|
||||
['fourteenth item', 'ITEM14'],
|
||||
['fifteenth item', 'ITEM15'],
|
||||
['sixteenth item', 'ITEM16'],
|
||||
['seventeenth item', 'ITEM17'],
|
||||
['eighteenth item', 'ITEM18'],
|
||||
['nineteenth item', 'ITEM19'],
|
||||
['twentieth item', 'ITEM20'],
|
||||
['twenty-first item', 'ITEM21'],
|
||||
['twenty-second item', 'ITEM22'],
|
||||
['twenty-third item', 'ITEM23'],
|
||||
['twenty-fourth item', 'ITEM24'],
|
||||
['twenty-fifth item', 'ITEM25'],
|
||||
['twenty-sixth item', 'ITEM26'],
|
||||
['twenty-seventh item', 'ITEM27'],
|
||||
['twenty-eighth item', 'ITEM28'],
|
||||
['twenty-ninth item', 'ITEM29'],
|
||||
['thirtieth item', 'ITEM30'],
|
||||
['thirty-first item', 'ITEM31'],
|
||||
['thirty-second item', 'ITEM32'],
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: 'test_dropdowns_images',
|
||||
message0: '%1',
|
||||
args0: [
|
||||
{
|
||||
NOTE: 'The following paths are relative to playground.html',
|
||||
type: 'field_dropdown',
|
||||
name: 'FIELDNAME',
|
||||
options: [
|
||||
[
|
||||
{
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/a.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'A',
|
||||
},
|
||||
'A',
|
||||
],
|
||||
[
|
||||
{
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/b.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'B',
|
||||
},
|
||||
'B',
|
||||
],
|
||||
[
|
||||
{
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/c.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'C',
|
||||
},
|
||||
'C',
|
||||
],
|
||||
[
|
||||
{
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/d.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'D',
|
||||
},
|
||||
'D',
|
||||
],
|
||||
[
|
||||
{
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/e.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'E',
|
||||
},
|
||||
'E',
|
||||
],
|
||||
[
|
||||
{
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/f.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'F',
|
||||
},
|
||||
'F',
|
||||
],
|
||||
[
|
||||
{
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/g.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'G',
|
||||
},
|
||||
'G',
|
||||
],
|
||||
[
|
||||
{
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/h.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'H',
|
||||
},
|
||||
'H',
|
||||
],
|
||||
[
|
||||
{
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/i.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'I',
|
||||
},
|
||||
'I',
|
||||
],
|
||||
[
|
||||
{
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/j.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'J',
|
||||
},
|
||||
'J',
|
||||
],
|
||||
[
|
||||
{
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/k.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'K',
|
||||
},
|
||||
'K',
|
||||
],
|
||||
[
|
||||
{
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/l.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'L',
|
||||
},
|
||||
'L',
|
||||
],
|
||||
[
|
||||
{
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/m.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'M',
|
||||
},
|
||||
'M',
|
||||
],
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: 'test_dropdowns_images_and_text',
|
||||
message0: '%1',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_dropdown',
|
||||
name: 'FIELDNAME',
|
||||
options: [
|
||||
['images and text', 'IMAGES AND TEXT'],
|
||||
[
|
||||
{
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/a.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'A',
|
||||
},
|
||||
'A',
|
||||
],
|
||||
[
|
||||
{
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/b.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'B',
|
||||
},
|
||||
'B',
|
||||
],
|
||||
[
|
||||
{
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/c.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'C',
|
||||
},
|
||||
'C',
|
||||
],
|
||||
[
|
||||
{
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/d.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'D',
|
||||
},
|
||||
'D',
|
||||
],
|
||||
[
|
||||
{
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/e.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'E',
|
||||
},
|
||||
'E',
|
||||
],
|
||||
[
|
||||
{
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/f.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'F',
|
||||
},
|
||||
'F',
|
||||
],
|
||||
[
|
||||
{
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/g.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'G',
|
||||
},
|
||||
'G',
|
||||
],
|
||||
[
|
||||
{
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/h.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'H',
|
||||
},
|
||||
'H',
|
||||
],
|
||||
['xyz', 'LMNOP'],
|
||||
[
|
||||
{
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/i.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'I',
|
||||
},
|
||||
'I',
|
||||
],
|
||||
[
|
||||
{
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/j.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'J',
|
||||
},
|
||||
'J',
|
||||
],
|
||||
[
|
||||
{
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/k.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'K',
|
||||
},
|
||||
'K',
|
||||
],
|
||||
[
|
||||
{
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/l.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'L',
|
||||
},
|
||||
'L',
|
||||
],
|
||||
[
|
||||
{
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/m.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'M',
|
||||
},
|
||||
'M',
|
||||
],
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: 'test_dropdowns_in_mutator',
|
||||
message0: 'dropdown mutator',
|
||||
mutator: 'test_dropdown_mutator',
|
||||
},
|
||||
{
|
||||
type: 'test_dropdowns_in_mutator_block',
|
||||
message0: 'dropdown %1',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_dropdown',
|
||||
name: 'DROPDOWN',
|
||||
options: [
|
||||
['option', 'ONE'],
|
||||
['option', 'TWO'],
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
||||
/**
|
||||
* An array of options for the dynamic dropdown.
|
||||
* @type {!Array.<!Array>}
|
||||
* @private
|
||||
*/
|
||||
const dynamicDropdownOptions_ = [];
|
||||
|
||||
/**
|
||||
* Handles "add option" button in the field test category. This will prompt
|
||||
* the user for an option to add.
|
||||
* @package
|
||||
*/
|
||||
const addDynamicDropdownOption = function () {
|
||||
Blockly.dialog.prompt(
|
||||
'Add an option?',
|
||||
'option ' + dynamicDropdownOptions_.length,
|
||||
function (text) {
|
||||
if (text) {
|
||||
// Do not remove this log! Helps you know if it was added correctly.
|
||||
console.log('Adding option: ' + text);
|
||||
// The option is an array containing human-readable text and a
|
||||
// language-neutral id.
|
||||
dynamicDropdownOptions_.push([
|
||||
text,
|
||||
'OPTION' + dynamicDropdownOptions_.length,
|
||||
]);
|
||||
}
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Handles "remove option" button in the field test category. This will prompt
|
||||
* the user for an option to remove. May remove multiple options with the
|
||||
* same name.
|
||||
* @package
|
||||
*/
|
||||
const removeDynamicDropdownOption = function () {
|
||||
const defaultText = dynamicDropdownOptions_[0]
|
||||
? dynamicDropdownOptions_[0][0]
|
||||
: '';
|
||||
Blockly.dialog.prompt('Remove an option?', defaultText, function (text) {
|
||||
for (let i = 0, option; (option = dynamicDropdownOptions_[i]); i++) {
|
||||
// The option is an array containing human-readable text and a
|
||||
// language-neutral id, we'll compare against the human-readable text.
|
||||
if (option[0] == text) {
|
||||
// Do not remove this log! Helps you know if it was removed correctly.
|
||||
console.log('Removing option: ' + text);
|
||||
dynamicDropdownOptions_.splice(i, 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Blockly.Blocks['test_dropdowns_dynamic_random'] = {
|
||||
init: function () {
|
||||
const dropdown = new Blockly.FieldDropdown(this.dynamicOptions);
|
||||
this.appendDummyInput()
|
||||
.appendField('dynamic random')
|
||||
.appendField(dropdown, 'OPTIONS');
|
||||
},
|
||||
|
||||
dynamicOptions: function () {
|
||||
const random = Math.floor(Math.random() * 10) + 1;
|
||||
const options = [];
|
||||
for (let i = 0; i < random; i++) {
|
||||
options.push([String(i), String(i)]);
|
||||
}
|
||||
return options;
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks['test_dropdowns_dynamic_connect_dependant'] = {
|
||||
init: function () {
|
||||
const dropdown = new Blockly.FieldDropdown(this.dynamicOptions);
|
||||
this.appendDummyInput()
|
||||
.appendField('dynamic connect-dependant')
|
||||
.appendField(dropdown, 'OPTIONS');
|
||||
this.setNextStatement(true);
|
||||
this.setPreviousStatement(true);
|
||||
},
|
||||
|
||||
dynamicOptions: function () {
|
||||
if (this.sourceBlock_ && this.sourceBlock_.getSurroundParent()) {
|
||||
const parent = this.sourceBlock_.getSurroundParent();
|
||||
const options = [
|
||||
['connected', 'CONNECTED_KEY'],
|
||||
[`surroundParent: ${parent.type}`, `${parent.id}_type_key`],
|
||||
[`surroundParent: ${parent.id}`, `${parent.id}_key`],
|
||||
];
|
||||
const top = this.sourceBlock_.getTopStackBlock();
|
||||
if (top.id !== parent.id) {
|
||||
options.push([`topStack: ${top.type}`, `${top.id}_type_key`]);
|
||||
options.push([`topStack: ${top.id}`, `${top.id}_key`]);
|
||||
}
|
||||
return options;
|
||||
} else {
|
||||
return [['unconnected', 'UNCONNECTED_KEY']];
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Mutator methods added to the test_dropdowns_in_mutator block.
|
||||
* @mixin
|
||||
* @package
|
||||
* @readonly
|
||||
*/
|
||||
const DROPDOWN_MUTATOR = {
|
||||
/**
|
||||
* Create XML to represent the block mutation.
|
||||
* @returns {Element} XML storage element.
|
||||
* @this {Blockly.Block}
|
||||
*/
|
||||
mutationToDom: function () {
|
||||
const container = Blockly.utils.xml.createElement('mutation');
|
||||
return container;
|
||||
},
|
||||
/**
|
||||
* Restore a block from XML.
|
||||
* @param {!Element} _xmlElement XML storage element.
|
||||
* @this {Blockly.Block}
|
||||
*/
|
||||
domToMutation: function (_xmlElement) {},
|
||||
/**
|
||||
* Returns the state of the block as a JSON serializable object.
|
||||
* @returns {!Object} The state of the block as a JSON serializable object.
|
||||
*/
|
||||
saveExtraState: function () {
|
||||
return {};
|
||||
},
|
||||
/**
|
||||
* Applies the given state to the block.
|
||||
* @param {!Object} _state The state to apply.
|
||||
*/
|
||||
loadExtraState: function (_state) {},
|
||||
/**
|
||||
* Populate the mutator's dialog with this block's components.
|
||||
* @param {!Blockly.Workspace} workspace Mutator's workspace.
|
||||
* @returns {!Blockly.Block} Root block in mutator.
|
||||
* @this {Blockly.Block}
|
||||
*/
|
||||
decompose: function (workspace) {
|
||||
const containerBlock = workspace.newBlock(
|
||||
'test_dropdowns_in_mutator_block',
|
||||
);
|
||||
containerBlock.initSvg();
|
||||
|
||||
return containerBlock;
|
||||
},
|
||||
/**
|
||||
* Reconfigure this block based on the mutator dialog's components.
|
||||
* @param {!Blockly.Block} _containerBlock Root block in mutator.
|
||||
* @this {Blockly.Block}
|
||||
*/
|
||||
compose: function (_containerBlock) {},
|
||||
};
|
||||
|
||||
/**
|
||||
* Register custom mutator used by the test_dropdowns_in_mutator block.
|
||||
*/
|
||||
Blockly.Extensions.registerMutator(
|
||||
'test_dropdown_mutator',
|
||||
DROPDOWN_MUTATOR,
|
||||
null,
|
||||
['test_dropdowns_in_mutator_block'],
|
||||
);
|
||||
|
||||
Blockly.Blocks['test_dropdowns_dynamic'] = {
|
||||
init: function () {
|
||||
const dropdown = new Blockly.FieldDropdown(this.dynamicOptions);
|
||||
this.appendDummyInput()
|
||||
.appendField('dynamic')
|
||||
.appendField(dropdown, 'OPTIONS');
|
||||
},
|
||||
|
||||
dynamicOptions: function () {
|
||||
if (!dynamicDropdownOptions_.length) {
|
||||
return [['', 'OPTION0']];
|
||||
}
|
||||
return dynamicDropdownOptions_;
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* The Dropdown field category.
|
||||
*/
|
||||
export const category = {
|
||||
kind: 'CATEGORY',
|
||||
name: 'Drop-downs',
|
||||
contents: [
|
||||
{
|
||||
kind: 'LABEL',
|
||||
text: 'Dynamic',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_dropdowns_dynamic',
|
||||
},
|
||||
{
|
||||
kind: 'BUTTON',
|
||||
text: 'Add option',
|
||||
callbackkey: 'addDynamicOption',
|
||||
},
|
||||
{
|
||||
kind: 'BUTTON',
|
||||
text: 'Remove option',
|
||||
callbackkey: 'removeDynamicOption',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_dropdowns_dynamic_random',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_dropdowns_dynamic_connect_dependant',
|
||||
},
|
||||
{
|
||||
kind: 'LABEL',
|
||||
text: 'Other',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_dropdowns_long',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_dropdowns_images',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_dropdowns_images_and_text',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize this toolbox category.
|
||||
* @param {!Blockly.WorkspaceSvg} workspace The Blockly workspace.
|
||||
*/
|
||||
export function onInit(workspace) {
|
||||
workspace.registerButtonCallback(
|
||||
'addDynamicOption',
|
||||
addDynamicDropdownOption,
|
||||
);
|
||||
workspace.registerButtonCallback(
|
||||
'removeDynamicOption',
|
||||
removeDynamicDropdownOption,
|
||||
);
|
||||
}
|
||||
53
node_modules/@blockly/block-test/src/fields/emojis.js
generated
vendored
Normal file
53
node_modules/@blockly/block-test/src/fields/emojis.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2020 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @fileoverview Emojis in fields test blocks.
|
||||
* @author samelh@google.com (Sam El-Husseini)
|
||||
*/
|
||||
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
/**
|
||||
* The Emoji category.
|
||||
*/
|
||||
export const category = {
|
||||
kind: 'CATEGORY',
|
||||
name: 'Emoji! o((*^ᴗ^*))o',
|
||||
contents: [
|
||||
{
|
||||
kind: 'LABEL',
|
||||
text: 'Unicode & Emojis',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_style_emoji',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
blockxml: `
|
||||
<block type="text">
|
||||
<field name="TEXT">Robot face in text field:🤖</field>
|
||||
</block>`,
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
blockxml: `
|
||||
<block type="text">
|
||||
<field name="TEXT">Zalgo in text field:B̛̻̦̬̘̰͎̥̈̔͊͞ͅl̡͖̫̺̬̖̣̳̃̀́͑͑̕͟͠͝o̢̹͙̮̫͔͋̉̊̑̿̽̚c̸̹̹̜͙̹̠͋̒͑̊̇͝k̡͉̫͇̖̳͖̊͒́̆̄̎̂̔̕͜͞l̰̙̞̳̩̠͖̯̀̆̈́̿̈̓͗y̨̡̟͇̮͈̬̙̲̏̅̀͘͠</field>
|
||||
</block>`,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize this toolbox category.
|
||||
* @param {!Blockly.WorkspaceSvg} workspace The Blockly workspace.
|
||||
*/
|
||||
export function onInit(workspace) {
|
||||
// NOP
|
||||
}
|
||||
281
node_modules/@blockly/block-test/src/fields/images.js
generated
vendored
Normal file
281
node_modules/@blockly/block-test/src/fields/images.js
generated
vendored
Normal file
@@ -0,0 +1,281 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2020 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @fileoverview Image fields test blocks.
|
||||
* @author samelh@google.com (Sam El-Husseini)
|
||||
*/
|
||||
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
Blockly.defineBlocksWithJsonArray([
|
||||
{
|
||||
type: 'test_images_datauri',
|
||||
message0: 'Image data: URI %1',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_image',
|
||||
src: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlvbj4xPC90aWZmOk9yaWVudGF0aW9uPgogICAgICA8L3JkZjpEZXNjcmlwdGlvbj4KICAgPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KTMInWQAABHZJREFUaAXtmEuPDFEUx8cwJIx4jQjxSGYt4pWQiGSIz4A1O2FtLyx8B4+MxIKEtQkRsZBIEF/AAgki3gzjNfx/Xfc/rkpVd1dXdU13OMm/z73ndc+5r6rqgYHu01wNAfqa5kTZx+1I3PtNJ35Aqe4P6VrW+9mnEl6o/g/hu0Ab6koxg0nsjn+dVF6c+Yr8SZgUaGeRfR0ry6alzEFaGuYY/AryafFODjQ++EKOlfRq+nXSxzTeY2FHGHcocM/uIvXZWoA2ZJ1td0pGjKMoRY6d9Nr8ndemXdrMyayVYr1wQ9gn3BVIhNklNluKg06fNslTFDacG4q4LgwLxIIcO+nV+HtOY5HoF2FbgXG3y3ZKwPdsAb/KTeOZIxESOhRG2SB+SrgvfBDeC/cEZKwgdFjA5wydQHFMy2rh8WWxOYx4UJybiiTBR+Fzqu/nin2kHohj0a+dmEWfNYpwAefV3iSMCiMC5+GSYD0PSgjfWVkJDmoaJLRO8EocUXulMC68EW4KpuNqUAy2+EDpePRnjdj/JMhKUASH37N/S+0FgrePV+akZLWTl3+jRt4j7BbGhCUC9EAgcbbThdC+KL5aMA2Fxi5xbLkMoKXCmEBMYjMG5DGTXgW/XuqtiuVZNr8S4nM7cbBHBbYTehcxqDZJOTGv2DvJoKuC45lvaWiSbRea+cyHNN8i0UwHgyfilwUS+SYsFkiCmSYWD7tXwkOB5J8H7uRcCL48EPEDTMYqgYngneyl8FSAPHbSq+DXSWSFYmuwIhzg4WDgSYr93GY7kjQ++OaR7fP0M3IPNiNo0mBWCcxMm+izCtbBHRM5emR5FOvxi21ZibifF6Mh96BNjSIlgX9GfRJJkwen4CLbgrj2Tcds2Y9nt6VxQYOOkyo4TsO86IrkjRGvjNvmsQ8yCox1cTu2LdQuW4gT4wYyuZ21rbxKtsHHbcdynEK8TCEM7GS5jp3k8pAB16plQdRYCRLHxjp8JwVilSpG/h0TA08IXwUSAyTFNdwM2Nge32sCsTqmTp09c8zsM4H3KB6EJMcqW5+Oj946X88jklHMGoE3AuvVbJ/KbC1G4crkW4Ptsld4KzimZ1yiGSJJF0chy4Q7Av7xta5uMfKgxbz+WPMOxv9VrMhtwcmTJDqADKIAkgVeNWS8CbAi2M4akciEMCXwusFrB0WQPJy+z0qWDh98S58RxeiYvEXgnJUVIdIJcQqBQ8ib6fCNY+FTmMpsLZIlATiH1MQHFWT+Oun+JcvSOVZk3n5zsH3TTEuKgEjCf4k6pjnyZjqvhmMRrzCVWZF4MJLwwzGW086TW1eqAA/mWXO/b/n/Qnpt6f6vyL++Ir6hzCubj7q3lscz79tC/DVoXlkhVT0QWyXkV/TxYGhueSv/lvq6CuFM8CryQjgdsqJf2VmpfK+GJLOYi+FbvtIiGKwbK+JZNo+LQlb5+WCAbqyIY5rHhXSt3Y3BPOPmXUs+Dlzld7K30iMNwD8q3Ex85lquZv8QhzimdD/W9Xyb5H0z1Zbsb+OT/8HoqhrfAAAAAElFTkSuQmCC',
|
||||
width: 50,
|
||||
height: 50,
|
||||
alt: '*',
|
||||
},
|
||||
],
|
||||
style: 'text_blocks',
|
||||
},
|
||||
{
|
||||
type: 'test_images_small',
|
||||
message0: 'Image too small %1',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_image',
|
||||
src: 'media/30px.png',
|
||||
width: 50,
|
||||
height: 50,
|
||||
alt: '*',
|
||||
},
|
||||
],
|
||||
style: 'text_blocks',
|
||||
},
|
||||
{
|
||||
type: 'test_images_large',
|
||||
message0: 'Image too large %1',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_image',
|
||||
src: 'media/200px.png',
|
||||
width: 50,
|
||||
height: 50,
|
||||
alt: '*',
|
||||
},
|
||||
],
|
||||
style: 'text_blocks',
|
||||
},
|
||||
{
|
||||
type: 'test_images_fliprtl',
|
||||
message0: 'Image flipped RTL %1',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_image',
|
||||
src: 'media/arrow.png',
|
||||
width: 50,
|
||||
height: 50,
|
||||
alt: '*',
|
||||
flipRtl: true,
|
||||
},
|
||||
],
|
||||
colour: 160,
|
||||
},
|
||||
{
|
||||
type: 'test_images_missing',
|
||||
message0: 'Image missing %1',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_image',
|
||||
src: 'missing.png',
|
||||
width: 50,
|
||||
height: 50,
|
||||
alt: '*',
|
||||
},
|
||||
],
|
||||
style: 'text_blocks',
|
||||
},
|
||||
{
|
||||
type: 'test_images_many_icons',
|
||||
message0:
|
||||
'Lots of network icons: %1 %2 %3 %4 %5 %6 %7 %8 %9 %10 %11' +
|
||||
' %12 %13 %14 %15 %16 %17 %18',
|
||||
args0: [
|
||||
{
|
||||
type: 'input_dummy',
|
||||
},
|
||||
{
|
||||
type: 'field_image',
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/a.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'A',
|
||||
},
|
||||
{
|
||||
type: 'field_image',
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/b.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'B',
|
||||
},
|
||||
{
|
||||
type: 'field_image',
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/c.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'C',
|
||||
},
|
||||
{
|
||||
type: 'field_image',
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/d.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'D',
|
||||
},
|
||||
{
|
||||
type: 'field_image',
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/e.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'E',
|
||||
},
|
||||
{
|
||||
type: 'field_image',
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/f.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'F',
|
||||
},
|
||||
{
|
||||
type: 'field_image',
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/g.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'G',
|
||||
},
|
||||
{
|
||||
type: 'field_image',
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/h.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'H',
|
||||
},
|
||||
{
|
||||
type: 'input_dummy',
|
||||
},
|
||||
{
|
||||
type: 'field_image',
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/a.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'A',
|
||||
},
|
||||
{
|
||||
type: 'field_image',
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/b.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'B',
|
||||
},
|
||||
{
|
||||
type: 'field_image',
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/c.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'C',
|
||||
},
|
||||
{
|
||||
type: 'field_image',
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/d.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'D',
|
||||
},
|
||||
{
|
||||
type: 'field_image',
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/e.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'E',
|
||||
},
|
||||
{
|
||||
type: 'field_image',
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/f.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'F',
|
||||
},
|
||||
{
|
||||
type: 'field_image',
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/g.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'G',
|
||||
},
|
||||
{
|
||||
type: 'field_image',
|
||||
src: 'https://blockly-demo.appspot.com/static/tests/media/h.png',
|
||||
width: 32,
|
||||
height: 32,
|
||||
alt: 'H',
|
||||
},
|
||||
],
|
||||
style: 'text_blocks',
|
||||
},
|
||||
]);
|
||||
|
||||
Blockly.Blocks['test_images_clickhandler'] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField('Image click handler')
|
||||
.appendField(
|
||||
new Blockly.FieldImage(
|
||||
'https://blockly-demo.appspot.com/static/tests/media/a.png',
|
||||
32,
|
||||
32,
|
||||
'image with click handler',
|
||||
this.onClick_,
|
||||
),
|
||||
'IMAGE',
|
||||
);
|
||||
this.setStyle('text_blocks');
|
||||
},
|
||||
onClick_: function () {
|
||||
alert('Image clicked');
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* The Image field category.
|
||||
*/
|
||||
export const category = {
|
||||
kind: 'CATEGORY',
|
||||
name: 'Images',
|
||||
contents: [
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_images_datauri',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_images_small',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_images_large',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_images_fliprtl',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_images_missing',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_images_many_icons',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_images_clickhandler',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize this toolbox category.
|
||||
* @param {!Blockly.WorkspaceSvg} workspace The Blockly workspace.
|
||||
*/
|
||||
export function onInit(workspace) {
|
||||
// NOP
|
||||
}
|
||||
51
node_modules/@blockly/block-test/src/fields/index.js
generated
vendored
Normal file
51
node_modules/@blockly/block-test/src/fields/index.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2020 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @fileoverview Fields test blocks.
|
||||
* @author samelh@google.com (Sam El-Husseini)
|
||||
*/
|
||||
|
||||
import {category as fieldDefaults, onInit as initDefaults} from './defaults';
|
||||
import {category as fieldNumbers, onInit as initNumbers} from './numbers';
|
||||
import {category as fieldDropdowns, onInit as initDropdowns} from './dropdowns';
|
||||
import {category as fieldImages, onInit as initImages} from './images';
|
||||
import {category as fieldEmoji, onInit as initEmoji} from './emojis';
|
||||
import {
|
||||
category as fieldValidators,
|
||||
onInit as initValidators,
|
||||
} from './validators';
|
||||
|
||||
/**
|
||||
* The fields category.
|
||||
*/
|
||||
export const category = {
|
||||
kind: 'CATEGORY',
|
||||
name: 'Fields',
|
||||
expanded: 'true',
|
||||
contents: [
|
||||
fieldDefaults,
|
||||
fieldNumbers,
|
||||
fieldDropdowns,
|
||||
fieldImages,
|
||||
fieldEmoji,
|
||||
fieldValidators,
|
||||
],
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize this toolbox category.
|
||||
* @param {!Blockly.WorkspaceSvg} workspace The Blockly workspace.
|
||||
*/
|
||||
export function onInit(workspace) {
|
||||
initDefaults(workspace);
|
||||
initNumbers(workspace);
|
||||
initDropdowns(workspace);
|
||||
initImages(workspace);
|
||||
initEmoji(workspace);
|
||||
initValidators(workspace);
|
||||
}
|
||||
167
node_modules/@blockly/block-test/src/fields/numbers.js
generated
vendored
Normal file
167
node_modules/@blockly/block-test/src/fields/numbers.js
generated
vendored
Normal file
@@ -0,0 +1,167 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2020 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @fileoverview Number fields test blocks.
|
||||
* @author samelh@google.com (Sam El-Husseini)
|
||||
*/
|
||||
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
Blockly.defineBlocksWithJsonArray([
|
||||
{
|
||||
type: 'test_numbers_float',
|
||||
message0: 'float %1',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_number',
|
||||
name: 'NUM',
|
||||
text: '0',
|
||||
},
|
||||
],
|
||||
style: 'math_blocks',
|
||||
output: 'Number',
|
||||
tooltip: 'A number.',
|
||||
},
|
||||
{
|
||||
type: 'test_numbers_whole',
|
||||
message0: 'precision 1 %1',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_number',
|
||||
name: 'NUM',
|
||||
precision: 1,
|
||||
text: '0',
|
||||
},
|
||||
],
|
||||
style: 'math_blocks',
|
||||
output: 'Number',
|
||||
tooltip: 'The number should be rounded to multiples of 1',
|
||||
},
|
||||
{
|
||||
type: 'test_numbers_hundredths',
|
||||
message0: 'precision 0.01 %1',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_number',
|
||||
name: 'NUM',
|
||||
precision: 0.01,
|
||||
text: '0',
|
||||
},
|
||||
],
|
||||
style: 'math_blocks',
|
||||
output: 'Number',
|
||||
tooltip: 'The number should be rounded to multiples of 0.01',
|
||||
},
|
||||
{
|
||||
type: 'test_numbers_halves',
|
||||
message0: 'precision 0.5 %1',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_number',
|
||||
name: 'NUM',
|
||||
precision: 0.5,
|
||||
text: '0',
|
||||
},
|
||||
],
|
||||
style: 'math_blocks',
|
||||
output: 'Number',
|
||||
tooltip: 'The number should be rounded to multiples of 0.5',
|
||||
},
|
||||
{
|
||||
type: 'test_numbers_three_halves',
|
||||
message0: 'precision 1.5 %1',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_number',
|
||||
name: 'NUM',
|
||||
precision: 1.5,
|
||||
text: '0',
|
||||
},
|
||||
],
|
||||
style: 'math_blocks',
|
||||
output: 'Number',
|
||||
tooltip: 'The number should be rounded to multiples of 1.5',
|
||||
},
|
||||
{
|
||||
type: 'test_numbers_whole_bounded',
|
||||
message0: 'midi note %1',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_number',
|
||||
name: 'NOTE',
|
||||
precision: 1,
|
||||
min: 1,
|
||||
max: 127,
|
||||
text: '0',
|
||||
},
|
||||
],
|
||||
style: 'math_blocks',
|
||||
output: 'Note',
|
||||
tooltip: 'A midi note.',
|
||||
},
|
||||
]);
|
||||
|
||||
/**
|
||||
* The Numbers field category.
|
||||
*/
|
||||
export const category = {
|
||||
kind: 'CATEGORY',
|
||||
name: 'Numbers',
|
||||
contents: [
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
blockxml: `
|
||||
<block type="test_numbers_float">
|
||||
<field name="NUM">123.456</field>
|
||||
</block>`,
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
blockxml: `
|
||||
<block type="test_numbers_hundredths">
|
||||
<field name="NUM">123.456</field>
|
||||
</block>`,
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
blockxml: `
|
||||
<block type="test_numbers_halves">
|
||||
<field name="NUM">123.456</field>
|
||||
</block>`,
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
blockxml: `
|
||||
<block type="test_numbers_whole">
|
||||
<field name="NUM">123.456</field>
|
||||
</block>`,
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
blockxml: `
|
||||
<block type="test_numbers_three_halves">
|
||||
<field name="NUM">123.456</field>
|
||||
</block>`,
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
blockxml: `
|
||||
<block type="test_numbers_whole_bounded">
|
||||
<field name="NOTE">60</field>
|
||||
</block>`,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize this toolbox category.
|
||||
* @param {!Blockly.WorkspaceSvg} workspace The Blockly workspace.
|
||||
*/
|
||||
export function onInit(workspace) {
|
||||
// NOP
|
||||
}
|
||||
577
node_modules/@blockly/block-test/src/fields/validators.js
generated
vendored
Normal file
577
node_modules/@blockly/block-test/src/fields/validators.js
generated
vendored
Normal file
@@ -0,0 +1,577 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2020 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @fileoverview Field validators test blocks.
|
||||
* @author samelh@google.com (Sam El-Husseini)
|
||||
*/
|
||||
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
Blockly.Blocks['test_validators_dispose_block'] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField('dispose block')
|
||||
.appendField(
|
||||
new Blockly.FieldTextInput('default', this.validate),
|
||||
'INPUT',
|
||||
);
|
||||
this.setColour(230);
|
||||
this.setCommentText(
|
||||
'Any changes to the text cause the block to be' + ' disposed',
|
||||
);
|
||||
},
|
||||
|
||||
validate: function (newValue) {
|
||||
if (newValue != 'default') {
|
||||
this.getSourceBlock().dispose(true);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks['test_validators_text_null'] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField('always null')
|
||||
.appendField(
|
||||
new Blockly.FieldTextInput('default', this.validate),
|
||||
'INPUT',
|
||||
);
|
||||
this.setColour(230);
|
||||
this.setCommentText(
|
||||
'All input validates to null (invalid). The display' +
|
||||
' text will remain the input text, but the value should be the' +
|
||||
' default text. The input should be red after the first keystroke.',
|
||||
);
|
||||
},
|
||||
|
||||
validate: function (newValue) {
|
||||
return null;
|
||||
},
|
||||
};
|
||||
Blockly.Blocks['test_validators_text_A'] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField("remove 'a'")
|
||||
.appendField(
|
||||
new Blockly.FieldTextInput('default', this.validate),
|
||||
'INPUT',
|
||||
);
|
||||
this.setColour(230);
|
||||
this.setCommentText(
|
||||
"All 'a' characters are removed from field value." +
|
||||
" The display text will include invalid 'a' characters while the" +
|
||||
' field is being edited, but the value will not.',
|
||||
);
|
||||
},
|
||||
|
||||
validate: function (newValue) {
|
||||
return newValue.replace(/a/g, '');
|
||||
},
|
||||
};
|
||||
Blockly.Blocks['test_validators_text_B'] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField("'b' -> null")
|
||||
.appendField(
|
||||
new Blockly.FieldTextInput('default', this.validate),
|
||||
'INPUT',
|
||||
);
|
||||
this.setColour(230);
|
||||
this.setCommentText(
|
||||
"Upon detecting a 'b' character the input will" +
|
||||
' validated to null (invalid). Upon removal it should revert to' +
|
||||
' being valid. The display text will remain the input text, but if' +
|
||||
' the input text is invalid the value should be the default text.',
|
||||
);
|
||||
},
|
||||
|
||||
validate: function (newValue) {
|
||||
if (newValue.indexOf('b') !== -1) {
|
||||
return null;
|
||||
}
|
||||
return newValue;
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks['test_validators_checkbox_null'] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField('always null')
|
||||
.appendField(new Blockly.FieldCheckbox(true, this.validate), 'INPUT');
|
||||
this.setColour(230);
|
||||
this.setCommentText(
|
||||
'The new input always validates to null (invalid).' +
|
||||
' This means that the field value should not change.',
|
||||
);
|
||||
},
|
||||
|
||||
validate: function (newValue) {
|
||||
return null;
|
||||
},
|
||||
};
|
||||
Blockly.Blocks['test_validators_checkbox_match'] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField('force match')
|
||||
.appendField(new Blockly.FieldCheckbox(true), 'MATCH')
|
||||
.appendField(new Blockly.FieldCheckbox(true, this.validate), 'INPUT');
|
||||
this.setColour(230);
|
||||
this.setCommentText(
|
||||
'The validator for this block only works on the end-most checkbox.' +
|
||||
' The validator will always return the value of the start-most' +
|
||||
' checkbox. Therefore they should always match.',
|
||||
);
|
||||
},
|
||||
|
||||
validate: function (newValue) {
|
||||
return this.sourceBlock_.getFieldValue('MATCH');
|
||||
},
|
||||
};
|
||||
Blockly.Blocks['test_validators_checkbox_not_match_null'] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField('not match -> null')
|
||||
.appendField(new Blockly.FieldCheckbox(true), 'MATCH')
|
||||
.appendField(new Blockly.FieldCheckbox(true, this.validate), 'INPUT');
|
||||
this.setColour(230);
|
||||
this.setCommentText(
|
||||
'The validator for this block only works on the' +
|
||||
' end-most checkbox. If the new value does not match the value of the' +
|
||||
' start-most checkbox, it will return null (invalid), which means the' +
|
||||
' field value should not change. Therefore they should always match.',
|
||||
);
|
||||
},
|
||||
|
||||
validate: function (newValue) {
|
||||
if (this.sourceBlock_.getFieldValue('MATCH') != newValue) {
|
||||
return null;
|
||||
}
|
||||
return newValue;
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks['test_validators_dropdown_null'] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField('always null')
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown(
|
||||
[
|
||||
['1a', '1A'],
|
||||
['1b', '1B'],
|
||||
['1c', '1C'],
|
||||
['2a', '2A'],
|
||||
['2b', '2B'],
|
||||
['2c', '2C'],
|
||||
],
|
||||
this.validate,
|
||||
),
|
||||
'INPUT',
|
||||
);
|
||||
this.setColour(230);
|
||||
this.setCommentText(
|
||||
'All input validates to null (invalid). This means' +
|
||||
' the field value should not change.',
|
||||
);
|
||||
},
|
||||
|
||||
validate: function (newValue) {
|
||||
return null;
|
||||
},
|
||||
};
|
||||
Blockly.Blocks['test_validators_dropdown_force_1s'] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField('force 1s')
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown(
|
||||
[
|
||||
['1a', '1A'],
|
||||
['1b', '1B'],
|
||||
['1c', '1C'],
|
||||
['2a', '2A'],
|
||||
['2b', '2B'],
|
||||
['2c', '2C'],
|
||||
],
|
||||
this.validate,
|
||||
),
|
||||
'INPUT',
|
||||
);
|
||||
this.setColour(230);
|
||||
this.setCommentText(
|
||||
"The input's value will always change to start with 1.",
|
||||
);
|
||||
},
|
||||
|
||||
validate: function (newValue) {
|
||||
return '1' + newValue.charAt(1);
|
||||
},
|
||||
};
|
||||
Blockly.Blocks['test_validators_dropdown_1s_null'] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField('not 1s -> null')
|
||||
.appendField(
|
||||
new Blockly.FieldDropdown(
|
||||
[
|
||||
['1a', '1A'],
|
||||
['1b', '1B'],
|
||||
['1c', '1C'],
|
||||
['2a', '2A'],
|
||||
['2b', '2B'],
|
||||
['2c', '2C'],
|
||||
],
|
||||
this.validate,
|
||||
),
|
||||
'INPUT',
|
||||
);
|
||||
this.setColour(230);
|
||||
this.setCommentText(
|
||||
'If the input does not start with 1, the input will validate to' +
|
||||
' null (invalid). Otherwise it will return the input value.',
|
||||
);
|
||||
},
|
||||
|
||||
validate: function (newValue) {
|
||||
if (newValue.charAt(0) != '1') {
|
||||
return null;
|
||||
}
|
||||
return newValue;
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks['test_validators_number_null'] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField('always null')
|
||||
.appendField(
|
||||
new Blockly.FieldNumber(123, null, null, null, this.validate),
|
||||
'INPUT',
|
||||
);
|
||||
this.setColour(230);
|
||||
this.setCommentText(
|
||||
'All input validates to null (invalid). The field will display the' +
|
||||
' input while the field is being edited, but the value should be the' +
|
||||
' default value. The input should be red after the first' +
|
||||
' keystroke.',
|
||||
);
|
||||
},
|
||||
|
||||
validate: function (newValue) {
|
||||
return null;
|
||||
},
|
||||
};
|
||||
Blockly.Blocks['test_validators_number_mult10_force'] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField('force mult of 10')
|
||||
.appendField(
|
||||
new Blockly.FieldNumber(123, null, null, null, this.validate),
|
||||
'INPUT',
|
||||
);
|
||||
this.setColour(230);
|
||||
this.setCommentText(
|
||||
'The input value will be rounded to the nearest' +
|
||||
' multiple of 10. The field will display the input while the field is' +
|
||||
' being edited, but the value should be the validated (rounded)' +
|
||||
' value. Note: If you want to do rounding this is not the proper' +
|
||||
' way, use the precision option of the number field constructor' +
|
||||
' instead.',
|
||||
);
|
||||
},
|
||||
|
||||
validate: function (newValue) {
|
||||
return Math.round(newValue / 10) * 10;
|
||||
},
|
||||
};
|
||||
Blockly.Blocks['test_validators_number_mult10_null'] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField('not mult of 10 -> null')
|
||||
.appendField(
|
||||
new Blockly.FieldNumber(123, null, null, null, this.validate),
|
||||
'INPUT',
|
||||
);
|
||||
this.setColour(230);
|
||||
this.setCommentText(
|
||||
'If the input value is not a multiple of 10, the' +
|
||||
' input will validate to null (invalid). The field will display the' +
|
||||
' input while the field is being edited, but if the input value is' +
|
||||
' invalid the value should be the default value.',
|
||||
);
|
||||
},
|
||||
|
||||
validate: function (newValue) {
|
||||
if (newValue % 10 != 0) {
|
||||
return null;
|
||||
}
|
||||
return newValue;
|
||||
},
|
||||
};
|
||||
|
||||
Blockly.Blocks['test_validators_variable_null'] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField('always null')
|
||||
.appendField(new Blockly.FieldVariable('1a', this.validate), 'INPUT');
|
||||
this.setColour(230);
|
||||
this.setCommentText(
|
||||
'All ids validate to null (invalid). This means' +
|
||||
' the variable should not change.',
|
||||
);
|
||||
},
|
||||
|
||||
validate: function (newValue) {
|
||||
return null;
|
||||
},
|
||||
};
|
||||
Blockly.Blocks['test_validators_variable_force_1s'] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField('force 1s')
|
||||
.appendField(new Blockly.FieldVariable('1a', this.validate), 'INPUT');
|
||||
this.setColour(230);
|
||||
this.setCommentText('The id will always change to start with 1.');
|
||||
},
|
||||
|
||||
validate: function (newValue) {
|
||||
return '1' + newValue.charAt(1);
|
||||
},
|
||||
};
|
||||
Blockly.Blocks['test_validators_variable_1s_null'] = {
|
||||
init: function () {
|
||||
this.appendDummyInput()
|
||||
.appendField('not 1s -> null')
|
||||
.appendField(new Blockly.FieldVariable('1a', this.validate), 'INPUT');
|
||||
this.setColour(230);
|
||||
this.setCommentText(
|
||||
'If the id does not start with 1, the id will' +
|
||||
' validate to null (invalid). Otherwise it will return the id.',
|
||||
);
|
||||
},
|
||||
|
||||
validate: function (newValue) {
|
||||
if (newValue.charAt(0) != '1') {
|
||||
return null;
|
||||
}
|
||||
return newValue;
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* The Validators field category.
|
||||
*/
|
||||
export const category = {
|
||||
kind: 'CATEGORY',
|
||||
name: 'Validators',
|
||||
contents: [
|
||||
{
|
||||
kind: 'BUTTON',
|
||||
text: 'add blocks to workspace',
|
||||
callbackkey: 'addAllBlocksToWorkspace',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '8',
|
||||
},
|
||||
{
|
||||
kind: 'BUTTON',
|
||||
text: 'set input',
|
||||
callbackkey: 'setInput',
|
||||
},
|
||||
{
|
||||
kind: 'LABEL',
|
||||
text: 'Dispose block',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '12',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_validators_dispose_block',
|
||||
},
|
||||
{
|
||||
kind: 'LABEL',
|
||||
text: 'Checkboxes',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '12',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_validators_checkbox_null',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '12',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_validators_checkbox_match',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '12',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_validators_checkbox_not_match_null',
|
||||
},
|
||||
{
|
||||
kind: 'LABEL',
|
||||
text: 'Dropdowns',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '12',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_validators_dropdown_null',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '12',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_validators_dropdown_force_1s',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '12',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_validators_dropdown_1s_null',
|
||||
},
|
||||
{
|
||||
kind: 'LABEL',
|
||||
text: 'Numbers',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '12',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_validators_number_null',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '12',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_validators_number_mult10_force',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '12',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_validators_number_mult10_null',
|
||||
},
|
||||
{
|
||||
kind: 'LABEL',
|
||||
text: 'Text',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '12',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_validators_text_null',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '12',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_validators_text_A',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '12',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_validators_text_B',
|
||||
},
|
||||
{
|
||||
kind: 'LABEL',
|
||||
text: 'Variables',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '8',
|
||||
},
|
||||
{
|
||||
'kind': 'BUTTON',
|
||||
'text': 'add test variables',
|
||||
'callbackkey': 'addVariables',
|
||||
'web-class': 'modifiesWorkspace',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '12',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_validators_variable_null',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '12',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_validators_variable_force_1s',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '12',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_validators_variable_1s_null',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize this toolbox category.
|
||||
* @param {!Blockly.WorkspaceSvg} workspace The Blockly workspace.
|
||||
*/
|
||||
export function onInit(workspace) {
|
||||
const addVariables = function (button) {
|
||||
workspace.createVariable('1b', '', '1B');
|
||||
workspace.createVariable('1c', '', '1C');
|
||||
workspace.createVariable('2a', '', '2A');
|
||||
workspace.createVariable('2b', '', '2B');
|
||||
workspace.createVariable('2c', '', '2C');
|
||||
};
|
||||
const setInput = function (button) {
|
||||
Blockly.dialog.prompt('Input text to set.', 'ab', function (input) {
|
||||
const blocks = button.getTargetWorkspace().getAllBlocks(false);
|
||||
for (let i = 0, block; (block = blocks[i]); i++) {
|
||||
if (block.getField('INPUT')) {
|
||||
block.setFieldValue(input, 'INPUT');
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
workspace.registerButtonCallback('addVariables', addVariables);
|
||||
workspace.registerButtonCallback('setInput', setInput);
|
||||
}
|
||||
80
node_modules/@blockly/block-test/src/index.js
generated
vendored
Normal file
80
node_modules/@blockly/block-test/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2020 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @fileoverview Import all the test blocks.
|
||||
* @author samelh@google.com (Sam El-Husseini)
|
||||
*/
|
||||
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
import {category as alignCategory, onInit as initAlign} from './align';
|
||||
import {category as basicCategory, onInit as initBasic} from './basic';
|
||||
import {
|
||||
category as chameleonCategory,
|
||||
onInit as initChameleon,
|
||||
} from './chameleon';
|
||||
import {
|
||||
category as connectionsCategory,
|
||||
onInit as initConnections,
|
||||
} from './connections';
|
||||
import {category as dragCategory, onInit as initDrag} from './drag';
|
||||
import {category as fieldsCategory, onInit as initFields} from './fields';
|
||||
import {category as mutatorsCategory, onInit as initMutators} from './mutators';
|
||||
import {category as styleCategory, onInit as initStyle} from './style';
|
||||
import {
|
||||
category as serializationCategory,
|
||||
onInit as initSerialization,
|
||||
} from './serialization/category';
|
||||
|
||||
/**
|
||||
* The Test blocks toolbox.
|
||||
*/
|
||||
export const toolboxTestBlocks = {
|
||||
contents: [
|
||||
alignCategory,
|
||||
basicCategory,
|
||||
chameleonCategory,
|
||||
connectionsCategory,
|
||||
dragCategory,
|
||||
fieldsCategory,
|
||||
mutatorsCategory,
|
||||
styleCategory,
|
||||
serializationCategory,
|
||||
],
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize this toolbox.
|
||||
* @param {!Blockly.WorkspaceSvg} workspace The Blockly workspace.
|
||||
*/
|
||||
export function toolboxTestBlocksInit(workspace) {
|
||||
initAlign(workspace);
|
||||
initBasic(workspace);
|
||||
initChameleon(workspace);
|
||||
initConnections(workspace);
|
||||
initDrag(workspace);
|
||||
initFields(workspace);
|
||||
initMutators(workspace);
|
||||
initStyle(workspace);
|
||||
initSerialization(workspace);
|
||||
|
||||
const addAllBlocksToWorkspace = function (button) {
|
||||
const workspace = button.getTargetWorkspace();
|
||||
const blocks = workspace.getFlyout().getWorkspace().getTopBlocks();
|
||||
for (let i = 0, block; (block = blocks[i]); i++) {
|
||||
const state = Blockly.serialization.blocks.save(block, {
|
||||
addCoordinates: true,
|
||||
});
|
||||
Blockly.serialization.blocks.append(state, workspace);
|
||||
}
|
||||
};
|
||||
workspace.registerButtonCallback(
|
||||
'addAllBlocksToWorkspace',
|
||||
addAllBlocksToWorkspace,
|
||||
);
|
||||
}
|
||||
257
node_modules/@blockly/block-test/src/mutators.js
generated
vendored
Normal file
257
node_modules/@blockly/block-test/src/mutators.js
generated
vendored
Normal file
@@ -0,0 +1,257 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2020 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @fileoverview Mutator test blocks.
|
||||
* @author samelh@google.com (Sam El-Husseini)
|
||||
*/
|
||||
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
Blockly.defineBlocksWithJsonArray([
|
||||
{
|
||||
type: 'test_mutator_textChange',
|
||||
message0: 'mutator text: %1',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_input',
|
||||
name: 'MUTATOR_TEXT',
|
||||
text: 'a label',
|
||||
},
|
||||
],
|
||||
style: 'colour_blocks',
|
||||
},
|
||||
]);
|
||||
|
||||
/**
|
||||
* Mutator methods added to the test_mutators_many block.
|
||||
* @mixin
|
||||
* @package
|
||||
* @readonly
|
||||
*/
|
||||
const COLOR_CHANGE_MUTATOR = {
|
||||
/**
|
||||
* Create XML to represent the block mutation.
|
||||
* @returns {Element} XML storage element.
|
||||
* @this {Blockly.Block}
|
||||
*/
|
||||
mutationToDom: function () {
|
||||
const container = Blockly.utils.xml.createElement('mutation');
|
||||
container.setAttribute('arbitrary', this.getFieldValue('LABEL'));
|
||||
return container;
|
||||
},
|
||||
/**
|
||||
* Restore a block from XML.
|
||||
* @param {!Element} xmlElement XML storage element.
|
||||
* @this {Blockly.Block}
|
||||
*/
|
||||
domToMutation: function (xmlElement) {
|
||||
this.setFieldValue(xmlElement.getAttribute('arbitrary'), 'LABEL');
|
||||
},
|
||||
/**
|
||||
* Returns the state of this block as a json serializable object.
|
||||
* @returns {{arbitrary: string}} The state of this block.
|
||||
* @this {Blockly.Block}
|
||||
*/
|
||||
saveExtraState: function () {
|
||||
return {arbitrary: this.getFieldValue('LABEL')};
|
||||
},
|
||||
/**
|
||||
* Applies the state to this block.
|
||||
* @param {{arbitrary: string}} state The state to apply.
|
||||
* @this {Blockly.Block}
|
||||
*/
|
||||
loadExtraState: function (state) {
|
||||
this.setFieldValue(state['arbitrary'], 'LABEL');
|
||||
},
|
||||
/**
|
||||
* Populate the mutator's dialog with this block's components.
|
||||
* @param {!Blockly.Workspace} workspace Mutator's workspace.
|
||||
* @returns {!Blockly.Block} Root block in mutator.
|
||||
* @this {Blockly.Block}
|
||||
*/
|
||||
decompose: function (workspace) {
|
||||
const containerBlock = Blockly.serialization.blocks.append(
|
||||
{type: 'test_mutator_textChange'},
|
||||
workspace,
|
||||
);
|
||||
containerBlock
|
||||
.getField('MUTATOR_TEXT')
|
||||
.setValue(this.getFieldValue('LABEL'));
|
||||
return containerBlock;
|
||||
},
|
||||
/**
|
||||
* Reconfigure this block based on the mutator dialog's components.
|
||||
* @param {!Blockly.Block} containerBlock Root block in mutator.
|
||||
* @this {Blockly.Block}
|
||||
*/
|
||||
compose: function (containerBlock) {
|
||||
this.setFieldValue(containerBlock.getFieldValue('MUTATOR_TEXT'), 'LABEL');
|
||||
},
|
||||
};
|
||||
|
||||
const n = 20;
|
||||
const blocksIds = [];
|
||||
for (let i = 0; i < n; i++) {
|
||||
blocksIds.push(`test_mutator_category_${i}`);
|
||||
}
|
||||
|
||||
const defineBlocks = blocksIds.map((t) => ({
|
||||
type: t,
|
||||
message0: 'mutator text: %1',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_input',
|
||||
name: 'MUTATOR_TEXT',
|
||||
text: 'a label',
|
||||
},
|
||||
],
|
||||
style: 'colour_blocks',
|
||||
}));
|
||||
|
||||
Blockly.defineBlocksWithJsonArray([
|
||||
{
|
||||
type: 'test_mutators_many',
|
||||
message0: 'test many blocks mutator %1',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_label',
|
||||
name: 'LABEL',
|
||||
text: 'changeable label',
|
||||
},
|
||||
],
|
||||
mutator: 'test_many_blocks_mutator',
|
||||
colour: '#000000',
|
||||
},
|
||||
...defineBlocks,
|
||||
]);
|
||||
|
||||
/** Register custom mutator used by the test_mutators_many block. */
|
||||
Blockly.Extensions.registerMutator(
|
||||
'test_many_blocks_mutator',
|
||||
COLOR_CHANGE_MUTATOR,
|
||||
null,
|
||||
[...blocksIds],
|
||||
);
|
||||
|
||||
Blockly.defineBlocksWithJsonArray([
|
||||
{
|
||||
type: 'test_mutators_noflyout',
|
||||
message0: 'noflyout mutator %1',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_label',
|
||||
name: 'LABEL',
|
||||
text: 'changeable label',
|
||||
},
|
||||
],
|
||||
mutator: 'test_noflyout_mutator',
|
||||
colour: '#000000',
|
||||
},
|
||||
]);
|
||||
|
||||
/** Register custom mutator used by the test_mutators_noflyout block. */
|
||||
Blockly.Extensions.registerMutator(
|
||||
'test_noflyout_mutator',
|
||||
COLOR_CHANGE_MUTATOR,
|
||||
null,
|
||||
[],
|
||||
);
|
||||
|
||||
Blockly.defineBlocksWithJsonArray([
|
||||
{
|
||||
type: 'test_mutators_changeableFlyout',
|
||||
message0: 'changeable flyout mutator %1',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_label',
|
||||
name: 'LABEL',
|
||||
text: 'changeable label',
|
||||
},
|
||||
],
|
||||
mutator: 'test_changeableFlyout_mutator',
|
||||
colour: '#000000',
|
||||
},
|
||||
]);
|
||||
|
||||
/** Register custom mutator used by the test_mutators_changeableFlyout block. */
|
||||
Blockly.Extensions.registerMutator(
|
||||
'test_changeableFlyout_mutator',
|
||||
COLOR_CHANGE_MUTATOR,
|
||||
null,
|
||||
['text'],
|
||||
);
|
||||
|
||||
/**
|
||||
* The Mutators category.
|
||||
*/
|
||||
export const category = {
|
||||
kind: 'CATEGORY',
|
||||
name: 'Mutators',
|
||||
contents: [
|
||||
{
|
||||
kind: 'LABEL',
|
||||
text: 'logic_compare',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'logic_compare',
|
||||
inputs: {
|
||||
A: {
|
||||
shadow: {
|
||||
type: 'math_number',
|
||||
fields: {NUM: 10},
|
||||
},
|
||||
},
|
||||
B: {
|
||||
shadow: {
|
||||
type: 'math_number',
|
||||
fields: {NUM: 10},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'logic_compare',
|
||||
inputs: {
|
||||
A: {
|
||||
block: {
|
||||
type: 'math_number',
|
||||
fields: {NUM: 10},
|
||||
},
|
||||
},
|
||||
B: {
|
||||
block: {
|
||||
type: 'math_number',
|
||||
fields: {NUM: 10},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_mutators_noflyout',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_mutators_many',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_mutators_changeableFlyout',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize this toolbox category.
|
||||
* @param {!Blockly.WorkspaceSvg} workspace The Blockly workspace.
|
||||
*/
|
||||
export function onInit(workspace) {
|
||||
// NOP
|
||||
}
|
||||
112
node_modules/@blockly/block-test/src/serialization/blocks.js
generated
vendored
Normal file
112
node_modules/@blockly/block-test/src/serialization/blocks.js
generated
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
// @ts-nocheck
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2021 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as Blockly from 'blockly/core';
|
||||
import './fields';
|
||||
|
||||
Blockly.defineBlocksWithJsonArray([
|
||||
{
|
||||
type: 'test_field_serialization_no_overrides',
|
||||
message0: 'no overrides: %1',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_no_overrides',
|
||||
name: 'LABEL',
|
||||
text: 'test',
|
||||
},
|
||||
],
|
||||
colour: 0,
|
||||
output: null,
|
||||
},
|
||||
{
|
||||
type: 'test_field_serialization_xml',
|
||||
message0: 'xml: %1',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_xml',
|
||||
name: 'LABEL',
|
||||
text: 'test',
|
||||
},
|
||||
],
|
||||
colour: 30,
|
||||
output: null,
|
||||
},
|
||||
{
|
||||
type: 'test_field_serialization_jso',
|
||||
message0: 'jso: %1',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_jso',
|
||||
name: 'LABEL',
|
||||
text: 'test',
|
||||
},
|
||||
],
|
||||
colour: 90,
|
||||
output: null,
|
||||
},
|
||||
{
|
||||
type: 'test_field_serialization_both',
|
||||
message0: 'both: %1',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_both',
|
||||
name: 'LABEL',
|
||||
text: 'test',
|
||||
},
|
||||
],
|
||||
colour: 150,
|
||||
output: null,
|
||||
},
|
||||
]);
|
||||
|
||||
Blockly.Blocks['test_extra_state_xml'] = Object.assign(
|
||||
{},
|
||||
Blockly.Blocks['lists_create_with'],
|
||||
);
|
||||
delete Blockly.Blocks['test_extra_state_xml'].saveExtraState;
|
||||
delete Blockly.Blocks['test_extra_state_xml'].loadExtraState;
|
||||
Blockly.Blocks['test_extra_state_xml'].init = function () {
|
||||
this.setColour(30);
|
||||
this.itemCount_ = 3;
|
||||
this.updateShape_();
|
||||
this.setOutput(true, 'Array');
|
||||
this.setMutator(
|
||||
new Blockly.icons.MutatorIcon(['lists_create_with_item'], this),
|
||||
);
|
||||
};
|
||||
|
||||
Blockly.Blocks['test_extra_state_jso'] = Object.assign(
|
||||
{},
|
||||
Blockly.Blocks['lists_create_with'],
|
||||
);
|
||||
delete Blockly.Blocks['test_extra_state_jso'].mutationToDom;
|
||||
delete Blockly.Blocks['test_extra_state_jso'].domToMutation;
|
||||
Blockly.Blocks['test_extra_state_jso'].init = function () {
|
||||
this.setColour(90);
|
||||
this.itemCount_ = 3;
|
||||
this.updateShape_();
|
||||
this.setOutput(true, 'Array');
|
||||
this.setMutator(
|
||||
new Blockly.icons.MutatorIcon(['lists_create_with_item'], this),
|
||||
);
|
||||
};
|
||||
|
||||
Blockly.Blocks['test_extra_state_both'] = Object.assign(
|
||||
{},
|
||||
Blockly.Blocks['lists_create_with'],
|
||||
);
|
||||
Blockly.Blocks['test_extra_state_both'].init = function () {
|
||||
this.setColour(150);
|
||||
this.itemCount_ = 3;
|
||||
this.updateShape_();
|
||||
this.setOutput(true, 'Array');
|
||||
this.setMutator(
|
||||
new Blockly.icons.MutatorIcon(['lists_create_with_item'], this),
|
||||
);
|
||||
};
|
||||
193
node_modules/@blockly/block-test/src/serialization/category.js
generated
vendored
Normal file
193
node_modules/@blockly/block-test/src/serialization/category.js
generated
vendored
Normal file
@@ -0,0 +1,193 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2021 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as Blockly from 'blockly/core';
|
||||
import './blocks';
|
||||
|
||||
/**
|
||||
* The Serialization category.
|
||||
*/
|
||||
export const category = {
|
||||
kind: 'CATEGORY',
|
||||
name: 'Serialization',
|
||||
contents: [
|
||||
{
|
||||
kind: 'BUTTON',
|
||||
text: 'add blocks to workspace',
|
||||
callbackkey: 'addAllBlocksToWorkspace',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: '8',
|
||||
},
|
||||
{
|
||||
kind: 'BUTTON',
|
||||
text: 'randomize text',
|
||||
callbackkey: 'randomizeText',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_field_serialization_no_overrides',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_field_serialization_xml',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_field_serialization_jso',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_field_serialization_both',
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: 30,
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
blockxml:
|
||||
'<block type="test_extra_state_xml">' +
|
||||
'<mutation items="2"></mutation>' +
|
||||
'</block>',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_extra_state_jso',
|
||||
extraState: {
|
||||
itemCount: 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_extra_state_both',
|
||||
extraState: {
|
||||
itemCount: 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: 30,
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'text_print',
|
||||
inputs: {
|
||||
TEXT: {
|
||||
shadow: {
|
||||
type: 'test_field_serialization_no_overrides',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'text_print',
|
||||
inputs: {
|
||||
TEXT: {
|
||||
shadow: {
|
||||
type: 'test_field_serialization_xml',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'text_print',
|
||||
inputs: {
|
||||
TEXT: {
|
||||
shadow: {
|
||||
type: 'test_field_serialization_jso',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'text_print',
|
||||
inputs: {
|
||||
TEXT: {
|
||||
shadow: {
|
||||
type: 'test_field_serialization_both',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'SEP',
|
||||
gap: 30,
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
blockxml:
|
||||
'<block type="text_print">' +
|
||||
'<value name="TEXT">' +
|
||||
'<shadow type="test_extra_state_xml">' +
|
||||
'<mutation items="2"></mutation>' +
|
||||
'</shadow>' +
|
||||
'</value>' +
|
||||
'</block>',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'text_print',
|
||||
inputs: {
|
||||
TEXT: {
|
||||
shadow: {
|
||||
type: 'test_extra_state_jso',
|
||||
extraState: {
|
||||
itemCount: 2,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'text_print',
|
||||
inputs: {
|
||||
TEXT: {
|
||||
shadow: {
|
||||
type: 'test_extra_state_both',
|
||||
extraState: {
|
||||
itemCount: 2,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize this toolbox category.
|
||||
* @param {!Blockly.WorkspaceSvg} workspace The Blockly workspace.
|
||||
*/
|
||||
export function onInit(workspace) {
|
||||
const randomizeText = function (button) {
|
||||
const targetWorkspace = button.getTargetWorkspace();
|
||||
const blocks = [
|
||||
...targetWorkspace.getBlocksByType(
|
||||
'test_field_serialization_no_overrides',
|
||||
),
|
||||
...targetWorkspace.getBlocksByType('test_field_serialization_xml'),
|
||||
...targetWorkspace.getBlocksByType('test_field_serialization_jso'),
|
||||
...targetWorkspace.getBlocksByType('test_field_serialization_both'),
|
||||
];
|
||||
const possible = 'ABCDEF';
|
||||
for (let i = 0, block; (block = blocks[i]); i++) {
|
||||
let text = '';
|
||||
for (let j = 0; j < 4; j++) {
|
||||
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
||||
}
|
||||
block.setFieldValue(text, 'LABEL');
|
||||
}
|
||||
};
|
||||
workspace.registerButtonCallback('randomizeText', randomizeText);
|
||||
}
|
||||
201
node_modules/@blockly/block-test/src/serialization/fields.js
generated
vendored
Normal file
201
node_modules/@blockly/block-test/src/serialization/fields.js
generated
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2021 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
/**
|
||||
* Field that does not override any serialization hooks.
|
||||
*/
|
||||
class NoOverridesField extends Blockly.FieldLabel {
|
||||
/**
|
||||
* Constructor.
|
||||
* @param {string=} value The value for the field to hold.
|
||||
* @param {string=} cssClass The css class to apply to the field.
|
||||
* @param {*} config The config for the field.
|
||||
*/
|
||||
constructor(value, cssClass, config) {
|
||||
super(value, cssClass, config);
|
||||
|
||||
this.EDITABLE = false;
|
||||
this.SERIALIZABLE = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the field based on its JSON definition.
|
||||
* @param {*} options Options for creating the field.
|
||||
* @returns {!NoOverridesField} The field that was created.
|
||||
*/
|
||||
NoOverridesField.fromJson = function (options) {
|
||||
const text = Blockly.utils.parsing.replaceMessageReferences(options['text']);
|
||||
return new this(text, undefined, options);
|
||||
};
|
||||
|
||||
Blockly.fieldRegistry.register('field_no_overrides', NoOverridesField);
|
||||
|
||||
/**
|
||||
* Field that overrides XML serialization hooks.
|
||||
*/
|
||||
class XmlField extends Blockly.FieldLabel {
|
||||
/**
|
||||
* Constructor.
|
||||
* @param {string=} value The value for the field to hold.
|
||||
* @param {string=} cssClass The css class to apply to the field.
|
||||
* @param {*} config The config for the field.
|
||||
*/
|
||||
constructor(value, cssClass, config) {
|
||||
super(value, cssClass, config);
|
||||
|
||||
this.EDITABLE = false;
|
||||
this.SERIALIZABLE = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the state of the field as XML.
|
||||
* @param {!Element} element The element to add the state to.
|
||||
* @returns {!Element} The element with the state added.
|
||||
*/
|
||||
toXml(element) {
|
||||
element.setAttribute('value', this.getValue());
|
||||
return element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the given state to the field.
|
||||
* @param {!Element} element The element containing the state to apply.
|
||||
*/
|
||||
fromXml(element) {
|
||||
this.setValue(element.getAttribute('value'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the field based on its JSON definition.
|
||||
* @param {*} options Options for creating the field.
|
||||
* @returns {!XmlField} The field that was created.
|
||||
*/
|
||||
XmlField.fromJson = function (options) {
|
||||
const text = Blockly.utils.parsing.replaceMessageReferences(options['text']);
|
||||
return new this(text, undefined, options);
|
||||
};
|
||||
|
||||
Blockly.fieldRegistry.register('field_xml', XmlField);
|
||||
|
||||
/**
|
||||
* Field that overrides JSO serialization hooks.
|
||||
*/
|
||||
class JsoField extends Blockly.FieldLabel {
|
||||
/**
|
||||
* Constructor.
|
||||
* @param {string=} value The value for the field to hold.
|
||||
* @param {string=} cssClass The css class to apply to the field.
|
||||
* @param {*} config The config for the field.
|
||||
*/
|
||||
constructor(value, cssClass, config) {
|
||||
super(value, cssClass, config);
|
||||
|
||||
this.EDITABLE = false;
|
||||
this.SERIALIZABLE = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the state of the field as a JSON serializable value.
|
||||
* @returns {*} The state of the field.
|
||||
*/
|
||||
saveState() {
|
||||
return {
|
||||
value: this.getValue(),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the given state to the field.
|
||||
* @param {*} state The state to apply.
|
||||
*/
|
||||
loadState(state) {
|
||||
this.setValue(state['value']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the field based on its JSON definition.
|
||||
* @param {*} options Options for creating the field.
|
||||
* @returns {!JsoField} The field that was created.
|
||||
*/
|
||||
JsoField.fromJson = function (options) {
|
||||
const text = Blockly.utils.parsing.replaceMessageReferences(options['text']);
|
||||
return new this(text, undefined, options);
|
||||
};
|
||||
|
||||
Blockly.fieldRegistry.register('field_jso', JsoField);
|
||||
|
||||
/**
|
||||
* Field that overrides XML and JSO serialization hooks.
|
||||
*/
|
||||
class BothField extends Blockly.FieldLabel {
|
||||
/**
|
||||
* Constructor.
|
||||
* @param {string=} value The value for the field to hold.
|
||||
* @param {string=} cssClass The css class to apply to the field.
|
||||
* @param {*} config The config for the field.
|
||||
*/
|
||||
constructor(value, cssClass, config) {
|
||||
super(value, cssClass, config);
|
||||
|
||||
this.EDITABLE = false;
|
||||
this.SERIALIZABLE = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the state of the field as XML.
|
||||
* @param {!Element} element The element to add the state to.
|
||||
* @returns {!Element} The element with the state added.
|
||||
*/
|
||||
toXml(element) {
|
||||
element.setAttribute('value', this.getValue());
|
||||
return element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the given state to the field.
|
||||
* @param {!Element} element The element containing the state to apply.
|
||||
*/
|
||||
fromXml(element) {
|
||||
this.setValue(element.getAttribute('value'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the state of the field as a JSON serializable value.
|
||||
* @returns {*} The state of the field.
|
||||
*/
|
||||
saveState() {
|
||||
return {
|
||||
value: this.getValue(),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the given state to the field.
|
||||
* @param {*} state The state to apply.
|
||||
*/
|
||||
loadState(state) {
|
||||
this.setValue(state['value']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the field based on its JSON definition.
|
||||
* @param {*} options Options for creating the field.
|
||||
* @returns {!BothField} The field that was created.
|
||||
*/
|
||||
BothField.fromJson = function (options) {
|
||||
const text = Blockly.utils.parsing.replaceMessageReferences(options['text']);
|
||||
return new this(text, undefined, options);
|
||||
};
|
||||
|
||||
Blockly.fieldRegistry.register('field_both', BothField);
|
||||
194
node_modules/@blockly/block-test/src/style.js
generated
vendored
Normal file
194
node_modules/@blockly/block-test/src/style.js
generated
vendored
Normal file
@@ -0,0 +1,194 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2020 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @fileoverview Style test blocks.
|
||||
* @author samelh@google.com (Sam El-Husseini)
|
||||
*/
|
||||
|
||||
import * as Blockly from 'blockly/core';
|
||||
|
||||
Blockly.defineBlocksWithJsonArray([
|
||||
{
|
||||
type: 'test_style_hat',
|
||||
message0: 'Hat block (event)',
|
||||
nextStatement: null,
|
||||
style: 'hat_blocks',
|
||||
},
|
||||
{
|
||||
type: 'test_style_hex1',
|
||||
message0: 'Block color: Bright purple %1 %2 %3 %4',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_input',
|
||||
name: 'TEXT',
|
||||
text: '#992aff',
|
||||
},
|
||||
{
|
||||
type: 'field_dropdown',
|
||||
name: 'DROPDOWN',
|
||||
options: [
|
||||
['option', 'ONE'],
|
||||
['option', 'TWO'],
|
||||
],
|
||||
},
|
||||
{
|
||||
type: 'field_checkbox',
|
||||
name: 'NAME',
|
||||
checked: true,
|
||||
},
|
||||
{
|
||||
type: 'input_value',
|
||||
name: 'NAME',
|
||||
},
|
||||
],
|
||||
previousStatement: null,
|
||||
nextStatement: null,
|
||||
colour: '#992aff',
|
||||
},
|
||||
{
|
||||
type: 'test_style_hex2',
|
||||
message0: 'Block color: White %1 %2 %3 %4',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_input',
|
||||
name: 'TEXT',
|
||||
text: '#fefefe',
|
||||
},
|
||||
{
|
||||
type: 'field_dropdown',
|
||||
name: 'DROPDOWN',
|
||||
options: [
|
||||
['option', 'ONE'],
|
||||
['option', 'TWO'],
|
||||
],
|
||||
},
|
||||
{
|
||||
type: 'field_checkbox',
|
||||
name: 'NAME',
|
||||
checked: true,
|
||||
},
|
||||
{
|
||||
type: 'input_value',
|
||||
name: 'NAME',
|
||||
},
|
||||
],
|
||||
previousStatement: null,
|
||||
nextStatement: null,
|
||||
colour: '#fefefe',
|
||||
},
|
||||
{
|
||||
type: 'test_style_hex3',
|
||||
message0: 'Block color: Black %1 %2 %3 %4',
|
||||
args0: [
|
||||
{
|
||||
type: 'field_input',
|
||||
name: 'TEXT',
|
||||
text: '#010101',
|
||||
},
|
||||
{
|
||||
type: 'field_dropdown',
|
||||
name: 'DROPDOWN',
|
||||
options: [
|
||||
['option', 'ONE'],
|
||||
['option', 'TWO'],
|
||||
],
|
||||
},
|
||||
{
|
||||
type: 'field_checkbox',
|
||||
name: 'NAME',
|
||||
checked: true,
|
||||
},
|
||||
{
|
||||
type: 'input_value',
|
||||
name: 'NAME',
|
||||
},
|
||||
],
|
||||
previousStatement: null,
|
||||
nextStatement: null,
|
||||
colour: '#010101',
|
||||
},
|
||||
{
|
||||
type: 'test_style_no_colour',
|
||||
message0: 'Block color: unset',
|
||||
},
|
||||
{
|
||||
type: 'test_style_hex4',
|
||||
message0: 'Block color: #RRGGBBAA (invalid)',
|
||||
colour: '#992aff99',
|
||||
},
|
||||
{
|
||||
type: 'test_style_hex5',
|
||||
message0: 'Block color: #RRGGBB (invalid)',
|
||||
colour: '#NotHex',
|
||||
},
|
||||
{
|
||||
type: 'test_style_emoji',
|
||||
message0: 'Robot Face: \uD83E\uDD16',
|
||||
colour: '#AAAAAA',
|
||||
},
|
||||
]);
|
||||
|
||||
/**
|
||||
* The Style category.
|
||||
*/
|
||||
export const category = {
|
||||
kind: 'CATEGORY',
|
||||
name: 'Style',
|
||||
contents: [
|
||||
{
|
||||
kind: 'LABEL',
|
||||
text: 'Hats',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_style_hat',
|
||||
},
|
||||
{
|
||||
kind: 'LABEL',
|
||||
text: 'Colour',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_style_hex1',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_style_hex2',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_style_hex3',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_style_no_colour',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_style_hex4',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_style_hex5',
|
||||
gap: '40',
|
||||
},
|
||||
{
|
||||
kind: 'BLOCK',
|
||||
type: 'test_style_hex5',
|
||||
disabled: 'true',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize this toolbox category.
|
||||
* @param {!Blockly.WorkspaceSvg} workspace The Blockly workspace.
|
||||
*/
|
||||
export function onInit(workspace) {
|
||||
// NOP
|
||||
}
|
||||
216
node_modules/@blockly/dev-tools/README.md
generated
vendored
Normal file
216
node_modules/@blockly/dev-tools/README.md
generated
vendored
Normal file
@@ -0,0 +1,216 @@
|
||||
# @blockly/dev-tools [](https://github.com/google/blockly)
|
||||
|
||||
A library of helpful tools for Blockly development.
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
npm install @blockly/dev-tools -D --save
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Playground
|
||||
|
||||
The playground is a tremendously useful tool for debugging your Blockly project. As a preview, here is [one of the plugin playgrounds](https://google.github.io/blockly-samples/plugins/theme-modern/test/). The playground features are:
|
||||
|
||||
- All the default blocks
|
||||
- All the language generators (JavaScript, Python, PHP, Lua, and Dart)
|
||||
- Switch between different Blockly options (eg: rtl, renderer, readOnly, zoom and scroll)
|
||||
- Switch between different toolboxes and themes
|
||||
- Import and export programs, or generate code using one of the built-in generators
|
||||
- Trigger programmatic actions (eg: Show/hide, Clear, Undo/Redo, Scale)
|
||||
- A debug renderer
|
||||
- Stress tests for the renderer
|
||||
- Log all events in the console
|
||||
|
||||
```js
|
||||
import {createPlayground} from '@blockly/dev-tools';
|
||||
|
||||
const defaultOptions = {
|
||||
...
|
||||
};
|
||||
createPlayground(document.getElementById('blocklyDiv'), (blocklyDiv, options) => {
|
||||
return Blockly.inject(blocklyDiv, options);
|
||||
}, defaultOptions);
|
||||
```
|
||||
|
||||
This package also exports pieces of the playground (addGUIControls, addCodeEditor) if you'd rather build your own playground.
|
||||
|
||||
### Toolboxes
|
||||
|
||||
Blockly built-in Simple and Category toolboxes.
|
||||
|
||||
```js
|
||||
import * as Blockly from 'blockly';
|
||||
import {toolboxSimple, toolboxCategories} from '@blockly/dev-tools';
|
||||
|
||||
Blockly.inject('blocklyDiv', {
|
||||
toolbox: toolboxCategories,
|
||||
});
|
||||
```
|
||||
|
||||
#### Test Toolbox
|
||||
|
||||
The test toolbox is re-exported in this package, but can be imported as a stand-alone through [@blockly/block-test](https://www.npmjs.com/package/@blockly/block-test). See the README for details.
|
||||
|
||||
### Helpers
|
||||
|
||||
#### `populateRandom`
|
||||
|
||||
The `populateRandom` function adds random blocks to a workspace. Blocks are selected from the full set of defined blocks. Pass in a worskpace and how many blocks should be created.
|
||||
|
||||
```js
|
||||
import {populateRandom} from '@blockly/dev-tools';
|
||||
// Add 10 random blocks to the workspace.
|
||||
populateRandom(workspace, 10);
|
||||
```
|
||||
|
||||
#### `spaghetti`
|
||||
|
||||
The `spaghetti` function is a renderer stress test that populates the workspace with nested if-statements. Pass in a worskpace and how deep the nesting should be.
|
||||
|
||||
```js
|
||||
import {spaghetti} from '@blockly/dev-tools';
|
||||
spaghetti(workspace, 8);
|
||||
```
|
||||
|
||||
#### `generateFieldTestBlocks`
|
||||
|
||||
The `generateFieldTestBlocks` function automatically generates a number of field testing blocks for the passed-in field. This is useful for testing field plugins.
|
||||
|
||||
```js
|
||||
import {generateFieldTestBlocks} from '@blockly/dev-tools';
|
||||
|
||||
const toolbox = generateFieldTestBlocks('field_template', [
|
||||
{
|
||||
args: {
|
||||
value: 0, // default value
|
||||
},
|
||||
},
|
||||
]);
|
||||
```
|
||||
|
||||
### Test Helpers
|
||||
|
||||
This package is also used in mocha tests, and exports a suite of useful test helpers.
|
||||
You can find the full list of helpers [here](https://github.com/google/blockly-samples/blob/master/plugins/dev-tools/src/test_helpers.mocha.js).
|
||||
|
||||
### Debug Renderer
|
||||
|
||||
The [debug renderer][dev-tools] is a renderer plugin that wraps your normal
|
||||
renderer, and visualizes the measurements the [render info][render-info]
|
||||
collects. This is extremely helpful for understanding what your renderer thinks
|
||||
about the block it is trying to render.
|
||||
|
||||
#### What it surfaces
|
||||
|
||||
The debug renderer can show you several different things.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Debug info</th>
|
||||
<th>Image</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
<td><a href="https://developers.google.com/blocklyguides/create-custom-blocks/appearance/renderers/concepts/rows">Rows</a></td>
|
||||
<td><img src="https://github.com/google/blockly-samples/raw/master/plugins/dev-tools/readme-media/row.png"/></td>
|
||||
<td>The bounds of the individual rows in a block.</td>
|
||||
<tr>
|
||||
<td><a href="https://developers.google.com/blocklyguides/create-custom-blocks/appearance/renderers/concepts/rows#row_spacer">Row spacers</a></td>
|
||||
<td><img src="https://github.com/google/blockly-samples/raw/master/plugins/dev-tools/readme-media/row-spacer.png"/></td>
|
||||
<td>The bounds of the row spacers in a block.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://developers.google.com/blocklyguides/create-custom-blocks/appearance/renderers/concepts/elements">Elements</a></td>
|
||||
<td><img src="https://github.com/google/blockly-samples/raw/master/plugins/dev-tools/readme-media/element.png"/></td>
|
||||
<td>The bounds of the elements in a block.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://developers.google.com/blocklyguides/create-custom-blocks/appearance/renderers/concepts/elements#element_spacer">Element spacers</a></td>
|
||||
<td><img src="https://github.com/google/blockly-samples/raw/master/plugins/dev-tools/readme-media/element-spacer.png"/></td>
|
||||
<td>The bounds of the element spacers in a block.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Connections</td>
|
||||
<td><img src="https://github.com/google/blockly-samples/raw/master/plugins/dev-tools/readme-media/connection.png"/></td>
|
||||
<td>
|
||||
The locations of the connection points, with large circles for next and
|
||||
input connections (parent connections) and small circles for output and
|
||||
previous connections (child connections).
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Block bounds</td>
|
||||
<td><img src="https://github.com/google/blockly-samples/raw/master/plugins/dev-tools/readme-media/block-bounds.png"/></td>
|
||||
<td>
|
||||
The bounds of the block, not including any child blocks.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Connectioned block bounds</td>
|
||||
<td><img src="https://github.com/google/blockly-samples/raw/master/plugins/dev-tools/readme-media/block-bounds-with-children.png"/></td>
|
||||
<td>
|
||||
The bounds of the block, including child blocks.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Render / paint</td>
|
||||
<td></td>
|
||||
<td>
|
||||
Flashes the block red when the renderer rerenders the block, equivalent
|
||||
to <a href="https://developer.chrome.com/docs/devtools/rendering/performance/#paint-flashing">paint flashing</a>
|
||||
in Chrome.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
#### How to use it
|
||||
|
||||
The debug renderer wraps your existing renderer, and then you can register and
|
||||
use it just like any other renderer.
|
||||
|
||||
```js
|
||||
import {createNewRenderer, DebugDrawer} from '@blockly/dev-tools';
|
||||
|
||||
const DebugRenderer = createNewRenderer(YourCustomRenderer);
|
||||
Blockly.blockRendering.register('debugRenderer', DebugRenderer);
|
||||
|
||||
Blockly.inject('blocklyDiv', {renderer: 'debugRenderer'});
|
||||
```
|
||||
|
||||
To see the different information the debug renderer surfaces, you can modify
|
||||
the config from the browser console.
|
||||
|
||||
```js
|
||||
DebugDrawer.config = {
|
||||
rows: true,
|
||||
rowSpacers: true,
|
||||
elems: true,
|
||||
elemSpacers: true,
|
||||
connections: true,
|
||||
blockBounds: true,
|
||||
connectedBlockBounds: true,
|
||||
render: true,
|
||||
};
|
||||
```
|
||||
|
||||
[render-info]: https://developers.google.com/blocklyguides/create-custom-blocks/appearance/renderers/concepts/info
|
||||
[dev-tools]: https://www.npmjs.com/package/@blockly/dev-tools
|
||||
|
||||
### Logger
|
||||
|
||||
A lightweight workspace console logger.
|
||||
|
||||
```js
|
||||
import {logger} from '@blockly/dev-tools';
|
||||
|
||||
logger.enableLogger(workspace);
|
||||
logger.disableLogger(workspace);
|
||||
```
|
||||
|
||||
The logger is included by default in the playground.
|
||||
|
||||
## License
|
||||
|
||||
Apache 2.0
|
||||
3
node_modules/@blockly/dev-tools/dist/index.js
generated
vendored
Normal file
3
node_modules/@blockly/dev-tools/dist/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
613
node_modules/@blockly/dev-tools/dist/index.js.LICENSE.txt
generated
vendored
Normal file
613
node_modules/@blockly/dev-tools/dist/index.js.LICENSE.txt
generated
vendored
Normal file
@@ -0,0 +1,613 @@
|
||||
/*!
|
||||
|
||||
diff v4.0.1
|
||||
|
||||
Software License Agreement (BSD License)
|
||||
|
||||
Copyright (c) 2009-2015, Kevin Decker <kpdecker@gmail.com>
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of Kevin Decker nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@license
|
||||
*/
|
||||
|
||||
/*!
|
||||
* ### ._obj
|
||||
*
|
||||
* Quick reference to stored `actual` value for plugin developers.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
/*!
|
||||
* ### .ifError(object)
|
||||
*
|
||||
* Asserts if value is not a false value, and throws if it is a true value.
|
||||
* This is added to allow for chai to be a drop-in replacement for Node's
|
||||
* assert class.
|
||||
*
|
||||
* var err = new Error('I am a custom error');
|
||||
* assert.ifError(err); // Rethrows err!
|
||||
*
|
||||
* @name ifError
|
||||
* @param {Object} object
|
||||
* @namespace Assert
|
||||
* @api public
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Aliases.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Assertion Constructor
|
||||
*
|
||||
* Creates object for chaining.
|
||||
*
|
||||
* `Assertion` objects contain metadata in the form of flags. Three flags can
|
||||
* be assigned during instantiation by passing arguments to this constructor:
|
||||
*
|
||||
* - `object`: This flag contains the target of the assertion. For example, in
|
||||
* the assertion `expect(numKittens).to.equal(7);`, the `object` flag will
|
||||
* contain `numKittens` so that the `equal` assertion can reference it when
|
||||
* needed.
|
||||
*
|
||||
* - `message`: This flag contains an optional custom error message to be
|
||||
* prepended to the error message that's generated by the assertion when it
|
||||
* fails.
|
||||
*
|
||||
* - `ssfi`: This flag stands for "start stack function indicator". It
|
||||
* contains a function reference that serves as the starting point for
|
||||
* removing frames from the stack trace of the error that's created by the
|
||||
* assertion when it fails. The goal is to provide a cleaner stack trace to
|
||||
* end users by removing Chai's internal functions. Note that it only works
|
||||
* in environments that support `Error.captureStackTrace`, and only when
|
||||
* `Chai.config.includeStack` hasn't been set to `false`.
|
||||
*
|
||||
* - `lockSsfi`: This flag controls whether or not the given `ssfi` flag
|
||||
* should retain its current value, even as assertions are chained off of
|
||||
* this object. This is usually set to `true` when creating a new assertion
|
||||
* from within another assertion. It's also temporarily set to `true` before
|
||||
* an overwritten assertion gets called by the overwriting assertion.
|
||||
*
|
||||
* - `eql`: This flag contains the deepEqual function to be used by the assertion.
|
||||
*
|
||||
* @param {Mixed} obj target of the assertion
|
||||
* @param {String} msg (optional) custom error message
|
||||
* @param {Function} ssfi (optional) starting point for removing stack frames
|
||||
* @param {Boolean} lockSsfi (optional) whether or not the ssfi flag is locked
|
||||
* @api private
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Chai dependencies.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Module export.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Add a chainable method
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Assert interface
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Assertion Error
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Chai - addChainingMethod utility
|
||||
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Chai - addLengthGuard utility
|
||||
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Chai - addMethod utility
|
||||
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Chai - addProperty utility
|
||||
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Chai - compareByInspect utility
|
||||
* Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Chai - expectTypes utility
|
||||
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Chai - flag utility
|
||||
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Chai - getActual utility
|
||||
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Chai - getOwnEnumerableProperties utility
|
||||
* Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Chai - getOwnEnumerablePropertySymbols utility
|
||||
* Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Chai - getProperties utility
|
||||
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Chai - isNaN utility
|
||||
* Copyright(c) 2012-2015 Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Chai - isProxyEnabled helper
|
||||
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Chai - message composition utility
|
||||
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Chai - overwriteChainableMethod utility
|
||||
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Chai - overwriteMethod utility
|
||||
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Chai - overwriteProperty utility
|
||||
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Chai - test utility
|
||||
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Chai - transferFlags utility
|
||||
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Chai version
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Check if a property exists
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Check to see if the MemoizeMap has recorded a result of the two operands
|
||||
*
|
||||
* @param {Mixed} leftHandOperand
|
||||
* @param {Mixed} rightHandOperand
|
||||
* @param {MemoizeMap} memoizeMap
|
||||
* @returns {Boolean|null} result
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Checks error against a given set of criteria
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Compare by inspect method
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Compare two Regular Expressions for equality.
|
||||
*
|
||||
* @param {RegExp} leftHandOperand
|
||||
* @param {RegExp} rightHandOperand
|
||||
* @return {Boolean} result
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Compare two Sets/Maps for equality. Faster than other equality functions.
|
||||
*
|
||||
* @param {Set} leftHandOperand
|
||||
* @param {Set} rightHandOperand
|
||||
* @param {Object} [options] (Optional)
|
||||
* @return {Boolean} result
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Configuration
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Core Assertions
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Deep equal utility
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Deep path info
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Dependencies that are used for multiple exports are required here only once
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Determine if the given object has an @@iterator function.
|
||||
*
|
||||
* @param {Object} target
|
||||
* @return {Boolean} `true` if the object has an @@iterator function.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Determines if two objects have matching values, given a set of keys. Defers to deepEqual for the equality check of
|
||||
* each key. If any value of the given key is not equal, the function will return false (early).
|
||||
*
|
||||
* @param {Mixed} leftHandOperand
|
||||
* @param {Mixed} rightHandOperand
|
||||
* @param {Array} keys An array of keys to compare the values of leftHandOperand and rightHandOperand against
|
||||
* @param {Object} [options] (Optional)
|
||||
* @return {Boolean} result
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Ensure correct constructor
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Expect interface
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Flag transferring utility
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Flag utility
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Function name
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Get own enumerable properties method
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Get own enumerable property symbols method
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Gets all entries from a Generator. This will consume the generator - which could have side effects.
|
||||
*
|
||||
* @param {Generator} target
|
||||
* @returns {Array} an array of entries from the Generator.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Gets all iterator entries from the given Object. If the Object has no @@iterator function, returns an empty array.
|
||||
* This will consume the iterator - which could have side effects depending on the @@iterator implementation.
|
||||
*
|
||||
* @param {Object} target
|
||||
* @returns {Array} an array of entries from the @@iterator function
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Gets all own and inherited enumerable keys from a target.
|
||||
*
|
||||
* @param {Object} target
|
||||
* @returns {Array} an array of own and inherited enumerable keys from the target.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Inherit from Error.prototype
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Inspect util
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Module dependencies
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Object Display util
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Overwrite chainable method
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Primary Export
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Primary Exports
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Primary `Assertion` prototype
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Proxify util
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Recursively check the equality of two Objects. Once basic sameness has been established it will defer to `deepEqual`
|
||||
* for each enumerable key in the object.
|
||||
*
|
||||
* @param {Mixed} leftHandOperand
|
||||
* @param {Mixed} rightHandOperand
|
||||
* @param {Object} [options] (Optional)
|
||||
* @return {Boolean} result
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Return a function that will copy properties from
|
||||
* one object to another excluding any originally
|
||||
* listed. Returned function will create a new `{}`.
|
||||
*
|
||||
* @param {String} excluded properties ...
|
||||
* @return {Function}
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Returns true if the argument is a primitive.
|
||||
*
|
||||
* This intentionally returns true for all objects that can be compared by reference,
|
||||
* including functions and symbols.
|
||||
*
|
||||
* @param {Mixed} value
|
||||
* @return {Boolean} result
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Set the result of the equality into the MemoizeMap
|
||||
*
|
||||
* @param {Mixed} leftHandOperand
|
||||
* @param {Mixed} rightHandOperand
|
||||
* @param {MemoizeMap} memoizeMap
|
||||
* @param {Boolean} result
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Should interface
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Simple equality for flat iterable objects such as Arrays, TypedArrays or Node.js buffers.
|
||||
*
|
||||
* @param {Iterable} leftHandOperand
|
||||
* @param {Iterable} rightHandOperand
|
||||
* @param {Object} [options] (Optional)
|
||||
* @return {Boolean} result
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Simple equality for generator objects such as those returned by generator functions.
|
||||
*
|
||||
* @param {Iterable} leftHandOperand
|
||||
* @param {Iterable} rightHandOperand
|
||||
* @param {Object} [options] (Optional)
|
||||
* @return {Boolean} result
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Statically set name
|
||||
*/
|
||||
|
||||
/*!
|
||||
* The main logic of the `deepEqual` function.
|
||||
*
|
||||
* @param {Mixed} leftHandOperand
|
||||
* @param {Mixed} rightHandOperand
|
||||
* @param {Object} [options] (optional) Additional options
|
||||
* @param {Array} [options.comparator] (optional) Override default algorithm, determining custom equality.
|
||||
* @param {Array} [options.memoize] (optional) Provide a custom memoization object which will cache the results of
|
||||
complex objects for a speed boost. By passing `false` you can disable memoization, but this will cause circular
|
||||
references to blow the stack.
|
||||
* @return {Boolean} equal match
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Utility Functions
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Utils for plugins (not exported)
|
||||
*/
|
||||
|
||||
/*!
|
||||
* actual utility
|
||||
*/
|
||||
|
||||
/*!
|
||||
* add Method
|
||||
*/
|
||||
|
||||
/*!
|
||||
* add Property
|
||||
*/
|
||||
|
||||
/*!
|
||||
* addLengthGuard util
|
||||
*/
|
||||
|
||||
/*!
|
||||
* assertion-error
|
||||
* Copyright(c) 2013 Jake Luer <jake@qualiancy.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* chai
|
||||
* Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* chai
|
||||
* Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* chai
|
||||
* http://chaijs.com
|
||||
* Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* deep-eql
|
||||
* Copyright(c) 2013 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* expectTypes utility
|
||||
*/
|
||||
|
||||
/*!
|
||||
* getOperator method
|
||||
*/
|
||||
|
||||
/*!
|
||||
* isNaN method
|
||||
*/
|
||||
|
||||
/*!
|
||||
* isProxyEnabled helper
|
||||
*/
|
||||
|
||||
/*!
|
||||
* message utility
|
||||
*/
|
||||
|
||||
/*!
|
||||
* overwrite Method
|
||||
*/
|
||||
|
||||
/*!
|
||||
* overwrite Property
|
||||
*/
|
||||
|
||||
/*!
|
||||
* test utility
|
||||
*/
|
||||
|
||||
/*!
|
||||
* type utility
|
||||
*/
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2020 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2021 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2022 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2024 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
1
node_modules/@blockly/dev-tools/dist/index.js.map
generated
vendored
Normal file
1
node_modules/@blockly/dev-tools/dist/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
24
node_modules/@blockly/dev-tools/node_modules/assertion-error/History.md
generated
vendored
Normal file
24
node_modules/@blockly/dev-tools/node_modules/assertion-error/History.md
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
1.1.0 / 2018-01-02
|
||||
==================
|
||||
|
||||
* Add type definitions ([#11](https://github.com/chaijs/assertion-error/pull/11))
|
||||
|
||||
1.0.1 / 2015-03-04
|
||||
==================
|
||||
|
||||
* Merge pull request #2 from simonzack/master
|
||||
* fixes `.stack` on firefox
|
||||
|
||||
1.0.0 / 2013-06-08
|
||||
==================
|
||||
|
||||
* readme: change travis and component urls
|
||||
* refactor: [*] prepare for move to chaijs gh org
|
||||
|
||||
0.1.0 / 2013-04-07
|
||||
==================
|
||||
|
||||
* test: use vanilla test runner/assert
|
||||
* pgk: remove unused deps
|
||||
* lib: implement
|
||||
* "Initial commit"
|
||||
41
node_modules/@blockly/dev-tools/node_modules/assertion-error/README.md
generated
vendored
Normal file
41
node_modules/@blockly/dev-tools/node_modules/assertion-error/README.md
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
# AssertionError [](https://travis-ci.org/chaijs/assertion-error)
|
||||
|
||||
> Error constructor for test and validation frameworks that implements standardized AssertionError specification.
|
||||
|
||||
## Installation
|
||||
|
||||
### Node.js
|
||||
|
||||
`assertion-error` is available on [npm](http://npmjs.org).
|
||||
|
||||
$ npm install assertion-error
|
||||
|
||||
### Component
|
||||
|
||||
`assertion-error` is available as a [component](https://github.com/component/component).
|
||||
|
||||
$ component install chaijs/assertion-error
|
||||
|
||||
## License
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2013 Jake Luer <jake@qualiancy.com> (http://qualiancy.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
11
node_modules/@blockly/dev-tools/node_modules/assertion-error/index.d.ts
generated
vendored
Normal file
11
node_modules/@blockly/dev-tools/node_modules/assertion-error/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
type AssertionError<T = {}> = Error & T & {
|
||||
showDiff: boolean;
|
||||
};
|
||||
|
||||
interface AssertionErrorConstructor {
|
||||
new<T = {}>(message: string, props?: T, ssf?: Function): AssertionError<T>;
|
||||
}
|
||||
|
||||
declare const AssertionError: AssertionErrorConstructor;
|
||||
|
||||
export = AssertionError;
|
||||
116
node_modules/@blockly/dev-tools/node_modules/assertion-error/index.js
generated
vendored
Normal file
116
node_modules/@blockly/dev-tools/node_modules/assertion-error/index.js
generated
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
/*!
|
||||
* assertion-error
|
||||
* Copyright(c) 2013 Jake Luer <jake@qualiancy.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Return a function that will copy properties from
|
||||
* one object to another excluding any originally
|
||||
* listed. Returned function will create a new `{}`.
|
||||
*
|
||||
* @param {String} excluded properties ...
|
||||
* @return {Function}
|
||||
*/
|
||||
|
||||
function exclude () {
|
||||
var excludes = [].slice.call(arguments);
|
||||
|
||||
function excludeProps (res, obj) {
|
||||
Object.keys(obj).forEach(function (key) {
|
||||
if (!~excludes.indexOf(key)) res[key] = obj[key];
|
||||
});
|
||||
}
|
||||
|
||||
return function extendExclude () {
|
||||
var args = [].slice.call(arguments)
|
||||
, i = 0
|
||||
, res = {};
|
||||
|
||||
for (; i < args.length; i++) {
|
||||
excludeProps(res, args[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
};
|
||||
|
||||
/*!
|
||||
* Primary Exports
|
||||
*/
|
||||
|
||||
module.exports = AssertionError;
|
||||
|
||||
/**
|
||||
* ### AssertionError
|
||||
*
|
||||
* An extension of the JavaScript `Error` constructor for
|
||||
* assertion and validation scenarios.
|
||||
*
|
||||
* @param {String} message
|
||||
* @param {Object} properties to include (optional)
|
||||
* @param {callee} start stack function (optional)
|
||||
*/
|
||||
|
||||
function AssertionError (message, _props, ssf) {
|
||||
var extend = exclude('name', 'message', 'stack', 'constructor', 'toJSON')
|
||||
, props = extend(_props || {});
|
||||
|
||||
// default values
|
||||
this.message = message || 'Unspecified AssertionError';
|
||||
this.showDiff = false;
|
||||
|
||||
// copy from properties
|
||||
for (var key in props) {
|
||||
this[key] = props[key];
|
||||
}
|
||||
|
||||
// capture stack trace
|
||||
ssf = ssf || AssertionError;
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, ssf);
|
||||
} else {
|
||||
try {
|
||||
throw new Error();
|
||||
} catch(e) {
|
||||
this.stack = e.stack;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* Inherit from Error.prototype
|
||||
*/
|
||||
|
||||
AssertionError.prototype = Object.create(Error.prototype);
|
||||
|
||||
/*!
|
||||
* Statically set name
|
||||
*/
|
||||
|
||||
AssertionError.prototype.name = 'AssertionError';
|
||||
|
||||
/*!
|
||||
* Ensure correct constructor
|
||||
*/
|
||||
|
||||
AssertionError.prototype.constructor = AssertionError;
|
||||
|
||||
/**
|
||||
* Allow errors to be converted to JSON for static transfer.
|
||||
*
|
||||
* @param {Boolean} include stack (default: `true`)
|
||||
* @return {Object} object that can be `JSON.stringify`
|
||||
*/
|
||||
|
||||
AssertionError.prototype.toJSON = function (stack) {
|
||||
var extend = exclude('constructor', 'toJSON', 'stack')
|
||||
, props = extend({ name: this.name }, this);
|
||||
|
||||
// include stack if exists and not turned off
|
||||
if (false !== stack && this.stack) {
|
||||
props.stack = this.stack;
|
||||
}
|
||||
|
||||
return props;
|
||||
};
|
||||
29
node_modules/@blockly/dev-tools/node_modules/assertion-error/package.json
generated
vendored
Normal file
29
node_modules/@blockly/dev-tools/node_modules/assertion-error/package.json
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "assertion-error",
|
||||
"version": "1.1.0",
|
||||
"description": "Error constructor for test and validation frameworks that implements standardized AssertionError specification.",
|
||||
"author": "Jake Luer <jake@qualiancy.com> (http://qualiancy.com)",
|
||||
"license": "MIT",
|
||||
"types": "./index.d.ts",
|
||||
"keywords": [
|
||||
"test",
|
||||
"assertion",
|
||||
"assertion-error"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:chaijs/assertion-error.git"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"main": "./index",
|
||||
"scripts": {
|
||||
"test": "make test"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"component": "*",
|
||||
"typescript": "^2.6.1"
|
||||
}
|
||||
}
|
||||
1
node_modules/@blockly/dev-tools/node_modules/chai/CODEOWNERS
generated
vendored
Normal file
1
node_modules/@blockly/dev-tools/node_modules/chai/CODEOWNERS
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
* @chaijs/chai
|
||||
58
node_modules/@blockly/dev-tools/node_modules/chai/CODE_OF_CONDUCT.md
generated
vendored
Normal file
58
node_modules/@blockly/dev-tools/node_modules/chai/CODE_OF_CONDUCT.md
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
# Contributor Code of Conduct
|
||||
|
||||
> Read in: [Español](http://contributor-covenant.org/version/1/3/0/es/) |
|
||||
[Français](http://contributor-covenant.org/version/1/3/0/fr/) |
|
||||
[Italiano](http://contributor-covenant.org/version/1/3/0/it/) |
|
||||
[Magyar](http://contributor-covenant.org/version/1/3/0/hu/) |
|
||||
[Polskie](http://contributor-covenant.org/version/1/3/0/pl/) |
|
||||
[Português](http://contributor-covenant.org/version/1/3/0/pt/) |
|
||||
[Português do Brasil](http://contributor-covenant.org/version/1/3/0/pt_br/)
|
||||
|
||||
As contributors and maintainers of this project, and in the interest of
|
||||
fostering an open and welcoming community, we pledge to respect all people who
|
||||
contribute through reporting issues, posting feature requests, updating
|
||||
documentation, submitting pull requests or patches, and other activities.
|
||||
|
||||
We are committed to making participation in this project a harassment-free
|
||||
experience for everyone, regardless of level of experience, gender, gender
|
||||
identity and expression, sexual orientation, disability, personal appearance,
|
||||
body size, race, ethnicity, age, religion, or nationality.
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery
|
||||
* Personal attacks
|
||||
* Trolling or insulting/derogatory comments
|
||||
* Public or private harassment
|
||||
* Publishing other's private information, such as physical or electronic
|
||||
addresses, without explicit permission
|
||||
* Other unethical or unprofessional conduct
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
By adopting this Code of Conduct, project maintainers commit themselves to
|
||||
fairly and consistently applying these principles to every aspect of managing
|
||||
this project. Project maintainers who do not follow or enforce the Code of
|
||||
Conduct may be permanently removed from the project team.
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community.
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting a project maintainer at chaijs@keithcirkel.co.uk. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. Maintainers are
|
||||
obligated to maintain confidentiality with regard to the reporter of an
|
||||
incident.
|
||||
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 1.3.0, available at
|
||||
[http://contributor-covenant.org/version/1/3/0/][version]
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/3/0/
|
||||
212
node_modules/@blockly/dev-tools/node_modules/chai/CONTRIBUTING.md
generated
vendored
Normal file
212
node_modules/@blockly/dev-tools/node_modules/chai/CONTRIBUTING.md
generated
vendored
Normal file
@@ -0,0 +1,212 @@
|
||||
# Chai Contribution Guidelines
|
||||
|
||||
We like to encourage you to contribute to the Chai.js repository. This should be as easy as possible for you but there are a few things to consider when contributing. The following guidelines for contribution should be followed if you want to submit a pull request or open an issue.
|
||||
|
||||
Following these guidelines helps to communicate that you respect the time of the developers managing and developing this open source project. In return, they should reciprocate that respect in addressing your issue or assessing patches and features.
|
||||
|
||||
#### Table of Contents
|
||||
|
||||
- [TLDR;](#tldr)
|
||||
- [Contributing](#contributing)
|
||||
- [Bug Reports](#bugs)
|
||||
- [Feature Requests](#features)
|
||||
- [Pull Requests](#pull-requests)
|
||||
- [Releasing](#releasing)
|
||||
- [Support](#support)
|
||||
- [Resources](#resources)
|
||||
- [Core Contributors](#contributors)
|
||||
|
||||
<a name="tldr"></a>
|
||||
## TLDR;
|
||||
|
||||
- Creating an Issue or Pull Request requires a [GitHub](http://github.com) account.
|
||||
- Issue reports should be **clear**, **concise** and **reproducible**. Check to see if your issue has already been resolved in the [master]() branch or already reported in Chai's [GitHub Issue Tracker](https://github.com/chaijs/chai/issues).
|
||||
- In general, avoid submitting PRs for new Assertions without asking core contributors first. More than likely it would be better implemented as a plugin.
|
||||
- Additional support is available via the [Google Group](http://groups.google.com/group/chaijs) or on irc.freenode.net#chaijs.
|
||||
- **IMPORTANT**: By submitting a patch, you agree to allow the project owner to license your work under the same license as that used by the project.
|
||||
|
||||
|
||||
|
||||
<a name="contributing"></a>
|
||||
## Contributing
|
||||
|
||||
The issue tracker is the preferred channel for [bug reports](#bugs),
|
||||
[feature requests](#features) and [submitting pull
|
||||
requests](#pull-requests), but please respect the following restrictions:
|
||||
|
||||
* Please **do not** use the issue tracker for personal support requests (use
|
||||
[Google Group](https://groups.google.com/forum/#!forum/chaijs) or IRC).
|
||||
* Please **do not** derail or troll issues. Keep the discussion on topic and
|
||||
respect the opinions of others
|
||||
|
||||
<a name="bugs"></a>
|
||||
### Bug Reports
|
||||
|
||||
A bug is a **demonstrable problem** that is caused by the code in the repository.
|
||||
|
||||
Guidelines for bug reports:
|
||||
|
||||
1. **Use the GitHub issue search** — check if the issue has already been reported.
|
||||
2. **Check if the issue has been fixed** — try to reproduce it using the latest `master` or development branch in the repository.
|
||||
3. **Isolate the problem** — create a test case to demonstrate your issue. Provide either a repo, gist, or code sample to demonstrate you problem.
|
||||
|
||||
A good bug report shouldn't leave others needing to chase you up for more information. Please try to be as detailed as possible in your report. What is your environment? What steps will reproduce the issue? What browser(s) and/or Node.js versions experience the problem? What would you expect to be the outcome? All these details will help people to fix any potential bugs.
|
||||
|
||||
Example:
|
||||
|
||||
> Short and descriptive example bug report title
|
||||
>
|
||||
> A summary of the issue and the browser/OS environment in which it occurs. If suitable, include the steps required to reproduce the bug.
|
||||
>
|
||||
> 1. This is the first step
|
||||
> 2. This is the second step
|
||||
> 3. Further steps, etc.
|
||||
>
|
||||
> `<url>` - a link to the reduced test case OR
|
||||
> ```js
|
||||
> expect(a).to.equal('a');
|
||||
> // code sample
|
||||
> ```
|
||||
>
|
||||
> Any other information you want to share that is relevant to the issue being reported. This might include the lines of code that you have identified as causing the bug, and potential solutions (and your opinions on their merits).
|
||||
|
||||
<a name="features"></a>
|
||||
### Feature Requests
|
||||
|
||||
Feature requests are welcome. But take a moment to find out whether your idea fits with the scope and aims of the project. It's up to *you* to make a strong case to convince the project's developers of the merits of this feature. Please provide as much detail and context as possible.
|
||||
|
||||
Furthermore, since Chai.js has a [robust plugin API](http://chaijs.com/guide/plugins/), we encourage you to publish **new Assertions** as plugins. If your feature is an enhancement to an **existing Assertion**, please propose your changes as an issue prior to opening a pull request. If the core Chai.js contributors feel your plugin would be better suited as a core assertion, they will invite you to open a PR in [chaijs/chai](https://github.com/chaijs/chai).
|
||||
|
||||
<a name="pull-requests"></a>
|
||||
### Pull Requests
|
||||
|
||||
- PRs for new core-assertions are advised against.
|
||||
- PRs for core-assertion bug fixes are always welcome.
|
||||
- PRs for enhancing the interfaces are always welcome.
|
||||
- PRs that increase test coverage are always welcome.
|
||||
- PRs are scrutinized for coding-style.
|
||||
|
||||
Good pull requests - patches, improvements, new features - are a fantastic help. They should remain focused in scope and avoid containing unrelated commits.
|
||||
|
||||
**Please ask first** before embarking on any significant pull request (e.g. implementing features, refactoring code), otherwise you risk spending a lot of time working on something that the project's developers might not want to merge into the project.
|
||||
|
||||
Please adhere to the coding conventions used throughout a project (indentation, accurate comments, etc.) and any other requirements (such as test coverage).
|
||||
|
||||
Follow this process if you'd like your work considered for inclusion in the project:
|
||||
|
||||
1. [Fork](http://help.github.com/fork-a-repo/) the project, clone your fork, and configure the remotes:
|
||||
|
||||
```bash
|
||||
# Clone your fork of the repo into the current directory
|
||||
git clone https://github.com/<your-username>/<repo-name>
|
||||
# Navigate to the newly cloned directory
|
||||
cd <repo-name>
|
||||
# Assign the original repo to a remote called "upstream"
|
||||
git remote add upstream https://github.com/<upstream-owner>/<repo-name>
|
||||
```
|
||||
|
||||
2. If you cloned a while ago, get the latest changes from upstream:
|
||||
|
||||
```bash
|
||||
git checkout <dev-branch>
|
||||
git pull upstream <dev-branch>
|
||||
```
|
||||
|
||||
3. Create a new topic branch (off the main project development branch) to contain your feature, change, or fix:
|
||||
|
||||
```bash
|
||||
git checkout -b <topic-branch-name>
|
||||
```
|
||||
|
||||
4. Commit your changes in logical chunks. Use Git's [interactive rebase](https://help.github.com/articles/interactive-rebase) feature to tidy up your commits before making them public.
|
||||
|
||||
5. Run you code to make sure it works. If you're still having problems please try to run `make clean` and then test your code again.
|
||||
|
||||
```bash
|
||||
npm test
|
||||
# when finished running tests...
|
||||
git checkout chai.js
|
||||
```
|
||||
|
||||
6. Locally merge (or rebase) the upstream development branch into your topic branch:
|
||||
|
||||
```bash
|
||||
git pull [--rebase] upstream <dev-branch>
|
||||
```
|
||||
|
||||
7. Push your topic branch up to your fork:
|
||||
|
||||
```bash
|
||||
git push origin <topic-branch-name>
|
||||
```
|
||||
|
||||
8. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/) with a clear title and description.
|
||||
|
||||
**IMPORTANT**: By submitting a patch, you agree to allow the project owner to license your work under the same license as that used by the project.
|
||||
|
||||
<a name="releasing"></a>
|
||||
## Releasing
|
||||
|
||||
Releases can be **prepared** by anyone with access to the code.
|
||||
|
||||
Simply run `make release-major`, `make release-minor`, or `make-release-patch`
|
||||
and it will automatically do the following:
|
||||
|
||||
- Build chai.js
|
||||
- Bump the version numbers across the project
|
||||
- Make a commit within git
|
||||
|
||||
All you need to do is push the commit up and make a pull request, one of the core contributors will merge it and publish a release.
|
||||
|
||||
### Publishing a Release
|
||||
|
||||
Anyone who is a core contributor (see the [Core Contributors Heading in the Readme](https://github.com/chaijs/chai#core-contributors)) can publish a release:
|
||||
|
||||
1. Go to the [Releases page on Github](https://github.com/chaijs/chai/releases)
|
||||
2. Hit "Draft a new release" (if you can't see this, you're not a core contributor!)
|
||||
3. Write human-friendly Release Notes based on changelog.
|
||||
- The release title is "x.x.x / YYYY-MM-DD" (where x.x.x is the version number)
|
||||
- If breaking changes, write migration tutorial(s) and reasoning.
|
||||
- Callouts for community contributions (PRs) with links to PR and contributing user.
|
||||
- Callouts for other fixes made by core contributors with links to issue.
|
||||
4. Hit "Save Draft" and get other core contributors to check your work, or alternatively hit "Publish release"
|
||||
5. That's it!
|
||||
|
||||
<a name="support"></a>
|
||||
## Support
|
||||
|
||||
<a name="resources"></a>
|
||||
### Resources
|
||||
|
||||
For most of the documentation you are going to want to visit [ChaiJS.com](http://chaijs.com).
|
||||
|
||||
- [Getting Started Guide](http://chaijs.com/guide/)
|
||||
- [API Reference](http://chaijs.com/api/)
|
||||
- [Plugins](http://chaijs.com/plugins/)
|
||||
|
||||
Or finally, you may find a core-contributor or like-minded developer in any of our support channels.
|
||||
|
||||
- IRC: irc.freenode.org #chaijs
|
||||
- [Mailing List / Google Group](https://groups.google.com/forum/#!forum/chaijs)
|
||||
|
||||
<a name="contributors"></a>
|
||||
### Core Contributors
|
||||
|
||||
Feel free to reach out to any of the core-contributors with you questions or concerns. We will do our best to respond in a timely manner.
|
||||
|
||||
- Jake Luer
|
||||
- GH: [@logicalparadox](https://github.com/logicalparadox)
|
||||
- TW: [@jakeluer](http://twitter.com/jakeluer)
|
||||
- IRC: logicalparadox
|
||||
- Veselin Todorov
|
||||
- GH: [@vesln](https://github.com/vesln/)
|
||||
- TW: [@vesln](http://twitter.com/vesln)
|
||||
- IRC: vesln
|
||||
- Keith Cirkel
|
||||
- GH: [@keithamus](https://github.com/keithamus)
|
||||
- TW: [@keithamus](http://twitter.com/keithamus)
|
||||
- IRC: keithamus
|
||||
- Lucas Fernandes da Costa
|
||||
- GH: [@lucasfcosta](https://github.com/lucasfcosta)
|
||||
- TW: [@lfernandescosta](https://twitter.com/lfernandescosta)
|
||||
- IRC: lucasfcosta
|
||||
1059
node_modules/@blockly/dev-tools/node_modules/chai/History.md
generated
vendored
Normal file
1059
node_modules/@blockly/dev-tools/node_modules/chai/History.md
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
21
node_modules/@blockly/dev-tools/node_modules/chai/LICENSE
generated
vendored
Normal file
21
node_modules/@blockly/dev-tools/node_modules/chai/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Chai.js Assertion Library
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
212
node_modules/@blockly/dev-tools/node_modules/chai/README.md
generated
vendored
Normal file
212
node_modules/@blockly/dev-tools/node_modules/chai/README.md
generated
vendored
Normal file
@@ -0,0 +1,212 @@
|
||||
<h1 align=center>
|
||||
<a href="http://chaijs.com" title="Chai Documentation">
|
||||
<img alt="ChaiJS" src="http://chaijs.com/img/chai-logo.png">
|
||||
</a>
|
||||
<br>
|
||||
chai
|
||||
</h1>
|
||||
|
||||
<p align=center>
|
||||
Chai is a BDD / TDD assertion library for <a href="http://nodejs.org">node</a> and the browser that can be delightfully paired with any javascript testing framework.
|
||||
</p>
|
||||
|
||||
<p align=center>
|
||||
<a href="./LICENSE">
|
||||
<img
|
||||
alt="license:mit"
|
||||
src="https://img.shields.io/badge/license-mit-green.svg?style=flat-square"
|
||||
/>
|
||||
</a>
|
||||
<a href="https://github.com/chaijs/chai/releases">
|
||||
<img
|
||||
alt="tag:?"
|
||||
src="https://img.shields.io/github/tag/chaijs/chai.svg?style=flat-square"
|
||||
/>
|
||||
</a>
|
||||
<a href="https://www.npmjs.com/package/chai">
|
||||
<img
|
||||
alt="node:?"
|
||||
src="https://img.shields.io/badge/node-%3E=4.0-blue.svg?style=flat-square"
|
||||
/>
|
||||
</a>
|
||||
<br/>
|
||||
<a href="https://saucelabs.com/u/chaijs">
|
||||
<img
|
||||
alt="Selenium Test Status"
|
||||
src="https://saucelabs.com/browser-matrix/chaijs.svg"
|
||||
/>
|
||||
</a>
|
||||
<br/>
|
||||
<a href="https://www.npmjs.com/packages/chai">
|
||||
<img
|
||||
alt="downloads:?"
|
||||
src="https://img.shields.io/npm/dm/chai.svg?style=flat-square"
|
||||
/>
|
||||
</a>
|
||||
<a href="https://travis-ci.org/chaijs/chai">
|
||||
<img
|
||||
alt="build:?"
|
||||
src="https://img.shields.io/travis/chaijs/chai/master.svg?style=flat-square"
|
||||
/>
|
||||
</a>
|
||||
<a href="https://codecov.io/gh/chaijs/chai">
|
||||
<img
|
||||
alt="coverage:?"
|
||||
src="https://img.shields.io/codecov/c/github/chaijs/chai.svg?style=flat-square"
|
||||
/>
|
||||
</a>
|
||||
<a href="">
|
||||
<img
|
||||
alt="devDependencies:?"
|
||||
src="https://img.shields.io/david/chaijs/chai.svg?style=flat-square"
|
||||
/>
|
||||
</a>
|
||||
<br/>
|
||||
<a href="https://chai-slack.herokuapp.com/">
|
||||
<img
|
||||
alt="Join the Slack chat"
|
||||
src="https://img.shields.io/badge/slack-join%20chat-E2206F.svg?style=flat-square"
|
||||
/>
|
||||
</a>
|
||||
<a href="https://gitter.im/chaijs/chai">
|
||||
<img
|
||||
alt="Join the Gitter chat"
|
||||
src="https://img.shields.io/badge/gitter-join%20chat-D0104D.svg?style=flat-square"
|
||||
/>
|
||||
</a>
|
||||
<a href="https://opencollective.com/chaijs">
|
||||
<img
|
||||
alt="OpenCollective Backers"
|
||||
src="https://opencollective.com/chaijs/backers/badge.svg?style=flat-square"
|
||||
/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
For more information or to download plugins, view the [documentation](http://chaijs.com).
|
||||
|
||||
## What is Chai?
|
||||
|
||||
Chai is an _assertion library_, similar to Node's built-in `assert`. It makes testing much easier by giving you lots of assertions you can run against your code.
|
||||
|
||||
## Installation
|
||||
|
||||
### Node.js
|
||||
|
||||
`chai` is available on [npm](http://npmjs.org). To install it, type:
|
||||
|
||||
$ npm install --save-dev chai
|
||||
|
||||
### Browsers
|
||||
|
||||
You can also use it within the browser; install via npm and use the `chai.js` file found within the download. For example:
|
||||
|
||||
```html
|
||||
<script src="./node_modules/chai/chai.js"></script>
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Import the library in your code, and then pick one of the styles you'd like to use - either `assert`, `expect` or `should`:
|
||||
|
||||
```js
|
||||
var chai = require('chai');
|
||||
var assert = chai.assert; // Using Assert style
|
||||
var expect = chai.expect; // Using Expect style
|
||||
var should = chai.should(); // Using Should style
|
||||
```
|
||||
|
||||
### Pre-Native Modules Usage (_registers the chai testing style globally_)
|
||||
|
||||
```js
|
||||
require('chai/register-assert'); // Using Assert style
|
||||
require('chai/register-expect'); // Using Expect style
|
||||
require('chai/register-should'); // Using Should style
|
||||
```
|
||||
|
||||
### Pre-Native Modules Usage (_as local variables_)
|
||||
|
||||
```js
|
||||
const { assert } = require('chai'); // Using Assert style
|
||||
const { expect } = require('chai'); // Using Expect style
|
||||
const { should } = require('chai'); // Using Should style
|
||||
should(); // Modifies `Object.prototype`
|
||||
|
||||
const { expect, use } = require('chai'); // Creates local variables `expect` and `use`; useful for plugin use
|
||||
```
|
||||
|
||||
### Native Modules Usage (_registers the chai testing style globally_)
|
||||
|
||||
```js
|
||||
import 'chai/register-assert'; // Using Assert style
|
||||
import 'chai/register-expect'; // Using Expect style
|
||||
import 'chai/register-should'; // Using Should style
|
||||
```
|
||||
|
||||
### Native Modules Usage (_local import only_)
|
||||
|
||||
```js
|
||||
import { assert } from 'chai'; // Using Assert style
|
||||
import { expect } from 'chai'; // Using Expect style
|
||||
import { should } from 'chai'; // Using Should style
|
||||
should(); // Modifies `Object.prototype`
|
||||
```
|
||||
|
||||
### Usage with Mocha
|
||||
|
||||
```bash
|
||||
mocha spec.js -r chai/register-assert # Using Assert style
|
||||
mocha spec.js -r chai/register-expect # Using Expect style
|
||||
mocha spec.js -r chai/register-should # Using Should style
|
||||
```
|
||||
|
||||
[Read more about these styles in our docs](http://chaijs.com/guide/styles/).
|
||||
|
||||
## Plugins
|
||||
|
||||
Chai offers a robust Plugin architecture for extending Chai's assertions and interfaces.
|
||||
|
||||
- Need a plugin? View the [official plugin list](http://chaijs.com/plugins).
|
||||
- Want to build a plugin? Read the [plugin api documentation](http://chaijs.com/guide/plugins/).
|
||||
- Have a plugin and want it listed? Simply add the following keywords to your package.json:
|
||||
- `chai-plugin`
|
||||
- `browser` if your plugin works in the browser as well as Node.js
|
||||
- `browser-only` if your plugin does not work with Node.js
|
||||
|
||||
### Related Projects
|
||||
|
||||
- [chaijs / chai-docs](https://github.com/chaijs/chai-docs): The chaijs.com website source code.
|
||||
- [chaijs / assertion-error](https://github.com/chaijs/assertion-error): Custom `Error` constructor thrown upon an assertion failing.
|
||||
- [chaijs / deep-eql](https://github.com/chaijs/deep-eql): Improved deep equality testing for Node.js and the browser.
|
||||
- [chaijs / type-detect](https://github.com/chaijs/type-detect): Improved typeof detection for Node.js and the browser.
|
||||
- [chaijs / check-error](https://github.com/chaijs/check-error): Error comparison and information related utility for Node.js and the browser.
|
||||
- [chaijs / loupe](https://github.com/chaijs/loupe): Inspect utility for Node.js and browsers.
|
||||
- [chaijs / pathval](https://github.com/chaijs/pathval): Object value retrieval given a string path.
|
||||
- [chaijs / get-func-name](https://github.com/chaijs/get-func-name): Utility for getting a function's name for node and the browser.
|
||||
|
||||
### Contributing
|
||||
|
||||
Thank you very much for considering to contribute!
|
||||
|
||||
Please make sure you follow our [Code Of Conduct](https://github.com/chaijs/chai/blob/master/CODE_OF_CONDUCT.md) and we also strongly recommend reading our [Contributing Guide](https://github.com/chaijs/chai/blob/master/CONTRIBUTING.md).
|
||||
|
||||
Here are a few issues other contributors frequently ran into when opening pull requests:
|
||||
|
||||
- Please do not commit changes to the `chai.js` build. We do it once per release.
|
||||
- Before pushing your commits, please make sure you [rebase](https://github.com/chaijs/chai/blob/master/CONTRIBUTING.md#pull-requests) them.
|
||||
|
||||
### Contributors
|
||||
|
||||
Please see the full
|
||||
[Contributors Graph](https://github.com/chaijs/chai/graphs/contributors) for our
|
||||
list of contributors.
|
||||
|
||||
### Core Contributors
|
||||
|
||||
Feel free to reach out to any of the core contributors with your questions or
|
||||
concerns. We will do our best to respond in a timely manner.
|
||||
|
||||
[](https://github.com/logicalparadox)
|
||||
[](https://github.com/vesln)
|
||||
[](https://github.com/keithamus)
|
||||
[](https://github.com/lucasfcosta)
|
||||
[](https://github.com/meeber)
|
||||
737
node_modules/@blockly/dev-tools/node_modules/chai/ReleaseNotes.md
generated
vendored
Normal file
737
node_modules/@blockly/dev-tools/node_modules/chai/ReleaseNotes.md
generated
vendored
Normal file
@@ -0,0 +1,737 @@
|
||||
# Release Notes
|
||||
|
||||
## Note
|
||||
|
||||
As of 3.0.0, the ReleaseNotes.md file has been deprecated. [Please refer to the release notes available on Github](https://github.com/chaijs/chai/releases). Or
|
||||
[the release notes on the chaijs.com website](https://chaijs.com/releases).
|
||||
|
||||
---
|
||||
|
||||
## 2.3.0 / 2015-04-26
|
||||
|
||||
Added `ownPropertyDescriptor` assertion:
|
||||
|
||||
```js
|
||||
expect('test').to.have.ownPropertyDescriptor('length');
|
||||
expect('test').to.have.ownPropertyDescriptor('length', { enumerable: false, configurable: false, writable: false, value: 4 });
|
||||
expect('test').not.to.have.ownPropertyDescriptor('length', { enumerable: false, configurable: false, writable: false, value: 3 });
|
||||
expect('test').ownPropertyDescriptor('length').to.have.property('enumerable', false);
|
||||
expect('test').ownPropertyDescriptor('length').to.have.keys('value');
|
||||
```
|
||||
|
||||
### Community Contributions
|
||||
|
||||
#### Code Features & Fixes
|
||||
|
||||
* [#408](https://github.com/chaijs/chai/pull/408) Add `ownPropertyDescriptor`
|
||||
assertion.
|
||||
By [@ljharb](https://github.com/ljharb)
|
||||
* [#422](https://github.com/chaijs/chai/pull/422) Improve ownPropertyDescriptor
|
||||
tests.
|
||||
By [@ljharb](https://github.com/ljharb)
|
||||
|
||||
#### Documentation fixes
|
||||
|
||||
* [#417](https://github.com/chaijs/chai/pull/417) Fix documentation typo
|
||||
By [@astorije](https://github.com/astorije)
|
||||
* [#423](https://github.com/chaijs/chai/pull/423) Fix inconsistency in docs.
|
||||
By [@ehntoo](https://github.com/ehntoo)
|
||||
|
||||
|
||||
## 2.2.0 / 2015-03-26
|
||||
|
||||
Deep property strings can now be escaped using `\\` - for example:
|
||||
|
||||
```js
|
||||
var deepCss = { '.link': { '[target]': 42 }};
|
||||
expect(deepCss).to.have.deep.property('\\.link.\\[target\\]', 42)
|
||||
```
|
||||
|
||||
### Community Contributions
|
||||
|
||||
#### Code Features & Fixes
|
||||
|
||||
* [#402](https://github.com/chaijs/chai/pull/402) Allow escaping of deep
|
||||
property keys.
|
||||
By [@umireon](https://github.com/umireon)
|
||||
|
||||
#### Documentation fixes
|
||||
|
||||
* [#405](https://github.com/chaijs/chai/pull/405) Tweak documentation around
|
||||
deep property escaping.
|
||||
By [@keithamus](https://github.com/keithamus)
|
||||
|
||||
|
||||
## 2.1.2 / 2015-03-15
|
||||
|
||||
A minor bug fix. No new features.
|
||||
|
||||
### Community Contributions
|
||||
|
||||
#### Code Features & Fixes
|
||||
|
||||
* [#395](https://github.com/chaijs/chai/pull/395) Fix eval-related bugs with
|
||||
assert.operator ([#386](https://github.com/chaijs/chai/pull/386)).
|
||||
By [@cjqed](https://github.com/cjqed)
|
||||
|
||||
## 2.1.1 / 2015-03-04
|
||||
|
||||
Two minor bugfixes. No new features.
|
||||
|
||||
### Community Contributions
|
||||
|
||||
#### Code Features & Fixes
|
||||
|
||||
* [#385](https://github.com/chaijs/chai/pull/385) Fix a bug (also described in
|
||||
[#387](https://github.com/chaijs/chai/pull/385)) where `deep.property` would not work with single
|
||||
key names. By [@eldritch-fossicker](https://github.com/eldritch-fossicker)
|
||||
* [#379](https://github.com/chaijs/chai/pull/379) Fix bug where tools which overwrite
|
||||
primitive prototypes, such as Babel or core-js would fail.
|
||||
By [@dcneiner](https://github.com/dcneiner)
|
||||
|
||||
#### Documentation fixes
|
||||
|
||||
* [#382](https://github.com/chaijs/chai/pull/382) Add doc for showDiff argument in assert.
|
||||
By [@astorije](https://github.com/astorije)
|
||||
* [#383](https://github.com/chaijs/chai/pull/383) Improve wording for truncateTreshold docs
|
||||
By [@gurdiga](https://github.com/gurdiga)
|
||||
* [#381](https://github.com/chaijs/chai/pull/381) Improve wording for assert.empty docs
|
||||
By [@astorije](https://github.com/astorije)
|
||||
|
||||
## 2.1.0 / 2015-02-23
|
||||
|
||||
Small release; fixes an issue where the Chai lib was incorrectly reporting the
|
||||
version number.
|
||||
|
||||
Adds new `should.fail()` and `expect.fail()` methods, which are convinience
|
||||
methods to throw Assertion Errors.
|
||||
|
||||
### Community Contributions
|
||||
|
||||
#### Code Features & Fixes
|
||||
|
||||
* [#356](https://github.com/chaijs/chai/pull/356) Add should.fail(), expect.fail(). By [@Soviut](https://github.com/Soviut)
|
||||
* [#374](https://github.com/chaijs/chai/pull/374) Increment version. By [@jmm](https://github.com/jmm)
|
||||
|
||||
## 2.0.0 / 2015-02-09
|
||||
|
||||
Unfortunately with 1.10.0 - compatibility broke with older versions because of
|
||||
the `addChainableNoop`. This change has been reverted.
|
||||
|
||||
Any plugins using `addChainableNoop` should cease to do so.
|
||||
|
||||
Any developers wishing for this behaviour can use [dirty-chai](https://www.npmjs.com/package/dirty-chai)
|
||||
by [@joshperry](https://github.com/joshperry)
|
||||
|
||||
### Community Contributions
|
||||
|
||||
#### Code Features & Fixes
|
||||
|
||||
* [#361](https://github.com/chaijs/chai/pull/361) `.keys()` now accepts Objects, extracting keys from them. By [@gregglind](https://github.com/gregglind)
|
||||
* [#359](https://github.com/chaijs/chai/pull/359) `.keys()` no longer mutates passed arrays. By [@gregglind](https://github.com/gregglind)
|
||||
* [#349](https://github.com/chaijs/chai/pull/349) Add a new chainable keyword - `.which`. By [@toastynerd](https://github.com/toastynerd)
|
||||
* [#333](https://github.com/chaijs/chai/pull/333) Add `.change`, `.increase` and `.decrease` assertions. By [@cmpolis](https://github.com/cmpolis)
|
||||
* [#335](https://github.com/chaijs/chai/pull/335) `chai.util` is now exposed [@DingoEatingFuzz](https://github.com/DingoEatingFuzz)
|
||||
* [#328](https://github.com/chaijs/chai/pull/328) Add `.includes` and `.contains` aliases (for `.include` and `.contain`). By [@lo1tuma](https://github.com/lo1tuma)
|
||||
* [#313](https://github.com/chaijs/chai/pull/313) Add `.any.keys()` and `.all.keys()` qualifiers. By [@cjqed](https://github.com/cjqed)
|
||||
* [#312](https://github.com/chaijs/chai/pull/312) Add `assert.sameDeepMembers()`. By [@cjqed](https://github.com/cjqed)
|
||||
* [#311](https://github.com/chaijs/chai/pull/311) Add `assert.isAbove()` and `assert.isBelow()`. By [@cjqed](https://github.com/cjqed)
|
||||
* [#308](https://github.com/chaijs/chai/pull/308) `property` and `deep.property` now pass if a value is set to `undefined`. By [@prodatakey](https://github.com/prodatakey)
|
||||
* [#309](https://github.com/chaijs/chai/pull/309) optimize deep equal in Arrays. By [@ericdouglas](https://github.com/ericdouglas)
|
||||
* [#306](https://github.com/chaijs/chai/pull/306) revert #297 - allowing lint-friendly tests. By [@keithamus](https://github.com/keithamus)
|
||||
|
||||
#### Documentation fixes
|
||||
|
||||
* [#357](https://github.com/chaijs/chai/pull/357) Copyright year updated in docs. By [@danilovaz](https://github.com/danilovaz)
|
||||
* [#325](https://github.com/chaijs/chai/pull/325) Fix documentation for overwriteChainableMethod. By [@chasenlehara](https://github.com/chasenlehara)
|
||||
* [#334](https://github.com/chaijs/chai/pull/334) Typo fix. By [@hurrymaplelad](https://github.com/hurrymaplelad)
|
||||
* [#317](https://github.com/chaijs/chai/pull/317) Typo fix. By [@jasonkarns](https://github.com/jasonkarns)
|
||||
* [#318](https://github.com/chaijs/chai/pull/318) Typo fix. By [@jasonkarns](https://github.com/jasonkarns)
|
||||
* [#316](https://github.com/chaijs/chai/pull/316) Typo fix. By [@jasonkarns](https://github.com/jasonkarns)
|
||||
|
||||
|
||||
## 1.10.0 / 2014-11-10
|
||||
|
||||
The following changes are required if you are upgrading from the previous version:
|
||||
|
||||
- **Users:**
|
||||
- No changes required
|
||||
- **Plugin Developers:**
|
||||
- Review `addChainableNoop` notes below.
|
||||
- **Core Contributors:**
|
||||
- Refresh `node_modules` folder for updated dependencies.
|
||||
|
||||
### Noop Function for Terminating Assertion Properties
|
||||
|
||||
The following assertions can now also be used in the function-call form:
|
||||
|
||||
* ok
|
||||
* true
|
||||
* false
|
||||
* null
|
||||
* undefined
|
||||
* exist
|
||||
* empty
|
||||
* arguments
|
||||
* Arguments
|
||||
|
||||
The above list of assertions are property getters that assert immediately on
|
||||
access. Because of that, they were written to be used by terminating the assertion
|
||||
chain with a property access.
|
||||
|
||||
```js
|
||||
expect(true).to.be.true;
|
||||
foo.should.be.ok;
|
||||
```
|
||||
|
||||
This syntax is definitely aesthetically pleasing but, if you are linting your
|
||||
test code, your linter will complain with an error something like "Expected an
|
||||
assignment or function call and instead saw an expression." Since the linter
|
||||
doesn't know about the property getter it assumes this line has no side-effects,
|
||||
and throws a warning in case you made a mistake.
|
||||
|
||||
Squelching these errors is not a good solution as test code is getting to be
|
||||
just as important as, if not more than, production code. Catching syntactical
|
||||
errors in tests using static analysis is a great tool to help make sure that your
|
||||
tests are well-defined and free of typos.
|
||||
|
||||
A better option was to provide a function-call form for these assertions so that
|
||||
the code's intent is more clear and the linters stop complaining about something
|
||||
looking off. This form is added in addition to the existing property access form
|
||||
and does not impact existing test code.
|
||||
|
||||
```js
|
||||
expect(true).to.be.true();
|
||||
foo.should.be.ok();
|
||||
```
|
||||
|
||||
These forms can also be mixed in any way, these are all functionally identical:
|
||||
|
||||
```js
|
||||
expect(true).to.be.true.and.not.false();
|
||||
expect(true).to.be.true().and.not.false;
|
||||
expect(true).to.be.true.and.not.false;
|
||||
```
|
||||
|
||||
#### Plugin Authors
|
||||
|
||||
If you would like to provide this function-call form for your terminating assertion
|
||||
properties, there is a new function to register these types of asserts. Instead
|
||||
of using `addProperty` to register terminating assertions, simply use `addChainableNoop`
|
||||
instead; the arguments to both are identical. The latter will make the assertion
|
||||
available in both the attribute and function-call forms and should have no impact
|
||||
on existing users of your plugin.
|
||||
|
||||
### Community Contributions
|
||||
|
||||
- [#297](https://github.com/chaijs/chai/pull/297) Allow writing lint-friendly tests. [@joshperry](https://github.com/joshperry)
|
||||
- [#298](https://github.com/chaijs/chai/pull/298) Add check for logging `-0`. [@dasilvacontin](https://github.com/dasilvacontin)
|
||||
- [#300](https://github.com/chaijs/chai/pull/300) Fix #299: the test is defining global variables [@julienw](https://github.com/julienw)
|
||||
|
||||
Thank you to all who took time to contribute!
|
||||
|
||||
## 1.9.2 / 2014-09-29
|
||||
|
||||
The following changes are required if you are upgrading from the previous version:
|
||||
|
||||
- **Users:**
|
||||
- No changes required
|
||||
- **Plugin Developers:**
|
||||
- No changes required
|
||||
- **Core Contributors:**
|
||||
- Refresh `node_modules` folder for updated dependencies.
|
||||
|
||||
### Community Contributions
|
||||
|
||||
- [#264](https://github.com/chaijs/chai/pull/264) Show diff for keys assertions [@cjthompson](https://github.com/cjthompson)
|
||||
- [#267](https://github.com/chaijs/chai/pull/267) Use SVG badges [@shinnn](https://github.com/shinnn)
|
||||
- [#268](https://github.com/chaijs/chai/pull/268) Allow messages to be functions (sinon-compat) [@charlierudolph](https://github.com/charlierudolph)
|
||||
- [#269](https://github.com/chaijs/chai/pull/269) Remove unused argument for #lengthOf [@charlierudolph](https://github.com/charlierudolph)
|
||||
- [#275](https://github.com/chaijs/chai/pull/275) Rewrite pretty-printing HTML elements to prevent throwing internal errors [@DrRataplan](https://github.com/DrRataplan)
|
||||
- [#277](https://github.com/chaijs/chai/pull/277) Fix assert documentation for #sameMembers [@charlierudolph](https://github.com/charlierudolph)
|
||||
- [#279](https://github.com/chaijs/chai/pull/279) closeTo should check value's type before assertion [@mohayonao](https://github.com/mohayonao)
|
||||
- [#289](https://github.com/chaijs/chai/pull/289) satisfy is called twice [@charlierudolph](https://github.com/charlierudolph)
|
||||
- [#292](https://github.com/chaijs/chai/pull/292) resolve conflicts with node-webkit and global usage [@boneskull](https://github.com/boneskull)
|
||||
|
||||
Thank you to all who took time to contribute!
|
||||
|
||||
## 1.9.1 / 2014-03-19
|
||||
|
||||
The following changes are required if you are upgrading from the previous version:
|
||||
|
||||
- **Users:**
|
||||
- Migrate configuration options to new interface. (see notes)
|
||||
- **Plugin Developers:**
|
||||
- No changes required
|
||||
- **Core Contributors:**
|
||||
- Refresh `node_modules` folder for updated dependencies.
|
||||
|
||||
### Configuration
|
||||
|
||||
There have been requests for changes and additions to the configuration mechanisms
|
||||
and their impact in the Chai architecture. As such, we have decoupled the
|
||||
configuration from the `Assertion` constructor. This not only allows for centralized
|
||||
configuration, but will allow us to shift the responsibility from the `Assertion`
|
||||
constructor to the `assert` interface in future releases.
|
||||
|
||||
These changes have been implemented in a non-breaking way, but a depretiation
|
||||
warning will be presented to users until they migrate. The old config method will
|
||||
be removed in either `v1.11.0` or `v2.0.0`, whichever comes first.
|
||||
|
||||
#### Quick Migration
|
||||
|
||||
```js
|
||||
// change this:
|
||||
chai.Assertion.includeStack = true;
|
||||
chai.Assertion.showDiff = false;
|
||||
|
||||
// ... to this:
|
||||
chai.config.includeStack = true;
|
||||
chai.config.showDiff = false;
|
||||
```
|
||||
|
||||
#### All Config Options
|
||||
|
||||
##### config.includeStack
|
||||
|
||||
- **@param** _{Boolean}_
|
||||
- **@default** `false`
|
||||
|
||||
User configurable property, influences whether stack trace is included in
|
||||
Assertion error message. Default of `false` suppresses stack trace in the error
|
||||
message.
|
||||
|
||||
##### config.showDiff
|
||||
|
||||
- **@param** _{Boolean}_
|
||||
- **@default** `true`
|
||||
|
||||
User configurable property, influences whether or not the `showDiff` flag
|
||||
should be included in the thrown AssertionErrors. `false` will always be `false`;
|
||||
`true` will be true when the assertion has requested a diff be shown.
|
||||
|
||||
##### config.truncateThreshold **(NEW)**
|
||||
|
||||
- **@param** _{Number}_
|
||||
- **@default** `40`
|
||||
|
||||
User configurable property, sets length threshold for actual and expected values
|
||||
in assertion errors. If this threshold is exceeded, the value is truncated.
|
||||
|
||||
Set it to zero if you want to disable truncating altogether.
|
||||
|
||||
```js
|
||||
chai.config.truncateThreshold = 0; // disable truncating
|
||||
```
|
||||
|
||||
### Community Contributions
|
||||
|
||||
- [#228](https://github.com/chaijs/chai/pull/228) Deep equality check for memebers. [@duncanbeevers](https://github.com/duncanbeevers)
|
||||
- [#247](https://github.com/chaijs/chai/pull/247) Proofreading. [@didorellano](https://github.com/didoarellano)
|
||||
- [#244](https://github.com/chaijs/chai/pull/244) Fix `contain`/`include` 1.9.0 regression. [@leider](https://github.com/leider)
|
||||
- [#233](https://github.com/chaijs/chai/pull/233) Improvements to `ssfi` for `assert` interface. [@refack](https://github.com/refack)
|
||||
- [#251](https://github.com/chaijs/chai/pull/251) New config option: object display threshold. [@romario333](https://github.com/romario333)
|
||||
|
||||
Thank you to all who took time to contribute!
|
||||
|
||||
### Other Bug Fixes
|
||||
|
||||
- [#183](https://github.com/chaijs/chai/issues/183) Allow `undefined` for actual. (internal api)
|
||||
- Update Karam(+plugins)/Istanbul to most recent versions.
|
||||
|
||||
## 1.9.0 / 2014-01-29
|
||||
|
||||
The following changes are required if you are upgrading from the previous version:
|
||||
|
||||
- **Users:**
|
||||
- No changes required
|
||||
- **Plugin Developers:**
|
||||
- Review [#219](https://github.com/chaijs/chai/pull/219).
|
||||
- **Core Contributors:**
|
||||
- Refresh `node_modules` folder for updated dependencies.
|
||||
|
||||
### Community Contributions
|
||||
|
||||
- [#202](https://github.com/chaijs/chai/pull/201) Improve error message for .throw(). [@andreineculau](https://github.com/andreineculau)
|
||||
- [#217](https://github.com/chaijs/chai/pull/217) Chai tests can be run with `--watch`. [@demands](https://github.com/demands)
|
||||
- [#219](https://github.com/chaijs/chai/pull/219) Add overwriteChainableMethod utility. [@demands](https://github.com/demands)
|
||||
- [#224](https://github.com/chaijs/chai/pull/224) Return error on throw method to chain on error properties. [@vbardales](https://github.com/vbardales)
|
||||
- [#226](https://github.com/chaijs/chai/pull/226) Add `has` to language chains. [@duncanbeevers](https://github.com/duncanbeevers)
|
||||
- [#230](https://github.com/chaijs/chai/pull/230) Support `{a:1,b:2}.should.include({a:1})` [@jkroso](https://github.com/jkroso)
|
||||
- [#231](https://github.com/chaijs/chai/pull/231) Update Copyright notices to 2014 [@duncanbeevers](https://github.com/duncanbeevers)
|
||||
- [#232](https://github.com/chaijs/chai/pull/232) Avoid error instantiation if possible on assert.throws. [@laconbass](https://github.com/laconbass)
|
||||
|
||||
Thank you to all who took time to contribute!
|
||||
|
||||
### Other Bug Fixes
|
||||
|
||||
- [#225](https://github.com/chaijs/chai/pull/225) Improved AMD wrapper provided by upstream `component(1)`.
|
||||
- [#185](https://github.com/chaijs/chai/issues/185) `assert.throws()` returns thrown error for further assertions.
|
||||
- [#237](https://github.com/chaijs/chai/pull/237) Remove coveralls/jscoverage, include istanbul coverage report in travis test.
|
||||
- Update Karma and Sauce runner versions for consistent CI results. No more karma@canary.
|
||||
|
||||
## 1.8.1 / 2013-10-10
|
||||
|
||||
The following changes are required if you are upgrading from the previous version:
|
||||
|
||||
- **Users:**
|
||||
- Refresh `node_modules` folder for updated dependencies.
|
||||
- **Plugin Developers:**
|
||||
- No changes required
|
||||
- **Core Contributors:**
|
||||
- Refresh `node_modules` folder for updated dependencies.
|
||||
|
||||
### Browserify
|
||||
|
||||
This is a small patch that updates the dependency tree so browserify users can install
|
||||
chai. (Remove conditional requires)
|
||||
|
||||
## 1.8.0 / 2013-09-18
|
||||
|
||||
The following changes are required if you are upgrading from the previous version:
|
||||
|
||||
- **Users:**
|
||||
- See `deep.equal` notes.
|
||||
- **Plugin Developers:**
|
||||
- No changes required
|
||||
- **Core Contributors:**
|
||||
- Refresh `node_modules` folder for updated dependencies.
|
||||
|
||||
### Deep Equals
|
||||
|
||||
This version of Chai focused on a overhaul to the deep equal utility. The code for this
|
||||
tool has been removed from the core lib and can now be found at:
|
||||
[chai / deep-eql](https://github.com/chaijs/deep-eql). As stated in previous releases,
|
||||
this is part of a larger initiative to provide transparency, independent testing, and coverage for
|
||||
some of the more complicated internal tools.
|
||||
|
||||
For the most part `.deep.equal` will behave the same as it has. However, in order to provide a
|
||||
consistent ruleset across all types being tested, the following changes have been made and _might_
|
||||
require changes to your tests.
|
||||
|
||||
**1.** Strict equality for non-traversable nodes according to [egal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
|
||||
|
||||
_Previously:_ Non-traversable equal via `===`.
|
||||
|
||||
```js
|
||||
expect(NaN).to.deep.equal(NaN);
|
||||
expect(-0).to.not.deep.equal(+0);
|
||||
```
|
||||
|
||||
**2.** Arguments are not Arrays (and all types must be equal):
|
||||
|
||||
_Previously:_ Some crazy nonsense that led to empty arrays deep equaling empty objects deep equaling dates.
|
||||
|
||||
```js
|
||||
expect(arguments).to.not.deep.equal([]);
|
||||
expect(Array.prototype.slice.call(arguments)).to.deep.equal([]);
|
||||
```
|
||||
|
||||
- [#156](https://github.com/chaijs/chai/issues/156) Empty object is eql to empty array
|
||||
- [#192](https://github.com/chaijs/chai/issues/192) empty object is eql to a Date object
|
||||
- [#194](https://github.com/chaijs/chai/issues/194) refactor deep-equal utility
|
||||
|
||||
### CI and Browser Testing
|
||||
|
||||
Chai now runs the browser CI suite using [Karma](http://karma-runner.github.io/) directed at
|
||||
[SauceLabs](https://saucelabs.com/). This means we get to know where our browser support stands...
|
||||
and we get a cool badge:
|
||||
|
||||
[](https://saucelabs.com/u/logicalparadox)
|
||||
|
||||
Look for the list of browsers/versions to expand over the coming releases.
|
||||
|
||||
- [#195](https://github.com/chaijs/chai/issues/195) karma test framework
|
||||
|
||||
## 1.7.2 / 2013-06-27
|
||||
|
||||
The following changes are required if you are upgrading from the previous version:
|
||||
|
||||
- **Users:**
|
||||
- No changes required.
|
||||
- **Plugin Developers:**
|
||||
- No changes required
|
||||
- **Core Contributors:**
|
||||
- Refresh `node_modules` folder for updated dependencies.
|
||||
|
||||
### Coverage Reporting
|
||||
|
||||
Coverage reporting has always been available for core-developers but the data has never been published
|
||||
for our end users. In our ongoing effort to improve accountability this data will now be published via
|
||||
the [coveralls.io](https://coveralls.io/) service. A badge has been added to the README and the full report
|
||||
can be viewed online at the [chai coveralls project](https://coveralls.io/r/chaijs/chai). Furthermore, PRs
|
||||
will receive automated messages indicating how their PR impacts test coverage. This service is tied to TravisCI.
|
||||
|
||||
### Other Fixes
|
||||
|
||||
- [#175](https://github.com/chaijs/chai/issues/175) Add `bower.json`. (Fix ignore all)
|
||||
|
||||
## 1.7.1 / 2013-06-24
|
||||
|
||||
The following changes are required if you are upgrading from the previous version:
|
||||
|
||||
- **Users:**
|
||||
- No changes required.
|
||||
- **Plugin Developers:**
|
||||
- No changes required
|
||||
- **Core Contributors:**
|
||||
- Refresh `node_modules` folder for updated dependencies.
|
||||
|
||||
### Official Bower Support
|
||||
|
||||
Support has been added for the Bower Package Manager ([bower.io])(http://bower.io/). Though
|
||||
Chai could be installed via Bower in the past, this update adds official support via the `bower.json`
|
||||
specification file.
|
||||
|
||||
- [#175](https://github.com/chaijs/chai/issues/175) Add `bower.json`.
|
||||
|
||||
## 1.7.0 / 2013-06-17
|
||||
|
||||
The following changes are required if you are upgrading from the previous version:
|
||||
|
||||
- **Users:**
|
||||
- No changes required.
|
||||
- **Plugin Developers:**
|
||||
- Review AssertionError update notice.
|
||||
- **Core Contributors:**
|
||||
- Refresh `node_modules` folder for updated dependencies.
|
||||
|
||||
### AssertionError Update Notice
|
||||
|
||||
Chai now uses [chaijs/assertion-error](https://github.com/chaijs/assertion-error) instead an internal
|
||||
constructor. This will allow for further iteration/experimentation of the AssertionError constructor
|
||||
independant of Chai. Future plans include stack parsing for callsite support.
|
||||
|
||||
This update constructor has a different constructor param signature that conforms more with the standard
|
||||
`Error` object. If your plugin throws and `AssertionError` directly you will need to update your plugin
|
||||
with the new signature.
|
||||
|
||||
```js
|
||||
var AssertionError = require('chai').AssertionError;
|
||||
|
||||
/**
|
||||
* previous
|
||||
*
|
||||
* @param {Object} options
|
||||
*/
|
||||
|
||||
throw new AssertionError({
|
||||
message: 'An assertion error occurred'
|
||||
, actual: actual
|
||||
, expect: expect
|
||||
, startStackFunction: arguments.callee
|
||||
, showStack: true
|
||||
});
|
||||
|
||||
/**
|
||||
* new
|
||||
*
|
||||
* @param {String} message
|
||||
* @param {Object} options
|
||||
* @param {Function} start stack function
|
||||
*/
|
||||
|
||||
throw new AssertionError('An assertion error occurred', {
|
||||
actual: actual
|
||||
, expect: expect
|
||||
, showStack: true
|
||||
}, arguments.callee);
|
||||
|
||||
// other signatures
|
||||
throw new AssertionError('An assertion error occurred');
|
||||
throw new AssertionError('An assertion error occurred', null, arguments.callee);
|
||||
```
|
||||
|
||||
#### External Dependencies
|
||||
|
||||
This is the first non-developement dependency for Chai. As Chai continues to evolve we will begin adding
|
||||
more; the next will likely be improved type detection and deep equality. With Chai's userbase continually growing
|
||||
there is an higher need for accountability and documentation. External dependencies will allow us to iterate and
|
||||
test on features independent from our interfaces.
|
||||
|
||||
Note: The browser packaged version `chai.js` will ALWAYS contain all dependencies needed to run Chai.
|
||||
|
||||
### Community Contributions
|
||||
|
||||
- [#169](https://github.com/chaijs/chai/pull/169) Fix deep equal comparison for Date/Regexp types. [@katsgeorgeek](https://github.com/katsgeorgeek)
|
||||
- [#171](https://github.com/chaijs/chai/pull/171) Add `assert.notOk()`. [@Bartvds](https://github.com/Bartvds)
|
||||
- [#173](https://github.com/chaijs/chai/pull/173) Fix `inspect` utility. [@domenic](https://github.com/domenic)
|
||||
|
||||
Thank you to all who took the time to contribute!
|
||||
|
||||
## 1.6.1 / 2013-06-05
|
||||
|
||||
The following changes are required if you are upgrading from the previous version:
|
||||
|
||||
- **Users:**
|
||||
- No changes required.
|
||||
- **Plugin Developers:**
|
||||
- No changes required.
|
||||
- **Core Contributors:**
|
||||
- Refresh `node_modules` folder for updated developement dependencies.
|
||||
|
||||
### Deep Equality
|
||||
|
||||
Regular Expressions are now tested as part of all deep equality assertions. In previous versions
|
||||
they silently passed for all scenarios. Thanks to [@katsgeorgeek](https://github.com/katsgeorgeek) for the contribution.
|
||||
|
||||
### Community Contributions
|
||||
|
||||
- [#161](https://github.com/chaijs/chai/pull/161) Fix documented name for assert interface's isDefined method. [@brandonpayton](https://github.com/brandonpayton)
|
||||
- [#168](https://github.com/chaijs/chai/pull/168) Fix comparison equality of two regexps for when using deep equality. [@katsgeorgeek](https://github.com/katsgeorgeek)
|
||||
|
||||
Thank you to all who took the time to contribute!
|
||||
|
||||
### Additional Notes
|
||||
|
||||
- Mocha has been locked at version `1.8.x` to ensure `mocha-phantomjs` compatibility.
|
||||
|
||||
## 1.6.0 / 2013-04-29
|
||||
|
||||
The following changes are required if you are upgrading from the previous version:
|
||||
|
||||
- **Users:**
|
||||
- No changes required.
|
||||
- **Plugin Developers:**
|
||||
- No changes required.
|
||||
- **Core Contributors:**
|
||||
- Refresh `node_modules` folder for updated developement dependencies.
|
||||
|
||||
### New Assertions
|
||||
|
||||
#### Array Members Inclusion
|
||||
|
||||
Asserts that the target is a superset of `set`, or that the target and `set` have the same members.
|
||||
Order is not taken into account. Thanks to [@NickHeiner](https://github.com/NickHeiner) for the contribution.
|
||||
|
||||
```js
|
||||
// (expect/should) full set
|
||||
expect([4, 2]).to.have.members([2, 4]);
|
||||
expect([5, 2]).to.not.have.members([5, 2, 1]);
|
||||
|
||||
// (expect/should) inclusion
|
||||
expect([1, 2, 3]).to.include.members([3, 2]);
|
||||
expect([1, 2, 3]).to.not.include.members([3, 2, 8]);
|
||||
|
||||
// (assert) full set
|
||||
assert.sameMembers([ 1, 2, 3 ], [ 2, 1, 3 ], 'same members');
|
||||
|
||||
// (assert) inclusion
|
||||
assert.includeMembers([ 1, 2, 3 ], [ 2, 1 ], 'include members');
|
||||
|
||||
```
|
||||
|
||||
#### Non-inclusion for Assert Interface
|
||||
|
||||
Most `assert` functions have a negative version, like `instanceOf()` has a corresponding `notInstaceOf()`.
|
||||
However `include()` did not have a corresponding `notInclude()`. This has been added.
|
||||
|
||||
```js
|
||||
assert.notInclude([ 1, 2, 3 ], 8);
|
||||
assert.notInclude('foobar', 'baz');
|
||||
```
|
||||
|
||||
### Community Contributions
|
||||
|
||||
- [#140](https://github.com/chaijs/chai/pull/140) Restore `call`/`apply` methods for plugin interface. [@RubenVerborgh](https://github.com/RubenVerborgh)
|
||||
- [#148](https://github.com/chaijs/chai/issues/148)/[#153](https://github.com/chaijs/chai/pull/153) Add `members` and `include.members` assertions. [#NickHeiner](https://github.com/NickHeiner)
|
||||
|
||||
Thank you to all who took time to contribute!
|
||||
|
||||
### Other Bug Fixes
|
||||
|
||||
- [#142](https://github.com/chaijs/chai/issues/142) `assert#include` will no longer silently pass on wrong-type haystack.
|
||||
- [#158](https://github.com/chaijs/chai/issues/158) `assert#notInclude` has been added.
|
||||
- Travis-CI now tests Node.js `v0.10.x`. Support for `v0.6.x` has been removed. `v0.8.x` is still tested as before.
|
||||
|
||||
## 1.5.0 / 2013-02-03
|
||||
|
||||
### Migration Requirements
|
||||
|
||||
The following changes are required if you are upgrading from the previous version:
|
||||
|
||||
- **Users:**
|
||||
- _Update [2013-02-04]:_ Some users may notice a small subset of deep equality assertions will no longer pass. This is the result of
|
||||
[#120](https://github.com/chaijs/chai/issues/120), an improvement to our deep equality algorithm. Users will need to revise their assertions
|
||||
to be more granular should this occur. Further information: [#139](https://github.com/chaijs/chai/issues/139).
|
||||
- **Plugin Developers:**
|
||||
- No changes required.
|
||||
- **Core Contributors:**
|
||||
- Refresh `node_modules` folder for updated developement dependencies.
|
||||
|
||||
### Community Contributions
|
||||
|
||||
- [#126](https://github.com/chaijs/chai/pull/126): Add `eqls` alias for `eql`. [@RubenVerborgh](https://github.com/RubenVerborgh)
|
||||
- [#127](https://github.com/chaijs/chai/issues/127): Performance refactor for chainable methods. [@RubenVerborgh](https://github.com/RubenVerborgh)
|
||||
- [#133](https://github.com/chaijs/chai/pull/133): Assertion `.throw` support for primitives. [@RubenVerborgh](https://github.com/RubenVerborgh)
|
||||
- [#137](https://github.com/chaijs/chai/issues/137): Assertion `.throw` support for empty messages. [@timnew](https://github.com/timnew)
|
||||
- [#136](https://github.com/chaijs/chai/pull/136): Fix backward negation messages when using `.above()` and `.below()`. [@whatthejeff](https://github.com/whatthejeff)
|
||||
|
||||
Thank you to all who took time to contribute!
|
||||
|
||||
### Other Bug Fixes
|
||||
|
||||
- Improve type detection of `.a()`/`.an()` to work in cross-browser scenarios.
|
||||
- [#116](https://github.com/chaijs/chai/issues/116): `.throw()` has cleaner display of errors when WebKit browsers.
|
||||
- [#120](https://github.com/chaijs/chai/issues/120): `.eql()` now works to compare dom nodes in browsers.
|
||||
|
||||
|
||||
### Usage Updates
|
||||
|
||||
#### For Users
|
||||
|
||||
**1. Component Support:** Chai now included the proper configuration to be installed as a
|
||||
[component](https://github.com/component/component). Component users are encouraged to consult
|
||||
[chaijs.com](http://chaijs.com) for the latest version number as using the master branch
|
||||
does not gaurantee stability.
|
||||
|
||||
```js
|
||||
// relevant component.json
|
||||
devDependencies: {
|
||||
"chaijs/chai": "1.5.0"
|
||||
}
|
||||
```
|
||||
|
||||
Alternatively, bleeding-edge is available:
|
||||
|
||||
$ component install chaijs/chai
|
||||
|
||||
**2. Configurable showDiff:** Some test runners (such as [mocha](http://visionmedia.github.com/mocha/))
|
||||
include support for showing the diff of strings and objects when an equality error occurs. Chai has
|
||||
already included support for this, however some users may not prefer this display behavior. To revert to
|
||||
no diff display, the following configuration is available:
|
||||
|
||||
```js
|
||||
chai.Assertion.showDiff = false; // diff output disabled
|
||||
chai.Assertion.showDiff = true; // default, diff output enabled
|
||||
```
|
||||
|
||||
#### For Plugin Developers
|
||||
|
||||
**1. New Utility - type**: The new utility `.type()` is available as a better implementation of `typeof`
|
||||
that can be used cross-browser. It handles the inconsistencies of Array, `null`, and `undefined` detection.
|
||||
|
||||
- **@param** _{Mixed}_ object to detect type of
|
||||
- **@return** _{String}_ object type
|
||||
|
||||
```js
|
||||
chai.use(function (c, utils) {
|
||||
// some examples
|
||||
utils.type({}); // 'object'
|
||||
utils.type(null); // `null'
|
||||
utils.type(undefined); // `undefined`
|
||||
utils.type([]); // `array`
|
||||
});
|
||||
```
|
||||
|
||||
#### For Core Contributors
|
||||
|
||||
**1. Browser Testing**: Browser testing of the `./chai.js` file is now available in the command line
|
||||
via PhantomJS. `make test` and Travis-CI will now also rebuild and test `./chai.js`. Consequently, all
|
||||
pull requests will now be browser tested in this way.
|
||||
|
||||
_Note: Contributors opening pull requests should still NOT include the browser build._
|
||||
|
||||
**2. SauceLabs Testing**: Early SauceLab support has been enabled with the file `./support/mocha-cloud.js`.
|
||||
Those interested in trying it out should create a free [Open Sauce](https://saucelabs.com/signup/plan) account
|
||||
and include their credentials in `./test/auth/sauce.json`.
|
||||
26
node_modules/@blockly/dev-tools/node_modules/chai/bower.json
generated
vendored
Normal file
26
node_modules/@blockly/dev-tools/node_modules/chai/bower.json
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "chai",
|
||||
"description": "BDD/TDD assertion library for node.js and the browser. Test framework agnostic.",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"test",
|
||||
"assertion",
|
||||
"assert",
|
||||
"testing",
|
||||
"chai"
|
||||
],
|
||||
"main": "chai.js",
|
||||
"ignore": [
|
||||
"build",
|
||||
"components",
|
||||
"lib",
|
||||
"node_modules",
|
||||
"support",
|
||||
"test",
|
||||
"index.js",
|
||||
"Makefile",
|
||||
".*"
|
||||
],
|
||||
"dependencies": {},
|
||||
"devDependencies": {}
|
||||
}
|
||||
11549
node_modules/@blockly/dev-tools/node_modules/chai/chai.js
generated
vendored
Normal file
11549
node_modules/@blockly/dev-tools/node_modules/chai/chai.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/@blockly/dev-tools/node_modules/chai/index.js
generated
vendored
Normal file
1
node_modules/@blockly/dev-tools/node_modules/chai/index.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('./lib/chai');
|
||||
14
node_modules/@blockly/dev-tools/node_modules/chai/index.mjs
generated
vendored
Normal file
14
node_modules/@blockly/dev-tools/node_modules/chai/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import chai from './index.js';
|
||||
|
||||
export const expect = chai.expect;
|
||||
export const version = chai.version;
|
||||
export const Assertion = chai.Assertion;
|
||||
export const AssertionError = chai.AssertionError;
|
||||
export const util = chai.util;
|
||||
export const config = chai.config;
|
||||
export const use = chai.use;
|
||||
export const should = chai.should;
|
||||
export const assert = chai.assert;
|
||||
export const core = chai.core;
|
||||
|
||||
export default chai;
|
||||
34
node_modules/@blockly/dev-tools/node_modules/chai/karma.conf.js
generated
vendored
Normal file
34
node_modules/@blockly/dev-tools/node_modules/chai/karma.conf.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
module.exports = function(config) {
|
||||
config.set({
|
||||
frameworks: [ 'mocha' ]
|
||||
, files: [
|
||||
'chai.js'
|
||||
, 'test/bootstrap/index.js'
|
||||
, 'test/*.js'
|
||||
]
|
||||
, reporters: [ 'progress' ]
|
||||
, colors: true
|
||||
, logLevel: config.LOG_INFO
|
||||
, autoWatch: false
|
||||
, browsers: [ 'HeadlessChrome' ]
|
||||
, customLaunchers: {
|
||||
HeadlessChrome: {
|
||||
base: 'ChromeHeadless'
|
||||
, flags: [ '--no-sandbox',]
|
||||
, }
|
||||
, }
|
||||
, browserDisconnectTimeout: 10000
|
||||
, browserDisconnectTolerance: 2
|
||||
, browserNoActivityTimeout: 20000
|
||||
, singleRun: true
|
||||
});
|
||||
|
||||
switch (process.env.CHAI_TEST_ENV) {
|
||||
case 'sauce':
|
||||
require('./karma.sauce')(config);
|
||||
break;
|
||||
default:
|
||||
// ...
|
||||
break;
|
||||
};
|
||||
};
|
||||
41
node_modules/@blockly/dev-tools/node_modules/chai/karma.sauce.js
generated
vendored
Normal file
41
node_modules/@blockly/dev-tools/node_modules/chai/karma.sauce.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
var version = require('./package.json').version;
|
||||
var ts = new Date().getTime();
|
||||
|
||||
module.exports = function(config) {
|
||||
var auth;
|
||||
|
||||
try {
|
||||
auth = require('./test/auth/index');
|
||||
} catch(ex) {
|
||||
auth = {};
|
||||
auth.SAUCE_USERNAME = process.env.SAUCE_USERNAME || null;
|
||||
auth.SAUCE_ACCESS_KEY = process.env.SAUCE_ACCESS_KEY || null;
|
||||
}
|
||||
|
||||
if (!auth.SAUCE_USERNAME || !auth.SAUCE_ACCESS_KEY) return;
|
||||
if (process.env.SKIP_SAUCE) return;
|
||||
|
||||
var branch = process.env.TRAVIS_BRANCH || 'local'
|
||||
var browserConfig = require('./sauce.browsers');
|
||||
var browsers = Object.keys(browserConfig);
|
||||
var tags = [ 'chaijs_' + version, auth.SAUCE_USERNAME + '@' + branch ];
|
||||
var tunnel = process.env.TRAVIS_JOB_NUMBER || ts;
|
||||
|
||||
if (process.env.TRAVIS_JOB_NUMBER) {
|
||||
tags.push('travis@' + process.env.TRAVIS_JOB_NUMBER);
|
||||
}
|
||||
|
||||
config.browsers = config.browsers.concat(browsers);
|
||||
Object.assign(config.customLaunchers, browserConfig);
|
||||
config.reporters.push('saucelabs');
|
||||
config.captureTimeout = 300000;
|
||||
|
||||
config.sauceLabs = {
|
||||
username: auth.SAUCE_USERNAME
|
||||
, accessKey: auth.SAUCE_ACCESS_KEY
|
||||
, startConnect: ('TRAVIS' in process.env) === false
|
||||
, tags: tags
|
||||
, testName: 'ChaiJS'
|
||||
, tunnelIdentifier: tunnel
|
||||
};
|
||||
};
|
||||
92
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai.js
generated
vendored
Normal file
92
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai.js
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
/*!
|
||||
* chai
|
||||
* Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
var used = [];
|
||||
|
||||
/*!
|
||||
* Chai version
|
||||
*/
|
||||
|
||||
exports.version = '4.3.8';
|
||||
|
||||
/*!
|
||||
* Assertion Error
|
||||
*/
|
||||
|
||||
exports.AssertionError = require('assertion-error');
|
||||
|
||||
/*!
|
||||
* Utils for plugins (not exported)
|
||||
*/
|
||||
|
||||
var util = require('./chai/utils');
|
||||
|
||||
/**
|
||||
* # .use(function)
|
||||
*
|
||||
* Provides a way to extend the internals of Chai.
|
||||
*
|
||||
* @param {Function}
|
||||
* @returns {this} for chaining
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.use = function (fn) {
|
||||
if (!~used.indexOf(fn)) {
|
||||
fn(exports, util);
|
||||
used.push(fn);
|
||||
}
|
||||
|
||||
return exports;
|
||||
};
|
||||
|
||||
/*!
|
||||
* Utility Functions
|
||||
*/
|
||||
|
||||
exports.util = util;
|
||||
|
||||
/*!
|
||||
* Configuration
|
||||
*/
|
||||
|
||||
var config = require('./chai/config');
|
||||
exports.config = config;
|
||||
|
||||
/*!
|
||||
* Primary `Assertion` prototype
|
||||
*/
|
||||
|
||||
var assertion = require('./chai/assertion');
|
||||
exports.use(assertion);
|
||||
|
||||
/*!
|
||||
* Core Assertions
|
||||
*/
|
||||
|
||||
var core = require('./chai/core/assertions');
|
||||
exports.use(core);
|
||||
|
||||
/*!
|
||||
* Expect interface
|
||||
*/
|
||||
|
||||
var expect = require('./chai/interface/expect');
|
||||
exports.use(expect);
|
||||
|
||||
/*!
|
||||
* Should interface
|
||||
*/
|
||||
|
||||
var should = require('./chai/interface/should');
|
||||
exports.use(should);
|
||||
|
||||
/*!
|
||||
* Assert interface
|
||||
*/
|
||||
|
||||
var assert = require('./chai/interface/assert');
|
||||
exports.use(assert);
|
||||
178
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/assertion.js
generated
vendored
Normal file
178
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/assertion.js
generated
vendored
Normal file
@@ -0,0 +1,178 @@
|
||||
/*!
|
||||
* chai
|
||||
* http://chaijs.com
|
||||
* Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
var config = require('./config');
|
||||
|
||||
module.exports = function (_chai, util) {
|
||||
/*!
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var AssertionError = _chai.AssertionError
|
||||
, flag = util.flag;
|
||||
|
||||
/*!
|
||||
* Module export.
|
||||
*/
|
||||
|
||||
_chai.Assertion = Assertion;
|
||||
|
||||
/*!
|
||||
* Assertion Constructor
|
||||
*
|
||||
* Creates object for chaining.
|
||||
*
|
||||
* `Assertion` objects contain metadata in the form of flags. Three flags can
|
||||
* be assigned during instantiation by passing arguments to this constructor:
|
||||
*
|
||||
* - `object`: This flag contains the target of the assertion. For example, in
|
||||
* the assertion `expect(numKittens).to.equal(7);`, the `object` flag will
|
||||
* contain `numKittens` so that the `equal` assertion can reference it when
|
||||
* needed.
|
||||
*
|
||||
* - `message`: This flag contains an optional custom error message to be
|
||||
* prepended to the error message that's generated by the assertion when it
|
||||
* fails.
|
||||
*
|
||||
* - `ssfi`: This flag stands for "start stack function indicator". It
|
||||
* contains a function reference that serves as the starting point for
|
||||
* removing frames from the stack trace of the error that's created by the
|
||||
* assertion when it fails. The goal is to provide a cleaner stack trace to
|
||||
* end users by removing Chai's internal functions. Note that it only works
|
||||
* in environments that support `Error.captureStackTrace`, and only when
|
||||
* `Chai.config.includeStack` hasn't been set to `false`.
|
||||
*
|
||||
* - `lockSsfi`: This flag controls whether or not the given `ssfi` flag
|
||||
* should retain its current value, even as assertions are chained off of
|
||||
* this object. This is usually set to `true` when creating a new assertion
|
||||
* from within another assertion. It's also temporarily set to `true` before
|
||||
* an overwritten assertion gets called by the overwriting assertion.
|
||||
*
|
||||
* - `eql`: This flag contains the deepEqual function to be used by the assertion.
|
||||
*
|
||||
* @param {Mixed} obj target of the assertion
|
||||
* @param {String} msg (optional) custom error message
|
||||
* @param {Function} ssfi (optional) starting point for removing stack frames
|
||||
* @param {Boolean} lockSsfi (optional) whether or not the ssfi flag is locked
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function Assertion (obj, msg, ssfi, lockSsfi) {
|
||||
flag(this, 'ssfi', ssfi || Assertion);
|
||||
flag(this, 'lockSsfi', lockSsfi);
|
||||
flag(this, 'object', obj);
|
||||
flag(this, 'message', msg);
|
||||
flag(this, 'eql', config.deepEqual || util.eql);
|
||||
|
||||
return util.proxify(this);
|
||||
}
|
||||
|
||||
Object.defineProperty(Assertion, 'includeStack', {
|
||||
get: function() {
|
||||
console.warn('Assertion.includeStack is deprecated, use chai.config.includeStack instead.');
|
||||
return config.includeStack;
|
||||
},
|
||||
set: function(value) {
|
||||
console.warn('Assertion.includeStack is deprecated, use chai.config.includeStack instead.');
|
||||
config.includeStack = value;
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(Assertion, 'showDiff', {
|
||||
get: function() {
|
||||
console.warn('Assertion.showDiff is deprecated, use chai.config.showDiff instead.');
|
||||
return config.showDiff;
|
||||
},
|
||||
set: function(value) {
|
||||
console.warn('Assertion.showDiff is deprecated, use chai.config.showDiff instead.');
|
||||
config.showDiff = value;
|
||||
}
|
||||
});
|
||||
|
||||
Assertion.addProperty = function (name, fn) {
|
||||
util.addProperty(this.prototype, name, fn);
|
||||
};
|
||||
|
||||
Assertion.addMethod = function (name, fn) {
|
||||
util.addMethod(this.prototype, name, fn);
|
||||
};
|
||||
|
||||
Assertion.addChainableMethod = function (name, fn, chainingBehavior) {
|
||||
util.addChainableMethod(this.prototype, name, fn, chainingBehavior);
|
||||
};
|
||||
|
||||
Assertion.overwriteProperty = function (name, fn) {
|
||||
util.overwriteProperty(this.prototype, name, fn);
|
||||
};
|
||||
|
||||
Assertion.overwriteMethod = function (name, fn) {
|
||||
util.overwriteMethod(this.prototype, name, fn);
|
||||
};
|
||||
|
||||
Assertion.overwriteChainableMethod = function (name, fn, chainingBehavior) {
|
||||
util.overwriteChainableMethod(this.prototype, name, fn, chainingBehavior);
|
||||
};
|
||||
|
||||
/**
|
||||
* ### .assert(expression, message, negateMessage, expected, actual, showDiff)
|
||||
*
|
||||
* Executes an expression and check expectations. Throws AssertionError for reporting if test doesn't pass.
|
||||
*
|
||||
* @name assert
|
||||
* @param {Philosophical} expression to be tested
|
||||
* @param {String|Function} message or function that returns message to display if expression fails
|
||||
* @param {String|Function} negatedMessage or function that returns negatedMessage to display if negated expression fails
|
||||
* @param {Mixed} expected value (remember to check for negation)
|
||||
* @param {Mixed} actual (optional) will default to `this.obj`
|
||||
* @param {Boolean} showDiff (optional) when set to `true`, assert will display a diff in addition to the message if expression fails
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Assertion.prototype.assert = function (expr, msg, negateMsg, expected, _actual, showDiff) {
|
||||
var ok = util.test(this, arguments);
|
||||
if (false !== showDiff) showDiff = true;
|
||||
if (undefined === expected && undefined === _actual) showDiff = false;
|
||||
if (true !== config.showDiff) showDiff = false;
|
||||
|
||||
if (!ok) {
|
||||
msg = util.getMessage(this, arguments);
|
||||
var actual = util.getActual(this, arguments);
|
||||
var assertionErrorObjectProperties = {
|
||||
actual: actual
|
||||
, expected: expected
|
||||
, showDiff: showDiff
|
||||
};
|
||||
|
||||
var operator = util.getOperator(this, arguments);
|
||||
if (operator) {
|
||||
assertionErrorObjectProperties.operator = operator;
|
||||
}
|
||||
|
||||
throw new AssertionError(
|
||||
msg,
|
||||
assertionErrorObjectProperties,
|
||||
(config.includeStack) ? this.assert : flag(this, 'ssfi'));
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
* ### ._obj
|
||||
*
|
||||
* Quick reference to stored `actual` value for plugin developers.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
Object.defineProperty(Assertion.prototype, '_obj',
|
||||
{ get: function () {
|
||||
return flag(this, 'object');
|
||||
}
|
||||
, set: function (val) {
|
||||
flag(this, 'object', val);
|
||||
}
|
||||
});
|
||||
};
|
||||
120
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/config.js
generated
vendored
Normal file
120
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/config.js
generated
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
module.exports = {
|
||||
|
||||
/**
|
||||
* ### config.includeStack
|
||||
*
|
||||
* User configurable property, influences whether stack trace
|
||||
* is included in Assertion error message. Default of false
|
||||
* suppresses stack trace in the error message.
|
||||
*
|
||||
* chai.config.includeStack = true; // enable stack on error
|
||||
*
|
||||
* @param {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
includeStack: false,
|
||||
|
||||
/**
|
||||
* ### config.showDiff
|
||||
*
|
||||
* User configurable property, influences whether or not
|
||||
* the `showDiff` flag should be included in the thrown
|
||||
* AssertionErrors. `false` will always be `false`; `true`
|
||||
* will be true when the assertion has requested a diff
|
||||
* be shown.
|
||||
*
|
||||
* @param {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
showDiff: true,
|
||||
|
||||
/**
|
||||
* ### config.truncateThreshold
|
||||
*
|
||||
* User configurable property, sets length threshold for actual and
|
||||
* expected values in assertion errors. If this threshold is exceeded, for
|
||||
* example for large data structures, the value is replaced with something
|
||||
* like `[ Array(3) ]` or `{ Object (prop1, prop2) }`.
|
||||
*
|
||||
* Set it to zero if you want to disable truncating altogether.
|
||||
*
|
||||
* This is especially userful when doing assertions on arrays: having this
|
||||
* set to a reasonable large value makes the failure messages readily
|
||||
* inspectable.
|
||||
*
|
||||
* chai.config.truncateThreshold = 0; // disable truncating
|
||||
*
|
||||
* @param {Number}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
truncateThreshold: 40,
|
||||
|
||||
/**
|
||||
* ### config.useProxy
|
||||
*
|
||||
* User configurable property, defines if chai will use a Proxy to throw
|
||||
* an error when a non-existent property is read, which protects users
|
||||
* from typos when using property-based assertions.
|
||||
*
|
||||
* Set it to false if you want to disable this feature.
|
||||
*
|
||||
* chai.config.useProxy = false; // disable use of Proxy
|
||||
*
|
||||
* This feature is automatically disabled regardless of this config value
|
||||
* in environments that don't support proxies.
|
||||
*
|
||||
* @param {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
useProxy: true,
|
||||
|
||||
/**
|
||||
* ### config.proxyExcludedKeys
|
||||
*
|
||||
* User configurable property, defines which properties should be ignored
|
||||
* instead of throwing an error if they do not exist on the assertion.
|
||||
* This is only applied if the environment Chai is running in supports proxies and
|
||||
* if the `useProxy` configuration setting is enabled.
|
||||
* By default, `then` and `inspect` will not throw an error if they do not exist on the
|
||||
* assertion object because the `.inspect` property is read by `util.inspect` (for example, when
|
||||
* using `console.log` on the assertion object) and `.then` is necessary for promise type-checking.
|
||||
*
|
||||
* // By default these keys will not throw an error if they do not exist on the assertion object
|
||||
* chai.config.proxyExcludedKeys = ['then', 'inspect'];
|
||||
*
|
||||
* @param {Array}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
proxyExcludedKeys: ['then', 'catch', 'inspect', 'toJSON'],
|
||||
|
||||
/**
|
||||
* ### config.deepEqual
|
||||
*
|
||||
* User configurable property, defines which a custom function to use for deepEqual
|
||||
* comparisons.
|
||||
* By default, the function used is the one from the `deep-eql` package without custom comparator.
|
||||
*
|
||||
* // use a custom comparator
|
||||
* chai.config.deepEqual = (expected, actual) => {
|
||||
* return chai.util.eql(expected, actual, {
|
||||
* comparator: (expected, actual) => {
|
||||
* // for non number comparison, use the default behavior
|
||||
* if(typeof expected !== 'number') return null;
|
||||
* // allow a difference of 10 between compared numbers
|
||||
* return typeof actual === 'number' && Math.abs(actual - expected) < 10
|
||||
* }
|
||||
* })
|
||||
* };
|
||||
*
|
||||
* @param {Function}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
deepEqual: null
|
||||
|
||||
};
|
||||
3850
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/core/assertions.js
generated
vendored
Normal file
3850
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/core/assertions.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
3113
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/interface/assert.js
generated
vendored
Normal file
3113
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/interface/assert.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
47
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/interface/expect.js
generated
vendored
Normal file
47
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/interface/expect.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
/*!
|
||||
* chai
|
||||
* Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
module.exports = function (chai, util) {
|
||||
chai.expect = function (val, message) {
|
||||
return new chai.Assertion(val, message);
|
||||
};
|
||||
|
||||
/**
|
||||
* ### .fail([message])
|
||||
* ### .fail(actual, expected, [message], [operator])
|
||||
*
|
||||
* Throw a failure.
|
||||
*
|
||||
* expect.fail();
|
||||
* expect.fail("custom error message");
|
||||
* expect.fail(1, 2);
|
||||
* expect.fail(1, 2, "custom error message");
|
||||
* expect.fail(1, 2, "custom error message", ">");
|
||||
* expect.fail(1, 2, undefined, ">");
|
||||
*
|
||||
* @name fail
|
||||
* @param {Mixed} actual
|
||||
* @param {Mixed} expected
|
||||
* @param {String} message
|
||||
* @param {String} operator
|
||||
* @namespace BDD
|
||||
* @api public
|
||||
*/
|
||||
|
||||
chai.expect.fail = function (actual, expected, message, operator) {
|
||||
if (arguments.length < 2) {
|
||||
message = actual;
|
||||
actual = undefined;
|
||||
}
|
||||
|
||||
message = message || 'expect.fail()';
|
||||
throw new chai.AssertionError(message, {
|
||||
actual: actual
|
||||
, expected: expected
|
||||
, operator: operator
|
||||
}, chai.expect.fail);
|
||||
};
|
||||
};
|
||||
219
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/interface/should.js
generated
vendored
Normal file
219
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/interface/should.js
generated
vendored
Normal file
@@ -0,0 +1,219 @@
|
||||
/*!
|
||||
* chai
|
||||
* Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
module.exports = function (chai, util) {
|
||||
var Assertion = chai.Assertion;
|
||||
|
||||
function loadShould () {
|
||||
// explicitly define this method as function as to have it's name to include as `ssfi`
|
||||
function shouldGetter() {
|
||||
if (this instanceof String
|
||||
|| this instanceof Number
|
||||
|| this instanceof Boolean
|
||||
|| typeof Symbol === 'function' && this instanceof Symbol
|
||||
|| typeof BigInt === 'function' && this instanceof BigInt) {
|
||||
return new Assertion(this.valueOf(), null, shouldGetter);
|
||||
}
|
||||
return new Assertion(this, null, shouldGetter);
|
||||
}
|
||||
function shouldSetter(value) {
|
||||
// See https://github.com/chaijs/chai/issues/86: this makes
|
||||
// `whatever.should = someValue` actually set `someValue`, which is
|
||||
// especially useful for `global.should = require('chai').should()`.
|
||||
//
|
||||
// Note that we have to use [[DefineProperty]] instead of [[Put]]
|
||||
// since otherwise we would trigger this very setter!
|
||||
Object.defineProperty(this, 'should', {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
}
|
||||
// modify Object.prototype to have `should`
|
||||
Object.defineProperty(Object.prototype, 'should', {
|
||||
set: shouldSetter
|
||||
, get: shouldGetter
|
||||
, configurable: true
|
||||
});
|
||||
|
||||
var should = {};
|
||||
|
||||
/**
|
||||
* ### .fail([message])
|
||||
* ### .fail(actual, expected, [message], [operator])
|
||||
*
|
||||
* Throw a failure.
|
||||
*
|
||||
* should.fail();
|
||||
* should.fail("custom error message");
|
||||
* should.fail(1, 2);
|
||||
* should.fail(1, 2, "custom error message");
|
||||
* should.fail(1, 2, "custom error message", ">");
|
||||
* should.fail(1, 2, undefined, ">");
|
||||
*
|
||||
*
|
||||
* @name fail
|
||||
* @param {Mixed} actual
|
||||
* @param {Mixed} expected
|
||||
* @param {String} message
|
||||
* @param {String} operator
|
||||
* @namespace BDD
|
||||
* @api public
|
||||
*/
|
||||
|
||||
should.fail = function (actual, expected, message, operator) {
|
||||
if (arguments.length < 2) {
|
||||
message = actual;
|
||||
actual = undefined;
|
||||
}
|
||||
|
||||
message = message || 'should.fail()';
|
||||
throw new chai.AssertionError(message, {
|
||||
actual: actual
|
||||
, expected: expected
|
||||
, operator: operator
|
||||
}, should.fail);
|
||||
};
|
||||
|
||||
/**
|
||||
* ### .equal(actual, expected, [message])
|
||||
*
|
||||
* Asserts non-strict equality (`==`) of `actual` and `expected`.
|
||||
*
|
||||
* should.equal(3, '3', '== coerces values to strings');
|
||||
*
|
||||
* @name equal
|
||||
* @param {Mixed} actual
|
||||
* @param {Mixed} expected
|
||||
* @param {String} message
|
||||
* @namespace Should
|
||||
* @api public
|
||||
*/
|
||||
|
||||
should.equal = function (val1, val2, msg) {
|
||||
new Assertion(val1, msg).to.equal(val2);
|
||||
};
|
||||
|
||||
/**
|
||||
* ### .throw(function, [constructor/string/regexp], [string/regexp], [message])
|
||||
*
|
||||
* Asserts that `function` will throw an error that is an instance of
|
||||
* `constructor`, or alternately that it will throw an error with message
|
||||
* matching `regexp`.
|
||||
*
|
||||
* should.throw(fn, 'function throws a reference error');
|
||||
* should.throw(fn, /function throws a reference error/);
|
||||
* should.throw(fn, ReferenceError);
|
||||
* should.throw(fn, ReferenceError, 'function throws a reference error');
|
||||
* should.throw(fn, ReferenceError, /function throws a reference error/);
|
||||
*
|
||||
* @name throw
|
||||
* @alias Throw
|
||||
* @param {Function} function
|
||||
* @param {ErrorConstructor} constructor
|
||||
* @param {RegExp} regexp
|
||||
* @param {String} message
|
||||
* @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
|
||||
* @namespace Should
|
||||
* @api public
|
||||
*/
|
||||
|
||||
should.Throw = function (fn, errt, errs, msg) {
|
||||
new Assertion(fn, msg).to.Throw(errt, errs);
|
||||
};
|
||||
|
||||
/**
|
||||
* ### .exist
|
||||
*
|
||||
* Asserts that the target is neither `null` nor `undefined`.
|
||||
*
|
||||
* var foo = 'hi';
|
||||
*
|
||||
* should.exist(foo, 'foo exists');
|
||||
*
|
||||
* @name exist
|
||||
* @namespace Should
|
||||
* @api public
|
||||
*/
|
||||
|
||||
should.exist = function (val, msg) {
|
||||
new Assertion(val, msg).to.exist;
|
||||
}
|
||||
|
||||
// negation
|
||||
should.not = {}
|
||||
|
||||
/**
|
||||
* ### .not.equal(actual, expected, [message])
|
||||
*
|
||||
* Asserts non-strict inequality (`!=`) of `actual` and `expected`.
|
||||
*
|
||||
* should.not.equal(3, 4, 'these numbers are not equal');
|
||||
*
|
||||
* @name not.equal
|
||||
* @param {Mixed} actual
|
||||
* @param {Mixed} expected
|
||||
* @param {String} message
|
||||
* @namespace Should
|
||||
* @api public
|
||||
*/
|
||||
|
||||
should.not.equal = function (val1, val2, msg) {
|
||||
new Assertion(val1, msg).to.not.equal(val2);
|
||||
};
|
||||
|
||||
/**
|
||||
* ### .throw(function, [constructor/regexp], [message])
|
||||
*
|
||||
* Asserts that `function` will _not_ throw an error that is an instance of
|
||||
* `constructor`, or alternately that it will not throw an error with message
|
||||
* matching `regexp`.
|
||||
*
|
||||
* should.not.throw(fn, Error, 'function does not throw');
|
||||
*
|
||||
* @name not.throw
|
||||
* @alias not.Throw
|
||||
* @param {Function} function
|
||||
* @param {ErrorConstructor} constructor
|
||||
* @param {RegExp} regexp
|
||||
* @param {String} message
|
||||
* @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
|
||||
* @namespace Should
|
||||
* @api public
|
||||
*/
|
||||
|
||||
should.not.Throw = function (fn, errt, errs, msg) {
|
||||
new Assertion(fn, msg).to.not.Throw(errt, errs);
|
||||
};
|
||||
|
||||
/**
|
||||
* ### .not.exist
|
||||
*
|
||||
* Asserts that the target is neither `null` nor `undefined`.
|
||||
*
|
||||
* var bar = null;
|
||||
*
|
||||
* should.not.exist(bar, 'bar does not exist');
|
||||
*
|
||||
* @name not.exist
|
||||
* @namespace Should
|
||||
* @api public
|
||||
*/
|
||||
|
||||
should.not.exist = function (val, msg) {
|
||||
new Assertion(val, msg).to.not.exist;
|
||||
}
|
||||
|
||||
should['throw'] = should['Throw'];
|
||||
should.not['throw'] = should.not['Throw'];
|
||||
|
||||
return should;
|
||||
};
|
||||
|
||||
chai.should = loadShould;
|
||||
chai.Should = loadShould;
|
||||
};
|
||||
152
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/addChainableMethod.js
generated
vendored
Normal file
152
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/addChainableMethod.js
generated
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
/*!
|
||||
* Chai - addChainingMethod utility
|
||||
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Module dependencies
|
||||
*/
|
||||
|
||||
var addLengthGuard = require('./addLengthGuard');
|
||||
var chai = require('../../chai');
|
||||
var flag = require('./flag');
|
||||
var proxify = require('./proxify');
|
||||
var transferFlags = require('./transferFlags');
|
||||
|
||||
/*!
|
||||
* Module variables
|
||||
*/
|
||||
|
||||
// Check whether `Object.setPrototypeOf` is supported
|
||||
var canSetPrototype = typeof Object.setPrototypeOf === 'function';
|
||||
|
||||
// Without `Object.setPrototypeOf` support, this module will need to add properties to a function.
|
||||
// However, some of functions' own props are not configurable and should be skipped.
|
||||
var testFn = function() {};
|
||||
var excludeNames = Object.getOwnPropertyNames(testFn).filter(function(name) {
|
||||
var propDesc = Object.getOwnPropertyDescriptor(testFn, name);
|
||||
|
||||
// Note: PhantomJS 1.x includes `callee` as one of `testFn`'s own properties,
|
||||
// but then returns `undefined` as the property descriptor for `callee`. As a
|
||||
// workaround, we perform an otherwise unnecessary type-check for `propDesc`,
|
||||
// and then filter it out if it's not an object as it should be.
|
||||
if (typeof propDesc !== 'object')
|
||||
return true;
|
||||
|
||||
return !propDesc.configurable;
|
||||
});
|
||||
|
||||
// Cache `Function` properties
|
||||
var call = Function.prototype.call,
|
||||
apply = Function.prototype.apply;
|
||||
|
||||
/**
|
||||
* ### .addChainableMethod(ctx, name, method, chainingBehavior)
|
||||
*
|
||||
* Adds a method to an object, such that the method can also be chained.
|
||||
*
|
||||
* utils.addChainableMethod(chai.Assertion.prototype, 'foo', function (str) {
|
||||
* var obj = utils.flag(this, 'object');
|
||||
* new chai.Assertion(obj).to.be.equal(str);
|
||||
* });
|
||||
*
|
||||
* Can also be accessed directly from `chai.Assertion`.
|
||||
*
|
||||
* chai.Assertion.addChainableMethod('foo', fn, chainingBehavior);
|
||||
*
|
||||
* The result can then be used as both a method assertion, executing both `method` and
|
||||
* `chainingBehavior`, or as a language chain, which only executes `chainingBehavior`.
|
||||
*
|
||||
* expect(fooStr).to.be.foo('bar');
|
||||
* expect(fooStr).to.be.foo.equal('foo');
|
||||
*
|
||||
* @param {Object} ctx object to which the method is added
|
||||
* @param {String} name of method to add
|
||||
* @param {Function} method function to be used for `name`, when called
|
||||
* @param {Function} chainingBehavior function to be called every time the property is accessed
|
||||
* @namespace Utils
|
||||
* @name addChainableMethod
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function addChainableMethod(ctx, name, method, chainingBehavior) {
|
||||
if (typeof chainingBehavior !== 'function') {
|
||||
chainingBehavior = function () { };
|
||||
}
|
||||
|
||||
var chainableBehavior = {
|
||||
method: method
|
||||
, chainingBehavior: chainingBehavior
|
||||
};
|
||||
|
||||
// save the methods so we can overwrite them later, if we need to.
|
||||
if (!ctx.__methods) {
|
||||
ctx.__methods = {};
|
||||
}
|
||||
ctx.__methods[name] = chainableBehavior;
|
||||
|
||||
Object.defineProperty(ctx, name,
|
||||
{ get: function chainableMethodGetter() {
|
||||
chainableBehavior.chainingBehavior.call(this);
|
||||
|
||||
var chainableMethodWrapper = function () {
|
||||
// Setting the `ssfi` flag to `chainableMethodWrapper` causes this
|
||||
// function to be the starting point for removing implementation
|
||||
// frames from the stack trace of a failed assertion.
|
||||
//
|
||||
// However, we only want to use this function as the starting point if
|
||||
// the `lockSsfi` flag isn't set.
|
||||
//
|
||||
// If the `lockSsfi` flag is set, then this assertion is being
|
||||
// invoked from inside of another assertion. In this case, the `ssfi`
|
||||
// flag has already been set by the outer assertion.
|
||||
//
|
||||
// Note that overwriting a chainable method merely replaces the saved
|
||||
// methods in `ctx.__methods` instead of completely replacing the
|
||||
// overwritten assertion. Therefore, an overwriting assertion won't
|
||||
// set the `ssfi` or `lockSsfi` flags.
|
||||
if (!flag(this, 'lockSsfi')) {
|
||||
flag(this, 'ssfi', chainableMethodWrapper);
|
||||
}
|
||||
|
||||
var result = chainableBehavior.method.apply(this, arguments);
|
||||
if (result !== undefined) {
|
||||
return result;
|
||||
}
|
||||
|
||||
var newAssertion = new chai.Assertion();
|
||||
transferFlags(this, newAssertion);
|
||||
return newAssertion;
|
||||
};
|
||||
|
||||
addLengthGuard(chainableMethodWrapper, name, true);
|
||||
|
||||
// Use `Object.setPrototypeOf` if available
|
||||
if (canSetPrototype) {
|
||||
// Inherit all properties from the object by replacing the `Function` prototype
|
||||
var prototype = Object.create(this);
|
||||
// Restore the `call` and `apply` methods from `Function`
|
||||
prototype.call = call;
|
||||
prototype.apply = apply;
|
||||
Object.setPrototypeOf(chainableMethodWrapper, prototype);
|
||||
}
|
||||
// Otherwise, redefine all properties (slow!)
|
||||
else {
|
||||
var asserterNames = Object.getOwnPropertyNames(ctx);
|
||||
asserterNames.forEach(function (asserterName) {
|
||||
if (excludeNames.indexOf(asserterName) !== -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
var pd = Object.getOwnPropertyDescriptor(ctx, asserterName);
|
||||
Object.defineProperty(chainableMethodWrapper, asserterName, pd);
|
||||
});
|
||||
}
|
||||
|
||||
transferFlags(this, chainableMethodWrapper);
|
||||
return proxify(chainableMethodWrapper);
|
||||
}
|
||||
, configurable: true
|
||||
});
|
||||
};
|
||||
60
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/addLengthGuard.js
generated
vendored
Normal file
60
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/addLengthGuard.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
var fnLengthDesc = Object.getOwnPropertyDescriptor(function () {}, 'length');
|
||||
|
||||
/*!
|
||||
* Chai - addLengthGuard utility
|
||||
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* ### .addLengthGuard(fn, assertionName, isChainable)
|
||||
*
|
||||
* Define `length` as a getter on the given uninvoked method assertion. The
|
||||
* getter acts as a guard against chaining `length` directly off of an uninvoked
|
||||
* method assertion, which is a problem because it references `function`'s
|
||||
* built-in `length` property instead of Chai's `length` assertion. When the
|
||||
* getter catches the user making this mistake, it throws an error with a
|
||||
* helpful message.
|
||||
*
|
||||
* There are two ways in which this mistake can be made. The first way is by
|
||||
* chaining the `length` assertion directly off of an uninvoked chainable
|
||||
* method. In this case, Chai suggests that the user use `lengthOf` instead. The
|
||||
* second way is by chaining the `length` assertion directly off of an uninvoked
|
||||
* non-chainable method. Non-chainable methods must be invoked prior to
|
||||
* chaining. In this case, Chai suggests that the user consult the docs for the
|
||||
* given assertion.
|
||||
*
|
||||
* If the `length` property of functions is unconfigurable, then return `fn`
|
||||
* without modification.
|
||||
*
|
||||
* Note that in ES6, the function's `length` property is configurable, so once
|
||||
* support for legacy environments is dropped, Chai's `length` property can
|
||||
* replace the built-in function's `length` property, and this length guard will
|
||||
* no longer be necessary. In the mean time, maintaining consistency across all
|
||||
* environments is the priority.
|
||||
*
|
||||
* @param {Function} fn
|
||||
* @param {String} assertionName
|
||||
* @param {Boolean} isChainable
|
||||
* @namespace Utils
|
||||
* @name addLengthGuard
|
||||
*/
|
||||
|
||||
module.exports = function addLengthGuard (fn, assertionName, isChainable) {
|
||||
if (!fnLengthDesc.configurable) return fn;
|
||||
|
||||
Object.defineProperty(fn, 'length', {
|
||||
get: function () {
|
||||
if (isChainable) {
|
||||
throw Error('Invalid Chai property: ' + assertionName + '.length. Due' +
|
||||
' to a compatibility issue, "length" cannot directly follow "' +
|
||||
assertionName + '". Use "' + assertionName + '.lengthOf" instead.');
|
||||
}
|
||||
|
||||
throw Error('Invalid Chai property: ' + assertionName + '.length. See' +
|
||||
' docs for proper usage of "' + assertionName + '".');
|
||||
}
|
||||
});
|
||||
|
||||
return fn;
|
||||
};
|
||||
68
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/addMethod.js
generated
vendored
Normal file
68
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/addMethod.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
/*!
|
||||
* Chai - addMethod utility
|
||||
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
var addLengthGuard = require('./addLengthGuard');
|
||||
var chai = require('../../chai');
|
||||
var flag = require('./flag');
|
||||
var proxify = require('./proxify');
|
||||
var transferFlags = require('./transferFlags');
|
||||
|
||||
/**
|
||||
* ### .addMethod(ctx, name, method)
|
||||
*
|
||||
* Adds a method to the prototype of an object.
|
||||
*
|
||||
* utils.addMethod(chai.Assertion.prototype, 'foo', function (str) {
|
||||
* var obj = utils.flag(this, 'object');
|
||||
* new chai.Assertion(obj).to.be.equal(str);
|
||||
* });
|
||||
*
|
||||
* Can also be accessed directly from `chai.Assertion`.
|
||||
*
|
||||
* chai.Assertion.addMethod('foo', fn);
|
||||
*
|
||||
* Then can be used as any other assertion.
|
||||
*
|
||||
* expect(fooStr).to.be.foo('bar');
|
||||
*
|
||||
* @param {Object} ctx object to which the method is added
|
||||
* @param {String} name of method to add
|
||||
* @param {Function} method function to be used for name
|
||||
* @namespace Utils
|
||||
* @name addMethod
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function addMethod(ctx, name, method) {
|
||||
var methodWrapper = function () {
|
||||
// Setting the `ssfi` flag to `methodWrapper` causes this function to be the
|
||||
// starting point for removing implementation frames from the stack trace of
|
||||
// a failed assertion.
|
||||
//
|
||||
// However, we only want to use this function as the starting point if the
|
||||
// `lockSsfi` flag isn't set.
|
||||
//
|
||||
// If the `lockSsfi` flag is set, then either this assertion has been
|
||||
// overwritten by another assertion, or this assertion is being invoked from
|
||||
// inside of another assertion. In the first case, the `ssfi` flag has
|
||||
// already been set by the overwriting assertion. In the second case, the
|
||||
// `ssfi` flag has already been set by the outer assertion.
|
||||
if (!flag(this, 'lockSsfi')) {
|
||||
flag(this, 'ssfi', methodWrapper);
|
||||
}
|
||||
|
||||
var result = method.apply(this, arguments);
|
||||
if (result !== undefined)
|
||||
return result;
|
||||
|
||||
var newAssertion = new chai.Assertion();
|
||||
transferFlags(this, newAssertion);
|
||||
return newAssertion;
|
||||
};
|
||||
|
||||
addLengthGuard(methodWrapper, name, false);
|
||||
ctx[name] = proxify(methodWrapper, name);
|
||||
};
|
||||
72
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/addProperty.js
generated
vendored
Normal file
72
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/addProperty.js
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
/*!
|
||||
* Chai - addProperty utility
|
||||
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
var chai = require('../../chai');
|
||||
var flag = require('./flag');
|
||||
var isProxyEnabled = require('./isProxyEnabled');
|
||||
var transferFlags = require('./transferFlags');
|
||||
|
||||
/**
|
||||
* ### .addProperty(ctx, name, getter)
|
||||
*
|
||||
* Adds a property to the prototype of an object.
|
||||
*
|
||||
* utils.addProperty(chai.Assertion.prototype, 'foo', function () {
|
||||
* var obj = utils.flag(this, 'object');
|
||||
* new chai.Assertion(obj).to.be.instanceof(Foo);
|
||||
* });
|
||||
*
|
||||
* Can also be accessed directly from `chai.Assertion`.
|
||||
*
|
||||
* chai.Assertion.addProperty('foo', fn);
|
||||
*
|
||||
* Then can be used as any other assertion.
|
||||
*
|
||||
* expect(myFoo).to.be.foo;
|
||||
*
|
||||
* @param {Object} ctx object to which the property is added
|
||||
* @param {String} name of property to add
|
||||
* @param {Function} getter function to be used for name
|
||||
* @namespace Utils
|
||||
* @name addProperty
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function addProperty(ctx, name, getter) {
|
||||
getter = getter === undefined ? function () {} : getter;
|
||||
|
||||
Object.defineProperty(ctx, name,
|
||||
{ get: function propertyGetter() {
|
||||
// Setting the `ssfi` flag to `propertyGetter` causes this function to
|
||||
// be the starting point for removing implementation frames from the
|
||||
// stack trace of a failed assertion.
|
||||
//
|
||||
// However, we only want to use this function as the starting point if
|
||||
// the `lockSsfi` flag isn't set and proxy protection is disabled.
|
||||
//
|
||||
// If the `lockSsfi` flag is set, then either this assertion has been
|
||||
// overwritten by another assertion, or this assertion is being invoked
|
||||
// from inside of another assertion. In the first case, the `ssfi` flag
|
||||
// has already been set by the overwriting assertion. In the second
|
||||
// case, the `ssfi` flag has already been set by the outer assertion.
|
||||
//
|
||||
// If proxy protection is enabled, then the `ssfi` flag has already been
|
||||
// set by the proxy getter.
|
||||
if (!isProxyEnabled() && !flag(this, 'lockSsfi')) {
|
||||
flag(this, 'ssfi', propertyGetter);
|
||||
}
|
||||
|
||||
var result = getter.call(this);
|
||||
if (result !== undefined)
|
||||
return result;
|
||||
|
||||
var newAssertion = new chai.Assertion();
|
||||
transferFlags(this, newAssertion);
|
||||
return newAssertion;
|
||||
}
|
||||
, configurable: true
|
||||
});
|
||||
};
|
||||
31
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/compareByInspect.js
generated
vendored
Normal file
31
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/compareByInspect.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
/*!
|
||||
* Chai - compareByInspect utility
|
||||
* Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Module dependencies
|
||||
*/
|
||||
|
||||
var inspect = require('./inspect');
|
||||
|
||||
/**
|
||||
* ### .compareByInspect(mixed, mixed)
|
||||
*
|
||||
* To be used as a compareFunction with Array.prototype.sort. Compares elements
|
||||
* using inspect instead of default behavior of using toString so that Symbols
|
||||
* and objects with irregular/missing toString can still be sorted without a
|
||||
* TypeError.
|
||||
*
|
||||
* @param {Mixed} first element to compare
|
||||
* @param {Mixed} second element to compare
|
||||
* @returns {Number} -1 if 'a' should come before 'b'; otherwise 1
|
||||
* @name compareByInspect
|
||||
* @namespace Utils
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function compareByInspect(a, b) {
|
||||
return inspect(a) < inspect(b) ? -1 : 1;
|
||||
};
|
||||
51
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/expectTypes.js
generated
vendored
Normal file
51
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/expectTypes.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
/*!
|
||||
* Chai - expectTypes utility
|
||||
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* ### .expectTypes(obj, types)
|
||||
*
|
||||
* Ensures that the object being tested against is of a valid type.
|
||||
*
|
||||
* utils.expectTypes(this, ['array', 'object', 'string']);
|
||||
*
|
||||
* @param {Mixed} obj constructed Assertion
|
||||
* @param {Array} type A list of allowed types for this assertion
|
||||
* @namespace Utils
|
||||
* @name expectTypes
|
||||
* @api public
|
||||
*/
|
||||
|
||||
var AssertionError = require('assertion-error');
|
||||
var flag = require('./flag');
|
||||
var type = require('type-detect');
|
||||
|
||||
module.exports = function expectTypes(obj, types) {
|
||||
var flagMsg = flag(obj, 'message');
|
||||
var ssfi = flag(obj, 'ssfi');
|
||||
|
||||
flagMsg = flagMsg ? flagMsg + ': ' : '';
|
||||
|
||||
obj = flag(obj, 'object');
|
||||
types = types.map(function (t) { return t.toLowerCase(); });
|
||||
types.sort();
|
||||
|
||||
// Transforms ['lorem', 'ipsum'] into 'a lorem, or an ipsum'
|
||||
var str = types.map(function (t, index) {
|
||||
var art = ~[ 'a', 'e', 'i', 'o', 'u' ].indexOf(t.charAt(0)) ? 'an' : 'a';
|
||||
var or = types.length > 1 && index === types.length - 1 ? 'or ' : '';
|
||||
return or + art + ' ' + t;
|
||||
}).join(', ');
|
||||
|
||||
var objType = type(obj).toLowerCase();
|
||||
|
||||
if (!types.some(function (expected) { return objType === expected; })) {
|
||||
throw new AssertionError(
|
||||
flagMsg + 'object tested must be ' + str + ', but ' + objType + ' given',
|
||||
undefined,
|
||||
ssfi
|
||||
);
|
||||
}
|
||||
};
|
||||
33
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/flag.js
generated
vendored
Normal file
33
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/flag.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/*!
|
||||
* Chai - flag utility
|
||||
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* ### .flag(object, key, [value])
|
||||
*
|
||||
* Get or set a flag value on an object. If a
|
||||
* value is provided it will be set, else it will
|
||||
* return the currently set value or `undefined` if
|
||||
* the value is not set.
|
||||
*
|
||||
* utils.flag(this, 'foo', 'bar'); // setter
|
||||
* utils.flag(this, 'foo'); // getter, returns `bar`
|
||||
*
|
||||
* @param {Object} object constructed Assertion
|
||||
* @param {String} key
|
||||
* @param {Mixed} value (optional)
|
||||
* @namespace Utils
|
||||
* @name flag
|
||||
* @api private
|
||||
*/
|
||||
|
||||
module.exports = function flag(obj, key, value) {
|
||||
var flags = obj.__flags || (obj.__flags = Object.create(null));
|
||||
if (arguments.length === 3) {
|
||||
flags[key] = value;
|
||||
} else {
|
||||
return flags[key];
|
||||
}
|
||||
};
|
||||
20
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/getActual.js
generated
vendored
Normal file
20
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/getActual.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
/*!
|
||||
* Chai - getActual utility
|
||||
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* ### .getActual(object, [actual])
|
||||
*
|
||||
* Returns the `actual` value for an Assertion.
|
||||
*
|
||||
* @param {Object} object (constructed Assertion)
|
||||
* @param {Arguments} chai.Assertion.prototype.assert arguments
|
||||
* @namespace Utils
|
||||
* @name getActual
|
||||
*/
|
||||
|
||||
module.exports = function getActual(obj, args) {
|
||||
return args.length > 4 ? args[4] : obj._obj;
|
||||
};
|
||||
26
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/getEnumerableProperties.js
generated
vendored
Normal file
26
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/getEnumerableProperties.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
/*!
|
||||
* Chai - getEnumerableProperties utility
|
||||
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* ### .getEnumerableProperties(object)
|
||||
*
|
||||
* This allows the retrieval of enumerable property names of an object,
|
||||
* inherited or not.
|
||||
*
|
||||
* @param {Object} object
|
||||
* @returns {Array}
|
||||
* @namespace Utils
|
||||
* @name getEnumerableProperties
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function getEnumerableProperties(object) {
|
||||
var result = [];
|
||||
for (var name in object) {
|
||||
result.push(name);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
50
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/getMessage.js
generated
vendored
Normal file
50
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/getMessage.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
/*!
|
||||
* Chai - message composition utility
|
||||
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Module dependencies
|
||||
*/
|
||||
|
||||
var flag = require('./flag')
|
||||
, getActual = require('./getActual')
|
||||
, objDisplay = require('./objDisplay');
|
||||
|
||||
/**
|
||||
* ### .getMessage(object, message, negateMessage)
|
||||
*
|
||||
* Construct the error message based on flags
|
||||
* and template tags. Template tags will return
|
||||
* a stringified inspection of the object referenced.
|
||||
*
|
||||
* Message template tags:
|
||||
* - `#{this}` current asserted object
|
||||
* - `#{act}` actual value
|
||||
* - `#{exp}` expected value
|
||||
*
|
||||
* @param {Object} object (constructed Assertion)
|
||||
* @param {Arguments} chai.Assertion.prototype.assert arguments
|
||||
* @namespace Utils
|
||||
* @name getMessage
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function getMessage(obj, args) {
|
||||
var negate = flag(obj, 'negate')
|
||||
, val = flag(obj, 'object')
|
||||
, expected = args[3]
|
||||
, actual = getActual(obj, args)
|
||||
, msg = negate ? args[2] : args[1]
|
||||
, flagMsg = flag(obj, 'message');
|
||||
|
||||
if(typeof msg === "function") msg = msg();
|
||||
msg = msg || '';
|
||||
msg = msg
|
||||
.replace(/#\{this\}/g, function () { return objDisplay(val); })
|
||||
.replace(/#\{act\}/g, function () { return objDisplay(actual); })
|
||||
.replace(/#\{exp\}/g, function () { return objDisplay(expected); });
|
||||
|
||||
return flagMsg ? flagMsg + ': ' + msg : msg;
|
||||
};
|
||||
55
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/getOperator.js
generated
vendored
Normal file
55
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/getOperator.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
var type = require('type-detect');
|
||||
|
||||
var flag = require('./flag');
|
||||
|
||||
function isObjectType(obj) {
|
||||
var objectType = type(obj);
|
||||
var objectTypes = ['Array', 'Object', 'function'];
|
||||
|
||||
return objectTypes.indexOf(objectType) !== -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* ### .getOperator(message)
|
||||
*
|
||||
* Extract the operator from error message.
|
||||
* Operator defined is based on below link
|
||||
* https://nodejs.org/api/assert.html#assert_assert.
|
||||
*
|
||||
* Returns the `operator` or `undefined` value for an Assertion.
|
||||
*
|
||||
* @param {Object} object (constructed Assertion)
|
||||
* @param {Arguments} chai.Assertion.prototype.assert arguments
|
||||
* @namespace Utils
|
||||
* @name getOperator
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function getOperator(obj, args) {
|
||||
var operator = flag(obj, 'operator');
|
||||
var negate = flag(obj, 'negate');
|
||||
var expected = args[3];
|
||||
var msg = negate ? args[2] : args[1];
|
||||
|
||||
if (operator) {
|
||||
return operator;
|
||||
}
|
||||
|
||||
if (typeof msg === 'function') msg = msg();
|
||||
|
||||
msg = msg || '';
|
||||
if (!msg) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (/\shave\s/.test(msg)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var isObject = isObjectType(expected);
|
||||
if (/\snot\s/.test(msg)) {
|
||||
return isObject ? 'notDeepStrictEqual' : 'notStrictEqual';
|
||||
}
|
||||
|
||||
return isObject ? 'deepStrictEqual' : 'strictEqual';
|
||||
};
|
||||
29
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/getOwnEnumerableProperties.js
generated
vendored
Normal file
29
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/getOwnEnumerableProperties.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
/*!
|
||||
* Chai - getOwnEnumerableProperties utility
|
||||
* Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Module dependencies
|
||||
*/
|
||||
|
||||
var getOwnEnumerablePropertySymbols = require('./getOwnEnumerablePropertySymbols');
|
||||
|
||||
/**
|
||||
* ### .getOwnEnumerableProperties(object)
|
||||
*
|
||||
* This allows the retrieval of directly-owned enumerable property names and
|
||||
* symbols of an object. This function is necessary because Object.keys only
|
||||
* returns enumerable property names, not enumerable property symbols.
|
||||
*
|
||||
* @param {Object} object
|
||||
* @returns {Array}
|
||||
* @namespace Utils
|
||||
* @name getOwnEnumerableProperties
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function getOwnEnumerableProperties(obj) {
|
||||
return Object.keys(obj).concat(getOwnEnumerablePropertySymbols(obj));
|
||||
};
|
||||
27
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/getOwnEnumerablePropertySymbols.js
generated
vendored
Normal file
27
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/getOwnEnumerablePropertySymbols.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
/*!
|
||||
* Chai - getOwnEnumerablePropertySymbols utility
|
||||
* Copyright(c) 2011-2016 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* ### .getOwnEnumerablePropertySymbols(object)
|
||||
*
|
||||
* This allows the retrieval of directly-owned enumerable property symbols of an
|
||||
* object. This function is necessary because Object.getOwnPropertySymbols
|
||||
* returns both enumerable and non-enumerable property symbols.
|
||||
*
|
||||
* @param {Object} object
|
||||
* @returns {Array}
|
||||
* @namespace Utils
|
||||
* @name getOwnEnumerablePropertySymbols
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function getOwnEnumerablePropertySymbols(obj) {
|
||||
if (typeof Object.getOwnPropertySymbols !== 'function') return [];
|
||||
|
||||
return Object.getOwnPropertySymbols(obj).filter(function (sym) {
|
||||
return Object.getOwnPropertyDescriptor(obj, sym).enumerable;
|
||||
});
|
||||
};
|
||||
36
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/getProperties.js
generated
vendored
Normal file
36
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/getProperties.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
/*!
|
||||
* Chai - getProperties utility
|
||||
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* ### .getProperties(object)
|
||||
*
|
||||
* This allows the retrieval of property names of an object, enumerable or not,
|
||||
* inherited or not.
|
||||
*
|
||||
* @param {Object} object
|
||||
* @returns {Array}
|
||||
* @namespace Utils
|
||||
* @name getProperties
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function getProperties(object) {
|
||||
var result = Object.getOwnPropertyNames(object);
|
||||
|
||||
function addProperty(property) {
|
||||
if (result.indexOf(property) === -1) {
|
||||
result.push(property);
|
||||
}
|
||||
}
|
||||
|
||||
var proto = Object.getPrototypeOf(object);
|
||||
while (proto !== null) {
|
||||
Object.getOwnPropertyNames(proto).forEach(addProperty);
|
||||
proto = Object.getPrototypeOf(proto);
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
178
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/index.js
generated
vendored
Normal file
178
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/index.js
generated
vendored
Normal file
@@ -0,0 +1,178 @@
|
||||
/*!
|
||||
* chai
|
||||
* Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Dependencies that are used for multiple exports are required here only once
|
||||
*/
|
||||
|
||||
var pathval = require('pathval');
|
||||
|
||||
/*!
|
||||
* test utility
|
||||
*/
|
||||
|
||||
exports.test = require('./test');
|
||||
|
||||
/*!
|
||||
* type utility
|
||||
*/
|
||||
|
||||
exports.type = require('type-detect');
|
||||
|
||||
/*!
|
||||
* expectTypes utility
|
||||
*/
|
||||
exports.expectTypes = require('./expectTypes');
|
||||
|
||||
/*!
|
||||
* message utility
|
||||
*/
|
||||
|
||||
exports.getMessage = require('./getMessage');
|
||||
|
||||
/*!
|
||||
* actual utility
|
||||
*/
|
||||
|
||||
exports.getActual = require('./getActual');
|
||||
|
||||
/*!
|
||||
* Inspect util
|
||||
*/
|
||||
|
||||
exports.inspect = require('./inspect');
|
||||
|
||||
/*!
|
||||
* Object Display util
|
||||
*/
|
||||
|
||||
exports.objDisplay = require('./objDisplay');
|
||||
|
||||
/*!
|
||||
* Flag utility
|
||||
*/
|
||||
|
||||
exports.flag = require('./flag');
|
||||
|
||||
/*!
|
||||
* Flag transferring utility
|
||||
*/
|
||||
|
||||
exports.transferFlags = require('./transferFlags');
|
||||
|
||||
/*!
|
||||
* Deep equal utility
|
||||
*/
|
||||
|
||||
exports.eql = require('deep-eql');
|
||||
|
||||
/*!
|
||||
* Deep path info
|
||||
*/
|
||||
|
||||
exports.getPathInfo = pathval.getPathInfo;
|
||||
|
||||
/*!
|
||||
* Check if a property exists
|
||||
*/
|
||||
|
||||
exports.hasProperty = pathval.hasProperty;
|
||||
|
||||
/*!
|
||||
* Function name
|
||||
*/
|
||||
|
||||
exports.getName = require('get-func-name');
|
||||
|
||||
/*!
|
||||
* add Property
|
||||
*/
|
||||
|
||||
exports.addProperty = require('./addProperty');
|
||||
|
||||
/*!
|
||||
* add Method
|
||||
*/
|
||||
|
||||
exports.addMethod = require('./addMethod');
|
||||
|
||||
/*!
|
||||
* overwrite Property
|
||||
*/
|
||||
|
||||
exports.overwriteProperty = require('./overwriteProperty');
|
||||
|
||||
/*!
|
||||
* overwrite Method
|
||||
*/
|
||||
|
||||
exports.overwriteMethod = require('./overwriteMethod');
|
||||
|
||||
/*!
|
||||
* Add a chainable method
|
||||
*/
|
||||
|
||||
exports.addChainableMethod = require('./addChainableMethod');
|
||||
|
||||
/*!
|
||||
* Overwrite chainable method
|
||||
*/
|
||||
|
||||
exports.overwriteChainableMethod = require('./overwriteChainableMethod');
|
||||
|
||||
/*!
|
||||
* Compare by inspect method
|
||||
*/
|
||||
|
||||
exports.compareByInspect = require('./compareByInspect');
|
||||
|
||||
/*!
|
||||
* Get own enumerable property symbols method
|
||||
*/
|
||||
|
||||
exports.getOwnEnumerablePropertySymbols = require('./getOwnEnumerablePropertySymbols');
|
||||
|
||||
/*!
|
||||
* Get own enumerable properties method
|
||||
*/
|
||||
|
||||
exports.getOwnEnumerableProperties = require('./getOwnEnumerableProperties');
|
||||
|
||||
/*!
|
||||
* Checks error against a given set of criteria
|
||||
*/
|
||||
|
||||
exports.checkError = require('check-error');
|
||||
|
||||
/*!
|
||||
* Proxify util
|
||||
*/
|
||||
|
||||
exports.proxify = require('./proxify');
|
||||
|
||||
/*!
|
||||
* addLengthGuard util
|
||||
*/
|
||||
|
||||
exports.addLengthGuard = require('./addLengthGuard');
|
||||
|
||||
/*!
|
||||
* isProxyEnabled helper
|
||||
*/
|
||||
|
||||
exports.isProxyEnabled = require('./isProxyEnabled');
|
||||
|
||||
/*!
|
||||
* isNaN method
|
||||
*/
|
||||
|
||||
exports.isNaN = require('./isNaN');
|
||||
|
||||
/*!
|
||||
* getOperator method
|
||||
*/
|
||||
|
||||
exports.getOperator = require('./getOperator');
|
||||
33
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/inspect.js
generated
vendored
Normal file
33
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/inspect.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
// This is (almost) directly from Node.js utils
|
||||
// https://github.com/joyent/node/blob/f8c335d0caf47f16d31413f89aa28eda3878e3aa/lib/util.js
|
||||
|
||||
var getName = require('get-func-name');
|
||||
var loupe = require('loupe');
|
||||
var config = require('../config');
|
||||
|
||||
module.exports = inspect;
|
||||
|
||||
/**
|
||||
* ### .inspect(obj, [showHidden], [depth], [colors])
|
||||
*
|
||||
* Echoes the value of a value. Tries to print the value out
|
||||
* in the best way possible given the different types.
|
||||
*
|
||||
* @param {Object} obj The object to print out.
|
||||
* @param {Boolean} showHidden Flag that shows hidden (not enumerable)
|
||||
* properties of objects. Default is false.
|
||||
* @param {Number} depth Depth in which to descend in object. Default is 2.
|
||||
* @param {Boolean} colors Flag to turn on ANSI escape codes to color the
|
||||
* output. Default is false (no coloring).
|
||||
* @namespace Utils
|
||||
* @name inspect
|
||||
*/
|
||||
function inspect(obj, showHidden, depth, colors) {
|
||||
var options = {
|
||||
colors: colors,
|
||||
depth: (typeof depth === 'undefined' ? 2 : depth),
|
||||
showHidden: showHidden,
|
||||
truncate: config.truncateThreshold ? config.truncateThreshold : Infinity,
|
||||
};
|
||||
return loupe.inspect(obj, options);
|
||||
}
|
||||
26
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/isNaN.js
generated
vendored
Normal file
26
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/isNaN.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
/*!
|
||||
* Chai - isNaN utility
|
||||
* Copyright(c) 2012-2015 Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* ### .isNaN(value)
|
||||
*
|
||||
* Checks if the given value is NaN or not.
|
||||
*
|
||||
* utils.isNaN(NaN); // true
|
||||
*
|
||||
* @param {Value} The value which has to be checked if it is NaN
|
||||
* @name isNaN
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function isNaN(value) {
|
||||
// Refer http://www.ecma-international.org/ecma-262/6.0/#sec-isnan-number
|
||||
// section's NOTE.
|
||||
return value !== value;
|
||||
}
|
||||
|
||||
// If ECMAScript 6's Number.isNaN is present, prefer that.
|
||||
module.exports = Number.isNaN || isNaN;
|
||||
24
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/isProxyEnabled.js
generated
vendored
Normal file
24
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/isProxyEnabled.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
var config = require('../config');
|
||||
|
||||
/*!
|
||||
* Chai - isProxyEnabled helper
|
||||
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* ### .isProxyEnabled()
|
||||
*
|
||||
* Helper function to check if Chai's proxy protection feature is enabled. If
|
||||
* proxies are unsupported or disabled via the user's Chai config, then return
|
||||
* false. Otherwise, return true.
|
||||
*
|
||||
* @namespace Utils
|
||||
* @name isProxyEnabled
|
||||
*/
|
||||
|
||||
module.exports = function isProxyEnabled() {
|
||||
return config.useProxy &&
|
||||
typeof Proxy !== 'undefined' &&
|
||||
typeof Reflect !== 'undefined';
|
||||
};
|
||||
51
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/objDisplay.js
generated
vendored
Normal file
51
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/objDisplay.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
/*!
|
||||
* Chai - flag utility
|
||||
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Module dependencies
|
||||
*/
|
||||
|
||||
var inspect = require('./inspect');
|
||||
var config = require('../config');
|
||||
|
||||
/**
|
||||
* ### .objDisplay(object)
|
||||
*
|
||||
* Determines if an object or an array matches
|
||||
* criteria to be inspected in-line for error
|
||||
* messages or should be truncated.
|
||||
*
|
||||
* @param {Mixed} javascript object to inspect
|
||||
* @returns {string} stringified object
|
||||
* @name objDisplay
|
||||
* @namespace Utils
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function objDisplay(obj) {
|
||||
var str = inspect(obj)
|
||||
, type = Object.prototype.toString.call(obj);
|
||||
|
||||
if (config.truncateThreshold && str.length >= config.truncateThreshold) {
|
||||
if (type === '[object Function]') {
|
||||
return !obj.name || obj.name === ''
|
||||
? '[Function]'
|
||||
: '[Function: ' + obj.name + ']';
|
||||
} else if (type === '[object Array]') {
|
||||
return '[ Array(' + obj.length + ') ]';
|
||||
} else if (type === '[object Object]') {
|
||||
var keys = Object.keys(obj)
|
||||
, kstr = keys.length > 2
|
||||
? keys.splice(0, 2).join(', ') + ', ...'
|
||||
: keys.join(', ');
|
||||
return '{ Object (' + kstr + ') }';
|
||||
} else {
|
||||
return str;
|
||||
}
|
||||
} else {
|
||||
return str;
|
||||
}
|
||||
};
|
||||
69
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/overwriteChainableMethod.js
generated
vendored
Normal file
69
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/overwriteChainableMethod.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
/*!
|
||||
* Chai - overwriteChainableMethod utility
|
||||
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
var chai = require('../../chai');
|
||||
var transferFlags = require('./transferFlags');
|
||||
|
||||
/**
|
||||
* ### .overwriteChainableMethod(ctx, name, method, chainingBehavior)
|
||||
*
|
||||
* Overwrites an already existing chainable method
|
||||
* and provides access to the previous function or
|
||||
* property. Must return functions to be used for
|
||||
* name.
|
||||
*
|
||||
* utils.overwriteChainableMethod(chai.Assertion.prototype, 'lengthOf',
|
||||
* function (_super) {
|
||||
* }
|
||||
* , function (_super) {
|
||||
* }
|
||||
* );
|
||||
*
|
||||
* Can also be accessed directly from `chai.Assertion`.
|
||||
*
|
||||
* chai.Assertion.overwriteChainableMethod('foo', fn, fn);
|
||||
*
|
||||
* Then can be used as any other assertion.
|
||||
*
|
||||
* expect(myFoo).to.have.lengthOf(3);
|
||||
* expect(myFoo).to.have.lengthOf.above(3);
|
||||
*
|
||||
* @param {Object} ctx object whose method / property is to be overwritten
|
||||
* @param {String} name of method / property to overwrite
|
||||
* @param {Function} method function that returns a function to be used for name
|
||||
* @param {Function} chainingBehavior function that returns a function to be used for property
|
||||
* @namespace Utils
|
||||
* @name overwriteChainableMethod
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function overwriteChainableMethod(ctx, name, method, chainingBehavior) {
|
||||
var chainableBehavior = ctx.__methods[name];
|
||||
|
||||
var _chainingBehavior = chainableBehavior.chainingBehavior;
|
||||
chainableBehavior.chainingBehavior = function overwritingChainableMethodGetter() {
|
||||
var result = chainingBehavior(_chainingBehavior).call(this);
|
||||
if (result !== undefined) {
|
||||
return result;
|
||||
}
|
||||
|
||||
var newAssertion = new chai.Assertion();
|
||||
transferFlags(this, newAssertion);
|
||||
return newAssertion;
|
||||
};
|
||||
|
||||
var _method = chainableBehavior.method;
|
||||
chainableBehavior.method = function overwritingChainableMethodWrapper() {
|
||||
var result = method(_method).apply(this, arguments);
|
||||
if (result !== undefined) {
|
||||
return result;
|
||||
}
|
||||
|
||||
var newAssertion = new chai.Assertion();
|
||||
transferFlags(this, newAssertion);
|
||||
return newAssertion;
|
||||
};
|
||||
};
|
||||
92
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/overwriteMethod.js
generated
vendored
Normal file
92
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/overwriteMethod.js
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
/*!
|
||||
* Chai - overwriteMethod utility
|
||||
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
var addLengthGuard = require('./addLengthGuard');
|
||||
var chai = require('../../chai');
|
||||
var flag = require('./flag');
|
||||
var proxify = require('./proxify');
|
||||
var transferFlags = require('./transferFlags');
|
||||
|
||||
/**
|
||||
* ### .overwriteMethod(ctx, name, fn)
|
||||
*
|
||||
* Overwrites an already existing method and provides
|
||||
* access to previous function. Must return function
|
||||
* to be used for name.
|
||||
*
|
||||
* utils.overwriteMethod(chai.Assertion.prototype, 'equal', function (_super) {
|
||||
* return function (str) {
|
||||
* var obj = utils.flag(this, 'object');
|
||||
* if (obj instanceof Foo) {
|
||||
* new chai.Assertion(obj.value).to.equal(str);
|
||||
* } else {
|
||||
* _super.apply(this, arguments);
|
||||
* }
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* Can also be accessed directly from `chai.Assertion`.
|
||||
*
|
||||
* chai.Assertion.overwriteMethod('foo', fn);
|
||||
*
|
||||
* Then can be used as any other assertion.
|
||||
*
|
||||
* expect(myFoo).to.equal('bar');
|
||||
*
|
||||
* @param {Object} ctx object whose method is to be overwritten
|
||||
* @param {String} name of method to overwrite
|
||||
* @param {Function} method function that returns a function to be used for name
|
||||
* @namespace Utils
|
||||
* @name overwriteMethod
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function overwriteMethod(ctx, name, method) {
|
||||
var _method = ctx[name]
|
||||
, _super = function () {
|
||||
throw new Error(name + ' is not a function');
|
||||
};
|
||||
|
||||
if (_method && 'function' === typeof _method)
|
||||
_super = _method;
|
||||
|
||||
var overwritingMethodWrapper = function () {
|
||||
// Setting the `ssfi` flag to `overwritingMethodWrapper` causes this
|
||||
// function to be the starting point for removing implementation frames from
|
||||
// the stack trace of a failed assertion.
|
||||
//
|
||||
// However, we only want to use this function as the starting point if the
|
||||
// `lockSsfi` flag isn't set.
|
||||
//
|
||||
// If the `lockSsfi` flag is set, then either this assertion has been
|
||||
// overwritten by another assertion, or this assertion is being invoked from
|
||||
// inside of another assertion. In the first case, the `ssfi` flag has
|
||||
// already been set by the overwriting assertion. In the second case, the
|
||||
// `ssfi` flag has already been set by the outer assertion.
|
||||
if (!flag(this, 'lockSsfi')) {
|
||||
flag(this, 'ssfi', overwritingMethodWrapper);
|
||||
}
|
||||
|
||||
// Setting the `lockSsfi` flag to `true` prevents the overwritten assertion
|
||||
// from changing the `ssfi` flag. By this point, the `ssfi` flag is already
|
||||
// set to the correct starting point for this assertion.
|
||||
var origLockSsfi = flag(this, 'lockSsfi');
|
||||
flag(this, 'lockSsfi', true);
|
||||
var result = method(_super).apply(this, arguments);
|
||||
flag(this, 'lockSsfi', origLockSsfi);
|
||||
|
||||
if (result !== undefined) {
|
||||
return result;
|
||||
}
|
||||
|
||||
var newAssertion = new chai.Assertion();
|
||||
transferFlags(this, newAssertion);
|
||||
return newAssertion;
|
||||
}
|
||||
|
||||
addLengthGuard(overwritingMethodWrapper, name, false);
|
||||
ctx[name] = proxify(overwritingMethodWrapper, name);
|
||||
};
|
||||
92
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/overwriteProperty.js
generated
vendored
Normal file
92
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/overwriteProperty.js
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
/*!
|
||||
* Chai - overwriteProperty utility
|
||||
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
var chai = require('../../chai');
|
||||
var flag = require('./flag');
|
||||
var isProxyEnabled = require('./isProxyEnabled');
|
||||
var transferFlags = require('./transferFlags');
|
||||
|
||||
/**
|
||||
* ### .overwriteProperty(ctx, name, fn)
|
||||
*
|
||||
* Overwrites an already existing property getter and provides
|
||||
* access to previous value. Must return function to use as getter.
|
||||
*
|
||||
* utils.overwriteProperty(chai.Assertion.prototype, 'ok', function (_super) {
|
||||
* return function () {
|
||||
* var obj = utils.flag(this, 'object');
|
||||
* if (obj instanceof Foo) {
|
||||
* new chai.Assertion(obj.name).to.equal('bar');
|
||||
* } else {
|
||||
* _super.call(this);
|
||||
* }
|
||||
* }
|
||||
* });
|
||||
*
|
||||
*
|
||||
* Can also be accessed directly from `chai.Assertion`.
|
||||
*
|
||||
* chai.Assertion.overwriteProperty('foo', fn);
|
||||
*
|
||||
* Then can be used as any other assertion.
|
||||
*
|
||||
* expect(myFoo).to.be.ok;
|
||||
*
|
||||
* @param {Object} ctx object whose property is to be overwritten
|
||||
* @param {String} name of property to overwrite
|
||||
* @param {Function} getter function that returns a getter function to be used for name
|
||||
* @namespace Utils
|
||||
* @name overwriteProperty
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function overwriteProperty(ctx, name, getter) {
|
||||
var _get = Object.getOwnPropertyDescriptor(ctx, name)
|
||||
, _super = function () {};
|
||||
|
||||
if (_get && 'function' === typeof _get.get)
|
||||
_super = _get.get
|
||||
|
||||
Object.defineProperty(ctx, name,
|
||||
{ get: function overwritingPropertyGetter() {
|
||||
// Setting the `ssfi` flag to `overwritingPropertyGetter` causes this
|
||||
// function to be the starting point for removing implementation frames
|
||||
// from the stack trace of a failed assertion.
|
||||
//
|
||||
// However, we only want to use this function as the starting point if
|
||||
// the `lockSsfi` flag isn't set and proxy protection is disabled.
|
||||
//
|
||||
// If the `lockSsfi` flag is set, then either this assertion has been
|
||||
// overwritten by another assertion, or this assertion is being invoked
|
||||
// from inside of another assertion. In the first case, the `ssfi` flag
|
||||
// has already been set by the overwriting assertion. In the second
|
||||
// case, the `ssfi` flag has already been set by the outer assertion.
|
||||
//
|
||||
// If proxy protection is enabled, then the `ssfi` flag has already been
|
||||
// set by the proxy getter.
|
||||
if (!isProxyEnabled() && !flag(this, 'lockSsfi')) {
|
||||
flag(this, 'ssfi', overwritingPropertyGetter);
|
||||
}
|
||||
|
||||
// Setting the `lockSsfi` flag to `true` prevents the overwritten
|
||||
// assertion from changing the `ssfi` flag. By this point, the `ssfi`
|
||||
// flag is already set to the correct starting point for this assertion.
|
||||
var origLockSsfi = flag(this, 'lockSsfi');
|
||||
flag(this, 'lockSsfi', true);
|
||||
var result = getter(_super).call(this);
|
||||
flag(this, 'lockSsfi', origLockSsfi);
|
||||
|
||||
if (result !== undefined) {
|
||||
return result;
|
||||
}
|
||||
|
||||
var newAssertion = new chai.Assertion();
|
||||
transferFlags(this, newAssertion);
|
||||
return newAssertion;
|
||||
}
|
||||
, configurable: true
|
||||
});
|
||||
};
|
||||
147
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/proxify.js
generated
vendored
Normal file
147
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/proxify.js
generated
vendored
Normal file
@@ -0,0 +1,147 @@
|
||||
var config = require('../config');
|
||||
var flag = require('./flag');
|
||||
var getProperties = require('./getProperties');
|
||||
var isProxyEnabled = require('./isProxyEnabled');
|
||||
|
||||
/*!
|
||||
* Chai - proxify utility
|
||||
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* ### .proxify(object)
|
||||
*
|
||||
* Return a proxy of given object that throws an error when a non-existent
|
||||
* property is read. By default, the root cause is assumed to be a misspelled
|
||||
* property, and thus an attempt is made to offer a reasonable suggestion from
|
||||
* the list of existing properties. However, if a nonChainableMethodName is
|
||||
* provided, then the root cause is instead a failure to invoke a non-chainable
|
||||
* method prior to reading the non-existent property.
|
||||
*
|
||||
* If proxies are unsupported or disabled via the user's Chai config, then
|
||||
* return object without modification.
|
||||
*
|
||||
* @param {Object} obj
|
||||
* @param {String} nonChainableMethodName
|
||||
* @namespace Utils
|
||||
* @name proxify
|
||||
*/
|
||||
|
||||
var builtins = ['__flags', '__methods', '_obj', 'assert'];
|
||||
|
||||
module.exports = function proxify(obj, nonChainableMethodName) {
|
||||
if (!isProxyEnabled()) return obj;
|
||||
|
||||
return new Proxy(obj, {
|
||||
get: function proxyGetter(target, property) {
|
||||
// This check is here because we should not throw errors on Symbol properties
|
||||
// such as `Symbol.toStringTag`.
|
||||
// The values for which an error should be thrown can be configured using
|
||||
// the `config.proxyExcludedKeys` setting.
|
||||
if (typeof property === 'string' &&
|
||||
config.proxyExcludedKeys.indexOf(property) === -1 &&
|
||||
!Reflect.has(target, property)) {
|
||||
// Special message for invalid property access of non-chainable methods.
|
||||
if (nonChainableMethodName) {
|
||||
throw Error('Invalid Chai property: ' + nonChainableMethodName + '.' +
|
||||
property + '. See docs for proper usage of "' +
|
||||
nonChainableMethodName + '".');
|
||||
}
|
||||
|
||||
// If the property is reasonably close to an existing Chai property,
|
||||
// suggest that property to the user. Only suggest properties with a
|
||||
// distance less than 4.
|
||||
var suggestion = null;
|
||||
var suggestionDistance = 4;
|
||||
getProperties(target).forEach(function(prop) {
|
||||
if (
|
||||
!Object.prototype.hasOwnProperty(prop) &&
|
||||
builtins.indexOf(prop) === -1
|
||||
) {
|
||||
var dist = stringDistanceCapped(
|
||||
property,
|
||||
prop,
|
||||
suggestionDistance
|
||||
);
|
||||
if (dist < suggestionDistance) {
|
||||
suggestion = prop;
|
||||
suggestionDistance = dist;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (suggestion !== null) {
|
||||
throw Error('Invalid Chai property: ' + property +
|
||||
'. Did you mean "' + suggestion + '"?');
|
||||
} else {
|
||||
throw Error('Invalid Chai property: ' + property);
|
||||
}
|
||||
}
|
||||
|
||||
// Use this proxy getter as the starting point for removing implementation
|
||||
// frames from the stack trace of a failed assertion. For property
|
||||
// assertions, this prevents the proxy getter from showing up in the stack
|
||||
// trace since it's invoked before the property getter. For method and
|
||||
// chainable method assertions, this flag will end up getting changed to
|
||||
// the method wrapper, which is good since this frame will no longer be in
|
||||
// the stack once the method is invoked. Note that Chai builtin assertion
|
||||
// properties such as `__flags` are skipped since this is only meant to
|
||||
// capture the starting point of an assertion. This step is also skipped
|
||||
// if the `lockSsfi` flag is set, thus indicating that this assertion is
|
||||
// being called from within another assertion. In that case, the `ssfi`
|
||||
// flag is already set to the outer assertion's starting point.
|
||||
if (builtins.indexOf(property) === -1 && !flag(target, 'lockSsfi')) {
|
||||
flag(target, 'ssfi', proxyGetter);
|
||||
}
|
||||
|
||||
return Reflect.get(target, property);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* # stringDistanceCapped(strA, strB, cap)
|
||||
* Return the Levenshtein distance between two strings, but no more than cap.
|
||||
* @param {string} strA
|
||||
* @param {string} strB
|
||||
* @param {number} number
|
||||
* @return {number} min(string distance between strA and strB, cap)
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function stringDistanceCapped(strA, strB, cap) {
|
||||
if (Math.abs(strA.length - strB.length) >= cap) {
|
||||
return cap;
|
||||
}
|
||||
|
||||
var memo = [];
|
||||
// `memo` is a two-dimensional array containing distances.
|
||||
// memo[i][j] is the distance between strA.slice(0, i) and
|
||||
// strB.slice(0, j).
|
||||
for (var i = 0; i <= strA.length; i++) {
|
||||
memo[i] = Array(strB.length + 1).fill(0);
|
||||
memo[i][0] = i;
|
||||
}
|
||||
for (var j = 0; j < strB.length; j++) {
|
||||
memo[0][j] = j;
|
||||
}
|
||||
|
||||
for (var i = 1; i <= strA.length; i++) {
|
||||
var ch = strA.charCodeAt(i - 1);
|
||||
for (var j = 1; j <= strB.length; j++) {
|
||||
if (Math.abs(i - j) >= cap) {
|
||||
memo[i][j] = cap;
|
||||
continue;
|
||||
}
|
||||
memo[i][j] = Math.min(
|
||||
memo[i - 1][j] + 1,
|
||||
memo[i][j - 1] + 1,
|
||||
memo[i - 1][j - 1] +
|
||||
(ch === strB.charCodeAt(j - 1) ? 0 : 1)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return memo[strA.length][strB.length];
|
||||
}
|
||||
28
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/test.js
generated
vendored
Normal file
28
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/test.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
/*!
|
||||
* Chai - test utility
|
||||
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Module dependencies
|
||||
*/
|
||||
|
||||
var flag = require('./flag');
|
||||
|
||||
/**
|
||||
* ### .test(object, expression)
|
||||
*
|
||||
* Test an object for expression.
|
||||
*
|
||||
* @param {Object} object (constructed Assertion)
|
||||
* @param {Arguments} chai.Assertion.prototype.assert arguments
|
||||
* @namespace Utils
|
||||
* @name test
|
||||
*/
|
||||
|
||||
module.exports = function test(obj, args) {
|
||||
var negate = flag(obj, 'negate')
|
||||
, expr = args[0];
|
||||
return negate ? !expr : expr;
|
||||
};
|
||||
45
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/transferFlags.js
generated
vendored
Normal file
45
node_modules/@blockly/dev-tools/node_modules/chai/lib/chai/utils/transferFlags.js
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
/*!
|
||||
* Chai - transferFlags utility
|
||||
* Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* ### .transferFlags(assertion, object, includeAll = true)
|
||||
*
|
||||
* Transfer all the flags for `assertion` to `object`. If
|
||||
* `includeAll` is set to `false`, then the base Chai
|
||||
* assertion flags (namely `object`, `ssfi`, `lockSsfi`,
|
||||
* and `message`) will not be transferred.
|
||||
*
|
||||
*
|
||||
* var newAssertion = new Assertion();
|
||||
* utils.transferFlags(assertion, newAssertion);
|
||||
*
|
||||
* var anotherAssertion = new Assertion(myObj);
|
||||
* utils.transferFlags(assertion, anotherAssertion, false);
|
||||
*
|
||||
* @param {Assertion} assertion the assertion to transfer the flags from
|
||||
* @param {Object} object the object to transfer the flags to; usually a new assertion
|
||||
* @param {Boolean} includeAll
|
||||
* @namespace Utils
|
||||
* @name transferFlags
|
||||
* @api private
|
||||
*/
|
||||
|
||||
module.exports = function transferFlags(assertion, object, includeAll) {
|
||||
var flags = assertion.__flags || (assertion.__flags = Object.create(null));
|
||||
|
||||
if (!object.__flags) {
|
||||
object.__flags = Object.create(null);
|
||||
}
|
||||
|
||||
includeAll = arguments.length === 3 ? includeAll : true;
|
||||
|
||||
for (var flag in flags) {
|
||||
if (includeAll ||
|
||||
(flag !== 'object' && flag !== 'ssfi' && flag !== 'lockSsfi' && flag != 'message')) {
|
||||
object.__flags[flag] = flags[flag];
|
||||
}
|
||||
}
|
||||
};
|
||||
63
node_modules/@blockly/dev-tools/node_modules/chai/package.json
generated
vendored
Normal file
63
node_modules/@blockly/dev-tools/node_modules/chai/package.json
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"author": "Jake Luer <jake@alogicalparadox.com>",
|
||||
"name": "chai",
|
||||
"description": "BDD/TDD assertion library for node.js and the browser. Test framework agnostic.",
|
||||
"keywords": [
|
||||
"test",
|
||||
"assertion",
|
||||
"assert",
|
||||
"testing",
|
||||
"chai"
|
||||
],
|
||||
"homepage": "http://chaijs.com",
|
||||
"license": "MIT",
|
||||
"contributors": [
|
||||
"Jake Luer <jake@alogicalparadox.com>",
|
||||
"Domenic Denicola <domenic@domenicdenicola.com> (http://domenicdenicola.com)",
|
||||
"Veselin Todorov <hi@vesln.com>",
|
||||
"John Firebaugh <john.firebaugh@gmail.com>"
|
||||
],
|
||||
"version": "4.4.1",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/chaijs/chai"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/chaijs/chai/issues"
|
||||
},
|
||||
"main": "./index",
|
||||
"exports": {
|
||||
".": {
|
||||
"require": "./index.js",
|
||||
"import": "./index.mjs"
|
||||
},
|
||||
"./*": "./*"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "make test"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"dependencies": {
|
||||
"assertion-error": "^1.1.0",
|
||||
"check-error": "^1.0.3",
|
||||
"deep-eql": "^4.1.3",
|
||||
"get-func-name": "^2.0.2",
|
||||
"loupe": "^2.3.6",
|
||||
"pathval": "^1.1.1",
|
||||
"type-detect": "^4.0.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browserify": "^16.5.2",
|
||||
"bump-cli": "^2.7.1",
|
||||
"codecov": "^3.8.3",
|
||||
"istanbul": "^0.4.5",
|
||||
"karma": "^6.4.2",
|
||||
"karma-chrome-launcher": "^2.2.0",
|
||||
"karma-firefox-launcher": "^1.3.0",
|
||||
"karma-mocha": "^2.0.1",
|
||||
"karma-sauce-launcher": "^4.1.4",
|
||||
"mocha": "^10.2.0"
|
||||
}
|
||||
}
|
||||
1
node_modules/@blockly/dev-tools/node_modules/chai/register-assert.js
generated
vendored
Normal file
1
node_modules/@blockly/dev-tools/node_modules/chai/register-assert.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
global.assert = require('./').assert;
|
||||
1
node_modules/@blockly/dev-tools/node_modules/chai/register-expect.js
generated
vendored
Normal file
1
node_modules/@blockly/dev-tools/node_modules/chai/register-expect.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
global.expect = require('./').expect;
|
||||
1
node_modules/@blockly/dev-tools/node_modules/chai/register-should.js
generated
vendored
Normal file
1
node_modules/@blockly/dev-tools/node_modules/chai/register-should.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
global.should = require('./').should();
|
||||
106
node_modules/@blockly/dev-tools/node_modules/chai/sauce.browsers.js
generated
vendored
Normal file
106
node_modules/@blockly/dev-tools/node_modules/chai/sauce.browsers.js
generated
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
|
||||
/*!
|
||||
* Chrome
|
||||
*/
|
||||
|
||||
exports['SL_Chrome'] = {
|
||||
base: 'SauceLabs'
|
||||
, browserName: 'chrome'
|
||||
};
|
||||
|
||||
/*!
|
||||
* Firefox
|
||||
*/
|
||||
|
||||
exports['SL_Firefox'] = {
|
||||
base: 'SauceLabs'
|
||||
, browserName: 'firefox'
|
||||
};
|
||||
|
||||
exports['SL_Firefox_ESR'] = {
|
||||
base: 'SauceLabs'
|
||||
, browserName: 'firefox'
|
||||
, version: 38
|
||||
};
|
||||
|
||||
/*!
|
||||
* Internet Explorer
|
||||
*/
|
||||
|
||||
exports['SL_IE'] = {
|
||||
base: 'SauceLabs'
|
||||
, browserName: 'internet explorer'
|
||||
};
|
||||
|
||||
/*!
|
||||
* TODO: fails because of Uint8Array support
|
||||
*
|
||||
exports['SL_IE_Old'] = {
|
||||
base: 'SauceLabs'
|
||||
, browserName: 'internet explorer'
|
||||
, version: 10
|
||||
};
|
||||
*/
|
||||
|
||||
exports['SL_Edge'] = {
|
||||
base: 'SauceLabs'
|
||||
, browserName: 'microsoftedge'
|
||||
};
|
||||
|
||||
/*!
|
||||
* Safari
|
||||
*/
|
||||
|
||||
exports['SL_Safari'] = {
|
||||
base: 'SauceLabs'
|
||||
, browserName: 'safari'
|
||||
, platform: 'Mac 10.11'
|
||||
};
|
||||
|
||||
/*!
|
||||
* iPhone
|
||||
*/
|
||||
|
||||
/*!
|
||||
* TODO: These take forever to boot or shut down. Causes timeout.
|
||||
*
|
||||
|
||||
exports['SL_iPhone_6'] = {
|
||||
base: 'SauceLabs'
|
||||
, browserName: 'iphone'
|
||||
, platform: 'Mac 10.8'
|
||||
, version: '6'
|
||||
};
|
||||
|
||||
exports['SL_iPhone_5-1'] = {
|
||||
base: 'SauceLabs'
|
||||
, browserName: 'iphone'
|
||||
, platform: 'Mac 10.8'
|
||||
, version: '5.1'
|
||||
};
|
||||
|
||||
exports['SL_iPhone_5'] = {
|
||||
base: 'SauceLabs'
|
||||
, browserName: 'iphone'
|
||||
, platform: 'Mac 10.6'
|
||||
, version: '5'
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Android
|
||||
*/
|
||||
|
||||
/*!
|
||||
* TODO: fails because of error serialization
|
||||
*
|
||||
|
||||
exports['SL_Android_4'] = {
|
||||
base: 'SauceLabs'
|
||||
, browserName: 'android'
|
||||
, platform: 'Linux'
|
||||
, version: '4'
|
||||
};
|
||||
|
||||
*/
|
||||
19
node_modules/@blockly/dev-tools/node_modules/check-error/LICENSE
generated
vendored
Normal file
19
node_modules/@blockly/dev-tools/node_modules/check-error/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2013 Jake Luer <jake@alogicalparadox.com> (http://alogicalparadox.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
207
node_modules/@blockly/dev-tools/node_modules/check-error/README.md
generated
vendored
Normal file
207
node_modules/@blockly/dev-tools/node_modules/check-error/README.md
generated
vendored
Normal file
@@ -0,0 +1,207 @@
|
||||
<h1 align=center>
|
||||
<a href="http://chaijs.com" title="Chai Documentation">
|
||||
<img alt="ChaiJS" src="http://chaijs.com/img/chai-logo.png"/> check-error
|
||||
</a>
|
||||
</h1>
|
||||
|
||||
<p align=center>
|
||||
Error comparison and information related utility for <a href="http://nodejs.org">node</a> and the browser.
|
||||
</p>
|
||||
|
||||
<p align=center>
|
||||
<a href="./LICENSE">
|
||||
<img
|
||||
alt="license:mit"
|
||||
src="https://img.shields.io/badge/license-mit-green.svg?style=flat-square"
|
||||
/>
|
||||
</a>
|
||||
<a href="https://github.com/chaijs/check-error/releases">
|
||||
<img
|
||||
alt="tag:?"
|
||||
src="https://img.shields.io/github/tag/chaijs/check-error.svg?style=flat-square"
|
||||
/>
|
||||
</a>
|
||||
<a href="https://travis-ci.org/chaijs/check-error">
|
||||
<img
|
||||
alt="build:?"
|
||||
src="https://img.shields.io/travis/chaijs/check-error/master.svg?style=flat-square"
|
||||
/>
|
||||
</a>
|
||||
<a href="https://coveralls.io/r/chaijs/check-error">
|
||||
<img
|
||||
alt="coverage:?"
|
||||
src="https://img.shields.io/coveralls/chaijs/check-error/master.svg?style=flat-square"
|
||||
/>
|
||||
</a>
|
||||
<a href="https://www.npmjs.com/packages/check-error">
|
||||
<img
|
||||
alt="npm:?"
|
||||
src="https://img.shields.io/npm/v/check-error.svg?style=flat-square"
|
||||
/>
|
||||
</a>
|
||||
<a href="https://www.npmjs.com/packages/check-error">
|
||||
<img
|
||||
alt="dependencies:?"
|
||||
src="https://img.shields.io/npm/dm/check-error.svg?style=flat-square"
|
||||
/>
|
||||
</a>
|
||||
<a href="">
|
||||
<img
|
||||
alt="devDependencies:?"
|
||||
src="https://img.shields.io/david/chaijs/check-error.svg?style=flat-square"
|
||||
/>
|
||||
</a>
|
||||
<br/>
|
||||
<a href="https://saucelabs.com/u/chaijs-check-error">
|
||||
<img
|
||||
alt="Selenium Test Status"
|
||||
src="https://saucelabs.com/browser-matrix/chaijs-check-error.svg"
|
||||
/>
|
||||
</a>
|
||||
<br>
|
||||
<a href="https://chai-slack.herokuapp.com/">
|
||||
<img
|
||||
alt="Join the Slack chat"
|
||||
src="https://img.shields.io/badge/slack-join%20chat-E2206F.svg?style=flat-square"
|
||||
/>
|
||||
</a>
|
||||
<a href="https://gitter.im/chaijs/chai">
|
||||
<img
|
||||
alt="Join the Gitter chat"
|
||||
src="https://img.shields.io/badge/gitter-join%20chat-D0104D.svg?style=flat-square"
|
||||
/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
## What is Check-Error?
|
||||
|
||||
Check-Error is a module which you can use to retrieve an Error's information such as its `message` or `constructor` name and also to check whether two Errors are compatible based on their messages, constructors or even instances.
|
||||
|
||||
## Installation
|
||||
|
||||
### Node.js
|
||||
|
||||
`check-error` is available on [npm](http://npmjs.org). To install it, type:
|
||||
|
||||
$ npm install check-error
|
||||
|
||||
### Browsers
|
||||
|
||||
You can also use it within the browser; install via npm and use the `check-error.js` file found within the download. For example:
|
||||
|
||||
```html
|
||||
<script src="./node_modules/check-error/check-error.js"></script>
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
The primary export of `check-error` is an object which has the following methods:
|
||||
|
||||
* `compatibleInstance(err, errorLike)` - Checks if an error is compatible with another `errorLike` object. If `errorLike` is an error instance we do a strict comparison, otherwise we return `false` by default, because instances of objects can only be compatible if they're both error instances.
|
||||
* `compatibleConstructor(err, errorLike)` - Checks if an error's constructor is compatible with another `errorLike` object. If `err` has the same constructor as `errorLike` or if `err` is an instance of `errorLike`.
|
||||
* `compatibleMessage(err, errMatcher)` - Checks if an error message is compatible with an `errMatcher` RegExp or String (we check if the message contains the String).
|
||||
* `getConstructorName(errorLike)` - Retrieves the name of a constructor, an error's constructor or `errorLike` itself if it's not an error instance or constructor.
|
||||
* `getMessage(err)` - Retrieves the message of an error or `err` itself if it's a String. If `err` or `err.message` is undefined we return an empty String.
|
||||
|
||||
```js
|
||||
var checkError = require('check-error');
|
||||
```
|
||||
|
||||
#### .compatibleInstance(err, errorLike)
|
||||
|
||||
```js
|
||||
var checkError = require('check-error');
|
||||
|
||||
var funcThatThrows = function() { throw new TypeError('I am a TypeError') };
|
||||
var caughtErr;
|
||||
|
||||
try {
|
||||
funcThatThrows();
|
||||
} catch(e) {
|
||||
caughtErr = e;
|
||||
}
|
||||
|
||||
var sameInstance = caughtErr;
|
||||
|
||||
checkError.compatibleInstance(caughtErr, sameInstance); // true
|
||||
checkError.compatibleInstance(caughtErr, new TypeError('Another error')); // false
|
||||
```
|
||||
|
||||
#### .compatibleConstructor(err, errorLike)
|
||||
|
||||
```js
|
||||
var checkError = require('check-error');
|
||||
|
||||
var funcThatThrows = function() { throw new TypeError('I am a TypeError') };
|
||||
var caughtErr;
|
||||
|
||||
try {
|
||||
funcThatThrows();
|
||||
} catch(e) {
|
||||
caughtErr = e;
|
||||
}
|
||||
|
||||
checkError.compatibleConstructor(caughtErr, Error); // true
|
||||
checkError.compatibleConstructor(caughtErr, TypeError); // true
|
||||
checkError.compatibleConstructor(caughtErr, RangeError); // false
|
||||
```
|
||||
|
||||
#### .compatibleMessage(err, errMatcher)
|
||||
|
||||
```js
|
||||
var checkError = require('check-error');
|
||||
|
||||
var funcThatThrows = function() { throw new TypeError('I am a TypeError') };
|
||||
var caughtErr;
|
||||
|
||||
try {
|
||||
funcThatThrows();
|
||||
} catch(e) {
|
||||
caughtErr = e;
|
||||
}
|
||||
|
||||
var sameInstance = caughtErr;
|
||||
|
||||
checkError.compatibleMessage(caughtErr, /TypeError$/); // true
|
||||
checkError.compatibleMessage(caughtErr, 'I am a'); // true
|
||||
checkError.compatibleMessage(caughtErr, /unicorn/); // false
|
||||
checkError.compatibleMessage(caughtErr, 'I do not exist'); // false
|
||||
```
|
||||
|
||||
#### .getConstructorName(errorLike)
|
||||
|
||||
```js
|
||||
var checkError = require('check-error');
|
||||
|
||||
var funcThatThrows = function() { throw new TypeError('I am a TypeError') };
|
||||
var caughtErr;
|
||||
|
||||
try {
|
||||
funcThatThrows();
|
||||
} catch(e) {
|
||||
caughtErr = e;
|
||||
}
|
||||
|
||||
var sameInstance = caughtErr;
|
||||
|
||||
checkError.getConstructorName(caughtErr) // 'TypeError'
|
||||
```
|
||||
|
||||
#### .getMessage(err)
|
||||
|
||||
```js
|
||||
var checkError = require('check-error');
|
||||
|
||||
var funcThatThrows = function() { throw new TypeError('I am a TypeError') };
|
||||
var caughtErr;
|
||||
|
||||
try {
|
||||
funcThatThrows();
|
||||
} catch(e) {
|
||||
caughtErr = e;
|
||||
}
|
||||
|
||||
var sameInstance = caughtErr;
|
||||
|
||||
checkError.getMessage(caughtErr) // 'I am a TypeError'
|
||||
```
|
||||
1
node_modules/@blockly/dev-tools/node_modules/check-error/check-error.js
generated
vendored
Normal file
1
node_modules/@blockly/dev-tools/node_modules/check-error/check-error.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({},{},[])
|
||||
148
node_modules/@blockly/dev-tools/node_modules/check-error/index.js
generated
vendored
Normal file
148
node_modules/@blockly/dev-tools/node_modules/check-error/index.js
generated
vendored
Normal file
@@ -0,0 +1,148 @@
|
||||
'use strict';
|
||||
|
||||
/* !
|
||||
* Chai - checkError utility
|
||||
* Copyright(c) 2012-2016 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
var getFunctionName = require('get-func-name');
|
||||
/**
|
||||
* ### .checkError
|
||||
*
|
||||
* Checks that an error conforms to a given set of criteria and/or retrieves information about it.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
/**
|
||||
* ### .compatibleInstance(thrown, errorLike)
|
||||
*
|
||||
* Checks if two instances are compatible (strict equal).
|
||||
* Returns false if errorLike is not an instance of Error, because instances
|
||||
* can only be compatible if they're both error instances.
|
||||
*
|
||||
* @name compatibleInstance
|
||||
* @param {Error} thrown error
|
||||
* @param {Error|ErrorConstructor} errorLike object to compare against
|
||||
* @namespace Utils
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function compatibleInstance(thrown, errorLike) {
|
||||
return errorLike instanceof Error && thrown === errorLike;
|
||||
}
|
||||
|
||||
/**
|
||||
* ### .compatibleConstructor(thrown, errorLike)
|
||||
*
|
||||
* Checks if two constructors are compatible.
|
||||
* This function can receive either an error constructor or
|
||||
* an error instance as the `errorLike` argument.
|
||||
* Constructors are compatible if they're the same or if one is
|
||||
* an instance of another.
|
||||
*
|
||||
* @name compatibleConstructor
|
||||
* @param {Error} thrown error
|
||||
* @param {Error|ErrorConstructor} errorLike object to compare against
|
||||
* @namespace Utils
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function compatibleConstructor(thrown, errorLike) {
|
||||
if (errorLike instanceof Error) {
|
||||
// If `errorLike` is an instance of any error we compare their constructors
|
||||
return thrown.constructor === errorLike.constructor || thrown instanceof errorLike.constructor;
|
||||
} else if (errorLike.prototype instanceof Error || errorLike === Error) {
|
||||
// If `errorLike` is a constructor that inherits from Error, we compare `thrown` to `errorLike` directly
|
||||
return thrown.constructor === errorLike || thrown instanceof errorLike;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* ### .compatibleMessage(thrown, errMatcher)
|
||||
*
|
||||
* Checks if an error's message is compatible with a matcher (String or RegExp).
|
||||
* If the message contains the String or passes the RegExp test,
|
||||
* it is considered compatible.
|
||||
*
|
||||
* @name compatibleMessage
|
||||
* @param {Error} thrown error
|
||||
* @param {String|RegExp} errMatcher to look for into the message
|
||||
* @namespace Utils
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function compatibleMessage(thrown, errMatcher) {
|
||||
var comparisonString = typeof thrown === 'string' ? thrown : thrown.message;
|
||||
if (errMatcher instanceof RegExp) {
|
||||
return errMatcher.test(comparisonString);
|
||||
} else if (typeof errMatcher === 'string') {
|
||||
return comparisonString.indexOf(errMatcher) !== -1; // eslint-disable-line no-magic-numbers
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* ### .getConstructorName(errorLike)
|
||||
*
|
||||
* Gets the constructor name for an Error instance or constructor itself.
|
||||
*
|
||||
* @name getConstructorName
|
||||
* @param {Error|ErrorConstructor} errorLike
|
||||
* @namespace Utils
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function getConstructorName(errorLike) {
|
||||
var constructorName = errorLike;
|
||||
if (errorLike instanceof Error) {
|
||||
constructorName = getFunctionName(errorLike.constructor);
|
||||
} else if (typeof errorLike === 'function') {
|
||||
// If `err` is not an instance of Error it is an error constructor itself or another function.
|
||||
// If we've got a common function we get its name, otherwise we may need to create a new instance
|
||||
// of the error just in case it's a poorly-constructed error. Please see chaijs/chai/issues/45 to know more.
|
||||
constructorName = getFunctionName(errorLike);
|
||||
if (constructorName === '') {
|
||||
var newConstructorName = getFunctionName(new errorLike()); // eslint-disable-line new-cap
|
||||
constructorName = newConstructorName || constructorName;
|
||||
}
|
||||
}
|
||||
|
||||
return constructorName;
|
||||
}
|
||||
|
||||
/**
|
||||
* ### .getMessage(errorLike)
|
||||
*
|
||||
* Gets the error message from an error.
|
||||
* If `err` is a String itself, we return it.
|
||||
* If the error has no message, we return an empty string.
|
||||
*
|
||||
* @name getMessage
|
||||
* @param {Error|String} errorLike
|
||||
* @namespace Utils
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function getMessage(errorLike) {
|
||||
var msg = '';
|
||||
if (errorLike && errorLike.message) {
|
||||
msg = errorLike.message;
|
||||
} else if (typeof errorLike === 'string') {
|
||||
msg = errorLike;
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
compatibleInstance: compatibleInstance,
|
||||
compatibleConstructor: compatibleConstructor,
|
||||
compatibleMessage: compatibleMessage,
|
||||
getMessage: getMessage,
|
||||
getConstructorName: getConstructorName,
|
||||
};
|
||||
87
node_modules/@blockly/dev-tools/node_modules/check-error/package.json
generated
vendored
Normal file
87
node_modules/@blockly/dev-tools/node_modules/check-error/package.json
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
{
|
||||
"name": "check-error",
|
||||
"description": "Error comparison and information related utility for node and the browser",
|
||||
"keywords": [
|
||||
"check-error",
|
||||
"error",
|
||||
"chai util"
|
||||
],
|
||||
"license": "MIT",
|
||||
"author": "Jake Luer <jake@alogicalparadox.com> (http://alogicalparadox.com)",
|
||||
"contributors": [
|
||||
"David Losert (https://github.com/davelosert)",
|
||||
"Keith Cirkel (https://github.com/keithamus)",
|
||||
"Miroslav Bajtoš (https://github.com/bajtos)",
|
||||
"Lucas Fernandes da Costa (https://github.com/lucasfcosta)"
|
||||
],
|
||||
"files": [
|
||||
"index.js",
|
||||
"check-error.js"
|
||||
],
|
||||
"main": "./index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/chaijs/check-error.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "browserify --bare $npm_package_main --standalone checkError -o check-error.js",
|
||||
"lint": "eslint --ignore-path .gitignore .",
|
||||
"prepublish": "npm run build",
|
||||
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
|
||||
"pretest": "npm run lint",
|
||||
"test": "npm run test:node && npm run test:browser && npm run upload-coverage",
|
||||
"test:browser": "karma start --singleRun=true",
|
||||
"test:node": "istanbul cover _mocha",
|
||||
"upload-coverage": "lcov-result-merger 'coverage/**/lcov.info' | coveralls; exit 0"
|
||||
},
|
||||
"config": {
|
||||
"ghooks": {
|
||||
"commit-msg": "validate-commit-msg"
|
||||
}
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"strict/es5"
|
||||
],
|
||||
"env": {
|
||||
"es6": true
|
||||
},
|
||||
"globals": {
|
||||
"HTMLElement": false
|
||||
},
|
||||
"rules": {
|
||||
"complexity": 0,
|
||||
"max-statements": 0
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"get-func-name": "^2.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browserify": "^13.0.0",
|
||||
"browserify-istanbul": "^1.0.0",
|
||||
"coveralls": "2.11.9",
|
||||
"eslint": "^2.4.0",
|
||||
"eslint-config-strict": "^8.5.0",
|
||||
"eslint-plugin-filenames": "^0.2.0",
|
||||
"ghooks": "^1.0.1",
|
||||
"istanbul": "^0.4.2",
|
||||
"karma": "^0.13.22",
|
||||
"karma-browserify": "^5.0.2",
|
||||
"karma-coverage": "^0.5.5",
|
||||
"karma-mocha": "^0.2.2",
|
||||
"karma-phantomjs-launcher": "^1.0.0",
|
||||
"karma-sauce-launcher": "^0.3.1",
|
||||
"lcov-result-merger": "^1.0.2",
|
||||
"mocha": "^2.4.5",
|
||||
"phantomjs-prebuilt": "^2.1.5",
|
||||
"semantic-release": "^4.3.5",
|
||||
"simple-assert": "^1.0.0",
|
||||
"travis-after-all": "^1.4.4",
|
||||
"validate-commit-msg": "^2.3.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"version": "1.0.3"
|
||||
}
|
||||
19
node_modules/@blockly/dev-tools/node_modules/deep-eql/LICENSE
generated
vendored
Normal file
19
node_modules/@blockly/dev-tools/node_modules/deep-eql/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2013 Jake Luer <jake@alogicalparadox.com> (http://alogicalparadox.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
93
node_modules/@blockly/dev-tools/node_modules/deep-eql/README.md
generated
vendored
Normal file
93
node_modules/@blockly/dev-tools/node_modules/deep-eql/README.md
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
<h1 align=center>
|
||||
<a href="http://chaijs.com" title="Chai Documentation">
|
||||
<img alt="deep-eql" src="https://raw.githubusercontent.com/chaijs/deep-eql/main/deep-eql-logo.svg"/>
|
||||
</a>
|
||||
</h1>
|
||||
|
||||
<p align=center>
|
||||
Improved deep equality testing for <a href="http://nodejs.org/">node</a> and the browser.
|
||||
</p>
|
||||
|
||||
<p align=center>
|
||||
<a href="https://github.com/chaijs/deep-eql/actions">
|
||||
<img
|
||||
alt="build:?"
|
||||
src="https://github.com/chaijs/deep-eql/workflows/Build/badge.svg"
|
||||
/>
|
||||
</a><a href="https://coveralls.io/r/chaijs/deep-eql">
|
||||
<img
|
||||
alt="coverage:?"
|
||||
src="https://img.shields.io/coveralls/chaijs/deep-eql/master.svg?style=flat-square"
|
||||
/>
|
||||
</a><a href="https://www.npmjs.com/packages/deep-eql">
|
||||
<img
|
||||
alt="dependencies:?"
|
||||
src="https://img.shields.io/npm/dm/deep-eql.svg?style=flat-square"
|
||||
/>
|
||||
</a><a href="">
|
||||
<img
|
||||
alt="devDependencies:?"
|
||||
src="https://img.shields.io/david/chaijs/deep-eql.svg?style=flat-square"
|
||||
/>
|
||||
</a>
|
||||
<br>
|
||||
<a href="https://chai-slack.herokuapp.com/">
|
||||
<img
|
||||
alt="Join the Slack chat"
|
||||
src="https://img.shields.io/badge/slack-join%20chat-E2206F.svg?style=flat-square"
|
||||
/>
|
||||
</a>
|
||||
<a href="https://gitter.im/chaijs/deep-eql">
|
||||
<img
|
||||
alt="Join the Gitter chat"
|
||||
src="https://img.shields.io/badge/gitter-join%20chat-D0104D.svg?style=flat-square"
|
||||
/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
## What is Deep-Eql?
|
||||
|
||||
Deep Eql is a module which you can use to determine if two objects are "deeply" equal - that is, rather than having referential equality (`a === b`), this module checks an object's keys recursively, until it finds primitives to check for referential equality. For more on equality in JavaScript, read [the comparison operators article on mdn](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators).
|
||||
|
||||
As an example, take the following:
|
||||
|
||||
```js
|
||||
1 === 1 // These are primitives, they hold the same reference - they are strictly equal
|
||||
1 == '1' // These are two different primitives, through type coercion they hold the same value - they are loosely equal
|
||||
{ a: 1 } !== { a: 1 } // These are two different objects, they hold different references and so are not strictly equal - even though they hold the same values inside
|
||||
{ a: 1 } != { a: 1 } // They have the same type, meaning loose equality performs the same check as strict equality - they are still not equal.
|
||||
|
||||
var deepEql = require("deep-eql");
|
||||
deepEql({ a: 1 }, { a: 1 }) === true // deepEql can determine that they share the same keys and those keys share the same values, therefore they are deeply equal!
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
### Node.js
|
||||
|
||||
`deep-eql` is available on [npm](http://npmjs.org).
|
||||
|
||||
$ npm install deep-eql
|
||||
|
||||
## Usage
|
||||
|
||||
The primary export of `deep-eql` is function that can be given two objects to compare. It will always return a boolean which can be used to determine if two objects are deeply equal.
|
||||
|
||||
### Rules
|
||||
|
||||
- Strict equality for non-traversable nodes according to [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is):
|
||||
- `eql(NaN, NaN).should.be.true;`
|
||||
- `eql(-0, +0).should.be.false;`
|
||||
- All own and inherited enumerable properties are considered:
|
||||
- `eql(Object.create({ foo: { a: 1 } }), Object.create({ foo: { a: 1 } })).should.be.true;`
|
||||
- `eql(Object.create({ foo: { a: 1 } }), Object.create({ foo: { a: 2 } })).should.be.false;`
|
||||
- When comparing `Error` objects, only `name`, `message`, and `code` properties are considered, regardless of enumerability:
|
||||
- `eql(Error('foo'), Error('foo')).should.be.true;`
|
||||
- `eql(Error('foo'), Error('bar')).should.be.false;`
|
||||
- `eql(Error('foo'), TypeError('foo')).should.be.false;`
|
||||
- `eql(Object.assign(Error('foo'), { code: 42 }), Object.assign(Error('foo'), { code: 42 })).should.be.true;`
|
||||
- `eql(Object.assign(Error('foo'), { code: 42 }), Object.assign(Error('foo'), { code: 13 })).should.be.false;`
|
||||
- `eql(Object.assign(Error('foo'), { otherProp: 42 }), Object.assign(Error('foo'), { otherProp: 13 })).should.be.true;`
|
||||
- Arguments are not Arrays:
|
||||
- `eql([], arguments).should.be.false;`
|
||||
- `eql([], Array.prototype.slice.call(arguments)).should.be.true;`
|
||||
1
node_modules/@blockly/dev-tools/node_modules/deep-eql/deep-eql.js
generated
vendored
Normal file
1
node_modules/@blockly/dev-tools/node_modules/deep-eql/deep-eql.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({},{},[])
|
||||
498
node_modules/@blockly/dev-tools/node_modules/deep-eql/index.js
generated
vendored
Normal file
498
node_modules/@blockly/dev-tools/node_modules/deep-eql/index.js
generated
vendored
Normal file
@@ -0,0 +1,498 @@
|
||||
'use strict';
|
||||
/* globals Symbol: false, Uint8Array: false, WeakMap: false */
|
||||
/*!
|
||||
* deep-eql
|
||||
* Copyright(c) 2013 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
var type = require('type-detect');
|
||||
function FakeMap() {
|
||||
this._key = 'chai/deep-eql__' + Math.random() + Date.now();
|
||||
}
|
||||
|
||||
FakeMap.prototype = {
|
||||
get: function get(key) {
|
||||
return key[this._key];
|
||||
},
|
||||
set: function set(key, value) {
|
||||
if (Object.isExtensible(key)) {
|
||||
Object.defineProperty(key, this._key, {
|
||||
value: value,
|
||||
configurable: true,
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
var MemoizeMap = typeof WeakMap === 'function' ? WeakMap : FakeMap;
|
||||
/*!
|
||||
* Check to see if the MemoizeMap has recorded a result of the two operands
|
||||
*
|
||||
* @param {Mixed} leftHandOperand
|
||||
* @param {Mixed} rightHandOperand
|
||||
* @param {MemoizeMap} memoizeMap
|
||||
* @returns {Boolean|null} result
|
||||
*/
|
||||
function memoizeCompare(leftHandOperand, rightHandOperand, memoizeMap) {
|
||||
// Technically, WeakMap keys can *only* be objects, not primitives.
|
||||
if (!memoizeMap || isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) {
|
||||
return null;
|
||||
}
|
||||
var leftHandMap = memoizeMap.get(leftHandOperand);
|
||||
if (leftHandMap) {
|
||||
var result = leftHandMap.get(rightHandOperand);
|
||||
if (typeof result === 'boolean') {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Set the result of the equality into the MemoizeMap
|
||||
*
|
||||
* @param {Mixed} leftHandOperand
|
||||
* @param {Mixed} rightHandOperand
|
||||
* @param {MemoizeMap} memoizeMap
|
||||
* @param {Boolean} result
|
||||
*/
|
||||
function memoizeSet(leftHandOperand, rightHandOperand, memoizeMap, result) {
|
||||
// Technically, WeakMap keys can *only* be objects, not primitives.
|
||||
if (!memoizeMap || isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) {
|
||||
return;
|
||||
}
|
||||
var leftHandMap = memoizeMap.get(leftHandOperand);
|
||||
if (leftHandMap) {
|
||||
leftHandMap.set(rightHandOperand, result);
|
||||
} else {
|
||||
leftHandMap = new MemoizeMap();
|
||||
leftHandMap.set(rightHandOperand, result);
|
||||
memoizeMap.set(leftHandOperand, leftHandMap);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* Primary Export
|
||||
*/
|
||||
|
||||
module.exports = deepEqual;
|
||||
module.exports.MemoizeMap = MemoizeMap;
|
||||
|
||||
/**
|
||||
* Assert deeply nested sameValue equality between two objects of any type.
|
||||
*
|
||||
* @param {Mixed} leftHandOperand
|
||||
* @param {Mixed} rightHandOperand
|
||||
* @param {Object} [options] (optional) Additional options
|
||||
* @param {Array} [options.comparator] (optional) Override default algorithm, determining custom equality.
|
||||
* @param {Array} [options.memoize] (optional) Provide a custom memoization object which will cache the results of
|
||||
complex objects for a speed boost. By passing `false` you can disable memoization, but this will cause circular
|
||||
references to blow the stack.
|
||||
* @return {Boolean} equal match
|
||||
*/
|
||||
function deepEqual(leftHandOperand, rightHandOperand, options) {
|
||||
// If we have a comparator, we can't assume anything; so bail to its check first.
|
||||
if (options && options.comparator) {
|
||||
return extensiveDeepEqual(leftHandOperand, rightHandOperand, options);
|
||||
}
|
||||
|
||||
var simpleResult = simpleEqual(leftHandOperand, rightHandOperand);
|
||||
if (simpleResult !== null) {
|
||||
return simpleResult;
|
||||
}
|
||||
|
||||
// Deeper comparisons are pushed through to a larger function
|
||||
return extensiveDeepEqual(leftHandOperand, rightHandOperand, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Many comparisons can be canceled out early via simple equality or primitive checks.
|
||||
* @param {Mixed} leftHandOperand
|
||||
* @param {Mixed} rightHandOperand
|
||||
* @return {Boolean|null} equal match
|
||||
*/
|
||||
function simpleEqual(leftHandOperand, rightHandOperand) {
|
||||
// Equal references (except for Numbers) can be returned early
|
||||
if (leftHandOperand === rightHandOperand) {
|
||||
// Handle +-0 cases
|
||||
return leftHandOperand !== 0 || 1 / leftHandOperand === 1 / rightHandOperand;
|
||||
}
|
||||
|
||||
// handle NaN cases
|
||||
if (
|
||||
leftHandOperand !== leftHandOperand && // eslint-disable-line no-self-compare
|
||||
rightHandOperand !== rightHandOperand // eslint-disable-line no-self-compare
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Anything that is not an 'object', i.e. symbols, functions, booleans, numbers,
|
||||
// strings, and undefined, can be compared by reference.
|
||||
if (isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) {
|
||||
// Easy out b/c it would have passed the first equality check
|
||||
return false;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*!
|
||||
* The main logic of the `deepEqual` function.
|
||||
*
|
||||
* @param {Mixed} leftHandOperand
|
||||
* @param {Mixed} rightHandOperand
|
||||
* @param {Object} [options] (optional) Additional options
|
||||
* @param {Array} [options.comparator] (optional) Override default algorithm, determining custom equality.
|
||||
* @param {Array} [options.memoize] (optional) Provide a custom memoization object which will cache the results of
|
||||
complex objects for a speed boost. By passing `false` you can disable memoization, but this will cause circular
|
||||
references to blow the stack.
|
||||
* @return {Boolean} equal match
|
||||
*/
|
||||
function extensiveDeepEqual(leftHandOperand, rightHandOperand, options) {
|
||||
options = options || {};
|
||||
options.memoize = options.memoize === false ? false : options.memoize || new MemoizeMap();
|
||||
var comparator = options && options.comparator;
|
||||
|
||||
// Check if a memoized result exists.
|
||||
var memoizeResultLeft = memoizeCompare(leftHandOperand, rightHandOperand, options.memoize);
|
||||
if (memoizeResultLeft !== null) {
|
||||
return memoizeResultLeft;
|
||||
}
|
||||
var memoizeResultRight = memoizeCompare(rightHandOperand, leftHandOperand, options.memoize);
|
||||
if (memoizeResultRight !== null) {
|
||||
return memoizeResultRight;
|
||||
}
|
||||
|
||||
// If a comparator is present, use it.
|
||||
if (comparator) {
|
||||
var comparatorResult = comparator(leftHandOperand, rightHandOperand);
|
||||
// Comparators may return null, in which case we want to go back to default behavior.
|
||||
if (comparatorResult === false || comparatorResult === true) {
|
||||
memoizeSet(leftHandOperand, rightHandOperand, options.memoize, comparatorResult);
|
||||
return comparatorResult;
|
||||
}
|
||||
// To allow comparators to override *any* behavior, we ran them first. Since it didn't decide
|
||||
// what to do, we need to make sure to return the basic tests first before we move on.
|
||||
var simpleResult = simpleEqual(leftHandOperand, rightHandOperand);
|
||||
if (simpleResult !== null) {
|
||||
// Don't memoize this, it takes longer to set/retrieve than to just compare.
|
||||
return simpleResult;
|
||||
}
|
||||
}
|
||||
|
||||
var leftHandType = type(leftHandOperand);
|
||||
if (leftHandType !== type(rightHandOperand)) {
|
||||
memoizeSet(leftHandOperand, rightHandOperand, options.memoize, false);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Temporarily set the operands in the memoize object to prevent blowing the stack
|
||||
memoizeSet(leftHandOperand, rightHandOperand, options.memoize, true);
|
||||
|
||||
var result = extensiveDeepEqualByType(leftHandOperand, rightHandOperand, leftHandType, options);
|
||||
memoizeSet(leftHandOperand, rightHandOperand, options.memoize, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
function extensiveDeepEqualByType(leftHandOperand, rightHandOperand, leftHandType, options) {
|
||||
switch (leftHandType) {
|
||||
case 'String':
|
||||
case 'Number':
|
||||
case 'Boolean':
|
||||
case 'Date':
|
||||
// If these types are their instance types (e.g. `new Number`) then re-deepEqual against their values
|
||||
return deepEqual(leftHandOperand.valueOf(), rightHandOperand.valueOf());
|
||||
case 'Promise':
|
||||
case 'Symbol':
|
||||
case 'function':
|
||||
case 'WeakMap':
|
||||
case 'WeakSet':
|
||||
return leftHandOperand === rightHandOperand;
|
||||
case 'Error':
|
||||
return keysEqual(leftHandOperand, rightHandOperand, [ 'name', 'message', 'code' ], options);
|
||||
case 'Arguments':
|
||||
case 'Int8Array':
|
||||
case 'Uint8Array':
|
||||
case 'Uint8ClampedArray':
|
||||
case 'Int16Array':
|
||||
case 'Uint16Array':
|
||||
case 'Int32Array':
|
||||
case 'Uint32Array':
|
||||
case 'Float32Array':
|
||||
case 'Float64Array':
|
||||
case 'Array':
|
||||
return iterableEqual(leftHandOperand, rightHandOperand, options);
|
||||
case 'RegExp':
|
||||
return regexpEqual(leftHandOperand, rightHandOperand);
|
||||
case 'Generator':
|
||||
return generatorEqual(leftHandOperand, rightHandOperand, options);
|
||||
case 'DataView':
|
||||
return iterableEqual(new Uint8Array(leftHandOperand.buffer), new Uint8Array(rightHandOperand.buffer), options);
|
||||
case 'ArrayBuffer':
|
||||
return iterableEqual(new Uint8Array(leftHandOperand), new Uint8Array(rightHandOperand), options);
|
||||
case 'Set':
|
||||
return entriesEqual(leftHandOperand, rightHandOperand, options);
|
||||
case 'Map':
|
||||
return entriesEqual(leftHandOperand, rightHandOperand, options);
|
||||
case 'Temporal.PlainDate':
|
||||
case 'Temporal.PlainTime':
|
||||
case 'Temporal.PlainDateTime':
|
||||
case 'Temporal.Instant':
|
||||
case 'Temporal.ZonedDateTime':
|
||||
case 'Temporal.PlainYearMonth':
|
||||
case 'Temporal.PlainMonthDay':
|
||||
return leftHandOperand.equals(rightHandOperand);
|
||||
case 'Temporal.Duration':
|
||||
return leftHandOperand.total('nanoseconds') === rightHandOperand.total('nanoseconds');
|
||||
case 'Temporal.TimeZone':
|
||||
case 'Temporal.Calendar':
|
||||
return leftHandOperand.toString() === rightHandOperand.toString();
|
||||
default:
|
||||
return objectEqual(leftHandOperand, rightHandOperand, options);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* Compare two Regular Expressions for equality.
|
||||
*
|
||||
* @param {RegExp} leftHandOperand
|
||||
* @param {RegExp} rightHandOperand
|
||||
* @return {Boolean} result
|
||||
*/
|
||||
|
||||
function regexpEqual(leftHandOperand, rightHandOperand) {
|
||||
return leftHandOperand.toString() === rightHandOperand.toString();
|
||||
}
|
||||
|
||||
/*!
|
||||
* Compare two Sets/Maps for equality. Faster than other equality functions.
|
||||
*
|
||||
* @param {Set} leftHandOperand
|
||||
* @param {Set} rightHandOperand
|
||||
* @param {Object} [options] (Optional)
|
||||
* @return {Boolean} result
|
||||
*/
|
||||
|
||||
function entriesEqual(leftHandOperand, rightHandOperand, options) {
|
||||
try {
|
||||
// IE11 doesn't support Set#entries or Set#@@iterator, so we need manually populate using Set#forEach
|
||||
if (leftHandOperand.size !== rightHandOperand.size) {
|
||||
return false;
|
||||
}
|
||||
if (leftHandOperand.size === 0) {
|
||||
return true;
|
||||
}
|
||||
} catch (sizeError) {
|
||||
// things that aren't actual Maps or Sets will throw here
|
||||
return false;
|
||||
}
|
||||
var leftHandItems = [];
|
||||
var rightHandItems = [];
|
||||
leftHandOperand.forEach(function gatherEntries(key, value) {
|
||||
leftHandItems.push([ key, value ]);
|
||||
});
|
||||
rightHandOperand.forEach(function gatherEntries(key, value) {
|
||||
rightHandItems.push([ key, value ]);
|
||||
});
|
||||
return iterableEqual(leftHandItems.sort(), rightHandItems.sort(), options);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Simple equality for flat iterable objects such as Arrays, TypedArrays or Node.js buffers.
|
||||
*
|
||||
* @param {Iterable} leftHandOperand
|
||||
* @param {Iterable} rightHandOperand
|
||||
* @param {Object} [options] (Optional)
|
||||
* @return {Boolean} result
|
||||
*/
|
||||
|
||||
function iterableEqual(leftHandOperand, rightHandOperand, options) {
|
||||
var length = leftHandOperand.length;
|
||||
if (length !== rightHandOperand.length) {
|
||||
return false;
|
||||
}
|
||||
if (length === 0) {
|
||||
return true;
|
||||
}
|
||||
var index = -1;
|
||||
while (++index < length) {
|
||||
if (deepEqual(leftHandOperand[index], rightHandOperand[index], options) === false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Simple equality for generator objects such as those returned by generator functions.
|
||||
*
|
||||
* @param {Iterable} leftHandOperand
|
||||
* @param {Iterable} rightHandOperand
|
||||
* @param {Object} [options] (Optional)
|
||||
* @return {Boolean} result
|
||||
*/
|
||||
|
||||
function generatorEqual(leftHandOperand, rightHandOperand, options) {
|
||||
return iterableEqual(getGeneratorEntries(leftHandOperand), getGeneratorEntries(rightHandOperand), options);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Determine if the given object has an @@iterator function.
|
||||
*
|
||||
* @param {Object} target
|
||||
* @return {Boolean} `true` if the object has an @@iterator function.
|
||||
*/
|
||||
function hasIteratorFunction(target) {
|
||||
return typeof Symbol !== 'undefined' &&
|
||||
typeof target === 'object' &&
|
||||
typeof Symbol.iterator !== 'undefined' &&
|
||||
typeof target[Symbol.iterator] === 'function';
|
||||
}
|
||||
|
||||
/*!
|
||||
* Gets all iterator entries from the given Object. If the Object has no @@iterator function, returns an empty array.
|
||||
* This will consume the iterator - which could have side effects depending on the @@iterator implementation.
|
||||
*
|
||||
* @param {Object} target
|
||||
* @returns {Array} an array of entries from the @@iterator function
|
||||
*/
|
||||
function getIteratorEntries(target) {
|
||||
if (hasIteratorFunction(target)) {
|
||||
try {
|
||||
return getGeneratorEntries(target[Symbol.iterator]());
|
||||
} catch (iteratorError) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/*!
|
||||
* Gets all entries from a Generator. This will consume the generator - which could have side effects.
|
||||
*
|
||||
* @param {Generator} target
|
||||
* @returns {Array} an array of entries from the Generator.
|
||||
*/
|
||||
function getGeneratorEntries(generator) {
|
||||
var generatorResult = generator.next();
|
||||
var accumulator = [ generatorResult.value ];
|
||||
while (generatorResult.done === false) {
|
||||
generatorResult = generator.next();
|
||||
accumulator.push(generatorResult.value);
|
||||
}
|
||||
return accumulator;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Gets all own and inherited enumerable keys from a target.
|
||||
*
|
||||
* @param {Object} target
|
||||
* @returns {Array} an array of own and inherited enumerable keys from the target.
|
||||
*/
|
||||
function getEnumerableKeys(target) {
|
||||
var keys = [];
|
||||
for (var key in target) {
|
||||
keys.push(key);
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
function getEnumerableSymbols(target) {
|
||||
var keys = [];
|
||||
var allKeys = Object.getOwnPropertySymbols(target);
|
||||
for (var i = 0; i < allKeys.length; i += 1) {
|
||||
var key = allKeys[i];
|
||||
if (Object.getOwnPropertyDescriptor(target, key).enumerable) {
|
||||
keys.push(key);
|
||||
}
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Determines if two objects have matching values, given a set of keys. Defers to deepEqual for the equality check of
|
||||
* each key. If any value of the given key is not equal, the function will return false (early).
|
||||
*
|
||||
* @param {Mixed} leftHandOperand
|
||||
* @param {Mixed} rightHandOperand
|
||||
* @param {Array} keys An array of keys to compare the values of leftHandOperand and rightHandOperand against
|
||||
* @param {Object} [options] (Optional)
|
||||
* @return {Boolean} result
|
||||
*/
|
||||
function keysEqual(leftHandOperand, rightHandOperand, keys, options) {
|
||||
var length = keys.length;
|
||||
if (length === 0) {
|
||||
return true;
|
||||
}
|
||||
for (var i = 0; i < length; i += 1) {
|
||||
if (deepEqual(leftHandOperand[keys[i]], rightHandOperand[keys[i]], options) === false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Recursively check the equality of two Objects. Once basic sameness has been established it will defer to `deepEqual`
|
||||
* for each enumerable key in the object.
|
||||
*
|
||||
* @param {Mixed} leftHandOperand
|
||||
* @param {Mixed} rightHandOperand
|
||||
* @param {Object} [options] (Optional)
|
||||
* @return {Boolean} result
|
||||
*/
|
||||
function objectEqual(leftHandOperand, rightHandOperand, options) {
|
||||
var leftHandKeys = getEnumerableKeys(leftHandOperand);
|
||||
var rightHandKeys = getEnumerableKeys(rightHandOperand);
|
||||
var leftHandSymbols = getEnumerableSymbols(leftHandOperand);
|
||||
var rightHandSymbols = getEnumerableSymbols(rightHandOperand);
|
||||
leftHandKeys = leftHandKeys.concat(leftHandSymbols);
|
||||
rightHandKeys = rightHandKeys.concat(rightHandSymbols);
|
||||
|
||||
if (leftHandKeys.length && leftHandKeys.length === rightHandKeys.length) {
|
||||
if (iterableEqual(mapSymbols(leftHandKeys).sort(), mapSymbols(rightHandKeys).sort()) === false) {
|
||||
return false;
|
||||
}
|
||||
return keysEqual(leftHandOperand, rightHandOperand, leftHandKeys, options);
|
||||
}
|
||||
|
||||
var leftHandEntries = getIteratorEntries(leftHandOperand);
|
||||
var rightHandEntries = getIteratorEntries(rightHandOperand);
|
||||
if (leftHandEntries.length && leftHandEntries.length === rightHandEntries.length) {
|
||||
leftHandEntries.sort();
|
||||
rightHandEntries.sort();
|
||||
return iterableEqual(leftHandEntries, rightHandEntries, options);
|
||||
}
|
||||
|
||||
if (leftHandKeys.length === 0 &&
|
||||
leftHandEntries.length === 0 &&
|
||||
rightHandKeys.length === 0 &&
|
||||
rightHandEntries.length === 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Returns true if the argument is a primitive.
|
||||
*
|
||||
* This intentionally returns true for all objects that can be compared by reference,
|
||||
* including functions and symbols.
|
||||
*
|
||||
* @param {Mixed} value
|
||||
* @return {Boolean} result
|
||||
*/
|
||||
function isPrimitive(value) {
|
||||
return value === null || typeof value !== 'object';
|
||||
}
|
||||
|
||||
function mapSymbols(arr) {
|
||||
return arr.map(function mapSymbol(entry) {
|
||||
if (typeof entry === 'symbol') {
|
||||
return entry.toString();
|
||||
}
|
||||
|
||||
return entry;
|
||||
});
|
||||
}
|
||||
79
node_modules/@blockly/dev-tools/node_modules/deep-eql/package.json
generated
vendored
Normal file
79
node_modules/@blockly/dev-tools/node_modules/deep-eql/package.json
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
{
|
||||
"name": "deep-eql",
|
||||
"version": "4.1.4",
|
||||
"description": "Improved deep equality testing for Node.js and the browser.",
|
||||
"keywords": [
|
||||
"chai util",
|
||||
"deep equal",
|
||||
"object equal",
|
||||
"testing"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:chaijs/deep-eql.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"author": "Jake Luer <jake@alogicalparadox.com>",
|
||||
"contributors": [
|
||||
"Keith Cirkel (https://github.com/keithamus)",
|
||||
"dougluce (https://github.com/dougluce)",
|
||||
"Lorenz Leutgeb (https://github.com/flowlo)"
|
||||
],
|
||||
"main": "./index",
|
||||
"files": [
|
||||
"index.js",
|
||||
"deep-eql.js"
|
||||
],
|
||||
"scripts": {
|
||||
"bench": "node bench",
|
||||
"build": "browserify $npm_package_main --standalone deepEqual -o deep-eql.js",
|
||||
"lint": "eslint --ignore-path .gitignore .",
|
||||
"prepublish": "npm run build",
|
||||
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
|
||||
"pretest": "npm run lint",
|
||||
"test": "npm run test:node && npm run test:browser",
|
||||
"test:browser": "karma start --singleRun=true",
|
||||
"test:node": "istanbul cover _mocha",
|
||||
"upload-coverage": "lcov-result-merger 'coverage/**/lcov.info' | coveralls; exit 0",
|
||||
"watch": "karma start --auto-watch --singleRun=false"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"strict/es5"
|
||||
],
|
||||
"rules": {
|
||||
"complexity": 0,
|
||||
"no-underscore-dangle": 0,
|
||||
"no-use-before-define": 0,
|
||||
"spaced-comment": 0
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"type-detect": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@js-temporal/polyfill": "^0.4.1",
|
||||
"benchmark": "^2.1.0",
|
||||
"browserify": "^17.0.0",
|
||||
"browserify-istanbul": "^3.0.1",
|
||||
"coveralls": "^3.1.1",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-config-strict": "^14.0.1",
|
||||
"eslint-plugin-filenames": "^1.3.2",
|
||||
"istanbul": "^0.4.2",
|
||||
"karma": "^6.3.4",
|
||||
"karma-browserify": "^8.1.0",
|
||||
"karma-chrome-launcher": "^3.1.0",
|
||||
"karma-coverage": "^2.0.3",
|
||||
"karma-mocha": "^2.0.1",
|
||||
"karma-sauce-launcher": "^4.1.4",
|
||||
"kewlr": "^0.4.1",
|
||||
"lcov-result-merger": "^1.0.2",
|
||||
"lodash.isequal": "^4.4.0",
|
||||
"mocha": "^9.1.1",
|
||||
"simple-assert": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
}
|
||||
5
node_modules/@blockly/dev-tools/node_modules/loupe/CHANGELOG.md
generated
vendored
Normal file
5
node_modules/@blockly/dev-tools/node_modules/loupe/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
0.0.1 / 2013-12-17
|
||||
==================
|
||||
|
||||
* Initial port from chai.js
|
||||
9
node_modules/@blockly/dev-tools/node_modules/loupe/LICENSE
generated
vendored
Normal file
9
node_modules/@blockly/dev-tools/node_modules/loupe/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2011-2013 Jake Luer jake@alogicalparadox.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
63
node_modules/@blockly/dev-tools/node_modules/loupe/README.md
generated
vendored
Normal file
63
node_modules/@blockly/dev-tools/node_modules/loupe/README.md
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||

|
||||

|
||||

|
||||
|
||||
# What is loupe?
|
||||
|
||||
Loupe turns the object you give it into a string. It's similar to Node.js' `util.inspect()` function, but it works cross platform, in most modern browsers as well as Node.
|
||||
|
||||
## Installation
|
||||
|
||||
### Node.js
|
||||
|
||||
`loupe` is available on [npm](http://npmjs.org). To install it, type:
|
||||
|
||||
$ npm install loupe
|
||||
|
||||
### Browsers
|
||||
|
||||
You can also use it within the browser; install via npm and use the `loupe.js` file found within the download. For example:
|
||||
|
||||
```html
|
||||
<script src="./node_modules/loupe/loupe.js"></script>
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
``` js
|
||||
const { inspect } = require('loupe');
|
||||
```
|
||||
|
||||
```js
|
||||
inspect({ foo: 'bar' }); // => "{ foo: 'bar' }"
|
||||
inspect(1); // => '1'
|
||||
inspect('foo'); // => "'foo'"
|
||||
inspect([ 1, 2, 3 ]); // => '[ 1, 2, 3 ]'
|
||||
inspect(/Test/g); // => '/Test/g'
|
||||
|
||||
// ...
|
||||
```
|
||||
|
||||
## Tests
|
||||
|
||||
```bash
|
||||
$ npm test
|
||||
```
|
||||
|
||||
Coverage:
|
||||
|
||||
```bash
|
||||
$ npm run upload-coverage
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2011-2013 Jake Luer jake@alogicalparadox.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
219
node_modules/@blockly/dev-tools/node_modules/loupe/index.js
generated
vendored
Normal file
219
node_modules/@blockly/dev-tools/node_modules/loupe/index.js
generated
vendored
Normal file
@@ -0,0 +1,219 @@
|
||||
/* !
|
||||
* loupe
|
||||
* Copyright(c) 2013 Jake Luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
import inspectArray from './lib/array'
|
||||
import inspectTypedArray from './lib/typedarray'
|
||||
import inspectDate from './lib/date'
|
||||
import inspectFunction from './lib/function'
|
||||
import inspectMap from './lib/map'
|
||||
import inspectNumber from './lib/number'
|
||||
import inspectBigInt from './lib/bigint'
|
||||
import inspectRegExp from './lib/regexp'
|
||||
import inspectSet from './lib/set'
|
||||
import inspectString from './lib/string'
|
||||
import inspectSymbol from './lib/symbol'
|
||||
import inspectPromise from './lib/promise'
|
||||
import inspectClass from './lib/class'
|
||||
import inspectObject from './lib/object'
|
||||
import inspectArguments from './lib/arguments'
|
||||
import inspectError from './lib/error'
|
||||
import inspectHTMLElement, { inspectHTMLCollection } from './lib/html'
|
||||
|
||||
import { normaliseOptions } from './lib/helpers'
|
||||
|
||||
const symbolsSupported = typeof Symbol === 'function' && typeof Symbol.for === 'function'
|
||||
const chaiInspect = symbolsSupported ? Symbol.for('chai/inspect') : '@@chai/inspect'
|
||||
let nodeInspect = false
|
||||
try {
|
||||
// eslint-disable-next-line global-require
|
||||
const nodeUtil = require('util')
|
||||
nodeInspect = nodeUtil.inspect ? nodeUtil.inspect.custom : false
|
||||
} catch (noNodeInspect) {
|
||||
nodeInspect = false
|
||||
}
|
||||
|
||||
function FakeMap() {
|
||||
// eslint-disable-next-line prefer-template
|
||||
this.key = 'chai/loupe__' + Math.random() + Date.now()
|
||||
}
|
||||
FakeMap.prototype = {
|
||||
// eslint-disable-next-line object-shorthand
|
||||
get: function get(key) {
|
||||
return key[this.key]
|
||||
},
|
||||
// eslint-disable-next-line object-shorthand
|
||||
has: function has(key) {
|
||||
return this.key in key
|
||||
},
|
||||
// eslint-disable-next-line object-shorthand
|
||||
set: function set(key, value) {
|
||||
if (Object.isExtensible(key)) {
|
||||
Object.defineProperty(key, this.key, {
|
||||
// eslint-disable-next-line object-shorthand
|
||||
value: value,
|
||||
configurable: true,
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
const constructorMap = new (typeof WeakMap === 'function' ? WeakMap : FakeMap)()
|
||||
const stringTagMap = {}
|
||||
const baseTypesMap = {
|
||||
undefined: (value, options) => options.stylize('undefined', 'undefined'),
|
||||
null: (value, options) => options.stylize(null, 'null'),
|
||||
|
||||
boolean: (value, options) => options.stylize(value, 'boolean'),
|
||||
Boolean: (value, options) => options.stylize(value, 'boolean'),
|
||||
|
||||
number: inspectNumber,
|
||||
Number: inspectNumber,
|
||||
|
||||
bigint: inspectBigInt,
|
||||
BigInt: inspectBigInt,
|
||||
|
||||
string: inspectString,
|
||||
String: inspectString,
|
||||
|
||||
function: inspectFunction,
|
||||
Function: inspectFunction,
|
||||
|
||||
symbol: inspectSymbol,
|
||||
// A Symbol polyfill will return `Symbol` not `symbol` from typedetect
|
||||
Symbol: inspectSymbol,
|
||||
|
||||
Array: inspectArray,
|
||||
Date: inspectDate,
|
||||
Map: inspectMap,
|
||||
Set: inspectSet,
|
||||
RegExp: inspectRegExp,
|
||||
Promise: inspectPromise,
|
||||
|
||||
// WeakSet, WeakMap are totally opaque to us
|
||||
WeakSet: (value, options) => options.stylize('WeakSet{…}', 'special'),
|
||||
WeakMap: (value, options) => options.stylize('WeakMap{…}', 'special'),
|
||||
|
||||
Arguments: inspectArguments,
|
||||
Int8Array: inspectTypedArray,
|
||||
Uint8Array: inspectTypedArray,
|
||||
Uint8ClampedArray: inspectTypedArray,
|
||||
Int16Array: inspectTypedArray,
|
||||
Uint16Array: inspectTypedArray,
|
||||
Int32Array: inspectTypedArray,
|
||||
Uint32Array: inspectTypedArray,
|
||||
Float32Array: inspectTypedArray,
|
||||
Float64Array: inspectTypedArray,
|
||||
|
||||
Generator: () => '',
|
||||
DataView: () => '',
|
||||
ArrayBuffer: () => '',
|
||||
|
||||
Error: inspectError,
|
||||
|
||||
HTMLCollection: inspectHTMLCollection,
|
||||
NodeList: inspectHTMLCollection,
|
||||
}
|
||||
|
||||
// eslint-disable-next-line complexity
|
||||
const inspectCustom = (value, options, type) => {
|
||||
if (chaiInspect in value && typeof value[chaiInspect] === 'function') {
|
||||
return value[chaiInspect](options)
|
||||
}
|
||||
|
||||
if (nodeInspect && nodeInspect in value && typeof value[nodeInspect] === 'function') {
|
||||
return value[nodeInspect](options.depth, options)
|
||||
}
|
||||
|
||||
if ('inspect' in value && typeof value.inspect === 'function') {
|
||||
return value.inspect(options.depth, options)
|
||||
}
|
||||
|
||||
if ('constructor' in value && constructorMap.has(value.constructor)) {
|
||||
return constructorMap.get(value.constructor)(value, options)
|
||||
}
|
||||
|
||||
if (stringTagMap[type]) {
|
||||
return stringTagMap[type](value, options)
|
||||
}
|
||||
|
||||
return ''
|
||||
}
|
||||
|
||||
const toString = Object.prototype.toString
|
||||
|
||||
// eslint-disable-next-line complexity
|
||||
export function inspect(value, options) {
|
||||
options = normaliseOptions(options)
|
||||
options.inspect = inspect
|
||||
const { customInspect } = options
|
||||
let type = value === null ? 'null' : typeof value
|
||||
if (type === 'object') {
|
||||
type = toString.call(value).slice(8, -1)
|
||||
}
|
||||
|
||||
// If it is a base value that we already support, then use Loupe's inspector
|
||||
if (baseTypesMap[type]) {
|
||||
return baseTypesMap[type](value, options)
|
||||
}
|
||||
|
||||
// If `options.customInspect` is set to true then try to use the custom inspector
|
||||
if (customInspect && value) {
|
||||
const output = inspectCustom(value, options, type)
|
||||
if (output) {
|
||||
if (typeof output === 'string') return output
|
||||
return inspect(output, options)
|
||||
}
|
||||
}
|
||||
|
||||
const proto = value ? Object.getPrototypeOf(value) : false
|
||||
// If it's a plain Object then use Loupe's inspector
|
||||
if (proto === Object.prototype || proto === null) {
|
||||
return inspectObject(value, options)
|
||||
}
|
||||
|
||||
// Specifically account for HTMLElements
|
||||
// eslint-disable-next-line no-undef
|
||||
if (value && typeof HTMLElement === 'function' && value instanceof HTMLElement) {
|
||||
return inspectHTMLElement(value, options)
|
||||
}
|
||||
|
||||
if ('constructor' in value) {
|
||||
// If it is a class, inspect it like an object but add the constructor name
|
||||
if (value.constructor !== Object) {
|
||||
return inspectClass(value, options)
|
||||
}
|
||||
|
||||
// If it is an object with an anonymous prototype, display it as an object.
|
||||
return inspectObject(value, options)
|
||||
}
|
||||
|
||||
// last chance to check if it's an object
|
||||
if (value === Object(value)) {
|
||||
return inspectObject(value, options)
|
||||
}
|
||||
|
||||
// We have run out of options! Just stringify the value
|
||||
return options.stylize(String(value), type)
|
||||
}
|
||||
|
||||
export function registerConstructor(constructor, inspector) {
|
||||
if (constructorMap.has(constructor)) {
|
||||
return false
|
||||
}
|
||||
constructorMap.set(constructor, inspector)
|
||||
return true
|
||||
}
|
||||
|
||||
export function registerStringTag(stringTag, inspector) {
|
||||
if (stringTag in stringTagMap) {
|
||||
return false
|
||||
}
|
||||
stringTagMap[stringTag] = inspector
|
||||
return true
|
||||
}
|
||||
|
||||
export const custom = chaiInspect
|
||||
|
||||
export default inspect
|
||||
7
node_modules/@blockly/dev-tools/node_modules/loupe/lib/arguments.js
generated
vendored
Normal file
7
node_modules/@blockly/dev-tools/node_modules/loupe/lib/arguments.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import { inspectList } from './helpers'
|
||||
|
||||
export default function inspectArguments(args, options) {
|
||||
if (args.length === 0) return 'Arguments[]'
|
||||
options.truncate -= 13
|
||||
return `Arguments[ ${inspectList(args, options)} ]`
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user