@tsparticles/plugin-sounds 4.0.0-beta.1 → 4.0.0-beta.11

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 (36) hide show
  1. package/{414.min.js → 300.min.js} +2 -2
  2. package/86.min.js +1 -0
  3. package/README.md +22 -0
  4. package/browser/index.js +1 -1
  5. package/cjs/index.js +1 -1
  6. package/dist_browser_SoundsPluginInstance_js.js +1 -1
  7. package/dist_browser_SoundsPlugin_js.js +1 -1
  8. package/esm/index.js +1 -1
  9. package/package.json +4 -5
  10. package/report.html +1 -1
  11. package/tsparticles.plugin.sounds.js +2 -2
  12. package/tsparticles.plugin.sounds.min.js +1 -1
  13. package/4.min.js +0 -1
  14. package/umd/Options/Classes/Sounds.js +0 -54
  15. package/umd/Options/Classes/SoundsAudio.js +0 -39
  16. package/umd/Options/Classes/SoundsEvent.js +0 -75
  17. package/umd/Options/Classes/SoundsIcon.js +0 -44
  18. package/umd/Options/Classes/SoundsIcons.js +0 -78
  19. package/umd/Options/Classes/SoundsMelody.js +0 -48
  20. package/umd/Options/Classes/SoundsNote.js +0 -34
  21. package/umd/Options/Classes/SoundsVolume.js +0 -49
  22. package/umd/Options/Interfaces/ISounds.js +0 -12
  23. package/umd/Options/Interfaces/ISoundsAudio.js +0 -12
  24. package/umd/Options/Interfaces/ISoundsEvent.js +0 -12
  25. package/umd/Options/Interfaces/ISoundsIcon.js +0 -12
  26. package/umd/Options/Interfaces/ISoundsIcons.js +0 -12
  27. package/umd/Options/Interfaces/ISoundsMelody.js +0 -12
  28. package/umd/Options/Interfaces/ISoundsNote.js +0 -12
  29. package/umd/Options/Interfaces/ISoundsVolume.js +0 -12
  30. package/umd/SoundsPlugin.js +0 -86
  31. package/umd/SoundsPluginInstance.js +0 -451
  32. package/umd/constants.js +0 -14
  33. package/umd/enums.js +0 -23
  34. package/umd/index.js +0 -54
  35. package/umd/types.js +0 -12
  36. package/umd/utils.js +0 -48
@@ -1,4 +1,4 @@
1
- "use strict";(this.webpackChunk_tsparticles_plugin_sounds=this.webpackChunk_tsparticles_plugin_sounds||[]).push([[414],{414(e,t,s){s.d(t,{SoundsPlugin:()=>m});var i=s(699),l=s(303);class o{loop;source;constructor(){this.loop=!1,this.source=""}load(e){(0,l.isNull)(e)||((0,l.isObject)(e)?(void 0!==e.loop&&(this.loop=e.loop),void 0!==e.source&&(this.source=e.source)):this.source=e)}}class n{duration;value;constructor(){this.duration=500,this.value=[]}load(e){(0,l.isNull)(e)||(void 0!==e.duration&&(this.duration=e.duration),void 0!==e.value&&(this.value=e.value))}}class a{loop;melodies;notes;constructor(){this.loop=!1,this.melodies=[],this.notes=[]}load(e){(0,l.isNull)(e)||(void 0!==e.loop&&(this.loop=e.loop),void 0!==e.melodies&&(this.melodies=e.melodies.map(e=>{let t=new a;return t.load(e),t})),void 0!==e.notes&&(this.notes=e.notes.map(e=>{let t=new n;return t.load(e),t})))}}class c{audio;event;filter;melodies;notes;constructor(){this.event=[],this.notes=[]}load(e){if(!(0,l.isNull)(e)&&(void 0!==e.event&&(this.event=e.event),void 0!==e.audio&&((0,l.isArray)(e.audio)?this.audio=e.audio.map(e=>{let t=new o;return t.load(e),t}):(this.audio=new o,this.audio.load(e.audio))),void 0!==e.notes&&(this.notes=e.notes.map(e=>{let t=new n;return t.load(e),t})),void 0!==e.melodies&&(this.melodies=e.melodies.map(e=>{let t=new a;return t.load(e),t})),e.filter))if((0,l.isString)(e.filter)){let t=globalThis[e.filter];(0,l.isFunction)(t)&&(this.filter=t)}else this.filter=e.filter}}class h{height;path;style;svg;width;constructor(){this.width=24,this.height=24,this.style=""}load(e){(0,l.isNull)(e)||(void 0!==e.path&&(this.path=e.path),void 0!==e.svg&&(this.svg=e.svg),void 0!==e.width&&(this.width=e.width),void 0!==e.height&&(this.height=e.height))}}class u{enable;mute;unmute;volumeDown;volumeUp;constructor(){this.mute=new h,this.unmute=new h,this.volumeDown=new h,this.volumeUp=new h,this.enable=!1,this.mute.svg=`<?xml version="1.0"?>
1
+ "use strict";(this.webpackChunk_tsparticles_plugin_sounds=this.webpackChunk_tsparticles_plugin_sounds||[]).push([[300],{300(e,t,s){s.d(t,{SoundsPlugin:()=>m});var i=s(886),l=s(303);class o{loop;source;constructor(){this.loop=!1,this.source=""}load(e){(0,l.isNull)(e)||((0,l.isObject)(e)?(void 0!==e.loop&&(this.loop=e.loop),void 0!==e.source&&(this.source=e.source)):this.source=e)}}class n{duration;value;constructor(){this.duration=500,this.value=[]}load(e){(0,l.isNull)(e)||(void 0!==e.duration&&(this.duration=e.duration),void 0!==e.value&&(this.value=e.value))}}class a{loop;melodies;notes;constructor(){this.loop=!1,this.melodies=[],this.notes=[]}load(e){(0,l.isNull)(e)||(void 0!==e.loop&&(this.loop=e.loop),void 0!==e.melodies&&(this.melodies=e.melodies.map(e=>{let t=new a;return t.load(e),t})),void 0!==e.notes&&(this.notes=e.notes.map(e=>{let t=new n;return t.load(e),t})))}}class c{audio;event;filter;melodies;notes;constructor(){this.event=[],this.notes=[]}load(e){if(!(0,l.isNull)(e)&&(void 0!==e.event&&(this.event=e.event),void 0!==e.audio&&((0,l.isArray)(e.audio)?this.audio=e.audio.map(e=>{let t=new o;return t.load(e),t}):(this.audio=new o,this.audio.load(e.audio))),void 0!==e.notes&&(this.notes=e.notes.map(e=>{let t=new n;return t.load(e),t})),void 0!==e.melodies&&(this.melodies=e.melodies.map(e=>{let t=new a;return t.load(e),t})),e.filter))if((0,l.isString)(e.filter)){let t=globalThis[e.filter];(0,l.isFunction)(t)&&(this.filter=t)}else this.filter=e.filter}}class h{height;path;style;svg;width;constructor(){this.width=24,this.height=24,this.style=""}load(e){(0,l.isNull)(e)||(void 0!==e.path&&(this.path=e.path),void 0!==e.svg&&(this.svg=e.svg),void 0!==e.width&&(this.width=e.width),void 0!==e.height&&(this.height=e.height))}}class u{enable;mute;unmute;volumeDown;volumeUp;constructor(){this.mute=new h,this.unmute=new h,this.volumeDown=new h,this.volumeUp=new h,this.enable=!1,this.mute.svg=`<?xml version="1.0"?>
2
2
  <svg baseProfile="tiny" height="24px" version="1.2" viewBox="0 0 24 24" width="24px"
3
3
  xml:space="preserve" xmlns="http://www.w3.org/2000/svg"
4
4
  xmlns:xlink="http://www.w3.org/1999/xlink">
@@ -30,4 +30,4 @@
30
30
  <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"/>
31
31
  <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"/>
32
32
  </g>
33
- </svg>`}load(e){(0,l.isNull)(e)||(void 0!==e.enable&&(this.enable=e.enable),this.mute.load(e.mute),this.unmute.load(e.unmute),this.volumeDown.load(e.volumeDown),this.volumeUp.load(e.volumeUp))}}class v{max;min;step;value;constructor(){this.value=100,this.max=100,this.min=0,this.step=10}load(e){(0,l.isNull)(e)||((0,l.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 d{autoPlay;enable;events;icons;volume;constructor(){this.autoPlay=!0,this.enable=!1,this.events=[],this.icons=new u,this.volume=new v}load(e){(0,l.isNull)(e)||(void 0!==e.autoPlay&&(this.autoPlay=e.autoPlay),void 0!==e.enable&&(this.enable=e.enable),void 0!==e.events&&(this.events=e.events.map(e=>{let t=new c;return t.load(e),t})),this.icons.load(e.icons),void 0!==e.volume&&this.volume.load(e.volume))}}var r=s(763);let p=()=>{removeEventListener(i.m,p),removeEventListener(i.s,p),(0,r.XK)()};class m{id="sounds";_engine;constructor(e){this._engine=e;const t={capture:!0,once:!0};addEventListener(i.m,p,t),addEventListener(i.s,p,t)}async getPlugin(e){let{SoundsPluginInstance:t}=await s.e(4).then(s.bind(s,4));return new t(e,this._engine)}loadOptions(e,t,s){if(!this.needsPlugin(t)&&!this.needsPlugin(s))return;let i=t.sounds;i?.load===void 0&&(t.sounds=i=new d),i.load(s?.sounds)}needsPlugin(e){return e?.sounds?.enable??!1}}},699(e,t,s){s.d(t,{m:()=>i,s:()=>l});let i="pointerdown",l="touchstart"},763(e,t,s){s.d(t,{E3:()=>n,XK:()=>a,jE:()=>l});let i=new Map;function l(e){let t=/(([A-G]b?)(\d))|pause/i.exec(e);if(!t?.length)return;let s=t[2]??t[0],l=i.get(s);if(l)return l[parseInt(t[3]??"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,n=()=>o,a=()=>{o=!1}}}]);
33
+ </svg>`}load(e){(0,l.isNull)(e)||(void 0!==e.enable&&(this.enable=e.enable),this.mute.load(e.mute),this.unmute.load(e.unmute),this.volumeDown.load(e.volumeDown),this.volumeUp.load(e.volumeUp))}}class v{max;min;step;value;constructor(){this.value=100,this.max=100,this.min=0,this.step=10}load(e){(0,l.isNull)(e)||((0,l.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 d{autoPlay;enable;events;icons;volume;constructor(){this.autoPlay=!0,this.enable=!1,this.events=[],this.icons=new u,this.volume=new v}load(e){(0,l.isNull)(e)||(void 0!==e.autoPlay&&(this.autoPlay=e.autoPlay),void 0!==e.enable&&(this.enable=e.enable),void 0!==e.events&&(this.events=e.events.map(e=>{let t=new c;return t.load(e),t})),this.icons.load(e.icons),void 0!==e.volume&&this.volume.load(e.volume))}}var r=s(238);let p=()=>{removeEventListener(i.m,p),removeEventListener(i.s,p),(0,r.XK)()};class m{id="sounds";_engine;constructor(e){this._engine=e;const t={capture:!0,once:!0};addEventListener(i.m,p,t),addEventListener(i.s,p,t)}async getPlugin(e){let{SoundsPluginInstance:t}=await s.e(86).then(s.bind(s,86));return new t(e,this._engine)}loadOptions(e,t,s){if(!this.needsPlugin(t)&&!this.needsPlugin(s))return;let i=t.sounds;i?.load===void 0&&(t.sounds=i=new d),i.load(s?.sounds)}needsPlugin(e){return e?.sounds?.enable??!1}}},886(e,t,s){s.d(t,{m:()=>i,s:()=>l});let i="pointerdown",l="touchstart"},238(e,t,s){s.d(t,{E3:()=>n,XK:()=>a,jE:()=>l});let i=new Map;function l(e){let t=/(([A-G]b?)(\d))|pause/i.exec(e);if(!t?.length)return;let s=t[2]??t[0],l=i.get(s);if(l)return l[parseInt(t[3]??"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,n=()=>o,a=()=>{o=!1}}}]);
package/86.min.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";(this.webpackChunk_tsparticles_plugin_sounds=this.webpackChunk_tsparticles_plugin_sounds||[]).push([[86],{86(t,e,i){i.d(e,{SoundsPluginInstance:()=>m});var n,s,a,o,u=i(303);(n=a||(a={})).mute="soundsMuted",n.unmute="soundsUnmuted",(s=o||(o={})).Block="block",s.None="none";var l=i(238),r=i(886);function c(t){var e,i,n,s,a,o,l,r;let c=(0,u.safeDocument)().createElement("img"),{clickCb:d,container:m,display:h,iconOptions:_,margin:p,options:g,pos:f,rightOffsets:v}=t,{width:y,path:w,style:O,svg:S}=_;return e=c,i=f.top+p,n=f.right-(p*(v.length+1)+y+v.reduce((t,e)=>t+e,0)),s=h,a=g.fullScreen.zIndex+1,o=y,l=p,r=O,e.style.userSelect="none",e.style.position="absolute",e.style.top=`${(i+l).toString()}px`,e.style.left=`${(n-l-o).toString()}px`,e.style.display=s,e.style.zIndex=(a+1).toString(),e.style.cssText+=r,c.src=w??(S?`data:image/svg+xml;base64,${btoa(S)}`:""),(m.canvas.element?.parentNode??(0,u.safeDocument)().body).append(c),c.addEventListener("click",()=>{d()}),c}function d(t){t&&t.remove()}class m{_audioMap;_audioSources;_container;_engine;_gain;_muteImg;_unmuteImg;_volume;_volumeDownImg;_volumeUpImg;constructor(t,e){this._container=t,this._engine=e,this._volume=0,this._audioSources=[],this._audioMap=new Map}async init(){let t=this._container.actualOptions.sounds;if(!t?.enable)return;if(t.autoPlay&&(0,l.E3)()){let t=()=>{removeEventListener(r.m,t),removeEventListener(r.s,t),(0,l.XK)(),this.unmute()},e={capture:!0,once:!0};addEventListener(r.m,t,e),addEventListener(r.s,t,e)}this._volume=t.volume.value;let e=t.events;for(let t of(this._audioMap=new Map,e)){if(!t.audio)continue;let e=(0,u.executeOnSingleOrMultiple)(t.audio,async t=>{let e=await fetch(t.source);if(!e.ok)return;let i=await e.arrayBuffer(),n=this._getAudioContext(),s=await n.decodeAudioData(i);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(){let t=this._container,e=t.actualOptions,i=e.sounds;if(!i?.enable||!t.canvas.element)return;t.muted=!0;let n=t.canvas.element,s={top:n.offsetTop,right:n.offsetLeft+n.offsetWidth},{mute:a,unmute:u,volumeDown:r,volumeUp:d}=i.icons,m=async()=>{await this.toggleMute()},h=i.icons.enable?o.Block:o.None;this._muteImg=c({container:t,options:e,pos:s,display:h,iconOptions:a,margin:10,rightOffsets:[r.width,d.width],clickCb:m}),this._unmuteImg=c({container:t,options:e,pos:s,display:o.None,iconOptions:u,margin:10,rightOffsets:[r.width,d.width],clickCb:m}),this._volumeDownImg=c({container:t,options:e,pos:s,display:h,iconOptions:r,margin:10,rightOffsets:[d.width],clickCb:async()=>{await this.volumeDown()}}),this._volumeUpImg=c({container:t,options:e,pos:s,display:h,iconOptions:d,margin:10,rightOffsets:[],clickCb:async()=>{await this.volumeUp()}}),!(0,l.E3)()&&i.autoPlay&&await this.unmute()}stop(){this._container.muted=!0,(async()=>{await this._mute(),d(this._muteImg),d(this._unmuteImg),d(this._volumeDownImg),d(this._volumeUpImg)})()}async toggleMute(){let t=this._container;t.muted=!t.muted,this._updateMuteIcons(),await this._updateMuteStatus()}async unmute(){this._container.muted&&await this.toggleMute()}async volumeDown(){let t=this._container,e=t.actualOptions.sounds;e?.enable&&(t.muted&&(this._volume=0),this._volume-=e.volume.step,await this._updateVolume())}async volumeUp(){let t=this._container.actualOptions.sounds;t?.enable&&(this._volume+=t.volume.step,await this._updateVolume())}_addBuffer=t=>{let e=t.createBufferSource();return this._audioSources.push(e),e};_addOscillator=t=>{let e=t.createOscillator();return this._audioSources.push(e),e};_getAudioContext(){let t=this._container;return t.audioContext??=new AudioContext,t.audioContext}_initEvents=()=>{let t=this._container,e=t.actualOptions.sounds;if(e?.enable&&t.canvas.element)for(let t of e.events){let e=i=>{i&&(async()=>{let n=t.filter&&!t.filter(i);if(this._container===i.container){if(this._container.muted||this._container.destroyed)return(0,u.executeOnSingleOrMultiple)(t.event,t=>{this._engine.removeEventListener(t,e)});if(!n){if(t.audio){let e=(0,u.itemFromSingleOrMultiple)(t.audio);if(!e)return;this._playBuffer(e)}else if(t.melodies){let e=(0,u.itemFromArray)(t.melodies);if(!e)return;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){let e=(0,u.itemFromArray)(t.notes);if(!e)return;await this._playNote([e],0,!1)}}}})()};(0,u.executeOnSingleOrMultiple)(t.event,t=>{this._engine.addEventListener(t,e)})}};_mute=async()=>{let t=this._container,e=this._getAudioContext();for(let t of this._audioSources)this._removeAudioSource(t);this._gain&&this._gain.disconnect(),await e.close(),t.audioContext=void 0,this._container.dispatchEvent(a.mute)};_playBuffer=t=>{let e=this._audioMap.get(t.source);if(!e)return;let i=this._container.audioContext;if(!i)return;let n=this._addBuffer(i);n.loop=t.loop,n.buffer=e,n.connect(this._gain??i.destination),n.start()};_playFrequency=async(t,e)=>{if(!this._gain||this._container.muted)return;let i=this._getAudioContext(),n=this._addOscillator(i);return n.connect(this._gain),n.type="sine",n.frequency.value=t,n.start(),new Promise(t=>{setTimeout(()=>{this._removeAudioSource(n),t()},e)})};_playMuteSound=()=>{if(this._container.muted)return;let t=this._getAudioContext(),e=t.createGain();e.connect(t.destination),e.gain.value=0;let i=t.createOscillator();i.connect(e),i.type="sine",i.frequency.value=1,i.start(),setTimeout(()=>{i.stop(),i.disconnect(),e.disconnect()})};_playNote=async(t,e,i)=>{if(this._container.muted)return;let n=t[e];if(!n)return;let s=n.value,a=(0,u.executeOnSingleOrMultiple)(s,async(i,n)=>this._playNoteValue(t,e,n));await ((0,u.isArray)(a)?Promise.allSettled(a):a);let o=e+1;i&&o>=t.length&&(o%=t.length),await this._playNote(t,o,i)};_playNoteValue=async(t,e,i)=>{let n=t[e];if(!n)return;let s=(0,u.itemFromSingleOrMultiple)(n.value,i,!0);if(s)try{let t=(0,l.jE)(s);if(!(0,u.isNumber)(t))return;await this._playFrequency(t,n.duration)}catch(t){(0,u.getLogger)().error(t)}};_removeAudioSource=t=>{t.stop(),t.disconnect(),this._audioSources.splice(this._audioSources.indexOf(t),1)};_unmute=()=>{let t=this._container.actualOptions.sounds;if(!t)return;let e=this._getAudioContext(),i=e.createGain();i.connect(e.destination),i.gain.value=t.volume.value/u.percentDenominator,this._gain=i,this._initEvents(),this._container.dispatchEvent(a.unmute)};_updateMuteIcons=()=>{let t=this._container,e=t.actualOptions.sounds;if(!e?.enable||!e.icons.enable)return;let i=this._muteImg,n=this._unmuteImg;i&&(i.style.display=t.muted?"block":"none"),n&&(n.style.display=t.muted?"none":"block")};_updateMuteStatus=async()=>{let t=this._container,e=this._getAudioContext();t.muted?(await e.suspend(),await this._mute()):(await e.resume(),this._unmute(),this._playMuteSound())};_updateVolume=async()=>{let t=this._container,e=t.actualOptions.sounds;if(!e?.enable)return;(0,u.clamp)(this._volume,e.volume.min,e.volume.max);let i=!1;this._volume<=0&&!t.muted?(this._volume=0,t.muted=!0,i=!0):this._volume>0&&t.muted&&(t.muted=!1,i=!0),i&&(this._updateMuteIcons(),await this._updateMuteStatus()),this._gain?.gain&&(this._gain.gain.value=this._volume/u.percentDenominator)}}}}]);
package/README.md CHANGED
@@ -8,6 +8,12 @@
8
8
 
9
9
  [tsParticles](https://github.com/tsparticles/tsparticles) plugin for particles sounds effect.
10
10
 
11
+ ## Quick checklist
12
+
13
+ 1. Install `@tsparticles/engine` (or use the CDN bundle below)
14
+ 2. Call the package loader function(s) before `tsParticles.load(...)`
15
+ 3. Apply the package options in your `tsParticles.load(...)` config
16
+
11
17
  ## How to use it
12
18
 
13
19
  ### CDN / Vanilla JS / jQuery
@@ -72,3 +78,19 @@ import { loadSoundsPlugin } from "@tsparticles/plugin-sounds";
72
78
  await loadSoundsPlugin(tsParticles);
73
79
  })();
74
80
  ```
81
+
82
+ ## Option mapping
83
+
84
+ - This package primarily extends runtime behavior or rendering and may not expose a single dedicated root options key.
85
+ - Use the usage example in this README and combine with the nearest options section in the docs.
86
+
87
+ ## Common pitfalls
88
+
89
+ - Calling `tsParticles.load(...)` before `loadSoundsPlugin(...)`
90
+ - Verify required peer packages before enabling advanced options
91
+ - Change one option group at a time to isolate regressions quickly
92
+
93
+ ## Related docs
94
+
95
+ - All packages catalog: <https://github.com/tsparticles/tsparticles>
96
+ - Main docs: <https://particles.js.org/docs/>
package/browser/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export async function loadSoundsPlugin(engine) {
2
- engine.checkVersion("4.0.0-beta.1");
2
+ engine.checkVersion("4.0.0-beta.11");
3
3
  await engine.pluginManager.register(async (e) => {
4
4
  const { SoundsPlugin } = await import("./SoundsPlugin.js");
5
5
  e.pluginManager.addPlugin(new SoundsPlugin(e));
package/cjs/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export async function loadSoundsPlugin(engine) {
2
- engine.checkVersion("4.0.0-beta.1");
2
+ engine.checkVersion("4.0.0-beta.11");
3
3
  await engine.pluginManager.register(async (e) => {
4
4
  const { SoundsPlugin } = await import("./SoundsPlugin.js");
5
5
  e.pluginManager.addPlugin(new SoundsPlugin(e));
@@ -4,7 +4,7 @@
4
4
  * Demo / Generator : https://particles.js.org/
5
5
  * GitHub : https://www.github.com/matteobruni/tsparticles
6
6
  * How to use? : Check the GitHub README
7
- * v4.0.0-beta.1
7
+ * v4.0.0-beta.11
8
8
  */
9
9
  "use strict";
10
10
  /*
@@ -4,7 +4,7 @@
4
4
  * Demo / Generator : https://particles.js.org/
5
5
  * GitHub : https://www.github.com/matteobruni/tsparticles
6
6
  * How to use? : Check the GitHub README
7
- * v4.0.0-beta.1
7
+ * v4.0.0-beta.11
8
8
  */
9
9
  "use strict";
10
10
  /*
package/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export async function loadSoundsPlugin(engine) {
2
- engine.checkVersion("4.0.0-beta.1");
2
+ engine.checkVersion("4.0.0-beta.11");
3
3
  await engine.pluginManager.register(async (e) => {
4
4
  const { SoundsPlugin } = await import("./SoundsPlugin.js");
5
5
  e.pluginManager.addPlugin(new SoundsPlugin(e));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/plugin-sounds",
3
- "version": "4.0.0-beta.1",
3
+ "version": "4.0.0-beta.11",
4
4
  "description": "tsParticles sounds plugin",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -80,13 +80,12 @@
80
80
  "browser": "./browser/index.js",
81
81
  "import": "./esm/index.js",
82
82
  "require": "./cjs/index.js",
83
- "umd": "./umd/index.js",
84
- "default": "./cjs/index.js"
83
+ "default": "./esm/index.js"
85
84
  },
86
85
  "./package.json": "./package.json"
87
86
  },
88
- "dependencies": {
89
- "@tsparticles/engine": "4.0.0-beta.1"
87
+ "peerDependencies": {
88
+ "@tsparticles/engine": "4.0.0-beta.11"
90
89
  },
91
90
  "publishConfig": {
92
91
  "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 [31 Mar 2026 at 08:48]</title>
6
+ <title>@tsparticles/plugin-sounds [8 Apr 2026 at 17:11]</title>
7
7
  <link
8
8
  rel="shortcut icon"
9
9
  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="
@@ -4,7 +4,7 @@
4
4
  * Demo / Generator : https://particles.js.org/
5
5
  * GitHub : https://www.github.com/matteobruni/tsparticles
6
6
  * How to use? : Check the GitHub README
7
- * v4.0.0-beta.1
7
+ * v4.0.0-beta.11
8
8
  */
9
9
  /*
10
10
  * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
@@ -44,7 +44,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
44
44
  \*******************************/
45
45
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
46
46
 
47
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadSoundsPlugin: () => (/* binding */ loadSoundsPlugin)\n/* harmony export */ });\nasync function loadSoundsPlugin(engine) {\n engine.checkVersion(\"4.0.0-beta.1\");\n await engine.pluginManager.register(async (e)=>{\n const { SoundsPlugin } = await __webpack_require__.e(/*! import() */ \"dist_browser_SoundsPlugin_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./SoundsPlugin.js */ \"./dist/browser/SoundsPlugin.js\"));\n e.pluginManager.addPlugin(new SoundsPlugin(e));\n });\n}\n\n\n//# sourceURL=webpack://@tsparticles/plugin-sounds/./dist/browser/index.js?\n}");
47
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadSoundsPlugin: () => (/* binding */ loadSoundsPlugin)\n/* harmony export */ });\nasync function loadSoundsPlugin(engine) {\n engine.checkVersion(\"4.0.0-beta.11\");\n await engine.pluginManager.register(async (e)=>{\n const { SoundsPlugin } = await __webpack_require__.e(/*! import() */ \"dist_browser_SoundsPlugin_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./SoundsPlugin.js */ \"./dist/browser/SoundsPlugin.js\"));\n e.pluginManager.addPlugin(new SoundsPlugin(e));\n });\n}\n\n\n//# sourceURL=webpack://@tsparticles/plugin-sounds/./dist/browser/index.js?\n}");
48
48
 
49
49
  /***/ }
50
50
 
@@ -1,2 +1,2 @@
1
1
  !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var r="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,e=>(()=>{"use strict";var t,r,o,n={303(t){t.exports=e}},i={};function a(e){var t=i[e];if(void 0!==t)return t.exports;var r=i[e]={exports:{}};return n[e](r,r.exports,a),r.exports}a.m=n,a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.f={},a.e=e=>Promise.all(Object.keys(a.f).reduce((t,r)=>(a.f[r](e,t),t),[])),a.u=e=>""+e+".min.js",a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s={},a.l=(e,t,r,o)=>{if(s[e])return void s[e].push(t);if(void 0!==r)for(var n,i,u=document.getElementsByTagName("script"),l=0;l<u.length;l++){var p=u[l];if(p.getAttribute("src")==e||p.getAttribute("data-webpack")=="@tsparticles/plugin-sounds:"+r){n=p;break}}n||(i=!0,(n=document.createElement("script")).charset="utf-8",a.nc&&n.setAttribute("nonce",a.nc),n.setAttribute("data-webpack","@tsparticles/plugin-sounds:"+r),n.src=e),s[e]=[t];var c=(t,r)=>{n.onerror=n.onload=null,clearTimeout(d);var o=s[e];if(delete s[e],n.parentNode&&n.parentNode.removeChild(n),o&&o.forEach(e=>e(r)),t)return t(r)},d=setTimeout(c.bind(null,void 0,{type:"timeout",target:n}),12e4);n.onerror=c.bind(null,n.onerror),n.onload=c.bind(null,n.onload),i&&document.head.appendChild(n)},a.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.g.importScripts&&(u=a.g.location+"");var s,u,l=a.g.document;if(!u&&l&&(l.currentScript&&"SCRIPT"===l.currentScript.tagName.toUpperCase()&&(u=l.currentScript.src),!u)){var p=l.getElementsByTagName("script");if(p.length)for(var c=p.length-1;c>-1&&(!u||!/^http(s?):/.test(u));)u=p[c--].src}if(!u)throw Error("Automatic publicPath is not supported in this browser");a.p=u=u.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),t={848:0},a.f.j=(e,r)=>{var o=a.o(t,e)?t[e]:void 0;if(0!==o)if(o)r.push(o[2]);else{var n=new Promise((r,n)=>o=t[e]=[r,n]);r.push(o[2]=n);var i=a.p+a.u(e),s=Error();a.l(i,r=>{if(a.o(t,e)&&(0!==(o=t[e])&&(t[e]=void 0),o)){var n=r&&("load"===r.type?"missing":r.type),i=r&&r.target&&r.target.src;s.message="Loading chunk "+e+` failed.
2
- (`+n+": "+i+")",s.name="ChunkLoadError",s.type=n,s.request=i,o[1](s)}},"chunk-"+e,e)}},r=(e,r)=>{var o,n,[i,s,u]=r,l=0;if(i.some(e=>0!==t[e])){for(o in s)a.o(s,o)&&(a.m[o]=s[o]);u&&u(a)}for(e&&e(r);l<i.length;l++)n=i[l],a.o(t,n)&&t[n]&&t[n][0](),t[n]=0},(o=this.webpackChunk_tsparticles_plugin_sounds=this.webpackChunk_tsparticles_plugin_sounds||[]).forEach(r.bind(null,0)),o.push=r.bind(null,o.push.bind(o));var d={};async function f(e){e.checkVersion("4.0.0-beta.1"),await e.pluginManager.register(async e=>{let{SoundsPlugin:t}=await a.e(414).then(a.bind(a,414));e.pluginManager.addPlugin(new t(e))})}return a.r(d),a.d(d,{loadSoundsPlugin:()=>f}),d})());
2
+ (`+n+": "+i+")",s.name="ChunkLoadError",s.type=n,s.request=i,o[1](s)}},"chunk-"+e,e)}},r=(e,r)=>{var o,n,[i,s,u]=r,l=0;if(i.some(e=>0!==t[e])){for(o in s)a.o(s,o)&&(a.m[o]=s[o]);u&&u(a)}for(e&&e(r);l<i.length;l++)n=i[l],a.o(t,n)&&t[n]&&t[n][0](),t[n]=0},(o=this.webpackChunk_tsparticles_plugin_sounds=this.webpackChunk_tsparticles_plugin_sounds||[]).forEach(r.bind(null,0)),o.push=r.bind(null,o.push.bind(o));var d={};async function f(e){e.checkVersion("4.0.0-beta.11"),await e.pluginManager.register(async e=>{let{SoundsPlugin:t}=await a.e(300).then(a.bind(a,300));e.pluginManager.addPlugin(new t(e))})}return a.r(d),a.d(d,{loadSoundsPlugin:()=>f}),d})());
package/4.min.js DELETED
@@ -1 +0,0 @@
1
- "use strict";(this.webpackChunk_tsparticles_plugin_sounds=this.webpackChunk_tsparticles_plugin_sounds||[]).push([[4],{4(t,e,i){i.d(e,{SoundsPluginInstance:()=>m});var n,s,a,o,u=i(303);(n=a||(a={})).mute="soundsMuted",n.unmute="soundsUnmuted",(s=o||(o={})).Block="block",s.None="none";var l=i(763),r=i(699);function c(t){var e,i,n,s,a,o,l,r;let c=(0,u.safeDocument)().createElement("img"),{clickCb:d,container:m,display:h,iconOptions:_,margin:p,options:g,pos:f,rightOffsets:v}=t,{width:y,path:w,style:O,svg:S}=_;return e=c,i=f.top+p,n=f.right-(p*(v.length+1)+y+v.reduce((t,e)=>t+e,0)),s=h,a=g.fullScreen.zIndex+1,o=y,l=p,r=O,e.style.userSelect="none",e.style.position="absolute",e.style.top=`${(i+l).toString()}px`,e.style.left=`${(n-l-o).toString()}px`,e.style.display=s,e.style.zIndex=(a+1).toString(),e.style.cssText+=r,c.src=w??(S?`data:image/svg+xml;base64,${btoa(S)}`:""),(m.canvas.element?.parentNode??(0,u.safeDocument)().body).append(c),c.addEventListener("click",()=>{d()}),c}function d(t){t&&t.remove()}class m{_audioMap;_audioSources;_container;_engine;_gain;_muteImg;_unmuteImg;_volume;_volumeDownImg;_volumeUpImg;constructor(t,e){this._container=t,this._engine=e,this._volume=0,this._audioSources=[],this._audioMap=new Map}async init(){let t=this._container.actualOptions.sounds;if(!t?.enable)return;if(t.autoPlay&&(0,l.E3)()){let t=()=>{removeEventListener(r.m,t),removeEventListener(r.s,t),(0,l.XK)(),this.unmute()},e={capture:!0,once:!0};addEventListener(r.m,t,e),addEventListener(r.s,t,e)}this._volume=t.volume.value;let e=t.events;for(let t of(this._audioMap=new Map,e)){if(!t.audio)continue;let e=(0,u.executeOnSingleOrMultiple)(t.audio,async t=>{let e=await fetch(t.source);if(!e.ok)return;let i=await e.arrayBuffer(),n=this._getAudioContext(),s=await n.decodeAudioData(i);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(){let t=this._container,e=t.actualOptions,i=e.sounds;if(!i?.enable||!t.canvas.element)return;t.muted=!0;let n=t.canvas.element,s={top:n.offsetTop,right:n.offsetLeft+n.offsetWidth},{mute:a,unmute:u,volumeDown:r,volumeUp:d}=i.icons,m=async()=>{await this.toggleMute()},h=i.icons.enable?o.Block:o.None;this._muteImg=c({container:t,options:e,pos:s,display:h,iconOptions:a,margin:10,rightOffsets:[r.width,d.width],clickCb:m}),this._unmuteImg=c({container:t,options:e,pos:s,display:o.None,iconOptions:u,margin:10,rightOffsets:[r.width,d.width],clickCb:m}),this._volumeDownImg=c({container:t,options:e,pos:s,display:h,iconOptions:r,margin:10,rightOffsets:[d.width],clickCb:async()=>{await this.volumeDown()}}),this._volumeUpImg=c({container:t,options:e,pos:s,display:h,iconOptions:d,margin:10,rightOffsets:[],clickCb:async()=>{await this.volumeUp()}}),!(0,l.E3)()&&i.autoPlay&&await this.unmute()}stop(){this._container.muted=!0,(async()=>{await this._mute(),d(this._muteImg),d(this._unmuteImg),d(this._volumeDownImg),d(this._volumeUpImg)})()}async toggleMute(){let t=this._container;t.muted=!t.muted,this._updateMuteIcons(),await this._updateMuteStatus()}async unmute(){this._container.muted&&await this.toggleMute()}async volumeDown(){let t=this._container,e=t.actualOptions.sounds;e?.enable&&(t.muted&&(this._volume=0),this._volume-=e.volume.step,await this._updateVolume())}async volumeUp(){let t=this._container.actualOptions.sounds;t?.enable&&(this._volume+=t.volume.step,await this._updateVolume())}_addBuffer=t=>{let e=t.createBufferSource();return this._audioSources.push(e),e};_addOscillator=t=>{let e=t.createOscillator();return this._audioSources.push(e),e};_getAudioContext(){let t=this._container;return t.audioContext??=new AudioContext,t.audioContext}_initEvents=()=>{let t=this._container,e=t.actualOptions.sounds;if(e?.enable&&t.canvas.element)for(let t of e.events){let e=i=>{i&&(async()=>{let n=t.filter&&!t.filter(i);if(this._container===i.container){if(this._container.muted||this._container.destroyed)return(0,u.executeOnSingleOrMultiple)(t.event,t=>{this._engine.removeEventListener(t,e)});if(!n){if(t.audio){let e=(0,u.itemFromSingleOrMultiple)(t.audio);if(!e)return;this._playBuffer(e)}else if(t.melodies){let e=(0,u.itemFromArray)(t.melodies);if(!e)return;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){let e=(0,u.itemFromArray)(t.notes);if(!e)return;await this._playNote([e],0,!1)}}}})()};(0,u.executeOnSingleOrMultiple)(t.event,t=>{this._engine.addEventListener(t,e)})}};_mute=async()=>{let t=this._container,e=this._getAudioContext();for(let t of this._audioSources)this._removeAudioSource(t);this._gain&&this._gain.disconnect(),await e.close(),t.audioContext=void 0,this._container.dispatchEvent(a.mute)};_playBuffer=t=>{let e=this._audioMap.get(t.source);if(!e)return;let i=this._container.audioContext;if(!i)return;let n=this._addBuffer(i);n.loop=t.loop,n.buffer=e,n.connect(this._gain??i.destination),n.start()};_playFrequency=async(t,e)=>{if(!this._gain||this._container.muted)return;let i=this._getAudioContext(),n=this._addOscillator(i);return n.connect(this._gain),n.type="sine",n.frequency.value=t,n.start(),new Promise(t=>{setTimeout(()=>{this._removeAudioSource(n),t()},e)})};_playMuteSound=()=>{if(this._container.muted)return;let t=this._getAudioContext(),e=t.createGain();e.connect(t.destination),e.gain.value=0;let i=t.createOscillator();i.connect(e),i.type="sine",i.frequency.value=1,i.start(),setTimeout(()=>{i.stop(),i.disconnect(),e.disconnect()})};_playNote=async(t,e,i)=>{if(this._container.muted)return;let n=t[e];if(!n)return;let s=n.value,a=(0,u.executeOnSingleOrMultiple)(s,async(i,n)=>this._playNoteValue(t,e,n));await ((0,u.isArray)(a)?Promise.allSettled(a):a);let o=e+1;i&&o>=t.length&&(o%=t.length),await this._playNote(t,o,i)};_playNoteValue=async(t,e,i)=>{let n=t[e];if(!n)return;let s=(0,u.itemFromSingleOrMultiple)(n.value,i,!0);if(s)try{let t=(0,l.jE)(s);if(!(0,u.isNumber)(t))return;await this._playFrequency(t,n.duration)}catch(t){(0,u.getLogger)().error(t)}};_removeAudioSource=t=>{t.stop(),t.disconnect(),this._audioSources.splice(this._audioSources.indexOf(t),1)};_unmute=()=>{let t=this._container.actualOptions.sounds;if(!t)return;let e=this._getAudioContext(),i=e.createGain();i.connect(e.destination),i.gain.value=t.volume.value/u.percentDenominator,this._gain=i,this._initEvents(),this._container.dispatchEvent(a.unmute)};_updateMuteIcons=()=>{let t=this._container,e=t.actualOptions.sounds;if(!e?.enable||!e.icons.enable)return;let i=this._muteImg,n=this._unmuteImg;i&&(i.style.display=t.muted?"block":"none"),n&&(n.style.display=t.muted?"none":"block")};_updateMuteStatus=async()=>{let t=this._container,e=this._getAudioContext();t.muted?(await e.suspend(),await this._mute()):(await e.resume(),this._unmute(),this._playMuteSound())};_updateVolume=async()=>{let t=this._container,e=t.actualOptions.sounds;if(!e?.enable)return;(0,u.clamp)(this._volume,e.volume.min,e.volume.max);let i=!1;this._volume<=0&&!t.muted?(this._volume=0,t.muted=!0,i=!0):this._volume>0&&t.muted&&(t.muted=!1,i=!0),i&&(this._updateMuteIcons(),await this._updateMuteStatus()),this._gain?.gain&&(this._gain.gain.value=this._volume/u.percentDenominator)}}}}]);
@@ -1,54 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "@tsparticles/engine", "./SoundsEvent.js", "./SoundsIcons.js", "./SoundsVolume.js"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Sounds = void 0;
13
- const engine_1 = require("@tsparticles/engine");
14
- const SoundsEvent_js_1 = require("./SoundsEvent.js");
15
- const SoundsIcons_js_1 = require("./SoundsIcons.js");
16
- const SoundsVolume_js_1 = require("./SoundsVolume.js");
17
- class Sounds {
18
- autoPlay;
19
- enable;
20
- events;
21
- icons;
22
- volume;
23
- constructor() {
24
- this.autoPlay = true;
25
- this.enable = false;
26
- this.events = [];
27
- this.icons = new SoundsIcons_js_1.SoundsIcons();
28
- this.volume = new SoundsVolume_js_1.SoundsVolume();
29
- }
30
- load(data) {
31
- if ((0, engine_1.isNull)(data)) {
32
- return;
33
- }
34
- if (data.autoPlay !== undefined) {
35
- this.autoPlay = data.autoPlay;
36
- }
37
- if (data.enable !== undefined) {
38
- this.enable = data.enable;
39
- }
40
- if (data.events !== undefined) {
41
- this.events = data.events.map(t => {
42
- const event = new SoundsEvent_js_1.SoundsEvent();
43
- event.load(t);
44
- return event;
45
- });
46
- }
47
- this.icons.load(data.icons);
48
- if (data.volume !== undefined) {
49
- this.volume.load(data.volume);
50
- }
51
- }
52
- }
53
- exports.Sounds = Sounds;
54
- });
@@ -1,39 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "@tsparticles/engine"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.SoundsAudio = void 0;
13
- const engine_1 = require("@tsparticles/engine");
14
- class SoundsAudio {
15
- loop;
16
- source;
17
- constructor() {
18
- this.loop = false;
19
- this.source = "";
20
- }
21
- load(data) {
22
- if ((0, engine_1.isNull)(data)) {
23
- return;
24
- }
25
- if ((0, engine_1.isObject)(data)) {
26
- if (data.loop !== undefined) {
27
- this.loop = data.loop;
28
- }
29
- if (data.source !== undefined) {
30
- this.source = data.source;
31
- }
32
- }
33
- else {
34
- this.source = data;
35
- }
36
- }
37
- }
38
- exports.SoundsAudio = SoundsAudio;
39
- });
@@ -1,75 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "@tsparticles/engine", "./SoundsAudio.js", "./SoundsMelody.js", "./SoundsNote.js"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.SoundsEvent = void 0;
13
- const engine_1 = require("@tsparticles/engine");
14
- const SoundsAudio_js_1 = require("./SoundsAudio.js");
15
- const SoundsMelody_js_1 = require("./SoundsMelody.js");
16
- const SoundsNote_js_1 = require("./SoundsNote.js");
17
- class SoundsEvent {
18
- audio;
19
- event;
20
- filter;
21
- melodies;
22
- notes;
23
- constructor() {
24
- this.event = [];
25
- this.notes = [];
26
- }
27
- load(data) {
28
- if ((0, engine_1.isNull)(data)) {
29
- return;
30
- }
31
- if (data.event !== undefined) {
32
- this.event = data.event;
33
- }
34
- if (data.audio !== undefined) {
35
- if ((0, engine_1.isArray)(data.audio)) {
36
- this.audio = data.audio.map(s => {
37
- const tmp = new SoundsAudio_js_1.SoundsAudio();
38
- tmp.load(s);
39
- return tmp;
40
- });
41
- }
42
- else {
43
- this.audio = new SoundsAudio_js_1.SoundsAudio();
44
- this.audio.load(data.audio);
45
- }
46
- }
47
- if (data.notes !== undefined) {
48
- this.notes = data.notes.map(t => {
49
- const tmp = new SoundsNote_js_1.SoundsNote();
50
- tmp.load(t);
51
- return tmp;
52
- });
53
- }
54
- if (data.melodies !== undefined) {
55
- this.melodies = data.melodies.map(t => {
56
- const tmp = new SoundsMelody_js_1.SoundsMelody();
57
- tmp.load(t);
58
- return tmp;
59
- });
60
- }
61
- if (data.filter) {
62
- if ((0, engine_1.isString)(data.filter)) {
63
- const filterFunc = globalThis[data.filter];
64
- if ((0, engine_1.isFunction)(filterFunc)) {
65
- this.filter = filterFunc;
66
- }
67
- }
68
- else {
69
- this.filter = data.filter;
70
- }
71
- }
72
- }
73
- }
74
- exports.SoundsEvent = SoundsEvent;
75
- });
@@ -1,44 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "@tsparticles/engine"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.SoundsIcon = void 0;
13
- const engine_1 = require("@tsparticles/engine");
14
- class SoundsIcon {
15
- height;
16
- path;
17
- style;
18
- svg;
19
- width;
20
- constructor() {
21
- this.width = 24;
22
- this.height = 24;
23
- this.style = "";
24
- }
25
- load(data) {
26
- if ((0, engine_1.isNull)(data)) {
27
- return;
28
- }
29
- if (data.path !== undefined) {
30
- this.path = data.path;
31
- }
32
- if (data.svg !== undefined) {
33
- this.svg = data.svg;
34
- }
35
- if (data.width !== undefined) {
36
- this.width = data.width;
37
- }
38
- if (data.height !== undefined) {
39
- this.height = data.height;
40
- }
41
- }
42
- }
43
- exports.SoundsIcon = SoundsIcon;
44
- });
@@ -1,78 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "@tsparticles/engine", "./SoundsIcon.js"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.SoundsIcons = void 0;
13
- const engine_1 = require("@tsparticles/engine");
14
- const SoundsIcon_js_1 = require("./SoundsIcon.js");
15
- class SoundsIcons {
16
- enable;
17
- mute;
18
- unmute;
19
- volumeDown;
20
- volumeUp;
21
- constructor() {
22
- this.mute = new SoundsIcon_js_1.SoundsIcon();
23
- this.unmute = new SoundsIcon_js_1.SoundsIcon();
24
- this.volumeDown = new SoundsIcon_js_1.SoundsIcon();
25
- this.volumeUp = new SoundsIcon_js_1.SoundsIcon();
26
- this.enable = false;
27
- this.mute.svg = `<?xml version="1.0"?>
28
- <svg baseProfile="tiny" height="24px" version="1.2" viewBox="0 0 24 24" width="24px"
29
- xml:space="preserve" xmlns="http://www.w3.org/2000/svg"
30
- xmlns:xlink="http://www.w3.org/1999/xlink">
31
- <g id="Layer_1">
32
- <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"/>
33
- </g>
34
- </svg>`;
35
- this.unmute.svg = `<?xml version="1.0"?>
36
- <svg baseProfile="tiny" height="24px" version="1.2" viewBox="0 0 24 24" width="24px"
37
- xml:space="preserve" xmlns="http://www.w3.org/2000/svg"
38
- xmlns:xlink="http://www.w3.org/1999/xlink">
39
- <g id="Layer_1">
40
- <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"/>
41
- </g>
42
- </svg>`;
43
- this.volumeDown.svg = `<?xml version="1.0"?>
44
- <svg baseProfile="tiny" height="24px" version="1.2" viewBox="0 0 24 24" width="24px"
45
- xml:space="preserve" xmlns="http://www.w3.org/2000/svg"
46
- xmlns:xlink="http://www.w3.org/1999/xlink">
47
- <g id="Layer_1">
48
- <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"/>
49
- <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"/>
50
- </g>
51
- </svg>`;
52
- this.volumeUp.svg = `<?xml version="1.0"?>
53
- <svg baseProfile="tiny" height="24px" version="1.2" viewBox="0 0 24 24" width="24px"
54
- xml:space="preserve" xmlns="http://www.w3.org/2000/svg"
55
- xmlns:xlink="http://www.w3.org/1999/xlink">
56
- <g id="Layer_1">
57
- <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"/>
58
- <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"/>
59
- <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"/>
60
- <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"/>
61
- </g>
62
- </svg>`;
63
- }
64
- load(data) {
65
- if ((0, engine_1.isNull)(data)) {
66
- return;
67
- }
68
- if (data.enable !== undefined) {
69
- this.enable = data.enable;
70
- }
71
- this.mute.load(data.mute);
72
- this.unmute.load(data.unmute);
73
- this.volumeDown.load(data.volumeDown);
74
- this.volumeUp.load(data.volumeUp);
75
- }
76
- }
77
- exports.SoundsIcons = SoundsIcons;
78
- });
@@ -1,48 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "@tsparticles/engine", "./SoundsNote.js"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.SoundsMelody = void 0;
13
- const engine_1 = require("@tsparticles/engine");
14
- const SoundsNote_js_1 = require("./SoundsNote.js");
15
- class SoundsMelody {
16
- loop;
17
- melodies;
18
- notes;
19
- constructor() {
20
- this.loop = false;
21
- this.melodies = [];
22
- this.notes = [];
23
- }
24
- load(data) {
25
- if ((0, engine_1.isNull)(data)) {
26
- return;
27
- }
28
- if (data.loop !== undefined) {
29
- this.loop = data.loop;
30
- }
31
- if (data.melodies !== undefined) {
32
- this.melodies = data.melodies.map(s => {
33
- const tmp = new SoundsMelody();
34
- tmp.load(s);
35
- return tmp;
36
- });
37
- }
38
- if (data.notes !== undefined) {
39
- this.notes = data.notes.map(s => {
40
- const tmp = new SoundsNote_js_1.SoundsNote();
41
- tmp.load(s);
42
- return tmp;
43
- });
44
- }
45
- }
46
- }
47
- exports.SoundsMelody = SoundsMelody;
48
- });
@@ -1,34 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "@tsparticles/engine"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.SoundsNote = void 0;
13
- const engine_1 = require("@tsparticles/engine");
14
- class SoundsNote {
15
- duration;
16
- value;
17
- constructor() {
18
- this.duration = 500;
19
- this.value = [];
20
- }
21
- load(data) {
22
- if ((0, engine_1.isNull)(data)) {
23
- return;
24
- }
25
- if (data.duration !== undefined) {
26
- this.duration = data.duration;
27
- }
28
- if (data.value !== undefined) {
29
- this.value = data.value;
30
- }
31
- }
32
- }
33
- exports.SoundsNote = SoundsNote;
34
- });