* feat(generators): Pass this CodeGenerator to generator functions
This implements option 1A of proposal 1 of #7086.
This commit is not by itself a breaking change, except in the unlikely event that
developers' custom generator functions take an (optional) second argument of a
dfferent type.
* feat(generators): Accept generator argument in block functions
Accept a CodeGenerator instance as parameter two of every
per-block-type generator function.
* fix(generators): Pass generator when calling other generator functions
Make sure to pass generator to any other block functions that are
called recursively.
* refactor(generators)!: Use generator argument in generator functions
Refactor per-block-type generator functions to use the provided
generator argument to make recursive calls, rather than depending
on the closed-over <lang>Generator instance.
This allows generator functions to be moved between CodeGenerator
instances (of the same language, at least).
This commit was created by search-and-replace and addresses most
but not all recursive references; remaining uses will require
manual attention and will be dealt with in a following commit.
BREAKING CHANGE: This commit makes the generator functions we provide
dependent on the new generator parameter. Although
CodeGenerator.prototype.blockToCode has been modified to supply this,
so this change will not affect most developers, this change will be a
breaking change where developers make direct calls to these generator
functions without supplying the generator parameter. See previous
commit for an example of the update required.
* refactor(generators): Manual fix for remaining uses of langGenerator
Manually replace remaining uses of <lang>Generator in block
generator functions.
* fix(generators): Delete duplicate procedures_callnoreturn generator
For some reason the generator function for procedures_callnoreturn
appears twice in generators/javascript/procedures.js. Delete the
first copy (since the second one overwrote it anyway).
* chore(generators): Format
Addresses various nits that escaped previous PRs:
* Add TSDoc for `BlockGenerator` in `core/generator.ts` for PR #7150.
* Fix bad formating in `generators/javascript.js` from PR #7153.
* Add missing `@enum` tag that should have been included in PR #7160.
* Delete obsolete comment from `generators/python.js` for PR #7163.
* refactor(generators): Introduce class JavascriptGenerator
Also fix an import ordering error.
* refactor(generators): Use Order.* instead of .ORDER_*
* refactor(generators): Don't rename javascriptGenerator
* feat(generators): Add block generator function dictionary
Add a dictionary of block generator functions, provisionally
called .forBlock. Look up generator functions there first, but
fall back to looking up on 'this' (with deprecation notice)
for backwards compatibility.
Also tweak error message generation to use template literal.
* refactor(generators)!: Update generator definitions to use dictionary
* fix(tests): Have blockToCodeTest clean up after itself
Have the blockToCodeTest helper function delete the block generator
functions it adds to generator once the test is done.
* refactor(tests): Use generator dictionary in insertion marker test
The use of generators in insertion_marker_test.js was overlooked
in the earlier commit making such updates, and some test here
were failing due to lack of cleanup in
cleanup in the generator_test.js.
BREAKING CHANGE: this PR moves the generator functions we provide
from their previous location directly on the CodeGenerator instances
to the new .forBlock dictionary on each instance. This does not oblige
external developers to do the same for their custom generators, but
they will need to update any code that references the generator
functions we provide (in generators/*/*, i.e. on javascriptGenerator,
dartGenerator etc.) e.g. to replace the implementation or reuse the
implementation for a different block type.
* feat: add basic mutator icon
* feat: add actual mutation behavior to icon
* chore: add bumping blocks back into the bubble
* fix: add updating block styles
* feat: add static methods to mutator icon
* chore: delete old mutator code
* fix: use the new mutator icon
* chore: docs and format
* chore: my own comments
* chore: first pass at PR comments
* chore: make type strings internal
* chore: add todo
* chore: format
* chore: move properties to module level
* chore: fix using in demos
* chore: move Mutator to icons.MutatorIcon
* chore: move reconnect to connection
* chore: move findParentWs to workspace
* chore: properly override and call super
* chore: remove bubbleIsVisible check
* chore: change imports to import type
* chore: use elvis operator
* chore: update renamings
* chore: reduce changes to js block files
* feat(j2ts): Add support for migrating renaming imports
Convert
const {foo: bar} = require(/*...*/);
into
import {foo as bar} from /*...*/;
^^^^^^^^^^
Also fix a bug that caused relative paths to ESM in the same
directory to be missing a leading "./".
* fix(build): Fix trivial error exports for generators
The UMD wrapper was inadvertently exporting the contents of (e.g.)
the Blockly.JavaScript closure module rather than the intended
export of Blockly.JavaScript.all module - which went unnoticed
because the latter just reexported the former - but we are
about to convert the former to ESM.
* chore(generators): Migrate language generators to ESM
Migrate the main language generators in generators/*.js to ESM.
This was done by running js2ts on the files, renaming them back
to .js, and commenting out "import type" statements, which are
legal TS but not needed in JS (at least if you are not actually
letting Closure Compiler do type checking, which we are not.)
* chore(generators): Migrate block generators to ESM
Migrate generators/*/*.js (except all.js) to ESM.
This was done by running js2ts on the files, renaming them back
to .js, and removing now-spurious @suppress {extraRequire}
directives.
* chores(generators): Migrate generator chunk entrypoints to ESM
This was done by running js2ts on the files, renaming them back
to .js, and manually fixing the export statements.
An additional change to the chunk exports configuration in
build_tasks.js was necessary in order for the UMD wrapper to
find the new module object, which is given a different name
than the old exports object.
* feat: Added basic example test for Blockly Playground and Blockly Demo
* feat: Added basic example test for Blockly Playground and Blockly Demo
* feat: Added basic example test for Blockly Playground and Blockly Demo
* feat: Added basic example test for Blockly Playground and Blockly Demo
* feat: Added basic example test for Blockly Playground and Blockly Demo
* feat: Added basic example test for Blockly Playground and Blockly Demo
* feat: Added basic example test for Blockly Playground and Blockly Demo
* feat: Added basic example test for Blockly Playground and Blockly Demo
* feat: Added basic example test for Blockly Playground and Blockly Demo
* feat: Added basic example test for Blockly Playground and Blockly Demo
* feat: Added basic example test for Blockly Playground and Blockly Demo
* feat: Added basic example test for Blockly Playground and Blockly Demo
* feat: Added basic example test for Blockly Playground and Blockly Demo
* feat: Add functionality to run playground and block factory test locally
* feat: Add functionality to run playground and block factory test locally
* feat: Add functionality to run playground and block factory test locally
* feat: Add functionality to run playground and block factory test locally
* feat: Create procedure test
* feat: Create procedure test
* feat: Create procedure test
* chore: test for procedures
* chore(deps): Bump @hyperjump/json-schema from 0.23.3 to 1.5.0
Bumps [@hyperjump/json-schema](https://github.com/hyperjump-io/json-schema) from 0.23.3 to 1.5.0.
- [Commits](https://github.com/hyperjump-io/json-schema/compare/v0.23.3...v1.5.0)
---
updated-dependencies:
- dependency-name: "@hyperjump/json-schema"
dependency-type: direct:development
update-type: version-update:semver-major
...
Signed-off-by: dependabot[bot] <support@github.com>
* chore(tests): Compatibility updates to validate-renamings.js
A minimal set of updates to validate-renamings.js to make it
compatible with @hyperjump/json-schema v1.5. The main difference
is that that package now ships ESM rather than CJS modules,
forcing the script to use import rather than require, with
various knock-on effects (no __dirname variable, must be named
*.mjs, etc.)
* chore(tests) Remove unneeded IIFE
* chore(tests): Additional tidy-up of ESM version
Now that validate-renamings is an ES module, we can do some other
cleanup to it.
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Christopher Allen <cpcallen+git@google.com>