From cc7a263fb3842ca6a2bc800288eca2d4474bfba0 Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Tue, 20 Jul 2021 13:48:56 -0700 Subject: [PATCH] Replace references to SPRITE and SOUND_LIMIT with internalConstants versions --- core/trashcan.js | 29 +++++++++++++++-------------- core/workspace_audio.js | 5 ++--- core/zoom_controls.js | 40 ++++++++++++++++++++++------------------ tests/deps.js | 6 +++--- 4 files changed, 42 insertions(+), 38 deletions(-) diff --git a/core/trashcan.js b/core/trashcan.js index 831a26ba4..619299b21 100644 --- a/core/trashcan.js +++ b/core/trashcan.js @@ -14,13 +14,12 @@ goog.provide('Blockly.Trashcan'); goog.require('Blockly.browserEvents'); goog.require('Blockly.ComponentManager'); -/** @suppress {extraRequire} */ -goog.require('Blockly.constants'); goog.require('Blockly.DeleteArea'); goog.require('Blockly.Events'); /** @suppress {extraRequire} */ goog.require('Blockly.Events.TrashcanOpen'); goog.require('Blockly.IAutoHideable'); +goog.require('Blockly.internalConstants'); goog.require('Blockly.IPositionable'); goog.require('Blockly.Options'); goog.require('Blockly.registry'); @@ -316,17 +315,18 @@ Blockly.Trashcan.prototype.createDom = function() { }, clip); var body = Blockly.utils.dom.createSvgElement( - Blockly.utils.Svg.IMAGE, - { - 'width': Blockly.SPRITE.width, + Blockly.utils.Svg.IMAGE, { + 'width': Blockly.internalConstants.SPRITE.width, 'x': -this.SPRITE_LEFT_, - 'height': Blockly.SPRITE.height, + 'height': Blockly.internalConstants.SPRITE.height, 'y': -this.SPRITE_TOP_, 'clip-path': 'url(#blocklyTrashBodyClipPath' + rnd + ')' }, this.svgGroup_); - body.setAttributeNS(Blockly.utils.dom.XLINK_NS, 'xlink:href', - this.workspace_.options.pathToMedia + Blockly.SPRITE.url); + body.setAttributeNS( + Blockly.utils.dom.XLINK_NS, 'xlink:href', + this.workspace_.options.pathToMedia + + Blockly.internalConstants.SPRITE.url); clip = Blockly.utils.dom.createSvgElement( Blockly.utils.Svg.CLIPPATH, @@ -336,17 +336,18 @@ Blockly.Trashcan.prototype.createDom = function() { Blockly.utils.Svg.RECT, {'width': this.WIDTH_, 'height': this.LID_HEIGHT_}, clip); this.svgLid_ = Blockly.utils.dom.createSvgElement( - Blockly.utils.Svg.IMAGE, - { - 'width': Blockly.SPRITE.width, + Blockly.utils.Svg.IMAGE, { + 'width': Blockly.internalConstants.SPRITE.width, 'x': -this.SPRITE_LEFT_, - 'height': Blockly.SPRITE.height, + 'height': Blockly.internalConstants.SPRITE.height, 'y': -this.SPRITE_TOP_, 'clip-path': 'url(#blocklyTrashLidClipPath' + rnd + ')' }, this.svgGroup_); - this.svgLid_.setAttributeNS(Blockly.utils.dom.XLINK_NS, 'xlink:href', - this.workspace_.options.pathToMedia + Blockly.SPRITE.url); + this.svgLid_.setAttributeNS( + Blockly.utils.dom.XLINK_NS, 'xlink:href', + this.workspace_.options.pathToMedia + + Blockly.internalConstants.SPRITE.url); // bindEventWithChecks_ quashes events too aggressively. See: // https://groups.google.com/forum/#!topic/blockly/QF4yB9Wx00s diff --git a/core/workspace_audio.js b/core/workspace_audio.js index 954b8f892..378c19287 100644 --- a/core/workspace_audio.js +++ b/core/workspace_audio.js @@ -13,8 +13,7 @@ goog.provide('Blockly.WorkspaceAudio'); -/** @suppress {extraRequire} */ -goog.require('Blockly.constants'); +goog.require('Blockly.internalConstants'); goog.require('Blockly.utils'); goog.require('Blockly.utils.global'); goog.require('Blockly.utils.userAgent'); @@ -135,7 +134,7 @@ Blockly.WorkspaceAudio.prototype.play = function(name, opt_volume) { // Don't play one sound on top of another. var now = new Date; if (this.lastSound_ != null && - now - this.lastSound_ < Blockly.SOUND_LIMIT) { + now - this.lastSound_ < Blockly.internalConstants.SOUND_LIMIT) { return; } this.lastSound_ = now; diff --git a/core/zoom_controls.js b/core/zoom_controls.js index 96ff41ac4..6ecf8b041 100644 --- a/core/zoom_controls.js +++ b/core/zoom_controls.js @@ -21,6 +21,7 @@ goog.require('Blockly.Events'); /** @suppress {extraRequire} */ goog.require('Blockly.Events.Click'); goog.require('Blockly.IPositionable'); +goog.require('Blockly.internalConstants'); goog.require('Blockly.Touch'); goog.require('Blockly.uiPosition'); goog.require('Blockly.utils'); @@ -337,17 +338,18 @@ Blockly.ZoomControls.prototype.createZoomOutSvg_ = function(rnd) { }, clip); var zoomoutSvg = Blockly.utils.dom.createSvgElement( - Blockly.utils.Svg.IMAGE, - { - 'width': Blockly.SPRITE.width, - 'height': Blockly.SPRITE.height, + Blockly.utils.Svg.IMAGE, { + 'width': Blockly.internalConstants.SPRITE.width, + 'height': Blockly.internalConstants.SPRITE.height, 'x': -64, 'y': -92, 'clip-path': 'url(#blocklyZoomoutClipPath' + rnd + ')' }, this.zoomOutGroup_); - zoomoutSvg.setAttributeNS(Blockly.utils.dom.XLINK_NS, 'xlink:href', - this.workspace_.options.pathToMedia + Blockly.SPRITE.url); + zoomoutSvg.setAttributeNS( + Blockly.utils.dom.XLINK_NS, 'xlink:href', + this.workspace_.options.pathToMedia + + Blockly.internalConstants.SPRITE.url); // Attach listener. this.onZoomOutWrapper_ = Blockly.browserEvents.conditionalBind( @@ -388,17 +390,18 @@ Blockly.ZoomControls.prototype.createZoomInSvg_ = function(rnd) { }, clip); var zoominSvg = Blockly.utils.dom.createSvgElement( - Blockly.utils.Svg.IMAGE, - { - 'width': Blockly.SPRITE.width, - 'height': Blockly.SPRITE.height, + Blockly.utils.Svg.IMAGE, { + 'width': Blockly.internalConstants.SPRITE.width, + 'height': Blockly.internalConstants.SPRITE.height, 'x': -32, 'y': -92, 'clip-path': 'url(#blocklyZoominClipPath' + rnd + ')' }, this.zoomInGroup_); - zoominSvg.setAttributeNS(Blockly.utils.dom.XLINK_NS, 'xlink:href', - this.workspace_.options.pathToMedia + Blockly.SPRITE.url); + zoominSvg.setAttributeNS( + Blockly.utils.dom.XLINK_NS, 'xlink:href', + this.workspace_.options.pathToMedia + + Blockly.internalConstants.SPRITE.url); // Attach listener. this.onZoomInWrapper_ = Blockly.browserEvents.conditionalBind( @@ -456,16 +459,17 @@ Blockly.ZoomControls.prototype.createZoomResetSvg_ = function(rnd) { }, clip); var zoomresetSvg = Blockly.utils.dom.createSvgElement( - Blockly.utils.Svg.IMAGE, - { - 'width': Blockly.SPRITE.width, - 'height': Blockly.SPRITE.height, + Blockly.utils.Svg.IMAGE, { + 'width': Blockly.internalConstants.SPRITE.width, + 'height': Blockly.internalConstants.SPRITE.height, 'y': -92, 'clip-path': 'url(#blocklyZoomresetClipPath' + rnd + ')' }, this.zoomResetGroup_); - zoomresetSvg.setAttributeNS(Blockly.utils.dom.XLINK_NS, 'xlink:href', - this.workspace_.options.pathToMedia + Blockly.SPRITE.url); + zoomresetSvg.setAttributeNS( + Blockly.utils.dom.XLINK_NS, 'xlink:href', + this.workspace_.options.pathToMedia + + Blockly.internalConstants.SPRITE.url); // Attach event listeners. this.onZoomResetWrapper_ = Blockly.browserEvents.conditionalBind( diff --git a/tests/deps.js b/tests/deps.js index d7e7ec201..abbcce849 100644 --- a/tests/deps.js +++ b/tests/deps.js @@ -177,7 +177,7 @@ goog.addDependency('../../core/toolbox/toolbox_item.js', ['Blockly.ToolboxItem'] goog.addDependency('../../core/tooltip.js', ['Blockly.Tooltip'], ['Blockly.browserEvents', 'Blockly.utils.string']); goog.addDependency('../../core/touch.js', ['Blockly.Touch'], ['Blockly.constants', 'Blockly.utils', 'Blockly.utils.global', 'Blockly.utils.string']); goog.addDependency('../../core/touch_gesture.js', ['Blockly.TouchGesture'], ['Blockly.Gesture', 'Blockly.browserEvents', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.object']); -goog.addDependency('../../core/trashcan.js', ['Blockly.Trashcan'], ['Blockly.ComponentManager', 'Blockly.DeleteArea', 'Blockly.Events', 'Blockly.Events.TrashcanOpen', 'Blockly.IAutoHideable', 'Blockly.IPositionable', 'Blockly.Options', 'Blockly.Xml', 'Blockly.browserEvents', 'Blockly.constants', 'Blockly.registry', 'Blockly.uiPosition', 'Blockly.utils', 'Blockly.utils.Rect', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.toolbox'], {'lang': 'es5'}); +goog.addDependency('../../core/trashcan.js', ['Blockly.Trashcan'], ['Blockly.ComponentManager', 'Blockly.DeleteArea', 'Blockly.Events', 'Blockly.Events.TrashcanOpen', 'Blockly.IAutoHideable', 'Blockly.IPositionable', 'Blockly.Options', 'Blockly.Xml', 'Blockly.browserEvents', 'Blockly.internalConstants', 'Blockly.registry', 'Blockly.uiPosition', 'Blockly.utils', 'Blockly.utils.Rect', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.toolbox'], {'lang': 'es5'}); goog.addDependency('../../core/utils.js', ['Blockly.utils'], ['Blockly.Msg', 'Blockly.constants', 'Blockly.utils.Coordinate', 'Blockly.utils.Rect', 'Blockly.utils.colour', 'Blockly.utils.global', 'Blockly.utils.string', 'Blockly.utils.style', 'Blockly.utils.userAgent']); goog.addDependency('../../core/utils/aria.js', ['Blockly.utils.aria'], []); goog.addDependency('../../core/utils/colour.js', ['Blockly.utils.colour'], [], {'lang': 'es6', 'module': 'goog'}); @@ -206,7 +206,7 @@ goog.addDependency('../../core/variables_dynamic.js', ['Blockly.VariablesDynamic goog.addDependency('../../core/warning.js', ['Blockly.Warning'], ['Blockly.Bubble', 'Blockly.Events', 'Blockly.Events.BubbleOpen', 'Blockly.Icon', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.object']); goog.addDependency('../../core/widgetdiv.js', ['Blockly.WidgetDiv'], ['Blockly.utils.dom']); goog.addDependency('../../core/workspace.js', ['Blockly.Workspace'], ['Blockly.ConnectionChecker', 'Blockly.Events', 'Blockly.IASTNodeLocation', 'Blockly.Options', 'Blockly.VariableMap', 'Blockly.registry', 'Blockly.utils', 'Blockly.utils.math']); -goog.addDependency('../../core/workspace_audio.js', ['Blockly.WorkspaceAudio'], ['Blockly.constants', 'Blockly.utils', 'Blockly.utils.global', 'Blockly.utils.userAgent'], {'lang': 'es5'}); +goog.addDependency('../../core/workspace_audio.js', ['Blockly.WorkspaceAudio'], ['Blockly.internalConstants', 'Blockly.utils', 'Blockly.utils.global', 'Blockly.utils.userAgent'], {'lang': 'es5'}); goog.addDependency('../../core/workspace_comment.js', ['Blockly.WorkspaceComment'], ['Blockly.Events', 'Blockly.Events.CommentChange', 'Blockly.Events.CommentCreate', 'Blockly.Events.CommentDelete', 'Blockly.Events.CommentMove', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.xml']); goog.addDependency('../../core/workspace_comment_render_svg.js', ['Blockly.WorkspaceCommentSvg.render'], ['Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Svg', 'Blockly.utils.dom']); goog.addDependency('../../core/workspace_comment_svg.js', ['Blockly.WorkspaceCommentSvg'], ['Blockly.Css', 'Blockly.Events', 'Blockly.Events.CommentCreate', 'Blockly.Events.CommentDelete', 'Blockly.Events.CommentMove', 'Blockly.Events.Selected', 'Blockly.WorkspaceComment', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Rect', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.object']); @@ -214,6 +214,6 @@ goog.addDependency('../../core/workspace_drag_surface_svg.js', ['Blockly.Workspa goog.addDependency('../../core/workspace_dragger.js', ['Blockly.WorkspaceDragger'], ['Blockly.utils.Coordinate']); goog.addDependency('../../core/workspace_svg.js', ['Blockly.WorkspaceSvg'], ['Blockly.BlockSvg', 'Blockly.ComponentManager', 'Blockly.ConnectionDB', 'Blockly.ContextMenu', 'Blockly.ContextMenuRegistry', 'Blockly.Events', 'Blockly.Events.BlockCreate', 'Blockly.Events.ThemeChange', 'Blockly.Events.ViewportChange', 'Blockly.Gesture', 'Blockly.Grid', 'Blockly.IASTNodeLocationSvg', 'Blockly.MarkerManager', 'Blockly.MetricsManager', 'Blockly.Msg', 'Blockly.Options', 'Blockly.ThemeManager', 'Blockly.Themes.Classic', 'Blockly.TouchGesture', 'Blockly.Workspace', 'Blockly.WorkspaceAudio', 'Blockly.WorkspaceDragSurfaceSvg', 'Blockly.Xml', 'Blockly.blockRendering', 'Blockly.browserEvents', 'Blockly.constants', 'Blockly.registry', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Metrics', 'Blockly.utils.Rect', 'Blockly.utils.Size', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.toolbox'], {'lang': 'es5'}); goog.addDependency('../../core/xml.js', ['Blockly.Xml'], ['Blockly.Events', 'Blockly.constants', 'Blockly.inputTypes', 'Blockly.utils', 'Blockly.utils.Size', 'Blockly.utils.dom', 'Blockly.utils.xml']); -goog.addDependency('../../core/zoom_controls.js', ['Blockly.ZoomControls'], ['Blockly.ComponentManager', 'Blockly.Css', 'Blockly.Events', 'Blockly.Events.Click', 'Blockly.IPositionable', 'Blockly.Touch', 'Blockly.browserEvents', 'Blockly.constants', 'Blockly.uiPosition', 'Blockly.utils', 'Blockly.utils.Rect', 'Blockly.utils.Svg', 'Blockly.utils.dom'], {'lang': 'es5'}); +goog.addDependency('../../core/zoom_controls.js', ['Blockly.ZoomControls'], ['Blockly.ComponentManager', 'Blockly.Css', 'Blockly.Events', 'Blockly.Events.Click', 'Blockly.IPositionable', 'Blockly.Touch', 'Blockly.browserEvents', 'Blockly.constants', 'Blockly.internalConstants', 'Blockly.uiPosition', 'Blockly.utils', 'Blockly.utils.Rect', 'Blockly.utils.Svg', 'Blockly.utils.dom'], {'lang': 'es5'}); goog.addDependency('base.js', [], []);