Migrate core/events/workspace_events.js to goog.module syntax (#5274)

* Migrate core/events/workspace_events.js to ES6 const/let

* Migrate core/events/workspace_events.js to goog.module

* Migrate core/events/workspace_events.js to named requires

* clang-format core/events/workspace_events.js

* Update build artifact sizes in check_metadata.sh

* Add comment about root cause of build artifact size change

* Migrate core/events/workspace_events.js to ES6 const/let

* Migrate core/events/workspace_events.js to goog.module

* Migrate core/events/workspace_events.js to named requires

* clang-format core/events/workspace_events.js

* Clarify require name for Blockly.Events.Abstract
This commit is contained in:
Aaron Dodson
2021-08-09 12:43:06 -07:00
committed by GitHub
parent b5444b4e89
commit fbd7c8ab79
2 changed files with 22 additions and 21 deletions

View File

@@ -10,14 +10,15 @@
*/
'use strict';
goog.provide('Blockly.Events.FinishedLoading');
goog.module('Blockly.Events.FinishedLoading');
goog.module.declareLegacyNamespace();
goog.require('Blockly.Events');
goog.require('Blockly.Events.Abstract');
goog.require('Blockly.registry');
goog.require('Blockly.utils.object');
goog.requireType('Blockly.Workspace');
const Events = goog.require('Blockly.Events');
const EventsAbstract = goog.require('Blockly.Events.Abstract');
/* eslint-disable-next-line no-unused-vars */
const Workspace = goog.requireType('Blockly.Workspace');
const object = goog.require('Blockly.utils.object');
const registry = goog.require('Blockly.registry');
/**
@@ -25,13 +26,12 @@ goog.requireType('Blockly.Workspace');
* Used to notify the developer when the workspace has finished loading (i.e
* domToWorkspace).
* Finished loading events do not record undo or redo.
* @param {!Blockly.Workspace=} opt_workspace The workspace that has finished
* @param {!Workspace=} opt_workspace The workspace that has finished
* loading. Undefined for a blank event.
* @extends {Blockly.Events.Abstract}
* @extends {EventsAbstract}
* @constructor
*/
Blockly.Events.FinishedLoading = function(opt_workspace) {
const FinishedLoading = function(opt_workspace) {
/**
* Whether or not the event is blank (to be populated by fromJson).
* @type {boolean}
@@ -50,26 +50,25 @@ Blockly.Events.FinishedLoading = function(opt_workspace) {
* perspective, and should be undone together.
* @type {string}
*/
this.group = Blockly.Events.getGroup();
this.group = Events.getGroup();
// Workspace events do not undo or redo.
this.recordUndo = false;
};
Blockly.utils.object.inherits(Blockly.Events.FinishedLoading,
Blockly.Events.Abstract);
object.inherits(FinishedLoading, EventsAbstract);
/**
* Type of this event.
* @type {string}
*/
Blockly.Events.FinishedLoading.prototype.type = Blockly.Events.FINISHED_LOADING;
FinishedLoading.prototype.type = Events.FINISHED_LOADING;
/**
* Encode the event as JSON.
* @return {!Object} JSON representation.
*/
Blockly.Events.FinishedLoading.prototype.toJson = function() {
var json = {
FinishedLoading.prototype.toJson = function() {
const json = {
'type': this.type,
};
if (this.group) {
@@ -85,11 +84,13 @@ Blockly.Events.FinishedLoading.prototype.toJson = function() {
* Decode the JSON event.
* @param {!Object} json JSON representation.
*/
Blockly.Events.FinishedLoading.prototype.fromJson = function(json) {
FinishedLoading.prototype.fromJson = function(json) {
this.isBlank = false;
this.workspaceId = json['workspaceId'];
this.group = json['group'];
};
Blockly.registry.register(Blockly.registry.Type.EVENT,
Blockly.Events.FINISHED_LOADING, Blockly.Events.FinishedLoading);
registry.register(
registry.Type.EVENT, Events.FINISHED_LOADING, FinishedLoading);
exports = FinishedLoading;

View File

@@ -48,7 +48,7 @@ goog.addDependency('../../core/events/events_trashcan_open.js', ['Blockly.Events
goog.addDependency('../../core/events/events_viewport.js', ['Blockly.Events.ViewportChange'], ['Blockly.Events', 'Blockly.Events.UiBase', 'Blockly.registry', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/events/ui_events.js', ['Blockly.Events.Ui', 'Blockly.Events.UiBase'], ['Blockly.Events', 'Blockly.Events.Abstract', 'Blockly.registry', 'Blockly.utils.object']);
goog.addDependency('../../core/events/variable_events.js', ['Blockly.Events.VarBase', 'Blockly.Events.VarCreate', 'Blockly.Events.VarDelete', 'Blockly.Events.VarRename'], ['Blockly.Events', 'Blockly.Events.Abstract', 'Blockly.registry', 'Blockly.utils.object']);
goog.addDependency('../../core/events/workspace_events.js', ['Blockly.Events.FinishedLoading'], ['Blockly.Events', 'Blockly.Events.Abstract', 'Blockly.registry', 'Blockly.utils.object'], {'lang': 'es5'});
goog.addDependency('../../core/events/workspace_events.js', ['Blockly.Events.FinishedLoading'], ['Blockly.Events', 'Blockly.Events.Abstract', 'Blockly.registry', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/events/ws_comment_events.js', ['Blockly.Events.CommentBase', 'Blockly.Events.CommentChange', 'Blockly.Events.CommentCreate', 'Blockly.Events.CommentDelete', 'Blockly.Events.CommentMove'], ['Blockly.Events', 'Blockly.Events.Abstract', 'Blockly.Xml', 'Blockly.registry', 'Blockly.utils.Coordinate', 'Blockly.utils.object', 'Blockly.utils.xml']);
goog.addDependency('../../core/extensions.js', ['Blockly.Extensions'], ['Blockly.utils'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/field.js', ['Blockly.Field'], ['Blockly.DropDownDiv', 'Blockly.Events', 'Blockly.Events.BlockChange', 'Blockly.Gesture', 'Blockly.IASTNodeLocationSvg', 'Blockly.IASTNodeLocationWithBlock', 'Blockly.IKeyboardAccessible', 'Blockly.IRegistrable', 'Blockly.MarkerManager', 'Blockly.Tooltip', 'Blockly.WidgetDiv', 'Blockly.browserEvents', 'Blockly.utils', 'Blockly.utils.Rect', 'Blockly.utils.Size', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.style', 'Blockly.utils.userAgent'], {'lang': 'es6', 'module': 'goog'});