From 084c421597977501df1f6b7e178391715dd17a7d Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Fri, 30 Jul 2021 13:44:21 -0700 Subject: [PATCH] Remove some unused functions and add deprecation warnings --- core/blockly.js | 84 +++---------------------------------------------- core/inject.js | 2 -- 2 files changed, 5 insertions(+), 81 deletions(-) diff --git a/core/blockly.js b/core/blockly.js index 7ad87be94..4d14aac1e 100644 --- a/core/blockly.js +++ b/core/blockly.js @@ -76,9 +76,14 @@ Blockly.VERSION = 'uncompiled'; // Add a getter and setter pair for Blockly.mainWorkspace, for legacy reasons. Object.defineProperty(Blockly, 'mainWorkspace', { set: function(x) { + Blockly.utils.deprecation.warn( + 'Blockly.mainWorkspace', 'September 2021', 'September 2022'); Blockly.common.setMainWorkspace(x); }, get: function() { + Blockly.utils.deprecation.warn( + 'Blockly.mainWorkspace', 'September 2021', 'September 2022', + 'Blockly.getMainWorkspace()'); return Blockly.common.getMainWorkspace(); } }); @@ -96,13 +101,6 @@ Blockly.selected = null; */ Blockly.draggingConnections = []; -/** - * Cached value for whether 3D is supported. - * @type {?boolean} - * @private - */ -Blockly.cache3dSupported_ = null; - /** * Container element to render the WidgetDiv, DropDownDiv and Tooltip. * @type {?Element} @@ -372,78 +370,6 @@ Blockly.hueToHex = function(hue) { Blockly.internalConstants.HSV_VALUE * 255); }; -/** - * Checks old colour constants are not overwritten by the host application. - * If a constant is overwritten, it prints a console warning directing the - * developer to use the equivalent Msg constant. - * @package - */ -Blockly.checkBlockColourConstants = function() { - Blockly.checkBlockColourConstant_( - 'LOGIC_HUE', ['Blocks', 'logic', 'HUE'], undefined); - Blockly.checkBlockColourConstant_( - 'LOGIC_HUE', ['Constants', 'Logic', 'HUE'], 210); - Blockly.checkBlockColourConstant_( - 'LOOPS_HUE', ['Blocks', 'loops', 'HUE'], undefined); - Blockly.checkBlockColourConstant_( - 'LOOPS_HUE', ['Constants', 'Loops', 'HUE'], 120); - Blockly.checkBlockColourConstant_( - 'MATH_HUE', ['Blocks', 'math', 'HUE'], undefined); - Blockly.checkBlockColourConstant_( - 'MATH_HUE', ['Constants', 'Math', 'HUE'], 230); - Blockly.checkBlockColourConstant_( - 'TEXTS_HUE', ['Blocks', 'texts', 'HUE'], undefined); - Blockly.checkBlockColourConstant_( - 'TEXTS_HUE', ['Constants', 'Text', 'HUE'], 160); - Blockly.checkBlockColourConstant_( - 'LISTS_HUE', ['Blocks', 'lists', 'HUE'], undefined); - Blockly.checkBlockColourConstant_( - 'LISTS_HUE', ['Constants', 'Lists', 'HUE'], 260); - Blockly.checkBlockColourConstant_( - 'COLOUR_HUE', ['Blocks', 'colour', 'HUE'], undefined); - Blockly.checkBlockColourConstant_( - 'COLOUR_HUE', ['Constants', 'Colour', 'HUE'], 20); - Blockly.checkBlockColourConstant_( - 'VARIABLES_HUE', ['Blocks', 'variables', 'HUE'], undefined); - Blockly.checkBlockColourConstant_( - 'VARIABLES_HUE', ['Constants', 'Variables', 'HUE'], 330); - // Blockly.Blocks.variables_dynamic.HUE never existed. - Blockly.checkBlockColourConstant_( - 'VARIABLES_DYNAMIC_HUE', ['Constants', 'VariablesDynamic', 'HUE'], 310); - Blockly.checkBlockColourConstant_( - 'PROCEDURES_HUE', ['Blocks', 'procedures', 'HUE'], undefined); - // Blockly.Constants.Procedures.HUE never existed. -}; - -/** - * Checks for a constant in the Blockly namespace, verifying it is undefined or - * has the old/original value. Prints a warning if this is not true. - * @param {string} msgName The Msg constant identifier. - * @param {!Array} blocklyNamePath The name parts of the tested - * constant. - * @param {number|undefined} expectedValue The expected value of the constant. - * @private - */ -Blockly.checkBlockColourConstant_ = function( - msgName, blocklyNamePath, expectedValue) { - var namePath = 'Blockly'; - var value = Blockly; - for (var i = 0; i < blocklyNamePath.length; ++i) { - namePath += '.' + blocklyNamePath[i]; - if (value) { - value = value[blocklyNamePath[i]]; - } - } - - if (value && value !== expectedValue) { - var warningPattern = (expectedValue === undefined) ? - '%1 has been removed. Use Blockly.Msg["%2"].' : - '%1 is deprecated and unused. Override Blockly.Msg["%2"].'; - var warning = warningPattern.replace('%1', namePath).replace('%2', msgName); - console.warn(warning); - } -}; - /** * Set the parent container. This is the container element that the WidgetDiv, * DropDownDiv, and Tooltip are rendered into the first time `Blockly.inject` diff --git a/core/inject.js b/core/inject.js index 6bb3e6077..3b3715b0f 100644 --- a/core/inject.js +++ b/core/inject.js @@ -45,8 +45,6 @@ goog.requireType('Blockly.BlockSvg'); * @return {!Blockly.WorkspaceSvg} Newly created main workspace. */ Blockly.inject = function(container, opt_options) { - Blockly.checkBlockColourConstants(); - if (typeof container == 'string') { container = document.getElementById(container) || document.querySelector(container);