tsparticles 1.39.2 → 1.40.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.
Files changed (168) hide show
  1. package/Core/Container.d.ts +3 -1
  2. package/Core/Container.js +30 -15
  3. package/Core/Loader.d.ts +12 -9
  4. package/Core/Loader.js +35 -19
  5. package/Core/Particle.d.ts +3 -1
  6. package/Core/Particle.js +17 -2
  7. package/Core/Particles.d.ts +3 -1
  8. package/Core/Particles.js +20 -5
  9. package/Core/Utils/InteractionManager.d.ts +5 -3
  10. package/Core/Utils/InteractionManager.js +19 -3
  11. package/Core/Utils/Plugins.d.ts +29 -15
  12. package/Core/Utils/Plugins.js +58 -46
  13. package/Options/Classes/Options.d.ts +2 -1
  14. package/Options/Classes/Options.js +14 -7
  15. package/Plugins/Emitters/EmitterInstance.d.ts +6 -3
  16. package/Plugins/Emitters/EmitterInstance.js +46 -16
  17. package/Plugins/Emitters/Emitters.d.ts +3 -1
  18. package/Plugins/Emitters/Emitters.js +17 -2
  19. package/Plugins/Emitters/{EmittersMain.d.ts → EmittersEngine.d.ts} +3 -1
  20. package/Plugins/Emitters/{EmittersMain.js → EmittersEngine.js} +0 -0
  21. package/Plugins/Emitters/IEmitterShape.d.ts +2 -2
  22. package/Plugins/Emitters/Options/Classes/Emitter.d.ts +1 -0
  23. package/Plugins/Emitters/Options/Classes/Emitter.js +1 -0
  24. package/Plugins/Emitters/Options/Interfaces/IEmitter.d.ts +1 -0
  25. package/Plugins/Emitters/ShapeManager.d.ts +6 -3
  26. package/Plugins/Emitters/ShapeManager.js +16 -4
  27. package/Plugins/Emitters/Shapes/Circle/CircleShape.d.ts +2 -2
  28. package/Plugins/Emitters/Shapes/Circle/CircleShape.js +2 -2
  29. package/Plugins/Emitters/Shapes/Square/SquareShape.d.ts +2 -2
  30. package/Plugins/Emitters/Shapes/Square/SquareShape.js +4 -4
  31. package/Plugins/Emitters/index.d.ts +3 -3
  32. package/Plugins/Emitters/index.js +25 -6
  33. package/README.md +1 -1
  34. package/browser/Core/Container.d.ts +4 -1
  35. package/browser/Core/Container.js +32 -16
  36. package/browser/Core/Loader.d.ts +12 -9
  37. package/browser/Core/Loader.js +35 -19
  38. package/browser/Core/Particle.d.ts +3 -1
  39. package/browser/Core/Particle.js +18 -3
  40. package/browser/Core/Particles.d.ts +3 -1
  41. package/browser/Core/Particles.js +21 -6
  42. package/browser/Core/Utils/InteractionManager.d.ts +5 -3
  43. package/browser/Core/Utils/InteractionManager.js +19 -3
  44. package/browser/Core/Utils/Plugins.d.ts +29 -15
  45. package/browser/Core/Utils/Plugins.js +58 -46
  46. package/browser/Options/Classes/Options.d.ts +2 -1
  47. package/browser/Options/Classes/Options.js +14 -7
  48. package/browser/Plugins/Emitters/EmitterInstance.d.ts +6 -3
  49. package/browser/Plugins/Emitters/EmitterInstance.js +46 -16
  50. package/browser/Plugins/Emitters/Emitters.d.ts +3 -1
  51. package/browser/Plugins/Emitters/Emitters.js +17 -2
  52. package/{esm/Plugins/Emitters/EmittersMain.d.ts → browser/Plugins/Emitters/EmittersEngine.d.ts} +3 -1
  53. package/browser/Plugins/Emitters/{EmittersMain.js → EmittersEngine.js} +0 -0
  54. package/browser/Plugins/Emitters/IEmitterShape.d.ts +2 -2
  55. package/browser/Plugins/Emitters/Options/Classes/Emitter.d.ts +1 -0
  56. package/browser/Plugins/Emitters/Options/Classes/Emitter.js +1 -0
  57. package/browser/Plugins/Emitters/Options/Interfaces/IEmitter.d.ts +4 -0
  58. package/browser/Plugins/Emitters/ShapeManager.d.ts +6 -3
  59. package/browser/Plugins/Emitters/ShapeManager.js +16 -4
  60. package/browser/Plugins/Emitters/Shapes/Circle/CircleShape.d.ts +2 -2
  61. package/browser/Plugins/Emitters/Shapes/Circle/CircleShape.js +2 -2
  62. package/browser/Plugins/Emitters/Shapes/Square/SquareShape.d.ts +2 -2
  63. package/browser/Plugins/Emitters/Shapes/Square/SquareShape.js +4 -4
  64. package/browser/Plugins/Emitters/index.d.ts +3 -3
  65. package/browser/Plugins/Emitters/index.js +25 -6
  66. package/browser/engine.d.ts +5 -1
  67. package/browser/engine.js +22 -17
  68. package/engine.d.ts +3 -0
  69. package/engine.js +20 -16
  70. package/esm/Core/Container.d.ts +3 -1
  71. package/esm/Core/Container.js +31 -16
  72. package/esm/Core/Loader.d.ts +12 -9
  73. package/esm/Core/Loader.js +35 -19
  74. package/esm/Core/Particle.d.ts +3 -1
  75. package/esm/Core/Particle.js +18 -3
  76. package/esm/Core/Particles.d.ts +3 -1
  77. package/esm/Core/Particles.js +21 -6
  78. package/esm/Core/Utils/InteractionManager.d.ts +5 -3
  79. package/esm/Core/Utils/InteractionManager.js +19 -3
  80. package/esm/Core/Utils/Plugins.d.ts +29 -15
  81. package/esm/Core/Utils/Plugins.js +58 -46
  82. package/esm/Options/Classes/Options.d.ts +2 -1
  83. package/esm/Options/Classes/Options.js +14 -7
  84. package/esm/Plugins/Emitters/EmitterInstance.d.ts +6 -3
  85. package/esm/Plugins/Emitters/EmitterInstance.js +46 -16
  86. package/esm/Plugins/Emitters/Emitters.d.ts +3 -1
  87. package/esm/Plugins/Emitters/Emitters.js +17 -2
  88. package/{browser/Plugins/Emitters/EmittersMain.d.ts → esm/Plugins/Emitters/EmittersEngine.d.ts} +3 -1
  89. package/esm/Plugins/Emitters/{EmittersMain.js → EmittersEngine.js} +0 -0
  90. package/esm/Plugins/Emitters/IEmitterShape.d.ts +2 -2
  91. package/esm/Plugins/Emitters/Options/Classes/Emitter.d.ts +1 -0
  92. package/esm/Plugins/Emitters/Options/Classes/Emitter.js +1 -0
  93. package/esm/Plugins/Emitters/Options/Interfaces/IEmitter.d.ts +1 -0
  94. package/esm/Plugins/Emitters/ShapeManager.d.ts +6 -3
  95. package/esm/Plugins/Emitters/ShapeManager.js +16 -4
  96. package/esm/Plugins/Emitters/Shapes/Circle/CircleShape.d.ts +2 -2
  97. package/esm/Plugins/Emitters/Shapes/Circle/CircleShape.js +2 -2
  98. package/esm/Plugins/Emitters/Shapes/Square/SquareShape.d.ts +2 -2
  99. package/esm/Plugins/Emitters/Shapes/Square/SquareShape.js +4 -4
  100. package/esm/Plugins/Emitters/index.d.ts +3 -3
  101. package/esm/Plugins/Emitters/index.js +25 -6
  102. package/esm/engine.d.ts +3 -0
  103. package/esm/engine.js +20 -16
  104. package/package.json +11 -6
  105. package/report.html +2 -2
  106. package/report.slim.html +2 -2
  107. package/tsparticles.engine.js +227 -118
  108. package/tsparticles.engine.min.js +2 -2
  109. package/tsparticles.interaction.external.attract.js +205 -100
  110. package/tsparticles.interaction.external.attract.min.js +2 -2
  111. package/tsparticles.interaction.external.bounce.js +205 -100
  112. package/tsparticles.interaction.external.bounce.min.js +2 -2
  113. package/tsparticles.interaction.external.bubble.js +205 -100
  114. package/tsparticles.interaction.external.bubble.min.js +2 -2
  115. package/tsparticles.interaction.external.connect.js +205 -100
  116. package/tsparticles.interaction.external.connect.min.js +2 -2
  117. package/tsparticles.interaction.external.grab.js +205 -100
  118. package/tsparticles.interaction.external.grab.min.js +2 -2
  119. package/tsparticles.interaction.external.repulse.js +205 -100
  120. package/tsparticles.interaction.external.repulse.min.js +2 -2
  121. package/tsparticles.interaction.external.trail.js +205 -100
  122. package/tsparticles.interaction.external.trail.min.js +2 -2
  123. package/tsparticles.interaction.particles.attract.js +205 -100
  124. package/tsparticles.interaction.particles.attract.min.js +2 -2
  125. package/tsparticles.interaction.particles.collisions.js +205 -100
  126. package/tsparticles.interaction.particles.collisions.min.js +2 -2
  127. package/tsparticles.interaction.particles.links.js +205 -100
  128. package/tsparticles.interaction.particles.links.min.js +2 -2
  129. package/tsparticles.js +347 -156
  130. package/tsparticles.min.js +2 -2
  131. package/tsparticles.pathseg.min.js +1 -1
  132. package/tsparticles.plugins.absorbers.js +205 -100
  133. package/tsparticles.plugins.absorbers.min.js +2 -2
  134. package/tsparticles.plugins.emitters.js +330 -143
  135. package/tsparticles.plugins.emitters.min.js +2 -2
  136. package/tsparticles.plugins.polygonMask.js +205 -100
  137. package/tsparticles.plugins.polygonMask.min.js +2 -2
  138. package/tsparticles.shape.circle.min.js +1 -1
  139. package/tsparticles.shape.image.js +208 -103
  140. package/tsparticles.shape.image.min.js +2 -2
  141. package/tsparticles.shape.line.min.js +1 -1
  142. package/tsparticles.shape.polygon.min.js +1 -1
  143. package/tsparticles.shape.square.min.js +1 -1
  144. package/tsparticles.shape.star.min.js +1 -1
  145. package/tsparticles.shape.text.js +205 -100
  146. package/tsparticles.shape.text.min.js +2 -2
  147. package/tsparticles.slim.js +227 -118
  148. package/tsparticles.slim.min.js +2 -2
  149. package/tsparticles.updater.angle.js +205 -100
  150. package/tsparticles.updater.angle.min.js +2 -2
  151. package/tsparticles.updater.color.js +205 -100
  152. package/tsparticles.updater.color.min.js +2 -2
  153. package/tsparticles.updater.life.js +205 -100
  154. package/tsparticles.updater.life.min.js +2 -2
  155. package/tsparticles.updater.opacity.js +205 -100
  156. package/tsparticles.updater.opacity.min.js +2 -2
  157. package/tsparticles.updater.outModes.js +205 -100
  158. package/tsparticles.updater.outModes.min.js +2 -2
  159. package/tsparticles.updater.roll.js +205 -100
  160. package/tsparticles.updater.roll.min.js +2 -2
  161. package/tsparticles.updater.size.js +205 -100
  162. package/tsparticles.updater.size.min.js +2 -2
  163. package/tsparticles.updater.strokeColor.js +205 -100
  164. package/tsparticles.updater.strokeColor.min.js +2 -2
  165. package/tsparticles.updater.tilt.js +205 -100
  166. package/tsparticles.updater.tilt.min.js +2 -2
  167. package/tsparticles.updater.wobble.js +205 -100
  168. package/tsparticles.updater.wobble.min.js +2 -2
@@ -506,15 +506,32 @@
506
506
  }
507
507
  }
508
508
  }
509
+ var __classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
510
+ if (kind === "m") throw new TypeError("Private method is not writable");
511
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
512
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
513
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value),
514
+ value;
515
+ };
516
+ var __classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
517
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
518
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
519
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
520
+ };
521
+ var _InteractionManager_engine;
509
522
  class InteractionManager_InteractionManager {
510
- constructor(container) {
523
+ constructor(engine, container) {
511
524
  this.container = container;
525
+ _InteractionManager_engine.set(this, void 0);
526
+ __classPrivateFieldSet(this, _InteractionManager_engine, engine, "f");
512
527
  this.externalInteractors = [];
513
528
  this.particleInteractors = [];
514
529
  this.init();
515
530
  }
516
531
  init() {
517
- const interactors = Plugins.getInteractors(this.container, true);
532
+ const interactors = __classPrivateFieldGet(this, _InteractionManager_engine, "f").plugins.getInteractors(this.container, true);
533
+ this.externalInteractors = [];
534
+ this.particleInteractors = [];
518
535
  for (const interactor of interactors) {
519
536
  switch (interactor.type) {
520
537
  case 0:
@@ -545,6 +562,7 @@
545
562
  }
546
563
  }
547
564
  }
565
+ _InteractionManager_engine = new WeakMap;
548
566
  function applyDistance(particle) {
549
567
  const initialPosition = particle.initialPosition;
550
568
  const {dx: dx, dy: dy} = getDistances(initialPosition, particle.position);
@@ -718,26 +736,38 @@
718
736
  return proximityFactor / slowFactor;
719
737
  }
720
738
  }
721
- const plugins = null && [];
722
- const interactorsInitializers = new Map;
723
- const updatersInitializers = new Map;
724
- const interactors = new Map;
725
- const updaters = new Map;
726
- const presets = new Map;
727
- const drawers = new Map;
728
- const pathGenerators = new Map;
729
- class Plugins_Plugins {
730
- static getPlugin(plugin) {
731
- return plugins.find((t => t.id === plugin));
739
+ var Plugins_classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
740
+ if (kind === "m") throw new TypeError("Private method is not writable");
741
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
742
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
743
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value),
744
+ value;
745
+ };
746
+ var _Plugins_engine;
747
+ class Plugins {
748
+ constructor(engine) {
749
+ _Plugins_engine.set(this, void 0);
750
+ Plugins_classPrivateFieldSet(this, _Plugins_engine, engine, "f");
751
+ this.plugins = [];
752
+ this.interactorsInitializers = new Map;
753
+ this.updatersInitializers = new Map;
754
+ this.interactors = new Map;
755
+ this.updaters = new Map;
756
+ this.presets = new Map;
757
+ this.drawers = new Map;
758
+ this.pathGenerators = new Map;
732
759
  }
733
- static addPlugin(plugin) {
734
- if (!Plugins_Plugins.getPlugin(plugin.id)) {
735
- plugins.push(plugin);
760
+ getPlugin(plugin) {
761
+ return this.plugins.find((t => t.id === plugin));
762
+ }
763
+ addPlugin(plugin) {
764
+ if (!this.getPlugin(plugin.id)) {
765
+ this.plugins.push(plugin);
736
766
  }
737
767
  }
738
- static getAvailablePlugins(container) {
768
+ getAvailablePlugins(container) {
739
769
  const res = new Map;
740
- for (const plugin of plugins) {
770
+ for (const plugin of this.plugins) {
741
771
  if (!plugin.needsPlugin(container.actualOptions)) {
742
772
  continue;
743
773
  }
@@ -745,61 +775,62 @@
745
775
  }
746
776
  return res;
747
777
  }
748
- static loadOptions(options, sourceOptions) {
749
- for (const plugin of plugins) {
778
+ loadOptions(options, sourceOptions) {
779
+ for (const plugin of this.plugins) {
750
780
  plugin.loadOptions(options, sourceOptions);
751
781
  }
752
782
  }
753
- static getPreset(preset) {
754
- return presets.get(preset);
783
+ getPreset(preset) {
784
+ return this.presets.get(preset);
755
785
  }
756
- static addPreset(presetKey, options, override = false) {
757
- if (override || !Plugins_Plugins.getPreset(presetKey)) {
758
- presets.set(presetKey, options);
786
+ addPreset(presetKey, options, override = false) {
787
+ if (override || !this.getPreset(presetKey)) {
788
+ this.presets.set(presetKey, options);
759
789
  }
760
790
  }
761
- static addShapeDrawer(type, drawer) {
762
- if (!Plugins_Plugins.getShapeDrawer(type)) {
763
- drawers.set(type, drawer);
791
+ addShapeDrawer(type, drawer) {
792
+ if (!this.getShapeDrawer(type)) {
793
+ this.drawers.set(type, drawer);
764
794
  }
765
795
  }
766
- static getShapeDrawer(type) {
767
- return drawers.get(type);
796
+ getShapeDrawer(type) {
797
+ return this.drawers.get(type);
768
798
  }
769
- static getSupportedShapes() {
770
- return drawers.keys();
799
+ getSupportedShapes() {
800
+ return this.drawers.keys();
771
801
  }
772
- static getPathGenerator(type) {
773
- return pathGenerators.get(type);
802
+ getPathGenerator(type) {
803
+ return this.pathGenerators.get(type);
774
804
  }
775
- static addPathGenerator(type, pathGenerator) {
776
- if (!Plugins_Plugins.getPathGenerator(type)) {
777
- pathGenerators.set(type, pathGenerator);
805
+ addPathGenerator(type, pathGenerator) {
806
+ if (!this.getPathGenerator(type)) {
807
+ this.pathGenerators.set(type, pathGenerator);
778
808
  }
779
809
  }
780
- static getInteractors(container, force = false) {
781
- let res = interactors.get(container);
810
+ getInteractors(container, force = false) {
811
+ let res = this.interactors.get(container);
782
812
  if (!res || force) {
783
- res = [ ...interactorsInitializers.values() ].map((t => t(container)));
784
- interactors.set(container, res);
813
+ res = [ ...this.interactorsInitializers.values() ].map((t => t(container)));
814
+ this.interactors.set(container, res);
785
815
  }
786
816
  return res;
787
817
  }
788
- static addInteractor(name, initInteractor) {
789
- interactorsInitializers.set(name, initInteractor);
818
+ addInteractor(name, initInteractor) {
819
+ this.interactorsInitializers.set(name, initInteractor);
790
820
  }
791
- static getUpdaters(container, force = false) {
792
- let res = updaters.get(container);
821
+ getUpdaters(container, force = false) {
822
+ let res = this.updaters.get(container);
793
823
  if (!res || force) {
794
- res = [ ...updatersInitializers.values() ].map((t => t(container)));
795
- updaters.set(container, res);
824
+ res = [ ...this.updatersInitializers.values() ].map((t => t(container)));
825
+ this.updaters.set(container, res);
796
826
  }
797
827
  return res;
798
828
  }
799
- static addParticleUpdater(name, initUpdater) {
800
- updatersInitializers.set(name, initUpdater);
829
+ addParticleUpdater(name, initUpdater) {
830
+ this.updatersInitializers.set(name, initUpdater);
801
831
  }
802
832
  }
833
+ _Plugins_engine = new WeakMap;
803
834
  class QuadTree_QuadTree {
804
835
  constructor(rectangle, capacity) {
805
836
  this.rectangle = rectangle;
@@ -2326,22 +2357,31 @@
2326
2357
  }
2327
2358
  }
2328
2359
  }
2329
- var __classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
2360
+ var Options_classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
2361
+ if (kind === "m") throw new TypeError("Private method is not writable");
2362
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
2363
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
2364
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value),
2365
+ value;
2366
+ };
2367
+ var Options_classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
2330
2368
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
2331
2369
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
2332
2370
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2333
2371
  };
2334
- var _Options_instances, _Options_findDefaultTheme;
2372
+ var _Options_instances, _Options_engine, _Options_findDefaultTheme;
2335
2373
  class Options_Options {
2336
- constructor() {
2374
+ constructor(engine) {
2337
2375
  _Options_instances.add(this);
2376
+ _Options_engine.set(this, void 0);
2377
+ Options_classPrivateFieldSet(this, _Options_engine, engine, "f");
2338
2378
  this.autoPlay = true;
2339
2379
  this.background = new Background;
2340
2380
  this.backgroundMask = new BackgroundMask;
2341
2381
  this.fullScreen = new FullScreen;
2342
2382
  this.detectRetina = true;
2343
2383
  this.duration = 0;
2344
- this.fpsLimit = 60;
2384
+ this.fpsLimit = 120;
2345
2385
  this.interactivity = new Interactivity;
2346
2386
  this.manualParticles = [];
2347
2387
  this.motion = new Motion;
@@ -2427,7 +2467,7 @@
2427
2467
  this.motion.load(data.motion);
2428
2468
  this.particles.load(data.particles);
2429
2469
  this.style = deepExtend(this.style, data.style);
2430
- Plugins.loadOptions(this, data);
2470
+ Options_classPrivateFieldGet(this, _Options_engine, "f").plugins.loadOptions(this, data);
2431
2471
  if (data.responsive !== undefined) {
2432
2472
  for (const responsive of data.responsive) {
2433
2473
  const optResponsive = new Responsive;
@@ -2443,8 +2483,8 @@
2443
2483
  this.themes.push(optTheme);
2444
2484
  }
2445
2485
  }
2446
- this.defaultDarkTheme = (_d = __classPrivateFieldGet(this, _Options_instances, "m", _Options_findDefaultTheme).call(this, "dark")) === null || _d === void 0 ? void 0 : _d.name;
2447
- this.defaultLightTheme = (_e = __classPrivateFieldGet(this, _Options_instances, "m", _Options_findDefaultTheme).call(this, "light")) === null || _e === void 0 ? void 0 : _e.name;
2486
+ this.defaultDarkTheme = (_d = Options_classPrivateFieldGet(this, _Options_instances, "m", _Options_findDefaultTheme).call(this, "dark")) === null || _d === void 0 ? void 0 : _d.name;
2487
+ this.defaultLightTheme = (_e = Options_classPrivateFieldGet(this, _Options_instances, "m", _Options_findDefaultTheme).call(this, "light")) === null || _e === void 0 ? void 0 : _e.name;
2448
2488
  }
2449
2489
  setTheme(name) {
2450
2490
  if (name) {
@@ -2453,7 +2493,7 @@
2453
2493
  this.load(chosenTheme.options);
2454
2494
  }
2455
2495
  } else {
2456
- const mediaMatch = typeof matchMedia !== "undefined" && matchMedia("(prefers-color-scheme: dark)"), clientDarkMode = mediaMatch && mediaMatch.matches, defaultTheme = __classPrivateFieldGet(this, _Options_instances, "m", _Options_findDefaultTheme).call(this, clientDarkMode ? "dark" : "light");
2496
+ const mediaMatch = typeof matchMedia !== "undefined" && matchMedia("(prefers-color-scheme: dark)"), clientDarkMode = mediaMatch && mediaMatch.matches, defaultTheme = Options_classPrivateFieldGet(this, _Options_instances, "m", _Options_findDefaultTheme).call(this, clientDarkMode ? "dark" : "light");
2457
2497
  if (defaultTheme) {
2458
2498
  this.load(defaultTheme.options);
2459
2499
  }
@@ -2466,13 +2506,26 @@
2466
2506
  return responsiveOptions === null || responsiveOptions === void 0 ? void 0 : responsiveOptions.maxWidth;
2467
2507
  }
2468
2508
  importPreset(preset) {
2469
- this.load(Plugins.getPreset(preset));
2509
+ this.load(Options_classPrivateFieldGet(this, _Options_engine, "f").plugins.getPreset(preset));
2470
2510
  }
2471
2511
  }
2472
- _Options_instances = new WeakSet, _Options_findDefaultTheme = function _Options_findDefaultTheme(mode) {
2512
+ _Options_engine = new WeakMap, _Options_instances = new WeakSet, _Options_findDefaultTheme = function _Options_findDefaultTheme(mode) {
2473
2513
  var _a;
2474
2514
  return (_a = this.themes.find((theme => theme.default.value && theme.default.mode === mode))) !== null && _a !== void 0 ? _a : this.themes.find((theme => theme.default.value && theme.default.mode === "any"));
2475
2515
  };
2516
+ var Particle_classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
2517
+ if (kind === "m") throw new TypeError("Private method is not writable");
2518
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
2519
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
2520
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value),
2521
+ value;
2522
+ };
2523
+ var Particle_classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
2524
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
2525
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
2526
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2527
+ };
2528
+ var _Particle_engine;
2476
2529
  const fixOutMode = data => {
2477
2530
  if (isInArray(data.outMode, data.checkModes) || isInArray(data.outMode, data.checkModes)) {
2478
2531
  if (data.coord > data.maxCoord - data.radius * 2) {
@@ -2483,11 +2536,13 @@
2483
2536
  }
2484
2537
  };
2485
2538
  class Particle_Particle {
2486
- constructor(id, container, position, overrideOptions, group) {
2539
+ constructor(engine, id, container, position, overrideOptions, group) {
2487
2540
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
2488
2541
  this.id = id;
2489
2542
  this.container = container;
2490
2543
  this.group = group;
2544
+ _Particle_engine.set(this, void 0);
2545
+ Particle_classPrivateFieldSet(this, _Particle_engine, engine, "f");
2491
2546
  this.fill = true;
2492
2547
  this.close = true;
2493
2548
  this.lastPathTime = 0;
@@ -2581,7 +2636,7 @@
2581
2636
  this.sides = 24;
2582
2637
  let drawer = container.drawers.get(this.shape);
2583
2638
  if (!drawer) {
2584
- drawer = Plugins.getShapeDrawer(this.shape);
2639
+ drawer = Particle_classPrivateFieldGet(this, _Particle_engine, "f").plugins.getShapeDrawer(this.shape);
2585
2640
  if (drawer) {
2586
2641
  container.drawers.set(this.shape, drawer);
2587
2642
  }
@@ -2821,9 +2876,25 @@
2821
2876
  return life;
2822
2877
  }
2823
2878
  }
2879
+ _Particle_engine = new WeakMap;
2880
+ var Particles_classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
2881
+ if (kind === "m") throw new TypeError("Private method is not writable");
2882
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
2883
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
2884
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value),
2885
+ value;
2886
+ };
2887
+ var Particles_classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
2888
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
2889
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
2890
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2891
+ };
2892
+ var _Particles_engine;
2824
2893
  class Particles_Particles {
2825
- constructor(container) {
2894
+ constructor(engine, container) {
2826
2895
  this.container = container;
2896
+ _Particles_engine.set(this, void 0);
2897
+ Particles_classPrivateFieldSet(this, _Particles_engine, engine, "f");
2827
2898
  this.nextId = 0;
2828
2899
  this.array = [];
2829
2900
  this.zArray = [];
@@ -2835,11 +2906,11 @@
2835
2906
  links: new Map,
2836
2907
  triangles: new Map
2837
2908
  };
2838
- this.interactionManager = new InteractionManager(container);
2909
+ this.interactionManager = new InteractionManager(Particles_classPrivateFieldGet(this, _Particles_engine, "f"), container);
2839
2910
  const canvasSize = this.container.canvas.size;
2840
2911
  this.linksColors = new Map;
2841
2912
  this.quadTree = new QuadTree(new Rectangle(-canvasSize.width / 4, -canvasSize.height / 4, canvasSize.width * 3 / 2, canvasSize.height * 3 / 2), 4);
2842
- this.updaters = Plugins.getUpdaters(container, true);
2913
+ this.updaters = Particles_classPrivateFieldGet(this, _Particles_engine, "f").plugins.getUpdaters(container, true);
2843
2914
  }
2844
2915
  get count() {
2845
2916
  return this.array.length;
@@ -2853,7 +2924,7 @@
2853
2924
  this.freqs.links = new Map;
2854
2925
  this.freqs.triangles = new Map;
2855
2926
  let handled = false;
2856
- this.updaters = Plugins.getUpdaters(container, true);
2927
+ this.updaters = Particles_classPrivateFieldGet(this, _Particles_engine, "f").plugins.getUpdaters(container, true);
2857
2928
  this.interactionManager.init();
2858
2929
  for (const [, plugin] of container.plugins) {
2859
2930
  if (plugin.particlesInitialization !== undefined) {
@@ -3100,7 +3171,7 @@
3100
3171
  }
3101
3172
  pushParticle(position, overrideOptions, group, initializer) {
3102
3173
  try {
3103
- const particle = new Particle(this.nextId, this.container, position, overrideOptions, group);
3174
+ const particle = new Particle(Particles_classPrivateFieldGet(this, _Particles_engine, "f"), this.nextId, this.container, position, overrideOptions, group);
3104
3175
  let canAdd = true;
3105
3176
  if (initializer) {
3106
3177
  canAdd = initializer(particle);
@@ -3118,6 +3189,7 @@
3118
3189
  }
3119
3190
  }
3120
3191
  }
3192
+ _Particles_engine = new WeakMap;
3121
3193
  class Retina_Retina {
3122
3194
  constructor(container) {
3123
3195
  this.container = container;
@@ -3205,10 +3277,25 @@
3205
3277
  }
3206
3278
  }
3207
3279
  }
3280
+ var Container_classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
3281
+ if (kind === "m") throw new TypeError("Private method is not writable");
3282
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
3283
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
3284
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value),
3285
+ value;
3286
+ };
3287
+ var Container_classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
3288
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3289
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
3290
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
3291
+ };
3292
+ var _Container_engine;
3208
3293
  class Container_Container {
3209
- constructor(id, sourceOptions, ...presets) {
3294
+ constructor(engine, id, sourceOptions, ...presets) {
3210
3295
  this.id = id;
3211
- this.fpsLimit = 60;
3296
+ _Container_engine.set(this, void 0);
3297
+ Container_classPrivateFieldSet(this, _Container_engine, engine, "f");
3298
+ this.fpsLimit = 120;
3212
3299
  this.duration = 0;
3213
3300
  this.lifeTime = 0;
3214
3301
  this.firstStart = true;
@@ -3222,7 +3309,7 @@
3222
3309
  this._initialSourceOptions = sourceOptions;
3223
3310
  this.retina = new Retina(this);
3224
3311
  this.canvas = new Canvas(this);
3225
- this.particles = new Particles(this);
3312
+ this.particles = new Particles(Container_classPrivateFieldGet(this, _Container_engine, "f"), this);
3226
3313
  this.drawer = new FrameManager(this);
3227
3314
  this.presets = presets;
3228
3315
  this.pathGenerator = {
@@ -3251,8 +3338,8 @@
3251
3338
  this.plugins = new Map;
3252
3339
  this.drawers = new Map;
3253
3340
  this.density = 1;
3254
- this._options = new Options;
3255
- this.actualOptions = new Options;
3341
+ this._options = new Options(Container_classPrivateFieldGet(this, _Container_engine, "f"));
3342
+ this.actualOptions = new Options(Container_classPrivateFieldGet(this, _Container_engine, "f"));
3256
3343
  this.eventListeners = new EventListeners(this);
3257
3344
  if (typeof IntersectionObserver !== "undefined" && IntersectionObserver) {
3258
3345
  this.intersectionObserver = new IntersectionObserver((entries => this.intersectionManager(entries)));
@@ -3367,7 +3454,7 @@
3367
3454
  return this.start();
3368
3455
  }
3369
3456
  reset() {
3370
- this._options = new Options;
3457
+ this._options = new Options(Container_classPrivateFieldGet(this, _Container_engine, "f"));
3371
3458
  return this.refresh();
3372
3459
  }
3373
3460
  stop() {
@@ -3381,7 +3468,7 @@
3381
3468
  this.particles.clear();
3382
3469
  this.canvas.clear();
3383
3470
  if (this.interactivity.element instanceof HTMLElement && this.intersectionObserver) {
3384
- this.intersectionObserver.observe(this.interactivity.element);
3471
+ this.intersectionObserver.unobserve(this.interactivity.element);
3385
3472
  }
3386
3473
  for (const [, plugin] of this.plugins) {
3387
3474
  if (plugin.stop) {
@@ -3508,20 +3595,20 @@
3508
3595
  return false;
3509
3596
  }
3510
3597
  async init() {
3511
- this._options = new Options;
3598
+ this._options = new Options(Container_classPrivateFieldGet(this, _Container_engine, "f"));
3512
3599
  for (const preset of this.presets) {
3513
- this._options.load(Plugins.getPreset(preset));
3600
+ this._options.load(Container_classPrivateFieldGet(this, _Container_engine, "f").plugins.getPreset(preset));
3514
3601
  }
3515
- const shapes = Plugins.getSupportedShapes();
3602
+ const shapes = Container_classPrivateFieldGet(this, _Container_engine, "f").plugins.getSupportedShapes();
3516
3603
  for (const type of shapes) {
3517
- const drawer = Plugins.getShapeDrawer(type);
3604
+ const drawer = Container_classPrivateFieldGet(this, _Container_engine, "f").plugins.getShapeDrawer(type);
3518
3605
  if (drawer) {
3519
3606
  this.drawers.set(type, drawer);
3520
3607
  }
3521
3608
  }
3522
3609
  this._options.load(this._initialSourceOptions);
3523
3610
  this._options.load(this._sourceOptions);
3524
- this.actualOptions = new Options;
3611
+ this.actualOptions = new Options(Container_classPrivateFieldGet(this, _Container_engine, "f"));
3525
3612
  this.actualOptions.load(this._options);
3526
3613
  this.retina.init();
3527
3614
  this.canvas.init();
@@ -3531,8 +3618,8 @@
3531
3618
  this.zLayers = this.actualOptions.zLayers;
3532
3619
  this.duration = getRangeValue(this.actualOptions.duration);
3533
3620
  this.lifeTime = 0;
3534
- this.fpsLimit = this.actualOptions.fpsLimit > 0 ? this.actualOptions.fpsLimit : 60;
3535
- const availablePlugins = Plugins.getAvailablePlugins(this);
3621
+ this.fpsLimit = this.actualOptions.fpsLimit > 0 ? this.actualOptions.fpsLimit : 120;
3622
+ const availablePlugins = Container_classPrivateFieldGet(this, _Container_engine, "f").plugins.getAvailablePlugins(this);
3536
3623
  for (const [id, plugin] of availablePlugins) {
3537
3624
  this.plugins.set(id, plugin);
3538
3625
  }
@@ -3550,7 +3637,7 @@
3550
3637
  }
3551
3638
  const pathOptions = this.actualOptions.particles.move.path;
3552
3639
  if (pathOptions.generator) {
3553
- const customGenerator = Plugins.getPathGenerator(pathOptions.generator);
3640
+ const customGenerator = Container_classPrivateFieldGet(this, _Container_engine, "f").plugins.getPathGenerator(pathOptions.generator);
3554
3641
  if (customGenerator) {
3555
3642
  if (customGenerator.init) {
3556
3643
  this.pathGenerator.init = customGenerator.init;
@@ -3587,24 +3674,41 @@
3587
3674
  }
3588
3675
  }
3589
3676
  }
3590
- const tsParticlesDom = null && [];
3677
+ _Container_engine = new WeakMap;
3678
+ var Loader_classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
3679
+ if (kind === "m") throw new TypeError("Private method is not writable");
3680
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
3681
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
3682
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value),
3683
+ value;
3684
+ };
3685
+ var Loader_classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
3686
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3687
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
3688
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
3689
+ };
3690
+ var _Loader_engine;
3591
3691
  function fetchError(statusCode) {
3592
3692
  console.error(`Error tsParticles - fetch status: ${statusCode}`);
3593
3693
  console.error("Error tsParticles - File config not found");
3594
3694
  }
3595
3695
  class Loader {
3596
- static dom() {
3597
- return tsParticlesDom;
3696
+ constructor(engine) {
3697
+ _Loader_engine.set(this, void 0);
3698
+ Loader_classPrivateFieldSet(this, _Loader_engine, engine, "f");
3598
3699
  }
3599
- static domItem(index) {
3600
- const dom = Loader.dom();
3700
+ dom() {
3701
+ return Loader_classPrivateFieldGet(this, _Loader_engine, "f").domArray;
3702
+ }
3703
+ domItem(index) {
3704
+ const dom = this.dom();
3601
3705
  const item = dom[index];
3602
3706
  if (item && !item.destroyed) {
3603
3707
  return item;
3604
3708
  }
3605
3709
  dom.splice(index, 1);
3606
3710
  }
3607
- static async loadOptions(params) {
3711
+ async loadOptions(params) {
3608
3712
  var _a, _b, _c;
3609
3713
  const tagId = (_a = params.tagId) !== null && _a !== void 0 ? _a : `tsparticles${Math.floor(Math.random() * 1e4)}`;
3610
3714
  const {options: options, index: index} = params;
@@ -3615,10 +3719,10 @@
3615
3719
  (_c = document.querySelector("body")) === null || _c === void 0 ? void 0 : _c.append(domContainer);
3616
3720
  }
3617
3721
  const currentOptions = options instanceof Array ? itemFromArray(options, index) : options;
3618
- const dom = Loader.dom();
3722
+ const dom = this.dom();
3619
3723
  const oldIndex = dom.findIndex((v => v.id === tagId));
3620
3724
  if (oldIndex >= 0) {
3621
- const old = Loader.domItem(oldIndex);
3725
+ const old = this.domItem(oldIndex);
3622
3726
  if (old && !old.destroyed) {
3623
3727
  old.destroy();
3624
3728
  dom.splice(oldIndex, 1);
@@ -3641,7 +3745,7 @@
3641
3745
  domContainer.appendChild(canvasEl);
3642
3746
  }
3643
3747
  }
3644
- const newItem = new Container(tagId, currentOptions);
3748
+ const newItem = new Container(Loader_classPrivateFieldGet(this, _Loader_engine, "f"), tagId, currentOptions);
3645
3749
  if (oldIndex >= 0) {
3646
3750
  dom.splice(oldIndex, 0, newItem);
3647
3751
  } else {
@@ -3651,7 +3755,7 @@
3651
3755
  await newItem.start();
3652
3756
  return newItem;
3653
3757
  }
3654
- static async loadRemoteOptions(params) {
3758
+ async loadRemoteOptions(params) {
3655
3759
  const {url: jsonUrl, index: index} = params;
3656
3760
  const url = jsonUrl instanceof Array ? itemFromArray(jsonUrl, index) : jsonUrl;
3657
3761
  if (!url) {
@@ -3663,14 +3767,14 @@
3663
3767
  return;
3664
3768
  }
3665
3769
  const data = await response.json();
3666
- return await Loader.loadOptions({
3770
+ return this.loadOptions({
3667
3771
  tagId: params.tagId,
3668
3772
  element: params.element,
3669
3773
  index: index,
3670
3774
  options: data
3671
3775
  });
3672
3776
  }
3673
- static load(tagId, options, index) {
3777
+ load(tagId, options, index) {
3674
3778
  const params = {
3675
3779
  index: index
3676
3780
  };
@@ -3686,7 +3790,7 @@
3686
3790
  }
3687
3791
  return this.loadOptions(params);
3688
3792
  }
3689
- static async set(id, domContainer, options, index) {
3793
+ async set(id, domContainer, options, index) {
3690
3794
  const params = {
3691
3795
  index: index
3692
3796
  };
@@ -3707,7 +3811,7 @@
3707
3811
  }
3708
3812
  return this.loadOptions(params);
3709
3813
  }
3710
- static async loadJSON(tagId, jsonUrl, index) {
3814
+ async loadJSON(tagId, jsonUrl, index) {
3711
3815
  let url, id;
3712
3816
  if (typeof jsonUrl === "number" || jsonUrl === undefined) {
3713
3817
  url = tagId;
@@ -3715,13 +3819,13 @@
3715
3819
  id = tagId;
3716
3820
  url = jsonUrl;
3717
3821
  }
3718
- return await Loader.loadRemoteOptions({
3822
+ return this.loadRemoteOptions({
3719
3823
  tagId: id,
3720
3824
  url: url,
3721
3825
  index: index
3722
3826
  });
3723
3827
  }
3724
- static async setJSON(id, domContainer, jsonUrl, index) {
3828
+ async setJSON(id, domContainer, jsonUrl, index) {
3725
3829
  let url, newId, newIndex, element;
3726
3830
  if (id instanceof HTMLElement) {
3727
3831
  element = id;
@@ -3733,15 +3837,15 @@
3733
3837
  url = jsonUrl;
3734
3838
  newIndex = index;
3735
3839
  }
3736
- return await Loader.loadRemoteOptions({
3840
+ return this.loadRemoteOptions({
3737
3841
  tagId: newId,
3738
3842
  url: url,
3739
3843
  index: newIndex,
3740
3844
  element: element
3741
3845
  });
3742
3846
  }
3743
- static setOnClickHandler(callback) {
3744
- const dom = Loader.dom();
3847
+ setOnClickHandler(callback) {
3848
+ const dom = this.dom();
3745
3849
  if (dom.length === 0) {
3746
3850
  throw new Error("Can only set click handlers after calling tsParticles.load() or tsParticles.loadJSON()");
3747
3851
  }
@@ -3750,6 +3854,7 @@
3750
3854
  }
3751
3855
  }
3752
3856
  }
3857
+ _Loader_engine = new WeakMap;
3753
3858
  function NumberUtils_clamp(num, min, max) {
3754
3859
  return Math.min(Math.max(num, min), max);
3755
3860
  }
@@ -4886,7 +4991,7 @@
4886
4991
  img.src = url;
4887
4992
  return imageRes;
4888
4993
  }
4889
- var __classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
4994
+ var ImageDrawer_classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
4890
4995
  if (kind === "m") throw new TypeError("Private method is not writable");
4891
4996
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4892
4997
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
@@ -4902,7 +5007,7 @@
4902
5007
  class ImageDrawer {
4903
5008
  constructor() {
4904
5009
  _ImageDrawer_images.set(this, void 0);
4905
- __classPrivateFieldSet(this, _ImageDrawer_images, [], "f");
5010
+ ImageDrawer_classPrivateFieldSet(this, _ImageDrawer_images, [], "f");
4906
5011
  }
4907
5012
  getSidesCount() {
4908
5013
  return 12;
@@ -4924,7 +5029,7 @@
4924
5029
  containerImages === null || containerImages === void 0 ? void 0 : containerImages.images.push(image);
4925
5030
  }
4926
5031
  destroy() {
4927
- __classPrivateFieldSet(this, _ImageDrawer_images, [], "f");
5032
+ ImageDrawer_classPrivateFieldSet(this, _ImageDrawer_images, [], "f");
4928
5033
  }
4929
5034
  async loadImageShape(container, imageShape) {
4930
5035
  const source = imageShape.src;