mirror of
https://github.com/google/blockly.git
synced 2026-01-08 01:20:12 +01:00
* 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'
302 lines
9.2 KiB
JavaScript
302 lines
9.2 KiB
JavaScript
/**
|
|
* @license
|
|
* Copyright 2022 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
/**
|
|
* @fileoverview The entrypoint for blockly_compressed.js. Provides
|
|
* various backwards-compatibility hacks. Not used when loading
|
|
* in uncompiled (uncompressed) mode via bootstrap.js.
|
|
*/
|
|
'use strict';
|
|
|
|
goog.module('Blockly.main');
|
|
|
|
const Blockly = goog.require('Blockly');
|
|
const ContextMenu = goog.require('Blockly.ContextMenu');
|
|
const Events = goog.require('Blockly.Events');
|
|
const Msg = goog.require('Blockly.Msg');
|
|
const Tooltip = goog.require('Blockly.Tooltip');
|
|
const WidgetDiv = goog.require('Blockly.WidgetDiv');
|
|
const colour = goog.require('Blockly.utils.colour');
|
|
const common = goog.require('Blockly.common');
|
|
const deprecation = goog.require('Blockly.utils.deprecation');
|
|
const dialog = goog.require('Blockly.dialog');
|
|
const eventUtils = goog.require('Blockly.Events.utils');
|
|
|
|
/*
|
|
* Aliased functions and properties that used to be on the Blockly namespace.
|
|
* Everything in this section is deprecated. Both external and internal code
|
|
* should avoid using these functions and use the designated replacements.
|
|
* Everything in this section will be removed in a future version of Blockly.
|
|
*/
|
|
|
|
// Add accessors for properties on Blockly that have now been deprecated.
|
|
Object.defineProperties(Blockly, {
|
|
/**
|
|
* Wrapper to window.alert() that app developers may override to
|
|
* provide alternatives to the modal browser window.
|
|
* @name Blockly.alert
|
|
* @type {!function(string, function()=)}
|
|
* @deprecated Use Blockly.dialog.alert / .setAlert() instead.
|
|
* (December 2021)
|
|
* @suppress {checkTypes}
|
|
*/
|
|
alert: {
|
|
set: function(newAlert) {
|
|
deprecation.warn('Blockly.alert', 'December 2021', 'December 2022');
|
|
dialog.setAlert(newAlert);
|
|
},
|
|
get: function() {
|
|
deprecation.warn(
|
|
'Blockly.alert', 'December 2021', 'December 2022',
|
|
'Blockly.dialog.alert()');
|
|
return dialog.alert;
|
|
},
|
|
},
|
|
/**
|
|
* Wrapper to window.confirm() that app developers may override to
|
|
* provide alternatives to the modal browser window.
|
|
* @name Blockly.confirm
|
|
* @type {!function(string, function()=)}
|
|
* @deprecated Use Blockly.dialog.confirm / .setConfirm() instead.
|
|
* (December 2021)
|
|
* @suppress {checkTypes}
|
|
*/
|
|
confirm: {
|
|
set: function(newConfirm) {
|
|
deprecation.warn('Blockly.confirm', 'December 2021', 'December 2022');
|
|
dialog.setConfirm(newConfirm);
|
|
},
|
|
get: function() {
|
|
deprecation.warn(
|
|
'Blockly.confirm', 'December 2021', 'December 2022',
|
|
'Blockly.dialog.confirm()');
|
|
return dialog.confirm;
|
|
},
|
|
},
|
|
/**
|
|
* The main workspace most recently used.
|
|
* Set by Blockly.WorkspaceSvg.prototype.markFocused
|
|
* @name Blockly.mainWorkspace
|
|
* @type {Workspace}
|
|
* @suppress {checkTypes}
|
|
*/
|
|
mainWorkspace: {
|
|
set: function(x) {
|
|
deprecation.warn(
|
|
'Blockly.mainWorkspace', 'version 9', 'version 10',
|
|
'Blockly.getMainWorkspace');
|
|
common.setMainWorkspace(x);
|
|
},
|
|
get: function() {
|
|
deprecation.warn(
|
|
'Blockly.mainWorkspace', 'version 9', 'version 10',
|
|
'Blockly.getMainWorkspace');
|
|
return common.getMainWorkspace();
|
|
},
|
|
},
|
|
/**
|
|
* Wrapper to window.prompt() that app developers may override to
|
|
* provide alternatives to the modal browser window. Built-in
|
|
* browser prompts are often used for better text input experience
|
|
* on mobile device. We strongly recommend testing mobile when
|
|
* overriding this.
|
|
* @name Blockly.prompt
|
|
* @type {!function(string, string, function()=)}
|
|
* @deprecated Use Blockly.dialog.prompt / .setPrompt() instead.
|
|
* (December 2021)
|
|
* @suppress {checkTypes}
|
|
*/
|
|
prompt: {
|
|
set: function(newPrompt) {
|
|
deprecation.warn('Blockly.prompt', 'December 2021', 'December 2022');
|
|
dialog.setPrompt(newPrompt);
|
|
},
|
|
get: function() {
|
|
deprecation.warn(
|
|
'Blockly.prompt', 'December 2021', 'December 2022',
|
|
'Blockly.dialog.prompt()');
|
|
return dialog.prompt;
|
|
},
|
|
},
|
|
/**
|
|
* Currently selected block.
|
|
* @name Blockly.selected
|
|
* @type {?ICopyable}
|
|
* @suppress {checkTypes}
|
|
*/
|
|
selected: {
|
|
get: function() {
|
|
deprecation.warn(
|
|
'Blockly.selected', 'version 9', 'version 10', 'Blockly.getSelected');
|
|
return common.getSelected();
|
|
},
|
|
set: function(newSelection) {
|
|
deprecation.warn(
|
|
'Blockly.selected', 'version 9', 'version 10', 'Blockly.getSelected');
|
|
common.setSelected(newSelection);
|
|
},
|
|
},
|
|
/**
|
|
* The richness of block colours, regardless of the hue.
|
|
* Must be in the range of 0 (inclusive) to 1 (exclusive).
|
|
* @name Blockly.HSV_SATURATION
|
|
* @type {number}
|
|
* @suppress {checkTypes}
|
|
*/
|
|
HSV_SATURATION: {
|
|
get: function() {
|
|
return colour.getHsvSaturation();
|
|
},
|
|
set: function(newValue) {
|
|
colour.setHsvSaturation(newValue);
|
|
},
|
|
},
|
|
/**
|
|
* The intensity of block colours, regardless of the hue.
|
|
* Must be in the range of 0 (inclusive) to 1 (exclusive).
|
|
* @name Blockly.HSV_VALUE
|
|
* @type {number}
|
|
* @suppress {checkTypes}
|
|
*/
|
|
HSV_VALUE: {
|
|
get: function() {
|
|
return colour.getHsvValue();
|
|
},
|
|
set: function(newValue) {
|
|
colour.setHsvValue(newValue);
|
|
},
|
|
},
|
|
});
|
|
|
|
// Add accessors for properties on Blockly.ContextMenu that have now
|
|
// been deprecated.
|
|
Object.defineProperties(ContextMenu, {
|
|
/**
|
|
* Which block is the context menu attached to?
|
|
* @name Blockly.ContextMenu.currentBlock
|
|
* @type {Block}
|
|
* @deprecated Use Blockly.Tooltip.getCurrentBlock() /
|
|
* .setCurrentBlock() instead. (September 2021)
|
|
* @suppress {checkTypes}
|
|
*/
|
|
currentBlock: {
|
|
get: function() {
|
|
deprecation.warn(
|
|
'Blockly.ContextMenu.currentBlock', 'September 2021',
|
|
'September 2022', 'Blockly.Tooltip.getCurrentBlock()');
|
|
return ContextMenu.getCurrentBlock();
|
|
},
|
|
set: function(block) {
|
|
deprecation.warn(
|
|
'Blockly.ContextMenu.currentBlock', 'September 2021',
|
|
'September 2022', 'Blockly.Tooltip.setCurrentBlock(block)');
|
|
ContextMenu.setCurrentBlock(block);
|
|
},
|
|
},
|
|
});
|
|
|
|
// Add accessors for properties on Blockly.Events that have now been
|
|
// deprecated.
|
|
Object.defineProperties(Events, {
|
|
/**
|
|
* Sets whether the next event should be added to the undo stack.
|
|
* @name Blockly.Evenents.recordUndo
|
|
* @type {boolean}
|
|
* @deprecated Use Blockly.Events.getRecordUndo() and
|
|
* .setRecordUndo(). (September 2021)
|
|
* @suppress {checkTypes}
|
|
*/
|
|
recordUndo: {
|
|
get: function() {
|
|
deprecation.warn(
|
|
'Blockly.Events.recordUndo', 'September 2021', 'September 2022',
|
|
'Blockly.Events.getRecordUndo()');
|
|
return eventUtils.getRecordUndo();
|
|
},
|
|
set: function(record) {
|
|
deprecation.warn(
|
|
'Blockly.Events.recordUndo', 'September 2021', 'September 2022',
|
|
'Blockly.Events.setRecordUndo()');
|
|
eventUtils.setRecordUndo(record);
|
|
},
|
|
},
|
|
});
|
|
|
|
|
|
// Add accessors for properties on Blockly.Tooltip that have now been
|
|
// deprecated.
|
|
Object.defineProperties(Tooltip, {
|
|
/**
|
|
* Is a tooltip currently showing?
|
|
* @name Blockly.Tooltip.visible
|
|
* @type {boolean}
|
|
* @deprecated Use Blockly.Tooltip.isVisible() instead. (September
|
|
* 2021)
|
|
* @suppress {checkTypes}
|
|
*/
|
|
visible: {
|
|
get: function() {
|
|
deprecation.warn(
|
|
'Blockly.Tooltip.visible', 'September 2021', 'September 2022',
|
|
'Blockly.Tooltip.isVisible()');
|
|
return Tooltip.isVisible();
|
|
},
|
|
},
|
|
/**
|
|
* The HTML container. Set once by createDom.
|
|
* @name Blockly.Tooltip.DIV
|
|
* @type {HTMLDivElement}
|
|
* @deprecated Use Blockly.Tooltip.getDiv() and .setDiv().
|
|
* (September 2021)
|
|
* @suppress {checkTypes}
|
|
*/
|
|
DIV: {
|
|
get: function() {
|
|
deprecation.warn(
|
|
'Blockly.Tooltip.DIV', 'September 2021', 'September 2022',
|
|
'Blockly.Tooltip.getDiv()');
|
|
return Tooltip.getDiv();
|
|
},
|
|
},
|
|
});
|
|
|
|
// Add accessors for properties on Blockly.WidgetDiv that have now been
|
|
// deprecated.
|
|
Object.defineProperties(WidgetDiv, {
|
|
/**
|
|
* The HTML container for popup overlays (e.g. editor widgets).
|
|
* @name Blockly.WidgetDiv.DIV
|
|
* @type {?Element}
|
|
* @deprecated Use Blockly.WidgetDiv.getDiv() and .setDiv().
|
|
* (September 2021)
|
|
* @suppress {checkTypes}
|
|
*/
|
|
DIV: {
|
|
get: function() {
|
|
deprecation.warn(
|
|
'Blockly.WidgetDiv.DIV', 'September 2021', 'September 2022',
|
|
'Blockly.WidgetDiv.getDiv()');
|
|
return WidgetDiv.getDiv();
|
|
},
|
|
},
|
|
});
|
|
|
|
// If Blockly is compiled with ADVANCED_COMPILATION and/or loaded as a
|
|
// CJS or ES module there will not be a Blockly global variable
|
|
// created. This can cause problems because a very common way of
|
|
// loading translations is to use a <script> tag to load one of
|
|
// the generated msg/*.js files, which consists of lines like:
|
|
//
|
|
// Blockly.Msg["ADD_COMMENT"] = "Add Comment";
|
|
// Blockly.Msg["CLEAN_UP"] = "Clean up Blocks";
|
|
//
|
|
// This obviously only works if Blockly.Msg is the Msg export from the
|
|
// Blockly.Msg module - so make sure it is, but only if there is not
|
|
// yet a Blockly global variable.
|
|
if (!('Blockly' in globalThis)) {
|
|
globalThis['Blockly'] = {'Msg': Msg};
|
|
}
|