@tsparticles/preset-confetti-explosions 4.5.0 → 4.5.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.
@@ -1,6 +1,6 @@
1
1
  (function(g){g.__tsParticlesInternals=g.__tsParticlesInternals||{};g.__tsParticlesInternals.bundles=g.__tsParticlesInternals.bundles||{};g.__tsParticlesInternals.effects=g.__tsParticlesInternals.effects||{};g.__tsParticlesInternals.engine=g.__tsParticlesInternals.engine||{};g.__tsParticlesInternals.interactions=g.__tsParticlesInternals.interactions||{};g.__tsParticlesInternals.palettes=g.__tsParticlesInternals.palettes||{};g.__tsParticlesInternals.paths=g.__tsParticlesInternals.paths||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins.emittersShapes=g.__tsParticlesInternals.plugins.emittersShapes||{};g.__tsParticlesInternals.presets=g.__tsParticlesInternals.presets||{};g.__tsParticlesInternals.shapes=g.__tsParticlesInternals.shapes||{};g.__tsParticlesInternals.updaters=g.__tsParticlesInternals.updaters||{};g.__tsParticlesInternals.utils=g.__tsParticlesInternals.utils||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas.utils=g.__tsParticlesInternals.canvas.utils||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path.utils=g.__tsParticlesInternals.path.utils||{};var __tsProxyFactory=typeof Proxy!=="undefined"?function(obj){return new Proxy(obj,{get:function(target,key){if(!(key in target)){target[key]={};}return target[key];}});}:function(obj){return obj;};g.__tsParticlesInternals.bundles=__tsProxyFactory(g.__tsParticlesInternals.bundles);g.__tsParticlesInternals.effects=__tsProxyFactory(g.__tsParticlesInternals.effects);g.__tsParticlesInternals.interactions=__tsProxyFactory(g.__tsParticlesInternals.interactions);g.__tsParticlesInternals.palettes=__tsProxyFactory(g.__tsParticlesInternals.palettes);g.__tsParticlesInternals.paths=__tsProxyFactory(g.__tsParticlesInternals.paths);g.__tsParticlesInternals.plugins=__tsProxyFactory(g.__tsParticlesInternals.plugins);g.__tsParticlesInternals.plugins.emittersShapes=__tsProxyFactory(g.__tsParticlesInternals.plugins.emittersShapes);g.__tsParticlesInternals.presets=__tsProxyFactory(g.__tsParticlesInternals.presets);g.__tsParticlesInternals.shapes=__tsProxyFactory(g.__tsParticlesInternals.shapes);g.__tsParticlesInternals.updaters=__tsProxyFactory(g.__tsParticlesInternals.updaters);g.__tsParticlesInternals.utils=__tsProxyFactory(g.__tsParticlesInternals.utils);g.__tsParticlesInternals.canvas=__tsProxyFactory(g.__tsParticlesInternals.canvas);g.__tsParticlesInternals.path=__tsProxyFactory(g.__tsParticlesInternals.path);})(typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:this);
2
2
  (function (g) {
3
- /* Preset v4.5.0 */
3
+ /* Preset v4.5.2 */
4
4
  g.__tsParticlesInternals = g.__tsParticlesInternals || {};
5
5
  g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
6
6
  (function (exports) {
@@ -120,7 +120,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
120
120
  }
121
121
  normalize() {
122
122
  const length = this.length;
123
- if (length != none) {
123
+ if (length !== none) {
124
124
  this.multTo(inverseFactorNumerator / length);
125
125
  }
126
126
  }
@@ -667,12 +667,8 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
667
667
  }
668
668
  addEventListener(type, listener) {
669
669
  this.removeEventListener(type, listener);
670
- let arr = this.#listeners.get(type);
671
- if (!arr) {
672
- arr = [];
673
- this.#listeners.set(type, arr);
674
- }
675
- arr.push(listener);
670
+ const arr = this.#listeners.get(type);
671
+ this.#listeners.set(type, arr ? [...arr, listener] : [listener]);
676
672
  }
677
673
  dispatchEvent(type, args) {
678
674
  const listeners = this.#listeners.get(type);
@@ -704,7 +700,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
704
700
  this.#listeners.delete(type);
705
701
  }
706
702
  else {
707
- arr.splice(idx, deleteCount);
703
+ this.#listeners.set(type, [...arr.slice(minIndex, idx), ...arr.slice(idx + deleteCount)]);
708
704
  }
709
705
  }
710
706
  }
@@ -881,11 +877,13 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
881
877
  #domArray = [];
882
878
  #eventDispatcher = new EventDispatcher();
883
879
  #initialized = false;
880
+ #loadSequence = 0;
881
+ #loadSequences = new Map();
884
882
  get items() {
885
883
  return this.#domArray;
886
884
  }
887
885
  get version() {
888
- return "4.5.0";
886
+ return "4.5.2";
889
887
  }
890
888
  addEventListener(type, listener) {
891
889
  this.#eventDispatcher.addEventListener(type, listener);
@@ -915,44 +913,60 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
915
913
  return item;
916
914
  }
917
915
  async load(params) {
918
- await this.init();
919
916
  let domSourceElement;
920
917
  if (typeof HTMLElement !== "undefined" && params.element instanceof HTMLElement) {
921
918
  domSourceElement = params.element;
922
919
  }
923
- const { Container } = await Promise.resolve().then(function () { return Container$1; }), 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({
924
- dispatchCallback: (eventType, args) => {
925
- this.dispatchEvent(eventType, args);
926
- },
927
- id,
928
- onDestroy: (remove) => {
929
- if (!remove) {
930
- return;
931
- }
932
- const mainArr = this.items, idx = mainArr.indexOf(newItem);
933
- if (idx >= removeMinIndex) {
934
- mainArr.splice(idx, removeDeleteCount);
920
+ const id = params.id ?? domSourceElement?.id ?? `tsparticles${Math.floor(getRandom() * loadRandomFactor).toString()}`, loadSequence = ++this.#loadSequence;
921
+ this.#loadSequences.set(id, loadSequence);
922
+ try {
923
+ await this.init();
924
+ const { Container } = await Promise.resolve().then(function () { return Container$1; }), { index, url } = params, options = url ? await getDataFromUrl({ fallback: params.options, url, index }) : params.options;
925
+ if (this.#loadSequences.get(id) !== loadSequence) {
926
+ return undefined;
927
+ }
928
+ const currentOptions = itemFromSingleOrMultiple(options, index), { items } = this, oldIndex = items.findIndex(v => v.id.description === id), newItem = new Container({
929
+ dispatchCallback: (eventType, args) => {
930
+ this.dispatchEvent(eventType, args);
931
+ },
932
+ id,
933
+ onDestroy: (remove) => {
934
+ if (!remove) {
935
+ return;
936
+ }
937
+ const mainArr = this.items, idx = mainArr.indexOf(newItem);
938
+ if (idx >= removeMinIndex) {
939
+ mainArr.splice(idx, removeDeleteCount);
940
+ }
941
+ },
942
+ pluginManager: this.pluginManager,
943
+ sourceOptions: currentOptions,
944
+ });
945
+ if (oldIndex >= loadMinIndex) {
946
+ const old = this.item(oldIndex), deleteCount = old ? one : none;
947
+ if (old && !old.destroyed) {
948
+ old.destroy(false);
935
949
  }
936
- },
937
- pluginManager: this.pluginManager,
938
- sourceOptions: currentOptions,
939
- });
940
- if (oldIndex >= loadMinIndex) {
941
- const old = this.item(oldIndex), deleteCount = old ? one : none;
942
- if (old && !old.destroyed) {
943
- old.destroy(false);
950
+ items.splice(oldIndex, deleteCount, newItem);
944
951
  }
945
- items.splice(oldIndex, deleteCount, newItem);
952
+ else {
953
+ items.push(newItem);
954
+ }
955
+ const sourceCanvas = typeof OffscreenCanvas !== "undefined" && params.element instanceof OffscreenCanvas
956
+ ? params.element
957
+ : getCanvasFromContainer(getDomContainer(id, domSourceElement));
958
+ newItem.canvas.loadCanvas(sourceCanvas);
959
+ await newItem.start();
960
+ if (newItem.destroyed) {
961
+ return undefined;
962
+ }
963
+ return newItem;
946
964
  }
947
- else {
948
- items.push(newItem);
965
+ finally {
966
+ if (this.#loadSequences.get(id) === loadSequence) {
967
+ this.#loadSequences.delete(id);
968
+ }
949
969
  }
950
- const sourceCanvas = typeof OffscreenCanvas !== "undefined" && params.element instanceof OffscreenCanvas
951
- ? params.element
952
- : getCanvasFromContainer(getDomContainer(id, domSourceElement));
953
- newItem.canvas.loadCanvas(sourceCanvas);
954
- await newItem.start();
955
- return newItem;
956
970
  }
957
971
  async refresh(refresh = true) {
958
972
  if (!refresh) {
@@ -2260,6 +2274,13 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
2260
2274
  }
2261
2275
  }
2262
2276
 
2277
+ function hasEnabledBlend(particleOptions) {
2278
+ if (!particleOptions || typeof particleOptions !== "object" || !("blend" in particleOptions)) {
2279
+ return false;
2280
+ }
2281
+ const blend = particleOptions.blend;
2282
+ return !!blend && typeof blend === "object" && "enable" in blend && !!blend.enable;
2283
+ }
2263
2284
  class BlendPlugin {
2264
2285
  id = "blend";
2265
2286
  async getPlugin(container) {
@@ -2281,12 +2302,31 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
2281
2302
  options.blend.load(source?.blend);
2282
2303
  }
2283
2304
  needsPlugin(options) {
2284
- return !!options?.blend?.enable || !!options?.particles?.blend?.enable;
2305
+ if (options?.blend?.enable ||
2306
+ options?.particles?.blend?.enable ||
2307
+ Object.values(options?.particles?.groups ?? {}).some(hasEnabledBlend)) {
2308
+ return true;
2309
+ }
2310
+ const emitters = options?.["emitters"];
2311
+ let emitterList = [];
2312
+ if (Array.isArray(emitters)) {
2313
+ emitterList = emitters;
2314
+ }
2315
+ else if (emitters) {
2316
+ emitterList = [emitters];
2317
+ }
2318
+ return emitterList.some(emitter => {
2319
+ if (!emitter || typeof emitter !== "object" || !("particles" in emitter)) {
2320
+ return false;
2321
+ }
2322
+ const particles = emitter.particles;
2323
+ return Array.isArray(particles) ? particles.some(hasEnabledBlend) : hasEnabledBlend(particles);
2324
+ });
2285
2325
  }
2286
2326
  }
2287
2327
 
2288
2328
  async function loadBlendPlugin(engine) {
2289
- engine.checkVersion("4.5.0");
2329
+ engine.checkVersion("4.5.2");
2290
2330
  await engine.pluginManager.register(e => {
2291
2331
  e.pluginManager.addPlugin(new BlendPlugin());
2292
2332
  });
@@ -2323,7 +2363,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
2323
2363
  }
2324
2364
 
2325
2365
  async function loadCircleShape(engine) {
2326
- engine.checkVersion("4.5.0");
2366
+ engine.checkVersion("4.5.2");
2327
2367
  await engine.pluginManager.register(e => {
2328
2368
  e.pluginManager.addShape(["circle"], () => {
2329
2369
  return Promise.resolve(new CircleDrawer());
@@ -2371,7 +2411,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
2371
2411
  }
2372
2412
 
2373
2413
  async function loadHexColorPlugin(engine) {
2374
- engine.checkVersion("4.5.0");
2414
+ engine.checkVersion("4.5.2");
2375
2415
  await engine.pluginManager.register(e => {
2376
2416
  e.pluginManager.addColorManager("hex", new HexColorManager());
2377
2417
  });
@@ -2424,7 +2464,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
2424
2464
  }
2425
2465
 
2426
2466
  async function loadHslColorPlugin(engine) {
2427
- engine.checkVersion("4.5.0");
2467
+ engine.checkVersion("4.5.2");
2428
2468
  await engine.pluginManager.register(e => {
2429
2469
  e.pluginManager.addColorManager("hsl", new HslColorManager());
2430
2470
  });
@@ -2456,7 +2496,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
2456
2496
  }
2457
2497
 
2458
2498
  async function loadMovePlugin(engine) {
2459
- engine.checkVersion("4.5.0");
2499
+ engine.checkVersion("4.5.2");
2460
2500
  if (typeof process !== "undefined" && process.env.NODE_ENV !== "production") {
2461
2501
  addErrorMessages(ErrorMessages$1);
2462
2502
  }
@@ -2672,7 +2712,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
2672
2712
  }
2673
2713
 
2674
2714
  async function loadOpacityUpdater(engine) {
2675
- engine.checkVersion("4.5.0");
2715
+ engine.checkVersion("4.5.2");
2676
2716
  await engine.pluginManager.register(e => {
2677
2717
  e.pluginManager.addParticleUpdater("opacity", container => {
2678
2718
  return Promise.resolve(new OpacityUpdater(container));
@@ -3001,7 +3041,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3001
3041
  }
3002
3042
 
3003
3043
  async function loadOutModesUpdater(engine) {
3004
- engine.checkVersion("4.5.0");
3044
+ engine.checkVersion("4.5.2");
3005
3045
  await engine.pluginManager.register(e => {
3006
3046
  e.pluginManager.addParticleUpdater("outModes", container => {
3007
3047
  return Promise.resolve(new OutOfCanvasUpdater(container));
@@ -3080,7 +3120,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3080
3120
  }
3081
3121
 
3082
3122
  async function loadPaintUpdater(engine) {
3083
- engine.checkVersion("4.5.0");
3123
+ engine.checkVersion("4.5.2");
3084
3124
  await engine.pluginManager.register(e => {
3085
3125
  e.pluginManager.addParticleUpdater("paint", container => {
3086
3126
  return Promise.resolve(new PaintUpdater(e.pluginManager, container));
@@ -3135,7 +3175,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3135
3175
  }
3136
3176
 
3137
3177
  async function loadRgbColorPlugin(engine) {
3138
- engine.checkVersion("4.5.0");
3178
+ engine.checkVersion("4.5.2");
3139
3179
  await engine.pluginManager.register(e => {
3140
3180
  e.pluginManager.addColorManager("rgb", new RgbColorManager());
3141
3181
  });
@@ -3220,7 +3260,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3220
3260
  }
3221
3261
 
3222
3262
  async function loadSizeUpdater(engine) {
3223
- engine.checkVersion("4.5.0");
3263
+ engine.checkVersion("4.5.2");
3224
3264
  await engine.pluginManager.register(e => {
3225
3265
  e.pluginManager.addParticleUpdater("size", container => {
3226
3266
  return Promise.resolve(new SizeUpdater(container));
@@ -3229,7 +3269,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3229
3269
  }
3230
3270
 
3231
3271
  async function loadBasic(engine) {
3232
- engine.checkVersion("4.5.0");
3272
+ engine.checkVersion("4.5.2");
3233
3273
  await engine.pluginManager.register(async (e) => {
3234
3274
  await Promise.all([
3235
3275
  loadBlendPlugin(e),
@@ -3369,7 +3409,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3369
3409
  direction;
3370
3410
  domId;
3371
3411
  draggable = false;
3372
- draw = true;
3412
+ draw = false;
3373
3413
  fill = true;
3374
3414
  life = new EmitterLife();
3375
3415
  name;
@@ -3494,7 +3534,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3494
3534
  })(EmitterClickMode || (EmitterClickMode = {}));
3495
3535
 
3496
3536
  async function loadEmittersPluginSimple(engine) {
3497
- engine.checkVersion("4.5.0");
3537
+ engine.checkVersion("4.5.2");
3498
3538
  if (typeof process !== "undefined" && process.env.NODE_ENV !== "production") {
3499
3539
  addErrorMessages(ErrorMessages);
3500
3540
  }
@@ -3551,7 +3591,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3551
3591
  }
3552
3592
 
3553
3593
  async function loadMotionPlugin(engine) {
3554
- engine.checkVersion("4.5.0");
3594
+ engine.checkVersion("4.5.2");
3555
3595
  await engine.pluginManager.register(e => {
3556
3596
  e.pluginManager.addPlugin(new MotionPlugin());
3557
3597
  });
@@ -3684,7 +3724,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3684
3724
  }
3685
3725
 
3686
3726
  async function loadRollUpdater(engine) {
3687
- engine.checkVersion("4.5.0");
3727
+ engine.checkVersion("4.5.2");
3688
3728
  await engine.pluginManager.register(e => {
3689
3729
  e.pluginManager.addParticleUpdater("roll", () => {
3690
3730
  return Promise.resolve(new RollUpdater(e.pluginManager));
@@ -3790,7 +3830,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3790
3830
  }
3791
3831
 
3792
3832
  async function loadRotateUpdater(engine) {
3793
- engine.checkVersion("4.5.0");
3833
+ engine.checkVersion("4.5.2");
3794
3834
  await engine.pluginManager.register(e => {
3795
3835
  e.pluginManager.addParticleUpdater("rotate", container => {
3796
3836
  return Promise.resolve(new RotateUpdater(container));
@@ -3814,7 +3854,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3814
3854
  }
3815
3855
 
3816
3856
  async function loadSquareShape(engine) {
3817
- engine.checkVersion("4.5.0");
3857
+ engine.checkVersion("4.5.2");
3818
3858
  await engine.pluginManager.register(e => {
3819
3859
  e.pluginManager.addShape(["edge", "square"], () => Promise.resolve(new SquareDrawer()));
3820
3860
  });
@@ -3923,7 +3963,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3923
3963
  }
3924
3964
 
3925
3965
  async function loadTiltUpdater(engine) {
3926
- engine.checkVersion("4.5.0");
3966
+ engine.checkVersion("4.5.2");
3927
3967
  await engine.pluginManager.register(e => {
3928
3968
  e.pluginManager.addParticleUpdater("tilt", container => {
3929
3969
  return Promise.resolve(new TiltUpdater(container));
@@ -4025,7 +4065,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
4025
4065
  }
4026
4066
 
4027
4067
  async function loadWobbleUpdater(engine) {
4028
- engine.checkVersion("4.5.0");
4068
+ engine.checkVersion("4.5.2");
4029
4069
  await engine.pluginManager.register(e => {
4030
4070
  e.pluginManager.addParticleUpdater("wobble", container => {
4031
4071
  return Promise.resolve(new WobbleUpdater(container));
@@ -4349,7 +4389,8 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
4349
4389
  });
4350
4390
  }
4351
4391
  drawParticles(delta) {
4352
- const { particles, actualOptions } = this.#container, clearedPlugin = this.clear();
4392
+ const { particles, actualOptions } = this.#container;
4393
+ this.clear();
4353
4394
  particles.update(delta);
4354
4395
  this.draw(ctx => {
4355
4396
  const width = this.#canvasManager.size.width, height = this.#canvasManager.size.height;
@@ -4371,9 +4412,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
4371
4412
  }
4372
4413
  }
4373
4414
  for (const plugin of this.#getLayerPlugins(DrawLayer.BackgroundMask)) {
4374
- if (plugin !== clearedPlugin) {
4375
- plugin.canvasPaint?.();
4376
- }
4415
+ plugin.canvasPaint?.();
4377
4416
  }
4378
4417
  for (const plugin of this.#getLayerPlugins(DrawLayer.CanvasSetup)) {
4379
4418
  plugin.drawSettingsSetup?.(ctx, delta);
@@ -4463,6 +4502,9 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
4463
4502
  ctx.clearRect(originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
4464
4503
  });
4465
4504
  }
4505
+ updateBackgroundElement() {
4506
+ this.#resolveBackgroundElement();
4507
+ }
4466
4508
  #applyPostDrawUpdaters(particle) {
4467
4509
  for (const updater of this.#postDrawUpdaters) {
4468
4510
  updater.afterDraw?.(particle);
@@ -4661,7 +4703,14 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
4661
4703
  }
4662
4704
  if (typeof background.element === "string") {
4663
4705
  if (typeof document !== "undefined") {
4664
- const node = document.querySelector(background.element);
4706
+ let node;
4707
+ try {
4708
+ node = document.querySelector(background.element);
4709
+ }
4710
+ catch {
4711
+ this.#warnOnce("background-element-invalid-selector", `Background element selector "${background.element}" is invalid`);
4712
+ return;
4713
+ }
4665
4714
  if (node && this.#isSupportedElement(node)) {
4666
4715
  this.#backgroundElement = node;
4667
4716
  }
@@ -5107,6 +5156,10 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
5107
5156
  this.#manageListeners(true);
5108
5157
  }
5109
5158
  removeListeners() {
5159
+ if (this.#resizeTimeout !== undefined) {
5160
+ clearTimeout(this.#resizeTimeout);
5161
+ this.#resizeTimeout = undefined;
5162
+ }
5110
5163
  this.#manageListeners(false);
5111
5164
  }
5112
5165
  #handleVisibilityChange() {
@@ -5481,10 +5534,10 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
5481
5534
  runParticleCreatedPlugins(container, this);
5482
5535
  }
5483
5536
  isInsideCanvas(direction) {
5484
- return this.#getInsideCanvasResult({ direction }).inside;
5537
+ return this.#getInsideCanvasResult(direction).inside;
5485
5538
  }
5486
5539
  isInsideCanvasForOutMode(outMode, direction) {
5487
- return this.#getInsideCanvasResult({ direction, outMode }).inside;
5540
+ return this.#getInsideCanvasResult(direction, outMode).inside;
5488
5541
  }
5489
5542
  isShowingBack() {
5490
5543
  if (!this.roll) {
@@ -5601,7 +5654,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
5601
5654
  });
5602
5655
  }
5603
5656
  #getDefaultInsideCanvasResult(direction, outMode) {
5604
- const radius = this.getRadius(), canvasSize = this.#container.canvas.size, position = this.position, isBounce = outMode === OutMode.bounce;
5657
+ const radius = this.getRadius(), canvasSize = this.#container.canvas.size, position = this.position, isBounce = outMode === OutMode.bounce || outMode === OutMode.split;
5605
5658
  if (direction === OutModeDirection.bottom) {
5606
5659
  return {
5607
5660
  inside: isBounce ? position.y + radius < canvasSize.height : position.y - radius < canvasSize.height,
@@ -5643,12 +5696,16 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
5643
5696
  radius: this.getRadius(),
5644
5697
  };
5645
5698
  }
5646
- #getInsideCanvasResult(data) {
5647
- const defaultResult = this.#getDefaultInsideCanvasResult(data.direction, data.outMode), container = this.#container, shapeDrawer = this.shape ? container.shapeDrawers.get(this.shape) : undefined, effectDrawer = this.effect ? container.effectDrawers.get(this.effect) : undefined, shapeCheck = shapeDrawer?.isInsideCanvas, effectCheck = effectDrawer?.isInsideCanvas;
5648
- if (!shapeCheck && !effectCheck) {
5699
+ #getInsideCanvasResult(direction, outMode) {
5700
+ const defaultResult = this.#getDefaultInsideCanvasResult(direction, outMode), container = this.#container, shapeDrawer = this.shape ? container.shapeDrawers.get(this.shape) : undefined, effectDrawer = this.effect ? container.effectDrawers.get(this.effect) : undefined;
5701
+ if (!shapeDrawer?.isInsideCanvas && !effectDrawer?.isInsideCanvas) {
5649
5702
  return defaultResult;
5650
5703
  }
5651
- const callbackData = this.#getInsideCanvasCallbackData(data.direction, data.outMode), shapeResult = shapeCheck ? this.#normalizeInsideCanvasResult(shapeCheck(callbackData), "shape") : undefined, effectResult = effectCheck ? this.#normalizeInsideCanvasResult(effectCheck(callbackData), "effect") : undefined;
5704
+ const callbackData = this.#getInsideCanvasCallbackData(direction, outMode), shapeResult = shapeDrawer?.isInsideCanvas
5705
+ ? this.#normalizeInsideCanvasResult(shapeDrawer.isInsideCanvas(callbackData), "shape")
5706
+ : undefined, effectResult = effectDrawer?.isInsideCanvas
5707
+ ? this.#normalizeInsideCanvasResult(effectDrawer.isInsideCanvas(callbackData), "effect")
5708
+ : undefined;
5652
5709
  if (shapeResult && effectResult) {
5653
5710
  const margin = Math.max(shapeResult.margin ?? defaultAngle, effectResult.margin ?? defaultAngle);
5654
5711
  return {
@@ -5714,8 +5771,8 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
5714
5771
  }
5715
5772
 
5716
5773
  class SpatialHashGrid {
5717
- #cellSize;
5718
5774
  #cells = new Map();
5775
+ #cellSize;
5719
5776
  #circlePool = [];
5720
5777
  #circlePoolIdx;
5721
5778
  #pendingCellSize;
@@ -5761,14 +5818,22 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
5761
5818
  return out;
5762
5819
  }
5763
5820
  queryCircle(position, radius, check, out = []) {
5764
- const circle = this.#acquireCircle(position.x, position.y, radius), result = this.query(circle, check, out);
5765
- this.#releaseShapes();
5766
- return result;
5821
+ const circle = this.#acquireCircle(position.x, position.y, radius);
5822
+ try {
5823
+ return this.query(circle, check, out);
5824
+ }
5825
+ finally {
5826
+ this.#circlePoolIdx--;
5827
+ }
5767
5828
  }
5768
5829
  queryRectangle(position, size, check, out = []) {
5769
- const rect = this.#acquireRectangle(position.x, position.y, size.width, size.height), result = this.query(rect, check, out);
5770
- this.#releaseShapes();
5771
- return result;
5830
+ const rect = this.#acquireRectangle(position.x, position.y, size.width, size.height);
5831
+ try {
5832
+ return this.query(rect, check, out);
5833
+ }
5834
+ finally {
5835
+ this.#rectanglePoolIdx--;
5836
+ }
5772
5837
  }
5773
5838
  #acquireCircle(x, y, r) {
5774
5839
  const idx = this.#circlePoolIdx++;
@@ -5827,10 +5892,6 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
5827
5892
  }
5828
5893
  }
5829
5894
  }
5830
- #releaseShapes() {
5831
- this.#circlePoolIdx = 0;
5832
- this.#rectanglePoolIdx = 0;
5833
- }
5834
5895
  }
5835
5896
 
5836
5897
  class ParticlesManager {
@@ -6369,8 +6430,8 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
6369
6430
  particleCreatedPlugins;
6370
6431
  particleDestroyedPlugins;
6371
6432
  particlePositionPlugins;
6372
- particleUpdaters;
6373
6433
  particles;
6434
+ particleUpdaters;
6374
6435
  peakNits;
6375
6436
  plugins;
6376
6437
  retina;
@@ -6378,6 +6439,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
6378
6439
  started;
6379
6440
  zLayers;
6380
6441
  #delay;
6442
+ #delayResolve;
6381
6443
  #delayTimeout;
6382
6444
  #delta = { value: 0, factor: 0 };
6383
6445
  #dispatchCallback;
@@ -6616,7 +6678,10 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
6616
6678
  await this.init();
6617
6679
  this.started = true;
6618
6680
  await new Promise(resolve => {
6681
+ this.#delayResolve = resolve;
6619
6682
  const start = async () => {
6683
+ this.#delayTimeout = undefined;
6684
+ this.#delayResolve = undefined;
6620
6685
  this.#eventListeners.addListeners();
6621
6686
  for (const plugin of this.plugins) {
6622
6687
  await plugin.start?.();
@@ -6632,9 +6697,11 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
6632
6697
  if (!guardCheck(this) || !this.started) {
6633
6698
  return;
6634
6699
  }
6635
- if (this.#delayTimeout) {
6700
+ if (this.#delayTimeout !== undefined) {
6636
6701
  clearTimeout(this.#delayTimeout);
6637
6702
  this.#delayTimeout = undefined;
6703
+ this.#delayResolve?.();
6704
+ this.#delayResolve = undefined;
6638
6705
  }
6639
6706
  this.#firstStart = true;
6640
6707
  this.started = false;
@@ -6658,6 +6725,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
6658
6725
  refresh = plugin.updateActualOptions() || refresh;
6659
6726
  }
6660
6727
  }
6728
+ this.canvas.render.updateBackgroundElement();
6661
6729
  return refresh;
6662
6730
  }
6663
6731
  #initPlugins(allContainerPlugins) {
@@ -7269,6 +7337,10 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
7269
7337
  if (this.options.spawn.stroke?.color) {
7270
7338
  this.spawnStrokeColor = rangeColorToHsl(this.#pluginManager, this.options.spawn.stroke.color);
7271
7339
  }
7340
+ const spawnFill = this.options.spawn.fill, spawnStroke = this.options.spawn.stroke;
7341
+ this.spawnFillOpacity = spawnFill?.opacity === undefined ? defaultOpacity$1 : getRangeValue(spawnFill.opacity);
7342
+ this.spawnStrokeOpacity = spawnStroke?.opacity === undefined ? defaultOpacity$1 : getRangeValue(spawnStroke.opacity);
7343
+ this.spawnStrokeWidth = spawnStroke?.width === undefined ? defaultStrokeWidth : getRangeValue(spawnStroke.width);
7272
7344
  this.#paused = !this.options.autoPlay;
7273
7345
  this.#particlesOptions = particlesOptions;
7274
7346
  this.#size = this.#calcSize();
@@ -7416,8 +7488,10 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
7416
7488
  this.#lifeCount--;
7417
7489
  }
7418
7490
  if (this.#lifeCount > minLifeCount || this.#immortal) {
7419
- this.position = this.#calcPosition();
7420
- this.#shape?.resize(this.position, this.size);
7491
+ if (!this.#positionOverride) {
7492
+ this.position = this.#calcPosition();
7493
+ this.#shape?.resize(this.position, this.size);
7494
+ }
7421
7495
  this.#spawnDelay = container.retina.reduceFactor
7422
7496
  ? (getRangeValue(this.options.life.delay ?? defaultLifeDelay) * millisecondsToSeconds) /
7423
7497
  container.retina.reduceFactor