From 4d4e8473477e1c22d1b549f1a13ba54b5fb4f038 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Tue, 19 Jul 2022 21:54:32 +0000 Subject: [PATCH 01/44] chore: fix circular dependencies w/ static workspace funcs --- core/common.ts | 33 ++++++++++ core/events/events_abstract.ts | 5 +- core/events/utils.ts | 15 ++--- core/gesture.ts | 41 ++++++------ core/inject.ts | 2 +- core/interfaces/i_collapsible_toolbox_item.ts | 2 +- core/interfaces/i_copyable.ts | 4 +- core/interfaces/i_delete_area.ts | 2 +- core/interfaces/i_drag_target.ts | 2 +- core/interfaces/i_positionable.ts | 2 +- core/interfaces/i_selectable.ts | 4 +- core/interfaces/i_serializer.ts | 2 +- core/keyboard_nav/marker.ts | 2 +- core/procedures.ts | 35 ++++++----- core/renderers/geras/drawer.ts | 10 +-- core/renderers/geras/highlighter.ts | 6 +- core/renderers/geras/info.ts | 26 ++++---- .../geras/measurables/inline_input.ts | 8 +-- .../geras/measurables/statement_input.ts | 8 +-- core/renderers/geras/path_object.ts | 12 ++-- core/renderers/geras/renderer.ts | 10 +-- core/renderers/measurables/connection.ts | 4 +- .../measurables/external_value_input.ts | 4 +- core/renderers/measurables/field.ts | 6 +- core/renderers/measurables/icon.ts | 4 +- core/renderers/measurables/inline_input.ts | 4 +- core/renderers/measurables/statement_input.ts | 4 +- core/renderers/thrasos/info.ts | 18 +++--- core/workspace.ts | 63 ++++++------------- 29 files changed, 175 insertions(+), 163 deletions(-) diff --git a/core/common.ts b/core/common.ts index 051c9e83c59..bf356d1ed27 100644 --- a/core/common.ts +++ b/core/common.ts @@ -26,6 +26,39 @@ import type {Workspace} from './workspace.js'; import type {WorkspaceSvg} from './workspace_svg.js'; +/** Database of all workspaces. */ +const WorkspaceDB_ = Object.create(null); + + +/** + * Find the workspace with the specified ID. + * @param id ID of workspace to find. + * @return The sought after workspace or null if not found. + */ +export function getWorkspaceById(id: string): Workspace|null { + return WorkspaceDB_[id] || null; +} + +/** + * Find all workspaces. + * @return Array of workspaces. + */ +export function getAllWorkspaces(): Workspace[] { + const workspaces = []; + for (const workspaceId in WorkspaceDB_) { + workspaces.push(WorkspaceDB_[workspaceId]); + } + return workspaces; +} + +export function registerWorkspace(workspace: Workspace) { + WorkspaceDB_[workspace.id] = workspace; +} + +export function unregisterWorkpace(workspace: Workspace) { + delete WorkspaceDB_[workspace.id]; +} + /** * The main workspace most recently used. * Set by Blockly.WorkspaceSvg.prototype.markFocused diff --git a/core/events/events_abstract.ts b/core/events/events_abstract.ts index 031e96fcf0e..9651cd6ea03 100644 --- a/core/events/events_abstract.ts +++ b/core/events/events_abstract.ts @@ -17,7 +17,8 @@ import * as goog from '../../closure/goog/goog.js'; goog.declareModuleId('Blockly.Events.Abstract'); -import {Workspace} from '../workspace.js'; +import * as common from '../common'; +import type {Workspace} from '../workspace'; import * as eventUtils from './utils.js'; @@ -99,7 +100,7 @@ export abstract class Abstract { getEventWorkspace_(): Workspace { let workspace; if (this.workspaceId) { - workspace = Workspace.getById(this.workspaceId); + workspace = common.getWorkspaceById(this.workspaceId); } if (!workspace) { throw Error( diff --git a/core/events/utils.ts b/core/events/utils.ts index db1f2cefd65..a169f72f72c 100644 --- a/core/events/utils.ts +++ b/core/events/utils.ts @@ -17,11 +17,12 @@ import * as goog from '../../closure/goog/goog.js'; goog.declareModuleId('Blockly.Events.utils'); -import type {Block} from '../block.js'; -import * as registry from '../registry.js'; -import * as idGenerator from '../utils/idgenerator.js'; -import {Workspace} from '../workspace.js'; -import type {WorkspaceSvg} from '../workspace_svg.js'; +import type {Block} from '../block'; +import * as common from '../common'; +import * as registry from '../registry'; +import * as idGenerator from '../utils/idgenerator'; +import type {Workspace} from '../workspace'; +import type {WorkspaceSvg} from '../workspace_svg'; import type {Abstract} from './events_abstract.js'; import type {BlockChange} from './events_block_change.js'; @@ -263,7 +264,7 @@ function fireNow() { if (!event.workspaceId) { continue; } - const eventWorkspace = Workspace.getById(event.workspaceId); + const eventWorkspace = common.getWorkspaceById(event.workspaceId); if (eventWorkspace) { eventWorkspace.fireChangeListener(event); } @@ -478,7 +479,7 @@ export function disableOrphans(event: Abstract) { return; } const eventWorkspace = - Workspace.getById(blockEvent.workspaceId) as WorkspaceSvg; + common.getWorkspaceById(blockEvent.workspaceId) as WorkspaceSvg; let block = eventWorkspace.getBlockById(blockEvent.blockId); if (block) { // Changing blocks as part of this event shouldn't be undoable. diff --git a/core/gesture.ts b/core/gesture.ts index 5d656d3151f..7ee356cb1d8 100644 --- a/core/gesture.ts +++ b/core/gesture.ts @@ -22,26 +22,25 @@ import './block_dragger.js'; // Unused import preserved for side-effects. Remove if unneeded. import './events/events_click.js'; -import * as blockAnimations from './block_animations.js'; -import type {BlockSvg} from './block_svg.js'; -import * as browserEvents from './browser_events.js'; -import {BubbleDragger} from './bubble_dragger.js'; -import * as common from './common.js'; -import {config} from './config.js'; -import * as eventUtils from './events/utils.js'; -import type {Field} from './field.js'; -import type {IBlockDragger} from './interfaces/i_block_dragger.js'; -import type {IBubble} from './interfaces/i_bubble.js'; -import type {IFlyout} from './interfaces/i_flyout.js'; -import * as internalConstants from './internal_constants.js'; -import * as registry from './registry.js'; -import * as Tooltip from './tooltip.js'; -import * as Touch from './touch.js'; -import {Coordinate} from './utils/coordinate.js'; -import {Workspace} from './workspace.js'; -import {WorkspaceCommentSvg} from './workspace_comment_svg.js'; -import {WorkspaceDragger} from './workspace_dragger.js'; -import type {WorkspaceSvg} from './workspace_svg.js'; +import * as blockAnimations from './block_animations'; +import type {BlockSvg} from './block_svg'; +import * as browserEvents from './browser_events'; +import {BubbleDragger} from './bubble_dragger'; +import * as common from './common'; +import {config} from './config'; +import * as eventUtils from './events/utils'; +import type {Field} from './field'; +import type {IBlockDragger} from './interfaces/i_block_dragger'; +import type {IBubble} from './interfaces/i_bubble'; +import type {IFlyout} from './interfaces/i_flyout'; +import * as internalConstants from './internal_constants'; +import * as registry from './registry'; +import * as Tooltip from './tooltip'; +import * as Touch from './touch'; +import {Coordinate} from './utils/coordinate'; +import {WorkspaceCommentSvg} from './workspace_comment_svg'; +import {WorkspaceDragger} from './workspace_dragger'; +import type {WorkspaceSvg} from './workspace_svg'; /** @@ -936,7 +935,7 @@ export class Gesture { * @return True if gesture is occurring. */ static inProgress(): boolean { - const workspaces = Workspace.getAll(); + const workspaces = common.getAllWorkspaces(); for (let i = 0, workspace; workspace = workspaces[i]; i++) { // Not actually necessarily a WorkspaceSvg, but it doesn't matter b/c // we're just checking if the property exists. Theoretically we would diff --git a/core/inject.ts b/core/inject.ts index 9d642e64223..090d9cb001c 100644 --- a/core/inject.ts +++ b/core/inject.ts @@ -315,7 +315,7 @@ let documentEventsBound = false; function bindDocumentEvents() { if (!documentEventsBound) { browserEvents.conditionalBind(document, 'scroll', null, function() { - const workspaces = Workspace.getAll(); + const workspaces = common.getAllWorkspaces(); for (let i = 0, workspace; workspace = workspaces[i]; i++) { if (workspace instanceof WorkspaceSvg) { workspace.updateInverseScreenCTM(); diff --git a/core/interfaces/i_collapsible_toolbox_item.ts b/core/interfaces/i_collapsible_toolbox_item.ts index 8329dc3c924..f2cc54a8c0f 100644 --- a/core/interfaces/i_collapsible_toolbox_item.ts +++ b/core/interfaces/i_collapsible_toolbox_item.ts @@ -20,7 +20,7 @@ goog.declareModuleId('Blockly.ICollapsibleToolboxItem'); // Unused import preserved for side-effects. Remove if unneeded. import './i_toolbox_item.js'; -import type {ISelectableToolboxItem} from './i_selectable_toolbox_item.js'; +import type {ISelectableToolboxItem} from './i_selectable_toolbox_item'; /** diff --git a/core/interfaces/i_copyable.ts b/core/interfaces/i_copyable.ts index 21265f111a2..fe27c426566 100644 --- a/core/interfaces/i_copyable.ts +++ b/core/interfaces/i_copyable.ts @@ -15,8 +15,8 @@ import * as goog from '../../closure/goog/goog.js'; goog.declareModuleId('Blockly.ICopyable'); -import type {WorkspaceSvg} from '../workspace_svg.js'; -import type {ISelectable} from './i_selectable.js'; +import type {WorkspaceSvg} from '../workspace_svg'; +import type {ISelectable} from './i_selectable'; /** @alias Blockly.ICopyable */ diff --git a/core/interfaces/i_delete_area.ts b/core/interfaces/i_delete_area.ts index 548de239686..b0fec86e10e 100644 --- a/core/interfaces/i_delete_area.ts +++ b/core/interfaces/i_delete_area.ts @@ -22,7 +22,7 @@ goog.declareModuleId('Blockly.IDeleteArea'); // Unused import preserved for side-effects. Remove if unneeded. import './i_draggable.js'; -import type {IDragTarget} from './i_drag_target.js'; +import type {IDragTarget} from './i_drag_target'; /** diff --git a/core/interfaces/i_drag_target.ts b/core/interfaces/i_drag_target.ts index 70795b4f19d..c66f7f8e0d7 100644 --- a/core/interfaces/i_drag_target.ts +++ b/core/interfaces/i_drag_target.ts @@ -25,7 +25,7 @@ import './i_draggable.js'; // Unused import preserved for side-effects. Remove if unneeded. import '../utils/rect.js'; -import type {IComponent} from './i_component.js'; +import type {IComponent} from './i_component'; /** diff --git a/core/interfaces/i_positionable.ts b/core/interfaces/i_positionable.ts index 0cdbde2b959..fb32cef0e0b 100644 --- a/core/interfaces/i_positionable.ts +++ b/core/interfaces/i_positionable.ts @@ -23,7 +23,7 @@ import '../metrics_manager.js'; // Unused import preserved for side-effects. Remove if unneeded. import '../utils/rect.js'; -import type {IComponent} from './i_component.js'; +import type {IComponent} from './i_component'; /** diff --git a/core/interfaces/i_selectable.ts b/core/interfaces/i_selectable.ts index 6fdaa8458ec..936019191e6 100644 --- a/core/interfaces/i_selectable.ts +++ b/core/interfaces/i_selectable.ts @@ -15,8 +15,8 @@ import * as goog from '../../closure/goog/goog.js'; goog.declareModuleId('Blockly.ISelectable'); -import type {IDeletable} from './i_deletable.js'; -import type {IMovable} from './i_movable.js'; +import type {IDeletable} from './i_deletable'; +import type {IMovable} from './i_movable'; /** diff --git a/core/interfaces/i_serializer.ts b/core/interfaces/i_serializer.ts index 5c926b86e6f..0f5b5fec52b 100644 --- a/core/interfaces/i_serializer.ts +++ b/core/interfaces/i_serializer.ts @@ -17,7 +17,7 @@ import * as goog from '../../closure/goog/goog.js'; goog.declareModuleId('Blockly.serialization.ISerializer'); -import type {Workspace} from '../workspace.js'; +import type {Workspace} from '../workspace'; /** diff --git a/core/keyboard_nav/marker.ts b/core/keyboard_nav/marker.ts index be79d745dbd..aa495c05deb 100644 --- a/core/keyboard_nav/marker.ts +++ b/core/keyboard_nav/marker.ts @@ -20,7 +20,7 @@ goog.declareModuleId('Blockly.Marker'); /* eslint-disable-next-line no-unused-vars */ import type {MarkerSvg} from '../renderers/common/marker_svg.js'; -import type {ASTNode} from './ast_node.js'; +import type {ASTNode} from './ast_node'; /** diff --git a/core/procedures.ts b/core/procedures.ts index 5935748e9f9..ad3fe3f2bae 100644 --- a/core/procedures.ts +++ b/core/procedures.ts @@ -18,20 +18,21 @@ goog.declareModuleId('Blockly.Procedures'); // Unused import preserved for side-effects. Remove if unneeded. import './events/events_block_change.js'; -import type {Block} from './block.js'; -import type {BlockSvg} from './block_svg.js'; -import {Blocks} from './blocks.js'; -import type {Abstract} from './events/events_abstract.js'; -import type {BubbleOpen} from './events/events_bubble_open.js'; -import * as eventUtils from './events/utils.js'; -import type {Field} from './field.js'; -import {Msg} from './msg.js'; -import {Names} from './names.js'; -import * as utilsXml from './utils/xml.js'; -import * as Variables from './variables.js'; -import {Workspace} from './workspace.js'; -import type {WorkspaceSvg} from './workspace_svg.js'; -import * as Xml from './xml.js'; +import type {Block} from './block'; +import type {BlockSvg} from './block_svg'; +import {Blocks} from './blocks'; +import * as common from './common'; +import type {Abstract} from './events/events_abstract'; +import type {BubbleOpen} from './events/events_bubble_open'; +import * as eventUtils from './events/utils'; +import type {Field} from './field'; +import {Msg} from './msg'; +import {Names} from './names'; +import * as utilsXml from './utils/xml'; +import * as Variables from './variables'; +import type {Workspace} from './workspace'; +import type {WorkspaceSvg} from './workspace_svg'; +import * as Xml from './xml'; /** @@ -333,8 +334,8 @@ export function mutatorOpenListener(e: Abstract) { return; } const workspaceId = (bubbleEvent.workspaceId); - const block = Workspace.getById(workspaceId)!.getBlockById( - bubbleEvent.blockId) as BlockSvg; + const block = common.getWorkspaceById(workspaceId)!.getBlockById( + bubbleEvent.blockId) as AnyDuringMigration as BlockSvg; const type = block.type; if (type !== 'procedures_defnoreturn' && type !== 'procedures_defreturn') { return; @@ -355,7 +356,7 @@ function mutatorChangeListener(e: Abstract) { return; } const workspaceId = e.workspaceId as string; - const workspace = Workspace.getById(workspaceId) as WorkspaceSvg; + const workspace = common.getWorkspaceById(workspaceId) as AnyDuringMigration as WorkspaceSvg; updateMutatorFlyout(workspace); } diff --git a/core/renderers/geras/drawer.ts b/core/renderers/geras/drawer.ts index 6c8fcdaa1ed..1c628b3b677 100644 --- a/core/renderers/geras/drawer.ts +++ b/core/renderers/geras/drawer.ts @@ -15,11 +15,11 @@ import * as goog from '../../../closure/goog/goog.js'; goog.declareModuleId('Blockly.geras.Drawer'); -import type {BlockSvg} from '../../block_svg.js'; -import * as svgPaths from '../../utils/svg_paths.js'; -import * as debug from '../common/debug.js'; -import {Drawer as BaseDrawer} from '../common/drawer.js'; -import type {Row} from '../measurables/row.js'; +import type {BlockSvg} from '../../block_svg'; +import * as svgPaths from '../../utils/svg_paths'; +import * as debug from '../common/debug'; +import {Drawer as BaseDrawer} from '../common/drawer'; +import type {Row} from '../measurables/row'; import type {ConstantProvider} from './constants.js'; import {Highlighter} from './highlighter.js'; diff --git a/core/renderers/geras/highlighter.ts b/core/renderers/geras/highlighter.ts index 8bef5459ba5..bd783bcdbe5 100644 --- a/core/renderers/geras/highlighter.ts +++ b/core/renderers/geras/highlighter.ts @@ -29,9 +29,9 @@ import {SpacerRow} from '../measurables/spacer_row.js'; import type {TopRow} from '../measurables/top_row.js'; import {Types} from '../measurables/types.js'; -import type {HighlightConstantProvider, InsideCorner, JaggedTeeth, Notch, OutsideCorner, PuzzleTab, StartHat} from './highlight_constants.js'; -import type {RenderInfo} from './info.js'; -import type {InlineInput} from './measurables/inline_input.js'; +import type {HighlightConstantProvider, InsideCorner, JaggedTeeth, Notch, OutsideCorner, PuzzleTab, StartHat} from './highlight_constants'; +import type {RenderInfo} from './info'; +import type {InlineInput} from './measurables/inline_input'; /** diff --git a/core/renderers/geras/info.ts b/core/renderers/geras/info.ts index d2df8ee4b37..5cbc8983a9a 100644 --- a/core/renderers/geras/info.ts +++ b/core/renderers/geras/info.ts @@ -17,19 +17,19 @@ import * as goog from '../../../closure/goog/goog.js'; goog.declareModuleId('Blockly.geras.RenderInfo'); -import type {BlockSvg} from '../../block_svg.js'; -import type {Input} from '../../input.js'; -import {inputTypes} from '../../input_types.js'; -import {RenderInfo as BaseRenderInfo} from '../common/info.js'; -import type {Measurable} from '../measurables/base.js'; -import type {BottomRow} from '../measurables/bottom_row.js'; -import {ExternalValueInput} from '../measurables/external_value_input.js'; -import type {Field} from '../measurables/field.js'; -import {InRowSpacer} from '../measurables/in_row_spacer.js'; -import type {InputRow} from '../measurables/input_row.js'; -import type {Row} from '../measurables/row.js'; -import type {TopRow} from '../measurables/top_row.js'; -import {Types} from '../measurables/types.js'; +import type {BlockSvg} from '../../block_svg'; +import type {Input} from '../../input'; +import {inputTypes} from '../../input_types'; +import {RenderInfo as BaseRenderInfo} from '../common/info'; +import type {Measurable} from '../measurables/base'; +import type {BottomRow} from '../measurables/bottom_row'; +import {ExternalValueInput} from '../measurables/external_value_input'; +import type {Field} from '../measurables/field'; +import {InRowSpacer} from '../measurables/in_row_spacer'; +import type {InputRow} from '../measurables/input_row'; +import type {Row} from '../measurables/row'; +import type {TopRow} from '../measurables/top_row'; +import {Types} from '../measurables/types'; import type {ConstantProvider} from './constants.js'; import {InlineInput} from './measurables/inline_input.js'; diff --git a/core/renderers/geras/measurables/inline_input.ts b/core/renderers/geras/measurables/inline_input.ts index 76dacf56b42..702cfdae5a8 100644 --- a/core/renderers/geras/measurables/inline_input.ts +++ b/core/renderers/geras/measurables/inline_input.ts @@ -18,10 +18,10 @@ import * as goog from '../../../../closure/goog/goog.js'; goog.declareModuleId('Blockly.geras.InlineInput'); /* eslint-disable-next-line no-unused-vars */ -import type {Input} from '../../../input.js'; -import type {ConstantProvider as BaseConstantProvider} from '../../../renderers/common/constants.js'; -import {InlineInput as BaseInlineInput} from '../../../renderers/measurables/inline_input.js'; -import type {ConstantProvider as GerasConstantProvider} from '../constants.js'; +import type {Input} from '../../../input'; +import type {ConstantProvider as BaseConstantProvider} from '../../../renderers/common/constants'; +import {InlineInput as BaseInlineInput} from '../../../renderers/measurables/inline_input'; +import type {ConstantProvider as GerasConstantProvider} from '../constants'; /** diff --git a/core/renderers/geras/measurables/statement_input.ts b/core/renderers/geras/measurables/statement_input.ts index f002a5bcb2f..c560abd676a 100644 --- a/core/renderers/geras/measurables/statement_input.ts +++ b/core/renderers/geras/measurables/statement_input.ts @@ -18,10 +18,10 @@ import * as goog from '../../../../closure/goog/goog.js'; goog.declareModuleId('Blockly.geras.StatementInput'); /* eslint-disable-next-line no-unused-vars */ -import type {Input} from '../../../input.js'; -import type {ConstantProvider as BaseConstantProvider} from '../../../renderers/common/constants.js'; -import {StatementInput as BaseStatementInput} from '../../../renderers/measurables/statement_input.js'; -import type {ConstantProvider as GerasConstantProvider} from '../constants.js'; +import type {Input} from '../../../input'; +import type {ConstantProvider as BaseConstantProvider} from '../../../renderers/common/constants'; +import {StatementInput as BaseStatementInput} from '../../../renderers/measurables/statement_input'; +import type {ConstantProvider as GerasConstantProvider} from '../constants'; /** diff --git a/core/renderers/geras/path_object.ts b/core/renderers/geras/path_object.ts index 27d35ac7067..92a765ee4a9 100644 --- a/core/renderers/geras/path_object.ts +++ b/core/renderers/geras/path_object.ts @@ -19,12 +19,12 @@ goog.declareModuleId('Blockly.geras.PathObject'); // Unused import preserved for side-effects. Remove if unneeded. import '../../theme.js'; -import type {BlockSvg} from '../../block_svg.js'; -import type {BlockStyle} from '../../theme.js'; -import * as colour from '../../utils/colour.js'; -import * as dom from '../../utils/dom.js'; -import {Svg} from '../../utils/svg.js'; -import {PathObject as BasePathObject} from '../common/path_object.js'; +import type {BlockSvg} from '../../block_svg'; +import type {BlockStyle} from '../../theme'; +import * as colour from '../../utils/colour'; +import * as dom from '../../utils/dom'; +import {Svg} from '../../utils/svg'; +import {PathObject as BasePathObject} from '../common/path_object'; import type {ConstantProvider} from './constants.js'; diff --git a/core/renderers/geras/renderer.ts b/core/renderers/geras/renderer.ts index 51a7ca29d12..3b02dbc71e0 100644 --- a/core/renderers/geras/renderer.ts +++ b/core/renderers/geras/renderer.ts @@ -19,11 +19,11 @@ goog.declareModuleId('Blockly.geras.Renderer'); // Unused import preserved for side-effects. Remove if unneeded. import '../common/constants.js'; -import type {BlockSvg} from '../../block_svg.js'; -import type {BlockStyle, Theme} from '../../theme.js'; -import * as blockRendering from '../common/block_rendering.js'; -import type {RenderInfo as BaseRenderInfo} from '../common/info.js'; -import {Renderer as BaseRenderer} from '../common/renderer.js'; +import type {BlockSvg} from '../../block_svg'; +import type {BlockStyle, Theme} from '../../theme'; +import * as blockRendering from '../common/block_rendering'; +import type {RenderInfo as BaseRenderInfo} from '../common/info'; +import {Renderer as BaseRenderer} from '../common/renderer'; import {ConstantProvider} from './constants.js'; import {Drawer} from './drawer.js'; diff --git a/core/renderers/measurables/connection.ts b/core/renderers/measurables/connection.ts index 84a121b2a9c..65b0a0d4f76 100644 --- a/core/renderers/measurables/connection.ts +++ b/core/renderers/measurables/connection.ts @@ -18,8 +18,8 @@ import * as goog from '../../../closure/goog/goog.js'; goog.declareModuleId('Blockly.blockRendering.Connection'); /* eslint-disable-next-line no-unused-vars */ -import type {RenderedConnection} from '../../rendered_connection.js'; -import type {ConstantProvider, Shape} from '../common/constants.js'; +import type {RenderedConnection} from '../../rendered_connection'; +import type {ConstantProvider, Shape} from '../common/constants'; import {Measurable} from './base.js'; import {Types} from './types.js'; diff --git a/core/renderers/measurables/external_value_input.ts b/core/renderers/measurables/external_value_input.ts index f7cf459b599..0f1c589a92b 100644 --- a/core/renderers/measurables/external_value_input.ts +++ b/core/renderers/measurables/external_value_input.ts @@ -18,8 +18,8 @@ import * as goog from '../../../closure/goog/goog.js'; goog.declareModuleId('Blockly.blockRendering.ExternalValueInput'); /* eslint-disable-next-line no-unused-vars */ -import type {Input} from '../../input.js'; -import type {ConstantProvider} from '../common/constants.js'; +import type {Input} from '../../input'; +import type {ConstantProvider} from '../common/constants'; import {InputConnection} from './input_connection.js'; import {Types} from './types.js'; diff --git a/core/renderers/measurables/field.ts b/core/renderers/measurables/field.ts index 39a5b24d804..e98d0ec36c4 100644 --- a/core/renderers/measurables/field.ts +++ b/core/renderers/measurables/field.ts @@ -18,9 +18,9 @@ import * as goog from '../../../closure/goog/goog.js'; goog.declareModuleId('Blockly.blockRendering.Field'); /* eslint-disable-next-line no-unused-vars */ -import type {Field as BlocklyField} from '../../field.js'; -import type {Input} from '../../input.js'; -import type {ConstantProvider} from '../common/constants.js'; +import type {Field as BlocklyField} from '../../field'; +import type {Input} from '../../input'; +import type {ConstantProvider} from '../common/constants'; import {Measurable} from './base.js'; import {Types} from './types.js'; diff --git a/core/renderers/measurables/icon.ts b/core/renderers/measurables/icon.ts index 80437c4fb31..cddf0db7172 100644 --- a/core/renderers/measurables/icon.ts +++ b/core/renderers/measurables/icon.ts @@ -18,8 +18,8 @@ import * as goog from '../../../closure/goog/goog.js'; goog.declareModuleId('Blockly.blockRendering.Icon'); /* eslint-disable-next-line no-unused-vars */ -import type {Icon as BlocklyIcon} from '../../icon.js'; -import type {ConstantProvider} from '../common/constants.js'; +import type {Icon as BlocklyIcon} from '../../icon'; +import type {ConstantProvider} from '../common/constants'; import {Measurable} from './base.js'; import {Types} from './types.js'; diff --git a/core/renderers/measurables/inline_input.ts b/core/renderers/measurables/inline_input.ts index ce24540d38c..7abf0d296a3 100644 --- a/core/renderers/measurables/inline_input.ts +++ b/core/renderers/measurables/inline_input.ts @@ -18,8 +18,8 @@ import * as goog from '../../../closure/goog/goog.js'; goog.declareModuleId('Blockly.blockRendering.InlineInput'); /* eslint-disable-next-line no-unused-vars */ -import type {Input} from '../../input.js'; -import type {ConstantProvider} from '../common/constants.js'; +import type {Input} from '../../input'; +import type {ConstantProvider} from '../common/constants'; import {InputConnection} from './input_connection.js'; import {Types} from './types.js'; diff --git a/core/renderers/measurables/statement_input.ts b/core/renderers/measurables/statement_input.ts index dad53205542..c15ed457385 100644 --- a/core/renderers/measurables/statement_input.ts +++ b/core/renderers/measurables/statement_input.ts @@ -18,8 +18,8 @@ import * as goog from '../../../closure/goog/goog.js'; goog.declareModuleId('Blockly.blockRendering.StatementInput'); /* eslint-disable-next-line no-unused-vars */ -import type {Input} from '../../input.js'; -import type {ConstantProvider} from '../common/constants.js'; +import type {Input} from '../../input'; +import type {ConstantProvider} from '../common/constants'; import {InputConnection} from './input_connection.js'; import {Types} from './types.js'; diff --git a/core/renderers/thrasos/info.ts b/core/renderers/thrasos/info.ts index 0d0a0ffd475..77b823e7ea5 100644 --- a/core/renderers/thrasos/info.ts +++ b/core/renderers/thrasos/info.ts @@ -17,15 +17,15 @@ import * as goog from '../../../closure/goog/goog.js'; goog.declareModuleId('Blockly.thrasos.RenderInfo'); -import type {BlockSvg} from '../../block_svg.js'; -import {RenderInfo as BaseRenderInfo} from '../common/info.js'; -import type {Measurable} from '../measurables/base.js'; -import type {BottomRow} from '../measurables/bottom_row.js'; -import type {Field} from '../measurables/field.js'; -import {InRowSpacer} from '../measurables/in_row_spacer.js'; -import type {Row} from '../measurables/row.js'; -import type {TopRow} from '../measurables/top_row.js'; -import {Types} from '../measurables/types.js'; +import type {BlockSvg} from '../../block_svg'; +import {RenderInfo as BaseRenderInfo} from '../common/info'; +import type {Measurable} from '../measurables/base'; +import type {BottomRow} from '../measurables/bottom_row'; +import type {Field} from '../measurables/field'; +import {InRowSpacer} from '../measurables/in_row_spacer'; +import type {Row} from '../measurables/row'; +import type {TopRow} from '../measurables/top_row'; +import {Types} from '../measurables/types'; import type {Renderer} from './renderer.js'; diff --git a/core/workspace.ts b/core/workspace.ts index 8ac2af06357..b0b08e51f62 100644 --- a/core/workspace.ts +++ b/core/workspace.ts @@ -18,26 +18,24 @@ goog.declareModuleId('Blockly.Workspace'); // Unused import preserved for side-effects. Remove if unneeded. import './connection_checker.js'; -import {Block} from './block.js'; -import type {BlocklyOptions} from './blockly_options.js'; -import type {ConnectionDB} from './connection_db.js'; -import type {Abstract} from './events/events_abstract.js'; -import * as eventUtils from './events/utils.js'; -import type {IASTNodeLocation} from './interfaces/i_ast_node_location.js'; -import type {IConnectionChecker} from './interfaces/i_connection_checker.js'; -import {Options} from './options.js'; -import * as registry from './registry.js'; -import * as arrayUtils from './utils/array.js'; -import * as idGenerator from './utils/idgenerator.js'; -import * as math from './utils/math.js'; -import type * as toolbox from './utils/toolbox.js'; -import {VariableMap} from './variable_map.js'; -import type {VariableModel} from './variable_model.js'; -import type {WorkspaceComment} from './workspace_comment.js'; - - -/** Database of all workspaces. */ -const WorkspaceDB_ = Object.create(null); +import {Block} from './block'; +import type {BlocklyOptions} from './blockly_options'; +import type {ConnectionDB} from './connection_db'; +import type {Abstract} from './events/events_abstract'; +import * as common from './common'; +import * as eventUtils from './events/utils'; +import type {IASTNodeLocation} from './interfaces/i_ast_node_location'; +import type {IConnectionChecker} from './interfaces/i_connection_checker'; +import {Options} from './options'; +import * as registry from './registry'; +import * as arrayUtils from './utils/array'; +import * as idGenerator from './utils/idgenerator'; +import * as math from './utils/math'; +import type * as toolbox from './utils/toolbox'; +import {VariableMap} from './variable_map'; +import type {VariableModel} from './variable_model'; +import type {WorkspaceComment} from './workspace_comment'; + /** * Class for a workspace. This is a data structure that contains blocks. @@ -112,7 +110,7 @@ export class Workspace implements IASTNodeLocation { /** @param opt_options Dictionary of options. */ constructor(opt_options?: Options) { this.id = idGenerator.genUid(); - WorkspaceDB_[this.id] = this; + common.registerWorkspace(this); this.options = opt_options || new Options(({} as BlocklyOptions)); this.RTL = !!this.options.RTL; this.horizontalLayout = !!this.options.horizontalLayout; @@ -145,7 +143,7 @@ export class Workspace implements IASTNodeLocation { this.listeners_.length = 0; this.clear(); // Remove from workspace database. - delete WorkspaceDB_[this.id]; + common.unregisterWorkpace(this); } /** @@ -771,25 +769,4 @@ export class Workspace implements IASTNodeLocation { setVariableMap(variableMap: VariableMap) { this.variableMap_ = variableMap; } - - /** - * Find the workspace with the specified ID. - * @param id ID of workspace to find. - * @return The sought after workspace or null if not found. - */ - static getById(id: string): Workspace|null { - return WorkspaceDB_[id] || null; - } - - /** - * Find all workspaces. - * @return Array of workspaces. - */ - static getAll(): Workspace[] { - const workspaces = []; - for (const workspaceId in WorkspaceDB_) { - workspaces.push(WorkspaceDB_[workspaceId]); - } - return workspaces; - } } From 7ebe9eb7e98d1f71e33f02c6cc462a785c027540 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Thu, 21 Jul 2022 17:15:27 +0000 Subject: [PATCH 02/44] remove preserved imports that aren't currently necessary (probably) --- core/block_svg.ts | 4 ++-- core/bubble.ts | 4 ++-- core/bubble_dragger.ts | 4 ++-- core/comment.ts | 6 +++--- core/connection.ts | 2 +- core/connection_db.ts | 2 +- core/extensions.ts | 2 +- core/field.ts | 4 ++-- core/flyout_vertical.ts | 4 ++-- core/gesture.ts | 2 +- core/interfaces/i_ast_node_location_with_block.ts | 2 +- core/interfaces/i_block_dragger.ts | 4 ++-- core/interfaces/i_bounded_element.ts | 2 +- core/interfaces/i_bubble.ts | 4 ++-- core/interfaces/i_collapsible_toolbox_item.ts | 2 +- core/interfaces/i_connection_checker.ts | 4 ++-- core/interfaces/i_delete_area.ts | 2 +- core/interfaces/i_drag_target.ts | 4 ++-- core/interfaces/i_flyout.ts | 8 ++++---- core/interfaces/i_keyboard_accessible.ts | 2 +- core/interfaces/i_metrics_manager.ts | 6 +++--- core/interfaces/i_positionable.ts | 4 ++-- core/interfaces/i_selectable_toolbox_item.ts | 2 +- core/interfaces/i_toolbox.ts | 8 ++++---- core/names.ts | 2 +- core/positionable_helpers.ts | 2 +- core/renderers/common/i_path_object.ts | 6 +++--- core/renderers/common/path_object.ts | 2 +- core/renderers/geras/highlighter.ts | 2 +- core/renderers/geras/path_object.ts | 2 +- core/renderers/geras/renderer.ts | 2 +- core/renderers/zelos/path_object.ts | 2 +- core/renderers/zelos/renderer.ts | 2 +- core/toolbox/toolbox.ts | 2 +- core/trashcan.ts | 2 +- core/utils/toolbox.ts | 4 ++-- core/workspace_svg.ts | 14 +++++++------- core/xml.ts | 8 ++++---- core/zoom_controls.ts | 2 +- 39 files changed, 71 insertions(+), 71 deletions(-) diff --git a/core/block_svg.ts b/core/block_svg.ts index f4aff257df5..c4911bab578 100644 --- a/core/block_svg.ts +++ b/core/block_svg.ts @@ -17,11 +17,11 @@ goog.declareModuleId('Blockly.BlockSvg'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import './theme.js'; +// import './theme'; // Unused import preserved for side-effects. Remove if unneeded. import './events/events_selected.js'; // Unused import preserved for side-effects. Remove if unneeded. -import './touch.js'; +// import './touch'; import {Block} from './block.js'; import * as blockAnimations from './block_animations.js'; diff --git a/core/bubble.ts b/core/bubble.ts index 1cdf60a2840..fa051c94a12 100644 --- a/core/bubble.ts +++ b/core/bubble.ts @@ -17,9 +17,9 @@ goog.declareModuleId('Blockly.Bubble'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import './metrics_manager.js'; +// import './metrics_manager'; // Unused import preserved for side-effects. Remove if unneeded. -import './workspace.js'; +// import './workspace'; import type {BlockDragSurfaceSvg} from './block_drag_surface.js'; import type {BlockSvg} from './block_svg.js'; diff --git a/core/bubble_dragger.ts b/core/bubble_dragger.ts index 719c80dee5f..ac7d05001cb 100644 --- a/core/bubble_dragger.ts +++ b/core/bubble_dragger.ts @@ -16,9 +16,9 @@ import * as goog from '../closure/goog/goog.js'; goog.declareModuleId('Blockly.BubbleDragger'); // Unused import preserved for side-effects. Remove if unneeded. -import './bubble.js'; +// import './bubble'; // Unused import preserved for side-effects. Remove if unneeded. -import './constants.js'; +// import './constants'; import type {BlockDragSurfaceSvg} from './block_drag_surface.js'; import {ComponentManager} from './component_manager.js'; diff --git a/core/comment.ts b/core/comment.ts index 01e47513432..91245b99ad4 100644 --- a/core/comment.ts +++ b/core/comment.ts @@ -17,16 +17,16 @@ goog.declareModuleId('Blockly.Comment'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import './block.js'; +// import './block'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import './workspace_svg.js'; +// import './workspace_svg'; // Unused import preserved for side-effects. Remove if unneeded. import './events/events_block_change.js'; // Unused import preserved for side-effects. Remove if unneeded. import './events/events_bubble_open.js'; // Unused import preserved for side-effects. Remove if unneeded. -import './warning.js'; +// import './warning'; import type {CommentModel} from './block.js'; import type {BlockSvg} from './block_svg.js'; diff --git a/core/connection.ts b/core/connection.ts index 5196ed29b07..a18d111dccd 100644 --- a/core/connection.ts +++ b/core/connection.ts @@ -16,7 +16,7 @@ import * as goog from '../closure/goog/goog.js'; goog.declareModuleId('Blockly.Connection'); // Unused import preserved for side-effects. Remove if unneeded. -import './constants.js'; +// import './constants'; import type {Block} from './block.js'; import {ConnectionType} from './connection_type.js'; diff --git a/core/connection_db.ts b/core/connection_db.ts index fd9cfc6f6a4..170479f4a2e 100644 --- a/core/connection_db.ts +++ b/core/connection_db.ts @@ -20,7 +20,7 @@ import * as goog from '../closure/goog/goog.js'; goog.declareModuleId('Blockly.ConnectionDB'); // Unused import preserved for side-effects. Remove if unneeded. -import './constants.js'; +// import './constants'; import {ConnectionType} from './connection_type.js'; import type {IConnectionChecker} from './interfaces/i_connection_checker.js'; diff --git a/core/extensions.ts b/core/extensions.ts index 9729dca5320..8ddd1ac77e2 100644 --- a/core/extensions.ts +++ b/core/extensions.ts @@ -22,7 +22,7 @@ import * as goog from '../closure/goog/goog.js'; goog.declareModuleId('Blockly.Extensions'); // Unused import preserved for side-effects. Remove if unneeded. -import './mutator.js'; +// import './mutator'; import type {Block} from './block.js'; import type {BlockSvg} from './block_svg.js'; diff --git a/core/field.ts b/core/field.ts index dd0a694a360..e47667cb51c 100644 --- a/core/field.ts +++ b/core/field.ts @@ -21,11 +21,11 @@ goog.declareModuleId('Blockly.Field'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import './shortcut_registry.js'; +// import './shortcut_registry'; // Unused import preserved for side-effects. Remove if unneeded. import './events/events_block_change.js'; // Unused import preserved for side-effects. Remove if unneeded. -import './gesture.js'; +// import './gesture'; import type {Block} from './block.js'; import type {BlockSvg} from './block_svg.js'; diff --git a/core/flyout_vertical.ts b/core/flyout_vertical.ts index 0e0d36e2dae..e41b00d2fad 100644 --- a/core/flyout_vertical.ts +++ b/core/flyout_vertical.ts @@ -16,9 +16,9 @@ import * as goog from '../closure/goog/goog.js'; goog.declareModuleId('Blockly.VerticalFlyout'); // Unused import preserved for side-effects. Remove if unneeded. -import './block.js'; +// import './block'; // Unused import preserved for side-effects. Remove if unneeded. -import './constants.js'; +// import './constants'; import * as browserEvents from './browser_events.js'; import * as dropDownDiv from './dropdowndiv.js'; diff --git a/core/gesture.ts b/core/gesture.ts index 7ee356cb1d8..a915f9d35f6 100644 --- a/core/gesture.ts +++ b/core/gesture.ts @@ -18,7 +18,7 @@ import * as goog from '../closure/goog/goog.js'; goog.declareModuleId('Blockly.Gesture'); // Unused import preserved for side-effects. Remove if unneeded. -import './block_dragger.js'; +// import './block_dragger'; // Unused import preserved for side-effects. Remove if unneeded. import './events/events_click.js'; diff --git a/core/interfaces/i_ast_node_location_with_block.ts b/core/interfaces/i_ast_node_location_with_block.ts index 89c9970f7c1..12ab7d073fc 100644 --- a/core/interfaces/i_ast_node_location_with_block.ts +++ b/core/interfaces/i_ast_node_location_with_block.ts @@ -19,7 +19,7 @@ goog.declareModuleId('Blockly.IASTNodeLocationWithBlock'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import '../block.js'; +// import '../block'; import type {IASTNodeLocation} from './i_ast_node_location.js'; diff --git a/core/interfaces/i_block_dragger.ts b/core/interfaces/i_block_dragger.ts index cf418838dce..550b063389d 100644 --- a/core/interfaces/i_block_dragger.ts +++ b/core/interfaces/i_block_dragger.ts @@ -17,10 +17,10 @@ goog.declareModuleId('Blockly.IBlockDragger'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import '../block_svg.js'; +// import '../block_svg'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import '../utils/coordinate.js'; +// import '../utils/coordinate'; /** diff --git a/core/interfaces/i_bounded_element.ts b/core/interfaces/i_bounded_element.ts index 10d27c3baf0..188f315af3f 100644 --- a/core/interfaces/i_bounded_element.ts +++ b/core/interfaces/i_bounded_element.ts @@ -17,7 +17,7 @@ goog.declareModuleId('Blockly.IBoundedElement'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import '../utils/rect.js'; +// import '../utils/rect'; /** diff --git a/core/interfaces/i_bubble.ts b/core/interfaces/i_bubble.ts index 6a2e6e0b99d..6d8ea7bcd09 100644 --- a/core/interfaces/i_bubble.ts +++ b/core/interfaces/i_bubble.ts @@ -17,10 +17,10 @@ goog.declareModuleId('Blockly.IBubble'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import '../block_drag_surface.js'; +// import '../block_drag_surface'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import '../utils/coordinate.js'; +// import '../utils/coordinate'; import type {IContextMenu} from './i_contextmenu.js'; import type {IDraggable} from './i_draggable.js'; diff --git a/core/interfaces/i_collapsible_toolbox_item.ts b/core/interfaces/i_collapsible_toolbox_item.ts index f2cc54a8c0f..a0ff9a09349 100644 --- a/core/interfaces/i_collapsible_toolbox_item.ts +++ b/core/interfaces/i_collapsible_toolbox_item.ts @@ -18,7 +18,7 @@ goog.declareModuleId('Blockly.ICollapsibleToolboxItem'); /* eslint-disable-next-line no-unused-vars */ /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import './i_toolbox_item.js'; +// import './i_toolbox_item'; import type {ISelectableToolboxItem} from './i_selectable_toolbox_item'; diff --git a/core/interfaces/i_connection_checker.ts b/core/interfaces/i_connection_checker.ts index 77585922bc9..ecd04ddc854 100644 --- a/core/interfaces/i_connection_checker.ts +++ b/core/interfaces/i_connection_checker.ts @@ -19,10 +19,10 @@ goog.declareModuleId('Blockly.IConnectionChecker'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import '../connection.js'; +// import '../connection'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import '../rendered_connection.js'; +// import '../rendered_connection'; /** diff --git a/core/interfaces/i_delete_area.ts b/core/interfaces/i_delete_area.ts index b0fec86e10e..a99c57ffdfb 100644 --- a/core/interfaces/i_delete_area.ts +++ b/core/interfaces/i_delete_area.ts @@ -20,7 +20,7 @@ goog.declareModuleId('Blockly.IDeleteArea'); /* eslint-disable-next-line no-unused-vars */ /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import './i_draggable.js'; +// import './i_draggable'; import type {IDragTarget} from './i_drag_target'; diff --git a/core/interfaces/i_drag_target.ts b/core/interfaces/i_drag_target.ts index c66f7f8e0d7..490e28f3b2f 100644 --- a/core/interfaces/i_drag_target.ts +++ b/core/interfaces/i_drag_target.ts @@ -20,10 +20,10 @@ goog.declareModuleId('Blockly.IDragTarget'); /* eslint-disable-next-line no-unused-vars */ /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import './i_draggable.js'; +// import './i_draggable'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import '../utils/rect.js'; +// import '../utils/rect'; import type {IComponent} from './i_component'; diff --git a/core/interfaces/i_flyout.ts b/core/interfaces/i_flyout.ts index 3ef49c71923..4bf210d4fd0 100644 --- a/core/interfaces/i_flyout.ts +++ b/core/interfaces/i_flyout.ts @@ -17,16 +17,16 @@ goog.declareModuleId('Blockly.IFlyout'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import '../utils/toolbox.js'; +// import '../utils/toolbox'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import '../block_svg.js'; +// import '../block_svg'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import '../utils/coordinate.js'; +// import '../utils/coordinate'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import '../utils/svg.js'; +// import '../utils/svg'; import type {WorkspaceSvg} from '../workspace_svg.js'; diff --git a/core/interfaces/i_keyboard_accessible.ts b/core/interfaces/i_keyboard_accessible.ts index f31ef205dba..33c950e2625 100644 --- a/core/interfaces/i_keyboard_accessible.ts +++ b/core/interfaces/i_keyboard_accessible.ts @@ -17,7 +17,7 @@ goog.declareModuleId('Blockly.IKeyboardAccessible'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import '../shortcut_registry.js'; +// import '../shortcut_registry'; /** diff --git a/core/interfaces/i_metrics_manager.ts b/core/interfaces/i_metrics_manager.ts index 3c1bc85dc5c..ad04829744a 100644 --- a/core/interfaces/i_metrics_manager.ts +++ b/core/interfaces/i_metrics_manager.ts @@ -17,13 +17,13 @@ goog.declareModuleId('Blockly.IMetricsManager'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import '../metrics_manager.js'; +// import '../metrics_manager'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import '../utils/metrics.js'; +// import '../utils/metrics'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import '../utils/size.js'; +// import '../utils/size'; /** diff --git a/core/interfaces/i_positionable.ts b/core/interfaces/i_positionable.ts index fb32cef0e0b..c44c0ae8706 100644 --- a/core/interfaces/i_positionable.ts +++ b/core/interfaces/i_positionable.ts @@ -18,10 +18,10 @@ goog.declareModuleId('Blockly.IPositionable'); /* eslint-disable-next-line no-unused-vars */ /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import '../metrics_manager.js'; +// import '../metrics_manager'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import '../utils/rect.js'; +// import '../utils/rect'; import type {IComponent} from './i_component'; diff --git a/core/interfaces/i_selectable_toolbox_item.ts b/core/interfaces/i_selectable_toolbox_item.ts index b2756ca3ebb..f992cb4833d 100644 --- a/core/interfaces/i_selectable_toolbox_item.ts +++ b/core/interfaces/i_selectable_toolbox_item.ts @@ -17,7 +17,7 @@ goog.declareModuleId('Blockly.ISelectableToolboxItem'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import '../utils/toolbox.js'; +// import '../utils/toolbox'; import type {IToolboxItem} from './i_toolbox_item.js'; diff --git a/core/interfaces/i_toolbox.ts b/core/interfaces/i_toolbox.ts index 2ce3e421e6d..0470af370cb 100644 --- a/core/interfaces/i_toolbox.ts +++ b/core/interfaces/i_toolbox.ts @@ -17,16 +17,16 @@ goog.declareModuleId('Blockly.IToolbox'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import '../utils/toolbox.js'; +// import '../utils/toolbox'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import './i_flyout.js'; +// import './i_flyout'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import './i_toolbox_item.js'; +// import './i_toolbox_item'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import '../workspace_svg.js'; +// import '../workspace_svg'; import type {IRegistrable} from './i_registrable.js'; diff --git a/core/names.ts b/core/names.ts index 5d831aa5d9b..5650051fde2 100644 --- a/core/names.ts +++ b/core/names.ts @@ -16,7 +16,7 @@ import * as goog from '../closure/goog/goog.js'; goog.declareModuleId('Blockly.Names'); // Unused import preserved for side-effects. Remove if unneeded. -import './procedures.js'; +// import './procedures'; import {Msg} from './msg.js'; import * as Procedures from './procedures.js'; diff --git a/core/positionable_helpers.ts b/core/positionable_helpers.ts index 6b93466fe39..654d8e7ebd1 100644 --- a/core/positionable_helpers.ts +++ b/core/positionable_helpers.ts @@ -17,7 +17,7 @@ goog.declareModuleId('Blockly.uiPosition'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import './metrics_manager.js'; +// import './metrics_manager'; import type {UiMetrics} from './metrics_manager.js'; import {Scrollbar} from './scrollbar.js'; diff --git a/core/renderers/common/i_path_object.ts b/core/renderers/common/i_path_object.ts index 86eac963e8e..58816e51623 100644 --- a/core/renderers/common/i_path_object.ts +++ b/core/renderers/common/i_path_object.ts @@ -19,13 +19,13 @@ goog.declareModuleId('Blockly.blockRendering.IPathObject'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import '../../block_svg.js'; +// import '../../block_svg'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import '../../connection.js'; +// import '../../connection'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import '../../theme.js'; +// import '../../theme'; import type {BlockStyle} from '../../theme.js'; diff --git a/core/renderers/common/path_object.ts b/core/renderers/common/path_object.ts index d8e85b995db..b1c03e5afb5 100644 --- a/core/renderers/common/path_object.ts +++ b/core/renderers/common/path_object.ts @@ -17,7 +17,7 @@ goog.declareModuleId('Blockly.blockRendering.PathObject'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import '../../theme.js'; +// import '../../theme'; import type {BlockSvg} from '../../block_svg.js'; import type {Connection} from '../../connection.js'; diff --git a/core/renderers/geras/highlighter.ts b/core/renderers/geras/highlighter.ts index bd783bcdbe5..09a80edc4de 100644 --- a/core/renderers/geras/highlighter.ts +++ b/core/renderers/geras/highlighter.ts @@ -19,7 +19,7 @@ goog.declareModuleId('Blockly.geras.Highlighter'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import './renderer.js'; +// import './renderer'; import * as svgPaths from '../../utils/svg_paths.js'; import type {ConstantProvider} from '../common/constants.js'; diff --git a/core/renderers/geras/path_object.ts b/core/renderers/geras/path_object.ts index 92a765ee4a9..6112b518add 100644 --- a/core/renderers/geras/path_object.ts +++ b/core/renderers/geras/path_object.ts @@ -17,7 +17,7 @@ goog.declareModuleId('Blockly.geras.PathObject'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import '../../theme.js'; +// import '../../theme'; import type {BlockSvg} from '../../block_svg'; import type {BlockStyle} from '../../theme'; diff --git a/core/renderers/geras/renderer.ts b/core/renderers/geras/renderer.ts index 3b02dbc71e0..fc6b0a0d1f1 100644 --- a/core/renderers/geras/renderer.ts +++ b/core/renderers/geras/renderer.ts @@ -17,7 +17,7 @@ goog.declareModuleId('Blockly.geras.Renderer'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import '../common/constants.js'; +// import '../common/constants'; import type {BlockSvg} from '../../block_svg'; import type {BlockStyle, Theme} from '../../theme'; diff --git a/core/renderers/zelos/path_object.ts b/core/renderers/zelos/path_object.ts index 80800fea1e1..9eeb637e37d 100644 --- a/core/renderers/zelos/path_object.ts +++ b/core/renderers/zelos/path_object.ts @@ -17,7 +17,7 @@ goog.declareModuleId('Blockly.zelos.PathObject'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import '../../theme.js'; +// import '../../theme'; import type {BlockSvg} from '../../block_svg.js'; import type {Connection} from '../../connection.js'; diff --git a/core/renderers/zelos/renderer.ts b/core/renderers/zelos/renderer.ts index eb4e606534a..d5494ce3ada 100644 --- a/core/renderers/zelos/renderer.ts +++ b/core/renderers/zelos/renderer.ts @@ -17,7 +17,7 @@ goog.declareModuleId('Blockly.zelos.Renderer'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import '../../theme.js'; +// import '../../theme'; import type {BlockSvg} from '../../block_svg.js'; import type {Connection} from '../../connection.js'; diff --git a/core/toolbox/toolbox.ts b/core/toolbox/toolbox.ts index be8d16f41eb..ee643f57ebd 100644 --- a/core/toolbox/toolbox.ts +++ b/core/toolbox/toolbox.ts @@ -17,7 +17,7 @@ goog.declareModuleId('Blockly.Toolbox'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import '../shortcut_registry.js'; +// import '../shortcut_registry'; // Unused import preserved for side-effects. Remove if unneeded. import '../events/events_toolbox_item_select.js'; diff --git a/core/trashcan.ts b/core/trashcan.ts index f12c727433a..90e1e194b4a 100644 --- a/core/trashcan.ts +++ b/core/trashcan.ts @@ -17,7 +17,7 @@ goog.declareModuleId('Blockly.Trashcan'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import './metrics_manager.js'; +// import './metrics_manager'; // Unused import preserved for side-effects. Remove if unneeded. import './events/events_trashcan_open.js'; diff --git a/core/utils/toolbox.ts b/core/utils/toolbox.ts index 77c583159ea..f1d8e1beda6 100644 --- a/core/utils/toolbox.ts +++ b/core/utils/toolbox.ts @@ -17,10 +17,10 @@ goog.declareModuleId('Blockly.utils.toolbox'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import '../toolbox/category.js'; +// import '../toolbox/category'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import '../toolbox/separator.js'; +// import '../toolbox/separator'; import type {ConnectionState} from '../serialization/blocks.js'; import type {CssConfig as CategoryCssConfig} from '../toolbox/category.js'; diff --git a/core/workspace_svg.ts b/core/workspace_svg.ts index 2ef9185f8a4..5dcbb0c3aa7 100644 --- a/core/workspace_svg.ts +++ b/core/workspace_svg.ts @@ -17,19 +17,19 @@ goog.declareModuleId('Blockly.WorkspaceSvg'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import './procedures.js'; +// import './procedures'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import './variables.js'; +// import './variables'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import './variables_dynamic.js'; +// import './variables_dynamic'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import './rendered_connection.js'; +// import './rendered_connection'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import './zoom_controls.js'; +// import './zoom_controls'; // Unused import preserved for side-effects. Remove if unneeded. import './events/events_block_create.js'; // Unused import preserved for side-effects. Remove if unneeded. @@ -37,9 +37,9 @@ import './events/events_theme_change.js'; // Unused import preserved for side-effects. Remove if unneeded. import './events/events_viewport.js'; // Unused import preserved for side-effects. Remove if unneeded. -import './metrics_manager.js'; +// import './metrics_manager'; // Unused import preserved for side-effects. Remove if unneeded. -import './msg.js'; +// import './msg'; import type {Block} from './block.js'; import type {BlockDragSurfaceSvg} from './block_drag_surface.js'; diff --git a/core/xml.ts b/core/xml.ts index f37a87f60ad..9390733f077 100644 --- a/core/xml.ts +++ b/core/xml.ts @@ -16,13 +16,13 @@ import * as goog from '../closure/goog/goog.js'; goog.declareModuleId('Blockly.Xml'); // Unused import preserved for side-effects. Remove if unneeded. -import './comment.js'; +// import './comment'; // Unused import preserved for side-effects. Remove if unneeded. -import './variables.js'; +// import './variables'; // Unused import preserved for side-effects. Remove if unneeded. -import './workspace_comment.js'; +// import './workspace_comment'; // Unused import preserved for side-effects. Remove if unneeded. -import './workspace_comment_svg.js'; +// import './workspace_comment_svg'; import type {Block} from './block.js'; import type {BlockSvg} from './block_svg.js'; diff --git a/core/zoom_controls.ts b/core/zoom_controls.ts index a3af6c75651..195c742c260 100644 --- a/core/zoom_controls.ts +++ b/core/zoom_controls.ts @@ -17,7 +17,7 @@ goog.declareModuleId('Blockly.ZoomControls'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -import './metrics_manager.js'; +// import './metrics_manager'; // Unused import preserved for side-effects. Remove if unneeded. import './events/events_click.js'; From c1c37d143e2953c6c93aebaf7752989119011d43 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Thu, 21 Jul 2022 17:36:52 +0000 Subject: [PATCH 03/44] fix circular dependency with workspaces and block using stub --- core/blockly.ts | 9 +++ core/workspace.ts | 6 +- core/workspace_svg.ts | 129 +++++++++++++++++++++--------------------- 3 files changed, 77 insertions(+), 67 deletions(-) diff --git a/core/blockly.ts b/core/blockly.ts index 20cfb36909a..6e5c403d312 100644 --- a/core/blockly.ts +++ b/core/blockly.ts @@ -571,6 +571,15 @@ export const VARIABLE_DYNAMIC_CATEGORY_NAME: string = export const PROCEDURE_CATEGORY_NAME: string = (Procedures as AnyDuringMigration).CATEGORY_NAME; +// I hate this so much. +Workspace.prototype.newBlock = function (prototypeName: string, opt_id?: string): Block { + return new Block(this, prototypeName, opt_id); +} + +WorkspaceSvg.prototype.newBlock = function (prototypeName: string, opt_id?: string): BlockSvg { + return new BlockSvg(this, prototypeName, opt_id); +} + // Re-export submodules that no longer declareLegacyNamespace. export {browserEvents}; export {ContextMenu}; diff --git a/core/workspace.ts b/core/workspace.ts index b0b08e51f62..e7727735104 100644 --- a/core/workspace.ts +++ b/core/workspace.ts @@ -18,7 +18,7 @@ goog.declareModuleId('Blockly.Workspace'); // Unused import preserved for side-effects. Remove if unneeded. import './connection_checker.js'; -import {Block} from './block'; +import type {Block} from './block'; import type {BlocklyOptions} from './blockly_options'; import type {ConnectionDB} from './connection_db'; import type {Abstract} from './events/events_abstract'; @@ -508,8 +508,8 @@ export class Workspace implements IASTNodeLocation { * ID. * @return The created block. */ - newBlock(prototypeName: string, opt_id?: string): Block { - return new Block(this, prototypeName, opt_id); + newBlock(prototypeName: string, opt_id?: string): AnyDuringMigration { + return {}; } /** diff --git a/core/workspace_svg.ts b/core/workspace_svg.ts index 5dcbb0c3aa7..590447713b5 100644 --- a/core/workspace_svg.ts +++ b/core/workspace_svg.ts @@ -41,67 +41,67 @@ import './events/events_viewport.js'; // Unused import preserved for side-effects. Remove if unneeded. // import './msg'; -import type {Block} from './block.js'; -import type {BlockDragSurfaceSvg} from './block_drag_surface.js'; -import {BlockSvg} from './block_svg.js'; -import type {BlocklyOptions} from './blockly_options.js'; -import * as browserEvents from './browser_events.js'; -import * as common from './common.js'; -import {ComponentManager} from './component_manager.js'; -import {config} from './config.js'; -import {ConnectionDB} from './connection_db.js'; -import * as ContextMenu from './contextmenu.js'; -import {ContextMenuRegistry} from './contextmenu_registry.js'; -import * as dropDownDiv from './dropdowndiv.js'; -import * as eventUtils from './events/utils.js'; -import type {FlyoutButton} from './flyout_button.js'; -import {Gesture} from './gesture.js'; -import {Grid} from './grid.js'; -import type {IASTNodeLocationSvg} from './interfaces/i_ast_node_location_svg.js'; -import type {IBoundedElement} from './interfaces/i_bounded_element.js'; -import type {ICopyable} from './interfaces/i_copyable.js'; -import type {IDragTarget} from './interfaces/i_drag_target.js'; -import type {IFlyout} from './interfaces/i_flyout.js'; -import type {IMetricsManager} from './interfaces/i_metrics_manager.js'; -import type {IToolbox} from './interfaces/i_toolbox.js'; -import type {Cursor} from './keyboard_nav/cursor.js'; -import type {Marker} from './keyboard_nav/marker.js'; -import {MarkerManager} from './marker_manager.js'; -import {Options} from './options.js'; -import * as Procedures from './procedures.js'; -import * as registry from './registry.js'; -import * as blockRendering from './renderers/common/block_rendering.js'; -import type {Renderer} from './renderers/common/renderer.js'; -import type {ScrollbarPair} from './scrollbar_pair.js'; -import * as blocks from './serialization/blocks.js'; -import type {Theme} from './theme.js'; -import {Classic} from './theme/classic.js'; -import {ThemeManager} from './theme_manager.js'; -import * as Tooltip from './tooltip.js'; -import {TouchGesture} from './touch_gesture.js'; -import {Trashcan} from './trashcan.js'; -import * as utils from './utils.js'; -import * as arrayUtils from './utils/array.js'; -import {Coordinate} from './utils/coordinate.js'; -import * as dom from './utils/dom.js'; -import type {Metrics} from './utils/metrics.js'; -import {Rect} from './utils/rect.js'; -import {Size} from './utils/size.js'; -import {Svg} from './utils/svg.js'; -import * as svgMath from './utils/svg_math.js'; -import * as toolbox from './utils/toolbox.js'; -import * as userAgent from './utils/useragent.js'; -import type {VariableModel} from './variable_model.js'; -import * as Variables from './variables.js'; -import * as VariablesDynamic from './variables_dynamic.js'; -import * as WidgetDiv from './widgetdiv.js'; -import {Workspace} from './workspace.js'; -import {WorkspaceAudio} from './workspace_audio.js'; -import {WorkspaceComment} from './workspace_comment.js'; -import {WorkspaceCommentSvg} from './workspace_comment_svg.js'; -import type {WorkspaceDragSurfaceSvg} from './workspace_drag_surface_svg.js'; -import * as Xml from './xml.js'; -import {ZoomControls} from './zoom_controls.js'; +import type {Block} from './block'; +import type {BlockDragSurfaceSvg} from './block_drag_surface'; +import type {BlockSvg} from './block_svg'; +import type {BlocklyOptions} from './blockly_options'; +import * as browserEvents from './browser_events'; +import * as common from './common'; +import {ComponentManager} from './component_manager'; +import {config} from './config'; +import {ConnectionDB} from './connection_db'; +import * as ContextMenu from './contextmenu'; +import {ContextMenuRegistry} from './contextmenu_registry'; +import * as dropDownDiv from './dropdowndiv'; +import * as eventUtils from './events/utils'; +import type {FlyoutButton} from './flyout_button'; +import {Gesture} from './gesture'; +import {Grid} from './grid'; +import type {IASTNodeLocationSvg} from './interfaces/i_ast_node_location_svg'; +import type {IBoundedElement} from './interfaces/i_bounded_element'; +import type {ICopyable} from './interfaces/i_copyable'; +import type {IDragTarget} from './interfaces/i_drag_target'; +import type {IFlyout} from './interfaces/i_flyout'; +import type {IMetricsManager} from './interfaces/i_metrics_manager'; +import type {IToolbox} from './interfaces/i_toolbox'; +import type {Cursor} from './keyboard_nav/cursor'; +import type {Marker} from './keyboard_nav/marker'; +import {MarkerManager} from './marker_manager'; +import {Options} from './options'; +import * as Procedures from './procedures'; +import * as registry from './registry'; +import * as blockRendering from './renderers/common/block_rendering'; +import type {Renderer} from './renderers/common/renderer'; +import type {ScrollbarPair} from './scrollbar_pair'; +import * as blocks from './serialization/blocks'; +import type {Theme} from './theme'; +import {Classic} from './theme/classic'; +import {ThemeManager} from './theme_manager'; +import * as Tooltip from './tooltip'; +import {TouchGesture} from './touch_gesture'; +import {Trashcan} from './trashcan'; +import * as utils from './utils'; +import * as arrayUtils from './utils/array'; +import {Coordinate} from './utils/coordinate'; +import * as dom from './utils/dom'; +import type {Metrics} from './utils/metrics'; +import {Rect} from './utils/rect'; +import {Size} from './utils/size'; +import {Svg} from './utils/svg'; +import * as svgMath from './utils/svg_math'; +import * as toolbox from './utils/toolbox'; +import * as userAgent from './utils/useragent'; +import type {VariableModel} from './variable_model'; +import * as Variables from './variables'; +import * as VariablesDynamic from './variables_dynamic'; +import * as WidgetDiv from './widgetdiv'; +import {Workspace} from './workspace'; +import {WorkspaceAudio} from './workspace_audio'; +import {WorkspaceComment} from './workspace_comment'; +import {WorkspaceCommentSvg} from './workspace_comment_svg'; +import type {WorkspaceDragSurfaceSvg} from './workspace_drag_surface_svg'; +import * as Xml from './xml'; +import {ZoomControls} from './zoom_controls'; /** Margin around the top/bottom/left/right after a zoomToFit call. */ @@ -1662,8 +1662,8 @@ export class WorkspaceSvg extends Workspace implements IASTNodeLocationSvg { * ID. * @return The created block. */ - override newBlock(prototypeName: string, opt_id?: string): BlockSvg { - return new BlockSvg(this, prototypeName, opt_id); + override newBlock(prototypeName: string, opt_id?: string): AnyDuringMigration { + return {}; } /** @@ -1856,7 +1856,8 @@ export class WorkspaceSvg extends Workspace implements IASTNodeLocationSvg { // Start at 1 since the 0th block was used for initialization. for (let i = 1; i < topElements.length; i++) { const topElement = topElements[i]; - if (topElement instanceof BlockSvg && topElement.isInsertionMarker()) { + if ((topElement as AnyDuringMigration).isInsertionmarker && + (topElement as AnyDuringMigration).isInsertionMarker()) { continue; } const blockBoundary = topElement.getBoundingRectangle(); From cb6f6887d11956729fae5ca087e9c425411ffc12 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Thu, 21 Jul 2022 17:42:20 +0000 Subject: [PATCH 04/44] fix dependency between variables and xml by moving function to utils --- core/utils/xml.ts | 9 +++++++++ core/variables.ts | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/core/utils/xml.ts b/core/utils/xml.ts index 169e7808669..74bcc84efe6 100644 --- a/core/utils/xml.ts +++ b/core/utils/xml.ts @@ -95,3 +95,12 @@ export function domToText(dom: Node): string { const oSerializer = new XMLSerializer(); return oSerializer.serializeToString(dom); } + +export function textToDom(text: string): Element { + const doc = textToDomDocument(text); + if (!doc || !doc.documentElement || + doc.getElementsByTagName('parsererror').length) { + throw Error('textToDom was unable to parse: ' + text); + } + return doc.documentElement; +} \ No newline at end of file diff --git a/core/variables.ts b/core/variables.ts index f3571530562..773dd3103c5 100644 --- a/core/variables.ts +++ b/core/variables.ts @@ -175,7 +175,7 @@ export function flyoutCategoryBlocks(workspace: Workspace): Element[] { // assignable to parameter of type 'Node'. block.appendChild( generateVariableFieldDom(mostRecentVariable) as AnyDuringMigration); - const value = Xml.textToDom( + const value = utilsXml.textToDom( '' + '' + '1' + From 1907e8069aa96da153dc5bfd1040e6804c41ee97 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Thu, 21 Jul 2022 22:12:45 +0000 Subject: [PATCH 05/44] add stub for trashcan as well --- core/blockly.ts | 4 ++++ core/workspace_svg.ts | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/core/blockly.ts b/core/blockly.ts index 6e5c403d312..8bbb8a20f88 100644 --- a/core/blockly.ts +++ b/core/blockly.ts @@ -580,6 +580,10 @@ WorkspaceSvg.prototype.newBlock = function (prototypeName: string, opt_id?: stri return new BlockSvg(this, prototypeName, opt_id); } +// WorkspaceSvg.newTrashcan = function(workspace: WorkspaceSvg): Trashcan { +// return new Trashcan(workspace); +// } + // Re-export submodules that no longer declareLegacyNamespace. export {browserEvents}; export {ContextMenu}; diff --git a/core/workspace_svg.ts b/core/workspace_svg.ts index 590447713b5..0fe93c7d2ae 100644 --- a/core/workspace_svg.ts +++ b/core/workspace_svg.ts @@ -79,7 +79,7 @@ import {Classic} from './theme/classic'; import {ThemeManager} from './theme_manager'; import * as Tooltip from './tooltip'; import {TouchGesture} from './touch_gesture'; -import {Trashcan} from './trashcan'; +import type {Trashcan} from './trashcan'; import * as utils from './utils'; import * as arrayUtils from './utils/array'; import {Coordinate} from './utils/coordinate'; @@ -954,11 +954,18 @@ export class WorkspaceSvg extends Workspace implements IASTNodeLocationSvg { * @internal */ addTrashcan() { - this.trashcan = new Trashcan(this); + this.trashcan = WorkspaceSvg.newTrashcan(this); const svgTrashcan = this.trashcan.createDom(); this.svgGroup_.insertBefore(svgTrashcan, this.svgBlockCanvas_); } + /** + * @internal + */ + static newTrashcan(workspace: WorkspaceSvg): AnyDuringMigration { + return {}; + } + /** * Add zoom controls. * @internal From beb152191ca17bcf6ff503b256ca003b650388c3 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Fri, 22 Jul 2022 15:34:42 +0000 Subject: [PATCH 06/44] fix line endings from rebase --- core/block_svg.ts | 4 +- core/bubble.ts | 4 +- core/bubble_dragger.ts | 4 +- core/comment.ts | 6 +- core/connection.ts | 2 +- core/connection_db.ts | 2 +- core/events/events_abstract.ts | 4 +- core/events/utils.ts | 12 +- core/extensions.ts | 2 +- core/field.ts | 4 +- core/flyout_vertical.ts | 4 +- core/gesture.ts | 40 ++-- .../i_ast_node_location_with_block.ts | 2 +- core/interfaces/i_block_dragger.ts | 4 +- core/interfaces/i_bounded_element.ts | 2 +- core/interfaces/i_bubble.ts | 4 +- core/interfaces/i_collapsible_toolbox_item.ts | 4 +- core/interfaces/i_connection_checker.ts | 4 +- core/interfaces/i_copyable.ts | 4 +- core/interfaces/i_delete_area.ts | 4 +- core/interfaces/i_drag_target.ts | 6 +- core/interfaces/i_flyout.ts | 8 +- core/interfaces/i_keyboard_accessible.ts | 2 +- core/interfaces/i_metrics_manager.ts | 6 +- core/interfaces/i_positionable.ts | 6 +- core/interfaces/i_selectable.ts | 4 +- core/interfaces/i_selectable_toolbox_item.ts | 2 +- core/interfaces/i_serializer.ts | 2 +- core/interfaces/i_toolbox.ts | 8 +- core/keyboard_nav/marker.ts | 2 +- core/names.ts | 2 +- core/positionable_helpers.ts | 2 +- core/procedures.ts | 30 +-- core/renderers/common/i_path_object.ts | 6 +- core/renderers/common/path_object.ts | 2 +- core/renderers/geras/drawer.ts | 10 +- core/renderers/geras/highlighter.ts | 8 +- core/renderers/geras/info.ts | 26 +-- .../geras/measurables/inline_input.ts | 8 +- .../geras/measurables/statement_input.ts | 8 +- core/renderers/geras/path_object.ts | 16 +- core/renderers/geras/renderer.ts | 12 +- core/renderers/measurables/connection.ts | 4 +- .../measurables/external_value_input.ts | 4 +- core/renderers/measurables/field.ts | 6 +- core/renderers/measurables/icon.ts | 4 +- core/renderers/measurables/inline_input.ts | 4 +- core/renderers/measurables/statement_input.ts | 4 +- core/renderers/thrasos/info.ts | 18 +- core/renderers/zelos/path_object.ts | 2 +- core/renderers/zelos/renderer.ts | 2 +- core/toolbox/toolbox.ts | 2 +- core/trashcan.ts | 2 +- core/utils/toolbox.ts | 4 +- core/workspace.ts | 34 ++-- core/workspace_svg.ts | 138 ++++++------- core/xml.ts | 8 +- core/zoom_controls.ts | 2 +- scripts/gulpfiles/chunks.json | 184 +++++++++--------- 59 files changed, 357 insertions(+), 357 deletions(-) diff --git a/core/block_svg.ts b/core/block_svg.ts index c4911bab578..05380675ee4 100644 --- a/core/block_svg.ts +++ b/core/block_svg.ts @@ -17,11 +17,11 @@ goog.declareModuleId('Blockly.BlockSvg'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import './theme'; +// import './theme.js'; // Unused import preserved for side-effects. Remove if unneeded. import './events/events_selected.js'; // Unused import preserved for side-effects. Remove if unneeded. -// import './touch'; +// import './touch.js'; import {Block} from './block.js'; import * as blockAnimations from './block_animations.js'; diff --git a/core/bubble.ts b/core/bubble.ts index fa051c94a12..af9a57f5253 100644 --- a/core/bubble.ts +++ b/core/bubble.ts @@ -17,9 +17,9 @@ goog.declareModuleId('Blockly.Bubble'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import './metrics_manager'; +// import './metrics_manager.js'; // Unused import preserved for side-effects. Remove if unneeded. -// import './workspace'; +// import './workspace.js'; import type {BlockDragSurfaceSvg} from './block_drag_surface.js'; import type {BlockSvg} from './block_svg.js'; diff --git a/core/bubble_dragger.ts b/core/bubble_dragger.ts index ac7d05001cb..d2379808207 100644 --- a/core/bubble_dragger.ts +++ b/core/bubble_dragger.ts @@ -16,9 +16,9 @@ import * as goog from '../closure/goog/goog.js'; goog.declareModuleId('Blockly.BubbleDragger'); // Unused import preserved for side-effects. Remove if unneeded. -// import './bubble'; +// import './bubble.js'; // Unused import preserved for side-effects. Remove if unneeded. -// import './constants'; +// import './constants.js'; import type {BlockDragSurfaceSvg} from './block_drag_surface.js'; import {ComponentManager} from './component_manager.js'; diff --git a/core/comment.ts b/core/comment.ts index 91245b99ad4..c066ff4b283 100644 --- a/core/comment.ts +++ b/core/comment.ts @@ -17,16 +17,16 @@ goog.declareModuleId('Blockly.Comment'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import './block'; +// import './block.js'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import './workspace_svg'; +// import './workspace_svg.js'; // Unused import preserved for side-effects. Remove if unneeded. import './events/events_block_change.js'; // Unused import preserved for side-effects. Remove if unneeded. import './events/events_bubble_open.js'; // Unused import preserved for side-effects. Remove if unneeded. -// import './warning'; +// import './warning.js'; import type {CommentModel} from './block.js'; import type {BlockSvg} from './block_svg.js'; diff --git a/core/connection.ts b/core/connection.ts index a18d111dccd..07d6c891825 100644 --- a/core/connection.ts +++ b/core/connection.ts @@ -16,7 +16,7 @@ import * as goog from '../closure/goog/goog.js'; goog.declareModuleId('Blockly.Connection'); // Unused import preserved for side-effects. Remove if unneeded. -// import './constants'; +// import './constants.js'; import type {Block} from './block.js'; import {ConnectionType} from './connection_type.js'; diff --git a/core/connection_db.ts b/core/connection_db.ts index 170479f4a2e..e6421376425 100644 --- a/core/connection_db.ts +++ b/core/connection_db.ts @@ -20,7 +20,7 @@ import * as goog from '../closure/goog/goog.js'; goog.declareModuleId('Blockly.ConnectionDB'); // Unused import preserved for side-effects. Remove if unneeded. -// import './constants'; +// import './constants.js'; import {ConnectionType} from './connection_type.js'; import type {IConnectionChecker} from './interfaces/i_connection_checker.js'; diff --git a/core/events/events_abstract.ts b/core/events/events_abstract.ts index 9651cd6ea03..51bec340642 100644 --- a/core/events/events_abstract.ts +++ b/core/events/events_abstract.ts @@ -17,8 +17,8 @@ import * as goog from '../../closure/goog/goog.js'; goog.declareModuleId('Blockly.Events.Abstract'); -import * as common from '../common'; -import type {Workspace} from '../workspace'; +import * as common from '../common.js'; +import type {Workspace} from '../workspace.js'; import * as eventUtils from './utils.js'; diff --git a/core/events/utils.ts b/core/events/utils.ts index a169f72f72c..eb906eac5c7 100644 --- a/core/events/utils.ts +++ b/core/events/utils.ts @@ -17,12 +17,12 @@ import * as goog from '../../closure/goog/goog.js'; goog.declareModuleId('Blockly.Events.utils'); -import type {Block} from '../block'; -import * as common from '../common'; -import * as registry from '../registry'; -import * as idGenerator from '../utils/idgenerator'; -import type {Workspace} from '../workspace'; -import type {WorkspaceSvg} from '../workspace_svg'; +import type {Block} from '../block.js'; +import * as common from '../common.js'; +import * as registry from '../registry.js'; +import * as idGenerator from '../utils/idgenerator.js'; +import type {Workspace} from '../workspace.js'; +import type {WorkspaceSvg} from '../workspace_svg.js'; import type {Abstract} from './events_abstract.js'; import type {BlockChange} from './events_block_change.js'; diff --git a/core/extensions.ts b/core/extensions.ts index 8ddd1ac77e2..b448f444fa0 100644 --- a/core/extensions.ts +++ b/core/extensions.ts @@ -22,7 +22,7 @@ import * as goog from '../closure/goog/goog.js'; goog.declareModuleId('Blockly.Extensions'); // Unused import preserved for side-effects. Remove if unneeded. -// import './mutator'; +// import './mutator.js'; import type {Block} from './block.js'; import type {BlockSvg} from './block_svg.js'; diff --git a/core/field.ts b/core/field.ts index e47667cb51c..0654411ed9f 100644 --- a/core/field.ts +++ b/core/field.ts @@ -21,11 +21,11 @@ goog.declareModuleId('Blockly.Field'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import './shortcut_registry'; +// import './shortcut_registry.js'; // Unused import preserved for side-effects. Remove if unneeded. import './events/events_block_change.js'; // Unused import preserved for side-effects. Remove if unneeded. -// import './gesture'; +// import './gesture.js'; import type {Block} from './block.js'; import type {BlockSvg} from './block_svg.js'; diff --git a/core/flyout_vertical.ts b/core/flyout_vertical.ts index e41b00d2fad..8f64f8f41d4 100644 --- a/core/flyout_vertical.ts +++ b/core/flyout_vertical.ts @@ -16,9 +16,9 @@ import * as goog from '../closure/goog/goog.js'; goog.declareModuleId('Blockly.VerticalFlyout'); // Unused import preserved for side-effects. Remove if unneeded. -// import './block'; +// import './block.js'; // Unused import preserved for side-effects. Remove if unneeded. -// import './constants'; +// import './constants.js'; import * as browserEvents from './browser_events.js'; import * as dropDownDiv from './dropdowndiv.js'; diff --git a/core/gesture.ts b/core/gesture.ts index a915f9d35f6..5d9ff2604a0 100644 --- a/core/gesture.ts +++ b/core/gesture.ts @@ -18,29 +18,29 @@ import * as goog from '../closure/goog/goog.js'; goog.declareModuleId('Blockly.Gesture'); // Unused import preserved for side-effects. Remove if unneeded. -// import './block_dragger'; +// import './block_dragger.js'; // Unused import preserved for side-effects. Remove if unneeded. import './events/events_click.js'; -import * as blockAnimations from './block_animations'; -import type {BlockSvg} from './block_svg'; -import * as browserEvents from './browser_events'; -import {BubbleDragger} from './bubble_dragger'; -import * as common from './common'; -import {config} from './config'; -import * as eventUtils from './events/utils'; -import type {Field} from './field'; -import type {IBlockDragger} from './interfaces/i_block_dragger'; -import type {IBubble} from './interfaces/i_bubble'; -import type {IFlyout} from './interfaces/i_flyout'; -import * as internalConstants from './internal_constants'; -import * as registry from './registry'; -import * as Tooltip from './tooltip'; -import * as Touch from './touch'; -import {Coordinate} from './utils/coordinate'; -import {WorkspaceCommentSvg} from './workspace_comment_svg'; -import {WorkspaceDragger} from './workspace_dragger'; -import type {WorkspaceSvg} from './workspace_svg'; +import * as blockAnimations from './block_animations.js'; +import type {BlockSvg} from './block_svg.js'; +import * as browserEvents from './browser_events.js'; +import {BubbleDragger} from './bubble_dragger.js'; +import * as common from './common.js'; +import {config} from './config.js'; +import * as eventUtils from './events/utils.js'; +import type {Field} from './field.js'; +import type {IBlockDragger} from './interfaces/i_block_dragger.js'; +import type {IBubble} from './interfaces/i_bubble.js'; +import type {IFlyout} from './interfaces/i_flyout.js'; +import * as internalConstants from './internal_constants.js'; +import * as registry from './registry.js'; +import * as Tooltip from './tooltip.js'; +import * as Touch from './touch.js'; +import {Coordinate} from './utils/coordinate.js'; +import {WorkspaceCommentSvg} from './workspace_comment_svg.js'; +import {WorkspaceDragger} from './workspace_dragger.js'; +import type {WorkspaceSvg} from './workspace_svg.js'; /** diff --git a/core/interfaces/i_ast_node_location_with_block.ts b/core/interfaces/i_ast_node_location_with_block.ts index 12ab7d073fc..727a1dca0c7 100644 --- a/core/interfaces/i_ast_node_location_with_block.ts +++ b/core/interfaces/i_ast_node_location_with_block.ts @@ -19,7 +19,7 @@ goog.declareModuleId('Blockly.IASTNodeLocationWithBlock'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import '../block'; +// import '../block.js'; import type {IASTNodeLocation} from './i_ast_node_location.js'; diff --git a/core/interfaces/i_block_dragger.ts b/core/interfaces/i_block_dragger.ts index 550b063389d..3e3a28ca76d 100644 --- a/core/interfaces/i_block_dragger.ts +++ b/core/interfaces/i_block_dragger.ts @@ -17,10 +17,10 @@ goog.declareModuleId('Blockly.IBlockDragger'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import '../block_svg'; +// import '../block_svg.js'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import '../utils/coordinate'; +// import '../utils/coordinate.js'; /** diff --git a/core/interfaces/i_bounded_element.ts b/core/interfaces/i_bounded_element.ts index 188f315af3f..f1fa6b77dcd 100644 --- a/core/interfaces/i_bounded_element.ts +++ b/core/interfaces/i_bounded_element.ts @@ -17,7 +17,7 @@ goog.declareModuleId('Blockly.IBoundedElement'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import '../utils/rect'; +// import '../utils/rect.js'; /** diff --git a/core/interfaces/i_bubble.ts b/core/interfaces/i_bubble.ts index 6d8ea7bcd09..5701ab4b92a 100644 --- a/core/interfaces/i_bubble.ts +++ b/core/interfaces/i_bubble.ts @@ -17,10 +17,10 @@ goog.declareModuleId('Blockly.IBubble'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import '../block_drag_surface'; +// import '../block_drag_surface.js'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import '../utils/coordinate'; +// import '../utils/coordinate.js'; import type {IContextMenu} from './i_contextmenu.js'; import type {IDraggable} from './i_draggable.js'; diff --git a/core/interfaces/i_collapsible_toolbox_item.ts b/core/interfaces/i_collapsible_toolbox_item.ts index a0ff9a09349..939b6597aba 100644 --- a/core/interfaces/i_collapsible_toolbox_item.ts +++ b/core/interfaces/i_collapsible_toolbox_item.ts @@ -18,9 +18,9 @@ goog.declareModuleId('Blockly.ICollapsibleToolboxItem'); /* eslint-disable-next-line no-unused-vars */ /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import './i_toolbox_item'; +// import './i_toolbox_item.js'; -import type {ISelectableToolboxItem} from './i_selectable_toolbox_item'; +import type {ISelectableToolboxItem} from './i_selectable_toolbox_item.js'; /** diff --git a/core/interfaces/i_connection_checker.ts b/core/interfaces/i_connection_checker.ts index ecd04ddc854..860c1f41222 100644 --- a/core/interfaces/i_connection_checker.ts +++ b/core/interfaces/i_connection_checker.ts @@ -19,10 +19,10 @@ goog.declareModuleId('Blockly.IConnectionChecker'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import '../connection'; +// import '../connection.js'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import '../rendered_connection'; +// import '../rendered_connection.js'; /** diff --git a/core/interfaces/i_copyable.ts b/core/interfaces/i_copyable.ts index fe27c426566..21265f111a2 100644 --- a/core/interfaces/i_copyable.ts +++ b/core/interfaces/i_copyable.ts @@ -15,8 +15,8 @@ import * as goog from '../../closure/goog/goog.js'; goog.declareModuleId('Blockly.ICopyable'); -import type {WorkspaceSvg} from '../workspace_svg'; -import type {ISelectable} from './i_selectable'; +import type {WorkspaceSvg} from '../workspace_svg.js'; +import type {ISelectable} from './i_selectable.js'; /** @alias Blockly.ICopyable */ diff --git a/core/interfaces/i_delete_area.ts b/core/interfaces/i_delete_area.ts index a99c57ffdfb..36304fd0669 100644 --- a/core/interfaces/i_delete_area.ts +++ b/core/interfaces/i_delete_area.ts @@ -20,9 +20,9 @@ goog.declareModuleId('Blockly.IDeleteArea'); /* eslint-disable-next-line no-unused-vars */ /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import './i_draggable'; +// import './i_draggable.js'; -import type {IDragTarget} from './i_drag_target'; +import type {IDragTarget} from './i_drag_target.js'; /** diff --git a/core/interfaces/i_drag_target.ts b/core/interfaces/i_drag_target.ts index 490e28f3b2f..b743fd6d6f8 100644 --- a/core/interfaces/i_drag_target.ts +++ b/core/interfaces/i_drag_target.ts @@ -20,12 +20,12 @@ goog.declareModuleId('Blockly.IDragTarget'); /* eslint-disable-next-line no-unused-vars */ /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import './i_draggable'; +// import './i_draggable.js'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import '../utils/rect'; +// import '../utils/rect.js'; -import type {IComponent} from './i_component'; +import type {IComponent} from './i_component.js'; /** diff --git a/core/interfaces/i_flyout.ts b/core/interfaces/i_flyout.ts index 4bf210d4fd0..0976d7a5faf 100644 --- a/core/interfaces/i_flyout.ts +++ b/core/interfaces/i_flyout.ts @@ -17,16 +17,16 @@ goog.declareModuleId('Blockly.IFlyout'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import '../utils/toolbox'; +// import '../utils/toolbox.js'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import '../block_svg'; +// import '../block_svg.js'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import '../utils/coordinate'; +// import '../utils/coordinate.js'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import '../utils/svg'; +// import '../utils/svg.js'; import type {WorkspaceSvg} from '../workspace_svg.js'; diff --git a/core/interfaces/i_keyboard_accessible.ts b/core/interfaces/i_keyboard_accessible.ts index 33c950e2625..83ea432ae36 100644 --- a/core/interfaces/i_keyboard_accessible.ts +++ b/core/interfaces/i_keyboard_accessible.ts @@ -17,7 +17,7 @@ goog.declareModuleId('Blockly.IKeyboardAccessible'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import '../shortcut_registry'; +// import '../shortcut_registry.js'; /** diff --git a/core/interfaces/i_metrics_manager.ts b/core/interfaces/i_metrics_manager.ts index ad04829744a..1419820234b 100644 --- a/core/interfaces/i_metrics_manager.ts +++ b/core/interfaces/i_metrics_manager.ts @@ -17,13 +17,13 @@ goog.declareModuleId('Blockly.IMetricsManager'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import '../metrics_manager'; +// import '../metrics_manager.js'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import '../utils/metrics'; +// import '../utils/metrics.js'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import '../utils/size'; +// import '../utils/size.js'; /** diff --git a/core/interfaces/i_positionable.ts b/core/interfaces/i_positionable.ts index c44c0ae8706..1490f9cf41c 100644 --- a/core/interfaces/i_positionable.ts +++ b/core/interfaces/i_positionable.ts @@ -18,12 +18,12 @@ goog.declareModuleId('Blockly.IPositionable'); /* eslint-disable-next-line no-unused-vars */ /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import '../metrics_manager'; +// import '../metrics_manager.js'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import '../utils/rect'; +// import '../utils/rect.js'; -import type {IComponent} from './i_component'; +import type {IComponent} from './i_component.js'; /** diff --git a/core/interfaces/i_selectable.ts b/core/interfaces/i_selectable.ts index 936019191e6..6fdaa8458ec 100644 --- a/core/interfaces/i_selectable.ts +++ b/core/interfaces/i_selectable.ts @@ -15,8 +15,8 @@ import * as goog from '../../closure/goog/goog.js'; goog.declareModuleId('Blockly.ISelectable'); -import type {IDeletable} from './i_deletable'; -import type {IMovable} from './i_movable'; +import type {IDeletable} from './i_deletable.js'; +import type {IMovable} from './i_movable.js'; /** diff --git a/core/interfaces/i_selectable_toolbox_item.ts b/core/interfaces/i_selectable_toolbox_item.ts index f992cb4833d..0cf663ae246 100644 --- a/core/interfaces/i_selectable_toolbox_item.ts +++ b/core/interfaces/i_selectable_toolbox_item.ts @@ -17,7 +17,7 @@ goog.declareModuleId('Blockly.ISelectableToolboxItem'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import '../utils/toolbox'; +// import '../utils/toolbox.js'; import type {IToolboxItem} from './i_toolbox_item.js'; diff --git a/core/interfaces/i_serializer.ts b/core/interfaces/i_serializer.ts index 0f5b5fec52b..5c926b86e6f 100644 --- a/core/interfaces/i_serializer.ts +++ b/core/interfaces/i_serializer.ts @@ -17,7 +17,7 @@ import * as goog from '../../closure/goog/goog.js'; goog.declareModuleId('Blockly.serialization.ISerializer'); -import type {Workspace} from '../workspace'; +import type {Workspace} from '../workspace.js'; /** diff --git a/core/interfaces/i_toolbox.ts b/core/interfaces/i_toolbox.ts index 0470af370cb..ceec06f30dd 100644 --- a/core/interfaces/i_toolbox.ts +++ b/core/interfaces/i_toolbox.ts @@ -17,16 +17,16 @@ goog.declareModuleId('Blockly.IToolbox'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import '../utils/toolbox'; +// import '../utils/toolbox.js'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import './i_flyout'; +// import './i_flyout.js'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import './i_toolbox_item'; +// import './i_toolbox_item.js'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import '../workspace_svg'; +// import '../workspace_svg.js'; import type {IRegistrable} from './i_registrable.js'; diff --git a/core/keyboard_nav/marker.ts b/core/keyboard_nav/marker.ts index aa495c05deb..be79d745dbd 100644 --- a/core/keyboard_nav/marker.ts +++ b/core/keyboard_nav/marker.ts @@ -20,7 +20,7 @@ goog.declareModuleId('Blockly.Marker'); /* eslint-disable-next-line no-unused-vars */ import type {MarkerSvg} from '../renderers/common/marker_svg.js'; -import type {ASTNode} from './ast_node'; +import type {ASTNode} from './ast_node.js'; /** diff --git a/core/names.ts b/core/names.ts index 5650051fde2..a74ceb529f8 100644 --- a/core/names.ts +++ b/core/names.ts @@ -16,7 +16,7 @@ import * as goog from '../closure/goog/goog.js'; goog.declareModuleId('Blockly.Names'); // Unused import preserved for side-effects. Remove if unneeded. -// import './procedures'; +// import './procedures.js'; import {Msg} from './msg.js'; import * as Procedures from './procedures.js'; diff --git a/core/positionable_helpers.ts b/core/positionable_helpers.ts index 654d8e7ebd1..d5f251b10dd 100644 --- a/core/positionable_helpers.ts +++ b/core/positionable_helpers.ts @@ -17,7 +17,7 @@ goog.declareModuleId('Blockly.uiPosition'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import './metrics_manager'; +// import './metrics_manager.js'; import type {UiMetrics} from './metrics_manager.js'; import {Scrollbar} from './scrollbar.js'; diff --git a/core/procedures.ts b/core/procedures.ts index ad3fe3f2bae..dccab8e6be9 100644 --- a/core/procedures.ts +++ b/core/procedures.ts @@ -18,21 +18,21 @@ goog.declareModuleId('Blockly.Procedures'); // Unused import preserved for side-effects. Remove if unneeded. import './events/events_block_change.js'; -import type {Block} from './block'; -import type {BlockSvg} from './block_svg'; -import {Blocks} from './blocks'; -import * as common from './common'; -import type {Abstract} from './events/events_abstract'; -import type {BubbleOpen} from './events/events_bubble_open'; -import * as eventUtils from './events/utils'; -import type {Field} from './field'; -import {Msg} from './msg'; -import {Names} from './names'; -import * as utilsXml from './utils/xml'; -import * as Variables from './variables'; -import type {Workspace} from './workspace'; -import type {WorkspaceSvg} from './workspace_svg'; -import * as Xml from './xml'; +import type {Block} from './block.js'; +import type {BlockSvg} from './block_svg.js'; +import {Blocks} from './blocks.js'; +import * as common from './common.js'; +import type {Abstract} from './events/events_abstract.js'; +import type {BubbleOpen} from './events/events_bubble_open.js'; +import * as eventUtils from './events/utils.js'; +import type {Field} from './field.js'; +import {Msg} from './msg.js'; +import {Names} from './names.js'; +import * as utilsXml from './utils/xml.js'; +import * as Variables from './variables.js'; +import type {Workspace} from './workspace.js'; +import type {WorkspaceSvg} from './workspace_svg.js'; +import * as Xml from './xml.js'; /** diff --git a/core/renderers/common/i_path_object.ts b/core/renderers/common/i_path_object.ts index 58816e51623..3ca30316043 100644 --- a/core/renderers/common/i_path_object.ts +++ b/core/renderers/common/i_path_object.ts @@ -19,13 +19,13 @@ goog.declareModuleId('Blockly.blockRendering.IPathObject'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import '../../block_svg'; +// import '../../block_svg.js'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import '../../connection'; +// import '../../connection.js'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import '../../theme'; +// import '../../theme.js'; import type {BlockStyle} from '../../theme.js'; diff --git a/core/renderers/common/path_object.ts b/core/renderers/common/path_object.ts index b1c03e5afb5..521b9cb4ff9 100644 --- a/core/renderers/common/path_object.ts +++ b/core/renderers/common/path_object.ts @@ -17,7 +17,7 @@ goog.declareModuleId('Blockly.blockRendering.PathObject'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import '../../theme'; +// import '../../theme.js'; import type {BlockSvg} from '../../block_svg.js'; import type {Connection} from '../../connection.js'; diff --git a/core/renderers/geras/drawer.ts b/core/renderers/geras/drawer.ts index 1c628b3b677..6c8fcdaa1ed 100644 --- a/core/renderers/geras/drawer.ts +++ b/core/renderers/geras/drawer.ts @@ -15,11 +15,11 @@ import * as goog from '../../../closure/goog/goog.js'; goog.declareModuleId('Blockly.geras.Drawer'); -import type {BlockSvg} from '../../block_svg'; -import * as svgPaths from '../../utils/svg_paths'; -import * as debug from '../common/debug'; -import {Drawer as BaseDrawer} from '../common/drawer'; -import type {Row} from '../measurables/row'; +import type {BlockSvg} from '../../block_svg.js'; +import * as svgPaths from '../../utils/svg_paths.js'; +import * as debug from '../common/debug.js'; +import {Drawer as BaseDrawer} from '../common/drawer.js'; +import type {Row} from '../measurables/row.js'; import type {ConstantProvider} from './constants.js'; import {Highlighter} from './highlighter.js'; diff --git a/core/renderers/geras/highlighter.ts b/core/renderers/geras/highlighter.ts index 09a80edc4de..3a8cab3f97f 100644 --- a/core/renderers/geras/highlighter.ts +++ b/core/renderers/geras/highlighter.ts @@ -19,7 +19,7 @@ goog.declareModuleId('Blockly.geras.Highlighter'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import './renderer'; +// import './renderer.js'; import * as svgPaths from '../../utils/svg_paths.js'; import type {ConstantProvider} from '../common/constants.js'; @@ -29,9 +29,9 @@ import {SpacerRow} from '../measurables/spacer_row.js'; import type {TopRow} from '../measurables/top_row.js'; import {Types} from '../measurables/types.js'; -import type {HighlightConstantProvider, InsideCorner, JaggedTeeth, Notch, OutsideCorner, PuzzleTab, StartHat} from './highlight_constants'; -import type {RenderInfo} from './info'; -import type {InlineInput} from './measurables/inline_input'; +import type {HighlightConstantProvider, InsideCorner, JaggedTeeth, Notch, OutsideCorner, PuzzleTab, StartHat} from './highlight_constants.js'; +import type {RenderInfo} from './info.js'; +import type {InlineInput} from './measurables/inline_input.js'; /** diff --git a/core/renderers/geras/info.ts b/core/renderers/geras/info.ts index 5cbc8983a9a..d2df8ee4b37 100644 --- a/core/renderers/geras/info.ts +++ b/core/renderers/geras/info.ts @@ -17,19 +17,19 @@ import * as goog from '../../../closure/goog/goog.js'; goog.declareModuleId('Blockly.geras.RenderInfo'); -import type {BlockSvg} from '../../block_svg'; -import type {Input} from '../../input'; -import {inputTypes} from '../../input_types'; -import {RenderInfo as BaseRenderInfo} from '../common/info'; -import type {Measurable} from '../measurables/base'; -import type {BottomRow} from '../measurables/bottom_row'; -import {ExternalValueInput} from '../measurables/external_value_input'; -import type {Field} from '../measurables/field'; -import {InRowSpacer} from '../measurables/in_row_spacer'; -import type {InputRow} from '../measurables/input_row'; -import type {Row} from '../measurables/row'; -import type {TopRow} from '../measurables/top_row'; -import {Types} from '../measurables/types'; +import type {BlockSvg} from '../../block_svg.js'; +import type {Input} from '../../input.js'; +import {inputTypes} from '../../input_types.js'; +import {RenderInfo as BaseRenderInfo} from '../common/info.js'; +import type {Measurable} from '../measurables/base.js'; +import type {BottomRow} from '../measurables/bottom_row.js'; +import {ExternalValueInput} from '../measurables/external_value_input.js'; +import type {Field} from '../measurables/field.js'; +import {InRowSpacer} from '../measurables/in_row_spacer.js'; +import type {InputRow} from '../measurables/input_row.js'; +import type {Row} from '../measurables/row.js'; +import type {TopRow} from '../measurables/top_row.js'; +import {Types} from '../measurables/types.js'; import type {ConstantProvider} from './constants.js'; import {InlineInput} from './measurables/inline_input.js'; diff --git a/core/renderers/geras/measurables/inline_input.ts b/core/renderers/geras/measurables/inline_input.ts index 702cfdae5a8..76dacf56b42 100644 --- a/core/renderers/geras/measurables/inline_input.ts +++ b/core/renderers/geras/measurables/inline_input.ts @@ -18,10 +18,10 @@ import * as goog from '../../../../closure/goog/goog.js'; goog.declareModuleId('Blockly.geras.InlineInput'); /* eslint-disable-next-line no-unused-vars */ -import type {Input} from '../../../input'; -import type {ConstantProvider as BaseConstantProvider} from '../../../renderers/common/constants'; -import {InlineInput as BaseInlineInput} from '../../../renderers/measurables/inline_input'; -import type {ConstantProvider as GerasConstantProvider} from '../constants'; +import type {Input} from '../../../input.js'; +import type {ConstantProvider as BaseConstantProvider} from '../../../renderers/common/constants.js'; +import {InlineInput as BaseInlineInput} from '../../../renderers/measurables/inline_input.js'; +import type {ConstantProvider as GerasConstantProvider} from '../constants.js'; /** diff --git a/core/renderers/geras/measurables/statement_input.ts b/core/renderers/geras/measurables/statement_input.ts index c560abd676a..f002a5bcb2f 100644 --- a/core/renderers/geras/measurables/statement_input.ts +++ b/core/renderers/geras/measurables/statement_input.ts @@ -18,10 +18,10 @@ import * as goog from '../../../../closure/goog/goog.js'; goog.declareModuleId('Blockly.geras.StatementInput'); /* eslint-disable-next-line no-unused-vars */ -import type {Input} from '../../../input'; -import type {ConstantProvider as BaseConstantProvider} from '../../../renderers/common/constants'; -import {StatementInput as BaseStatementInput} from '../../../renderers/measurables/statement_input'; -import type {ConstantProvider as GerasConstantProvider} from '../constants'; +import type {Input} from '../../../input.js'; +import type {ConstantProvider as BaseConstantProvider} from '../../../renderers/common/constants.js'; +import {StatementInput as BaseStatementInput} from '../../../renderers/measurables/statement_input.js'; +import type {ConstantProvider as GerasConstantProvider} from '../constants.js'; /** diff --git a/core/renderers/geras/path_object.ts b/core/renderers/geras/path_object.ts index 6112b518add..78b6177a76c 100644 --- a/core/renderers/geras/path_object.ts +++ b/core/renderers/geras/path_object.ts @@ -17,14 +17,14 @@ goog.declareModuleId('Blockly.geras.PathObject'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import '../../theme'; - -import type {BlockSvg} from '../../block_svg'; -import type {BlockStyle} from '../../theme'; -import * as colour from '../../utils/colour'; -import * as dom from '../../utils/dom'; -import {Svg} from '../../utils/svg'; -import {PathObject as BasePathObject} from '../common/path_object'; +// import '../../theme.js'; + +import type {BlockSvg} from '../../block_svg.js'; +import type {BlockStyle} from '../../theme.js'; +import * as colour from '../../utils/colour.js'; +import * as dom from '../../utils/dom.js'; +import {Svg} from '../../utils/svg.js'; +import {PathObject as BasePathObject} from '../common/path_object.js'; import type {ConstantProvider} from './constants.js'; diff --git a/core/renderers/geras/renderer.ts b/core/renderers/geras/renderer.ts index fc6b0a0d1f1..6ecb10262ca 100644 --- a/core/renderers/geras/renderer.ts +++ b/core/renderers/geras/renderer.ts @@ -17,13 +17,13 @@ goog.declareModuleId('Blockly.geras.Renderer'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import '../common/constants'; +// import '../common/constants.js'; -import type {BlockSvg} from '../../block_svg'; -import type {BlockStyle, Theme} from '../../theme'; -import * as blockRendering from '../common/block_rendering'; -import type {RenderInfo as BaseRenderInfo} from '../common/info'; -import {Renderer as BaseRenderer} from '../common/renderer'; +import type {BlockSvg} from '../../block_svg.js'; +import type {BlockStyle, Theme} from '../../theme.js'; +import * as blockRendering from '../common/block_rendering.js'; +import type {RenderInfo as BaseRenderInfo} from '../common/info.js'; +import {Renderer as BaseRenderer} from '../common/renderer.js'; import {ConstantProvider} from './constants.js'; import {Drawer} from './drawer.js'; diff --git a/core/renderers/measurables/connection.ts b/core/renderers/measurables/connection.ts index 65b0a0d4f76..84a121b2a9c 100644 --- a/core/renderers/measurables/connection.ts +++ b/core/renderers/measurables/connection.ts @@ -18,8 +18,8 @@ import * as goog from '../../../closure/goog/goog.js'; goog.declareModuleId('Blockly.blockRendering.Connection'); /* eslint-disable-next-line no-unused-vars */ -import type {RenderedConnection} from '../../rendered_connection'; -import type {ConstantProvider, Shape} from '../common/constants'; +import type {RenderedConnection} from '../../rendered_connection.js'; +import type {ConstantProvider, Shape} from '../common/constants.js'; import {Measurable} from './base.js'; import {Types} from './types.js'; diff --git a/core/renderers/measurables/external_value_input.ts b/core/renderers/measurables/external_value_input.ts index 0f1c589a92b..f7cf459b599 100644 --- a/core/renderers/measurables/external_value_input.ts +++ b/core/renderers/measurables/external_value_input.ts @@ -18,8 +18,8 @@ import * as goog from '../../../closure/goog/goog.js'; goog.declareModuleId('Blockly.blockRendering.ExternalValueInput'); /* eslint-disable-next-line no-unused-vars */ -import type {Input} from '../../input'; -import type {ConstantProvider} from '../common/constants'; +import type {Input} from '../../input.js'; +import type {ConstantProvider} from '../common/constants.js'; import {InputConnection} from './input_connection.js'; import {Types} from './types.js'; diff --git a/core/renderers/measurables/field.ts b/core/renderers/measurables/field.ts index e98d0ec36c4..39a5b24d804 100644 --- a/core/renderers/measurables/field.ts +++ b/core/renderers/measurables/field.ts @@ -18,9 +18,9 @@ import * as goog from '../../../closure/goog/goog.js'; goog.declareModuleId('Blockly.blockRendering.Field'); /* eslint-disable-next-line no-unused-vars */ -import type {Field as BlocklyField} from '../../field'; -import type {Input} from '../../input'; -import type {ConstantProvider} from '../common/constants'; +import type {Field as BlocklyField} from '../../field.js'; +import type {Input} from '../../input.js'; +import type {ConstantProvider} from '../common/constants.js'; import {Measurable} from './base.js'; import {Types} from './types.js'; diff --git a/core/renderers/measurables/icon.ts b/core/renderers/measurables/icon.ts index cddf0db7172..80437c4fb31 100644 --- a/core/renderers/measurables/icon.ts +++ b/core/renderers/measurables/icon.ts @@ -18,8 +18,8 @@ import * as goog from '../../../closure/goog/goog.js'; goog.declareModuleId('Blockly.blockRendering.Icon'); /* eslint-disable-next-line no-unused-vars */ -import type {Icon as BlocklyIcon} from '../../icon'; -import type {ConstantProvider} from '../common/constants'; +import type {Icon as BlocklyIcon} from '../../icon.js'; +import type {ConstantProvider} from '../common/constants.js'; import {Measurable} from './base.js'; import {Types} from './types.js'; diff --git a/core/renderers/measurables/inline_input.ts b/core/renderers/measurables/inline_input.ts index 7abf0d296a3..ce24540d38c 100644 --- a/core/renderers/measurables/inline_input.ts +++ b/core/renderers/measurables/inline_input.ts @@ -18,8 +18,8 @@ import * as goog from '../../../closure/goog/goog.js'; goog.declareModuleId('Blockly.blockRendering.InlineInput'); /* eslint-disable-next-line no-unused-vars */ -import type {Input} from '../../input'; -import type {ConstantProvider} from '../common/constants'; +import type {Input} from '../../input.js'; +import type {ConstantProvider} from '../common/constants.js'; import {InputConnection} from './input_connection.js'; import {Types} from './types.js'; diff --git a/core/renderers/measurables/statement_input.ts b/core/renderers/measurables/statement_input.ts index c15ed457385..dad53205542 100644 --- a/core/renderers/measurables/statement_input.ts +++ b/core/renderers/measurables/statement_input.ts @@ -18,8 +18,8 @@ import * as goog from '../../../closure/goog/goog.js'; goog.declareModuleId('Blockly.blockRendering.StatementInput'); /* eslint-disable-next-line no-unused-vars */ -import type {Input} from '../../input'; -import type {ConstantProvider} from '../common/constants'; +import type {Input} from '../../input.js'; +import type {ConstantProvider} from '../common/constants.js'; import {InputConnection} from './input_connection.js'; import {Types} from './types.js'; diff --git a/core/renderers/thrasos/info.ts b/core/renderers/thrasos/info.ts index 77b823e7ea5..0d0a0ffd475 100644 --- a/core/renderers/thrasos/info.ts +++ b/core/renderers/thrasos/info.ts @@ -17,15 +17,15 @@ import * as goog from '../../../closure/goog/goog.js'; goog.declareModuleId('Blockly.thrasos.RenderInfo'); -import type {BlockSvg} from '../../block_svg'; -import {RenderInfo as BaseRenderInfo} from '../common/info'; -import type {Measurable} from '../measurables/base'; -import type {BottomRow} from '../measurables/bottom_row'; -import type {Field} from '../measurables/field'; -import {InRowSpacer} from '../measurables/in_row_spacer'; -import type {Row} from '../measurables/row'; -import type {TopRow} from '../measurables/top_row'; -import {Types} from '../measurables/types'; +import type {BlockSvg} from '../../block_svg.js'; +import {RenderInfo as BaseRenderInfo} from '../common/info.js'; +import type {Measurable} from '../measurables/base.js'; +import type {BottomRow} from '../measurables/bottom_row.js'; +import type {Field} from '../measurables/field.js'; +import {InRowSpacer} from '../measurables/in_row_spacer.js'; +import type {Row} from '../measurables/row.js'; +import type {TopRow} from '../measurables/top_row.js'; +import {Types} from '../measurables/types.js'; import type {Renderer} from './renderer.js'; diff --git a/core/renderers/zelos/path_object.ts b/core/renderers/zelos/path_object.ts index 9eeb637e37d..6e809856509 100644 --- a/core/renderers/zelos/path_object.ts +++ b/core/renderers/zelos/path_object.ts @@ -17,7 +17,7 @@ goog.declareModuleId('Blockly.zelos.PathObject'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import '../../theme'; +// import '../../theme.js'; import type {BlockSvg} from '../../block_svg.js'; import type {Connection} from '../../connection.js'; diff --git a/core/renderers/zelos/renderer.ts b/core/renderers/zelos/renderer.ts index d5494ce3ada..ae70ddff224 100644 --- a/core/renderers/zelos/renderer.ts +++ b/core/renderers/zelos/renderer.ts @@ -17,7 +17,7 @@ goog.declareModuleId('Blockly.zelos.Renderer'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import '../../theme'; +// import '../../theme.js'; import type {BlockSvg} from '../../block_svg.js'; import type {Connection} from '../../connection.js'; diff --git a/core/toolbox/toolbox.ts b/core/toolbox/toolbox.ts index ee643f57ebd..1b6847129f6 100644 --- a/core/toolbox/toolbox.ts +++ b/core/toolbox/toolbox.ts @@ -17,7 +17,7 @@ goog.declareModuleId('Blockly.Toolbox'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import '../shortcut_registry'; +// import '../shortcut_registry.js'; // Unused import preserved for side-effects. Remove if unneeded. import '../events/events_toolbox_item_select.js'; diff --git a/core/trashcan.ts b/core/trashcan.ts index 90e1e194b4a..5ecdbb74bb8 100644 --- a/core/trashcan.ts +++ b/core/trashcan.ts @@ -17,7 +17,7 @@ goog.declareModuleId('Blockly.Trashcan'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import './metrics_manager'; +// import './metrics_manager.js'; // Unused import preserved for side-effects. Remove if unneeded. import './events/events_trashcan_open.js'; diff --git a/core/utils/toolbox.ts b/core/utils/toolbox.ts index f1d8e1beda6..c00a20b69ac 100644 --- a/core/utils/toolbox.ts +++ b/core/utils/toolbox.ts @@ -17,10 +17,10 @@ goog.declareModuleId('Blockly.utils.toolbox'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import '../toolbox/category'; +// import '../toolbox/category.js'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import '../toolbox/separator'; +// import '../toolbox/separator.js'; import type {ConnectionState} from '../serialization/blocks.js'; import type {CssConfig as CategoryCssConfig} from '../toolbox/category.js'; diff --git a/core/workspace.ts b/core/workspace.ts index e7727735104..8508356f496 100644 --- a/core/workspace.ts +++ b/core/workspace.ts @@ -18,23 +18,23 @@ goog.declareModuleId('Blockly.Workspace'); // Unused import preserved for side-effects. Remove if unneeded. import './connection_checker.js'; -import type {Block} from './block'; -import type {BlocklyOptions} from './blockly_options'; -import type {ConnectionDB} from './connection_db'; -import type {Abstract} from './events/events_abstract'; -import * as common from './common'; -import * as eventUtils from './events/utils'; -import type {IASTNodeLocation} from './interfaces/i_ast_node_location'; -import type {IConnectionChecker} from './interfaces/i_connection_checker'; -import {Options} from './options'; -import * as registry from './registry'; -import * as arrayUtils from './utils/array'; -import * as idGenerator from './utils/idgenerator'; -import * as math from './utils/math'; -import type * as toolbox from './utils/toolbox'; -import {VariableMap} from './variable_map'; -import type {VariableModel} from './variable_model'; -import type {WorkspaceComment} from './workspace_comment'; +import type {Block} from './block.js'; +import type {BlocklyOptions} from './blockly_options.js'; +import type {ConnectionDB} from './connection_db.js'; +import type {Abstract} from './events/events_abstract.js'; +import * as common from './common.js'; +import * as eventUtils from './events/utils.js'; +import type {IASTNodeLocation} from './interfaces/i_ast_node_location.js'; +import type {IConnectionChecker} from './interfaces/i_connection_checker.js'; +import {Options} from './options.js'; +import * as registry from './registry.js'; +import * as arrayUtils from './utils/array.js'; +import * as idGenerator from './utils/idgenerator.js'; +import * as math from './utils/math.js'; +import type * as toolbox from './utils/toolbox.js'; +import {VariableMap} from './variable_map.js'; +import type {VariableModel} from './variable_model.js'; +import type {WorkspaceComment} from './workspace_comment.js'; /** diff --git a/core/workspace_svg.ts b/core/workspace_svg.ts index 0fe93c7d2ae..4e5620fff7d 100644 --- a/core/workspace_svg.ts +++ b/core/workspace_svg.ts @@ -17,19 +17,19 @@ goog.declareModuleId('Blockly.WorkspaceSvg'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import './procedures'; +// import './procedures.js'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import './variables'; +// import './variables.js'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import './variables_dynamic'; +// import './variables_dynamic.js'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import './rendered_connection'; +// import './rendered_connection.js'; /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import './zoom_controls'; +// import './zoom_controls.js'; // Unused import preserved for side-effects. Remove if unneeded. import './events/events_block_create.js'; // Unused import preserved for side-effects. Remove if unneeded. @@ -37,71 +37,71 @@ import './events/events_theme_change.js'; // Unused import preserved for side-effects. Remove if unneeded. import './events/events_viewport.js'; // Unused import preserved for side-effects. Remove if unneeded. -// import './metrics_manager'; +// import './metrics_manager.js'; // Unused import preserved for side-effects. Remove if unneeded. -// import './msg'; - -import type {Block} from './block'; -import type {BlockDragSurfaceSvg} from './block_drag_surface'; -import type {BlockSvg} from './block_svg'; -import type {BlocklyOptions} from './blockly_options'; -import * as browserEvents from './browser_events'; -import * as common from './common'; -import {ComponentManager} from './component_manager'; -import {config} from './config'; -import {ConnectionDB} from './connection_db'; -import * as ContextMenu from './contextmenu'; -import {ContextMenuRegistry} from './contextmenu_registry'; -import * as dropDownDiv from './dropdowndiv'; -import * as eventUtils from './events/utils'; -import type {FlyoutButton} from './flyout_button'; -import {Gesture} from './gesture'; -import {Grid} from './grid'; -import type {IASTNodeLocationSvg} from './interfaces/i_ast_node_location_svg'; -import type {IBoundedElement} from './interfaces/i_bounded_element'; -import type {ICopyable} from './interfaces/i_copyable'; -import type {IDragTarget} from './interfaces/i_drag_target'; -import type {IFlyout} from './interfaces/i_flyout'; -import type {IMetricsManager} from './interfaces/i_metrics_manager'; -import type {IToolbox} from './interfaces/i_toolbox'; -import type {Cursor} from './keyboard_nav/cursor'; -import type {Marker} from './keyboard_nav/marker'; -import {MarkerManager} from './marker_manager'; -import {Options} from './options'; -import * as Procedures from './procedures'; -import * as registry from './registry'; -import * as blockRendering from './renderers/common/block_rendering'; -import type {Renderer} from './renderers/common/renderer'; -import type {ScrollbarPair} from './scrollbar_pair'; -import * as blocks from './serialization/blocks'; -import type {Theme} from './theme'; -import {Classic} from './theme/classic'; -import {ThemeManager} from './theme_manager'; -import * as Tooltip from './tooltip'; -import {TouchGesture} from './touch_gesture'; -import type {Trashcan} from './trashcan'; -import * as utils from './utils'; -import * as arrayUtils from './utils/array'; -import {Coordinate} from './utils/coordinate'; -import * as dom from './utils/dom'; -import type {Metrics} from './utils/metrics'; -import {Rect} from './utils/rect'; -import {Size} from './utils/size'; -import {Svg} from './utils/svg'; -import * as svgMath from './utils/svg_math'; -import * as toolbox from './utils/toolbox'; -import * as userAgent from './utils/useragent'; -import type {VariableModel} from './variable_model'; -import * as Variables from './variables'; -import * as VariablesDynamic from './variables_dynamic'; -import * as WidgetDiv from './widgetdiv'; -import {Workspace} from './workspace'; -import {WorkspaceAudio} from './workspace_audio'; -import {WorkspaceComment} from './workspace_comment'; -import {WorkspaceCommentSvg} from './workspace_comment_svg'; -import type {WorkspaceDragSurfaceSvg} from './workspace_drag_surface_svg'; -import * as Xml from './xml'; -import {ZoomControls} from './zoom_controls'; +// import './msg.js'; + +import type {Block} from './block.js'; +import type {BlockDragSurfaceSvg} from './block_drag_surface.js'; +import type {BlockSvg} from './block_svg.js'; +import type {BlocklyOptions} from './blockly_options.js'; +import * as browserEvents from './browser_events.js'; +import * as common from './common.js'; +import {ComponentManager} from './component_manager.js'; +import {config} from './config.js'; +import {ConnectionDB} from './connection_db.js'; +import * as ContextMenu from './contextmenu.js'; +import {ContextMenuRegistry} from './contextmenu_registry.js'; +import * as dropDownDiv from './dropdowndiv.js'; +import * as eventUtils from './events/utils.js'; +import type {FlyoutButton} from './flyout_button.js'; +import {Gesture} from './gesture.js'; +import {Grid} from './grid.js'; +import type {IASTNodeLocationSvg} from './interfaces/i_ast_node_location_svg.js'; +import type {IBoundedElement} from './interfaces/i_bounded_element.js'; +import type {ICopyable} from './interfaces/i_copyable.js'; +import type {IDragTarget} from './interfaces/i_drag_target.js'; +import type {IFlyout} from './interfaces/i_flyout.js'; +import type {IMetricsManager} from './interfaces/i_metrics_manager.js'; +import type {IToolbox} from './interfaces/i_toolbox.js'; +import type {Cursor} from './keyboard_nav/cursor.js'; +import type {Marker} from './keyboard_nav/marker.js'; +import {MarkerManager} from './marker_manager.js'; +import {Options} from './options.js'; +import * as Procedures from './procedures.js'; +import * as registry from './registry.js'; +import * as blockRendering from './renderers/common/block_rendering.js'; +import type {Renderer} from './renderers/common/renderer.js'; +import type {ScrollbarPair} from './scrollbar_pair.js'; +import * as blocks from './serialization/blocks.js'; +import type {Theme} from './theme.js'; +import {Classic} from './theme/classic.js'; +import {ThemeManager} from './theme_manager.js'; +import * as Tooltip from './tooltip.js'; +import {TouchGesture} from './touch_gesture.js'; +import type {Trashcan} from './trashcan.js'; +import * as utils from './utils.js'; +import * as arrayUtils from './utils/array.js'; +import {Coordinate} from './utils/coordinate.js'; +import * as dom from './utils/dom.js'; +import type {Metrics} from './utils/metrics.js'; +import {Rect} from './utils/rect.js'; +import {Size} from './utils/size.js'; +import {Svg} from './utils/svg.js'; +import * as svgMath from './utils/svg_math.js'; +import * as toolbox from './utils/toolbox.js'; +import * as userAgent from './utils/useragent.js'; +import type {VariableModel} from './variable_model.js'; +import * as Variables from './variables.js'; +import * as VariablesDynamic from './variables_dynamic.js'; +import * as WidgetDiv from './widgetdiv.js'; +import {Workspace} from './workspace.js'; +import {WorkspaceAudio} from './workspace_audio.js'; +import {WorkspaceComment} from './workspace_comment.js'; +import {WorkspaceCommentSvg} from './workspace_comment_svg.js'; +import type {WorkspaceDragSurfaceSvg} from './workspace_drag_surface_svg.js'; +import * as Xml from './xml.js'; +import {ZoomControls} from './zoom_controls.js'; /** Margin around the top/bottom/left/right after a zoomToFit call. */ diff --git a/core/xml.ts b/core/xml.ts index 9390733f077..414b8e54e14 100644 --- a/core/xml.ts +++ b/core/xml.ts @@ -16,13 +16,13 @@ import * as goog from '../closure/goog/goog.js'; goog.declareModuleId('Blockly.Xml'); // Unused import preserved for side-effects. Remove if unneeded. -// import './comment'; +// import './comment.js'; // Unused import preserved for side-effects. Remove if unneeded. -// import './variables'; +// import './variables.js'; // Unused import preserved for side-effects. Remove if unneeded. -// import './workspace_comment'; +// import './workspace_comment.js'; // Unused import preserved for side-effects. Remove if unneeded. -// import './workspace_comment_svg'; +// import './workspace_comment_svg.js'; import type {Block} from './block.js'; import type {BlockSvg} from './block_svg.js'; diff --git a/core/zoom_controls.ts b/core/zoom_controls.ts index 195c742c260..e8947a157cc 100644 --- a/core/zoom_controls.ts +++ b/core/zoom_controls.ts @@ -17,7 +17,7 @@ goog.declareModuleId('Blockly.ZoomControls'); /* eslint-disable-next-line no-unused-vars */ // Unused import preserved for side-effects. Remove if unneeded. -// import './metrics_manager'; +// import './metrics_manager.js'; // Unused import preserved for side-effects. Remove if unneeded. import './events/events_click.js'; diff --git a/scripts/gulpfiles/chunks.json b/scripts/gulpfiles/chunks.json index ed827caaf72..c07b7efa418 100644 --- a/scripts/gulpfiles/chunks.json +++ b/scripts/gulpfiles/chunks.json @@ -9,8 +9,12 @@ "all4:11:main" ], "js": [ + "./build/src/core/trashcan.js", "./build/src/core/toolbox/toolbox.js", + "./build/src/core/toolbox/separator.js", "./build/src/core/toolbox/collapsible_category.js", + "./build/src/core/toolbox/toolbox_item.js", + "./build/src/core/toolbox/category.js", "./build/src/core/theme/zelos.js", "./build/src/core/theme/themes.js", "./build/src/core/shortcut_items.js", @@ -35,22 +39,24 @@ "./build/src/core/renderers/minimalist/drawer.js", "./build/src/core/renderers/minimalist/constants.js", "./build/src/core/renderers/minimalist/minimalist.js", + "./build/src/core/renderers/geras/renderer.js", "./build/src/core/renderers/geras/path_object.js", "./build/src/core/renderers/geras/measurables/statement_input.js", "./build/src/core/renderers/geras/measurables/inline_input.js", "./build/src/core/renderers/geras/info.js", "./build/src/core/renderers/geras/highlight_constants.js", - "./build/src/core/renderers/geras/renderer.js", "./build/src/core/renderers/geras/highlighter.js", "./build/src/core/renderers/geras/drawer.js", "./build/src/core/renderers/geras/constants.js", "./build/src/core/renderers/geras/geras.js", "./build/src/core/workspace_drag_surface_svg.js", + "./build/src/core/shortcut_registry.js", "./build/src/core/inject.js", "./build/src/core/generator.js", "./build/src/core/flyout_vertical.js", "./build/src/core/flyout_horizontal.js", "./build/src/core/scrollbar_pair.js", + "./build/src/core/metrics_manager.js", "./build/src/core/flyout_metrics_manager.js", "./build/src/core/flyout_button.js", "./build/src/core/flyout_base.js", @@ -63,43 +69,51 @@ "./build/src/core/field_checkbox.js", "./build/src/core/field_textinput.js", "./build/src/core/field_angle.js", + "./build/src/core/drag_target.js", + "./build/src/core/delete_area.js", "./build/src/core/events/events_block_move.js", "./build/src/core/events/events_comment_move.js", "./build/src/core/events/events_toolbox_item_select.js", + "./build/src/core/events/events_trashcan_open.js", "./build/src/core/events/events.js", "./build/src/core/contextmenu_items.js", + "./build/src/core/warning.js", + "./build/src/core/rendered_connection.js", + "./build/src/core/keyboard_nav/marker.js", + "./build/src/core/keyboard_nav/cursor.js", + "./build/src/core/keyboard_nav/basic_cursor.js", + "./build/src/core/keyboard_nav/tab_navigate_cursor.js", + "./build/src/core/comment.js", + "./build/src/core/block_svg.js", + "./build/src/core/bump_objects.js", + "./build/src/core/events/events_block_drag.js", + "./build/src/core/block_dragger.js", "./build/src/core/block_drag_surface.js", - "./build/src/core/events/events_ui.js", - "./build/src/core/events/workspace_events.js", - "./build/src/core/serialization/registry.js", - "./build/src/core/serialization/priorities.js", - "./build/src/core/serialization/exceptions.js", + "./build/src/core/sprites.js", + "./build/src/core/positionable_helpers.js", + "./build/src/core/zoom_controls.js", + "./build/src/core/workspace_audio.js", "./build/src/core/events/events_var_rename.js", "./build/src/core/events/events_var_delete.js", "./build/src/core/variable_map.js", - "./build/src/core/constants.js", - "./build/src/core/connection.js", "./build/src/core/connection_checker.js", "./build/src/core/workspace.js", - "./build/src/core/field_dropdown.js", - "./build/src/core/workspace_audio.js", + "./build/src/core/variables_dynamic.js", "./build/src/core/utils.js", - "./build/src/core/drag_target.js", - "./build/src/core/delete_area.js", - "./build/src/core/events/events_trashcan_open.js", - "./build/src/core/trashcan.js", "./build/src/core/touch_gesture.js", "./build/src/core/theme_manager.js", + "./build/src/core/insertion_marker_manager.js", "./build/src/core/renderers/common/renderer.js", "./build/src/core/renderers/common/path_object.js", + "./build/src/core/keyboard_nav/ast_node.js", "./build/src/core/events/events_marker_move.js", "./build/src/core/renderers/common/marker_svg.js", - "./build/src/core/input_types.js", - "./build/src/core/input.js", "./build/src/core/renderers/common/info.js", "./build/src/core/renderers/common/drawer.js", + "./build/src/core/field_label.js", "./build/src/core/renderers/common/debugger.js", "./build/src/core/renderers/common/debug.js", + "./build/src/core/utils/svg_paths.js", "./build/src/core/renderers/common/constants.js", "./build/src/core/renderers/measurables/top_row.js", "./build/src/core/renderers/measurables/square_corner.js", @@ -124,112 +138,98 @@ "./build/src/core/renderers/measurables/types.js", "./build/src/core/renderers/measurables/base.js", "./build/src/core/renderers/common/block_rendering.js", + "./build/src/core/names.js", + "./build/src/core/procedures.js", "./build/src/core/grid.js", - "./build/src/core/connection_db.js", - "./build/src/core/warning.js", - "./build/src/core/keyboard_nav/marker.js", - "./build/src/core/keyboard_nav/cursor.js", - "./build/src/core/keyboard_nav/basic_cursor.js", - "./build/src/core/keyboard_nav/tab_navigate_cursor.js", - "./build/src/core/keyboard_nav/ast_node.js", - "./build/src/core/field_registry.js", - "./build/src/core/utils/sentinel.js", - "./build/src/core/marker_manager.js", - "./build/src/core/dropdowndiv.js", "./build/src/core/workspace_dragger.js", - "./build/src/core/tooltip.js", + "./build/src/core/internal_constants.js", "./build/src/core/bubble_dragger.js", - "./build/src/core/insertion_marker_manager.js", - "./build/src/core/bump_objects.js", - "./build/src/core/events/events_block_drag.js", - "./build/src/core/block_dragger.js", + "./build/src/core/block_animations.js", + "./build/src/core/events/events_click.js", "./build/src/core/gesture.js", - "./build/src/core/shortcut_registry.js", - "./build/src/core/field.js", - "./build/src/core/field_label.js", "./build/src/core/contextmenu_registry.js", - "./build/src/core/events/events_comment_change.js", - "./build/src/core/workspace_comment.js", - "./build/src/core/events/events_comment_delete.js", - "./build/src/core/events/events_comment_base.js", - "./build/src/core/events/events_comment_create.js", - "./build/src/core/workspace_comment_svg.js", - "./build/src/core/widgetdiv.js", - "./build/src/core/menuitem.js", - "./build/src/core/utils/keycodes.js", - "./build/src/core/menu.js", - "./build/src/core/clipboard.js", - "./build/src/core/contextmenu.js", - "./build/src/core/block_animations.js", - "./build/src/core/events/events_selected.js", - "./build/src/core/block_svg.js", - "./build/src/core/events/events_viewport.js", - "./build/src/core/events/events_theme_change.js", - "./build/src/core/sprites.js", - "./build/src/core/positionable_helpers.js", + "./build/src/core/connection_db.js", "./build/src/core/utils/array.js", "./build/src/core/component_manager.js", - "./build/src/core/events/events_click.js", - "./build/src/core/zoom_controls.js", - "./build/src/core/utils/svg_paths.js", - "./build/src/core/internal_constants.js", - "./build/src/core/rendered_connection.js", - "./build/src/core/variables_dynamic.js", - "./build/src/core/names.js", - "./build/src/core/procedures.js", + "./build/src/core/events/events_viewport.js", + "./build/src/core/events/events_theme_change.js", "./build/src/core/workspace_svg.js", + "./build/src/core/utils/toolbox.js", "./build/src/core/theme/classic.js", "./build/src/core/theme.js", "./build/src/core/options.js", "./build/src/core/icon.js", - "./build/src/core/config.js", - "./build/src/core/utils/math.js", - "./build/src/core/utils/style.js", - "./build/src/core/utils/rect.js", - "./build/src/core/utils/svg_math.js", - "./build/src/core/utils/svg.js", - "./build/src/core/utils/coordinate.js", "./build/src/core/scrollbar.js", - "./build/src/core/touch.js", - "./build/src/core/browser_events.js", - "./build/src/core/toolbox/separator.js", - "./build/src/core/toolbox/toolbox_item.js", - "./build/src/core/msg.js", - "./build/src/core/utils/parsing.js", - "./build/src/core/utils/useragent.js", - "./build/src/core/utils/dom.js", - "./build/src/core/utils/colour.js", - "./build/src/core/utils/aria.js", - "./build/src/core/utils/deprecation.js", - "./build/src/core/css.js", - "./build/src/core/toolbox/category.js", - "./build/src/core/utils/toolbox.js", - "./build/src/core/utils/size.js", - "./build/src/core/metrics_manager.js", "./build/src/core/bubble.js", - "./build/src/core/events/events_ui_base.js", "./build/src/core/events/events_bubble_open.js", "./build/src/core/mutator.js", + "./build/src/core/field_registry.js", + "./build/src/core/utils/sentinel.js", + "./build/src/core/utils/colour.js", + "./build/src/core/utils/parsing.js", + "./build/src/core/tooltip.js", + "./build/src/core/marker_manager.js", + "./build/src/core/field.js", + "./build/src/core/utils/math.js", + "./build/src/core/dropdowndiv.js", + "./build/src/core/field_dropdown.js", "./build/src/core/extensions.js", + "./build/src/core/constants.js", + "./build/src/core/connection_type.js", + "./build/src/core/connection.js", "./build/src/core/events/events_block_delete.js", - "./build/src/core/events/events_abstract.js", - "./build/src/core/events/events_block_base.js", "./build/src/core/events/events_block_change.js", "./build/src/core/block.js", + "./build/src/core/input.js", "./build/src/core/utils/object.js", + "./build/src/core/utils/string.js", + "./build/src/core/events/events_ui.js", + "./build/src/core/events/workspace_events.js", + "./build/src/core/events/events_block_base.js", + "./build/src/core/serialization/registry.js", + "./build/src/core/serialization/priorities.js", + "./build/src/core/serialization/exceptions.js", + "./build/src/core/utils/useragent.js", + "./build/src/core/utils/dom.js", "./build/src/core/dialog.js", + "./build/src/core/msg.js", + "./build/src/core/events/events_abstract.js", "./build/src/core/events/events_var_base.js", "./build/src/core/events/events_var_create.js", "./build/src/core/variable_model.js", "./build/src/core/variables.js", - "./build/src/core/utils/string.js", - "./build/src/core/comment.js", + "./build/src/core/events/events_comment_base.js", + "./build/src/core/events/events_comment_change.js", + "./build/src/core/events/events_comment_create.js", + "./build/src/core/events/events_comment_delete.js", + "./build/src/core/utils/coordinate.js", + "./build/src/core/workspace_comment.js", + "./build/src/core/events/events_ui_base.js", + "./build/src/core/events/events_selected.js", + "./build/src/core/touch.js", + "./build/src/core/browser_events.js", + "./build/src/core/clipboard.js", + "./build/src/core/config.js", + "./build/src/core/utils/aria.js", + "./build/src/core/utils/keycodes.js", + "./build/src/core/utils/rect.js", + "./build/src/core/utils/style.js", + "./build/src/core/menu.js", + "./build/src/core/menuitem.js", + "./build/src/core/utils/deprecation.js", + "./build/src/core/utils/svg_math.js", + "./build/src/core/widgetdiv.js", + "./build/src/core/contextmenu.js", + "./build/src/core/css.js", + "./build/src/core/utils/svg.js", + "./build/src/core/workspace_comment_svg.js", "./build/src/core/xml.js", "./build/src/core/utils/xml.js", - "./build/src/core/connection_type.js", + "./build/src/core/utils/size.js", + "./build/src/core/input_types.js", + "./build/src/core/utils/idgenerator.js", "./build/src/core/blocks.js", "./build/src/core/common.js", - "./build/src/core/utils/idgenerator.js", "./build/src/core/events/utils.js", "./build/src/core/serialization/blocks.js", "./build/src/core/registry.js", From 2065b5d43b6248416e3d2b590369a8a5fb08fde7 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Fri, 22 Jul 2022 18:19:01 +0000 Subject: [PATCH 07/44] fix goog/base order --- closure/goog/goog.js | 139 +++++++++++++++++++++++++++++++------------ 1 file changed, 100 insertions(+), 39 deletions(-) diff --git a/closure/goog/goog.js b/closure/goog/goog.js index 8791f716ef7..f7422fdd8f9 100644 --- a/closure/goog/goog.js +++ b/closure/goog/goog.js @@ -36,48 +36,109 @@ * goog.require calls. */ -export const global = goog.global; -export const require = goog.require; -export const define = goog.define; -export const DEBUG = goog.DEBUG; -export const LOCALE = goog.LOCALE; -export const TRUSTED_SITE = goog.TRUSTED_SITE; -export const DISALLOW_TEST_ONLY_CODE = goog.DISALLOW_TEST_ONLY_CODE; -export const getGoogModule = goog.module.get; -export const setTestOnly = goog.setTestOnly; -export const forwardDeclare = goog.forwardDeclare; -export const getObjectByName = goog.getObjectByName; -export const basePath = goog.basePath; -export const addSingletonGetter = goog.addSingletonGetter; -export const typeOf = goog.typeOf; -export const isArrayLike = goog.isArrayLike; -export const isDateLike = goog.isDateLike; -export const isObject = goog.isObject; -export const getUid = goog.getUid; -export const hasUid = goog.hasUid; -export const removeUid = goog.removeUid; -export const now = Date.now; -export const globalEval = goog.globalEval; -export const getCssName = goog.getCssName; -export const setCssNameMapping = goog.setCssNameMapping; -export const getMsg = goog.getMsg; -export const getMsgWithFallback = goog.getMsgWithFallback; -export const exportSymbol = goog.exportSymbol; -export const exportProperty = goog.exportProperty; -export const abstractMethod = goog.abstractMethod; -export const cloneObject = goog.cloneObject; -export const bind = goog.bind; -export const partial = goog.partial; -export const inherits = goog.inherits; -export const scope = goog.scope; -export const defineClass = goog.defineClass; -export const declareModuleId = goog.declareModuleId; +export const global = globalThis; +export const require = function(namespace) { + if (!COMPILED) { + // Might need to lazy load on old IE. + if (goog.ENABLE_DEBUG_LOADER) { + goog.debugLoader_.requested(namespace); + } + + // If the object already exists we do not need to do anything. + if (goog.isProvided_(namespace)) { + if (goog.isInModuleLoader_()) { + return goog.module.getInternal_(namespace); + } + } else if (goog.ENABLE_DEBUG_LOADER) { + var moduleLoaderState = goog.moduleLoaderState_; + goog.moduleLoaderState_ = null; + try { + goog.debugLoader_.load_(namespace); + } finally { + goog.moduleLoaderState_ = moduleLoaderState; + } + } + + return null; + } +}; + + +// export const define = goog.define; +// export const DEBUG = goog.DEBUG; +// export const LOCALE = goog.LOCALE; +// export const TRUSTED_SITE = goog.TRUSTED_SITE; +// export const DISALLOW_TEST_ONLY_CODE = goog.DISALLOW_TEST_ONLY_CODE; +// export const getGoogModule = goog.module.get; +// export const setTestOnly = goog.setTestOnly; +// export const forwardDeclare = goog.forwardDeclare; +// export const getObjectByName = goog.getObjectByName; +// export const basePath = goog.basePath; +// export const addSingletonGetter = goog.addSingletonGetter; +// export const typeOf = goog.typeOf; +// export const isArrayLike = goog.isArrayLike; +// export const isDateLike = goog.isDateLike; +// export const isObject = goog.isObject; +// export const getUid = goog.getUid; +// export const hasUid = goog.hasUid; +// export const removeUid = goog.removeUid; +// export const now = Date.now; +// export const globalEval = goog.globalEval; +// export const getCssName = goog.getCssName; +// export const setCssNameMapping = goog.setCssNameMapping; +// export const getMsg = goog.getMsg; +// export const getMsgWithFallback = goog.getMsgWithFallback; +// export const exportSymbol = goog.exportSymbol; +// export const exportProperty = goog.exportProperty; +// export const abstractMethod = goog.abstractMethod; +// export const cloneObject = goog.cloneObject; +// export const bind = goog.bind; +// export const partial = goog.partial; +// export const inherits = goog.inherits; +// export const scope = goog.scope; +// export const defineClass = goog.defineClass; +export const declareModuleId = function(namespace) { + if (!COMPILED) { + if (!goog.isInEs6ModuleLoader_()) { + throw new Error( + 'goog.declareModuleId may only be called from ' + + 'within an ES6 module'); + } + if (goog.moduleLoaderState_ && goog.moduleLoaderState_.moduleName) { + throw new Error( + 'goog.declareModuleId may only be called once per module.'); + } + if (namespace in goog.loadedModules_) { + throw new Error( + 'Module with namespace "' + namespace + '" already exists.'); + } + } + if (goog.moduleLoaderState_) { + // Not bundled - debug loading. + goog.moduleLoaderState_.moduleName = namespace; + } else { + // Bundled - not debug loading, no module loader state. + var jscomp = goog.global['$jscomp']; + if (!jscomp || typeof jscomp.getCurrentModulePath != 'function') { + throw new Error( + 'Module with namespace "' + namespace + + '" has been loaded incorrectly.'); + } + var exports = jscomp.require(jscomp.getCurrentModulePath()); + goog.loadedModules_[namespace] = { + exports: exports, + type: goog.ModuleType.ES6, + moduleId: namespace + }; + } +}; + // Export select properties of module. Do not export the function itself or // goog.module.declareLegacyNamespace. -export const module = { - get: goog.module.get, -}; +// export const module = { +// get: goog.module.get, +// }; // Omissions include: // goog.ENABLE_DEBUG_LOADER - define only used in base. From fa18faa30c0ebaaf96b4d7768108b86b14dc43f6 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Fri, 22 Jul 2022 18:19:19 +0000 Subject: [PATCH 08/44] add trashcan patch --- core/blockly.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/blockly.ts b/core/blockly.ts index 8bbb8a20f88..e9f39daaa0a 100644 --- a/core/blockly.ts +++ b/core/blockly.ts @@ -580,9 +580,9 @@ WorkspaceSvg.prototype.newBlock = function (prototypeName: string, opt_id?: stri return new BlockSvg(this, prototypeName, opt_id); } -// WorkspaceSvg.newTrashcan = function(workspace: WorkspaceSvg): Trashcan { -// return new Trashcan(workspace); -// } +WorkspaceSvg.newTrashcan = function(workspace: WorkspaceSvg): Trashcan { + return new Trashcan(workspace); +} // Re-export submodules that no longer declareLegacyNamespace. export {browserEvents}; From 2dfd41a5b12041d045479b192975579bdb83100f Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Fri, 22 Jul 2022 18:39:16 +0000 Subject: [PATCH 09/44] fix: types of compose and decompose in block --- core/block.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/block.ts b/core/block.ts index 2931dd6ac40..d9552a8a6cd 100644 --- a/core/block.ts +++ b/core/block.ts @@ -144,13 +144,13 @@ export class Block implements IASTNodeLocation, IDeletable { * An optional function that reconfigures the block based on the contents of * the mutator dialog. */ - compose?: ((p1: Block) => void)|null = null; + compose?: ((p1: Block) => void)|null = undefined; /** * An optional function that populates the mutator's dialog with * this block's components. */ - decompose?: ((p1: Workspace) => Block)|null = null; + decompose?: ((p1: Workspace) => Block)|null = undefined; id: string; // AnyDuringMigration because: Type 'null' is not assignable to type // 'Connection'. From 1678ebcd28cfdb055f58b7bb8df35a8f821a4756 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Fri, 22 Jul 2022 18:39:26 +0000 Subject: [PATCH 10/44] fix: workspace naming in toolbox --- core/toolbox/toolbox.ts | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/core/toolbox/toolbox.ts b/core/toolbox/toolbox.ts index be8d16f41eb..3ca3ceeffcd 100644 --- a/core/toolbox/toolbox.ts +++ b/core/toolbox/toolbox.ts @@ -107,10 +107,14 @@ export class Toolbox extends DeleteArea implements IAutoHideable, protected boundEvents_: browserEvents.Data[] = []; override wouldDelete_: AnyDuringMigration; + protected readonly workspace_: WorkspaceSvg; + /** @param workspace The workspace in which to create new blocks. */ - constructor(private readonly workspace: WorkspaceSvg) { + constructor(workspace: WorkspaceSvg) { super(); + this.workspace_ = workspace; + /** The JSON describing the contents of this toolbox. */ // AnyDuringMigration because: Type 'ToolboxInfo | { contents: never[]; }' // is not assignable to type 'ToolboxInfo'. @@ -141,12 +145,12 @@ export class Toolbox extends DeleteArea implements IAutoHideable, /** Initializes the toolbox */ init() { - const workspace = this.workspace; + const workspace = this.workspace_; const svg = workspace.getParentSvg(); this.flyout_ = this.createFlyout_(); - this.HtmlDiv = this.createDom_(this.workspace); + this.HtmlDiv = this.createDom_(this.workspace_); dom.insertAfter(this.flyout_.createDom('svg'), svg); this.setVisible(true); this.flyout_.init(workspace); @@ -156,7 +160,7 @@ export class Toolbox extends DeleteArea implements IAutoHideable, themeManager.subscribe( this.HtmlDiv, 'toolboxBackgroundColour', 'background-color'); themeManager.subscribe(this.HtmlDiv, 'toolboxForegroundColour', 'color'); - this.workspace.getComponentManager().addComponent({ + this.workspace_.getComponentManager().addComponent({ component: this, weight: 1, capabilities: [ @@ -310,7 +314,7 @@ export class Toolbox extends DeleteArea implements IAutoHideable, * `Blockly.VerticalFlyout`, and no flyout plugin is specified. */ protected createFlyout_(): IFlyout { - const workspace = this.workspace; + const workspace = this.workspace_; // TODO (#4247): Look into adding a makeFlyout method to Blockly Options. const workspaceOptions = new Options(({ 'parentWorkspace': workspace, @@ -603,7 +607,7 @@ export class Toolbox extends DeleteArea implements IAutoHideable, * @return The parent workspace for the toolbox. */ getWorkspace(): WorkspaceSvg { - return this.workspace; + return this.workspace_; } /** @@ -637,7 +641,7 @@ export class Toolbox extends DeleteArea implements IAutoHideable, * whether the workspace is in rtl. */ position() { - const workspaceMetrics = this.workspace.getMetrics(); + const workspaceMetrics = this.workspace_.getMetrics(); const toolboxDiv = this.HtmlDiv; if (!toolboxDiv) { // Not initialized yet. @@ -675,7 +679,7 @@ export class Toolbox extends DeleteArea implements IAutoHideable, handleToolboxItemResize() { // Reposition the workspace so that (0,0) is in the correct position // relative to the new absolute edge (ie toolbox edge). - const workspace = this.workspace; + const workspace = this.workspace_; const rect = this.HtmlDiv!.getBoundingClientRect(); const newX = this.toolboxPosition === toolbox.Position.LEFT ? workspace.scrollX + rect.width : @@ -735,7 +739,7 @@ export class Toolbox extends DeleteArea implements IAutoHideable, this.isVisible_ = isVisible; // Invisible toolbox is ignored as drag targets and must have the drag // target updated. - this.workspace.recordDragTargets(); + this.workspace_.recordDragTargets(); } /** @@ -887,7 +891,7 @@ export class Toolbox extends DeleteArea implements IAutoHideable, newElement = null; } const event = new (eventUtils.get(eventUtils.TOOLBOX_ITEM_SELECT))! - (oldElement, newElement, this.workspace.id); + (oldElement, newElement, this.workspace_.id); eventUtils.fire(event); } @@ -981,7 +985,7 @@ export class Toolbox extends DeleteArea implements IAutoHideable, /** Disposes of this toolbox. */ dispose() { - this.workspace.getComponentManager().removeComponent('toolbox'); + this.workspace_.getComponentManager().removeComponent('toolbox'); this.flyout_!.dispose(); for (let i = 0; i < this.contents_.length; i++) { const toolboxItem = this.contents_[i]; @@ -996,7 +1000,7 @@ export class Toolbox extends DeleteArea implements IAutoHideable, // AnyDuringMigration because: Argument of type 'HTMLDivElement | null' is // not assignable to parameter of type 'Element'. - this.workspace.getThemeManager().unsubscribe( + this.workspace_.getThemeManager().unsubscribe( this.HtmlDiv as AnyDuringMigration); dom.removeNode(this.HtmlDiv); } From 7c327664d4188515a1f5742eae4ffdb6093c6c06 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Fri, 22 Jul 2022 22:13:48 +0000 Subject: [PATCH 11/44] chore: add jsdoc --- core/toolbox/toolbox.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/core/toolbox/toolbox.ts b/core/toolbox/toolbox.ts index 3ca3ceeffcd..05c0be4b3e0 100644 --- a/core/toolbox/toolbox.ts +++ b/core/toolbox/toolbox.ts @@ -107,6 +107,7 @@ export class Toolbox extends DeleteArea implements IAutoHideable, protected boundEvents_: browserEvents.Data[] = []; override wouldDelete_: AnyDuringMigration; + /** The workspace this toolbox is on. */ protected readonly workspace_: WorkspaceSvg; /** @param workspace The workspace in which to create new blocks. */ From 5eaf042b873049fe6530866332cf9914237a8644 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Fri, 22 Jul 2022 22:19:49 +0000 Subject: [PATCH 12/44] chore: restore registry comments to better positions --- core/registry.ts | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/core/registry.ts b/core/registry.ts index 0439d1482ba..003d2a20001 100644 --- a/core/registry.ts +++ b/core/registry.ts @@ -61,19 +61,44 @@ export const DEFAULT = 'default'; * @alias Blockly.registry.Type */ export class Type { + // Type.CONNECTION_CHECKER = new Type('connectionChecker'); static CONNECTION_CHECKER = new Type('connectionChecker'); + + // Type.CURSOR = new Type('cursor'); static CURSOR = new Type('cursor'); + + // Type.EVENT = new Type('event'); static EVENT = new Type('event'); + + // Type.FIELD = new Type('field'); static FIELD = new Type('field'); + + // Type.RENDERER = new Type('renderer'); static RENDERER = new Type('renderer'); + + // Type.TOOLBOX = new Type('toolbox'); static TOOLBOX = new Type('toolbox'); + + // Type.THEME = new Type('theme'); static THEME = new Type('theme'); + + // Type.TOOLBOX_ITEM = new Type('toolboxItem'); static TOOLBOX_ITEM = new Type('toolboxItem'); + + // Type.FLYOUTS_VERTICAL_TOOLBOX = new Type('flyoutsVerticalToolbox'); static FLYOUTS_VERTICAL_TOOLBOX = new Type('flyoutsVerticalToolbox'); + + // Type.FLYOUTS_HORIZONTAL_TOOLBOX = new Type('flyoutsHorizontalToolbox'); static FLYOUTS_HORIZONTAL_TOOLBOX = new Type('flyoutsHorizontalToolbox'); + + // Type.METRICS_MANAGER = new Type('metricsManager'); static METRICS_MANAGER = new Type('metricsManager'); + + // Type.BLOCK_DRAGGER = new Type('blockDragger'); static BLOCK_DRAGGER = new Type('blockDragger'); + + // Type.SERIALIZER = new Type('serializer'); /** @internal */ static SERIALIZER = new Type('serializer'); @@ -89,31 +114,11 @@ export class Type { } } -// Type.CONNECTION_CHECKER = new Type('connectionChecker'); - -// Type.CURSOR = new Type('cursor'); - -// Type.EVENT = new Type('event'); - -// Type.FIELD = new Type('field'); - -// Type.RENDERER = new Type('renderer'); - -// Type.TOOLBOX = new Type('toolbox'); - -// Type.THEME = new Type('theme'); - -// Type.TOOLBOX_ITEM = new Type('toolboxItem'); -// Type.FLYOUTS_VERTICAL_TOOLBOX = new Type('flyoutsVerticalToolbox'); -// Type.FLYOUTS_HORIZONTAL_TOOLBOX = new Type('flyoutsHorizontalToolbox'); -// Type.METRICS_MANAGER = new Type('metricsManager'); -// Type.BLOCK_DRAGGER = new Type('blockDragger'); -// Type.SERIALIZER = new Type('serializer'); /** * Registers a class based on a type and name. From 090cd0a53c83a993c8905513d6af50d8f1a7c1c8 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Mon, 25 Jul 2022 18:57:06 +0000 Subject: [PATCH 13/44] chore: remove implementations in goog.js --- closure/goog/goog.js | 62 +++----------------------------------------- 1 file changed, 3 insertions(+), 59 deletions(-) diff --git a/closure/goog/goog.js b/closure/goog/goog.js index f7422fdd8f9..6e81b698771 100644 --- a/closure/goog/goog.js +++ b/closure/goog/goog.js @@ -37,33 +37,7 @@ */ export const global = globalThis; -export const require = function(namespace) { - if (!COMPILED) { - // Might need to lazy load on old IE. - if (goog.ENABLE_DEBUG_LOADER) { - goog.debugLoader_.requested(namespace); - } - - // If the object already exists we do not need to do anything. - if (goog.isProvided_(namespace)) { - if (goog.isInModuleLoader_()) { - return goog.module.getInternal_(namespace); - } - } else if (goog.ENABLE_DEBUG_LOADER) { - var moduleLoaderState = goog.moduleLoaderState_; - goog.moduleLoaderState_ = null; - try { - goog.debugLoader_.load_(namespace); - } finally { - goog.moduleLoaderState_ = moduleLoaderState; - } - } - - return null; - } -}; - - +// export const require = goog.require; // export const define = goog.define; // export const DEBUG = goog.DEBUG; // export const LOCALE = goog.LOCALE; @@ -98,38 +72,8 @@ export const require = function(namespace) { // export const scope = goog.scope; // export const defineClass = goog.defineClass; export const declareModuleId = function(namespace) { - if (!COMPILED) { - if (!goog.isInEs6ModuleLoader_()) { - throw new Error( - 'goog.declareModuleId may only be called from ' + - 'within an ES6 module'); - } - if (goog.moduleLoaderState_ && goog.moduleLoaderState_.moduleName) { - throw new Error( - 'goog.declareModuleId may only be called once per module.'); - } - if (namespace in goog.loadedModules_) { - throw new Error( - 'Module with namespace "' + namespace + '" already exists.'); - } - } - if (goog.moduleLoaderState_) { - // Not bundled - debug loading. - goog.moduleLoaderState_.moduleName = namespace; - } else { - // Bundled - not debug loading, no module loader state. - var jscomp = goog.global['$jscomp']; - if (!jscomp || typeof jscomp.getCurrentModulePath != 'function') { - throw new Error( - 'Module with namespace "' + namespace + - '" has been loaded incorrectly.'); - } - var exports = jscomp.require(jscomp.getCurrentModulePath()); - goog.loadedModules_[namespace] = { - exports: exports, - type: goog.ModuleType.ES6, - moduleId: namespace - }; + if (window.goog && window.goog.declareModuleId) { + window.goog.declareModuleId.call(this, namespace); } }; From e0cc6e03e53e3b847d3a15ff886c137dc4aaeee0 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Mon, 25 Jul 2022 18:57:31 +0000 Subject: [PATCH 14/44] chore: fix types of stubs --- core/workspace.ts | 4 ++-- core/workspace_svg.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/workspace.ts b/core/workspace.ts index 8508356f496..d3aa51bf38a 100644 --- a/core/workspace.ts +++ b/core/workspace.ts @@ -508,8 +508,8 @@ export class Workspace implements IASTNodeLocation { * ID. * @return The created block. */ - newBlock(prototypeName: string, opt_id?: string): AnyDuringMigration { - return {}; + newBlock(prototypeName: string, opt_id?: string): Block { + throw new Error('unimplemented'); } /** diff --git a/core/workspace_svg.ts b/core/workspace_svg.ts index 4e5620fff7d..5269b73f64a 100644 --- a/core/workspace_svg.ts +++ b/core/workspace_svg.ts @@ -962,8 +962,8 @@ export class WorkspaceSvg extends Workspace implements IASTNodeLocationSvg { /** * @internal */ - static newTrashcan(workspace: WorkspaceSvg): AnyDuringMigration { - return {}; + static newTrashcan(workspace: WorkspaceSvg): Trashcan { + throw new Error('unimplemented'); } /** @@ -1669,8 +1669,8 @@ export class WorkspaceSvg extends Workspace implements IASTNodeLocationSvg { * ID. * @return The created block. */ - override newBlock(prototypeName: string, opt_id?: string): AnyDuringMigration { - return {}; + override newBlock(prototypeName: string, opt_id?: string): BlockSvg { + throw new Error('unimplemented'); } /** From b205d872b6bb6626ce5f4cac0aefecae05250c0f Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Mon, 25 Jul 2022 19:11:17 +0000 Subject: [PATCH 15/44] chore: remove added AnyDuringMigration casts --- core/procedures.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/procedures.ts b/core/procedures.ts index dccab8e6be9..f5ac72f7317 100644 --- a/core/procedures.ts +++ b/core/procedures.ts @@ -335,7 +335,7 @@ export function mutatorOpenListener(e: Abstract) { } const workspaceId = (bubbleEvent.workspaceId); const block = common.getWorkspaceById(workspaceId)!.getBlockById( - bubbleEvent.blockId) as AnyDuringMigration as BlockSvg; + bubbleEvent.blockId) as BlockSvg; const type = block.type; if (type !== 'procedures_defnoreturn' && type !== 'procedures_defreturn') { return; @@ -356,7 +356,7 @@ function mutatorChangeListener(e: Abstract) { return; } const workspaceId = e.workspaceId as string; - const workspace = common.getWorkspaceById(workspaceId) as AnyDuringMigration as WorkspaceSvg; + const workspace = common.getWorkspaceById(workspaceId) as WorkspaceSvg; updateMutatorFlyout(workspace); } From 28fb935398ec683087607634d2b1a75bca4130ed Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Mon, 25 Jul 2022 19:14:45 +0000 Subject: [PATCH 16/44] chore: remove modifications to xml and variables --- core/utils/xml.ts | 9 --------- core/variables.ts | 2 +- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/core/utils/xml.ts b/core/utils/xml.ts index 74bcc84efe6..1309a599c8b 100644 --- a/core/utils/xml.ts +++ b/core/utils/xml.ts @@ -94,13 +94,4 @@ export function textToDomDocument(text: string): Document { export function domToText(dom: Node): string { const oSerializer = new XMLSerializer(); return oSerializer.serializeToString(dom); -} - -export function textToDom(text: string): Element { - const doc = textToDomDocument(text); - if (!doc || !doc.documentElement || - doc.getElementsByTagName('parsererror').length) { - throw Error('textToDom was unable to parse: ' + text); - } - return doc.documentElement; } \ No newline at end of file diff --git a/core/variables.ts b/core/variables.ts index 773dd3103c5..f3571530562 100644 --- a/core/variables.ts +++ b/core/variables.ts @@ -175,7 +175,7 @@ export function flyoutCategoryBlocks(workspace: Workspace): Element[] { // assignable to parameter of type 'Node'. block.appendChild( generateVariableFieldDom(mostRecentVariable) as AnyDuringMigration); - const value = utilsXml.textToDom( + const value = Xml.textToDom( '' + '' + '1' + From ba997ca1d8d5795bc7d247da6a26ea595ad7e019 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Mon, 25 Jul 2022 19:17:25 +0000 Subject: [PATCH 17/44] chore: format --- core/blockly.ts | 27 ++++++++++++++++----------- core/workspace.ts | 2 +- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/core/blockly.ts b/core/blockly.ts index e9f39daaa0a..c539154c8b9 100644 --- a/core/blockly.ts +++ b/core/blockly.ts @@ -572,17 +572,22 @@ export const PROCEDURE_CATEGORY_NAME: string = (Procedures as AnyDuringMigration).CATEGORY_NAME; // I hate this so much. -Workspace.prototype.newBlock = function (prototypeName: string, opt_id?: string): Block { - return new Block(this, prototypeName, opt_id); -} - -WorkspaceSvg.prototype.newBlock = function (prototypeName: string, opt_id?: string): BlockSvg { - return new BlockSvg(this, prototypeName, opt_id); -} - -WorkspaceSvg.newTrashcan = function(workspace: WorkspaceSvg): Trashcan { - return new Trashcan(workspace); -} +Workspace.prototype.newBlock = function(prototypeName: string, opt_id?: string): + Block { + return new Block( + this, prototypeName, opt_id); + } + + WorkspaceSvg.prototype.newBlock = + function(prototypeName: string, opt_id?: string): + BlockSvg { + return new BlockSvg(this, prototypeName, opt_id); + } + + WorkspaceSvg.newTrashcan = function(workspace: WorkspaceSvg): + Trashcan { + return new Trashcan(workspace); + } // Re-export submodules that no longer declareLegacyNamespace. export {browserEvents}; diff --git a/core/workspace.ts b/core/workspace.ts index d3aa51bf38a..76ad30ec045 100644 --- a/core/workspace.ts +++ b/core/workspace.ts @@ -18,7 +18,7 @@ goog.declareModuleId('Blockly.Workspace'); // Unused import preserved for side-effects. Remove if unneeded. import './connection_checker.js'; -import type {Block} from './block.js'; +import type {Block} from './block.js'; import type {BlocklyOptions} from './blockly_options.js'; import type {ConnectionDB} from './connection_db.js'; import type {Abstract} from './events/events_abstract.js'; From 03d14024c0d6cc8c7abc09234a7dead95807ce94 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Tue, 26 Jul 2022 21:42:29 +0000 Subject: [PATCH 18/44] chore: remove event requirements in workspace comments --- core/blockly.ts | 2 ++ core/workspace_comment.ts | 6 +++--- core/workspace_comment_svg.ts | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/core/blockly.ts b/core/blockly.ts index c539154c8b9..15602775a2e 100644 --- a/core/blockly.ts +++ b/core/blockly.ts @@ -589,6 +589,8 @@ Workspace.prototype.newBlock = function(prototypeName: string, opt_id?: string): return new Trashcan(workspace); } + + // Re-export submodules that no longer declareLegacyNamespace. export {browserEvents}; export {ContextMenu}; diff --git a/core/workspace_comment.ts b/core/workspace_comment.ts index ce6d8d76f7c..8d0403adafd 100644 --- a/core/workspace_comment.ts +++ b/core/workspace_comment.ts @@ -16,11 +16,11 @@ import * as goog from '../closure/goog/goog.js'; goog.declareModuleId('Blockly.WorkspaceComment'); // Unused import preserved for side-effects. Remove if unneeded. -import './events/events_comment_change.js'; +// import './events/events_comment_change.js'; // Unused import preserved for side-effects. Remove if unneeded. -import './events/events_comment_create.js'; +// import './events/events_comment_create.js'; // Unused import preserved for side-effects. Remove if unneeded. -import './events/events_comment_delete.js'; +// import './events/events_comment_delete.js'; import type {CommentMove} from './events/events_comment_move.js'; import * as eventUtils from './events/utils.js'; diff --git a/core/workspace_comment_svg.ts b/core/workspace_comment_svg.ts index a0257a5c7a3..f86082f5ed3 100644 --- a/core/workspace_comment_svg.ts +++ b/core/workspace_comment_svg.ts @@ -16,9 +16,9 @@ import * as goog from '../closure/goog/goog.js'; goog.declareModuleId('Blockly.WorkspaceCommentSvg'); // Unused import preserved for side-effects. Remove if unneeded. -import './events/events_comment_create.js'; +// import './events/events_comment_create.js'; // Unused import preserved for side-effects. Remove if unneeded. -import './events/events_comment_delete.js'; +// import './events/events_comment_delete.js'; // Unused import preserved for side-effects. Remove if unneeded. import './events/events_selected.js'; From 3556a3c7af4c079e1999b9005a60ddb5903286e1 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Tue, 26 Jul 2022 21:46:11 +0000 Subject: [PATCH 19/44] chore: fix circular dependency with xml and workspace comments --- core/blockly.ts | 15 +++++++++++++++ core/workspace_comment_svg.ts | 14 +------------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/core/blockly.ts b/core/blockly.ts index 15602775a2e..5391cab534d 100644 --- a/core/blockly.ts +++ b/core/blockly.ts @@ -589,6 +589,21 @@ Workspace.prototype.newBlock = function(prototypeName: string, opt_id?: string): return new Trashcan(workspace); } +WorkspaceCommentSvg.prototype.showContextMenu = function(this: WorkspaceCommentSvg, e: Event) { + if (this.workspace.options.readOnly) { + return; + } + // Save the current workspace comment in a variable for use in closures. + const comment = this; + const menuOptions = []; + + if (this.isDeletable() && this.isMovable()) { + menuOptions.push(ContextMenu.commentDuplicateOption(comment)); + menuOptions.push(ContextMenu.commentDeleteOption(comment)); + } + + ContextMenu.show(e, menuOptions, this.RTL); +} // Re-export submodules that no longer declareLegacyNamespace. diff --git a/core/workspace_comment_svg.ts b/core/workspace_comment_svg.ts index f86082f5ed3..b17a6fc1085 100644 --- a/core/workspace_comment_svg.ts +++ b/core/workspace_comment_svg.ts @@ -210,19 +210,7 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements * @internal */ showContextMenu(e: Event) { - if (this.workspace.options.readOnly) { - return; - } - // Save the current workspace comment in a variable for use in closures. - const comment = this; - const menuOptions = []; - - if (this.isDeletable() && this.isMovable()) { - menuOptions.push(ContextMenu.commentDuplicateOption(comment)); - menuOptions.push(ContextMenu.commentDeleteOption(comment)); - } - - ContextMenu.show(e, menuOptions, this.RTL); + throw new Error('unimplemented')l; } /** From 5c9da665c49ff11c52c7eca9684e1535420d194a Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Tue, 26 Jul 2022 21:47:00 +0000 Subject: [PATCH 20/44] fixup remove ContextMenu import --- core/workspace_comment_svg.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/workspace_comment_svg.ts b/core/workspace_comment_svg.ts index b17a6fc1085..36a70256316 100644 --- a/core/workspace_comment_svg.ts +++ b/core/workspace_comment_svg.ts @@ -25,7 +25,7 @@ import './events/events_selected.js'; import type {BlockDragSurfaceSvg} from './block_drag_surface.js'; import * as browserEvents from './browser_events.js'; import * as common from './common.js'; -import * as ContextMenu from './contextmenu.js'; +// import * as ContextMenu from './contextmenu.js'; import * as Css from './css.js'; import type {CommentMove} from './events/events_comment_move.js'; import * as eventUtils from './events/utils.js'; From 72acfd42f4f8ce9715c8d185c485db59ed61c53e Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Tue, 26 Jul 2022 21:50:02 +0000 Subject: [PATCH 21/44] chore: fix dependency between mutator and workspace --- core/blockly.ts | 4 ++++ core/mutator.ts | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/core/blockly.ts b/core/blockly.ts index 5391cab534d..c030fcc3c49 100644 --- a/core/blockly.ts +++ b/core/blockly.ts @@ -605,6 +605,10 @@ WorkspaceCommentSvg.prototype.showContextMenu = function(this: WorkspaceCommentS ContextMenu.show(e, menuOptions, this.RTL); } +Mutator.prototype.newWorkspaceSvg = function(options: Options): WorkspaceSvg { + return new WorkspaceSvg(options); +} + // Re-export submodules that no longer declareLegacyNamespace. export {browserEvents}; diff --git a/core/mutator.ts b/core/mutator.ts index 0b3d1e29753..dc66c6923c6 100644 --- a/core/mutator.ts +++ b/core/mutator.ts @@ -36,7 +36,7 @@ import * as dom from './utils/dom.js'; import {Svg} from './utils/svg.js'; import * as toolbox from './utils/toolbox.js'; import * as xml from './utils/xml.js'; -import {WorkspaceSvg} from './workspace_svg.js'; +import type {WorkspaceSvg} from './workspace_svg.js'; /** @@ -190,7 +190,7 @@ export class Mutator extends Icon { if (hasFlyout) { workspaceOptions.languageTree = toolbox.convertToolboxDefToJson(quarkXml); } - this.workspace_ = new WorkspaceSvg(workspaceOptions); + this.workspace_ = this.newWorkspaceSvg(workspaceOptions); this.workspace_.isMutator = true; this.workspace_.addChangeListener(eventUtils.disableOrphans); @@ -214,6 +214,13 @@ export class Mutator extends Icon { return this.svgDialog_ as AnyDuringMigration; } + /** + * @internal + */ + newWorkspaceSvg(options: Options): WorkspaceSvg { + throw new Error('unimplemented'); + } + /** Add or remove the UI indicating if this icon may be clicked or not. */ override updateEditable() { super.updateEditable(); From b66345ed6179356c87146f3c21b2590518ec427b Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Tue, 26 Jul 2022 21:52:23 +0000 Subject: [PATCH 22/44] chore: break circular dependency between names and procedures --- core/blockly.ts | 10 ++++++++++ core/names.ts | 10 ++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/core/blockly.ts b/core/blockly.ts index c030fcc3c49..c50cbafdbda 100644 --- a/core/blockly.ts +++ b/core/blockly.ts @@ -609,6 +609,16 @@ Mutator.prototype.newWorkspaceSvg = function(options: Options): WorkspaceSvg { return new WorkspaceSvg(options); } +Names.prototype.populateProcedures = function(this: Names, workspace: Workspace) { + let procedures = Procedures.allProcedures(workspace); + // Flatten the return vs no-return procedure lists. + let flattenedProcedures: AnyDuringMigration[][] = + procedures[0].concat(procedures[1]); + for (let i = 0; i < flattenedProcedures.length; i++) { + this.getName(flattenedProcedures[i][0], Names.NameType.PROCEDURE); + } +} + // Re-export submodules that no longer declareLegacyNamespace. export {browserEvents}; diff --git a/core/names.ts b/core/names.ts index a74ceb529f8..9322cc79272 100644 --- a/core/names.ts +++ b/core/names.ts @@ -19,7 +19,7 @@ goog.declareModuleId('Blockly.Names'); // import './procedures.js'; import {Msg} from './msg.js'; -import * as Procedures from './procedures.js'; +// import * as Procedures from './procedures.js'; import type {VariableMap} from './variable_map.js'; import * as Variables from './variables.js'; import type {Workspace} from './workspace.js'; @@ -129,13 +129,7 @@ export class Names { * @param workspace Workspace to generate procedures from. */ populateProcedures(workspace: Workspace) { - let procedures = Procedures.allProcedures(workspace); - // Flatten the return vs no-return procedure lists. - let flattenedProcedures: AnyDuringMigration[][] = - procedures[0].concat(procedures[1]); - for (let i = 0; i < flattenedProcedures.length; i++) { - this.getName(flattenedProcedures[i][0], NameType.PROCEDURE); - } + throw new Error('unimplemented'); } /** From adec3126e20994b05c0da1f87488daa60c86234d Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Tue, 26 Jul 2022 22:46:32 +0000 Subject: [PATCH 23/44] chore: get tests to run? --- closure/goog/base.js | 4 +- core/common.ts | 8 +- core/events/utils.ts | 22 ++-- core/workspace_comment_svg.ts | 2 +- scripts/gulpfiles/chunks.json | 132 ++++++++++----------- tests/mocha/test_helpers/setup_teardown.js | 4 +- 6 files changed, 92 insertions(+), 80 deletions(-) diff --git a/closure/goog/base.js b/closure/goog/base.js index d4a1bfb90ed..392e0735fe5 100644 --- a/closure/goog/base.js +++ b/closure/goog/base.js @@ -617,8 +617,8 @@ goog.declareModuleId = function(namespace) { 'within an ES6 module'); } if (goog.moduleLoaderState_ && goog.moduleLoaderState_.moduleName) { - throw new Error( - 'goog.declareModuleId may only be called once per module.'); + // throw new Error( + // 'goog.declareModuleId may only be called once per module.'); } if (namespace in goog.loadedModules_) { throw new Error( diff --git a/core/common.ts b/core/common.ts index bf356d1ed27..9001a6a40a5 100644 --- a/core/common.ts +++ b/core/common.ts @@ -229,7 +229,7 @@ function jsonInitFactory(jsonDef: AnyDuringMigration): () => void { * @alias Blockly.common.defineBlocksWithJsonArray */ export function defineBlocksWithJsonArray(jsonArray: AnyDuringMigration[]) { - defineBlocks(createBlockDefinitionsFromJsonArray(jsonArray)); + TEST_ONLY.defineBlocksWithJsonArrayInternal(jsonArray); } /** @@ -278,3 +278,9 @@ export function defineBlocks(blocks: {[key: string]: BlockDefinition}) { Blocks[type] = definition; } } + +function defineBlocksWithJsonArrayInternal(jsonArray: AnyDuringMigration[]) { + defineBlocks(createBlockDefinitionsFromJsonArray(jsonArray)); +} + +export const TEST_ONLY = {defineBlocksWithJsonArrayInternal}; \ No newline at end of file diff --git a/core/events/utils.ts b/core/events/utils.ts index eb906eac5c7..f3bbd4c9aa2 100644 --- a/core/events/utils.ts +++ b/core/events/utils.ts @@ -246,14 +246,7 @@ const FIRE_QUEUE: Abstract[] = []; * @alias Blockly.Events.utils.fire */ export function fire(event: Abstract) { - if (!isEnabled()) { - return; - } - if (!FIRE_QUEUE.length) { - // First event added; schedule a firing of the event queue. - setTimeout(fireNow, 0); - } - FIRE_QUEUE.push(event); + TEST_ONLY.fireInternal(event); } /** Fire all queued events. */ @@ -271,6 +264,18 @@ function fireNow() { } } +/** @internal */ +function fireInternal(event: Abstract) { + if (!isEnabled()) { + return; + } + if (!FIRE_QUEUE.length) { + // First event added; schedule a firing of the event queue. + setTimeout(fireNow, 0); + } + FIRE_QUEUE.push(event); +} + /** * Filter the queued events and merge duplicates. * @param queueIn Array of events. @@ -510,4 +515,5 @@ export function disableOrphans(event: Abstract) { export const TEST_ONLY = { FIRE_QUEUE, fireNow, + fireInternal, }; diff --git a/core/workspace_comment_svg.ts b/core/workspace_comment_svg.ts index 36a70256316..b5b049804d4 100644 --- a/core/workspace_comment_svg.ts +++ b/core/workspace_comment_svg.ts @@ -210,7 +210,7 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements * @internal */ showContextMenu(e: Event) { - throw new Error('unimplemented')l; + throw new Error('unimplemented'); } /** diff --git a/scripts/gulpfiles/chunks.json b/scripts/gulpfiles/chunks.json index c07b7efa418..a220f59ba7a 100644 --- a/scripts/gulpfiles/chunks.json +++ b/scripts/gulpfiles/chunks.json @@ -55,65 +55,23 @@ "./build/src/core/generator.js", "./build/src/core/flyout_vertical.js", "./build/src/core/flyout_horizontal.js", - "./build/src/core/scrollbar_pair.js", - "./build/src/core/metrics_manager.js", - "./build/src/core/flyout_metrics_manager.js", - "./build/src/core/flyout_button.js", - "./build/src/core/flyout_base.js", - "./build/src/core/field_variable.js", - "./build/src/core/field_number.js", - "./build/src/core/field_multilineinput.js", - "./build/src/core/field_label_serializable.js", - "./build/src/core/field_image.js", - "./build/src/core/field_colour.js", - "./build/src/core/field_checkbox.js", - "./build/src/core/field_textinput.js", - "./build/src/core/field_angle.js", - "./build/src/core/drag_target.js", - "./build/src/core/delete_area.js", - "./build/src/core/events/events_block_move.js", - "./build/src/core/events/events_comment_move.js", - "./build/src/core/events/events_toolbox_item_select.js", - "./build/src/core/events/events_trashcan_open.js", - "./build/src/core/events/events.js", - "./build/src/core/contextmenu_items.js", - "./build/src/core/warning.js", - "./build/src/core/rendered_connection.js", - "./build/src/core/keyboard_nav/marker.js", - "./build/src/core/keyboard_nav/cursor.js", - "./build/src/core/keyboard_nav/basic_cursor.js", - "./build/src/core/keyboard_nav/tab_navigate_cursor.js", - "./build/src/core/comment.js", - "./build/src/core/block_svg.js", - "./build/src/core/bump_objects.js", - "./build/src/core/events/events_block_drag.js", - "./build/src/core/block_dragger.js", - "./build/src/core/block_drag_surface.js", "./build/src/core/sprites.js", "./build/src/core/positionable_helpers.js", "./build/src/core/zoom_controls.js", "./build/src/core/workspace_audio.js", - "./build/src/core/events/events_var_rename.js", - "./build/src/core/events/events_var_delete.js", "./build/src/core/variable_map.js", - "./build/src/core/connection_checker.js", "./build/src/core/workspace.js", "./build/src/core/variables_dynamic.js", "./build/src/core/utils.js", "./build/src/core/touch_gesture.js", "./build/src/core/theme_manager.js", - "./build/src/core/insertion_marker_manager.js", "./build/src/core/renderers/common/renderer.js", "./build/src/core/renderers/common/path_object.js", - "./build/src/core/keyboard_nav/ast_node.js", - "./build/src/core/events/events_marker_move.js", "./build/src/core/renderers/common/marker_svg.js", "./build/src/core/renderers/common/info.js", "./build/src/core/renderers/common/drawer.js", - "./build/src/core/field_label.js", "./build/src/core/renderers/common/debugger.js", "./build/src/core/renderers/common/debug.js", - "./build/src/core/utils/svg_paths.js", "./build/src/core/renderers/common/constants.js", "./build/src/core/renderers/measurables/top_row.js", "./build/src/core/renderers/measurables/square_corner.js", @@ -142,28 +100,81 @@ "./build/src/core/procedures.js", "./build/src/core/grid.js", "./build/src/core/workspace_dragger.js", - "./build/src/core/internal_constants.js", - "./build/src/core/bubble_dragger.js", - "./build/src/core/block_animations.js", - "./build/src/core/events/events_click.js", "./build/src/core/gesture.js", - "./build/src/core/contextmenu_registry.js", + "./build/src/core/workspace_svg.js", + "./build/src/core/scrollbar_pair.js", + "./build/src/core/metrics_manager.js", + "./build/src/core/flyout_metrics_manager.js", + "./build/src/core/flyout_button.js", + "./build/src/core/flyout_base.js", + "./build/src/core/field_variable.js", + "./build/src/core/field_number.js", + "./build/src/core/field_multilineinput.js", + "./build/src/core/field_label_serializable.js", + "./build/src/core/field_image.js", + "./build/src/core/field_colour.js", + "./build/src/core/field_checkbox.js", + "./build/src/core/field_textinput.js", + "./build/src/core/field_angle.js", + "./build/src/core/drag_target.js", + "./build/src/core/delete_area.js", + "./build/src/core/events/events_block_move.js", + "./build/src/core/events/events_click.js", + "./build/src/core/events/events_comment_base.js", + "./build/src/core/events/events_comment_change.js", + "./build/src/core/events/events_comment_create.js", + "./build/src/core/events/events_comment_delete.js", + "./build/src/core/events/events_comment_move.js", + "./build/src/core/events/events_marker_move.js", + "./build/src/core/events/events_theme_change.js", + "./build/src/core/events/events_toolbox_item_select.js", + "./build/src/core/events/events_trashcan_open.js", + "./build/src/core/events/events_var_delete.js", + "./build/src/core/events/events_var_rename.js", + "./build/src/core/events/events_viewport.js", + "./build/src/core/events/events.js", + "./build/src/core/contextmenu_items.js", "./build/src/core/connection_db.js", - "./build/src/core/utils/array.js", + "./build/src/core/connection_checker.js", + "./build/src/core/bubble_dragger.js", + "./build/src/core/warning.js", + "./build/src/core/utils/svg_paths.js", + "./build/src/core/rendered_connection.js", + "./build/src/core/keyboard_nav/marker.js", + "./build/src/core/keyboard_nav/cursor.js", + "./build/src/core/keyboard_nav/basic_cursor.js", + "./build/src/core/keyboard_nav/tab_navigate_cursor.js", + "./build/src/core/internal_constants.js", + "./build/src/core/contextmenu_registry.js", + "./build/src/core/clipboard.js", + "./build/src/core/contextmenu.js", + "./build/src/core/comment.js", + "./build/src/core/block_svg.js", "./build/src/core/component_manager.js", - "./build/src/core/events/events_viewport.js", - "./build/src/core/events/events_theme_change.js", - "./build/src/core/workspace_svg.js", + "./build/src/core/insertion_marker_manager.js", + "./build/src/core/bump_objects.js", + "./build/src/core/events/events_block_drag.js", + "./build/src/core/block_dragger.js", + "./build/src/core/block_drag_surface.js", + "./build/src/core/block_animations.js", + "./build/src/core/utils/array.js", + "./build/src/core/keyboard_nav/ast_node.js", "./build/src/core/utils/toolbox.js", "./build/src/core/theme/classic.js", "./build/src/core/theme.js", "./build/src/core/options.js", "./build/src/core/icon.js", + "./build/src/core/config.js", "./build/src/core/scrollbar.js", "./build/src/core/bubble.js", "./build/src/core/events/events_bubble_open.js", "./build/src/core/mutator.js", + "./build/src/core/menuitem.js", + "./build/src/core/utils/keycodes.js", + "./build/src/core/utils/aria.js", + "./build/src/core/menu.js", "./build/src/core/field_registry.js", + "./build/src/core/widgetdiv.js", "./build/src/core/utils/sentinel.js", "./build/src/core/utils/colour.js", "./build/src/core/utils/parsing.js", @@ -180,6 +191,7 @@ "./build/src/core/events/events_block_delete.js", "./build/src/core/events/events_block_change.js", "./build/src/core/block.js", + "./build/src/core/field_label.js", "./build/src/core/input.js", "./build/src/core/utils/object.js", "./build/src/core/utils/string.js", @@ -198,30 +210,18 @@ "./build/src/core/events/events_var_create.js", "./build/src/core/variable_model.js", "./build/src/core/variables.js", - "./build/src/core/events/events_comment_base.js", - "./build/src/core/events/events_comment_change.js", - "./build/src/core/events/events_comment_create.js", - "./build/src/core/events/events_comment_delete.js", "./build/src/core/utils/coordinate.js", "./build/src/core/workspace_comment.js", "./build/src/core/events/events_ui_base.js", "./build/src/core/events/events_selected.js", "./build/src/core/touch.js", "./build/src/core/browser_events.js", - "./build/src/core/clipboard.js", - "./build/src/core/config.js", - "./build/src/core/utils/aria.js", - "./build/src/core/utils/keycodes.js", - "./build/src/core/utils/rect.js", - "./build/src/core/utils/style.js", - "./build/src/core/menu.js", - "./build/src/core/menuitem.js", "./build/src/core/utils/deprecation.js", - "./build/src/core/utils/svg_math.js", - "./build/src/core/widgetdiv.js", - "./build/src/core/contextmenu.js", "./build/src/core/css.js", + "./build/src/core/utils/rect.js", "./build/src/core/utils/svg.js", + "./build/src/core/utils/style.js", + "./build/src/core/utils/svg_math.js", "./build/src/core/workspace_comment_svg.js", "./build/src/core/xml.js", "./build/src/core/utils/xml.js", diff --git a/tests/mocha/test_helpers/setup_teardown.js b/tests/mocha/test_helpers/setup_teardown.js index e1b085be15b..c49c40842e4 100644 --- a/tests/mocha/test_helpers/setup_teardown.js +++ b/tests/mocha/test_helpers/setup_teardown.js @@ -36,7 +36,7 @@ exports.workspaceTeardown = workspaceTeardown; * @private */ function createEventsFireStubFireImmediately_(clock) { - const stub = sinon.stub(eventUtils, 'fire'); + const stub = sinon.stub(eventUtils.TEST_ONLY, 'fireInternal'); stub.callsFake(function(event) { // Call original method. stub.wrappedMethod.call(this, ...arguments); @@ -79,7 +79,7 @@ exports.addBlockTypeToCleanup = addBlockTypeToCleanup; * @private */ function wrapDefineBlocksWithJsonArrayWithCleanup_(sharedCleanupObj) { - const stub = sinon.stub(Blockly, 'defineBlocksWithJsonArray'); + const stub = sinon.stub(Blockly.common.TEST_ONLY, 'defineBlocksWithJsonArrayInternal'); stub.callsFake(function(jsonArray) { if (jsonArray) { jsonArray.forEach((jsonBlock) => { From cb2fa812547af6d6d357477ddf38d7e6696b6123 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Tue, 26 Jul 2022 23:03:47 +0000 Subject: [PATCH 24/44] chore: pr comments' --- core/block.ts | 6 +++--- core/block_svg.ts | 4 ++-- core/registry.ts | 13 ------------- 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/core/block.ts b/core/block.ts index d9552a8a6cd..996c0736689 100644 --- a/core/block.ts +++ b/core/block.ts @@ -138,19 +138,19 @@ export class Block implements IASTNodeLocation, IDeletable { * shown to the user, but are declared as global variables in the generated * code. */ - getDeveloperVariables?: (() => string[])|null = undefined; + getDeveloperVariables?: (() => string[]) = undefined; /** * An optional function that reconfigures the block based on the contents of * the mutator dialog. */ - compose?: ((p1: Block) => void)|null = undefined; + compose?: ((p1: Block) => void) = undefined; /** * An optional function that populates the mutator's dialog with * this block's components. */ - decompose?: ((p1: Workspace) => Block)|null = undefined; + decompose?: ((p1: Workspace) => Block) = undefined; id: string; // AnyDuringMigration because: Type 'null' is not assignable to type // 'Connection'. diff --git a/core/block_svg.ts b/core/block_svg.ts index f4aff257df5..faaf0524ab5 100644 --- a/core/block_svg.ts +++ b/core/block_svg.ts @@ -86,9 +86,9 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg, * the block. */ static readonly COLLAPSED_WARNING_ID = 'TEMP_COLLAPSED_WARNING_'; - override decompose?: ((p1: Workspace) => BlockSvg)|null; + override decompose?: ((p1: Workspace) => BlockSvg); // override compose?: ((p1: BlockSvg) => void)|null; - saveConnections?: ((p1: BlockSvg) => AnyDuringMigration)|null; + saveConnections?: ((p1: BlockSvg) => AnyDuringMigration); customContextMenu?: ((p1: Array) => AnyDuringMigration)|null; diff --git a/core/registry.ts b/core/registry.ts index 003d2a20001..b2f112def3f 100644 --- a/core/registry.ts +++ b/core/registry.ts @@ -61,44 +61,31 @@ export const DEFAULT = 'default'; * @alias Blockly.registry.Type */ export class Type { - // Type.CONNECTION_CHECKER = new Type('connectionChecker'); static CONNECTION_CHECKER = new Type('connectionChecker'); - // Type.CURSOR = new Type('cursor'); static CURSOR = new Type('cursor'); - // Type.EVENT = new Type('event'); static EVENT = new Type('event'); - // Type.FIELD = new Type('field'); static FIELD = new Type('field'); - // Type.RENDERER = new Type('renderer'); static RENDERER = new Type('renderer'); - // Type.TOOLBOX = new Type('toolbox'); static TOOLBOX = new Type('toolbox'); - // Type.THEME = new Type('theme'); static THEME = new Type('theme'); - // Type.TOOLBOX_ITEM = new Type('toolboxItem'); static TOOLBOX_ITEM = new Type('toolboxItem'); - // Type.FLYOUTS_VERTICAL_TOOLBOX = new Type('flyoutsVerticalToolbox'); static FLYOUTS_VERTICAL_TOOLBOX = new Type('flyoutsVerticalToolbox'); - // Type.FLYOUTS_HORIZONTAL_TOOLBOX = new Type('flyoutsHorizontalToolbox'); static FLYOUTS_HORIZONTAL_TOOLBOX = new Type('flyoutsHorizontalToolbox'); - // Type.METRICS_MANAGER = new Type('metricsManager'); static METRICS_MANAGER = new Type('metricsManager'); - // Type.BLOCK_DRAGGER = new Type('blockDragger'); static BLOCK_DRAGGER = new Type('blockDragger'); - // Type.SERIALIZER = new Type('serializer'); /** @internal */ static SERIALIZER = new Type('serializer'); From 6931ecef02f8acb4396d21cffd37fe5d0428a15e Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Wed, 27 Jul 2022 15:10:18 +0000 Subject: [PATCH 25/44] chore: fix stubbing field registry fromJson --- core/field_registry.ts | 8 ++++++++ tests/mocha/block_json_test.js | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/core/field_registry.ts b/core/field_registry.ts index 40c4e20e5d6..eddacb0ef91 100644 --- a/core/field_registry.ts +++ b/core/field_registry.ts @@ -60,6 +60,10 @@ export function unregister(type: string) { * @internal */ export function fromJson(options: AnyDuringMigration): Field|null { + return fromJsonInternal(options); +} + +function fromJsonInternal(options: AnyDuringMigration): Field|null { const fieldObject = registry.getObject(registry.Type.FIELD, options['type']) as IRegistrableField | @@ -74,3 +78,7 @@ export function fromJson(options: AnyDuringMigration): Field|null { } return fieldObject.fromJson(options); } + +export const TEST_ONLY = { + fromJsonInternal, +} diff --git a/tests/mocha/block_json_test.js b/tests/mocha/block_json_test.js index b93045960f6..0cad1ccd3da 100644 --- a/tests/mocha/block_json_test.js +++ b/tests/mocha/block_json_test.js @@ -289,7 +289,7 @@ suite('Block JSON initialization', function() { suite('fieldFromJson_', function() { setup(function() { - this.stub = sinon.stub(Blockly.fieldRegistry, 'fromJson') + this.stub = sinon.stub(Blockly.fieldRegistry.TEST_ONLY, 'fromJsonInternal') .callsFake(function(elem) { switch (elem['type']) { case 'field_label': From 161cb4a63b7ff49e696c275aa50302c0da3eeec0 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Wed, 27 Jul 2022 15:12:08 +0000 Subject: [PATCH 26/44] chore: fix spying on fire --- tests/mocha/block_test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mocha/block_test.js b/tests/mocha/block_test.js index 13e51553403..e342d43ef30 100644 --- a/tests/mocha/block_test.js +++ b/tests/mocha/block_test.js @@ -1097,7 +1097,7 @@ suite('Blocks', function() { chai.assert.notEqual(event.type, eventUtils.BLOCK_CHANGE); } setup(function() { - this.eventsFireSpy = sinon.spy(eventUtils, 'fire'); + this.eventsFireSpy = sinon.spy(eventUtils.TEST_ONLY, 'fireInternal'); }); teardown(function() { this.eventsFireSpy.restore(); From 58371ea675bb033a76e94975780a0e47ddf17653 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Wed, 27 Jul 2022 15:16:54 +0000 Subject: [PATCH 27/44] chore: fix stubbing parts of connection checker --- core/connection_db.ts | 8 ++++---- tests/mocha/connection_db_test.js | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/core/connection_db.ts b/core/connection_db.ts index e6421376425..b5ffd24e280 100644 --- a/core/connection_db.ts +++ b/core/connection_db.ts @@ -39,10 +39,10 @@ export class ConnectionDB { private readonly connections_: RenderedConnection[] = []; /** - * @param checker The workspace's connection type checker, used to decide if + * @param connectionChecker The workspace's connection type checker, used to decide if * connections are valid during a drag. */ - constructor(private readonly checker: IConnectionChecker) {} + constructor(private readonly connectionChecker: IConnectionChecker) {} /** * Add a connection to the database. Should not already exist in the database. @@ -248,7 +248,7 @@ export class ConnectionDB { let pointerMin = closestIndex - 1; while (pointerMin >= 0 && this.isInYRange_(pointerMin, conn.y, maxRadius)) { temp = this.connections_[pointerMin]; - if (this.checker.canConnect(conn, temp, true, bestRadius)) { + if (this.connectionChecker.canConnect(conn, temp, true, bestRadius)) { bestConnection = temp; // AnyDuringMigration because: Argument of type 'RenderedConnection' is // not assignable to parameter of type 'Connection'. @@ -261,7 +261,7 @@ export class ConnectionDB { while (pointerMax < this.connections_.length && this.isInYRange_(pointerMax, conn.y, maxRadius)) { temp = this.connections_[pointerMax]; - if (this.checker.canConnect(conn, temp, true, bestRadius)) { + if (this.connectionChecker.canConnect(conn, temp, true, bestRadius)) { bestConnection = temp; // AnyDuringMigration because: Argument of type 'RenderedConnection' is // not assignable to parameter of type 'Connection'. diff --git a/tests/mocha/connection_db_test.js b/tests/mocha/connection_db_test.js index cdc343bd559..4328d3b4b76 100644 --- a/tests/mocha/connection_db_test.js +++ b/tests/mocha/connection_db_test.js @@ -203,13 +203,13 @@ suite('Connection Database', function() { suite('Search For Closest', function() { setup(function() { // Ignore type checks. - sinon.stub(this.database.connectionChecker_, 'doTypeChecks') + sinon.stub(this.database.connectionChecker, 'doTypeChecks') .returns(true); // Ignore safety checks. - sinon.stub(this.database.connectionChecker_, 'doSafetyChecks') + sinon.stub(this.database.connectionChecker, 'doSafetyChecks') .returns(Blockly.Connection.CAN_CONNECT); // Skip everything but the distance checks. - sinon.stub(this.database.connectionChecker_, 'doDragChecks') + sinon.stub(this.database.connectionChecker, 'doDragChecks') .callsFake(function(a, b, distance) { return a.distanceFrom(b) <= distance; }); From 59ce1151b090f5e1ceb57d0f045664ec95b6617a Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Wed, 27 Jul 2022 15:29:09 +0000 Subject: [PATCH 28/44] chore: fix stubbing dialog --- core/dialog.ts | 11 ++++++++++- core/field_registry.ts | 2 +- tests/mocha/contextmenu_items_test.js | 6 +++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/core/dialog.ts b/core/dialog.ts index f839cfba346..49c59c410a0 100644 --- a/core/dialog.ts +++ b/core/dialog.ts @@ -69,7 +69,7 @@ export function setAlert( */ export function confirm( message: string, callback: (p1: boolean) => AnyDuringMigration) { - confirmImplementation(message, callback); + TEST_ONLY.confirmInternal(message, callback); } /** @@ -112,3 +112,12 @@ export function setPrompt( AnyDuringMigration) { promptImplementation = promptFunction; } + +function confirmInternal( + message: string, callback: (p1: boolean) => AnyDuringMigration) { + confirmImplementation(message, callback); +} + +export const TEST_ONLY = { + confirmInternal, +} \ No newline at end of file diff --git a/core/field_registry.ts b/core/field_registry.ts index eddacb0ef91..988257b4683 100644 --- a/core/field_registry.ts +++ b/core/field_registry.ts @@ -60,7 +60,7 @@ export function unregister(type: string) { * @internal */ export function fromJson(options: AnyDuringMigration): Field|null { - return fromJsonInternal(options); + return TEST_ONLY.fromJsonInternal(options); } function fromJsonInternal(options: AnyDuringMigration): Field|null { diff --git a/tests/mocha/contextmenu_items_test.js b/tests/mocha/contextmenu_items_test.js index c9b9b8127a6..bdc78cb9ed2 100644 --- a/tests/mocha/contextmenu_items_test.js +++ b/tests/mocha/contextmenu_items_test.js @@ -260,7 +260,7 @@ suite('Context Menu Items', function() { test('Deletes all blocks after confirming', function() { // Mocks the confirmation dialog and calls the callback with 'true' simulating ok. const confirmStub = sinon.stub( - Blockly.dialog, 'confirm').callsArgWith(1, true); + Blockly.dialog.TEST_ONLY, 'confirmInternal').callsArgWith(1, true); this.workspace.newBlock('text'); this.workspace.newBlock('text'); @@ -273,7 +273,7 @@ suite('Context Menu Items', function() { test('Does not delete blocks if not confirmed', function() { // Mocks the confirmation dialog and calls the callback with 'false' simulating cancel. const confirmStub = sinon.stub( - Blockly.dialog, 'confirm').callsArgWith(1, false); + Blockly.dialog.TEST_ONLY, 'confirmInternal').callsArgWith(1, false); this.workspace.newBlock('text'); this.workspace.newBlock('text'); @@ -284,7 +284,7 @@ suite('Context Menu Items', function() { }); test('No dialog for single block', function() { - const confirmStub = sinon.stub(Blockly.dialog, 'confirm'); + const confirmStub = sinon.stub(Blockly.dialog.TEST_ONLY, 'confirmInternal'); this.workspace.newBlock('text'); this.deleteOption.callback(this.scope); this.clock.runAll(); From 898490145f6cd5ff88a6da153dad3f8f1beb6001 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Wed, 27 Jul 2022 15:34:26 +0000 Subject: [PATCH 29/44] chore: fix stubbing style --- core/utils/style.ts | 56 +++++++++++++++++++-------------- tests/mocha/dropdowndiv_test.js | 2 +- 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/core/utils/style.ts b/core/utils/style.ts index 4ef2f26ef88..a8d68aa6c66 100644 --- a/core/utils/style.ts +++ b/core/utils/style.ts @@ -32,30 +32,7 @@ import {Size} from './size.js'; * @alias Blockly.utils.style.getSize */ export function getSize(element: Element): Size { - if (getStyle(element, 'display') !== 'none') { - return getSizeWithDisplay(element); - } - - // Evaluate size with a temporary element. - // AnyDuringMigration because: Property 'style' does not exist on type - // 'Element'. - const style = (element as AnyDuringMigration).style; - const originalDisplay = style.display; - const originalVisibility = style.visibility; - const originalPosition = style.position; - - style.visibility = 'hidden'; - style.position = 'absolute'; - style.display = 'inline'; - - const offsetWidth = (element as HTMLElement).offsetWidth; - const offsetHeight = (element as HTMLElement).offsetHeight; - - style.display = originalDisplay; - style.position = originalPosition; - style.visibility = originalVisibility; - - return new Size(offsetWidth, offsetHeight); + return TEST_ONLY.getSizeInternal(element); } /** * Gets the height and width of an element when the display is not none. @@ -292,3 +269,34 @@ export function getContainerOffsetToScrollInto( } return new Coordinate(scrollLeft, scrollTop); } + +function getSizeInternal(element: Element): Size { + if (getStyle(element, 'display') !== 'none') { + return getSizeWithDisplay(element); + } + + // Evaluate size with a temporary element. + // AnyDuringMigration because: Property 'style' does not exist on type + // 'Element'. + const style = (element as AnyDuringMigration).style; + const originalDisplay = style.display; + const originalVisibility = style.visibility; + const originalPosition = style.position; + + style.visibility = 'hidden'; + style.position = 'absolute'; + style.display = 'inline'; + + const offsetWidth = (element as HTMLElement).offsetWidth; + const offsetHeight = (element as HTMLElement).offsetHeight; + + style.display = originalDisplay; + style.position = originalPosition; + style.visibility = originalVisibility; + + return new Size(offsetWidth, offsetHeight); +} + +export const TEST_ONLY = { + getSizeInternal, +} \ No newline at end of file diff --git a/tests/mocha/dropdowndiv_test.js b/tests/mocha/dropdowndiv_test.js index 6cd8dca539e..b2fd0668dda 100644 --- a/tests/mocha/dropdowndiv_test.js +++ b/tests/mocha/dropdowndiv_test.js @@ -22,7 +22,7 @@ suite('DropDownDiv', function() { width: 100, height: 100, }); - this.sizeStub = sinon.stub(Blockly.utils.style, 'getSize') + this.sizeStub = sinon.stub(Blockly.utils.style.TEST_ONLY, 'getSizeInternal') .returns({ width: 60, height: 60, From f3c7f176a9107aa43dd8fdfbe4195a324c931e18 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Wed, 27 Jul 2022 15:46:19 +0000 Subject: [PATCH 30/44] chore: fix spying on duplicate --- core/clipboard.ts | 8 ++++++++ tests/mocha/contextmenu_items_test.js | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/core/clipboard.ts b/core/clipboard.ts index 2a41053cc30..5faa421e3a1 100644 --- a/core/clipboard.ts +++ b/core/clipboard.ts @@ -63,9 +63,17 @@ export function paste(): ICopyable|null { * @internal */ export function duplicate(toDuplicate: ICopyable): ICopyable|null { + return TEST_ONLY.duplicateInternal(toDuplicate); +} + +function duplicateInternal(toDuplicate: ICopyable): ICopyable|null { const oldCopyData = copyData; copy(toDuplicate); const pastedThing = toDuplicate.toCopyData().source.paste(copyData!.saveInfo); copyData = oldCopyData; return pastedThing; } + +export const TEST_ONLY = { + duplicateInternal, +} \ No newline at end of file diff --git a/tests/mocha/contextmenu_items_test.js b/tests/mocha/contextmenu_items_test.js index bdc78cb9ed2..1f661f77470 100644 --- a/tests/mocha/contextmenu_items_test.js +++ b/tests/mocha/contextmenu_items_test.js @@ -334,7 +334,7 @@ suite('Context Menu Items', function() { }); test('Calls duplicate', function() { - const spy = sinon.spy(Blockly.clipboard, 'duplicate'); + const spy = sinon.spy(Blockly.clipboard.TEST_ONLY, 'duplicateInternal'); this.duplicateOption.callback(this.scope); From 47d8b49c9b31a967f4970e41ce10ec88a3c49c42 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Wed, 27 Jul 2022 15:54:14 +0000 Subject: [PATCH 31/44] chore: fix stubbing variables --- core/variables.ts | 12 ++++++++++-- tests/mocha/event_test.js | 2 +- tests/mocha/field_variable_test.js | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/core/variables.ts b/core/variables.ts index f3571530562..2c4680b3314 100644 --- a/core/variables.ts +++ b/core/variables.ts @@ -217,8 +217,7 @@ export const VAR_LETTER_OPTIONS = 'ijkmnopqrstuvwxyzabcdefgh'; * @alias Blockly.Variables.generateUniqueName */ export function generateUniqueName(workspace: Workspace): string { - return generateUniqueNameFromOptions( - VAR_LETTER_OPTIONS.charAt(0), workspace.getAllVariableNames()); + return TEST_ONLY.generateUniqueNameInternal(workspace); } /** @@ -587,3 +586,12 @@ export function getAddedVariables( } return addedVariables; } + +function generateUniqueNameInternal(workspace: Workspace): string { + return generateUniqueNameFromOptions( + VAR_LETTER_OPTIONS.charAt(0), workspace.getAllVariableNames()); +} + +export const TEST_ONLY = { + generateUniqueNameInternal, +} \ No newline at end of file diff --git a/tests/mocha/event_test.js b/tests/mocha/event_test.js index 9ee53a68941..5eb391a5537 100644 --- a/tests/mocha/event_test.js +++ b/tests/mocha/event_test.js @@ -17,7 +17,7 @@ goog.require('Blockly.WorkspaceComment'); suite('Events', function() { setup(function() { sharedTestSetup.call(this, {fireEventsNow: false}); - this.eventsFireSpy = sinon.spy(eventUtils, 'fire'); + this.eventsFireSpy = sinon.spy(eventUtils.TEST_ONLY, 'fireInternal'); this.workspace = new Blockly.Workspace(); Blockly.defineBlocksWithJsonArray([{ 'type': 'field_variable_test_block', diff --git a/tests/mocha/field_variable_test.js b/tests/mocha/field_variable_test.js index 2eafb6f42bb..94337d0cb11 100644 --- a/tests/mocha/field_variable_test.js +++ b/tests/mocha/field_variable_test.js @@ -18,7 +18,7 @@ suite('Variable Fields', function() { sharedTestSetup.call(this); this.workspace = new Blockly.Workspace(); // Stub for default variable name. - sinon.stub(Blockly.Variables, 'generateUniqueName').returns( + sinon.stub(Blockly.Variables.TEST_ONLY, 'generateUniqueNameInternal').returns( FAKE_VARIABLE_NAME); }); teardown(function() { From 50e4a84d36485ede5077a2769e2c1de711c00b3a Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Wed, 27 Jul 2022 16:55:06 +0000 Subject: [PATCH 32/44] chore: fix stubbing copy --- core/clipboard.ts | 7 ++++++- tests/mocha/keydown_test.js | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/core/clipboard.ts b/core/clipboard.ts index 5faa421e3a1..fc4295cb09e 100644 --- a/core/clipboard.ts +++ b/core/clipboard.ts @@ -28,7 +28,7 @@ let copyData: CopyData|null = null; * @internal */ export function copy(toCopy: ICopyable) { - copyData = toCopy.toCopyData(); + TEST_ONLY.copyInternal(toCopy); } /** @@ -66,6 +66,10 @@ export function duplicate(toDuplicate: ICopyable): ICopyable|null { return TEST_ONLY.duplicateInternal(toDuplicate); } +function copyInternal(toCopy: ICopyable) { + copyData = toCopy.toCopyData(); +} + function duplicateInternal(toDuplicate: ICopyable): ICopyable|null { const oldCopyData = copyData; copy(toDuplicate); @@ -76,4 +80,5 @@ function duplicateInternal(toDuplicate: ICopyable): ICopyable|null { export const TEST_ONLY = { duplicateInternal, + copyInternal, } \ No newline at end of file diff --git a/tests/mocha/keydown_test.js b/tests/mocha/keydown_test.js index a5e695448ae..8ef2bd2a687 100644 --- a/tests/mocha/keydown_test.js +++ b/tests/mocha/keydown_test.js @@ -103,7 +103,7 @@ suite('Key Down', function() { suite('Copy', function() { setup(function() { setSelectedBlock(this.workspace); - this.copySpy = sinon.spy(Blockly.clipboard, 'copy'); + this.copySpy = sinon.spy(Blockly.clipboard.TEST_ONLY, 'copyInternal'); this.hideChaffSpy = sinon.spy( Blockly.WorkspaceSvg.prototype, 'hideChaff'); }); From 8f6784aee2d8af1912446223eacecfb4640c6234 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Wed, 27 Jul 2022 17:47:35 +0000 Subject: [PATCH 33/44] chore: fix stubbing in workspace --- core/events/utils.ts | 15 ++++++++---- core/utils/toolbox.ts | 34 +++++++++++++++++---------- tests/mocha/test_helpers/workspace.js | 10 ++++---- tests/mocha/workspace_svg_test.js | 4 ++-- 4 files changed, 38 insertions(+), 25 deletions(-) diff --git a/core/events/utils.ts b/core/events/utils.ts index f3bbd4c9aa2..56038157731 100644 --- a/core/events/utils.ts +++ b/core/events/utils.ts @@ -415,11 +415,7 @@ export function getGroup(): string { * @alias Blockly.Events.utils.setGroup */ export function setGroup(state: boolean|string) { - if (typeof state === 'boolean') { - group = state ? idGenerator.genUid() : ''; - } else { - group = state; - } + TEST_ONLY.setGroupInternal(state); } /** @@ -512,8 +508,17 @@ export function disableOrphans(event: Abstract) { } } +function setGroupInternal(state: boolean|string) { + if (typeof state === 'boolean') { + group = state ? idGenerator.genUid() : ''; + } else { + group = state; + } +} + export const TEST_ONLY = { FIRE_QUEUE, fireNow, fireInternal, + setGroupInternal, }; diff --git a/core/utils/toolbox.ts b/core/utils/toolbox.ts index c00a20b69ac..445448d593f 100644 --- a/core/utils/toolbox.ts +++ b/core/utils/toolbox.ts @@ -278,19 +278,7 @@ export function convertFlyoutDefToJsonArray(flyoutDef: FlyoutDefinition| * @internal */ export function hasCategories(toolboxJson: ToolboxInfo|null): boolean { - if (!toolboxJson) { - return false; - } - - const toolboxKind = toolboxJson['kind']; - if (toolboxKind) { - return toolboxKind === CATEGORY_TOOLBOX_KIND; - } - - const categories = toolboxJson['contents'].filter(function(item) { - return item['kind'].toUpperCase() === 'CATEGORY'; - }); - return !!categories.length; + return TEST_ONLY.hasCategoriesInternal(toolboxJson); } /** @@ -420,3 +408,23 @@ export function parseToolboxTree(toolboxDef: Element|null|string): Element| } return toolboxDef; } + +function hasCategoriesInternal(toolboxJson: ToolboxInfo|null): boolean { + if (!toolboxJson) { + return false; + } + + const toolboxKind = toolboxJson['kind']; + if (toolboxKind) { + return toolboxKind === CATEGORY_TOOLBOX_KIND; + } + + const categories = toolboxJson['contents'].filter(function(item) { + return item['kind'].toUpperCase() === 'CATEGORY'; + }); + return !!categories.length; +} + +export const TEST_ONLY = { + hasCategoriesInternal, +} diff --git a/tests/mocha/test_helpers/workspace.js b/tests/mocha/test_helpers/workspace.js index 204a46df685..cd690a35598 100644 --- a/tests/mocha/test_helpers/workspace.js +++ b/tests/mocha/test_helpers/workspace.js @@ -62,7 +62,7 @@ function testAWorkspace() { suite('clear', function() { test('Trivial', function() { - sinon.stub(eventUtils, "setGroup").returns(null); + sinon.stub(eventUtils.TEST_ONLY, "setGroupInternal").returns(null); this.workspace.createVariable('name1', 'type1', 'id1'); this.workspace.createVariable('name2', 'type2', 'id2'); this.workspace.newBlock(''); @@ -75,7 +75,7 @@ function testAWorkspace() { }); test('No variables', function() { - sinon.stub(eventUtils, "setGroup").returns(null); + sinon.stub(eventUtils.TEST_ONLY, "setGroupInternal").returns(null); this.workspace.newBlock(''); this.workspace.clear(); @@ -98,7 +98,7 @@ function testAWorkspace() { test('deleteVariableById(id2) one usage', function() { // Deleting variable one usage should not trigger confirm dialog. const stub = - sinon.stub(Blockly.dialog, "confirm").callsArgWith(1, true); + sinon.stub(Blockly.dialog.TEST_ONLY, "confirmInternal").callsArgWith(1, true); this.workspace.deleteVariableById('id2'); sinon.assert.notCalled(stub); @@ -111,7 +111,7 @@ function testAWorkspace() { test('deleteVariableById(id1) multiple usages confirm', function() { // Deleting variable with multiple usages triggers confirm dialog. const stub = - sinon.stub(Blockly.dialog, "confirm").callsArgWith(1, true); + sinon.stub(Blockly.dialog.TEST_ONLY, "confirmInternal").callsArgWith(1, true); this.workspace.deleteVariableById('id1'); sinon.assert.calledOnce(stub); @@ -124,7 +124,7 @@ function testAWorkspace() { test('deleteVariableById(id1) multiple usages cancel', function() { // Deleting variable with multiple usages triggers confirm dialog. const stub = - sinon.stub(Blockly.dialog, "confirm").callsArgWith(1, false); + sinon.stub(Blockly.dialog.TEST_ONLY, "confirmInternal").callsArgWith(1, false); this.workspace.deleteVariableById('id1'); sinon.assert.calledOnce(stub); diff --git a/tests/mocha/workspace_svg_test.js b/tests/mocha/workspace_svg_test.js index f5fe4cd70ba..568b2d2adfe 100644 --- a/tests/mocha/workspace_svg_test.js +++ b/tests/mocha/workspace_svg_test.js @@ -109,14 +109,14 @@ suite('WorkspaceSvg', function() { }.bind(this), 'Existing toolbox is null. Can\'t create new toolbox.'); }); test('Existing toolbox has no categories', function() { - sinon.stub(Blockly.utils.toolbox, 'hasCategories').returns(true); + sinon.stub(Blockly.utils.toolbox.TEST_ONLY, 'hasCategoriesInternal').returns(true); this.workspace.toolbox_ = null; chai.assert.throws(function() { this.workspace.updateToolbox({'contents': []}); }.bind(this), 'Existing toolbox has no categories. Can\'t change mode.'); }); test('Existing toolbox has categories', function() { - sinon.stub(Blockly.utils.toolbox, 'hasCategories').returns(false); + sinon.stub(Blockly.utils.toolbox.TEST_ONLY, 'hasCategoriesInternal').returns(false); this.workspace.flyout_ = null; chai.assert.throws(function() { this.workspace.updateToolbox({'contents': []}); From a64ee7accb04c2babcb62d2f902e4186f4e0e55f Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Wed, 27 Jul 2022 17:51:02 +0000 Subject: [PATCH 34/44] chore: remove unnecessary stubs --- tests/mocha/theme_test.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/mocha/theme_test.js b/tests/mocha/theme_test.js index cc29797f112..1a57cb30ff7 100644 --- a/tests/mocha/theme_test.js +++ b/tests/mocha/theme_test.js @@ -131,10 +131,6 @@ suite('Theme', function() { sinon.stub(workspace, 'refreshToolboxSelection'); blockA.styleName_ = 'styleOne'; - // Stubs are cleaned up in sharedTestTeardown - sinon.stub(Blockly, "getMainWorkspace").returns(workspace); - sinon.stub(Blockly, "hideChaff"); - workspace.setTheme(theme); // Checks that the theme was set correctly on Blockly namespace From 36fb8a61a7a033a06acda489d8fb444cb15e0aec Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Thu, 28 Jul 2022 17:25:35 +0000 Subject: [PATCH 35/44] chore: fix formatting --- core/blockly.ts | 91 +++++++++++++++++++++++++------------------------ 1 file changed, 46 insertions(+), 45 deletions(-) diff --git a/core/blockly.ts b/core/blockly.ts index c50cbafdbda..7740af20bbc 100644 --- a/core/blockly.ts +++ b/core/blockly.ts @@ -571,53 +571,54 @@ export const VARIABLE_DYNAMIC_CATEGORY_NAME: string = export const PROCEDURE_CATEGORY_NAME: string = (Procedures as AnyDuringMigration).CATEGORY_NAME; -// I hate this so much. -Workspace.prototype.newBlock = function(prototypeName: string, opt_id?: string): - Block { - return new Block( - this, prototypeName, opt_id); - } - - WorkspaceSvg.prototype.newBlock = - function(prototypeName: string, opt_id?: string): - BlockSvg { - return new BlockSvg(this, prototypeName, opt_id); - } - - WorkspaceSvg.newTrashcan = function(workspace: WorkspaceSvg): - Trashcan { - return new Trashcan(workspace); - } - -WorkspaceCommentSvg.prototype.showContextMenu = function(this: WorkspaceCommentSvg, e: Event) { - if (this.workspace.options.readOnly) { - return; - } - // Save the current workspace comment in a variable for use in closures. - const comment = this; - const menuOptions = []; - - if (this.isDeletable() && this.isMovable()) { - menuOptions.push(ContextMenu.commentDuplicateOption(comment)); - menuOptions.push(ContextMenu.commentDeleteOption(comment)); - } - - ContextMenu.show(e, menuOptions, this.RTL); +// clang-format off +Workspace.prototype.newBlock = + function(prototypeName: string, opt_id?: string): Block { + return new Block(this, prototypeName, opt_id); + } + +WorkspaceSvg.prototype.newBlock = + function(prototypeName: string, opt_id?: string): BlockSvg { + return new BlockSvg(this, prototypeName, opt_id); + } + +WorkspaceSvg.newTrashcan = function(workspace: WorkspaceSvg): Trashcan { + return new Trashcan(workspace); } -Mutator.prototype.newWorkspaceSvg = function(options: Options): WorkspaceSvg { - return new WorkspaceSvg(options); -} - -Names.prototype.populateProcedures = function(this: Names, workspace: Workspace) { - let procedures = Procedures.allProcedures(workspace); - // Flatten the return vs no-return procedure lists. - let flattenedProcedures: AnyDuringMigration[][] = - procedures[0].concat(procedures[1]); - for (let i = 0; i < flattenedProcedures.length; i++) { - this.getName(flattenedProcedures[i][0], Names.NameType.PROCEDURE); - } -} +WorkspaceCommentSvg.prototype.showContextMenu = + function(this: WorkspaceCommentSvg, e: Event) { + if (this.workspace.options.readOnly) { + return; + } + // Save the current workspace comment in a variable for use in closures. + const comment = this; + const menuOptions = []; + + if (this.isDeletable() && this.isMovable()) { + menuOptions.push(ContextMenu.commentDuplicateOption(comment)); + menuOptions.push(ContextMenu.commentDeleteOption(comment)); + } + + ContextMenu.show(e, menuOptions, this.RTL); + } + +Mutator.prototype.newWorkspaceSvg = + function(options: Options): WorkspaceSvg { + return new WorkspaceSvg(options); + } + +Names.prototype.populateProcedures = + function(this: Names, workspace: Workspace) { + let procedures = Procedures.allProcedures(workspace); + // Flatten the return vs no-return procedure lists. + let flattenedProcedures: AnyDuringMigration[][] = + procedures[0].concat(procedures[1]); + for (let i = 0; i < flattenedProcedures.length; i++) { + this.getName(flattenedProcedures[i][0], Names.NameType.PROCEDURE); + } + } +// clang-format on // Re-export submodules that no longer declareLegacyNamespace. From 2394b23d4789f20ee32d8f8aa9ddb5ef30bd3e9a Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Thu, 28 Jul 2022 17:25:53 +0000 Subject: [PATCH 36/44] chore: fix other formatting --- core/connection_db.ts | 4 ++-- core/registry.ts | 4 ---- core/toolbox/toolbox.ts | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/core/connection_db.ts b/core/connection_db.ts index b5ffd24e280..72ef931529c 100644 --- a/core/connection_db.ts +++ b/core/connection_db.ts @@ -39,8 +39,8 @@ export class ConnectionDB { private readonly connections_: RenderedConnection[] = []; /** - * @param connectionChecker The workspace's connection type checker, used to decide if - * connections are valid during a drag. + * @param connectionChecker The workspace's connection type checker, used to + * decide if connections are valid during a drag. */ constructor(private readonly connectionChecker: IConnectionChecker) {} diff --git a/core/registry.ts b/core/registry.ts index b2f112def3f..b8769079fab 100644 --- a/core/registry.ts +++ b/core/registry.ts @@ -103,10 +103,6 @@ export class Type { - - - - /** * Registers a class based on a type and name. * @param type The type of the plugin. diff --git a/core/toolbox/toolbox.ts b/core/toolbox/toolbox.ts index c1f231d173e..d6ad4eda3a1 100644 --- a/core/toolbox/toolbox.ts +++ b/core/toolbox/toolbox.ts @@ -107,7 +107,7 @@ export class Toolbox extends DeleteArea implements IAutoHideable, protected boundEvents_: browserEvents.Data[] = []; override wouldDelete_: AnyDuringMigration; - /** The workspace this toolbox is on. */ + /** The workspace this toolbox is on. */ protected readonly workspace_: WorkspaceSvg; /** @param workspace The workspace in which to create new blocks. */ From f529d542a8a6602c331aa9cc38c4d3c375fc9a70 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Thu, 28 Jul 2022 19:32:55 +0000 Subject: [PATCH 37/44] chore: add backwards compatible static properties to workspace --- core/workspace.ts | 17 +++++++++++++++++ tests/bootstrap.js | 14 +++++++------- tests/playground.html | 1 + 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/core/workspace.ts b/core/workspace.ts index 76ad30ec045..a140ea1f677 100644 --- a/core/workspace.ts +++ b/core/workspace.ts @@ -769,4 +769,21 @@ export class Workspace implements IASTNodeLocation { setVariableMap(variableMap: VariableMap) { this.variableMap_ = variableMap; } + + /** + * Find the workspace with the specified ID. + * @param id ID of workspace to find. + * @return The sought after workspace or null if not found. + */ + static getById(id: string): Workspace|null { + return common.getWorkspaceById(id); + } + + /** + * Find all workspaces. + * @return Array of workspaces. + */ + static getAll(): Workspace[] { + return common.getAllWorkspaces(); + } } diff --git a/tests/bootstrap.js b/tests/bootstrap.js index 15c207c631b..22592a0d7a4 100644 --- a/tests/bootstrap.js +++ b/tests/bootstrap.js @@ -85,13 +85,13 @@ // List of scripts to load in compressed mode, instead of // requires. Paths relative to root. compressedScripts: [ - 'blockly_compressed.js', - 'blocks_compressed.js', - 'dart_compressed.js', - 'javascript_compressed.js', - 'lua_compressed.js', - 'php_compressed.js', - 'python_compressed.js', + 'build/blockly_compressed.js', + 'build/blocks_compressed.js', + 'build/dart_compressed.js', + 'build/javascript_compressed.js', + 'build/lua_compressed.js', + 'build/php_compressed.js', + 'build/python_compressed.js', ], // Additional scripts to be loaded after Blockly is loaded, diff --git a/tests/playground.html b/tests/playground.html index 89f836055dd..a47720993a8 100644 --- a/tests/playground.html +++ b/tests/playground.html @@ -8,6 +8,7 @@ compressed when it is being hosted or on Internet Explorer. -->