mirror of
https://github.com/google/blockly.git
synced 2026-01-08 01:20:12 +01:00
* chore(deps): Update closure/goog/base.js, add goog.js
* Update base.js from the latest version (20220104.0.0).
* Also copy over goog.js, which provides access to asuitable subset
of goog.* via an importable module).
* refactor(tests): Have playground.html load Blockly as a module
N.B.:
* We still need a preparation step, in order to load base.js and
deps.js via <script> tags in uncompiled mode; in compiled mode
it will instead load all the *_compressed.js files via <script>
tags.
Acess to the Blockly object is via:
import Blockly from './playgrounds/blockly.mjs';
(N.B: no "* as", since blockly.mjs has only a default export.)
* There remain two serious defects when running in uncompiled mode:
* It does not attempt to load msg/messages.js, causing startup to
fail.
* Module loading only works if there are no ES Modules; if there
are, something goes wrong with base.js's attempt to sequence
module loads causing goog.modules that import ES modules to get
a null exports object for that import. X-(
* fix(tests): Have playground.html load messages.js before generators
This fixes the issue caused by missing messages when loading
the generators.
* fix(tests): Move bootsrap calls to prepare.js
Move the calls to goog.bootstrap from blockly.mjs to prepare.mjs.
This is needed to work around a bug in the Cosure Library debug
loader (https://github.com/google/closure-library/issues/1152).
This gets a bit ugly because most of the code has to go in a
<script> (because it needs goog.bootstrap, which was loaded by
an earlier <script> tag).
* fix(documentation): Minor comment corrections for PR #5931
39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
/**
|
|
* @license
|
|
* Copyright 2022 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
/**
|
|
* @fileoverview Finishes loading Blockly and exports it as this
|
|
* module's default export.
|
|
*
|
|
* It is exported as the default export to avoid having to
|
|
* re-export each property on Blockly individually, because you
|
|
* can't do:
|
|
*
|
|
* export * from <dynamically computed source>; // SYNTAX ERROR
|
|
*
|
|
* You must use a <script> tag to load prepare.js first, before
|
|
* importing this module in a <script type=module> to obtain the
|
|
* loaded value.
|
|
*
|
|
* See tests/playground.html for example usage.
|
|
*/
|
|
|
|
let Blockly;
|
|
|
|
if (window.BlocklyLoader) {
|
|
// Uncompiled mode. Use top-level await
|
|
// (https://v8.dev/features/top-level-await) to block loading of
|
|
// this module until goog.bootstrap()ping of Blockly is finished.
|
|
Blockly = await window.BlocklyLoader;
|
|
} else if (window.Blockly) {
|
|
// Compiled mode. Retrieve the pre-installed Blockly global.
|
|
Blockly = globalThis.Blockly;
|
|
} else {
|
|
throw new Error('neither window.Blockly nor window.BlocklyLoader found');
|
|
}
|
|
|
|
export default Blockly;
|