Commit Graph

403 Commits

Author SHA1 Message Date
Beka Westberg
07057d087c feat: adds hooks for serializing plugins (#5276)
* Reformat registry tests

* Add tests for plugin hooks

* Add plugin hooks for serialization

* Switch PluginSerializer to IPluginSerializer

* fix: types

* fix: PR comments

* fix: tests

* cleanup: formatting

* fix: types

* feat: add respecting case in registry

* feat: add separate registry for serializers

* fix: rename serialiation registry alias

* fix: move serializer interface into interface dir
2021-09-20 13:08:35 -07:00
Beka Westberg
486123e4ff fix: insertion markers and change events to work with JSO hooks (#5378)
* fix: add tests for fixing change events

* fix: change events and insertion markers

* fix: build:

* fix: remove duplicate code

* fix: requires
2021-09-20 13:08:35 -07:00
Beka Westberg
1d4cbd1ab6 Add serializing shadows as JSOs for the JSO system (#5246)
* Move existing tests into new suite

* Add tests for setShadowState

* Add assertions for serialization

* Unskip serialization tests

* Add logic to handle shadows in both systems

* Uncomment tests

* fix: add access modifiers to new comment funcs

* fix: fixup types

* fix: remove addNextBlocks = true

* feat: add real child of shadow errors

* fix: types
2021-09-20 13:08:35 -07:00
Beka Westberg
1b47953c58 feat: add serialization and deserialization of comments (#5216)
* Add tests for (de)seralizing icons

* Add logic for (de)serializing icons

* fix: add docs for saveIcons

* fix: add timeout for setting comment visible
2021-09-20 13:08:35 -07:00
Beka Westberg
91922aa571 Add throwing exceptions during deserialization (#5200)
* Add exception definitions

* Add tests for throwing errors during deserialization

* Add actually throwing exceptions

* Cleanup

* Cleanup

* Fix tests

* fix: PR Comments
2021-09-20 13:08:35 -07:00
Beka Westberg
ee78b41987 feat: upgrade block defs to have JSO serialization hooks (#5329)
* Respect nulls from blocks.save

* Upgrade list blocks to use JSO serialization

* Upgrade logic blocks to use JSO serialization

* Upgrade math blocks to use JSO serialization

* Upgrade text blocks to use JSO serialization

* Upgrade procedure blocks to use JSO serialization

* Add more mutator tests

* Fix firing enabled events

* PR Comments
2021-09-20 13:08:35 -07:00
Beka Westberg
bd77b4ad3d fix: touch up some deserialization behavior (#5181)
* Add parameter for recording undo.

This sets up the most common default behavior, but also makes it clear
to people that it is happening, because it might not be expected.

* Add grouping of events

* Add text width caching

* Add disabling workspace resizing

* Add performance optimizations

* Respect nulls from blocks.save

* Cleanup from rebase

* PR Comments

* Cleanup from rebase
2021-09-20 13:08:35 -07:00
Beka Westberg
d3a9e517b2 feat: add top level save and load functions for JSO serialization (#5132)
* Add top-level serialization API

* Add using JSO system in serializer tests

* Make compiler happy
2021-09-20 13:08:35 -07:00
Beka Westberg
28ff2c84c6 feat: add JSO serialization and deserialization of variables (#5131)
* Add variable serialization tests

* Fix requires for new file

* Add serialization and deserialization of variables

* Remove only in tests

* Cleanup
2021-09-20 13:08:35 -07:00
Beka Westberg
56d3cb6c8f feat: add serialization of child blocks (#5120)
* Add tests for serializing connected blocks

* Add serialization of child blocks

* Add tests for not serializing children

* Add options for not serializing children

* Fix types

* Change addNextBlocks to default to true

* Cleanup

* Fix types
2021-09-20 13:08:35 -07:00
Beka Westberg
ceeda333dc Add serialization of basic block attributes to JSOs (#5053)
* Add basic attribute tests

* Add basic block serialization

* Add more attribute tests

* Change save to use options dictionary

* Add obeying save options

* Add test for data attribute

* Add saving data tag

* Move to ES6 syntax

* Fixup move to es6 syntax

* Declare module

* Format and lint

* Add docs

* Add returning null on insertion markers

* Fixup for move to module

* Switch to other function declarations

* Cleanup for finalized style

* Fix lint and types

* Export State def

* Switch disabled=true to enabled=false
2021-09-20 13:08:35 -07:00
Beka Westberg
f77526e558 Move browser event utils from utils.js to browser_events.js (#5464)
* fix: move browser event utils to browserEvents

* fix: mark browser event utils in utils as deprecated

* fix: move uses of browser event funcs to browserEvents

* fix: remove browserEvents definition of noEvent

* fix: add renames for browser event utils

* docs: add suggested alternatives for browser event utils

* fix: change deprecations to stubs

* fix: PR comments
2021-09-17 14:49:01 -07:00
Aaron Dodson
511ce5df2b Migrate core/blockly.js to goog.module syntax (#5494)
* Migrate core/blockly.js to ES6 const/let

* Migrate core/blockly.js to goog.module

* Migrate core/blockly.js to named requires

* clang-format core/blockly.js

* Consolidate accessors in core/blockly.js
2021-09-17 14:30:23 -07:00
Aaron Dodson
7aab18409f Migrate selected from Blockly to Blockly.common (#5489)
* Add getSelected/setSelected to core/common.js

* Migrate core to use Blockly.common.getSelected/setSelected instead of Blockly.selected

* Migrate demos to use Blockly.common.getSelected/setSelected instead of Blockly.selected

* Remove Blockly.selected

* Use variable instead of calling common.getSelected() multiple times

* Add accessor for selected on Blockly

* Add renaming record for Blockly.selected -> Blockly.common.getSelected/setSelected
2021-09-17 11:42:43 -07:00
Christopher Allen
dbf10cf167 Clean up get/set accessor definitions (#5488)
* Use Object.defineProperties instead of .defineProperty when
  installing get and set accessors for previously-mutable exports.

* Add entries to renamings.js where feasible (i.e., for static rather
  than instance properties).

(Don't do blockly.js yet, to avoid merge conflicts.)
2021-09-17 19:30:21 +01:00
Maribeth Bottorff
6dbc534dcc refactor: Move Blockly.svgResize to Blockly.common (#5485)
* refactor: Move Blockly.svgResize to Blockly.common

* fix formatting and deps
2021-09-16 15:53:33 -07:00
Maribeth Bottorff
3bac582edb refactor: move Blockly.deleteBlock out of blockly.js (#5483) 2021-09-16 15:13:59 -07:00
Maribeth Bottorff
c5acc1de72 refactor: remove unused Blockly.onContextMenu_ (#5480) 2021-09-16 15:01:12 -07:00
Maribeth Bottorff
1334bd3f1b refactor: Migrate Blockly.onKeyDown out of blockly.js (#5476)
* refactor: move Blockly.onKeyDown to inject.js

* fix the tests
2021-09-16 14:48:03 -07:00
Christopher Allen
51d9dad31f Re-export Blockly.utils.* submodules from Blockly.utils (#5465)
* Reexport Blockly.utils.* modules from Blockly.utils

* Update metadata (file sizes) again

  blockly_compressed.js has gotten too big for the second time this
  quarter.  Update the expected file sizes for it so that tests
  will continue to pass.
2021-09-16 18:23:33 +01:00
Christopher Allen
81e645a771 Remove vestigial (circular) require of Blockly (#5474) 2021-09-16 16:46:06 +01:00
Aaron Dodson
6a4a359f7b Migrate hideChaff() from Blockly to WorkspaceSvg (#5460)
* Add hideChaff() to core/workspace_svg.js

* Mark Blockly.hideChaff as deprecated

* Update uses of Blockly.hideChaff() to WorkspaceSvg.hideChaff() in core

* Update uses of Blockly.hideChaff() to WorkspaceSvg.hideChaff() in demos

* Style and formatting fixes

* Switch from accessor to stub wrapper for Blockly.hideChaff

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

Co-authored-by: Christopher Allen <cpcallen+github@gmail.com>
2021-09-15 13:41:20 -07:00
Rachel Fenichel
9b8cd7ce5b Migrate core/inject.js to goog_module syntax (#5456)
* Move bump objects function into a separate module

* Fix types

* Migrate core/inject.js to ES6 const/let

* Migrate core/inject.js to goog.module and move more functions to bump_objects.js

* Migrate core/inject.js named requires

* clang-format core/inject.js

* Rename private functions
2021-09-15 08:15:25 -07:00
Aaron Dodson
2ba51d4d75 Migrate Blockly.hueToHex to Blockly.utils.colour.hueToHex (#5462)
* Move hueToHex to core/utils/colour.js

* Mark Blockly.hueToHex as deprecated and pass calls through to Blockly.utils.colour.hueToHex

* Migrate core to use Blockly.utils.colour.hueToHex

* Migrate demos to use Blockly.utils.colour.hueToHex
2021-09-14 14:13:24 -07:00
Christopher Allen
d202ae0201 Don't monkey-patch Blocky.utils.xml.document (#5461)
Use Blockly.utils.xml.setDocument instead.
2021-09-14 19:55:31 +01:00
Rachel Fenichel
f4430e9e47 Move bump objects function into a separate module (#5453)
* Move bump objects function into a separate module

* Fix types

* Update core/bump_objects.js

Fix missing newline.

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

Co-authored-by: Christopher Allen <cpcallen+github@gmail.com>
2021-09-14 10:02:38 -07:00
Aaron Dodson
ce8e7921a2 Move alert/confirm/prompt to a new file, dialog.js (#5457)
* Migrate prompt/alert/confirm to dedicated module

* Update core/blockly.js to pass through calls to prompt/alert/confirm to core/dialog.js

* Update calls to Blockly.prompt/alert/confirm to dialog.prompt/alert/confirm

* Fix typo and errant redeclaration of Blockly.prompt

* Clarify JSDoc on customizing Blockly.dialog.alert/confirm/prompt
2021-09-14 08:19:53 -07:00
Christopher Allen
ff9320f8d9 Migrate core/utils/xml.js to goog.module syntax (#5459)
* Migrate core/utils/xml.js to ES6 const/let

* Migrate core/utils/xml.js to goog.module

  The document() function is renamed to getDocument() so as to avoid
  shadowing the global of the same name.

* clang-format core/utils/xml.js

* Call monkey-patchable exports.global internally too

  This fixes Node test failures due to the monkey-patching of
  Blockly.utils.xml.global in scripts/package/node/core.js not being
  able to affect the target calls in createElement and createTextNode.
2021-09-14 15:51:06 +01:00
Christopher Allen
f9d0caa112 Migrate core.global.js to named exports (#5451)
This is part of #5153 but is being prioritised because we want remove
the declareLegacyNamespace calls from the core/utils/*.js modules and
then reexport them explicitly via utils.js, and it turns out that
doing so results in the exports object of this module being passed to
Object.freeze - which fails on the global object, which can't be made
non-extensible!

The new name chosen for the former default export is globalThis, since
it is intended to have the same value as the global variable of that
name; see:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis
2021-09-14 14:39:29 +01:00
Christopher Allen
09fb59f6ee Fix deps.js (#5452)
Running npm run build:deps in goog_module makes a change to tests/deps.js that was previously committed by PR #5441 but which appears to have been inadvertently undone by #5222.
2021-09-10 22:16:48 +01:00
Christopher Allen
7a2e23876e Migrate core/msg.js to goog.module syntax (#5448)
* Migrate core/msg.js to goog.module
* Migrate core/msg.js named requires
2021-09-10 18:10:23 +01:00
Aaron Dodson
53061ac6e5 Migrate core/touch_gesture.js to goog.module syntax (#5449)
* Migrate core/touch_gesture.js to ES6 const/let

* Migrate core/touch_gesture.js to goog.module

* Migrate core/touch_gesture.js to named requires

* clang-format core/touch_gesture.js

* Remove Blockly prefix from Touch
2021-09-09 14:19:32 -07:00
Aaron Dodson
646a931d77 Migrate core/tooltip.js to goog.module syntax (#5222)
* Migrate core/tooltip.js to ES6 const/let

* Migrate core/tooltip.js to goog.module

* Migrate core/tooltip.js to named requires

* clang-format core/tooltip.js

* Fix exports of mutable fields in core/tooltip.js

* Don't assign a value when exporting visible in core/tooltip.js
2021-09-09 12:45:16 -07:00
Christopher Allen
79b814018e Migrate core/utils.js to goog.module syntax (#5446)
* Add missing requires for Blockly.utils.*
  - Blockly.utils.svgPaths in core/rendered_connection.js
  - Blockly.utils.colour in core/toolbox/category.js
  - Blockly.utils.KeyCodes in core/toolbox/toolbox.js
* Migrate core/utils.js to ES6 const/let
* Migrate core/utils.js to goog.module
* Migrate core/utils.js named requires
* clang-format core/utils.js
2021-09-09 17:25:53 +01:00
Christopher Allen
a6471c4276 Rename Blockly.utils.IdGenerator to idGenerator and move Blockly.utils.genUid to there (#5441)
* Rename Blockly.utils.IdGenerator -> idGenerator
* Move genUid from Blockly.utils to Blockly.utils.idGenerator
2021-09-09 17:08:44 +01:00
Christopher Allen
2d89a36e7d Migrate core/utils/useragent.js to goog.module syntax (#5435)
* Migrate core/utils/useragent.js to ES6 const/let
* Migrate core/utils/useragent.js to goog.module
* Migrate core/utils/useragent.js named requires
* clang-format core/utils/useragent.js
2021-09-07 18:48:18 +01:00
Christopher Allen
c31895dc60 fix: Add missing require for Blockly.utils.object, .Size (#5427)
Some files were using Blockly.utils.object.inherits (or .mixin) without
having imported Blockly.utils.object.

Similarly, trashcan.js tried to use utils.Size as a constructor
instead of importing Size from Blockly.utils.Size.
2021-09-03 22:45:54 +01:00
Aaron Dodson
a3b52aaab3 Migrate core/events/events.js to goog.module syntax (#5302)
* Migrate core/events/events.js to ES6 const/let

* Migrate core/events/events.js to goog.module

* Migrate core/events/events.js to named requires

* clang-format core/events/events.js

* Migrate Blockly core to use getRecordUndo/setRecordUndo

* Update core/events.js to reflect latest guidance around exporting mutable fields
2021-08-26 08:53:31 -07:00
alschmiedt
6be7bc1b2b Merge pull request #5207 from alschmiedt/migrate_dropdown
Migrate dropdown to goog.module syntax
2021-08-24 13:08:43 -07:00
Aaron Dodson
4751eea529 Migrate core/events/ws_comment_events.js to goog.module syntax (#5380)
* Split provides in core/events/ws_comment_events.js into individual files

* Migrate core/events/events_comment_* to ES6 const/let

* Migrate core/events/events_comment_* to goog.module

* Migrate core/events/events_comment_* to named requires

* clang-format core/events/events_comment_*

* Revert now-unnecessary changes to tests/mocha/event_test.js

* Update fileoverview comments for separated comment event classes
2021-08-24 08:00:27 -07:00
alschmiedt
c349db1a2e Adds test deps back in 2021-08-19 17:14:05 -07:00
alschmiedt
168b71e964 Updates to the new pattern for testing private 2021-08-19 17:07:05 -07:00
alschmiedt
3d75bd6493 Attempt to fix tests 2021-08-19 17:03:55 -07:00
alschmiedt
f29d795a7e Migrate core/dropdowndiv.js to goog.module 2021-08-19 16:58:45 -07:00
kozbial
40474324f6 Migrate core/renderers/zelos/measurables/inputs.js to goog.module 2021-08-19 10:40:53 -07:00
kozbial
7037a15011 Migrate core/utils/global.js to goog.module 2021-08-19 10:40:26 -07:00
kozbial
cf5c38c3f5 Migrate core/utils/svg.js to goog.module 2021-08-19 09:36:57 -07:00
kozbial
c85714b1c6 Migrate core/renderers/zelos/measurables/rows.js to goog.module 2021-08-19 09:35:26 -07:00
kozbial
3e1099e2b8 Split classes from core/renderers/zelos/measurables/rows.js into multiple files 2021-08-19 09:35:26 -07:00
kozbial
d37df416e1 Migrate core/renderers/zelos/measurables/row_elements.js to goog.module 2021-08-18 15:57:53 -07:00