@tsparticles/plugin-sounds 3.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +70 -0
  3. package/browser/Options/Classes/Sounds.js +30 -0
  4. package/browser/Options/Classes/SoundsAudio.js +22 -0
  5. package/browser/Options/Classes/SoundsEvent.js +54 -0
  6. package/browser/Options/Classes/SoundsIcon.js +23 -0
  7. package/browser/Options/Classes/SoundsIcons.js +54 -0
  8. package/browser/Options/Classes/SoundsMelody.js +30 -0
  9. package/browser/Options/Classes/SoundsNote.js +17 -0
  10. package/browser/Options/Classes/SoundsVolume.js +30 -0
  11. package/browser/Options/Interfaces/ISounds.js +1 -0
  12. package/browser/Options/Interfaces/ISoundsAudio.js +1 -0
  13. package/browser/Options/Interfaces/ISoundsEvent.js +1 -0
  14. package/browser/Options/Interfaces/ISoundsIcon.js +1 -0
  15. package/browser/Options/Interfaces/ISoundsIcons.js +1 -0
  16. package/browser/Options/Interfaces/ISoundsMelody.js +1 -0
  17. package/browser/Options/Interfaces/ISoundsNote.js +1 -0
  18. package/browser/Options/Interfaces/ISoundsVolume.js +1 -0
  19. package/browser/SoundsInstance.js +336 -0
  20. package/browser/enums.js +1 -0
  21. package/browser/index.js +29 -0
  22. package/browser/types.js +1 -0
  23. package/browser/utils.js +26 -0
  24. package/cjs/Options/Classes/Sounds.js +34 -0
  25. package/cjs/Options/Classes/SoundsAudio.js +26 -0
  26. package/cjs/Options/Classes/SoundsEvent.js +58 -0
  27. package/cjs/Options/Classes/SoundsIcon.js +27 -0
  28. package/cjs/Options/Classes/SoundsIcons.js +58 -0
  29. package/cjs/Options/Classes/SoundsMelody.js +34 -0
  30. package/cjs/Options/Classes/SoundsNote.js +21 -0
  31. package/cjs/Options/Classes/SoundsVolume.js +34 -0
  32. package/cjs/Options/Interfaces/ISounds.js +2 -0
  33. package/cjs/Options/Interfaces/ISoundsAudio.js +2 -0
  34. package/cjs/Options/Interfaces/ISoundsEvent.js +2 -0
  35. package/cjs/Options/Interfaces/ISoundsIcon.js +2 -0
  36. package/cjs/Options/Interfaces/ISoundsIcons.js +2 -0
  37. package/cjs/Options/Interfaces/ISoundsMelody.js +2 -0
  38. package/cjs/Options/Interfaces/ISoundsNote.js +2 -0
  39. package/cjs/Options/Interfaces/ISoundsVolume.js +2 -0
  40. package/cjs/SoundsInstance.js +359 -0
  41. package/cjs/enums.js +2 -0
  42. package/cjs/index.js +44 -0
  43. package/cjs/types.js +2 -0
  44. package/cjs/utils.js +30 -0
  45. package/esm/Options/Classes/Sounds.js +30 -0
  46. package/esm/Options/Classes/SoundsAudio.js +22 -0
  47. package/esm/Options/Classes/SoundsEvent.js +54 -0
  48. package/esm/Options/Classes/SoundsIcon.js +23 -0
  49. package/esm/Options/Classes/SoundsIcons.js +54 -0
  50. package/esm/Options/Classes/SoundsMelody.js +30 -0
  51. package/esm/Options/Classes/SoundsNote.js +17 -0
  52. package/esm/Options/Classes/SoundsVolume.js +30 -0
  53. package/esm/Options/Interfaces/ISounds.js +1 -0
  54. package/esm/Options/Interfaces/ISoundsAudio.js +1 -0
  55. package/esm/Options/Interfaces/ISoundsEvent.js +1 -0
  56. package/esm/Options/Interfaces/ISoundsIcon.js +1 -0
  57. package/esm/Options/Interfaces/ISoundsIcons.js +1 -0
  58. package/esm/Options/Interfaces/ISoundsMelody.js +1 -0
  59. package/esm/Options/Interfaces/ISoundsNote.js +1 -0
  60. package/esm/Options/Interfaces/ISoundsVolume.js +1 -0
  61. package/esm/SoundsInstance.js +336 -0
  62. package/esm/enums.js +1 -0
  63. package/esm/index.js +29 -0
  64. package/esm/types.js +1 -0
  65. package/esm/utils.js +26 -0
  66. package/package.json +81 -0
  67. package/report.html +39 -0
  68. package/tsparticles.plugin.sounds.js +780 -0
  69. package/tsparticles.plugin.sounds.min.js +2 -0
  70. package/tsparticles.plugin.sounds.min.js.LICENSE.txt +8 -0
  71. package/types/Options/Classes/Sounds.d.ts +13 -0
  72. package/types/Options/Classes/SoundsAudio.d.ts +8 -0
  73. package/types/Options/Classes/SoundsEvent.d.ts +20 -0
  74. package/types/Options/Classes/SoundsIcon.d.ts +10 -0
  75. package/types/Options/Classes/SoundsIcons.d.ts +11 -0
  76. package/types/Options/Classes/SoundsMelody.d.ts +10 -0
  77. package/types/Options/Classes/SoundsNote.d.ts +8 -0
  78. package/types/Options/Classes/SoundsVolume.d.ts +10 -0
  79. package/types/Options/Interfaces/ISounds.d.ts +9 -0
  80. package/types/Options/Interfaces/ISoundsAudio.d.ts +4 -0
  81. package/types/Options/Interfaces/ISoundsEvent.d.ts +12 -0
  82. package/types/Options/Interfaces/ISoundsIcon.d.ts +6 -0
  83. package/types/Options/Interfaces/ISoundsIcons.d.ts +7 -0
  84. package/types/Options/Interfaces/ISoundsMelody.d.ts +6 -0
  85. package/types/Options/Interfaces/ISoundsNote.d.ts +5 -0
  86. package/types/Options/Interfaces/ISoundsVolume.d.ts +6 -0
  87. package/types/SoundsInstance.d.ts +32 -0
  88. package/types/enums.d.ts +4 -0
  89. package/types/index.d.ts +2 -0
  90. package/types/types.d.ts +15 -0
  91. package/types/utils.d.ts +1 -0
  92. package/umd/Options/Classes/Sounds.js +44 -0
  93. package/umd/Options/Classes/SoundsAudio.js +36 -0
  94. package/umd/Options/Classes/SoundsEvent.js +68 -0
  95. package/umd/Options/Classes/SoundsIcon.js +37 -0
  96. package/umd/Options/Classes/SoundsIcons.js +68 -0
  97. package/umd/Options/Classes/SoundsMelody.js +44 -0
  98. package/umd/Options/Classes/SoundsNote.js +31 -0
  99. package/umd/Options/Classes/SoundsVolume.js +44 -0
  100. package/umd/Options/Interfaces/ISounds.js +12 -0
  101. package/umd/Options/Interfaces/ISoundsAudio.js +12 -0
  102. package/umd/Options/Interfaces/ISoundsEvent.js +12 -0
  103. package/umd/Options/Interfaces/ISoundsIcon.js +12 -0
  104. package/umd/Options/Interfaces/ISoundsIcons.js +12 -0
  105. package/umd/Options/Interfaces/ISoundsMelody.js +12 -0
  106. package/umd/Options/Interfaces/ISoundsNote.js +12 -0
  107. package/umd/Options/Interfaces/ISoundsVolume.js +12 -0
  108. package/umd/SoundsInstance.js +350 -0
  109. package/umd/enums.js +12 -0
  110. package/umd/index.js +43 -0
  111. package/umd/types.js +12 -0
  112. package/umd/utils.js +40 -0
@@ -0,0 +1,2 @@
1
+ /*! For license information please see tsparticles.plugin.sounds.min.js.LICENSE.txt */
2
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var i="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in i)("object"==typeof exports?exports:e)[o]=i[o]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},i={};function o(e){var n=i[e];if(void 0!==n)return n.exports;var s=i[e]={exports:{}};return t[e](s,s.exports,o),s.exports}o.d=(e,t)=>{for(var i in t)o.o(t,i)&&!o.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{o.r(n),o.d(n,{loadSoundsPlugin:()=>f});class e{constructor(){this.loop=!1,this.source=""}load(e){void 0!==e&&("object"==typeof e?(void 0!==e.loop&&(this.loop=e.loop),void 0!==e.source&&(this.source=e.source)):this.source=e)}}class t{constructor(){this.duration=500,this.value=[]}load(e){e&&(void 0!==e.duration&&(this.duration=e.duration),void 0!==e.value&&(this.value=e.value))}}class i{constructor(){this.loop=!1,this.melodies=[],this.notes=[]}load(e){void 0!==e&&(void 0!==e.loop&&(this.loop=e.loop),void 0!==e.melodies&&(this.melodies=e.melodies.map((e=>{const t=new i;return t.load(e),t}))),void 0!==e.notes&&(this.notes=e.notes.map((e=>{const i=new t;return i.load(e),i}))))}}class s{constructor(){this.event=[],this.notes=[]}load(o){o&&(void 0!==o.event&&(this.event=o.event),void 0!==o.audio&&(o.audio instanceof Array?this.audio=o.audio.map((t=>{const i=new e;return i.load(t),i})):(this.audio=new e,this.audio.load(o.audio))),void 0!==o.notes&&(this.notes=o.notes.map((e=>{const i=new t;return i.load(e),i}))),void 0!==o.melodies&&(this.melodies=o.melodies.map((e=>{const t=new i;return t.load(e),t}))),void 0!==o.filter&&("string"==typeof o.filter?"function"==typeof window[o.filter]&&(this.filter=window[o.filter]):this.filter=o.filter))}}class a{constructor(){this.width=24,this.height=24}load(e){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 l{constructor(){this.mute=new a,this.unmute=new a,this.volumeDown=new a,this.volumeUp=new a,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(e){e&&(this.mute.load(e.mute),this.unmute.load(e.unmute),this.volumeDown.load(e.volumeDown),this.volumeUp.load(e.volumeUp))}}class u{constructor(){this.value=100,this.max=100,this.min=0,this.step=10}load(e){void 0!==e&&("object"==typeof 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 c{constructor(){this.enable=!1,this.events=[],this.icons=new l,this.volume=new u}load(e){e&&(void 0!==e.enable&&(this.enable=e.enable),void 0!==e.events&&(this.events=e.events.map((e=>{const t=new s;return t.load(e),t}))),this.icons.load(e.icons),void 0!==e.volume&&this.volume.load(e.volume))}}var r=o(533);const d=new Map;function h(e){const t=/(([A-G]b?)(\d))|pause/i.exec(e);if(!t||!t.length)return;console.log(t);const i=t[2]||t[0],o=d.get(i);return o?o[parseInt(t[3]||"0")]:void 0}function v(e,t,i,o,n,s,a){e.style.userSelect="none",e.style.webkitUserSelect="none",e.style.position="absolute",e.style.top=`${t+a}px`,e.style.left=i-a-s+"px",e.style.display=o,e.style.zIndex=`${n+1}`}d.set("C",[16.35,32.7,65.41,130.81,261.63,523.25,1046.5,2093,4186.01]),d.set("Db",[17.32,34.65,69.3,138.59,277.18,554.37,1108.73,2217.46,4434.92]),d.set("D",[18.35,36.71,73.42,146.83,293.66,587.33,1174.66,2349.32,4698.63]),d.set("Eb",[19.45,38.89,77.78,155.56,311.13,622.25,1244.51,2489.02,4978.03]),d.set("E",[20.6,41.2,82.41,164.81,329.63,659.25,1318.51,2637.02,5274.04]),d.set("F",[21.83,43.65,87.31,174.61,349.23,698.46,1396.91,2793.83,5587.65]),d.set("Gb",[23.12,46.25,92.5,185,369.99,739.99,1479.98,2959.96,5919.91]),d.set("G",[24.5,49,98,196,392,783.99,1567.98,3135.96,6271.93]),d.set("Ab",[25.96,51.91,103.83,207.65,415.3,830.61,1661.22,3322.44,6644.88]),d.set("A",[27.5,55,110,220,440,880,1760,3520,7040]),d.set("Bb",[29.14,58.27,116.54,233.08,466.16,932.33,1864.66,3729.31,7458.62]),d.set("B",[30.87,61.74,123.47,246.94,493.88,987.77,1975.53,3951.07,7902.13]),d.set("pause",[0]);class m{constructor(e,t){this._container=e,this._engine=t,this._volume=0,this._audioSources=[],this._audioMap=new Map}async init(){const e=this._container,t=e.actualOptions.sounds;if(!(null==t?void 0:t.enable))return;this._volume=t.volume.value;const i=t.events;this._audioMap=new Map;for(const t of i)t.audio&&(0,r.executeOnSingleOrMultiple)(t.audio,(async t=>{const i=await fetch(t.source);if(!i.ok)return;const o=await i.arrayBuffer();e.audioContext=new AudioContext;const n=await e.audioContext.decodeAudioData(o);this._audioMap.set(t.source,n)}))}async start(){var e,t,i,o;const n=this._container,s=n.actualOptions,a=s.sounds;if(!(null==a?void 0:a.enable)||!n.canvas.element)return;n.muted=!0,this._muteImg=document.createElement("img"),this._unmuteImg=document.createElement("img"),this._volumeDownImg=document.createElement("img"),this._volumeUpImg=document.createElement("img");const l=this._muteImg,u=this._unmuteImg,c=this._volumeDownImg,r=this._volumeUpImg,d=n.canvas.element.offsetTop,h=n.canvas.element.offsetLeft+n.canvas.element.offsetWidth,m=a.icons,p=m.mute,f=m.unmute,g=m.volumeDown,_=m.volumeUp,w=10;v(l,d+w,h-30-p.width-g.width-_.width,"block",s.fullScreen.zIndex+1,p.width,w),v(u,d+w,h-30-f.width-g.width-_.width,"none",s.fullScreen.zIndex+1,f.width,w),v(c,d+w,h-20-g.width-_.width,"block",s.fullScreen.zIndex+1,g.width,w),v(r,d+w,h-w-_.width,"block",s.fullScreen.zIndex+1,_.width,w),l.src=null!==(e=p.path)&&void 0!==e?e:p.svg?`data:image/svg+xml;base64,${btoa(p.svg)}`:"",u.src=null!==(t=f.path)&&void 0!==t?t:f.svg?`data:image/svg+xml;base64,${btoa(f.svg)}`:"",c.src=null!==(i=g.path)&&void 0!==i?i:g.svg?`data:image/svg+xml;base64,${btoa(g.svg)}`:"",r.src=null!==(o=_.path)&&void 0!==o?o:_.svg?`data:image/svg+xml;base64,${btoa(_.svg)}`:"";const x=n.canvas.element.parentNode||document.body;x.append(l),x.append(u),x.append(c),x.append(r);const y=()=>{n.muted=!n.muted,this._updateMuteIcons(),this._updateMuteStatus()};l.addEventListener("click",y),u.addEventListener("click",y),c.addEventListener("click",(()=>{n.muted&&(this._volume=0),this._volume-=a.volume.step,this._updateVolume()})),r.addEventListener("click",(()=>{n.muted&&(this._volume=0),this._volume+=a.volume.step,this._updateVolume()}))}stop(){this._container.muted=!0,this._mute(),this._muteImg&&this._muteImg.remove(),this._unmuteImg&&this._unmuteImg.remove(),this._volumeDownImg&&this._volumeDownImg.remove(),this._volumeUpImg&&this._volumeUpImg.remove()}_addBuffer(e){const t=e.createBufferSource();return this._audioSources.push(t),t}_addOscillator(e){const t=e.createOscillator();return this._audioSources.push(t),t}_initEvents(){const e=this._container,t=e.actualOptions.sounds;if((null==t?void 0:t.enable)&&e.canvas.element)for(const e of t.events){const t=async i=>{if(this._container===i.container)if(!this._container||this._container.muted||this._container.destroyed)(0,r.executeOnSingleOrMultiple)(e.event,(e=>{this._engine.removeEventListener(e,t)}));else if(!e.filter||e.filter(i))if(e.audio)this._playBuffer((0,r.itemFromSingleOrMultiple)(e.audio));else if(e.melodies){const t=(0,r.itemFromArray)(e.melodies);t.melodies.length?await Promise.allSettled(t.melodies.map((e=>this._playNote(e.notes,0,t.loop)))):await this._playNote(t.notes,0,t.loop)}else if(e.notes){const t=(0,r.itemFromArray)(e.notes);await this._playNote([t],0,!1)}};(0,r.executeOnSingleOrMultiple)(e.event,(e=>{this._engine.addEventListener(e,t)}))}}_mute(){const e=this._container;if(e.audioContext){for(const e of this._audioSources)this._removeAudioSource(e);this._gain&&this._gain.disconnect(),e.audioContext.close(),e.audioContext=void 0,this._engine.dispatchEvent("soundsMuted",{container:this._container})}}_playBuffer(e){var t;const i=this._audioMap.get(e.source);if(!i)return;const o=this._container.audioContext;if(!o)return;const n=this._addBuffer(o);n.loop=e.loop,n.buffer=i,n.connect(null!==(t=this._gain)&&void 0!==t?t:o.destination),n.start()}async _playFrequency(e,t){if(!this._container.audioContext||!this._gain)return;const i=this._addOscillator(this._container.audioContext);return i.connect(this._gain),i.type="sine",i.frequency.value=e,i.start(),new Promise((e=>{setTimeout((()=>{this._removeAudioSource(i),e()}),t)}))}_playMuteSound(){const e=this._container;if(!e.audioContext)return;const t=e.audioContext.createGain();t.connect(e.audioContext.destination),t.gain.value=0;const i=e.audioContext.createOscillator();i.connect(t),i.type="sine",i.frequency.value=1,i.start(),setTimeout((()=>{i.stop(),i.disconnect(),t.disconnect()}))}async _playNote(e,t,i){if(this._container.muted)return;const o=e[t];if(!o)return;const n=o.value,s=(0,r.executeOnSingleOrMultiple)(n,(async(i,o)=>this._playNoteValue(e,t,o)));await(s instanceof Array?Promise.allSettled(s):s);let a=t+1;i&&a>=e.length&&(a%=e.length),this._container.muted||await this._playNote(e,a,i)}async _playNoteValue(e,t,i){const o=e[t];if(!o)return;const n=(0,r.itemFromSingleOrMultiple)(o.value,i,!0);try{const e=h(n);if("number"!=typeof e)return;await this._playFrequency(e,o.duration)}catch(e){console.error(e)}}_removeAudioSource(e){e.stop(),e.disconnect(),this._audioSources.splice(this._audioSources.indexOf(e),1)}_unmute(){const e=this._container,t=e.actualOptions.sounds;if(!t)return;e.audioContext||(e.audioContext=new AudioContext),this._audioSources||(this._audioSources=[]);const i=e.audioContext.createGain();i.connect(e.audioContext.destination),i.gain.value=t.volume.value/100,this._gain=i,this._initEvents(),this._engine.dispatchEvent("soundsUnmuted",{container:this._container})}_updateMuteIcons(){const e=this._container,t=this._muteImg,i=this._unmuteImg;t&&(t.style.display=e.muted?"block":"none"),i&&(i.style.display=e.muted?"none":"block")}_updateMuteStatus(){this._container.muted?this._mute():(this._unmute(),this._playMuteSound())}_updateVolume(){var e;const t=this._container,i=t.actualOptions.sounds;if(!(null==i?void 0:i.enable))return;(0,r.clamp)(this._volume,i.volume.min,i.volume.max);let o=!1;this._volume<=0&&!t.muted?(this._volume=0,t.muted=!0,o=!0):this._volume>0&&t.muted&&(t.muted=!1,o=!0),o&&(this._updateMuteIcons(),this._updateMuteStatus()),(null===(e=this._gain)||void 0===e?void 0:e.gain)&&(this._gain.gain.value=this._volume/100)}}class p{constructor(e){this.id="sounds",this._engine=e}getPlugin(e){return new m(e,this._engine)}loadOptions(e,t){if(!this.needsPlugin(t))return;let i=e.sounds;void 0===(null==i?void 0:i.load)&&(e.sounds=i=new c),i.load(null==t?void 0:t.sounds)}needsPlugin(e){var t,i;return null!==(i=null===(t=null==e?void 0:e.sounds)||void 0===t?void 0:t.enable)&&void 0!==i&&i}}async function f(e){const t=new p(e);await e.addPlugin(t)}})(),n})()));
@@ -0,0 +1,8 @@
1
+ /*!
2
+ * Author : Matteo Bruni
3
+ * MIT license: https://opensource.org/licenses/MIT
4
+ * Demo / Generator : https://particles.js.org/
5
+ * GitHub : https://www.github.com/matteobruni/tsparticles
6
+ * How to use? : Check the GitHub README
7
+ * v3.0.0-alpha.0
8
+ */
@@ -0,0 +1,13 @@
1
+ import type { IOptionLoader, RecursivePartial } from "@tsparticles/engine";
2
+ import type { ISounds } from "../Interfaces/ISounds";
3
+ import { SoundsEvent } from "./SoundsEvent";
4
+ import { SoundsIcons } from "./SoundsIcons";
5
+ import { SoundsVolume } from "./SoundsVolume";
6
+ export declare class Sounds implements ISounds, IOptionLoader<ISounds> {
7
+ enable: boolean;
8
+ events: SoundsEvent[];
9
+ icons: SoundsIcons;
10
+ volume: SoundsVolume;
11
+ constructor();
12
+ load(data?: RecursivePartial<ISounds>): void;
13
+ }
@@ -0,0 +1,8 @@
1
+ import type { IOptionLoader, RecursivePartial } from "@tsparticles/engine";
2
+ import type { ISoundsAudio } from "../Interfaces/ISoundsAudio";
3
+ export declare class SoundsAudio implements ISoundsAudio, IOptionLoader<ISoundsAudio> {
4
+ loop: boolean;
5
+ source: string;
6
+ constructor();
7
+ load(data?: RecursivePartial<ISoundsAudio | string>): void;
8
+ }
@@ -0,0 +1,20 @@
1
+ import type { IOptionLoader, RecursivePartial, SingleOrMultiple } from "@tsparticles/engine";
2
+ import type { FilterFunction } from "../../types";
3
+ import type { ISoundsEvent } from "../Interfaces/ISoundsEvent";
4
+ import { SoundsAudio } from "./SoundsAudio";
5
+ import { SoundsMelody } from "./SoundsMelody";
6
+ import { SoundsNote } from "./SoundsNote";
7
+ declare global {
8
+ interface Window {
9
+ [key: string]: unknown;
10
+ }
11
+ }
12
+ export declare class SoundsEvent implements ISoundsEvent, IOptionLoader<ISoundsEvent> {
13
+ audio?: SingleOrMultiple<SoundsAudio>;
14
+ event: SingleOrMultiple<string>;
15
+ filter?: FilterFunction;
16
+ melodies?: SoundsMelody[];
17
+ notes?: SoundsNote[];
18
+ constructor();
19
+ load(data?: RecursivePartial<ISoundsEvent>): void;
20
+ }
@@ -0,0 +1,10 @@
1
+ import type { IOptionLoader, RecursivePartial } from "@tsparticles/engine";
2
+ import type { ISoundsIcon } from "../Interfaces/ISoundsIcon";
3
+ export declare class SoundsIcon implements ISoundsIcon, IOptionLoader<ISoundsIcon> {
4
+ height: number;
5
+ path?: string;
6
+ svg?: string;
7
+ width: number;
8
+ constructor();
9
+ load(data?: RecursivePartial<ISoundsIcon>): void;
10
+ }
@@ -0,0 +1,11 @@
1
+ import type { IOptionLoader, RecursivePartial } from "@tsparticles/engine";
2
+ import type { ISoundsIcons } from "../Interfaces/ISoundsIcons";
3
+ import { SoundsIcon } from "./SoundsIcon";
4
+ export declare class SoundsIcons implements ISoundsIcons, IOptionLoader<ISoundsIcons> {
5
+ mute: SoundsIcon;
6
+ unmute: SoundsIcon;
7
+ volumeDown: SoundsIcon;
8
+ volumeUp: SoundsIcon;
9
+ constructor();
10
+ load(data?: RecursivePartial<ISoundsIcons>): void;
11
+ }
@@ -0,0 +1,10 @@
1
+ import type { IOptionLoader, RecursivePartial } from "@tsparticles/engine";
2
+ import type { ISoundsMelody } from "../Interfaces/ISoundsMelody";
3
+ import { SoundsNote } from "./SoundsNote";
4
+ export declare class SoundsMelody implements ISoundsMelody, IOptionLoader<ISoundsMelody> {
5
+ loop: boolean;
6
+ melodies: SoundsMelody[];
7
+ notes: SoundsNote[];
8
+ constructor();
9
+ load(data?: RecursivePartial<ISoundsMelody>): void;
10
+ }
@@ -0,0 +1,8 @@
1
+ import type { IOptionLoader, RecursivePartial, SingleOrMultiple } from "@tsparticles/engine";
2
+ import type { ISoundsNote } from "../Interfaces/ISoundsNote";
3
+ export declare class SoundsNote implements ISoundsNote, IOptionLoader<ISoundsNote> {
4
+ duration: number;
5
+ value: SingleOrMultiple<string>;
6
+ constructor();
7
+ load(data?: RecursivePartial<ISoundsNote>): void;
8
+ }
@@ -0,0 +1,10 @@
1
+ import type { IOptionLoader, RecursivePartial } from "@tsparticles/engine";
2
+ import type { ISoundsVolume } from "../Interfaces/ISoundsVolume";
3
+ export declare class SoundsVolume implements ISoundsVolume, IOptionLoader<ISoundsVolume> {
4
+ max: number;
5
+ min: number;
6
+ step: number;
7
+ value: number;
8
+ constructor();
9
+ load(data?: RecursivePartial<ISoundsVolume | number>): void;
10
+ }
@@ -0,0 +1,9 @@
1
+ import type { ISoundsEvent } from "./ISoundsEvent";
2
+ import type { ISoundsIcons } from "./ISoundsIcons";
3
+ import type { ISoundsVolume } from "./ISoundsVolume";
4
+ export interface ISounds {
5
+ enable: boolean;
6
+ events: ISoundsEvent[];
7
+ icons: ISoundsIcons;
8
+ volume: ISoundsVolume | number;
9
+ }
@@ -0,0 +1,4 @@
1
+ export interface ISoundsAudio {
2
+ loop: boolean;
3
+ source: string;
4
+ }
@@ -0,0 +1,12 @@
1
+ import type { FilterFunction } from "../../types";
2
+ import type { ISoundsAudio } from "./ISoundsAudio";
3
+ import type { ISoundsMelody } from "./ISoundsMelody";
4
+ import type { ISoundsNote } from "./ISoundsNote";
5
+ import type { SingleOrMultiple } from "@tsparticles/engine";
6
+ export interface ISoundsEvent {
7
+ audio?: SingleOrMultiple<ISoundsAudio | string>;
8
+ event: SingleOrMultiple<string>;
9
+ filter?: string | FilterFunction;
10
+ melodies?: ISoundsMelody[];
11
+ notes?: ISoundsNote[];
12
+ }
@@ -0,0 +1,6 @@
1
+ export interface ISoundsIcon {
2
+ height: number;
3
+ path?: string;
4
+ svg?: string;
5
+ width: number;
6
+ }
@@ -0,0 +1,7 @@
1
+ import type { ISoundsIcon } from "./ISoundsIcon";
2
+ export interface ISoundsIcons {
3
+ mute: ISoundsIcon;
4
+ unmute: ISoundsIcon;
5
+ volumeDown: ISoundsIcon;
6
+ volumeUp: ISoundsIcon;
7
+ }
@@ -0,0 +1,6 @@
1
+ import type { ISoundsNote } from "./ISoundsNote";
2
+ export interface ISoundsMelody {
3
+ loop: boolean;
4
+ melodies: ISoundsMelody[];
5
+ notes: ISoundsNote[];
6
+ }
@@ -0,0 +1,5 @@
1
+ import type { SingleOrMultiple } from "@tsparticles/engine";
2
+ export interface ISoundsNote {
3
+ duration: number;
4
+ value: SingleOrMultiple<string>;
5
+ }
@@ -0,0 +1,6 @@
1
+ export interface ISoundsVolume {
2
+ max: number;
3
+ min: number;
4
+ step: number;
5
+ value: number;
6
+ }
@@ -0,0 +1,32 @@
1
+ import type { Engine, IContainerPlugin } from "@tsparticles/engine";
2
+ import type { SoundsContainer } from "./types";
3
+ export declare class SoundsInstance implements IContainerPlugin {
4
+ private _audioMap;
5
+ private _audioSources;
6
+ private readonly _container;
7
+ private readonly _engine;
8
+ private _gain?;
9
+ private _muteImg?;
10
+ private _unmuteImg?;
11
+ private _volume;
12
+ private _volumeDownImg?;
13
+ private _volumeUpImg?;
14
+ constructor(container: SoundsContainer, engine: Engine);
15
+ init(): Promise<void>;
16
+ start(): Promise<void>;
17
+ stop(): void;
18
+ private _addBuffer;
19
+ private _addOscillator;
20
+ private _initEvents;
21
+ private _mute;
22
+ private _playBuffer;
23
+ private _playFrequency;
24
+ private _playMuteSound;
25
+ private _playNote;
26
+ private _playNoteValue;
27
+ private _removeAudioSource;
28
+ private _unmute;
29
+ private _updateMuteIcons;
30
+ private _updateMuteStatus;
31
+ private _updateVolume;
32
+ }
@@ -0,0 +1,4 @@
1
+ export declare const enum SoundsEventType {
2
+ mute = "soundsMuted",
3
+ unmute = "soundsUnmuted"
4
+ }
@@ -0,0 +1,2 @@
1
+ import type { Engine } from "@tsparticles/engine";
2
+ export declare function loadSoundsPlugin(engine: Engine): Promise<void>;
@@ -0,0 +1,15 @@
1
+ import type { Container, CustomEventArgs, IOptions, Options } from "@tsparticles/engine";
2
+ import type { ISounds } from "./Options/Interfaces/ISounds";
3
+ import type { Sounds } from "./Options/Classes/Sounds";
4
+ export type FilterFunction = (args: CustomEventArgs) => boolean;
5
+ export type ISoundsOptions = IOptions & {
6
+ sounds?: ISounds;
7
+ };
8
+ export type SoundsOptions = Options & {
9
+ sounds?: Sounds;
10
+ };
11
+ export type SoundsContainer = Container & {
12
+ actualOptions: SoundsOptions;
13
+ audioContext?: AudioContext;
14
+ muted?: boolean;
15
+ };
@@ -0,0 +1 @@
1
+ export declare function getNoteFrequency(note: string): number | undefined;
@@ -0,0 +1,44 @@
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", "./SoundsEvent", "./SoundsIcons", "./SoundsVolume"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Sounds = void 0;
13
+ const SoundsEvent_1 = require("./SoundsEvent");
14
+ const SoundsIcons_1 = require("./SoundsIcons");
15
+ const SoundsVolume_1 = require("./SoundsVolume");
16
+ class Sounds {
17
+ constructor() {
18
+ this.enable = false;
19
+ this.events = [];
20
+ this.icons = new SoundsIcons_1.SoundsIcons();
21
+ this.volume = new SoundsVolume_1.SoundsVolume();
22
+ }
23
+ load(data) {
24
+ if (!data) {
25
+ return;
26
+ }
27
+ if (data.enable !== undefined) {
28
+ this.enable = data.enable;
29
+ }
30
+ if (data.events !== undefined) {
31
+ this.events = data.events.map((t) => {
32
+ const event = new SoundsEvent_1.SoundsEvent();
33
+ event.load(t);
34
+ return event;
35
+ });
36
+ }
37
+ this.icons.load(data.icons);
38
+ if (data.volume !== undefined) {
39
+ this.volume.load(data.volume);
40
+ }
41
+ }
42
+ }
43
+ exports.Sounds = Sounds;
44
+ });
@@ -0,0 +1,36 @@
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"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.SoundsAudio = void 0;
13
+ class SoundsAudio {
14
+ constructor() {
15
+ this.loop = false;
16
+ this.source = "";
17
+ }
18
+ load(data) {
19
+ if (data === undefined) {
20
+ return;
21
+ }
22
+ if (typeof data === "object") {
23
+ if (data.loop !== undefined) {
24
+ this.loop = data.loop;
25
+ }
26
+ if (data.source !== undefined) {
27
+ this.source = data.source;
28
+ }
29
+ }
30
+ else {
31
+ this.source = data;
32
+ }
33
+ }
34
+ }
35
+ exports.SoundsAudio = SoundsAudio;
36
+ });
@@ -0,0 +1,68 @@
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", "./SoundsAudio", "./SoundsMelody", "./SoundsNote"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.SoundsEvent = void 0;
13
+ const SoundsAudio_1 = require("./SoundsAudio");
14
+ const SoundsMelody_1 = require("./SoundsMelody");
15
+ const SoundsNote_1 = require("./SoundsNote");
16
+ class SoundsEvent {
17
+ constructor() {
18
+ this.event = [];
19
+ this.notes = [];
20
+ }
21
+ load(data) {
22
+ if (!data) {
23
+ return;
24
+ }
25
+ if (data.event !== undefined) {
26
+ this.event = data.event;
27
+ }
28
+ if (data.audio !== undefined) {
29
+ if (data.audio instanceof Array) {
30
+ this.audio = data.audio.map((s) => {
31
+ const tmp = new SoundsAudio_1.SoundsAudio();
32
+ tmp.load(s);
33
+ return tmp;
34
+ });
35
+ }
36
+ else {
37
+ this.audio = new SoundsAudio_1.SoundsAudio();
38
+ this.audio.load(data.audio);
39
+ }
40
+ }
41
+ if (data.notes !== undefined) {
42
+ this.notes = data.notes.map((t) => {
43
+ const tmp = new SoundsNote_1.SoundsNote();
44
+ tmp.load(t);
45
+ return tmp;
46
+ });
47
+ }
48
+ if (data.melodies !== undefined) {
49
+ this.melodies = data.melodies.map((t) => {
50
+ const tmp = new SoundsMelody_1.SoundsMelody();
51
+ tmp.load(t);
52
+ return tmp;
53
+ });
54
+ }
55
+ if (data.filter !== undefined) {
56
+ if (typeof data.filter === "string") {
57
+ if (typeof window[data.filter] === "function") {
58
+ this.filter = window[data.filter];
59
+ }
60
+ }
61
+ else {
62
+ this.filter = data.filter;
63
+ }
64
+ }
65
+ }
66
+ }
67
+ exports.SoundsEvent = SoundsEvent;
68
+ });
@@ -0,0 +1,37 @@
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"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.SoundsIcon = void 0;
13
+ class SoundsIcon {
14
+ constructor() {
15
+ this.width = 24;
16
+ this.height = 24;
17
+ }
18
+ load(data) {
19
+ if (!data) {
20
+ return;
21
+ }
22
+ if (data.path !== undefined) {
23
+ this.path = data.path;
24
+ }
25
+ if (data.svg !== undefined) {
26
+ this.svg = data.svg;
27
+ }
28
+ if (data.width !== undefined) {
29
+ this.width = data.width;
30
+ }
31
+ if (data.height !== undefined) {
32
+ this.height = data.height;
33
+ }
34
+ }
35
+ }
36
+ exports.SoundsIcon = SoundsIcon;
37
+ });
@@ -0,0 +1,68 @@
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", "./SoundsIcon"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.SoundsIcons = void 0;
13
+ const SoundsIcon_1 = require("./SoundsIcon");
14
+ class SoundsIcons {
15
+ constructor() {
16
+ this.mute = new SoundsIcon_1.SoundsIcon();
17
+ this.unmute = new SoundsIcon_1.SoundsIcon();
18
+ this.volumeDown = new SoundsIcon_1.SoundsIcon();
19
+ this.volumeUp = new SoundsIcon_1.SoundsIcon();
20
+ this.mute.svg = `<?xml version="1.0"?>
21
+ <svg baseProfile="tiny" height="24px" version="1.2" viewBox="0 0 24 24" width="24px"
22
+ xml:space="preserve" xmlns="http://www.w3.org/2000/svg"
23
+ xmlns:xlink="http://www.w3.org/1999/xlink">
24
+ <g id="Layer_1">
25
+ <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"/>
26
+ </g>
27
+ </svg>`;
28
+ this.unmute.svg = `<?xml version="1.0"?>
29
+ <svg baseProfile="tiny" height="24px" version="1.2" viewBox="0 0 24 24" width="24px"
30
+ xml:space="preserve" xmlns="http://www.w3.org/2000/svg"
31
+ xmlns:xlink="http://www.w3.org/1999/xlink">
32
+ <g id="Layer_1">
33
+ <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"/>
34
+ </g>
35
+ </svg>`;
36
+ this.volumeDown.svg = `<?xml version="1.0"?>
37
+ <svg baseProfile="tiny" height="24px" version="1.2" viewBox="0 0 24 24" width="24px"
38
+ xml:space="preserve" xmlns="http://www.w3.org/2000/svg"
39
+ xmlns:xlink="http://www.w3.org/1999/xlink">
40
+ <g id="Layer_1">
41
+ <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"/>
42
+ <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"/>
43
+ </g>
44
+ </svg>`;
45
+ this.volumeUp.svg = `<?xml version="1.0"?>
46
+ <svg baseProfile="tiny" height="24px" version="1.2" viewBox="0 0 24 24" width="24px"
47
+ xml:space="preserve" xmlns="http://www.w3.org/2000/svg"
48
+ xmlns:xlink="http://www.w3.org/1999/xlink">
49
+ <g id="Layer_1">
50
+ <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"/>
51
+ <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"/>
52
+ <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"/>
53
+ <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"/>
54
+ </g>
55
+ </svg>`;
56
+ }
57
+ load(data) {
58
+ if (!data) {
59
+ return;
60
+ }
61
+ this.mute.load(data.mute);
62
+ this.unmute.load(data.unmute);
63
+ this.volumeDown.load(data.volumeDown);
64
+ this.volumeUp.load(data.volumeUp);
65
+ }
66
+ }
67
+ exports.SoundsIcons = SoundsIcons;
68
+ });
@@ -0,0 +1,44 @@
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", "./SoundsNote"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.SoundsMelody = void 0;
13
+ const SoundsNote_1 = require("./SoundsNote");
14
+ class SoundsMelody {
15
+ constructor() {
16
+ this.loop = false;
17
+ this.melodies = [];
18
+ this.notes = [];
19
+ }
20
+ load(data) {
21
+ if (data === undefined) {
22
+ return;
23
+ }
24
+ if (data.loop !== undefined) {
25
+ this.loop = data.loop;
26
+ }
27
+ if (data.melodies !== undefined) {
28
+ this.melodies = data.melodies.map((s) => {
29
+ const tmp = new SoundsMelody();
30
+ tmp.load(s);
31
+ return tmp;
32
+ });
33
+ }
34
+ if (data.notes !== undefined) {
35
+ this.notes = data.notes.map((s) => {
36
+ const tmp = new SoundsNote_1.SoundsNote();
37
+ tmp.load(s);
38
+ return tmp;
39
+ });
40
+ }
41
+ }
42
+ }
43
+ exports.SoundsMelody = SoundsMelody;
44
+ });
@@ -0,0 +1,31 @@
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"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.SoundsNote = void 0;
13
+ class SoundsNote {
14
+ constructor() {
15
+ this.duration = 500;
16
+ this.value = [];
17
+ }
18
+ load(data) {
19
+ if (!data) {
20
+ return;
21
+ }
22
+ if (data.duration !== undefined) {
23
+ this.duration = data.duration;
24
+ }
25
+ if (data.value !== undefined) {
26
+ this.value = data.value;
27
+ }
28
+ }
29
+ }
30
+ exports.SoundsNote = SoundsNote;
31
+ });