diff --git a/src/engine/runtime.js b/src/engine/runtime.js index 169c880f7d7..3ce8a69f12a 100644 --- a/src/engine/runtime.js +++ b/src/engine/runtime.js @@ -1429,6 +1429,12 @@ class Runtime extends EventEmitter { break; } + // Check if "blockShape" is specified + if (blockInfo.blockShape) { + blockJSON.outputShape = blockInfo.outputShape || ScratchBlocksConstants.OUTPUT_SHAPE_ROUND; + } + + const blockText = Array.isArray(blockInfo.text) ? blockInfo.text : [blockInfo.text]; let inTextNum = 0; // text for the next block "arm" is blockText[inTextNum] let inBranchNum = 0; // how many branches have we placed into the JSON so far? diff --git a/src/extension-support/block-shape.js b/src/extension-support/block-shape.js new file mode 100644 index 00000000000..854975ada88 --- /dev/null +++ b/src/extension-support/block-shape.js @@ -0,0 +1,25 @@ +// Use the constants instead of manually redefining them again +const ScratchBlocksConstants = require('../engine/scratch-blocks-constants'); + +/** + * Types of block shapes + * @enum {number} + */ +const BlockShape = { + /** + * Output shape: hexagonal (booleans/predicates). + */ + HEXAGONAL: ScratchBlocksConstants.OUTPUT_SHAPE_HEXAGONAL, + + /** + * Output shape: rounded (numbers). + */ + ROUND: ScratchBlocksConstants.OUTPUT_SHAPE_ROUND, + + /** + * Output shape: squared (any/all values; strings). + */ + SQUARE: ScratchBlocksConstants.OUTPUT_SHAPE_SQUARE +}; + +module.exports = BlockShape; diff --git a/src/extension-support/tw-extension-api-common.js b/src/extension-support/tw-extension-api-common.js index e2ac0b74d0f..20503d56dcf 100644 --- a/src/extension-support/tw-extension-api-common.js +++ b/src/extension-support/tw-extension-api-common.js @@ -1,11 +1,13 @@ const ArgumentType = require('./argument-type'); const BlockType = require('./block-type'); +const BlockShape = require('./block-shape'); const TargetType = require('./target-type'); const Cast = require('../util/cast'); const Scratch = { ArgumentType, BlockType, + BlockShape, TargetType, Cast };