@tsparticles/fireworks 4.1.3 → 4.2.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.
@@ -1,5 +1,5 @@
1
1
  (function(g){g.__tsParticlesInternals=g.__tsParticlesInternals||{};g.__tsParticlesInternals.bundles=g.__tsParticlesInternals.bundles||{};g.__tsParticlesInternals.effects=g.__tsParticlesInternals.effects||{};g.__tsParticlesInternals.engine=g.__tsParticlesInternals.engine||{};g.__tsParticlesInternals.interactions=g.__tsParticlesInternals.interactions||{};g.__tsParticlesInternals.palettes=g.__tsParticlesInternals.palettes||{};g.__tsParticlesInternals.paths=g.__tsParticlesInternals.paths||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins.emittersShapes=g.__tsParticlesInternals.plugins.emittersShapes||{};g.__tsParticlesInternals.presets=g.__tsParticlesInternals.presets||{};g.__tsParticlesInternals.shapes=g.__tsParticlesInternals.shapes||{};g.__tsParticlesInternals.updaters=g.__tsParticlesInternals.updaters||{};g.__tsParticlesInternals.utils=g.__tsParticlesInternals.utils||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas.utils=g.__tsParticlesInternals.canvas.utils||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path.utils=g.__tsParticlesInternals.path.utils||{};var __tsProxyFactory=typeof Proxy!=="undefined"?function(obj){return new Proxy(obj,{get:function(target,key){if(!(key in target)){target[key]={};}return target[key];}});}:function(obj){return obj;};g.__tsParticlesInternals.bundles=__tsProxyFactory(g.__tsParticlesInternals.bundles);g.__tsParticlesInternals.effects=__tsProxyFactory(g.__tsParticlesInternals.effects);g.__tsParticlesInternals.interactions=__tsProxyFactory(g.__tsParticlesInternals.interactions);g.__tsParticlesInternals.palettes=__tsProxyFactory(g.__tsParticlesInternals.palettes);g.__tsParticlesInternals.paths=__tsProxyFactory(g.__tsParticlesInternals.paths);g.__tsParticlesInternals.plugins=__tsProxyFactory(g.__tsParticlesInternals.plugins);g.__tsParticlesInternals.plugins.emittersShapes=__tsProxyFactory(g.__tsParticlesInternals.plugins.emittersShapes);g.__tsParticlesInternals.presets=__tsProxyFactory(g.__tsParticlesInternals.presets);g.__tsParticlesInternals.shapes=__tsProxyFactory(g.__tsParticlesInternals.shapes);g.__tsParticlesInternals.updaters=__tsProxyFactory(g.__tsParticlesInternals.updaters);g.__tsParticlesInternals.utils=__tsProxyFactory(g.__tsParticlesInternals.utils);g.__tsParticlesInternals.canvas=__tsProxyFactory(g.__tsParticlesInternals.canvas);g.__tsParticlesInternals.path=__tsProxyFactory(g.__tsParticlesInternals.path);g.tsparticlesInternalExports=g.tsparticlesInternalExports||{};})(typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:this);
2
- /* tsParticles v4.1.3 */
2
+ /* tsParticles v4.2.0 */
3
3
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tsparticles/engine'), require('@tsparticles/basic'), require('@tsparticles/plugin-blend'), require('@tsparticles/updater-destroy'), require('@tsparticles/plugin-emitters/plugin'), require('@tsparticles/plugin-emitters-shape-square'), require('@tsparticles/updater-life'), require('@tsparticles/shape-line'), require('@tsparticles/updater-paint'), require('@tsparticles/updater-rotate'), require('@tsparticles/plugin-sounds')) :
5
5
  typeof define === 'function' && define.amd ? define(['exports', '@tsparticles/engine', '@tsparticles/basic', '@tsparticles/plugin-blend', '@tsparticles/updater-destroy', '@tsparticles/plugin-emitters/plugin', '@tsparticles/plugin-emitters-shape-square', '@tsparticles/updater-life', '@tsparticles/shape-line', '@tsparticles/updater-paint', '@tsparticles/updater-rotate', '@tsparticles/plugin-sounds'], factory) :
@@ -79,9 +79,6 @@
79
79
  if (engine.isNull(data)) {
80
80
  return;
81
81
  }
82
- if (data.background !== undefined) {
83
- this.background = data.background;
84
- }
85
82
  if (data.colors !== undefined) {
86
83
  if (engine.isArray(data.colors)) {
87
84
  this.colors = [...data.colors];
@@ -90,34 +87,22 @@
90
87
  this.colors = data.colors;
91
88
  }
92
89
  }
93
- if (data.brightness !== undefined) {
94
- this.brightness = engine.setRangeValue(data.brightness);
95
- }
96
- if (data.gravity !== undefined) {
97
- this.gravity = engine.setRangeValue(data.gravity);
98
- }
99
- if (data.minHeight !== undefined) {
100
- this.minHeight = engine.setRangeValue(data.minHeight);
101
- }
102
- if (data.rate !== undefined) {
103
- this.rate = engine.setRangeValue(data.rate);
104
- }
105
- if (data.saturation !== undefined) {
106
- this.saturation = engine.setRangeValue(data.saturation);
107
- }
108
- if (data.sounds !== undefined) {
109
- this.sounds = data.sounds;
110
- }
111
- if (data.speed !== undefined) {
112
- this.speed = engine.setRangeValue(data.speed);
113
- }
114
- if (data.splitCount !== undefined) {
115
- this.splitCount = engine.setRangeValue(data.splitCount);
116
- }
90
+ engine.loadProperty(this, "background", data.background);
91
+ engine.loadRangeProperty(this, "brightness", data.brightness);
92
+ engine.loadRangeProperty(this, "gravity", data.gravity);
93
+ engine.loadRangeProperty(this, "minHeight", data.minHeight);
94
+ engine.loadRangeProperty(this, "rate", data.rate);
95
+ engine.loadRangeProperty(this, "saturation", data.saturation);
96
+ engine.loadProperty(this, "sounds", data.sounds);
97
+ engine.loadRangeProperty(this, "speed", data.speed);
98
+ engine.loadRangeProperty(this, "splitCount", data.splitCount);
117
99
  }
118
100
  }
119
101
 
120
102
  const instances = new Map();
103
+ function deleteFireworksInstance(id) {
104
+ instances.delete(id);
105
+ }
121
106
  const explodeSoundCheck = (args) => {
122
107
  const data = args.data;
123
108
  return data?.particle?.options.move.gravity.enable ?? false;
@@ -293,7 +278,10 @@
293
278
  return existing;
294
279
  }
295
280
  if (existing) {
296
- return existing;
281
+ if (!existing.destroyed) {
282
+ return existing;
283
+ }
284
+ instances.delete(id);
297
285
  }
298
286
  const create = async () => {
299
287
  const options = new FireworkOptions();
@@ -303,7 +291,7 @@
303
291
  instances.delete(id);
304
292
  return;
305
293
  }
306
- const { FireworksInstance } = await Promise.resolve().then(function () { return FireworksInstance$1; }), instance = new FireworksInstance(container);
294
+ const { FireworksInstance } = await Promise.resolve().then(function () { return FireworksInstance$1; }), instance = new FireworksInstance(container, id);
307
295
  instances.set(id, instance);
308
296
  return instance;
309
297
  }, createPromise = create();
@@ -313,7 +301,7 @@
313
301
 
314
302
  let initPromise = null;
315
303
  async function doInitPlugins(engine) {
316
- engine.checkVersion("4.1.3");
304
+ engine.checkVersion("4.2.0");
317
305
  await engine.pluginManager.register(async (e) => {
318
306
  const loadEmittersForFireworks = async (e) => {
319
307
  await plugin.loadEmittersPluginSimple(e);
@@ -360,7 +348,7 @@
360
348
  fireworks.init = async () => {
361
349
  await initPlugins(engine.tsParticles);
362
350
  };
363
- fireworks.version = "4.1.3";
351
+ fireworks.version = "4.2.0";
364
352
  globalThis.fireworks = fireworks;
365
353
 
366
354
  const globalObject = globalThis;
@@ -369,8 +357,17 @@
369
357
 
370
358
  class FireworksInstance {
371
359
  #container;
372
- constructor(container) {
360
+ #id;
361
+ constructor(container, id) {
373
362
  this.#container = container;
363
+ this.#id = id;
364
+ }
365
+ get destroyed() {
366
+ return this.#container.destroyed;
367
+ }
368
+ destroy() {
369
+ this.#container.destroy();
370
+ deleteFireworksInstance(this.#id);
374
371
  }
375
372
  pause() {
376
373
  this.#container.pause();
@@ -1 +1 @@
1
- !function(t){t.__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.bundles=t.__tsParticlesInternals.bundles||{},t.__tsParticlesInternals.effects=t.__tsParticlesInternals.effects||{},t.__tsParticlesInternals.engine=t.__tsParticlesInternals.engine||{},t.__tsParticlesInternals.interactions=t.__tsParticlesInternals.interactions||{},t.__tsParticlesInternals.palettes=t.__tsParticlesInternals.palettes||{},t.__tsParticlesInternals.paths=t.__tsParticlesInternals.paths||{},t.__tsParticlesInternals.plugins=t.__tsParticlesInternals.plugins||{},t.__tsParticlesInternals.plugins=t.__tsParticlesInternals.plugins||{},t.__tsParticlesInternals.plugins.emittersShapes=t.__tsParticlesInternals.plugins.emittersShapes||{},t.__tsParticlesInternals.presets=t.__tsParticlesInternals.presets||{},t.__tsParticlesInternals.shapes=t.__tsParticlesInternals.shapes||{},t.__tsParticlesInternals.updaters=t.__tsParticlesInternals.updaters||{},t.__tsParticlesInternals.utils=t.__tsParticlesInternals.utils||{},t.__tsParticlesInternals.canvas=t.__tsParticlesInternals.canvas||{},t.__tsParticlesInternals.canvas=t.__tsParticlesInternals.canvas||{},t.__tsParticlesInternals.canvas.utils=t.__tsParticlesInternals.canvas.utils||{},t.__tsParticlesInternals.path=t.__tsParticlesInternals.path||{},t.__tsParticlesInternals.path=t.__tsParticlesInternals.path||{},t.__tsParticlesInternals.path.utils=t.__tsParticlesInternals.path.utils||{};var s="undefined"!=typeof Proxy?function(t){return new Proxy(t,{get:function(t,s){return s in t||(t[s]={}),t[s]}})}:function(t){return t};t.__tsParticlesInternals.bundles=s(t.__tsParticlesInternals.bundles),t.__tsParticlesInternals.effects=s(t.__tsParticlesInternals.effects),t.__tsParticlesInternals.interactions=s(t.__tsParticlesInternals.interactions),t.__tsParticlesInternals.palettes=s(t.__tsParticlesInternals.palettes),t.__tsParticlesInternals.paths=s(t.__tsParticlesInternals.paths),t.__tsParticlesInternals.plugins=s(t.__tsParticlesInternals.plugins),t.__tsParticlesInternals.plugins.emittersShapes=s(t.__tsParticlesInternals.plugins.emittersShapes),t.__tsParticlesInternals.presets=s(t.__tsParticlesInternals.presets),t.__tsParticlesInternals.shapes=s(t.__tsParticlesInternals.shapes),t.__tsParticlesInternals.updaters=s(t.__tsParticlesInternals.updaters),t.__tsParticlesInternals.utils=s(t.__tsParticlesInternals.utils),t.__tsParticlesInternals.canvas=s(t.__tsParticlesInternals.canvas),t.__tsParticlesInternals.path=s(t.__tsParticlesInternals.path),t.tsparticlesInternalExports=t.tsparticlesInternalExports||{}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:this),function(t,s){"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("@tsparticles/engine"),require("@tsparticles/basic"),require("@tsparticles/plugin-blend"),require("@tsparticles/updater-destroy"),require("@tsparticles/plugin-emitters/plugin"),require("@tsparticles/plugin-emitters-shape-square"),require("@tsparticles/updater-life"),require("@tsparticles/shape-line"),require("@tsparticles/updater-paint"),require("@tsparticles/updater-rotate"),require("@tsparticles/plugin-sounds")):"function"==typeof define&&define.amd?define(["exports","@tsparticles/engine","@tsparticles/basic","@tsparticles/plugin-blend","@tsparticles/updater-destroy","@tsparticles/plugin-emitters/plugin","@tsparticles/plugin-emitters-shape-square","@tsparticles/updater-life","@tsparticles/shape-line","@tsparticles/updater-paint","@tsparticles/updater-rotate","@tsparticles/plugin-sounds"],s):s(((t="undefined"!=typeof globalThis?globalThis:t||self).__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.bundles=t.__tsParticlesInternals.bundles||{},t.__tsParticlesInternals.bundles.fireworks=t.__tsParticlesInternals.bundles.fireworks||{}),t.__tsParticlesInternals.engine,t.__tsParticlesInternals.bundles.basic,t.__tsParticlesInternals.plugins.blend,t.__tsParticlesInternals.updaters.destroy,t.__tsParticlesInternals.plugins["emitters/plugin"],t.__tsParticlesInternals.plugins.emittersShapes.square,t.__tsParticlesInternals.updaters.life,t.__tsParticlesInternals.shapes.line,t.__tsParticlesInternals.updaters.paint,t.__tsParticlesInternals.updaters.rotate,t.__tsParticlesInternals.plugins.sounds)}(this,function(t,s,e,a,n,r,i,l,o,c,u,p){"use strict";class _{background;brightness;colors;gravity;minHeight;rate;saturation;sounds;speed;splitCount;constructor(){this.background="none",this.brightness={min:-30,max:30},this.colors=["#FF0000","#FF2A00","#FF5500","#FF8000","#FFAA00","#FFD400","#FFFF00","#D4FF00","#AAFF00","#80FF00","#55FF00","#2AFF00","#00FF00","#00FF2A","#00FF55","#00FF80","#00FFAA","#00FFD4","#00FFFF","#00D4FF","#00AAFF","#0080FF","#0055FF","#002AFF","#0000FF","#2A00FF","#5500FF","#8000FF","#AA00FF","#D400FF","#FF00FF","#FF00D4","#FF00AA","#FF0080","#FF0055","#FF002A"],this.gravity=30,this.minHeight={min:10,max:30},this.rate=10,this.saturation={min:-30,max:30},this.sounds=!0,this.speed={min:20,max:40},this.splitCount=100}load(t){s.isNull(t)||(void 0!==t.background&&(this.background=t.background),void 0!==t.colors&&(s.isArray(t.colors)?this.colors=[...t.colors]:this.colors=t.colors),void 0!==t.brightness&&(this.brightness=s.setRangeValue(t.brightness)),void 0!==t.gravity&&(this.gravity=s.setRangeValue(t.gravity)),void 0!==t.minHeight&&(this.minHeight=s.setRangeValue(t.minHeight)),void 0!==t.rate&&(this.rate=s.setRangeValue(t.rate)),void 0!==t.saturation&&(this.saturation=s.setRangeValue(t.saturation)),void 0!==t.sounds&&(this.sounds=t.sounds),void 0!==t.speed&&(this.speed=s.setRangeValue(t.speed)),void 0!==t.splitCount&&(this.splitCount=s.setRangeValue(t.splitCount)))}}const d=new Map,P=t=>{const s=t.data;return s?.particle?.options.move.gravity.enable??!1};function g(t,e){return{detectRetina:!0,background:{color:t.background},blend:{enable:!0,mode:"lighter"},fullScreen:{enable:!e},fpsLimit:60,emitters:{direction:s.MoveDirection.top,life:{count:0,duration:.1,delay:.1},rate:{delay:s.isNumber(t.rate)?1/t.rate:{min:1/s.getRangeMin(t.rate),max:1/s.getRangeMax(t.rate)},quantity:1},size:{width:100,height:0},position:{y:100,x:50}},particles:{number:{value:0},paint:{fill:{enable:!1},stroke:{color:{value:t.colors},width:2}},destroy:{mode:"split",bounds:{top:s.setRangeValue(t.minHeight)},split:{count:1,factor:{value:.333333},rate:{value:t.splitCount},strokeColorOffset:{s:t.saturation,l:t.brightness},particles:{group:"split",number:{value:0},opacity:{value:{min:.1,max:1},animation:{enable:!0,speed:{min:2,max:4},sync:!0,startValue:s.StartValueType.max,destroy:s.DestroyType.min,count:1}},size:{value:{min:5,max:10}},life:{count:1,duration:{value:{min:.5,max:1}}},move:{decay:.05,enable:!0,gravity:{enable:!1},speed:{min:10,max:25},direction:"outside",outModes:s.OutMode.destroy}}}},life:{count:1},shape:{type:"line",options:{line:{cap:"round"}}},size:{value:{min:10,max:20}},rotate:{path:!0},move:{enable:!0,gravity:{acceleration:s.setRangeValue(t.gravity),enable:!0,inverse:!0,maxSpeed:150},speed:s.setRangeValue(t.speed),outModes:{default:s.OutMode.destroy,top:s.OutMode.none}}},sounds:{enable:t.sounds,events:[{event:s.EventType.particleRemoved,filter:P,audio:["https://particles.js.org/audio/explosion0.mp3","https://particles.js.org/audio/explosion1.mp3","https://particles.js.org/audio/explosion2.mp3"]}],volume:50}}}async function I(t,s,e,a){const n=d.get(s);if(n instanceof Promise)return n;if(n)return n;const r=(async()=>{const n=new _;n.load(e);const r=g(n,a),i=await t.load({id:s,element:a,options:r});if(!i)return void d.delete(s);const{FireworksInstance:l}=await Promise.resolve().then(function(){return b}),o=new l(i);return d.set(s,o),o})();return d.set(s,r),r}let h=null;async function F(t){return h||(h=async function(t){t.checkVersion("4.1.3"),await t.pluginManager.register(async t=>{await Promise.all([e.loadBasic(t),o.loadLineShape(t),a.loadBlendPlugin(t),(async t=>{await r.loadEmittersPluginSimple(t),await i.loadEmittersShapeSquare(t)})(t),p.loadSoundsPlugin(t),u.loadRotateUpdater(t),n.loadDestroyUpdater(t),l.loadLifeUpdater(t),c.loadPaintUpdater(t)])})}(t),h)}async function f(t,e){let a,n;return await F(s.tsParticles),s.isString(t)?(a=t,n=e??{}):(a="fireworks",n=t??{}),I(s.tsParticles,a,n)}f.create=async(t,e)=>{await F(s.tsParticles);const a=t?.id??"fireworks";return I(s.tsParticles,a,e??{},t??void 0)},f.init=async()=>{await F(s.tsParticles)},f.version="4.1.3",globalThis.fireworks=f;const m=globalThis;m.__tsParticlesInternals=m.__tsParticlesInternals??{},m.fireworks=f;var b=Object.freeze({__proto__:null,FireworksInstance:class{#t;constructor(t){this.#t=t}pause(){this.#t.pause()}play(){this.#t.play()}stop(){this.#t.stop()}}});t.fireworks=f}),Object.assign(globalThis.window||globalThis,{fireworks:(globalThis.__tsParticlesInternals.bundles.fireworks||{}).fireworks}),delete(globalThis.window||globalThis).tsparticlesInternalExports;
1
+ !function(t){t.__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.bundles=t.__tsParticlesInternals.bundles||{},t.__tsParticlesInternals.effects=t.__tsParticlesInternals.effects||{},t.__tsParticlesInternals.engine=t.__tsParticlesInternals.engine||{},t.__tsParticlesInternals.interactions=t.__tsParticlesInternals.interactions||{},t.__tsParticlesInternals.palettes=t.__tsParticlesInternals.palettes||{},t.__tsParticlesInternals.paths=t.__tsParticlesInternals.paths||{},t.__tsParticlesInternals.plugins=t.__tsParticlesInternals.plugins||{},t.__tsParticlesInternals.plugins=t.__tsParticlesInternals.plugins||{},t.__tsParticlesInternals.plugins.emittersShapes=t.__tsParticlesInternals.plugins.emittersShapes||{},t.__tsParticlesInternals.presets=t.__tsParticlesInternals.presets||{},t.__tsParticlesInternals.shapes=t.__tsParticlesInternals.shapes||{},t.__tsParticlesInternals.updaters=t.__tsParticlesInternals.updaters||{},t.__tsParticlesInternals.utils=t.__tsParticlesInternals.utils||{},t.__tsParticlesInternals.canvas=t.__tsParticlesInternals.canvas||{},t.__tsParticlesInternals.canvas=t.__tsParticlesInternals.canvas||{},t.__tsParticlesInternals.canvas.utils=t.__tsParticlesInternals.canvas.utils||{},t.__tsParticlesInternals.path=t.__tsParticlesInternals.path||{},t.__tsParticlesInternals.path=t.__tsParticlesInternals.path||{},t.__tsParticlesInternals.path.utils=t.__tsParticlesInternals.path.utils||{};var e="undefined"!=typeof Proxy?function(t){return new Proxy(t,{get:function(t,e){return e in t||(t[e]={}),t[e]}})}:function(t){return t};t.__tsParticlesInternals.bundles=e(t.__tsParticlesInternals.bundles),t.__tsParticlesInternals.effects=e(t.__tsParticlesInternals.effects),t.__tsParticlesInternals.interactions=e(t.__tsParticlesInternals.interactions),t.__tsParticlesInternals.palettes=e(t.__tsParticlesInternals.palettes),t.__tsParticlesInternals.paths=e(t.__tsParticlesInternals.paths),t.__tsParticlesInternals.plugins=e(t.__tsParticlesInternals.plugins),t.__tsParticlesInternals.plugins.emittersShapes=e(t.__tsParticlesInternals.plugins.emittersShapes),t.__tsParticlesInternals.presets=e(t.__tsParticlesInternals.presets),t.__tsParticlesInternals.shapes=e(t.__tsParticlesInternals.shapes),t.__tsParticlesInternals.updaters=e(t.__tsParticlesInternals.updaters),t.__tsParticlesInternals.utils=e(t.__tsParticlesInternals.utils),t.__tsParticlesInternals.canvas=e(t.__tsParticlesInternals.canvas),t.__tsParticlesInternals.path=e(t.__tsParticlesInternals.path),t.tsparticlesInternalExports=t.tsparticlesInternalExports||{}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:this),function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@tsparticles/engine"),require("@tsparticles/basic"),require("@tsparticles/plugin-blend"),require("@tsparticles/updater-destroy"),require("@tsparticles/plugin-emitters/plugin"),require("@tsparticles/plugin-emitters-shape-square"),require("@tsparticles/updater-life"),require("@tsparticles/shape-line"),require("@tsparticles/updater-paint"),require("@tsparticles/updater-rotate"),require("@tsparticles/plugin-sounds")):"function"==typeof define&&define.amd?define(["exports","@tsparticles/engine","@tsparticles/basic","@tsparticles/plugin-blend","@tsparticles/updater-destroy","@tsparticles/plugin-emitters/plugin","@tsparticles/plugin-emitters-shape-square","@tsparticles/updater-life","@tsparticles/shape-line","@tsparticles/updater-paint","@tsparticles/updater-rotate","@tsparticles/plugin-sounds"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.bundles=t.__tsParticlesInternals.bundles||{},t.__tsParticlesInternals.bundles.fireworks=t.__tsParticlesInternals.bundles.fireworks||{}),t.__tsParticlesInternals.engine,t.__tsParticlesInternals.bundles.basic,t.__tsParticlesInternals.plugins.blend,t.__tsParticlesInternals.updaters.destroy,t.__tsParticlesInternals.plugins["emitters/plugin"],t.__tsParticlesInternals.plugins.emittersShapes.square,t.__tsParticlesInternals.updaters.life,t.__tsParticlesInternals.shapes.line,t.__tsParticlesInternals.updaters.paint,t.__tsParticlesInternals.updaters.rotate,t.__tsParticlesInternals.plugins.sounds)}(this,function(t,e,s,a,n,r,i,l,o,c,p,u){"use strict";class _{background;brightness;colors;gravity;minHeight;rate;saturation;sounds;speed;splitCount;constructor(){this.background="none",this.brightness={min:-30,max:30},this.colors=["#FF0000","#FF2A00","#FF5500","#FF8000","#FFAA00","#FFD400","#FFFF00","#D4FF00","#AAFF00","#80FF00","#55FF00","#2AFF00","#00FF00","#00FF2A","#00FF55","#00FF80","#00FFAA","#00FFD4","#00FFFF","#00D4FF","#00AAFF","#0080FF","#0055FF","#002AFF","#0000FF","#2A00FF","#5500FF","#8000FF","#AA00FF","#D400FF","#FF00FF","#FF00D4","#FF00AA","#FF0080","#FF0055","#FF002A"],this.gravity=30,this.minHeight={min:10,max:30},this.rate=10,this.saturation={min:-30,max:30},this.sounds=!0,this.speed={min:20,max:40},this.splitCount=100}load(t){e.isNull(t)||(void 0!==t.colors&&(e.isArray(t.colors)?this.colors=[...t.colors]:this.colors=t.colors),e.loadProperty(this,"background",t.background),e.loadRangeProperty(this,"brightness",t.brightness),e.loadRangeProperty(this,"gravity",t.gravity),e.loadRangeProperty(this,"minHeight",t.minHeight),e.loadRangeProperty(this,"rate",t.rate),e.loadRangeProperty(this,"saturation",t.saturation),e.loadProperty(this,"sounds",t.sounds),e.loadRangeProperty(this,"speed",t.speed),e.loadRangeProperty(this,"splitCount",t.splitCount))}}const d=new Map;const P=t=>{const e=t.data;return e?.particle?.options.move.gravity.enable??!1};function g(t,s){return{detectRetina:!0,background:{color:t.background},blend:{enable:!0,mode:"lighter"},fullScreen:{enable:!s},fpsLimit:60,emitters:{direction:e.MoveDirection.top,life:{count:0,duration:.1,delay:.1},rate:{delay:e.isNumber(t.rate)?1/t.rate:{min:1/e.getRangeMin(t.rate),max:1/e.getRangeMax(t.rate)},quantity:1},size:{width:100,height:0},position:{y:100,x:50}},particles:{number:{value:0},paint:{fill:{enable:!1},stroke:{color:{value:t.colors},width:2}},destroy:{mode:"split",bounds:{top:e.setRangeValue(t.minHeight)},split:{count:1,factor:{value:.333333},rate:{value:t.splitCount},strokeColorOffset:{s:t.saturation,l:t.brightness},particles:{group:"split",number:{value:0},opacity:{value:{min:.1,max:1},animation:{enable:!0,speed:{min:2,max:4},sync:!0,startValue:e.StartValueType.max,destroy:e.DestroyType.min,count:1}},size:{value:{min:5,max:10}},life:{count:1,duration:{value:{min:.5,max:1}}},move:{decay:.05,enable:!0,gravity:{enable:!1},speed:{min:10,max:25},direction:"outside",outModes:e.OutMode.destroy}}}},life:{count:1},shape:{type:"line",options:{line:{cap:"round"}}},size:{value:{min:10,max:20}},rotate:{path:!0},move:{enable:!0,gravity:{acceleration:e.setRangeValue(t.gravity),enable:!0,inverse:!0,maxSpeed:150},speed:e.setRangeValue(t.speed),outModes:{default:e.OutMode.destroy,top:e.OutMode.none}}},sounds:{enable:t.sounds,events:[{event:e.EventType.particleRemoved,filter:P,audio:["https://particles.js.org/audio/explosion0.mp3","https://particles.js.org/audio/explosion1.mp3","https://particles.js.org/audio/explosion2.mp3"]}],volume:50}}}async function h(t,e,s,a){const n=d.get(e);if(n instanceof Promise)return n;if(n){if(!n.destroyed)return n;d.delete(e)}const r=(async()=>{const n=new _;n.load(s);const r=g(n,a),i=await t.load({id:e,element:a,options:r});if(!i)return void d.delete(e);const{FireworksInstance:l}=await Promise.resolve().then(function(){return y}),o=new l(i,e);return d.set(e,o),o})();return d.set(e,r),r}let I=null;async function F(t){return I||(I=async function(t){t.checkVersion("4.2.0"),await t.pluginManager.register(async t=>{await Promise.all([s.loadBasic(t),o.loadLineShape(t),a.loadBlendPlugin(t),(async t=>{await r.loadEmittersPluginSimple(t),await i.loadEmittersShapeSquare(t)})(t),u.loadSoundsPlugin(t),p.loadRotateUpdater(t),n.loadDestroyUpdater(t),l.loadLifeUpdater(t),c.loadPaintUpdater(t)])})}(t),I)}async function f(t,s){let a,n;return await F(e.tsParticles),e.isString(t)?(a=t,n=s??{}):(a="fireworks",n=t??{}),h(e.tsParticles,a,n)}f.create=async(t,s)=>{await F(e.tsParticles);const a=t?.id??"fireworks";return h(e.tsParticles,a,s??{},t??void 0)},f.init=async()=>{await F(e.tsParticles)},f.version="4.2.0",globalThis.fireworks=f;const m=globalThis;m.__tsParticlesInternals=m.__tsParticlesInternals??{},m.fireworks=f;var y=Object.freeze({__proto__:null,FireworksInstance:class{#t;#e;constructor(t,e){this.#t=t,this.#e=e}get destroyed(){return this.#t.destroyed}destroy(){var t;this.#t.destroy(),t=this.#e,d.delete(t)}pause(){this.#t.pause()}play(){this.#t.play()}stop(){this.#t.stop()}}});t.fireworks=f}),Object.assign(globalThis.window||globalThis,{fireworks:(globalThis.__tsParticlesInternals.bundles.fireworks||{}).fireworks}),delete(globalThis.window||globalThis).tsparticlesInternalExports;
@@ -1,7 +1,9 @@
1
1
  import type { Container } from "@tsparticles/engine";
2
2
  export declare class FireworksInstance {
3
3
  #private;
4
- constructor(container: Container);
4
+ constructor(container: Container, id: string);
5
+ get destroyed(): boolean;
6
+ destroy(): void;
5
7
  pause(): void;
6
8
  play(): void;
7
9
  stop(): void;
package/types/utils.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { type CustomEventArgs, type Engine, type ISourceOptions, type RecursivePartial } from "@tsparticles/engine";
2
2
  import type { FireworksInstance } from "./FireworksInstance.js";
3
3
  import type { IFireworkOptions } from "./IFireworkOptions.js";
4
+ export declare function deleteFireworksInstance(id: string): void;
4
5
  export declare const explodeSoundCheck: (args: CustomEventArgs) => boolean;
5
6
  export declare function getOptions(options: IFireworkOptions, canvas?: HTMLCanvasElement): ISourceOptions;
6
7
  export declare function getFireworksInstance(engine: Engine, id: string, sourceOptions: RecursivePartial<IFireworkOptions>, canvas?: HTMLCanvasElement): Promise<FireworksInstance | undefined>;