@tsparticles/stencil 4.0.5
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/LICENSE +21 -0
- package/README.md +73 -0
- package/dist/cjs/Container-DFed5jPA.js +3556 -0
- package/dist/cjs/app-globals-V2Kpy_OQ.js +5 -0
- package/dist/cjs/index-BY5-j3YK.js +1143 -0
- package/dist/cjs/index-Dwz1YgEM.js +1229 -0
- package/dist/cjs/index.cjs.js +9 -0
- package/dist/cjs/loader.cjs.js +13 -0
- package/dist/cjs/stencil-particles.cjs.entry.js +76 -0
- package/dist/cjs/tsparticlesstencil.cjs.js +25 -0
- package/dist/collection/collection-manifest.json +13 -0
- package/dist/collection/components/stencil-particles/stencil-particles.js +144 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/initParticlesEngine.js +38 -0
- package/dist/esm/Container-Di-pVL5B.js +3554 -0
- package/dist/esm/app-globals-DQuL1Twl.js +3 -0
- package/dist/esm/index-BzK79uqU.js +1223 -0
- package/dist/esm/index-CPcFDf6d.js +1052 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/loader.js +11 -0
- package/dist/esm/stencil-particles.entry.js +74 -0
- package/dist/esm/tsparticlesstencil.js +21 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/tsparticlesstencil/index.esm.js +1 -0
- package/dist/tsparticlesstencil/p-2a10755a.entry.js +1 -0
- package/dist/tsparticlesstencil/p-BzK79uqU.js +2 -0
- package/dist/tsparticlesstencil/p-C6McIuSD.js +1 -0
- package/dist/tsparticlesstencil/p-DQuL1Twl.js +1 -0
- package/dist/tsparticlesstencil/p-x9G6hxBi.js +1 -0
- package/dist/tsparticlesstencil/tsparticlesstencil.esm.js +1 -0
- package/dist/types/components/stencil-particles/stencil-particles.d.ts +16 -0
- package/dist/types/components.d.ts +52 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/initParticlesEngine.d.ts +5 -0
- package/dist/types/stencil-public-runtime.d.ts +1860 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/package.json +64 -0
|
@@ -0,0 +1,1143 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const generatedAttribute = "generated", defaultCompositeValue = "source-over", resizeEvent = "resize", visibilityChangeEvent = "visibilitychange", percentDenominator = 100, half = 0.5, millisecondsToSeconds = 1000, originPoint = {
|
|
4
|
+
x: 0,
|
|
5
|
+
y: 0,
|
|
6
|
+
z: 0,
|
|
7
|
+
}, defaultTransform = {
|
|
8
|
+
a: 1,
|
|
9
|
+
b: 0,
|
|
10
|
+
c: 0,
|
|
11
|
+
d: 1,
|
|
12
|
+
}, randomColorValue = "random", double = 2, doublePI = Math.PI * double, defaultFps = 60, generatedTrue = "true", generatedFalse = "false", canvasTag = "canvas", defaultRetryCount = 0, squareExp = 2, spatialHashGridCellSize = 100, defaultRemoveQuantity = 1, defaultRatio = 1, defaultReduceFactor = 1, inverseFactorNumerator = 1, rgbMax = 255, hMax = 360, sMax = 100, lMax = 100, hMin = 0, sMin = 0, hPhase = 60, empty = 0, quarter = 0.25, threeQuarter = half + quarter, defaultTransformValue = 1, minimumSize = 0, zIndexFactorOffset = 1, defaultOpacity = 1, removeDeleteCount = 1, removeMinIndex = 0, defaultFpsLimit = 120, minFpsLimit = 0, canvasFirstIndex = 0, loadRandomFactor = 10000, loadMinIndex = 0, one = 1, none = 0, tryCountIncrement = 1, minZ = 0, minLimit = 0, countOffset = 1, minCount = 0, minIndex = 0, defaultDensityFactor = 1, deleteCount = 1, defaultAngle = 0, identity = 1, minStrokeWidth = 0, lFactor = 1, lMin = 0, triple = 3, sextuple = 6, sNormalizedOffset = 1, phaseNumerator = 1, defaultRgbMin = 0, defaultZoom = 1;
|
|
13
|
+
|
|
14
|
+
exports.MoveDirection = void 0;
|
|
15
|
+
(function (MoveDirection) {
|
|
16
|
+
MoveDirection["bottom"] = "bottom";
|
|
17
|
+
MoveDirection["bottomLeft"] = "bottom-left";
|
|
18
|
+
MoveDirection["bottomRight"] = "bottom-right";
|
|
19
|
+
MoveDirection["left"] = "left";
|
|
20
|
+
MoveDirection["none"] = "none";
|
|
21
|
+
MoveDirection["right"] = "right";
|
|
22
|
+
MoveDirection["top"] = "top";
|
|
23
|
+
MoveDirection["topLeft"] = "top-left";
|
|
24
|
+
MoveDirection["topRight"] = "top-right";
|
|
25
|
+
MoveDirection["outside"] = "outside";
|
|
26
|
+
MoveDirection["inside"] = "inside";
|
|
27
|
+
})(exports.MoveDirection || (exports.MoveDirection = {}));
|
|
28
|
+
|
|
29
|
+
function getZ(source) {
|
|
30
|
+
return "z" in source ? source.z : originPoint.z;
|
|
31
|
+
}
|
|
32
|
+
class Vector3d {
|
|
33
|
+
x;
|
|
34
|
+
y;
|
|
35
|
+
z;
|
|
36
|
+
constructor(x = originPoint.x, y = originPoint.y, z = originPoint.z) {
|
|
37
|
+
this.x = x;
|
|
38
|
+
this.y = y;
|
|
39
|
+
this.z = z;
|
|
40
|
+
}
|
|
41
|
+
static get origin() {
|
|
42
|
+
return Vector3d.create(originPoint.x, originPoint.y, originPoint.z);
|
|
43
|
+
}
|
|
44
|
+
get angle() {
|
|
45
|
+
return Math.atan2(this.y, this.x);
|
|
46
|
+
}
|
|
47
|
+
set angle(angle) {
|
|
48
|
+
this.#updateFromAngle(angle, this.length);
|
|
49
|
+
}
|
|
50
|
+
get length() {
|
|
51
|
+
return Math.sqrt(this.getLengthSq());
|
|
52
|
+
}
|
|
53
|
+
set length(length) {
|
|
54
|
+
this.#updateFromAngle(this.angle, length);
|
|
55
|
+
}
|
|
56
|
+
static clone(source) {
|
|
57
|
+
return Vector3d.create(source.x, source.y, getZ(source));
|
|
58
|
+
}
|
|
59
|
+
static create(x, y, z) {
|
|
60
|
+
if (typeof x === "number") {
|
|
61
|
+
return new Vector3d(x, y ?? originPoint.y, z ?? originPoint.z);
|
|
62
|
+
}
|
|
63
|
+
return new Vector3d(x.x, x.y, getZ(x));
|
|
64
|
+
}
|
|
65
|
+
add(v) {
|
|
66
|
+
return Vector3d.create(this.x + v.x, this.y + v.y, this.z + getZ(v));
|
|
67
|
+
}
|
|
68
|
+
addTo(v) {
|
|
69
|
+
this.x += v.x;
|
|
70
|
+
this.y += v.y;
|
|
71
|
+
this.z += getZ(v);
|
|
72
|
+
}
|
|
73
|
+
copy() {
|
|
74
|
+
return Vector3d.clone(this);
|
|
75
|
+
}
|
|
76
|
+
div(n) {
|
|
77
|
+
return Vector3d.create(this.x / n, this.y / n, this.z / n);
|
|
78
|
+
}
|
|
79
|
+
divTo(n) {
|
|
80
|
+
this.x /= n;
|
|
81
|
+
this.y /= n;
|
|
82
|
+
this.z /= n;
|
|
83
|
+
}
|
|
84
|
+
getLengthSq() {
|
|
85
|
+
return this.x ** squareExp + this.y ** squareExp;
|
|
86
|
+
}
|
|
87
|
+
mult(n) {
|
|
88
|
+
return Vector3d.create(this.x * n, this.y * n, this.z * n);
|
|
89
|
+
}
|
|
90
|
+
multTo(n) {
|
|
91
|
+
this.x *= n;
|
|
92
|
+
this.y *= n;
|
|
93
|
+
this.z *= n;
|
|
94
|
+
}
|
|
95
|
+
normalize() {
|
|
96
|
+
const length = this.length;
|
|
97
|
+
if (length != none) {
|
|
98
|
+
this.multTo(inverseFactorNumerator / length);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
rotate(angle) {
|
|
102
|
+
return Vector3d.create(this.x * Math.cos(angle) - this.y * Math.sin(angle), this.x * Math.sin(angle) + this.y * Math.cos(angle), originPoint.z);
|
|
103
|
+
}
|
|
104
|
+
setTo(c) {
|
|
105
|
+
this.x = c.x;
|
|
106
|
+
this.y = c.y;
|
|
107
|
+
this.z = getZ(c);
|
|
108
|
+
}
|
|
109
|
+
sub(v) {
|
|
110
|
+
return Vector3d.create(this.x - v.x, this.y - v.y, this.z - getZ(v));
|
|
111
|
+
}
|
|
112
|
+
subFrom(v) {
|
|
113
|
+
this.x -= v.x;
|
|
114
|
+
this.y -= v.y;
|
|
115
|
+
this.z -= getZ(v);
|
|
116
|
+
}
|
|
117
|
+
#updateFromAngle(angle, length) {
|
|
118
|
+
this.x = Math.cos(angle) * length;
|
|
119
|
+
this.y = Math.sin(angle) * length;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
class Vector extends Vector3d {
|
|
123
|
+
constructor(x = originPoint.x, y = originPoint.y) {
|
|
124
|
+
super(x, y, originPoint.z);
|
|
125
|
+
}
|
|
126
|
+
static get origin() {
|
|
127
|
+
return Vector.create(originPoint.x, originPoint.y);
|
|
128
|
+
}
|
|
129
|
+
static clone(source) {
|
|
130
|
+
return Vector.create(source.x, source.y);
|
|
131
|
+
}
|
|
132
|
+
static create(x, y) {
|
|
133
|
+
if (typeof x === "number") {
|
|
134
|
+
return new Vector(x, y ?? originPoint.y);
|
|
135
|
+
}
|
|
136
|
+
return new Vector(x.x, x.y);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function isBoolean(arg) {
|
|
141
|
+
return typeof arg === "boolean";
|
|
142
|
+
}
|
|
143
|
+
function isString(arg) {
|
|
144
|
+
return typeof arg === "string";
|
|
145
|
+
}
|
|
146
|
+
function isNumber(arg) {
|
|
147
|
+
return typeof arg === "number";
|
|
148
|
+
}
|
|
149
|
+
function isObject(arg) {
|
|
150
|
+
return typeof arg === "object" && arg !== null;
|
|
151
|
+
}
|
|
152
|
+
function isArray(arg) {
|
|
153
|
+
return Array.isArray(arg);
|
|
154
|
+
}
|
|
155
|
+
function isNull(arg) {
|
|
156
|
+
return arg === null || arg === undefined;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const piDeg = 180, degToRadFactor = Math.PI / piDeg;
|
|
160
|
+
let _random = Math.random;
|
|
161
|
+
const _animationLoop = {
|
|
162
|
+
nextFrame: (cb) => requestAnimationFrame(cb),
|
|
163
|
+
cancel: (idx) => {
|
|
164
|
+
cancelAnimationFrame(idx);
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
function getRandom() {
|
|
168
|
+
const min = 0, max = 1;
|
|
169
|
+
return clamp(_random(), min, max - Number.EPSILON);
|
|
170
|
+
}
|
|
171
|
+
function getRandomInRange(min, max) {
|
|
172
|
+
return getRandom() * (max - min) + min;
|
|
173
|
+
}
|
|
174
|
+
function animate(fn) {
|
|
175
|
+
return _animationLoop.nextFrame(fn);
|
|
176
|
+
}
|
|
177
|
+
function cancelAnimation(handle) {
|
|
178
|
+
_animationLoop.cancel(handle);
|
|
179
|
+
}
|
|
180
|
+
function clamp(num, min, max) {
|
|
181
|
+
return Math.min(Math.max(num, min), max);
|
|
182
|
+
}
|
|
183
|
+
function randomInRangeValue(r) {
|
|
184
|
+
const max = getRangeMax(r), minOffset = 0;
|
|
185
|
+
let min = getRangeMin(r);
|
|
186
|
+
if (max === min) {
|
|
187
|
+
min = minOffset;
|
|
188
|
+
}
|
|
189
|
+
return getRandomInRange(min, max);
|
|
190
|
+
}
|
|
191
|
+
function getRangeValue(value) {
|
|
192
|
+
return isNumber(value) ? value : randomInRangeValue(value);
|
|
193
|
+
}
|
|
194
|
+
function getRangeMin(value) {
|
|
195
|
+
return isNumber(value) ? value : value.min;
|
|
196
|
+
}
|
|
197
|
+
function getRangeMax(value) {
|
|
198
|
+
return isNumber(value) ? value : value.max;
|
|
199
|
+
}
|
|
200
|
+
function setRangeValue(source, value) {
|
|
201
|
+
if (source === value || (value === undefined && isNumber(source))) {
|
|
202
|
+
return source;
|
|
203
|
+
}
|
|
204
|
+
const min = getRangeMin(source), max = getRangeMax(source);
|
|
205
|
+
return value !== undefined
|
|
206
|
+
? {
|
|
207
|
+
min: Math.min(min, value),
|
|
208
|
+
max: Math.max(max, value),
|
|
209
|
+
}
|
|
210
|
+
: setRangeValue(min, max);
|
|
211
|
+
}
|
|
212
|
+
function getDistanceSq(pointA, pointB) {
|
|
213
|
+
const dx = pointA.x - pointB.x, dy = pointA.y - pointB.y;
|
|
214
|
+
return dx * dx + dy * dy;
|
|
215
|
+
}
|
|
216
|
+
function checkDistance(pointA, pointB, distance) {
|
|
217
|
+
return getDistanceSq(pointA, pointB) <= distance * distance;
|
|
218
|
+
}
|
|
219
|
+
function degToRad(degrees) {
|
|
220
|
+
return degrees * degToRadFactor;
|
|
221
|
+
}
|
|
222
|
+
function getParticleDirectionAngle(direction, position, center) {
|
|
223
|
+
if (isNumber(direction)) {
|
|
224
|
+
return degToRad(direction);
|
|
225
|
+
}
|
|
226
|
+
switch (direction) {
|
|
227
|
+
case exports.MoveDirection.top:
|
|
228
|
+
return -Math.PI * half;
|
|
229
|
+
case exports.MoveDirection.topRight:
|
|
230
|
+
return -Math.PI * quarter;
|
|
231
|
+
case exports.MoveDirection.right:
|
|
232
|
+
return empty;
|
|
233
|
+
case exports.MoveDirection.bottomRight:
|
|
234
|
+
return Math.PI * quarter;
|
|
235
|
+
case exports.MoveDirection.bottom:
|
|
236
|
+
return Math.PI * half;
|
|
237
|
+
case exports.MoveDirection.bottomLeft:
|
|
238
|
+
return Math.PI * threeQuarter;
|
|
239
|
+
case exports.MoveDirection.left:
|
|
240
|
+
return Math.PI;
|
|
241
|
+
case exports.MoveDirection.topLeft:
|
|
242
|
+
return -Math.PI * threeQuarter;
|
|
243
|
+
case exports.MoveDirection.inside:
|
|
244
|
+
return Math.atan2(center.y - position.y, center.x - position.x);
|
|
245
|
+
case exports.MoveDirection.outside:
|
|
246
|
+
return Math.atan2(position.y - center.y, position.x - center.x);
|
|
247
|
+
default:
|
|
248
|
+
return getRandom() * doublePI;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
function getParticleBaseVelocity(direction) {
|
|
252
|
+
const baseVelocity = Vector.origin;
|
|
253
|
+
baseVelocity.length = 1;
|
|
254
|
+
baseVelocity.angle = direction;
|
|
255
|
+
return baseVelocity;
|
|
256
|
+
}
|
|
257
|
+
function calcExactPositionOrRandomFromSize(data) {
|
|
258
|
+
const { position, size } = data;
|
|
259
|
+
return {
|
|
260
|
+
x: position?.x ?? getRandom() * size.width,
|
|
261
|
+
y: position?.y ?? getRandom() * size.height,
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
var AnimationMode;
|
|
266
|
+
(function (AnimationMode) {
|
|
267
|
+
AnimationMode["auto"] = "auto";
|
|
268
|
+
AnimationMode["increase"] = "increase";
|
|
269
|
+
AnimationMode["decrease"] = "decrease";
|
|
270
|
+
AnimationMode["random"] = "random";
|
|
271
|
+
})(AnimationMode || (AnimationMode = {}));
|
|
272
|
+
|
|
273
|
+
var AnimationStatus;
|
|
274
|
+
(function (AnimationStatus) {
|
|
275
|
+
AnimationStatus["increasing"] = "increasing";
|
|
276
|
+
AnimationStatus["decreasing"] = "decreasing";
|
|
277
|
+
})(AnimationStatus || (AnimationStatus = {}));
|
|
278
|
+
|
|
279
|
+
var DestroyType;
|
|
280
|
+
(function (DestroyType) {
|
|
281
|
+
DestroyType["none"] = "none";
|
|
282
|
+
DestroyType["max"] = "max";
|
|
283
|
+
DestroyType["min"] = "min";
|
|
284
|
+
})(DestroyType || (DestroyType = {}));
|
|
285
|
+
|
|
286
|
+
exports.OutModeDirection = void 0;
|
|
287
|
+
(function (OutModeDirection) {
|
|
288
|
+
OutModeDirection["bottom"] = "bottom";
|
|
289
|
+
OutModeDirection["left"] = "left";
|
|
290
|
+
OutModeDirection["right"] = "right";
|
|
291
|
+
OutModeDirection["top"] = "top";
|
|
292
|
+
})(exports.OutModeDirection || (exports.OutModeDirection = {}));
|
|
293
|
+
|
|
294
|
+
exports.PixelMode = void 0;
|
|
295
|
+
(function (PixelMode) {
|
|
296
|
+
PixelMode["precise"] = "precise";
|
|
297
|
+
PixelMode["percent"] = "percent";
|
|
298
|
+
})(exports.PixelMode || (exports.PixelMode = {}));
|
|
299
|
+
|
|
300
|
+
var StartValueType;
|
|
301
|
+
(function (StartValueType) {
|
|
302
|
+
StartValueType["max"] = "max";
|
|
303
|
+
StartValueType["min"] = "min";
|
|
304
|
+
StartValueType["random"] = "random";
|
|
305
|
+
})(StartValueType || (StartValueType = {}));
|
|
306
|
+
|
|
307
|
+
function memoize(fn, options) {
|
|
308
|
+
const cache = new Map(), keyFn = options?.keyFn, stableStringify = (obj, seen = new WeakSet()) => {
|
|
309
|
+
if (obj === null) {
|
|
310
|
+
return "null";
|
|
311
|
+
}
|
|
312
|
+
const t = typeof obj;
|
|
313
|
+
if (t === "undefined") {
|
|
314
|
+
return "undefined";
|
|
315
|
+
}
|
|
316
|
+
if (t === "number" || t === "boolean" || t === "string") {
|
|
317
|
+
return JSON.stringify(obj);
|
|
318
|
+
}
|
|
319
|
+
if (t === "function") {
|
|
320
|
+
try {
|
|
321
|
+
const fn = obj;
|
|
322
|
+
return fn.toString();
|
|
323
|
+
}
|
|
324
|
+
catch {
|
|
325
|
+
return '"[Function]"';
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
if (t === "symbol") {
|
|
329
|
+
try {
|
|
330
|
+
return obj.toString();
|
|
331
|
+
}
|
|
332
|
+
catch {
|
|
333
|
+
return '"[Symbol]"';
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
if (Array.isArray(obj)) {
|
|
337
|
+
return `[${obj.map(i => stableStringify(i, seen)).join(",")}]`;
|
|
338
|
+
}
|
|
339
|
+
if (seen.has(obj)) {
|
|
340
|
+
return '"[Circular]"';
|
|
341
|
+
}
|
|
342
|
+
seen.add(obj);
|
|
343
|
+
const keys = Object.keys(obj).sort();
|
|
344
|
+
return `{${keys.map(k => `${JSON.stringify(k)}:${stableStringify(obj[k], seen)}`).join(",")}}`;
|
|
345
|
+
}, defaultKeyer = (args) => stableStringify(args), makeKey = (args) => (keyFn ? keyFn(args) : defaultKeyer(args));
|
|
346
|
+
return (...args) => {
|
|
347
|
+
const key = makeKey(args), now = Date.now(), entry = cache.get(key);
|
|
348
|
+
if (entry !== undefined) {
|
|
349
|
+
{
|
|
350
|
+
cache.delete(key);
|
|
351
|
+
cache.set(key, { value: entry.value, ts: entry.ts });
|
|
352
|
+
return entry.value;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
const result = fn(...args);
|
|
356
|
+
cache.set(key, { value: result, ts: now });
|
|
357
|
+
return result;
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
function hasMatchMedia() {
|
|
361
|
+
return typeof matchMedia !== "undefined";
|
|
362
|
+
}
|
|
363
|
+
function safeDocument() {
|
|
364
|
+
return globalThis.document;
|
|
365
|
+
}
|
|
366
|
+
function safeMatchMedia(query) {
|
|
367
|
+
if (!hasMatchMedia()) {
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
return matchMedia(query);
|
|
371
|
+
}
|
|
372
|
+
function safeMutationObserver(callback) {
|
|
373
|
+
if (typeof MutationObserver === "undefined") {
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
return new MutationObserver(callback);
|
|
377
|
+
}
|
|
378
|
+
function isInArray(value, array) {
|
|
379
|
+
return value === array || (isArray(array) && array.includes(value));
|
|
380
|
+
}
|
|
381
|
+
function arrayRandomIndex(array) {
|
|
382
|
+
return Math.floor(getRandom() * array.length);
|
|
383
|
+
}
|
|
384
|
+
function itemFromArray(array, index, useIndex = true) {
|
|
385
|
+
return array[index !== undefined && useIndex ? index % array.length : arrayRandomIndex(array)];
|
|
386
|
+
}
|
|
387
|
+
function deepExtend(destination, ...sources) {
|
|
388
|
+
for (const source of sources) {
|
|
389
|
+
if (isNull(source)) {
|
|
390
|
+
continue;
|
|
391
|
+
}
|
|
392
|
+
if (!isObject(source)) {
|
|
393
|
+
destination = source;
|
|
394
|
+
continue;
|
|
395
|
+
}
|
|
396
|
+
if (Array.isArray(source)) {
|
|
397
|
+
if (!Array.isArray(destination)) {
|
|
398
|
+
destination = [];
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
else if (!isObject(destination) || Array.isArray(destination)) {
|
|
402
|
+
destination = {};
|
|
403
|
+
}
|
|
404
|
+
const sourceKeys = Object.keys(source), dangerousKeys = new Set(["__proto__", "constructor", "prototype"]), hasNested = sourceKeys.some(k => {
|
|
405
|
+
const v = source[k];
|
|
406
|
+
return isObject(v) || Array.isArray(v);
|
|
407
|
+
});
|
|
408
|
+
if (!hasNested) {
|
|
409
|
+
const sourceDict = source, destDict = destination;
|
|
410
|
+
for (const key of sourceKeys) {
|
|
411
|
+
if (dangerousKeys.has(key)) {
|
|
412
|
+
continue;
|
|
413
|
+
}
|
|
414
|
+
if (key in sourceDict) {
|
|
415
|
+
const v = sourceDict[key];
|
|
416
|
+
if (v !== undefined) {
|
|
417
|
+
destDict[key] = v;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
continue;
|
|
422
|
+
}
|
|
423
|
+
for (const key of sourceKeys) {
|
|
424
|
+
if (dangerousKeys.has(key)) {
|
|
425
|
+
continue;
|
|
426
|
+
}
|
|
427
|
+
const sourceDict = source, destDict = destination, value = sourceDict[key];
|
|
428
|
+
destDict[key] = Array.isArray(value)
|
|
429
|
+
? value.map(v => deepExtend(undefined, v))
|
|
430
|
+
: deepExtend(destDict[key], value);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
return destination;
|
|
434
|
+
}
|
|
435
|
+
function executeOnSingleOrMultiple(obj, callback) {
|
|
436
|
+
const defaultIndex = 0;
|
|
437
|
+
return isArray(obj) ? obj.map((item, index) => callback(item, index)) : callback(obj, defaultIndex);
|
|
438
|
+
}
|
|
439
|
+
function itemFromSingleOrMultiple(obj, index, useIndex) {
|
|
440
|
+
return isArray(obj) ? itemFromArray(obj, index, useIndex) : obj;
|
|
441
|
+
}
|
|
442
|
+
function getPositionOrSize(positionOrSize, canvasSize) {
|
|
443
|
+
const isPercent = positionOrSize.mode === exports.PixelMode.percent;
|
|
444
|
+
if (!isPercent) {
|
|
445
|
+
const { mode: _, ...rest } = positionOrSize;
|
|
446
|
+
return rest;
|
|
447
|
+
}
|
|
448
|
+
const isPosition = "x" in positionOrSize;
|
|
449
|
+
if (isPosition) {
|
|
450
|
+
return {
|
|
451
|
+
x: (positionOrSize.x / percentDenominator) * canvasSize.width,
|
|
452
|
+
y: (positionOrSize.y / percentDenominator) * canvasSize.height,
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
else {
|
|
456
|
+
return {
|
|
457
|
+
width: (positionOrSize.width / percentDenominator) * canvasSize.width,
|
|
458
|
+
height: (positionOrSize.height / percentDenominator) * canvasSize.height,
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
function getPosition(position, canvasSize) {
|
|
463
|
+
return getPositionOrSize(position, canvasSize);
|
|
464
|
+
}
|
|
465
|
+
function cloneStyle(style) {
|
|
466
|
+
const clonedStyle = safeDocument().createElement("div").style;
|
|
467
|
+
for (const key in style) {
|
|
468
|
+
const styleKey = style[key];
|
|
469
|
+
if (!(key in style) || isNull(styleKey)) {
|
|
470
|
+
continue;
|
|
471
|
+
}
|
|
472
|
+
const styleValue = style.getPropertyValue?.(styleKey);
|
|
473
|
+
if (!styleValue) {
|
|
474
|
+
continue;
|
|
475
|
+
}
|
|
476
|
+
const stylePriority = style.getPropertyPriority?.(styleKey);
|
|
477
|
+
if (stylePriority) {
|
|
478
|
+
clonedStyle.setProperty(styleKey, styleValue, stylePriority);
|
|
479
|
+
}
|
|
480
|
+
else {
|
|
481
|
+
clonedStyle.setProperty(styleKey, styleValue);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
return clonedStyle;
|
|
485
|
+
}
|
|
486
|
+
function computeFullScreenStyle(zIndex) {
|
|
487
|
+
const fullScreenStyle = safeDocument().createElement("div").style, radix = 10, style = {
|
|
488
|
+
width: "100%",
|
|
489
|
+
height: "100%",
|
|
490
|
+
margin: "0",
|
|
491
|
+
padding: "0",
|
|
492
|
+
borderWidth: "0",
|
|
493
|
+
position: "fixed",
|
|
494
|
+
zIndex: zIndex.toString(radix),
|
|
495
|
+
"z-index": zIndex.toString(radix),
|
|
496
|
+
top: "0",
|
|
497
|
+
left: "0",
|
|
498
|
+
"pointer-events": "none",
|
|
499
|
+
};
|
|
500
|
+
for (const key in style) {
|
|
501
|
+
const value = style[key];
|
|
502
|
+
if (value === undefined) {
|
|
503
|
+
continue;
|
|
504
|
+
}
|
|
505
|
+
fullScreenStyle.setProperty(key, value);
|
|
506
|
+
}
|
|
507
|
+
return fullScreenStyle;
|
|
508
|
+
}
|
|
509
|
+
const getFullScreenStyle = memoize(computeFullScreenStyle);
|
|
510
|
+
function manageListener(element, event, handler, add, options) {
|
|
511
|
+
if (add) {
|
|
512
|
+
let addOptions = { passive: true };
|
|
513
|
+
if (isBoolean(options)) {
|
|
514
|
+
addOptions.capture = options;
|
|
515
|
+
}
|
|
516
|
+
else if (options !== undefined) {
|
|
517
|
+
addOptions = options;
|
|
518
|
+
}
|
|
519
|
+
element.addEventListener(event, handler, addOptions);
|
|
520
|
+
}
|
|
521
|
+
else {
|
|
522
|
+
const removeOptions = options;
|
|
523
|
+
element.removeEventListener(event, handler, removeOptions);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
async function getItemsFromInitializer(container, map, initializers, force = false) {
|
|
527
|
+
let res = map.get(container);
|
|
528
|
+
if (!res || force) {
|
|
529
|
+
res = await Promise.all([...initializers.values()].map(t => t(container)));
|
|
530
|
+
map.set(container, res);
|
|
531
|
+
}
|
|
532
|
+
return res;
|
|
533
|
+
}
|
|
534
|
+
async function getItemMapFromInitializer(container, map, initializers, force = false) {
|
|
535
|
+
let res = map.get(container);
|
|
536
|
+
if (!res || force) {
|
|
537
|
+
const entries = await Promise.all([...initializers.entries()].map(([key, initializer]) => initializer(container).then(item => [key, item])));
|
|
538
|
+
res = new Map(entries);
|
|
539
|
+
map.set(container, res);
|
|
540
|
+
}
|
|
541
|
+
return res;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
class EventDispatcher {
|
|
545
|
+
#listeners;
|
|
546
|
+
constructor() {
|
|
547
|
+
this.#listeners = new Map();
|
|
548
|
+
}
|
|
549
|
+
addEventListener(type, listener) {
|
|
550
|
+
this.removeEventListener(type, listener);
|
|
551
|
+
let arr = this.#listeners.get(type);
|
|
552
|
+
if (!arr) {
|
|
553
|
+
arr = [];
|
|
554
|
+
this.#listeners.set(type, arr);
|
|
555
|
+
}
|
|
556
|
+
arr.push(listener);
|
|
557
|
+
}
|
|
558
|
+
dispatchEvent(type, args) {
|
|
559
|
+
const listeners = this.#listeners.get(type);
|
|
560
|
+
listeners?.forEach(handler => {
|
|
561
|
+
handler(args);
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
hasEventListener(type) {
|
|
565
|
+
return !!this.#listeners.get(type);
|
|
566
|
+
}
|
|
567
|
+
removeAllEventListeners(type) {
|
|
568
|
+
if (!type) {
|
|
569
|
+
this.#listeners = new Map();
|
|
570
|
+
}
|
|
571
|
+
else {
|
|
572
|
+
this.#listeners.delete(type);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
removeEventListener(type, listener) {
|
|
576
|
+
const arr = this.#listeners.get(type);
|
|
577
|
+
if (!arr) {
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
const length = arr.length, idx = arr.indexOf(listener);
|
|
581
|
+
if (idx < minIndex) {
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
if (length === deleteCount) {
|
|
585
|
+
this.#listeners.delete(type);
|
|
586
|
+
}
|
|
587
|
+
else {
|
|
588
|
+
arr.splice(idx, deleteCount);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
exports.EventType = void 0;
|
|
594
|
+
(function (EventType) {
|
|
595
|
+
EventType["configAdded"] = "configAdded";
|
|
596
|
+
EventType["containerInit"] = "containerInit";
|
|
597
|
+
EventType["particlesSetup"] = "particlesSetup";
|
|
598
|
+
EventType["containerStarted"] = "containerStarted";
|
|
599
|
+
EventType["containerStopped"] = "containerStopped";
|
|
600
|
+
EventType["containerDestroyed"] = "containerDestroyed";
|
|
601
|
+
EventType["containerPaused"] = "containerPaused";
|
|
602
|
+
EventType["containerPlay"] = "containerPlay";
|
|
603
|
+
EventType["containerBuilt"] = "containerBuilt";
|
|
604
|
+
EventType["particleAdded"] = "particleAdded";
|
|
605
|
+
EventType["particleDestroyed"] = "particleDestroyed";
|
|
606
|
+
EventType["particleRemoved"] = "particleRemoved";
|
|
607
|
+
})(exports.EventType || (exports.EventType = {}));
|
|
608
|
+
|
|
609
|
+
class PluginManager {
|
|
610
|
+
colorManagers = new Map();
|
|
611
|
+
easingFunctions = new Map();
|
|
612
|
+
effectDrawers = new Map();
|
|
613
|
+
initializers = {
|
|
614
|
+
effects: new Map(),
|
|
615
|
+
shapes: new Map(),
|
|
616
|
+
updaters: new Map(),
|
|
617
|
+
};
|
|
618
|
+
palettes = new Map();
|
|
619
|
+
plugins = [];
|
|
620
|
+
presets = new Map();
|
|
621
|
+
shapeDrawers = new Map();
|
|
622
|
+
updaters = new Map();
|
|
623
|
+
#allLoadersSet = new Set();
|
|
624
|
+
#configs = new Map();
|
|
625
|
+
#engine;
|
|
626
|
+
#executedSet = new Set();
|
|
627
|
+
#initialized = false;
|
|
628
|
+
#isRunningLoaders = false;
|
|
629
|
+
#loadPromises = new Set();
|
|
630
|
+
constructor(engine) {
|
|
631
|
+
this.#engine = engine;
|
|
632
|
+
}
|
|
633
|
+
get configs() {
|
|
634
|
+
const res = {};
|
|
635
|
+
for (const [name, config] of this.#configs) {
|
|
636
|
+
res[name] = config;
|
|
637
|
+
}
|
|
638
|
+
return res;
|
|
639
|
+
}
|
|
640
|
+
addColorManager(name, manager) {
|
|
641
|
+
this.colorManagers.set(name, manager);
|
|
642
|
+
}
|
|
643
|
+
addConfig(config) {
|
|
644
|
+
const key = config.key ?? config.name ?? "default";
|
|
645
|
+
this.#configs.set(key, config);
|
|
646
|
+
this.#engine.dispatchEvent(exports.EventType.configAdded, { data: { name: key, config } });
|
|
647
|
+
}
|
|
648
|
+
addEasing(name, easing) {
|
|
649
|
+
if (this.easingFunctions.get(name)) {
|
|
650
|
+
return;
|
|
651
|
+
}
|
|
652
|
+
this.easingFunctions.set(name, easing);
|
|
653
|
+
}
|
|
654
|
+
addEffect(effect, drawer) {
|
|
655
|
+
this.initializers.effects.set(effect, drawer);
|
|
656
|
+
}
|
|
657
|
+
addPalette(name, palette) {
|
|
658
|
+
this.palettes.set(name, palette);
|
|
659
|
+
}
|
|
660
|
+
addParticleUpdater(name, updaterInitializer) {
|
|
661
|
+
this.initializers.updaters.set(name, updaterInitializer);
|
|
662
|
+
}
|
|
663
|
+
addPlugin(plugin) {
|
|
664
|
+
if (this.getPlugin(plugin.id)) {
|
|
665
|
+
return;
|
|
666
|
+
}
|
|
667
|
+
this.plugins.push(plugin);
|
|
668
|
+
}
|
|
669
|
+
addPreset(preset, options, override = false) {
|
|
670
|
+
if (!(override || !this.getPreset(preset))) {
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
this.presets.set(preset, options);
|
|
674
|
+
}
|
|
675
|
+
addShape(shapes, drawer) {
|
|
676
|
+
for (const shape of shapes) {
|
|
677
|
+
this.initializers.shapes.set(shape, drawer);
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
clearPlugins(container) {
|
|
681
|
+
this.effectDrawers.delete(container);
|
|
682
|
+
this.shapeDrawers.delete(container);
|
|
683
|
+
this.updaters.delete(container);
|
|
684
|
+
}
|
|
685
|
+
getEasing(name) {
|
|
686
|
+
return this.easingFunctions.get(name) ?? ((value) => value);
|
|
687
|
+
}
|
|
688
|
+
getEffectDrawers(container, force = false) {
|
|
689
|
+
return getItemMapFromInitializer(container, this.effectDrawers, this.initializers.effects, force);
|
|
690
|
+
}
|
|
691
|
+
getPalette(name) {
|
|
692
|
+
return this.palettes.get(name);
|
|
693
|
+
}
|
|
694
|
+
getPlugin(plugin) {
|
|
695
|
+
return this.plugins.find(t => t.id === plugin);
|
|
696
|
+
}
|
|
697
|
+
getPreset(preset) {
|
|
698
|
+
return this.presets.get(preset);
|
|
699
|
+
}
|
|
700
|
+
async getShapeDrawers(container, force = false) {
|
|
701
|
+
return getItemMapFromInitializer(container, this.shapeDrawers, this.initializers.shapes, force);
|
|
702
|
+
}
|
|
703
|
+
async getUpdaters(container, force = false) {
|
|
704
|
+
return getItemsFromInitializer(container, this.updaters, this.initializers.updaters, force);
|
|
705
|
+
}
|
|
706
|
+
async init() {
|
|
707
|
+
if (this.#initialized || this.#isRunningLoaders) {
|
|
708
|
+
return;
|
|
709
|
+
}
|
|
710
|
+
this.#isRunningLoaders = true;
|
|
711
|
+
this.#executedSet = new Set();
|
|
712
|
+
this.#allLoadersSet = new Set(this.#loadPromises);
|
|
713
|
+
try {
|
|
714
|
+
for (const loader of this.#allLoadersSet) {
|
|
715
|
+
await this.#runLoader(loader, this.#executedSet, this.#allLoadersSet);
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
finally {
|
|
719
|
+
this.#loadPromises.clear();
|
|
720
|
+
this.#isRunningLoaders = false;
|
|
721
|
+
this.#initialized = true;
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
loadParticlesOptions(container, options, ...sourceOptions) {
|
|
725
|
+
const updaters = this.updaters.get(container);
|
|
726
|
+
if (!updaters) {
|
|
727
|
+
return;
|
|
728
|
+
}
|
|
729
|
+
updaters.forEach(updater => updater.loadOptions?.(options, ...sourceOptions));
|
|
730
|
+
}
|
|
731
|
+
async register(...loaders) {
|
|
732
|
+
if (this.#initialized) {
|
|
733
|
+
throw new Error("Register plugins can only be done before calling tsParticles.load()");
|
|
734
|
+
}
|
|
735
|
+
for (const loader of loaders) {
|
|
736
|
+
if (this.#isRunningLoaders) {
|
|
737
|
+
await this.#runLoader(loader, this.#executedSet, this.#allLoadersSet);
|
|
738
|
+
}
|
|
739
|
+
else {
|
|
740
|
+
this.#loadPromises.add(loader);
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
async #runLoader(loader, executed, allLoaders) {
|
|
745
|
+
if (executed.has(loader))
|
|
746
|
+
return;
|
|
747
|
+
executed.add(loader);
|
|
748
|
+
allLoaders.add(loader);
|
|
749
|
+
await loader(this.#engine);
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
const errorPrefix = "tsParticles - Error";
|
|
754
|
+
const wrap = (fn) => (...args) => {
|
|
755
|
+
fn(...args);
|
|
756
|
+
}, _logger = {
|
|
757
|
+
debug: wrap(console.debug),
|
|
758
|
+
error: (message, ...optionalParams) => {
|
|
759
|
+
console.error(`${errorPrefix} - ${message}`, ...optionalParams);
|
|
760
|
+
},
|
|
761
|
+
info: wrap(console.info),
|
|
762
|
+
log: wrap(console.log),
|
|
763
|
+
trace: wrap(console.trace),
|
|
764
|
+
verbose: wrap(console.log),
|
|
765
|
+
warning: wrap(console.warn),
|
|
766
|
+
};
|
|
767
|
+
function getLogger() {
|
|
768
|
+
return _logger;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
const fullPercent = "100%";
|
|
772
|
+
async function getDataFromUrl(data) {
|
|
773
|
+
const url = itemFromSingleOrMultiple(data.url, data.index);
|
|
774
|
+
if (!url) {
|
|
775
|
+
return data.fallback;
|
|
776
|
+
}
|
|
777
|
+
const response = await fetch(url);
|
|
778
|
+
if (response.ok) {
|
|
779
|
+
return (await response.json());
|
|
780
|
+
}
|
|
781
|
+
getLogger().error(`${response.status.toString()} while retrieving config file`);
|
|
782
|
+
return data.fallback;
|
|
783
|
+
}
|
|
784
|
+
const getCanvasFromContainer = (domContainer) => {
|
|
785
|
+
const documentSafe = safeDocument();
|
|
786
|
+
let canvasEl;
|
|
787
|
+
const isCanvas = domContainer instanceof HTMLCanvasElement || domContainer.tagName.toLowerCase() === canvasTag;
|
|
788
|
+
if (isCanvas) {
|
|
789
|
+
canvasEl = domContainer;
|
|
790
|
+
canvasEl.dataset[generatedAttribute] ??= generatedFalse;
|
|
791
|
+
if (canvasEl.dataset[generatedAttribute] === generatedTrue) {
|
|
792
|
+
canvasEl.style.width ||= fullPercent;
|
|
793
|
+
canvasEl.style.height ||= fullPercent;
|
|
794
|
+
canvasEl.style.pointerEvents = "none";
|
|
795
|
+
canvasEl.style.setProperty("pointer-events", "none");
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
else {
|
|
799
|
+
const existingCanvases = domContainer.getElementsByTagName(canvasTag), foundCanvas = existingCanvases.item(canvasFirstIndex);
|
|
800
|
+
if (foundCanvas) {
|
|
801
|
+
canvasEl = foundCanvas;
|
|
802
|
+
canvasEl.dataset[generatedAttribute] = generatedFalse;
|
|
803
|
+
}
|
|
804
|
+
else {
|
|
805
|
+
canvasEl = documentSafe.createElement(canvasTag);
|
|
806
|
+
canvasEl.dataset[generatedAttribute] = generatedTrue;
|
|
807
|
+
domContainer.appendChild(canvasEl);
|
|
808
|
+
}
|
|
809
|
+
canvasEl.style.width ||= fullPercent;
|
|
810
|
+
canvasEl.style.height ||= fullPercent;
|
|
811
|
+
canvasEl.style.pointerEvents = "none";
|
|
812
|
+
canvasEl.style.setProperty("pointer-events", "none");
|
|
813
|
+
}
|
|
814
|
+
return canvasEl;
|
|
815
|
+
}, getDomContainer = (id, source) => {
|
|
816
|
+
const documentSafe = safeDocument();
|
|
817
|
+
let domContainer = source ?? documentSafe.getElementById(id);
|
|
818
|
+
if (domContainer) {
|
|
819
|
+
return domContainer;
|
|
820
|
+
}
|
|
821
|
+
domContainer = documentSafe.createElement("canvas");
|
|
822
|
+
domContainer.id = id;
|
|
823
|
+
domContainer.dataset[generatedAttribute] = generatedTrue;
|
|
824
|
+
documentSafe.body.append(domContainer);
|
|
825
|
+
return domContainer;
|
|
826
|
+
};
|
|
827
|
+
class Engine {
|
|
828
|
+
pluginManager = new PluginManager(this);
|
|
829
|
+
#domArray = [];
|
|
830
|
+
#eventDispatcher = new EventDispatcher();
|
|
831
|
+
#initialized = false;
|
|
832
|
+
get items() {
|
|
833
|
+
return this.#domArray;
|
|
834
|
+
}
|
|
835
|
+
get version() {
|
|
836
|
+
return "4.0.5";
|
|
837
|
+
}
|
|
838
|
+
addEventListener(type, listener) {
|
|
839
|
+
this.#eventDispatcher.addEventListener(type, listener);
|
|
840
|
+
}
|
|
841
|
+
checkVersion(pluginVersion) {
|
|
842
|
+
if (this.version === pluginVersion) {
|
|
843
|
+
return;
|
|
844
|
+
}
|
|
845
|
+
throw new Error(`The tsParticles version is different from the loaded plugins version. Engine version: ${this.version}. Plugin version: ${pluginVersion}`);
|
|
846
|
+
}
|
|
847
|
+
dispatchEvent(type, args) {
|
|
848
|
+
this.#eventDispatcher.dispatchEvent(type, args);
|
|
849
|
+
}
|
|
850
|
+
async init() {
|
|
851
|
+
if (this.#initialized) {
|
|
852
|
+
return;
|
|
853
|
+
}
|
|
854
|
+
await this.pluginManager.init();
|
|
855
|
+
this.#initialized = true;
|
|
856
|
+
}
|
|
857
|
+
item(index) {
|
|
858
|
+
const items = this.items, item = items[index];
|
|
859
|
+
if (item?.destroyed) {
|
|
860
|
+
items.splice(index, removeDeleteCount);
|
|
861
|
+
return;
|
|
862
|
+
}
|
|
863
|
+
return item;
|
|
864
|
+
}
|
|
865
|
+
async load(params) {
|
|
866
|
+
await this.init();
|
|
867
|
+
let domSourceElement;
|
|
868
|
+
if (typeof HTMLElement !== "undefined" && params.element instanceof HTMLElement) {
|
|
869
|
+
domSourceElement = params.element;
|
|
870
|
+
}
|
|
871
|
+
const { Container } = await Promise.resolve().then(function () { return require('./Container-DFed5jPA.js'); }), id = params.id ?? domSourceElement?.id ?? `tsparticles${Math.floor(getRandom() * loadRandomFactor).toString()}`, { index, url } = params, options = url ? await getDataFromUrl({ fallback: params.options, url, index }) : params.options, currentOptions = itemFromSingleOrMultiple(options, index), { items } = this, oldIndex = items.findIndex(v => v.id.description === id), newItem = new Container({
|
|
872
|
+
dispatchCallback: (eventType, args) => {
|
|
873
|
+
this.dispatchEvent(eventType, args);
|
|
874
|
+
},
|
|
875
|
+
id,
|
|
876
|
+
onDestroy: (remove) => {
|
|
877
|
+
if (!remove) {
|
|
878
|
+
return;
|
|
879
|
+
}
|
|
880
|
+
const mainArr = this.items, idx = mainArr.indexOf(newItem);
|
|
881
|
+
if (idx >= removeMinIndex) {
|
|
882
|
+
mainArr.splice(idx, removeDeleteCount);
|
|
883
|
+
}
|
|
884
|
+
},
|
|
885
|
+
pluginManager: this.pluginManager,
|
|
886
|
+
sourceOptions: currentOptions,
|
|
887
|
+
});
|
|
888
|
+
if (oldIndex >= loadMinIndex) {
|
|
889
|
+
const old = this.item(oldIndex), deleteCount = old ? one : none;
|
|
890
|
+
if (old && !old.destroyed) {
|
|
891
|
+
old.destroy(false);
|
|
892
|
+
}
|
|
893
|
+
items.splice(oldIndex, deleteCount, newItem);
|
|
894
|
+
}
|
|
895
|
+
else {
|
|
896
|
+
items.push(newItem);
|
|
897
|
+
}
|
|
898
|
+
const sourceCanvas = typeof OffscreenCanvas !== "undefined" && params.element instanceof OffscreenCanvas
|
|
899
|
+
? params.element
|
|
900
|
+
: getCanvasFromContainer(getDomContainer(id, domSourceElement));
|
|
901
|
+
newItem.canvas.loadCanvas(sourceCanvas);
|
|
902
|
+
await newItem.start();
|
|
903
|
+
return newItem;
|
|
904
|
+
}
|
|
905
|
+
async refresh(refresh = true) {
|
|
906
|
+
if (!refresh) {
|
|
907
|
+
return;
|
|
908
|
+
}
|
|
909
|
+
await Promise.all(this.items.map(t => t.refresh()));
|
|
910
|
+
}
|
|
911
|
+
removeEventListener(type, listener) {
|
|
912
|
+
this.#eventDispatcher.removeEventListener(type, listener);
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
function initEngine() {
|
|
917
|
+
return new Engine();
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
exports.RangeType = void 0;
|
|
921
|
+
(function (RangeType) {
|
|
922
|
+
RangeType["circle"] = "circle";
|
|
923
|
+
RangeType["rectangle"] = "rectangle";
|
|
924
|
+
})(exports.RangeType || (exports.RangeType = {}));
|
|
925
|
+
|
|
926
|
+
var RotateDirection;
|
|
927
|
+
(function (RotateDirection) {
|
|
928
|
+
RotateDirection["clockwise"] = "clockwise";
|
|
929
|
+
RotateDirection["counterClockwise"] = "counter-clockwise";
|
|
930
|
+
RotateDirection["random"] = "random";
|
|
931
|
+
})(RotateDirection || (RotateDirection = {}));
|
|
932
|
+
|
|
933
|
+
exports.LimitMode = void 0;
|
|
934
|
+
(function (LimitMode) {
|
|
935
|
+
LimitMode["delete"] = "delete";
|
|
936
|
+
LimitMode["wait"] = "wait";
|
|
937
|
+
})(exports.LimitMode || (exports.LimitMode = {}));
|
|
938
|
+
|
|
939
|
+
exports.OutMode = void 0;
|
|
940
|
+
(function (OutMode) {
|
|
941
|
+
OutMode["bounce"] = "bounce";
|
|
942
|
+
OutMode["none"] = "none";
|
|
943
|
+
OutMode["out"] = "out";
|
|
944
|
+
OutMode["destroy"] = "destroy";
|
|
945
|
+
OutMode["split"] = "split";
|
|
946
|
+
})(exports.OutMode || (exports.OutMode = {}));
|
|
947
|
+
|
|
948
|
+
exports.AlterType = void 0;
|
|
949
|
+
(function (AlterType) {
|
|
950
|
+
AlterType["darken"] = "darken";
|
|
951
|
+
AlterType["enlighten"] = "enlighten";
|
|
952
|
+
})(exports.AlterType || (exports.AlterType = {}));
|
|
953
|
+
|
|
954
|
+
var GradientType;
|
|
955
|
+
(function (GradientType) {
|
|
956
|
+
GradientType["linear"] = "linear";
|
|
957
|
+
GradientType["radial"] = "radial";
|
|
958
|
+
GradientType["random"] = "random";
|
|
959
|
+
})(GradientType || (GradientType = {}));
|
|
960
|
+
|
|
961
|
+
exports.ParticleOutType = void 0;
|
|
962
|
+
(function (ParticleOutType) {
|
|
963
|
+
ParticleOutType["normal"] = "normal";
|
|
964
|
+
ParticleOutType["inside"] = "inside";
|
|
965
|
+
ParticleOutType["outside"] = "outside";
|
|
966
|
+
})(exports.ParticleOutType || (exports.ParticleOutType = {}));
|
|
967
|
+
|
|
968
|
+
var EasingType;
|
|
969
|
+
(function (EasingType) {
|
|
970
|
+
EasingType["easeInBack"] = "ease-in-back";
|
|
971
|
+
EasingType["easeInBounce"] = "ease-in-bounce";
|
|
972
|
+
EasingType["easeInCirc"] = "ease-in-circ";
|
|
973
|
+
EasingType["easeInCubic"] = "ease-in-cubic";
|
|
974
|
+
EasingType["easeInElastic"] = "ease-in-elastic";
|
|
975
|
+
EasingType["easeInExpo"] = "ease-in-expo";
|
|
976
|
+
EasingType["easeInGaussian"] = "ease-in-gaussian";
|
|
977
|
+
EasingType["easeInLinear"] = "ease-in-linear";
|
|
978
|
+
EasingType["easeInQuad"] = "ease-in-quad";
|
|
979
|
+
EasingType["easeInQuart"] = "ease-in-quart";
|
|
980
|
+
EasingType["easeInQuint"] = "ease-in-quint";
|
|
981
|
+
EasingType["easeInSigmoid"] = "ease-in-sigmoid";
|
|
982
|
+
EasingType["easeInSine"] = "ease-in-sine";
|
|
983
|
+
EasingType["easeInSmoothstep"] = "ease-in-smoothstep";
|
|
984
|
+
EasingType["easeOutBack"] = "ease-out-back";
|
|
985
|
+
EasingType["easeOutBounce"] = "ease-out-bounce";
|
|
986
|
+
EasingType["easeOutCirc"] = "ease-out-circ";
|
|
987
|
+
EasingType["easeOutCubic"] = "ease-out-cubic";
|
|
988
|
+
EasingType["easeOutElastic"] = "ease-out-elastic";
|
|
989
|
+
EasingType["easeOutExpo"] = "ease-out-expo";
|
|
990
|
+
EasingType["easeOutGaussian"] = "ease-out-gaussian";
|
|
991
|
+
EasingType["easeOutLinear"] = "ease-out-linear";
|
|
992
|
+
EasingType["easeOutQuad"] = "ease-out-quad";
|
|
993
|
+
EasingType["easeOutQuart"] = "ease-out-quart";
|
|
994
|
+
EasingType["easeOutQuint"] = "ease-out-quint";
|
|
995
|
+
EasingType["easeOutSigmoid"] = "ease-out-sigmoid";
|
|
996
|
+
EasingType["easeOutSine"] = "ease-out-sine";
|
|
997
|
+
EasingType["easeOutSmoothstep"] = "ease-out-smoothstep";
|
|
998
|
+
EasingType["easeInOutBack"] = "ease-in-out-back";
|
|
999
|
+
EasingType["easeInOutBounce"] = "ease-in-out-bounce";
|
|
1000
|
+
EasingType["easeInOutCirc"] = "ease-in-out-circ";
|
|
1001
|
+
EasingType["easeInOutCubic"] = "ease-in-out-cubic";
|
|
1002
|
+
EasingType["easeInOutElastic"] = "ease-in-out-elastic";
|
|
1003
|
+
EasingType["easeInOutExpo"] = "ease-in-out-expo";
|
|
1004
|
+
EasingType["easeInOutGaussian"] = "ease-in-out-gaussian";
|
|
1005
|
+
EasingType["easeInOutLinear"] = "ease-in-out-linear";
|
|
1006
|
+
EasingType["easeInOutQuad"] = "ease-in-out-quad";
|
|
1007
|
+
EasingType["easeInOutQuart"] = "ease-in-out-quart";
|
|
1008
|
+
EasingType["easeInOutQuint"] = "ease-in-out-quint";
|
|
1009
|
+
EasingType["easeInOutSigmoid"] = "ease-in-out-sigmoid";
|
|
1010
|
+
EasingType["easeInOutSine"] = "ease-in-out-sine";
|
|
1011
|
+
EasingType["easeInOutSmoothstep"] = "ease-in-out-smoothstep";
|
|
1012
|
+
})(EasingType || (EasingType = {}));
|
|
1013
|
+
|
|
1014
|
+
const tsParticles = initEngine();
|
|
1015
|
+
|
|
1016
|
+
let initialized = false;
|
|
1017
|
+
let initPromise;
|
|
1018
|
+
let initCallback;
|
|
1019
|
+
async function initParticlesEngine(init) {
|
|
1020
|
+
if (initialized) {
|
|
1021
|
+
return;
|
|
1022
|
+
}
|
|
1023
|
+
if (initPromise) {
|
|
1024
|
+
if (initCallback !== init) {
|
|
1025
|
+
throw new Error("initParticlesEngine callback must be stable across the app lifecycle.");
|
|
1026
|
+
}
|
|
1027
|
+
await initPromise;
|
|
1028
|
+
return;
|
|
1029
|
+
}
|
|
1030
|
+
initCallback = init;
|
|
1031
|
+
initPromise = (async () => {
|
|
1032
|
+
if (init) {
|
|
1033
|
+
await init(tsParticles);
|
|
1034
|
+
}
|
|
1035
|
+
if (typeof tsParticles.init === "function") {
|
|
1036
|
+
await tsParticles.init();
|
|
1037
|
+
}
|
|
1038
|
+
initialized = true;
|
|
1039
|
+
})().catch((error) => {
|
|
1040
|
+
initPromise = undefined;
|
|
1041
|
+
initCallback = undefined;
|
|
1042
|
+
initialized = false;
|
|
1043
|
+
throw error;
|
|
1044
|
+
});
|
|
1045
|
+
await initPromise;
|
|
1046
|
+
}
|
|
1047
|
+
function isParticlesEngineInitialized() {
|
|
1048
|
+
return initialized;
|
|
1049
|
+
}
|
|
1050
|
+
async function waitForParticlesEngineInitialization() {
|
|
1051
|
+
await (initPromise !== null && initPromise !== void 0 ? initPromise : Promise.resolve());
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
exports.Vector = Vector;
|
|
1055
|
+
exports.Vector3d = Vector3d;
|
|
1056
|
+
exports.animate = animate;
|
|
1057
|
+
exports.calcExactPositionOrRandomFromSize = calcExactPositionOrRandomFromSize;
|
|
1058
|
+
exports.cancelAnimation = cancelAnimation;
|
|
1059
|
+
exports.checkDistance = checkDistance;
|
|
1060
|
+
exports.clamp = clamp;
|
|
1061
|
+
exports.cloneStyle = cloneStyle;
|
|
1062
|
+
exports.countOffset = countOffset;
|
|
1063
|
+
exports.deepExtend = deepExtend;
|
|
1064
|
+
exports.defaultAngle = defaultAngle;
|
|
1065
|
+
exports.defaultCompositeValue = defaultCompositeValue;
|
|
1066
|
+
exports.defaultDensityFactor = defaultDensityFactor;
|
|
1067
|
+
exports.defaultFps = defaultFps;
|
|
1068
|
+
exports.defaultFpsLimit = defaultFpsLimit;
|
|
1069
|
+
exports.defaultOpacity = defaultOpacity;
|
|
1070
|
+
exports.defaultRatio = defaultRatio;
|
|
1071
|
+
exports.defaultReduceFactor = defaultReduceFactor;
|
|
1072
|
+
exports.defaultRemoveQuantity = defaultRemoveQuantity;
|
|
1073
|
+
exports.defaultRetryCount = defaultRetryCount;
|
|
1074
|
+
exports.defaultRgbMin = defaultRgbMin;
|
|
1075
|
+
exports.defaultTransform = defaultTransform;
|
|
1076
|
+
exports.defaultTransformValue = defaultTransformValue;
|
|
1077
|
+
exports.defaultZoom = defaultZoom;
|
|
1078
|
+
exports.degToRad = degToRad;
|
|
1079
|
+
exports.deleteCount = deleteCount;
|
|
1080
|
+
exports.double = double;
|
|
1081
|
+
exports.doublePI = doublePI;
|
|
1082
|
+
exports.empty = empty;
|
|
1083
|
+
exports.executeOnSingleOrMultiple = executeOnSingleOrMultiple;
|
|
1084
|
+
exports.generatedAttribute = generatedAttribute;
|
|
1085
|
+
exports.getFullScreenStyle = getFullScreenStyle;
|
|
1086
|
+
exports.getLogger = getLogger;
|
|
1087
|
+
exports.getParticleBaseVelocity = getParticleBaseVelocity;
|
|
1088
|
+
exports.getParticleDirectionAngle = getParticleDirectionAngle;
|
|
1089
|
+
exports.getPosition = getPosition;
|
|
1090
|
+
exports.getRandom = getRandom;
|
|
1091
|
+
exports.getRandomInRange = getRandomInRange;
|
|
1092
|
+
exports.getRangeValue = getRangeValue;
|
|
1093
|
+
exports.hMax = hMax;
|
|
1094
|
+
exports.hMin = hMin;
|
|
1095
|
+
exports.hPhase = hPhase;
|
|
1096
|
+
exports.half = half;
|
|
1097
|
+
exports.identity = identity;
|
|
1098
|
+
exports.initParticlesEngine = initParticlesEngine;
|
|
1099
|
+
exports.isArray = isArray;
|
|
1100
|
+
exports.isBoolean = isBoolean;
|
|
1101
|
+
exports.isInArray = isInArray;
|
|
1102
|
+
exports.isNull = isNull;
|
|
1103
|
+
exports.isNumber = isNumber;
|
|
1104
|
+
exports.isObject = isObject;
|
|
1105
|
+
exports.isParticlesEngineInitialized = isParticlesEngineInitialized;
|
|
1106
|
+
exports.isString = isString;
|
|
1107
|
+
exports.itemFromArray = itemFromArray;
|
|
1108
|
+
exports.itemFromSingleOrMultiple = itemFromSingleOrMultiple;
|
|
1109
|
+
exports.lFactor = lFactor;
|
|
1110
|
+
exports.lMax = lMax;
|
|
1111
|
+
exports.lMin = lMin;
|
|
1112
|
+
exports.manageListener = manageListener;
|
|
1113
|
+
exports.millisecondsToSeconds = millisecondsToSeconds;
|
|
1114
|
+
exports.minCount = minCount;
|
|
1115
|
+
exports.minFpsLimit = minFpsLimit;
|
|
1116
|
+
exports.minIndex = minIndex;
|
|
1117
|
+
exports.minLimit = minLimit;
|
|
1118
|
+
exports.minStrokeWidth = minStrokeWidth;
|
|
1119
|
+
exports.minZ = minZ;
|
|
1120
|
+
exports.minimumSize = minimumSize;
|
|
1121
|
+
exports.one = one;
|
|
1122
|
+
exports.originPoint = originPoint;
|
|
1123
|
+
exports.phaseNumerator = phaseNumerator;
|
|
1124
|
+
exports.randomColorValue = randomColorValue;
|
|
1125
|
+
exports.randomInRangeValue = randomInRangeValue;
|
|
1126
|
+
exports.resizeEvent = resizeEvent;
|
|
1127
|
+
exports.rgbMax = rgbMax;
|
|
1128
|
+
exports.sMax = sMax;
|
|
1129
|
+
exports.sMin = sMin;
|
|
1130
|
+
exports.sNormalizedOffset = sNormalizedOffset;
|
|
1131
|
+
exports.safeDocument = safeDocument;
|
|
1132
|
+
exports.safeMatchMedia = safeMatchMedia;
|
|
1133
|
+
exports.safeMutationObserver = safeMutationObserver;
|
|
1134
|
+
exports.setRangeValue = setRangeValue;
|
|
1135
|
+
exports.sextuple = sextuple;
|
|
1136
|
+
exports.spatialHashGridCellSize = spatialHashGridCellSize;
|
|
1137
|
+
exports.squareExp = squareExp;
|
|
1138
|
+
exports.triple = triple;
|
|
1139
|
+
exports.tryCountIncrement = tryCountIncrement;
|
|
1140
|
+
exports.tsParticles = tsParticles;
|
|
1141
|
+
exports.visibilityChangeEvent = visibilityChangeEvent;
|
|
1142
|
+
exports.waitForParticlesEngineInitialization = waitForParticlesEngineInitialization;
|
|
1143
|
+
exports.zIndexFactorOffset = zIndexFactorOffset;
|