@tsparticles/particles 4.1.3 → 4.2.1

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,7 +1,17 @@
1
+ import { deleteParticlesInstance } from "./utils.js";
1
2
  export class ParticlesInstance {
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
+ deleteParticlesInstance(this.#id);
5
15
  }
6
16
  pause() {
7
17
  this.#container.pause();
@@ -6,7 +6,7 @@ import { loadParticlesCollisionsInteraction } from "@tsparticles/interaction-par
6
6
  import { loadParticlesLinksInteraction } from "@tsparticles/interaction-particles-links";
7
7
  let initPromise = null;
8
8
  async function doInitPlugins(engine) {
9
- engine.checkVersion("4.1.3");
9
+ engine.checkVersion("4.2.1");
10
10
  await engine.pluginManager.register(async (e) => {
11
11
  const loadParticlesInteractivity = async (e) => {
12
12
  await loadInteractivityPlugin(e);
@@ -49,5 +49,5 @@ particles.create = async (canvas, options) => {
49
49
  particles.init = async () => {
50
50
  await initPlugins(tsParticles);
51
51
  };
52
- particles.version = "4.1.3";
52
+ particles.version = "4.2.1";
53
53
  globalThis.particles = particles;
@@ -2,7 +2,7 @@ import { isString, tsParticles } from "@tsparticles/engine/lazy";
2
2
  import { getParticlesInstance } from "./utils.js";
3
3
  let initPromise = null;
4
4
  async function doInitPlugins(engine) {
5
- engine.checkVersion("4.1.3");
5
+ engine.checkVersion("4.2.1");
6
6
  await engine.pluginManager.register(async (e) => {
7
7
  const [{ loadBasic }, { loadInteractivityPlugin }, { loadParticlesCollisionsInteraction }, { loadParticlesLinksInteraction },] = await Promise.all([
8
8
  import("@tsparticles/basic/lazy"),
@@ -50,5 +50,5 @@ particles.create = async (canvas, options) => {
50
50
  particles.init = async () => {
51
51
  await initPlugins(tsParticles);
52
52
  };
53
- particles.version = "4.1.3";
53
+ particles.version = "4.2.1";
54
54
  globalThis.particles = particles;
package/browser/utils.js CHANGED
@@ -1,4 +1,8 @@
1
- const instances = new Map(), defaultCount = 80, defaultLinksWidth = 100, defaultSpeed = 3, defaultOpacity = 1, defaultRadius = 3;
1
+ const instances = new Map();
2
+ export function deleteParticlesInstance(id) {
3
+ instances.delete(id);
4
+ }
5
+ const defaultCount = 80, defaultLinksWidth = 100, defaultSpeed = 3, defaultOpacity = 1, defaultRadius = 3;
2
6
  function getDefaultOptions(options, canvas) {
3
7
  return {
4
8
  fullScreen: {
@@ -41,7 +45,10 @@ export async function getParticlesInstance(engine, id, sourceOptions, canvas) {
41
45
  return existing;
42
46
  }
43
47
  if (existing) {
44
- return existing;
48
+ if (!existing.destroyed) {
49
+ return existing;
50
+ }
51
+ instances.delete(id);
45
52
  }
46
53
  const create = async () => {
47
54
  const particlesOptions = getDefaultOptions(sourceOptions, canvas), container = await engine.load({ id, element: canvas, options: particlesOptions });
@@ -49,7 +56,7 @@ export async function getParticlesInstance(engine, id, sourceOptions, canvas) {
49
56
  instances.delete(id);
50
57
  return;
51
58
  }
52
- const { ParticlesInstance } = await import("./ParticlesInstance.js"), instance = new ParticlesInstance(container);
59
+ const { ParticlesInstance } = await import("./ParticlesInstance.js"), instance = new ParticlesInstance(container, id);
53
60
  instances.set(id, instance);
54
61
  return instance;
55
62
  }, createPromise = create();
@@ -1,7 +1,17 @@
1
+ import { deleteParticlesInstance } from "./utils.js";
1
2
  export class ParticlesInstance {
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
+ deleteParticlesInstance(this.#id);
5
15
  }
6
16
  pause() {
7
17
  this.#container.pause();
package/cjs/particles.js CHANGED
@@ -6,7 +6,7 @@ import { loadParticlesCollisionsInteraction } from "@tsparticles/interaction-par
6
6
  import { loadParticlesLinksInteraction } from "@tsparticles/interaction-particles-links";
7
7
  let initPromise = null;
8
8
  async function doInitPlugins(engine) {
9
- engine.checkVersion("4.1.3");
9
+ engine.checkVersion("4.2.1");
10
10
  await engine.pluginManager.register(async (e) => {
11
11
  const loadParticlesInteractivity = async (e) => {
12
12
  await loadInteractivityPlugin(e);
@@ -49,5 +49,5 @@ particles.create = async (canvas, options) => {
49
49
  particles.init = async () => {
50
50
  await initPlugins(tsParticles);
51
51
  };
52
- particles.version = "4.1.3";
52
+ particles.version = "4.2.1";
53
53
  globalThis.particles = particles;
@@ -2,7 +2,7 @@ import { isString, tsParticles } from "@tsparticles/engine/lazy";
2
2
  import { getParticlesInstance } from "./utils.js";
3
3
  let initPromise = null;
4
4
  async function doInitPlugins(engine) {
5
- engine.checkVersion("4.1.3");
5
+ engine.checkVersion("4.2.1");
6
6
  await engine.pluginManager.register(async (e) => {
7
7
  const [{ loadBasic }, { loadInteractivityPlugin }, { loadParticlesCollisionsInteraction }, { loadParticlesLinksInteraction },] = await Promise.all([
8
8
  import("@tsparticles/basic/lazy"),
@@ -50,5 +50,5 @@ particles.create = async (canvas, options) => {
50
50
  particles.init = async () => {
51
51
  await initPlugins(tsParticles);
52
52
  };
53
- particles.version = "4.1.3";
53
+ particles.version = "4.2.1";
54
54
  globalThis.particles = particles;
package/cjs/utils.js CHANGED
@@ -1,4 +1,8 @@
1
- const instances = new Map(), defaultCount = 80, defaultLinksWidth = 100, defaultSpeed = 3, defaultOpacity = 1, defaultRadius = 3;
1
+ const instances = new Map();
2
+ export function deleteParticlesInstance(id) {
3
+ instances.delete(id);
4
+ }
5
+ const defaultCount = 80, defaultLinksWidth = 100, defaultSpeed = 3, defaultOpacity = 1, defaultRadius = 3;
2
6
  function getDefaultOptions(options, canvas) {
3
7
  return {
4
8
  fullScreen: {
@@ -41,7 +45,10 @@ export async function getParticlesInstance(engine, id, sourceOptions, canvas) {
41
45
  return existing;
42
46
  }
43
47
  if (existing) {
44
- return existing;
48
+ if (!existing.destroyed) {
49
+ return existing;
50
+ }
51
+ instances.delete(id);
45
52
  }
46
53
  const create = async () => {
47
54
  const particlesOptions = getDefaultOptions(sourceOptions, canvas), container = await engine.load({ id, element: canvas, options: particlesOptions });
@@ -49,7 +56,7 @@ export async function getParticlesInstance(engine, id, sourceOptions, canvas) {
49
56
  instances.delete(id);
50
57
  return;
51
58
  }
52
- const { ParticlesInstance } = await import("./ParticlesInstance.js"), instance = new ParticlesInstance(container);
59
+ const { ParticlesInstance } = await import("./ParticlesInstance.js"), instance = new ParticlesInstance(container, id);
53
60
  instances.set(id, instance);
54
61
  return instance;
55
62
  }, createPromise = create();
@@ -1,7 +1,17 @@
1
+ import { deleteParticlesInstance } from "./utils.js";
1
2
  export class ParticlesInstance {
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
+ deleteParticlesInstance(this.#id);
5
15
  }
6
16
  pause() {
7
17
  this.#container.pause();
package/esm/particles.js CHANGED
@@ -6,7 +6,7 @@ import { loadParticlesCollisionsInteraction } from "@tsparticles/interaction-par
6
6
  import { loadParticlesLinksInteraction } from "@tsparticles/interaction-particles-links";
7
7
  let initPromise = null;
8
8
  async function doInitPlugins(engine) {
9
- engine.checkVersion("4.1.3");
9
+ engine.checkVersion("4.2.1");
10
10
  await engine.pluginManager.register(async (e) => {
11
11
  const loadParticlesInteractivity = async (e) => {
12
12
  await loadInteractivityPlugin(e);
@@ -49,5 +49,5 @@ particles.create = async (canvas, options) => {
49
49
  particles.init = async () => {
50
50
  await initPlugins(tsParticles);
51
51
  };
52
- particles.version = "4.1.3";
52
+ particles.version = "4.2.1";
53
53
  globalThis.particles = particles;
@@ -2,7 +2,7 @@ import { isString, tsParticles } from "@tsparticles/engine/lazy";
2
2
  import { getParticlesInstance } from "./utils.js";
3
3
  let initPromise = null;
4
4
  async function doInitPlugins(engine) {
5
- engine.checkVersion("4.1.3");
5
+ engine.checkVersion("4.2.1");
6
6
  await engine.pluginManager.register(async (e) => {
7
7
  const [{ loadBasic }, { loadInteractivityPlugin }, { loadParticlesCollisionsInteraction }, { loadParticlesLinksInteraction },] = await Promise.all([
8
8
  import("@tsparticles/basic/lazy"),
@@ -50,5 +50,5 @@ particles.create = async (canvas, options) => {
50
50
  particles.init = async () => {
51
51
  await initPlugins(tsParticles);
52
52
  };
53
- particles.version = "4.1.3";
53
+ particles.version = "4.2.1";
54
54
  globalThis.particles = particles;
package/esm/utils.js CHANGED
@@ -1,4 +1,8 @@
1
- const instances = new Map(), defaultCount = 80, defaultLinksWidth = 100, defaultSpeed = 3, defaultOpacity = 1, defaultRadius = 3;
1
+ const instances = new Map();
2
+ export function deleteParticlesInstance(id) {
3
+ instances.delete(id);
4
+ }
5
+ const defaultCount = 80, defaultLinksWidth = 100, defaultSpeed = 3, defaultOpacity = 1, defaultRadius = 3;
2
6
  function getDefaultOptions(options, canvas) {
3
7
  return {
4
8
  fullScreen: {
@@ -41,7 +45,10 @@ export async function getParticlesInstance(engine, id, sourceOptions, canvas) {
41
45
  return existing;
42
46
  }
43
47
  if (existing) {
44
- return existing;
48
+ if (!existing.destroyed) {
49
+ return existing;
50
+ }
51
+ instances.delete(id);
45
52
  }
46
53
  const create = async () => {
47
54
  const particlesOptions = getDefaultOptions(sourceOptions, canvas), container = await engine.load({ id, element: canvas, options: particlesOptions });
@@ -49,7 +56,7 @@ export async function getParticlesInstance(engine, id, sourceOptions, canvas) {
49
56
  instances.delete(id);
50
57
  return;
51
58
  }
52
- const { ParticlesInstance } = await import("./ParticlesInstance.js"), instance = new ParticlesInstance(container);
59
+ const { ParticlesInstance } = await import("./ParticlesInstance.js"), instance = new ParticlesInstance(container, id);
53
60
  instances.set(id, instance);
54
61
  return instance;
55
62
  }, createPromise = create();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tsparticles/particles",
3
- "version": "4.1.3",
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.1",
4
+ "description": "Minimal tsParticles particles bundle — lightweight particle engine without confetti or fireworks extras. Perfect for pure particle backgrounds. 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",
@@ -9,8 +9,49 @@
9
9
  "directory": "bundles/particles"
10
10
  },
11
11
  "keywords": [
12
- "particles",
12
+ "front-end",
13
+ "frontend",
13
14
  "tsparticles",
15
+ "particles.js",
16
+ "particlesjs",
17
+ "particles",
18
+ "particle",
19
+ "canvas",
20
+ "jsparticles",
21
+ "xparticles",
22
+ "particles-js",
23
+ "particles-bg",
24
+ "particles-bg-vue",
25
+ "particles-ts",
26
+ "particles.ts",
27
+ "react-particles-js",
28
+ "react-particles.js",
29
+ "react-particles",
30
+ "react",
31
+ "reactjs",
32
+ "vue-particles",
33
+ "ngx-particles",
34
+ "angular-particles",
35
+ "particleground",
36
+ "vue",
37
+ "vuejs",
38
+ "preact",
39
+ "preactjs",
40
+ "jquery",
41
+ "angularjs",
42
+ "angular",
43
+ "typescript",
44
+ "javascript",
45
+ "animation",
46
+ "web",
47
+ "html5",
48
+ "web-design",
49
+ "webdesign",
50
+ "css",
51
+ "html",
52
+ "css3",
53
+ "animated",
54
+ "background",
14
55
  "canvas"
15
56
  ],
16
57
  "author": "Matteo Bruni <matteo.bruni@me.com>",
@@ -40,11 +81,11 @@
40
81
  "./package.json": "./package.json"
41
82
  },
42
83
  "dependencies": {
43
- "@tsparticles/basic": "4.1.3",
44
- "@tsparticles/engine": "4.1.3",
45
- "@tsparticles/interaction-particles-collisions": "4.1.3",
46
- "@tsparticles/interaction-particles-links": "4.1.3",
47
- "@tsparticles/plugin-interactivity": "4.1.3"
84
+ "@tsparticles/basic": "4.2.1",
85
+ "@tsparticles/engine": "4.2.1",
86
+ "@tsparticles/interaction-particles-collisions": "4.2.1",
87
+ "@tsparticles/interaction-particles-links": "4.2.1",
88
+ "@tsparticles/plugin-interactivity": "4.2.1"
48
89
  },
49
90
  "publishConfig": {
50
91
  "access": "public"