From f7c88bfcd91bb2168137358e91ce01ae17036bee Mon Sep 17 00:00:00 2001 From: kozbial Date: Mon, 26 Jul 2021 14:46:27 -0700 Subject: [PATCH] Migrate core/workspace_audio.js to goog.module --- core/workspace_audio.js | 18 ++++++++++-------- tests/deps.js | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/core/workspace_audio.js b/core/workspace_audio.js index 1ca2a2255..72e66d952 100644 --- a/core/workspace_audio.js +++ b/core/workspace_audio.js @@ -11,10 +11,10 @@ */ 'use strict'; -goog.provide('Blockly.WorkspaceAudio'); +goog.module('Blockly.WorkspaceAudio'); +goog.module.declareLegacyNamespace(); goog.require('Blockly.internalConstants'); -goog.require('Blockly.utils'); goog.require('Blockly.utils.global'); goog.require('Blockly.utils.userAgent'); @@ -27,7 +27,7 @@ goog.requireType('Blockly.WorkspaceSvg'); * this audio object belongs to, or null. * @constructor */ -Blockly.WorkspaceAudio = function(parentWorkspace) { +const WorkspaceAudio = function(parentWorkspace) { /** * The parent of the workspace this object belongs to, or null. May be @@ -49,13 +49,13 @@ Blockly.WorkspaceAudio = function(parentWorkspace) { * @type {Date} * @private */ -Blockly.WorkspaceAudio.prototype.lastSound_ = null; +WorkspaceAudio.prototype.lastSound_ = null; /** * Dispose of this audio manager. * @package */ -Blockly.WorkspaceAudio.prototype.dispose = function() { +WorkspaceAudio.prototype.dispose = function() { this.parentWorkspace_ = null; this.SOUNDS_ = null; }; @@ -67,7 +67,7 @@ Blockly.WorkspaceAudio.prototype.dispose = function() { * Filenames include path from Blockly's root. File extensions matter. * @param {string} name Name of sound. */ -Blockly.WorkspaceAudio.prototype.load = function(filenames, name) { +WorkspaceAudio.prototype.load = function(filenames, name) { if (!filenames.length) { return; } @@ -98,7 +98,7 @@ Blockly.WorkspaceAudio.prototype.load = function(filenames, name) { * Preload all the audio files so that they play quickly when asked for. * @package */ -Blockly.WorkspaceAudio.prototype.preload = function() { +WorkspaceAudio.prototype.preload = function() { for (let name in this.SOUNDS_) { const sound = this.SOUNDS_[name]; sound.volume = 0.01; @@ -129,7 +129,7 @@ Blockly.WorkspaceAudio.prototype.preload = function() { * @param {string} name Name of sound. * @param {number=} opt_volume Volume of sound (0-1). */ -Blockly.WorkspaceAudio.prototype.play = function(name, opt_volume) { +WorkspaceAudio.prototype.play = function(name, opt_volume) { const sound = this.SOUNDS_[name]; if (sound) { // Don't play one sound on top of another. @@ -155,3 +155,5 @@ Blockly.WorkspaceAudio.prototype.play = function(name, opt_volume) { this.parentWorkspace_.getAudioManager().play(name, opt_volume); } }; + +exports = WorkspaceAudio; diff --git a/tests/deps.js b/tests/deps.js index 957896ec3..0018d3a1d 100644 --- a/tests/deps.js +++ b/tests/deps.js @@ -202,7 +202,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'], {'lang': 'es6', 'module': 'goog'}); 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.internalConstants', 'Blockly.utils', 'Blockly.utils.global', 'Blockly.utils.userAgent'], {'lang': 'es5'}); +goog.addDependency('../../core/workspace_audio.js', ['Blockly.WorkspaceAudio'], ['Blockly.internalConstants', 'Blockly.utils.global', 'Blockly.utils.userAgent'], {'lang': 'es6', 'module': 'goog'}); 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']);