Commit Graph

403 Commits

Author SHA1 Message Date
Rachel Fenichel
93a1bce1ac refactor: convert generators/javascript/loops.js to goog.module (#5758)
* refactor: convert generators/javascript/loops.js to goog.module

* refactor: convert generators/javascript/loops.js to named requires

* chore: run clang-format

* chore: rebuild deps.js
2021-11-30 18:51:11 -08:00
Rachel Fenichel
e11fe348b2 refactor: convert some js block generators to goog.module (#5756)
* refactor: convert generators/javascript/colour.js to goog.module

* refactor: convert generators/javascript/colour.js to named requires

* chore: run clang-format

* refactor: convert generators/javascript/lists.js to goog.module

* refactor: convert generators/javascript/lists.js to named requires

* chore: run clang-format

* refactor: convert generators/javascript/logic.js to goog.module

* refactor: convert generators/javascript/logic.js to named requires

* chore: run clang-format

* refactor: convert genereators/javascript/math.js to goog.module

* refactor: convert generators/javascript/math.js to named requires

* chore: rebuild deps.js
2021-11-30 17:31:55 -08:00
Rachel Fenichel
d9991516cc refactor: convert generators/javascript/procedures.js to goog.module (#5754)
* refactor: convert generators/javascript/procedures.js to goog.module

* refactor: convert generators/javascript/procedures.js to named requires

* chore: run clang-format
2021-11-30 17:25:03 -08:00
Christopher Allen
208d2008a3 refactor: Migrate blocks/loops.js to goog.module syntax (#5755)
* refactor: Turn .getSurroundLoop into a (Block) method

  This considerably simplifies the code in the genrators, obviating
  the need for generators to import Blockly.Constants.Loops, and
  allowing the compiler to remove blocks/loops.js from the first
  (Blockly) chunk of the compilation.

  (The latter could and should have been arranged by making the
  generator chunks depend on the blocks chunk, but that is no longer
  necessary.)

* refactor: Migrate blocks/loops.js to goog.module

* refactor: Migrate blocks/loops.js named requires

* chore: clang-format blocks/loops.js
2021-11-30 23:51:27 +00:00
Rachel Fenichel
874bbc13c9 refactor: convert some js block generators to goog.module (#5750)
* chore: migrate generators/javascript/text.js to goog.module

* chore: convert generators/javascript/text.js to named requires

* refactor: convert generators/javascript/variables.js to goog.module

* refactor: convert generators/javascript/variables_dynamic to goog.module
2021-11-30 15:09:29 -08:00
alschmiedt
780198e0c0 chore: revert #5730 (#5740)
* 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.
2021-11-30 19:27:19 +00:00
Rachel Fenichel
af2bf583af refactor: migrate generators/dart.js to goog.module syntax (#5749)
* chore: migrate generators/dart.js to goog.module

* chore: migrate generators/dart.js to named requires

* chore: Update generators/dart.js to alphabetize imports

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

Co-authored-by: Christopher Allen <cpcallen+github@gmail.com>
2021-11-30 11:11:18 -08:00
Christopher Allen
2ca6740758 refactor: Migrate blocks/logic.js to goog.module syntax (#5748)
* refactor: Migrate blocks/logic.js to goog.module

* refactor: Migrate blocks/logic.js named requires

* chore: clang-format blocks/logic.js
2021-11-30 17:43:35 +00:00
Rachel Fenichel
8ef0b20146 feat: clarify variable and procedure constants (#5743)
* chore: move dynamic category names into their respective files

* feat: create NameType enum on Names

* chore: use NameType enum for Names helper functions

* docs: update comments for category names
2021-11-30 09:13:36 -08:00
Rachel Fenichel
4db047ff32 chore: fix missing requires in generators (#5744)
* chore: fix some missing requires in generators

* chore: fix missing requires in dart block generators

* chore: replace Blockly.isNumber with Blockly.utils.string.isNumber in generators

* chore: fix more missing requires in block generators
2021-11-30 08:51:21 -08:00
Christopher Allen
1a992386ae refactor: Migrate blocks/lists.js to goog.module syntax (#5746)
* Migrate blocks/lists.js to goog.module

* Migrate blocks/lists.js named requires

* clang-format blocks/lists.js
2021-11-30 16:23:00 +00:00
Christopher Allen
b21130aef8 refactor: Migrate blocks/procedures.js to goog.module syntax (#5736)
* Migrate blocks/procedures.js to goog.module

* Migrate blocks/procedures.js named requires

* clang-format blocks/procedures.js

* chore: Factor common methods out of block definitions

  Addressing comments on PR #5736.
2021-11-30 16:19:47 +00:00
Christopher Allen
25a4561e21 Migrate blocks/colour.js to goog.module syntax (#5738)
* Migrate blocks/colour.js to goog.module

* Migrate blocks/colour.js named requires

This causes an apparently harmless reordering of the files for the
first chunk.

* clang-format blocks/colour.js
2021-11-29 22:51:06 +00:00
Christopher Allen
c0d22f2002 refactor: Rename ALIGN to Align and move from constants.js to input.js (#5742)
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.
2021-11-29 21:59:48 +00:00
Christopher Allen
985af10f6e chore(build): Use chunked compilation (#5721)
* 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.
2021-11-29 17:50:17 +00:00
alschmiedt
308253bfdf chore: moves the public loop mixin into its own file (#5730) 2021-11-24 15:57:28 -08:00
Rachel Fenichel
27699ed08b chore: move remaining function definitions out of blockly.js (#5699)
* chore: move remaining function definitions out of blockly.js

* chore: record renamings

* chore: add aliases to moved function jsdoc

* chore: add deprecation warnings in blockly.js

* chore: fix bad merge

* chore: move functions in response to PR comments

* chore: move isNumber to utils.string
2021-11-17 11:13:27 -08:00
Christopher Allen
335ff199d7 refactor: Update uncompiled-mode dependency loading for playground, tests (#5715)
* chore: rename module Blockly.blocks.Lists to ....lists

All the other Blockly.blocks modules have lower-case names.  This
one being named with an upper-case initial appears to have been a
typo on my part.

This module name is not mentioned anywhere else in the source code
(though it will be soon!) so no other files need to be edited.
Further, it does not appear anywhere in the last release (which
before PR #5696) so it is not necessary to add an entry in
renamings.js for this change.

* chore(build): Rationalise deps.js, deps.mocha.js

* Include blocks/*.js (Blockly.blocks.*) in tests/deps.js, since
  these modules are used in the playground.  (They are goog.provide
  modules loaded via <script> tags, so their absence from deps.js
  does not cause errors - but it will when they are migrated to
  goog.module and must be loaded via goog.require.)

* Filter the entries in deps.mocha.js so that it includes only the
  additional mocha test modules (i.e. those not mentioned in deps.js
  already).

* refactor: Load blocks and generators using goog.require
2021-11-17 00:04:45 +00:00
Rachel Fenichel
075385c87c chore: move remaining functions out of utils.js (#5714)
* chore: move arrayRemove to a new utils.array namespace

* chore: move getBlockTypeCounts out of utils.js

* chore: remove last functions from utils.js

* chore: reorder imports

* chore: add re-export for runAfterPageLoad
2021-11-15 18:12:45 -08:00
Rachel Fenichel
969fcac455 chore: Move functions from utils (#5706)
* chore: move functions from utils to more specific files

* chore: use new names for utils functions

* chore: run clang-format

* chore: add deprecation warnings back to utils.js
2021-11-15 15:59:27 -08:00
Christopher Allen
82fde60fe6 chore: update deps.js, deps.mocha.js (#5698) 2021-11-09 17:14:04 -08:00
Christopher Allen
beefe361a3 fix!(blocks): Rename Blockly.Blocks.* modules to Blockly.blocks.* (#5696)
Use Blockly.blocks.* for blocks modules, leaving the Blockly.Blocks
name for the block dictionary object.

This resolves a problem with advanced compilation of Blockly Games,
 where, in the compressed output, (the minified name of)
 Blockly.Blocks gets overwritten, with the dictionary object defined in
 core/blocks.js being replaced by an empty namespace object
 created by the provides of Blockly.Blocks.* in blocks/*.js. Without
 this fix, some block definitions end up being created in the
 dictionary and some on the namespace object—with chaos
 predictably ensuing.
2021-11-08 18:35:38 +00:00
Christopher Allen
5cdc5f587f chore: Update deps.js with modified lang values (#5636)
This updates should have been included in PR #5626 but were apparently
omitted (and the omission not noted by the code reviewer either!)
2021-10-25 17:11:22 +01:00
Aaron Dodson
3851b14627 refactor: Migrate to named exports (#5623)
* refactor: Migrate to named exports

* fix: Sort requires

* fix: Remove duplicate deps
2021-10-20 15:53:23 -07:00
Aaron Dodson
30eb4d45c3 fix: Positioning of pasted/duplicated blocks in LTR workspaces (#5613) 2021-10-18 12:15:27 -07:00
Sandeep Dubey
ec9092fd67 Changes Css.register API to accept string param (#5472)
* Chnages Css.register API to accept string param

* Address self review comments and nits

* Fix code-comment

* Address minor review comments and nits

* Allow passing an array of strings when registering CSS

* Fix lint errors

Co-authored-by: Aaron Dodson <adodson@google.com>
2021-10-14 15:47:10 -07:00
Christopher Allen
d2d5dc4b71 fix: Use require instead of requireType for interfaces (#5568)
But only if the interface is used in an @implements or @extends
declaration.

Fixes #5450
2021-09-29 17:44:21 +01:00
alschmiedt
839cb7bef1 fix: infinite loop when using defineProperties (#5549) 2021-09-27 14:31:30 -07:00
alschmiedt
2b34748e0e chore: remove declareLegacyNamespace from events (#5532)
- Adds an extra events/utils.js file to hold helper methods related to events.
2021-09-24 14:20:32 -07:00
Christopher Allen
16b6d4526a refactor: Rename Blockly.Blocks, migrate to named exports (#5515)
* Rename Blockly.Blocks to Blockly.blocks
  Because it does not export a type as its default export.

  Part of #5073.

* Name default export of Blockly.blocks Blocks.

  Use named exports in Blockly.blocks by giving the former default
  export the name Blocks.

  Part of #5153.

* Reexport Blockly.blocks from blockly.js

* Document the format of renamings.js better.
2021-09-24 19:12:03 +01:00
Christopher Allen
8ab8536739 refactor: Migrate Blockly.ConnectionType to named exports (#5533)
* refactor: Migrate Blockly.ConnectionType to named exports
* Add corresponding information to renamings.js
2021-09-24 17:38:08 +01:00
kozbial
757878c646 chore: Remove declareLegacyNamespace() from files under interfaces/* 2021-09-24 09:05:17 -07:00
Aaron Dodson
6b07ccab96 chore: Remove declareLegacyNamespace from renderers (#5528)
* chore: Remove declareLegacyNamespace from Geras renderer

* chore: Remove declareLegacyNamespace from minimalist renderer

* chore: Remove declareLegacyNamespace from thrasos renderer

* chore: Remove declareLegacyNamespace from zelos renderer

* fix: Move debugger functionality out of Blockly.blockRendering to avoid dependency cycle when re-exporting submodules

* chore: Remove declareLegacyNamespace from Blockly.blockRendering.*
2021-09-24 08:33:35 -07:00
Himanshu
3629ed5f65 refactor: Rename Blockly.connectionTypes to Blockly.ConnectionType (#5407)
* Renamed Blockly.connectionTypes to Blockly.ConnectionType
* Renamed core/connection_types.js to connection_type.js
* Add entry to renamings.js for renaming of Blockly.connectionTypes

Co-authored-by: Christopher Allen <cpcallen+git@google.com>
2021-09-24 12:45:10 +01:00
kozbial
de330c8874 chore: Remove declareLegacyNamespace() from theme files 2021-09-23 15:32:28 -07:00
Aaron Dodson
e0693a65d2 chore: Remove declareLegacyNamespace() from files in core (#5525)
* chore: Remove declareLegacyNamespace() from files in core

* fix: Update missing/errant re-exports in blockly.js
2021-09-23 14:48:52 -07:00
Aaron Dodson
ede7e8c18d chore: Remove declareLegacyNamespace() from field_* files 2021-09-23 14:29:56 -07:00
kozbial
8bd2e8c9e2 chore: Remove declareLegacyNamespace() from toolbox/ files 2021-09-23 11:23:02 -07:00
Neil Fraser
fd917f42b8 Migrate core/field_angle.js to to goog.module syntax (#5521)
Move angle picker field to goog module and ES6.
2021-09-23 09:37:23 -07:00
kozbial
fd251dae22 Merge branch 'goog_module' into merge-develop-to-goog_module 2021-09-22 09:27:52 -07:00
kozbial
6fc90213a6 Merge branch 'develop' into merge-develop-to-goog_module 2021-09-21 16:04:33 -07:00
Aaron Dodson
d6c9423bdf Remove declareLegacyNamespace from block-related files. 2021-09-21 13:18:07 -07:00
Rachel Fenichel
953e3b67b1 chore: remove deprecated functions (#5509) 2021-09-21 13:10:33 -07:00
Christopher Allen
e7955084ae refactor: Remove remaining references to Blockly.* from goog.modules (#5505) 2021-09-21 17:51:35 +01:00
alschmiedt
d79640592f chore: rebuild deps after rebase 2021-09-20 13:08:35 -07:00
Beka Westberg
e954193009 fix: project cereal cleanup (#5398)
* fix: make exception constructors package

* fix: rename blocks.load to blocks.append

* fix: inline docs

* fix: consistency in block serialization

* fix: remove unexported functions

* fix: interface requires

* fix: tag TODO with issue number
2021-09-20 13:08:35 -07:00
Beka Westberg
84514efb09 fix: create and delete events, and the trashcan (#5425)
* fix: create and delete events with JSON serialization

* fix: trashcan with JSON serialization

* fix: build

* fix: tests

* fix: PR comments

* fix: types

* fix: tests
2021-09-20 13:08:35 -07:00
Beka Westberg
e7541cb315 fix: copy paste with json system (#5423)
* fix: copy paste w/ json system

* fix: pr comments
2021-09-20 13:08:35 -07:00
Beka Westberg
96935c2502 fix: cereal backwards compatibility (#5421)
* fix: remove duplicate serialization hook implementations

* feat: add backwards compatibility to field serialization

* feat: add support for serializing old mutator hooks

* fix: build

* fix: refactor field changes into helpers

* fix: typo

* fix: removing xmlns

* tests: add tests for serialization and deserialization of mutator hooks

* fix: switch to early returns
2021-09-20 13:08:35 -07:00
Beka Westberg
410365f4a1 feat: add support for defining toolboxes using pure json (#5392)
* feat: add recycling to core

* feat: add support for json block definitions in flyout

* tests: reorganize tests

* tests: add tests for generating contents

* Fixup reycling

* tests: add tests for recycling

* fix: types

* fix: lint

* fix: PR comments

* fix: creating blocks from flyout

* test: add test block to playground

* fix: types

* feat: add support for enabled
2021-09-20 13:08:35 -07:00