tsparticles 1.39.3 → 1.40.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.
- package/Core/Container.d.ts +3 -1
- package/Core/Container.js +27 -12
- package/Core/Loader.d.ts +12 -9
- package/Core/Loader.js +35 -19
- package/Core/Particle.d.ts +3 -1
- package/Core/Particle.js +17 -2
- package/Core/Particles.d.ts +3 -1
- package/Core/Particles.js +20 -5
- package/Core/Utils/InteractionManager.d.ts +3 -1
- package/Core/Utils/InteractionManager.js +17 -3
- package/Core/Utils/Plugins.d.ts +29 -15
- package/Core/Utils/Plugins.js +58 -46
- package/Options/Classes/Options.d.ts +2 -1
- package/Options/Classes/Options.js +13 -6
- package/Plugins/Emitters/EmitterInstance.d.ts +6 -3
- package/Plugins/Emitters/EmitterInstance.js +46 -16
- package/Plugins/Emitters/Emitters.d.ts +3 -1
- package/Plugins/Emitters/Emitters.js +17 -2
- package/Plugins/Emitters/{EmittersMain.d.ts → EmittersEngine.d.ts} +3 -1
- package/Plugins/Emitters/{EmittersMain.js → EmittersEngine.js} +0 -0
- package/Plugins/Emitters/IEmitterShape.d.ts +2 -2
- package/Plugins/Emitters/Options/Classes/Emitter.d.ts +1 -0
- package/Plugins/Emitters/Options/Classes/Emitter.js +1 -0
- package/Plugins/Emitters/Options/Interfaces/IEmitter.d.ts +1 -0
- package/Plugins/Emitters/ShapeManager.d.ts +6 -3
- package/Plugins/Emitters/ShapeManager.js +16 -4
- package/Plugins/Emitters/Shapes/Circle/CircleShape.d.ts +2 -2
- package/Plugins/Emitters/Shapes/Circle/CircleShape.js +2 -2
- package/Plugins/Emitters/Shapes/Square/SquareShape.d.ts +2 -2
- package/Plugins/Emitters/Shapes/Square/SquareShape.js +4 -4
- package/Plugins/Emitters/index.d.ts +3 -3
- package/Plugins/Emitters/index.js +25 -6
- package/README.md +1 -1
- package/browser/Core/Container.d.ts +4 -1
- package/browser/Core/Container.js +29 -13
- package/browser/Core/Loader.d.ts +12 -9
- package/browser/Core/Loader.js +35 -19
- package/browser/Core/Particle.d.ts +3 -1
- package/browser/Core/Particle.js +18 -3
- package/browser/Core/Particles.d.ts +3 -1
- package/browser/Core/Particles.js +21 -6
- package/browser/Core/Utils/InteractionManager.d.ts +3 -1
- package/browser/Core/Utils/InteractionManager.js +17 -3
- package/browser/Core/Utils/Plugins.d.ts +29 -15
- package/browser/Core/Utils/Plugins.js +58 -46
- package/browser/Options/Classes/Options.d.ts +2 -1
- package/browser/Options/Classes/Options.js +13 -6
- package/browser/Plugins/Emitters/EmitterInstance.d.ts +6 -3
- package/browser/Plugins/Emitters/EmitterInstance.js +46 -16
- package/browser/Plugins/Emitters/Emitters.d.ts +3 -1
- package/browser/Plugins/Emitters/Emitters.js +17 -2
- package/{esm/Plugins/Emitters/EmittersMain.d.ts → browser/Plugins/Emitters/EmittersEngine.d.ts} +3 -1
- package/browser/Plugins/Emitters/{EmittersMain.js → EmittersEngine.js} +0 -0
- package/browser/Plugins/Emitters/IEmitterShape.d.ts +2 -2
- package/browser/Plugins/Emitters/Options/Classes/Emitter.d.ts +1 -0
- package/browser/Plugins/Emitters/Options/Classes/Emitter.js +1 -0
- package/browser/Plugins/Emitters/Options/Interfaces/IEmitter.d.ts +4 -0
- package/browser/Plugins/Emitters/ShapeManager.d.ts +6 -3
- package/browser/Plugins/Emitters/ShapeManager.js +16 -4
- package/browser/Plugins/Emitters/Shapes/Circle/CircleShape.d.ts +2 -2
- package/browser/Plugins/Emitters/Shapes/Circle/CircleShape.js +2 -2
- package/browser/Plugins/Emitters/Shapes/Square/SquareShape.d.ts +2 -2
- package/browser/Plugins/Emitters/Shapes/Square/SquareShape.js +4 -4
- package/browser/Plugins/Emitters/index.d.ts +3 -3
- package/browser/Plugins/Emitters/index.js +25 -6
- package/browser/engine.d.ts +5 -1
- package/browser/engine.js +22 -17
- package/engine.d.ts +3 -0
- package/engine.js +20 -16
- package/esm/Core/Container.d.ts +3 -1
- package/esm/Core/Container.js +28 -13
- package/esm/Core/Loader.d.ts +12 -9
- package/esm/Core/Loader.js +35 -19
- package/esm/Core/Particle.d.ts +3 -1
- package/esm/Core/Particle.js +18 -3
- package/esm/Core/Particles.d.ts +3 -1
- package/esm/Core/Particles.js +21 -6
- package/esm/Core/Utils/InteractionManager.d.ts +3 -1
- package/esm/Core/Utils/InteractionManager.js +17 -3
- package/esm/Core/Utils/Plugins.d.ts +29 -15
- package/esm/Core/Utils/Plugins.js +58 -46
- package/esm/Options/Classes/Options.d.ts +2 -1
- package/esm/Options/Classes/Options.js +13 -6
- package/esm/Plugins/Emitters/EmitterInstance.d.ts +6 -3
- package/esm/Plugins/Emitters/EmitterInstance.js +46 -16
- package/esm/Plugins/Emitters/Emitters.d.ts +3 -1
- package/esm/Plugins/Emitters/Emitters.js +17 -2
- package/{browser/Plugins/Emitters/EmittersMain.d.ts → esm/Plugins/Emitters/EmittersEngine.d.ts} +3 -1
- package/esm/Plugins/Emitters/{EmittersMain.js → EmittersEngine.js} +0 -0
- package/esm/Plugins/Emitters/IEmitterShape.d.ts +2 -2
- package/esm/Plugins/Emitters/Options/Classes/Emitter.d.ts +1 -0
- package/esm/Plugins/Emitters/Options/Classes/Emitter.js +1 -0
- package/esm/Plugins/Emitters/Options/Interfaces/IEmitter.d.ts +1 -0
- package/esm/Plugins/Emitters/ShapeManager.d.ts +6 -3
- package/esm/Plugins/Emitters/ShapeManager.js +16 -4
- package/esm/Plugins/Emitters/Shapes/Circle/CircleShape.d.ts +2 -2
- package/esm/Plugins/Emitters/Shapes/Circle/CircleShape.js +2 -2
- package/esm/Plugins/Emitters/Shapes/Square/SquareShape.d.ts +2 -2
- package/esm/Plugins/Emitters/Shapes/Square/SquareShape.js +4 -4
- package/esm/Plugins/Emitters/index.d.ts +3 -3
- package/esm/Plugins/Emitters/index.js +25 -6
- package/esm/engine.d.ts +3 -0
- package/esm/engine.js +20 -16
- package/package.json +1 -1
- package/report.html +2 -2
- package/report.slim.html +2 -2
- package/tsparticles.engine.js +221 -114
- package/tsparticles.engine.min.js +2 -2
- package/tsparticles.interaction.external.attract.js +199 -96
- package/tsparticles.interaction.external.attract.min.js +2 -2
- package/tsparticles.interaction.external.bounce.js +199 -96
- package/tsparticles.interaction.external.bounce.min.js +2 -2
- package/tsparticles.interaction.external.bubble.js +199 -96
- package/tsparticles.interaction.external.bubble.min.js +2 -2
- package/tsparticles.interaction.external.connect.js +199 -96
- package/tsparticles.interaction.external.connect.min.js +2 -2
- package/tsparticles.interaction.external.grab.js +199 -96
- package/tsparticles.interaction.external.grab.min.js +2 -2
- package/tsparticles.interaction.external.repulse.js +199 -96
- package/tsparticles.interaction.external.repulse.min.js +2 -2
- package/tsparticles.interaction.external.trail.js +199 -96
- package/tsparticles.interaction.external.trail.min.js +2 -2
- package/tsparticles.interaction.particles.attract.js +199 -96
- package/tsparticles.interaction.particles.attract.min.js +2 -2
- package/tsparticles.interaction.particles.collisions.js +199 -96
- package/tsparticles.interaction.particles.collisions.min.js +2 -2
- package/tsparticles.interaction.particles.links.js +199 -96
- package/tsparticles.interaction.particles.links.min.js +2 -2
- package/tsparticles.js +341 -152
- package/tsparticles.min.js +2 -2
- package/tsparticles.pathseg.min.js +1 -1
- package/tsparticles.plugins.absorbers.js +199 -96
- package/tsparticles.plugins.absorbers.min.js +2 -2
- package/tsparticles.plugins.emitters.js +324 -139
- package/tsparticles.plugins.emitters.min.js +2 -2
- package/tsparticles.plugins.polygonMask.js +199 -96
- package/tsparticles.plugins.polygonMask.min.js +2 -2
- package/tsparticles.shape.circle.min.js +1 -1
- package/tsparticles.shape.image.js +202 -99
- package/tsparticles.shape.image.min.js +2 -2
- package/tsparticles.shape.line.min.js +1 -1
- package/tsparticles.shape.polygon.min.js +1 -1
- package/tsparticles.shape.square.min.js +1 -1
- package/tsparticles.shape.star.min.js +1 -1
- package/tsparticles.shape.text.js +199 -96
- package/tsparticles.shape.text.min.js +2 -2
- package/tsparticles.slim.js +221 -114
- package/tsparticles.slim.min.js +2 -2
- package/tsparticles.updater.angle.js +199 -96
- package/tsparticles.updater.angle.min.js +2 -2
- package/tsparticles.updater.color.js +199 -96
- package/tsparticles.updater.color.min.js +2 -2
- package/tsparticles.updater.life.js +199 -96
- package/tsparticles.updater.life.min.js +2 -2
- package/tsparticles.updater.opacity.js +199 -96
- package/tsparticles.updater.opacity.min.js +2 -2
- package/tsparticles.updater.outModes.js +199 -96
- package/tsparticles.updater.outModes.min.js +2 -2
- package/tsparticles.updater.roll.js +199 -96
- package/tsparticles.updater.roll.min.js +2 -2
- package/tsparticles.updater.size.js +199 -96
- package/tsparticles.updater.size.min.js +2 -2
- package/tsparticles.updater.strokeColor.js +199 -96
- package/tsparticles.updater.strokeColor.min.js +2 -2
- package/tsparticles.updater.tilt.js +199 -96
- package/tsparticles.updater.tilt.min.js +2 -2
- package/tsparticles.updater.wobble.js +199 -96
- package/tsparticles.updater.wobble.min.js +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export class CircleShape {
|
|
2
|
-
randomPosition(position,
|
|
2
|
+
randomPosition(position, size, fill) {
|
|
3
3
|
const generateTheta = (x, y) => {
|
|
4
4
|
const u = Math.random() / 4.0;
|
|
5
5
|
const theta = Math.atan((y / x) * Math.tan(2 * Math.PI * u));
|
|
@@ -18,7 +18,7 @@ export class CircleShape {
|
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
const radius = (x, y, theta) => (x * y) / Math.sqrt((y * Math.cos(theta)) ** 2 + (x * Math.sin(theta)) ** 2);
|
|
21
|
-
const [a, b] = [
|
|
21
|
+
const [a, b] = [size.width / 2, size.height / 2];
|
|
22
22
|
const randomTheta = generateTheta(a, b), maxRadius = radius(a, b, randomTheta), randomRadius = fill ? maxRadius * Math.sqrt(Math.random()) : maxRadius;
|
|
23
23
|
return {
|
|
24
24
|
x: position.x + randomRadius * Math.cos(randomTheta),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ICoordinates } from "../../../../Core";
|
|
1
|
+
import type { ICoordinates, IDimension } from "../../../../Core";
|
|
2
2
|
import type { IEmitterShape } from "../../IEmitterShape";
|
|
3
3
|
export declare class SquareShape implements IEmitterShape {
|
|
4
|
-
randomPosition(position: ICoordinates,
|
|
4
|
+
randomPosition(position: ICoordinates, size: IDimension, fill: boolean): ICoordinates;
|
|
5
5
|
}
|
|
@@ -2,15 +2,15 @@ function randomSquareCoordinate(position, offset) {
|
|
|
2
2
|
return position + offset * (Math.random() - 0.5);
|
|
3
3
|
}
|
|
4
4
|
export class SquareShape {
|
|
5
|
-
randomPosition(position,
|
|
5
|
+
randomPosition(position, size, fill) {
|
|
6
6
|
if (fill) {
|
|
7
7
|
return {
|
|
8
|
-
x: randomSquareCoordinate(position.x,
|
|
9
|
-
y: randomSquareCoordinate(position.y,
|
|
8
|
+
x: randomSquareCoordinate(position.x, size.width),
|
|
9
|
+
y: randomSquareCoordinate(position.y, size.height),
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
12
|
else {
|
|
13
|
-
const halfW =
|
|
13
|
+
const halfW = size.width / 2, halfH = size.height / 2, side = Math.floor(Math.random() * 4), v = (Math.random() - 0.5) * 2;
|
|
14
14
|
switch (side) {
|
|
15
15
|
case 0:
|
|
16
16
|
// top-left
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function loadEmittersPlugin(engine:
|
|
3
|
-
export * from "./
|
|
1
|
+
import { EmittersEngine } from "./EmittersEngine";
|
|
2
|
+
export declare function loadEmittersPlugin(engine: EmittersEngine): Promise<void>;
|
|
3
|
+
export * from "./EmittersEngine";
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _EmittersPlugin_engine;
|
|
1
13
|
import { CircleShape } from "./Shapes/Circle/CircleShape";
|
|
2
14
|
import { Emitter } from "./Options/Classes/Emitter";
|
|
3
15
|
import { Emitters } from "./Emitters";
|
|
@@ -8,11 +20,13 @@ import { isInArray } from "../../Utils";
|
|
|
8
20
|
* @category Emitters Plugin
|
|
9
21
|
*/
|
|
10
22
|
class EmittersPlugin {
|
|
11
|
-
constructor() {
|
|
23
|
+
constructor(engine) {
|
|
24
|
+
_EmittersPlugin_engine.set(this, void 0);
|
|
25
|
+
__classPrivateFieldSet(this, _EmittersPlugin_engine, engine, "f");
|
|
12
26
|
this.id = "emitters";
|
|
13
27
|
}
|
|
14
28
|
getPlugin(container) {
|
|
15
|
-
return new Emitters(container);
|
|
29
|
+
return new Emitters(__classPrivateFieldGet(this, _EmittersPlugin_engine, "f"), container);
|
|
16
30
|
}
|
|
17
31
|
needsPlugin(options) {
|
|
18
32
|
var _a, _b, _c;
|
|
@@ -66,15 +80,20 @@ class EmittersPlugin {
|
|
|
66
80
|
}
|
|
67
81
|
}
|
|
68
82
|
}
|
|
83
|
+
_EmittersPlugin_engine = new WeakMap();
|
|
69
84
|
export async function loadEmittersPlugin(engine) {
|
|
70
|
-
|
|
71
|
-
|
|
85
|
+
if (!engine.emitterShapeManager) {
|
|
86
|
+
engine.emitterShapeManager = new ShapeManager(engine);
|
|
87
|
+
}
|
|
72
88
|
if (!engine.addEmitterShape) {
|
|
73
89
|
engine.addEmitterShape = (name, shape) => {
|
|
74
|
-
|
|
90
|
+
var _a;
|
|
91
|
+
(_a = engine.emitterShapeManager) === null || _a === void 0 ? void 0 : _a.addShape(name, shape);
|
|
75
92
|
};
|
|
76
93
|
}
|
|
94
|
+
const plugin = new EmittersPlugin(engine);
|
|
95
|
+
await engine.addPlugin(plugin);
|
|
77
96
|
engine.addEmitterShape("circle" /* circle */, new CircleShape());
|
|
78
97
|
engine.addEmitterShape("square" /* square */, new SquareShape());
|
|
79
98
|
}
|
|
80
|
-
export * from "./
|
|
99
|
+
export * from "./EmittersEngine";
|
package/browser/engine.d.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import type { Container, IInteractor, IMovePathGenerator, IParticleUpdater, IPlugin, IShapeDrawer, Particle } from "./Core";
|
|
2
|
+
import { Plugins } from "./Core";
|
|
2
3
|
import type { RecursivePartial, ShapeDrawerAfterEffectFunction, ShapeDrawerDestroyFunction, ShapeDrawerDrawFunction, ShapeDrawerInitFunction, SingleOrMultiple } from "./Types";
|
|
3
4
|
import type { IOptions } from "./Options/Interfaces/IOptions";
|
|
4
5
|
/**
|
|
5
6
|
* Engine class for creating the singleton on window.
|
|
6
|
-
* It's a singleton proxy to the
|
|
7
|
+
* It's a singleton proxy to the Loader class for initializing [[Container]] instances,
|
|
8
|
+
* and for Plugins class responsible for every external feature
|
|
7
9
|
* @category Engine
|
|
8
10
|
*/
|
|
9
11
|
export declare class Engine {
|
|
10
12
|
#private;
|
|
13
|
+
readonly domArray: Container[];
|
|
14
|
+
readonly plugins: Plugins;
|
|
11
15
|
constructor();
|
|
12
16
|
/**
|
|
13
17
|
* init method, used by imports
|
package/browser/engine.js
CHANGED
|
@@ -9,17 +9,22 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _Engine_initialized;
|
|
12
|
+
var _Engine_initialized, _Engine_loader;
|
|
13
13
|
import { Loader, Plugins } from "./Core";
|
|
14
14
|
/**
|
|
15
15
|
* Engine class for creating the singleton on window.
|
|
16
|
-
* It's a singleton proxy to the
|
|
16
|
+
* It's a singleton proxy to the Loader class for initializing [[Container]] instances,
|
|
17
|
+
* and for Plugins class responsible for every external feature
|
|
17
18
|
* @category Engine
|
|
18
19
|
*/
|
|
19
20
|
export class Engine {
|
|
20
21
|
constructor() {
|
|
21
22
|
_Engine_initialized.set(this, void 0);
|
|
23
|
+
_Engine_loader.set(this, void 0);
|
|
22
24
|
__classPrivateFieldSet(this, _Engine_initialized, false, "f");
|
|
25
|
+
this.domArray = [];
|
|
26
|
+
__classPrivateFieldSet(this, _Engine_loader, new Loader(this), "f");
|
|
27
|
+
this.plugins = new Plugins(this);
|
|
23
28
|
}
|
|
24
29
|
/**
|
|
25
30
|
* init method, used by imports
|
|
@@ -37,7 +42,7 @@ export class Engine {
|
|
|
37
42
|
* @returns A Promise with the [[Container]] object created
|
|
38
43
|
*/
|
|
39
44
|
async loadFromArray(tagId, options, index) {
|
|
40
|
-
return
|
|
45
|
+
return __classPrivateFieldGet(this, _Engine_loader, "f").load(tagId, options, index);
|
|
41
46
|
}
|
|
42
47
|
/**
|
|
43
48
|
* Loads the provided options to create a [[Container]] object.
|
|
@@ -46,7 +51,7 @@ export class Engine {
|
|
|
46
51
|
* @returns A Promise with the [[Container]] object created
|
|
47
52
|
*/
|
|
48
53
|
async load(tagId, options) {
|
|
49
|
-
return
|
|
54
|
+
return __classPrivateFieldGet(this, _Engine_loader, "f").load(tagId, options);
|
|
50
55
|
}
|
|
51
56
|
/**
|
|
52
57
|
* Loads the provided option to create a [[Container]] object using the element parameter as a container
|
|
@@ -55,7 +60,7 @@ export class Engine {
|
|
|
55
60
|
* @param options The options object to initialize the [[Container]]
|
|
56
61
|
*/
|
|
57
62
|
async set(id, element, options) {
|
|
58
|
-
return
|
|
63
|
+
return __classPrivateFieldGet(this, _Engine_loader, "f").set(id, element, options);
|
|
59
64
|
}
|
|
60
65
|
/**
|
|
61
66
|
* Loads the provided json with a GET request. The content will be used to create a [[Container]] object.
|
|
@@ -66,7 +71,7 @@ export class Engine {
|
|
|
66
71
|
* @returns A Promise with the [[Container]] object created
|
|
67
72
|
*/
|
|
68
73
|
async loadJSON(tagId, pathConfigJson, index) {
|
|
69
|
-
return
|
|
74
|
+
return __classPrivateFieldGet(this, _Engine_loader, "f").loadJSON(tagId, pathConfigJson, index);
|
|
70
75
|
}
|
|
71
76
|
/**
|
|
72
77
|
* Loads the provided option to create a [[Container]] object using the element parameter as a container
|
|
@@ -77,21 +82,21 @@ export class Engine {
|
|
|
77
82
|
* @returns A Promise with the [[Container]] object created
|
|
78
83
|
*/
|
|
79
84
|
async setJSON(id, element, pathConfigJson, index) {
|
|
80
|
-
return
|
|
85
|
+
return __classPrivateFieldGet(this, _Engine_loader, "f").setJSON(id, element, pathConfigJson, index);
|
|
81
86
|
}
|
|
82
87
|
/**
|
|
83
88
|
* Adds an additional click handler to all the loaded [[Container]] objects.
|
|
84
89
|
* @param callback The function called after the click event is fired
|
|
85
90
|
*/
|
|
86
91
|
setOnClickHandler(callback) {
|
|
87
|
-
|
|
92
|
+
__classPrivateFieldGet(this, _Engine_loader, "f").setOnClickHandler(callback);
|
|
88
93
|
}
|
|
89
94
|
/**
|
|
90
95
|
* All the [[Container]] objects loaded
|
|
91
96
|
* @returns All the [[Container]] objects loaded
|
|
92
97
|
*/
|
|
93
98
|
dom() {
|
|
94
|
-
return
|
|
99
|
+
return __classPrivateFieldGet(this, _Engine_loader, "f").dom();
|
|
95
100
|
}
|
|
96
101
|
/**
|
|
97
102
|
* Retrieves a [[Container]] from all the objects loaded
|
|
@@ -99,7 +104,7 @@ export class Engine {
|
|
|
99
104
|
* @returns The [[Container]] object at specified index, if present or not destroyed, otherwise undefined
|
|
100
105
|
*/
|
|
101
106
|
domItem(index) {
|
|
102
|
-
return
|
|
107
|
+
return __classPrivateFieldGet(this, _Engine_loader, "f").domItem(index);
|
|
103
108
|
}
|
|
104
109
|
/**
|
|
105
110
|
* Reloads all existing tsParticles loaded instances
|
|
@@ -130,7 +135,7 @@ export class Engine {
|
|
|
130
135
|
else {
|
|
131
136
|
customDrawer = drawer;
|
|
132
137
|
}
|
|
133
|
-
|
|
138
|
+
this.plugins.addShapeDrawer(shape, customDrawer);
|
|
134
139
|
await this.refresh();
|
|
135
140
|
}
|
|
136
141
|
/**
|
|
@@ -140,7 +145,7 @@ export class Engine {
|
|
|
140
145
|
* @param override if true, the preset will override any existing with the same name
|
|
141
146
|
*/
|
|
142
147
|
async addPreset(preset, options, override = false) {
|
|
143
|
-
|
|
148
|
+
this.plugins.addPreset(preset, options, override);
|
|
144
149
|
await this.refresh();
|
|
145
150
|
}
|
|
146
151
|
/**
|
|
@@ -148,7 +153,7 @@ export class Engine {
|
|
|
148
153
|
* @param plugin the plugin implementation of [[IPlugin]]
|
|
149
154
|
*/
|
|
150
155
|
async addPlugin(plugin) {
|
|
151
|
-
|
|
156
|
+
this.plugins.addPlugin(plugin);
|
|
152
157
|
await this.refresh();
|
|
153
158
|
}
|
|
154
159
|
/**
|
|
@@ -157,7 +162,7 @@ export class Engine {
|
|
|
157
162
|
* @param generator the path generator object
|
|
158
163
|
*/
|
|
159
164
|
async addPathGenerator(name, generator) {
|
|
160
|
-
|
|
165
|
+
this.plugins.addPathGenerator(name, generator);
|
|
161
166
|
await this.refresh();
|
|
162
167
|
}
|
|
163
168
|
/**
|
|
@@ -166,7 +171,7 @@ export class Engine {
|
|
|
166
171
|
* @param interactorInitializer
|
|
167
172
|
*/
|
|
168
173
|
async addInteractor(name, interactorInitializer) {
|
|
169
|
-
|
|
174
|
+
this.plugins.addInteractor(name, interactorInitializer);
|
|
170
175
|
await this.refresh();
|
|
171
176
|
}
|
|
172
177
|
/**
|
|
@@ -175,8 +180,8 @@ export class Engine {
|
|
|
175
180
|
* @param updaterInitializer
|
|
176
181
|
*/
|
|
177
182
|
async addParticleUpdater(name, updaterInitializer) {
|
|
178
|
-
|
|
183
|
+
this.plugins.addParticleUpdater(name, updaterInitializer);
|
|
179
184
|
await this.refresh();
|
|
180
185
|
}
|
|
181
186
|
}
|
|
182
|
-
_Engine_initialized = new WeakMap();
|
|
187
|
+
_Engine_initialized = new WeakMap(), _Engine_loader = new WeakMap();
|
package/engine.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { Container, IInteractor, IMovePathGenerator, IParticleUpdater, IPlugin, IShapeDrawer, Particle } from "./Core";
|
|
2
|
+
import { Plugins } from "./Core";
|
|
2
3
|
import type { RecursivePartial, ShapeDrawerAfterEffectFunction, ShapeDrawerDestroyFunction, ShapeDrawerDrawFunction, ShapeDrawerInitFunction, SingleOrMultiple } from "./Types";
|
|
3
4
|
import type { IOptions } from "./Options/Interfaces/IOptions";
|
|
4
5
|
export declare class Engine {
|
|
5
6
|
#private;
|
|
7
|
+
readonly domArray: Container[];
|
|
8
|
+
readonly plugins: Plugins;
|
|
6
9
|
constructor();
|
|
7
10
|
init(): void;
|
|
8
11
|
loadFromArray(tagId: string, options: RecursivePartial<IOptions>[], index?: number): Promise<Container | undefined>;
|
package/engine.js
CHANGED
|
@@ -10,14 +10,18 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
11
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
12
|
};
|
|
13
|
-
var _Engine_initialized;
|
|
13
|
+
var _Engine_initialized, _Engine_loader;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.Engine = void 0;
|
|
16
16
|
const Core_1 = require("./Core");
|
|
17
17
|
class Engine {
|
|
18
18
|
constructor() {
|
|
19
19
|
_Engine_initialized.set(this, void 0);
|
|
20
|
+
_Engine_loader.set(this, void 0);
|
|
20
21
|
__classPrivateFieldSet(this, _Engine_initialized, false, "f");
|
|
22
|
+
this.domArray = [];
|
|
23
|
+
__classPrivateFieldSet(this, _Engine_loader, new Core_1.Loader(this), "f");
|
|
24
|
+
this.plugins = new Core_1.Plugins(this);
|
|
21
25
|
}
|
|
22
26
|
init() {
|
|
23
27
|
if (!__classPrivateFieldGet(this, _Engine_initialized, "f")) {
|
|
@@ -25,28 +29,28 @@ class Engine {
|
|
|
25
29
|
}
|
|
26
30
|
}
|
|
27
31
|
async loadFromArray(tagId, options, index) {
|
|
28
|
-
return
|
|
32
|
+
return __classPrivateFieldGet(this, _Engine_loader, "f").load(tagId, options, index);
|
|
29
33
|
}
|
|
30
34
|
async load(tagId, options) {
|
|
31
|
-
return
|
|
35
|
+
return __classPrivateFieldGet(this, _Engine_loader, "f").load(tagId, options);
|
|
32
36
|
}
|
|
33
37
|
async set(id, element, options) {
|
|
34
|
-
return
|
|
38
|
+
return __classPrivateFieldGet(this, _Engine_loader, "f").set(id, element, options);
|
|
35
39
|
}
|
|
36
40
|
async loadJSON(tagId, pathConfigJson, index) {
|
|
37
|
-
return
|
|
41
|
+
return __classPrivateFieldGet(this, _Engine_loader, "f").loadJSON(tagId, pathConfigJson, index);
|
|
38
42
|
}
|
|
39
43
|
async setJSON(id, element, pathConfigJson, index) {
|
|
40
|
-
return
|
|
44
|
+
return __classPrivateFieldGet(this, _Engine_loader, "f").setJSON(id, element, pathConfigJson, index);
|
|
41
45
|
}
|
|
42
46
|
setOnClickHandler(callback) {
|
|
43
|
-
|
|
47
|
+
__classPrivateFieldGet(this, _Engine_loader, "f").setOnClickHandler(callback);
|
|
44
48
|
}
|
|
45
49
|
dom() {
|
|
46
|
-
return
|
|
50
|
+
return __classPrivateFieldGet(this, _Engine_loader, "f").dom();
|
|
47
51
|
}
|
|
48
52
|
domItem(index) {
|
|
49
|
-
return
|
|
53
|
+
return __classPrivateFieldGet(this, _Engine_loader, "f").domItem(index);
|
|
50
54
|
}
|
|
51
55
|
async refresh() {
|
|
52
56
|
for (const instance of this.dom()) {
|
|
@@ -66,29 +70,29 @@ class Engine {
|
|
|
66
70
|
else {
|
|
67
71
|
customDrawer = drawer;
|
|
68
72
|
}
|
|
69
|
-
|
|
73
|
+
this.plugins.addShapeDrawer(shape, customDrawer);
|
|
70
74
|
await this.refresh();
|
|
71
75
|
}
|
|
72
76
|
async addPreset(preset, options, override = false) {
|
|
73
|
-
|
|
77
|
+
this.plugins.addPreset(preset, options, override);
|
|
74
78
|
await this.refresh();
|
|
75
79
|
}
|
|
76
80
|
async addPlugin(plugin) {
|
|
77
|
-
|
|
81
|
+
this.plugins.addPlugin(plugin);
|
|
78
82
|
await this.refresh();
|
|
79
83
|
}
|
|
80
84
|
async addPathGenerator(name, generator) {
|
|
81
|
-
|
|
85
|
+
this.plugins.addPathGenerator(name, generator);
|
|
82
86
|
await this.refresh();
|
|
83
87
|
}
|
|
84
88
|
async addInteractor(name, interactorInitializer) {
|
|
85
|
-
|
|
89
|
+
this.plugins.addInteractor(name, interactorInitializer);
|
|
86
90
|
await this.refresh();
|
|
87
91
|
}
|
|
88
92
|
async addParticleUpdater(name, updaterInitializer) {
|
|
89
|
-
|
|
93
|
+
this.plugins.addParticleUpdater(name, updaterInitializer);
|
|
90
94
|
await this.refresh();
|
|
91
95
|
}
|
|
92
96
|
}
|
|
93
97
|
exports.Engine = Engine;
|
|
94
|
-
_Engine_initialized = new WeakMap();
|
|
98
|
+
_Engine_initialized = new WeakMap(), _Engine_loader = new WeakMap();
|
package/esm/Core/Container.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FrameManager, Vector } from "./Utils";
|
|
2
2
|
import type { IAttract, IBubble, IContainerInteractivity, IContainerPlugin, IMovePathGenerator, IRepulse, IShapeDrawer } from "./Interfaces";
|
|
3
3
|
import { Canvas } from "./Canvas";
|
|
4
|
+
import type { Engine } from "../engine";
|
|
4
5
|
import type { IOptions } from "../Options/Interfaces/IOptions";
|
|
5
6
|
import { Options } from "../Options/Classes/Options";
|
|
6
7
|
import { Particle } from "./Particle";
|
|
@@ -8,6 +9,7 @@ import { Particles } from "./Particles";
|
|
|
8
9
|
import type { RecursivePartial } from "../Types";
|
|
9
10
|
import { Retina } from "./Retina";
|
|
10
11
|
export declare class Container {
|
|
12
|
+
#private;
|
|
11
13
|
readonly id: string;
|
|
12
14
|
started: boolean;
|
|
13
15
|
destroyed: boolean;
|
|
@@ -43,7 +45,7 @@ export declare class Container {
|
|
|
43
45
|
private readonly presets;
|
|
44
46
|
private readonly eventListeners;
|
|
45
47
|
private readonly intersectionObserver?;
|
|
46
|
-
constructor(id: string, sourceOptions?: RecursivePartial<IOptions>, ...presets: string[]);
|
|
48
|
+
constructor(engine: Engine, id: string, sourceOptions?: RecursivePartial<IOptions>, ...presets: string[]);
|
|
47
49
|
play(force?: boolean): void;
|
|
48
50
|
pause(): void;
|
|
49
51
|
draw(force: boolean): void;
|
package/esm/Core/Container.js
CHANGED
|
@@ -1,12 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _Container_engine;
|
|
13
|
+
import { EventListeners, FrameManager, Vector } from "./Utils";
|
|
2
14
|
import { animate, cancelAnimation, getRangeValue } from "../Utils";
|
|
3
15
|
import { Canvas } from "./Canvas";
|
|
4
16
|
import { Options } from "../Options/Classes/Options";
|
|
5
17
|
import { Particles } from "./Particles";
|
|
6
18
|
import { Retina } from "./Retina";
|
|
7
19
|
export class Container {
|
|
8
|
-
constructor(id, sourceOptions, ...presets) {
|
|
20
|
+
constructor(engine, id, sourceOptions, ...presets) {
|
|
9
21
|
this.id = id;
|
|
22
|
+
_Container_engine.set(this, void 0);
|
|
23
|
+
__classPrivateFieldSet(this, _Container_engine, engine, "f");
|
|
10
24
|
this.fpsLimit = 120;
|
|
11
25
|
this.duration = 0;
|
|
12
26
|
this.lifeTime = 0;
|
|
@@ -21,7 +35,7 @@ export class Container {
|
|
|
21
35
|
this._initialSourceOptions = sourceOptions;
|
|
22
36
|
this.retina = new Retina(this);
|
|
23
37
|
this.canvas = new Canvas(this);
|
|
24
|
-
this.particles = new Particles(this);
|
|
38
|
+
this.particles = new Particles(__classPrivateFieldGet(this, _Container_engine, "f"), this);
|
|
25
39
|
this.drawer = new FrameManager(this);
|
|
26
40
|
this.presets = presets;
|
|
27
41
|
this.pathGenerator = {
|
|
@@ -48,8 +62,8 @@ export class Container {
|
|
|
48
62
|
this.plugins = new Map();
|
|
49
63
|
this.drawers = new Map();
|
|
50
64
|
this.density = 1;
|
|
51
|
-
this._options = new Options();
|
|
52
|
-
this.actualOptions = new Options();
|
|
65
|
+
this._options = new Options(__classPrivateFieldGet(this, _Container_engine, "f"));
|
|
66
|
+
this.actualOptions = new Options(__classPrivateFieldGet(this, _Container_engine, "f"));
|
|
53
67
|
this.eventListeners = new EventListeners(this);
|
|
54
68
|
if (typeof IntersectionObserver !== "undefined" && IntersectionObserver) {
|
|
55
69
|
this.intersectionObserver = new IntersectionObserver((entries) => this.intersectionManager(entries));
|
|
@@ -165,7 +179,7 @@ export class Container {
|
|
|
165
179
|
return this.start();
|
|
166
180
|
}
|
|
167
181
|
reset() {
|
|
168
|
-
this._options = new Options();
|
|
182
|
+
this._options = new Options(__classPrivateFieldGet(this, _Container_engine, "f"));
|
|
169
183
|
return this.refresh();
|
|
170
184
|
}
|
|
171
185
|
stop() {
|
|
@@ -307,20 +321,20 @@ export class Container {
|
|
|
307
321
|
return false;
|
|
308
322
|
}
|
|
309
323
|
async init() {
|
|
310
|
-
this._options = new Options();
|
|
324
|
+
this._options = new Options(__classPrivateFieldGet(this, _Container_engine, "f"));
|
|
311
325
|
for (const preset of this.presets) {
|
|
312
|
-
this._options.load(
|
|
326
|
+
this._options.load(__classPrivateFieldGet(this, _Container_engine, "f").plugins.getPreset(preset));
|
|
313
327
|
}
|
|
314
|
-
const shapes =
|
|
328
|
+
const shapes = __classPrivateFieldGet(this, _Container_engine, "f").plugins.getSupportedShapes();
|
|
315
329
|
for (const type of shapes) {
|
|
316
|
-
const drawer =
|
|
330
|
+
const drawer = __classPrivateFieldGet(this, _Container_engine, "f").plugins.getShapeDrawer(type);
|
|
317
331
|
if (drawer) {
|
|
318
332
|
this.drawers.set(type, drawer);
|
|
319
333
|
}
|
|
320
334
|
}
|
|
321
335
|
this._options.load(this._initialSourceOptions);
|
|
322
336
|
this._options.load(this._sourceOptions);
|
|
323
|
-
this.actualOptions = new Options();
|
|
337
|
+
this.actualOptions = new Options(__classPrivateFieldGet(this, _Container_engine, "f"));
|
|
324
338
|
this.actualOptions.load(this._options);
|
|
325
339
|
this.retina.init();
|
|
326
340
|
this.canvas.init();
|
|
@@ -331,7 +345,7 @@ export class Container {
|
|
|
331
345
|
this.duration = getRangeValue(this.actualOptions.duration);
|
|
332
346
|
this.lifeTime = 0;
|
|
333
347
|
this.fpsLimit = this.actualOptions.fpsLimit > 0 ? this.actualOptions.fpsLimit : 120;
|
|
334
|
-
const availablePlugins =
|
|
348
|
+
const availablePlugins = __classPrivateFieldGet(this, _Container_engine, "f").plugins.getAvailablePlugins(this);
|
|
335
349
|
for (const [id, plugin] of availablePlugins) {
|
|
336
350
|
this.plugins.set(id, plugin);
|
|
337
351
|
}
|
|
@@ -350,7 +364,7 @@ export class Container {
|
|
|
350
364
|
}
|
|
351
365
|
const pathOptions = this.actualOptions.particles.move.path;
|
|
352
366
|
if (pathOptions.generator) {
|
|
353
|
-
const customGenerator =
|
|
367
|
+
const customGenerator = __classPrivateFieldGet(this, _Container_engine, "f").plugins.getPathGenerator(pathOptions.generator);
|
|
354
368
|
if (customGenerator) {
|
|
355
369
|
if (customGenerator.init) {
|
|
356
370
|
this.pathGenerator.init = customGenerator.init;
|
|
@@ -388,3 +402,4 @@ export class Container {
|
|
|
388
402
|
}
|
|
389
403
|
}
|
|
390
404
|
}
|
|
405
|
+
_Container_engine = new WeakMap();
|
package/esm/Core/Loader.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Container } from "./Container";
|
|
2
|
+
import type { Engine } from "../engine";
|
|
2
3
|
import type { IOptions } from "../Options/Interfaces/IOptions";
|
|
3
4
|
import type { Particle } from "./Particle";
|
|
4
5
|
import type { RecursivePartial } from "../Types";
|
|
@@ -16,14 +17,16 @@ interface RemoteLoaderParams {
|
|
|
16
17
|
url?: SingleOrMultiple<string>;
|
|
17
18
|
}
|
|
18
19
|
export declare class Loader {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
#private;
|
|
21
|
+
constructor(engine: Engine);
|
|
22
|
+
dom(): Container[];
|
|
23
|
+
domItem(index: number): Container | undefined;
|
|
24
|
+
loadOptions(params: LoaderParams): Promise<Container | undefined>;
|
|
25
|
+
loadRemoteOptions(params: RemoteLoaderParams): Promise<Container | undefined>;
|
|
26
|
+
load(tagId: string | SingleOrMultiple<RecursivePartial<IOptions>>, options?: SingleOrMultiple<RecursivePartial<IOptions>> | number, index?: number): Promise<Container | undefined>;
|
|
27
|
+
set(id: string | HTMLElement, domContainer: HTMLElement | SingleOrMultiple<RecursivePartial<IOptions>>, options?: SingleOrMultiple<RecursivePartial<IOptions>> | number, index?: number): Promise<Container | undefined>;
|
|
28
|
+
loadJSON(tagId: string | SingleOrMultiple<string>, jsonUrl?: SingleOrMultiple<string> | number, index?: number): Promise<Container | undefined>;
|
|
29
|
+
setJSON(id: string | HTMLElement, domContainer: HTMLElement | SingleOrMultiple<string>, jsonUrl: SingleOrMultiple<string> | (number | undefined), index?: number): Promise<Container | undefined>;
|
|
30
|
+
setOnClickHandler(callback: (evt: Event, particles?: Particle[]) => void): void;
|
|
28
31
|
}
|
|
29
32
|
export {};
|