Files
blockly/core/main.js
Christopher Allen be809d9d98 refactor(tests): Migrate generator tests to import shims; delete bootstrap.js (#7414)
* refactor(tests): Use shims instead of bootstrap to load Blockly

  - Modify tests/generators/index.html to import the test shims
    instead of using bootstrap.js to load Blockly.

  - Modify test/generators/webdriver.js to have it wait for the
    workspace to exist before calling loadSelected().  There was
    previously a race which index.html had been winning, but
    now webdriver.js is winning (and the tests failing because
    there is no workspace yet when start() is called.

* chore(tests): Delete bootstrap.js etc.

  - Delete bootstrap.js, bootstrap_helper.js, and bootstrap_done.mjs.
  - Remove remaining references to bootstrap.js

* refactor(build): Remove deps npm script

  buildDeps is now only needed by buildCompiled, not ever for
  runnning in uncompressed mode, so:

  - Remove the deps gulp task (and the deps npm script.
  - Have the minify task run buildJavaScript and buildDeps directly.

  Additionally, the buildAdvanceCompilationTest target hasn't
  needed deps.js for some time (if ever), so skip having it run
  buildDeps entirely.

* refactor(build): Repatriate DEPS_FILE to build_tasks.js

  Since this is no longer used anywhere else it doesn't need to
  live in common.js.

* fix(scripts): Remove vestigial references to deps.mocha.js

* docs(tests): Add additional explanatory note
2023-08-31 00:02:58 +01:00

105 lines
3.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 blockly.loader.mjs.
*/
'use strict';
goog.module('Blockly.main');
const Blockly = goog.require('Blockly');
const Msg = goog.require('Blockly.Msg');
const colour = goog.require('Blockly.utils.colour');
const deprecation = goog.require('Blockly.utils.deprecation');
/*
* 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, {
/**
* 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}
* @deprecated Use Blockly.utils.colour.getHsvSaturation() /
* .setHsvSaturation() instead. (July 2023)
* @suppress {checkTypes}
*/
HSV_SATURATION: {
get: function () {
deprecation.warn(
'Blockly.HSV_SATURATION',
'version 10',
'version 11',
'Blockly.utils.colour.getHsvSaturation()',
);
return colour.getHsvSaturation();
},
set: function (newValue) {
deprecation.warn(
'Blockly.HSV_SATURATION',
'version 10',
'version 11',
'Blockly.utils.colour.setHsvSaturation()',
);
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}
* @deprecated Use Blockly.utils.colour.getHsvValue() / .setHsvValue instead.
* (July 2023)
* @suppress {checkTypes}
*/
HSV_VALUE: {
get: function () {
deprecation.warn(
'Blockly.HSV_VALUE',
'version 10',
'version 11',
'Blockly.utils.colour.getHsvValue()',
);
return colour.getHsvValue();
},
set: function (newValue) {
deprecation.warn(
'Blockly.HSV_VALUE',
'version 10',
'version 11',
'Blockly.utils.colour.setHsvValue()',
);
colour.setHsvValue(newValue);
},
},
});
// 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};
}