@tsparticles/fireworks 4.1.2 → 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,4 +1,4 @@
1
- import { isArray, isNull, setRangeValue, } from "@tsparticles/engine";
1
+ import { isArray, isNull, loadProperty, loadRangeProperty, } from "@tsparticles/engine";
2
2
  export class FireworkOptions {
3
3
  background;
4
4
  brightness;
@@ -72,9 +72,6 @@ export class FireworkOptions {
72
72
  if (isNull(data)) {
73
73
  return;
74
74
  }
75
- if (data.background !== undefined) {
76
- this.background = data.background;
77
- }
78
75
  if (data.colors !== undefined) {
79
76
  if (isArray(data.colors)) {
80
77
  this.colors = [...data.colors];
@@ -83,29 +80,14 @@ export class FireworkOptions {
83
80
  this.colors = data.colors;
84
81
  }
85
82
  }
86
- if (data.brightness !== undefined) {
87
- this.brightness = setRangeValue(data.brightness);
88
- }
89
- if (data.gravity !== undefined) {
90
- this.gravity = setRangeValue(data.gravity);
91
- }
92
- if (data.minHeight !== undefined) {
93
- this.minHeight = setRangeValue(data.minHeight);
94
- }
95
- if (data.rate !== undefined) {
96
- this.rate = setRangeValue(data.rate);
97
- }
98
- if (data.saturation !== undefined) {
99
- this.saturation = setRangeValue(data.saturation);
100
- }
101
- if (data.sounds !== undefined) {
102
- this.sounds = data.sounds;
103
- }
104
- if (data.speed !== undefined) {
105
- this.speed = setRangeValue(data.speed);
106
- }
107
- if (data.splitCount !== undefined) {
108
- this.splitCount = setRangeValue(data.splitCount);
109
- }
83
+ loadProperty(this, "background", data.background);
84
+ loadRangeProperty(this, "brightness", data.brightness);
85
+ loadRangeProperty(this, "gravity", data.gravity);
86
+ loadRangeProperty(this, "minHeight", data.minHeight);
87
+ loadRangeProperty(this, "rate", data.rate);
88
+ loadRangeProperty(this, "saturation", data.saturation);
89
+ loadProperty(this, "sounds", data.sounds);
90
+ loadRangeProperty(this, "speed", data.speed);
91
+ loadRangeProperty(this, "splitCount", data.splitCount);
110
92
  }
111
93
  }
@@ -1,7 +1,17 @@
1
+ import { deleteFireworksInstance } from "./utils.js";
1
2
  export class FireworksInstance {
2
3
  #container;
3
- constructor(container) {
4
+ #id;
5
+ constructor(container, id) {
4
6
  this.#container = container;
7
+ this.#id = id;
8
+ }
9
+ get destroyed() {
10
+ return this.#container.destroyed;
11
+ }
12
+ destroy() {
13
+ this.#container.destroy();
14
+ deleteFireworksInstance(this.#id);
5
15
  }
6
16
  pause() {
7
17
  this.#container.pause();
@@ -12,7 +12,7 @@ import { loadRotateUpdater } from "@tsparticles/updater-rotate";
12
12
  import { loadSoundsPlugin } from "@tsparticles/plugin-sounds";
13
13
  let initPromise = null;
14
14
  async function doInitPlugins(engine) {
15
- engine.checkVersion("4.1.2");
15
+ engine.checkVersion("4.2.0");
16
16
  await engine.pluginManager.register(async (e) => {
17
17
  const loadEmittersForFireworks = async (e) => {
18
18
  await loadEmittersPluginSimple(e);
@@ -59,5 +59,5 @@ fireworks.create = async (canvas, options) => {
59
59
  fireworks.init = async () => {
60
60
  await initPlugins(tsParticles);
61
61
  };
62
- fireworks.version = "4.1.2";
62
+ fireworks.version = "4.2.0";
63
63
  globalThis.fireworks = fireworks;
@@ -2,7 +2,7 @@ import { isString, tsParticles } from "@tsparticles/engine/lazy";
2
2
  import { getFireworksInstance } from "./utils.js";
3
3
  let initPromise = null;
4
4
  async function doInitPlugins(engine) {
5
- engine.checkVersion("4.1.2");
5
+ engine.checkVersion("4.2.0");
6
6
  await engine.pluginManager.register(async (e) => {
7
7
  const [{ loadBasic }, { loadLineShape }, { loadBlendPlugin }, { loadEmittersPluginSimple }, { loadEmittersShapeSquare }, { loadSoundsPlugin }, { loadRotateUpdater }, { loadDestroyUpdater }, { loadLifeUpdater }, { loadPaintUpdater },] = await Promise.all([
8
8
  import("@tsparticles/basic/lazy"),
@@ -60,5 +60,5 @@ fireworks.create = async (canvas, options) => {
60
60
  fireworks.init = async () => {
61
61
  await initPlugins(tsParticles);
62
62
  };
63
- fireworks.version = "4.1.2";
63
+ fireworks.version = "4.2.0";
64
64
  globalThis.fireworks = fireworks;
package/browser/utils.js CHANGED
@@ -1,6 +1,9 @@
1
1
  import { DestroyType, EventType, MoveDirection, OutMode, StartValueType, getRangeMax, getRangeMin, isNumber, setRangeValue, } from "@tsparticles/engine";
2
2
  import { FireworkOptions } from "./FireworkOptions.js";
3
3
  const instances = new Map();
4
+ export function deleteFireworksInstance(id) {
5
+ instances.delete(id);
6
+ }
4
7
  export const explodeSoundCheck = (args) => {
5
8
  const data = args.data;
6
9
  return data?.particle?.options.move.gravity.enable ?? false;
@@ -176,7 +179,10 @@ export async function getFireworksInstance(engine, id, sourceOptions, canvas) {
176
179
  return existing;
177
180
  }
178
181
  if (existing) {
179
- return existing;
182
+ if (!existing.destroyed) {
183
+ return existing;
184
+ }
185
+ instances.delete(id);
180
186
  }
181
187
  const create = async () => {
182
188
  const options = new FireworkOptions();
@@ -186,7 +192,7 @@ export async function getFireworksInstance(engine, id, sourceOptions, canvas) {
186
192
  instances.delete(id);
187
193
  return;
188
194
  }
189
- const { FireworksInstance } = await import("./FireworksInstance.js"), instance = new FireworksInstance(container);
195
+ const { FireworksInstance } = await import("./FireworksInstance.js"), instance = new FireworksInstance(container, id);
190
196
  instances.set(id, instance);
191
197
  return instance;
192
198
  }, createPromise = create();
@@ -1,4 +1,4 @@
1
- import { isArray, isNull, setRangeValue, } from "@tsparticles/engine";
1
+ import { isArray, isNull, loadProperty, loadRangeProperty, } from "@tsparticles/engine";
2
2
  export class FireworkOptions {
3
3
  background;
4
4
  brightness;
@@ -72,9 +72,6 @@ export class FireworkOptions {
72
72
  if (isNull(data)) {
73
73
  return;
74
74
  }
75
- if (data.background !== undefined) {
76
- this.background = data.background;
77
- }
78
75
  if (data.colors !== undefined) {
79
76
  if (isArray(data.colors)) {
80
77
  this.colors = [...data.colors];
@@ -83,29 +80,14 @@ export class FireworkOptions {
83
80
  this.colors = data.colors;
84
81
  }
85
82
  }
86
- if (data.brightness !== undefined) {
87
- this.brightness = setRangeValue(data.brightness);
88
- }
89
- if (data.gravity !== undefined) {
90
- this.gravity = setRangeValue(data.gravity);
91
- }
92
- if (data.minHeight !== undefined) {
93
- this.minHeight = setRangeValue(data.minHeight);
94
- }
95
- if (data.rate !== undefined) {
96
- this.rate = setRangeValue(data.rate);
97
- }
98
- if (data.saturation !== undefined) {
99
- this.saturation = setRangeValue(data.saturation);
100
- }
101
- if (data.sounds !== undefined) {
102
- this.sounds = data.sounds;
103
- }
104
- if (data.speed !== undefined) {
105
- this.speed = setRangeValue(data.speed);
106
- }
107
- if (data.splitCount !== undefined) {
108
- this.splitCount = setRangeValue(data.splitCount);
109
- }
83
+ loadProperty(this, "background", data.background);
84
+ loadRangeProperty(this, "brightness", data.brightness);
85
+ loadRangeProperty(this, "gravity", data.gravity);
86
+ loadRangeProperty(this, "minHeight", data.minHeight);
87
+ loadRangeProperty(this, "rate", data.rate);
88
+ loadRangeProperty(this, "saturation", data.saturation);
89
+ loadProperty(this, "sounds", data.sounds);
90
+ loadRangeProperty(this, "speed", data.speed);
91
+ loadRangeProperty(this, "splitCount", data.splitCount);
110
92
  }
111
93
  }
@@ -1,7 +1,17 @@
1
+ import { deleteFireworksInstance } from "./utils.js";
1
2
  export class FireworksInstance {
2
3
  #container;
3
- constructor(container) {
4
+ #id;
5
+ constructor(container, id) {
4
6
  this.#container = container;
7
+ this.#id = id;
8
+ }
9
+ get destroyed() {
10
+ return this.#container.destroyed;
11
+ }
12
+ destroy() {
13
+ this.#container.destroy();
14
+ deleteFireworksInstance(this.#id);
5
15
  }
6
16
  pause() {
7
17
  this.#container.pause();
package/cjs/fireworks.js CHANGED
@@ -12,7 +12,7 @@ import { loadRotateUpdater } from "@tsparticles/updater-rotate";
12
12
  import { loadSoundsPlugin } from "@tsparticles/plugin-sounds";
13
13
  let initPromise = null;
14
14
  async function doInitPlugins(engine) {
15
- engine.checkVersion("4.1.2");
15
+ engine.checkVersion("4.2.0");
16
16
  await engine.pluginManager.register(async (e) => {
17
17
  const loadEmittersForFireworks = async (e) => {
18
18
  await loadEmittersPluginSimple(e);
@@ -59,5 +59,5 @@ fireworks.create = async (canvas, options) => {
59
59
  fireworks.init = async () => {
60
60
  await initPlugins(tsParticles);
61
61
  };
62
- fireworks.version = "4.1.2";
62
+ fireworks.version = "4.2.0";
63
63
  globalThis.fireworks = fireworks;
@@ -2,7 +2,7 @@ import { isString, tsParticles } from "@tsparticles/engine/lazy";
2
2
  import { getFireworksInstance } from "./utils.js";
3
3
  let initPromise = null;
4
4
  async function doInitPlugins(engine) {
5
- engine.checkVersion("4.1.2");
5
+ engine.checkVersion("4.2.0");
6
6
  await engine.pluginManager.register(async (e) => {
7
7
  const [{ loadBasic }, { loadLineShape }, { loadBlendPlugin }, { loadEmittersPluginSimple }, { loadEmittersShapeSquare }, { loadSoundsPlugin }, { loadRotateUpdater }, { loadDestroyUpdater }, { loadLifeUpdater }, { loadPaintUpdater },] = await Promise.all([
8
8
  import("@tsparticles/basic/lazy"),
@@ -60,5 +60,5 @@ fireworks.create = async (canvas, options) => {
60
60
  fireworks.init = async () => {
61
61
  await initPlugins(tsParticles);
62
62
  };
63
- fireworks.version = "4.1.2";
63
+ fireworks.version = "4.2.0";
64
64
  globalThis.fireworks = fireworks;
package/cjs/utils.js CHANGED
@@ -1,6 +1,9 @@
1
1
  import { DestroyType, EventType, MoveDirection, OutMode, StartValueType, getRangeMax, getRangeMin, isNumber, setRangeValue, } from "@tsparticles/engine";
2
2
  import { FireworkOptions } from "./FireworkOptions.js";
3
3
  const instances = new Map();
4
+ export function deleteFireworksInstance(id) {
5
+ instances.delete(id);
6
+ }
4
7
  export const explodeSoundCheck = (args) => {
5
8
  const data = args.data;
6
9
  return data?.particle?.options.move.gravity.enable ?? false;
@@ -176,7 +179,10 @@ export async function getFireworksInstance(engine, id, sourceOptions, canvas) {
176
179
  return existing;
177
180
  }
178
181
  if (existing) {
179
- return existing;
182
+ if (!existing.destroyed) {
183
+ return existing;
184
+ }
185
+ instances.delete(id);
180
186
  }
181
187
  const create = async () => {
182
188
  const options = new FireworkOptions();
@@ -186,7 +192,7 @@ export async function getFireworksInstance(engine, id, sourceOptions, canvas) {
186
192
  instances.delete(id);
187
193
  return;
188
194
  }
189
- const { FireworksInstance } = await import("./FireworksInstance.js"), instance = new FireworksInstance(container);
195
+ const { FireworksInstance } = await import("./FireworksInstance.js"), instance = new FireworksInstance(container, id);
190
196
  instances.set(id, instance);
191
197
  return instance;
192
198
  }, createPromise = create();
@@ -1,4 +1,4 @@
1
- import { isArray, isNull, setRangeValue, } from "@tsparticles/engine";
1
+ import { isArray, isNull, loadProperty, loadRangeProperty, } from "@tsparticles/engine";
2
2
  export class FireworkOptions {
3
3
  background;
4
4
  brightness;
@@ -72,9 +72,6 @@ export class FireworkOptions {
72
72
  if (isNull(data)) {
73
73
  return;
74
74
  }
75
- if (data.background !== undefined) {
76
- this.background = data.background;
77
- }
78
75
  if (data.colors !== undefined) {
79
76
  if (isArray(data.colors)) {
80
77
  this.colors = [...data.colors];
@@ -83,29 +80,14 @@ export class FireworkOptions {
83
80
  this.colors = data.colors;
84
81
  }
85
82
  }
86
- if (data.brightness !== undefined) {
87
- this.brightness = setRangeValue(data.brightness);
88
- }
89
- if (data.gravity !== undefined) {
90
- this.gravity = setRangeValue(data.gravity);
91
- }
92
- if (data.minHeight !== undefined) {
93
- this.minHeight = setRangeValue(data.minHeight);
94
- }
95
- if (data.rate !== undefined) {
96
- this.rate = setRangeValue(data.rate);
97
- }
98
- if (data.saturation !== undefined) {
99
- this.saturation = setRangeValue(data.saturation);
100
- }
101
- if (data.sounds !== undefined) {
102
- this.sounds = data.sounds;
103
- }
104
- if (data.speed !== undefined) {
105
- this.speed = setRangeValue(data.speed);
106
- }
107
- if (data.splitCount !== undefined) {
108
- this.splitCount = setRangeValue(data.splitCount);
109
- }
83
+ loadProperty(this, "background", data.background);
84
+ loadRangeProperty(this, "brightness", data.brightness);
85
+ loadRangeProperty(this, "gravity", data.gravity);
86
+ loadRangeProperty(this, "minHeight", data.minHeight);
87
+ loadRangeProperty(this, "rate", data.rate);
88
+ loadRangeProperty(this, "saturation", data.saturation);
89
+ loadProperty(this, "sounds", data.sounds);
90
+ loadRangeProperty(this, "speed", data.speed);
91
+ loadRangeProperty(this, "splitCount", data.splitCount);
110
92
  }
111
93
  }
@@ -1,7 +1,17 @@
1
+ import { deleteFireworksInstance } from "./utils.js";
1
2
  export class FireworksInstance {
2
3
  #container;
3
- constructor(container) {
4
+ #id;
5
+ constructor(container, id) {
4
6
  this.#container = container;
7
+ this.#id = id;
8
+ }
9
+ get destroyed() {
10
+ return this.#container.destroyed;
11
+ }
12
+ destroy() {
13
+ this.#container.destroy();
14
+ deleteFireworksInstance(this.#id);
5
15
  }
6
16
  pause() {
7
17
  this.#container.pause();
package/esm/fireworks.js CHANGED
@@ -12,7 +12,7 @@ import { loadRotateUpdater } from "@tsparticles/updater-rotate";
12
12
  import { loadSoundsPlugin } from "@tsparticles/plugin-sounds";
13
13
  let initPromise = null;
14
14
  async function doInitPlugins(engine) {
15
- engine.checkVersion("4.1.2");
15
+ engine.checkVersion("4.2.0");
16
16
  await engine.pluginManager.register(async (e) => {
17
17
  const loadEmittersForFireworks = async (e) => {
18
18
  await loadEmittersPluginSimple(e);
@@ -59,5 +59,5 @@ fireworks.create = async (canvas, options) => {
59
59
  fireworks.init = async () => {
60
60
  await initPlugins(tsParticles);
61
61
  };
62
- fireworks.version = "4.1.2";
62
+ fireworks.version = "4.2.0";
63
63
  globalThis.fireworks = fireworks;
@@ -2,7 +2,7 @@ import { isString, tsParticles } from "@tsparticles/engine/lazy";
2
2
  import { getFireworksInstance } from "./utils.js";
3
3
  let initPromise = null;
4
4
  async function doInitPlugins(engine) {
5
- engine.checkVersion("4.1.2");
5
+ engine.checkVersion("4.2.0");
6
6
  await engine.pluginManager.register(async (e) => {
7
7
  const [{ loadBasic }, { loadLineShape }, { loadBlendPlugin }, { loadEmittersPluginSimple }, { loadEmittersShapeSquare }, { loadSoundsPlugin }, { loadRotateUpdater }, { loadDestroyUpdater }, { loadLifeUpdater }, { loadPaintUpdater },] = await Promise.all([
8
8
  import("@tsparticles/basic/lazy"),
@@ -60,5 +60,5 @@ fireworks.create = async (canvas, options) => {
60
60
  fireworks.init = async () => {
61
61
  await initPlugins(tsParticles);
62
62
  };
63
- fireworks.version = "4.1.2";
63
+ fireworks.version = "4.2.0";
64
64
  globalThis.fireworks = fireworks;
package/esm/utils.js CHANGED
@@ -1,6 +1,9 @@
1
1
  import { DestroyType, EventType, MoveDirection, OutMode, StartValueType, getRangeMax, getRangeMin, isNumber, setRangeValue, } from "@tsparticles/engine";
2
2
  import { FireworkOptions } from "./FireworkOptions.js";
3
3
  const instances = new Map();
4
+ export function deleteFireworksInstance(id) {
5
+ instances.delete(id);
6
+ }
4
7
  export const explodeSoundCheck = (args) => {
5
8
  const data = args.data;
6
9
  return data?.particle?.options.move.gravity.enable ?? false;
@@ -176,7 +179,10 @@ export async function getFireworksInstance(engine, id, sourceOptions, canvas) {
176
179
  return existing;
177
180
  }
178
181
  if (existing) {
179
- return existing;
182
+ if (!existing.destroyed) {
183
+ return existing;
184
+ }
185
+ instances.delete(id);
180
186
  }
181
187
  const create = async () => {
182
188
  const options = new FireworkOptions();
@@ -186,7 +192,7 @@ export async function getFireworksInstance(engine, id, sourceOptions, canvas) {
186
192
  instances.delete(id);
187
193
  return;
188
194
  }
189
- const { FireworksInstance } = await import("./FireworksInstance.js"), instance = new FireworksInstance(container);
195
+ const { FireworksInstance } = await import("./FireworksInstance.js"), instance = new FireworksInstance(container, id);
190
196
  instances.set(id, instance);
191
197
  return instance;
192
198
  }, createPromise = create();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tsparticles/fireworks",
3
- "version": "4.1.2",
4
- "description": "Easily create highly customizable particle animations and use them as animated backgrounds for your website. Ready to use components available also for React, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Riot.js, Inferno.",
3
+ "version": "4.2.0",
4
+ "description": "tsParticles fireworks bundle easily create spectacular fireworks and fountain particle effects with built-in presets. Ready to use components available for React, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Riot.js, Inferno.",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
7
7
  "type": "git",
@@ -105,17 +105,17 @@
105
105
  "./package.json": "./package.json"
106
106
  },
107
107
  "dependencies": {
108
- "@tsparticles/basic": "4.1.2",
109
- "@tsparticles/engine": "4.1.2",
110
- "@tsparticles/plugin-blend": "4.1.2",
111
- "@tsparticles/plugin-emitters": "4.1.2",
112
- "@tsparticles/plugin-emitters-shape-square": "4.1.2",
113
- "@tsparticles/plugin-sounds": "4.1.2",
114
- "@tsparticles/shape-line": "4.1.2",
115
- "@tsparticles/updater-destroy": "4.1.2",
116
- "@tsparticles/updater-life": "4.1.2",
117
- "@tsparticles/updater-paint": "4.1.2",
118
- "@tsparticles/updater-rotate": "4.1.2"
108
+ "@tsparticles/basic": "4.2.0",
109
+ "@tsparticles/engine": "4.2.0",
110
+ "@tsparticles/plugin-blend": "4.2.0",
111
+ "@tsparticles/plugin-emitters": "4.2.0",
112
+ "@tsparticles/plugin-emitters-shape-square": "4.2.0",
113
+ "@tsparticles/plugin-sounds": "4.2.0",
114
+ "@tsparticles/shape-line": "4.2.0",
115
+ "@tsparticles/updater-destroy": "4.2.0",
116
+ "@tsparticles/updater-life": "4.2.0",
117
+ "@tsparticles/updater-paint": "4.2.0",
118
+ "@tsparticles/updater-rotate": "4.2.0"
119
119
  },
120
120
  "publishConfig": {
121
121
  "access": "public"