feature(blocks): Export block definitions (#5908)

* 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
This commit is contained in:
Christopher Allen
2022-01-31 21:41:29 +00:00
committed by GitHub
parent 74ef1cbf52
commit ffb8907db8
16 changed files with 208 additions and 71 deletions

View File

@@ -626,7 +626,7 @@ function cleanBuildDir(done) {
* Runs clang format on all files in the core directory.
*/
function format() {
return gulp.src(['core/**/*.js'], {base: '.'})
return gulp.src(['core/**/*.js', 'blocks/**/*.js'], {base: '.'})
.pipe(clangFormatter.format('file', clangFormat))
.pipe(gulp.dest('.'));
};

View File

@@ -72,7 +72,6 @@
"./core/menuitem.js",
"./core/menu.js",
"./core/contextmenu.js",
"./core/blocks.js",
"./core/utils/global.js",
"./core/utils/useragent.js",
"./core/utils/svg.js",
@@ -264,6 +263,7 @@
"./core/xml.js",
"./core/connection.js",
"./core/common.js",
"./core/blocks.js",
"./closure/goog/base_minimal.js",
"./core/blockly.js",
"./blocks/variables_dynamic.js",