@tsparticles/stencil 4.1.3 → 4.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/README.md +13 -0
  2. package/dist/cjs/{Container-0BqPfTsu.js → Container-BIhHE6mu.js} +659 -1010
  3. package/dist/cjs/{index-Bw7g3biq.js → index-BIoj1BEO.js} +57 -160
  4. package/dist/cjs/{index-B2lLThjb.js → index-BjS63OiI.js} +95 -5
  5. package/dist/cjs/index.cjs.js +1 -1
  6. package/dist/cjs/loader.cjs.js +2 -2
  7. package/dist/cjs/stencil-particles.cjs.entry.js +23 -6
  8. package/dist/cjs/tsparticlesstencil.cjs.js +2 -2
  9. package/dist/collection/components/stencil-particles/stencil-particles.js +83 -4
  10. package/dist/esm/{Container-BxLt611H.js → Container-DZZsfp6i.js} +659 -1010
  11. package/dist/esm/{index-BXzC9NH1.js → index-BH3sNkGS.js} +57 -160
  12. package/dist/esm/{index-DKFk70aj.js → index-PhwiK2_P.js} +95 -6
  13. package/dist/esm/index.js +1 -1
  14. package/dist/esm/loader.js +3 -3
  15. package/dist/esm/stencil-particles.entry.js +23 -6
  16. package/dist/esm/tsparticlesstencil.js +3 -3
  17. package/dist/tsparticlesstencil/index.esm.js +1 -1
  18. package/dist/tsparticlesstencil/p-CIUgBOXY.js +1 -0
  19. package/dist/tsparticlesstencil/p-PhwiK2_P.js +2 -0
  20. package/dist/tsparticlesstencil/p-QSzGOBhI.js +1 -0
  21. package/dist/tsparticlesstencil/p-bd76f15b.entry.js +1 -0
  22. package/dist/tsparticlesstencil/tsparticlesstencil.esm.js +1 -1
  23. package/dist/types/components/stencil-particles/stencil-particles.d.ts +6 -2
  24. package/dist/types/components.d.ts +24 -2
  25. package/package.json +8 -7
  26. package/dist/tsparticlesstencil/p-BhGs05ap.js +0 -1
  27. package/dist/tsparticlesstencil/p-DKFk70aj.js +0 -2
  28. package/dist/tsparticlesstencil/p-LyLjQmWv.js +0 -1
  29. package/dist/tsparticlesstencil/p-cf6e2424.entry.js +0 -1
@@ -7,7 +7,7 @@ const generatedAttribute = "generated", defaultCompositeValue = "source-over", r
7
7
  b: 0,
8
8
  c: 0,
9
9
  d: 1,
10
- }, 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;
10
+ }, 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, maxNits = 400, triple = 3, sextuple = 6, sNormalizedOffset = 1, phaseNumerator = 1, defaultRgbMin = 0, defaultZoom = 1;
11
11
 
12
12
  var MoveDirection;
13
13
  (function (MoveDirection) {
@@ -74,11 +74,6 @@ class Vector3d {
74
74
  div(n) {
75
75
  return Vector3d.create(this.x / n, this.y / n, this.z / n);
76
76
  }
77
- divTo(n) {
78
- this.x /= n;
79
- this.y /= n;
80
- this.z /= n;
81
- }
82
77
  getLengthSq() {
83
78
  return this.x ** squareExp + this.y ** squareExp;
84
79
  }
@@ -260,27 +255,6 @@ function calcExactPositionOrRandomFromSize(data) {
260
255
  };
261
256
  }
262
257
 
263
- var AnimationMode;
264
- (function (AnimationMode) {
265
- AnimationMode["auto"] = "auto";
266
- AnimationMode["increase"] = "increase";
267
- AnimationMode["decrease"] = "decrease";
268
- AnimationMode["random"] = "random";
269
- })(AnimationMode || (AnimationMode = {}));
270
-
271
- var AnimationStatus;
272
- (function (AnimationStatus) {
273
- AnimationStatus["increasing"] = "increasing";
274
- AnimationStatus["decreasing"] = "decreasing";
275
- })(AnimationStatus || (AnimationStatus = {}));
276
-
277
- var DestroyType;
278
- (function (DestroyType) {
279
- DestroyType["none"] = "none";
280
- DestroyType["max"] = "max";
281
- DestroyType["min"] = "min";
282
- })(DestroyType || (DestroyType = {}));
283
-
284
258
  var OutModeDirection;
285
259
  (function (OutModeDirection) {
286
260
  OutModeDirection["bottom"] = "bottom";
@@ -295,66 +269,6 @@ var PixelMode;
295
269
  PixelMode["percent"] = "percent";
296
270
  })(PixelMode || (PixelMode = {}));
297
271
 
298
- var StartValueType;
299
- (function (StartValueType) {
300
- StartValueType["max"] = "max";
301
- StartValueType["min"] = "min";
302
- StartValueType["random"] = "random";
303
- })(StartValueType || (StartValueType = {}));
304
-
305
- function memoize(fn, options) {
306
- const cache = new Map(), keyFn = options?.keyFn, stableStringify = (obj, seen = new WeakSet()) => {
307
- if (obj === null) {
308
- return "null";
309
- }
310
- const t = typeof obj;
311
- if (t === "undefined") {
312
- return "undefined";
313
- }
314
- if (t === "number" || t === "boolean" || t === "string") {
315
- return JSON.stringify(obj);
316
- }
317
- if (t === "function") {
318
- try {
319
- const fn = obj;
320
- return fn.toString();
321
- }
322
- catch {
323
- return '"[Function]"';
324
- }
325
- }
326
- if (t === "symbol") {
327
- try {
328
- return obj.toString();
329
- }
330
- catch {
331
- return '"[Symbol]"';
332
- }
333
- }
334
- if (Array.isArray(obj)) {
335
- return `[${obj.map(i => stableStringify(i, seen)).join(",")}]`;
336
- }
337
- if (seen.has(obj)) {
338
- return '"[Circular]"';
339
- }
340
- seen.add(obj);
341
- const keys = Object.keys(obj).sort();
342
- return `{${keys.map(k => `${JSON.stringify(k)}:${stableStringify(obj[k], seen)}`).join(",")}}`;
343
- }, defaultKeyer = (args) => stableStringify(args), makeKey = (args) => (keyFn ? keyFn(args) : defaultKeyer(args));
344
- return (...args) => {
345
- const key = makeKey(args), now = Date.now(), entry = cache.get(key);
346
- if (entry !== undefined) {
347
- {
348
- cache.delete(key);
349
- cache.set(key, { value: entry.value, ts: entry.ts });
350
- return entry.value;
351
- }
352
- }
353
- const result = fn(...args);
354
- cache.set(key, { value: result, ts: now });
355
- return result;
356
- };
357
- }
358
272
  function hasMatchMedia() {
359
273
  return typeof matchMedia !== "undefined";
360
274
  }
@@ -376,11 +290,8 @@ function safeMutationObserver(callback) {
376
290
  function isInArray(value, array) {
377
291
  return value === array || (isArray(array) && array.includes(value));
378
292
  }
379
- function arrayRandomIndex(array) {
380
- return Math.floor(getRandom() * array.length);
381
- }
382
293
  function itemFromArray(array, index, useIndex = true) {
383
- return array[index !== undefined && useIndex ? index % array.length : arrayRandomIndex(array)];
294
+ return array[index !== undefined && useIndex ? index % array.length : Math.floor(getRandom() * array.length)];
384
295
  }
385
296
  function deepExtend(destination, ...sources) {
386
297
  for (const source of sources) {
@@ -481,30 +392,34 @@ function cloneStyle(style) {
481
392
  }
482
393
  return clonedStyle;
483
394
  }
484
- function computeFullScreenStyle(zIndex) {
485
- const fullScreenStyle = safeDocument().createElement("div").style, radix = 10, style = {
486
- width: "100%",
487
- height: "100%",
488
- margin: "0",
489
- padding: "0",
490
- borderWidth: "0",
491
- position: "fixed",
492
- zIndex: zIndex.toString(radix),
493
- "z-index": zIndex.toString(radix),
494
- top: "0",
495
- left: "0",
496
- "pointer-events": "none",
497
- };
498
- for (const key in style) {
499
- const value = style[key];
500
- if (value === undefined) {
501
- continue;
395
+ let _cachedZIndex, _cachedStyle;
396
+ function getFullScreenStyle(zIndex) {
397
+ if (_cachedZIndex !== zIndex || !_cachedStyle) {
398
+ _cachedZIndex = zIndex;
399
+ const fullScreenStyle = safeDocument().createElement("div").style, radix = 10, style = {
400
+ width: "100%",
401
+ height: "100%",
402
+ margin: "0",
403
+ padding: "0",
404
+ borderWidth: "0",
405
+ position: "fixed",
406
+ zIndex: zIndex.toString(radix),
407
+ "z-index": zIndex.toString(radix),
408
+ top: "0",
409
+ left: "0",
410
+ "pointer-events": "none",
411
+ };
412
+ for (const key in style) {
413
+ const value = style[key];
414
+ if (value === undefined) {
415
+ continue;
416
+ }
417
+ fullScreenStyle.setProperty(key, value);
502
418
  }
503
- fullScreenStyle.setProperty(key, value);
419
+ _cachedStyle = fullScreenStyle;
504
420
  }
505
- return fullScreenStyle;
421
+ return _cachedStyle;
506
422
  }
507
- const getFullScreenStyle = memoize(computeFullScreenStyle);
508
423
  function manageListener(element, event, handler, add, options) {
509
424
  if (add) {
510
425
  let addOptions = { passive: true };
@@ -831,7 +746,7 @@ class Engine {
831
746
  return this.#domArray;
832
747
  }
833
748
  get version() {
834
- return "4.1.3";
749
+ return "4.2.1";
835
750
  }
836
751
  addEventListener(type, listener) {
837
752
  this.#eventDispatcher.addEventListener(type, listener);
@@ -866,7 +781,7 @@ class Engine {
866
781
  if (typeof HTMLElement !== "undefined" && params.element instanceof HTMLElement) {
867
782
  domSourceElement = params.element;
868
783
  }
869
- const { Container } = await import('./Container-BxLt611H.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({
784
+ const { Container } = await import('./Container-DZZsfp6i.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({
870
785
  dispatchCallback: (eventType, args) => {
871
786
  this.dispatchEvent(eventType, args);
872
787
  },
@@ -928,6 +843,14 @@ var RotateDirection;
928
843
  RotateDirection["random"] = "random";
929
844
  })(RotateDirection || (RotateDirection = {}));
930
845
 
846
+ var AnimationMode;
847
+ (function (AnimationMode) {
848
+ AnimationMode["auto"] = "auto";
849
+ AnimationMode["increase"] = "increase";
850
+ AnimationMode["decrease"] = "decrease";
851
+ AnimationMode["random"] = "random";
852
+ })(AnimationMode || (AnimationMode = {}));
853
+
931
854
  var LimitMode;
932
855
  (function (LimitMode) {
933
856
  LimitMode["delete"] = "delete";
@@ -949,6 +872,13 @@ var AlterType;
949
872
  AlterType["enlighten"] = "enlighten";
950
873
  })(AlterType || (AlterType = {}));
951
874
 
875
+ var DestroyType;
876
+ (function (DestroyType) {
877
+ DestroyType["none"] = "none";
878
+ DestroyType["max"] = "max";
879
+ DestroyType["min"] = "min";
880
+ })(DestroyType || (DestroyType = {}));
881
+
952
882
  var GradientType;
953
883
  (function (GradientType) {
954
884
  GradientType["linear"] = "linear";
@@ -963,51 +893,18 @@ var ParticleOutType;
963
893
  ParticleOutType["outside"] = "outside";
964
894
  })(ParticleOutType || (ParticleOutType = {}));
965
895
 
966
- var EasingType;
967
- (function (EasingType) {
968
- EasingType["easeInBack"] = "ease-in-back";
969
- EasingType["easeInBounce"] = "ease-in-bounce";
970
- EasingType["easeInCirc"] = "ease-in-circ";
971
- EasingType["easeInCubic"] = "ease-in-cubic";
972
- EasingType["easeInElastic"] = "ease-in-elastic";
973
- EasingType["easeInExpo"] = "ease-in-expo";
974
- EasingType["easeInGaussian"] = "ease-in-gaussian";
975
- EasingType["easeInLinear"] = "ease-in-linear";
976
- EasingType["easeInQuad"] = "ease-in-quad";
977
- EasingType["easeInQuart"] = "ease-in-quart";
978
- EasingType["easeInQuint"] = "ease-in-quint";
979
- EasingType["easeInSigmoid"] = "ease-in-sigmoid";
980
- EasingType["easeInSine"] = "ease-in-sine";
981
- EasingType["easeInSmoothstep"] = "ease-in-smoothstep";
982
- EasingType["easeOutBack"] = "ease-out-back";
983
- EasingType["easeOutBounce"] = "ease-out-bounce";
984
- EasingType["easeOutCirc"] = "ease-out-circ";
985
- EasingType["easeOutCubic"] = "ease-out-cubic";
986
- EasingType["easeOutElastic"] = "ease-out-elastic";
987
- EasingType["easeOutExpo"] = "ease-out-expo";
988
- EasingType["easeOutGaussian"] = "ease-out-gaussian";
989
- EasingType["easeOutLinear"] = "ease-out-linear";
990
- EasingType["easeOutQuad"] = "ease-out-quad";
991
- EasingType["easeOutQuart"] = "ease-out-quart";
992
- EasingType["easeOutQuint"] = "ease-out-quint";
993
- EasingType["easeOutSigmoid"] = "ease-out-sigmoid";
994
- EasingType["easeOutSine"] = "ease-out-sine";
995
- EasingType["easeOutSmoothstep"] = "ease-out-smoothstep";
996
- EasingType["easeInOutBack"] = "ease-in-out-back";
997
- EasingType["easeInOutBounce"] = "ease-in-out-bounce";
998
- EasingType["easeInOutCirc"] = "ease-in-out-circ";
999
- EasingType["easeInOutCubic"] = "ease-in-out-cubic";
1000
- EasingType["easeInOutElastic"] = "ease-in-out-elastic";
1001
- EasingType["easeInOutExpo"] = "ease-in-out-expo";
1002
- EasingType["easeInOutGaussian"] = "ease-in-out-gaussian";
1003
- EasingType["easeInOutLinear"] = "ease-in-out-linear";
1004
- EasingType["easeInOutQuad"] = "ease-in-out-quad";
1005
- EasingType["easeInOutQuart"] = "ease-in-out-quart";
1006
- EasingType["easeInOutQuint"] = "ease-in-out-quint";
1007
- EasingType["easeInOutSigmoid"] = "ease-in-out-sigmoid";
1008
- EasingType["easeInOutSine"] = "ease-in-out-sine";
1009
- EasingType["easeInOutSmoothstep"] = "ease-in-out-smoothstep";
1010
- })(EasingType || (EasingType = {}));
896
+ var StartValueType;
897
+ (function (StartValueType) {
898
+ StartValueType["max"] = "max";
899
+ StartValueType["min"] = "min";
900
+ StartValueType["random"] = "random";
901
+ })(StartValueType || (StartValueType = {}));
902
+
903
+ var AnimationStatus;
904
+ (function (AnimationStatus) {
905
+ AnimationStatus["increasing"] = "increasing";
906
+ AnimationStatus["decreasing"] = "decreasing";
907
+ })(AnimationStatus || (AnimationStatus = {}));
1011
908
 
1012
909
  const tsParticles = initEngine();
1013
910
 
@@ -1049,4 +946,4 @@ async function waitForParticlesEngineInitialization() {
1049
946
  await (initPromise !== null && initPromise !== void 0 ? initPromise : Promise.resolve());
1050
947
  }
1051
948
 
1052
- export { millisecondsToSeconds as $, AlterType as A, lFactor as B, double as C, hPhase as D, rgbMax as E, getRandomInRange as F, identity as G, defaultRgbMin as H, sextuple as I, triple as J, phaseNumerator as K, LimitMode as L, MoveDirection as M, sNormalizedOffset as N, OutMode as O, PixelMode as P, minimumSize as Q, RangeType as R, defaultCompositeValue as S, defaultTransformValue as T, zIndexFactorOffset as U, safeMutationObserver as V, generatedAttribute as W, cloneStyle as X, safeMatchMedia as Y, getFullScreenStyle as Z, safeDocument as _, isNull as a, manageListener as a0, visibilityChangeEvent as a1, resizeEvent as a2, Vector3d as a3, EventType as a4, defaultAngle as a5, defaultTransform as a6, ParticleOutType as a7, itemFromSingleOrMultiple as a8, getRandom as a9, defaultRatio as aA, defaultReduceFactor as aB, animate as aC, defaultFpsLimit as aD, minFpsLimit as aE, cancelAnimation as aF, defaultFps as aG, isParticlesEngineInitialized as aH, waitForParticlesEngineInitialization as aI, defaultRetryCount as aa, tryCountIncrement as ab, getParticleBaseVelocity as ac, randomInRangeValue as ad, OutModeDirection as ae, clamp as af, minZ as ag, getPosition as ah, getParticleDirectionAngle as ai, Vector as aj, getRangeValue as ak, doublePI as al, calcExactPositionOrRandomFromSize as am, isInArray as an, degToRad as ao, spatialHashGridCellSize as ap, minLimit as aq, minCount as ar, getLogger as as, minIndex as at, defaultRemoveQuantity as au, defaultDensityFactor as av, empty as aw, deleteCount as ax, countOffset as ay, one as az, setRangeValue as b, checkDistance as c, hMax as d, lMax as e, sMin as f, sMax as g, hMin as h, initParticlesEngine as i, isString as j, isArray as k, lMin as l, deepExtend as m, isNumber as n, isObject as o, executeOnSingleOrMultiple as p, isBoolean as q, originPoint as r, squareExp as s, tsParticles as t, minStrokeWidth as u, defaultZoom as v, itemFromArray as w, defaultOpacity as x, randomColorValue as y, half as z };
949
+ export { safeDocument as $, AlterType as A, rgbMax as B, getRandomInRange as C, identity as D, defaultRgbMin as E, maxNits as F, sextuple as G, triple as H, phaseNumerator as I, sNormalizedOffset as J, originPoint as K, LimitMode as L, MoveDirection as M, minimumSize as N, OutMode as O, PixelMode as P, defaultCompositeValue as Q, RangeType as R, minStrokeWidth as S, defaultZoom as T, zIndexFactorOffset as U, defaultTransformValue as V, safeMutationObserver as W, generatedAttribute as X, cloneStyle as Y, safeMatchMedia as Z, getFullScreenStyle as _, isNull as a, millisecondsToSeconds as a0, manageListener as a1, visibilityChangeEvent as a2, resizeEvent as a3, Vector3d as a4, EventType as a5, defaultAngle as a6, defaultTransform as a7, defaultRetryCount as a8, tryCountIncrement as a9, defaultRatio as aA, defaultReduceFactor as aB, animate as aC, defaultFpsLimit as aD, minFpsLimit as aE, cancelAnimation as aF, defaultFps as aG, isParticlesEngineInitialized as aH, waitForParticlesEngineInitialization as aI, getParticleBaseVelocity as aa, randomInRangeValue as ab, getRandom as ac, OutModeDirection as ad, clamp as ae, minZ as af, getPosition as ag, getParticleDirectionAngle as ah, ParticleOutType as ai, Vector as aj, getRangeValue as ak, calcExactPositionOrRandomFromSize as al, itemFromSingleOrMultiple as am, isInArray as an, doublePI as ao, degToRad as ap, spatialHashGridCellSize as aq, minLimit as ar, minCount as as, getLogger as at, minIndex as au, defaultRemoveQuantity as av, defaultDensityFactor as aw, deleteCount as ax, countOffset as ay, one as az, setRangeValue as b, checkDistance as c, hMax as d, lMax as e, sMin as f, sMax as g, hMin as h, initParticlesEngine as i, isString as j, isArray as k, lMin as l, deepExtend as m, isNumber as n, isObject as o, executeOnSingleOrMultiple as p, isBoolean as q, itemFromArray as r, squareExp as s, tsParticles as t, defaultOpacity as u, randomColorValue as v, lFactor as w, half as x, double as y, hPhase as z };
@@ -82,6 +82,7 @@ var registerHost = (hostElement, cmpMeta) => {
82
82
  hostElement.__stencil__getHostRef = () => ref;
83
83
  return ref;
84
84
  };
85
+ var isMemberInElement = (elm, memberName) => memberName in elm;
85
86
  var consoleError = (e, el) => (0, console.error)(e, el);
86
87
 
87
88
  // src/client/client-load-module.ts
@@ -289,6 +290,25 @@ var parsePropertyValue = (propValue, propType, isFormAssociated) => {
289
290
  }
290
291
  return propValue;
291
292
  };
293
+ var getElement = (ref) => {
294
+ var _a;
295
+ return (_a = getHostRef(ref)) == null ? void 0 : _a.$hostElement$ ;
296
+ };
297
+
298
+ // src/runtime/event-emitter.ts
299
+ var createEvent = (ref, name, flags) => {
300
+ const elm = getElement(ref);
301
+ return {
302
+ emit: (detail) => {
303
+ return emitEvent(elm, name, {
304
+ bubbles: true,
305
+ composed: true,
306
+ cancelable: true,
307
+ detail
308
+ });
309
+ }
310
+ };
311
+ };
292
312
  var emitEvent = (elm, name, opts) => {
293
313
  const ev = plt.ce(name, opts);
294
314
  elm.dispatchEvent(ev);
@@ -298,6 +318,7 @@ var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialRen
298
318
  if (oldValue === newValue) {
299
319
  return;
300
320
  }
321
+ let isProp = isMemberInElement(elm, memberName);
301
322
  memberName.toLowerCase();
302
323
  if (memberName === "style") {
303
324
  {
@@ -324,7 +345,70 @@ var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialRen
324
345
  if (newValue) {
325
346
  queueRefAttachment(newValue, elm);
326
347
  }
327
- } else ;
348
+ } else if (memberName[0] === "a" && memberName.startsWith("attr:")) {
349
+ const propName = memberName.slice(5);
350
+ let attrName;
351
+ {
352
+ const hostRef = getHostRef(elm);
353
+ if (hostRef && hostRef.$cmpMeta$ && hostRef.$cmpMeta$.$members$) {
354
+ const memberMeta = hostRef.$cmpMeta$.$members$[propName];
355
+ if (memberMeta && memberMeta[1]) {
356
+ attrName = memberMeta[1];
357
+ }
358
+ }
359
+ }
360
+ if (!attrName) {
361
+ attrName = propName.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
362
+ }
363
+ if (newValue == null || newValue === false) {
364
+ if (newValue !== false || elm.getAttribute(attrName) === "") {
365
+ elm.removeAttribute(attrName);
366
+ }
367
+ } else {
368
+ elm.setAttribute(attrName, newValue === true ? "" : newValue);
369
+ }
370
+ return;
371
+ } else if (memberName[0] === "p" && memberName.startsWith("prop:")) {
372
+ const propName = memberName.slice(5);
373
+ try {
374
+ elm[propName] = newValue;
375
+ } catch (e) {
376
+ }
377
+ return;
378
+ } else {
379
+ const isComplex = isComplexType(newValue);
380
+ if ((isProp || isComplex && newValue !== null) && !isSvg) {
381
+ try {
382
+ if (!elm.tagName.includes("-")) {
383
+ const n = newValue == null ? "" : newValue;
384
+ if (memberName === "list") {
385
+ isProp = false;
386
+ } else if (oldValue == null || elm[memberName] !== n) {
387
+ if (typeof elm.__lookupSetter__(memberName) === "function") {
388
+ elm[memberName] = n;
389
+ } else {
390
+ elm.setAttribute(memberName, n);
391
+ }
392
+ }
393
+ } else if (elm[memberName] !== newValue) {
394
+ elm[memberName] = newValue;
395
+ }
396
+ } catch (e) {
397
+ }
398
+ }
399
+ if (newValue == null || newValue === false) {
400
+ if (newValue !== false || elm.getAttribute(memberName) === "") {
401
+ {
402
+ elm.removeAttribute(memberName);
403
+ }
404
+ }
405
+ } else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex && elm.nodeType === 1 /* ElementNode */) {
406
+ newValue = newValue === true ? "" : newValue;
407
+ {
408
+ elm.setAttribute(memberName, newValue);
409
+ }
410
+ }
411
+ }
328
412
  };
329
413
 
330
414
  // src/runtime/vdom/update-element.ts
@@ -339,7 +423,9 @@ var updateElement = (oldVnode, newVnode, isSvgMode2, isInitialRender) => {
339
423
  elm,
340
424
  memberName,
341
425
  oldVnodeAttrs[memberName],
342
- void 0);
426
+ void 0,
427
+ isSvgMode2,
428
+ newVnode.$flags$);
343
429
  }
344
430
  }
345
431
  }
@@ -348,7 +434,9 @@ var updateElement = (oldVnode, newVnode, isSvgMode2, isInitialRender) => {
348
434
  elm,
349
435
  memberName,
350
436
  oldVnodeAttrs[memberName],
351
- newVnodeAttrs[memberName]);
437
+ newVnodeAttrs[memberName],
438
+ isSvgMode2,
439
+ newVnode.$flags$);
352
440
  }
353
441
  };
354
442
  function sortedAttrNames(attrNames) {
@@ -361,6 +449,7 @@ function sortedAttrNames(attrNames) {
361
449
  );
362
450
  }
363
451
  var hostTagName;
452
+ var isSvgMode = false;
364
453
  var refCallbacksToRemove = [];
365
454
  var refCallbacksToAttach = [];
366
455
  var createElm = (oldParentVNode, newParentVNode, childIndex) => {
@@ -376,7 +465,7 @@ var createElm = (oldParentVNode, newParentVNode, childIndex) => {
376
465
  newVNode2.$tag$
377
466
  );
378
467
  {
379
- updateElement(null, newVNode2);
468
+ updateElement(null, newVNode2, isSvgMode);
380
469
  }
381
470
  if (newVNode2.$children$) {
382
471
  const appendTarget = newVNode2.$tag$ === "template" ? elm.content : elm;
@@ -522,7 +611,7 @@ var patch = (oldVNode, newVNode2, isInitialRender = false) => {
522
611
  const newChildren = newVNode2.$children$;
523
612
  {
524
613
  {
525
- updateElement(oldVNode, newVNode2);
614
+ updateElement(oldVNode, newVNode2, isSvgMode);
526
615
  }
527
616
  if (oldChildren !== null && newChildren !== null) {
528
617
  updateChildren(elm, oldChildren, newVNode2, newChildren, isInitialRender);
@@ -1220,4 +1309,4 @@ function transformTag(tag) {
1220
1309
  return tag;
1221
1310
  }
1222
1311
 
1223
- export { bootstrapLazy as b, h, promiseResolve as p, registerInstance as r, setNonce as s };
1312
+ export { bootstrapLazy as b, createEvent as c, h, promiseResolve as p, registerInstance as r, setNonce as s };
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- export { i as initParticlesEngine, aH as isParticlesEngineInitialized, aI as waitForParticlesEngineInitialization } from './index-BXzC9NH1.js';
1
+ export { i as initParticlesEngine, aH as isParticlesEngineInitialized, aI as waitForParticlesEngineInitialization } from './index-BH3sNkGS.js';
@@ -1,11 +1,11 @@
1
- import { b as bootstrapLazy } from './index-DKFk70aj.js';
2
- export { s as setNonce } from './index-DKFk70aj.js';
1
+ import { b as bootstrapLazy } from './index-PhwiK2_P.js';
2
+ export { s as setNonce } from './index-PhwiK2_P.js';
3
3
  import { g as globalScripts } from './app-globals-DQuL1Twl.js';
4
4
 
5
5
  const defineCustomElements = async (win, options) => {
6
6
  if (typeof window === 'undefined') return undefined;
7
7
  await globalScripts();
8
- return bootstrapLazy([["stencil-particles",[[0,"stencil-particles",{"options":[16],"url":[1],"init":[16]},null,{"options":[{"onPropsChange":0}],"url":[{"onPropsChange":0}],"init":[{"onPropsChange":0}]}]]]], options);
8
+ return bootstrapLazy([["stencil-particles",[[0,"stencil-particles",{"options":[16],"url":[1],"init":[16],"containerId":[1,"container-id"],"theme":[1]},null,{"options":[{"onPropsChange":0}],"url":[{"onPropsChange":0}],"init":[{"onPropsChange":0}],"containerId":[{"onPropsChange":0}],"theme":[{"onThemeChange":0}]}]]]], options);
9
9
  };
10
10
 
11
11
  export { defineCustomElements };
@@ -1,9 +1,10 @@
1
- import { r as registerInstance, h } from './index-DKFk70aj.js';
2
- import { i as initParticlesEngine, t as tsParticles } from './index-BXzC9NH1.js';
1
+ import { r as registerInstance, c as createEvent, h } from './index-PhwiK2_P.js';
2
+ import { i as initParticlesEngine, t as tsParticles } from './index-BH3sNkGS.js';
3
3
 
4
4
  const StencilParticles = class {
5
5
  constructor(hostRef) {
6
6
  registerInstance(this, hostRef);
7
+ this.particlesLoaded = createEvent(this, "particlesLoaded");
7
8
  this.renderId = 0;
8
9
  }
9
10
  async componentDidLoad() {
@@ -18,8 +19,14 @@ const StencilParticles = class {
18
19
  async onPropsChange() {
19
20
  await this.loadParticles(++this.renderId);
20
21
  }
22
+ async onThemeChange() {
23
+ var _a, _b;
24
+ if (!this.container)
25
+ return;
26
+ (_b = (_a = this.container).loadTheme) === null || _b === void 0 ? void 0 : _b.call(_a, this.theme);
27
+ }
21
28
  async loadParticles(currentRenderId) {
22
- var _a;
29
+ var _a, _b, _c;
23
30
  (_a = this.container) === null || _a === void 0 ? void 0 : _a.destroy();
24
31
  if (!this.containerElement) {
25
32
  console.warn("[stencil-particles] container element not available yet");
@@ -38,8 +45,8 @@ const StencilParticles = class {
38
45
  return;
39
46
  }
40
47
  // Load particles directly onto the DOM element.
41
- // tsParticles will auto-generate a unique internal ID, preventing collisions.
42
- const loadParams = Object.assign({ element: this.containerElement }, (this.options ? { options: this.options } : { url: this.url }));
48
+ // If a container-id is provided, use it so consumers can retrieve the container later.
49
+ const loadParams = Object.assign(Object.assign({ element: this.containerElement }, (this.containerId ? { id: this.containerId } : {})), (this.options ? { options: this.options } : { url: this.url }));
43
50
  container = await tsParticles.load(loadParams);
44
51
  }
45
52
  catch (error) {
@@ -52,9 +59,13 @@ const StencilParticles = class {
52
59
  return;
53
60
  }
54
61
  this.container = container;
62
+ this.particlesLoaded.emit(container);
63
+ if (container && this.theme) {
64
+ (_c = (_b = container).loadTheme) === null || _c === void 0 ? void 0 : _c.call(_b, this.theme);
65
+ }
55
66
  }
56
67
  render() {
57
- return (h("div", { key: '870e2cc222aed94f8bbfa274dc3c047392ed8b1a', ref: el => {
68
+ return (h("div", { key: 'f5fe33d147a1a606a75fe0d1ee385bacaf0e0b7d', id: this.containerId, ref: el => {
58
69
  this.containerElement = el;
59
70
  }, style: { width: "100%", height: "100%" } }));
60
71
  }
@@ -67,6 +78,12 @@ const StencilParticles = class {
67
78
  }],
68
79
  "init": [{
69
80
  "onPropsChange": 0
81
+ }],
82
+ "containerId": [{
83
+ "onPropsChange": 0
84
+ }],
85
+ "theme": [{
86
+ "onThemeChange": 0
70
87
  }]
71
88
  }; }
72
89
  };
@@ -1,5 +1,5 @@
1
- import { p as promiseResolve, b as bootstrapLazy } from './index-DKFk70aj.js';
2
- export { s as setNonce } from './index-DKFk70aj.js';
1
+ import { p as promiseResolve, b as bootstrapLazy } from './index-PhwiK2_P.js';
2
+ export { s as setNonce } from './index-PhwiK2_P.js';
3
3
  import { g as globalScripts } from './app-globals-DQuL1Twl.js';
4
4
 
5
5
  /*
@@ -17,5 +17,5 @@ var patchBrowser = () => {
17
17
 
18
18
  patchBrowser().then(async (options) => {
19
19
  await globalScripts();
20
- return bootstrapLazy([["stencil-particles",[[0,"stencil-particles",{"options":[16],"url":[1],"init":[16]},null,{"options":[{"onPropsChange":0}],"url":[{"onPropsChange":0}],"init":[{"onPropsChange":0}]}]]]], options);
20
+ return bootstrapLazy([["stencil-particles",[[0,"stencil-particles",{"options":[16],"url":[1],"init":[16],"containerId":[1,"container-id"],"theme":[1]},null,{"options":[{"onPropsChange":0}],"url":[{"onPropsChange":0}],"init":[{"onPropsChange":0}],"containerId":[{"onPropsChange":0}],"theme":[{"onThemeChange":0}]}]]]], options);
21
21
  });
@@ -1 +1 @@
1
- export{i as initParticlesEngine,aH as isParticlesEngineInitialized,aI as waitForParticlesEngineInitialization}from"./p-BhGs05ap.js";
1
+ export{i as initParticlesEngine,aH as isParticlesEngineInitialized,aI as waitForParticlesEngineInitialization}from"./p-QSzGOBhI.js";