* docs: Make JSDoc @deprecated usage more consistent
* refactor(VariableMap)!: Refresh toolbox when map modified
Delete the following methods from WorkspaceSvg:
- renameVariableById
- deleteVariableById
- createVariable
Modify the following methods on VariableMap to call
this.workspace.refreshToolboxSelection() if this.workspace
is a WorkspaceSvg, replicating the behaviour of the
aforementioned deleted methods and additionally ensuring
that that method is called following any change to the
variable map:
- renameVariable
- changeVariableType
- renameVariableAndUses
- createVariable
- addVariable
- deleteVariable
BREAKING CHANGE:
This change ensures that the toolbox will be refreshed regardless
of what route the VaribleMap was updated, rather than only being
refreshed when it is updated via calls to methods on WorkspaceSvg.
Overall this is much more likely to fix a bug (where the toolbox
wasn't being refreshed when it should have been) than cause one
(by refreshing the toolbox when it shouldn't be), but this is
still a behaviour change which could _conceivably_ result an
unexpected regression.
* refactor(VariableMap): Remove calls to deprecated getVariableUsesById
Also refactor to use named imports core/variables.ts methods.
* refactor(Workspace): Use named imports for core/variables.ts methods
* refactor(FieldVariable): Remove call to deprecated getVariablesOfType
* refactor(variables): Remove calls to deprecated methods
* refactor(variables_dynamic): Remove call to deprecated getAllVariables
* refactor(xml): Remove calls to deprecated createVariable
* refactor(Events.VarCreate): Remove calls to deprecated methods
* refactor(Events.VarDelete): Remove calls to deprecated methods
* refactor(Events.VarRename): Remove calls to deprecated methods
* docs(events): JSDoc improvments
* fix(filter): Introduce enqueueEvent; don't reorder in filter
Remove the broken BlockChange event reordering code from filter.
Instead, do necessary event reordering (correctly, this time)
in a new enqueueEvent function used by fireInternal.
* chore(events): Deprecate forward parameter of filter
Since we don't filter in undo any more, and filtering in reverse
order causes problems, prepare to remove this opportunity for
error.
* fix(events): Only merge adjacent events
Simplify filter by having it consider only adjacent events in the
queue for merging.
Previously any events in the queue could potentially be merged if
they were of suitable (typically identical) .type, even if other
events had occurred between them (with the sole exception of
BlockMove events, which would only be merged with adjacent
events). This could potentially result in replay failures during
undo/redo/mirroring, though it is unknown whether any such
problems occurred in practice.
* refactor(events): Tweaks
- Use for…of loop where appropriate.
- Make filter reason-merging code more concise.
- Use arrow functions when calling Array.prototype.filter.
* chore(events): Fix typos for PR #8539.
* refactor(events): Introduce type predicates for event classes
Introduce predicates for testing Abstract event subclasses based on
their .type properties. These are useful because there are places
where it is not possible to use instanceof <ClassConstructor> tests
for type narrowing due to load ordering issues that would be caused
by the need to import (rather than just import type) the class
constructors in question.
* refactor(events): Use event type predicates
Simplify several sections of code by using type predicates for
type narrowing and thereby avoiding the need for explicit casts.
* chore(events): Fix copyright date of recently-added files
* chore: Remove unused import
Use of the filter function in Workspace.prototype.undo has caused
problems with repeated undo/redo (see issue #7026), the
originally-chosen fix for which was the addition (in PR #7069) of
code to fireNow to post-filter the .undoStack_ and .redoStack_ of
any workspace that had just been involved in dispatching events.
This apparently resolved the issue but added considerable
additional complexity and made it difficult to reason about how
events are processed for undo/redo.
Instead, since this filtering typically does nothing (at least
nothing desirable), simply don't re-filter events on the undo
stack before replaying them.
* refactor(events): Use "export ... from" where applicable
* refactor(events): Introduce EventType enum
Introduce an enum for the event .type values. We can't actually
use it as the type of the .type property on Abstract events,
because we want to allow developers to add their own custom
event types inheriting from this type, but at least this way we
can be reasonably sure that all of our own event subclasses have
distinct .type values—plus consistent use of enum syntax
(EventType.TYPE_NAME) is probably good for readability overall.
Put it in a separate module from the rest of events/utils.ts
because it would be helpful if event utils could use
event instanceof SomeEventType
for type narrowing but but at the moment most events are in
modules that depend on events/utils.ts for their .type
constant, and although circular ESM dependencies should work
in principle there are various restrictions and this
particular circularity causes issues at the moment.
A few of the event classes also depend on utils.ts for fire()
or other functions, which will be harder to deal with, but at
least this commit is win in terms of reducing the complexity
of our dependencies, making most of the Abstract event subclass
module dependent on type.ts, which has no imports, rather than
on utils.ts which has multiple imports.
* chore(deps): Add pretter-plugin-organize-imports
* chore: Remove insignificant blank lines in import sections
Since prettier-plugin-organize-imports sorts imports within
sections separated by blank lines, but preserves the section
divisions, remove any blank lines that are not dividing imports
into meaningful sections.
Do not remove blank lines separating side-effect-only imports
from main imports.
* chore: Remove unneded eslint-disable directives
* chore: Organise imports
* feat: Invalid Blocks
* Rename the new json property from invalid to invalidReasons.
* Merged isValid into isEnabled.
* Minor fixes.
* More minor fixes.
* Reverting some stuff that didn't need to change.
* Addressing PR feedback.
* Update the BlockInfo interface to match State.
* Make BlockChange.disabledReason private.
* chore: switch events to use new comment class
* fix: switch create and delete events to use JSON
* work on getting new comments to fire events
* chore: fixup tests
* chore: rename workspace comment test to comment view test
* chore: add tests for firing events
* chore: remove TODO
* fix(build): Restore erroneously-deleted filter function
This was deleted in PR #7406 as it was mainly being used to
filter core/ vs. test/mocha/ deps into separate deps files -
but it turns out also to be used for filtering error
messages too. Oops.
* refactor(tests): Migrate advanced compilation test to ES Modules
* refactor(build): Migrate main.js to TypeScript
This turns out to be pretty straight forward, even if it would
cause crashing if one actually tried to import this module
instead of just feeding it to Closure Compiler.
* chore(build): Remove goog.declareModuleId calls
Replace goog.declareModuleId calls with a comment recording the
former module ID for posterity (or at least until we decide
how to reformat the renamings file.
* chore(tests): Delete closure/goog/*
For the moment we still need something to serve as base.js for
the benefit of closure-make-deps, so we keep a vestigial
base.js around, containing only the @provideGoog declaration.
* refactor(build): Remove vestigial base.js
By changing slightly the command line arguments to
closure-make-deps and closure-calculate-chunks the need to have
any base.js is eliminated.
* chore: Typo fix for PR #7415
* Copy core/events/events_block_change.ts to core/events/events_block_field_intermediate_change.ts
* New intermediate event type for field edits.
* Addressing PR feedback.
* Ran npm run format.
* Fixed procedure mutator responding to param edits.
* Intermediate events now inherit from BlockBase.
* Addressing feedback on PR.
* chore: format
* 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: Add 'reason' field to move event
There are many types of move. This addition allows one to detect what the reason for each move is.
* Clang formatting.
And unsaved editor tabs.
* Change reason string to array.
* refactor: Remove uses of AnyDuringMigration from xml.ts.
* refactor: Remove uses of AnyDuringMigration from block_svg.ts.
* refactor: Remove uses of AnyDuringMigration from theme_manager.ts.
* refactor: Remove uses of AnyDuringMigration from names.ts.
* refactor: Remove uses of AnyDuringMigration from field_angle.ts.
* refactor: Remove some uses of AnyDuringMigration from block.ts.
* refactor: Make safename construction more readable.
* fix: Use a default size for block comments.
* fix: Clarify test of shadow block disposal.
* fix: Update assert in workspace_svg_test to use isDeadOrDying().
* refactor(xml): Move textToDom to core/utils/xml.ts
This function being in core/xml.ts was the cause for the last
remaining circular import in core/ (between variables.ts and
xml.ts).
Moving it to utils/xml.ts makes sense anyway, since there is
nothing Blockly-specific about this function.
Fixes#6817.
* fix(closure): Reenable goog.declareModuleId multiple-call check
Reenable an assertion which check to make sure that
goog.declareModuleId is not called more than once in a module
(and which also catches circular imports amongst ES modules, which
are not detected by closure-make-deps).
* chore(tests,demos): Augo-migrate use of textToDom
Testing the migration file entry by auto-migrating all uses of
Blockly.Xml.textToDom to Blockly.utils.xml.textToDom.
* chore(blocks): Manually migrate remaining use of textToDom
Update the one remaining call to textToDom (in blocks/lists.ts)
to the function's new location - also removing the last use of
the Blockly.Xml / core/xml.ts) module from this file.
* docs(xml): Remove unneeded @alias per comments on PR #6818
* fix(imports): Remove unused import
* chore: Remove uses of AnyDuringMigration in workspace_comment_svg.ts.
* chore: Remove uses of AnyDuringMigration in toolbox.ts.
* chore: Remove uses of AnyDuringMigration in field_colour.ts.
* chore: Remove uses of AnyDuringMigration from field_image.ts.
* chore: Remove uses of AnyDuringMigration from workspace.ts.
* Update core/workspace_comment_svg.ts
Co-authored-by: Christopher Allen <cpcallen+github@gmail.com>
* chore: Remove uses of AnyDuringMigration in collapsible_category.ts.
* chore: Revert unary - change to make clang-format happy.
* chore: Remove unnecessary quotes in toolbox.ts.
* Update core/workspace_comment_svg.ts
Co-authored-by: Christopher Allen <cpcallen+github@gmail.com>
---------
Co-authored-by: Christopher Allen <cpcallen+github@gmail.com>
* chore: make inline docs for events informative
* Notifies the developer -> Notifies listeners
* chore: cleanup from PR comments
* chore: final PR fixes
* chore: format