Commit Graph

392 Commits

Author SHA1 Message Date
Tasheena
a481253bb4 refactor(VariableMap): Stop using deprecated wrapper methods (#9340)
* refactor(VariableMap): Stop using deprecated wrapper methods

* fix format

* fix: Apply review suggestions

Co-authored-by: Christopher Allen <cpcallen+github@gmail.com>

* fix: restore blank line

---------

Co-authored-by: Christopher Allen <cpcallen+github@gmail.com>
2025-09-24 15:23:41 +00:00
Ben Henning
4074cee31b feat!: Make everything ISelectable focusable (#9004)
* feat!: Make bubbles, comments, and icons focusable

* feat!: Make ISelectable and ICopyable focusable.

* feat: Consolidate selection calls.

Now everything is based on focus with selection only being used as a
proxy.

* feat: Invert responsibility for setSelected().

Now setSelected() is only for quasi-external use.

* feat: Push up shadow check to getters.

Needed new common-level helper.

* chore: Lint fixes.

* feat!: Allow IFocusableNode to disable focus.

* chore: post-merge lint fixes

* fix: Fix tests + text bubble focusing.

This fixed then regressed a circular dependency causing the node and
advanced compilation steps to fail. This investigation is ongoing.

* fix: Clean up & fix imports.

This ensures the node and advanced compilation test steps now pass.

* fix: Lint fixes + revert commented out logic.

* chore: Remove unnecessary cast.

Addresses reviewer comment.

* fix: Some issues and a bunch of clean-ups.

This addresses a bunch of review comments, and fixes selecting workspace
comments.

* chore: Lint fix.

* fix: Remove unnecessary shadow consideration.

* chore: Revert import.

* chore: Some doc updates & added a warn statement.
2025-05-09 08:16:14 -07:00
RoboErikG
04a31f950f fix: Wrap toolbox refreshes in a timeout when modifying variables (#8980) 2025-05-06 10:58:05 -07:00
Aaron Dodson
bcdb65c623 release: Merge branch 'develop' into rc/v12.0.0 2025-01-10 10:53:09 -08:00
Aaron Dodson
4dcffa0914 fix: Don't create intermediate variables when renaming a procedure argument. (#8723) 2025-01-08 09:37:28 -08:00
Aaron Dodson
b8bb26f8fd fix: Fix serialization of the lists_split block. (#8702) 2025-01-06 10:54:33 -08:00
Aaron Dodson
9fcd5a3037 release: Merge branch 'rc/v11.2.0' into rc/v12.0.0 2024-12-04 12:06:12 -08:00
Aaron Dodson
cd1e540cca fix: Disable newly created function call blocks when the corresponding definition is disabled. (#8665) 2024-12-03 13:40:26 -08:00
John Nesky
51f6dab0b2 fix: Simplify list and text WHERE validation (#8575)
* fix: Simplify list and text WHERE validation

* Addressing PR review comments.
2024-09-20 14:46:06 -07:00
Aaron Dodson
14d119b204 fix: improve prompting when deleting variables (#8529)
* fix: improve variable deletion behaviors.

* fix: don't prompt about deletion of only 1 variable block when triggered programmatically.

* fix: include the triggering block in the count of referencing blocks

* fix: only count the triggering block as a referencing block if it's not in the flyout
2024-08-19 15:47:00 -07:00
Christopher Allen
ce22f42868 chore: Organise imports (#8527)
* 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
2024-08-15 03:16:14 +01:00
Christopher Allen
ebb56b2ce8 docs(blocks): block.ts and blocks/* JSDoc / formatting / etc. cleanup (#8431)
* docs(block): Improve documentation for well-known block methods

  Improve the JSDocs for the declarations of well-known block
  methods:

  - getDeveloperVariables
  - compose
  - decompose
  - saveConnections

* docs(blocks): Improve block comments

  Fix JSDoc formatting in both core/block.ts and blocks/*, as well as
  making various other minor improvments.

* chore(blocks): Remove one unexported const
2024-07-25 17:25:24 +01:00
Aaron Dodson
294ef74d1b refactor: Use IVariableModel instead of VariableModel. (#8400)
* refactor: Use IVariableModel methods instead of directly accessing properties.

* refactor: replace references to VariableModel with IVariableModel.
2024-07-19 14:58:04 -07:00
Neil Fraser
4e688bf949 fix: Don't record undo events for enable/disable (#8058)
There's no need to record and replay these events since the change will happen automatically anyway.

Resolves #7951
2024-05-07 20:33:50 +02:00
John Nesky
cee7f916bb feat!: Invalid Blocks (#7958)
* 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.
2024-04-17 19:47:51 -07:00
Beka Westberg
ed403d0b77 feat!: change gestures to look at selected when dragging (#7991)
* feat: change gestures to look at selected when dragging

* chore: fix tests

* chore: format

* chore: PR comments
2024-04-04 08:52:43 -07:00
Christopher Allen
10ffcb706d release: Merge branch 'develop' into rc/v11.0.0 2024-03-18 19:57:04 +00:00
Neil Fraser
0ecbcde9fc chore: Use .includes and .startsWith, not .indexOf (#7936)
Easier to read than the diverse collection of `=== 0` and `!== -1` and `> -1` tests.
2024-03-15 00:03:55 +01:00
Rachel Fenichel
67c3aae76c feat!: delete angle, colour, and multiline input fields and blocks (#7932)
* chore: delete mocha tests for angle field

* feat! : delete angle field

* chore(tests): delete colour tests from generator tests and golden files

* chore: delete colour blocks and associated generators

* chore: remove colour blocks from playgrounds

* chore: delete mocha tests for colour fields

* chore: fix incorrect comment

* chore: delete colour field from core

* chore: delete multiline input tests from generators tests and golden files

* chore: delete multiline text block and associated generators

* chore: remove multiline text block from playgrounds

* chore: delete mocha tests for multiline input field

* chore: delete multiline input field from core
2024-03-13 13:28:26 -07:00
Beka Westberg
cac6b64ab0 chore: merge develop into v11 2024-03-12 16:10:59 +00:00
devilhyt
a20a8a77cf fix: libraryBlocks exports 2024-02-25 17:56:25 +08:00
Beka Westberg
5db9b5bf11 fix: block initialization (#7777)
* fix: reorganize initialization

* chore: fix failing tests

* fix: tests

* chore: format

* chore: remove console trace
2024-01-23 08:48:08 -08:00
Beka Westberg
75007a064c chore!: delete deprecations for v11. (#7732)
* chore: delete basic deprecations

* chore: remove deprecated align enum

* chore: remove generator deprecation

* chore: format
2024-01-23 08:48:08 -08:00
Christopher Allen
4ab8d00099 refactor(generators): Migrate JavaScript generators to TypeScript (#7602)
* refactor(generators): Migrate javascript_generator.js to TypeScript

* refactor(generators): Simplify getAdjusted

  Slightly simplify the implementation of getAdjusted, in part to
  make it more readable.  Also improve its JSDoc comment.

* refactor(generators): Migrate generators/javascript/* to TypeScript

  First pass doing very mechanistic migration, not attempting to fix
  all the resulting type errors.

* fix(generators): Fix type errors in generator functions

  This consists almost entirely of adding casts, so the code output
  by tsc should be as similar as possible to the pre-migration .js
  source files.

* refactor(generators): Migrate generators/javascript.js to TypeScript

  The way the generator functions are added to
  javascriptGenerator.forBlock has been modified so that incorrect
  generator function signatures will cause tsc to generate a type
  error.

* chore(generator): Format

  One block protected with // prettier-ignore to preserve careful
  comment formatting.

  Where there are repeated concatenations prettier has made a pretty
  mess of things, but the correct fix is probably to use template
  literals instead (rather than just locally disabling prettier).
  This has been added to the to-do list in #7600.

* fix(generators): Fixes for PR #7602

* fix(generators): Fix syntax error
2023-10-30 08:16:13 +00:00
Hady Bazzi
c8cc33a01a fix: text join block warning when using block-plus-minus plugin (#7598) 2023-10-20 10:18:33 -07:00
John Nesky
1b2e91246e chore: Use JSON objects for context menu callbackFactory (#7382)
* chore: use json object for context callbackFactory

* Add test file for context menu callback function.
2023-09-08 16:16:59 -07:00
Christopher Allen
b0a7c004a9 refactor(build): Delete Closure Library (#7415)
* 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
2023-08-31 00:24:47 +01:00
dependabot[bot]
2546b01d70 chore(deps): Bump prettier from 2.8.8 to 3.0.0 (#7322)
* chore(deps): Bump prettier from 2.8.8 to 3.0.0

Bumps [prettier](https://github.com/prettier/prettier) from 2.8.8 to 3.0.0.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.8.8...3.0.0)

---
updated-dependencies:
- dependency-name: prettier
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore: Reformat using Prettier v3.0 defaults

The main change is to add trailing commas to the last line of
block-formatted function calls.

---------

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>
2023-07-25 14:56:10 +00:00
Christopher Allen
b6e084257e refactor(blocks): Migrate blocks/blocks.js to TypeScript (#7193)
* refactor(blocks): Auto-migration of blocks/blocks.js to ts

* fix(blocks): Manually migrate & fix types in blocks.ts

* fix(build): Update location of blocks/blocks.ts exports object

* fix(blocks): Remove lint

* chore(blocks): Format
2023-06-21 22:07:20 +01:00
Christopher Allen
ec71261813 refactor(blocks): Migrate blocks/procedures.js to TypeScript (#7192)
* refactor(blocks): Auto-migration of blocks/procedures.js to ts

* fix(blocks): Revert obvious automigration fails in blocks/procedures.js

* fix(blocks): Manually migrate & fix types in procecures.ts

* fix(blocks): Remove lint

* chore(blocks): Format

* fix(7192): Corrections for PR #7192
2023-06-21 21:51:14 +01:00
Christopher Allen
ea74772e30 fix(blocks): Mark previously-@private methods @internal (#7194)
Where certain block mixin methods had been marked @private,
and these annotations had been deleted while migrating the
containing files to TypeScript, mark those methods as
@internal.
2023-06-21 20:38:27 +01:00
Christopher Allen
95dd63b2bd refactor(blocks): Migrate blocks/logic.js to TypeScript (#7003)
* refactor(blocks): Auto-migration of blocks/logic.js to ts

* fix(blocks): Manually migrate & fix types in logic.ts

* chore(blocks): Fix import order

* chore(blocks): Fixes for PR #7003

* chore(blocks): Lint removal

* chore(blocks): Format blocks/logic.ts
2023-06-16 21:13:41 +01:00
Beka Westberg
d7ccf8a5ee fix: input exports (#7165)
* fix: input exports

* chore: fix build

* chore: attempt to fix build

* chore: attempt to fix build

* chore: create new align enum to replace old one

* chore: format

* fix: Tweak renamings entries

It appears that the goal is to map:

Blockly.Input.Align -> Blockly.inputs.Align
Blockly.Align -> Blockly.inputs.Align
Blockly.ALIGN_* -> Blockly.inputs.Align.*

I believe this commit achieves that in a more minimal (and correct)
way—but if I have misunderstood the intention then this will not
be a useful correction.

---------

Co-authored-by: Christopher Allen <cpcallen+git@google.com>
2023-06-16 11:27:46 -07:00
Beka Westberg
2f74ce822f fix!: refactor mutator icon (#7115)
* 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
2023-06-02 12:18:41 -07:00
Beka Westberg
f4e378d096 fix!: refactor warning icon (#7112)
* feat: add basic warning icon

* feat: work on actually using the warning icon

* chore: add docs

* chore: delete old warning icon

* chore: fix build

* chore: my own comments

* chore: move Warning to icons.WarningIcon

* chore: move properties to the module level

* chore: properly override and call super

* chore: properly use optional chaining

* chore: fixup comment typo

* chore: change imports to import type

* chore: reduces changes in block js files

* chore: add renaming
2023-06-02 09:34:34 -07:00
Beka Westberg
42b8c6e3ab fix: return annotations (#7118)
* chore: remove suppress annotations

* chore: remove fileoverview annotation

* chore: remove other unused annotations

* chore: change return to returns

* chore: enable tag linting
2023-05-24 13:01:33 -07:00
Rachel Fenichel
de904ab128 chore: remove deprecated functionality for v10 (#7077)
* chore: remove deprecated functionality in events files

* chore: remove deprecated items in renderers

* chore: remove deprecated items in core

* chore: remove mixin deprecation

* chore: fix tests after removing deprecations
2023-05-11 14:30:54 -07:00
Maribeth Bottorff
88ff901a72 chore: use prettier instead of clang-format (#7014)
* chore: add and configure prettier

* chore: remove clang-format

* chore: remove clang-format config

* chore: lint additional ts files

* chore: fix lint errors in blocks

* chore: add prettier-ignore where needed

* chore: ignore js blocks when formatting

* chore: fix playground html syntax

* chore: fix yaml spacing from merge

* chore: convert text blocks to use arrow functions

* chore: format everything with prettier

* chore: fix lint unused imports in blocks
2023-05-10 16:01:39 -07:00
Beka Westberg
af991f5e1b fix: switch most remaining render calls to queueRender (#7024)
* chore: remove render call from procedure blocks

* chore: have workspace queue renders when unhiding

* chore: remove forced rendering from flyouts

* chore: change mutators to use queueing

* chore: change shadows to use queueing

* chore: add comments about icon rendering
2023-05-09 16:57:11 -07:00
Beka Westberg
3a9a9bd24e feat: break input types into separate classes (#7019)
* chore: move input and input types into new directory

* feat: define and export new input types

* feat: modify blocks to construct individual inputs

* chore: transition code to use actual type checks

* chore: fixup input type type

* chore: format

* chore: fixup PR comments

* chore: fix build
2023-05-04 08:50:45 -07:00
Rachel Fenichel
d47369acfe refactor(blocks): Migrate blocks/text.js to TypeScript (#6958)
* refactor(blocks): auto-migration of blocks/text.js to ts

* refactor(blocks): fix up some types in blocks/text.ts

* refactor(blocks): improve some types in text.ts

* refactor(blocks): additional type cleanups

* chore: format

* chore: fix typo

* chore: respond to PR comments

* chore: respond to PR comments
2023-04-28 10:54:28 -07:00
Rachel Fenichel
96ecfea857 refactor(blocks): Migrate blocks/variables.js and blocks/variables_dynamic.js to TypeScript (#7001)
* refactor: run js2ts on variables

* refactor: clean up conversion of variables blocks to typescript

* refactor: add types for custom context menu options

* refactor: run js2ts on blocks/variables_dynamic.js

* refactor: clean up types in variables_dynamic

* chore: respond to PR comments

* chore: format
2023-04-24 13:09:02 -07:00
Rachel Fenichel
a4d0b67985 refactor(blocks): Migrate blocks/loops.js to TypeScript (#6957)
* refactor(blocks): Auto-migration of blocks/loops.js to ts

* fix(blocks): Manually migrate types and fix imports in loops.ts

* chore: respond to PR comments
2023-04-18 15:58:21 -07:00
Christopher Allen
0177dff49c refactor(blocks): Migrate blocks/lists.js to TypeScript (#6902)
* refactor(blocks): Auto-migration of blocks/lists.js to ts

* fix(blocks): Manually migrate & fix types in lists.ts

* chore(blocks): format lists.ts

  Not running clang-format on this as for some reason it decides
  half way through the file to indent everything after that by
  an extra four spaces (and then has to re-wrap a bunch of lines
  that are consequently too long).

* refactor(blocks): Improve types in lists.ts

  It turns out that the way I originally specified the types for
  the mixins meant that they were all 'any', which is a bit
  useless.  Change them so that tsc actually typechecks
  properties (including method calls) on the mixed-in blocks,
  and then fix the numerous additional type errors which
  doing this revealed.

  (By "fix", I mean apply "as" casts and "!"s as required to
  suppress type errors from tsc.  Actually fixing the code in a
  way that makes the blocks meaningfully more bulletproof is
  left as an exercise to the reader - sorry, I mean: will be
  dealt with in a future PR.)

* fix(blocks): Additional fixes for comments PR #6902
2023-04-18 12:50:54 +01:00
Christopher Allen
bb9f31853d refactor(blocks): Migrate blocks/math.js to TypeScript (#6900)
* refactor(blocks): Auto-migration of blocks/math.js to ts

  This is just the result of running js2ts on this file.

* fix(blocks): Manually migrate & fix types in math.ts

* chore(blocks): clang-format math.ts

* fix(blocks): Corrections for comments on PR #6900

* refactor(blocks): Define types for mixin-ed blocks, etc.

  Define types to represent the union of Block and each of the
  *_MIXINs, and use these types for the type of this in mixin
  methods.

* refactor(blocks): Misc minor changes

  Make sure validator functions explicitly return undefined.
  Field.prototype.setValidator takes a FieldValidator<T>, which
  must be a non-void function.  I'm not sure why tsc was not
  objecting to the void implementation here, but it does in
  other very similar situations so for consistency explicitly
  return undefined to signal the value should be used unchanged.

  Also undo previous change of !. to ?.: I think it wisest to
  try to preserve the existing behaviour as exactly as possible
  for now, and make behaviour changes (i.e., ones that affect
  the generated code) separately.

* fix(blocks): Fix erroneous typing of mixins

  It turns out that the previous types for these were completely
  wrong, for two reasons:

  - They should be intersection types (which have the union of the
    properties), not union types (which have the interseciton of the
    properties).
  - The *_MIXIN types were already declared as having type
    BlockDefinition, which is ultimately an alias for any.

  TypeScript doesn't like (some) kinds of circularly defined types,
  so fixing the above necessitates declaring a few auxiliary types
  just to make the type checker happy - but the end result is
  excellent and caught an actual type error in the code.
2023-03-17 20:24:09 +00:00
Christopher Allen
a0b4a214a9 refactor(blocks): Migrate blocks/colour.js to TypeScript (#6901)
* refactor(blocks): Auto-migration of blocks/colour.js to ts

* fix(blocks): Manually migrate types & fix imports in colour.ts
2023-03-17 15:36:44 +00:00
Aaron Dodson
cf8be1f5d1 refactor: Use the field registry to instantiate fields in block definitions. (#6811)
* refactor: Use the field registry to instantiate fields for list blocks.

* refactor: Use the field registry to instantiate fields for procedure blocks.

* refactor: Use the field registry to instantiate fields for text blocks.
2023-02-07 08:06:54 -08:00
Christopher Allen
167e26521c refactor: Remove last remaining circular import in core/ (#6818)
* 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
2023-02-07 12:11:11 +00:00
Beka Westberg
e4d7c381bc chore: revert changes to procedure blocks (#6794)
* chore: revert procedure blocks

* chore: fix tests
2023-01-26 09:21:54 -08:00
Beka Westberg
3eb7031f14 chore: reexport procedure related symbols (#6769)
* chore: reexport triggerProcedureUpdate

* chore: export interfaces

* fix: incorrect module ID in IProcedureBlock
2023-01-20 10:29:58 -08:00