@tsparticles/particles 4.0.0-beta.12

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 (51) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +112 -0
  3. package/browser/IParticlesOptions.js +1 -0
  4. package/browser/ParticlesInstance.js +15 -0
  5. package/browser/browser.js +5 -0
  6. package/browser/bundle.js +6 -0
  7. package/browser/index.js +1 -0
  8. package/browser/index.lazy.js +1 -0
  9. package/browser/package.json +1 -0
  10. package/browser/particles.js +53 -0
  11. package/browser/particles.lazy.js +54 -0
  12. package/browser/types.js +1 -0
  13. package/browser/utils.js +55 -0
  14. package/cjs/IParticlesOptions.js +1 -0
  15. package/cjs/ParticlesInstance.js +15 -0
  16. package/cjs/browser.js +5 -0
  17. package/cjs/bundle.js +6 -0
  18. package/cjs/index.js +1 -0
  19. package/cjs/index.lazy.js +1 -0
  20. package/cjs/package.json +1 -0
  21. package/cjs/particles.js +53 -0
  22. package/cjs/particles.lazy.js +54 -0
  23. package/cjs/types.js +1 -0
  24. package/cjs/utils.js +55 -0
  25. package/esm/IParticlesOptions.js +1 -0
  26. package/esm/ParticlesInstance.js +15 -0
  27. package/esm/browser.js +5 -0
  28. package/esm/bundle.js +6 -0
  29. package/esm/index.js +1 -0
  30. package/esm/index.lazy.js +1 -0
  31. package/esm/package.json +1 -0
  32. package/esm/particles.js +53 -0
  33. package/esm/particles.lazy.js +54 -0
  34. package/esm/types.js +1 -0
  35. package/esm/utils.js +55 -0
  36. package/package.json +53 -0
  37. package/report.html +4950 -0
  38. package/tsparticles.particles.bundle.js +7819 -0
  39. package/tsparticles.particles.bundle.min.js +1 -0
  40. package/tsparticles.particles.js +145 -0
  41. package/tsparticles.particles.min.js +1 -0
  42. package/types/IParticlesOptions.d.ts +13 -0
  43. package/types/ParticlesInstance.d.ts +8 -0
  44. package/types/browser.d.ts +1 -0
  45. package/types/bundle.d.ts +3 -0
  46. package/types/index.d.ts +4 -0
  47. package/types/index.lazy.d.ts +4 -0
  48. package/types/particles.d.ts +17 -0
  49. package/types/particles.lazy.d.ts +17 -0
  50. package/types/types.d.ts +6 -0
  51. package/types/utils.d.ts +4 -0
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Matteo Bruni
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
package/README.md ADDED
@@ -0,0 +1,112 @@
1
+ [![banner](https://particles.js.org/images/banner2.png)](https://particles.js.org)
2
+
3
+ # tsParticles Particles Bundle
4
+
5
+ [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/@tsparticles/particles/badge)](https://www.jsdelivr.com/package/npm/@tsparticles/particles) [![npmjs](https://badge.fury.io/js/@tsparticles/particles.svg)](https://www.npmjs.com/package/@tsparticles/particles) [![npmjs](https://img.shields.io/npm/dt/@tsparticles/particles)](https://www.npmjs.com/package/@tsparticles/particles) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni)
6
+
7
+ tsParticles `particles` bundle to create simple particle effects with a focused API.
8
+
9
+ **Included Packages**
10
+
11
+ - [@tsparticles/basic (and all its dependencies)](https://github.com/tsparticles/tsparticles/tree/main/bundles/basic)
12
+ - [@tsparticles/engine](https://github.com/tsparticles/tsparticles/tree/main/engine)
13
+ - [@tsparticles/plugin-interactivity](https://github.com/tsparticles/tsparticles/tree/main/plugins/interactivity)
14
+ - [@tsparticles/interaction-particles-collisions](https://github.com/tsparticles/tsparticles/tree/main/interactions/particles/collisions)
15
+ - [@tsparticles/interaction-particles-links](https://github.com/tsparticles/tsparticles/tree/main/interactions/particles/links)
16
+
17
+ ## Exposed API
18
+
19
+ The package API is centered on `particles`.
20
+
21
+ ```ts
22
+ import { particles } from "@tsparticles/particles";
23
+
24
+ // Main API
25
+ const instance = await particles();
26
+ const byId = await particles("canvas-id", options);
27
+ const byOptions = await particles(options);
28
+
29
+ // Extra helpers
30
+ await particles.init();
31
+ const custom = await particles.create(canvas, options);
32
+
33
+ console.log(particles.version);
34
+ ```
35
+
36
+ `@tsparticles/particles` does not expose `tsParticles` from its main entrypoint.
37
+ If you need direct engine APIs, import them from `@tsparticles/engine`.
38
+
39
+ ## Installation
40
+
41
+ ```bash
42
+ pnpm add @tsparticles/particles
43
+ ```
44
+
45
+ Lazy entrypoint (loads dependencies on demand):
46
+
47
+ ```ts
48
+ import { particles } from "@tsparticles/particles/lazy";
49
+ ```
50
+
51
+ ## How to use it
52
+
53
+ ```ts
54
+ import { particles } from "@tsparticles/particles";
55
+
56
+ const instance = await particles({
57
+ count: 120,
58
+ color: "#00f",
59
+ links: true,
60
+ linksColor: "#0ff",
61
+ linksLength: 140,
62
+ radius: 4,
63
+ shape: ["circle", "square"],
64
+ });
65
+
66
+ instance?.pause();
67
+ instance?.play();
68
+ instance?.stop();
69
+ ```
70
+
71
+ ### Custom canvas via `particles.create`
72
+
73
+ ```ts
74
+ import { particles } from "@tsparticles/particles";
75
+
76
+ const canvas = document.getElementById("my-canvas") as HTMLCanvasElement;
77
+ await particles.create(canvas, { links: true });
78
+ ```
79
+
80
+ ### Options
81
+
82
+ Main options (shallow overview):
83
+
84
+ - `count` Number: particles amount (default: 80)
85
+ - `radius` Number or RangeValue: particle radius (default: 3)
86
+ - `links` Boolean: enable links between particles
87
+ - `linksLength` Number: maximum link distance
88
+ - `speed` Number or RangeValue: particle movement speed
89
+ - `collisions` Boolean: enable particle collisions
90
+ - `opacity` Number: particle opacity
91
+ - `shape` String or Array<String>: particle shape type(s)
92
+ - `color` String: particle color
93
+ - `linksColor` String: link color
94
+
95
+ ### Returned instance methods
96
+
97
+ The resolved `ParticlesInstance` exposes:
98
+
99
+ - `pause()`
100
+ - `play()`
101
+ - `stop()`
102
+
103
+ ## Common pitfalls
104
+
105
+ - Calling `particles` before scripts are loaded in CDN usage
106
+ - Assuming `tsParticles` is exported by `@tsparticles/particles` main entrypoint
107
+ - Reusing the same `id` unintentionally (the package caches instances by id)
108
+
109
+ ## Related docs
110
+
111
+ - All packages catalog: <https://github.com/tsparticles/tsparticles>
112
+ - Main docs: <https://particles.js.org/docs/>
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ export class ParticlesInstance {
2
+ _container;
3
+ constructor(container) {
4
+ this._container = container;
5
+ }
6
+ pause() {
7
+ this._container.pause();
8
+ }
9
+ play() {
10
+ this._container.play();
11
+ }
12
+ stop() {
13
+ this._container.stop();
14
+ }
15
+ }
@@ -0,0 +1,5 @@
1
+ import { particles } from "./index.js";
2
+ const globalObject = globalThis;
3
+ globalObject.__tsParticlesInternals = globalObject.__tsParticlesInternals ?? {};
4
+ globalObject.particles = particles;
5
+ export * from "./index.js";
@@ -0,0 +1,6 @@
1
+ import { particles } from "./index.js";
2
+ export { particles } from "./index.js";
3
+ export * from "@tsparticles/engine";
4
+ const globalObject = globalThis;
5
+ globalObject.__tsParticlesInternals = globalObject.__tsParticlesInternals ?? {};
6
+ globalObject.particles = particles;
@@ -0,0 +1 @@
1
+ export * from "./particles.js";
@@ -0,0 +1 @@
1
+ export * from "./particles.lazy.js";
@@ -0,0 +1 @@
1
+ { "type": "module" }
@@ -0,0 +1,53 @@
1
+ import { isString, tsParticles } from "@tsparticles/engine";
2
+ import { getParticlesInstance } from "./utils.js";
3
+ import { loadBasic } from "@tsparticles/basic";
4
+ import { loadInteractivityPlugin } from "@tsparticles/plugin-interactivity";
5
+ import { loadParticlesCollisionsInteraction } from "@tsparticles/interaction-particles-collisions";
6
+ import { loadParticlesLinksInteraction } from "@tsparticles/interaction-particles-links";
7
+ let initPromise = null;
8
+ async function doInitPlugins(engine) {
9
+ engine.checkVersion("4.0.0-beta.12");
10
+ await engine.pluginManager.register(async (e) => {
11
+ const loadParticlesInteractivity = async (e) => {
12
+ await loadInteractivityPlugin(e);
13
+ await Promise.all([
14
+ loadParticlesCollisionsInteraction(e),
15
+ loadParticlesLinksInteraction(e),
16
+ ]);
17
+ };
18
+ await Promise.all([
19
+ loadBasic(e),
20
+ loadParticlesInteractivity(e),
21
+ ]);
22
+ });
23
+ }
24
+ async function initPlugins(engine) {
25
+ if (initPromise) {
26
+ return initPromise;
27
+ }
28
+ initPromise = doInitPlugins(engine);
29
+ return initPromise;
30
+ }
31
+ export async function particles(idOrOptions, sourceOptions) {
32
+ await initPlugins(tsParticles);
33
+ let id, options;
34
+ if (isString(idOrOptions)) {
35
+ id = idOrOptions;
36
+ options = sourceOptions ?? {};
37
+ }
38
+ else {
39
+ id = "particles";
40
+ options = idOrOptions ?? {};
41
+ }
42
+ return getParticlesInstance(tsParticles, id, options);
43
+ }
44
+ particles.create = async (canvas, options) => {
45
+ await initPlugins(tsParticles);
46
+ const id = canvas.id || "particles";
47
+ return getParticlesInstance(tsParticles, id, options ?? {}, canvas);
48
+ };
49
+ particles.init = async () => {
50
+ await initPlugins(tsParticles);
51
+ };
52
+ particles.version = "4.0.0-beta.12";
53
+ globalThis.particles = particles;
@@ -0,0 +1,54 @@
1
+ import { isString, tsParticles } from "@tsparticles/engine/lazy";
2
+ import { getParticlesInstance } from "./utils.js";
3
+ let initPromise = null;
4
+ async function doInitPlugins(engine) {
5
+ engine.checkVersion("4.0.0-beta.12");
6
+ await engine.pluginManager.register(async (e) => {
7
+ const [{ loadBasic }, { loadInteractivityPlugin }, { loadParticlesCollisionsInteraction }, { loadParticlesLinksInteraction },] = await Promise.all([
8
+ import("@tsparticles/basic/lazy"),
9
+ import("@tsparticles/plugin-interactivity/lazy"),
10
+ import("@tsparticles/interaction-particles-collisions/lazy"),
11
+ import("@tsparticles/interaction-particles-links/lazy"),
12
+ ]), loadParticlesInteractivity = async (e) => {
13
+ await loadInteractivityPlugin(e);
14
+ await Promise.all([
15
+ loadParticlesCollisionsInteraction(e),
16
+ loadParticlesLinksInteraction(e),
17
+ ]);
18
+ };
19
+ await Promise.all([
20
+ loadBasic(e),
21
+ loadParticlesInteractivity(e),
22
+ ]);
23
+ });
24
+ }
25
+ async function initPlugins(engine) {
26
+ if (initPromise) {
27
+ return initPromise;
28
+ }
29
+ initPromise = doInitPlugins(engine);
30
+ return initPromise;
31
+ }
32
+ export async function particles(idOrOptions, sourceOptions) {
33
+ await initPlugins(tsParticles);
34
+ let id, options;
35
+ if (isString(idOrOptions)) {
36
+ id = idOrOptions;
37
+ options = sourceOptions ?? {};
38
+ }
39
+ else {
40
+ id = "particles";
41
+ options = idOrOptions ?? {};
42
+ }
43
+ return getParticlesInstance(tsParticles, id, options);
44
+ }
45
+ particles.create = async (canvas, options) => {
46
+ await initPlugins(tsParticles);
47
+ const id = canvas.id || "particles";
48
+ return getParticlesInstance(tsParticles, id, options ?? {}, canvas);
49
+ };
50
+ particles.init = async () => {
51
+ await initPlugins(tsParticles);
52
+ };
53
+ particles.version = "4.0.0-beta.12";
54
+ globalThis.particles = particles;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,55 @@
1
+ const instances = new Map(), defaultCount = 80, defaultLinksWidth = 100, defaultSpeed = 3, defaultOpacity = 1, defaultRadius = 3;
2
+ function getDefaultOptions(options) {
3
+ return {
4
+ particles: {
5
+ number: {
6
+ value: options.count ?? defaultCount,
7
+ },
8
+ color: {
9
+ value: options.color ?? "#fff",
10
+ },
11
+ links: {
12
+ enable: options.links ?? false,
13
+ color: options.linksColor ?? "#fff",
14
+ distance: options.linksLength ?? defaultLinksWidth,
15
+ },
16
+ collisions: {
17
+ enable: options.collisions ?? false,
18
+ },
19
+ move: {
20
+ enable: true,
21
+ speed: options.speed ?? defaultSpeed,
22
+ },
23
+ opacity: {
24
+ value: options.opacity ?? defaultOpacity,
25
+ },
26
+ shape: {
27
+ type: options.shape ?? "circle",
28
+ },
29
+ size: {
30
+ value: options.radius ?? defaultRadius,
31
+ },
32
+ },
33
+ };
34
+ }
35
+ export async function getParticlesInstance(engine, id, sourceOptions, canvas) {
36
+ const existing = instances.get(id);
37
+ if (existing instanceof Promise) {
38
+ return existing;
39
+ }
40
+ if (existing) {
41
+ return existing;
42
+ }
43
+ const create = async () => {
44
+ const particlesOptions = getDefaultOptions(sourceOptions), container = await engine.load({ id, element: canvas, options: particlesOptions });
45
+ if (!container) {
46
+ instances.delete(id);
47
+ return;
48
+ }
49
+ const { ParticlesInstance } = await import("./ParticlesInstance.js"), instance = new ParticlesInstance(container);
50
+ instances.set(id, instance);
51
+ return instance;
52
+ }, createPromise = create();
53
+ instances.set(id, createPromise);
54
+ return createPromise;
55
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ export class ParticlesInstance {
2
+ _container;
3
+ constructor(container) {
4
+ this._container = container;
5
+ }
6
+ pause() {
7
+ this._container.pause();
8
+ }
9
+ play() {
10
+ this._container.play();
11
+ }
12
+ stop() {
13
+ this._container.stop();
14
+ }
15
+ }
package/cjs/browser.js ADDED
@@ -0,0 +1,5 @@
1
+ import { particles } from "./index.js";
2
+ const globalObject = globalThis;
3
+ globalObject.__tsParticlesInternals = globalObject.__tsParticlesInternals ?? {};
4
+ globalObject.particles = particles;
5
+ export * from "./index.js";
package/cjs/bundle.js ADDED
@@ -0,0 +1,6 @@
1
+ import { particles } from "./index.js";
2
+ export { particles } from "./index.js";
3
+ export * from "@tsparticles/engine";
4
+ const globalObject = globalThis;
5
+ globalObject.__tsParticlesInternals = globalObject.__tsParticlesInternals ?? {};
6
+ globalObject.particles = particles;
package/cjs/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from "./particles.js";
@@ -0,0 +1 @@
1
+ export * from "./particles.lazy.js";
@@ -0,0 +1 @@
1
+ { "type": "commonjs" }
@@ -0,0 +1,53 @@
1
+ import { isString, tsParticles } from "@tsparticles/engine";
2
+ import { getParticlesInstance } from "./utils.js";
3
+ import { loadBasic } from "@tsparticles/basic";
4
+ import { loadInteractivityPlugin } from "@tsparticles/plugin-interactivity";
5
+ import { loadParticlesCollisionsInteraction } from "@tsparticles/interaction-particles-collisions";
6
+ import { loadParticlesLinksInteraction } from "@tsparticles/interaction-particles-links";
7
+ let initPromise = null;
8
+ async function doInitPlugins(engine) {
9
+ engine.checkVersion("4.0.0-beta.12");
10
+ await engine.pluginManager.register(async (e) => {
11
+ const loadParticlesInteractivity = async (e) => {
12
+ await loadInteractivityPlugin(e);
13
+ await Promise.all([
14
+ loadParticlesCollisionsInteraction(e),
15
+ loadParticlesLinksInteraction(e),
16
+ ]);
17
+ };
18
+ await Promise.all([
19
+ loadBasic(e),
20
+ loadParticlesInteractivity(e),
21
+ ]);
22
+ });
23
+ }
24
+ async function initPlugins(engine) {
25
+ if (initPromise) {
26
+ return initPromise;
27
+ }
28
+ initPromise = doInitPlugins(engine);
29
+ return initPromise;
30
+ }
31
+ export async function particles(idOrOptions, sourceOptions) {
32
+ await initPlugins(tsParticles);
33
+ let id, options;
34
+ if (isString(idOrOptions)) {
35
+ id = idOrOptions;
36
+ options = sourceOptions ?? {};
37
+ }
38
+ else {
39
+ id = "particles";
40
+ options = idOrOptions ?? {};
41
+ }
42
+ return getParticlesInstance(tsParticles, id, options);
43
+ }
44
+ particles.create = async (canvas, options) => {
45
+ await initPlugins(tsParticles);
46
+ const id = canvas.id || "particles";
47
+ return getParticlesInstance(tsParticles, id, options ?? {}, canvas);
48
+ };
49
+ particles.init = async () => {
50
+ await initPlugins(tsParticles);
51
+ };
52
+ particles.version = "4.0.0-beta.12";
53
+ globalThis.particles = particles;
@@ -0,0 +1,54 @@
1
+ import { isString, tsParticles } from "@tsparticles/engine/lazy";
2
+ import { getParticlesInstance } from "./utils.js";
3
+ let initPromise = null;
4
+ async function doInitPlugins(engine) {
5
+ engine.checkVersion("4.0.0-beta.12");
6
+ await engine.pluginManager.register(async (e) => {
7
+ const [{ loadBasic }, { loadInteractivityPlugin }, { loadParticlesCollisionsInteraction }, { loadParticlesLinksInteraction },] = await Promise.all([
8
+ import("@tsparticles/basic/lazy"),
9
+ import("@tsparticles/plugin-interactivity/lazy"),
10
+ import("@tsparticles/interaction-particles-collisions/lazy"),
11
+ import("@tsparticles/interaction-particles-links/lazy"),
12
+ ]), loadParticlesInteractivity = async (e) => {
13
+ await loadInteractivityPlugin(e);
14
+ await Promise.all([
15
+ loadParticlesCollisionsInteraction(e),
16
+ loadParticlesLinksInteraction(e),
17
+ ]);
18
+ };
19
+ await Promise.all([
20
+ loadBasic(e),
21
+ loadParticlesInteractivity(e),
22
+ ]);
23
+ });
24
+ }
25
+ async function initPlugins(engine) {
26
+ if (initPromise) {
27
+ return initPromise;
28
+ }
29
+ initPromise = doInitPlugins(engine);
30
+ return initPromise;
31
+ }
32
+ export async function particles(idOrOptions, sourceOptions) {
33
+ await initPlugins(tsParticles);
34
+ let id, options;
35
+ if (isString(idOrOptions)) {
36
+ id = idOrOptions;
37
+ options = sourceOptions ?? {};
38
+ }
39
+ else {
40
+ id = "particles";
41
+ options = idOrOptions ?? {};
42
+ }
43
+ return getParticlesInstance(tsParticles, id, options);
44
+ }
45
+ particles.create = async (canvas, options) => {
46
+ await initPlugins(tsParticles);
47
+ const id = canvas.id || "particles";
48
+ return getParticlesInstance(tsParticles, id, options ?? {}, canvas);
49
+ };
50
+ particles.init = async () => {
51
+ await initPlugins(tsParticles);
52
+ };
53
+ particles.version = "4.0.0-beta.12";
54
+ globalThis.particles = particles;
package/cjs/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/cjs/utils.js ADDED
@@ -0,0 +1,55 @@
1
+ const instances = new Map(), defaultCount = 80, defaultLinksWidth = 100, defaultSpeed = 3, defaultOpacity = 1, defaultRadius = 3;
2
+ function getDefaultOptions(options) {
3
+ return {
4
+ particles: {
5
+ number: {
6
+ value: options.count ?? defaultCount,
7
+ },
8
+ color: {
9
+ value: options.color ?? "#fff",
10
+ },
11
+ links: {
12
+ enable: options.links ?? false,
13
+ color: options.linksColor ?? "#fff",
14
+ distance: options.linksLength ?? defaultLinksWidth,
15
+ },
16
+ collisions: {
17
+ enable: options.collisions ?? false,
18
+ },
19
+ move: {
20
+ enable: true,
21
+ speed: options.speed ?? defaultSpeed,
22
+ },
23
+ opacity: {
24
+ value: options.opacity ?? defaultOpacity,
25
+ },
26
+ shape: {
27
+ type: options.shape ?? "circle",
28
+ },
29
+ size: {
30
+ value: options.radius ?? defaultRadius,
31
+ },
32
+ },
33
+ };
34
+ }
35
+ export async function getParticlesInstance(engine, id, sourceOptions, canvas) {
36
+ const existing = instances.get(id);
37
+ if (existing instanceof Promise) {
38
+ return existing;
39
+ }
40
+ if (existing) {
41
+ return existing;
42
+ }
43
+ const create = async () => {
44
+ const particlesOptions = getDefaultOptions(sourceOptions), container = await engine.load({ id, element: canvas, options: particlesOptions });
45
+ if (!container) {
46
+ instances.delete(id);
47
+ return;
48
+ }
49
+ const { ParticlesInstance } = await import("./ParticlesInstance.js"), instance = new ParticlesInstance(container);
50
+ instances.set(id, instance);
51
+ return instance;
52
+ }, createPromise = create();
53
+ instances.set(id, createPromise);
54
+ return createPromise;
55
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ export class ParticlesInstance {
2
+ _container;
3
+ constructor(container) {
4
+ this._container = container;
5
+ }
6
+ pause() {
7
+ this._container.pause();
8
+ }
9
+ play() {
10
+ this._container.play();
11
+ }
12
+ stop() {
13
+ this._container.stop();
14
+ }
15
+ }
package/esm/browser.js ADDED
@@ -0,0 +1,5 @@
1
+ import { particles } from "./index.js";
2
+ const globalObject = globalThis;
3
+ globalObject.__tsParticlesInternals = globalObject.__tsParticlesInternals ?? {};
4
+ globalObject.particles = particles;
5
+ export * from "./index.js";
package/esm/bundle.js ADDED
@@ -0,0 +1,6 @@
1
+ import { particles } from "./index.js";
2
+ export { particles } from "./index.js";
3
+ export * from "@tsparticles/engine";
4
+ const globalObject = globalThis;
5
+ globalObject.__tsParticlesInternals = globalObject.__tsParticlesInternals ?? {};
6
+ globalObject.particles = particles;
package/esm/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from "./particles.js";
@@ -0,0 +1 @@
1
+ export * from "./particles.lazy.js";
@@ -0,0 +1 @@
1
+ { "type": "module" }
@@ -0,0 +1,53 @@
1
+ import { isString, tsParticles } from "@tsparticles/engine";
2
+ import { getParticlesInstance } from "./utils.js";
3
+ import { loadBasic } from "@tsparticles/basic";
4
+ import { loadInteractivityPlugin } from "@tsparticles/plugin-interactivity";
5
+ import { loadParticlesCollisionsInteraction } from "@tsparticles/interaction-particles-collisions";
6
+ import { loadParticlesLinksInteraction } from "@tsparticles/interaction-particles-links";
7
+ let initPromise = null;
8
+ async function doInitPlugins(engine) {
9
+ engine.checkVersion("4.0.0-beta.12");
10
+ await engine.pluginManager.register(async (e) => {
11
+ const loadParticlesInteractivity = async (e) => {
12
+ await loadInteractivityPlugin(e);
13
+ await Promise.all([
14
+ loadParticlesCollisionsInteraction(e),
15
+ loadParticlesLinksInteraction(e),
16
+ ]);
17
+ };
18
+ await Promise.all([
19
+ loadBasic(e),
20
+ loadParticlesInteractivity(e),
21
+ ]);
22
+ });
23
+ }
24
+ async function initPlugins(engine) {
25
+ if (initPromise) {
26
+ return initPromise;
27
+ }
28
+ initPromise = doInitPlugins(engine);
29
+ return initPromise;
30
+ }
31
+ export async function particles(idOrOptions, sourceOptions) {
32
+ await initPlugins(tsParticles);
33
+ let id, options;
34
+ if (isString(idOrOptions)) {
35
+ id = idOrOptions;
36
+ options = sourceOptions ?? {};
37
+ }
38
+ else {
39
+ id = "particles";
40
+ options = idOrOptions ?? {};
41
+ }
42
+ return getParticlesInstance(tsParticles, id, options);
43
+ }
44
+ particles.create = async (canvas, options) => {
45
+ await initPlugins(tsParticles);
46
+ const id = canvas.id || "particles";
47
+ return getParticlesInstance(tsParticles, id, options ?? {}, canvas);
48
+ };
49
+ particles.init = async () => {
50
+ await initPlugins(tsParticles);
51
+ };
52
+ particles.version = "4.0.0-beta.12";
53
+ globalThis.particles = particles;