Commit Graph

326 Commits

Author SHA1 Message Date
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
Rachel Fenichel
5deed5a194 chore: fix or ignore remaining lint (#5709)
* chore: fix or ignore remaining lint

* chore: fix bad annotations

* chore: use push for array concatenation

* chore: revert use of spread for array operations
2021-11-17 08:39:00 -08:00
Devesh Kumar
44525754a6 fix: Change Marker in blockly.js becuase of the usage of the Marker class as a named export (#5629)
Fixed marker as per style guide and the export of tabnavigator as well.

Fixes #5606.
2021-10-26 15:33:29 +01:00
alschmiedt
0f3c06306f chore: runs clang format on all files (#5627) 2021-10-21 15:22:24 -07:00
Rachel Fenichel
e8d6f7f408 chore: auto-fix violations of comma-dangle rule (#5625) 2021-10-21 09:01:51 -07: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
Christopher Allen
56d4fbb39f fix: Don't kludge accessors in compiled mode (#5591)
In compiled mode we don't need to add exports to the global Blockly
object because they'll already be there - and attempting to do so
causes problems when a project imports multiple separate copies of
Blockly (which it shouldn't, but many plugins do).

This is part of the fix for google/blockly-samples#902.
2021-10-15 22:09:55 +01:00
Neil Fraser
90b3f75d82 Remove @author tags (#5601)
Our files are up to a decade old, and have churned so much, that the initial author of the file no longer has much meaning.

Furthermore, this will encourage developers to post to the developer group, rather than emailing Googlers (usually me) directly.
2021-10-15 09:50:46 -07:00
Neil Fraser
c929b3015b chore: Convert == to === and != to !== where possible. (#5599) 2021-10-15 09:17:04 -07:00
Rachel Fenichel
b25e24fd02 chore: Run clang-format on core/*.js (#5589)
* Run clang-format on core/*.js

* Revert changes for css formatting
2021-10-07 10:32:02 -07:00
Christopher Allen
c5ffd036ca fix: JSDoc improvments for accessors, etc. (#5567)
* fix: Revert removal of documentation for get/set accessors.
  
  This partially reverts commit 839cb7b,
  "fix: infinite loop when using defineProperties (#5549)"

* docs: Use @name to attach JSDocs to accessors

  Reintroduce documentation for deprecated properties where it was
  removed when converting them to accessors.

* docs: Remove duplicate @package declarations

* fix: Fix eslint and compiler errors/warnings

* fix: Minor JSDoc tweaks to address comments on PR #5567
2021-09-29 01:57:28 +01:00
Monica Kozbial
56d26b8a35 Add missing @alias annotations (#5559) 2021-09-28 08:55:30 -07:00
Monica Kozbial
d8fbe1b05b Add namespace and alias annotations to jsdoc (#5550)
* Add annotations to files under core/events

* Add annotations to files under core/interfaces

* Add annotations to files under core/keyboard_nav

* Add annotations to files under core/renderers

* Add annotations to files under core/serialization

* Add annotations to files under core/theme

* Add annotations to files under core/toolbox

* Add annotations to files under core/utils

* Add annotations to files under core
2021-09-27 14:42:54 -07:00
Christopher Allen
06a41de61e fix: Add hack to copy accessors to global Blockly namespace object (#5536)
Ugly, but it works.
2021-09-27 17:51:59 +01: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
Aaron Dodson
e1310b6464 fix: JSDoc generation for modules without classes 2021-09-22 14:37:55 -07:00
alschmiedt
73580b0ddb chore: named exports for keyboard_nav* files (#5517) 2021-09-22 11:25:38 -07:00
Rachel Fenichel
3adfaaf6d9 chore: named exports for block* files (#5512)
* chore: named export for block.js

* chore: named export for block_drag_surface.js

* chore: named export for block_dragger.js

* chore: named export for block_svg.js

* Fix import ordering

* chore: fix imports using requireType

* Remove extra require
2021-09-22 08:46:19 -07:00
alschmiedt
cf091351d8 chore: remove deprecateLegacyNamespace from keyboard nav files
* chore: Remove deprecateLegacyNamespace & fix tests

* chore: export from the blockly file
2021-09-21 17:18:34 -07:00
Aaron Dodson
d6c9423bdf Remove declareLegacyNamespace from block-related files. 2021-09-21 13:18:07 -07:00
Christopher Allen
e7955084ae refactor: Remove remaining references to Blockly.* from goog.modules (#5505) 2021-09-21 17:51:35 +01: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
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
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
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
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
Rachel Fenichel
d5a6d7d3db Move draggingConnections to common 2021-08-04 15:59:41 -07:00
Rachel Fenichel
1eabe91fa6 Move set/getParentContainer into common 2021-08-04 15:59:41 -07:00
Rachel Fenichel
084c421597 Remove some unused functions and add deprecation warnings 2021-08-04 15:59:41 -07:00
Rachel Fenichel
2e30bbe7ce Update uses of mainWorkspace in core 2021-07-30 11:30:34 -07:00
Rachel Fenichel
a86f1484d2 Move main workspace to a new file, common.js 2021-07-30 11:30:31 -07:00
Rachel Fenichel
f7549f73a6 Use CopyData type 2021-07-29 17:16:58 -07:00
Rachel Fenichel
714bb6120f Fix annotations 2021-07-29 12:52:14 -07:00
Rachel Fenichel
d58a878fad Switch to getter for keyboard contents. 2021-07-29 12:43:49 -07:00