Commit Graph

1710 Commits

Author SHA1 Message Date
Beka Westberg
32c7585cd7 fix: proc json serialization (#6746)
* fix: params not being rendered when loading from JSON

* chore: fix tests
2023-01-11 16:55:06 -08:00
Beka Westberg
902c30948a chore: refactor procedures namespace (#6745)
* chore: refactor procedures namespace

* fix: getCallers

* chore: add inline docs
2023-01-11 07:45:14 -08:00
Beka Westberg
8978f573d3 chore: delete old proc data code (#6736)
* chore: refactor getVars and getVarModels

* chore: cleanup renaming procedures

* fix: updating params in mutator

* chore: remove dead visual update code

* chore: fix test assertions

* chore: move context menu to use procedure model

* fix: renaming early parameters not applying

* chore: remove data update code

* chore: remove references to argumnets from caller serialization

* chore: remove extraneous visual update code

* chore: remove delete event listener

* chore: remove last unused data attributes

* fix: creating procedure defs with params from callers

* chore: format

* chore: cleanup from rebase

* chore: format

* chore: remove logs

* chore: fix PR comments

* chore: cleanup

* chore: make hasReturn_ private
2023-01-09 16:22:24 -08:00
Samriddhi
5dbcaeb4e2 fix: change assertFieldValue in test helpers to use deepEqual (#6739) 2023-01-09 09:51:13 -08:00
Christopher Allen
f1e5f22423 chore(tests): Enable testing on node.js v18.x on GitHub CI (#6619)
* chore(tests): Enable testing on node.js v18.x on GitHub CI

* chore(tests): Remove outdated calls to test:prepare npm script

The calls to `npm run test:prepare` in `tests/scripts/setup_*_env.sh`
should have been removed along with that npm script in PR #4906.

* chore(deps): Fix alphabetisation in package.json
2023-01-09 09:57:12 +00:00
Beka Westberg
d27f7c81b4 fix: undoing and redoing deleting procedures (#6722)
* fix: undoing and redoing deleting procedure defs

* chore: added tests for undoing and redoing procedure def deletes

* fix: dragging blocks from flyout

* chore: PR comments

* chore: fixup from rebase
2023-01-06 16:02:45 -08:00
Beka Westberg
23fb76b9f2 fix: undoing and redoing parameter events (#6721)
* fix: undoing and redoing parameters creating dupe parameters

* chore: add tests for undoing and redoing adding parameters

* fix: undoing and redoing renaming parameters

* chore: change tests to tick clock

* chore: format

* chore: add tests for deleting procedure parameters

* chore: fix tests

* chore: unskip tests

* chore: fix return type of saveExtraState

* chore: increase mocha timeout
2023-01-06 15:32:04 -08:00
Beka Westberg
e1995ae3b0 feat: procedure callers respond to models (#6718)
* chore: add test for reconnecting procedure input blocks

* feat: add caller blocks responding to updates

* chore: format

* chore: add test for deserializing callers before defs

* chore: format
2023-01-06 09:55:36 -08:00
Beka Westberg
dee3951541 feat: procedure defs deserialize models (#6706)
* feat: add procedure defs deserializing models

* chore: rename model to model_

* chore: cleanup

* chore: fix tests failures

* fix: PR comments
2023-01-05 15:19:17 -08:00
Beka Westberg
faf5a08c90 feat: procedure def blocks respond to models (#6673)
* feat: make procedure def blocks respond to model updates

* chore: format

* chore: unskip tests
2023-01-05 15:11:37 -08:00
Beka Westberg
5d20b62339 feat: procedure blocks update models (#6672)
* feat: procedure blocks have models

* feat: add updating the name of the model

* feat: add procedure defs updating the model enabled state

* feat: add procedure blocks updating parameters in the model

* fix: add disposing of the procedure model

* chore: updates test to check for identity of parameters

* chore: move statement handling into setStatement

* fix: make parameter IDs consistent

* chore: un-only tests

* chore: fixup tests

* chore: revert validator to use Procedures.rename

* chore: cleanup typo
2023-01-05 14:31:20 -08:00
Beka Westberg
863c985928 chore(tests): procedure blocks (#6670)
* chore: sketch out necessary test cases

* chore: add tests for updating the data models

* chore: outline more response tests

* chore: add tests for updating procedure def blocks based on models

* chore: add tests for updating procedure callers based on procedure model updates

* chore: add tests for renaming procedures

* chore: add tests for adding procedure parameters

* chore: add tests for renaming procedure parameters

* chore: add tests for reordering procedure parameters

* chore: add tests for enabling and disabling procedures

* chore: add tests for deleting procedure def

* chore: fixup tests that we accidentally broke

* chore: format
2022-12-19 15:18:55 -08:00
Christopher Allen
e4f42aa8fa chore(tests): Update metadata for 2022 Q4 release (#6710) 2022-12-15 17:50:52 +00:00
Beka Westberg
658e14ff75 fix: not being able to set field values to empty (#6702) 2022-12-14 17:08:15 -08:00
Christopher Allen
3be3d4a6ff chore: miscellaneous fixes to docs, style, and tests (#6705)
* docs(icon): Better description for Icon.prototype.setVisible

  Also tweak description of getBlock.

* docs(blocks): Fix typo in description of BlockDefinition

* chore(tests): Factor out common goog:chromeOptions

* chore(build): Minor style fixes
2022-12-14 23:48:12 +00:00
Christopher Allen
f528eccba7 fix(tests): Fix bootstrapping of generators in compressed mode (#6703)
Previously we had code that would, in uncompiled mode, make sure
that javascriptGenerator etc. were set to the corresponding module
exports object (by fetching it with goog.module.get), but in
compressed mode we made no effort to set (e.g.) javascriptGenerator
to Blockly.JavaScript, which is where that export actually appears
in the namespace tree when loading the chunk via a <script> tag.

This commit introduces two new configuration options to bootstrap.js
(preconfigured with defaults that should work in most cases) mapping
global variable names to their corresponding module identifiers, and
modifies the code in bootstrap_helper.js to set global variables
appropriately in both uncompressed and compressed modes.
2022-12-14 19:47:27 +00:00
Beka Westberg
d6230b2a44 feat: procedure event serialization (#6669)
* feat: add serialization to procedure base event

* feat: add serialization to procedure change return event

* feat: add serialization to procedure create event

* feat: add serialization of the procedure delete event

* feat: add serialization of procedure enable events

* feat: add serialization of procedure parameter create events

* feat: add serialization of the parameter delete event

* feat: add serialization of procedure parameter rename events

* feat: add serialization for procedure rename events
2022-12-09 10:30:39 -08:00
Beka Westberg
0ea319c4c3 feat: add destroy lifecycle hook to blocks (#6678)
* chore: move healing tests

* chore: add tests for calling destroy

* feat: add calling the destroy callback

* chore: cleanup reversions

* chore: fixup type of destroy
2022-12-05 14:39:07 -08:00
Aaron Dodson
90cb965e7c refactor: Migrate to PointerEvents (#6598)
* refactor: Remove checks for PointerEvent support.

* refactor: Deprecate and remove calls to splitEventByTouches.

* refactor: Deprecate and remove calls to setClientFromTouch().

* refactor: Use PointerEvent in place of Event/MouseEvent/TouchEvent/PseudoEvent.

* refactor: Update references to mouse/touch events in code and documentation to reference pointer events.

* refactor: Merge Gesture and TouchGesture

* chore: clang-format changed files

* refactor: Bind and expect PointerEvents instead of MouseEvents.

* refactor: Rename TouchGesture to Gesture.

* fix: Fix test failures.

* chore: clang-format changed files.

* fix: Fix errant _ from merging

* refactor: Clean up dead code in browser_events.ts.

* chore: Update version in deprecation notices to reflect release schedule

* fix: Fixed a bug that caused the browser context menu to not be suppressed in Chrome.

* fix: Re-export Gesture as TouchGesture for backwards compatibility.

* refactor: Deprecate and remove uses of opt_noPreventDefault.

* chore: Fix error message in gesture.ts.

* chore: Removed obsolete todo.
2022-12-05 11:27:52 -08:00
Beka Westberg
9741cd2530 chore: add simple round tripping tests (#6668) 2022-12-05 10:30:28 -08:00
Beka Westberg
fc2c10d0d0 feat: make the variable map return early for noops (#6674)
* chore: add variable map tests

* chore: move firing create events into the variable map

* feat: add early returning in the case of noop renames

* chore: format
2022-12-02 08:10:41 -08:00
Beka Westberg
67275e4bba Revert "feat!: allow blocks to receive their own delete events" (#6676) 2022-12-01 14:55:31 -08:00
Beka Westberg
089841c26f Revert "fix: blocks not receiving their own delete events (#6655)" (#6675)
This reverts commit 485bd4dddf.
2022-12-01 14:11:30 -08:00
Beka Westberg
c959ce85ae feat: add running procedure events (#6650)
* chore: fixup procedure change event tests

* feat: add running procedure change return events

* fixup change return

* feat: add running the procedure rename event

* feat: add running procedure enable events

* feat: add running parameter rename events

* feat: add running procedure create events

* feat: add running procedure delete events

* feat: add running parameter create events

* feat: add running procedure parameter delete events

* chore: add types to all of the new procedure events

* chore: format

* chore: use type imports

* chore: fix test comments

* chore: add more inline docs
2022-12-01 08:38:50 -08:00
Beka Westberg
485bd4dddf fix: blocks not receiving their own delete events (#6655)
* fix: blocks not receiving their own delete events

* chore: unskip tests
2022-11-29 08:39:21 -08:00
Beka Westberg
d5de2da2de fix(deps): update json schema validation (#6637) 2022-11-29 07:57:02 -08:00
Neil Fraser
5a64a9a7f7 fix: Fix the compiler test, and check if it worked. (#6638)
* Add tsick.js to rewrite enums.

tsc generates JavaScript which is incompatible with the Closure Compiler's advanced optimizations.

* Remove unused 'outputCode' variable.

* Rename 'run_X_in_browser.js' to 'webdriver.js'

The Mocha and generator tests can both be run either manually or via our webdriver.  In all cases they run in a browser.  These two 'run_X_in_browser.js' files only apply to webdriver, thus they are confusingly named.

Also delete completely unused (and broken) `run_all_tests.sh`

* Linting improvements to mocha/webdriver.js

Still not at 100%.  Complains about require/module/process/__dirname not being defined in multiple places.

* runTestBlock -> runTestFunction

'Block' means something very different in Blockly.

* Removal of `var` from scripts.

* Add webdriver test to verify compile test worked.

* Resolve conficts with 'develop'.

* Address PR comments.
2022-11-25 11:45:00 -08:00
Maribeth Bottorff
be4b8323c5 feat: add option to disable modal inputs on mobile (#6625) 2022-11-22 11:52:46 -08:00
Christopher Allen
0c81291188 chore(build): Re-delete tests/run_all_tests.js (#6636)
The bash script tests/run_all_tests.sh was deleted in PR #6431, where
it was replaced by scripts/gulpfiles/test_tasks.js, but it was
inadvertently resurrected by PR #6475, apparently due to an error when
manually resolving conflicts for merge commit 00676ed.

Begone, undead script!
2022-11-21 19:57:26 +00:00
Beka Westberg
7b055dbc7e chore(tests): test running procedure events (#6627)
* chore: define necessary events

* chore: cleanup test organization

* chore: cleanup comment

* chore: move assertEventFiredShallow to test helpers

* chore: add tests for running the procedure change return events

* chore: work on tests??

* chore: add tests for running the change return events

* chore: add tests for running enable events

* chore: add tests for procedure rename events

* chore: add tests for renaming procedure parameters

* chore: add tests for running procedure create events

* chore: add tests for running procedure parameter create events

* chore: add tests for running procedure delete events

* chore: add tests for running procedure parameter delete events

* chore: skip all tests for running procedure events
2022-11-18 16:01:41 -08:00
Beka Westberg
f64c934f04 feat: refactor event serialization to use static fromJson method (#6614)
* feat: add new path for deserialization of events

* chore: add tests for round-tripping events

* chore: add static fromJson methods to all events

* chore: add inline docs to new static methods

* chore: add deprecation warnings

* chore: cleanup

* chore: add deprecation and docs to abstract

* chore: format

* chore: cleanup from rebase

* chore: update docs comment
2022-11-14 11:07:36 -08:00
Beka Westberg
0532b5d1c0 feat: add firing of procedure events. (#6604)
* feat: add empty implementations of events

* chore: register all events

* chore: change assertions to shallow match properties

* feat: add firing events from the observable procedure map

* fix: make event not fired assertions actually fail

* chore: fixup typos in tests

* feat: add firing procedure model events

* feat: add firing parameter create and parameter delete events

* chore: reorganize event tests into suites

* feat: add firing parameter rename events

* chore: format

* chore: use tripple equals
2022-11-10 16:38:32 -08:00
Rachel Fenichel
92efdb91d1 chore: clean up insertion marker code (#6602)
* chore: move comments

* chore: remove underscores from private property names

* chore: remove underscores from properties and methods in insertion marker manager

* chore: format

* chore: track closestConnection and localConnection as a single object

* chore: format

* chore: add comments and simplify shouldUpdatePreviews

* chore(docs): add jsdoc for new params

* chore: use destructuring assignments

* chore: improve readability

* chore: address review feedback

* chore: respond to review feedback

* chore: fix types in shouldDelete

* chore: make wouldDeleteBlock a property

* chore: format
2022-11-10 09:32:27 -08:00
Beka Westberg
1f862cb878 chore: disable serialization of procedure data for point release (#6610)
* chore: disable serialization of procedure data for point release

* chore: format
2022-11-09 14:28:05 -08:00
Beka Westberg
1d43bd4ee4 test: firing procedure events (#6593)
* chore: add basic tests

* chore: add assertion explanations

* chore: define some additional tests

* chore: add tests for not firing when not added to map

* chore: add better assertions for not firing events

* chore: change the order of return type tests

* chore: skip tests
2022-11-04 15:22:56 -07:00
Rachel Fenichel
82dc9664ba test: add tests for the insertion marker manager (#6596)
* test: make sure the insertion marker manager creates the correct number of markers

* test: add more tests for insertion marker manager

* chore: format

* test: respond to pr feedback

* test: make test names more descriptive

* test: add row_to_stack test block
2022-11-03 12:58:33 -07:00
Christopher Allen
52a0d525d7 chore(build): Remove build products from the Blockly repository (#6475)
* feat(build): Make build tasks invoke their prerequisites

  - Divide gulp targets into three kinds: main sequence,
    manually invokable, and script-only.  The first two categories
    automatically invoke their prerequisites.
  - Give (most of) the affected gulp targets shorter and more memorable
    names that could become their npm script names in future.

* feat(build): Make package tasks invoke their prerequisites

  Have the package task invoke the cleanBuildDir (as well as
  cleanPackageDir) and build tasks.  Remove the checkBuildDir
  task as it is now redundant since a fresh build is done every
  time.

* feat(build): Make git tasks invoke their prerequisites

* feat(build): Make cleanup, license [sic] tasks invoke their prerequisites

  Turns out they don't have any, so this commit just classifies
  their gulp targets according to the established scheme.

* feat(build): Make appengine tasks invoke their prerequisites

  In this case prepareDeployDir will eventually depend on package
  but does not for now.

* feat(build): Have npm scripts run npm ci first where applicable

  Have any npm script that have external effects (e.g. publishing an
  npm package, pushing a new version to appengine, or updating GitHub
  Pages) start by running npm ci to ensure that all dependencies are
  up-to-date with respect to package-lock.json.

  (This is done by npm and not a gulp script because gulp itself
  might need updating.  So might npm, but that is less likely to
  make any difference to what gets published/pushed.)

* chore(build): have tests use package target

  Have the tests just run the package target (with debug flags)
  since that runs the the build target automatically.

* feat(tests): Write Closure Compiler output directly to dist/

  Since they are already UMD-wrapped, have Closure Compiler write
  output chunks directly to RELEASE_DIR, i.e. dist/.

* chore(tests): Use freshly-build files in compressed mode.

  Use the freshly-built build/*_compresssed.js files when bootstrapping
  in compressed mode, rather than using the checked-in files in the
  repository root.

  This helps ensure that compressed and uncompressed mode will be
  testing (as closely as possible) the same code.

  Obsoletes #6218 (though the issues discussed there have not actually
  yet been addressed in this branch).

* chore(build): Write intermediate langfiles to build/msg

  Write the results of create_messages.py to build/msg instead of
  build/msg/js.

* fix(build): Use build/msg/en.js instead of msg/messages.js in tests

  This has no direct effect but fixes a long-standing misdesign
  where we are testing against the input to, rather than the output
  of, the language file processing pipeline.

* feat(demos): Use freshly-built files

  Use the freshly-built dist/*_compresssed.js and build/msg/* files
  rather than using the checked-in files in the repository root.

  This helps ensure that these demos are using the most recent
  version of Blockly (even in the develop branch).

* fix(build): Update appengine deployment to include built files

  Modify the prepareDemos task as follows:

  - Use the git index instead of HEAD, so that most local changes
    will be applied (without copying whatever .gitignored cruft
    might be in the local directory).
  - Run clean and build and then copy build/msg and
    dist/*_compressed.js* to the deploy directory.

  This fixes the problem created by the previous commit, wherein the
  demos relied on built files that were not being deployed to
  appengine.

* fix(build): Update GitHub Pages deployment to include built files

  Modify the updateGithubPages task to run clean and build and
  then git add build/msg dist/*_compressed.js*, so that they will
  be included in the deployed pages.

  This fixes the problem created by the previous^2 commit,
  wherein the demos relied on built files that were not being
  deployed to GitHub Pages.

* chore(build): Remove build products from repository

  Remove *_compressed.js* and msg/js/* from the blockly repository.
  Also remove the now-obsolete checkinBuilt gulp task.

* chore(build): Apply relevant changes to test_tasks.js

  Apply changes made to run_all_tests.sh and check_metadata.sh to
  the corresponding parts of their JS replacements in
  test_tasks.js.

* chore(build): Make updates suggested in PR #6475

  - Remove `clean:builddir` and `clean:releasedir` - `clean`
    is sufficient.
  - Remove duplicate `require` from `appengine_tasks.js`.

* feat(build): Use shorter npm script names

  Since scripts that run build tasks now automatically run their
  prerequisite tasks, the previous naming scheme of task `build`
  running all the `build:subtask`s no longe really makes very
  much sense.

  Additionally, following a chat discussion, there seems to be a
  rough consensus to use "messages" to refer to the .json input
  files, and "langfiles" to the generated .js output files.

  Consequently, simplify npm script names by renaming as follows:

  - "generate:langfiles" -> "messages"
  - "build:langfiles" -> "langfiles"
  - "build:js" -> "tsc"
  - "build:deps" -> "deps"
  - "build:compiled" -> "minify"
  - "build:compressed": delete this synonym for "build:compiled",

  ("minify" was chosen as agnostic to Closure Compiler vs. WebPack.)

* chores(build): Add deprecation notice for old scripts

  To reduce potential confusion/frustration, restore the previous
  npm scripts but have them display a deprecation notice instead
  (note that npm prints the script contents before running it, so
  echo is not needed).

* docs(build): Add comments distinguishing 'messages' from 'langfiles'
2022-11-03 13:15:10 +00:00
Rachel Fenichel
f95af3614c chore: remove some underscores in icon-related classes (#6583)
* chore: remove underscores from properties and methods in comment.ts

* chore: remove some underscores from icon-related classes

* chore: cleanup

* chore: respond to PR feedback

* chore: catch one more bit of PR feedback
2022-10-31 13:43:50 -07:00
Neil Fraser
e90aba9273 fix: Rename Generator to CodeGenerator (#6585)
Stops collisions with ES6's Generator.
The old Blockly.Generator still exists as a name, but is now deprecated.
2022-10-28 01:59:00 +02:00
Beka Westberg
2311a94b03 feat: add serialization of procedure models (#6582)
* feat: add procedure model serializer

* chore: cleanup

* fix: serializer registration

* chore: add inline docs

* chore: cleanup and unskip tests

* chore: format

* fix: refactor factories to use generics

* chore: format

* chore: add docs to constructor
2022-10-27 15:41:46 -07:00
YAMADA Yutaka
52879dd953 fix(build): build/test on windows (#6431)
* build: build/test on windows

* chore(deps): bump @hyperjump/json-schema from 0.18.4 to 0.18.5
* chore(deps): add gulp-gzip 1.4.2
* build: migrate test scripts to gulp task (test_tasks.js)
* build: not to use the grep command
* build: normalize path

* fix: Modified based on review suggestions.
* Add JSDoc comment
* Line length <= 80 characters.
* Formatting test output as previously.
* Always continue even if a test unit fails.
* Suppress the gulp messages.
* Fix test_tasks.js to pass eslint.

* fix: Modified based on review suggestions.
* Change generator test output directory.
* Formatting test output as previously.

* fix: Formatting test output as previously.

* fix: Modified based on review suggestions.
2022-10-27 21:02:50 +01:00
Beka Westberg
fed57f24b7 fix: refactors concrete implementations of the procedure data models (#6575)
* fix: expand the IParameterModel interface

* fix: remove support for return types from the concrete procedure model

* feat: add an interface for the procedure map, and add getting procedures

* fix: add procedure map to workspace

* chore: format

* fix: add name parameter to procedure model to match parameter model

* chore: format

* chore: fix comments
2022-10-25 14:12:57 -07:00
Beka Westberg
97450b2622 chore: add tests for procedure serialization (#6574)
* chore: define necessary tests

* chore: implement tests for procedure serialization

* chore: format

* chore: change tests from only to skip

* chore: update tests to use mocks

* chore: cleanup

* chore: skip tests

* chore: add deserialization tests

* chore: cleanup from rebase
2022-10-25 09:05:44 -07:00
Beka Westberg
c9ced48de2 feat: trigger updates to IProcedureBlock blocks (#6570)
* feat: add interface and method for updating procedure blocks

* chore: remove module ID declarations

* feat: add actually triggering updates

* chore: format

* chore: clean up tests
2022-10-25 08:56:13 -07:00
Beka Westberg
7ffe1fa89f chore: update procedure map tests to match the refactored API (#6569)
* chore: add tests for the backing variable of parameter models

* chore: update existing procedure map tests

* chore: update block update tests to use refactored API

* chore: update tests to actually use fluent API

* chore: format

* chore: fix tests

* chore: reorganize tests

* chore: format

* chore: add comment
2022-10-25 08:51:40 -07:00
Beka Westberg
d58844d23c Revert "chore: update procedure map tests to match the refactored API (#6562)" (#6568)
This reverts commit 5f70fc415b.
2022-10-19 10:42:32 -07:00
Beka Westberg
5f70fc415b chore: update procedure map tests to match the refactored API (#6562)
* fix: feedback on procedure model implementations

* chore: format

* chore: add tests for the backing variable of parameter models

* chore: update existing procedure map tests

* chore: update block update tests to use refactored API

* chore: update tests to actually use fluent API

* chore: format

* chore: fix tests

* chore: reorganize tests

* chore: format

* chore: add comment
2022-10-19 10:28:40 -07:00
Maribeth Bottorff
caf91c82a6 fix: fix pinch to zoom (#6544)
* fix: fix pinch to zoom

* chore: format
2022-10-13 18:05:42 -07:00
Beka Westberg
ad22de1e53 test: add shared procedures playground (#6485)
* test: add shared procedures playground

* test: use json toolbox in testplayground

* chore: delete unnecessary toolbox def
2022-10-13 15:26:00 -07:00
Neil Fraser
9b81317d32 chore: Remove blockly factory use of utils.dom.add/removeClass (#6534)
* Remove usages of utils.dom.add/removeClass from Blockly Factory
* Use template strings for error messages.

(Random stuff found while working on something larger.)
2022-10-13 01:30:17 +02:00