@tsparticles/particles 4.5.0 → 4.5.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.
@@ -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
- /* tsParticles v4.5.0 */
3
+ /* tsParticles v4.5.1 */
4
4
  g.__tsParticlesInternals = g.__tsParticlesInternals || {};
5
5
  g.__tsParticlesInternals.bundles = g.__tsParticlesInternals.bundles || {};
6
6
  (function (exports) {
@@ -737,12 +737,8 @@ g.__tsParticlesInternals.bundles = g.__tsParticlesInternals.bundles || {};
737
737
  }
738
738
  addEventListener(type, listener) {
739
739
  this.removeEventListener(type, listener);
740
- let arr = this.#listeners.get(type);
741
- if (!arr) {
742
- arr = [];
743
- this.#listeners.set(type, arr);
744
- }
745
- arr.push(listener);
740
+ const arr = this.#listeners.get(type);
741
+ this.#listeners.set(type, arr ? [...arr, listener] : [listener]);
746
742
  }
747
743
  dispatchEvent(type, args) {
748
744
  const listeners = this.#listeners.get(type);
@@ -774,7 +770,7 @@ g.__tsParticlesInternals.bundles = g.__tsParticlesInternals.bundles || {};
774
770
  this.#listeners.delete(type);
775
771
  }
776
772
  else {
777
- arr.splice(idx, deleteCount);
773
+ this.#listeners.set(type, [...arr.slice(minIndex, idx), ...arr.slice(idx + deleteCount)]);
778
774
  }
779
775
  }
780
776
  }
@@ -955,7 +951,7 @@ g.__tsParticlesInternals.bundles = g.__tsParticlesInternals.bundles || {};
955
951
  return this.#domArray;
956
952
  }
957
953
  get version() {
958
- return "4.5.0";
954
+ return "4.5.1";
959
955
  }
960
956
  addEventListener(type, listener) {
961
957
  this.#eventDispatcher.addEventListener(type, listener);
@@ -2521,7 +2517,7 @@ g.__tsParticlesInternals.bundles = g.__tsParticlesInternals.bundles || {};
2521
2517
  }
2522
2518
 
2523
2519
  async function loadBlendPlugin(engine) {
2524
- engine.checkVersion("4.5.0");
2520
+ engine.checkVersion("4.5.1");
2525
2521
  await engine.pluginManager.register(e => {
2526
2522
  e.pluginManager.addPlugin(new BlendPlugin());
2527
2523
  });
@@ -2558,7 +2554,7 @@ g.__tsParticlesInternals.bundles = g.__tsParticlesInternals.bundles || {};
2558
2554
  }
2559
2555
 
2560
2556
  async function loadCircleShape(engine) {
2561
- engine.checkVersion("4.5.0");
2557
+ engine.checkVersion("4.5.1");
2562
2558
  await engine.pluginManager.register(e => {
2563
2559
  e.pluginManager.addShape(["circle"], () => {
2564
2560
  return Promise.resolve(new CircleDrawer());
@@ -2606,7 +2602,7 @@ g.__tsParticlesInternals.bundles = g.__tsParticlesInternals.bundles || {};
2606
2602
  }
2607
2603
 
2608
2604
  async function loadHexColorPlugin(engine) {
2609
- engine.checkVersion("4.5.0");
2605
+ engine.checkVersion("4.5.1");
2610
2606
  await engine.pluginManager.register(e => {
2611
2607
  e.pluginManager.addColorManager("hex", new HexColorManager());
2612
2608
  });
@@ -2659,7 +2655,7 @@ g.__tsParticlesInternals.bundles = g.__tsParticlesInternals.bundles || {};
2659
2655
  }
2660
2656
 
2661
2657
  async function loadHslColorPlugin(engine) {
2662
- engine.checkVersion("4.5.0");
2658
+ engine.checkVersion("4.5.1");
2663
2659
  await engine.pluginManager.register(e => {
2664
2660
  e.pluginManager.addColorManager("hsl", new HslColorManager());
2665
2661
  });
@@ -2691,7 +2687,7 @@ g.__tsParticlesInternals.bundles = g.__tsParticlesInternals.bundles || {};
2691
2687
  }
2692
2688
 
2693
2689
  async function loadMovePlugin(engine) {
2694
- engine.checkVersion("4.5.0");
2690
+ engine.checkVersion("4.5.1");
2695
2691
  if (typeof process !== "undefined" && process.env.NODE_ENV !== "production") {
2696
2692
  addErrorMessages(ErrorMessages$2);
2697
2693
  }
@@ -2901,7 +2897,7 @@ g.__tsParticlesInternals.bundles = g.__tsParticlesInternals.bundles || {};
2901
2897
  }
2902
2898
 
2903
2899
  async function loadOpacityUpdater(engine) {
2904
- engine.checkVersion("4.5.0");
2900
+ engine.checkVersion("4.5.1");
2905
2901
  await engine.pluginManager.register(e => {
2906
2902
  e.pluginManager.addParticleUpdater("opacity", container => {
2907
2903
  return Promise.resolve(new OpacityUpdater(container));
@@ -3230,7 +3226,7 @@ g.__tsParticlesInternals.bundles = g.__tsParticlesInternals.bundles || {};
3230
3226
  }
3231
3227
 
3232
3228
  async function loadOutModesUpdater(engine) {
3233
- engine.checkVersion("4.5.0");
3229
+ engine.checkVersion("4.5.1");
3234
3230
  await engine.pluginManager.register(e => {
3235
3231
  e.pluginManager.addParticleUpdater("outModes", container => {
3236
3232
  return Promise.resolve(new OutOfCanvasUpdater(container));
@@ -3309,7 +3305,7 @@ g.__tsParticlesInternals.bundles = g.__tsParticlesInternals.bundles || {};
3309
3305
  }
3310
3306
 
3311
3307
  async function loadPaintUpdater(engine) {
3312
- engine.checkVersion("4.5.0");
3308
+ engine.checkVersion("4.5.1");
3313
3309
  await engine.pluginManager.register(e => {
3314
3310
  e.pluginManager.addParticleUpdater("paint", container => {
3315
3311
  return Promise.resolve(new PaintUpdater(e.pluginManager, container));
@@ -3364,7 +3360,7 @@ g.__tsParticlesInternals.bundles = g.__tsParticlesInternals.bundles || {};
3364
3360
  }
3365
3361
 
3366
3362
  async function loadRgbColorPlugin(engine) {
3367
- engine.checkVersion("4.5.0");
3363
+ engine.checkVersion("4.5.1");
3368
3364
  await engine.pluginManager.register(e => {
3369
3365
  e.pluginManager.addColorManager("rgb", new RgbColorManager());
3370
3366
  });
@@ -3449,7 +3445,7 @@ g.__tsParticlesInternals.bundles = g.__tsParticlesInternals.bundles || {};
3449
3445
  }
3450
3446
 
3451
3447
  async function loadSizeUpdater(engine) {
3452
- engine.checkVersion("4.5.0");
3448
+ engine.checkVersion("4.5.1");
3453
3449
  await engine.pluginManager.register(e => {
3454
3450
  e.pluginManager.addParticleUpdater("size", container => {
3455
3451
  return Promise.resolve(new SizeUpdater(container));
@@ -3458,7 +3454,7 @@ g.__tsParticlesInternals.bundles = g.__tsParticlesInternals.bundles || {};
3458
3454
  }
3459
3455
 
3460
3456
  async function loadBasic(engine) {
3461
- engine.checkVersion("4.5.0");
3457
+ engine.checkVersion("4.5.1");
3462
3458
  await engine.pluginManager.register(async (e) => {
3463
3459
  await Promise.all([
3464
3460
  loadBlendPlugin(e),
@@ -3664,7 +3660,7 @@ g.__tsParticlesInternals.bundles = g.__tsParticlesInternals.bundles || {};
3664
3660
  const clickEvent = "click", mouseDownEvent = "pointerdown", mouseUpEvent = "pointerup", mouseLeaveEvent = "pointerleave", mouseMoveEvent = "pointermove", touchStartEvent = "touchstart", touchEndEvent = "touchend", touchMoveEvent = "touchmove", touchCancelEvent = "touchcancel";
3665
3661
 
3666
3662
  async function loadInteractivityPlugin(engine) {
3667
- engine.checkVersion("4.5.0");
3663
+ engine.checkVersion("4.5.1");
3668
3664
  if (typeof process !== "undefined" && process.env.NODE_ENV !== "production") {
3669
3665
  addErrorMessages(ErrorMessages$1);
3670
3666
  }
@@ -4116,7 +4112,7 @@ g.__tsParticlesInternals.bundles = g.__tsParticlesInternals.bundles || {};
4116
4112
  }
4117
4113
 
4118
4114
  async function loadParticlesCollisionsInteraction(engine) {
4119
- engine.checkVersion("4.5.0");
4115
+ engine.checkVersion("4.5.1");
4120
4116
  if (typeof process !== "undefined" && process.env.NODE_ENV !== "production") {
4121
4117
  addErrorMessages(ErrorMessages);
4122
4118
  }
@@ -4176,6 +4172,30 @@ g.__tsParticlesInternals.bundles = g.__tsParticlesInternals.bundles || {};
4176
4172
  }
4177
4173
  return false;
4178
4174
  }
4175
+ query(grid) {
4176
+ const { x, y } = this.position, { width, height } = this.#canvasSize, radius = this.radius, crossesLeft = x - radius <= originPoint.x, crossesRight = x + radius >= width, crossesTop = y - radius <= originPoint.y, crossesBottom = y + radius >= height;
4177
+ if (!crossesLeft && !crossesRight && !crossesTop && !crossesBottom) {
4178
+ return grid.query(this);
4179
+ }
4180
+ const xShifts = [originPoint.x], yShifts = [originPoint.y];
4181
+ if (crossesLeft)
4182
+ xShifts.push(width);
4183
+ if (crossesRight)
4184
+ xShifts.push(-width);
4185
+ if (crossesTop)
4186
+ yShifts.push(height);
4187
+ if (crossesBottom)
4188
+ yShifts.push(-height);
4189
+ const particles = new Set();
4190
+ for (const dx of xShifts) {
4191
+ for (const dy of yShifts) {
4192
+ for (const particle of grid.queryCircle({ x: x + dx, y: y + dy }, radius)) {
4193
+ particles.add(particle);
4194
+ }
4195
+ }
4196
+ }
4197
+ return [...particles];
4198
+ }
4179
4199
  }
4180
4200
 
4181
4201
  class LinksShadow {
@@ -4285,7 +4305,9 @@ g.__tsParticlesInternals.bundles = g.__tsParticlesInternals.bundles || {};
4285
4305
  if (pos1.x < originPoint.x || pos1.y < originPoint.y || pos1.x > canvasSize.width || pos1.y > canvasSize.height) {
4286
4306
  return;
4287
4307
  }
4288
- const linkOpt1 = p1.options.links, optOpacity = linkOpt1.opacity, optDistance = p1.retina.linksDistance ?? minDistance$1, warp = linkOpt1.warp, range = warp ? new CircleWarp(pos1.x, pos1.y, optDistance, canvasSize) : new Circle(pos1.x, pos1.y, optDistance), query = container.particles.grid.query(range);
4308
+ const linkOpt1 = p1.options.links, optOpacity = linkOpt1.opacity, optDistance = p1.retina.linksDistance ?? minDistance$1, warp = linkOpt1.warp, query = (warp
4309
+ ? new CircleWarp(pos1.x, pos1.y, optDistance, canvasSize).query(container.particles.grid)
4310
+ : container.particles.grid.queryCircle(pos1, optDistance));
4289
4311
  for (const p2 of query) {
4290
4312
  const linkOpt2 = p2.options.links;
4291
4313
  if (p1 === p2 ||
@@ -4373,7 +4395,7 @@ g.__tsParticlesInternals.bundles = g.__tsParticlesInternals.bundles || {};
4373
4395
  }
4374
4396
 
4375
4397
  async function loadParticlesLinksInteraction(engine) {
4376
- engine.checkVersion("4.5.0");
4398
+ engine.checkVersion("4.5.1");
4377
4399
  await engine.pluginManager.register((e) => {
4378
4400
  const pluginManager = e.pluginManager;
4379
4401
  ensureInteractivityPluginLoaded(e);
@@ -4386,7 +4408,7 @@ g.__tsParticlesInternals.bundles = g.__tsParticlesInternals.bundles || {};
4386
4408
 
4387
4409
  let initPromise = null;
4388
4410
  async function doInitPlugins(engine) {
4389
- engine.checkVersion("4.5.0");
4411
+ engine.checkVersion("4.5.1");
4390
4412
  await engine.pluginManager.register(async (e) => {
4391
4413
  const loadParticlesInteractivity = async (e) => {
4392
4414
  await loadInteractivityPlugin(e);
@@ -4429,7 +4451,7 @@ g.__tsParticlesInternals.bundles = g.__tsParticlesInternals.bundles || {};
4429
4451
  particles.init = async () => {
4430
4452
  await initPlugins(tsParticles);
4431
4453
  };
4432
- particles.version = "4.5.0";
4454
+ particles.version = "4.5.1";
4433
4455
  globalThis.particles = particles;
4434
4456
 
4435
4457
  const globalObject = globalThis;
@@ -5356,6 +5378,10 @@ g.__tsParticlesInternals.bundles = g.__tsParticlesInternals.bundles || {};
5356
5378
  this.#manageListeners(true);
5357
5379
  }
5358
5380
  removeListeners() {
5381
+ if (this.#resizeTimeout !== undefined) {
5382
+ clearTimeout(this.#resizeTimeout);
5383
+ this.#resizeTimeout = undefined;
5384
+ }
5359
5385
  this.#manageListeners(false);
5360
5386
  }
5361
5387
  #handleVisibilityChange() {
@@ -6010,14 +6036,22 @@ g.__tsParticlesInternals.bundles = g.__tsParticlesInternals.bundles || {};
6010
6036
  return out;
6011
6037
  }
6012
6038
  queryCircle(position, radius, check, out = []) {
6013
- const circle = this.#acquireCircle(position.x, position.y, radius), result = this.query(circle, check, out);
6014
- this.#releaseShapes();
6015
- return result;
6039
+ const circle = this.#acquireCircle(position.x, position.y, radius);
6040
+ try {
6041
+ return this.query(circle, check, out);
6042
+ }
6043
+ finally {
6044
+ this.#circlePoolIdx--;
6045
+ }
6016
6046
  }
6017
6047
  queryRectangle(position, size, check, out = []) {
6018
- const rect = this.#acquireRectangle(position.x, position.y, size.width, size.height), result = this.query(rect, check, out);
6019
- this.#releaseShapes();
6020
- return result;
6048
+ const rect = this.#acquireRectangle(position.x, position.y, size.width, size.height);
6049
+ try {
6050
+ return this.query(rect, check, out);
6051
+ }
6052
+ finally {
6053
+ this.#rectanglePoolIdx--;
6054
+ }
6021
6055
  }
6022
6056
  #acquireCircle(x, y, r) {
6023
6057
  const idx = this.#circlePoolIdx++;
@@ -6076,10 +6110,6 @@ g.__tsParticlesInternals.bundles = g.__tsParticlesInternals.bundles || {};
6076
6110
  }
6077
6111
  }
6078
6112
  }
6079
- #releaseShapes() {
6080
- this.#circlePoolIdx = 0;
6081
- this.#rectanglePoolIdx = 0;
6082
- }
6083
6113
  }
6084
6114
 
6085
6115
  class ParticlesManager {
@@ -6627,6 +6657,7 @@ g.__tsParticlesInternals.bundles = g.__tsParticlesInternals.bundles || {};
6627
6657
  started;
6628
6658
  zLayers;
6629
6659
  #delay;
6660
+ #delayResolve;
6630
6661
  #delayTimeout;
6631
6662
  #delta = { value: 0, factor: 0 };
6632
6663
  #dispatchCallback;
@@ -6865,7 +6896,10 @@ g.__tsParticlesInternals.bundles = g.__tsParticlesInternals.bundles || {};
6865
6896
  await this.init();
6866
6897
  this.started = true;
6867
6898
  await new Promise(resolve => {
6899
+ this.#delayResolve = resolve;
6868
6900
  const start = async () => {
6901
+ this.#delayTimeout = undefined;
6902
+ this.#delayResolve = undefined;
6869
6903
  this.#eventListeners.addListeners();
6870
6904
  for (const plugin of this.plugins) {
6871
6905
  await plugin.start?.();
@@ -6881,9 +6915,11 @@ g.__tsParticlesInternals.bundles = g.__tsParticlesInternals.bundles || {};
6881
6915
  if (!guardCheck(this) || !this.started) {
6882
6916
  return;
6883
6917
  }
6884
- if (this.#delayTimeout) {
6918
+ if (this.#delayTimeout !== undefined) {
6885
6919
  clearTimeout(this.#delayTimeout);
6886
6920
  this.#delayTimeout = undefined;
6921
+ this.#delayResolve?.();
6922
+ this.#delayResolve = undefined;
6887
6923
  }
6888
6924
  this.#firstStart = true;
6889
6925
  this.started = false;
@@ -7347,7 +7383,9 @@ g.__tsParticlesInternals.bundles = g.__tsParticlesInternals.bundles || {};
7347
7383
  manageListener(interactivityEl, mouseMoveEvent, handlers.mouseMove, add);
7348
7384
  manageListener(interactivityEl, touchStartEvent, handlers.touchStart, add);
7349
7385
  manageListener(interactivityEl, touchMoveEvent, handlers.touchMove, add);
7350
- manageListener(interactivityEl, touchEndEvent, options.interactivity?.events.onClick.enable ? handlers.touchEndClick : handlers.touchEnd, add);
7386
+ const onClickEnabled = !!options.interactivity?.events.onClick.enable;
7387
+ manageListener(interactivityEl, touchEndEvent, handlers.touchEndClick, add && onClickEnabled);
7388
+ manageListener(interactivityEl, touchEndEvent, handlers.touchEnd, add && !onClickEnabled);
7351
7389
  manageListener(interactivityEl, mouseUpEvent, handlers.mouseUp, add);
7352
7390
  manageListener(interactivityEl, mouseDownEvent, handlers.mouseDown, add);
7353
7391
  manageListener(interactivityEl, mouseLeaveEvent, handlers.mouseLeave, add);