Migrate core/workspace_audio.js to goog.module

This commit is contained in:
kozbial
2021-07-26 14:46:27 -07:00
committed by Monica Kozbial
parent 6787624e3e
commit f7c88bfcd9
2 changed files with 11 additions and 9 deletions

View File

@@ -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;

View File

@@ -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']);