From 51d9dad31f8e185c9e6ae7bdda2aafd29786e823 Mon Sep 17 00:00:00 2001 From: Christopher Allen Date: Thu, 16 Sep 2021 18:23:33 +0100 Subject: [PATCH] Re-export `Blockly.utils.*` submodules from `Blockly.utils` (#5465) * Reexport Blockly.utils.* modules from Blockly.utils * Update metadata (file sizes) again blockly_compressed.js has gotten too big for the second time this quarter. Update the expected file sizes for it so that tests will continue to pass. --- core/utils.js | 38 ++++++++++++++++++++++++++++++--- core/utils/aria.js | 1 - core/utils/colour.js | 1 - core/utils/coordinate.js | 1 - core/utils/deprecation.js | 1 - core/utils/dom.js | 1 - core/utils/global.js | 1 - core/utils/idgenerator.js | 1 - core/utils/keycodes.js | 1 - core/utils/math.js | 1 - core/utils/metrics.js | 1 - core/utils/object.js | 1 - core/utils/rect.js | 1 - core/utils/size.js | 1 - core/utils/string.js | 1 - core/utils/style.js | 1 - core/utils/svg.js | 1 - core/utils/svg_paths.js | 1 - core/utils/toolbox.js | 1 - core/utils/useragent.js | 1 - core/utils/xml.js | 1 - package-lock.json | 15 +++++++------ package.json | 2 +- tests/deps.js | 2 +- tests/scripts/check_metadata.sh | 10 +++++---- 25 files changed, 51 insertions(+), 36 deletions(-) diff --git a/core/utils.js b/core/utils.js index cb711e1a8..f09526afe 100644 --- a/core/utils.js +++ b/core/utils.js @@ -22,20 +22,52 @@ goog.module.declareLegacyNamespace(); /* eslint-disable-next-line no-unused-vars */ const Block = goog.requireType('Blockly.Block'); const Coordinate = goog.require('Blockly.utils.Coordinate'); +const KeyCodes = goog.require('Blockly.utils.KeyCodes'); +const Metrics = goog.require('Blockly.utils.Metrics'); const Msg = goog.require('Blockly.Msg'); const Rect = goog.require('Blockly.utils.Rect'); +const Size = goog.require('Blockly.utils.Size'); +const Svg = goog.require('Blockly.utils.Svg'); /* eslint-disable-next-line no-unused-vars */ const WorkspaceSvg = goog.requireType('Blockly.WorkspaceSvg'); +const aria = goog.require('Blockly.utils.aria'); const colourUtils = goog.require('Blockly.utils.colour'); const deprecation = goog.require('Blockly.utils.deprecation'); -const {globalThis} = goog.require('Blockly.utils.global'); +const dom = goog.require('Blockly.utils.dom'); +const global = goog.require('Blockly.utils.global'); const idGenerator = goog.require('Blockly.utils.idGenerator'); const internalConstants = goog.require('Blockly.internalConstants'); +const math = goog.require('Blockly.utils.math'); +const object = goog.require('Blockly.utils.object'); const stringUtils = goog.require('Blockly.utils.string'); const style = goog.require('Blockly.utils.style'); +const svgPaths = goog.require('Blockly.utils.svgPaths'); +const toolbox = goog.require('Blockly.utils.toolbox'); const userAgent = goog.require('Blockly.utils.userAgent'); +const xmlUtils = goog.require('Blockly.utils.xml'); +exports.aria = aria; +exports.colour = colourUtils; +exports.Coordinate = Coordinate; +exports.deprecation = deprecation; +exports.dom = dom; +exports.global = global; +exports.idGenerator = idGenerator; +exports.KeyCodes = KeyCodes; +exports.math = math; +exports.Metrics = Metrics; +exports.object = object; +exports.Rect = Rect; +exports.Size = Size; +exports.string = stringUtils; +exports.style = style; +exports.Svg = Svg; +exports.svgPaths = svgPaths; +exports.toolbox = toolbox; +exports.userAgent = userAgent; +exports.xml = xmlUtils; + /** * Don't do anything for this event, just halt propagation. * @param {!Event} e An event. @@ -433,7 +465,7 @@ const is3dSupported = function() { } // CC-BY-SA Lorenzo Polidori // stackoverflow.com/questions/5661671/detecting-transform-translate3d-support - if (!globalThis['getComputedStyle']) { + if (!global.globalThis['getComputedStyle']) { return false; } @@ -453,7 +485,7 @@ const is3dSupported = function() { for (let t in transforms) { if (el.style[t] !== undefined) { el.style[t] = 'translate3d(1px,1px,1px)'; - const computedStyle = globalThis['getComputedStyle'](el); + const computedStyle = global.globalThis['getComputedStyle'](el); if (!computedStyle) { // getComputedStyle in Firefox returns null when Blockly is loaded // inside an iframe with display: none. Returning false and not diff --git a/core/utils/aria.js b/core/utils/aria.js index b387b4677..6d9274117 100644 --- a/core/utils/aria.js +++ b/core/utils/aria.js @@ -17,7 +17,6 @@ * @namespace */ goog.module('Blockly.utils.aria'); -goog.module.declareLegacyNamespace(); /** ARIA states/properties prefix. */ diff --git a/core/utils/colour.js b/core/utils/colour.js index 20f437cc7..acdc18a8c 100644 --- a/core/utils/colour.js +++ b/core/utils/colour.js @@ -17,7 +17,6 @@ * @namespace */ goog.module('Blockly.utils.colour'); -goog.module.declareLegacyNamespace(); const internalConstants = goog.require('Blockly.internalConstants'); diff --git a/core/utils/coordinate.js b/core/utils/coordinate.js index ca5a248d3..4376fa83d 100644 --- a/core/utils/coordinate.js +++ b/core/utils/coordinate.js @@ -17,7 +17,6 @@ * @namespace */ goog.module('Blockly.utils.Coordinate'); -goog.module.declareLegacyNamespace(); /** * Class for representing coordinates and positions. diff --git a/core/utils/deprecation.js b/core/utils/deprecation.js index 870294172..4edfef9a4 100644 --- a/core/utils/deprecation.js +++ b/core/utils/deprecation.js @@ -16,7 +16,6 @@ * @namespace */ goog.module('Blockly.utils.deprecation'); -goog.module.declareLegacyNamespace(); /** diff --git a/core/utils/dom.js b/core/utils/dom.js index f226cf406..f22a1a458 100644 --- a/core/utils/dom.js +++ b/core/utils/dom.js @@ -17,7 +17,6 @@ * @namespace */ goog.module('Blockly.utils.dom'); -goog.module.declareLegacyNamespace(); /* eslint-disable-next-line no-unused-vars */ const Svg = goog.requireType('Blockly.utils.Svg'); diff --git a/core/utils/global.js b/core/utils/global.js index 75b9241bf..b969ad38a 100644 --- a/core/utils/global.js +++ b/core/utils/global.js @@ -11,7 +11,6 @@ 'use strict'; goog.module('Blockly.utils.global'); -goog.module.declareLegacyNamespace(); /** diff --git a/core/utils/idgenerator.js b/core/utils/idgenerator.js index 14f78747c..5c8c61b08 100644 --- a/core/utils/idgenerator.js +++ b/core/utils/idgenerator.js @@ -15,7 +15,6 @@ * @namespace */ goog.module('Blockly.utils.idGenerator'); -goog.module.declareLegacyNamespace(); /** diff --git a/core/utils/keycodes.js b/core/utils/keycodes.js index 586d2f97e..1501fa2ac 100644 --- a/core/utils/keycodes.js +++ b/core/utils/keycodes.js @@ -17,7 +17,6 @@ * @namespace */ goog.module('Blockly.utils.KeyCodes'); -goog.module.declareLegacyNamespace(); /** diff --git a/core/utils/math.js b/core/utils/math.js index 9b717d065..c54f6fb0f 100644 --- a/core/utils/math.js +++ b/core/utils/math.js @@ -17,7 +17,6 @@ * @namespace */ goog.module('Blockly.utils.math'); -goog.module.declareLegacyNamespace(); /** diff --git a/core/utils/metrics.js b/core/utils/metrics.js index 55cadfae9..909c5fa39 100644 --- a/core/utils/metrics.js +++ b/core/utils/metrics.js @@ -15,7 +15,6 @@ * @namespace */ goog.module('Blockly.utils.Metrics'); -goog.module.declareLegacyNamespace(); /** diff --git a/core/utils/object.js b/core/utils/object.js index 3507d33ab..bb56d11fd 100644 --- a/core/utils/object.js +++ b/core/utils/object.js @@ -15,7 +15,6 @@ * @namespace */ goog.module('Blockly.utils.object'); -goog.module.declareLegacyNamespace(); /** diff --git a/core/utils/rect.js b/core/utils/rect.js index 85ade5388..a77ee3728 100644 --- a/core/utils/rect.js +++ b/core/utils/rect.js @@ -17,7 +17,6 @@ * @namespace */ goog.module('Blockly.utils.Rect'); -goog.module.declareLegacyNamespace(); /** diff --git a/core/utils/size.js b/core/utils/size.js index 56ec2eb91..11d604125 100644 --- a/core/utils/size.js +++ b/core/utils/size.js @@ -17,7 +17,6 @@ * @namespace */ goog.module('Blockly.utils.Size'); -goog.module.declareLegacyNamespace(); /** diff --git a/core/utils/string.js b/core/utils/string.js index ce815616f..f65673f09 100644 --- a/core/utils/string.js +++ b/core/utils/string.js @@ -17,7 +17,6 @@ * @namespace */ goog.module('Blockly.utils.string'); -goog.module.declareLegacyNamespace(); /** diff --git a/core/utils/style.js b/core/utils/style.js index 0fbd22093..13d05e752 100644 --- a/core/utils/style.js +++ b/core/utils/style.js @@ -17,7 +17,6 @@ * @namespace */ goog.module('Blockly.utils.style'); -goog.module.declareLegacyNamespace(); const Coordinate = goog.require('Blockly.utils.Coordinate'); const Size = goog.require('Blockly.utils.Size'); diff --git a/core/utils/svg.js b/core/utils/svg.js index 39392790e..79b55248e 100644 --- a/core/utils/svg.js +++ b/core/utils/svg.js @@ -16,7 +16,6 @@ * @namespace */ goog.module('Blockly.utils.Svg'); -goog.module.declareLegacyNamespace(); /** diff --git a/core/utils/svg_paths.js b/core/utils/svg_paths.js index 7286e8bc6..a1f9bf2e8 100644 --- a/core/utils/svg_paths.js +++ b/core/utils/svg_paths.js @@ -16,7 +16,6 @@ * @namespace */ goog.module('Blockly.utils.svgPaths'); -goog.module.declareLegacyNamespace(); /** diff --git a/core/utils/toolbox.js b/core/utils/toolbox.js index 73b57cbd7..34208bf13 100644 --- a/core/utils/toolbox.js +++ b/core/utils/toolbox.js @@ -15,7 +15,6 @@ * @namespace */ goog.module('Blockly.utils.toolbox'); -goog.module.declareLegacyNamespace(); /* eslint-disable-next-line no-unused-vars */ const ToolboxCategory = goog.requireType('Blockly.ToolboxCategory'); diff --git a/core/utils/useragent.js b/core/utils/useragent.js index 011e72eb0..245a23c27 100644 --- a/core/utils/useragent.js +++ b/core/utils/useragent.js @@ -17,7 +17,6 @@ * @namespace */ goog.module('Blockly.utils.userAgent'); -goog.module.declareLegacyNamespace(); const {globalThis} = goog.require('Blockly.utils.global'); diff --git a/core/utils/xml.js b/core/utils/xml.js index 34dfdb170..af3043de2 100644 --- a/core/utils/xml.js +++ b/core/utils/xml.js @@ -17,7 +17,6 @@ * @namespace */ goog.module('Blockly.utils.xml'); -goog.module.declareLegacyNamespace(); const {globalThis} = goog.require('Blockly.utils.global'); diff --git a/package-lock.json b/package-lock.json index 99f8989af..c4172ca05 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,6 +5,7 @@ "requires": true, "packages": { "": { + "name": "blockly", "version": "6.20210701.0", "license": "Apache-2.0", "dependencies": { @@ -12,7 +13,7 @@ }, "devDependencies": { "@blockly/block-test": "^1.0.0", - "@blockly/dev-tools": "^2.6.0", + "@blockly/dev-tools": "^2.6.1-beta.0", "@blockly/theme-modern": "^2.1.1", "@wdio/selenium-standalone-service": "^6.11.0", "babel-eslint": "^10.1.0", @@ -278,9 +279,9 @@ } }, "node_modules/@blockly/dev-tools": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/@blockly/dev-tools/-/dev-tools-2.6.0.tgz", - "integrity": "sha512-/FRRg4/WQMEf2hMA5dcpjh2W6HwxgBK+a9fLuUDNckH+QMenO+6wk/YkZpQStyMu+EP8BDP8L2Z4iSORAenl8w==", + "version": "2.6.1-beta.0", + "resolved": "https://registry.npmjs.org/@blockly/dev-tools/-/dev-tools-2.6.1-beta.0.tgz", + "integrity": "sha512-GKnOT+EkvhRtwG6ZRseWEFB96xMyzzY6CPCkPHbCHGNnOB4Z4j3jmU2zIMkWG8lR8pQF0CCWKZinDrMtXSeLjQ==", "dev": true, "dependencies": { "@blockly/block-test": "^1.1.5", @@ -12734,9 +12735,9 @@ "requires": {} }, "@blockly/dev-tools": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/@blockly/dev-tools/-/dev-tools-2.6.0.tgz", - "integrity": "sha512-/FRRg4/WQMEf2hMA5dcpjh2W6HwxgBK+a9fLuUDNckH+QMenO+6wk/YkZpQStyMu+EP8BDP8L2Z4iSORAenl8w==", + "version": "2.6.1-beta.0", + "resolved": "https://registry.npmjs.org/@blockly/dev-tools/-/dev-tools-2.6.1-beta.0.tgz", + "integrity": "sha512-GKnOT+EkvhRtwG6ZRseWEFB96xMyzzY6CPCkPHbCHGNnOB4Z4j3jmU2zIMkWG8lR8pQF0CCWKZinDrMtXSeLjQ==", "dev": true, "requires": { "@blockly/block-test": "^1.1.5", diff --git a/package.json b/package.json index d06842b0e..dc83a9df4 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "license": "Apache-2.0", "devDependencies": { "@blockly/block-test": "^1.0.0", - "@blockly/dev-tools": "^2.6.0", + "@blockly/dev-tools": "^2.6.1-beta.0", "@blockly/theme-modern": "^2.1.1", "@wdio/selenium-standalone-service": "^6.11.0", "babel-eslint": "^10.1.0", diff --git a/tests/deps.js b/tests/deps.js index 86ee6ee14..86160bb66 100644 --- a/tests/deps.js +++ b/tests/deps.js @@ -211,7 +211,7 @@ goog.addDependency('../../core/tooltip.js', ['Blockly.Tooltip'], ['Blockly.brows goog.addDependency('../../core/touch.js', ['Blockly.Touch'], ['Blockly.internalConstants', 'Blockly.utils.global', 'Blockly.utils.string'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/touch_gesture.js', ['Blockly.TouchGesture'], ['Blockly.Gesture', 'Blockly.Touch', 'Blockly.browserEvents', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/trashcan.js', ['Blockly.Trashcan'], ['Blockly.ComponentManager', 'Blockly.DeleteArea', 'Blockly.Events', 'Blockly.Events.TrashcanOpen', 'Blockly.Options', 'Blockly.Xml', 'Blockly.browserEvents', 'Blockly.internalConstants', 'Blockly.registry', 'Blockly.uiPosition', 'Blockly.utils.Rect', 'Blockly.utils.Size', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.toolbox'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../core/utils.js', ['Blockly.utils'], ['Blockly.Msg', 'Blockly.internalConstants', 'Blockly.utils.Coordinate', 'Blockly.utils.Rect', 'Blockly.utils.colour', 'Blockly.utils.deprecation', 'Blockly.utils.global', 'Blockly.utils.idGenerator', 'Blockly.utils.string', 'Blockly.utils.style', 'Blockly.utils.userAgent'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../core/utils.js', ['Blockly.utils'], ['Blockly.Msg', 'Blockly.internalConstants', 'Blockly.utils.Coordinate', 'Blockly.utils.KeyCodes', 'Blockly.utils.Metrics', 'Blockly.utils.Rect', 'Blockly.utils.Size', 'Blockly.utils.Svg', 'Blockly.utils.aria', 'Blockly.utils.colour', 'Blockly.utils.deprecation', 'Blockly.utils.dom', 'Blockly.utils.global', 'Blockly.utils.idGenerator', 'Blockly.utils.math', 'Blockly.utils.object', 'Blockly.utils.string', 'Blockly.utils.style', 'Blockly.utils.svgPaths', 'Blockly.utils.toolbox', 'Blockly.utils.userAgent', 'Blockly.utils.xml'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/utils/aria.js', ['Blockly.utils.aria'], [], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/utils/colour.js', ['Blockly.utils.colour'], ['Blockly.internalConstants'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/utils/coordinate.js', ['Blockly.utils.Coordinate'], [], {'lang': 'es6', 'module': 'goog'}); diff --git a/tests/scripts/check_metadata.sh b/tests/scripts/check_metadata.sh index 642be7191..b716d0063 100755 --- a/tests/scripts/check_metadata.sh +++ b/tests/scripts/check_metadata.sh @@ -25,8 +25,9 @@ readonly BUILD_DIR='build' # Q4 2020 4.20201217.0 653624 # Q1 2021 5.20210325.0 653957 # Q2 2021 6.20210701.0 664497 -# Q3 2021 6.20210701.0 731695 (mid-quarter goog.module conversion change) -readonly BLOCKLY_SIZE_EXPECTED=731695 +# Q3 2021 6.20210701.0 731695 (mid-quarter goog.module conversion) +# Q3 2021 6.20210701.0 808807 (late-quarter goog.module conversion) +readonly BLOCKLY_SIZE_EXPECTED=808807 # Size of blocks_compressed.js # Q2 2019 2.20190722.0 75618 @@ -51,8 +52,9 @@ readonly BLOCKS_SIZE_EXPECTED=76669 # Q4 2020 4.20201217.0 138115 # Q1 2021 5.20210325.0 136118 # Q2 2021 6.20210701.0 142112 -# Q3 2021 6.20210701.0 147476 (mid-quarter goog.module conversion change) -readonly BLOCKLY_GZ_SIZE_EXPECTED=147476 +# Q3 2021 6.20210701.0 147476 (mid-quarter goog.module conversion) +# Q3 2021 6.20210701.0 152025 (late-quarter goog.module conversion) +readonly BLOCKLY_GZ_SIZE_EXPECTED=152025 # Size of blocks_compressed.js.gz # Q2 2019 2.20190722.0 14552