* fix(build): Correctly handle out-of-order chunks
It turns out that closure-calculate-chunks does not guarantee that
calculated chunks will be output in the same order as the
entrypoints, so modify getChunkOptions so that it no longer makes
that assumption.
* refactor(build): Introduce NAMESPACE_PROPERTY; rename NAMESPACE_OBJECT
Rename the constant NAMESPACE_OBJECT to NAMESPACE_VARIABLE to
better explain its actual meaning, and introduce
NAMESPACE_PROPERTY to specify what property the namespace object
will be stored in (and change the previous value, "internal_",
to "__namespace__" to reduce the chance of conflicts with
properties created by the output of Closure Compiler).
* refactor(build): Always save namespace object on chunk exports object
This is so that chunks whose parent chunk is not the root chunk
(chunks[0]) can obtain the namespace object. (See following commit.)
* fix(build): Correct handling of chunk dependencies
Previously getChunkOptions and chunkWrapper incorrectly assumed
that a chunk could have more than one dependency.
In fact, each chunk can have only a single dependency, which is
its parent chunk. It is used only to retrieve the namespace
object, which is saved on to the exports object for the chunk so
that any child chunk(s) can obtain it.
Update getChunkOptions and chunkWrapper (making the latter
longer but more readable) accordingly.
* refactor(build): Rename/repurpose chunk.exports -> .reexport
And remove chunk.importAs, since it was no longer being used
anywhere.
* fix: remove unnecessary s from reexports
Co-authored-by: alschmiedt <aschmiedt@google.com>
* feat(tests): Add a test script for the renamings file
* Make scripts/migration/renamings.js a valid JSON5 file.
* Add a schema for it in tests/migration/renamings-schema.json.
* Add a script to test one against the other, as
tests/migration/validate-renamings. It is a node.js script
that will exit 0 if the renamings file is valid, or 1 if it
is not (and print a not-very-helpful error message from which
is possible, with some effort, to deduce what the error is.)
* fix: convert to JSON5 and refactor example
* fix: convert keys to new key names
* fix: change versions to arrays instead of objects
* fix: fix version numbers
* fix: associate renames with the version where they were added
* fix: fixup example
* fix: put older renames at the bottom, and newer renames at the top
* fix: enable renamings test in run_all_tests
* fix: put newer renames back at the bottom
This reverts commit efe070e344.
* fix(tests): add missing additionalProperties: false to schema
And fix the resulting validation error in the example entry.
* chore(tests): Improve wording of example entry; add extra examples
Tweaked line wrapping of some existing entries (example and
acutal) that were otherwise untouched.
* feat: add dropDownDiv renaming to new database
* feat(tests): Check for duplicate entries for the same module
Also fixed extraneous whitespace in run_all_tests.sh
* fix(tests): Make validate-renamings.js compatible with node.js v12
Also remove success message, to adhere to usual unix convention
(silence implies success) as eslint does, and reduce unecessary
npm test output clutter.
* fix(tests): Fixes for PR #5980
* Fix typos.
* Remove redundant check.
Co-authored-by: Beka Westberg <bwestberg@google.com>
* Revert "fix: lint"
This reverts commit 050956d105.
* Revert "fix: run mocha as a module"
This reverts commit 4dac25ae99.
* Revert "move to modules, but break mocha"
This reverts commit 220d7bbd1d.
* refactor(tests): Migrate tests/compile/main.js to goog.module
* feat(tests): Enable --debug for test:compile:advanced; demote errors
* Enable the --debug flag when running the
buildAdvancedCompilationTest gulp task.
* Remove partialAlias diagnostic group from `JSC_ERROR`, demoting
JSC_PARTIAL_NAMESPACE to warning.
Reverts "Revert 'fix(tests): Enable --debug for test:compile:advanced;
fix some errors (#5959)'".
* fix: remove drop down div class
* fix: change name and export for drop down div
* fix: make module-local variables conform to styleguide
* fix: format
* fix: shadowing
* fix: move core test helpers into new directory
* fix: add test helpers to core and convert to goog modules
* fix: change tests to use local helpers
* fix: change local tests to use chai asserts
* fix: skip field tests in serializer b/c test blocks are unavailable
* fix: rename some helper files
* fix: rename some helper modules
* fix: split block helpers into code gen and serialization
* fix: split block defs into new helper file
* fix: split warning helpers into new file
* fix: split user input helpers into new file
* fix: split event helpers into a new file
* fix: split variable helper into new file
* fix: move remaining test helpers to new setup-teardown file
* fix: rename setup and teardown module
* fix: cleanup from rebase
* fix: undo accidental rename
* fix: lint?
* fix: bad toolbox definitions namespace
* fix: fixup warning helpers
* fix: remove inclusion of dev-tools in mocha tests
* move to modules, but break mocha
* fix: run mocha as a module
* fix: lint
* refactor: refactor tooltip show method
* refactor: make Tooltip a class that is accessed via a singleton
* revert: "refactor: make Tooltip a class that is accessed via a singleton"
This reverts commit b3d543cc35.
* feat: add the ability to set a custom tooltip function
* fix: check for null where it matters for types
* feat: Add a test for the custom tooltip function
* fix: fix formatting
* fix: format test
* fix: remove unnecessary teardown call in test
* Enable the --debug flag when running the
buildAdvancedCompilationTest gulp task.
* Migrate test/compile/main.js to goog.module.
* Use more selective goog.requires.
* Reduces compiled size from ~400k to ~370k.
* @suppress "extra" requires needed for side effects.
* refact: move super call to top of block svg
* refact: run conversion script on block svg and block
* fix: make debug build happy
* fix: tests
* style: format
* fix: cleanup from rebase
* fix: use new.target instead of a new parameter
* fix: add more overridden casted methods to BlockSvg
* style: fix typos
* style: move override tags to the end of JSDoc
* fix: cleanup from rebase
* refactor: Initial test at refactoring fields to ES6
* refact: reorganize text input and descendants to call super first
* refact: run conversion script on text input field and subclasses
* clean: cleanup fields post-conversion script
* refact: reorganize dropdown and variable fields to call super first
* refact: run class conversion script on dropdown and variable
* clean: clean fields post conversion script
* refact: reorganize misc fields to call super first
* refact: run conversion script on misc fields
* clean: cleanup misc fields after conversion
* fix: add setting the value and whatnot back to the base field. Pass sentinel conistently
* format
* refact: work on making debug compiler happy
* clean: finish making debug build happy
* fix: work on making tests happy
* fix: finish making tests happy
* Fix: fixup angle and multiline fields
* clean: format
* fix: move default value back to DEFAULT_VALUE
* fix: change SENTINEL to SKIP_SETUP
* fix: inline docs
* fix: some misc PR comments
* fix: format
* fix: make compiler hapy with new.target
* fix: types in FieldDropdown
* fix: add @final annotations to Field
* feat: move Sentinel to a utils file
* fix: remove ImageProperties from external API
* clean: cleanup chunks and deps
* fix: remove unnecessary properties from rows
* refactor: run conversion script on measurables
* clean: cleanup from conversion
* fix: make debug build happy
* clean: format
* fix: remove widthWithConnectedBlocks assignment on element
* fix: add inline docs for statementEdge
Because of our mis-use of @package, and the removal of the hack
that made it work reasonably (in PR #5918), compilation was
generating a large number of JSC_BAD_PACKAGE_PROPERTY_ACCESS
warnings, making it hard to see any other warnings/errors that
might be generated.
To make compiler diagnostics more useful, disable the visibility
diagnostic group entirely for the time being.
Also improve the documentation for JSCOMP_ERROR and the newly-
-introduced JSCOMP_WARNING and JSCOMP_OFF.
Rather than ignoring blockly_uncompressed.js, gulpfile.js and
core/utils/global.js entirely, add suitable eslint-disable directives
to those files so that they lint cleanly (and migrate gulpfile to
use const instead of var).
...and rename Blockly.blocks.all (blocks/all.js) to
Blockly.libraryBlocks (blocks/blocks.js
BREAKING CHANGE: (only) because the exports object from the
`blocks_compressed.js` chunk will be accessed as
`Blockly.libraryBlocks` instead of `Blockly.blocks.all` when the
chunk is loaded in a browser via a `<script>` tag. There will
be no changes visible when the chunk is loaded via ES module
`import` or CJS `require`.
* chore(deps): Update closure/goog/base.js, add goog.js
* Update base.js from the latest version (20220104.0.0).
* Also copy over goog.js, which provides access to asuitable subset
of goog.* via an importable module).
* refactor(tests): Have playground.html load Blockly as a module
N.B.:
* We still need a preparation step, in order to load base.js and
deps.js via <script> tags in uncompiled mode; in compiled mode
it will instead load all the *_compressed.js files via <script>
tags.
Acess to the Blockly object is via:
import Blockly from './playgrounds/blockly.mjs';
(N.B: no "* as", since blockly.mjs has only a default export.)
* There remain two serious defects when running in uncompiled mode:
* It does not attempt to load msg/messages.js, causing startup to
fail.
* Module loading only works if there are no ES Modules; if there
are, something goes wrong with base.js's attempt to sequence
module loads causing goog.modules that import ES modules to get
a null exports object for that import. X-(
* fix(tests): Have playground.html load messages.js before generators
This fixes the issue caused by missing messages when loading
the generators.
* fix(tests): Move bootsrap calls to prepare.js
Move the calls to goog.bootstrap from blockly.mjs to prepare.mjs.
This is needed to work around a bug in the Cosure Library debug
loader (https://github.com/google/closure-library/issues/1152).
This gets a bit ugly because most of the code has to go in a
<script> (because it needs goog.bootstrap, which was loaded by
an earlier <script> tag).
* fix(documentation): Minor comment corrections for PR #5931
* refact: convert toolbox items to ES6 classes
* fix: and SENTINEL so that contents can be parsed properly
* fix: fix types and whatnot related to new SENTINEL
* clean: format
* refactor: reorganize overridable calls into the init function, and remove sentinel
* clean: format
* fix: inline docs and organization
* fix(build): Correctly handle deep export paths
A problem can occur when loading chunks in a browser: although
factory() will create the full exported path on $, and thus the
assignment
root.<path> = factory(...) { ...; return $.<path> }
will normally be a do-nothing in every chunk except the first, if
the exported path (e.g. Blockly.blocks.all) is more than one level
deeper than any previously-existing path (e.g. Blockly), this will
fail because root.<path> is evaluated before calling factory(), and
so the left hand side will will evaluate to a undefined reference
(e.g. undefined.all) and TypeError will be thrown before the call
to factory is evaluated.
To fix this, call factory first and store the exports object in a
variable before assigning it to the exported path.
Fixes#5932.
* refactor: convert shortcut registry to es6 class
* refactor: convert context menu registry to es6 class
* refactor: convert registry type to es6 class
* chore: format
* chore: respond to PR comments