@tsparticles/plugin-sounds 3.3.0 → 3.4.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 (41) hide show
  1. package/browser/Options/Classes/Sounds.js +1 -1
  2. package/browser/Options/Classes/SoundsEvent.js +3 -3
  3. package/browser/Options/Classes/SoundsMelody.js +2 -2
  4. package/browser/SoundsInstance.js +13 -12
  5. package/browser/SoundsPlugin.js +3 -3
  6. package/browser/enums.js +10 -1
  7. package/browser/index.js +1 -1
  8. package/cjs/Options/Classes/Sounds.js +1 -1
  9. package/cjs/Options/Classes/SoundsEvent.js +3 -3
  10. package/cjs/Options/Classes/SoundsMelody.js +2 -2
  11. package/cjs/SoundsInstance.js +13 -12
  12. package/cjs/SoundsPlugin.js +3 -3
  13. package/cjs/enums.js +11 -0
  14. package/cjs/index.js +2 -2
  15. package/esm/Options/Classes/Sounds.js +1 -1
  16. package/esm/Options/Classes/SoundsEvent.js +3 -3
  17. package/esm/Options/Classes/SoundsMelody.js +2 -2
  18. package/esm/SoundsInstance.js +13 -12
  19. package/esm/SoundsPlugin.js +3 -3
  20. package/esm/enums.js +10 -1
  21. package/esm/index.js +1 -1
  22. package/package.json +2 -2
  23. package/report.html +1 -1
  24. package/tsparticles.plugin.sounds.js +122 -200
  25. package/tsparticles.plugin.sounds.min.js +1 -1
  26. package/tsparticles.plugin.sounds.min.js.LICENSE.txt +1 -1
  27. package/types/SoundsPlugin.d.ts +1 -1
  28. package/types/enums.d.ts +2 -2
  29. package/umd/Options/Classes/Sounds.js +1 -1
  30. package/umd/Options/Classes/SoundsEvent.js +3 -3
  31. package/umd/Options/Classes/SoundsMelody.js +2 -2
  32. package/umd/SoundsInstance.js +14 -13
  33. package/umd/SoundsPlugin.js +4 -28
  34. package/umd/enums.js +11 -0
  35. package/umd/index.js +3 -27
  36. package/826.min.js +0 -2
  37. package/826.min.js.LICENSE.txt +0 -1
  38. package/999.min.js +0 -2
  39. package/999.min.js.LICENSE.txt +0 -1
  40. package/dist_browser_SoundsInstance_js.js +0 -30
  41. package/dist_browser_SoundsPlugin_js.js +0 -120
@@ -4,13 +4,14 @@
4
4
  if (v !== undefined) module.exports = v;
5
5
  }
6
6
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "@tsparticles/engine", "./utils.js"], factory);
7
+ define(["require", "exports", "@tsparticles/engine", "./enums.js", "./utils.js"], factory);
8
8
  }
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.SoundsInstance = void 0;
13
13
  const engine_1 = require("@tsparticles/engine");
14
+ const enums_js_1 = require("./enums.js");
14
15
  const utils_js_1 = require("./utils.js");
15
16
  const zIndexOffset = 1, rightOffset = 1, minVolume = 0;
16
17
  function initImage(data) {
@@ -45,12 +46,12 @@
45
46
  }
46
47
  class SoundsInstance {
47
48
  constructor(container, engine) {
48
- this._addBuffer = (audioCtx) => {
49
+ this._addBuffer = audioCtx => {
49
50
  const buffer = audioCtx.createBufferSource();
50
51
  this._audioSources.push(buffer);
51
52
  return buffer;
52
53
  };
53
- this._addOscillator = (audioCtx) => {
54
+ this._addOscillator = audioCtx => {
54
55
  const oscillator = audioCtx.createOscillator();
55
56
  this._audioSources.push(oscillator);
56
57
  return oscillator;
@@ -68,7 +69,7 @@
68
69
  return;
69
70
  }
70
71
  if (!this._container || !!this._container.muted || this._container.destroyed) {
71
- (0, engine_1.executeOnSingleOrMultiple)(event.event, (item) => {
72
+ (0, engine_1.executeOnSingleOrMultiple)(event.event, item => {
72
73
  this._engine.removeEventListener(item, cb);
73
74
  });
74
75
  return;
@@ -83,7 +84,7 @@
83
84
  else if (event.melodies) {
84
85
  const melody = (0, engine_1.itemFromArray)(event.melodies);
85
86
  if (melody.melodies.length) {
86
- await Promise.allSettled(melody.melodies.map((m) => this._playNote(m.notes, defaultNoteIndex, melody.loop)));
87
+ await Promise.allSettled(melody.melodies.map(m => this._playNote(m.notes, defaultNoteIndex, melody.loop)));
87
88
  }
88
89
  else {
89
90
  await this._playNote(melody.notes, defaultNoteIndex, melody.loop);
@@ -95,7 +96,7 @@
95
96
  }
96
97
  })();
97
98
  };
98
- (0, engine_1.executeOnSingleOrMultiple)(event.event, (item) => {
99
+ (0, engine_1.executeOnSingleOrMultiple)(event.event, item => {
99
100
  this._engine.addEventListener(item, cb);
100
101
  });
101
102
  }
@@ -110,9 +111,9 @@
110
111
  }
111
112
  await audioContext.close();
112
113
  container.audioContext = undefined;
113
- this._engine.dispatchEvent("soundsMuted", { container: this._container });
114
+ this._engine.dispatchEvent(enums_js_1.SoundsEventType.mute, { container: this._container });
114
115
  };
115
- this._playBuffer = (audio) => {
116
+ this._playBuffer = audio => {
116
117
  const audioBuffer = this._audioMap.get(audio.source);
117
118
  if (!audioBuffer) {
118
119
  return;
@@ -136,7 +137,7 @@
136
137
  oscillator.type = "sine";
137
138
  oscillator.frequency.value = frequency;
138
139
  oscillator.start();
139
- return new Promise((resolve) => {
140
+ return new Promise(resolve => {
140
141
  setTimeout(() => {
141
142
  this._removeAudioSource(oscillator);
142
143
  resolve();
@@ -201,7 +202,7 @@
201
202
  (0, engine_1.getLogger)().error(e);
202
203
  }
203
204
  };
204
- this._removeAudioSource = (source) => {
205
+ this._removeAudioSource = source => {
205
206
  source.stop();
206
207
  source.disconnect();
207
208
  const deleteCount = 1;
@@ -221,7 +222,7 @@
221
222
  gain.gain.value = soundsOptions.volume.value / engine_1.percentDenominator;
222
223
  this._gain = gain;
223
224
  this._initEvents();
224
- this._engine.dispatchEvent("soundsUnmuted", { container: this._container });
225
+ this._engine.dispatchEvent(enums_js_1.SoundsEventType.unmute, { container: this._container });
225
226
  };
226
227
  this._updateMuteIcons = () => {
227
228
  const container = this._container, soundsOptions = container.actualOptions.sounds;
@@ -336,7 +337,7 @@
336
337
  right: canvas.offsetLeft + canvas.offsetWidth,
337
338
  }, { mute, unmute, volumeDown, volumeUp } = soundsOptions.icons, margin = 10, toggleMute = async () => {
338
339
  await this.toggleMute();
339
- }, enableIcons = soundsOptions.icons.enable, display = enableIcons ? "block" : "none";
340
+ }, enableIcons = soundsOptions.icons.enable, display = enableIcons ? enums_js_1.ImageDisplay.Block : enums_js_1.ImageDisplay.None;
340
341
  this._muteImg = initImage({
341
342
  container,
342
343
  options,
@@ -351,7 +352,7 @@
351
352
  container,
352
353
  options,
353
354
  pos,
354
- display: "none",
355
+ display: enums_js_1.ImageDisplay.None,
355
356
  iconOptions: unmute,
356
357
  margin,
357
358
  rightOffsets: [volumeDown.width, volumeUp.width],
@@ -1,41 +1,18 @@
1
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2
- if (k2 === undefined) k2 = k;
3
- var desc = Object.getOwnPropertyDescriptor(m, k);
4
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
5
- desc = { enumerable: true, get: function() { return m[k]; } };
6
- }
7
- Object.defineProperty(o, k2, desc);
8
- }) : (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- o[k2] = m[k];
11
- }));
12
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
13
- Object.defineProperty(o, "default", { enumerable: true, value: v });
14
- }) : function(o, v) {
15
- o["default"] = v;
16
- });
17
- var __importStar = (this && this.__importStar) || function (mod) {
18
- if (mod && mod.__esModule) return mod;
19
- var result = {};
20
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
21
- __setModuleDefault(result, mod);
22
- return result;
23
- };
24
1
  (function (factory) {
25
2
  if (typeof module === "object" && typeof module.exports === "object") {
26
3
  var v = factory(require, exports);
27
4
  if (v !== undefined) module.exports = v;
28
5
  }
29
6
  else if (typeof define === "function" && define.amd) {
30
- define(["require", "exports", "@tsparticles/engine", "./Options/Classes/Sounds.js", "./utils.js"], factory);
7
+ define(["require", "exports", "@tsparticles/engine", "./Options/Classes/Sounds.js", "./SoundsInstance.js", "./utils.js"], factory);
31
8
  }
32
9
  })(function (require, exports) {
33
10
  "use strict";
34
- var __syncRequire = typeof module === "object" && typeof module.exports === "object";
35
11
  Object.defineProperty(exports, "__esModule", { value: true });
36
12
  exports.SoundsPlugin = void 0;
37
13
  const engine_1 = require("@tsparticles/engine");
38
14
  const Sounds_js_1 = require("./Options/Classes/Sounds.js");
15
+ const SoundsInstance_js_1 = require("./SoundsInstance.js");
39
16
  const utils_js_1 = require("./utils.js");
40
17
  const generalFirstClickHandler = () => {
41
18
  removeEventListener(engine_1.mouseDownEvent, generalFirstClickHandler);
@@ -53,9 +30,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
53
30
  addEventListener(engine_1.mouseDownEvent, generalFirstClickHandler, listenerOptions);
54
31
  addEventListener(engine_1.touchStartEvent, generalFirstClickHandler, listenerOptions);
55
32
  }
56
- async getPlugin(container) {
57
- const { SoundsInstance } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./SoundsInstance.js"))) : new Promise((resolve_1, reject_1) => { require(["./SoundsInstance.js"], resolve_1, reject_1); }).then(__importStar));
58
- return new SoundsInstance(container, this._engine);
33
+ getPlugin(container) {
34
+ return Promise.resolve(new SoundsInstance_js_1.SoundsInstance(container, this._engine));
59
35
  }
60
36
  loadOptions(options, source) {
61
37
  if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
package/umd/enums.js CHANGED
@@ -9,4 +9,15 @@
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ImageDisplay = exports.SoundsEventType = void 0;
13
+ var SoundsEventType;
14
+ (function (SoundsEventType) {
15
+ SoundsEventType["mute"] = "soundsMuted";
16
+ SoundsEventType["unmute"] = "soundsUnmuted";
17
+ })(SoundsEventType || (exports.SoundsEventType = SoundsEventType = {}));
18
+ var ImageDisplay;
19
+ (function (ImageDisplay) {
20
+ ImageDisplay["Block"] = "block";
21
+ ImageDisplay["None"] = "none";
22
+ })(ImageDisplay || (exports.ImageDisplay = ImageDisplay = {}));
12
23
  });
package/umd/index.js CHANGED
@@ -1,42 +1,18 @@
1
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2
- if (k2 === undefined) k2 = k;
3
- var desc = Object.getOwnPropertyDescriptor(m, k);
4
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
5
- desc = { enumerable: true, get: function() { return m[k]; } };
6
- }
7
- Object.defineProperty(o, k2, desc);
8
- }) : (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- o[k2] = m[k];
11
- }));
12
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
13
- Object.defineProperty(o, "default", { enumerable: true, value: v });
14
- }) : function(o, v) {
15
- o["default"] = v;
16
- });
17
- var __importStar = (this && this.__importStar) || function (mod) {
18
- if (mod && mod.__esModule) return mod;
19
- var result = {};
20
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
21
- __setModuleDefault(result, mod);
22
- return result;
23
- };
24
1
  (function (factory) {
25
2
  if (typeof module === "object" && typeof module.exports === "object") {
26
3
  var v = factory(require, exports);
27
4
  if (v !== undefined) module.exports = v;
28
5
  }
29
6
  else if (typeof define === "function" && define.amd) {
30
- define(["require", "exports"], factory);
7
+ define(["require", "exports", "./SoundsPlugin.js"], factory);
31
8
  }
32
9
  })(function (require, exports) {
33
10
  "use strict";
34
- var __syncRequire = typeof module === "object" && typeof module.exports === "object";
35
11
  Object.defineProperty(exports, "__esModule", { value: true });
36
12
  exports.loadSoundsPlugin = void 0;
13
+ const SoundsPlugin_js_1 = require("./SoundsPlugin.js");
37
14
  async function loadSoundsPlugin(engine, refresh = true) {
38
- const { SoundsPlugin } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./SoundsPlugin.js"))) : new Promise((resolve_1, reject_1) => { require(["./SoundsPlugin.js"], resolve_1, reject_1); }).then(__importStar));
39
- await engine.addPlugin(new SoundsPlugin(engine), refresh);
15
+ await engine.addPlugin(new SoundsPlugin_js_1.SoundsPlugin(engine), refresh);
40
16
  }
41
17
  exports.loadSoundsPlugin = loadSoundsPlugin;
42
18
  });
package/826.min.js DELETED
@@ -1,2 +0,0 @@
1
- /*! For license information please see 826.min.js.LICENSE.txt */
2
- (this.webpackChunk_tsparticles_plugin_sounds=this.webpackChunk_tsparticles_plugin_sounds||[]).push([[826],{826:(t,e,n)=>{n.d(e,{SoundsInstance:()=>c});var i=n(303),s=n(972);const o=1;function a(t){const e=document.createElement("img"),{clickCb:n,container:i,display:s,iconOptions:a,margin:u,options:c,pos:r,rightOffsets:l}=t,{width:h,path:d,style:m,svg:_}=a;!function(t,e,n,i,s,a,u,c){t.style.userSelect="none",t.style.webkitUserSelect="none",t.style.position="absolute",t.style.top=`${e+u}px`,t.style.left=n-u-a+"px",t.style.display=i,t.style.zIndex=`${s+o}`,t.style.cssText+=c}(e,r.top+u,r.right-(u*(l.length+1)+h+l.reduce(((t,e)=>t+e),0)),s,c.fullScreen.zIndex+o,h,u,m),e.src=d??(_?`data:image/svg+xml;base64,${btoa(_)}`:"");return(i.canvas.element?.parentNode??document.body).append(e),e.addEventListener("click",(()=>{n()})),e}function u(t){t&&t.remove()}class c{constructor(t,e){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 t=this._container,e=t.actualOptions.sounds;if(e?.enable&&t.canvas.element)for(const t of e.events){const e=n=>{(async()=>{const s=t.filter&&!t.filter(n);if(this._container!==n.container)return;if(!this._container||this._container.muted||this._container.destroyed)return void(0,i.executeOnSingleOrMultiple)(t.event,(t=>{this._engine.removeEventListener(t,e)}));if(s)return;if(t.audio)this._playBuffer((0,i.itemFromSingleOrMultiple)(t.audio));else if(t.melodies){const e=(0,i.itemFromArray)(t.melodies);e.melodies.length?await Promise.allSettled(e.melodies.map((t=>this._playNote(t.notes,0,e.loop)))):await this._playNote(e.notes,0,e.loop)}else if(t.notes){const e=(0,i.itemFromArray)(t.notes);await this._playNote([e],0,!1)}})()};(0,i.executeOnSingleOrMultiple)(t.event,(t=>{this._engine.addEventListener(t,e)}))}},this._mute=async()=>{const t=this._container,e=this._getAudioContext();for(const t of this._audioSources)this._removeAudioSource(t);this._gain&&this._gain.disconnect(),await e.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 n=this._container.audioContext;if(!n)return;const i=this._addBuffer(n);i.loop=t.loop,i.buffer=e,i.connect(this._gain??n.destination),i.start()},this._playFrequency=async(t,e)=>{if(!this._gain||this._container.muted)return;const n=this._getAudioContext(),i=this._addOscillator(n);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=()=>{if(this._container.muted)return;const t=this._getAudioContext(),e=t.createGain();e.connect(t.destination),e.gain.value=0;const n=t.createOscillator();n.connect(e),n.type="sine",n.frequency.value=1,n.start(),setTimeout((()=>{n.stop(),n.disconnect(),e.disconnect()}))},this._playNote=async(t,e,n)=>{if(this._container.muted)return;const s=t[e];if(!s)return;const o=s.value,a=(0,i.executeOnSingleOrMultiple)(o,(async(n,i)=>this._playNoteValue(t,e,i)));await((0,i.isArray)(a)?Promise.allSettled(a):a);let u=e+1;n&&u>=t.length&&(u%=t.length),this._container.muted||await this._playNote(t,u,n)},this._playNoteValue=async(t,e,n)=>{const o=t[e];if(!o)return;const a=(0,i.itemFromSingleOrMultiple)(o.value,n,!0);try{const t=(0,s.jE)(a);if(!(0,i.isNumber)(t))return;await this._playFrequency(t,o.duration)}catch(t){(0,i.getLogger)().error(t)}},this._removeAudioSource=t=>{t.stop(),t.disconnect();this._audioSources.splice(this._audioSources.indexOf(t),1)},this._unmute=()=>{const t=this._container.actualOptions.sounds;if(!t)return;const e=this._getAudioContext();this._audioSources||(this._audioSources=[]);const n=e.createGain();n.connect(e.destination),n.gain.value=t.volume.value/i.percentDenominator,this._gain=n,this._initEvents(),this._engine.dispatchEvent("soundsUnmuted",{container:this._container})},this._updateMuteIcons=()=>{const t=this._container,e=t.actualOptions.sounds;if(!e?.enable||!e.icons.enable)return;const n=this._muteImg,i=this._unmuteImg;n&&(n.style.display=t.muted?"block":"none"),i&&(i.style.display=t.muted?"none":"block")},this._updateMuteStatus=async()=>{const t=this._container,e=this._getAudioContext();t.muted?(await(e?.suspend()),await this._mute()):(await(e?.resume()),this._unmute(),this._playMuteSound())},this._updateVolume=async()=>{const t=this._container,e=t.actualOptions.sounds;if(!e?.enable)return;(0,i.clamp)(this._volume,e.volume.min,e.volume.max);let n=!1;this._volume<=0&&!t.muted?(this._volume=0,t.muted=!0,n=!0):this._volume>0&&t.muted&&(t.muted=!1,n=!0),n&&(this._updateMuteIcons(),await this._updateMuteStatus()),this._gain?.gain&&(this._gain.gain.value=this._volume/i.percentDenominator)},this._container=t,this._engine=e,this._volume=0,this._audioSources=[],this._audioMap=new Map}async init(){const t=this._container.actualOptions.sounds;if(!t?.enable)return;if(t.autoPlay&&(0,s.E3)()){const t=()=>{removeEventListener(i.mouseDownEvent,t),removeEventListener(i.touchStartEvent,t),(0,s.XK)(),this.unmute()},e={capture:!0,once:!0};addEventListener(i.mouseDownEvent,t,e),addEventListener(i.touchStartEvent,t,e)}this._volume=t.volume.value;const e=t.events;this._audioMap=new Map;for(const t of e){if(!t.audio)continue;const e=(0,i.executeOnSingleOrMultiple)(t.audio,(async t=>{const e=await fetch(t.source);if(!e.ok)return;const n=await e.arrayBuffer(),i=this._getAudioContext(),s=await i.decodeAudioData(n);this._audioMap.set(t.source,s)}));e instanceof Promise?await e:await Promise.allSettled(e)}}async mute(){this._container.muted||await this.toggleMute()}async start(){const t=this._container,e=t.actualOptions,n=e.sounds;if(!n?.enable||!t.canvas.element)return;t.muted=!0;const i=t.canvas.element,o={top:i.offsetTop,right:i.offsetLeft+i.offsetWidth},{mute:u,unmute:c,volumeDown:r,volumeUp:l}=n.icons,h=async()=>{await this.toggleMute()},d=n.icons.enable?"block":"none";this._muteImg=a({container:t,options:e,pos:o,display:d,iconOptions:u,margin:10,rightOffsets:[r.width,l.width],clickCb:h}),this._unmuteImg=a({container:t,options:e,pos:o,display:"none",iconOptions:c,margin:10,rightOffsets:[r.width,l.width],clickCb:h}),this._volumeDownImg=a({container:t,options:e,pos:o,display:d,iconOptions:r,margin:10,rightOffsets:[l.width],clickCb:async()=>{await this.volumeDown()}}),this._volumeUpImg=a({container:t,options:e,pos:o,display:d,iconOptions:l,margin:10,rightOffsets:[],clickCb:async()=>{await this.volumeUp()}}),!(0,s.E3)()&&n.autoPlay&&await this.unmute()}stop(){this._container.muted=!0,(async()=>{await this._mute(),u(this._muteImg),u(this._unmuteImg),u(this._volumeDownImg),u(this._volumeUpImg)})()}async toggleMute(){const t=this._container;t.muted=!t.muted,this._updateMuteIcons(),await this._updateMuteStatus()}async unmute(){this._container.muted&&await this.toggleMute()}async volumeDown(){const t=this._container,e=t.actualOptions.sounds;e?.enable&&(t.muted&&(this._volume=0),this._volume-=e.volume.step,await this._updateVolume())}async volumeUp(){const t=this._container.actualOptions.sounds;t?.enable&&(this._volume+=t.volume.step,await this._updateVolume())}_getAudioContext(){const t=this._container;return t.audioContext||(t.audioContext=new AudioContext),t.audioContext}}}}]);
@@ -1 +0,0 @@
1
- /*! tsParticles Sounds Plugin v3.3.0 by Matteo Bruni */
package/999.min.js DELETED
@@ -1,2 +0,0 @@
1
- /*! For license information please see 999.min.js.LICENSE.txt */
2
- (this.webpackChunk_tsparticles_plugin_sounds=this.webpackChunk_tsparticles_plugin_sounds||[]).push([[999],{999:(t,s,e)=>{e.d(s,{SoundsPlugin:()=>w});var i=e(303);class n{constructor(){this.loop=!1,this.source=""}load(t){void 0!==t&&((0,i.isObject)(t)?(void 0!==t.loop&&(this.loop=t.loop),void 0!==t.source&&(this.source=t.source)):this.source=t)}}class o{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 l{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 s=new l;return s.load(t),s}))),void 0!==t.notes&&(this.notes=t.notes.map((t=>{const s=new o;return s.load(t),s}))))}}class c{constructor(){this.event=[],this.notes=[]}load(t){if(t&&(void 0!==t.event&&(this.event=t.event),void 0!==t.audio&&((0,i.isArray)(t.audio)?this.audio=t.audio.map((t=>{const s=new n;return s.load(t),s})):(this.audio=new n,this.audio.load(t.audio))),void 0!==t.notes&&(this.notes=t.notes.map((t=>{const s=new o;return s.load(t),s}))),void 0!==t.melodies&&(this.melodies=t.melodies.map((t=>{const s=new l;return s.load(t),s}))),t.filter))if((0,i.isString)(t.filter)){const s=window[t.filter];(0,i.isFunction)(s)&&(this.filter=s)}else this.filter=t.filter}}class a{constructor(){this.width=24,this.height=24,this.style=""}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 h{constructor(){this.mute=new a,this.unmute=new a,this.volumeDown=new a,this.volumeUp=new a,this.enable=!1,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&&(void 0!==t.enable&&(this.enable=t.enable),this.mute.load(t.mute),this.unmute.load(t.unmute),this.volumeDown.load(t.volumeDown),this.volumeUp.load(t.volumeUp))}}class v{constructor(){this.value=100,this.max=100,this.min=0,this.step=10}load(t){void 0!==t&&((0,i.isObject)(t)?(void 0!==t.max&&(this.max=t.max),void 0!==t.min&&(this.min=t.min),void 0!==t.step&&(this.step=t.step),void 0!==t.value&&(this.value=t.value)):this.value=t)}}class d{constructor(){this.autoPlay=!0,this.enable=!1,this.events=[],this.icons=new h,this.volume=new v}load(t){t&&(void 0!==t.autoPlay&&(this.autoPlay=t.autoPlay),void 0!==t.enable&&(this.enable=t.enable),void 0!==t.events&&(this.events=t.events.map((t=>{const s=new c;return s.load(t),s}))),this.icons.load(t.icons),void 0!==t.volume&&this.volume.load(t.volume))}}var r=e(972);const u=()=>{removeEventListener(i.mouseDownEvent,u),removeEventListener(i.touchStartEvent,u),(0,r.XK)()};class w{constructor(t){this.id="sounds",this._engine=t;const s={capture:!0,once:!0};addEventListener(i.mouseDownEvent,u,s),addEventListener(i.touchStartEvent,u,s)}async getPlugin(t){const{SoundsInstance:s}=await e.e(826).then(e.bind(e,826));return new s(t,this._engine)}loadOptions(t,s){if(!this.needsPlugin(t)&&!this.needsPlugin(s))return;let e=t.sounds;void 0===e?.load&&(t.sounds=e=new d),e.load(s?.sounds)}needsPlugin(t){return t?.sounds?.enable??!1}}},972:(t,s,e)=>{e.d(s,{E3:()=>l,XK:()=>c,jE:()=>n});const i=new Map;function n(t){const s=/(([A-G]b?)(\d))|pause/i.exec(t);if(!s?.length)return;const e=s[2]||s[0],n=i.get(e);return n?n[parseInt(s[3]||"0")]:void 0}i.set("C",[16.35,32.7,65.41,130.81,261.63,523.25,1046.5,2093,4186.01]),i.set("Db",[17.32,34.65,69.3,138.59,277.18,554.37,1108.73,2217.46,4434.92]),i.set("D",[18.35,36.71,73.42,146.83,293.66,587.33,1174.66,2349.32,4698.63]),i.set("Eb",[19.45,38.89,77.78,155.56,311.13,622.25,1244.51,2489.02,4978.03]),i.set("E",[20.6,41.2,82.41,164.81,329.63,659.25,1318.51,2637.02,5274.04]),i.set("F",[21.83,43.65,87.31,174.61,349.23,698.46,1396.91,2793.83,5587.65]),i.set("Gb",[23.12,46.25,92.5,185,369.99,739.99,1479.98,2959.96,5919.91]),i.set("G",[24.5,49,98,196,392,783.99,1567.98,3135.96,6271.93]),i.set("Ab",[25.96,51.91,103.83,207.65,415.3,830.61,1661.22,3322.44,6644.88]),i.set("A",[27.5,55,110,220,440,880,1760,3520,7040]),i.set("Bb",[29.14,58.27,116.54,233.08,466.16,932.33,1864.66,3729.31,7458.62]),i.set("B",[30.87,61.74,123.47,246.94,493.88,987.77,1975.53,3951.07,7902.13]),i.set("pause",[0]);let o=!0;const l=()=>o,c=()=>{o=!1}}}]);
@@ -1 +0,0 @@
1
- /*! tsParticles Sounds Plugin v3.3.0 by Matteo Bruni */
@@ -1,30 +0,0 @@
1
- /*!
2
- * Author : Matteo Bruni
3
- * MIT license: https://opensource.org/licenses/MIT
4
- * Demo / Generator : https://particles.js.org/
5
- * GitHub : https://www.github.com/matteobruni/tsparticles
6
- * How to use? : Check the GitHub README
7
- * v3.3.0
8
- */
9
- "use strict";
10
- /*
11
- * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
12
- * This devtool is neither made for production nor for readable output files.
13
- * It uses "eval()" calls to create a separate source file in the browser devtools.
14
- * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
15
- * or disable the default devtool with "devtool: false".
16
- * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
17
- */
18
- (this["webpackChunk_tsparticles_plugin_sounds"] = this["webpackChunk_tsparticles_plugin_sounds"] || []).push([["dist_browser_SoundsInstance_js"],{
19
-
20
- /***/ "./dist/browser/SoundsInstance.js":
21
- /*!****************************************!*\
22
- !*** ./dist/browser/SoundsInstance.js ***!
23
- \****************************************/
24
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
25
-
26
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SoundsInstance: () => (/* binding */ SoundsInstance)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ \"./dist/browser/utils.js\");\n\n\nconst zIndexOffset = 1,\n rightOffset = 1,\n minVolume = 0;\nfunction initImage(data) {\n const img = document.createElement(\"img\"),\n {\n clickCb,\n container,\n display,\n iconOptions,\n margin,\n options,\n pos,\n rightOffsets\n } = data,\n {\n width,\n path,\n style,\n svg\n } = iconOptions,\n defaultAccumulator = 0;\n setIconStyle(img, pos.top + margin, pos.right - (margin * (rightOffsets.length + rightOffset) + width + rightOffsets.reduce((a, b) => a + b, defaultAccumulator)), display, options.fullScreen.zIndex + zIndexOffset, width, margin, style);\n img.src = path ?? (svg ? `data:image/svg+xml;base64,${btoa(svg)}` : \"\");\n const parent = container.canvas.element?.parentNode ?? document.body;\n parent.append(img);\n img.addEventListener(\"click\", () => {\n void clickCb();\n });\n return img;\n}\nfunction removeImage(image) {\n if (!image) {\n return;\n }\n image.remove();\n}\nfunction setIconStyle(icon, top, left, display, zIndex, width, margin, style) {\n icon.style.userSelect = \"none\";\n icon.style.webkitUserSelect = \"none\";\n icon.style.position = \"absolute\";\n icon.style.top = `${top + margin}px`;\n icon.style.left = `${left - margin - width}px`;\n icon.style.display = display;\n icon.style.zIndex = `${zIndex + zIndexOffset}`;\n icon.style.cssText += style;\n}\nclass SoundsInstance {\n constructor(container, engine) {\n this._addBuffer = audioCtx => {\n const buffer = audioCtx.createBufferSource();\n this._audioSources.push(buffer);\n return buffer;\n };\n this._addOscillator = audioCtx => {\n const oscillator = audioCtx.createOscillator();\n this._audioSources.push(oscillator);\n return oscillator;\n };\n this._initEvents = () => {\n const container = this._container,\n soundsOptions = container.actualOptions.sounds;\n if (!soundsOptions?.enable || !container.canvas.element) {\n return;\n }\n for (const event of soundsOptions.events) {\n const cb = args => {\n void (async () => {\n const filterNotValid = event.filter && !event.filter(args);\n if (this._container !== args.container) {\n return;\n }\n if (!this._container || !!this._container.muted || this._container.destroyed) {\n (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.executeOnSingleOrMultiple)(event.event, item => {\n this._engine.removeEventListener(item, cb);\n });\n return;\n }\n if (filterNotValid) {\n return;\n }\n const defaultNoteIndex = 0;\n if (event.audio) {\n this._playBuffer((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.itemFromSingleOrMultiple)(event.audio));\n } else if (event.melodies) {\n const melody = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.itemFromArray)(event.melodies);\n if (melody.melodies.length) {\n await Promise.allSettled(melody.melodies.map(m => this._playNote(m.notes, defaultNoteIndex, melody.loop)));\n } else {\n await this._playNote(melody.notes, defaultNoteIndex, melody.loop);\n }\n } else if (event.notes) {\n const note = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.itemFromArray)(event.notes);\n await this._playNote([note], defaultNoteIndex, false);\n }\n })();\n };\n (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.executeOnSingleOrMultiple)(event.event, item => {\n this._engine.addEventListener(item, cb);\n });\n }\n };\n this._mute = async () => {\n const container = this._container,\n audioContext = this._getAudioContext();\n for (const source of this._audioSources) {\n this._removeAudioSource(source);\n }\n if (this._gain) {\n this._gain.disconnect();\n }\n await audioContext.close();\n container.audioContext = undefined;\n this._engine.dispatchEvent(\"soundsMuted\", {\n container: this._container\n });\n };\n this._playBuffer = audio => {\n const audioBuffer = this._audioMap.get(audio.source);\n if (!audioBuffer) {\n return;\n }\n const audioCtx = this._container.audioContext;\n if (!audioCtx) {\n return;\n }\n const source = this._addBuffer(audioCtx);\n source.loop = audio.loop;\n source.buffer = audioBuffer;\n source.connect(this._gain ?? audioCtx.destination);\n source.start();\n };\n this._playFrequency = async (frequency, duration) => {\n if (!this._gain || this._container.muted) {\n return;\n }\n const audioContext = this._getAudioContext(),\n oscillator = this._addOscillator(audioContext);\n oscillator.connect(this._gain);\n oscillator.type = \"sine\";\n oscillator.frequency.value = frequency;\n oscillator.start();\n return new Promise(resolve => {\n setTimeout(() => {\n this._removeAudioSource(oscillator);\n resolve();\n }, duration);\n });\n };\n this._playMuteSound = () => {\n if (this._container.muted) {\n return;\n }\n const audioContext = this._getAudioContext(),\n gain = audioContext.createGain();\n gain.connect(audioContext.destination);\n gain.gain.value = 0;\n const oscillator = audioContext.createOscillator();\n oscillator.connect(gain);\n oscillator.type = \"sine\";\n oscillator.frequency.value = 1;\n oscillator.start();\n setTimeout(() => {\n oscillator.stop();\n oscillator.disconnect();\n gain.disconnect();\n });\n };\n this._playNote = async (notes, noteIdx, loop) => {\n if (this._container.muted) {\n return;\n }\n const note = notes[noteIdx];\n if (!note) {\n return;\n }\n const value = note.value;\n const promises = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.executeOnSingleOrMultiple)(value, async (_, idx) => {\n return this._playNoteValue(notes, noteIdx, idx);\n });\n await ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isArray)(promises) ? Promise.allSettled(promises) : promises);\n const indexOffset = 1;\n let nextNoteIdx = noteIdx + indexOffset;\n if (loop && nextNoteIdx >= notes.length) {\n nextNoteIdx = nextNoteIdx % notes.length;\n }\n if (this._container.muted) {\n return;\n }\n await this._playNote(notes, nextNoteIdx, loop);\n };\n this._playNoteValue = async (notes, noteIdx, valueIdx) => {\n const note = notes[noteIdx];\n if (!note) {\n return;\n }\n const value = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.itemFromSingleOrMultiple)(note.value, valueIdx, true);\n try {\n const freq = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.getNoteFrequency)(value);\n if (!(0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNumber)(freq)) {\n return;\n }\n await this._playFrequency(freq, note.duration);\n } catch (e) {\n (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getLogger)().error(e);\n }\n };\n this._removeAudioSource = source => {\n source.stop();\n source.disconnect();\n const deleteCount = 1;\n this._audioSources.splice(this._audioSources.indexOf(source), deleteCount);\n };\n this._unmute = () => {\n const container = this._container,\n options = container.actualOptions,\n soundsOptions = options.sounds;\n if (!soundsOptions) {\n return;\n }\n const audioContext = this._getAudioContext();\n if (!this._audioSources) {\n this._audioSources = [];\n }\n const gain = audioContext.createGain();\n gain.connect(audioContext.destination);\n gain.gain.value = soundsOptions.volume.value / _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.percentDenominator;\n this._gain = gain;\n this._initEvents();\n this._engine.dispatchEvent(\"soundsUnmuted\", {\n container: this._container\n });\n };\n this._updateMuteIcons = () => {\n const container = this._container,\n soundsOptions = container.actualOptions.sounds;\n if (!soundsOptions?.enable || !soundsOptions.icons.enable) {\n return;\n }\n const muteImg = this._muteImg,\n unmuteImg = this._unmuteImg;\n if (muteImg) {\n muteImg.style.display = container.muted ? \"block\" : \"none\";\n }\n if (unmuteImg) {\n unmuteImg.style.display = container.muted ? \"none\" : \"block\";\n }\n };\n this._updateMuteStatus = async () => {\n const container = this._container,\n audioContext = this._getAudioContext();\n if (container.muted) {\n await audioContext?.suspend();\n await this._mute();\n } else {\n await audioContext?.resume();\n this._unmute();\n this._playMuteSound();\n }\n };\n this._updateVolume = async () => {\n const container = this._container,\n soundsOptions = container.actualOptions.sounds;\n if (!soundsOptions?.enable) {\n return;\n }\n (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.clamp)(this._volume, soundsOptions.volume.min, soundsOptions.volume.max);\n let stateChanged = false;\n if (this._volume <= minVolume && !container.muted) {\n this._volume = 0;\n container.muted = true;\n stateChanged = true;\n } else if (this._volume > minVolume && container.muted) {\n container.muted = false;\n stateChanged = true;\n }\n if (stateChanged) {\n this._updateMuteIcons();\n await this._updateMuteStatus();\n }\n if (this._gain?.gain) {\n this._gain.gain.value = this._volume / _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.percentDenominator;\n }\n };\n this._container = container;\n this._engine = engine;\n this._volume = 0;\n this._audioSources = [];\n this._audioMap = new Map();\n }\n async init() {\n const container = this._container,\n options = container.actualOptions,\n soundsOptions = options.sounds;\n if (!soundsOptions?.enable) {\n return;\n }\n if (soundsOptions.autoPlay && (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.isWindowMuted)()) {\n const firstClickHandler = () => {\n removeEventListener(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.mouseDownEvent, firstClickHandler);\n removeEventListener(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.touchStartEvent, firstClickHandler);\n (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.unmuteWindow)();\n void this.unmute();\n };\n const listenerOptions = {\n capture: true,\n once: true\n };\n addEventListener(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.mouseDownEvent, firstClickHandler, listenerOptions);\n addEventListener(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.touchStartEvent, firstClickHandler, listenerOptions);\n }\n this._volume = soundsOptions.volume.value;\n const events = soundsOptions.events;\n this._audioMap = new Map();\n for (const event of events) {\n if (!event.audio) {\n continue;\n }\n const promises = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.executeOnSingleOrMultiple)(event.audio, async audio => {\n const response = await fetch(audio.source);\n if (!response.ok) {\n return;\n }\n const arrayBuffer = await response.arrayBuffer(),\n audioContext = this._getAudioContext(),\n audioBuffer = await audioContext.decodeAudioData(arrayBuffer);\n this._audioMap.set(audio.source, audioBuffer);\n });\n if (promises instanceof Promise) {\n await promises;\n } else {\n await Promise.allSettled(promises);\n }\n }\n }\n async mute() {\n if (!this._container.muted) {\n await this.toggleMute();\n }\n }\n async start() {\n const container = this._container,\n options = container.actualOptions,\n soundsOptions = options.sounds;\n if (!soundsOptions?.enable || !container.canvas.element) {\n return;\n }\n container.muted = true;\n const canvas = container.canvas.element,\n pos = {\n top: canvas.offsetTop,\n right: canvas.offsetLeft + canvas.offsetWidth\n },\n {\n mute,\n unmute,\n volumeDown,\n volumeUp\n } = soundsOptions.icons,\n margin = 10,\n toggleMute = async () => {\n await this.toggleMute();\n },\n enableIcons = soundsOptions.icons.enable,\n display = enableIcons ? \"block\" : \"none\";\n this._muteImg = initImage({\n container,\n options,\n pos,\n display,\n iconOptions: mute,\n margin,\n rightOffsets: [volumeDown.width, volumeUp.width],\n clickCb: toggleMute\n });\n this._unmuteImg = initImage({\n container,\n options,\n pos,\n display: \"none\",\n iconOptions: unmute,\n margin,\n rightOffsets: [volumeDown.width, volumeUp.width],\n clickCb: toggleMute\n });\n this._volumeDownImg = initImage({\n container,\n options,\n pos,\n display,\n iconOptions: volumeDown,\n margin,\n rightOffsets: [volumeUp.width],\n clickCb: async () => {\n await this.volumeDown();\n }\n });\n this._volumeUpImg = initImage({\n container,\n options,\n pos,\n display,\n iconOptions: volumeUp,\n margin,\n rightOffsets: [],\n clickCb: async () => {\n await this.volumeUp();\n }\n });\n if (!(0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.isWindowMuted)() && soundsOptions.autoPlay) {\n await this.unmute();\n }\n }\n stop() {\n this._container.muted = true;\n void (async () => {\n await this._mute();\n removeImage(this._muteImg);\n removeImage(this._unmuteImg);\n removeImage(this._volumeDownImg);\n removeImage(this._volumeUpImg);\n })();\n }\n async toggleMute() {\n const container = this._container;\n container.muted = !container.muted;\n this._updateMuteIcons();\n await this._updateMuteStatus();\n }\n async unmute() {\n if (this._container.muted) {\n await this.toggleMute();\n }\n }\n async volumeDown() {\n const container = this._container,\n soundsOptions = container.actualOptions.sounds;\n if (!soundsOptions?.enable) {\n return;\n }\n if (container.muted) {\n this._volume = 0;\n }\n this._volume -= soundsOptions.volume.step;\n await this._updateVolume();\n }\n async volumeUp() {\n const container = this._container,\n soundsOptions = container.actualOptions.sounds;\n if (!soundsOptions?.enable) {\n return;\n }\n this._volume += soundsOptions.volume.step;\n await this._updateVolume();\n }\n _getAudioContext() {\n const container = this._container;\n if (!container.audioContext) {\n container.audioContext = new AudioContext();\n }\n return container.audioContext;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-sounds/./dist/browser/SoundsInstance.js?");
27
-
28
- /***/ })
29
-
30
- }]);
@@ -1,120 +0,0 @@
1
- /*!
2
- * Author : Matteo Bruni
3
- * MIT license: https://opensource.org/licenses/MIT
4
- * Demo / Generator : https://particles.js.org/
5
- * GitHub : https://www.github.com/matteobruni/tsparticles
6
- * How to use? : Check the GitHub README
7
- * v3.3.0
8
- */
9
- "use strict";
10
- /*
11
- * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
12
- * This devtool is neither made for production nor for readable output files.
13
- * It uses "eval()" calls to create a separate source file in the browser devtools.
14
- * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
15
- * or disable the default devtool with "devtool: false".
16
- * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
17
- */
18
- (this["webpackChunk_tsparticles_plugin_sounds"] = this["webpackChunk_tsparticles_plugin_sounds"] || []).push([["dist_browser_SoundsPlugin_js"],{
19
-
20
- /***/ "./dist/browser/Options/Classes/Sounds.js":
21
- /*!************************************************!*\
22
- !*** ./dist/browser/Options/Classes/Sounds.js ***!
23
- \************************************************/
24
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
25
-
26
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Sounds: () => (/* binding */ Sounds)\n/* harmony export */ });\n/* harmony import */ var _SoundsEvent_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./SoundsEvent.js */ \"./dist/browser/Options/Classes/SoundsEvent.js\");\n/* harmony import */ var _SoundsIcons_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./SoundsIcons.js */ \"./dist/browser/Options/Classes/SoundsIcons.js\");\n/* harmony import */ var _SoundsVolume_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./SoundsVolume.js */ \"./dist/browser/Options/Classes/SoundsVolume.js\");\n\n\n\nclass Sounds {\n constructor() {\n this.autoPlay = true;\n this.enable = false;\n this.events = [];\n this.icons = new _SoundsIcons_js__WEBPACK_IMPORTED_MODULE_0__.SoundsIcons();\n this.volume = new _SoundsVolume_js__WEBPACK_IMPORTED_MODULE_1__.SoundsVolume();\n }\n load(data) {\n if (!data) {\n return;\n }\n if (data.autoPlay !== undefined) {\n this.autoPlay = data.autoPlay;\n }\n if (data.enable !== undefined) {\n this.enable = data.enable;\n }\n if (data.events !== undefined) {\n this.events = data.events.map(t => {\n const event = new _SoundsEvent_js__WEBPACK_IMPORTED_MODULE_2__.SoundsEvent();\n event.load(t);\n return event;\n });\n }\n this.icons.load(data.icons);\n if (data.volume !== undefined) {\n this.volume.load(data.volume);\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-sounds/./dist/browser/Options/Classes/Sounds.js?");
27
-
28
- /***/ }),
29
-
30
- /***/ "./dist/browser/Options/Classes/SoundsAudio.js":
31
- /*!*****************************************************!*\
32
- !*** ./dist/browser/Options/Classes/SoundsAudio.js ***!
33
- \*****************************************************/
34
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
35
-
36
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SoundsAudio: () => (/* binding */ SoundsAudio)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n\nclass SoundsAudio {\n constructor() {\n this.loop = false;\n this.source = \"\";\n }\n load(data) {\n if (data === undefined) {\n return;\n }\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isObject)(data)) {\n if (data.loop !== undefined) {\n this.loop = data.loop;\n }\n if (data.source !== undefined) {\n this.source = data.source;\n }\n } else {\n this.source = data;\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-sounds/./dist/browser/Options/Classes/SoundsAudio.js?");
37
-
38
- /***/ }),
39
-
40
- /***/ "./dist/browser/Options/Classes/SoundsEvent.js":
41
- /*!*****************************************************!*\
42
- !*** ./dist/browser/Options/Classes/SoundsEvent.js ***!
43
- \*****************************************************/
44
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
45
-
46
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SoundsEvent: () => (/* binding */ SoundsEvent)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _SoundsAudio_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./SoundsAudio.js */ \"./dist/browser/Options/Classes/SoundsAudio.js\");\n/* harmony import */ var _SoundsMelody_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./SoundsMelody.js */ \"./dist/browser/Options/Classes/SoundsMelody.js\");\n/* harmony import */ var _SoundsNote_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./SoundsNote.js */ \"./dist/browser/Options/Classes/SoundsNote.js\");\n\n\n\n\nclass SoundsEvent {\n constructor() {\n this.event = [];\n this.notes = [];\n }\n load(data) {\n if (!data) {\n return;\n }\n if (data.event !== undefined) {\n this.event = data.event;\n }\n if (data.audio !== undefined) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isArray)(data.audio)) {\n this.audio = data.audio.map(s => {\n const tmp = new _SoundsAudio_js__WEBPACK_IMPORTED_MODULE_1__.SoundsAudio();\n tmp.load(s);\n return tmp;\n });\n } else {\n this.audio = new _SoundsAudio_js__WEBPACK_IMPORTED_MODULE_1__.SoundsAudio();\n this.audio.load(data.audio);\n }\n }\n if (data.notes !== undefined) {\n this.notes = data.notes.map(t => {\n const tmp = new _SoundsNote_js__WEBPACK_IMPORTED_MODULE_2__.SoundsNote();\n tmp.load(t);\n return tmp;\n });\n }\n if (data.melodies !== undefined) {\n this.melodies = data.melodies.map(t => {\n const tmp = new _SoundsMelody_js__WEBPACK_IMPORTED_MODULE_3__.SoundsMelody();\n tmp.load(t);\n return tmp;\n });\n }\n if (data.filter) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isString)(data.filter)) {\n const filterFunc = window[data.filter];\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isFunction)(filterFunc)) {\n this.filter = filterFunc;\n }\n } else {\n this.filter = data.filter;\n }\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-sounds/./dist/browser/Options/Classes/SoundsEvent.js?");
47
-
48
- /***/ }),
49
-
50
- /***/ "./dist/browser/Options/Classes/SoundsIcon.js":
51
- /*!****************************************************!*\
52
- !*** ./dist/browser/Options/Classes/SoundsIcon.js ***!
53
- \****************************************************/
54
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
55
-
56
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SoundsIcon: () => (/* binding */ SoundsIcon)\n/* harmony export */ });\nclass SoundsIcon {\n constructor() {\n this.width = 24;\n this.height = 24;\n this.style = \"\";\n }\n load(data) {\n if (!data) {\n return;\n }\n if (data.path !== undefined) {\n this.path = data.path;\n }\n if (data.svg !== undefined) {\n this.svg = data.svg;\n }\n if (data.width !== undefined) {\n this.width = data.width;\n }\n if (data.height !== undefined) {\n this.height = data.height;\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-sounds/./dist/browser/Options/Classes/SoundsIcon.js?");
57
-
58
- /***/ }),
59
-
60
- /***/ "./dist/browser/Options/Classes/SoundsIcons.js":
61
- /*!*****************************************************!*\
62
- !*** ./dist/browser/Options/Classes/SoundsIcons.js ***!
63
- \*****************************************************/
64
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
65
-
66
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SoundsIcons: () => (/* binding */ SoundsIcons)\n/* harmony export */ });\n/* harmony import */ var _SoundsIcon_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./SoundsIcon.js */ \"./dist/browser/Options/Classes/SoundsIcon.js\");\n\nclass SoundsIcons {\n constructor() {\n this.mute = new _SoundsIcon_js__WEBPACK_IMPORTED_MODULE_0__.SoundsIcon();\n this.unmute = new _SoundsIcon_js__WEBPACK_IMPORTED_MODULE_0__.SoundsIcon();\n this.volumeDown = new _SoundsIcon_js__WEBPACK_IMPORTED_MODULE_0__.SoundsIcon();\n this.volumeUp = new _SoundsIcon_js__WEBPACK_IMPORTED_MODULE_0__.SoundsIcon();\n this.enable = false;\n 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>`;\n 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>`;\n 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>`;\n 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>`;\n }\n load(data) {\n if (!data) {\n return;\n }\n if (data.enable !== undefined) {\n this.enable = data.enable;\n }\n this.mute.load(data.mute);\n this.unmute.load(data.unmute);\n this.volumeDown.load(data.volumeDown);\n this.volumeUp.load(data.volumeUp);\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-sounds/./dist/browser/Options/Classes/SoundsIcons.js?");
67
-
68
- /***/ }),
69
-
70
- /***/ "./dist/browser/Options/Classes/SoundsMelody.js":
71
- /*!******************************************************!*\
72
- !*** ./dist/browser/Options/Classes/SoundsMelody.js ***!
73
- \******************************************************/
74
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
75
-
76
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SoundsMelody: () => (/* binding */ SoundsMelody)\n/* harmony export */ });\n/* harmony import */ var _SoundsNote_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./SoundsNote.js */ \"./dist/browser/Options/Classes/SoundsNote.js\");\n\nclass SoundsMelody {\n constructor() {\n this.loop = false;\n this.melodies = [];\n this.notes = [];\n }\n load(data) {\n if (data === undefined) {\n return;\n }\n if (data.loop !== undefined) {\n this.loop = data.loop;\n }\n if (data.melodies !== undefined) {\n this.melodies = data.melodies.map(s => {\n const tmp = new SoundsMelody();\n tmp.load(s);\n return tmp;\n });\n }\n if (data.notes !== undefined) {\n this.notes = data.notes.map(s => {\n const tmp = new _SoundsNote_js__WEBPACK_IMPORTED_MODULE_0__.SoundsNote();\n tmp.load(s);\n return tmp;\n });\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-sounds/./dist/browser/Options/Classes/SoundsMelody.js?");
77
-
78
- /***/ }),
79
-
80
- /***/ "./dist/browser/Options/Classes/SoundsNote.js":
81
- /*!****************************************************!*\
82
- !*** ./dist/browser/Options/Classes/SoundsNote.js ***!
83
- \****************************************************/
84
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
85
-
86
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SoundsNote: () => (/* binding */ SoundsNote)\n/* harmony export */ });\nclass SoundsNote {\n constructor() {\n this.duration = 500;\n this.value = [];\n }\n load(data) {\n if (!data) {\n return;\n }\n if (data.duration !== undefined) {\n this.duration = data.duration;\n }\n if (data.value !== undefined) {\n this.value = data.value;\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-sounds/./dist/browser/Options/Classes/SoundsNote.js?");
87
-
88
- /***/ }),
89
-
90
- /***/ "./dist/browser/Options/Classes/SoundsVolume.js":
91
- /*!******************************************************!*\
92
- !*** ./dist/browser/Options/Classes/SoundsVolume.js ***!
93
- \******************************************************/
94
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
95
-
96
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SoundsVolume: () => (/* binding */ SoundsVolume)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n\nclass SoundsVolume {\n constructor() {\n this.value = 100;\n this.max = 100;\n this.min = 0;\n this.step = 10;\n }\n load(data) {\n if (data === undefined) {\n return;\n }\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isObject)(data)) {\n if (data.max !== undefined) {\n this.max = data.max;\n }\n if (data.min !== undefined) {\n this.min = data.min;\n }\n if (data.step !== undefined) {\n this.step = data.step;\n }\n if (data.value !== undefined) {\n this.value = data.value;\n }\n } else {\n this.value = data;\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-sounds/./dist/browser/Options/Classes/SoundsVolume.js?");
97
-
98
- /***/ }),
99
-
100
- /***/ "./dist/browser/SoundsPlugin.js":
101
- /*!**************************************!*\
102
- !*** ./dist/browser/SoundsPlugin.js ***!
103
- \**************************************/
104
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
105
-
106
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SoundsPlugin: () => (/* binding */ SoundsPlugin)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _Options_Classes_Sounds_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Options/Classes/Sounds.js */ \"./dist/browser/Options/Classes/Sounds.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ \"./dist/browser/utils.js\");\n\n\n\nconst generalFirstClickHandler = () => {\n removeEventListener(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.mouseDownEvent, generalFirstClickHandler);\n removeEventListener(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.touchStartEvent, generalFirstClickHandler);\n (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.unmuteWindow)();\n};\nclass SoundsPlugin {\n constructor(engine) {\n this.id = \"sounds\";\n this._engine = engine;\n const listenerOptions = {\n capture: true,\n once: true\n };\n addEventListener(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.mouseDownEvent, generalFirstClickHandler, listenerOptions);\n addEventListener(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.touchStartEvent, generalFirstClickHandler, listenerOptions);\n }\n async getPlugin(container) {\n const {\n SoundsInstance\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_SoundsInstance_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./SoundsInstance.js */ \"./dist/browser/SoundsInstance.js\"));\n return new SoundsInstance(container, this._engine);\n }\n loadOptions(options, source) {\n if (!this.needsPlugin(options) && !this.needsPlugin(source)) {\n return;\n }\n let soundsOptions = options.sounds;\n if (soundsOptions?.load === undefined) {\n options.sounds = soundsOptions = new _Options_Classes_Sounds_js__WEBPACK_IMPORTED_MODULE_2__.Sounds();\n }\n soundsOptions.load(source?.sounds);\n }\n needsPlugin(options) {\n return options?.sounds?.enable ?? false;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-sounds/./dist/browser/SoundsPlugin.js?");
107
-
108
- /***/ }),
109
-
110
- /***/ "./dist/browser/utils.js":
111
- /*!*******************************!*\
112
- !*** ./dist/browser/utils.js ***!
113
- \*******************************/
114
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
115
-
116
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ getNoteFrequency: () => (/* binding */ getNoteFrequency),\n/* harmony export */ isWindowMuted: () => (/* binding */ isWindowMuted),\n/* harmony export */ unmuteWindow: () => (/* binding */ unmuteWindow)\n/* harmony export */ });\nconst notes = new Map();\nnotes.set(\"C\", [16.35, 32.7, 65.41, 130.81, 261.63, 523.25, 1046.5, 2093.0, 4186.01]);\nnotes.set(\"Db\", [17.32, 34.65, 69.3, 138.59, 277.18, 554.37, 1108.73, 2217.46, 4434.92]);\nnotes.set(\"D\", [18.35, 36.71, 73.42, 146.83, 293.66, 587.33, 1174.66, 2349.32, 4698.63]);\nnotes.set(\"Eb\", [19.45, 38.89, 77.78, 155.56, 311.13, 622.25, 1244.51, 2489.02, 4978.03]);\nnotes.set(\"E\", [20.6, 41.2, 82.41, 164.81, 329.63, 659.25, 1318.51, 2637.02, 5274.04]);\nnotes.set(\"F\", [21.83, 43.65, 87.31, 174.61, 349.23, 698.46, 1396.91, 2793.83, 5587.65]);\nnotes.set(\"Gb\", [23.12, 46.25, 92.5, 185.0, 369.99, 739.99, 1479.98, 2959.96, 5919.91]);\nnotes.set(\"G\", [24.5, 49.0, 98.0, 196.0, 392.0, 783.99, 1567.98, 3135.96, 6271.93]);\nnotes.set(\"Ab\", [25.96, 51.91, 103.83, 207.65, 415.3, 830.61, 1661.22, 3322.44, 6644.88]);\nnotes.set(\"A\", [27.5, 55.0, 110.0, 220.0, 440.0, 880.0, 1760.0, 3520.0, 7040.0]);\nnotes.set(\"Bb\", [29.14, 58.27, 116.54, 233.08, 466.16, 932.33, 1864.66, 3729.31, 7458.62]);\nnotes.set(\"B\", [30.87, 61.74, 123.47, 246.94, 493.88, 987.77, 1975.53, 3951.07, 7902.13]);\nnotes.set(\"pause\", [0]);\nfunction getNoteFrequency(note) {\n const regex = /(([A-G]b?)(\\d))|pause/i,\n result = regex.exec(note),\n groupKey = 2,\n defaultMatchKey = 0,\n innerGroupKey = 3;\n if (!result?.length) {\n return;\n }\n const noteKey = result[groupKey] || result[defaultMatchKey],\n noteItem = notes.get(noteKey);\n if (!noteItem) {\n return;\n }\n return noteItem[parseInt(result[innerGroupKey] || \"0\")];\n}\nlet muted = true;\nconst isWindowMuted = () => {\n return muted;\n};\nconst unmuteWindow = () => {\n muted = false;\n};\n\n//# sourceURL=webpack://@tsparticles/plugin-sounds/./dist/browser/utils.js?");
117
-
118
- /***/ })
119
-
120
- }]);