@tsparticles/plugin-sounds 3.0.0-alpha.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.
Files changed (112) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +70 -0
  3. package/browser/Options/Classes/Sounds.js +30 -0
  4. package/browser/Options/Classes/SoundsAudio.js +22 -0
  5. package/browser/Options/Classes/SoundsEvent.js +54 -0
  6. package/browser/Options/Classes/SoundsIcon.js +23 -0
  7. package/browser/Options/Classes/SoundsIcons.js +54 -0
  8. package/browser/Options/Classes/SoundsMelody.js +30 -0
  9. package/browser/Options/Classes/SoundsNote.js +17 -0
  10. package/browser/Options/Classes/SoundsVolume.js +30 -0
  11. package/browser/Options/Interfaces/ISounds.js +1 -0
  12. package/browser/Options/Interfaces/ISoundsAudio.js +1 -0
  13. package/browser/Options/Interfaces/ISoundsEvent.js +1 -0
  14. package/browser/Options/Interfaces/ISoundsIcon.js +1 -0
  15. package/browser/Options/Interfaces/ISoundsIcons.js +1 -0
  16. package/browser/Options/Interfaces/ISoundsMelody.js +1 -0
  17. package/browser/Options/Interfaces/ISoundsNote.js +1 -0
  18. package/browser/Options/Interfaces/ISoundsVolume.js +1 -0
  19. package/browser/SoundsInstance.js +336 -0
  20. package/browser/enums.js +1 -0
  21. package/browser/index.js +29 -0
  22. package/browser/types.js +1 -0
  23. package/browser/utils.js +26 -0
  24. package/cjs/Options/Classes/Sounds.js +34 -0
  25. package/cjs/Options/Classes/SoundsAudio.js +26 -0
  26. package/cjs/Options/Classes/SoundsEvent.js +58 -0
  27. package/cjs/Options/Classes/SoundsIcon.js +27 -0
  28. package/cjs/Options/Classes/SoundsIcons.js +58 -0
  29. package/cjs/Options/Classes/SoundsMelody.js +34 -0
  30. package/cjs/Options/Classes/SoundsNote.js +21 -0
  31. package/cjs/Options/Classes/SoundsVolume.js +34 -0
  32. package/cjs/Options/Interfaces/ISounds.js +2 -0
  33. package/cjs/Options/Interfaces/ISoundsAudio.js +2 -0
  34. package/cjs/Options/Interfaces/ISoundsEvent.js +2 -0
  35. package/cjs/Options/Interfaces/ISoundsIcon.js +2 -0
  36. package/cjs/Options/Interfaces/ISoundsIcons.js +2 -0
  37. package/cjs/Options/Interfaces/ISoundsMelody.js +2 -0
  38. package/cjs/Options/Interfaces/ISoundsNote.js +2 -0
  39. package/cjs/Options/Interfaces/ISoundsVolume.js +2 -0
  40. package/cjs/SoundsInstance.js +359 -0
  41. package/cjs/enums.js +2 -0
  42. package/cjs/index.js +44 -0
  43. package/cjs/types.js +2 -0
  44. package/cjs/utils.js +30 -0
  45. package/esm/Options/Classes/Sounds.js +30 -0
  46. package/esm/Options/Classes/SoundsAudio.js +22 -0
  47. package/esm/Options/Classes/SoundsEvent.js +54 -0
  48. package/esm/Options/Classes/SoundsIcon.js +23 -0
  49. package/esm/Options/Classes/SoundsIcons.js +54 -0
  50. package/esm/Options/Classes/SoundsMelody.js +30 -0
  51. package/esm/Options/Classes/SoundsNote.js +17 -0
  52. package/esm/Options/Classes/SoundsVolume.js +30 -0
  53. package/esm/Options/Interfaces/ISounds.js +1 -0
  54. package/esm/Options/Interfaces/ISoundsAudio.js +1 -0
  55. package/esm/Options/Interfaces/ISoundsEvent.js +1 -0
  56. package/esm/Options/Interfaces/ISoundsIcon.js +1 -0
  57. package/esm/Options/Interfaces/ISoundsIcons.js +1 -0
  58. package/esm/Options/Interfaces/ISoundsMelody.js +1 -0
  59. package/esm/Options/Interfaces/ISoundsNote.js +1 -0
  60. package/esm/Options/Interfaces/ISoundsVolume.js +1 -0
  61. package/esm/SoundsInstance.js +336 -0
  62. package/esm/enums.js +1 -0
  63. package/esm/index.js +29 -0
  64. package/esm/types.js +1 -0
  65. package/esm/utils.js +26 -0
  66. package/package.json +81 -0
  67. package/report.html +39 -0
  68. package/tsparticles.plugin.sounds.js +780 -0
  69. package/tsparticles.plugin.sounds.min.js +2 -0
  70. package/tsparticles.plugin.sounds.min.js.LICENSE.txt +8 -0
  71. package/types/Options/Classes/Sounds.d.ts +13 -0
  72. package/types/Options/Classes/SoundsAudio.d.ts +8 -0
  73. package/types/Options/Classes/SoundsEvent.d.ts +20 -0
  74. package/types/Options/Classes/SoundsIcon.d.ts +10 -0
  75. package/types/Options/Classes/SoundsIcons.d.ts +11 -0
  76. package/types/Options/Classes/SoundsMelody.d.ts +10 -0
  77. package/types/Options/Classes/SoundsNote.d.ts +8 -0
  78. package/types/Options/Classes/SoundsVolume.d.ts +10 -0
  79. package/types/Options/Interfaces/ISounds.d.ts +9 -0
  80. package/types/Options/Interfaces/ISoundsAudio.d.ts +4 -0
  81. package/types/Options/Interfaces/ISoundsEvent.d.ts +12 -0
  82. package/types/Options/Interfaces/ISoundsIcon.d.ts +6 -0
  83. package/types/Options/Interfaces/ISoundsIcons.d.ts +7 -0
  84. package/types/Options/Interfaces/ISoundsMelody.d.ts +6 -0
  85. package/types/Options/Interfaces/ISoundsNote.d.ts +5 -0
  86. package/types/Options/Interfaces/ISoundsVolume.d.ts +6 -0
  87. package/types/SoundsInstance.d.ts +32 -0
  88. package/types/enums.d.ts +4 -0
  89. package/types/index.d.ts +2 -0
  90. package/types/types.d.ts +15 -0
  91. package/types/utils.d.ts +1 -0
  92. package/umd/Options/Classes/Sounds.js +44 -0
  93. package/umd/Options/Classes/SoundsAudio.js +36 -0
  94. package/umd/Options/Classes/SoundsEvent.js +68 -0
  95. package/umd/Options/Classes/SoundsIcon.js +37 -0
  96. package/umd/Options/Classes/SoundsIcons.js +68 -0
  97. package/umd/Options/Classes/SoundsMelody.js +44 -0
  98. package/umd/Options/Classes/SoundsNote.js +31 -0
  99. package/umd/Options/Classes/SoundsVolume.js +44 -0
  100. package/umd/Options/Interfaces/ISounds.js +12 -0
  101. package/umd/Options/Interfaces/ISoundsAudio.js +12 -0
  102. package/umd/Options/Interfaces/ISoundsEvent.js +12 -0
  103. package/umd/Options/Interfaces/ISoundsIcon.js +12 -0
  104. package/umd/Options/Interfaces/ISoundsIcons.js +12 -0
  105. package/umd/Options/Interfaces/ISoundsMelody.js +12 -0
  106. package/umd/Options/Interfaces/ISoundsNote.js +12 -0
  107. package/umd/Options/Interfaces/ISoundsVolume.js +12 -0
  108. package/umd/SoundsInstance.js +350 -0
  109. package/umd/enums.js +12 -0
  110. package/umd/index.js +43 -0
  111. package/umd/types.js +12 -0
  112. package/umd/utils.js +40 -0
@@ -0,0 +1,780 @@
1
+ /*!
2
+ * Author : Matteo Bruni
3
+ * MIT license: https://opensource.org/licenses/MIT
4
+ * Demo / Generator : https://particles.js.org/
5
+ * GitHub : https://www.github.com/matteobruni/tsparticles
6
+ * How to use? : Check the GitHub README
7
+ * v3.0.0-alpha.0
8
+ */
9
+ (function webpackUniversalModuleDefinition(root, factory) {
10
+ if(typeof exports === 'object' && typeof module === 'object')
11
+ module.exports = factory(require("@tsparticles/engine"));
12
+ else if(typeof define === 'function' && define.amd)
13
+ define(["@tsparticles/engine"], factory);
14
+ else {
15
+ var a = typeof exports === 'object' ? factory(require("@tsparticles/engine")) : factory(root["window"]);
16
+ for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
17
+ }
18
+ })(this, (__WEBPACK_EXTERNAL_MODULE__533__) => {
19
+ return /******/ (() => { // webpackBootstrap
20
+ /******/ "use strict";
21
+ /******/ var __webpack_modules__ = ({
22
+
23
+ /***/ 533:
24
+ /***/ ((module) => {
25
+
26
+ module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
27
+
28
+ /***/ })
29
+
30
+ /******/ });
31
+ /************************************************************************/
32
+ /******/ // The module cache
33
+ /******/ var __webpack_module_cache__ = {};
34
+ /******/
35
+ /******/ // The require function
36
+ /******/ function __webpack_require__(moduleId) {
37
+ /******/ // Check if module is in cache
38
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
39
+ /******/ if (cachedModule !== undefined) {
40
+ /******/ return cachedModule.exports;
41
+ /******/ }
42
+ /******/ // Create a new module (and put it into the cache)
43
+ /******/ var module = __webpack_module_cache__[moduleId] = {
44
+ /******/ // no module.id needed
45
+ /******/ // no module.loaded needed
46
+ /******/ exports: {}
47
+ /******/ };
48
+ /******/
49
+ /******/ // Execute the module function
50
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
51
+ /******/
52
+ /******/ // Return the exports of the module
53
+ /******/ return module.exports;
54
+ /******/ }
55
+ /******/
56
+ /************************************************************************/
57
+ /******/ /* webpack/runtime/define property getters */
58
+ /******/ (() => {
59
+ /******/ // define getter functions for harmony exports
60
+ /******/ __webpack_require__.d = (exports, definition) => {
61
+ /******/ for(var key in definition) {
62
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
63
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
64
+ /******/ }
65
+ /******/ }
66
+ /******/ };
67
+ /******/ })();
68
+ /******/
69
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
70
+ /******/ (() => {
71
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
72
+ /******/ })();
73
+ /******/
74
+ /******/ /* webpack/runtime/make namespace object */
75
+ /******/ (() => {
76
+ /******/ // define __esModule on exports
77
+ /******/ __webpack_require__.r = (exports) => {
78
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
79
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
80
+ /******/ }
81
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
82
+ /******/ };
83
+ /******/ })();
84
+ /******/
85
+ /************************************************************************/
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
+ ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/SoundsAudio.js
98
+ class SoundsAudio {
99
+ constructor() {
100
+ this.loop = false;
101
+ this.source = "";
102
+ }
103
+ load(data) {
104
+ if (data === undefined) {
105
+ return;
106
+ }
107
+ if (typeof data === "object") {
108
+ if (data.loop !== undefined) {
109
+ this.loop = data.loop;
110
+ }
111
+ if (data.source !== undefined) {
112
+ this.source = data.source;
113
+ }
114
+ } else {
115
+ this.source = data;
116
+ }
117
+ }
118
+ }
119
+ ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/SoundsNote.js
120
+ class SoundsNote {
121
+ constructor() {
122
+ this.duration = 500;
123
+ this.value = [];
124
+ }
125
+ load(data) {
126
+ if (!data) {
127
+ return;
128
+ }
129
+ if (data.duration !== undefined) {
130
+ this.duration = data.duration;
131
+ }
132
+ if (data.value !== undefined) {
133
+ this.value = data.value;
134
+ }
135
+ }
136
+ }
137
+ ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/SoundsMelody.js
138
+
139
+ class SoundsMelody {
140
+ constructor() {
141
+ this.loop = false;
142
+ this.melodies = [];
143
+ this.notes = [];
144
+ }
145
+ load(data) {
146
+ if (data === undefined) {
147
+ return;
148
+ }
149
+ if (data.loop !== undefined) {
150
+ this.loop = data.loop;
151
+ }
152
+ if (data.melodies !== undefined) {
153
+ this.melodies = data.melodies.map(s => {
154
+ const tmp = new SoundsMelody();
155
+ tmp.load(s);
156
+ return tmp;
157
+ });
158
+ }
159
+ if (data.notes !== undefined) {
160
+ this.notes = data.notes.map(s => {
161
+ const tmp = new SoundsNote();
162
+ tmp.load(s);
163
+ return tmp;
164
+ });
165
+ }
166
+ }
167
+ }
168
+ ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/SoundsEvent.js
169
+
170
+
171
+
172
+ class SoundsEvent {
173
+ constructor() {
174
+ this.event = [];
175
+ this.notes = [];
176
+ }
177
+ load(data) {
178
+ if (!data) {
179
+ return;
180
+ }
181
+ if (data.event !== undefined) {
182
+ this.event = data.event;
183
+ }
184
+ if (data.audio !== undefined) {
185
+ if (data.audio instanceof Array) {
186
+ this.audio = data.audio.map(s => {
187
+ const tmp = new SoundsAudio();
188
+ tmp.load(s);
189
+ return tmp;
190
+ });
191
+ } else {
192
+ this.audio = new SoundsAudio();
193
+ this.audio.load(data.audio);
194
+ }
195
+ }
196
+ if (data.notes !== undefined) {
197
+ this.notes = data.notes.map(t => {
198
+ const tmp = new SoundsNote();
199
+ tmp.load(t);
200
+ return tmp;
201
+ });
202
+ }
203
+ if (data.melodies !== undefined) {
204
+ this.melodies = data.melodies.map(t => {
205
+ const tmp = new SoundsMelody();
206
+ tmp.load(t);
207
+ return tmp;
208
+ });
209
+ }
210
+ if (data.filter !== undefined) {
211
+ if (typeof data.filter === "string") {
212
+ if (typeof window[data.filter] === "function") {
213
+ this.filter = window[data.filter];
214
+ }
215
+ } else {
216
+ this.filter = data.filter;
217
+ }
218
+ }
219
+ }
220
+ }
221
+ ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/SoundsIcon.js
222
+ class SoundsIcon {
223
+ constructor() {
224
+ this.width = 24;
225
+ this.height = 24;
226
+ }
227
+ load(data) {
228
+ if (!data) {
229
+ return;
230
+ }
231
+ if (data.path !== undefined) {
232
+ this.path = data.path;
233
+ }
234
+ if (data.svg !== undefined) {
235
+ this.svg = data.svg;
236
+ }
237
+ if (data.width !== undefined) {
238
+ this.width = data.width;
239
+ }
240
+ if (data.height !== undefined) {
241
+ this.height = data.height;
242
+ }
243
+ }
244
+ }
245
+ ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/SoundsIcons.js
246
+
247
+ class SoundsIcons {
248
+ constructor() {
249
+ this.mute = new SoundsIcon();
250
+ this.unmute = new SoundsIcon();
251
+ this.volumeDown = new SoundsIcon();
252
+ this.volumeUp = new SoundsIcon();
253
+ this.mute.svg = `<?xml version="1.0"?>
254
+ <svg baseProfile="tiny" height="24px" version="1.2" viewBox="0 0 24 24" width="24px"
255
+ xml:space="preserve" xmlns="http://www.w3.org/2000/svg"
256
+ xmlns:xlink="http://www.w3.org/1999/xlink">
257
+ <g id="Layer_1">
258
+ <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"/>
259
+ </g>
260
+ </svg>`;
261
+ this.unmute.svg = `<?xml version="1.0"?>
262
+ <svg baseProfile="tiny" height="24px" version="1.2" viewBox="0 0 24 24" width="24px"
263
+ xml:space="preserve" xmlns="http://www.w3.org/2000/svg"
264
+ xmlns:xlink="http://www.w3.org/1999/xlink">
265
+ <g id="Layer_1">
266
+ <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"/>
267
+ </g>
268
+ </svg>`;
269
+ this.volumeDown.svg = `<?xml version="1.0"?>
270
+ <svg baseProfile="tiny" height="24px" version="1.2" viewBox="0 0 24 24" width="24px"
271
+ xml:space="preserve" xmlns="http://www.w3.org/2000/svg"
272
+ xmlns:xlink="http://www.w3.org/1999/xlink">
273
+ <g id="Layer_1">
274
+ <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"/>
275
+ <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"/>
276
+ </g>
277
+ </svg>`;
278
+ this.volumeUp.svg = `<?xml version="1.0"?>
279
+ <svg baseProfile="tiny" height="24px" version="1.2" viewBox="0 0 24 24" width="24px"
280
+ xml:space="preserve" xmlns="http://www.w3.org/2000/svg"
281
+ xmlns:xlink="http://www.w3.org/1999/xlink">
282
+ <g id="Layer_1">
283
+ <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"/>
284
+ <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"/>
285
+ <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"/>
286
+ <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"/>
287
+ </g>
288
+ </svg>`;
289
+ }
290
+ load(data) {
291
+ if (!data) {
292
+ return;
293
+ }
294
+ this.mute.load(data.mute);
295
+ this.unmute.load(data.unmute);
296
+ this.volumeDown.load(data.volumeDown);
297
+ this.volumeUp.load(data.volumeUp);
298
+ }
299
+ }
300
+ ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/SoundsVolume.js
301
+ class SoundsVolume {
302
+ constructor() {
303
+ this.value = 100;
304
+ this.max = 100;
305
+ this.min = 0;
306
+ this.step = 10;
307
+ }
308
+ load(data) {
309
+ if (data === undefined) {
310
+ return;
311
+ }
312
+ if (typeof data === "object") {
313
+ if (data.max !== undefined) {
314
+ this.max = data.max;
315
+ }
316
+ if (data.min !== undefined) {
317
+ this.min = data.min;
318
+ }
319
+ if (data.step !== undefined) {
320
+ this.step = data.step;
321
+ }
322
+ if (data.value !== undefined) {
323
+ this.value = data.value;
324
+ }
325
+ } else {
326
+ this.value = data;
327
+ }
328
+ }
329
+ }
330
+ ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Sounds.js
331
+
332
+
333
+
334
+ class Sounds {
335
+ constructor() {
336
+ this.enable = false;
337
+ this.events = [];
338
+ this.icons = new SoundsIcons();
339
+ this.volume = new SoundsVolume();
340
+ }
341
+ load(data) {
342
+ if (!data) {
343
+ return;
344
+ }
345
+ if (data.enable !== undefined) {
346
+ this.enable = data.enable;
347
+ }
348
+ if (data.events !== undefined) {
349
+ this.events = data.events.map(t => {
350
+ const event = new SoundsEvent();
351
+ event.load(t);
352
+ return event;
353
+ });
354
+ }
355
+ this.icons.load(data.icons);
356
+ if (data.volume !== undefined) {
357
+ this.volume.load(data.volume);
358
+ }
359
+ }
360
+ }
361
+ // EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
362
+ var engine_root_window_ = __webpack_require__(533);
363
+ ;// CONCATENATED MODULE: ./dist/browser/utils.js
364
+ const notes = new Map();
365
+ notes.set("C", [16.35, 32.7, 65.41, 130.81, 261.63, 523.25, 1046.5, 2093.0, 4186.01]);
366
+ notes.set("Db", [17.32, 34.65, 69.3, 138.59, 277.18, 554.37, 1108.73, 2217.46, 4434.92]);
367
+ notes.set("D", [18.35, 36.71, 73.42, 146.83, 293.66, 587.33, 1174.66, 2349.32, 4698.63]);
368
+ notes.set("Eb", [19.45, 38.89, 77.78, 155.56, 311.13, 622.25, 1244.51, 2489.02, 4978.03]);
369
+ notes.set("E", [20.6, 41.2, 82.41, 164.81, 329.63, 659.25, 1318.51, 2637.02, 5274.04]);
370
+ notes.set("F", [21.83, 43.65, 87.31, 174.61, 349.23, 698.46, 1396.91, 2793.83, 5587.65]);
371
+ notes.set("Gb", [23.12, 46.25, 92.5, 185.0, 369.99, 739.99, 1479.98, 2959.96, 5919.91]);
372
+ notes.set("G", [24.5, 49.0, 98.0, 196.0, 392.0, 783.99, 1567.98, 3135.96, 6271.93]);
373
+ notes.set("Ab", [25.96, 51.91, 103.83, 207.65, 415.3, 830.61, 1661.22, 3322.44, 6644.88]);
374
+ notes.set("A", [27.5, 55.0, 110.0, 220.0, 440.0, 880.0, 1760.0, 3520.0, 7040.0]);
375
+ notes.set("Bb", [29.14, 58.27, 116.54, 233.08, 466.16, 932.33, 1864.66, 3729.31, 7458.62]);
376
+ notes.set("B", [30.87, 61.74, 123.47, 246.94, 493.88, 987.77, 1975.53, 3951.07, 7902.13]);
377
+ notes.set("pause", [0]);
378
+ function getNoteFrequency(note) {
379
+ const regex = /(([A-G]b?)(\d))|pause/i,
380
+ result = regex.exec(note);
381
+ if (!result || !result.length) {
382
+ return;
383
+ }
384
+ console.log(result);
385
+ const noteKey = result[2] || result[0],
386
+ noteItem = notes.get(noteKey);
387
+ if (!noteItem) {
388
+ return;
389
+ }
390
+ return noteItem[parseInt(result[3] || "0")];
391
+ }
392
+ ;// CONCATENATED MODULE: ./dist/browser/SoundsInstance.js
393
+
394
+
395
+
396
+ function setIconStyle(icon, top, left, display, zIndex, width, margin) {
397
+ icon.style.userSelect = "none";
398
+ icon.style.webkitUserSelect = "none";
399
+ icon.style.position = "absolute";
400
+ icon.style.top = `${top + margin}px`;
401
+ icon.style.left = `${left - margin - width}px`;
402
+ icon.style.display = display;
403
+ icon.style.zIndex = `${zIndex + 1}`;
404
+ }
405
+ class SoundsInstance {
406
+ constructor(container, engine) {
407
+ this._container = container;
408
+ this._engine = engine;
409
+ this._volume = 0;
410
+ this._audioSources = [];
411
+ this._audioMap = new Map();
412
+ }
413
+ async init() {
414
+ const container = this._container,
415
+ options = container.actualOptions,
416
+ soundsOptions = options.sounds;
417
+ if (!(soundsOptions === null || soundsOptions === void 0 ? void 0 : soundsOptions.enable)) {
418
+ return;
419
+ }
420
+ this._volume = soundsOptions.volume.value;
421
+ const events = soundsOptions.events;
422
+ this._audioMap = new Map();
423
+ for (const event of events) {
424
+ if (!event.audio) {
425
+ continue;
426
+ }
427
+ (0,engine_root_window_.executeOnSingleOrMultiple)(event.audio, async audio => {
428
+ const response = await fetch(audio.source);
429
+ if (!response.ok) {
430
+ return;
431
+ }
432
+ const arrayBuffer = await response.arrayBuffer();
433
+ container.audioContext = new AudioContext();
434
+ const audioBuffer = await container.audioContext.decodeAudioData(arrayBuffer);
435
+ this._audioMap.set(audio.source, audioBuffer);
436
+ });
437
+ }
438
+ }
439
+ async start() {
440
+ var _a, _b, _c, _d;
441
+ const container = this._container,
442
+ options = container.actualOptions,
443
+ soundsOptions = options.sounds;
444
+ if (!(soundsOptions === null || soundsOptions === void 0 ? void 0 : soundsOptions.enable) || !container.canvas.element) {
445
+ return;
446
+ }
447
+ container.muted = true;
448
+ this._muteImg = document.createElement("img");
449
+ this._unmuteImg = document.createElement("img");
450
+ this._volumeDownImg = document.createElement("img");
451
+ this._volumeUpImg = document.createElement("img");
452
+ const muteImg = this._muteImg,
453
+ unmuteImg = this._unmuteImg,
454
+ volumeDownImg = this._volumeDownImg,
455
+ volumeUpImg = this._volumeUpImg,
456
+ containerTop = container.canvas.element.offsetTop,
457
+ containerRight = container.canvas.element.offsetLeft + container.canvas.element.offsetWidth,
458
+ iconsOptions = soundsOptions.icons,
459
+ muteOptions = iconsOptions.mute,
460
+ unmuteOptions = iconsOptions.unmute,
461
+ volumeDownOptions = iconsOptions.volumeDown,
462
+ volumeUpOptions = iconsOptions.volumeUp,
463
+ margin = 10;
464
+ setIconStyle(muteImg, containerTop + margin, containerRight - margin * 3 - muteOptions.width - volumeDownOptions.width - volumeUpOptions.width, "block", options.fullScreen.zIndex + 1, muteOptions.width, margin);
465
+ setIconStyle(unmuteImg, containerTop + margin, containerRight - margin * 3 - unmuteOptions.width - volumeDownOptions.width - volumeUpOptions.width, "none", options.fullScreen.zIndex + 1, unmuteOptions.width, margin);
466
+ setIconStyle(volumeDownImg, containerTop + margin, containerRight - margin * 2 - volumeDownOptions.width - volumeUpOptions.width, "block", options.fullScreen.zIndex + 1, volumeDownOptions.width, margin);
467
+ setIconStyle(volumeUpImg, containerTop + margin, containerRight - margin - volumeUpOptions.width, "block", options.fullScreen.zIndex + 1, volumeUpOptions.width, margin);
468
+ muteImg.src = (_a = muteOptions.path) !== null && _a !== void 0 ? _a : muteOptions.svg ? `data:image/svg+xml;base64,${btoa(muteOptions.svg)}` : "";
469
+ unmuteImg.src = (_b = unmuteOptions.path) !== null && _b !== void 0 ? _b : unmuteOptions.svg ? `data:image/svg+xml;base64,${btoa(unmuteOptions.svg)}` : "";
470
+ volumeDownImg.src = (_c = volumeDownOptions.path) !== null && _c !== void 0 ? _c : volumeDownOptions.svg ? `data:image/svg+xml;base64,${btoa(volumeDownOptions.svg)}` : "";
471
+ volumeUpImg.src = (_d = volumeUpOptions.path) !== null && _d !== void 0 ? _d : volumeUpOptions.svg ? `data:image/svg+xml;base64,${btoa(volumeUpOptions.svg)}` : "";
472
+ const parent = container.canvas.element.parentNode || document.body;
473
+ parent.append(muteImg);
474
+ parent.append(unmuteImg);
475
+ parent.append(volumeDownImg);
476
+ parent.append(volumeUpImg);
477
+ const toggleMute = () => {
478
+ container.muted = !container.muted;
479
+ this._updateMuteIcons();
480
+ this._updateMuteStatus();
481
+ };
482
+ const volumeDown = () => {
483
+ if (container.muted) {
484
+ this._volume = 0;
485
+ }
486
+ this._volume -= soundsOptions.volume.step;
487
+ this._updateVolume();
488
+ };
489
+ const volumeUp = () => {
490
+ if (container.muted) {
491
+ this._volume = 0;
492
+ }
493
+ this._volume += soundsOptions.volume.step;
494
+ this._updateVolume();
495
+ };
496
+ muteImg.addEventListener("click", toggleMute);
497
+ unmuteImg.addEventListener("click", toggleMute);
498
+ volumeDownImg.addEventListener("click", volumeDown);
499
+ volumeUpImg.addEventListener("click", volumeUp);
500
+ }
501
+ stop() {
502
+ this._container.muted = true;
503
+ this._mute();
504
+ if (this._muteImg) {
505
+ this._muteImg.remove();
506
+ }
507
+ if (this._unmuteImg) {
508
+ this._unmuteImg.remove();
509
+ }
510
+ if (this._volumeDownImg) {
511
+ this._volumeDownImg.remove();
512
+ }
513
+ if (this._volumeUpImg) {
514
+ this._volumeUpImg.remove();
515
+ }
516
+ }
517
+ _addBuffer(audioCtx) {
518
+ const buffer = audioCtx.createBufferSource();
519
+ this._audioSources.push(buffer);
520
+ return buffer;
521
+ }
522
+ _addOscillator(audioCtx) {
523
+ const oscillator = audioCtx.createOscillator();
524
+ this._audioSources.push(oscillator);
525
+ return oscillator;
526
+ }
527
+ _initEvents() {
528
+ const container = this._container,
529
+ soundsOptions = container.actualOptions.sounds;
530
+ if (!(soundsOptions === null || soundsOptions === void 0 ? void 0 : soundsOptions.enable) || !container.canvas.element) {
531
+ return;
532
+ }
533
+ for (const event of soundsOptions.events) {
534
+ const cb = async args => {
535
+ if (this._container !== args.container) {
536
+ return;
537
+ }
538
+ if (!this._container || this._container.muted || this._container.destroyed) {
539
+ (0,engine_root_window_.executeOnSingleOrMultiple)(event.event, item => {
540
+ this._engine.removeEventListener(item, cb);
541
+ });
542
+ return;
543
+ }
544
+ if (event.filter && !event.filter(args)) {
545
+ return;
546
+ }
547
+ if (event.audio) {
548
+ this._playBuffer((0,engine_root_window_.itemFromSingleOrMultiple)(event.audio));
549
+ } else if (event.melodies) {
550
+ const melody = (0,engine_root_window_.itemFromArray)(event.melodies);
551
+ if (melody.melodies.length) {
552
+ await Promise.allSettled(melody.melodies.map(m => this._playNote(m.notes, 0, melody.loop)));
553
+ } else {
554
+ await this._playNote(melody.notes, 0, melody.loop);
555
+ }
556
+ } else if (event.notes) {
557
+ const note = (0,engine_root_window_.itemFromArray)(event.notes);
558
+ await this._playNote([note], 0, false);
559
+ }
560
+ };
561
+ (0,engine_root_window_.executeOnSingleOrMultiple)(event.event, item => {
562
+ this._engine.addEventListener(item, cb);
563
+ });
564
+ }
565
+ }
566
+ _mute() {
567
+ const container = this._container;
568
+ if (!container.audioContext) {
569
+ return;
570
+ }
571
+ for (const source of this._audioSources) {
572
+ this._removeAudioSource(source);
573
+ }
574
+ if (this._gain) {
575
+ this._gain.disconnect();
576
+ }
577
+ container.audioContext.close();
578
+ container.audioContext = undefined;
579
+ this._engine.dispatchEvent("soundsMuted", {
580
+ container: this._container
581
+ });
582
+ }
583
+ _playBuffer(audio) {
584
+ var _a;
585
+ const audioBuffer = this._audioMap.get(audio.source);
586
+ if (!audioBuffer) {
587
+ return;
588
+ }
589
+ const audioCtx = this._container.audioContext;
590
+ if (!audioCtx) {
591
+ return;
592
+ }
593
+ const source = this._addBuffer(audioCtx);
594
+ source.loop = audio.loop;
595
+ source.buffer = audioBuffer;
596
+ source.connect((_a = this._gain) !== null && _a !== void 0 ? _a : audioCtx.destination);
597
+ source.start();
598
+ }
599
+ async _playFrequency(frequency, duration) {
600
+ if (!this._container.audioContext || !this._gain) {
601
+ return;
602
+ }
603
+ const oscillator = this._addOscillator(this._container.audioContext);
604
+ oscillator.connect(this._gain);
605
+ oscillator.type = "sine";
606
+ oscillator.frequency.value = frequency;
607
+ oscillator.start();
608
+ return new Promise(resolve => {
609
+ setTimeout(() => {
610
+ this._removeAudioSource(oscillator);
611
+ resolve();
612
+ }, duration);
613
+ });
614
+ }
615
+ _playMuteSound() {
616
+ const container = this._container;
617
+ if (!container.audioContext) {
618
+ return;
619
+ }
620
+ const gain = container.audioContext.createGain();
621
+ gain.connect(container.audioContext.destination);
622
+ gain.gain.value = 0;
623
+ const oscillator = container.audioContext.createOscillator();
624
+ oscillator.connect(gain);
625
+ oscillator.type = "sine";
626
+ oscillator.frequency.value = 1;
627
+ oscillator.start();
628
+ setTimeout(() => {
629
+ oscillator.stop();
630
+ oscillator.disconnect();
631
+ gain.disconnect();
632
+ });
633
+ }
634
+ async _playNote(notes, noteIdx, loop) {
635
+ if (this._container.muted) {
636
+ return;
637
+ }
638
+ const note = notes[noteIdx];
639
+ if (!note) {
640
+ return;
641
+ }
642
+ const value = note.value;
643
+ const promises = (0,engine_root_window_.executeOnSingleOrMultiple)(value, async (_, idx) => {
644
+ return this._playNoteValue(notes, noteIdx, idx);
645
+ });
646
+ await (promises instanceof Array ? Promise.allSettled(promises) : promises);
647
+ let nextNoteIdx = noteIdx + 1;
648
+ if (loop && nextNoteIdx >= notes.length) {
649
+ nextNoteIdx = nextNoteIdx % notes.length;
650
+ }
651
+ if (this._container.muted) {
652
+ return;
653
+ }
654
+ await this._playNote(notes, nextNoteIdx, loop);
655
+ }
656
+ async _playNoteValue(notes, noteIdx, valueIdx) {
657
+ const note = notes[noteIdx];
658
+ if (!note) {
659
+ return;
660
+ }
661
+ const value = (0,engine_root_window_.itemFromSingleOrMultiple)(note.value, valueIdx, true);
662
+ try {
663
+ const freq = getNoteFrequency(value);
664
+ if (typeof freq !== "number") {
665
+ return;
666
+ }
667
+ await this._playFrequency(freq, note.duration);
668
+ } catch (e) {
669
+ console.error(e);
670
+ }
671
+ }
672
+ _removeAudioSource(source) {
673
+ source.stop();
674
+ source.disconnect();
675
+ this._audioSources.splice(this._audioSources.indexOf(source), 1);
676
+ }
677
+ _unmute() {
678
+ const container = this._container,
679
+ options = container.actualOptions,
680
+ soundsOptions = options.sounds;
681
+ if (!soundsOptions) {
682
+ return;
683
+ }
684
+ if (!container.audioContext) {
685
+ container.audioContext = new AudioContext();
686
+ }
687
+ if (!this._audioSources) {
688
+ this._audioSources = [];
689
+ }
690
+ const gain = container.audioContext.createGain();
691
+ gain.connect(container.audioContext.destination);
692
+ gain.gain.value = soundsOptions.volume.value / 100;
693
+ this._gain = gain;
694
+ this._initEvents();
695
+ this._engine.dispatchEvent("soundsUnmuted", {
696
+ container: this._container
697
+ });
698
+ }
699
+ _updateMuteIcons() {
700
+ const container = this._container,
701
+ muteImg = this._muteImg,
702
+ unmuteImg = this._unmuteImg;
703
+ if (muteImg) {
704
+ muteImg.style.display = container.muted ? "block" : "none";
705
+ }
706
+ if (unmuteImg) {
707
+ unmuteImg.style.display = container.muted ? "none" : "block";
708
+ }
709
+ }
710
+ _updateMuteStatus() {
711
+ const container = this._container;
712
+ if (container.muted) {
713
+ this._mute();
714
+ } else {
715
+ this._unmute();
716
+ this._playMuteSound();
717
+ }
718
+ }
719
+ _updateVolume() {
720
+ var _a;
721
+ const container = this._container,
722
+ soundsOptions = container.actualOptions.sounds;
723
+ if (!(soundsOptions === null || soundsOptions === void 0 ? void 0 : soundsOptions.enable)) {
724
+ return;
725
+ }
726
+ (0,engine_root_window_.clamp)(this._volume, soundsOptions.volume.min, soundsOptions.volume.max);
727
+ let stateChanged = false;
728
+ if (this._volume <= 0 && !container.muted) {
729
+ this._volume = 0;
730
+ container.muted = true;
731
+ stateChanged = true;
732
+ } else if (this._volume > 0 && container.muted) {
733
+ container.muted = false;
734
+ stateChanged = true;
735
+ }
736
+ if (stateChanged) {
737
+ this._updateMuteIcons();
738
+ this._updateMuteStatus();
739
+ }
740
+ if ((_a = this._gain) === null || _a === void 0 ? void 0 : _a.gain) {
741
+ this._gain.gain.value = this._volume / 100;
742
+ }
743
+ }
744
+ }
745
+ ;// CONCATENATED MODULE: ./dist/browser/index.js
746
+
747
+
748
+ class SoundsPlugin {
749
+ constructor(engine) {
750
+ this.id = "sounds";
751
+ this._engine = engine;
752
+ }
753
+ getPlugin(container) {
754
+ return new SoundsInstance(container, this._engine);
755
+ }
756
+ loadOptions(options, source) {
757
+ if (!this.needsPlugin(source)) {
758
+ return;
759
+ }
760
+ let soundsOptions = options.sounds;
761
+ if ((soundsOptions === null || soundsOptions === void 0 ? void 0 : soundsOptions.load) === undefined) {
762
+ options.sounds = soundsOptions = new Sounds();
763
+ }
764
+ soundsOptions.load(source === null || source === void 0 ? void 0 : source.sounds);
765
+ }
766
+ needsPlugin(options) {
767
+ var _a, _b;
768
+ return (_b = (_a = options === null || options === void 0 ? void 0 : options.sounds) === null || _a === void 0 ? void 0 : _a.enable) !== null && _b !== void 0 ? _b : false;
769
+ }
770
+ }
771
+ async function loadSoundsPlugin(engine) {
772
+ const plugin = new SoundsPlugin(engine);
773
+ await engine.addPlugin(plugin);
774
+ }
775
+ })();
776
+
777
+ /******/ return __webpack_exports__;
778
+ /******/ })()
779
+ ;
780
+ });