@tsparticles/react 4.1.1 → 4.1.3

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 (2) hide show
  1. package/Particles.js +27 -25
  2. package/package.json +2 -2
package/Particles.js CHANGED
@@ -1,37 +1,39 @@
1
1
  import { useParticlesProvider as e } from "./ParticlesProvider.js";
2
- import { useEffect as t } from "react";
3
- import { tsParticles as n } from "@tsparticles/engine";
4
- import { jsx as r } from "react/jsx-runtime";
2
+ import { useEffect as t, useRef as n } from "react";
3
+ import { tsParticles as r } from "@tsparticles/engine";
4
+ import { jsx as i } from "react/jsx-runtime";
5
5
  //#region lib/Particles.tsx
6
- var i = (i) => {
7
- let { className: a, id: o, options: s, particlesLoaded: c, style: l, url: u } = i, { loaded: d } = e();
6
+ var a = (a) => {
7
+ let { className: o, id: s, options: c, particlesLoaded: l, style: u, url: d } = a, { loaded: f } = e(), p = n(void 0);
8
8
  return t(() => {
9
- if (!d) return;
10
- let e, t = !1;
11
- return n.load({
12
- id: o ?? "tsparticles",
13
- url: u,
14
- options: s
15
- }).then((n) => {
16
- if (t) {
17
- n?.destroy();
18
- return;
9
+ if (!f) return;
10
+ let e = s ?? "tsparticles";
11
+ return r.load({
12
+ id: e,
13
+ url: d,
14
+ options: c
15
+ }).then((t) => {
16
+ if (!t?.destroyed) {
17
+ if (!document.getElementById(e)) {
18
+ t?.destroy();
19
+ return;
20
+ }
21
+ p.current = t, l?.(t);
19
22
  }
20
- e = n, c?.(n);
21
23
  }), () => {
22
- t = !0, e?.destroy();
24
+ p.current?.destroy(), p.current = void 0;
23
25
  };
24
26
  }, [
25
- o,
26
- d,
27
27
  s,
28
+ f,
28
29
  c,
29
- u
30
- ]), /* @__PURE__ */ r("div", {
31
- id: o ?? "tsparticles",
32
- className: a,
33
- style: l
30
+ l,
31
+ d
32
+ ]), /* @__PURE__ */ i("div", {
33
+ id: s ?? "tsparticles",
34
+ className: o,
35
+ style: u
34
36
  });
35
37
  };
36
38
  //#endregion
37
- export { i as default };
39
+ export { a as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/react",
3
- "version": "4.1.1",
3
+ "version": "4.1.3",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "license": "MIT",
19
19
  "peerDependencies": {
20
- "@tsparticles/engine": "4.1.1",
20
+ "@tsparticles/engine": "4.1.3",
21
21
  "react": ">=16.8.0",
22
22
  "react-dom": ">=16.8.0"
23
23
  },