@tsparticles/preset-hyperspace 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
  }
@@ -2666,7 +2706,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
2666
2706
  }
2667
2707
 
2668
2708
  async function loadOpacityUpdater(engine) {
2669
- engine.checkVersion("4.5.0");
2709
+ engine.checkVersion("4.5.2");
2670
2710
  await engine.pluginManager.register(e => {
2671
2711
  e.pluginManager.addParticleUpdater("opacity", container => {
2672
2712
  return Promise.resolve(new OpacityUpdater(container));
@@ -2995,7 +3035,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
2995
3035
  }
2996
3036
 
2997
3037
  async function loadOutModesUpdater(engine) {
2998
- engine.checkVersion("4.5.0");
3038
+ engine.checkVersion("4.5.2");
2999
3039
  await engine.pluginManager.register(e => {
3000
3040
  e.pluginManager.addParticleUpdater("outModes", container => {
3001
3041
  return Promise.resolve(new OutOfCanvasUpdater(container));
@@ -3074,7 +3114,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3074
3114
  }
3075
3115
 
3076
3116
  async function loadPaintUpdater(engine) {
3077
- engine.checkVersion("4.5.0");
3117
+ engine.checkVersion("4.5.2");
3078
3118
  await engine.pluginManager.register(e => {
3079
3119
  e.pluginManager.addParticleUpdater("paint", container => {
3080
3120
  return Promise.resolve(new PaintUpdater(e.pluginManager, container));
@@ -3129,7 +3169,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3129
3169
  }
3130
3170
 
3131
3171
  async function loadRgbColorPlugin(engine) {
3132
- engine.checkVersion("4.5.0");
3172
+ engine.checkVersion("4.5.2");
3133
3173
  await engine.pluginManager.register(e => {
3134
3174
  e.pluginManager.addColorManager("rgb", new RgbColorManager());
3135
3175
  });
@@ -3214,7 +3254,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3214
3254
  }
3215
3255
 
3216
3256
  async function loadSizeUpdater(engine) {
3217
- engine.checkVersion("4.5.0");
3257
+ engine.checkVersion("4.5.2");
3218
3258
  await engine.pluginManager.register(e => {
3219
3259
  e.pluginManager.addParticleUpdater("size", container => {
3220
3260
  return Promise.resolve(new SizeUpdater(container));
@@ -3223,7 +3263,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3223
3263
  }
3224
3264
 
3225
3265
  async function loadBasic(engine) {
3226
- engine.checkVersion("4.5.0");
3266
+ engine.checkVersion("4.5.2");
3227
3267
  await engine.pluginManager.register(async (e) => {
3228
3268
  await Promise.all([
3229
3269
  loadBlendPlugin(e),
@@ -3333,7 +3373,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3333
3373
  direction;
3334
3374
  domId;
3335
3375
  draggable = false;
3336
- draw = true;
3376
+ draw = false;
3337
3377
  fill = true;
3338
3378
  life = new EmitterLife();
3339
3379
  name;
@@ -3477,7 +3517,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3477
3517
  })(EmitterClickMode || (EmitterClickMode = {}));
3478
3518
 
3479
3519
  async function loadEmittersPluginSimple(engine) {
3480
- engine.checkVersion("4.5.0");
3520
+ engine.checkVersion("4.5.2");
3481
3521
  if (typeof process !== "undefined" && process.env.NODE_ENV !== "production") {
3482
3522
  addErrorMessages(ErrorMessages);
3483
3523
  }
@@ -3626,7 +3666,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3626
3666
  }
3627
3667
 
3628
3668
  async function loadEmittersShapeSquare(engine) {
3629
- engine.checkVersion("4.5.0");
3669
+ engine.checkVersion("4.5.2");
3630
3670
  await engine.pluginManager.register((e) => {
3631
3671
  ensureEmittersPluginLoaded(e);
3632
3672
  e.pluginManager.addEmitterShapeGenerator?.("square", new EmittersSquareShapeGenerator());
@@ -3708,7 +3748,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3708
3748
  particle.destroy();
3709
3749
  return;
3710
3750
  }
3711
- const widthRange = setRangeValue(minCanvasSize, canvasSize.width), heightRange = setRangeValue(minCanvasSize, canvasSize.width);
3751
+ const widthRange = setRangeValue(minCanvasSize, canvasSize.width), heightRange = setRangeValue(minCanvasSize, canvasSize.height);
3712
3752
  particle.position.x = randomInRangeValue(widthRange);
3713
3753
  particle.position.y = randomInRangeValue(heightRange);
3714
3754
  particle.spawning = true;
@@ -3770,7 +3810,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3770
3810
  }
3771
3811
 
3772
3812
  async function loadLifeUpdater(engine) {
3773
- engine.checkVersion("4.5.0");
3813
+ engine.checkVersion("4.5.2");
3774
3814
  await engine.pluginManager.register(e => {
3775
3815
  e.pluginManager.addParticleUpdater("life", container => {
3776
3816
  return Promise.resolve(new LifeUpdater(container));
@@ -3834,7 +3874,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
3834
3874
  }
3835
3875
 
3836
3876
  async function loadTrailPlugin(engine) {
3837
- engine.checkVersion("4.5.0");
3877
+ engine.checkVersion("4.5.2");
3838
3878
  await engine.pluginManager.register(e => {
3839
3879
  e.pluginManager.addPlugin(new TrailPlugin(e.pluginManager));
3840
3880
  });
@@ -4085,7 +4125,8 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
4085
4125
  });
4086
4126
  }
4087
4127
  drawParticles(delta) {
4088
- const { particles, actualOptions } = this.#container, clearedPlugin = this.clear();
4128
+ const { particles, actualOptions } = this.#container;
4129
+ this.clear();
4089
4130
  particles.update(delta);
4090
4131
  this.draw(ctx => {
4091
4132
  const width = this.#canvasManager.size.width, height = this.#canvasManager.size.height;
@@ -4107,9 +4148,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
4107
4148
  }
4108
4149
  }
4109
4150
  for (const plugin of this.#getLayerPlugins(DrawLayer.BackgroundMask)) {
4110
- if (plugin !== clearedPlugin) {
4111
- plugin.canvasPaint?.();
4112
- }
4151
+ plugin.canvasPaint?.();
4113
4152
  }
4114
4153
  for (const plugin of this.#getLayerPlugins(DrawLayer.CanvasSetup)) {
4115
4154
  plugin.drawSettingsSetup?.(ctx, delta);
@@ -4199,6 +4238,9 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
4199
4238
  ctx.clearRect(originPoint.x, originPoint.y, this.#canvasManager.size.width, this.#canvasManager.size.height);
4200
4239
  });
4201
4240
  }
4241
+ updateBackgroundElement() {
4242
+ this.#resolveBackgroundElement();
4243
+ }
4202
4244
  #applyPostDrawUpdaters(particle) {
4203
4245
  for (const updater of this.#postDrawUpdaters) {
4204
4246
  updater.afterDraw?.(particle);
@@ -4397,7 +4439,14 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
4397
4439
  }
4398
4440
  if (typeof background.element === "string") {
4399
4441
  if (typeof document !== "undefined") {
4400
- const node = document.querySelector(background.element);
4442
+ let node;
4443
+ try {
4444
+ node = document.querySelector(background.element);
4445
+ }
4446
+ catch {
4447
+ this.#warnOnce("background-element-invalid-selector", `Background element selector "${background.element}" is invalid`);
4448
+ return;
4449
+ }
4401
4450
  if (node && this.#isSupportedElement(node)) {
4402
4451
  this.#backgroundElement = node;
4403
4452
  }
@@ -4843,6 +4892,10 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
4843
4892
  this.#manageListeners(true);
4844
4893
  }
4845
4894
  removeListeners() {
4895
+ if (this.#resizeTimeout !== undefined) {
4896
+ clearTimeout(this.#resizeTimeout);
4897
+ this.#resizeTimeout = undefined;
4898
+ }
4846
4899
  this.#manageListeners(false);
4847
4900
  }
4848
4901
  #handleVisibilityChange() {
@@ -5217,10 +5270,10 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
5217
5270
  runParticleCreatedPlugins(container, this);
5218
5271
  }
5219
5272
  isInsideCanvas(direction) {
5220
- return this.#getInsideCanvasResult({ direction }).inside;
5273
+ return this.#getInsideCanvasResult(direction).inside;
5221
5274
  }
5222
5275
  isInsideCanvasForOutMode(outMode, direction) {
5223
- return this.#getInsideCanvasResult({ direction, outMode }).inside;
5276
+ return this.#getInsideCanvasResult(direction, outMode).inside;
5224
5277
  }
5225
5278
  isShowingBack() {
5226
5279
  if (!this.roll) {
@@ -5337,7 +5390,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
5337
5390
  });
5338
5391
  }
5339
5392
  #getDefaultInsideCanvasResult(direction, outMode) {
5340
- const radius = this.getRadius(), canvasSize = this.#container.canvas.size, position = this.position, isBounce = outMode === OutMode.bounce;
5393
+ const radius = this.getRadius(), canvasSize = this.#container.canvas.size, position = this.position, isBounce = outMode === OutMode.bounce || outMode === OutMode.split;
5341
5394
  if (direction === OutModeDirection.bottom) {
5342
5395
  return {
5343
5396
  inside: isBounce ? position.y + radius < canvasSize.height : position.y - radius < canvasSize.height,
@@ -5379,12 +5432,16 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
5379
5432
  radius: this.getRadius(),
5380
5433
  };
5381
5434
  }
5382
- #getInsideCanvasResult(data) {
5383
- 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;
5384
- if (!shapeCheck && !effectCheck) {
5435
+ #getInsideCanvasResult(direction, outMode) {
5436
+ 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;
5437
+ if (!shapeDrawer?.isInsideCanvas && !effectDrawer?.isInsideCanvas) {
5385
5438
  return defaultResult;
5386
5439
  }
5387
- const callbackData = this.#getInsideCanvasCallbackData(data.direction, data.outMode), shapeResult = shapeCheck ? this.#normalizeInsideCanvasResult(shapeCheck(callbackData), "shape") : undefined, effectResult = effectCheck ? this.#normalizeInsideCanvasResult(effectCheck(callbackData), "effect") : undefined;
5440
+ const callbackData = this.#getInsideCanvasCallbackData(direction, outMode), shapeResult = shapeDrawer?.isInsideCanvas
5441
+ ? this.#normalizeInsideCanvasResult(shapeDrawer.isInsideCanvas(callbackData), "shape")
5442
+ : undefined, effectResult = effectDrawer?.isInsideCanvas
5443
+ ? this.#normalizeInsideCanvasResult(effectDrawer.isInsideCanvas(callbackData), "effect")
5444
+ : undefined;
5388
5445
  if (shapeResult && effectResult) {
5389
5446
  const margin = Math.max(shapeResult.margin ?? defaultAngle, effectResult.margin ?? defaultAngle);
5390
5447
  return {
@@ -5450,8 +5507,8 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
5450
5507
  }
5451
5508
 
5452
5509
  class SpatialHashGrid {
5453
- #cellSize;
5454
5510
  #cells = new Map();
5511
+ #cellSize;
5455
5512
  #circlePool = [];
5456
5513
  #circlePoolIdx;
5457
5514
  #pendingCellSize;
@@ -5497,14 +5554,22 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
5497
5554
  return out;
5498
5555
  }
5499
5556
  queryCircle(position, radius, check, out = []) {
5500
- const circle = this.#acquireCircle(position.x, position.y, radius), result = this.query(circle, check, out);
5501
- this.#releaseShapes();
5502
- return result;
5557
+ const circle = this.#acquireCircle(position.x, position.y, radius);
5558
+ try {
5559
+ return this.query(circle, check, out);
5560
+ }
5561
+ finally {
5562
+ this.#circlePoolIdx--;
5563
+ }
5503
5564
  }
5504
5565
  queryRectangle(position, size, check, out = []) {
5505
- const rect = this.#acquireRectangle(position.x, position.y, size.width, size.height), result = this.query(rect, check, out);
5506
- this.#releaseShapes();
5507
- return result;
5566
+ const rect = this.#acquireRectangle(position.x, position.y, size.width, size.height);
5567
+ try {
5568
+ return this.query(rect, check, out);
5569
+ }
5570
+ finally {
5571
+ this.#rectanglePoolIdx--;
5572
+ }
5508
5573
  }
5509
5574
  #acquireCircle(x, y, r) {
5510
5575
  const idx = this.#circlePoolIdx++;
@@ -5563,10 +5628,6 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
5563
5628
  }
5564
5629
  }
5565
5630
  }
5566
- #releaseShapes() {
5567
- this.#circlePoolIdx = 0;
5568
- this.#rectanglePoolIdx = 0;
5569
- }
5570
5631
  }
5571
5632
 
5572
5633
  class ParticlesManager {
@@ -6105,8 +6166,8 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
6105
6166
  particleCreatedPlugins;
6106
6167
  particleDestroyedPlugins;
6107
6168
  particlePositionPlugins;
6108
- particleUpdaters;
6109
6169
  particles;
6170
+ particleUpdaters;
6110
6171
  peakNits;
6111
6172
  plugins;
6112
6173
  retina;
@@ -6114,6 +6175,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
6114
6175
  started;
6115
6176
  zLayers;
6116
6177
  #delay;
6178
+ #delayResolve;
6117
6179
  #delayTimeout;
6118
6180
  #delta = { value: 0, factor: 0 };
6119
6181
  #dispatchCallback;
@@ -6352,7 +6414,10 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
6352
6414
  await this.init();
6353
6415
  this.started = true;
6354
6416
  await new Promise(resolve => {
6417
+ this.#delayResolve = resolve;
6355
6418
  const start = async () => {
6419
+ this.#delayTimeout = undefined;
6420
+ this.#delayResolve = undefined;
6356
6421
  this.#eventListeners.addListeners();
6357
6422
  for (const plugin of this.plugins) {
6358
6423
  await plugin.start?.();
@@ -6368,9 +6433,11 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
6368
6433
  if (!guardCheck(this) || !this.started) {
6369
6434
  return;
6370
6435
  }
6371
- if (this.#delayTimeout) {
6436
+ if (this.#delayTimeout !== undefined) {
6372
6437
  clearTimeout(this.#delayTimeout);
6373
6438
  this.#delayTimeout = undefined;
6439
+ this.#delayResolve?.();
6440
+ this.#delayResolve = undefined;
6374
6441
  }
6375
6442
  this.#firstStart = true;
6376
6443
  this.started = false;
@@ -6394,6 +6461,7 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
6394
6461
  refresh = plugin.updateActualOptions() || refresh;
6395
6462
  }
6396
6463
  }
6464
+ this.canvas.render.updateBackgroundElement();
6397
6465
  return refresh;
6398
6466
  }
6399
6467
  #initPlugins(allContainerPlugins) {
@@ -6977,6 +7045,10 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
6977
7045
  if (this.options.spawn.stroke?.color) {
6978
7046
  this.spawnStrokeColor = rangeColorToHsl(this.#pluginManager, this.options.spawn.stroke.color);
6979
7047
  }
7048
+ const spawnFill = this.options.spawn.fill, spawnStroke = this.options.spawn.stroke;
7049
+ this.spawnFillOpacity = spawnFill?.opacity === undefined ? defaultOpacity$1 : getRangeValue(spawnFill.opacity);
7050
+ this.spawnStrokeOpacity = spawnStroke?.opacity === undefined ? defaultOpacity$1 : getRangeValue(spawnStroke.opacity);
7051
+ this.spawnStrokeWidth = spawnStroke?.width === undefined ? defaultStrokeWidth : getRangeValue(spawnStroke.width);
6980
7052
  this.#paused = !this.options.autoPlay;
6981
7053
  this.#particlesOptions = particlesOptions;
6982
7054
  this.#size = this.#calcSize();
@@ -7124,8 +7196,10 @@ g.__tsParticlesInternals.presets = g.__tsParticlesInternals.presets || {};
7124
7196
  this.#lifeCount--;
7125
7197
  }
7126
7198
  if (this.#lifeCount > minLifeCount || this.#immortal) {
7127
- this.position = this.#calcPosition();
7128
- this.#shape?.resize(this.position, this.size);
7199
+ if (!this.#positionOverride) {
7200
+ this.position = this.#calcPosition();
7201
+ this.#shape?.resize(this.position, this.size);
7202
+ }
7129
7203
  this.#spawnDelay = container.retina.reduceFactor
7130
7204
  ? (getRangeValue(this.options.life.delay ?? defaultLifeDelay) * millisecondsToSeconds) /
7131
7205
  container.retina.reduceFactor