@tsparticles/plugin-sounds 3.1.0 → 3.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,15 @@
4
4
  * Demo / Generator : https://particles.js.org/
5
5
  * GitHub : https://www.github.com/matteobruni/tsparticles
6
6
  * How to use? : Check the GitHub README
7
- * v3.1.0
7
+ * v3.2.1
8
+ */
9
+ /*
10
+ * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
11
+ * This devtool is neither made for production nor for readable output files.
12
+ * It uses "eval()" calls to create a separate source file in the browser devtools.
13
+ * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
14
+ * or disable the default devtool with "devtool: false".
15
+ * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
8
16
  */
9
17
  (function webpackUniversalModuleDefinition(root, factory) {
10
18
  if(typeof exports === 'object' && typeof module === 'object')
@@ -15,15 +23,28 @@
15
23
  var a = typeof exports === 'object' ? factory(require("@tsparticles/engine")) : factory(root["window"]);
16
24
  for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
17
25
  }
18
- })(this, (__WEBPACK_EXTERNAL_MODULE__533__) => {
26
+ })(this, (__WEBPACK_EXTERNAL_MODULE__tsparticles_engine__) => {
19
27
  return /******/ (() => { // webpackBootstrap
20
28
  /******/ "use strict";
21
29
  /******/ var __webpack_modules__ = ({
22
30
 
23
- /***/ 533:
31
+ /***/ "./dist/browser/index.js":
32
+ /*!*******************************!*\
33
+ !*** ./dist/browser/index.js ***!
34
+ \*******************************/
35
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
36
+
37
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadSoundsPlugin: () => (/* binding */ loadSoundsPlugin)\n/* harmony export */ });\nasync function loadSoundsPlugin(engine, refresh = true) {\n const {\n SoundsPlugin\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_SoundsPlugin_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./SoundsPlugin.js */ \"./dist/browser/SoundsPlugin.js\"));\n await engine.addPlugin(new SoundsPlugin(engine), refresh);\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-sounds/./dist/browser/index.js?");
38
+
39
+ /***/ }),
40
+
41
+ /***/ "@tsparticles/engine":
42
+ /*!*********************************************************************************************************************************!*\
43
+ !*** external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"} ***!
44
+ \*********************************************************************************************************************************/
24
45
  /***/ ((module) => {
25
46
 
26
- module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
47
+ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
27
48
 
28
49
  /***/ })
29
50
 
@@ -53,7 +74,22 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
53
74
  /******/ return module.exports;
54
75
  /******/ }
55
76
  /******/
77
+ /******/ // expose the modules object (__webpack_modules__)
78
+ /******/ __webpack_require__.m = __webpack_modules__;
79
+ /******/
56
80
  /************************************************************************/
81
+ /******/ /* webpack/runtime/compat get default export */
82
+ /******/ (() => {
83
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
84
+ /******/ __webpack_require__.n = (module) => {
85
+ /******/ var getter = module && module.__esModule ?
86
+ /******/ () => (module['default']) :
87
+ /******/ () => (module);
88
+ /******/ __webpack_require__.d(getter, { a: getter });
89
+ /******/ return getter;
90
+ /******/ };
91
+ /******/ })();
92
+ /******/
57
93
  /******/ /* webpack/runtime/define property getters */
58
94
  /******/ (() => {
59
95
  /******/ // define getter functions for harmony exports
@@ -66,11 +102,91 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
66
102
  /******/ };
67
103
  /******/ })();
68
104
  /******/
105
+ /******/ /* webpack/runtime/ensure chunk */
106
+ /******/ (() => {
107
+ /******/ __webpack_require__.f = {};
108
+ /******/ // This file contains only the entry chunk.
109
+ /******/ // The chunk loading function for additional chunks
110
+ /******/ __webpack_require__.e = (chunkId) => {
111
+ /******/ return Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => {
112
+ /******/ __webpack_require__.f[key](chunkId, promises);
113
+ /******/ return promises;
114
+ /******/ }, []));
115
+ /******/ };
116
+ /******/ })();
117
+ /******/
118
+ /******/ /* webpack/runtime/get javascript chunk filename */
119
+ /******/ (() => {
120
+ /******/ // This function allow to reference async chunks
121
+ /******/ __webpack_require__.u = (chunkId) => {
122
+ /******/ // return url for filenames based on template
123
+ /******/ return "" + chunkId + ".js";
124
+ /******/ };
125
+ /******/ })();
126
+ /******/
127
+ /******/ /* webpack/runtime/global */
128
+ /******/ (() => {
129
+ /******/ __webpack_require__.g = (function() {
130
+ /******/ if (typeof globalThis === 'object') return globalThis;
131
+ /******/ try {
132
+ /******/ return this || new Function('return this')();
133
+ /******/ } catch (e) {
134
+ /******/ if (typeof window === 'object') return window;
135
+ /******/ }
136
+ /******/ })();
137
+ /******/ })();
138
+ /******/
69
139
  /******/ /* webpack/runtime/hasOwnProperty shorthand */
70
140
  /******/ (() => {
71
141
  /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
72
142
  /******/ })();
73
143
  /******/
144
+ /******/ /* webpack/runtime/load script */
145
+ /******/ (() => {
146
+ /******/ var inProgress = {};
147
+ /******/ var dataWebpackPrefix = "@tsparticles/plugin-sounds:";
148
+ /******/ // loadScript function to load a script via script tag
149
+ /******/ __webpack_require__.l = (url, done, key, chunkId) => {
150
+ /******/ if(inProgress[url]) { inProgress[url].push(done); return; }
151
+ /******/ var script, needAttach;
152
+ /******/ if(key !== undefined) {
153
+ /******/ var scripts = document.getElementsByTagName("script");
154
+ /******/ for(var i = 0; i < scripts.length; i++) {
155
+ /******/ var s = scripts[i];
156
+ /******/ if(s.getAttribute("src") == url || s.getAttribute("data-webpack") == dataWebpackPrefix + key) { script = s; break; }
157
+ /******/ }
158
+ /******/ }
159
+ /******/ if(!script) {
160
+ /******/ needAttach = true;
161
+ /******/ script = document.createElement('script');
162
+ /******/
163
+ /******/ script.charset = 'utf-8';
164
+ /******/ script.timeout = 120;
165
+ /******/ if (__webpack_require__.nc) {
166
+ /******/ script.setAttribute("nonce", __webpack_require__.nc);
167
+ /******/ }
168
+ /******/ script.setAttribute("data-webpack", dataWebpackPrefix + key);
169
+ /******/
170
+ /******/ script.src = url;
171
+ /******/ }
172
+ /******/ inProgress[url] = [done];
173
+ /******/ var onScriptComplete = (prev, event) => {
174
+ /******/ // avoid mem leaks in IE.
175
+ /******/ script.onerror = script.onload = null;
176
+ /******/ clearTimeout(timeout);
177
+ /******/ var doneFns = inProgress[url];
178
+ /******/ delete inProgress[url];
179
+ /******/ script.parentNode && script.parentNode.removeChild(script);
180
+ /******/ doneFns && doneFns.forEach((fn) => (fn(event)));
181
+ /******/ if(prev) return prev(event);
182
+ /******/ }
183
+ /******/ var timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000);
184
+ /******/ script.onerror = onScriptComplete.bind(null, script.onerror);
185
+ /******/ script.onload = onScriptComplete.bind(null, script.onload);
186
+ /******/ needAttach && document.head.appendChild(script);
187
+ /******/ };
188
+ /******/ })();
189
+ /******/
74
190
  /******/ /* webpack/runtime/make namespace object */
75
191
  /******/ (() => {
76
192
  /******/ // define __esModule on exports
@@ -82,844 +198,128 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
82
198
  /******/ };
83
199
  /******/ })();
84
200
  /******/
201
+ /******/ /* webpack/runtime/publicPath */
202
+ /******/ (() => {
203
+ /******/ var scriptUrl;
204
+ /******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
205
+ /******/ var document = __webpack_require__.g.document;
206
+ /******/ if (!scriptUrl && document) {
207
+ /******/ if (document.currentScript)
208
+ /******/ scriptUrl = document.currentScript.src;
209
+ /******/ if (!scriptUrl) {
210
+ /******/ var scripts = document.getElementsByTagName("script");
211
+ /******/ if(scripts.length) {
212
+ /******/ var i = scripts.length - 1;
213
+ /******/ while (i > -1 && !scriptUrl) scriptUrl = scripts[i--].src;
214
+ /******/ }
215
+ /******/ }
216
+ /******/ }
217
+ /******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration
218
+ /******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.
219
+ /******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
220
+ /******/ scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
221
+ /******/ __webpack_require__.p = scriptUrl;
222
+ /******/ })();
223
+ /******/
224
+ /******/ /* webpack/runtime/jsonp chunk loading */
225
+ /******/ (() => {
226
+ /******/ // no baseURI
227
+ /******/
228
+ /******/ // object to store loaded and loading chunks
229
+ /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
230
+ /******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
231
+ /******/ var installedChunks = {
232
+ /******/ "tsparticles.plugin.sounds": 0
233
+ /******/ };
234
+ /******/
235
+ /******/ __webpack_require__.f.j = (chunkId, promises) => {
236
+ /******/ // JSONP chunk loading for javascript
237
+ /******/ var installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;
238
+ /******/ if(installedChunkData !== 0) { // 0 means "already installed".
239
+ /******/
240
+ /******/ // a Promise means "currently loading".
241
+ /******/ if(installedChunkData) {
242
+ /******/ promises.push(installedChunkData[2]);
243
+ /******/ } else {
244
+ /******/ if(true) { // all chunks have JS
245
+ /******/ // setup Promise in chunk cache
246
+ /******/ var promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject]));
247
+ /******/ promises.push(installedChunkData[2] = promise);
248
+ /******/
249
+ /******/ // start chunk loading
250
+ /******/ var url = __webpack_require__.p + __webpack_require__.u(chunkId);
251
+ /******/ // create error before stack unwound to get useful stacktrace later
252
+ /******/ var error = new Error();
253
+ /******/ var loadingEnded = (event) => {
254
+ /******/ if(__webpack_require__.o(installedChunks, chunkId)) {
255
+ /******/ installedChunkData = installedChunks[chunkId];
256
+ /******/ if(installedChunkData !== 0) installedChunks[chunkId] = undefined;
257
+ /******/ if(installedChunkData) {
258
+ /******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
259
+ /******/ var realSrc = event && event.target && event.target.src;
260
+ /******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')';
261
+ /******/ error.name = 'ChunkLoadError';
262
+ /******/ error.type = errorType;
263
+ /******/ error.request = realSrc;
264
+ /******/ installedChunkData[1](error);
265
+ /******/ }
266
+ /******/ }
267
+ /******/ };
268
+ /******/ __webpack_require__.l(url, loadingEnded, "chunk-" + chunkId, chunkId);
269
+ /******/ }
270
+ /******/ }
271
+ /******/ }
272
+ /******/ };
273
+ /******/
274
+ /******/ // no prefetching
275
+ /******/
276
+ /******/ // no preloaded
277
+ /******/
278
+ /******/ // no HMR
279
+ /******/
280
+ /******/ // no HMR manifest
281
+ /******/
282
+ /******/ // no on chunks loaded
283
+ /******/
284
+ /******/ // install a JSONP callback for chunk loading
285
+ /******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
286
+ /******/ var chunkIds = data[0];
287
+ /******/ var moreModules = data[1];
288
+ /******/ var runtime = data[2];
289
+ /******/ // add "moreModules" to the modules object,
290
+ /******/ // then flag all "chunkIds" as loaded and fire callback
291
+ /******/ var moduleId, chunkId, i = 0;
292
+ /******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) {
293
+ /******/ for(moduleId in moreModules) {
294
+ /******/ if(__webpack_require__.o(moreModules, moduleId)) {
295
+ /******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
296
+ /******/ }
297
+ /******/ }
298
+ /******/ if(runtime) var result = runtime(__webpack_require__);
299
+ /******/ }
300
+ /******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
301
+ /******/ for(;i < chunkIds.length; i++) {
302
+ /******/ chunkId = chunkIds[i];
303
+ /******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
304
+ /******/ installedChunks[chunkId][0]();
305
+ /******/ }
306
+ /******/ installedChunks[chunkId] = 0;
307
+ /******/ }
308
+ /******/
309
+ /******/ }
310
+ /******/
311
+ /******/ var chunkLoadingGlobal = this["webpackChunk_tsparticles_plugin_sounds"] = this["webpackChunk_tsparticles_plugin_sounds"] || [];
312
+ /******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
313
+ /******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
314
+ /******/ })();
315
+ /******/
85
316
  /************************************************************************/
86
- var __webpack_exports__ = {};
87
- // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
88
- (() => {
89
- // ESM COMPAT FLAG
90
- __webpack_require__.r(__webpack_exports__);
91
-
92
- // EXPORTS
93
- __webpack_require__.d(__webpack_exports__, {
94
- loadSoundsPlugin: () => (/* binding */ loadSoundsPlugin)
95
- });
96
-
97
- // EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
98
- var engine_root_window_ = __webpack_require__(533);
99
- ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/SoundsAudio.js
100
-
101
- class SoundsAudio {
102
- constructor() {
103
- this.loop = false;
104
- this.source = "";
105
- }
106
- load(data) {
107
- if (data === undefined) {
108
- return;
109
- }
110
- if ((0,engine_root_window_.isObject)(data)) {
111
- if (data.loop !== undefined) {
112
- this.loop = data.loop;
113
- }
114
- if (data.source !== undefined) {
115
- this.source = data.source;
116
- }
117
- } else {
118
- this.source = data;
119
- }
120
- }
121
- }
122
- ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/SoundsNote.js
123
- class SoundsNote {
124
- constructor() {
125
- this.duration = 500;
126
- this.value = [];
127
- }
128
- load(data) {
129
- if (!data) {
130
- return;
131
- }
132
- if (data.duration !== undefined) {
133
- this.duration = data.duration;
134
- }
135
- if (data.value !== undefined) {
136
- this.value = data.value;
137
- }
138
- }
139
- }
140
- ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/SoundsMelody.js
141
-
142
- class SoundsMelody {
143
- constructor() {
144
- this.loop = false;
145
- this.melodies = [];
146
- this.notes = [];
147
- }
148
- load(data) {
149
- if (data === undefined) {
150
- return;
151
- }
152
- if (data.loop !== undefined) {
153
- this.loop = data.loop;
154
- }
155
- if (data.melodies !== undefined) {
156
- this.melodies = data.melodies.map(s => {
157
- const tmp = new SoundsMelody();
158
- tmp.load(s);
159
- return tmp;
160
- });
161
- }
162
- if (data.notes !== undefined) {
163
- this.notes = data.notes.map(s => {
164
- const tmp = new SoundsNote();
165
- tmp.load(s);
166
- return tmp;
167
- });
168
- }
169
- }
170
- }
171
- ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/SoundsEvent.js
172
-
173
-
174
-
175
-
176
- class SoundsEvent {
177
- constructor() {
178
- this.event = [];
179
- this.notes = [];
180
- }
181
- load(data) {
182
- if (!data) {
183
- return;
184
- }
185
- if (data.event !== undefined) {
186
- this.event = data.event;
187
- }
188
- if (data.audio !== undefined) {
189
- if ((0,engine_root_window_.isArray)(data.audio)) {
190
- this.audio = data.audio.map(s => {
191
- const tmp = new SoundsAudio();
192
- tmp.load(s);
193
- return tmp;
194
- });
195
- } else {
196
- this.audio = new SoundsAudio();
197
- this.audio.load(data.audio);
198
- }
199
- }
200
- if (data.notes !== undefined) {
201
- this.notes = data.notes.map(t => {
202
- const tmp = new SoundsNote();
203
- tmp.load(t);
204
- return tmp;
205
- });
206
- }
207
- if (data.melodies !== undefined) {
208
- this.melodies = data.melodies.map(t => {
209
- const tmp = new SoundsMelody();
210
- tmp.load(t);
211
- return tmp;
212
- });
213
- }
214
- if (data.filter) {
215
- if ((0,engine_root_window_.isString)(data.filter)) {
216
- const filterFunc = window[data.filter];
217
- if ((0,engine_root_window_.isFunction)(filterFunc)) {
218
- this.filter = filterFunc;
219
- }
220
- } else {
221
- this.filter = data.filter;
222
- }
223
- }
224
- }
225
- }
226
- ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/SoundsIcon.js
227
- class SoundsIcon {
228
- constructor() {
229
- this.width = 24;
230
- this.height = 24;
231
- this.style = "";
232
- }
233
- load(data) {
234
- if (!data) {
235
- return;
236
- }
237
- if (data.path !== undefined) {
238
- this.path = data.path;
239
- }
240
- if (data.svg !== undefined) {
241
- this.svg = data.svg;
242
- }
243
- if (data.width !== undefined) {
244
- this.width = data.width;
245
- }
246
- if (data.height !== undefined) {
247
- this.height = data.height;
248
- }
249
- }
250
- }
251
- ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/SoundsIcons.js
252
-
253
- class SoundsIcons {
254
- constructor() {
255
- this.mute = new SoundsIcon();
256
- this.unmute = new SoundsIcon();
257
- this.volumeDown = new SoundsIcon();
258
- this.volumeUp = new SoundsIcon();
259
- this.enable = false;
260
- this.mute.svg = `<?xml version="1.0"?>
261
- <svg baseProfile="tiny" height="24px" version="1.2" viewBox="0 0 24 24" width="24px"
262
- xml:space="preserve" xmlns="http://www.w3.org/2000/svg"
263
- xmlns:xlink="http://www.w3.org/1999/xlink">
264
- <g id="Layer_1">
265
- <path fill="#fff" d="M19.707,5.293c-0.391-0.391-1.023-0.391-1.414,0l-1.551,1.551c-0.345-0.688-0.987-1.02-1.604-1.02c-0.449,0-0.905,0.152-1.356,0.453l-2.672,1.781C10.357,8.561,8.904,9,8,9c-1.654,0-3,1.346-3,3v2c0,1.237,0.754,2.302,1.826,2.76l-1.533,1.533c-0.391,0.391-0.391,1.023,0,1.414C5.488,19.902,5.744,20,6,20s0.512-0.098,0.707-0.293l2.527-2.527c0.697,0.174,1.416,0.455,1.875,0.762l2.672,1.781c0.451,0.301,0.907,0.453,1.356,0.453C16.035,20.176,17,19.495,17,18V9.414l2.707-2.707C20.098,6.316,20.098,5.684,19.707,5.293z M14.891,7.941c0.038-0.025,0.073-0.046,0.104-0.062C14.998,7.914,15,7.954,15,8v1.293l-2,2V9.202L14.891,7.941z M7,12c0-0.552,0.448-1,1-1c1.211,0,2.907-0.495,4-1.146v2.439l-2.83,2.83C8.757,15.046,8.356,15,8,15c-0.552,0-1-0.448-1-1V12z M10.301,15.406L12,13.707v2.439C11.519,15.859,10.925,15.604,10.301,15.406z M14.994,18.12c-0.03-0.016-0.065-0.036-0.104-0.062L13,16.798v-4.091l2-2V18C15,18.046,14.998,18.086,14.994,18.12z"/>
266
- </g>
267
- </svg>`;
268
- this.unmute.svg = `<?xml version="1.0"?>
269
- <svg baseProfile="tiny" height="24px" version="1.2" viewBox="0 0 24 24" width="24px"
270
- xml:space="preserve" xmlns="http://www.w3.org/2000/svg"
271
- xmlns:xlink="http://www.w3.org/1999/xlink">
272
- <g id="Layer_1">
273
- <path fill="#fff" d="M17.138,5.824c-0.449,0-0.905,0.152-1.356,0.453l-2.672,1.781C12.357,8.561,10.904,9,10,9c-1.654,0-3,1.346-3,3v2c0,1.654,1.346,3,3,3c0.904,0,2.357,0.439,3.109,0.941l2.672,1.781c0.451,0.301,0.907,0.453,1.356,0.453C18.035,20.176,19,19.495,19,18V8C19,6.505,18.035,5.824,17.138,5.824z M14,16.146C12.907,15.495,11.211,15,10,15c-0.552,0-1-0.448-1-1v-2c0-0.552,0.448-1,1-1c1.211,0,2.907-0.495,4-1.146V16.146z M17,18c0,0.046-0.002,0.086-0.006,0.12c-0.03-0.016-0.065-0.036-0.104-0.062L15,16.798V9.202l1.891-1.261c0.038-0.025,0.073-0.046,0.104-0.062C16.998,7.914,17,7.954,17,8V18z"/>
274
- </g>
275
- </svg>`;
276
- this.volumeDown.svg = `<?xml version="1.0"?>
277
- <svg baseProfile="tiny" height="24px" version="1.2" viewBox="0 0 24 24" width="24px"
278
- xml:space="preserve" xmlns="http://www.w3.org/2000/svg"
279
- xmlns:xlink="http://www.w3.org/1999/xlink">
280
- <g id="Layer_1">
281
- <path fill="#fff" d="M15.138,5.824c-0.449,0-0.905,0.152-1.356,0.453l-2.672,1.781C10.357,8.561,8.904,9,8,9c-1.654,0-3,1.346-3,3v2c0,1.654,1.346,3,3,3c0.904,0,2.357,0.439,3.109,0.941l2.672,1.781c0.451,0.301,0.907,0.453,1.356,0.453C16.035,20.176,17,19.495,17,18V8C17,6.505,16.035,5.824,15.138,5.824z M8,15c-0.552,0-1-0.448-1-1v-2c0-0.552,0.448-1,1-1c1.211,0,2.907-0.495,4-1.146v6.293C10.907,15.495,9.211,15,8,15z M15,18c0,0.046-0.002,0.086-0.006,0.12c-0.03-0.016-0.065-0.036-0.104-0.062L13,16.798V9.202l1.891-1.261c0.038-0.025,0.073-0.046,0.104-0.062C14.998,7.914,15,7.954,15,8V18z"/>
282
- <path fill="#fff" d="M18.292,10.294c-0.39,0.391-0.39,1.023,0.002,1.414c0.345,0.345,0.535,0.803,0.535,1.291c0,0.489-0.19,0.948-0.536,1.294c-0.391,0.39-0.391,1.023,0,1.414C18.488,15.902,18.744,16,19,16s0.512-0.098,0.707-0.293c0.724-0.723,1.122-1.685,1.122-2.708s-0.398-1.984-1.123-2.707C19.317,9.903,18.683,9.901,18.292,10.294z"/>
283
- </g>
284
- </svg>`;
285
- this.volumeUp.svg = `<?xml version="1.0"?>
286
- <svg baseProfile="tiny" height="24px" version="1.2" viewBox="0 0 24 24" width="24px"
287
- xml:space="preserve" xmlns="http://www.w3.org/2000/svg"
288
- xmlns:xlink="http://www.w3.org/1999/xlink">
289
- <g id="Layer_1">
290
- <path fill="#fff" d="M16.706,10.292c-0.389-0.389-1.023-0.391-1.414,0.002c-0.39,0.391-0.39,1.023,0.002,1.414c0.345,0.345,0.535,0.803,0.535,1.291c0,0.489-0.19,0.948-0.536,1.294c-0.391,0.39-0.391,1.023,0,1.414C15.488,15.902,15.744,16,16,16s0.512-0.098,0.707-0.293c0.724-0.723,1.122-1.685,1.122-2.708S17.431,11.015,16.706,10.292z"/>
291
- <path fill="#fff" d="M18.706,8.292c-0.391-0.389-1.023-0.39-1.414,0.002c-0.39,0.391-0.39,1.024,0.002,1.414c0.879,0.877,1.363,2.044,1.364,3.287c0.001,1.246-0.484,2.417-1.365,3.298c-0.391,0.391-0.391,1.023,0,1.414C17.488,17.902,17.744,18,18,18s0.512-0.098,0.707-0.293c1.259-1.259,1.952-2.933,1.951-4.713C20.657,11.217,19.964,9.547,18.706,8.292z"/>
292
- <path fill="#fff" d="M20.706,6.292c-0.391-0.389-1.023-0.39-1.414,0.002c-0.39,0.391-0.39,1.024,0.002,1.414c1.412,1.409,2.191,3.285,2.192,5.284c0.002,2.002-0.777,3.885-2.193,5.301c-0.391,0.391-0.391,1.023,0,1.414C19.488,19.902,19.744,20,20,20s0.512-0.098,0.707-0.293c1.794-1.794,2.781-4.18,2.779-6.717C23.485,10.457,22.497,8.078,20.706,6.292z"/>
293
- <path fill="#fff" d="M12.138,5.824c-0.449,0-0.905,0.152-1.356,0.453L8.109,8.059C7.357,8.561,5.904,9,5,9c-1.654,0-3,1.346-3,3v2c0,1.654,1.346,3,3,3c0.904,0,2.357,0.439,3.109,0.941l2.672,1.781c0.451,0.301,0.907,0.453,1.356,0.453C13.035,20.176,14,19.495,14,18V8C14,6.505,13.035,5.824,12.138,5.824z M5,15c-0.552,0-1-0.448-1-1v-2c0-0.552,0.448-1,1-1c1.211,0,2.907-0.495,4-1.146v6.293C7.907,15.495,6.211,15,5,15z M12,18c0,0.046-0.002,0.086-0.006,0.12c-0.03-0.016-0.065-0.036-0.104-0.062L10,16.798V9.202l1.891-1.261c0.038-0.025,0.073-0.046,0.104-0.062C11.998,7.914,12,7.954,12,8V18z"/>
294
- </g>
295
- </svg>`;
296
- }
297
- load(data) {
298
- if (!data) {
299
- return;
300
- }
301
- if (data.enable !== undefined) {
302
- this.enable = data.enable;
303
- }
304
- this.mute.load(data.mute);
305
- this.unmute.load(data.unmute);
306
- this.volumeDown.load(data.volumeDown);
307
- this.volumeUp.load(data.volumeUp);
308
- }
309
- }
310
- ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/SoundsVolume.js
311
-
312
- class SoundsVolume {
313
- constructor() {
314
- this.value = 100;
315
- this.max = 100;
316
- this.min = 0;
317
- this.step = 10;
318
- }
319
- load(data) {
320
- if (data === undefined) {
321
- return;
322
- }
323
- if ((0,engine_root_window_.isObject)(data)) {
324
- if (data.max !== undefined) {
325
- this.max = data.max;
326
- }
327
- if (data.min !== undefined) {
328
- this.min = data.min;
329
- }
330
- if (data.step !== undefined) {
331
- this.step = data.step;
332
- }
333
- if (data.value !== undefined) {
334
- this.value = data.value;
335
- }
336
- } else {
337
- this.value = data;
338
- }
339
- }
340
- }
341
- ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Sounds.js
342
-
343
-
344
-
345
- class Sounds {
346
- constructor() {
347
- this.autoPlay = true;
348
- this.enable = false;
349
- this.events = [];
350
- this.icons = new SoundsIcons();
351
- this.volume = new SoundsVolume();
352
- }
353
- load(data) {
354
- if (!data) {
355
- return;
356
- }
357
- if (data.autoPlay !== undefined) {
358
- this.autoPlay = data.autoPlay;
359
- }
360
- if (data.enable !== undefined) {
361
- this.enable = data.enable;
362
- }
363
- if (data.events !== undefined) {
364
- this.events = data.events.map(t => {
365
- const event = new SoundsEvent();
366
- event.load(t);
367
- return event;
368
- });
369
- }
370
- this.icons.load(data.icons);
371
- if (data.volume !== undefined) {
372
- this.volume.load(data.volume);
373
- }
374
- }
375
- }
376
- ;// CONCATENATED MODULE: ./dist/browser/utils.js
377
- const notes = new Map();
378
- notes.set("C", [16.35, 32.7, 65.41, 130.81, 261.63, 523.25, 1046.5, 2093.0, 4186.01]);
379
- notes.set("Db", [17.32, 34.65, 69.3, 138.59, 277.18, 554.37, 1108.73, 2217.46, 4434.92]);
380
- notes.set("D", [18.35, 36.71, 73.42, 146.83, 293.66, 587.33, 1174.66, 2349.32, 4698.63]);
381
- notes.set("Eb", [19.45, 38.89, 77.78, 155.56, 311.13, 622.25, 1244.51, 2489.02, 4978.03]);
382
- notes.set("E", [20.6, 41.2, 82.41, 164.81, 329.63, 659.25, 1318.51, 2637.02, 5274.04]);
383
- notes.set("F", [21.83, 43.65, 87.31, 174.61, 349.23, 698.46, 1396.91, 2793.83, 5587.65]);
384
- notes.set("Gb", [23.12, 46.25, 92.5, 185.0, 369.99, 739.99, 1479.98, 2959.96, 5919.91]);
385
- notes.set("G", [24.5, 49.0, 98.0, 196.0, 392.0, 783.99, 1567.98, 3135.96, 6271.93]);
386
- notes.set("Ab", [25.96, 51.91, 103.83, 207.65, 415.3, 830.61, 1661.22, 3322.44, 6644.88]);
387
- notes.set("A", [27.5, 55.0, 110.0, 220.0, 440.0, 880.0, 1760.0, 3520.0, 7040.0]);
388
- notes.set("Bb", [29.14, 58.27, 116.54, 233.08, 466.16, 932.33, 1864.66, 3729.31, 7458.62]);
389
- notes.set("B", [30.87, 61.74, 123.47, 246.94, 493.88, 987.77, 1975.53, 3951.07, 7902.13]);
390
- notes.set("pause", [0]);
391
- function getNoteFrequency(note) {
392
- const regex = /(([A-G]b?)(\d))|pause/i,
393
- result = regex.exec(note),
394
- groupKey = 2,
395
- defaultMatchKey = 0,
396
- innerGroupKey = 3;
397
- if (!result?.length) {
398
- return;
399
- }
400
- const noteKey = result[groupKey] || result[defaultMatchKey],
401
- noteItem = notes.get(noteKey);
402
- if (!noteItem) {
403
- return;
404
- }
405
- return noteItem[parseInt(result[innerGroupKey] || "0")];
406
- }
407
- let muted = true;
408
- const isWindowMuted = () => {
409
- return muted;
410
- };
411
- const unmuteWindow = () => {
412
- muted = false;
413
- };
414
- ;// CONCATENATED MODULE: ./dist/browser/SoundsInstance.js
415
-
416
-
417
- const zIndexOffset = 1,
418
- rightOffset = 1,
419
- minVolume = 0;
420
- function initImage(data) {
421
- const img = document.createElement("img"),
422
- {
423
- clickCb,
424
- container,
425
- display,
426
- iconOptions,
427
- margin,
428
- options,
429
- pos,
430
- rightOffsets
431
- } = data,
432
- {
433
- width,
434
- path,
435
- style,
436
- svg
437
- } = iconOptions,
438
- defaultAccumulator = 0;
439
- setIconStyle(img, pos.top + margin, pos.right - (margin * (rightOffsets.length + rightOffset) + width + rightOffsets.reduce((a, b) => a + b, defaultAccumulator)), display, options.fullScreen.zIndex + zIndexOffset, width, margin, style);
440
- img.src = path ?? (svg ? `data:image/svg+xml;base64,${btoa(svg)}` : "");
441
- const parent = container.canvas.element?.parentNode ?? document.body;
442
- parent.append(img);
443
- img.addEventListener("click", () => {
444
- void clickCb();
445
- });
446
- return img;
447
- }
448
- function removeImage(image) {
449
- if (!image) {
450
- return;
451
- }
452
- image.remove();
453
- }
454
- function setIconStyle(icon, top, left, display, zIndex, width, margin, style) {
455
- icon.style.userSelect = "none";
456
- icon.style.webkitUserSelect = "none";
457
- icon.style.position = "absolute";
458
- icon.style.top = `${top + margin}px`;
459
- icon.style.left = `${left - margin - width}px`;
460
- icon.style.display = display;
461
- icon.style.zIndex = `${zIndex + zIndexOffset}`;
462
- icon.style.cssText += style;
463
- }
464
- class SoundsInstance {
465
- constructor(container, engine) {
466
- this._addBuffer = audioCtx => {
467
- const buffer = audioCtx.createBufferSource();
468
- this._audioSources.push(buffer);
469
- return buffer;
470
- };
471
- this._addOscillator = audioCtx => {
472
- const oscillator = audioCtx.createOscillator();
473
- this._audioSources.push(oscillator);
474
- return oscillator;
475
- };
476
- this._initEvents = () => {
477
- const container = this._container,
478
- soundsOptions = container.actualOptions.sounds;
479
- if (!soundsOptions?.enable || !container.canvas.element) {
480
- return;
481
- }
482
- for (const event of soundsOptions.events) {
483
- const cb = args => {
484
- void (async () => {
485
- const filterNotValid = event.filter && !event.filter(args);
486
- if (this._container !== args.container) {
487
- return;
488
- }
489
- if (!this._container || !!this._container.muted || this._container.destroyed) {
490
- (0,engine_root_window_.executeOnSingleOrMultiple)(event.event, item => {
491
- this._engine.removeEventListener(item, cb);
492
- });
493
- return;
494
- }
495
- if (filterNotValid) {
496
- return;
497
- }
498
- const defaultNoteIndex = 0;
499
- if (event.audio) {
500
- this._playBuffer((0,engine_root_window_.itemFromSingleOrMultiple)(event.audio));
501
- } else if (event.melodies) {
502
- const melody = (0,engine_root_window_.itemFromArray)(event.melodies);
503
- if (melody.melodies.length) {
504
- await Promise.allSettled(melody.melodies.map(m => this._playNote(m.notes, defaultNoteIndex, melody.loop)));
505
- } else {
506
- await this._playNote(melody.notes, defaultNoteIndex, melody.loop);
507
- }
508
- } else if (event.notes) {
509
- const note = (0,engine_root_window_.itemFromArray)(event.notes);
510
- await this._playNote([note], defaultNoteIndex, false);
511
- }
512
- })();
513
- };
514
- (0,engine_root_window_.executeOnSingleOrMultiple)(event.event, item => {
515
- this._engine.addEventListener(item, cb);
516
- });
517
- }
518
- };
519
- this._mute = async () => {
520
- const container = this._container,
521
- audioContext = this._getAudioContext();
522
- for (const source of this._audioSources) {
523
- this._removeAudioSource(source);
524
- }
525
- if (this._gain) {
526
- this._gain.disconnect();
527
- }
528
- await audioContext.close();
529
- container.audioContext = undefined;
530
- this._engine.dispatchEvent("soundsMuted", {
531
- container: this._container
532
- });
533
- };
534
- this._playBuffer = audio => {
535
- const audioBuffer = this._audioMap.get(audio.source);
536
- if (!audioBuffer) {
537
- return;
538
- }
539
- const audioCtx = this._container.audioContext;
540
- if (!audioCtx) {
541
- return;
542
- }
543
- const source = this._addBuffer(audioCtx);
544
- source.loop = audio.loop;
545
- source.buffer = audioBuffer;
546
- source.connect(this._gain ?? audioCtx.destination);
547
- source.start();
548
- };
549
- this._playFrequency = async (frequency, duration) => {
550
- if (!this._gain || this._container.muted) {
551
- return;
552
- }
553
- const audioContext = this._getAudioContext(),
554
- oscillator = this._addOscillator(audioContext);
555
- oscillator.connect(this._gain);
556
- oscillator.type = "sine";
557
- oscillator.frequency.value = frequency;
558
- oscillator.start();
559
- return new Promise(resolve => {
560
- setTimeout(() => {
561
- this._removeAudioSource(oscillator);
562
- resolve();
563
- }, duration);
564
- });
565
- };
566
- this._playMuteSound = () => {
567
- if (this._container.muted) {
568
- return;
569
- }
570
- const audioContext = this._getAudioContext(),
571
- gain = audioContext.createGain();
572
- gain.connect(audioContext.destination);
573
- gain.gain.value = 0;
574
- const oscillator = audioContext.createOscillator();
575
- oscillator.connect(gain);
576
- oscillator.type = "sine";
577
- oscillator.frequency.value = 1;
578
- oscillator.start();
579
- setTimeout(() => {
580
- oscillator.stop();
581
- oscillator.disconnect();
582
- gain.disconnect();
583
- });
584
- };
585
- this._playNote = async (notes, noteIdx, loop) => {
586
- if (this._container.muted) {
587
- return;
588
- }
589
- const note = notes[noteIdx];
590
- if (!note) {
591
- return;
592
- }
593
- const value = note.value;
594
- const promises = (0,engine_root_window_.executeOnSingleOrMultiple)(value, async (_, idx) => {
595
- return this._playNoteValue(notes, noteIdx, idx);
596
- });
597
- await ((0,engine_root_window_.isArray)(promises) ? Promise.allSettled(promises) : promises);
598
- const indexOffset = 1;
599
- let nextNoteIdx = noteIdx + indexOffset;
600
- if (loop && nextNoteIdx >= notes.length) {
601
- nextNoteIdx = nextNoteIdx % notes.length;
602
- }
603
- if (this._container.muted) {
604
- return;
605
- }
606
- await this._playNote(notes, nextNoteIdx, loop);
607
- };
608
- this._playNoteValue = async (notes, noteIdx, valueIdx) => {
609
- const note = notes[noteIdx];
610
- if (!note) {
611
- return;
612
- }
613
- const value = (0,engine_root_window_.itemFromSingleOrMultiple)(note.value, valueIdx, true);
614
- try {
615
- const freq = getNoteFrequency(value);
616
- if (!(0,engine_root_window_.isNumber)(freq)) {
617
- return;
618
- }
619
- await this._playFrequency(freq, note.duration);
620
- } catch (e) {
621
- (0,engine_root_window_.getLogger)().error(e);
622
- }
623
- };
624
- this._removeAudioSource = source => {
625
- source.stop();
626
- source.disconnect();
627
- const deleteCount = 1;
628
- this._audioSources.splice(this._audioSources.indexOf(source), deleteCount);
629
- };
630
- this._unmute = () => {
631
- const container = this._container,
632
- options = container.actualOptions,
633
- soundsOptions = options.sounds;
634
- if (!soundsOptions) {
635
- return;
636
- }
637
- const audioContext = this._getAudioContext();
638
- if (!this._audioSources) {
639
- this._audioSources = [];
640
- }
641
- const gain = audioContext.createGain();
642
- gain.connect(audioContext.destination);
643
- gain.gain.value = soundsOptions.volume.value / engine_root_window_.percentDenominator;
644
- this._gain = gain;
645
- this._initEvents();
646
- this._engine.dispatchEvent("soundsUnmuted", {
647
- container: this._container
648
- });
649
- };
650
- this._updateMuteIcons = () => {
651
- const container = this._container,
652
- soundsOptions = container.actualOptions.sounds;
653
- if (!soundsOptions?.enable || !soundsOptions.icons.enable) {
654
- return;
655
- }
656
- const muteImg = this._muteImg,
657
- unmuteImg = this._unmuteImg;
658
- if (muteImg) {
659
- muteImg.style.display = container.muted ? "block" : "none";
660
- }
661
- if (unmuteImg) {
662
- unmuteImg.style.display = container.muted ? "none" : "block";
663
- }
664
- };
665
- this._updateMuteStatus = async () => {
666
- const container = this._container,
667
- audioContext = this._getAudioContext();
668
- if (container.muted) {
669
- await audioContext?.suspend();
670
- await this._mute();
671
- } else {
672
- await audioContext?.resume();
673
- this._unmute();
674
- this._playMuteSound();
675
- }
676
- };
677
- this._updateVolume = async () => {
678
- const container = this._container,
679
- soundsOptions = container.actualOptions.sounds;
680
- if (!soundsOptions?.enable) {
681
- return;
682
- }
683
- (0,engine_root_window_.clamp)(this._volume, soundsOptions.volume.min, soundsOptions.volume.max);
684
- let stateChanged = false;
685
- if (this._volume <= minVolume && !container.muted) {
686
- this._volume = 0;
687
- container.muted = true;
688
- stateChanged = true;
689
- } else if (this._volume > minVolume && container.muted) {
690
- container.muted = false;
691
- stateChanged = true;
692
- }
693
- if (stateChanged) {
694
- this._updateMuteIcons();
695
- await this._updateMuteStatus();
696
- }
697
- if (this._gain?.gain) {
698
- this._gain.gain.value = this._volume / engine_root_window_.percentDenominator;
699
- }
700
- };
701
- this._container = container;
702
- this._engine = engine;
703
- this._volume = 0;
704
- this._audioSources = [];
705
- this._audioMap = new Map();
706
- }
707
- async init() {
708
- const container = this._container,
709
- options = container.actualOptions,
710
- soundsOptions = options.sounds;
711
- if (!soundsOptions?.enable) {
712
- return;
713
- }
714
- if (soundsOptions.autoPlay && isWindowMuted()) {
715
- const firstClickHandler = () => {
716
- removeEventListener(engine_root_window_.mouseDownEvent, firstClickHandler);
717
- removeEventListener(engine_root_window_.touchStartEvent, firstClickHandler);
718
- unmuteWindow();
719
- void this.unmute();
720
- };
721
- const listenerOptions = {
722
- capture: true,
723
- once: true
724
- };
725
- addEventListener(engine_root_window_.mouseDownEvent, firstClickHandler, listenerOptions);
726
- addEventListener(engine_root_window_.touchStartEvent, firstClickHandler, listenerOptions);
727
- }
728
- this._volume = soundsOptions.volume.value;
729
- const events = soundsOptions.events;
730
- this._audioMap = new Map();
731
- for (const event of events) {
732
- if (!event.audio) {
733
- continue;
734
- }
735
- const promises = (0,engine_root_window_.executeOnSingleOrMultiple)(event.audio, async audio => {
736
- const response = await fetch(audio.source);
737
- if (!response.ok) {
738
- return;
739
- }
740
- const arrayBuffer = await response.arrayBuffer(),
741
- audioContext = this._getAudioContext(),
742
- audioBuffer = await audioContext.decodeAudioData(arrayBuffer);
743
- this._audioMap.set(audio.source, audioBuffer);
744
- });
745
- if (promises instanceof Promise) {
746
- await promises;
747
- } else {
748
- await Promise.allSettled(promises);
749
- }
750
- }
751
- }
752
- async mute() {
753
- if (!this._container.muted) {
754
- await this.toggleMute();
755
- }
756
- }
757
- async start() {
758
- const container = this._container,
759
- options = container.actualOptions,
760
- soundsOptions = options.sounds;
761
- if (!soundsOptions?.enable || !container.canvas.element) {
762
- return;
763
- }
764
- container.muted = true;
765
- const canvas = container.canvas.element,
766
- pos = {
767
- top: canvas.offsetTop,
768
- right: canvas.offsetLeft + canvas.offsetWidth
769
- },
770
- {
771
- mute,
772
- unmute,
773
- volumeDown,
774
- volumeUp
775
- } = soundsOptions.icons,
776
- margin = 10,
777
- toggleMute = async () => {
778
- await this.toggleMute();
779
- },
780
- enableIcons = soundsOptions.icons.enable,
781
- display = enableIcons ? "block" : "none";
782
- this._muteImg = initImage({
783
- container,
784
- options,
785
- pos,
786
- display,
787
- iconOptions: mute,
788
- margin,
789
- rightOffsets: [volumeDown.width, volumeUp.width],
790
- clickCb: toggleMute
791
- });
792
- this._unmuteImg = initImage({
793
- container,
794
- options,
795
- pos,
796
- display: "none",
797
- iconOptions: unmute,
798
- margin,
799
- rightOffsets: [volumeDown.width, volumeUp.width],
800
- clickCb: toggleMute
801
- });
802
- this._volumeDownImg = initImage({
803
- container,
804
- options,
805
- pos,
806
- display,
807
- iconOptions: volumeDown,
808
- margin,
809
- rightOffsets: [volumeUp.width],
810
- clickCb: async () => {
811
- await this.volumeDown();
812
- }
813
- });
814
- this._volumeUpImg = initImage({
815
- container,
816
- options,
817
- pos,
818
- display,
819
- iconOptions: volumeUp,
820
- margin,
821
- rightOffsets: [],
822
- clickCb: async () => {
823
- await this.volumeUp();
824
- }
825
- });
826
- if (!isWindowMuted() && soundsOptions.autoPlay) {
827
- await this.unmute();
828
- }
829
- }
830
- stop() {
831
- this._container.muted = true;
832
- void (async () => {
833
- await this._mute();
834
- removeImage(this._muteImg);
835
- removeImage(this._unmuteImg);
836
- removeImage(this._volumeDownImg);
837
- removeImage(this._volumeUpImg);
838
- })();
839
- }
840
- async toggleMute() {
841
- const container = this._container;
842
- container.muted = !container.muted;
843
- this._updateMuteIcons();
844
- await this._updateMuteStatus();
845
- }
846
- async unmute() {
847
- if (this._container.muted) {
848
- await this.toggleMute();
849
- }
850
- }
851
- async volumeDown() {
852
- const container = this._container,
853
- soundsOptions = container.actualOptions.sounds;
854
- if (!soundsOptions?.enable) {
855
- return;
856
- }
857
- if (container.muted) {
858
- this._volume = 0;
859
- }
860
- this._volume -= soundsOptions.volume.step;
861
- await this._updateVolume();
862
- }
863
- async volumeUp() {
864
- const container = this._container,
865
- soundsOptions = container.actualOptions.sounds;
866
- if (!soundsOptions?.enable) {
867
- return;
868
- }
869
- this._volume += soundsOptions.volume.step;
870
- await this._updateVolume();
871
- }
872
- _getAudioContext() {
873
- const container = this._container;
874
- if (!container.audioContext) {
875
- container.audioContext = new AudioContext();
876
- }
877
- return container.audioContext;
878
- }
879
- }
880
- ;// CONCATENATED MODULE: ./dist/browser/index.js
881
-
882
-
883
-
884
-
885
- const generalFirstClickHandler = () => {
886
- removeEventListener(engine_root_window_.mouseDownEvent, generalFirstClickHandler);
887
- removeEventListener(engine_root_window_.touchStartEvent, generalFirstClickHandler);
888
- unmuteWindow();
889
- };
890
- class SoundsPlugin {
891
- constructor(engine) {
892
- this.id = "sounds";
893
- this._engine = engine;
894
- const listenerOptions = {
895
- capture: true,
896
- once: true
897
- };
898
- addEventListener(engine_root_window_.mouseDownEvent, generalFirstClickHandler, listenerOptions);
899
- addEventListener(engine_root_window_.touchStartEvent, generalFirstClickHandler, listenerOptions);
900
- }
901
- getPlugin(container) {
902
- return new SoundsInstance(container, this._engine);
903
- }
904
- loadOptions(options, source) {
905
- if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
906
- return;
907
- }
908
- let soundsOptions = options.sounds;
909
- if (soundsOptions?.load === undefined) {
910
- options.sounds = soundsOptions = new Sounds();
911
- }
912
- soundsOptions.load(source?.sounds);
913
- }
914
- needsPlugin(options) {
915
- return options?.sounds?.enable ?? false;
916
- }
917
- }
918
- async function loadSoundsPlugin(engine, refresh = true) {
919
- await engine.addPlugin(new SoundsPlugin(engine), refresh);
920
- }
921
- })();
922
-
317
+ /******/
318
+ /******/ // startup
319
+ /******/ // Load entry module and return exports
320
+ /******/ // This entry module can't be inlined because the eval devtool is used.
321
+ /******/ var __webpack_exports__ = __webpack_require__("./dist/browser/index.js");
322
+ /******/
923
323
  /******/ return __webpack_exports__;
924
324
  /******/ })()
925
325
  ;