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).
* 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
* 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
* refactor: move optional function declarations into the constructor
* refactor: convert options.js to es6 class
* refactor: convert generator.js to es6 class
* refactor: convert workspace_events.js to es6 class
* refactor: convert events_abstract.js to an es6 class
* chore: format
* chore: fix lint
* chore: rebuild
* chore: respond to PR feedback
Same as PR #5640, except for the addition of a parameter in the JSON to turn this on or off. While one would normally want animations/sounds on (e.g. undo/redo stack) sometimes they'd be annoying (e.g. events from realtime collaborators).
* refactor: update several files to es6 classes
* refactor: update several files to es6 classes
* chore: add some type casts for specificity about event types
* chore: run formatter
* chore: rebuild
* refactor: update workspace_comment and _svg to es classes
* refactor: update classes that extend icon to es classes
* refactor: update icon to es6 class
* refactor: update connection classes to es6 classes and add casts as needed
* refactor: update scrollbar to es6 class and add casts as needed
* refactor: update workspace_svg to es6 class
* refactor: update several files to es6 classes
* refactor: update several files to es6 classes
* refactor: update renderers/common/info.js to es6 class
* refactor: update several files to es6 classes
* chore: rebuild deps.js
* chore: run format
* chore: use casts to narrow types in renderers
* chore: add @struct and type information on common measurables
* refactor: update some renderer measurables to es6 classes
* refactor: convert many measurables to es6 classes
* chore: format
* chore: rebuild
* 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
* refactor: convert flyout_button.js to ES6 class
* chore: move some properties into constructor and add annotations for flyout base
* refactor: convert flyout_horizontal.js to ES6 class
* refactor: convert flyout_vertical.js to ES6 class
* refactor: convert flyout_base.js to ES6 class
* refactor: convert flyout_metrics_manager.js to ES6 class
* refactor: convert insertion_marker_manager.js to ES6 class
* refactor: convert metrics_manager.js to ES6 class
* refactor: convert grid.js to ES6 class
* refactor: convert input.js to ES6 class
* refactor: convert touch_gesture.js to ES6 class
* refactor: convert gesture.js to ES6 class
* refactor: convert trashcan.js to ES6 class
* chore: rebuild and run format
* chore: fix review comments
* chore: respond to PR comments
* chore(tests): update event assert functions to pass in types directly
* refactor: move event types from prototypes to constructors
* refactor: convert events/events_block_change.js to ES6 class
* refactor: convert events/events_block_create.js to ES6 class
* refactor: convert events/events_block_delete.js to ES6 class
* refactor: convert events/events_block_drag.js to ES6 class
* refactor: convert events/events_block_move.js to ES6 class
* refactor: convert events/events_click.js to ES6 class
* refactor: convert events/events_comment_change.js to ES6 class
* refactor: convert events/events_comment_create.js to ES6 class
* refactor: convert events/events_comment_delete.js to ES6 class
* refactor: convert events/events_comment_move.js to ES6 class
* refactor: convert events/events_marker_move.js to ES6 class
* refactor: convert events/events_selected.js to ES6 class
* refactor: convert events/events_theme_change.js to ES6 class
* refactor: convert events/events_toolbox_item_select.js to ES6 class
* refactor: convert events/events_trashcan_open.js to ES6 class
* refactor: convert events/events_ui.js to ES6 class
* refactor: convert events/events_var_create.js to ES6 class
* refactor: convert events/events_var_delete.js to ES6 class
* refactor: convert events/events_var_rename.js to ES6 class
* refactor: convert events/events_viewport.js to ES6 class
* chore: rebuild
* chore: run clang-format
* refactor: convert menu.js to ES6 class
* refactor: convert menuitem.js to ES6 class
* refactor: convert scrollbar_pair.js to ES6 class
* chore: define properties in the constructor in names.js
* refactor: convert names.js to ES6 class
* chore: run clang-format
* refactor: convert utils/coordinate.js to ES6 class
* refactor: convert utils/rect.js to ES6 class
* refactor: convert utils/size.js to ES6 class
* refactor: convert block_drag_surface.js to ES6 class
* refactor: convert block_dragger.js to ES6 class
* refactor: convert bubble_dragger.js to ES6 class
* chore: declare bubble property in the constructor
* refactor: convert bubble.js to ES6 class
* chore: clang-format
* chore(lint): lint and format
* refactor: move properties to constructor in block_drag_surface.js
* refactor: move properties to constructor in block_svg.js
* refactor: move properties to constructor in block.js
* refactor: move properties to constructor in bubble.js
* refactor: move properties to constructor in connection.js
* refactor: move properties to constructor in flyout_base.js
* refactor: move properties to constructor in flyout_button.js
* refactor: move properties to constructor in generator.js
* refactor: move properties to constructor in grid.js
* refactor: move properties to constructor in input.js
* refactor: move properties to constructor in mutator.js
* refactor: move properties to constructor in scrollbar.js
* refactor: move properties to constructor in trashcan.js
* refactor: move properties to constructor in warning.js
* refactor: move properties to constructor in workspace_audio.js
* refactor: move properties to constructor in workspace_drag_surface_svg.js
* refactor: move properties to constructor in workspace_svg.js
* refactor: move properties to constructor in workspace.js
* refactor: move properties to constructor in zoom_controls.js
* chore: rebuild
* refactor: convert zoom_controls.js to es6 class and format
* refactor: convert workspace_audio.js to es6 class and format
* refactor: convert workspace_dragger.js to es6 class and format
* refactor: convert workspace_drag_surface_svg.js to es6 class and format
* refactor: convert variable_model.js to es6 class and format
* refactor: convert variable_map.js to es6 class and format
* refactor: convert theme.js to es6 class and format
* chore: remove bad comment
Observed this error in Blockly Games Bird 6 (Chrome OS):
Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.
It has only shown up once, and I can't reproduce, but it looks like the drag surface was being cleared while empty. Maybe some weird multi-touch operation?
Open question: Leave the code as is so that the error is thown and visible, or supress it?
* Change getCandidate_ and showInsertionMarker_ to be more dynamic
* Ran clang formatter
* Fix typos
* Fix issue with dragging stacks
* From PR comment
* Add deprecation warnings and reorganize blockly.js
* Update usages of deprecated properties
* chore: make dates consistent, remove extra function
* chore: run clang-format and fix lint
* chore: add more tags
* chore: fix updated location of Align types
* chore: fix deprecated usages in tests
* chore: rebuild deps
* chore: fix moved Align types in demos and tests
* chore: update which properties are actually deprecated
* chore: don't deprecate Blockly.selected.
* chore: Remove requires that duplicate those in blockly.js
* refactor: Remove core/requires.js, make blockly.js be entry point
It sort of makes sense, doesn't it?
The only remaining require not duplicated in `blockly.js` was that for
`Blockly.themes.Classic`, but it is already required by
`Blockly.themes` (itself required by `Blockly`).
* fix(test): Fix advanced compilation test
- Fix loading of blocks in `tests/compile/main.js` caused by
recent `goog.module`-ification work.
- Fix problem caused by ADVANCED_OPTIMISATIONS renaming the Msg
property on the fake Blockly object created by the
translation-loading hack in `blockly.js`.
* chore(build): Reenable advanced compilation test
Fixes#5602.
* chore: revert #5730
* fix: Fix compile failure due to incorrect visibility
The CONTROL_FLOW_IN_LOOP_CHECK_MIXIN is intended to be used outside of
blocks/ (it is, in particular, used in generators/) so it should have
been marked @public from the beginning.
This constant is used to specify the alignment of
an Input, so it should live in the same file as the Input class.
I've done this as a separate named export, but it could alternatively
be made a static member of Input (i.e., Input.Align with only Input
being exported by name).
Where mocha tests were referring to Blockly.constants.ALIGN.*
without actually requiring Blockly.constants, I have reverted
them to refer to Blockly.ALIGN_* instead (pending conversion
to named requries).
Part of #5073.
* chore(build): Add "all" modules for blocks & generators
These modules (Blockly.blocks.all and Blockly.<Generator>.all) will
be the entry points for the corresponding chunks.
They also make it easier to pull in all the modules in each package
(e.g. for playground and tests).
It is necessary to set the Closure Compiler dependency_mode to
SORT_ONLY as otherwise it tries to compile the "all" modules before
their dependencies, which fails.
The only impact on the _compressed.js files is the addition of a short
string to the very end of each file, e.g.:
var module$exports$Blockly$JavaScript$all={};
* chore(deps): Add devDependency on closure-calculate-chunks
* feat(build): First pass at chunked complation
Add a new buildCompiled gulp target (npm run build:compiled) that
uses closure-calculate-chunks to do chunked compliation of core/,
blocks/ and generators/ all in a single pass.
This work is incomplete: the resulting *_compressed.js files don't
(yet) have UMD wrappers.
* chore(build): Generate chunk wrappers
A first pass; this does not have support for a namespace object yet.
* refactor(build): Use chunked compilation by default
Remove old "compressed" gulp tasks in favour of new "compiled" task.
* chore(build): Remove cruft from buildCompiled
Remove unneeded `done` parameter and commented-out options that had
been cargo-culted from the old build pipeline.
* fix(build): Fix test failures caused by new build pipeline
- Exclude closure/goog/base.js from compiler input; use
externs/goog-externs.js instead.
- Have the build:debug and build:strict targets only build the first
chunk (blockly_compressed.js).
- Fix namespace entries for blocks and generators.
* fix(build): Fix build failures on node v12
closure-calculate-chunks requires node.js v14 or later.
When running on node.js v14 or later have getChunkOptions save
the output of closure-calculate-chunks to
scripts/gulpfiles/chunks.json. When running on older versions of
node.js have it use this checked-in, cached output instead of
attempting to run closure-calculate-chunks.
* chore(build): enable --rename_prefix_namespace
This will allow modules in blocks/ and generators/ to use
goog.require to obtain the exports object of goog.modules from
core/.
* fix(build): Always build all chunks
The previous commit enabled --rename_prefix_namespace option to
Closure Compiler, and this causes the buildCompressed target to
work fine when run without --debug or --strict, but adding either
of those flags (as for example when `npm test` runs
`npm run build:debug`) causes an issue:
- Because of many compiler errors in blocks/ and generators/,
a previous commit added a hack to only build the first chunk
when doing debug/strict builds.
- When asked to build only one chunk, Closure Compiler ignores the
--rename_prefix_namespace flag, because it 'correctly' infers
that there are no later chunks that will need to access global
variables from the first chunk.
- This causes a test failure, because `npm test` first runs
`npm run build`, which generates a valid blockly_compressed.js,
but this is then overrwritten by an invalid one when it next runs
`npm run build:debug`.
(The invalid one is missing all `$.` prefixes on 'global' variables,
including on Blockly, so the wrapper's last two lines -
"$.Blockly.internal_ = $;" and "return $.Blockly" - fail.)
The fix is to add appropriate @suppress annotations to blocks/*.js and
generators/**/*.js and then remove the first-chunk-only hack.
* refactor(build): Just build once
Since the previous commit caused `npm run build:debug` to do
everything that `... build:compressed` does - and to produce
byte-for-byte identical output - it doesn't make sense to run
both when testing. To that end:
- Replace the build:debug and build:strict package scripts that
did `gulp buildCompressed --...` with new scripts build-debug
and build-strict that do `gulp build --...` instead.
(The target names are changed so as to extend our existing naming
convention as follows: a target named "foo:bar" does some sub-part
of the job done by target "foo", but a target named "foo-bar" does
all the work of the target "foo" with some extra options.)
- build:debug:log and build:strict:log are similarly replaced with
build-debug-log and build-strict-log.
- Modify run_all_tests.js to just do `npm run build-debug` instead of
doing both `npm run build` and `npm run build:debug`.
- Also remove the 'build:blocks' script that should have been removed
when the buildBlocks gulp task was deleted previously.
* refactor(build): Compile with base_minimal.js instead of base.js
Introduce a (very!) cut-down version of closure/goog/base.js named
base_minimal.js that is used as input to the compiler as an
alternative to using externs/goog-externs.js (which will be deleted
once the buildAdvancedCompilationTest target has been updated).
This will allow use of goog.setTestOnly since it will now exist in
compiled mode, and allows the changes made in 5b112db to filter
base.js out of the files for the first chunk to be reverted.
(It also obliges a change to the compiled-mode check in blockly.js.)
* fix(build): Fix buildAdvanceCompilationTest
- In build_tasks.js:
- Replace the old compile() function with a new one factored out of
buildCompiled().
- Update buildAdvancedCompilationTest to use the new compile()
and other helpers created in the meantime.
- Remove no-longer-used maybeAddClosureLibrary().
- Remove externs/{block,generator,goog}-externs.js, which are no longer
used by any compile pipeline.
- Update core/blockly.js to fix issue with detection of compiled mode
when using ADVANCED_OPTIMISATIONS.
- Update only other use of globalThis, in core/utils/xml.js, to
consistently treat it as a dictionary object.
- Update instructions in tests/compile/index.html.
This commit is sort-of-a-prerequisite to #5602; test:compile:advanced
was previously working but the generated `main_compresed.js` would
throw errors upon loading.
The e.pageX (and .pageY) checks aren't strict enough. 0 is a perfectly valid coordinate.
Checking for the existence of changedTouches is an easier way to distinguish a PointerEvent from a TouchEvent.
* Add new connection checks and tests
* Enable concurrent output and previous connections on blocks
* and remove assumption from unplug().
* Make changes compatible with new module system
* Fix issue do to Connection class change.
. and change some var's to const's now that that appears to be ok ;-)
* Fix more code that assumes only one of output and previous connections
* Change function name as per PR comment
* Fix lint errors
* Fix clang format issues