diff --git a/core/blockly.js b/core/blockly.js index 48fc78e21dc..af38821f11f 100644 --- a/core/blockly.js +++ b/core/blockly.js @@ -545,12 +545,12 @@ exports.DRAG_STICKY = internalConstants.DRAG_STICKY; exports.DRAG_BEGIN = internalConstants.DRAG_BEGIN; exports.DRAG_FREE = internalConstants.DRAG_FREE; exports.OPPOSITE_TYPE = internalConstants.OPPOSITE_TYPE; -exports.VARIABLE_CATEGORY_NAME = internalConstants.VARIABLE_CATEGORY_NAME; exports.VARIABLE_DYNAMIC_CATEGORY_NAME = internalConstants.VARIABLE_DYNAMIC_CATEGORY_NAME; -exports.PROCEDURE_CATEGORY_NAME = internalConstants.PROCEDURE_CATEGORY_NAME; exports.RENAME_VARIABLE_ID = internalConstants.RENAME_VARIABLE_ID; exports.DELETE_VARIABLE_ID = internalConstants.DELETE_VARIABLE_ID; +exports.VARIABLE_CATEGORY_NAME = constants.VARIABLE_CATEGORY_NAME; +exports.PROCEDURE_CATEGORY_NAME = constants.PROCEDURE_CATEGORY_NAME; exports.COLLAPSED_INPUT_NAME = constants.COLLAPSED_INPUT_NAME; exports.COLLAPSED_FIELD_NAME = constants.COLLAPSED_FIELD_NAME; diff --git a/core/constants.js b/core/constants.js index 4077596e163..7598f07cd19 100644 --- a/core/constants.js +++ b/core/constants.js @@ -43,3 +43,23 @@ exports.COLLAPSED_INPUT_NAME = COLLAPSED_INPUT_NAME; */ const COLLAPSED_FIELD_NAME = '_TEMP_COLLAPSED_FIELD'; exports.COLLAPSED_FIELD_NAME = COLLAPSED_FIELD_NAME; + +/** + * String for use in the "custom" attribute of a category in toolbox XML. + * This string indicates that the category should be dynamically populated with + * variable blocks. + * @const {string} + * @alias Blockly.constants.VARIABLE_CATEGORY_NAME + */ +const VARIABLE_CATEGORY_NAME = 'VARIABLE'; +exports.VARIABLE_CATEGORY_NAME = VARIABLE_CATEGORY_NAME; + +/** + * String for use in the "custom" attribute of a category in toolbox XML. + * This string indicates that the category should be dynamically populated with + * procedure blocks. + * @const {string} + * @alias Blockly.constants.PROCEDURE_CATEGORY_NAME + */ +const PROCEDURE_CATEGORY_NAME = 'PROCEDURE'; +exports.PROCEDURE_CATEGORY_NAME = PROCEDURE_CATEGORY_NAME; diff --git a/core/generator.js b/core/generator.js index 3c163b5be1c..92014095454 100644 --- a/core/generator.js +++ b/core/generator.js @@ -18,8 +18,8 @@ goog.module('Blockly.Generator'); const common = goog.require('Blockly.common'); +const constants = goog.require('Blockly.constants'); const deprecation = goog.require('Blockly.utils.deprecation'); -const internalConstants = goog.require('Blockly.internalConstants'); /* eslint-disable-next-line no-unused-vars */ const {Block} = goog.requireType('Blockly.Block'); /* eslint-disable-next-line no-unused-vars */ @@ -468,7 +468,7 @@ Object.defineProperties(Generator.prototype, { Generator.prototype.provideFunction_ = function(desiredName, code) { if (!this.definitions_[desiredName]) { const functionName = this.nameDB_.getDistinctName( - desiredName, internalConstants.PROCEDURE_CATEGORY_NAME); + desiredName, constants.PROCEDURE_CATEGORY_NAME); this.functionNames_[desiredName] = functionName; let codeText = code.join('\n').replace( this.FUNCTION_NAME_PLACEHOLDER_REGEXP_, functionName); diff --git a/core/internal_constants.js b/core/internal_constants.js index 2b4725f3fb4..1341a08ad06 100644 --- a/core/internal_constants.js +++ b/core/internal_constants.js @@ -196,16 +196,6 @@ OPPOSITE_TYPE[ConnectionType.PREVIOUS_STATEMENT] = exports.OPPOSITE_TYPE = OPPOSITE_TYPE; -/** - * String for use in the "custom" attribute of a category in toolbox XML. - * This string indicates that the category should be dynamically populated with - * variable blocks. - * @const {string} - * @alias Blockly.internalConstants.VARIABLE_CATEGORY_NAME - */ -const VARIABLE_CATEGORY_NAME = 'VARIABLE'; -exports.VARIABLE_CATEGORY_NAME = VARIABLE_CATEGORY_NAME; - /** * String for use in the "custom" attribute of a category in toolbox XML. * This string indicates that the category should be dynamically populated with @@ -216,16 +206,6 @@ exports.VARIABLE_CATEGORY_NAME = VARIABLE_CATEGORY_NAME; const VARIABLE_DYNAMIC_CATEGORY_NAME = 'VARIABLE_DYNAMIC'; exports.VARIABLE_DYNAMIC_CATEGORY_NAME = VARIABLE_DYNAMIC_CATEGORY_NAME; -/** - * String for use in the "custom" attribute of a category in toolbox XML. - * This string indicates that the category should be dynamically populated with - * procedure blocks. - * @const {string} - * @alias Blockly.internalConstants.PROCEDURE_CATEGORY_NAME - */ -const PROCEDURE_CATEGORY_NAME = 'PROCEDURE'; -exports.PROCEDURE_CATEGORY_NAME = PROCEDURE_CATEGORY_NAME; - /** * String for use in the dropdown created in field_variable. * This string indicates that this option in the dropdown is 'Rename diff --git a/core/names.js b/core/names.js index 9ac8c151329..e562afdd345 100644 --- a/core/names.js +++ b/core/names.js @@ -17,7 +17,7 @@ goog.module('Blockly.Names'); const Msg = goog.require('Blockly.Msg'); const Variables = goog.require('Blockly.Variables'); -const internalConstants = goog.require('Blockly.internalConstants'); +const constants = goog.require('Blockly.constants'); /* eslint-disable-next-line no-unused-vars */ const {VariableMap} = goog.requireType('Blockly.VariableMap'); /* eslint-disable-next-line no-unused-vars */ @@ -85,7 +85,7 @@ Names.prototype.setVariableMap = function(map) { /** * Get the name for a user-defined variable, based on its ID. * This should only be used for variables of realm - * internalConstants.VARIABLE_CATEGORY_NAME. + * constants.VARIABLE_CATEGORY_NAME. * @param {string} id The ID to look up in the variable map. * @return {?string} The name of the referenced variable, or null if there was * no variable map or the variable was not found in the map. @@ -115,8 +115,7 @@ Names.prototype.getNameForUserVariable_ = function(id) { Names.prototype.populateVariables = function(workspace) { const variables = Variables.allUsedVarModels(workspace); for (let i = 0; i < variables.length; i++) { - this.getName( - variables[i].getId(), internalConstants.VARIABLE_CATEGORY_NAME); + this.getName(variables[i].getId(), constants.VARIABLE_CATEGORY_NAME); } }; @@ -130,7 +129,7 @@ Names.prototype.populateProcedures = function(workspace) { // Flatten the return vs no-return procedure lists. procedures = procedures[0].concat(procedures[1]); for (let i = 0; i < procedures.length; i++) { - this.getName(procedures[i][0], internalConstants.PROCEDURE_CATEGORY_NAME); + this.getName(procedures[i][0], constants.PROCEDURE_CATEGORY_NAME); } }; @@ -144,7 +143,7 @@ Names.prototype.populateProcedures = function(workspace) { */ Names.prototype.getName = function(nameOrId, realm) { let name = nameOrId; - if (realm === internalConstants.VARIABLE_CATEGORY_NAME) { + if (realm === constants.VARIABLE_CATEGORY_NAME) { const varName = this.getNameForUserVariable_(nameOrId); if (varName) { // Successful ID lookup. @@ -153,7 +152,7 @@ Names.prototype.getName = function(nameOrId, realm) { } const normalizedName = name.toLowerCase(); - const isVar = realm === internalConstants.VARIABLE_CATEGORY_NAME || + const isVar = realm === constants.VARIABLE_CATEGORY_NAME || realm === Names.DEVELOPER_VARIABLE_TYPE; const prefix = isVar ? this.variablePrefix_ : ''; @@ -200,7 +199,7 @@ Names.prototype.getDistinctName = function(name, realm) { } safeName += i; this.dbReverse_[safeName] = true; - const isVar = realm === internalConstants.VARIABLE_CATEGORY_NAME || + const isVar = realm === constants.VARIABLE_CATEGORY_NAME || realm === Names.DEVELOPER_VARIABLE_TYPE; const prefix = isVar ? this.variablePrefix_ : ''; return prefix + safeName; diff --git a/core/workspace_svg.js b/core/workspace_svg.js index 229798771f3..028631b107d 100644 --- a/core/workspace_svg.js +++ b/core/workspace_svg.js @@ -30,6 +30,7 @@ const blockRendering = goog.require('Blockly.blockRendering'); const blocks = goog.require('Blockly.serialization.blocks'); const browserEvents = goog.require('Blockly.browserEvents'); const common = goog.require('Blockly.common'); +const constants = goog.require('Blockly.constants'); const dom = goog.require('Blockly.utils.dom'); const eventUtils = goog.require('Blockly.Events.utils'); const internalConstants = goog.require('Blockly.internalConstants'); @@ -226,7 +227,7 @@ const WorkspaceSvg = function( const Variables = goog.module.get('Blockly.Variables'); if (Variables && Variables.flyoutCategory) { this.registerToolboxCategoryCallback( - internalConstants.VARIABLE_CATEGORY_NAME, Variables.flyoutCategory); + constants.VARIABLE_CATEGORY_NAME, Variables.flyoutCategory); } const VariablesDynamic = goog.module.get('Blockly.VariablesDynamic'); @@ -239,7 +240,7 @@ const WorkspaceSvg = function( const Procedures = goog.module.get('Blockly.Procedures'); if (Procedures && Procedures.flyoutCategory) { this.registerToolboxCategoryCallback( - internalConstants.PROCEDURE_CATEGORY_NAME, Procedures.flyoutCategory); + constants.PROCEDURE_CATEGORY_NAME, Procedures.flyoutCategory); this.addChangeListener(Procedures.mutatorOpenListener); } diff --git a/tests/deps.js b/tests/deps.js index d2ba83cdcd4..e43d7a2aa8c 100644 --- a/tests/deps.js +++ b/tests/deps.js @@ -85,7 +85,7 @@ goog.addDependency('../../core/flyout_button.js', ['Blockly.FlyoutButton'], ['Bl goog.addDependency('../../core/flyout_horizontal.js', ['Blockly.HorizontalFlyout'], ['Blockly.DropDownDiv', 'Blockly.Flyout', 'Blockly.Scrollbar', 'Blockly.WidgetDiv', 'Blockly.browserEvents', 'Blockly.registry', 'Blockly.utils.Rect', 'Blockly.utils.object', 'Blockly.utils.toolbox'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/flyout_metrics_manager.js', ['Blockly.FlyoutMetricsManager'], ['Blockly.MetricsManager', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/flyout_vertical.js', ['Blockly.VerticalFlyout'], ['Blockly.Block', 'Blockly.DropDownDiv', 'Blockly.Flyout', 'Blockly.Scrollbar', 'Blockly.WidgetDiv', 'Blockly.browserEvents', 'Blockly.constants', 'Blockly.registry', 'Blockly.utils.Rect', 'Blockly.utils.object', 'Blockly.utils.toolbox'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../core/generator.js', ['Blockly.Generator'], ['Blockly.common', 'Blockly.internalConstants', 'Blockly.utils.deprecation'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../core/generator.js', ['Blockly.Generator'], ['Blockly.common', 'Blockly.constants', 'Blockly.utils.deprecation'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/gesture.js', ['Blockly.Gesture'], ['Blockly.BlockDragger', 'Blockly.BubbleDragger', 'Blockly.Events.Click', 'Blockly.Events.utils', 'Blockly.Tooltip', 'Blockly.Touch', 'Blockly.Workspace', 'Blockly.WorkspaceDragger', 'Blockly.blockAnimations', 'Blockly.browserEvents', 'Blockly.common', 'Blockly.internalConstants', 'Blockly.registry', 'Blockly.utils.Coordinate'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/grid.js', ['Blockly.Grid'], ['Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.userAgent'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/icon.js', ['Blockly.Icon'], ['Blockly.browserEvents', 'Blockly.utils.Coordinate', 'Blockly.utils.Size', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.svgMath'], {'lang': 'es6', 'module': 'goog'}); @@ -135,7 +135,7 @@ goog.addDependency('../../core/menuitem.js', ['Blockly.MenuItem'], ['Blockly.uti goog.addDependency('../../core/metrics_manager.js', ['Blockly.MetricsManager'], ['Blockly.IMetricsManager', 'Blockly.registry', 'Blockly.utils.Size', 'Blockly.utils.toolbox'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/msg.js', ['Blockly.Msg'], ['Blockly.utils.global'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/mutator.js', ['Blockly.Mutator'], ['Blockly.Bubble', 'Blockly.Events.BlockChange', 'Blockly.Events.BubbleOpen', 'Blockly.Events.utils', 'Blockly.Icon', 'Blockly.Options', 'Blockly.WorkspaceSvg', 'Blockly.internalConstants', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.toolbox', 'Blockly.utils.xml'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../core/names.js', ['Blockly.Names'], ['Blockly.Msg', 'Blockly.Variables', 'Blockly.internalConstants'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../core/names.js', ['Blockly.Names'], ['Blockly.Msg', 'Blockly.Variables', 'Blockly.constants'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/options.js', ['Blockly.Options'], ['Blockly.Theme', 'Blockly.Themes.Classic', 'Blockly.registry', 'Blockly.utils.idGenerator', 'Blockly.utils.toolbox'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/positionable_helpers.js', ['Blockly.uiPosition'], ['Blockly.Scrollbar', 'Blockly.utils.Rect', 'Blockly.utils.toolbox'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/procedures.js', ['Blockly.Procedures'], ['Blockly.Events.BlockChange', 'Blockly.Events.utils', 'Blockly.Msg', 'Blockly.Names', 'Blockly.Variables', 'Blockly.Workspace', 'Blockly.Xml', 'Blockly.blocks', 'Blockly.utils.xml'], {'lang': 'es6', 'module': 'goog'}); @@ -263,7 +263,7 @@ goog.addDependency('../../core/workspace_comment.js', ['Blockly.WorkspaceComment goog.addDependency('../../core/workspace_comment_svg.js', ['Blockly.WorkspaceCommentSvg'], ['Blockly.ContextMenu', 'Blockly.Css', 'Blockly.Events.CommentCreate', 'Blockly.Events.CommentDelete', 'Blockly.Events.CommentMove', 'Blockly.Events.Selected', 'Blockly.Events.utils', 'Blockly.IBoundedElement', 'Blockly.IBubble', 'Blockly.ICopyable', 'Blockly.Touch', 'Blockly.WorkspaceComment', 'Blockly.browserEvents', 'Blockly.common', 'Blockly.utils.Coordinate', 'Blockly.utils.Rect', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.svgMath'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/workspace_drag_surface_svg.js', ['Blockly.WorkspaceDragSurfaceSvg'], ['Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.svgMath'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/workspace_dragger.js', ['Blockly.WorkspaceDragger'], ['Blockly.common', 'Blockly.utils.Coordinate'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../core/workspace_svg.js', ['Blockly.WorkspaceSvg'], ['Blockly.BlockSvg', 'Blockly.ComponentManager', 'Blockly.ConnectionDB', 'Blockly.ContextMenu', 'Blockly.ContextMenuRegistry', 'Blockly.DropDownDiv', 'Blockly.Events.BlockCreate', 'Blockly.Events.ThemeChange', 'Blockly.Events.ViewportChange', 'Blockly.Events.utils', 'Blockly.Gesture', 'Blockly.Grid', 'Blockly.IASTNodeLocationSvg', 'Blockly.MarkerManager', 'Blockly.MetricsManager', 'Blockly.Msg', 'Blockly.Options', 'Blockly.ThemeManager', 'Blockly.Themes.Classic', 'Blockly.Tooltip', 'Blockly.TouchGesture', 'Blockly.WidgetDiv', 'Blockly.Workspace', 'Blockly.WorkspaceAudio', 'Blockly.Xml', 'Blockly.blockRendering', 'Blockly.browserEvents', 'Blockly.common', 'Blockly.internalConstants', 'Blockly.registry', 'Blockly.serialization.blocks', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Rect', 'Blockly.utils.Size', 'Blockly.utils.Svg', 'Blockly.utils.array', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.svgMath', 'Blockly.utils.toolbox', 'Blockly.utils.userAgent'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../core/workspace_svg.js', ['Blockly.WorkspaceSvg'], ['Blockly.BlockSvg', 'Blockly.ComponentManager', 'Blockly.ConnectionDB', 'Blockly.ContextMenu', 'Blockly.ContextMenuRegistry', 'Blockly.DropDownDiv', 'Blockly.Events.BlockCreate', 'Blockly.Events.ThemeChange', 'Blockly.Events.ViewportChange', 'Blockly.Events.utils', 'Blockly.Gesture', 'Blockly.Grid', 'Blockly.IASTNodeLocationSvg', 'Blockly.MarkerManager', 'Blockly.MetricsManager', 'Blockly.Msg', 'Blockly.Options', 'Blockly.ThemeManager', 'Blockly.Themes.Classic', 'Blockly.Tooltip', 'Blockly.TouchGesture', 'Blockly.WidgetDiv', 'Blockly.Workspace', 'Blockly.WorkspaceAudio', 'Blockly.Xml', 'Blockly.blockRendering', 'Blockly.browserEvents', 'Blockly.common', 'Blockly.constants', 'Blockly.internalConstants', 'Blockly.registry', 'Blockly.serialization.blocks', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Rect', 'Blockly.utils.Size', 'Blockly.utils.Svg', 'Blockly.utils.array', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.svgMath', 'Blockly.utils.toolbox', 'Blockly.utils.userAgent'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/xml.js', ['Blockly.Xml'], ['Blockly.Events.utils', 'Blockly.inputTypes', 'Blockly.utils.Size', 'Blockly.utils.dom', 'Blockly.utils.xml'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/zoom_controls.js', ['Blockly.ZoomControls'], ['Blockly.ComponentManager', 'Blockly.Css', 'Blockly.Events.Click', 'Blockly.Events.utils', 'Blockly.IPositionable', 'Blockly.Touch', 'Blockly.browserEvents', 'Blockly.internalConstants', 'Blockly.uiPosition', 'Blockly.utils.Rect', 'Blockly.utils.Size', 'Blockly.utils.Svg', 'Blockly.utils.dom'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../generators/dart.js', ['Blockly.Dart'], ['Blockly.Generator', 'Blockly.inputTypes', 'Blockly.utils.string'], {'lang': 'es6'});