@tsparticles/plugin-sounds 3.0.1 → 3.0.2
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/browser/SoundsInstance.js +41 -36
- package/cjs/SoundsInstance.js +41 -36
- package/esm/SoundsInstance.js +41 -36
- package/package.json +2 -2
- package/report.html +2 -2
- package/tsparticles.plugin.sounds.js +40 -35
- package/tsparticles.plugin.sounds.min.js +1 -1
- package/tsparticles.plugin.sounds.min.js.LICENSE.txt +1 -1
- package/umd/SoundsInstance.js +41 -36
|
@@ -42,35 +42,38 @@ export class SoundsInstance {
|
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
44
|
for (const event of soundsOptions.events) {
|
|
45
|
-
const cb =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
executeOnSingleOrMultiple(event.event, (item) => {
|
|
51
|
-
this._engine.removeEventListener(item, cb);
|
|
52
|
-
});
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if (event.filter && !event.filter(args)) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
if (event.audio) {
|
|
59
|
-
this._playBuffer(itemFromSingleOrMultiple(event.audio));
|
|
60
|
-
}
|
|
61
|
-
else if (event.melodies) {
|
|
62
|
-
const melody = itemFromArray(event.melodies);
|
|
63
|
-
if (melody.melodies.length) {
|
|
64
|
-
await Promise.allSettled(melody.melodies.map((m) => this._playNote(m.notes, 0, melody.loop)));
|
|
45
|
+
const cb = (args) => {
|
|
46
|
+
(async () => {
|
|
47
|
+
const filterNotValid = event.filter && !event.filter(args);
|
|
48
|
+
if (this._container !== args.container) {
|
|
49
|
+
return;
|
|
65
50
|
}
|
|
66
|
-
|
|
67
|
-
|
|
51
|
+
if (!this._container || this._container.muted || this._container.destroyed) {
|
|
52
|
+
executeOnSingleOrMultiple(event.event, (item) => {
|
|
53
|
+
this._engine.removeEventListener(item, cb);
|
|
54
|
+
});
|
|
55
|
+
return;
|
|
68
56
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
57
|
+
if (filterNotValid) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (event.audio) {
|
|
61
|
+
this._playBuffer(itemFromSingleOrMultiple(event.audio));
|
|
62
|
+
}
|
|
63
|
+
else if (event.melodies) {
|
|
64
|
+
const melody = itemFromArray(event.melodies);
|
|
65
|
+
if (melody.melodies.length) {
|
|
66
|
+
await Promise.allSettled(melody.melodies.map((m) => this._playNote(m.notes, 0, melody.loop)));
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
await this._playNote(melody.notes, 0, melody.loop);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else if (event.notes) {
|
|
73
|
+
const note = itemFromArray(event.notes);
|
|
74
|
+
await this._playNote([note], 0, false);
|
|
75
|
+
}
|
|
76
|
+
})();
|
|
74
77
|
};
|
|
75
78
|
executeOnSingleOrMultiple(event.event, (item) => {
|
|
76
79
|
this._engine.addEventListener(item, cb);
|
|
@@ -214,17 +217,19 @@ export class SoundsInstance {
|
|
|
214
217
|
unmuteImg.style.display = container.muted ? "none" : "block";
|
|
215
218
|
}
|
|
216
219
|
};
|
|
217
|
-
this._updateMuteStatus = () => {
|
|
220
|
+
this._updateMuteStatus = async () => {
|
|
218
221
|
const container = this._container;
|
|
219
222
|
if (container.muted) {
|
|
223
|
+
await container.audioContext?.suspend();
|
|
220
224
|
this._mute();
|
|
221
225
|
}
|
|
222
226
|
else {
|
|
227
|
+
await container.audioContext?.resume();
|
|
223
228
|
this._unmute();
|
|
224
229
|
this._playMuteSound();
|
|
225
230
|
}
|
|
226
231
|
};
|
|
227
|
-
this._updateVolume = () => {
|
|
232
|
+
this._updateVolume = async () => {
|
|
228
233
|
const container = this._container, soundsOptions = container.actualOptions.sounds;
|
|
229
234
|
if (!soundsOptions?.enable) {
|
|
230
235
|
return;
|
|
@@ -242,7 +247,7 @@ export class SoundsInstance {
|
|
|
242
247
|
}
|
|
243
248
|
if (stateChanged) {
|
|
244
249
|
this._updateMuteIcons();
|
|
245
|
-
this._updateMuteStatus();
|
|
250
|
+
await this._updateMuteStatus();
|
|
246
251
|
}
|
|
247
252
|
if (this._gain?.gain) {
|
|
248
253
|
this._gain.gain.value = this._volume / 100;
|
|
@@ -288,10 +293,10 @@ export class SoundsInstance {
|
|
|
288
293
|
top: canvas.offsetTop,
|
|
289
294
|
right: canvas.offsetLeft + canvas.offsetWidth,
|
|
290
295
|
}, { mute, unmute, volumeDown, volumeUp } = soundsOptions.icons, margin = 10;
|
|
291
|
-
const toggleMute = () => {
|
|
296
|
+
const toggleMute = async () => {
|
|
292
297
|
container.muted = !container.muted;
|
|
293
298
|
this._updateMuteIcons();
|
|
294
|
-
this._updateMuteStatus();
|
|
299
|
+
await this._updateMuteStatus();
|
|
295
300
|
};
|
|
296
301
|
this._muteImg = initImage({
|
|
297
302
|
container,
|
|
@@ -321,12 +326,12 @@ export class SoundsInstance {
|
|
|
321
326
|
iconOptions: volumeDown,
|
|
322
327
|
margin,
|
|
323
328
|
rightOffsets: [volumeUp.width],
|
|
324
|
-
clickCb: () => {
|
|
329
|
+
clickCb: async () => {
|
|
325
330
|
if (container.muted) {
|
|
326
331
|
this._volume = 0;
|
|
327
332
|
}
|
|
328
333
|
this._volume -= soundsOptions.volume.step;
|
|
329
|
-
this._updateVolume();
|
|
334
|
+
await this._updateVolume();
|
|
330
335
|
},
|
|
331
336
|
});
|
|
332
337
|
this._volumeUpImg = initImage({
|
|
@@ -337,12 +342,12 @@ export class SoundsInstance {
|
|
|
337
342
|
iconOptions: volumeUp,
|
|
338
343
|
margin,
|
|
339
344
|
rightOffsets: [],
|
|
340
|
-
clickCb: () => {
|
|
345
|
+
clickCb: async () => {
|
|
341
346
|
if (container.muted) {
|
|
342
347
|
this._volume = 0;
|
|
343
348
|
}
|
|
344
349
|
this._volume += soundsOptions.volume.step;
|
|
345
|
-
this._updateVolume();
|
|
350
|
+
await this._updateVolume();
|
|
346
351
|
},
|
|
347
352
|
});
|
|
348
353
|
}
|
package/cjs/SoundsInstance.js
CHANGED
|
@@ -45,35 +45,38 @@ class SoundsInstance {
|
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
47
|
for (const event of soundsOptions.events) {
|
|
48
|
-
const cb =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
(0, engine_1.executeOnSingleOrMultiple)(event.event, (item) => {
|
|
54
|
-
this._engine.removeEventListener(item, cb);
|
|
55
|
-
});
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
if (event.filter && !event.filter(args)) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
if (event.audio) {
|
|
62
|
-
this._playBuffer((0, engine_1.itemFromSingleOrMultiple)(event.audio));
|
|
63
|
-
}
|
|
64
|
-
else if (event.melodies) {
|
|
65
|
-
const melody = (0, engine_1.itemFromArray)(event.melodies);
|
|
66
|
-
if (melody.melodies.length) {
|
|
67
|
-
await Promise.allSettled(melody.melodies.map((m) => this._playNote(m.notes, 0, melody.loop)));
|
|
48
|
+
const cb = (args) => {
|
|
49
|
+
(async () => {
|
|
50
|
+
const filterNotValid = event.filter && !event.filter(args);
|
|
51
|
+
if (this._container !== args.container) {
|
|
52
|
+
return;
|
|
68
53
|
}
|
|
69
|
-
|
|
70
|
-
|
|
54
|
+
if (!this._container || this._container.muted || this._container.destroyed) {
|
|
55
|
+
(0, engine_1.executeOnSingleOrMultiple)(event.event, (item) => {
|
|
56
|
+
this._engine.removeEventListener(item, cb);
|
|
57
|
+
});
|
|
58
|
+
return;
|
|
71
59
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
60
|
+
if (filterNotValid) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (event.audio) {
|
|
64
|
+
this._playBuffer((0, engine_1.itemFromSingleOrMultiple)(event.audio));
|
|
65
|
+
}
|
|
66
|
+
else if (event.melodies) {
|
|
67
|
+
const melody = (0, engine_1.itemFromArray)(event.melodies);
|
|
68
|
+
if (melody.melodies.length) {
|
|
69
|
+
await Promise.allSettled(melody.melodies.map((m) => this._playNote(m.notes, 0, melody.loop)));
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
await this._playNote(melody.notes, 0, melody.loop);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else if (event.notes) {
|
|
76
|
+
const note = (0, engine_1.itemFromArray)(event.notes);
|
|
77
|
+
await this._playNote([note], 0, false);
|
|
78
|
+
}
|
|
79
|
+
})();
|
|
77
80
|
};
|
|
78
81
|
(0, engine_1.executeOnSingleOrMultiple)(event.event, (item) => {
|
|
79
82
|
this._engine.addEventListener(item, cb);
|
|
@@ -217,17 +220,19 @@ class SoundsInstance {
|
|
|
217
220
|
unmuteImg.style.display = container.muted ? "none" : "block";
|
|
218
221
|
}
|
|
219
222
|
};
|
|
220
|
-
this._updateMuteStatus = () => {
|
|
223
|
+
this._updateMuteStatus = async () => {
|
|
221
224
|
const container = this._container;
|
|
222
225
|
if (container.muted) {
|
|
226
|
+
await container.audioContext?.suspend();
|
|
223
227
|
this._mute();
|
|
224
228
|
}
|
|
225
229
|
else {
|
|
230
|
+
await container.audioContext?.resume();
|
|
226
231
|
this._unmute();
|
|
227
232
|
this._playMuteSound();
|
|
228
233
|
}
|
|
229
234
|
};
|
|
230
|
-
this._updateVolume = () => {
|
|
235
|
+
this._updateVolume = async () => {
|
|
231
236
|
const container = this._container, soundsOptions = container.actualOptions.sounds;
|
|
232
237
|
if (!soundsOptions?.enable) {
|
|
233
238
|
return;
|
|
@@ -245,7 +250,7 @@ class SoundsInstance {
|
|
|
245
250
|
}
|
|
246
251
|
if (stateChanged) {
|
|
247
252
|
this._updateMuteIcons();
|
|
248
|
-
this._updateMuteStatus();
|
|
253
|
+
await this._updateMuteStatus();
|
|
249
254
|
}
|
|
250
255
|
if (this._gain?.gain) {
|
|
251
256
|
this._gain.gain.value = this._volume / 100;
|
|
@@ -291,10 +296,10 @@ class SoundsInstance {
|
|
|
291
296
|
top: canvas.offsetTop,
|
|
292
297
|
right: canvas.offsetLeft + canvas.offsetWidth,
|
|
293
298
|
}, { mute, unmute, volumeDown, volumeUp } = soundsOptions.icons, margin = 10;
|
|
294
|
-
const toggleMute = () => {
|
|
299
|
+
const toggleMute = async () => {
|
|
295
300
|
container.muted = !container.muted;
|
|
296
301
|
this._updateMuteIcons();
|
|
297
|
-
this._updateMuteStatus();
|
|
302
|
+
await this._updateMuteStatus();
|
|
298
303
|
};
|
|
299
304
|
this._muteImg = initImage({
|
|
300
305
|
container,
|
|
@@ -324,12 +329,12 @@ class SoundsInstance {
|
|
|
324
329
|
iconOptions: volumeDown,
|
|
325
330
|
margin,
|
|
326
331
|
rightOffsets: [volumeUp.width],
|
|
327
|
-
clickCb: () => {
|
|
332
|
+
clickCb: async () => {
|
|
328
333
|
if (container.muted) {
|
|
329
334
|
this._volume = 0;
|
|
330
335
|
}
|
|
331
336
|
this._volume -= soundsOptions.volume.step;
|
|
332
|
-
this._updateVolume();
|
|
337
|
+
await this._updateVolume();
|
|
333
338
|
},
|
|
334
339
|
});
|
|
335
340
|
this._volumeUpImg = initImage({
|
|
@@ -340,12 +345,12 @@ class SoundsInstance {
|
|
|
340
345
|
iconOptions: volumeUp,
|
|
341
346
|
margin,
|
|
342
347
|
rightOffsets: [],
|
|
343
|
-
clickCb: () => {
|
|
348
|
+
clickCb: async () => {
|
|
344
349
|
if (container.muted) {
|
|
345
350
|
this._volume = 0;
|
|
346
351
|
}
|
|
347
352
|
this._volume += soundsOptions.volume.step;
|
|
348
|
-
this._updateVolume();
|
|
353
|
+
await this._updateVolume();
|
|
349
354
|
},
|
|
350
355
|
});
|
|
351
356
|
}
|
package/esm/SoundsInstance.js
CHANGED
|
@@ -42,35 +42,38 @@ export class SoundsInstance {
|
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
44
|
for (const event of soundsOptions.events) {
|
|
45
|
-
const cb =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
executeOnSingleOrMultiple(event.event, (item) => {
|
|
51
|
-
this._engine.removeEventListener(item, cb);
|
|
52
|
-
});
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if (event.filter && !event.filter(args)) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
if (event.audio) {
|
|
59
|
-
this._playBuffer(itemFromSingleOrMultiple(event.audio));
|
|
60
|
-
}
|
|
61
|
-
else if (event.melodies) {
|
|
62
|
-
const melody = itemFromArray(event.melodies);
|
|
63
|
-
if (melody.melodies.length) {
|
|
64
|
-
await Promise.allSettled(melody.melodies.map((m) => this._playNote(m.notes, 0, melody.loop)));
|
|
45
|
+
const cb = (args) => {
|
|
46
|
+
(async () => {
|
|
47
|
+
const filterNotValid = event.filter && !event.filter(args);
|
|
48
|
+
if (this._container !== args.container) {
|
|
49
|
+
return;
|
|
65
50
|
}
|
|
66
|
-
|
|
67
|
-
|
|
51
|
+
if (!this._container || this._container.muted || this._container.destroyed) {
|
|
52
|
+
executeOnSingleOrMultiple(event.event, (item) => {
|
|
53
|
+
this._engine.removeEventListener(item, cb);
|
|
54
|
+
});
|
|
55
|
+
return;
|
|
68
56
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
57
|
+
if (filterNotValid) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (event.audio) {
|
|
61
|
+
this._playBuffer(itemFromSingleOrMultiple(event.audio));
|
|
62
|
+
}
|
|
63
|
+
else if (event.melodies) {
|
|
64
|
+
const melody = itemFromArray(event.melodies);
|
|
65
|
+
if (melody.melodies.length) {
|
|
66
|
+
await Promise.allSettled(melody.melodies.map((m) => this._playNote(m.notes, 0, melody.loop)));
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
await this._playNote(melody.notes, 0, melody.loop);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else if (event.notes) {
|
|
73
|
+
const note = itemFromArray(event.notes);
|
|
74
|
+
await this._playNote([note], 0, false);
|
|
75
|
+
}
|
|
76
|
+
})();
|
|
74
77
|
};
|
|
75
78
|
executeOnSingleOrMultiple(event.event, (item) => {
|
|
76
79
|
this._engine.addEventListener(item, cb);
|
|
@@ -214,17 +217,19 @@ export class SoundsInstance {
|
|
|
214
217
|
unmuteImg.style.display = container.muted ? "none" : "block";
|
|
215
218
|
}
|
|
216
219
|
};
|
|
217
|
-
this._updateMuteStatus = () => {
|
|
220
|
+
this._updateMuteStatus = async () => {
|
|
218
221
|
const container = this._container;
|
|
219
222
|
if (container.muted) {
|
|
223
|
+
await container.audioContext?.suspend();
|
|
220
224
|
this._mute();
|
|
221
225
|
}
|
|
222
226
|
else {
|
|
227
|
+
await container.audioContext?.resume();
|
|
223
228
|
this._unmute();
|
|
224
229
|
this._playMuteSound();
|
|
225
230
|
}
|
|
226
231
|
};
|
|
227
|
-
this._updateVolume = () => {
|
|
232
|
+
this._updateVolume = async () => {
|
|
228
233
|
const container = this._container, soundsOptions = container.actualOptions.sounds;
|
|
229
234
|
if (!soundsOptions?.enable) {
|
|
230
235
|
return;
|
|
@@ -242,7 +247,7 @@ export class SoundsInstance {
|
|
|
242
247
|
}
|
|
243
248
|
if (stateChanged) {
|
|
244
249
|
this._updateMuteIcons();
|
|
245
|
-
this._updateMuteStatus();
|
|
250
|
+
await this._updateMuteStatus();
|
|
246
251
|
}
|
|
247
252
|
if (this._gain?.gain) {
|
|
248
253
|
this._gain.gain.value = this._volume / 100;
|
|
@@ -288,10 +293,10 @@ export class SoundsInstance {
|
|
|
288
293
|
top: canvas.offsetTop,
|
|
289
294
|
right: canvas.offsetLeft + canvas.offsetWidth,
|
|
290
295
|
}, { mute, unmute, volumeDown, volumeUp } = soundsOptions.icons, margin = 10;
|
|
291
|
-
const toggleMute = () => {
|
|
296
|
+
const toggleMute = async () => {
|
|
292
297
|
container.muted = !container.muted;
|
|
293
298
|
this._updateMuteIcons();
|
|
294
|
-
this._updateMuteStatus();
|
|
299
|
+
await this._updateMuteStatus();
|
|
295
300
|
};
|
|
296
301
|
this._muteImg = initImage({
|
|
297
302
|
container,
|
|
@@ -321,12 +326,12 @@ export class SoundsInstance {
|
|
|
321
326
|
iconOptions: volumeDown,
|
|
322
327
|
margin,
|
|
323
328
|
rightOffsets: [volumeUp.width],
|
|
324
|
-
clickCb: () => {
|
|
329
|
+
clickCb: async () => {
|
|
325
330
|
if (container.muted) {
|
|
326
331
|
this._volume = 0;
|
|
327
332
|
}
|
|
328
333
|
this._volume -= soundsOptions.volume.step;
|
|
329
|
-
this._updateVolume();
|
|
334
|
+
await this._updateVolume();
|
|
330
335
|
},
|
|
331
336
|
});
|
|
332
337
|
this._volumeUpImg = initImage({
|
|
@@ -337,12 +342,12 @@ export class SoundsInstance {
|
|
|
337
342
|
iconOptions: volumeUp,
|
|
338
343
|
margin,
|
|
339
344
|
rightOffsets: [],
|
|
340
|
-
clickCb: () => {
|
|
345
|
+
clickCb: async () => {
|
|
341
346
|
if (container.muted) {
|
|
342
347
|
this._volume = 0;
|
|
343
348
|
}
|
|
344
349
|
this._volume += soundsOptions.volume.step;
|
|
345
|
-
this._updateVolume();
|
|
350
|
+
await this._updateVolume();
|
|
346
351
|
},
|
|
347
352
|
});
|
|
348
353
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/plugin-sounds",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
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": "^3.0.
|
|
89
|
+
"@tsparticles/engine": "^3.0.2"
|
|
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 [6 Dec 2023 at
|
|
6
|
+
<title>@tsparticles/plugin-sounds [6 Dec 2023 at 17:43]</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>
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
<body>
|
|
32
32
|
<div id="app"></div>
|
|
33
33
|
<script>
|
|
34
|
-
window.chartData = [{"label":"tsparticles.plugin.sounds.js","isAsset":true,"statSize":
|
|
34
|
+
window.chartData = [{"label":"tsparticles.plugin.sounds.js","isAsset":true,"statSize":24461,"parsedSize":28475,"gzipSize":6915,"groups":[{"label":"dist/browser","path":"./dist/browser","statSize":24419,"groups":[{"id":810,"label":"index.js + 10 modules (concatenated)","path":"./dist/browser/index.js + 10 modules (concatenated)","statSize":24419,"parsedSize":28475,"gzipSize":6915,"concatenated":true,"groups":[{"label":"dist/browser","path":"./dist/browser/index.js + 10 modules (concatenated)/dist/browser","statSize":24419,"groups":[{"id":null,"label":"index.js","path":"./dist/browser/index.js + 10 modules (concatenated)/dist/browser/index.js","statSize":804,"parsedSize":937,"gzipSize":227,"inaccurateSizes":true},{"id":null,"label":"SoundsInstance.js","path":"./dist/browser/index.js + 10 modules (concatenated)/dist/browser/SoundsInstance.js","statSize":11967,"parsedSize":13954,"gzipSize":3388,"inaccurateSizes":true},{"label":"Options/Classes","path":"./dist/browser/index.js + 10 modules (concatenated)/dist/browser/Options/Classes","statSize":10207,"groups":[{"id":null,"label":"Sounds.js","path":"./dist/browser/index.js + 10 modules (concatenated)/dist/browser/Options/Classes/Sounds.js","statSize":739,"parsedSize":861,"gzipSize":209,"inaccurateSizes":true},{"id":null,"label":"SoundsIcons.js","path":"./dist/browser/index.js + 10 modules (concatenated)/dist/browser/Options/Classes/SoundsIcons.js","statSize":5666,"parsedSize":6607,"gzipSize":1604,"inaccurateSizes":true},{"id":null,"label":"SoundsVolume.js","path":"./dist/browser/index.js + 10 modules (concatenated)/dist/browser/Options/Classes/SoundsVolume.js","statSize":619,"parsedSize":721,"gzipSize":175,"inaccurateSizes":true},{"id":null,"label":"SoundsEvent.js","path":"./dist/browser/index.js + 10 modules (concatenated)/dist/browser/Options/Classes/SoundsEvent.js","statSize":1343,"parsedSize":1566,"gzipSize":380,"inaccurateSizes":true},{"id":null,"label":"SoundsIcon.js","path":"./dist/browser/index.js + 10 modules (concatenated)/dist/browser/Options/Classes/SoundsIcon.js","statSize":434,"parsedSize":506,"gzipSize":122,"inaccurateSizes":true},{"id":null,"label":"SoundsAudio.js","path":"./dist/browser/index.js + 10 modules (concatenated)/dist/browser/Options/Classes/SoundsAudio.js","statSize":441,"parsedSize":514,"gzipSize":124,"inaccurateSizes":true},{"id":null,"label":"SoundsNote.js","path":"./dist/browser/index.js + 10 modules (concatenated)/dist/browser/Options/Classes/SoundsNote.js","statSize":306,"parsedSize":356,"gzipSize":86,"inaccurateSizes":true},{"id":null,"label":"SoundsMelody.js","path":"./dist/browser/index.js + 10 modules (concatenated)/dist/browser/Options/Classes/SoundsMelody.js","statSize":659,"parsedSize":768,"gzipSize":186,"inaccurateSizes":true}],"parsedSize":11902,"gzipSize":2890,"inaccurateSizes":true},{"id":null,"label":"utils.js","path":"./dist/browser/index.js + 10 modules (concatenated)/dist/browser/utils.js","statSize":1441,"parsedSize":1680,"gzipSize":408,"inaccurateSizes":true}],"parsedSize":28475,"gzipSize":6915,"inaccurateSizes":true}]}],"parsedSize":28475,"gzipSize":6915},{"label":"engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles","path":"./engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles","statSize":42,"groups":[{"id":533,"label":"engine\",\"root\":\"window\"}","path":"./engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles/engine\",\"root\":\"window\"}","statSize":42}],"parsedSize":0,"gzipSize":0}],"isInitialByEntrypoint":{"tsparticles.plugin.sounds":true}}];
|
|
35
35
|
window.entrypoints = ["tsparticles.plugin.sounds","tsparticles.plugin.sounds.min"];
|
|
36
36
|
window.defaultSizes = "parsed";
|
|
37
37
|
</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
|
-
* v3.0.
|
|
7
|
+
* v3.0.2
|
|
8
8
|
*/
|
|
9
9
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
10
10
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
@@ -452,32 +452,35 @@ class SoundsInstance {
|
|
|
452
452
|
return;
|
|
453
453
|
}
|
|
454
454
|
for (const event of soundsOptions.events) {
|
|
455
|
-
const cb =
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
(0,engine_root_window_.executeOnSingleOrMultiple)(event.event, item => {
|
|
461
|
-
this._engine.removeEventListener(item, cb);
|
|
462
|
-
});
|
|
463
|
-
return;
|
|
464
|
-
}
|
|
465
|
-
if (event.filter && !event.filter(args)) {
|
|
466
|
-
return;
|
|
467
|
-
}
|
|
468
|
-
if (event.audio) {
|
|
469
|
-
this._playBuffer((0,engine_root_window_.itemFromSingleOrMultiple)(event.audio));
|
|
470
|
-
} else if (event.melodies) {
|
|
471
|
-
const melody = (0,engine_root_window_.itemFromArray)(event.melodies);
|
|
472
|
-
if (melody.melodies.length) {
|
|
473
|
-
await Promise.allSettled(melody.melodies.map(m => this._playNote(m.notes, 0, melody.loop)));
|
|
474
|
-
} else {
|
|
475
|
-
await this._playNote(melody.notes, 0, melody.loop);
|
|
455
|
+
const cb = args => {
|
|
456
|
+
(async () => {
|
|
457
|
+
const filterNotValid = event.filter && !event.filter(args);
|
|
458
|
+
if (this._container !== args.container) {
|
|
459
|
+
return;
|
|
476
460
|
}
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
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
|
+
})();
|
|
481
484
|
};
|
|
482
485
|
(0,engine_root_window_.executeOnSingleOrMultiple)(event.event, item => {
|
|
483
486
|
this._engine.addEventListener(item, cb);
|
|
@@ -630,16 +633,18 @@ class SoundsInstance {
|
|
|
630
633
|
unmuteImg.style.display = container.muted ? "none" : "block";
|
|
631
634
|
}
|
|
632
635
|
};
|
|
633
|
-
this._updateMuteStatus = () => {
|
|
636
|
+
this._updateMuteStatus = async () => {
|
|
634
637
|
const container = this._container;
|
|
635
638
|
if (container.muted) {
|
|
639
|
+
await container.audioContext?.suspend();
|
|
636
640
|
this._mute();
|
|
637
641
|
} else {
|
|
642
|
+
await container.audioContext?.resume();
|
|
638
643
|
this._unmute();
|
|
639
644
|
this._playMuteSound();
|
|
640
645
|
}
|
|
641
646
|
};
|
|
642
|
-
this._updateVolume = () => {
|
|
647
|
+
this._updateVolume = async () => {
|
|
643
648
|
const container = this._container,
|
|
644
649
|
soundsOptions = container.actualOptions.sounds;
|
|
645
650
|
if (!soundsOptions?.enable) {
|
|
@@ -657,7 +662,7 @@ class SoundsInstance {
|
|
|
657
662
|
}
|
|
658
663
|
if (stateChanged) {
|
|
659
664
|
this._updateMuteIcons();
|
|
660
|
-
this._updateMuteStatus();
|
|
665
|
+
await this._updateMuteStatus();
|
|
661
666
|
}
|
|
662
667
|
if (this._gain?.gain) {
|
|
663
668
|
this._gain.gain.value = this._volume / 100;
|
|
@@ -715,10 +720,10 @@ class SoundsInstance {
|
|
|
715
720
|
volumeUp
|
|
716
721
|
} = soundsOptions.icons,
|
|
717
722
|
margin = 10;
|
|
718
|
-
const toggleMute = () => {
|
|
723
|
+
const toggleMute = async () => {
|
|
719
724
|
container.muted = !container.muted;
|
|
720
725
|
this._updateMuteIcons();
|
|
721
|
-
this._updateMuteStatus();
|
|
726
|
+
await this._updateMuteStatus();
|
|
722
727
|
};
|
|
723
728
|
this._muteImg = initImage({
|
|
724
729
|
container,
|
|
@@ -748,12 +753,12 @@ class SoundsInstance {
|
|
|
748
753
|
iconOptions: volumeDown,
|
|
749
754
|
margin,
|
|
750
755
|
rightOffsets: [volumeUp.width],
|
|
751
|
-
clickCb: () => {
|
|
756
|
+
clickCb: async () => {
|
|
752
757
|
if (container.muted) {
|
|
753
758
|
this._volume = 0;
|
|
754
759
|
}
|
|
755
760
|
this._volume -= soundsOptions.volume.step;
|
|
756
|
-
this._updateVolume();
|
|
761
|
+
await this._updateVolume();
|
|
757
762
|
}
|
|
758
763
|
});
|
|
759
764
|
this._volumeUpImg = initImage({
|
|
@@ -764,12 +769,12 @@ class SoundsInstance {
|
|
|
764
769
|
iconOptions: volumeUp,
|
|
765
770
|
margin,
|
|
766
771
|
rightOffsets: [],
|
|
767
|
-
clickCb: () => {
|
|
772
|
+
clickCb: async () => {
|
|
768
773
|
if (container.muted) {
|
|
769
774
|
this._volume = 0;
|
|
770
775
|
}
|
|
771
776
|
this._volume += soundsOptions.volume.step;
|
|
772
|
-
this._updateVolume();
|
|
777
|
+
await this._updateVolume();
|
|
773
778
|
}
|
|
774
779
|
});
|
|
775
780
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see tsparticles.plugin.sounds.min.js.LICENSE.txt */
|
|
2
|
-
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],e);else{var i="object"==typeof exports?e(require("@tsparticles/engine")):e(t.window);for(var s in i)("object"==typeof exports?exports:t)[s]=i[s]}}(this,(t=>(()=>{"use strict";var e={533:e=>{e.exports=t}},i={};function s(t){var o=i[t];if(void 0!==o)return o.exports;var n=i[t]={exports:{}};return e[t](n,n.exports,s),n.exports}s.d=(t,e)=>{for(var i in e)s.o(e,i)&&!s.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{s.r(o),s.d(o,{loadSoundsPlugin:()=>g});var t=s(533);class e{constructor(){this.loop=!1,this.source=""}load(e){void 0!==e&&((0,t.isObject)(e)?(void 0!==e.loop&&(this.loop=e.loop),void 0!==e.source&&(this.source=e.source)):this.source=e)}}class i{constructor(){this.duration=500,this.value=[]}load(t){t&&(void 0!==t.duration&&(this.duration=t.duration),void 0!==t.value&&(this.value=t.value))}}class n{constructor(){this.loop=!1,this.melodies=[],this.notes=[]}load(t){void 0!==t&&(void 0!==t.loop&&(this.loop=t.loop),void 0!==t.melodies&&(this.melodies=t.melodies.map((t=>{const e=new n;return e.load(t),e}))),void 0!==t.notes&&(this.notes=t.notes.map((t=>{const e=new i;return e.load(t),e}))))}}class a{constructor(){this.event=[],this.notes=[]}load(s){s&&(void 0!==s.event&&(this.event=s.event),void 0!==s.audio&&((0,t.isArray)(s.audio)?this.audio=s.audio.map((t=>{const i=new e;return i.load(t),i})):(this.audio=new e,this.audio.load(s.audio))),void 0!==s.notes&&(this.notes=s.notes.map((t=>{const e=new i;return e.load(t),e}))),void 0!==s.melodies&&(this.melodies=s.melodies.map((t=>{const e=new n;return e.load(t),e}))),void 0!==s.filter&&((0,t.isString)(s.filter)?(0,t.isFunction)(window[s.filter])&&(this.filter=window[s.filter]):this.filter=s.filter))}}class l{constructor(){this.width=24,this.height=24}load(t){t&&(void 0!==t.path&&(this.path=t.path),void 0!==t.svg&&(this.svg=t.svg),void 0!==t.width&&(this.width=t.width),void 0!==t.height&&(this.height=t.height))}}class c{constructor(){this.mute=new l,this.unmute=new l,this.volumeDown=new l,this.volumeUp=new l,this.mute.svg='<?xml version="1.0"?>\n<svg baseProfile="tiny" height="24px" version="1.2" viewBox="0 0 24 24" width="24px"\n xml:space="preserve" xmlns="http://www.w3.org/2000/svg"\n xmlns:xlink="http://www.w3.org/1999/xlink">\n <g id="Layer_1">\n <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"/>\n </g>\n</svg>',this.unmute.svg='<?xml version="1.0"?>\n<svg baseProfile="tiny" height="24px" version="1.2" viewBox="0 0 24 24" width="24px"\n xml:space="preserve" xmlns="http://www.w3.org/2000/svg"\n xmlns:xlink="http://www.w3.org/1999/xlink">\n <g id="Layer_1">\n <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"/>\n </g>\n</svg>',this.volumeDown.svg='<?xml version="1.0"?>\n<svg baseProfile="tiny" height="24px" version="1.2" viewBox="0 0 24 24" width="24px"\n xml:space="preserve" xmlns="http://www.w3.org/2000/svg"\n xmlns:xlink="http://www.w3.org/1999/xlink">\n <g id="Layer_1">\n <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"/>\n <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"/>\n </g>\n</svg>',this.volumeUp.svg='<?xml version="1.0"?>\n<svg baseProfile="tiny" height="24px" version="1.2" viewBox="0 0 24 24" width="24px"\n xml:space="preserve" xmlns="http://www.w3.org/2000/svg"\n xmlns:xlink="http://www.w3.org/1999/xlink">\n <g id="Layer_1">\n <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"/>\n <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"/>\n <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"/>\n <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"/>\n </g>\n</svg>'}load(t){t&&(this.mute.load(t.mute),this.unmute.load(t.unmute),this.volumeDown.load(t.volumeDown),this.volumeUp.load(t.volumeUp))}}class u{constructor(){this.value=100,this.max=100,this.min=0,this.step=10}load(e){void 0!==e&&((0,t.isObject)(e)?(void 0!==e.max&&(this.max=e.max),void 0!==e.min&&(this.min=e.min),void 0!==e.step&&(this.step=e.step),void 0!==e.value&&(this.value=e.value)):this.value=e)}}class r{constructor(){this.enable=!1,this.events=[],this.icons=new c,this.volume=new u}load(t){t&&(void 0!==t.enable&&(this.enable=t.enable),void 0!==t.events&&(this.events=t.events.map((t=>{const e=new a;return e.load(t),e}))),this.icons.load(t.icons),void 0!==t.volume&&this.volume.load(t.volume))}}const d=new Map;function h(t){const e=/(([A-G]b?)(\d))|pause/i.exec(t);if(!e||!e.length)return;const i=e[2]||e[0],s=d.get(i);return s?s[parseInt(e[3]||"0")]:void 0}function p(t){const e=document.createElement("img"),{clickCb:i,container:s,display:o,iconOptions:n,margin:a,options:l,pos:c,rightOffsets:u}=t,{width:r,path:d,svg:h}=n;!function(t,e,i,s,o,n,a){t.style.userSelect="none",t.style.webkitUserSelect="none",t.style.position="absolute",t.style.top=`${e+a}px`,t.style.left=i-a-n+"px",t.style.display=s,t.style.zIndex=`${o+1}`}(e,c.top+a,c.right-(a*(u.length+1)+r+u.reduce(((t,e)=>t+e),0)),o,l.fullScreen.zIndex+1,r,a),e.src=d??(h?`data:image/svg+xml;base64,${btoa(h)}`:"");return(s.canvas.element?.parentNode||document.body).append(e),e.addEventListener("click",i),e}function m(t){t&&t.remove()}d.set("C",[16.35,32.7,65.41,130.81,261.63,523.25,1046.5,2093,4186.01]),d.set("Db",[17.32,34.65,69.3,138.59,277.18,554.37,1108.73,2217.46,4434.92]),d.set("D",[18.35,36.71,73.42,146.83,293.66,587.33,1174.66,2349.32,4698.63]),d.set("Eb",[19.45,38.89,77.78,155.56,311.13,622.25,1244.51,2489.02,4978.03]),d.set("E",[20.6,41.2,82.41,164.81,329.63,659.25,1318.51,2637.02,5274.04]),d.set("F",[21.83,43.65,87.31,174.61,349.23,698.46,1396.91,2793.83,5587.65]),d.set("Gb",[23.12,46.25,92.5,185,369.99,739.99,1479.98,2959.96,5919.91]),d.set("G",[24.5,49,98,196,392,783.99,1567.98,3135.96,6271.93]),d.set("Ab",[25.96,51.91,103.83,207.65,415.3,830.61,1661.22,3322.44,6644.88]),d.set("A",[27.5,55,110,220,440,880,1760,3520,7040]),d.set("Bb",[29.14,58.27,116.54,233.08,466.16,932.33,1864.66,3729.31,7458.62]),d.set("B",[30.87,61.74,123.47,246.94,493.88,987.77,1975.53,3951.07,7902.13]),d.set("pause",[0]);class v{constructor(e,i){this._addBuffer=t=>{const e=t.createBufferSource();return this._audioSources.push(e),e},this._addOscillator=t=>{const e=t.createOscillator();return this._audioSources.push(e),e},this._initEvents=()=>{const e=this._container,i=e.actualOptions.sounds;if(i?.enable&&e.canvas.element)for(const e of i.events){const i=async s=>{if(this._container===s.container)if(!this._container||this._container.muted||this._container.destroyed)(0,t.executeOnSingleOrMultiple)(e.event,(t=>{this._engine.removeEventListener(t,i)}));else if(!e.filter||e.filter(s))if(e.audio)this._playBuffer((0,t.itemFromSingleOrMultiple)(e.audio));else if(e.melodies){const i=(0,t.itemFromArray)(e.melodies);i.melodies.length?await Promise.allSettled(i.melodies.map((t=>this._playNote(t.notes,0,i.loop)))):await this._playNote(i.notes,0,i.loop)}else if(e.notes){const i=(0,t.itemFromArray)(e.notes);await this._playNote([i],0,!1)}};(0,t.executeOnSingleOrMultiple)(e.event,(t=>{this._engine.addEventListener(t,i)}))}},this._mute=()=>{const t=this._container;if(t.audioContext){for(const t of this._audioSources)this._removeAudioSource(t);this._gain&&this._gain.disconnect(),t.audioContext.close(),t.audioContext=void 0,this._engine.dispatchEvent("soundsMuted",{container:this._container})}},this._playBuffer=t=>{const e=this._audioMap.get(t.source);if(!e)return;const i=this._container.audioContext;if(!i)return;const s=this._addBuffer(i);s.loop=t.loop,s.buffer=e,s.connect(this._gain??i.destination),s.start()},this._playFrequency=async(t,e)=>{if(!this._container.audioContext||!this._gain)return;const i=this._addOscillator(this._container.audioContext);return i.connect(this._gain),i.type="sine",i.frequency.value=t,i.start(),new Promise((t=>{setTimeout((()=>{this._removeAudioSource(i),t()}),e)}))},this._playMuteSound=()=>{const t=this._container;if(!t.audioContext)return;const e=t.audioContext.createGain();e.connect(t.audioContext.destination),e.gain.value=0;const i=t.audioContext.createOscillator();i.connect(e),i.type="sine",i.frequency.value=1,i.start(),setTimeout((()=>{i.stop(),i.disconnect(),e.disconnect()}))},this._playNote=async(e,i,s)=>{if(this._container.muted)return;const o=e[i];if(!o)return;const n=o.value,a=(0,t.executeOnSingleOrMultiple)(n,(async(t,s)=>this._playNoteValue(e,i,s)));await((0,t.isArray)(a)?Promise.allSettled(a):a);let l=i+1;s&&l>=e.length&&(l%=e.length),this._container.muted||await this._playNote(e,l,s)},this._playNoteValue=async(e,i,s)=>{const o=e[i];if(!o)return;const n=(0,t.itemFromSingleOrMultiple)(o.value,s,!0);try{const e=h(n);if(!(0,t.isNumber)(e))return;await this._playFrequency(e,o.duration)}catch(e){(0,t.getLogger)().error(e)}},this._removeAudioSource=t=>{t.stop(),t.disconnect(),this._audioSources.splice(this._audioSources.indexOf(t),1)},this._unmute=()=>{const t=this._container,e=t.actualOptions.sounds;if(!e)return;t.audioContext||(t.audioContext=new AudioContext);const{audioContext:i}=t;this._audioSources||(this._audioSources=[]);const s=i.createGain();s.connect(i.destination),s.gain.value=e.volume.value/100,this._gain=s,this._initEvents(),this._engine.dispatchEvent("soundsUnmuted",{container:this._container})},this._updateMuteIcons=()=>{const t=this._container,e=this._muteImg,i=this._unmuteImg;e&&(e.style.display=t.muted?"block":"none"),i&&(i.style.display=t.muted?"none":"block")},this._updateMuteStatus=()=>{this._container.muted?this._mute():(this._unmute(),this._playMuteSound())},this._updateVolume=()=>{const e=this._container,i=e.actualOptions.sounds;if(!i?.enable)return;(0,t.clamp)(this._volume,i.volume.min,i.volume.max);let s=!1;this._volume<=0&&!e.muted?(this._volume=0,e.muted=!0,s=!0):this._volume>0&&e.muted&&(e.muted=!1,s=!0),s&&(this._updateMuteIcons(),this._updateMuteStatus()),this._gain?.gain&&(this._gain.gain.value=this._volume/100)},this._container=e,this._engine=i,this._volume=0,this._audioSources=[],this._audioMap=new Map}async init(){const e=this._container,i=e.actualOptions.sounds;if(!i?.enable)return;this._volume=i.volume.value;const s=i.events;this._audioMap=new Map;for(const i of s)i.audio&&(0,t.executeOnSingleOrMultiple)(i.audio,(async t=>{const i=await fetch(t.source);if(!i.ok)return;const s=await i.arrayBuffer();e.audioContext=new AudioContext;const o=await e.audioContext.decodeAudioData(s);this._audioMap.set(t.source,o)}))}async start(){const t=this._container,e=t.actualOptions,i=e.sounds;if(!i?.enable||!t.canvas.element)return;t.muted=!0;const s=t.canvas.element,o={top:s.offsetTop,right:s.offsetLeft+s.offsetWidth},{mute:n,unmute:a,volumeDown:l,volumeUp:c}=i.icons,u=()=>{t.muted=!t.muted,this._updateMuteIcons(),this._updateMuteStatus()};this._muteImg=p({container:t,options:e,pos:o,display:"block",iconOptions:n,margin:10,rightOffsets:[l.width,c.width],clickCb:u}),this._unmuteImg=p({container:t,options:e,pos:o,display:"none",iconOptions:a,margin:10,rightOffsets:[l.width,c.width],clickCb:u}),this._volumeDownImg=p({container:t,options:e,pos:o,display:"block",iconOptions:l,margin:10,rightOffsets:[c.width],clickCb:()=>{t.muted&&(this._volume=0),this._volume-=i.volume.step,this._updateVolume()}}),this._volumeUpImg=p({container:t,options:e,pos:o,display:"block",iconOptions:c,margin:10,rightOffsets:[],clickCb:()=>{t.muted&&(this._volume=0),this._volume+=i.volume.step,this._updateVolume()}})}stop(){this._container.muted=!0,this._mute(),m(this._muteImg),m(this._unmuteImg),m(this._volumeDownImg),m(this._volumeUpImg)}}class f{constructor(t){this.id="sounds",this._engine=t}getPlugin(t){return new v(t,this._engine)}loadOptions(t,e){if(!this.needsPlugin(t)&&!this.needsPlugin(e))return;let i=t.sounds;void 0===i?.load&&(t.sounds=i=new r),i.load(e?.sounds)}needsPlugin(t){return t?.sounds?.enable??!1}}async function g(t,e=!0){await t.addPlugin(new f(t),e)}})(),o})()));
|
|
2
|
+
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],e);else{var i="object"==typeof exports?e(require("@tsparticles/engine")):e(t.window);for(var s in i)("object"==typeof exports?exports:t)[s]=i[s]}}(this,(t=>(()=>{"use strict";var e={533:e=>{e.exports=t}},i={};function s(t){var o=i[t];if(void 0!==o)return o.exports;var n=i[t]={exports:{}};return e[t](n,n.exports,s),n.exports}s.d=(t,e)=>{for(var i in e)s.o(e,i)&&!s.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{s.r(o),s.d(o,{loadSoundsPlugin:()=>g});var t=s(533);class e{constructor(){this.loop=!1,this.source=""}load(e){void 0!==e&&((0,t.isObject)(e)?(void 0!==e.loop&&(this.loop=e.loop),void 0!==e.source&&(this.source=e.source)):this.source=e)}}class i{constructor(){this.duration=500,this.value=[]}load(t){t&&(void 0!==t.duration&&(this.duration=t.duration),void 0!==t.value&&(this.value=t.value))}}class n{constructor(){this.loop=!1,this.melodies=[],this.notes=[]}load(t){void 0!==t&&(void 0!==t.loop&&(this.loop=t.loop),void 0!==t.melodies&&(this.melodies=t.melodies.map((t=>{const e=new n;return e.load(t),e}))),void 0!==t.notes&&(this.notes=t.notes.map((t=>{const e=new i;return e.load(t),e}))))}}class a{constructor(){this.event=[],this.notes=[]}load(s){s&&(void 0!==s.event&&(this.event=s.event),void 0!==s.audio&&((0,t.isArray)(s.audio)?this.audio=s.audio.map((t=>{const i=new e;return i.load(t),i})):(this.audio=new e,this.audio.load(s.audio))),void 0!==s.notes&&(this.notes=s.notes.map((t=>{const e=new i;return e.load(t),e}))),void 0!==s.melodies&&(this.melodies=s.melodies.map((t=>{const e=new n;return e.load(t),e}))),void 0!==s.filter&&((0,t.isString)(s.filter)?(0,t.isFunction)(window[s.filter])&&(this.filter=window[s.filter]):this.filter=s.filter))}}class c{constructor(){this.width=24,this.height=24}load(t){t&&(void 0!==t.path&&(this.path=t.path),void 0!==t.svg&&(this.svg=t.svg),void 0!==t.width&&(this.width=t.width),void 0!==t.height&&(this.height=t.height))}}class l{constructor(){this.mute=new c,this.unmute=new c,this.volumeDown=new c,this.volumeUp=new c,this.mute.svg='<?xml version="1.0"?>\n<svg baseProfile="tiny" height="24px" version="1.2" viewBox="0 0 24 24" width="24px"\n xml:space="preserve" xmlns="http://www.w3.org/2000/svg"\n xmlns:xlink="http://www.w3.org/1999/xlink">\n <g id="Layer_1">\n <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"/>\n </g>\n</svg>',this.unmute.svg='<?xml version="1.0"?>\n<svg baseProfile="tiny" height="24px" version="1.2" viewBox="0 0 24 24" width="24px"\n xml:space="preserve" xmlns="http://www.w3.org/2000/svg"\n xmlns:xlink="http://www.w3.org/1999/xlink">\n <g id="Layer_1">\n <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"/>\n </g>\n</svg>',this.volumeDown.svg='<?xml version="1.0"?>\n<svg baseProfile="tiny" height="24px" version="1.2" viewBox="0 0 24 24" width="24px"\n xml:space="preserve" xmlns="http://www.w3.org/2000/svg"\n xmlns:xlink="http://www.w3.org/1999/xlink">\n <g id="Layer_1">\n <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"/>\n <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"/>\n </g>\n</svg>',this.volumeUp.svg='<?xml version="1.0"?>\n<svg baseProfile="tiny" height="24px" version="1.2" viewBox="0 0 24 24" width="24px"\n xml:space="preserve" xmlns="http://www.w3.org/2000/svg"\n xmlns:xlink="http://www.w3.org/1999/xlink">\n <g id="Layer_1">\n <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"/>\n <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"/>\n <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"/>\n <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"/>\n </g>\n</svg>'}load(t){t&&(this.mute.load(t.mute),this.unmute.load(t.unmute),this.volumeDown.load(t.volumeDown),this.volumeUp.load(t.volumeUp))}}class u{constructor(){this.value=100,this.max=100,this.min=0,this.step=10}load(e){void 0!==e&&((0,t.isObject)(e)?(void 0!==e.max&&(this.max=e.max),void 0!==e.min&&(this.min=e.min),void 0!==e.step&&(this.step=e.step),void 0!==e.value&&(this.value=e.value)):this.value=e)}}class r{constructor(){this.enable=!1,this.events=[],this.icons=new l,this.volume=new u}load(t){t&&(void 0!==t.enable&&(this.enable=t.enable),void 0!==t.events&&(this.events=t.events.map((t=>{const e=new a;return e.load(t),e}))),this.icons.load(t.icons),void 0!==t.volume&&this.volume.load(t.volume))}}const d=new Map;function h(t){const e=/(([A-G]b?)(\d))|pause/i.exec(t);if(!e||!e.length)return;const i=e[2]||e[0],s=d.get(i);return s?s[parseInt(e[3]||"0")]:void 0}function p(t){const e=document.createElement("img"),{clickCb:i,container:s,display:o,iconOptions:n,margin:a,options:c,pos:l,rightOffsets:u}=t,{width:r,path:d,svg:h}=n;!function(t,e,i,s,o,n,a){t.style.userSelect="none",t.style.webkitUserSelect="none",t.style.position="absolute",t.style.top=`${e+a}px`,t.style.left=i-a-n+"px",t.style.display=s,t.style.zIndex=`${o+1}`}(e,l.top+a,l.right-(a*(u.length+1)+r+u.reduce(((t,e)=>t+e),0)),o,c.fullScreen.zIndex+1,r,a),e.src=d??(h?`data:image/svg+xml;base64,${btoa(h)}`:"");return(s.canvas.element?.parentNode||document.body).append(e),e.addEventListener("click",i),e}function m(t){t&&t.remove()}d.set("C",[16.35,32.7,65.41,130.81,261.63,523.25,1046.5,2093,4186.01]),d.set("Db",[17.32,34.65,69.3,138.59,277.18,554.37,1108.73,2217.46,4434.92]),d.set("D",[18.35,36.71,73.42,146.83,293.66,587.33,1174.66,2349.32,4698.63]),d.set("Eb",[19.45,38.89,77.78,155.56,311.13,622.25,1244.51,2489.02,4978.03]),d.set("E",[20.6,41.2,82.41,164.81,329.63,659.25,1318.51,2637.02,5274.04]),d.set("F",[21.83,43.65,87.31,174.61,349.23,698.46,1396.91,2793.83,5587.65]),d.set("Gb",[23.12,46.25,92.5,185,369.99,739.99,1479.98,2959.96,5919.91]),d.set("G",[24.5,49,98,196,392,783.99,1567.98,3135.96,6271.93]),d.set("Ab",[25.96,51.91,103.83,207.65,415.3,830.61,1661.22,3322.44,6644.88]),d.set("A",[27.5,55,110,220,440,880,1760,3520,7040]),d.set("Bb",[29.14,58.27,116.54,233.08,466.16,932.33,1864.66,3729.31,7458.62]),d.set("B",[30.87,61.74,123.47,246.94,493.88,987.77,1975.53,3951.07,7902.13]),d.set("pause",[0]);class v{constructor(e,i){this._addBuffer=t=>{const e=t.createBufferSource();return this._audioSources.push(e),e},this._addOscillator=t=>{const e=t.createOscillator();return this._audioSources.push(e),e},this._initEvents=()=>{const e=this._container,i=e.actualOptions.sounds;if(i?.enable&&e.canvas.element)for(const e of i.events){const i=s=>{(async()=>{const o=e.filter&&!e.filter(s);if(this._container===s.container)if(!this._container||this._container.muted||this._container.destroyed)(0,t.executeOnSingleOrMultiple)(e.event,(t=>{this._engine.removeEventListener(t,i)}));else if(!o)if(e.audio)this._playBuffer((0,t.itemFromSingleOrMultiple)(e.audio));else if(e.melodies){const i=(0,t.itemFromArray)(e.melodies);i.melodies.length?await Promise.allSettled(i.melodies.map((t=>this._playNote(t.notes,0,i.loop)))):await this._playNote(i.notes,0,i.loop)}else if(e.notes){const i=(0,t.itemFromArray)(e.notes);await this._playNote([i],0,!1)}})()};(0,t.executeOnSingleOrMultiple)(e.event,(t=>{this._engine.addEventListener(t,i)}))}},this._mute=()=>{const t=this._container;if(t.audioContext){for(const t of this._audioSources)this._removeAudioSource(t);this._gain&&this._gain.disconnect(),t.audioContext.close(),t.audioContext=void 0,this._engine.dispatchEvent("soundsMuted",{container:this._container})}},this._playBuffer=t=>{const e=this._audioMap.get(t.source);if(!e)return;const i=this._container.audioContext;if(!i)return;const s=this._addBuffer(i);s.loop=t.loop,s.buffer=e,s.connect(this._gain??i.destination),s.start()},this._playFrequency=async(t,e)=>{if(!this._container.audioContext||!this._gain)return;const i=this._addOscillator(this._container.audioContext);return i.connect(this._gain),i.type="sine",i.frequency.value=t,i.start(),new Promise((t=>{setTimeout((()=>{this._removeAudioSource(i),t()}),e)}))},this._playMuteSound=()=>{const t=this._container;if(!t.audioContext)return;const e=t.audioContext.createGain();e.connect(t.audioContext.destination),e.gain.value=0;const i=t.audioContext.createOscillator();i.connect(e),i.type="sine",i.frequency.value=1,i.start(),setTimeout((()=>{i.stop(),i.disconnect(),e.disconnect()}))},this._playNote=async(e,i,s)=>{if(this._container.muted)return;const o=e[i];if(!o)return;const n=o.value,a=(0,t.executeOnSingleOrMultiple)(n,(async(t,s)=>this._playNoteValue(e,i,s)));await((0,t.isArray)(a)?Promise.allSettled(a):a);let c=i+1;s&&c>=e.length&&(c%=e.length),this._container.muted||await this._playNote(e,c,s)},this._playNoteValue=async(e,i,s)=>{const o=e[i];if(!o)return;const n=(0,t.itemFromSingleOrMultiple)(o.value,s,!0);try{const e=h(n);if(!(0,t.isNumber)(e))return;await this._playFrequency(e,o.duration)}catch(e){(0,t.getLogger)().error(e)}},this._removeAudioSource=t=>{t.stop(),t.disconnect(),this._audioSources.splice(this._audioSources.indexOf(t),1)},this._unmute=()=>{const t=this._container,e=t.actualOptions.sounds;if(!e)return;t.audioContext||(t.audioContext=new AudioContext);const{audioContext:i}=t;this._audioSources||(this._audioSources=[]);const s=i.createGain();s.connect(i.destination),s.gain.value=e.volume.value/100,this._gain=s,this._initEvents(),this._engine.dispatchEvent("soundsUnmuted",{container:this._container})},this._updateMuteIcons=()=>{const t=this._container,e=this._muteImg,i=this._unmuteImg;e&&(e.style.display=t.muted?"block":"none"),i&&(i.style.display=t.muted?"none":"block")},this._updateMuteStatus=async()=>{const t=this._container;t.muted?(await(t.audioContext?.suspend()),this._mute()):(await(t.audioContext?.resume()),this._unmute(),this._playMuteSound())},this._updateVolume=async()=>{const e=this._container,i=e.actualOptions.sounds;if(!i?.enable)return;(0,t.clamp)(this._volume,i.volume.min,i.volume.max);let s=!1;this._volume<=0&&!e.muted?(this._volume=0,e.muted=!0,s=!0):this._volume>0&&e.muted&&(e.muted=!1,s=!0),s&&(this._updateMuteIcons(),await this._updateMuteStatus()),this._gain?.gain&&(this._gain.gain.value=this._volume/100)},this._container=e,this._engine=i,this._volume=0,this._audioSources=[],this._audioMap=new Map}async init(){const e=this._container,i=e.actualOptions.sounds;if(!i?.enable)return;this._volume=i.volume.value;const s=i.events;this._audioMap=new Map;for(const i of s)i.audio&&(0,t.executeOnSingleOrMultiple)(i.audio,(async t=>{const i=await fetch(t.source);if(!i.ok)return;const s=await i.arrayBuffer();e.audioContext=new AudioContext;const o=await e.audioContext.decodeAudioData(s);this._audioMap.set(t.source,o)}))}async start(){const t=this._container,e=t.actualOptions,i=e.sounds;if(!i?.enable||!t.canvas.element)return;t.muted=!0;const s=t.canvas.element,o={top:s.offsetTop,right:s.offsetLeft+s.offsetWidth},{mute:n,unmute:a,volumeDown:c,volumeUp:l}=i.icons,u=async()=>{t.muted=!t.muted,this._updateMuteIcons(),await this._updateMuteStatus()};this._muteImg=p({container:t,options:e,pos:o,display:"block",iconOptions:n,margin:10,rightOffsets:[c.width,l.width],clickCb:u}),this._unmuteImg=p({container:t,options:e,pos:o,display:"none",iconOptions:a,margin:10,rightOffsets:[c.width,l.width],clickCb:u}),this._volumeDownImg=p({container:t,options:e,pos:o,display:"block",iconOptions:c,margin:10,rightOffsets:[l.width],clickCb:async()=>{t.muted&&(this._volume=0),this._volume-=i.volume.step,await this._updateVolume()}}),this._volumeUpImg=p({container:t,options:e,pos:o,display:"block",iconOptions:l,margin:10,rightOffsets:[],clickCb:async()=>{t.muted&&(this._volume=0),this._volume+=i.volume.step,await this._updateVolume()}})}stop(){this._container.muted=!0,this._mute(),m(this._muteImg),m(this._unmuteImg),m(this._volumeDownImg),m(this._volumeUpImg)}}class f{constructor(t){this.id="sounds",this._engine=t}getPlugin(t){return new v(t,this._engine)}loadOptions(t,e){if(!this.needsPlugin(t)&&!this.needsPlugin(e))return;let i=t.sounds;void 0===i?.load&&(t.sounds=i=new r),i.load(e?.sounds)}needsPlugin(t){return t?.sounds?.enable??!1}}async function g(t,e=!0){await t.addPlugin(new f(t),e)}})(),o})()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/*! tsParticles Sounds Plugin v3.0.
|
|
1
|
+
/*! tsParticles Sounds Plugin v3.0.2 by Matteo Bruni */
|
package/umd/SoundsInstance.js
CHANGED
|
@@ -54,35 +54,38 @@
|
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
56
|
for (const event of soundsOptions.events) {
|
|
57
|
-
const cb =
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
(0, engine_1.executeOnSingleOrMultiple)(event.event, (item) => {
|
|
63
|
-
this._engine.removeEventListener(item, cb);
|
|
64
|
-
});
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
if (event.filter && !event.filter(args)) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
if (event.audio) {
|
|
71
|
-
this._playBuffer((0, engine_1.itemFromSingleOrMultiple)(event.audio));
|
|
72
|
-
}
|
|
73
|
-
else if (event.melodies) {
|
|
74
|
-
const melody = (0, engine_1.itemFromArray)(event.melodies);
|
|
75
|
-
if (melody.melodies.length) {
|
|
76
|
-
await Promise.allSettled(melody.melodies.map((m) => this._playNote(m.notes, 0, melody.loop)));
|
|
57
|
+
const cb = (args) => {
|
|
58
|
+
(async () => {
|
|
59
|
+
const filterNotValid = event.filter && !event.filter(args);
|
|
60
|
+
if (this._container !== args.container) {
|
|
61
|
+
return;
|
|
77
62
|
}
|
|
78
|
-
|
|
79
|
-
|
|
63
|
+
if (!this._container || this._container.muted || this._container.destroyed) {
|
|
64
|
+
(0, engine_1.executeOnSingleOrMultiple)(event.event, (item) => {
|
|
65
|
+
this._engine.removeEventListener(item, cb);
|
|
66
|
+
});
|
|
67
|
+
return;
|
|
80
68
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
69
|
+
if (filterNotValid) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (event.audio) {
|
|
73
|
+
this._playBuffer((0, engine_1.itemFromSingleOrMultiple)(event.audio));
|
|
74
|
+
}
|
|
75
|
+
else if (event.melodies) {
|
|
76
|
+
const melody = (0, engine_1.itemFromArray)(event.melodies);
|
|
77
|
+
if (melody.melodies.length) {
|
|
78
|
+
await Promise.allSettled(melody.melodies.map((m) => this._playNote(m.notes, 0, melody.loop)));
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
await this._playNote(melody.notes, 0, melody.loop);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
else if (event.notes) {
|
|
85
|
+
const note = (0, engine_1.itemFromArray)(event.notes);
|
|
86
|
+
await this._playNote([note], 0, false);
|
|
87
|
+
}
|
|
88
|
+
})();
|
|
86
89
|
};
|
|
87
90
|
(0, engine_1.executeOnSingleOrMultiple)(event.event, (item) => {
|
|
88
91
|
this._engine.addEventListener(item, cb);
|
|
@@ -226,17 +229,19 @@
|
|
|
226
229
|
unmuteImg.style.display = container.muted ? "none" : "block";
|
|
227
230
|
}
|
|
228
231
|
};
|
|
229
|
-
this._updateMuteStatus = () => {
|
|
232
|
+
this._updateMuteStatus = async () => {
|
|
230
233
|
const container = this._container;
|
|
231
234
|
if (container.muted) {
|
|
235
|
+
await container.audioContext?.suspend();
|
|
232
236
|
this._mute();
|
|
233
237
|
}
|
|
234
238
|
else {
|
|
239
|
+
await container.audioContext?.resume();
|
|
235
240
|
this._unmute();
|
|
236
241
|
this._playMuteSound();
|
|
237
242
|
}
|
|
238
243
|
};
|
|
239
|
-
this._updateVolume = () => {
|
|
244
|
+
this._updateVolume = async () => {
|
|
240
245
|
const container = this._container, soundsOptions = container.actualOptions.sounds;
|
|
241
246
|
if (!soundsOptions?.enable) {
|
|
242
247
|
return;
|
|
@@ -254,7 +259,7 @@
|
|
|
254
259
|
}
|
|
255
260
|
if (stateChanged) {
|
|
256
261
|
this._updateMuteIcons();
|
|
257
|
-
this._updateMuteStatus();
|
|
262
|
+
await this._updateMuteStatus();
|
|
258
263
|
}
|
|
259
264
|
if (this._gain?.gain) {
|
|
260
265
|
this._gain.gain.value = this._volume / 100;
|
|
@@ -300,10 +305,10 @@
|
|
|
300
305
|
top: canvas.offsetTop,
|
|
301
306
|
right: canvas.offsetLeft + canvas.offsetWidth,
|
|
302
307
|
}, { mute, unmute, volumeDown, volumeUp } = soundsOptions.icons, margin = 10;
|
|
303
|
-
const toggleMute = () => {
|
|
308
|
+
const toggleMute = async () => {
|
|
304
309
|
container.muted = !container.muted;
|
|
305
310
|
this._updateMuteIcons();
|
|
306
|
-
this._updateMuteStatus();
|
|
311
|
+
await this._updateMuteStatus();
|
|
307
312
|
};
|
|
308
313
|
this._muteImg = initImage({
|
|
309
314
|
container,
|
|
@@ -333,12 +338,12 @@
|
|
|
333
338
|
iconOptions: volumeDown,
|
|
334
339
|
margin,
|
|
335
340
|
rightOffsets: [volumeUp.width],
|
|
336
|
-
clickCb: () => {
|
|
341
|
+
clickCb: async () => {
|
|
337
342
|
if (container.muted) {
|
|
338
343
|
this._volume = 0;
|
|
339
344
|
}
|
|
340
345
|
this._volume -= soundsOptions.volume.step;
|
|
341
|
-
this._updateVolume();
|
|
346
|
+
await this._updateVolume();
|
|
342
347
|
},
|
|
343
348
|
});
|
|
344
349
|
this._volumeUpImg = initImage({
|
|
@@ -349,12 +354,12 @@
|
|
|
349
354
|
iconOptions: volumeUp,
|
|
350
355
|
margin,
|
|
351
356
|
rightOffsets: [],
|
|
352
|
-
clickCb: () => {
|
|
357
|
+
clickCb: async () => {
|
|
353
358
|
if (container.muted) {
|
|
354
359
|
this._volume = 0;
|
|
355
360
|
}
|
|
356
361
|
this._volume += soundsOptions.volume.step;
|
|
357
|
-
this._updateVolume();
|
|
362
|
+
await this._updateVolume();
|
|
358
363
|
},
|
|
359
364
|
});
|
|
360
365
|
}
|