@tsparticles/plugin-sounds 4.0.0-alpha.8 → 4.0.0-beta.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 (58) hide show
  1. package/30.min.js +33 -0
  2. package/915.min.js +1 -0
  3. package/browser/Options/Classes/Sounds.js +5 -0
  4. package/browser/Options/Classes/SoundsAudio.js +2 -0
  5. package/browser/Options/Classes/SoundsEvent.js +5 -0
  6. package/browser/Options/Classes/SoundsIcon.js +5 -0
  7. package/browser/Options/Classes/SoundsIcons.js +5 -0
  8. package/browser/Options/Classes/SoundsMelody.js +3 -0
  9. package/browser/Options/Classes/SoundsNote.js +2 -0
  10. package/browser/Options/Classes/SoundsVolume.js +4 -0
  11. package/browser/SoundsPlugin.js +2 -1
  12. package/browser/SoundsPluginInstance.js +246 -237
  13. package/browser/index.js +1 -1
  14. package/cjs/Options/Classes/Sounds.js +5 -0
  15. package/cjs/Options/Classes/SoundsAudio.js +2 -0
  16. package/cjs/Options/Classes/SoundsEvent.js +5 -0
  17. package/cjs/Options/Classes/SoundsIcon.js +5 -0
  18. package/cjs/Options/Classes/SoundsIcons.js +5 -0
  19. package/cjs/Options/Classes/SoundsMelody.js +3 -0
  20. package/cjs/Options/Classes/SoundsNote.js +2 -0
  21. package/cjs/Options/Classes/SoundsVolume.js +4 -0
  22. package/cjs/SoundsPlugin.js +2 -1
  23. package/cjs/SoundsPluginInstance.js +246 -237
  24. package/cjs/index.js +1 -1
  25. package/dist_browser_SoundsPluginInstance_js.js +3 -3
  26. package/dist_browser_SoundsPlugin_js.js +12 -12
  27. package/esm/Options/Classes/Sounds.js +5 -0
  28. package/esm/Options/Classes/SoundsAudio.js +2 -0
  29. package/esm/Options/Classes/SoundsEvent.js +5 -0
  30. package/esm/Options/Classes/SoundsIcon.js +5 -0
  31. package/esm/Options/Classes/SoundsIcons.js +5 -0
  32. package/esm/Options/Classes/SoundsMelody.js +3 -0
  33. package/esm/Options/Classes/SoundsNote.js +2 -0
  34. package/esm/Options/Classes/SoundsVolume.js +4 -0
  35. package/esm/SoundsPlugin.js +2 -1
  36. package/esm/SoundsPluginInstance.js +246 -237
  37. package/esm/index.js +1 -1
  38. package/package.json +2 -2
  39. package/report.html +1 -1
  40. package/tsparticles.plugin.sounds.js +31 -19
  41. package/tsparticles.plugin.sounds.min.js +2 -2
  42. package/types/SoundsPlugin.d.ts +1 -1
  43. package/umd/Options/Classes/Sounds.js +5 -0
  44. package/umd/Options/Classes/SoundsAudio.js +2 -0
  45. package/umd/Options/Classes/SoundsEvent.js +5 -0
  46. package/umd/Options/Classes/SoundsIcon.js +5 -0
  47. package/umd/Options/Classes/SoundsIcons.js +5 -0
  48. package/umd/Options/Classes/SoundsMelody.js +3 -0
  49. package/umd/Options/Classes/SoundsNote.js +2 -0
  50. package/umd/Options/Classes/SoundsVolume.js +4 -0
  51. package/umd/SoundsPlugin.js +2 -1
  52. package/umd/SoundsPluginInstance.js +246 -237
  53. package/umd/index.js +1 -1
  54. package/296.min.js +0 -2
  55. package/296.min.js.LICENSE.txt +0 -1
  56. package/340.min.js +0 -2
  57. package/340.min.js.LICENSE.txt +0 -1
  58. package/tsparticles.plugin.sounds.min.js.LICENSE.txt +0 -1
@@ -31,242 +31,17 @@ function setIconStyle(icon, top, left, display, zIndex, width, margin, style) {
31
31
  icon.style.cssText += style;
32
32
  }
33
33
  export class SoundsPluginInstance {
34
+ _audioMap;
35
+ _audioSources;
36
+ _container;
37
+ _engine;
38
+ _gain;
39
+ _muteImg;
40
+ _unmuteImg;
41
+ _volume;
42
+ _volumeDownImg;
43
+ _volumeUpImg;
34
44
  constructor(container, engine) {
35
- this._addBuffer = audioCtx => {
36
- const buffer = audioCtx.createBufferSource();
37
- this._audioSources.push(buffer);
38
- return buffer;
39
- };
40
- this._addOscillator = audioCtx => {
41
- const oscillator = audioCtx.createOscillator();
42
- this._audioSources.push(oscillator);
43
- return oscillator;
44
- };
45
- this._initEvents = () => {
46
- const container = this._container, soundsOptions = container.actualOptions.sounds;
47
- if (!soundsOptions?.enable || !container.canvas.element) {
48
- return;
49
- }
50
- for (const event of soundsOptions.events) {
51
- const cb = (args) => {
52
- if (!args) {
53
- return;
54
- }
55
- void (async () => {
56
- const filterNotValid = event.filter && !event.filter(args);
57
- if (this._container !== args.container) {
58
- return;
59
- }
60
- if (!!this._container.muted || this._container.destroyed) {
61
- executeOnSingleOrMultiple(event.event, item => {
62
- this._engine.removeEventListener(item, cb);
63
- });
64
- return;
65
- }
66
- if (filterNotValid) {
67
- return;
68
- }
69
- const defaultNoteIndex = 0;
70
- if (event.audio) {
71
- const audio = itemFromSingleOrMultiple(event.audio);
72
- if (!audio) {
73
- return;
74
- }
75
- this._playBuffer(audio);
76
- }
77
- else if (event.melodies) {
78
- const melody = itemFromArray(event.melodies);
79
- if (!melody) {
80
- return;
81
- }
82
- if (melody.melodies.length) {
83
- await Promise.allSettled(melody.melodies.map(m => this._playNote(m.notes, defaultNoteIndex, melody.loop)));
84
- }
85
- else {
86
- await this._playNote(melody.notes, defaultNoteIndex, melody.loop);
87
- }
88
- }
89
- else if (event.notes) {
90
- const note = itemFromArray(event.notes);
91
- if (!note) {
92
- return;
93
- }
94
- await this._playNote([note], defaultNoteIndex, false);
95
- }
96
- })();
97
- };
98
- executeOnSingleOrMultiple(event.event, item => {
99
- this._engine.addEventListener(item, cb);
100
- });
101
- }
102
- };
103
- this._mute = async () => {
104
- const container = this._container, audioContext = this._getAudioContext();
105
- for (const source of this._audioSources) {
106
- this._removeAudioSource(source);
107
- }
108
- if (this._gain) {
109
- this._gain.disconnect();
110
- }
111
- await audioContext.close();
112
- container.audioContext = undefined;
113
- this._engine.dispatchEvent(SoundsEventType.mute, { container: this._container });
114
- };
115
- this._playBuffer = audio => {
116
- const audioBuffer = this._audioMap.get(audio.source);
117
- if (!audioBuffer) {
118
- return;
119
- }
120
- const audioCtx = this._container.audioContext;
121
- if (!audioCtx) {
122
- return;
123
- }
124
- const source = this._addBuffer(audioCtx);
125
- source.loop = audio.loop;
126
- source.buffer = audioBuffer;
127
- source.connect(this._gain ?? audioCtx.destination);
128
- source.start();
129
- };
130
- this._playFrequency = async (frequency, duration) => {
131
- if (!this._gain || this._container.muted) {
132
- return;
133
- }
134
- const audioContext = this._getAudioContext(), oscillator = this._addOscillator(audioContext);
135
- oscillator.connect(this._gain);
136
- oscillator.type = "sine";
137
- oscillator.frequency.value = frequency;
138
- oscillator.start();
139
- return new Promise(resolve => {
140
- setTimeout(() => {
141
- this._removeAudioSource(oscillator);
142
- resolve();
143
- }, duration);
144
- });
145
- };
146
- this._playMuteSound = () => {
147
- if (this._container.muted) {
148
- return;
149
- }
150
- const audioContext = this._getAudioContext(), gain = audioContext.createGain();
151
- gain.connect(audioContext.destination);
152
- gain.gain.value = 0;
153
- const oscillator = audioContext.createOscillator();
154
- oscillator.connect(gain);
155
- oscillator.type = "sine";
156
- oscillator.frequency.value = 1;
157
- oscillator.start();
158
- setTimeout(() => {
159
- oscillator.stop();
160
- oscillator.disconnect();
161
- gain.disconnect();
162
- });
163
- };
164
- this._playNote = async (notes, noteIdx, loop) => {
165
- if (this._container.muted) {
166
- return;
167
- }
168
- const note = notes[noteIdx];
169
- if (!note) {
170
- return;
171
- }
172
- const value = note.value, promises = executeOnSingleOrMultiple(value, async (_, idx) => {
173
- return this._playNoteValue(notes, noteIdx, idx);
174
- });
175
- await (isArray(promises) ? Promise.allSettled(promises) : promises);
176
- const indexOffset = 1;
177
- let nextNoteIdx = noteIdx + indexOffset;
178
- if (loop && nextNoteIdx >= notes.length) {
179
- nextNoteIdx = nextNoteIdx % notes.length;
180
- }
181
- await this._playNote(notes, nextNoteIdx, loop);
182
- };
183
- this._playNoteValue = async (notes, noteIdx, valueIdx) => {
184
- const note = notes[noteIdx];
185
- if (!note) {
186
- return;
187
- }
188
- const value = itemFromSingleOrMultiple(note.value, valueIdx, true);
189
- if (!value) {
190
- return;
191
- }
192
- try {
193
- const freq = getNoteFrequency(value);
194
- if (!isNumber(freq)) {
195
- return;
196
- }
197
- await this._playFrequency(freq, note.duration);
198
- }
199
- catch (e) {
200
- getLogger().error(e);
201
- }
202
- };
203
- this._removeAudioSource = source => {
204
- source.stop();
205
- source.disconnect();
206
- const deleteCount = 1;
207
- this._audioSources.splice(this._audioSources.indexOf(source), deleteCount);
208
- };
209
- this._unmute = () => {
210
- const container = this._container, options = container.actualOptions, soundsOptions = options.sounds;
211
- if (!soundsOptions) {
212
- return;
213
- }
214
- const audioContext = this._getAudioContext(), gain = audioContext.createGain();
215
- gain.connect(audioContext.destination);
216
- gain.gain.value = soundsOptions.volume.value / percentDenominator;
217
- this._gain = gain;
218
- this._initEvents();
219
- this._engine.dispatchEvent(SoundsEventType.unmute, { container: this._container });
220
- };
221
- this._updateMuteIcons = () => {
222
- const container = this._container, soundsOptions = container.actualOptions.sounds;
223
- if (!soundsOptions?.enable || !soundsOptions.icons.enable) {
224
- return;
225
- }
226
- const muteImg = this._muteImg, unmuteImg = this._unmuteImg;
227
- if (muteImg) {
228
- muteImg.style.display = container.muted ? "block" : "none";
229
- }
230
- if (unmuteImg) {
231
- unmuteImg.style.display = container.muted ? "none" : "block";
232
- }
233
- };
234
- this._updateMuteStatus = async () => {
235
- const container = this._container, audioContext = this._getAudioContext();
236
- if (container.muted) {
237
- await audioContext.suspend();
238
- await this._mute();
239
- }
240
- else {
241
- await audioContext.resume();
242
- this._unmute();
243
- this._playMuteSound();
244
- }
245
- };
246
- this._updateVolume = async () => {
247
- const container = this._container, soundsOptions = container.actualOptions.sounds;
248
- if (!soundsOptions?.enable) {
249
- return;
250
- }
251
- clamp(this._volume, soundsOptions.volume.min, soundsOptions.volume.max);
252
- let stateChanged = false;
253
- if (this._volume <= minVolume && !container.muted) {
254
- this._volume = 0;
255
- container.muted = true;
256
- stateChanged = true;
257
- }
258
- else if (this._volume > minVolume && container.muted) {
259
- container.muted = false;
260
- stateChanged = true;
261
- }
262
- if (stateChanged) {
263
- this._updateMuteIcons();
264
- await this._updateMuteStatus();
265
- }
266
- if (this._gain?.gain) {
267
- this._gain.gain.value = this._volume / percentDenominator;
268
- }
269
- };
270
45
  this._container = container;
271
46
  this._engine = engine;
272
47
  this._volume = 0;
@@ -284,8 +59,7 @@ export class SoundsPluginInstance {
284
59
  removeEventListener(touchStartEvent, firstClickHandler);
285
60
  unmuteWindow();
286
61
  void this.unmute();
287
- };
288
- const listenerOptions = {
62
+ }, listenerOptions = {
289
63
  capture: true,
290
64
  once: true,
291
65
  };
@@ -420,9 +194,244 @@ export class SoundsPluginInstance {
420
194
  this._volume += soundsOptions.volume.step;
421
195
  await this._updateVolume();
422
196
  }
197
+ _addBuffer = audioCtx => {
198
+ const buffer = audioCtx.createBufferSource();
199
+ this._audioSources.push(buffer);
200
+ return buffer;
201
+ };
202
+ _addOscillator = audioCtx => {
203
+ const oscillator = audioCtx.createOscillator();
204
+ this._audioSources.push(oscillator);
205
+ return oscillator;
206
+ };
423
207
  _getAudioContext() {
424
208
  const container = this._container;
425
209
  container.audioContext ??= new AudioContext();
426
210
  return container.audioContext;
427
211
  }
212
+ _initEvents = () => {
213
+ const container = this._container, soundsOptions = container.actualOptions.sounds;
214
+ if (!soundsOptions?.enable || !container.canvas.element) {
215
+ return;
216
+ }
217
+ for (const event of soundsOptions.events) {
218
+ const cb = (args) => {
219
+ if (!args) {
220
+ return;
221
+ }
222
+ void (async () => {
223
+ const filterNotValid = event.filter && !event.filter(args);
224
+ if (this._container !== args.container) {
225
+ return;
226
+ }
227
+ if (!!this._container.muted || this._container.destroyed) {
228
+ executeOnSingleOrMultiple(event.event, item => {
229
+ this._engine.removeEventListener(item, cb);
230
+ });
231
+ return;
232
+ }
233
+ if (filterNotValid) {
234
+ return;
235
+ }
236
+ const defaultNoteIndex = 0;
237
+ if (event.audio) {
238
+ const audio = itemFromSingleOrMultiple(event.audio);
239
+ if (!audio) {
240
+ return;
241
+ }
242
+ this._playBuffer(audio);
243
+ }
244
+ else if (event.melodies) {
245
+ const melody = itemFromArray(event.melodies);
246
+ if (!melody) {
247
+ return;
248
+ }
249
+ if (melody.melodies.length) {
250
+ await Promise.allSettled(melody.melodies.map(m => this._playNote(m.notes, defaultNoteIndex, melody.loop)));
251
+ }
252
+ else {
253
+ await this._playNote(melody.notes, defaultNoteIndex, melody.loop);
254
+ }
255
+ }
256
+ else if (event.notes) {
257
+ const note = itemFromArray(event.notes);
258
+ if (!note) {
259
+ return;
260
+ }
261
+ await this._playNote([note], defaultNoteIndex, false);
262
+ }
263
+ })();
264
+ };
265
+ executeOnSingleOrMultiple(event.event, item => {
266
+ this._engine.addEventListener(item, cb);
267
+ });
268
+ }
269
+ };
270
+ _mute = async () => {
271
+ const container = this._container, audioContext = this._getAudioContext();
272
+ for (const source of this._audioSources) {
273
+ this._removeAudioSource(source);
274
+ }
275
+ if (this._gain) {
276
+ this._gain.disconnect();
277
+ }
278
+ await audioContext.close();
279
+ container.audioContext = undefined;
280
+ this._engine.dispatchEvent(SoundsEventType.mute, { container: this._container });
281
+ };
282
+ _playBuffer = audio => {
283
+ const audioBuffer = this._audioMap.get(audio.source);
284
+ if (!audioBuffer) {
285
+ return;
286
+ }
287
+ const audioCtx = this._container.audioContext;
288
+ if (!audioCtx) {
289
+ return;
290
+ }
291
+ const source = this._addBuffer(audioCtx);
292
+ source.loop = audio.loop;
293
+ source.buffer = audioBuffer;
294
+ source.connect(this._gain ?? audioCtx.destination);
295
+ source.start();
296
+ };
297
+ _playFrequency = async (frequency, duration) => {
298
+ if (!this._gain || this._container.muted) {
299
+ return;
300
+ }
301
+ const audioContext = this._getAudioContext(), oscillator = this._addOscillator(audioContext);
302
+ oscillator.connect(this._gain);
303
+ oscillator.type = "sine";
304
+ oscillator.frequency.value = frequency;
305
+ oscillator.start();
306
+ return new Promise(resolve => {
307
+ setTimeout(() => {
308
+ this._removeAudioSource(oscillator);
309
+ resolve();
310
+ }, duration);
311
+ });
312
+ };
313
+ _playMuteSound = () => {
314
+ if (this._container.muted) {
315
+ return;
316
+ }
317
+ const audioContext = this._getAudioContext(), gain = audioContext.createGain();
318
+ gain.connect(audioContext.destination);
319
+ gain.gain.value = 0;
320
+ const oscillator = audioContext.createOscillator();
321
+ oscillator.connect(gain);
322
+ oscillator.type = "sine";
323
+ oscillator.frequency.value = 1;
324
+ oscillator.start();
325
+ setTimeout(() => {
326
+ oscillator.stop();
327
+ oscillator.disconnect();
328
+ gain.disconnect();
329
+ });
330
+ };
331
+ _playNote = async (notes, noteIdx, loop) => {
332
+ if (this._container.muted) {
333
+ return;
334
+ }
335
+ const note = notes[noteIdx];
336
+ if (!note) {
337
+ return;
338
+ }
339
+ const value = note.value, promises = executeOnSingleOrMultiple(value, async (_, idx) => {
340
+ return this._playNoteValue(notes, noteIdx, idx);
341
+ });
342
+ await (isArray(promises) ? Promise.allSettled(promises) : promises);
343
+ const indexOffset = 1;
344
+ let nextNoteIdx = noteIdx + indexOffset;
345
+ if (loop && nextNoteIdx >= notes.length) {
346
+ nextNoteIdx = nextNoteIdx % notes.length;
347
+ }
348
+ await this._playNote(notes, nextNoteIdx, loop);
349
+ };
350
+ _playNoteValue = async (notes, noteIdx, valueIdx) => {
351
+ const note = notes[noteIdx];
352
+ if (!note) {
353
+ return;
354
+ }
355
+ const value = itemFromSingleOrMultiple(note.value, valueIdx, true);
356
+ if (!value) {
357
+ return;
358
+ }
359
+ try {
360
+ const freq = getNoteFrequency(value);
361
+ if (!isNumber(freq)) {
362
+ return;
363
+ }
364
+ await this._playFrequency(freq, note.duration);
365
+ }
366
+ catch (e) {
367
+ getLogger().error(e);
368
+ }
369
+ };
370
+ _removeAudioSource = source => {
371
+ source.stop();
372
+ source.disconnect();
373
+ const deleteCount = 1;
374
+ this._audioSources.splice(this._audioSources.indexOf(source), deleteCount);
375
+ };
376
+ _unmute = () => {
377
+ const container = this._container, options = container.actualOptions, soundsOptions = options.sounds;
378
+ if (!soundsOptions) {
379
+ return;
380
+ }
381
+ const audioContext = this._getAudioContext(), gain = audioContext.createGain();
382
+ gain.connect(audioContext.destination);
383
+ gain.gain.value = soundsOptions.volume.value / percentDenominator;
384
+ this._gain = gain;
385
+ this._initEvents();
386
+ this._engine.dispatchEvent(SoundsEventType.unmute, { container: this._container });
387
+ };
388
+ _updateMuteIcons = () => {
389
+ const container = this._container, soundsOptions = container.actualOptions.sounds;
390
+ if (!soundsOptions?.enable || !soundsOptions.icons.enable) {
391
+ return;
392
+ }
393
+ const muteImg = this._muteImg, unmuteImg = this._unmuteImg;
394
+ if (muteImg) {
395
+ muteImg.style.display = container.muted ? "block" : "none";
396
+ }
397
+ if (unmuteImg) {
398
+ unmuteImg.style.display = container.muted ? "none" : "block";
399
+ }
400
+ };
401
+ _updateMuteStatus = async () => {
402
+ const container = this._container, audioContext = this._getAudioContext();
403
+ if (container.muted) {
404
+ await audioContext.suspend();
405
+ await this._mute();
406
+ }
407
+ else {
408
+ await audioContext.resume();
409
+ this._unmute();
410
+ this._playMuteSound();
411
+ }
412
+ };
413
+ _updateVolume = async () => {
414
+ const container = this._container, soundsOptions = container.actualOptions.sounds;
415
+ if (!soundsOptions?.enable) {
416
+ return;
417
+ }
418
+ clamp(this._volume, soundsOptions.volume.min, soundsOptions.volume.max);
419
+ let stateChanged = false;
420
+ if (this._volume <= minVolume && !container.muted) {
421
+ this._volume = 0;
422
+ container.muted = true;
423
+ stateChanged = true;
424
+ }
425
+ else if (this._volume > minVolume && container.muted) {
426
+ container.muted = false;
427
+ stateChanged = true;
428
+ }
429
+ if (stateChanged) {
430
+ this._updateMuteIcons();
431
+ await this._updateMuteStatus();
432
+ }
433
+ if (this._gain?.gain) {
434
+ this._gain.gain.value = this._volume / percentDenominator;
435
+ }
436
+ };
428
437
  }
package/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export async function loadSoundsPlugin(engine) {
2
- engine.checkVersion("4.0.0-alpha.8");
2
+ engine.checkVersion("4.0.0-beta.0");
3
3
  await engine.register(async (e) => {
4
4
  const { SoundsPlugin } = await import("./SoundsPlugin.js");
5
5
  e.addPlugin(new SoundsPlugin(engine));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/plugin-sounds",
3
- "version": "4.0.0-alpha.8",
3
+ "version": "4.0.0-beta.0",
4
4
  "description": "tsParticles sounds plugin",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -86,7 +86,7 @@
86
86
  "./package.json": "./package.json"
87
87
  },
88
88
  "dependencies": {
89
- "@tsparticles/engine": "4.0.0-alpha.8"
89
+ "@tsparticles/engine": "4.0.0-beta.0"
90
90
  },
91
91
  "publishConfig": {
92
92
  "access": "public"
package/report.html CHANGED
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="UTF-8"/>
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1"/>
6
- <title>@tsparticles/plugin-sounds [23 Jan 2026 at 23:46]</title>
6
+ <title>@tsparticles/plugin-sounds [19 Mar 2026 at 14:00]</title>
7
7
  <link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H0/ojfMKpzOd0rNgQcb3F3O/j9f7c8v6g3Pz0/P/w+v/q+P7n9v6T1/uQ1vuE0vqLut/y+v+Z2fvt+f+15Pzv9fuc2/vR7v2V2Pvd6/bg9P7I6/285/2y4/yp3/zp8vk8i8kqgMT7/P31+fyv4vxGkcz6/P6/6P3j7vfS5PNnpNUxhcbO7f7F6v3O4vHK3/DA2u631Ouy0eqXweKJud5wqthfoNMMbLvY8f73+v2dxeR8sNtTmdDx9/zX6PSjyeaCtd1YnNGX2PuQveCGt95Nls42h8dLlM3F4vBtAAAAM3RSTlMAAyOx0/sKBvik8opWGBMOAe3l1snDm2E9LSb06eHcu5JpHbarfHZCN9CBb08zzkdNS0kYaptYAAAFV0lEQVRYw92X51/aYBDHHS2O2qqttVbrqNq9m+TJIAYIShBkWwqIiCgoWvfeq7Z2/s29hyQNyUcR7LveGwVyXy6XH8/9rqxglLfUPLxVduUor3h0rfp2TYvpivk37929TkG037hffoX0+peVtZQc1589rigVUdXS/ABSAyEmGIO/1XfvldSK8vs3OqB6u3m0nxmIrvgB0dj7rr7Y9IbuF68hnfFaiHA/sxqm0wciIG43P60qKv9WXWc1RXGh/mFESFABTSBi0sNAKzqet17eCtOb3kZIDwxEEU0oAIJGYxNBDhBND29e0rtXXbcpuPmED9IhEAAQ/AXEaF8EPmnrrKsv0LvWR3fg5sWDNAFZOgAgaKvZDogHNU9MFwnnYROkc56RD5CjAbQX9Ow4g7upCsvYu55aSI/Nj0H1akgKQEUM94dwK65hYRmFU9MIcH/fqJYOZYcnuJSU/waKDgTOEVaVKhwrTRP5XzgSpAITYzom7UvkhFX5VutmxeNnWDjjswTKTyfgluNDGbUpWissXhF3s7mlSml+czWkg3D0l1nNjGNjz3myOQOa1KM/jOS6ebdbAVTCi4gljHSFrviza7tOgRWcS0MOUX9zdNgag5w7rRqA44Lzw0hr1WqES36dFliSJFlh2rXIae3FFcDDgKdxrUIDePr8jGcSClV1u7A9xeN0ModY/pHMxmR1EzRh8TJiwqsHmKW0l4FCEZI+jHio+JdPPE9qwQtTRxku2D8sIeRL2LnxWSllANCQGOIiqVHAz2ye2JR0DcH+HoxDkaADLjgxjKQ+AwCX/g0+DNgdG0ukYCONAe+dbc2IAc6fwt1ARoDSezNHxV2Cmzwv3O6lDMV55edBGwGK9n1+x2F8EDfAGCxug8MhpsMEcTEAWf3rx2vZhe/LAmtIn/6apE6PN0ULKgywD9mmdxbmFl3OvD5AS5fW5zLbv/YHmcsBTjf/afDz3MaZTVCfAP9z6/Bw6ycv8EUBWJIn9zYcoAWWlW9+OzO3vkTy8H+RANLmdrpOuYWdZYEXpo+TlCJrW5EARb7fF+bWdqf3hhyZI1nWJQHgznErZhbjoEsWqi8dQNoE294aldzFurwSABL2XXMf9+H1VQGke9exw5P/AnA5Pv5ngMul7LOvO922iwACu8WkCwLCafvM4CeWPxfA8lNHcWZSoi8EwMAIciKX2Z4SWCMAa3snCZ/G4EA8D6CMLNFsGQhkkz/gQNEBbPCbWsxGUpYVu3z8IyNAknwJkfPMEhLyrdi5RTyUVACkw4GSFRNWJNEW+fgPGwHD8/JxnRuLabN4CGNRkAE23na2+VmEAUmrYymSGjMAYqH84YUIyzgzs3XC7gNgH36Vcc4zKY9o9fgPBXUAiHHwVboBHGLiX6Zcjp1f2wu4tvzZKo0ecPnDtQYDQvJXaBeNzce45Fp28ZQLrEZVuFqgBwOalArKXnW1UzlnSusQKJqKYNuz4tOnI6sZG4zanpemv+7ySU2jbA9h6uhcgpfy6G2PahirDZ6zvq6zDduMVFTKvzw8wgyEdelwY9in3XkEPs3osJuwRQ4qTkfzifndg9Gfc4pdsu82+tTnHZTBa2EAMrqr2t43pguc8tNm7JQVQ2S0ukj2d22dhXYP0/veWtwKrCkNoNimAN5+Xr/oLrxswKbVJjteWrX7eR63o4j9q0GxnaBdWgGA5VStpanIjQmEhV0/nVt5VOFUvix6awJhPcAaTEShgrG+iGyvb5a0Ndb1YGHFPEwoqAinoaykaID1o1pdPNu7XsnCKQ3R+hwWIIhGvORcJUBYXe3Xa3vq/mF/N9V13ugufMkfXn+KHsRD0B8AAAAASUVORK5CYII=" type="image/x-icon" />
8
8
 
9
9
  <script>
@@ -4,7 +4,7 @@
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
- * v4.0.0-alpha.8
7
+ * v4.0.0-beta.0
8
8
  */
9
9
  /*
10
10
  * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
@@ -28,16 +28,6 @@ return /******/ (() => { // webpackBootstrap
28
28
  /******/ "use strict";
29
29
  /******/ var __webpack_modules__ = ({
30
30
 
31
- /***/ "./dist/browser/index.js"
32
- /*!*******************************!*\
33
- !*** ./dist/browser/index.js ***!
34
- \*******************************/
35
- (__unused_webpack___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) {\n engine.checkVersion(\"4.0.0-alpha.8\");\n await engine.register(async e => {\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 e.addPlugin(new SoundsPlugin(engine));\n });\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-sounds/./dist/browser/index.js?\n}");
38
-
39
- /***/ },
40
-
41
31
  /***/ "@tsparticles/engine"
42
32
  /*!*********************************************************************************************************************************!*\
43
33
  !*** external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"} ***!
@@ -46,6 +36,16 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
46
36
 
47
37
  module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
48
38
 
39
+ /***/ },
40
+
41
+ /***/ "./dist/browser/index.js"
42
+ /*!*******************************!*\
43
+ !*** ./dist/browser/index.js ***!
44
+ \*******************************/
45
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
46
+
47
+ 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) {\n engine.checkVersion(\"4.0.0-beta.0\");\n await engine.register(async (e)=>{\n const { SoundsPlugin } = await __webpack_require__.e(/*! import() */ \"dist_browser_SoundsPlugin_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./SoundsPlugin.js */ \"./dist/browser/SoundsPlugin.js\"));\n e.addPlugin(new SoundsPlugin(engine));\n });\n}\n\n\n//# sourceURL=webpack://@tsparticles/plugin-sounds/./dist/browser/index.js?\n}");
48
+
49
49
  /***/ }
50
50
 
51
51
  /******/ });
@@ -60,12 +60,6 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
60
60
  /******/ if (cachedModule !== undefined) {
61
61
  /******/ return cachedModule.exports;
62
62
  /******/ }
63
- /******/ // Check if module exists (development only)
64
- /******/ if (__webpack_modules__[moduleId] === undefined) {
65
- /******/ var e = new Error("Cannot find module '" + moduleId + "'");
66
- /******/ e.code = 'MODULE_NOT_FOUND';
67
- /******/ throw e;
68
- /******/ }
69
63
  /******/ // Create a new module (and put it into the cache)
70
64
  /******/ var module = __webpack_module_cache__[moduleId] = {
71
65
  /******/ // no module.id needed
@@ -74,6 +68,12 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
74
68
  /******/ };
75
69
  /******/
76
70
  /******/ // Execute the module function
71
+ /******/ if (!(moduleId in __webpack_modules__)) {
72
+ /******/ delete __webpack_module_cache__[moduleId];
73
+ /******/ var e = new Error("Cannot find module '" + moduleId + "'");
74
+ /******/ e.code = 'MODULE_NOT_FOUND';
75
+ /******/ throw e;
76
+ /******/ }
77
77
  /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
78
78
  /******/
79
79
  /******/ // Return the exports of the module
@@ -118,6 +118,18 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
118
118
  /******/ };
119
119
  /******/ })();
120
120
  /******/
121
+ /******/ /* webpack/runtime/global */
122
+ /******/ (() => {
123
+ /******/ __webpack_require__.g = (function() {
124
+ /******/ if (typeof globalThis === 'object') return globalThis;
125
+ /******/ try {
126
+ /******/ return this || new Function('return this')();
127
+ /******/ } catch (e) {
128
+ /******/ if (typeof window === 'object') return window;
129
+ /******/ }
130
+ /******/ })();
131
+ /******/ })();
132
+ /******/
121
133
  /******/ /* webpack/runtime/hasOwnProperty shorthand */
122
134
  /******/ (() => {
123
135
  /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
@@ -182,8 +194,8 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
182
194
  /******/ /* webpack/runtime/publicPath */
183
195
  /******/ (() => {
184
196
  /******/ var scriptUrl;
185
- /******/ if (globalThis.importScripts) scriptUrl = globalThis.location + "";
186
- /******/ var document = globalThis.document;
197
+ /******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
198
+ /******/ var document = __webpack_require__.g.document;
187
199
  /******/ if (!scriptUrl && document) {
188
200
  /******/ if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT')
189
201
  /******/ scriptUrl = document.currentScript.src;
@@ -1,2 +1,2 @@
1
- /*! For license information please see tsparticles.plugin.sounds.min.js.LICENSE.txt */
2
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var r="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,(e=>(()=>{var t,r,o={303(t){t.exports=e}},n={};function i(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return o[e](r,r.exports,i),r.exports}i.m=o,i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.f={},i.e=e=>Promise.all(Object.keys(i.f).reduce(((t,r)=>(i.f[r](e,t),t)),[])),i.u=e=>e+".min.js",i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),t={},r="@tsparticles/plugin-sounds:",i.l=(e,o,n,a)=>{if(t[e])t[e].push(o);else{var s,l;if(void 0!==n)for(var p=document.getElementsByTagName("script"),u=0;u<p.length;u++){var c=p[u];if(c.getAttribute("src")==e||c.getAttribute("data-webpack")==r+n){s=c;break}}s||(l=!0,(s=document.createElement("script")).charset="utf-8",i.nc&&s.setAttribute("nonce",i.nc),s.setAttribute("data-webpack",r+n),s.src=e),t[e]=[o];var d=(r,o)=>{s.onerror=s.onload=null,clearTimeout(f);var n=t[e];if(delete t[e],s.parentNode&&s.parentNode.removeChild(s),n&&n.forEach((e=>e(o))),r)return r(o)},f=setTimeout(d.bind(null,void 0,{type:"timeout",target:s}),12e4);s.onerror=d.bind(null,s.onerror),s.onload=d.bind(null,s.onload),l&&document.head.appendChild(s)}},i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;globalThis.importScripts&&(e=globalThis.location+"");var t=globalThis.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var o=r.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=r[o--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),i.p=e})(),(()=>{var e={848:0};i.f.j=(t,r)=>{var o=i.o(e,t)?e[t]:void 0;if(0!==o)if(o)r.push(o[2]);else{var n=new Promise(((r,n)=>o=e[t]=[r,n]));r.push(o[2]=n);var a=i.p+i.u(t),s=new Error;i.l(a,(r=>{if(i.o(e,t)&&(0!==(o=e[t])&&(e[t]=void 0),o)){var n=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;s.message="Loading chunk "+t+" failed.\n("+n+": "+a+")",s.name="ChunkLoadError",s.type=n,s.request=a,o[1](s)}}),"chunk-"+t,t)}};var t=(t,r)=>{var o,n,[a,s,l]=r,p=0;if(a.some((t=>0!==e[t]))){for(o in s)i.o(s,o)&&(i.m[o]=s[o]);if(l)l(i)}for(t&&t(r);p<a.length;p++)n=a[p],i.o(e,n)&&e[n]&&e[n][0](),e[n]=0},r=this.webpackChunk_tsparticles_plugin_sounds=this.webpackChunk_tsparticles_plugin_sounds||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var a={};async function s(e){e.checkVersion("4.0.0-alpha.8"),await e.register((async t=>{const{SoundsPlugin:r}=await i.e(296).then(i.bind(i,296));t.addPlugin(new r(e))}))}return i.r(a),i.d(a,{loadSoundsPlugin:()=>s}),a})()));
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var r="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,e=>(()=>{"use strict";var t,r,o,n={303(t){t.exports=e}},i={};function a(e){var t=i[e];if(void 0!==t)return t.exports;var r=i[e]={exports:{}};return n[e](r,r.exports,a),r.exports}a.m=n,a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.f={},a.e=e=>Promise.all(Object.keys(a.f).reduce((t,r)=>(a.f[r](e,t),t),[])),a.u=e=>""+e+".min.js",a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s={},a.l=(e,t,r,o)=>{if(s[e])return void s[e].push(t);if(void 0!==r)for(var n,i,u=document.getElementsByTagName("script"),c=0;c<u.length;c++){var l=u[c];if(l.getAttribute("src")==e||l.getAttribute("data-webpack")=="@tsparticles/plugin-sounds:"+r){n=l;break}}n||(i=!0,(n=document.createElement("script")).charset="utf-8",a.nc&&n.setAttribute("nonce",a.nc),n.setAttribute("data-webpack","@tsparticles/plugin-sounds:"+r),n.src=e),s[e]=[t];var p=(t,r)=>{n.onerror=n.onload=null,clearTimeout(d);var o=s[e];if(delete s[e],n.parentNode&&n.parentNode.removeChild(n),o&&o.forEach(e=>e(r)),t)return t(r)},d=setTimeout(p.bind(null,void 0,{type:"timeout",target:n}),12e4);n.onerror=p.bind(null,n.onerror),n.onload=p.bind(null,n.onload),i&&document.head.appendChild(n)},a.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.g.importScripts&&(u=a.g.location+"");var s,u,c=a.g.document;if(!u&&c&&(c.currentScript&&"SCRIPT"===c.currentScript.tagName.toUpperCase()&&(u=c.currentScript.src),!u)){var l=c.getElementsByTagName("script");if(l.length)for(var p=l.length-1;p>-1&&(!u||!/^http(s?):/.test(u));)u=l[p--].src}if(!u)throw Error("Automatic publicPath is not supported in this browser");a.p=u=u.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),t={848:0},a.f.j=(e,r)=>{var o=a.o(t,e)?t[e]:void 0;if(0!==o)if(o)r.push(o[2]);else{var n=new Promise((r,n)=>o=t[e]=[r,n]);r.push(o[2]=n);var i=a.p+a.u(e),s=Error();a.l(i,r=>{if(a.o(t,e)&&(0!==(o=t[e])&&(t[e]=void 0),o)){var n=r&&("load"===r.type?"missing":r.type),i=r&&r.target&&r.target.src;s.message="Loading chunk "+e+` failed.
2
+ (`+n+": "+i+")",s.name="ChunkLoadError",s.type=n,s.request=i,o[1](s)}},"chunk-"+e,e)}},r=(e,r)=>{var o,n,[i,s,u]=r,c=0;if(i.some(e=>0!==t[e])){for(o in s)a.o(s,o)&&(a.m[o]=s[o]);u&&u(a)}for(e&&e(r);c<i.length;c++)n=i[c],a.o(t,n)&&t[n]&&t[n][0](),t[n]=0},(o=this.webpackChunk_tsparticles_plugin_sounds=this.webpackChunk_tsparticles_plugin_sounds||[]).forEach(r.bind(null,0)),o.push=r.bind(null,o.push.bind(o));var d={};async function f(e){e.checkVersion("4.0.0-beta.0"),await e.register(async t=>{let{SoundsPlugin:r}=await a.e(30).then(a.bind(a,30));t.addPlugin(new r(e))})}return a.r(d),a.d(d,{loadSoundsPlugin:()=>f}),d})());
@@ -1,7 +1,7 @@
1
1
  import { type Container, type Engine, type IContainerPlugin, type IPlugin, type RecursivePartial } from "@tsparticles/engine";
2
2
  import type { ISoundsOptions, SoundsOptions } from "./types.js";
3
3
  export declare class SoundsPlugin implements IPlugin {
4
- readonly id: string;
4
+ readonly id = "sounds";
5
5
  private readonly _engine;
6
6
  constructor(engine: Engine);
7
7
  getPlugin(container: Container): Promise<IContainerPlugin>;