@tsparticles/plugin-sounds 3.0.3 → 3.2.0
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.
- package/265.min.js +2 -0
- package/265.min.js.LICENSE.txt +1 -0
- package/714.min.js +2 -0
- package/714.min.js.LICENSE.txt +1 -0
- package/browser/Options/Classes/Sounds.js +4 -0
- package/browser/Options/Classes/SoundsEvent.js +4 -3
- package/browser/Options/Classes/SoundsIcon.js +1 -0
- package/browser/Options/Classes/SoundsIcons.js +4 -0
- package/browser/SoundsInstance.js +130 -69
- package/browser/SoundsPlugin.js +37 -0
- package/browser/index.js +1 -24
- package/browser/utils.js +11 -4
- package/cjs/Options/Classes/Sounds.js +4 -0
- package/cjs/Options/Classes/SoundsEvent.js +4 -3
- package/cjs/Options/Classes/SoundsIcon.js +1 -0
- package/cjs/Options/Classes/SoundsIcons.js +4 -0
- package/cjs/SoundsInstance.js +128 -67
- package/cjs/SoundsPlugin.js +64 -0
- package/cjs/index.js +24 -24
- package/cjs/utils.js +14 -5
- package/dist_browser_SoundsInstance_js.js +30 -0
- package/dist_browser_SoundsPlugin_js.js +120 -0
- package/esm/Options/Classes/Sounds.js +4 -0
- package/esm/Options/Classes/SoundsEvent.js +4 -3
- package/esm/Options/Classes/SoundsIcon.js +1 -0
- package/esm/Options/Classes/SoundsIcons.js +4 -0
- package/esm/SoundsInstance.js +130 -69
- package/esm/SoundsPlugin.js +37 -0
- package/esm/index.js +1 -24
- package/esm/utils.js +11 -4
- package/package.json +2 -2
- package/report.html +3 -3
- package/tsparticles.plugin.sounds.js +241 -738
- package/tsparticles.plugin.sounds.min.js +1 -1
- package/tsparticles.plugin.sounds.min.js.LICENSE.txt +1 -1
- package/types/Options/Classes/Sounds.d.ts +1 -0
- package/types/Options/Classes/SoundsEvent.d.ts +0 -5
- package/types/Options/Classes/SoundsIcon.d.ts +1 -0
- package/types/Options/Classes/SoundsIcons.d.ts +1 -0
- package/types/Options/Interfaces/ISounds.d.ts +1 -0
- package/types/Options/Interfaces/ISoundsIcon.d.ts +1 -0
- package/types/Options/Interfaces/ISoundsIcons.d.ts +1 -0
- package/types/SoundsInstance.d.ts +6 -0
- package/types/SoundsPlugin.d.ts +11 -0
- package/types/index.d.ts +1 -1
- package/types/types.d.ts +5 -5
- package/types/utils.d.ts +2 -0
- package/umd/Options/Classes/Sounds.js +4 -0
- package/umd/Options/Classes/SoundsEvent.js +4 -3
- package/umd/Options/Classes/SoundsIcon.js +1 -0
- package/umd/Options/Classes/SoundsIcons.js +4 -0
- package/umd/SoundsInstance.js +128 -67
- package/umd/SoundsPlugin.js +75 -0
- package/umd/index.js +26 -25
- package/umd/utils.js +14 -5
|
@@ -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.0
|
|
7
|
+
* v3.2.0
|
|
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, (
|
|
26
|
+
})(this, (__WEBPACK_EXTERNAL_MODULE__tsparticles_engine__) => {
|
|
19
27
|
return /******/ (() => { // webpackBootstrap
|
|
20
28
|
/******/ "use strict";
|
|
21
29
|
/******/ var __webpack_modules__ = ({
|
|
22
30
|
|
|
23
|
-
/***/
|
|
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 =
|
|
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,741 +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
|
-
|
|
87
|
-
//
|
|
88
|
-
|
|
89
|
-
//
|
|
90
|
-
__webpack_require__.
|
|
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 !== undefined) {
|
|
215
|
-
if ((0,engine_root_window_.isString)(data.filter)) {
|
|
216
|
-
if ((0,engine_root_window_.isFunction)(window[data.filter])) {
|
|
217
|
-
this.filter = window[data.filter];
|
|
218
|
-
}
|
|
219
|
-
} else {
|
|
220
|
-
this.filter = data.filter;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/SoundsIcon.js
|
|
226
|
-
class SoundsIcon {
|
|
227
|
-
constructor() {
|
|
228
|
-
this.width = 24;
|
|
229
|
-
this.height = 24;
|
|
230
|
-
}
|
|
231
|
-
load(data) {
|
|
232
|
-
if (!data) {
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
if (data.path !== undefined) {
|
|
236
|
-
this.path = data.path;
|
|
237
|
-
}
|
|
238
|
-
if (data.svg !== undefined) {
|
|
239
|
-
this.svg = data.svg;
|
|
240
|
-
}
|
|
241
|
-
if (data.width !== undefined) {
|
|
242
|
-
this.width = data.width;
|
|
243
|
-
}
|
|
244
|
-
if (data.height !== undefined) {
|
|
245
|
-
this.height = data.height;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/SoundsIcons.js
|
|
250
|
-
|
|
251
|
-
class SoundsIcons {
|
|
252
|
-
constructor() {
|
|
253
|
-
this.mute = new SoundsIcon();
|
|
254
|
-
this.unmute = new SoundsIcon();
|
|
255
|
-
this.volumeDown = new SoundsIcon();
|
|
256
|
-
this.volumeUp = new SoundsIcon();
|
|
257
|
-
this.mute.svg = `<?xml version="1.0"?>
|
|
258
|
-
<svg baseProfile="tiny" height="24px" version="1.2" viewBox="0 0 24 24" width="24px"
|
|
259
|
-
xml:space="preserve" xmlns="http://www.w3.org/2000/svg"
|
|
260
|
-
xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
261
|
-
<g id="Layer_1">
|
|
262
|
-
<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"/>
|
|
263
|
-
</g>
|
|
264
|
-
</svg>`;
|
|
265
|
-
this.unmute.svg = `<?xml version="1.0"?>
|
|
266
|
-
<svg baseProfile="tiny" height="24px" version="1.2" viewBox="0 0 24 24" width="24px"
|
|
267
|
-
xml:space="preserve" xmlns="http://www.w3.org/2000/svg"
|
|
268
|
-
xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
269
|
-
<g id="Layer_1">
|
|
270
|
-
<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"/>
|
|
271
|
-
</g>
|
|
272
|
-
</svg>`;
|
|
273
|
-
this.volumeDown.svg = `<?xml version="1.0"?>
|
|
274
|
-
<svg baseProfile="tiny" height="24px" version="1.2" viewBox="0 0 24 24" width="24px"
|
|
275
|
-
xml:space="preserve" xmlns="http://www.w3.org/2000/svg"
|
|
276
|
-
xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
277
|
-
<g id="Layer_1">
|
|
278
|
-
<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"/>
|
|
279
|
-
<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"/>
|
|
280
|
-
</g>
|
|
281
|
-
</svg>`;
|
|
282
|
-
this.volumeUp.svg = `<?xml version="1.0"?>
|
|
283
|
-
<svg baseProfile="tiny" height="24px" version="1.2" viewBox="0 0 24 24" width="24px"
|
|
284
|
-
xml:space="preserve" xmlns="http://www.w3.org/2000/svg"
|
|
285
|
-
xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
286
|
-
<g id="Layer_1">
|
|
287
|
-
<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"/>
|
|
288
|
-
<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"/>
|
|
289
|
-
<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"/>
|
|
290
|
-
<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"/>
|
|
291
|
-
</g>
|
|
292
|
-
</svg>`;
|
|
293
|
-
}
|
|
294
|
-
load(data) {
|
|
295
|
-
if (!data) {
|
|
296
|
-
return;
|
|
297
|
-
}
|
|
298
|
-
this.mute.load(data.mute);
|
|
299
|
-
this.unmute.load(data.unmute);
|
|
300
|
-
this.volumeDown.load(data.volumeDown);
|
|
301
|
-
this.volumeUp.load(data.volumeUp);
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/SoundsVolume.js
|
|
305
|
-
|
|
306
|
-
class SoundsVolume {
|
|
307
|
-
constructor() {
|
|
308
|
-
this.value = 100;
|
|
309
|
-
this.max = 100;
|
|
310
|
-
this.min = 0;
|
|
311
|
-
this.step = 10;
|
|
312
|
-
}
|
|
313
|
-
load(data) {
|
|
314
|
-
if (data === undefined) {
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
if ((0,engine_root_window_.isObject)(data)) {
|
|
318
|
-
if (data.max !== undefined) {
|
|
319
|
-
this.max = data.max;
|
|
320
|
-
}
|
|
321
|
-
if (data.min !== undefined) {
|
|
322
|
-
this.min = data.min;
|
|
323
|
-
}
|
|
324
|
-
if (data.step !== undefined) {
|
|
325
|
-
this.step = data.step;
|
|
326
|
-
}
|
|
327
|
-
if (data.value !== undefined) {
|
|
328
|
-
this.value = data.value;
|
|
329
|
-
}
|
|
330
|
-
} else {
|
|
331
|
-
this.value = data;
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Sounds.js
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
class Sounds {
|
|
340
|
-
constructor() {
|
|
341
|
-
this.enable = false;
|
|
342
|
-
this.events = [];
|
|
343
|
-
this.icons = new SoundsIcons();
|
|
344
|
-
this.volume = new SoundsVolume();
|
|
345
|
-
}
|
|
346
|
-
load(data) {
|
|
347
|
-
if (!data) {
|
|
348
|
-
return;
|
|
349
|
-
}
|
|
350
|
-
if (data.enable !== undefined) {
|
|
351
|
-
this.enable = data.enable;
|
|
352
|
-
}
|
|
353
|
-
if (data.events !== undefined) {
|
|
354
|
-
this.events = data.events.map(t => {
|
|
355
|
-
const event = new SoundsEvent();
|
|
356
|
-
event.load(t);
|
|
357
|
-
return event;
|
|
358
|
-
});
|
|
359
|
-
}
|
|
360
|
-
this.icons.load(data.icons);
|
|
361
|
-
if (data.volume !== undefined) {
|
|
362
|
-
this.volume.load(data.volume);
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
;// CONCATENATED MODULE: ./dist/browser/utils.js
|
|
367
|
-
const notes = new Map();
|
|
368
|
-
notes.set("C", [16.35, 32.7, 65.41, 130.81, 261.63, 523.25, 1046.5, 2093.0, 4186.01]);
|
|
369
|
-
notes.set("Db", [17.32, 34.65, 69.3, 138.59, 277.18, 554.37, 1108.73, 2217.46, 4434.92]);
|
|
370
|
-
notes.set("D", [18.35, 36.71, 73.42, 146.83, 293.66, 587.33, 1174.66, 2349.32, 4698.63]);
|
|
371
|
-
notes.set("Eb", [19.45, 38.89, 77.78, 155.56, 311.13, 622.25, 1244.51, 2489.02, 4978.03]);
|
|
372
|
-
notes.set("E", [20.6, 41.2, 82.41, 164.81, 329.63, 659.25, 1318.51, 2637.02, 5274.04]);
|
|
373
|
-
notes.set("F", [21.83, 43.65, 87.31, 174.61, 349.23, 698.46, 1396.91, 2793.83, 5587.65]);
|
|
374
|
-
notes.set("Gb", [23.12, 46.25, 92.5, 185.0, 369.99, 739.99, 1479.98, 2959.96, 5919.91]);
|
|
375
|
-
notes.set("G", [24.5, 49.0, 98.0, 196.0, 392.0, 783.99, 1567.98, 3135.96, 6271.93]);
|
|
376
|
-
notes.set("Ab", [25.96, 51.91, 103.83, 207.65, 415.3, 830.61, 1661.22, 3322.44, 6644.88]);
|
|
377
|
-
notes.set("A", [27.5, 55.0, 110.0, 220.0, 440.0, 880.0, 1760.0, 3520.0, 7040.0]);
|
|
378
|
-
notes.set("Bb", [29.14, 58.27, 116.54, 233.08, 466.16, 932.33, 1864.66, 3729.31, 7458.62]);
|
|
379
|
-
notes.set("B", [30.87, 61.74, 123.47, 246.94, 493.88, 987.77, 1975.53, 3951.07, 7902.13]);
|
|
380
|
-
notes.set("pause", [0]);
|
|
381
|
-
function getNoteFrequency(note) {
|
|
382
|
-
const regex = /(([A-G]b?)(\d))|pause/i,
|
|
383
|
-
result = regex.exec(note);
|
|
384
|
-
if (!result || !result.length) {
|
|
385
|
-
return;
|
|
386
|
-
}
|
|
387
|
-
const noteKey = result[2] || result[0],
|
|
388
|
-
noteItem = notes.get(noteKey);
|
|
389
|
-
if (!noteItem) {
|
|
390
|
-
return;
|
|
391
|
-
}
|
|
392
|
-
return noteItem[parseInt(result[3] || "0")];
|
|
393
|
-
}
|
|
394
|
-
;// CONCATENATED MODULE: ./dist/browser/SoundsInstance.js
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
function initImage(data) {
|
|
398
|
-
const img = document.createElement("img"),
|
|
399
|
-
{
|
|
400
|
-
clickCb,
|
|
401
|
-
container,
|
|
402
|
-
display,
|
|
403
|
-
iconOptions,
|
|
404
|
-
margin,
|
|
405
|
-
options,
|
|
406
|
-
pos,
|
|
407
|
-
rightOffsets
|
|
408
|
-
} = data,
|
|
409
|
-
{
|
|
410
|
-
width,
|
|
411
|
-
path,
|
|
412
|
-
svg
|
|
413
|
-
} = iconOptions;
|
|
414
|
-
setIconStyle(img, pos.top + margin, pos.right - (margin * (rightOffsets.length + 1) + width + rightOffsets.reduce((a, b) => a + b, 0)), display, options.fullScreen.zIndex + 1, width, margin);
|
|
415
|
-
img.src = path ?? (svg ? `data:image/svg+xml;base64,${btoa(svg)}` : "");
|
|
416
|
-
const parent = container.canvas.element?.parentNode || document.body;
|
|
417
|
-
parent.append(img);
|
|
418
|
-
img.addEventListener("click", clickCb);
|
|
419
|
-
return img;
|
|
420
|
-
}
|
|
421
|
-
function removeImage(image) {
|
|
422
|
-
if (!image) {
|
|
423
|
-
return;
|
|
424
|
-
}
|
|
425
|
-
image.remove();
|
|
426
|
-
}
|
|
427
|
-
function setIconStyle(icon, top, left, display, zIndex, width, margin) {
|
|
428
|
-
icon.style.userSelect = "none";
|
|
429
|
-
icon.style.webkitUserSelect = "none";
|
|
430
|
-
icon.style.position = "absolute";
|
|
431
|
-
icon.style.top = `${top + margin}px`;
|
|
432
|
-
icon.style.left = `${left - margin - width}px`;
|
|
433
|
-
icon.style.display = display;
|
|
434
|
-
icon.style.zIndex = `${zIndex + 1}`;
|
|
435
|
-
}
|
|
436
|
-
class SoundsInstance {
|
|
437
|
-
constructor(container, engine) {
|
|
438
|
-
this._addBuffer = audioCtx => {
|
|
439
|
-
const buffer = audioCtx.createBufferSource();
|
|
440
|
-
this._audioSources.push(buffer);
|
|
441
|
-
return buffer;
|
|
442
|
-
};
|
|
443
|
-
this._addOscillator = audioCtx => {
|
|
444
|
-
const oscillator = audioCtx.createOscillator();
|
|
445
|
-
this._audioSources.push(oscillator);
|
|
446
|
-
return oscillator;
|
|
447
|
-
};
|
|
448
|
-
this._initEvents = () => {
|
|
449
|
-
const container = this._container,
|
|
450
|
-
soundsOptions = container.actualOptions.sounds;
|
|
451
|
-
if (!soundsOptions?.enable || !container.canvas.element) {
|
|
452
|
-
return;
|
|
453
|
-
}
|
|
454
|
-
for (const event of soundsOptions.events) {
|
|
455
|
-
const cb = args => {
|
|
456
|
-
(async () => {
|
|
457
|
-
const filterNotValid = event.filter && !event.filter(args);
|
|
458
|
-
if (this._container !== args.container) {
|
|
459
|
-
return;
|
|
460
|
-
}
|
|
461
|
-
if (!this._container || this._container.muted || this._container.destroyed) {
|
|
462
|
-
(0,engine_root_window_.executeOnSingleOrMultiple)(event.event, item => {
|
|
463
|
-
this._engine.removeEventListener(item, cb);
|
|
464
|
-
});
|
|
465
|
-
return;
|
|
466
|
-
}
|
|
467
|
-
if (filterNotValid) {
|
|
468
|
-
return;
|
|
469
|
-
}
|
|
470
|
-
if (event.audio) {
|
|
471
|
-
this._playBuffer((0,engine_root_window_.itemFromSingleOrMultiple)(event.audio));
|
|
472
|
-
} else if (event.melodies) {
|
|
473
|
-
const melody = (0,engine_root_window_.itemFromArray)(event.melodies);
|
|
474
|
-
if (melody.melodies.length) {
|
|
475
|
-
await Promise.allSettled(melody.melodies.map(m => this._playNote(m.notes, 0, melody.loop)));
|
|
476
|
-
} else {
|
|
477
|
-
await this._playNote(melody.notes, 0, melody.loop);
|
|
478
|
-
}
|
|
479
|
-
} else if (event.notes) {
|
|
480
|
-
const note = (0,engine_root_window_.itemFromArray)(event.notes);
|
|
481
|
-
await this._playNote([note], 0, false);
|
|
482
|
-
}
|
|
483
|
-
})();
|
|
484
|
-
};
|
|
485
|
-
(0,engine_root_window_.executeOnSingleOrMultiple)(event.event, item => {
|
|
486
|
-
this._engine.addEventListener(item, cb);
|
|
487
|
-
});
|
|
488
|
-
}
|
|
489
|
-
};
|
|
490
|
-
this._mute = () => {
|
|
491
|
-
const container = this._container;
|
|
492
|
-
if (!container.audioContext) {
|
|
493
|
-
return;
|
|
494
|
-
}
|
|
495
|
-
for (const source of this._audioSources) {
|
|
496
|
-
this._removeAudioSource(source);
|
|
497
|
-
}
|
|
498
|
-
if (this._gain) {
|
|
499
|
-
this._gain.disconnect();
|
|
500
|
-
}
|
|
501
|
-
container.audioContext.close();
|
|
502
|
-
container.audioContext = undefined;
|
|
503
|
-
this._engine.dispatchEvent("soundsMuted", {
|
|
504
|
-
container: this._container
|
|
505
|
-
});
|
|
506
|
-
};
|
|
507
|
-
this._playBuffer = audio => {
|
|
508
|
-
const audioBuffer = this._audioMap.get(audio.source);
|
|
509
|
-
if (!audioBuffer) {
|
|
510
|
-
return;
|
|
511
|
-
}
|
|
512
|
-
const audioCtx = this._container.audioContext;
|
|
513
|
-
if (!audioCtx) {
|
|
514
|
-
return;
|
|
515
|
-
}
|
|
516
|
-
const source = this._addBuffer(audioCtx);
|
|
517
|
-
source.loop = audio.loop;
|
|
518
|
-
source.buffer = audioBuffer;
|
|
519
|
-
source.connect(this._gain ?? audioCtx.destination);
|
|
520
|
-
source.start();
|
|
521
|
-
};
|
|
522
|
-
this._playFrequency = async (frequency, duration) => {
|
|
523
|
-
if (!this._container.audioContext || !this._gain) {
|
|
524
|
-
return;
|
|
525
|
-
}
|
|
526
|
-
const oscillator = this._addOscillator(this._container.audioContext);
|
|
527
|
-
oscillator.connect(this._gain);
|
|
528
|
-
oscillator.type = "sine";
|
|
529
|
-
oscillator.frequency.value = frequency;
|
|
530
|
-
oscillator.start();
|
|
531
|
-
return new Promise(resolve => {
|
|
532
|
-
setTimeout(() => {
|
|
533
|
-
this._removeAudioSource(oscillator);
|
|
534
|
-
resolve();
|
|
535
|
-
}, duration);
|
|
536
|
-
});
|
|
537
|
-
};
|
|
538
|
-
this._playMuteSound = () => {
|
|
539
|
-
const container = this._container;
|
|
540
|
-
if (!container.audioContext) {
|
|
541
|
-
return;
|
|
542
|
-
}
|
|
543
|
-
const gain = container.audioContext.createGain();
|
|
544
|
-
gain.connect(container.audioContext.destination);
|
|
545
|
-
gain.gain.value = 0;
|
|
546
|
-
const oscillator = container.audioContext.createOscillator();
|
|
547
|
-
oscillator.connect(gain);
|
|
548
|
-
oscillator.type = "sine";
|
|
549
|
-
oscillator.frequency.value = 1;
|
|
550
|
-
oscillator.start();
|
|
551
|
-
setTimeout(() => {
|
|
552
|
-
oscillator.stop();
|
|
553
|
-
oscillator.disconnect();
|
|
554
|
-
gain.disconnect();
|
|
555
|
-
});
|
|
556
|
-
};
|
|
557
|
-
this._playNote = async (notes, noteIdx, loop) => {
|
|
558
|
-
if (this._container.muted) {
|
|
559
|
-
return;
|
|
560
|
-
}
|
|
561
|
-
const note = notes[noteIdx];
|
|
562
|
-
if (!note) {
|
|
563
|
-
return;
|
|
564
|
-
}
|
|
565
|
-
const value = note.value;
|
|
566
|
-
const promises = (0,engine_root_window_.executeOnSingleOrMultiple)(value, async (_, idx) => {
|
|
567
|
-
return this._playNoteValue(notes, noteIdx, idx);
|
|
568
|
-
});
|
|
569
|
-
await ((0,engine_root_window_.isArray)(promises) ? Promise.allSettled(promises) : promises);
|
|
570
|
-
let nextNoteIdx = noteIdx + 1;
|
|
571
|
-
if (loop && nextNoteIdx >= notes.length) {
|
|
572
|
-
nextNoteIdx = nextNoteIdx % notes.length;
|
|
573
|
-
}
|
|
574
|
-
if (this._container.muted) {
|
|
575
|
-
return;
|
|
576
|
-
}
|
|
577
|
-
await this._playNote(notes, nextNoteIdx, loop);
|
|
578
|
-
};
|
|
579
|
-
this._playNoteValue = async (notes, noteIdx, valueIdx) => {
|
|
580
|
-
const note = notes[noteIdx];
|
|
581
|
-
if (!note) {
|
|
582
|
-
return;
|
|
583
|
-
}
|
|
584
|
-
const value = (0,engine_root_window_.itemFromSingleOrMultiple)(note.value, valueIdx, true);
|
|
585
|
-
try {
|
|
586
|
-
const freq = getNoteFrequency(value);
|
|
587
|
-
if (!(0,engine_root_window_.isNumber)(freq)) {
|
|
588
|
-
return;
|
|
589
|
-
}
|
|
590
|
-
await this._playFrequency(freq, note.duration);
|
|
591
|
-
} catch (e) {
|
|
592
|
-
(0,engine_root_window_.getLogger)().error(e);
|
|
593
|
-
}
|
|
594
|
-
};
|
|
595
|
-
this._removeAudioSource = source => {
|
|
596
|
-
source.stop();
|
|
597
|
-
source.disconnect();
|
|
598
|
-
this._audioSources.splice(this._audioSources.indexOf(source), 1);
|
|
599
|
-
};
|
|
600
|
-
this._unmute = () => {
|
|
601
|
-
const container = this._container,
|
|
602
|
-
options = container.actualOptions,
|
|
603
|
-
soundsOptions = options.sounds;
|
|
604
|
-
if (!soundsOptions) {
|
|
605
|
-
return;
|
|
606
|
-
}
|
|
607
|
-
if (!container.audioContext) {
|
|
608
|
-
container.audioContext = new AudioContext();
|
|
609
|
-
}
|
|
610
|
-
const {
|
|
611
|
-
audioContext
|
|
612
|
-
} = container;
|
|
613
|
-
if (!this._audioSources) {
|
|
614
|
-
this._audioSources = [];
|
|
615
|
-
}
|
|
616
|
-
const gain = audioContext.createGain();
|
|
617
|
-
gain.connect(audioContext.destination);
|
|
618
|
-
gain.gain.value = soundsOptions.volume.value / 100;
|
|
619
|
-
this._gain = gain;
|
|
620
|
-
this._initEvents();
|
|
621
|
-
this._engine.dispatchEvent("soundsUnmuted", {
|
|
622
|
-
container: this._container
|
|
623
|
-
});
|
|
624
|
-
};
|
|
625
|
-
this._updateMuteIcons = () => {
|
|
626
|
-
const container = this._container,
|
|
627
|
-
muteImg = this._muteImg,
|
|
628
|
-
unmuteImg = this._unmuteImg;
|
|
629
|
-
if (muteImg) {
|
|
630
|
-
muteImg.style.display = container.muted ? "block" : "none";
|
|
631
|
-
}
|
|
632
|
-
if (unmuteImg) {
|
|
633
|
-
unmuteImg.style.display = container.muted ? "none" : "block";
|
|
634
|
-
}
|
|
635
|
-
};
|
|
636
|
-
this._updateMuteStatus = async () => {
|
|
637
|
-
const container = this._container;
|
|
638
|
-
if (container.muted) {
|
|
639
|
-
await container.audioContext?.suspend();
|
|
640
|
-
this._mute();
|
|
641
|
-
} else {
|
|
642
|
-
await container.audioContext?.resume();
|
|
643
|
-
this._unmute();
|
|
644
|
-
this._playMuteSound();
|
|
645
|
-
}
|
|
646
|
-
};
|
|
647
|
-
this._updateVolume = async () => {
|
|
648
|
-
const container = this._container,
|
|
649
|
-
soundsOptions = container.actualOptions.sounds;
|
|
650
|
-
if (!soundsOptions?.enable) {
|
|
651
|
-
return;
|
|
652
|
-
}
|
|
653
|
-
(0,engine_root_window_.clamp)(this._volume, soundsOptions.volume.min, soundsOptions.volume.max);
|
|
654
|
-
let stateChanged = false;
|
|
655
|
-
if (this._volume <= 0 && !container.muted) {
|
|
656
|
-
this._volume = 0;
|
|
657
|
-
container.muted = true;
|
|
658
|
-
stateChanged = true;
|
|
659
|
-
} else if (this._volume > 0 && container.muted) {
|
|
660
|
-
container.muted = false;
|
|
661
|
-
stateChanged = true;
|
|
662
|
-
}
|
|
663
|
-
if (stateChanged) {
|
|
664
|
-
this._updateMuteIcons();
|
|
665
|
-
await this._updateMuteStatus();
|
|
666
|
-
}
|
|
667
|
-
if (this._gain?.gain) {
|
|
668
|
-
this._gain.gain.value = this._volume / 100;
|
|
669
|
-
}
|
|
670
|
-
};
|
|
671
|
-
this._container = container;
|
|
672
|
-
this._engine = engine;
|
|
673
|
-
this._volume = 0;
|
|
674
|
-
this._audioSources = [];
|
|
675
|
-
this._audioMap = new Map();
|
|
676
|
-
}
|
|
677
|
-
async init() {
|
|
678
|
-
const container = this._container,
|
|
679
|
-
options = container.actualOptions,
|
|
680
|
-
soundsOptions = options.sounds;
|
|
681
|
-
if (!soundsOptions?.enable) {
|
|
682
|
-
return;
|
|
683
|
-
}
|
|
684
|
-
this._volume = soundsOptions.volume.value;
|
|
685
|
-
const events = soundsOptions.events;
|
|
686
|
-
this._audioMap = new Map();
|
|
687
|
-
for (const event of events) {
|
|
688
|
-
if (!event.audio) {
|
|
689
|
-
continue;
|
|
690
|
-
}
|
|
691
|
-
(0,engine_root_window_.executeOnSingleOrMultiple)(event.audio, async audio => {
|
|
692
|
-
const response = await fetch(audio.source);
|
|
693
|
-
if (!response.ok) {
|
|
694
|
-
return;
|
|
695
|
-
}
|
|
696
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
697
|
-
container.audioContext = new AudioContext();
|
|
698
|
-
const audioBuffer = await container.audioContext.decodeAudioData(arrayBuffer);
|
|
699
|
-
this._audioMap.set(audio.source, audioBuffer);
|
|
700
|
-
});
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
async start() {
|
|
704
|
-
const container = this._container,
|
|
705
|
-
options = container.actualOptions,
|
|
706
|
-
soundsOptions = options.sounds;
|
|
707
|
-
if (!soundsOptions?.enable || !container.canvas.element) {
|
|
708
|
-
return;
|
|
709
|
-
}
|
|
710
|
-
container.muted = true;
|
|
711
|
-
const canvas = container.canvas.element,
|
|
712
|
-
pos = {
|
|
713
|
-
top: canvas.offsetTop,
|
|
714
|
-
right: canvas.offsetLeft + canvas.offsetWidth
|
|
715
|
-
},
|
|
716
|
-
{
|
|
717
|
-
mute,
|
|
718
|
-
unmute,
|
|
719
|
-
volumeDown,
|
|
720
|
-
volumeUp
|
|
721
|
-
} = soundsOptions.icons,
|
|
722
|
-
margin = 10;
|
|
723
|
-
const toggleMute = async () => {
|
|
724
|
-
container.muted = !container.muted;
|
|
725
|
-
this._updateMuteIcons();
|
|
726
|
-
await this._updateMuteStatus();
|
|
727
|
-
};
|
|
728
|
-
this._muteImg = initImage({
|
|
729
|
-
container,
|
|
730
|
-
options,
|
|
731
|
-
pos,
|
|
732
|
-
display: "block",
|
|
733
|
-
iconOptions: mute,
|
|
734
|
-
margin,
|
|
735
|
-
rightOffsets: [volumeDown.width, volumeUp.width],
|
|
736
|
-
clickCb: toggleMute
|
|
737
|
-
});
|
|
738
|
-
this._unmuteImg = initImage({
|
|
739
|
-
container,
|
|
740
|
-
options,
|
|
741
|
-
pos,
|
|
742
|
-
display: "none",
|
|
743
|
-
iconOptions: unmute,
|
|
744
|
-
margin,
|
|
745
|
-
rightOffsets: [volumeDown.width, volumeUp.width],
|
|
746
|
-
clickCb: toggleMute
|
|
747
|
-
});
|
|
748
|
-
this._volumeDownImg = initImage({
|
|
749
|
-
container,
|
|
750
|
-
options,
|
|
751
|
-
pos,
|
|
752
|
-
display: "block",
|
|
753
|
-
iconOptions: volumeDown,
|
|
754
|
-
margin,
|
|
755
|
-
rightOffsets: [volumeUp.width],
|
|
756
|
-
clickCb: async () => {
|
|
757
|
-
if (container.muted) {
|
|
758
|
-
this._volume = 0;
|
|
759
|
-
}
|
|
760
|
-
this._volume -= soundsOptions.volume.step;
|
|
761
|
-
await this._updateVolume();
|
|
762
|
-
}
|
|
763
|
-
});
|
|
764
|
-
this._volumeUpImg = initImage({
|
|
765
|
-
container,
|
|
766
|
-
options,
|
|
767
|
-
pos,
|
|
768
|
-
display: "block",
|
|
769
|
-
iconOptions: volumeUp,
|
|
770
|
-
margin,
|
|
771
|
-
rightOffsets: [],
|
|
772
|
-
clickCb: async () => {
|
|
773
|
-
if (container.muted) {
|
|
774
|
-
this._volume = 0;
|
|
775
|
-
}
|
|
776
|
-
this._volume += soundsOptions.volume.step;
|
|
777
|
-
await this._updateVolume();
|
|
778
|
-
}
|
|
779
|
-
});
|
|
780
|
-
}
|
|
781
|
-
stop() {
|
|
782
|
-
this._container.muted = true;
|
|
783
|
-
this._mute();
|
|
784
|
-
removeImage(this._muteImg);
|
|
785
|
-
removeImage(this._unmuteImg);
|
|
786
|
-
removeImage(this._volumeDownImg);
|
|
787
|
-
removeImage(this._volumeUpImg);
|
|
788
|
-
}
|
|
789
|
-
}
|
|
790
|
-
;// CONCATENATED MODULE: ./dist/browser/index.js
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
class SoundsPlugin {
|
|
794
|
-
constructor(engine) {
|
|
795
|
-
this.id = "sounds";
|
|
796
|
-
this._engine = engine;
|
|
797
|
-
}
|
|
798
|
-
getPlugin(container) {
|
|
799
|
-
return new SoundsInstance(container, this._engine);
|
|
800
|
-
}
|
|
801
|
-
loadOptions(options, source) {
|
|
802
|
-
if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
|
|
803
|
-
return;
|
|
804
|
-
}
|
|
805
|
-
let soundsOptions = options.sounds;
|
|
806
|
-
if (soundsOptions?.load === undefined) {
|
|
807
|
-
options.sounds = soundsOptions = new Sounds();
|
|
808
|
-
}
|
|
809
|
-
soundsOptions.load(source?.sounds);
|
|
810
|
-
}
|
|
811
|
-
needsPlugin(options) {
|
|
812
|
-
return options?.sounds?.enable ?? false;
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
async function loadSoundsPlugin(engine, refresh = true) {
|
|
816
|
-
await engine.addPlugin(new SoundsPlugin(engine), refresh);
|
|
817
|
-
}
|
|
818
|
-
})();
|
|
819
|
-
|
|
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
|
+
/******/
|
|
820
323
|
/******/ return __webpack_exports__;
|
|
821
324
|
/******/ })()
|
|
822
325
|
;
|