* chore: change the way we look for upstream remote
* chore: use js instead of shell
thanks christopher
Co-authored-by: Christopher Allen <cpcallen+github@gmail.com>
* chore: store the found upstream name
---------
Co-authored-by: Christopher Allen <cpcallen+github@gmail.com>
* fix: update build path for windows
When using single quote on windows, e.g. 'build/src', the folder
are created with a single quote at the beginning `'build` and end
`src'`. This commit fixes this issue.
* fix: update python command and folder separator
Ensure that when running on windows, python command is python and
not python3. Also, separators are normalized to posix style `/` even on
windows system
* fix: add global PYTHON constant to run python command
* fix: simplify `path.sep` to forwadslash since it is cross-platform
* fix(syntax): replace double quote with single quote
* refactor(generators): Move lang.js -> lang/lang_gernator.js
Move the LangGenerator definitions into their respective
subdirectories and add a _generator suffix to their filenames,
i.e. generators/javascript.js becomes
generators/javascript/javascript_generator.js.
This is to keep related code together and allow the `lang/all.js`
entrypoints to be moved to the top level generators/ directory.
No goog module IDs were changed, so playground and test code
that accesses this modules by filename does not need to be modified.
* refactor(generators) Move lang/all.js -> lang.js
- Move the entrypoints in generators/*/all.js to correspondingly-named
files in generators/ instead—i.e., generators/javascript/all.js
becomes generators/javascript.js.
- Update build_tasks.js accordingly.
* fix(generators): Add missing exports for LuaGenerator, PhpGenerator
These were inadvertently omitted from #7161 and #7162, respectively.
* refactor(generators): Make block generator modules side-effect free
- Move declaration of <lang>Generator instance from
generators/<lang>/<lang>_generator.js to generators/<lang>.js.
- Move .addReservedWords() calls from generators/<lang>/*.js to
generators/<lang>.js
- Modify generators/<lang>/*.js to export block generator functions
individually, rather than installing on <lang>Generator instance.
- Modify generators/<lang>.js to import and install block generator
functions on <lang>Generator instance.
* fix(tests): Fix tests broken by restructuring of generators
Where these tests needed block generator functions preinstalled
they should have been importing the Blockly.<Lang>.all module.
Where they do not need the provided block generator functions
they can now create their own empty <Lang>Generator instances.
* chore: Update renamings file
- Fix a malformation in previous entries that was not detected by
the renaming file validator test.
- Add entries describing the work done in this and related recent
PRs.
* fix: Correct minor errors in PR #7173
- Fix a search-and-replace error in renamings.json5
- Fix an incorrect-but-usable import in generator_test.js
* fix(build): Include node_modules/@blockly/ in gh-pages branch
- Add node_modules/@blockly to the list of files added to the gh-pages
branch.
- Add a _config.yml file telling Jekyll (which is needed to produce
the homepage served at https://google.github.io/blockly/, and hence
can't be disabled with a .nojekyll file instead) not to exclude
node_modules (which it does by default).
* refactor(build): Modernise git_tasks.js
- Various style updates:
- Use CONSTANT_CASE.
- Use /** JSDoc comments */
- Use `template ${literals}`.
- Use git switch instead of git checkout.
- Try to avoid use of remote names; use URLs where possible.
* refactor(build): Look up upstream git remote
Since git reset can't take a URL but needs an actual remote name,
use git branch -v to look up the remote for
github.com/google/blockly and then use that remote name.
* chores(build): format
Due to errors in PRs #7171 and 7173 (and the author's failure to do
enough local testing before submitting those PRs), compressed mode
loading was broken in the playgrounds. Fix this by:
- Fix a typo in bootstrap.js ("Blocky" -> "Blockly").
- Updating the chunks definitions build_tasks.js to use the new
variables we expect to contain generator exports objects.
* 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>
Refactor bootstrap.js and bootstrap_helper.js to be able to deal
with generator chunks. In particular for each chunk, specify:
- The goog.module ID to goog.require() in uncompressed mode.
- The script filename to load in compressed mode.
- Where the chunk's UMD wrapper will save the export object when
loaded as a script.
- What global variable the chunk's export object should be saved in
(if desired).
- Any individual named exports to destructure to global variables.
This allows the bootstrap scripts to be slightly simpler while
also being more flexible.
Previously, when loading a generator chunk (e.g.,
javascript_compressed.js) as a script (e.g., in a browser using
a <SCRIPT> tag), only a single named export from that chunk would
be made available (e.g, javascriptGenerator would be made availabe
as Blockly.JavaScript).
Until recently, that was fine because each generator chunk had only
a single named export, but now each one additionally has a
<Lang>Generator class and Order enum export.
To allow these new exports to be accessed by script users, the
chunk wrappers are modified to provide the whole export object
at a correspondingly-named global variable—e.g., when loaded as
a script javascript_compressed.js creates a global variable named
javascript, so the named exports can be accessed as
javascript.javascriptGenerator, javascript.JavascriptGenerator
and javascript.Order, as if the user had imported them via
import * as javascript from 'blockly/javascript';
This PR includes a breaking change and a deprecation, both of
which are only applicable when loading generators as scripts
(e.g. via a <SCRIPT> tag):
BREAKING CHANGE: The generator chunks will, when loaded as scripts
(e.g. via a <SCRIPT> tag, now clobber any existing global variable
of the corresponding name:
- dart_compresed.js will set dart
- javascript_compresed.js will set javascript
- lua_compresed.js will set lua
- php_compresed.js will set php
- python_compresed.js will set python
DEPRECATION: Accessing the generator instances at their previous
locations (Blockly.Dart, Blockly.JavaScript, Blockly.Lua,
Blockly.PHP, and Blockly.Python) is deprecated and may cease
to work in a future version of Blockly.
* 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
* feat(j2ts): Add support for migrating renaming imports
Convert
const {foo: bar} = require(/*...*/);
into
import {foo as bar} from /*...*/;
^^^^^^^^^^
Also fix a bug that caused relative paths to ESM in the same
directory to be missing a leading "./".
* fix(build): Fix trivial error exports for generators
The UMD wrapper was inadvertently exporting the contents of (e.g.)
the Blockly.JavaScript closure module rather than the intended
export of Blockly.JavaScript.all module - which went unnoticed
because the latter just reexported the former - but we are
about to convert the former to ESM.
* chore(generators): Migrate language generators to ESM
Migrate the main language generators in generators/*.js to ESM.
This was done by running js2ts on the files, renaming them back
to .js, and commenting out "import type" statements, which are
legal TS but not needed in JS (at least if you are not actually
letting Closure Compiler do type checking, which we are not.)
* chore(generators): Migrate block generators to ESM
Migrate generators/*/*.js (except all.js) to ESM.
This was done by running js2ts on the files, renaming them back
to .js, and removing now-spurious @suppress {extraRequire}
directives.
* chores(generators): Migrate generator chunk entrypoints to ESM
This was done by running js2ts on the files, renaming them back
to .js, and manually fixing the export statements.
An additional change to the chunk exports configuration in
build_tasks.js was necessary in order for the UMD wrapper to
find the new module object, which is given a different name
than the old exports object.
* chore(deps): Bump @hyperjump/json-schema from 0.23.3 to 1.5.0
Bumps [@hyperjump/json-schema](https://github.com/hyperjump-io/json-schema) from 0.23.3 to 1.5.0.
- [Commits](https://github.com/hyperjump-io/json-schema/compare/v0.23.3...v1.5.0)
---
updated-dependencies:
- dependency-name: "@hyperjump/json-schema"
dependency-type: direct:development
update-type: version-update:semver-major
...
Signed-off-by: dependabot[bot] <support@github.com>
* chore(tests): Compatibility updates to validate-renamings.js
A minimal set of updates to validate-renamings.js to make it
compatible with @hyperjump/json-schema v1.5. The main difference
is that that package now ships ESM rather than CJS modules,
forcing the script to use import rather than require, with
various knock-on effects (no __dirname variable, must be named
*.mjs, etc.)
* chore(tests) Remove unneeded IIFE
* chore(tests): Additional tidy-up of ESM version
Now that validate-renamings is an ES module, we can do some other
cleanup to it.
---------
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>
Temporarily exclude the generated .d.ts files for blocks/* and
generators/* from the package.
This will in due course replace the (very simplistic) hand-written
versions in typings/, but for now they are not referenced
anywhere a developer's tooling should be looking, and contain
in some cases actually incorrect typings (e.g., in unmigrated
blocks files, the blocks export is typed as ObjectConstructor,
which is wrong), so do not include them in the package least they
cause problems for the unwary.
* Reduce usage of obsolete .keyCode property.
* Rename private properties/methods which violate eslint rules.
* Use arrays of bound events rather than individual properties.
* Improve typing info.
* Also fix O(n^2) recursive performance issue in theme's getComponentStyle function.
* And replace String(...) with '${...}' (smaller, faster).
* .toString() is considered harmful.
There are small typos in:
- closure/goog/base.js
- demos/minimap/minimap.js
- gulpfile.js
- scripts/gulpfiles/build_tasks.js
- scripts/gulpfiles/cleanup_tasks.js
- scripts/gulpfiles/license_tasks.js
Fixes:
- Should read `prerequisites` rather than `prequisites`.
- Should read `satisfies` rather than `satisifies`.
- Should read `regenerates` rather than `regenrates`.
- Should read `minimap` rather than `mimimap`.
- Should read `diagnostic` rather than `disagnostic`.
Signed-off-by: Tim Gates <tim.gates@iress.com>
* feat: added `tests/typescript` to test supported TS examples
* fix: update the test name, description, and output
* chore: remove unused imports in `test_tasks.js`
* fix: wrap README line at 80 characters
* fix: implemented `different_user_input.ts` feedback
* fix: correct mistaken comments
* chore: rename `./eslintrc.json` to `./eslintrc.js`
* feat: added linting for tests/typescript
* chore: cleanup eslintrc lines over 80 characters
* fix: updated `.eslintrc.js` to provide an override for linting itself
* fix: updated tests to build to the `build` directory
* feat: updated `gulp format` to handle formatting `.eslintrc.js`
* fix: updated `.eslintrc.js` to align with both formatter and linter
* fix: updated config comment wording
* fix: removed quotes for valid identifiers
* Revert "fix: removed quotes for valid identifiers"
This reverts commit 03eff91aea1468e503bc79a90fb139914d3f39d2.
* 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
* fix(tests): Fix errors in event tests
- Fix actual syntax errors in imports in event_marker_move_test.js
and event_selected.test.js, which were preventing those tests from
being run.
- Remove suite.only directives in those tests that would prevent
all the other tests from running.
* refactor(build): Improve buildDeps
- Run closure-make-deps only once, instead of separately for core/
and tests/.
- Specify a larger exec maxBuffer size, to ensure output and
diagnostics are not truncated.
- Change stderr filtering in buildDeps to filter out bounded
generics messages and blank lines.
- Attempt to suppress warnings in stderr output when
closure-make-deps returns a non-zero exit code.
Unfortunately, there seems to be a race condition which usually
the stderr argument to the exec callback not to contain the
complete output, so in that case print a helpful message.
- Have buildDeps just return a Promise instead of using a callback.
* fix(docs): Typo fix in JSDoc for log helper
* fix(node): Don't use global variables for jsdom injection
Introduce a (hopefully generally applicable) mechanism for
injecting dependencies into modules, specifically in this case
to inject required bits of JSDOM's Window and Document
implementations into core/utils/xml.js when running in
node.js or other environments lacking a DOM.
The injectDependencies function uses an options object to
facilitate optionally injecting multiple named dependencies
at the same time.
Rename the xmlDocument local variable back to document (was
renamed in #5461) so that the name used in this module
corresponds to the usual global variable it replaces.
Change the injection in scripts/package/node/core.js to use
injectDependencies instead of setXmlDocument + global variables;
also eliminate apparently-unnecessary creation of a special
Document instance, using the default one supplied by jsdom
instead.
Fixes#6725.
* deprecate(xml): Deprecate getXmlDocument and setXmlDocument
Mark getXmlDocument and setXmlDocument as @deprecated, with
suitable calls to deprecation.warn().
There are no remaining callers to either function within core -
setXmlDocument was only used by the node.js wrapper, and and
apparently getXmlDocument was never used AFAICT - and we do not
anticipate that either were used by external developers.
* fix: Corrections for comments on PR #6764.
* 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
To make `npm install` and `npm ci` faster, and to avoid redundant
work when doing either of these followed by `npm run build` (or
any other script which does a build), delete the `prepare`
script and instead add an invocation of `npm run deps` to the
beginning of the `start` script.
Modify the prepareDemos script to copy the messages and compressed
files to their previous locations in the deploy directory, to
fix 404 errors on devsite that we can't immediately fix by pushing
devsite.
* 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.