mirror of
https://github.com/google/blockly.git
synced 2026-01-08 01:20:12 +01:00
* refactor: Provide a BlockDefinition type
* refactor: Split defineBlocksWithJsonArray
Split defineBlocksWithJsonArray into:
- createBlockDefinitionsFromJsonArray, which creates BlockDefinitions
from a (possibly JSON-originated) POJsO array, having no side-effects
except possibly issuing warnings to the console.
- defineBlocks, which add any dictionary of BlockDefinitions to
the Blocks dictionary.
* feat(blocks): Export block definitions per-module
- Define all blocks in a local blocks dictionary, often using
createBlockDefinitionFromJsonArray, without registering them.
- Separately, use defineBlocks to register the exported
BlockDefinitions at the end of each Blockly.blocks.*
module.
- In Blockly.blocks.all, create a blocks export that combines all
of the blocks exports from the individual blocks modules.
* chore: have format script run clang-format on blocks/ too
34 lines
760 B
JavaScript
34 lines
760 B
JavaScript
/**
|
|
* @license
|
|
* Copyright 2013 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
/**
|
|
* @fileoverview A mapping of block type names to block prototype objects.
|
|
*/
|
|
'use strict';
|
|
|
|
/**
|
|
* A mapping of block type names to block prototype objects.
|
|
* @namespace Blockly.blocks
|
|
*/
|
|
goog.module('Blockly.blocks');
|
|
|
|
|
|
/**
|
|
* A block definition. For now this very lose, but it can potentially
|
|
* be refined e.g. by replacing this typedef with a class definition.
|
|
* @typedef {!Object}
|
|
*/
|
|
let BlockDefinition;
|
|
exports.BlockDefinition = BlockDefinition;
|
|
|
|
/**
|
|
* A mapping of block type names to block prototype objects.
|
|
* @type {!Object<string,!BlockDefinition>}
|
|
* @alias Blockly.blocks.Blocks
|
|
*/
|
|
const Blocks = Object.create(null);
|
|
exports.Blocks = Blocks;
|