Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/blockly.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
20 changes: 20 additions & 0 deletions core/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
4 changes: 2 additions & 2 deletions core/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down
20 changes: 0 additions & 20 deletions core/internal_constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
15 changes: 7 additions & 8 deletions core/names.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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);
}
};

Expand All @@ -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);
}
};

Expand All @@ -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.
Expand All @@ -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_ : '';
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions core/workspace_svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand All @@ -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);
}

Expand Down
6 changes: 3 additions & 3 deletions tests/deps.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.