From e16a0a4bce83dac71e6c1aeae4168d3620fda82f Mon Sep 17 00:00:00 2001 From: kozbial Date: Tue, 3 Aug 2021 16:26:34 -0700 Subject: [PATCH] Migrate core/events/events_ui.js and core/events/events_ui_base.js to goog.module --- core/events/events_ui.js | 22 ++++++++++++---------- core/events/events_ui_base.js | 16 ++++++++-------- tests/deps.js | 4 ++-- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/core/events/events_ui.js b/core/events/events_ui.js index b28d86a2e..5504b61d6 100644 --- a/core/events/events_ui.js +++ b/core/events/events_ui.js @@ -11,7 +11,8 @@ */ 'use strict'; -goog.provide('Blockly.Events.Ui'); +goog.module('Blockly.Events.Ui'); +goog.module.declareLegacyNamespace(); goog.require('Blockly.Events'); goog.require('Blockly.Events.UiBase'); @@ -33,30 +34,30 @@ goog.requireType('Blockly.Block'); * @deprecated December 2020. Instead use a more specific UI event. * @constructor */ -Blockly.Events.Ui = function(opt_block, opt_element, opt_oldValue, +const Ui = function(opt_block, opt_element, opt_oldValue, opt_newValue) { const workspaceId = opt_block ? opt_block.workspace.id : undefined; - Blockly.Events.Ui.superClass_.constructor.call(this, workspaceId); + Ui.superClass_.constructor.call(this, workspaceId); this.blockId = opt_block ? opt_block.id : null; this.element = typeof opt_element == 'undefined' ? '' : opt_element; this.oldValue = typeof opt_oldValue == 'undefined' ? '' : opt_oldValue; this.newValue = typeof opt_newValue == 'undefined' ? '' : opt_newValue; }; -Blockly.utils.object.inherits(Blockly.Events.Ui, Blockly.Events.UiBase); +Blockly.utils.object.inherits(Ui, Blockly.Events.UiBase); /** * Type of this event. * @type {string} */ -Blockly.Events.Ui.prototype.type = Blockly.Events.UI; +Ui.prototype.type = Blockly.Events.UI; /** * Encode the event as JSON. * @return {!Object} JSON representation. */ -Blockly.Events.Ui.prototype.toJson = function() { - const json = Blockly.Events.Ui.superClass_.toJson.call(this); +Ui.prototype.toJson = function() { + const json = Ui.superClass_.toJson.call(this); json['element'] = this.element; if (this.newValue !== undefined) { json['newValue'] = this.newValue; @@ -71,12 +72,13 @@ Blockly.Events.Ui.prototype.toJson = function() { * Decode the JSON event. * @param {!Object} json JSON representation. */ -Blockly.Events.Ui.prototype.fromJson = function(json) { - Blockly.Events.Ui.superClass_.fromJson.call(this, json); +Ui.prototype.fromJson = function(json) { + Ui.superClass_.fromJson.call(this, json); this.element = json['element']; this.newValue = json['newValue']; this.blockId = json['blockId']; }; Blockly.registry.register(Blockly.registry.Type.EVENT, Blockly.Events.UI, - Blockly.Events.Ui); \ No newline at end of file + Ui); +exports = Ui; diff --git a/core/events/events_ui_base.js b/core/events/events_ui_base.js index b286b9283..9d54f0dcf 100644 --- a/core/events/events_ui_base.js +++ b/core/events/events_ui_base.js @@ -11,14 +11,12 @@ */ 'use strict'; -goog.provide('Blockly.Events.UiBase'); +goog.module('Blockly.Events.UiBase'); +goog.module.declareLegacyNamespace(); -goog.require('Blockly.Events'); goog.require('Blockly.Events.Abstract'); goog.require('Blockly.utils.object'); -goog.requireType('Blockly.Block'); - /** * Base class for a UI event. @@ -31,8 +29,8 @@ goog.requireType('Blockly.Block'); * @extends {Blockly.Events.Abstract} * @constructor */ -Blockly.Events.UiBase = function(opt_workspaceId) { - Blockly.Events.UiBase.superClass_.constructor.call(this); +const UiBase = function(opt_workspaceId) { + UiBase.superClass_.constructor.call(this); /** * Whether or not the event is blank (to be populated by fromJson). @@ -49,10 +47,12 @@ Blockly.Events.UiBase = function(opt_workspaceId) { // UI events do not undo or redo. this.recordUndo = false; }; -Blockly.utils.object.inherits(Blockly.Events.UiBase, Blockly.Events.Abstract); +Blockly.utils.object.inherits(UiBase, Blockly.Events.Abstract); /** * Whether or not the event is a UI event. * @type {boolean} */ -Blockly.Events.UiBase.prototype.isUiEvent = true; +UiBase.prototype.isUiEvent = true; + +exports = UiBase; diff --git a/tests/deps.js b/tests/deps.js index 9d4b8a6bd..3da6c1e78 100644 --- a/tests/deps.js +++ b/tests/deps.js @@ -49,8 +49,8 @@ goog.addDependency('../../core/events/events_selected.js', ['Blockly.Events.Sele goog.addDependency('../../core/events/events_theme_change.js', ['Blockly.Events.ThemeChange'], ['Blockly.Events', 'Blockly.Events.UiBase', 'Blockly.registry', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/events/events_toolbox_item_select.js', ['Blockly.Events.ToolboxItemSelect'], ['Blockly.Events', 'Blockly.Events.UiBase', 'Blockly.registry', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/events/events_trashcan_open.js', ['Blockly.Events.TrashcanOpen'], ['Blockly.Events', 'Blockly.Events.UiBase', 'Blockly.registry', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'}); -goog.addDependency('../../core/events/events_ui.js', ['Blockly.Events.Ui'], ['Blockly.Events', 'Blockly.Events.UiBase', 'Blockly.registry', 'Blockly.utils.object']); -goog.addDependency('../../core/events/events_ui_base.js', ['Blockly.Events.UiBase'], ['Blockly.Events', 'Blockly.Events.Abstract', 'Blockly.utils.object']); +goog.addDependency('../../core/events/events_ui.js', ['Blockly.Events.Ui'], ['Blockly.Events', 'Blockly.Events.UiBase', 'Blockly.registry', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'}); +goog.addDependency('../../core/events/events_ui_base.js', ['Blockly.Events.UiBase'], ['Blockly.Events.Abstract', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/events/events_var_base.js', ['Blockly.Events.VarBase'], ['Blockly.Events.Abstract', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/events/events_var_create.js', ['Blockly.Events.VarCreate'], ['Blockly.Events', 'Blockly.Events.VarBase', 'Blockly.registry', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'}); goog.addDependency('../../core/events/events_var_delete.js', ['Blockly.Events.VarDelete'], ['Blockly.Events', 'Blockly.Events.VarBase', 'Blockly.registry', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'});