@tsparticles/engine 4.0.0-beta.0 → 4.0.0-beta.2
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/155.min.js +1 -0
- package/README.md +0 -21
- package/browser/Core/CanvasManager.js +303 -0
- package/browser/Core/Container.js +64 -34
- package/browser/Core/Engine.js +26 -138
- package/browser/Core/Interfaces/IPositionFromSizeParams.js +1 -1
- package/browser/Core/Particle.js +29 -28
- package/{cjs/Core/Particles.js → browser/Core/ParticlesManager.js} +28 -57
- package/browser/Core/RenderManager.js +303 -0
- package/browser/Core/Retina.js +3 -8
- package/browser/Core/Utils/PluginManager.js +145 -0
- package/browser/Options/Classes/Options.js +7 -7
- package/browser/Options/Classes/Particles/ParticlesOptions.js +5 -5
- package/browser/Types/CanvasContextType.js +1 -0
- package/browser/Utils/CanvasUtils.js +1 -1
- package/browser/Utils/ColorUtils.js +21 -21
- package/browser/Utils/LogUtils.js +1 -0
- package/browser/Utils/OptionsUtils.js +2 -2
- package/cjs/Core/CanvasManager.js +303 -0
- package/cjs/Core/Container.js +64 -34
- package/cjs/Core/Engine.js +26 -138
- package/cjs/Core/Interfaces/IPositionFromSizeParams.js +1 -1
- package/cjs/Core/Particle.js +29 -28
- package/{esm/Core/Particles.js → cjs/Core/ParticlesManager.js} +28 -57
- package/cjs/Core/RenderManager.js +303 -0
- package/cjs/Core/Retina.js +3 -8
- package/cjs/Core/Utils/PluginManager.js +145 -0
- package/cjs/Options/Classes/Options.js +7 -7
- package/cjs/Options/Classes/Particles/ParticlesOptions.js +5 -5
- package/cjs/Types/CanvasContextType.js +1 -0
- package/cjs/Utils/CanvasUtils.js +1 -1
- package/cjs/Utils/ColorUtils.js +21 -21
- package/cjs/Utils/LogUtils.js +1 -0
- package/cjs/Utils/OptionsUtils.js +2 -2
- package/dist_browser_Core_Container_js.js +24 -14
- package/esm/Core/CanvasManager.js +303 -0
- package/esm/Core/Container.js +64 -34
- package/esm/Core/Engine.js +26 -138
- package/esm/Core/Interfaces/IPositionFromSizeParams.js +1 -1
- package/esm/Core/Particle.js +29 -28
- package/{browser/Core/Particles.js → esm/Core/ParticlesManager.js} +28 -57
- package/esm/Core/RenderManager.js +303 -0
- package/esm/Core/Retina.js +3 -8
- package/esm/Core/Utils/PluginManager.js +145 -0
- package/esm/Options/Classes/Options.js +7 -7
- package/esm/Options/Classes/Particles/ParticlesOptions.js +5 -5
- package/esm/Types/CanvasContextType.js +1 -0
- package/esm/Utils/CanvasUtils.js +1 -1
- package/esm/Utils/ColorUtils.js +21 -21
- package/esm/Utils/LogUtils.js +1 -0
- package/esm/Utils/OptionsUtils.js +2 -2
- package/package.json +2 -3
- package/report.html +84 -29
- package/tsparticles.engine.js +18 -8
- package/tsparticles.engine.min.js +2 -2
- package/types/Core/CanvasManager.d.ts +39 -0
- package/types/Core/Container.d.ts +26 -7
- package/types/Core/Engine.d.ts +2 -54
- package/types/Core/Interfaces/IContainerPlugin.d.ts +8 -7
- package/types/Core/Interfaces/IDrawParticleParams.d.ts +2 -1
- package/types/Core/Interfaces/IParticleRetinaProps.d.ts +4 -4
- package/types/Core/Interfaces/IParticleUpdater.d.ts +2 -1
- package/types/Core/Interfaces/IShapeDrawData.d.ts +2 -1
- package/types/Core/Particle.d.ts +4 -4
- package/types/Core/{Particles.d.ts → ParticlesManager.d.ts} +4 -11
- package/types/Core/{Canvas.d.ts → RenderManager.d.ts} +12 -33
- package/types/Core/Retina.d.ts +0 -2
- package/types/Core/Utils/PluginManager.d.ts +62 -0
- package/types/Options/Classes/Options.d.ts +3 -3
- package/types/Options/Classes/Particles/ParticlesOptions.d.ts +3 -3
- package/types/Types/CanvasContextType.d.ts +1 -0
- package/types/Utils/CanvasUtils.d.ts +8 -5
- package/types/Utils/ColorUtils.d.ts +8 -8
- package/types/Utils/LogUtils.d.ts +1 -0
- package/types/Utils/OptionsUtils.d.ts +2 -2
- package/types/export-types.d.ts +4 -2
- package/164.min.js +0 -1
- package/browser/Core/Canvas.js +0 -570
- package/cjs/Core/Canvas.js +0 -570
- package/esm/Core/Canvas.js +0 -570
- package/umd/Core/Canvas.js +0 -584
- package/umd/Core/Container.js +0 -356
- package/umd/Core/Engine.js +0 -295
- package/umd/Core/Interfaces/Colors.js +0 -12
- package/umd/Core/Interfaces/IBounds.js +0 -12
- package/umd/Core/Interfaces/IBubbleParticleData.js +0 -12
- package/umd/Core/Interfaces/ICircleBouncer.js +0 -12
- package/umd/Core/Interfaces/IColorManager.js +0 -12
- package/umd/Core/Interfaces/IContainerPlugin.js +0 -12
- package/umd/Core/Interfaces/ICoordinates.js +0 -12
- package/umd/Core/Interfaces/IDelta.js +0 -12
- package/umd/Core/Interfaces/IDimension.js +0 -12
- package/umd/Core/Interfaces/IDistance.js +0 -12
- package/umd/Core/Interfaces/IDrawParticleParams.js +0 -12
- package/umd/Core/Interfaces/IEffectDrawer.js +0 -12
- package/umd/Core/Interfaces/ILoadParams.js +0 -12
- package/umd/Core/Interfaces/IPalette.js +0 -12
- package/umd/Core/Interfaces/IParticleColorStyle.js +0 -12
- package/umd/Core/Interfaces/IParticleHslAnimation.js +0 -12
- package/umd/Core/Interfaces/IParticleLife.js +0 -12
- package/umd/Core/Interfaces/IParticleOpacityData.js +0 -12
- package/umd/Core/Interfaces/IParticleRetinaProps.js +0 -12
- package/umd/Core/Interfaces/IParticleRoll.js +0 -12
- package/umd/Core/Interfaces/IParticleRotateData.js +0 -12
- package/umd/Core/Interfaces/IParticleTransformValues.js +0 -12
- package/umd/Core/Interfaces/IParticleUpdater.js +0 -12
- package/umd/Core/Interfaces/IParticleValueAnimation.js +0 -12
- package/umd/Core/Interfaces/IPlugin.js +0 -12
- package/umd/Core/Interfaces/IPositionFromSizeParams.js +0 -12
- package/umd/Core/Interfaces/IRangeValue.js +0 -12
- package/umd/Core/Interfaces/IShapeDrawData.js +0 -12
- package/umd/Core/Interfaces/IShapeDrawer.js +0 -12
- package/umd/Core/Interfaces/IShapeValues.js +0 -12
- package/umd/Core/Interfaces/ISlowParticleData.js +0 -12
- package/umd/Core/Particle.js +0 -432
- package/umd/Core/Particles.js +0 -407
- package/umd/Core/Retina.js +0 -52
- package/umd/Core/Utils/Constants.js +0 -23
- package/umd/Core/Utils/EventListeners.js +0 -102
- package/umd/Core/Utils/Ranges.js +0 -91
- package/umd/Core/Utils/SpatialHashGrid.js +0 -116
- package/umd/Core/Utils/Vectors.js +0 -126
- package/umd/Enums/AnimationStatus.js +0 -18
- package/umd/Enums/Directions/MoveDirection.js +0 -27
- package/umd/Enums/Directions/OutModeDirection.js +0 -20
- package/umd/Enums/Directions/RotateDirection.js +0 -19
- package/umd/Enums/Modes/AnimationMode.js +0 -20
- package/umd/Enums/Modes/LimitMode.js +0 -18
- package/umd/Enums/Modes/OutMode.js +0 -21
- package/umd/Enums/Modes/PixelMode.js +0 -18
- package/umd/Enums/RangeType.js +0 -18
- package/umd/Enums/Types/AlterType.js +0 -18
- package/umd/Enums/Types/DestroyType.js +0 -19
- package/umd/Enums/Types/EasingType.js +0 -58
- package/umd/Enums/Types/EventType.js +0 -28
- package/umd/Enums/Types/GradientType.js +0 -19
- package/umd/Enums/Types/ParticleOutType.js +0 -19
- package/umd/Enums/Types/StartValueType.js +0 -19
- package/umd/Options/Classes/AnimatableColor.js +0 -52
- package/umd/Options/Classes/AnimationOptions.js +0 -79
- package/umd/Options/Classes/Background/Background.js +0 -56
- package/umd/Options/Classes/ColorAnimation.js +0 -44
- package/umd/Options/Classes/FullScreen/FullScreen.js +0 -34
- package/umd/Options/Classes/HslAnimation.js +0 -30
- package/umd/Options/Classes/Options.js +0 -171
- package/umd/Options/Classes/OptionsColor.js +0 -42
- package/umd/Options/Classes/Particles/Bounce/ParticlesBounce.js +0 -31
- package/umd/Options/Classes/Particles/Bounce/ParticlesBounceFactor.js +0 -21
- package/umd/Options/Classes/Particles/Effect/Effect.js +0 -46
- package/umd/Options/Classes/Particles/Fill.js +0 -42
- package/umd/Options/Classes/Particles/Move/Move.js +0 -120
- package/umd/Options/Classes/Particles/Move/MoveAngle.js +0 -35
- package/umd/Options/Classes/Particles/Move/MoveCenter.js +0 -45
- package/umd/Options/Classes/Particles/Move/MoveGravity.js +0 -45
- package/umd/Options/Classes/Particles/Move/OutModes.js +0 -38
- package/umd/Options/Classes/Particles/Move/Path/MovePath.js +0 -46
- package/umd/Options/Classes/Particles/Move/Spin.js +0 -40
- package/umd/Options/Classes/Particles/Number/ParticlesDensity.js +0 -41
- package/umd/Options/Classes/Particles/Number/ParticlesNumber.js +0 -37
- package/umd/Options/Classes/Particles/Number/ParticlesNumberLimit.js +0 -35
- package/umd/Options/Classes/Particles/Opacity/Opacity.js +0 -35
- package/umd/Options/Classes/Particles/Opacity/OpacityAnimation.js +0 -34
- package/umd/Options/Classes/Particles/ParticlesOptions.js +0 -116
- package/umd/Options/Classes/Particles/Shape/Shape.js +0 -46
- package/umd/Options/Classes/Particles/Size/Size.js +0 -35
- package/umd/Options/Classes/Particles/Size/SizeAnimation.js +0 -34
- package/umd/Options/Classes/Particles/Stroke.js +0 -39
- package/umd/Options/Classes/Particles/ZIndex/ZIndex.js +0 -42
- package/umd/Options/Classes/ResizeEvent.js +0 -34
- package/umd/Options/Classes/ValueWithRandom.js +0 -56
- package/umd/Options/Interfaces/Background/IBackground.js +0 -12
- package/umd/Options/Interfaces/FullScreen/IFullScreen.js +0 -12
- package/umd/Options/Interfaces/IAnimatable.js +0 -12
- package/umd/Options/Interfaces/IAnimatableColor.js +0 -12
- package/umd/Options/Interfaces/IAnimation.js +0 -12
- package/umd/Options/Interfaces/IColorAnimation.js +0 -12
- package/umd/Options/Interfaces/IHslAnimation.js +0 -12
- package/umd/Options/Interfaces/IOptionLoader.js +0 -12
- package/umd/Options/Interfaces/IOptions.js +0 -12
- package/umd/Options/Interfaces/IOptionsColor.js +0 -12
- package/umd/Options/Interfaces/IResizeEvent.js +0 -12
- package/umd/Options/Interfaces/IValueWithRandom.js +0 -12
- package/umd/Options/Interfaces/Particles/Bounce/IParticlesBounce.js +0 -12
- package/umd/Options/Interfaces/Particles/Effect/IEffect.js +0 -12
- package/umd/Options/Interfaces/Particles/IFill.js +0 -12
- package/umd/Options/Interfaces/Particles/IParticlesOptions.js +0 -12
- package/umd/Options/Interfaces/Particles/IStroke.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/IMove.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/IMoveAngle.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/IMoveCenter.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/IMoveGravity.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/IOutModes.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/ISpin.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/Path/IMovePath.js +0 -12
- package/umd/Options/Interfaces/Particles/Number/IParticlesDensity.js +0 -12
- package/umd/Options/Interfaces/Particles/Number/IParticlesNumber.js +0 -12
- package/umd/Options/Interfaces/Particles/Number/IParticlesNumberLimit.js +0 -12
- package/umd/Options/Interfaces/Particles/Opacity/IOpacity.js +0 -12
- package/umd/Options/Interfaces/Particles/Opacity/IOpacityAnimation.js +0 -12
- package/umd/Options/Interfaces/Particles/Shape/IShape.js +0 -12
- package/umd/Options/Interfaces/Particles/Size/ISize.js +0 -12
- package/umd/Options/Interfaces/Particles/Size/ISizeAnimation.js +0 -12
- package/umd/Options/Interfaces/Particles/ZIndex/IZIndex.js +0 -12
- package/umd/Types/CustomEventArgs.js +0 -12
- package/umd/Types/CustomEventListener.js +0 -12
- package/umd/Types/EasingFunction.js +0 -12
- package/umd/Types/EngineInitializers.js +0 -12
- package/umd/Types/ExportResult.js +0 -12
- package/umd/Types/ISourceOptions.js +0 -12
- package/umd/Types/ParticlesGroups.js +0 -12
- package/umd/Types/PathOptions.js +0 -12
- package/umd/Types/RangeValue.js +0 -12
- package/umd/Types/RecursivePartial.js +0 -12
- package/umd/Types/ShapeData.js +0 -12
- package/umd/Types/SingleOrMultiple.js +0 -12
- package/umd/Utils/CanvasUtils.js +0 -145
- package/umd/Utils/ColorUtils.js +0 -395
- package/umd/Utils/EventDispatcher.js +0 -63
- package/umd/Utils/LogUtils.js +0 -36
- package/umd/Utils/MathUtils.js +0 -203
- package/umd/Utils/OptionsUtils.js +0 -25
- package/umd/Utils/TypeUtils.js +0 -40
- package/umd/Utils/Utils.js +0 -484
- package/umd/bundle.js +0 -32
- package/umd/export-types.js +0 -12
- package/umd/exports.js +0 -82
- package/umd/index.js +0 -32
- package/umd/initEngine.js +0 -17
package/umd/Core/Container.js
DELETED
|
@@ -1,356 +0,0 @@
|
|
|
1
|
-
(function (factory) {
|
|
2
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
-
var v = factory(require, exports);
|
|
4
|
-
if (v !== undefined) module.exports = v;
|
|
5
|
-
}
|
|
6
|
-
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "../Utils/MathUtils.js", "./Utils/Constants.js", "./Canvas.js", "./Utils/EventListeners.js", "../Enums/Types/EventType.js", "../Options/Classes/Options.js", "./Particles.js", "./Retina.js", "../Utils/LogUtils.js", "../Utils/OptionsUtils.js"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Container = void 0;
|
|
13
|
-
const MathUtils_js_1 = require("../Utils/MathUtils.js");
|
|
14
|
-
const Constants_js_1 = require("./Utils/Constants.js");
|
|
15
|
-
const Canvas_js_1 = require("./Canvas.js");
|
|
16
|
-
const EventListeners_js_1 = require("./Utils/EventListeners.js");
|
|
17
|
-
const EventType_js_1 = require("../Enums/Types/EventType.js");
|
|
18
|
-
const Options_js_1 = require("../Options/Classes/Options.js");
|
|
19
|
-
const Particles_js_1 = require("./Particles.js");
|
|
20
|
-
const Retina_js_1 = require("./Retina.js");
|
|
21
|
-
const LogUtils_js_1 = require("../Utils/LogUtils.js");
|
|
22
|
-
const OptionsUtils_js_1 = require("../Utils/OptionsUtils.js");
|
|
23
|
-
function guardCheck(container) {
|
|
24
|
-
return !container.destroyed;
|
|
25
|
-
}
|
|
26
|
-
function updateDelta(delta, value, fpsLimit = Constants_js_1.defaultFps, smooth = false) {
|
|
27
|
-
delta.value = value;
|
|
28
|
-
delta.factor = smooth ? Constants_js_1.defaultFps / fpsLimit : (Constants_js_1.defaultFps * value) / Constants_js_1.millisecondsToSeconds;
|
|
29
|
-
}
|
|
30
|
-
function loadContainerOptions(engine, container, ...sourceOptionsArr) {
|
|
31
|
-
const options = new Options_js_1.Options(engine, container);
|
|
32
|
-
(0, OptionsUtils_js_1.loadOptions)(options, ...sourceOptionsArr);
|
|
33
|
-
return options;
|
|
34
|
-
}
|
|
35
|
-
class Container {
|
|
36
|
-
actualOptions;
|
|
37
|
-
canvas;
|
|
38
|
-
destroyed;
|
|
39
|
-
fpsLimit;
|
|
40
|
-
hdr;
|
|
41
|
-
id;
|
|
42
|
-
pageHidden;
|
|
43
|
-
particleCreatedPlugins;
|
|
44
|
-
particleDestroyedPlugins;
|
|
45
|
-
particlePositionPlugins;
|
|
46
|
-
particles;
|
|
47
|
-
plugins;
|
|
48
|
-
retina;
|
|
49
|
-
started;
|
|
50
|
-
zLayers;
|
|
51
|
-
_delay;
|
|
52
|
-
_delayTimeout;
|
|
53
|
-
_delta = { value: 0, factor: 0 };
|
|
54
|
-
_drawAnimationFrame;
|
|
55
|
-
_duration;
|
|
56
|
-
_engine;
|
|
57
|
-
_eventListeners;
|
|
58
|
-
_firstStart;
|
|
59
|
-
_initialSourceOptions;
|
|
60
|
-
_lastFrameTime;
|
|
61
|
-
_lifeTime;
|
|
62
|
-
_options;
|
|
63
|
-
_paused;
|
|
64
|
-
_smooth;
|
|
65
|
-
_sourceOptions;
|
|
66
|
-
constructor(engine, id, sourceOptions) {
|
|
67
|
-
this._engine = engine;
|
|
68
|
-
this.id = Symbol(id);
|
|
69
|
-
this.fpsLimit = 120;
|
|
70
|
-
this.hdr = false;
|
|
71
|
-
this._smooth = false;
|
|
72
|
-
this._delay = 0;
|
|
73
|
-
this._duration = 0;
|
|
74
|
-
this._lifeTime = 0;
|
|
75
|
-
this._firstStart = true;
|
|
76
|
-
this.started = false;
|
|
77
|
-
this.destroyed = false;
|
|
78
|
-
this._paused = true;
|
|
79
|
-
this._lastFrameTime = 0;
|
|
80
|
-
this.zLayers = 100;
|
|
81
|
-
this.pageHidden = false;
|
|
82
|
-
this._sourceOptions = sourceOptions;
|
|
83
|
-
this._initialSourceOptions = sourceOptions;
|
|
84
|
-
this.retina = new Retina_js_1.Retina(this);
|
|
85
|
-
this.canvas = new Canvas_js_1.Canvas(this, this._engine);
|
|
86
|
-
this.particles = new Particles_js_1.Particles(this._engine, this);
|
|
87
|
-
this.plugins = [];
|
|
88
|
-
this.particleDestroyedPlugins = [];
|
|
89
|
-
this.particleCreatedPlugins = [];
|
|
90
|
-
this.particlePositionPlugins = [];
|
|
91
|
-
this._options = loadContainerOptions(this._engine, this);
|
|
92
|
-
this.actualOptions = loadContainerOptions(this._engine, this);
|
|
93
|
-
this._eventListeners = new EventListeners_js_1.EventListeners(this);
|
|
94
|
-
this._engine.dispatchEvent(EventType_js_1.EventType.containerBuilt, { container: this });
|
|
95
|
-
}
|
|
96
|
-
get animationStatus() {
|
|
97
|
-
return !this._paused && !this.pageHidden && guardCheck(this);
|
|
98
|
-
}
|
|
99
|
-
get options() {
|
|
100
|
-
return this._options;
|
|
101
|
-
}
|
|
102
|
-
get sourceOptions() {
|
|
103
|
-
return this._sourceOptions;
|
|
104
|
-
}
|
|
105
|
-
addLifeTime(value) {
|
|
106
|
-
this._lifeTime += value;
|
|
107
|
-
}
|
|
108
|
-
alive() {
|
|
109
|
-
return !this._duration || this._lifeTime <= this._duration;
|
|
110
|
-
}
|
|
111
|
-
destroy(remove = true) {
|
|
112
|
-
if (!guardCheck(this)) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
this.stop();
|
|
116
|
-
this.particles.destroy();
|
|
117
|
-
this.canvas.destroy();
|
|
118
|
-
for (const plugin of this.plugins) {
|
|
119
|
-
plugin.destroy?.();
|
|
120
|
-
}
|
|
121
|
-
this.plugins.length = 0;
|
|
122
|
-
this._engine.clearPlugins(this);
|
|
123
|
-
this.destroyed = true;
|
|
124
|
-
if (remove) {
|
|
125
|
-
const mainArr = this._engine.items, idx = mainArr.indexOf(this);
|
|
126
|
-
if (idx >= Constants_js_1.removeMinIndex) {
|
|
127
|
-
mainArr.splice(idx, Constants_js_1.removeDeleteCount);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
this._engine.dispatchEvent(EventType_js_1.EventType.containerDestroyed, { container: this });
|
|
131
|
-
}
|
|
132
|
-
draw(force) {
|
|
133
|
-
if (!guardCheck(this)) {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
let refreshTime = force;
|
|
137
|
-
this._drawAnimationFrame = (0, MathUtils_js_1.animate)((timestamp) => {
|
|
138
|
-
if (refreshTime) {
|
|
139
|
-
this._lastFrameTime = undefined;
|
|
140
|
-
refreshTime = false;
|
|
141
|
-
}
|
|
142
|
-
this._nextFrame(timestamp);
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
async export(type, options = {}) {
|
|
146
|
-
for (const plugin of this.plugins) {
|
|
147
|
-
if (!plugin.export) {
|
|
148
|
-
continue;
|
|
149
|
-
}
|
|
150
|
-
const res = await plugin.export(type, options);
|
|
151
|
-
if (!res.supported) {
|
|
152
|
-
continue;
|
|
153
|
-
}
|
|
154
|
-
return res.blob;
|
|
155
|
-
}
|
|
156
|
-
(0, LogUtils_js_1.getLogger)().error(`Export plugin with type ${type} not found`);
|
|
157
|
-
return undefined;
|
|
158
|
-
}
|
|
159
|
-
async init() {
|
|
160
|
-
if (!guardCheck(this)) {
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
const allContainerPlugins = new Map();
|
|
164
|
-
for (const plugin of this._engine.plugins) {
|
|
165
|
-
const containerPlugin = await plugin.getPlugin(this);
|
|
166
|
-
if (containerPlugin.preInit) {
|
|
167
|
-
await containerPlugin.preInit();
|
|
168
|
-
}
|
|
169
|
-
allContainerPlugins.set(plugin, containerPlugin);
|
|
170
|
-
}
|
|
171
|
-
await this.particles.initPlugins();
|
|
172
|
-
this._options = loadContainerOptions(this._engine, this, this._initialSourceOptions, this.sourceOptions);
|
|
173
|
-
this.actualOptions = loadContainerOptions(this._engine, this, this._options);
|
|
174
|
-
this.plugins.length = 0;
|
|
175
|
-
this.particleDestroyedPlugins.length = 0;
|
|
176
|
-
this.particleCreatedPlugins.length = 0;
|
|
177
|
-
this.particlePositionPlugins.length = 0;
|
|
178
|
-
for (const [plugin, containerPlugin] of allContainerPlugins) {
|
|
179
|
-
if (plugin.needsPlugin(this.actualOptions)) {
|
|
180
|
-
this.plugins.push(containerPlugin);
|
|
181
|
-
if (containerPlugin.particleCreated) {
|
|
182
|
-
this.particleCreatedPlugins.push(containerPlugin);
|
|
183
|
-
}
|
|
184
|
-
if (containerPlugin.particleDestroyed) {
|
|
185
|
-
this.particleDestroyedPlugins.push(containerPlugin);
|
|
186
|
-
}
|
|
187
|
-
if (containerPlugin.particlePosition) {
|
|
188
|
-
this.particlePositionPlugins.push(containerPlugin);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
this.retina.init();
|
|
193
|
-
this.canvas.init();
|
|
194
|
-
this.updateActualOptions();
|
|
195
|
-
this.canvas.initBackground();
|
|
196
|
-
this.canvas.resize();
|
|
197
|
-
const { delay, duration, fpsLimit, hdr, smooth, zLayers } = this.actualOptions;
|
|
198
|
-
this.hdr = hdr;
|
|
199
|
-
this.zLayers = zLayers;
|
|
200
|
-
this._duration = (0, MathUtils_js_1.getRangeValue)(duration) * Constants_js_1.millisecondsToSeconds;
|
|
201
|
-
this._delay = (0, MathUtils_js_1.getRangeValue)(delay) * Constants_js_1.millisecondsToSeconds;
|
|
202
|
-
this._lifeTime = 0;
|
|
203
|
-
this.fpsLimit = fpsLimit > Constants_js_1.minFpsLimit ? fpsLimit : Constants_js_1.defaultFpsLimit;
|
|
204
|
-
this._smooth = smooth;
|
|
205
|
-
for (const plugin of this.plugins) {
|
|
206
|
-
await plugin.init?.();
|
|
207
|
-
}
|
|
208
|
-
await this.particles.init();
|
|
209
|
-
this._engine.dispatchEvent(EventType_js_1.EventType.containerInit, { container: this });
|
|
210
|
-
this.particles.setDensity();
|
|
211
|
-
for (const plugin of this.plugins) {
|
|
212
|
-
plugin.particlesSetup?.();
|
|
213
|
-
}
|
|
214
|
-
this._engine.dispatchEvent(EventType_js_1.EventType.particlesSetup, { container: this });
|
|
215
|
-
}
|
|
216
|
-
pause() {
|
|
217
|
-
if (!guardCheck(this)) {
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
if (this._drawAnimationFrame !== undefined) {
|
|
221
|
-
(0, MathUtils_js_1.cancelAnimation)(this._drawAnimationFrame);
|
|
222
|
-
delete this._drawAnimationFrame;
|
|
223
|
-
}
|
|
224
|
-
if (this._paused) {
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
for (const plugin of this.plugins) {
|
|
228
|
-
plugin.pause?.();
|
|
229
|
-
}
|
|
230
|
-
if (!this.pageHidden) {
|
|
231
|
-
this._paused = true;
|
|
232
|
-
}
|
|
233
|
-
this._engine.dispatchEvent(EventType_js_1.EventType.containerPaused, { container: this });
|
|
234
|
-
}
|
|
235
|
-
play(force) {
|
|
236
|
-
if (!guardCheck(this)) {
|
|
237
|
-
return;
|
|
238
|
-
}
|
|
239
|
-
const needsUpdate = this._paused || force;
|
|
240
|
-
if (this._firstStart && !this.actualOptions.autoPlay) {
|
|
241
|
-
this._firstStart = false;
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
244
|
-
if (this._paused) {
|
|
245
|
-
this._paused = false;
|
|
246
|
-
}
|
|
247
|
-
if (needsUpdate) {
|
|
248
|
-
for (const plugin of this.plugins) {
|
|
249
|
-
if (plugin.play) {
|
|
250
|
-
plugin.play();
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
this._engine.dispatchEvent(EventType_js_1.EventType.containerPlay, { container: this });
|
|
255
|
-
this.draw(needsUpdate ?? false);
|
|
256
|
-
}
|
|
257
|
-
async refresh() {
|
|
258
|
-
if (!guardCheck(this)) {
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
this.stop();
|
|
262
|
-
return this.start();
|
|
263
|
-
}
|
|
264
|
-
async reset(sourceOptions) {
|
|
265
|
-
if (!guardCheck(this)) {
|
|
266
|
-
return;
|
|
267
|
-
}
|
|
268
|
-
this._initialSourceOptions = sourceOptions;
|
|
269
|
-
this._sourceOptions = sourceOptions;
|
|
270
|
-
this._options = loadContainerOptions(this._engine, this, this._initialSourceOptions, this.sourceOptions);
|
|
271
|
-
this.actualOptions = loadContainerOptions(this._engine, this, this._options);
|
|
272
|
-
return this.refresh();
|
|
273
|
-
}
|
|
274
|
-
async start() {
|
|
275
|
-
if (!guardCheck(this) || this.started) {
|
|
276
|
-
return;
|
|
277
|
-
}
|
|
278
|
-
await this.init();
|
|
279
|
-
this.started = true;
|
|
280
|
-
await new Promise(resolve => {
|
|
281
|
-
const start = async () => {
|
|
282
|
-
this._eventListeners.addListeners();
|
|
283
|
-
for (const plugin of this.plugins) {
|
|
284
|
-
await plugin.start?.();
|
|
285
|
-
}
|
|
286
|
-
this._engine.dispatchEvent(EventType_js_1.EventType.containerStarted, { container: this });
|
|
287
|
-
this.play();
|
|
288
|
-
resolve();
|
|
289
|
-
};
|
|
290
|
-
this._delayTimeout = setTimeout(() => void start(), this._delay);
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
stop() {
|
|
294
|
-
if (!guardCheck(this) || !this.started) {
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
297
|
-
if (this._delayTimeout) {
|
|
298
|
-
clearTimeout(this._delayTimeout);
|
|
299
|
-
delete this._delayTimeout;
|
|
300
|
-
}
|
|
301
|
-
this._firstStart = true;
|
|
302
|
-
this.started = false;
|
|
303
|
-
this._eventListeners.removeListeners();
|
|
304
|
-
this.pause();
|
|
305
|
-
this.particles.clear();
|
|
306
|
-
this.canvas.stop();
|
|
307
|
-
for (const plugin of this.plugins) {
|
|
308
|
-
plugin.stop?.();
|
|
309
|
-
}
|
|
310
|
-
this.particleCreatedPlugins.length = 0;
|
|
311
|
-
this.particleDestroyedPlugins.length = 0;
|
|
312
|
-
this.particlePositionPlugins.length = 0;
|
|
313
|
-
this._sourceOptions = this._options;
|
|
314
|
-
this._engine.dispatchEvent(EventType_js_1.EventType.containerStopped, { container: this });
|
|
315
|
-
}
|
|
316
|
-
updateActualOptions() {
|
|
317
|
-
let refresh = false;
|
|
318
|
-
for (const plugin of this.plugins) {
|
|
319
|
-
if (plugin.updateActualOptions) {
|
|
320
|
-
refresh = plugin.updateActualOptions() || refresh;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
return refresh;
|
|
324
|
-
}
|
|
325
|
-
_nextFrame = (timestamp) => {
|
|
326
|
-
try {
|
|
327
|
-
if (!this._smooth &&
|
|
328
|
-
this._lastFrameTime !== undefined &&
|
|
329
|
-
timestamp < this._lastFrameTime + Constants_js_1.millisecondsToSeconds / this.fpsLimit) {
|
|
330
|
-
this.draw(false);
|
|
331
|
-
return;
|
|
332
|
-
}
|
|
333
|
-
this._lastFrameTime ??= timestamp;
|
|
334
|
-
updateDelta(this._delta, timestamp - this._lastFrameTime, this.fpsLimit, this._smooth);
|
|
335
|
-
this.addLifeTime(this._delta.value);
|
|
336
|
-
this._lastFrameTime = timestamp;
|
|
337
|
-
if (this._delta.value > Constants_js_1.millisecondsToSeconds) {
|
|
338
|
-
this.draw(false);
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
|
-
this.canvas.drawParticles(this._delta);
|
|
342
|
-
if (!this.alive()) {
|
|
343
|
-
this.destroy();
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
if (this.animationStatus) {
|
|
347
|
-
this.draw(false);
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
catch (e) {
|
|
351
|
-
(0, LogUtils_js_1.getLogger)().error("error in animation loop", e);
|
|
352
|
-
}
|
|
353
|
-
};
|
|
354
|
-
}
|
|
355
|
-
exports.Container = Container;
|
|
356
|
-
});
|
package/umd/Core/Engine.js
DELETED
|
@@ -1,295 +0,0 @@
|
|
|
1
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2
|
-
if (k2 === undefined) k2 = k;
|
|
3
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
5
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
6
|
-
}
|
|
7
|
-
Object.defineProperty(o, k2, desc);
|
|
8
|
-
}) : (function(o, m, k, k2) {
|
|
9
|
-
if (k2 === undefined) k2 = k;
|
|
10
|
-
o[k2] = m[k];
|
|
11
|
-
}));
|
|
12
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
13
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
14
|
-
}) : function(o, v) {
|
|
15
|
-
o["default"] = v;
|
|
16
|
-
});
|
|
17
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
18
|
-
var ownKeys = function(o) {
|
|
19
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
20
|
-
var ar = [];
|
|
21
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
22
|
-
return ar;
|
|
23
|
-
};
|
|
24
|
-
return ownKeys(o);
|
|
25
|
-
};
|
|
26
|
-
return function (mod) {
|
|
27
|
-
if (mod && mod.__esModule) return mod;
|
|
28
|
-
var result = {};
|
|
29
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
30
|
-
__setModuleDefault(result, mod);
|
|
31
|
-
return result;
|
|
32
|
-
};
|
|
33
|
-
})();
|
|
34
|
-
(function (factory) {
|
|
35
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
36
|
-
var v = factory(require, exports);
|
|
37
|
-
if (v !== undefined) module.exports = v;
|
|
38
|
-
}
|
|
39
|
-
else if (typeof define === "function" && define.amd) {
|
|
40
|
-
define(["require", "exports", "./Utils/Constants.js", "../Utils/Utils.js", "../Utils/EventDispatcher.js", "../Enums/Types/EventType.js", "../Utils/LogUtils.js", "../Utils/MathUtils.js"], factory);
|
|
41
|
-
}
|
|
42
|
-
})(function (require, exports) {
|
|
43
|
-
"use strict";
|
|
44
|
-
var __syncRequire = typeof module === "object" && typeof module.exports === "object";
|
|
45
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
-
exports.Engine = void 0;
|
|
47
|
-
const Constants_js_1 = require("./Utils/Constants.js");
|
|
48
|
-
const Utils_js_1 = require("../Utils/Utils.js");
|
|
49
|
-
const EventDispatcher_js_1 = require("../Utils/EventDispatcher.js");
|
|
50
|
-
const EventType_js_1 = require("../Enums/Types/EventType.js");
|
|
51
|
-
const LogUtils_js_1 = require("../Utils/LogUtils.js");
|
|
52
|
-
const MathUtils_js_1 = require("../Utils/MathUtils.js");
|
|
53
|
-
const fullPercent = "100%";
|
|
54
|
-
async function getDataFromUrl(data) {
|
|
55
|
-
const url = (0, Utils_js_1.itemFromSingleOrMultiple)(data.url, data.index);
|
|
56
|
-
if (!url) {
|
|
57
|
-
return data.fallback;
|
|
58
|
-
}
|
|
59
|
-
const response = await fetch(url);
|
|
60
|
-
if (response.ok) {
|
|
61
|
-
return (await response.json());
|
|
62
|
-
}
|
|
63
|
-
(0, LogUtils_js_1.getLogger)().error(`${response.status.toString()} while retrieving config file`);
|
|
64
|
-
return data.fallback;
|
|
65
|
-
}
|
|
66
|
-
const getCanvasFromContainer = (domContainer) => {
|
|
67
|
-
const documentSafe = (0, Utils_js_1.safeDocument)();
|
|
68
|
-
let canvasEl;
|
|
69
|
-
if (domContainer instanceof HTMLCanvasElement || domContainer.tagName.toLowerCase() === Constants_js_1.canvasTag) {
|
|
70
|
-
canvasEl = domContainer;
|
|
71
|
-
canvasEl.dataset[Constants_js_1.generatedAttribute] ??= Constants_js_1.generatedFalse;
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
const existingCanvases = domContainer.getElementsByTagName(Constants_js_1.canvasTag), foundCanvas = existingCanvases[Constants_js_1.canvasFirstIndex];
|
|
75
|
-
if (foundCanvas) {
|
|
76
|
-
canvasEl = foundCanvas;
|
|
77
|
-
canvasEl.dataset[Constants_js_1.generatedAttribute] = Constants_js_1.generatedFalse;
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
canvasEl = documentSafe.createElement(Constants_js_1.canvasTag);
|
|
81
|
-
canvasEl.dataset[Constants_js_1.generatedAttribute] = Constants_js_1.generatedTrue;
|
|
82
|
-
domContainer.appendChild(canvasEl);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
canvasEl.style.width ||= fullPercent;
|
|
86
|
-
canvasEl.style.height ||= fullPercent;
|
|
87
|
-
return canvasEl;
|
|
88
|
-
}, getDomContainer = (id, source) => {
|
|
89
|
-
const documentSafe = (0, Utils_js_1.safeDocument)();
|
|
90
|
-
let domContainer = source ?? documentSafe.getElementById(id);
|
|
91
|
-
if (domContainer) {
|
|
92
|
-
return domContainer;
|
|
93
|
-
}
|
|
94
|
-
domContainer = documentSafe.createElement("div");
|
|
95
|
-
domContainer.id = id;
|
|
96
|
-
domContainer.dataset[Constants_js_1.generatedAttribute] = Constants_js_1.generatedTrue;
|
|
97
|
-
documentSafe.body.append(domContainer);
|
|
98
|
-
return domContainer;
|
|
99
|
-
};
|
|
100
|
-
class Engine {
|
|
101
|
-
colorManagers = new Map();
|
|
102
|
-
easingFunctions = new Map();
|
|
103
|
-
effectDrawers = new Map();
|
|
104
|
-
initializers = {
|
|
105
|
-
effects: new Map(),
|
|
106
|
-
shapes: new Map(),
|
|
107
|
-
updaters: new Map(),
|
|
108
|
-
};
|
|
109
|
-
palettes = new Map();
|
|
110
|
-
plugins = [];
|
|
111
|
-
presets = new Map();
|
|
112
|
-
shapeDrawers = new Map();
|
|
113
|
-
updaters = new Map();
|
|
114
|
-
_allLoadersSet = new Set();
|
|
115
|
-
_configs = new Map();
|
|
116
|
-
_domArray = [];
|
|
117
|
-
_eventDispatcher = new EventDispatcher_js_1.EventDispatcher();
|
|
118
|
-
_executedSet = new Set();
|
|
119
|
-
_initialized = false;
|
|
120
|
-
_isRunningLoaders = false;
|
|
121
|
-
_loadPromises = new Set();
|
|
122
|
-
get configs() {
|
|
123
|
-
const res = {};
|
|
124
|
-
for (const [name, config] of this._configs) {
|
|
125
|
-
res[name] = config;
|
|
126
|
-
}
|
|
127
|
-
return res;
|
|
128
|
-
}
|
|
129
|
-
get items() {
|
|
130
|
-
return this._domArray;
|
|
131
|
-
}
|
|
132
|
-
get version() {
|
|
133
|
-
return "4.0.0-beta.0";
|
|
134
|
-
}
|
|
135
|
-
addColorManager(name, manager) {
|
|
136
|
-
this.colorManagers.set(name, manager);
|
|
137
|
-
}
|
|
138
|
-
addConfig(config) {
|
|
139
|
-
const key = config.key ?? config.name ?? "default";
|
|
140
|
-
this._configs.set(key, config);
|
|
141
|
-
this._eventDispatcher.dispatchEvent(EventType_js_1.EventType.configAdded, { data: { name: key, config } });
|
|
142
|
-
}
|
|
143
|
-
addEasing(name, easing) {
|
|
144
|
-
if (this.easingFunctions.get(name)) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
this.easingFunctions.set(name, easing);
|
|
148
|
-
}
|
|
149
|
-
addEffect(effect, drawer) {
|
|
150
|
-
this.initializers.effects.set(effect, drawer);
|
|
151
|
-
}
|
|
152
|
-
addEventListener(type, listener) {
|
|
153
|
-
this._eventDispatcher.addEventListener(type, listener);
|
|
154
|
-
}
|
|
155
|
-
addPalette(name, palette) {
|
|
156
|
-
this.palettes.set(name, palette);
|
|
157
|
-
}
|
|
158
|
-
addParticleUpdater(name, updaterInitializer) {
|
|
159
|
-
this.initializers.updaters.set(name, updaterInitializer);
|
|
160
|
-
}
|
|
161
|
-
addPlugin(plugin) {
|
|
162
|
-
if (this.getPlugin(plugin.id)) {
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
this.plugins.push(plugin);
|
|
166
|
-
}
|
|
167
|
-
addPreset(preset, options, override = false) {
|
|
168
|
-
if (!(override || !this.getPreset(preset))) {
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
this.presets.set(preset, options);
|
|
172
|
-
}
|
|
173
|
-
addShape(shapes, drawer) {
|
|
174
|
-
for (const shape of shapes) {
|
|
175
|
-
this.initializers.shapes.set(shape, drawer);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
checkVersion(pluginVersion) {
|
|
179
|
-
if (this.version === pluginVersion) {
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
throw new Error(`The tsParticles version is different from the loaded plugins version. Engine version: ${this.version}. Plugin version: ${pluginVersion}`);
|
|
183
|
-
}
|
|
184
|
-
clearPlugins(container) {
|
|
185
|
-
this.effectDrawers.delete(container);
|
|
186
|
-
this.shapeDrawers.delete(container);
|
|
187
|
-
this.updaters.delete(container);
|
|
188
|
-
}
|
|
189
|
-
dispatchEvent(type, args) {
|
|
190
|
-
this._eventDispatcher.dispatchEvent(type, args);
|
|
191
|
-
}
|
|
192
|
-
getEasing(name) {
|
|
193
|
-
return this.easingFunctions.get(name) ?? ((value) => value);
|
|
194
|
-
}
|
|
195
|
-
getEffectDrawers(container, force = false) {
|
|
196
|
-
return (0, Utils_js_1.getItemMapFromInitializer)(container, this.effectDrawers, this.initializers.effects, force);
|
|
197
|
-
}
|
|
198
|
-
getPalette(name) {
|
|
199
|
-
return this.palettes.get(name);
|
|
200
|
-
}
|
|
201
|
-
getPlugin(plugin) {
|
|
202
|
-
return this.plugins.find(t => t.id === plugin);
|
|
203
|
-
}
|
|
204
|
-
getPreset(preset) {
|
|
205
|
-
return this.presets.get(preset);
|
|
206
|
-
}
|
|
207
|
-
async getShapeDrawers(container, force = false) {
|
|
208
|
-
return (0, Utils_js_1.getItemMapFromInitializer)(container, this.shapeDrawers, this.initializers.shapes, force);
|
|
209
|
-
}
|
|
210
|
-
async getUpdaters(container, force = false) {
|
|
211
|
-
return (0, Utils_js_1.getItemsFromInitializer)(container, this.updaters, this.initializers.updaters, force);
|
|
212
|
-
}
|
|
213
|
-
async init() {
|
|
214
|
-
if (this._initialized || this._isRunningLoaders) {
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
this._isRunningLoaders = true;
|
|
218
|
-
this._executedSet = new Set();
|
|
219
|
-
this._allLoadersSet = new Set(this._loadPromises);
|
|
220
|
-
try {
|
|
221
|
-
for (const loader of this._allLoadersSet) {
|
|
222
|
-
await this._runLoader(loader, this._executedSet, this._allLoadersSet);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
finally {
|
|
226
|
-
this._loadPromises.clear();
|
|
227
|
-
this._isRunningLoaders = false;
|
|
228
|
-
this._initialized = true;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
item(index) {
|
|
232
|
-
const { items } = this, item = items[index];
|
|
233
|
-
if (item?.destroyed) {
|
|
234
|
-
items.splice(index, Constants_js_1.removeDeleteCount);
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
return item;
|
|
238
|
-
}
|
|
239
|
-
async load(params) {
|
|
240
|
-
await this.init();
|
|
241
|
-
const { Container } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./Container.js"))) : new Promise((resolve_1, reject_1) => { require(["./Container.js"], resolve_1, reject_1); }).then(__importStar)), id = params.id ?? params.element?.id ?? `tsparticles${Math.floor((0, MathUtils_js_1.getRandom)() * Constants_js_1.loadRandomFactor).toString()}`, { index, url } = params, options = url ? await getDataFromUrl({ fallback: params.options, url, index }) : params.options, currentOptions = (0, Utils_js_1.itemFromSingleOrMultiple)(options, index), { items } = this, oldIndex = items.findIndex(v => v.id.description === id), newItem = new Container(this, id, currentOptions);
|
|
242
|
-
if (oldIndex >= Constants_js_1.loadMinIndex) {
|
|
243
|
-
const old = this.item(oldIndex), deleteCount = old ? Constants_js_1.one : Constants_js_1.none;
|
|
244
|
-
if (old && !old.destroyed) {
|
|
245
|
-
old.destroy(false);
|
|
246
|
-
}
|
|
247
|
-
items.splice(oldIndex, deleteCount, newItem);
|
|
248
|
-
}
|
|
249
|
-
else {
|
|
250
|
-
items.push(newItem);
|
|
251
|
-
}
|
|
252
|
-
const domContainer = getDomContainer(id, params.element), canvasEl = getCanvasFromContainer(domContainer);
|
|
253
|
-
newItem.canvas.loadCanvas(canvasEl);
|
|
254
|
-
await newItem.start();
|
|
255
|
-
return newItem;
|
|
256
|
-
}
|
|
257
|
-
loadParticlesOptions(container, options, ...sourceOptions) {
|
|
258
|
-
const updaters = this.updaters.get(container);
|
|
259
|
-
if (!updaters) {
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
updaters.forEach(updater => updater.loadOptions?.(options, ...sourceOptions));
|
|
263
|
-
}
|
|
264
|
-
async refresh(refresh = true) {
|
|
265
|
-
if (!refresh) {
|
|
266
|
-
return;
|
|
267
|
-
}
|
|
268
|
-
await Promise.all(this.items.map(t => t.refresh()));
|
|
269
|
-
}
|
|
270
|
-
async register(...loaders) {
|
|
271
|
-
if (this._initialized) {
|
|
272
|
-
throw new Error("Register plugins can only be done before calling tsParticles.load()");
|
|
273
|
-
}
|
|
274
|
-
for (const loader of loaders) {
|
|
275
|
-
if (this._isRunningLoaders) {
|
|
276
|
-
await this._runLoader(loader, this._executedSet, this._allLoadersSet);
|
|
277
|
-
}
|
|
278
|
-
else {
|
|
279
|
-
this._loadPromises.add(loader);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
removeEventListener(type, listener) {
|
|
284
|
-
this._eventDispatcher.removeEventListener(type, listener);
|
|
285
|
-
}
|
|
286
|
-
async _runLoader(loader, executed, allLoaders) {
|
|
287
|
-
if (executed.has(loader))
|
|
288
|
-
return;
|
|
289
|
-
executed.add(loader);
|
|
290
|
-
allLoaders.add(loader);
|
|
291
|
-
await loader(this);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
exports.Engine = Engine;
|
|
295
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
(function (factory) {
|
|
2
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
-
var v = factory(require, exports);
|
|
4
|
-
if (v !== undefined) module.exports = v;
|
|
5
|
-
}
|
|
6
|
-
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
(function (factory) {
|
|
2
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
-
var v = factory(require, exports);
|
|
4
|
-
if (v !== undefined) module.exports = v;
|
|
5
|
-
}
|
|
6
|
-
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
(function (factory) {
|
|
2
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
-
var v = factory(require, exports);
|
|
4
|
-
if (v !== undefined) module.exports = v;
|
|
5
|
-
}
|
|
6
|
-
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
});
|