diff --git a/blocks/lists.js b/blocks/lists.js index 33043da8662..5aa43b269ef 100644 --- a/blocks/lists.js +++ b/blocks/lists.js @@ -18,7 +18,6 @@ goog.provide('Blockly.Constants.Lists'); goog.require('Blockly'); -goog.require('Blockly.blocks'); goog.require('Blockly.FieldDropdown'); goog.require('Blockly.FieldLabel'); goog.require('Blockly.Mutator'); @@ -115,7 +114,7 @@ Blockly.defineBlocksWithJsonArray([ // BEGIN JSON EXTRACT } ]); // END JSON EXTRACT (Do not delete this comment.) -Blockly.blocks['lists_create_with'] = { +Blockly.Blocks['lists_create_with'] = { /** * Block for creating a list with any number of elements of any type. * @this {Blockly.Block} @@ -259,7 +258,7 @@ Blockly.blocks['lists_create_with'] = { } }; -Blockly.blocks['lists_create_with_container'] = { +Blockly.Blocks['lists_create_with_container'] = { /** * Mutator block for list container. * @this {Blockly.Block} @@ -274,7 +273,7 @@ Blockly.blocks['lists_create_with_container'] = { } }; -Blockly.blocks['lists_create_with_item'] = { +Blockly.Blocks['lists_create_with_item'] = { /** * Mutator block for adding items. * @this {Blockly.Block} @@ -290,7 +289,7 @@ Blockly.blocks['lists_create_with_item'] = { } }; -Blockly.blocks['lists_indexOf'] = { +Blockly.Blocks['lists_indexOf'] = { /** * Block for finding an item in the list. * @this {Blockly.Block} @@ -319,7 +318,7 @@ Blockly.blocks['lists_indexOf'] = { } }; -Blockly.blocks['lists_getIndex'] = { +Blockly.Blocks['lists_getIndex'] = { /** * Block for getting element at index. * @this {Blockly.Block} @@ -510,7 +509,7 @@ Blockly.blocks['lists_getIndex'] = { } }; -Blockly.blocks['lists_setIndex'] = { +Blockly.Blocks['lists_setIndex'] = { /** * Block for setting the element at index. * @this {Blockly.Block} @@ -656,7 +655,7 @@ Blockly.blocks['lists_setIndex'] = { } }; -Blockly.blocks['lists_getSublist'] = { +Blockly.Blocks['lists_getSublist'] = { /** * Block for getting sublist. * @this {Blockly.Block} @@ -772,7 +771,7 @@ Blockly.blocks['lists_getSublist'] = { } }; -Blockly.blocks['lists_sort'] = { +Blockly.Blocks['lists_sort'] = { /** * Block for sorting a list. * @this {Blockly.Block} @@ -812,7 +811,7 @@ Blockly.blocks['lists_sort'] = { } }; -Blockly.blocks['lists_split'] = { +Blockly.Blocks['lists_split'] = { /** * Block for splitting text into a list, or joining a list into text. * @this {Blockly.Block} diff --git a/blocks/procedures.js b/blocks/procedures.js index 0900c6ba5bc..0ff23f78035 100644 --- a/blocks/procedures.js +++ b/blocks/procedures.js @@ -13,7 +13,6 @@ goog.provide('Blockly.blocks.procedures'); goog.require('Blockly'); -goog.require('Blockly.blocks'); goog.require('Blockly.Comment'); goog.require('Blockly.FieldCheckbox'); goog.require('Blockly.FieldLabel'); @@ -22,7 +21,7 @@ goog.require('Blockly.Mutator'); goog.require('Blockly.Warning'); -Blockly.blocks['procedures_defnoreturn'] = { +Blockly.Blocks['procedures_defnoreturn'] = { /** * Block for defining a procedure with no return value. * @this {Blockly.Block} @@ -450,7 +449,7 @@ Blockly.blocks['procedures_defnoreturn'] = { callType_: 'procedures_callnoreturn' }; -Blockly.blocks['procedures_defreturn'] = { +Blockly.Blocks['procedures_defreturn'] = { /** * Block for defining a procedure with a return value. * @this {Blockly.Block} @@ -482,12 +481,14 @@ Blockly.blocks['procedures_defreturn'] = { this.setStatements_(true); this.statementConnection_ = null; }, - setStatements_: Blockly.blocks['procedures_defnoreturn'].setStatements_, - updateParams_: Blockly.blocks['procedures_defnoreturn'].updateParams_, - mutationToDom: Blockly.blocks['procedures_defnoreturn'].mutationToDom, - domToMutation: Blockly.blocks['procedures_defnoreturn'].domToMutation, - decompose: Blockly.blocks['procedures_defnoreturn'].decompose, - compose: Blockly.blocks['procedures_defnoreturn'].compose, + setStatements_: Blockly.Blocks['procedures_defnoreturn'].setStatements_, + updateParams_: Blockly.Blocks['procedures_defnoreturn'].updateParams_, + mutationToDom: Blockly.Blocks['procedures_defnoreturn'].mutationToDom, + domToMutation: Blockly.Blocks['procedures_defnoreturn'].domToMutation, + saveExtraState: Blockly.Blocks['procedures_defnoreturn'].saveExtraState, + loadExtraState: Blockly.Blocks['procedures_defnoreturn'].loadExtraState, + decompose: Blockly.Blocks['procedures_defnoreturn'].decompose, + compose: Blockly.Blocks['procedures_defnoreturn'].compose, /** * Return the signature of this procedure definition. * @return {!Array} Tuple containing three elements: @@ -499,16 +500,16 @@ Blockly.blocks['procedures_defreturn'] = { getProcedureDef: function() { return [this.getFieldValue('NAME'), this.arguments_, true]; }, - getVars: Blockly.blocks['procedures_defnoreturn'].getVars, - getVarModels: Blockly.blocks['procedures_defnoreturn'].getVarModels, - renameVarById: Blockly.blocks['procedures_defnoreturn'].renameVarById, - updateVarName: Blockly.blocks['procedures_defnoreturn'].updateVarName, - displayRenamedVar_: Blockly.blocks['procedures_defnoreturn'].displayRenamedVar_, - customContextMenu: Blockly.blocks['procedures_defnoreturn'].customContextMenu, + getVars: Blockly.Blocks['procedures_defnoreturn'].getVars, + getVarModels: Blockly.Blocks['procedures_defnoreturn'].getVarModels, + renameVarById: Blockly.Blocks['procedures_defnoreturn'].renameVarById, + updateVarName: Blockly.Blocks['procedures_defnoreturn'].updateVarName, + displayRenamedVar_: Blockly.Blocks['procedures_defnoreturn'].displayRenamedVar_, + customContextMenu: Blockly.Blocks['procedures_defnoreturn'].customContextMenu, callType_: 'procedures_callreturn' }; -Blockly.blocks['procedures_mutatorcontainer'] = { +Blockly.Blocks['procedures_mutatorcontainer'] = { /** * Mutator block for procedure container. * @this {Blockly.Block} @@ -526,7 +527,7 @@ Blockly.blocks['procedures_mutatorcontainer'] = { }, }; -Blockly.blocks['procedures_mutatorarg'] = { +Blockly.Blocks['procedures_mutatorarg'] = { /** * Mutator block for procedure argument. * @this {Blockly.Block} @@ -637,7 +638,7 @@ Blockly.blocks['procedures_mutatorarg'] = { } }; -Blockly.blocks['procedures_callnoreturn'] = { +Blockly.Blocks['procedures_callnoreturn'] = { /** * Block for calling a procedure with no return value. * @this {Blockly.Block} @@ -1029,7 +1030,7 @@ Blockly.blocks['procedures_callnoreturn'] = { defType_: 'procedures_defnoreturn' }; -Blockly.blocks['procedures_callreturn'] = { +Blockly.Blocks['procedures_callreturn'] = { /** * Block for calling a procedure with a return value. * @this {Blockly.Block} @@ -1048,24 +1049,24 @@ Blockly.blocks['procedures_callreturn'] = { this.previousEnabledState_ = true; }, - getProcedureCall: Blockly.blocks['procedures_callnoreturn'].getProcedureCall, - renameProcedure: Blockly.blocks['procedures_callnoreturn'].renameProcedure, + getProcedureCall: Blockly.Blocks['procedures_callnoreturn'].getProcedureCall, + renameProcedure: Blockly.Blocks['procedures_callnoreturn'].renameProcedure, setProcedureParameters_: - Blockly.blocks['procedures_callnoreturn'].setProcedureParameters_, - updateShape_: Blockly.blocks['procedures_callnoreturn'].updateShape_, - mutationToDom: Blockly.blocks['procedures_callnoreturn'].mutationToDom, - domToMutation: Blockly.blocks['procedures_callnoreturn'].domToMutation, - saveExtraState: Blockly.blocks['procedures_callnoreturn'].saveExtraState, - loadExtraState: Blockly.blocks['procedures_callnoreturn'].loadExtraState, - getVars: Blockly.blocks['procedures_callnoreturn'].getVars, - getVarModels: Blockly.blocks['procedures_callnoreturn'].getVarModels, - onchange: Blockly.blocks['procedures_callnoreturn'].onchange, + Blockly.Blocks['procedures_callnoreturn'].setProcedureParameters_, + updateShape_: Blockly.Blocks['procedures_callnoreturn'].updateShape_, + mutationToDom: Blockly.Blocks['procedures_callnoreturn'].mutationToDom, + domToMutation: Blockly.Blocks['procedures_callnoreturn'].domToMutation, + saveExtraState: Blockly.Blocks['procedures_callnoreturn'].saveExtraState, + loadExtraState: Blockly.Blocks['procedures_callnoreturn'].loadExtraState, + getVars: Blockly.Blocks['procedures_callnoreturn'].getVars, + getVarModels: Blockly.Blocks['procedures_callnoreturn'].getVarModels, + onchange: Blockly.Blocks['procedures_callnoreturn'].onchange, customContextMenu: - Blockly.blocks['procedures_callnoreturn'].customContextMenu, + Blockly.Blocks['procedures_callnoreturn'].customContextMenu, defType_: 'procedures_defreturn' }; -Blockly.blocks['procedures_ifreturn'] = { +Blockly.Blocks['procedures_ifreturn'] = { /** * Block for conditionally returning a value from a procedure. * @this {Blockly.Block} @@ -1162,7 +1163,7 @@ Blockly.blocks['procedures_ifreturn'] = { /** * List of block types that are functions and thus do not need warnings. * To add a new function type add this to your code: - * Blockly.blocks['procedures_ifreturn'].FUNCTION_TYPES.push('custom_func'); + * Blockly.Blocks['procedures_ifreturn'].FUNCTION_TYPES.push('custom_func'); */ FUNCTION_TYPES: ['procedures_defnoreturn', 'procedures_defreturn'] }; diff --git a/blocks/text.js b/blocks/text.js index 23af2cc3a18..6cb48095b7b 100644 --- a/blocks/text.js +++ b/blocks/text.js @@ -14,7 +14,6 @@ goog.provide('Blockly.blocks.texts'); // Deprecated goog.provide('Blockly.Constants.Text'); goog.require('Blockly'); -goog.require('Blockly.blocks'); goog.require('Blockly.FieldDropdown'); goog.require('Blockly.FieldImage'); goog.require('Blockly.FieldMultilineInput'); @@ -226,7 +225,7 @@ Blockly.defineBlocksWithJsonArray([ // BEGIN JSON EXTRACT } ]); // END JSON EXTRACT (Do not delete this comment.) -Blockly.blocks['text_getSubstring'] = { +Blockly.Blocks['text_getSubstring'] = { /** * Block for getting substring. * @this {Blockly.Block} @@ -347,7 +346,7 @@ Blockly.blocks['text_getSubstring'] = { } }; -Blockly.blocks['text_changeCase'] = { +Blockly.Blocks['text_changeCase'] = { /** * Block for changing capitalization. * @this {Blockly.Block} @@ -368,7 +367,7 @@ Blockly.blocks['text_changeCase'] = { } }; -Blockly.blocks['text_trim'] = { +Blockly.Blocks['text_trim'] = { /** * Block for trimming spaces. * @this {Blockly.Block} @@ -389,7 +388,7 @@ Blockly.blocks['text_trim'] = { } }; -Blockly.blocks['text_print'] = { +Blockly.Blocks['text_print'] = { /** * Block for print statement. * @this {Blockly.Block} @@ -412,7 +411,7 @@ Blockly.blocks['text_print'] = { } }; -Blockly.blocks['text_prompt_ext'] = { +Blockly.Blocks['text_prompt_ext'] = { /** * Block for prompt function (external message). * @this {Blockly.Block} @@ -474,7 +473,7 @@ Blockly.blocks['text_prompt_ext'] = { // XML hooks are kept for backwards compatibility. }; -Blockly.blocks['text_prompt'] = { +Blockly.Blocks['text_prompt'] = { /** * Block for prompt function (internal message). * The 'text_prompt_ext' block is preferred as it is more flexible. @@ -506,12 +505,12 @@ Blockly.blocks['text_prompt'] = { Blockly.Msg['TEXT_PROMPT_TOOLTIP_NUMBER']; }); }, - updateType_: Blockly.blocks['text_prompt_ext'].updateType_, - mutationToDom: Blockly.blocks['text_prompt_ext'].mutationToDom, - domToMutation: Blockly.blocks['text_prompt_ext'].domToMutation + updateType_: Blockly.Blocks['text_prompt_ext'].updateType_, + mutationToDom: Blockly.Blocks['text_prompt_ext'].mutationToDom, + domToMutation: Blockly.Blocks['text_prompt_ext'].domToMutation }; -Blockly.blocks['text_count'] = { +Blockly.Blocks['text_count'] = { /** * Block for counting how many times one string appears within another string. * @this {Blockly.Block} @@ -540,7 +539,7 @@ Blockly.blocks['text_count'] = { } }; -Blockly.blocks['text_replace'] = { +Blockly.Blocks['text_replace'] = { /** * Block for replacing one string with another in the text. * @this {Blockly.Block} @@ -574,7 +573,7 @@ Blockly.blocks['text_replace'] = { } }; -Blockly.blocks['text_reverse'] = { +Blockly.Blocks['text_reverse'] = { /** * Block for reversing a string. * @this {Blockly.Block} diff --git a/core/block.js b/core/block.js index 4389adf9c4d..401d57495a1 100644 --- a/core/block.js +++ b/core/block.js @@ -15,6 +15,7 @@ goog.module('Blockly.Block'); /* eslint-disable-next-line no-unused-vars */ const Abstract = goog.requireType('Blockly.Events.Abstract'); const ASTNode = goog.require('Blockly.ASTNode'); +const {Blocks} = goog.require('Blockly.blocks'); /* eslint-disable-next-line no-unused-vars */ const Comment = goog.requireType('Blockly.Comment'); const Connection = goog.require('Blockly.Connection'); @@ -36,7 +37,6 @@ const Tooltip = goog.require('Blockly.Tooltip'); const VariableModel = goog.requireType('Blockly.VariableModel'); /* eslint-disable-next-line no-unused-vars */ const Workspace = goog.requireType('Blockly.Workspace'); -const blocks = goog.require('Blockly.blocks'); const common = goog.require('Blockly.common'); const connectionTypes = goog.require('Blockly.connectionTypes'); const constants = goog.require('Blockly.constants'); @@ -208,7 +208,7 @@ const Block = function(workspace, prototypeName, opt_id) { if (prototypeName) { /** @type {string} */ this.type = prototypeName; - const prototype = blocks.definitions[prototypeName]; + const prototype = Blocks[prototypeName]; if (!prototype || typeof prototype != 'object') { throw TypeError('Unknown block type: ' + prototypeName); } diff --git a/core/blockly.js b/core/blockly.js index 57f9874e5fc..ea3fb977059 100644 --- a/core/blockly.js +++ b/core/blockly.js @@ -21,6 +21,7 @@ const Block = goog.require('Blockly.Block'); const BlockDragger = goog.require('Blockly.BlockDragger'); const BlockDragSurfaceSvg = goog.require('Blockly.BlockDragSurfaceSvg'); const BlockSvg = goog.require('Blockly.BlockSvg'); +const {Blocks} = goog.require('Blockly.blocks'); /* eslint-disable-next-line no-unused-vars */ const ICopyable = goog.requireType('Blockly.ICopyable'); const Size = goog.require('Blockly.utils.Size'); @@ -28,7 +29,6 @@ const Size = goog.require('Blockly.utils.Size'); const Workspace = goog.requireType('Blockly.Workspace'); /* eslint-disable-next-line no-unused-vars */ const WorkspaceSvg = goog.requireType('Blockly.WorkspaceSvg'); -const blocks = goog.require('Blockly.blocks'); const browserEvents = goog.require('Blockly.browserEvents'); const clipboard = goog.require('Blockly.clipboard'); const colour = goog.require('Blockly.utils.colour'); @@ -63,9 +63,7 @@ goog.require('Blockly.Xml'); // Reexports. -exports.blocks = blocks.definitions; -/** @deprecated Use Blockly.blocks.definitions instead. */ -exports.Blocks = blocks.definitions; +exports.Blocks = Blocks; /** * Blockly core version. @@ -247,12 +245,12 @@ const defineBlocksWithJsonArray = function(jsonArray) { 'Block definition #' + i + ' in JSON array is missing a type attribute. Skipping.'); } else { - if (blocks.definitions[typename]) { + if (Blocks[typename]) { console.warn( 'Block definition #' + i + ' in JSON array' + ' overwrites prior definition of "' + typename + '".'); } - blocks.definitions[typename] = {init: jsonInitFactory(elem)}; + Blocks[typename] = {init: jsonInitFactory(elem)}; } } } diff --git a/core/blocks.js b/core/blocks.js index 61079669538..04d2cae0fbe 100644 --- a/core/blocks.js +++ b/core/blocks.js @@ -20,6 +20,6 @@ goog.module('Blockly.blocks'); * A mapping of block type names to block prototype objects. * @type {!Object} */ -const definitions = Object.create(null); +const Blocks = Object.create(null); -exports.definitions = definitions; +exports.Blocks = Blocks; diff --git a/core/procedures.js b/core/procedures.js index 598f68003d1..9518632723b 100644 --- a/core/procedures.js +++ b/core/procedures.js @@ -21,6 +21,7 @@ goog.module.declareLegacyNamespace(); const Abstract = goog.requireType('Blockly.Events.Abstract'); /* eslint-disable-next-line no-unused-vars */ const Block = goog.requireType('Blockly.Block'); +const {Blocks} = goog.require('Blockly.blocks'); const Events = goog.require('Blockly.Events'); /* eslint-disable-next-line no-unused-vars */ const Field = goog.requireType('Blockly.Field'); @@ -31,7 +32,6 @@ const Workspace = goog.require('Blockly.Workspace'); /* eslint-disable-next-line no-unused-vars */ const WorkspaceSvg = goog.requireType('Blockly.WorkspaceSvg'); const Xml = goog.require('Blockly.Xml'); -const blocks = goog.require('Blockly.blocks'); const utilsXml = goog.require('Blockly.utils.xml'); /** @suppress {extraRequire} */ goog.require('Blockly.Events.BlockChange'); @@ -193,7 +193,7 @@ exports.rename = rename; */ const flyoutCategory = function(workspace) { const xmlList = []; - if (blocks.definitions['procedures_defnoreturn']) { + if (Blocks['procedures_defnoreturn']) { // // do something // @@ -207,7 +207,7 @@ const flyoutCategory = function(workspace) { block.appendChild(nameField); xmlList.push(block); } - if (blocks.definitions['procedures_defreturn']) { + if (Blocks['procedures_defreturn']) { // // do something // @@ -221,7 +221,7 @@ const flyoutCategory = function(workspace) { block.appendChild(nameField); xmlList.push(block); } - if (blocks.definitions['procedures_ifreturn']) { + if (Blocks['procedures_ifreturn']) { // const block = utilsXml.createElement('block'); block.setAttribute('type', 'procedures_ifreturn'); diff --git a/core/variables.js b/core/variables.js index 5f4c65c5b4e..061019ed117 100644 --- a/core/variables.js +++ b/core/variables.js @@ -17,12 +17,12 @@ goog.module('Blockly.Variables'); goog.module.declareLegacyNamespace(); +const {Blocks} = goog.require('Blockly.blocks'); const Msg = goog.require('Blockly.Msg'); const VariableModel = goog.require('Blockly.VariableModel'); /* eslint-disable-next-line no-unused-vars */ const Workspace = goog.requireType('Blockly.Workspace'); const Xml = goog.require('Blockly.Xml'); -const blocks = goog.require('Blockly.blocks'); const dialog = goog.require('Blockly.dialog'); const utilsXml = goog.require('Blockly.utils.xml'); @@ -140,17 +140,17 @@ const flyoutCategoryBlocks = function(workspace) { if (variableModelList.length > 0) { // New variables are added to the end of the variableModelList. const mostRecentVariable = variableModelList[variableModelList.length - 1]; - if (blocks.definitions['variables_set']) { + if (Blocks['variables_set']) { const block = utilsXml.createElement('block'); block.setAttribute('type', 'variables_set'); - block.setAttribute('gap', blocks.definitions['math_change'] ? 8 : 24); + block.setAttribute('gap', Blocks['math_change'] ? 8 : 24); block.appendChild(generateVariableFieldDom(mostRecentVariable)); xmlList.push(block); } - if (blocks.definitions['math_change']) { + if (Blocks['math_change']) { const block = utilsXml.createElement('block'); block.setAttribute('type', 'math_change'); - block.setAttribute('gap', blocks.definitions['variables_get'] ? 20 : 8); + block.setAttribute('gap', Blocks['variables_get'] ? 20 : 8); block.appendChild(generateVariableFieldDom(mostRecentVariable)); const value = Xml.textToDom( '' + @@ -162,7 +162,7 @@ const flyoutCategoryBlocks = function(workspace) { xmlList.push(block); } - if (blocks.definitions['variables_get']) { + if (Blocks['variables_get']) { variableModelList.sort(VariableModel.compareByName); for (let i = 0, variable; (variable = variableModelList[i]); i++) { const block = utilsXml.createElement('block'); diff --git a/core/variables_dynamic.js b/core/variables_dynamic.js index a87893cda65..a433915f7e2 100644 --- a/core/variables_dynamic.js +++ b/core/variables_dynamic.js @@ -14,12 +14,12 @@ goog.module('Blockly.VariablesDynamic'); goog.module.declareLegacyNamespace(); +const {Blocks} = goog.require('Blockly.blocks'); const Msg = goog.require('Blockly.Msg'); const VariableModel = goog.require('Blockly.VariableModel'); const Variables = goog.require('Blockly.Variables'); /* eslint-disable-next-line no-unused-vars */ const Workspace = goog.requireType('Blockly.Workspace'); -const blocks = goog.require('Blockly.blocks'); const xml = goog.require('Blockly.utils.xml'); @@ -86,7 +86,7 @@ const flyoutCategoryBlocks = function(workspace) { const xmlList = []; if (variableModelList.length > 0) { - if (blocks.definitions['variables_set_dynamic']) { + if (Blocks['variables_set_dynamic']) { const firstVariable = variableModelList[variableModelList.length - 1]; const block = xml.createElement('block'); block.setAttribute('type', 'variables_set_dynamic'); @@ -94,7 +94,7 @@ const flyoutCategoryBlocks = function(workspace) { block.appendChild(Variables.generateVariableFieldDom(firstVariable)); xmlList.push(block); } - if (blocks.definitions['variables_get_dynamic']) { + if (Blocks['variables_get_dynamic']) { variableModelList.sort(VariableModel.compareByName); for (let i = 0, variable; (variable = variableModelList[i]); i++) { const block = xml.createElement('block'); diff --git a/scripts/migration/renamings.js b/scripts/migration/renamings.js index 419df33538e..ad7d28940be 100644 --- a/scripts/migration/renamings.js +++ b/scripts/migration/renamings.js @@ -153,8 +153,8 @@ const renamings = { }, 'Blockly.Blocks': { module: 'Blockly.blocks', - export: 'definitions', // Previous default export now named. - path: 'Blockly.blocks', // But still on tree with nearly the same name. + export: 'Blocks', // Previous default export now named. + path: 'Blockly.Blocks', // But still on tree with original name. }, 'Blockly.ContextMenu': { exports: { diff --git a/tests/deps.js b/tests/deps.js index b2a999367e7..1fb006b89fd 100644 --- a/tests/deps.js +++ b/tests/deps.js @@ -1,10 +1,10 @@ goog.addDependency('../../blocks/colour.js', ['Blockly.Constants.Colour', 'Blockly.blocks.colour'], ['Blockly', 'Blockly.FieldColour', 'Blockly.FieldLabel']); -goog.addDependency('../../blocks/lists.js', ['Blockly.Constants.Lists'], ['Blockly', 'Blockly.FieldDropdown', 'Blockly.FieldLabel', 'Blockly.Mutator', 'Blockly.blocks'], {'lang': 'es5'}); +goog.addDependency('../../blocks/lists.js', ['Blockly.Constants.Lists'], ['Blockly', 'Blockly.FieldDropdown', 'Blockly.FieldLabel', 'Blockly.Mutator'], {'lang': 'es5'}); goog.addDependency('../../blocks/logic.js', ['Blockly.Constants.Logic', 'Blockly.blocks.logic'], ['Blockly', 'Blockly.FieldDropdown', 'Blockly.FieldLabel', 'Blockly.Mutator']); goog.addDependency('../../blocks/loops.js', ['Blockly.Constants.Loops', 'Blockly.blocks.loops'], ['Blockly', 'Blockly.FieldDropdown', 'Blockly.FieldLabel', 'Blockly.FieldNumber', 'Blockly.FieldVariable', 'Blockly.Warning']); goog.addDependency('../../blocks/math.js', ['Blockly.Constants.Math', 'Blockly.blocks.math'], ['Blockly', 'Blockly.FieldDropdown', 'Blockly.FieldLabel', 'Blockly.FieldNumber', 'Blockly.FieldVariable'], {'lang': 'es5'}); -goog.addDependency('../../blocks/procedures.js', ['Blockly.blocks.procedures'], ['Blockly', 'Blockly.Comment', 'Blockly.FieldCheckbox', 'Blockly.FieldLabel', 'Blockly.FieldTextInput', 'Blockly.Mutator', 'Blockly.Warning', 'Blockly.blocks'], {'lang': 'es6'}); -goog.addDependency('../../blocks/text.js', ['Blockly.Constants.Text', 'Blockly.blocks.texts'], ['Blockly', 'Blockly.FieldDropdown', 'Blockly.FieldImage', 'Blockly.FieldMultilineInput', 'Blockly.FieldTextInput', 'Blockly.FieldVariable', 'Blockly.Mutator', 'Blockly.blocks'], {'lang': 'es5'}); +goog.addDependency('../../blocks/procedures.js', ['Blockly.blocks.procedures'], ['Blockly', 'Blockly.Comment', 'Blockly.FieldCheckbox', 'Blockly.FieldLabel', 'Blockly.FieldTextInput', 'Blockly.Mutator', 'Blockly.Warning'], {'lang': 'es6'}); +goog.addDependency('../../blocks/text.js', ['Blockly.Constants.Text', 'Blockly.blocks.texts'], ['Blockly', 'Blockly.FieldDropdown', 'Blockly.FieldImage', 'Blockly.FieldMultilineInput', 'Blockly.FieldTextInput', 'Blockly.FieldVariable', 'Blockly.Mutator'], {'lang': 'es5'}); goog.addDependency('../../blocks/variables.js', ['Blockly.Constants.Variables', 'Blockly.blocks.variables'], ['Blockly', 'Blockly.FieldLabel', 'Blockly.FieldVariable']); goog.addDependency('../../blocks/variables_dynamic.js', ['Blockly.Constants.VariablesDynamic'], ['Blockly', 'Blockly.FieldLabel', 'Blockly.FieldVariable']); goog.addDependency('../../core/block.js', ['Blockly.Block'], ['Blockly.ASTNode', 'Blockly.Connection', 'Blockly.Events', 'Blockly.Events.BlockChange', 'Blockly.Events.BlockCreate', 'Blockly.Events.BlockDelete', 'Blockly.Events.BlockMove', 'Blockly.Extensions', 'Blockly.Input', 'Blockly.Tooltip', 'Blockly.blocks', 'Blockly.common', 'Blockly.connectionTypes', 'Blockly.constants', 'Blockly.fieldRegistry', 'Blockly.inputTypes', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Size', 'Blockly.utils.idGenerator', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'}); diff --git a/tests/deps.mocha.js b/tests/deps.mocha.js index 30a3f2d57ba..589038539c8 100644 --- a/tests/deps.mocha.js +++ b/tests/deps.mocha.js @@ -1,10 +1,10 @@ goog.addDependency('../../blocks/colour.js', ['Blockly.Constants.Colour', 'Blockly.blocks.colour'], ['Blockly', 'Blockly.FieldColour', 'Blockly.FieldLabel']); -goog.addDependency('../../blocks/lists.js', ['Blockly.Constants.Lists'], ['Blockly', 'Blockly.FieldDropdown', 'Blockly.FieldLabel', 'Blockly.Mutator', 'Blockly.blocks'], {'lang': 'es5'}); +goog.addDependency('../../blocks/lists.js', ['Blockly.Constants.Lists'], ['Blockly', 'Blockly.FieldDropdown', 'Blockly.FieldLabel', 'Blockly.Mutator'], {'lang': 'es5'}); goog.addDependency('../../blocks/logic.js', ['Blockly.Constants.Logic', 'Blockly.blocks.logic'], ['Blockly', 'Blockly.FieldDropdown', 'Blockly.FieldLabel', 'Blockly.Mutator']); goog.addDependency('../../blocks/loops.js', ['Blockly.Constants.Loops', 'Blockly.blocks.loops'], ['Blockly', 'Blockly.FieldDropdown', 'Blockly.FieldLabel', 'Blockly.FieldNumber', 'Blockly.FieldVariable', 'Blockly.Warning']); goog.addDependency('../../blocks/math.js', ['Blockly.Constants.Math', 'Blockly.blocks.math'], ['Blockly', 'Blockly.FieldDropdown', 'Blockly.FieldLabel', 'Blockly.FieldNumber', 'Blockly.FieldVariable'], {'lang': 'es5'}); -goog.addDependency('../../blocks/procedures.js', ['Blockly.blocks.procedures'], ['Blockly', 'Blockly.Comment', 'Blockly.FieldCheckbox', 'Blockly.FieldLabel', 'Blockly.FieldTextInput', 'Blockly.Mutator', 'Blockly.Warning', 'Blockly.blocks'], {'lang': 'es6'}); -goog.addDependency('../../blocks/text.js', ['Blockly.Constants.Text', 'Blockly.blocks.texts'], ['Blockly', 'Blockly.FieldDropdown', 'Blockly.FieldImage', 'Blockly.FieldMultilineInput', 'Blockly.FieldTextInput', 'Blockly.FieldVariable', 'Blockly.Mutator', 'Blockly.blocks'], {'lang': 'es5'}); +goog.addDependency('../../blocks/procedures.js', ['Blockly.blocks.procedures'], ['Blockly', 'Blockly.Comment', 'Blockly.FieldCheckbox', 'Blockly.FieldLabel', 'Blockly.FieldTextInput', 'Blockly.Mutator', 'Blockly.Warning'], {'lang': 'es6'}); +goog.addDependency('../../blocks/text.js', ['Blockly.Constants.Text', 'Blockly.blocks.texts'], ['Blockly', 'Blockly.FieldDropdown', 'Blockly.FieldImage', 'Blockly.FieldMultilineInput', 'Blockly.FieldTextInput', 'Blockly.FieldVariable', 'Blockly.Mutator'], {'lang': 'es5'}); goog.addDependency('../../blocks/variables.js', ['Blockly.Constants.Variables', 'Blockly.blocks.variables'], ['Blockly', 'Blockly.FieldLabel', 'Blockly.FieldVariable']); goog.addDependency('../../blocks/variables_dynamic.js', ['Blockly.Constants.VariablesDynamic'], ['Blockly', 'Blockly.FieldLabel', 'Blockly.FieldVariable']); goog.addDependency('../../core/block.js', ['Blockly.Block'], ['Blockly.ASTNode', 'Blockly.Connection', 'Blockly.Events', 'Blockly.Events.BlockChange', 'Blockly.Events.BlockCreate', 'Blockly.Events.BlockDelete', 'Blockly.Events.BlockMove', 'Blockly.Extensions', 'Blockly.Input', 'Blockly.Tooltip', 'Blockly.blocks', 'Blockly.common', 'Blockly.connectionTypes', 'Blockly.constants', 'Blockly.fieldRegistry', 'Blockly.inputTypes', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Size', 'Blockly.utils.idGenerator', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'}); diff --git a/tests/mocha/block_test.js b/tests/mocha/block_test.js index addd3d60d28..7ae4aea9e80 100644 --- a/tests/mocha/block_test.js +++ b/tests/mocha/block_test.js @@ -6,7 +6,7 @@ goog.module('Blockly.test.blocks'); -const blocks = goog.require('Blockly.blocks'); +const {Blocks} = goog.require('Blockly.blocks'); const {createDeprecationWarningStub, createRenderedBlock, sharedTestSetup, sharedTestTeardown, workspaceTeardown} = goog.require('Blockly.test.helpers'); @@ -1989,7 +1989,7 @@ suite('Blocks', function() { // so we assert init was called to be safe. var initCalled = false; var recordUndoDuringInit; - blocks.definitions['init_test_block'].init = function() { + Blocks['init_test_block'].init = function() { initCalled = true; recordUndoDuringInit = Blockly.Events.getRecordUndo(); throw new Error(); diff --git a/tests/mocha/test_helpers.js b/tests/mocha/test_helpers.js index eb6e3ec9217..12ed012f176 100644 --- a/tests/mocha/test_helpers.js +++ b/tests/mocha/test_helpers.js @@ -7,7 +7,7 @@ goog.module('Blockly.test.helpers'); const KeyCodes = goog.require('Blockly.utils.KeyCodes'); -const blocks = goog.require('Blockly.blocks'); +const {Blocks} = goog.require('Blockly.blocks'); /** @@ -138,7 +138,7 @@ exports.addMessageToCleanup = addMessageToCleanup; /** * Adds block type to shared cleanup object so that it is cleaned from - * Blockly.blocks.definitions global in sharedTestTeardown. + * Blockly.Blocks global in sharedTestTeardown. * @param {!Object} sharedCleanupObj The shared cleanup object created in * sharedTestSetup. * @param {string} blockType The block type to add to shared cleanup object. @@ -151,7 +151,7 @@ exports.addBlockTypeToCleanup = addBlockTypeToCleanup; /** * Wraps Blockly.defineBlocksWithJsonArray using stub in order to keep track of * block types passed in to method on shared cleanup object so they are cleaned - * from Blockly.blocks.definitions global in sharedTestTeardown. + * from Blockly.Blocks global in sharedTestTeardown. * @param {!Object} sharedCleanupObj The shared cleanup object created in * sharedTestSetup. * @private @@ -253,7 +253,7 @@ function sharedTestTeardown() { var blockTypes = this.sharedCleanup.blockTypesCleanup_; for (let i = 0; i < blockTypes.length; i++) { - delete blocks.definitions[blockTypes[i]]; + delete Blocks[blockTypes[i]]; } var messages = this.sharedCleanup.messagesCleanup_; for (let i = 0; i < messages.length; i++) {