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
  class ParticlesInteractorBase {
549
567
  constructor(container) {
550
568
  this.container = container;
@@ -724,26 +742,38 @@
724
742
  return proximityFactor / slowFactor;
725
743
  }
726
744
  }
727
- const plugins = null && [];
728
- const interactorsInitializers = new Map;
729
- const updatersInitializers = new Map;
730
- const interactors = new Map;
731
- const updaters = new Map;
732
- const presets = new Map;
733
- const drawers = new Map;
734
- const pathGenerators = new Map;
735
- class Plugins_Plugins {
736
- static getPlugin(plugin) {
737
- return plugins.find((t => t.id === plugin));
745
+ var Plugins_classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
746
+ if (kind === "m") throw new TypeError("Private method is not writable");
747
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
748
+ 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");
749
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value),
750
+ value;
751
+ };
752
+ var _Plugins_engine;
753
+ class Plugins {
754
+ constructor(engine) {
755
+ _Plugins_engine.set(this, void 0);
756
+ Plugins_classPrivateFieldSet(this, _Plugins_engine, engine, "f");
757
+ this.plugins = [];
758
+ this.interactorsInitializers = new Map;
759
+ this.updatersInitializers = new Map;
760
+ this.interactors = new Map;
761
+ this.updaters = new Map;
762
+ this.presets = new Map;
763
+ this.drawers = new Map;
764
+ this.pathGenerators = new Map;
765
+ }
766
+ getPlugin(plugin) {
767
+ return this.plugins.find((t => t.id === plugin));
738
768
  }
739
- static addPlugin(plugin) {
740
- if (!Plugins_Plugins.getPlugin(plugin.id)) {
741
- plugins.push(plugin);
769
+ addPlugin(plugin) {
770
+ if (!this.getPlugin(plugin.id)) {
771
+ this.plugins.push(plugin);
742
772
  }
743
773
  }
744
- static getAvailablePlugins(container) {
774
+ getAvailablePlugins(container) {
745
775
  const res = new Map;
746
- for (const plugin of plugins) {
776
+ for (const plugin of this.plugins) {
747
777
  if (!plugin.needsPlugin(container.actualOptions)) {
748
778
  continue;
749
779
  }
@@ -751,61 +781,62 @@
751
781
  }
752
782
  return res;
753
783
  }
754
- static loadOptions(options, sourceOptions) {
755
- for (const plugin of plugins) {
784
+ loadOptions(options, sourceOptions) {
785
+ for (const plugin of this.plugins) {
756
786
  plugin.loadOptions(options, sourceOptions);
757
787
  }
758
788
  }
759
- static getPreset(preset) {
760
- return presets.get(preset);
789
+ getPreset(preset) {
790
+ return this.presets.get(preset);
761
791
  }
762
- static addPreset(presetKey, options, override = false) {
763
- if (override || !Plugins_Plugins.getPreset(presetKey)) {
764
- presets.set(presetKey, options);
792
+ addPreset(presetKey, options, override = false) {
793
+ if (override || !this.getPreset(presetKey)) {
794
+ this.presets.set(presetKey, options);
765
795
  }
766
796
  }
767
- static addShapeDrawer(type, drawer) {
768
- if (!Plugins_Plugins.getShapeDrawer(type)) {
769
- drawers.set(type, drawer);
797
+ addShapeDrawer(type, drawer) {
798
+ if (!this.getShapeDrawer(type)) {
799
+ this.drawers.set(type, drawer);
770
800
  }
771
801
  }
772
- static getShapeDrawer(type) {
773
- return drawers.get(type);
802
+ getShapeDrawer(type) {
803
+ return this.drawers.get(type);
774
804
  }
775
- static getSupportedShapes() {
776
- return drawers.keys();
805
+ getSupportedShapes() {
806
+ return this.drawers.keys();
777
807
  }
778
- static getPathGenerator(type) {
779
- return pathGenerators.get(type);
808
+ getPathGenerator(type) {
809
+ return this.pathGenerators.get(type);
780
810
  }
781
- static addPathGenerator(type, pathGenerator) {
782
- if (!Plugins_Plugins.getPathGenerator(type)) {
783
- pathGenerators.set(type, pathGenerator);
811
+ addPathGenerator(type, pathGenerator) {
812
+ if (!this.getPathGenerator(type)) {
813
+ this.pathGenerators.set(type, pathGenerator);
784
814
  }
785
815
  }
786
- static getInteractors(container, force = false) {
787
- let res = interactors.get(container);
816
+ getInteractors(container, force = false) {
817
+ let res = this.interactors.get(container);
788
818
  if (!res || force) {
789
- res = [ ...interactorsInitializers.values() ].map((t => t(container)));
790
- interactors.set(container, res);
819
+ res = [ ...this.interactorsInitializers.values() ].map((t => t(container)));
820
+ this.interactors.set(container, res);
791
821
  }
792
822
  return res;
793
823
  }
794
- static addInteractor(name, initInteractor) {
795
- interactorsInitializers.set(name, initInteractor);
824
+ addInteractor(name, initInteractor) {
825
+ this.interactorsInitializers.set(name, initInteractor);
796
826
  }
797
- static getUpdaters(container, force = false) {
798
- let res = updaters.get(container);
827
+ getUpdaters(container, force = false) {
828
+ let res = this.updaters.get(container);
799
829
  if (!res || force) {
800
- res = [ ...updatersInitializers.values() ].map((t => t(container)));
801
- updaters.set(container, res);
830
+ res = [ ...this.updatersInitializers.values() ].map((t => t(container)));
831
+ this.updaters.set(container, res);
802
832
  }
803
833
  return res;
804
834
  }
805
- static addParticleUpdater(name, initUpdater) {
806
- updatersInitializers.set(name, initUpdater);
835
+ addParticleUpdater(name, initUpdater) {
836
+ this.updatersInitializers.set(name, initUpdater);
807
837
  }
808
838
  }
839
+ _Plugins_engine = new WeakMap;
809
840
  class QuadTree_QuadTree {
810
841
  constructor(rectangle, capacity) {
811
842
  this.rectangle = rectangle;
@@ -2423,22 +2454,31 @@
2423
2454
  }
2424
2455
  }
2425
2456
  }
2426
- var __classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
2457
+ var Options_classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
2458
+ if (kind === "m") throw new TypeError("Private method is not writable");
2459
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
2460
+ 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");
2461
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value),
2462
+ value;
2463
+ };
2464
+ var Options_classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
2427
2465
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
2428
2466
  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");
2429
2467
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2430
2468
  };
2431
- var _Options_instances, _Options_findDefaultTheme;
2469
+ var _Options_instances, _Options_engine, _Options_findDefaultTheme;
2432
2470
  class Options_Options {
2433
- constructor() {
2471
+ constructor(engine) {
2434
2472
  _Options_instances.add(this);
2473
+ _Options_engine.set(this, void 0);
2474
+ Options_classPrivateFieldSet(this, _Options_engine, engine, "f");
2435
2475
  this.autoPlay = true;
2436
2476
  this.background = new Background;
2437
2477
  this.backgroundMask = new BackgroundMask;
2438
2478
  this.fullScreen = new FullScreen;
2439
2479
  this.detectRetina = true;
2440
2480
  this.duration = 0;
2441
- this.fpsLimit = 60;
2481
+ this.fpsLimit = 120;
2442
2482
  this.interactivity = new Interactivity;
2443
2483
  this.manualParticles = [];
2444
2484
  this.motion = new Motion;
@@ -2524,7 +2564,7 @@
2524
2564
  this.motion.load(data.motion);
2525
2565
  this.particles.load(data.particles);
2526
2566
  this.style = deepExtend(this.style, data.style);
2527
- Plugins.loadOptions(this, data);
2567
+ Options_classPrivateFieldGet(this, _Options_engine, "f").plugins.loadOptions(this, data);
2528
2568
  if (data.responsive !== undefined) {
2529
2569
  for (const responsive of data.responsive) {
2530
2570
  const optResponsive = new Responsive;
@@ -2540,8 +2580,8 @@
2540
2580
  this.themes.push(optTheme);
2541
2581
  }
2542
2582
  }
2543
- this.defaultDarkTheme = (_d = __classPrivateFieldGet(this, _Options_instances, "m", _Options_findDefaultTheme).call(this, "dark")) === null || _d === void 0 ? void 0 : _d.name;
2544
- this.defaultLightTheme = (_e = __classPrivateFieldGet(this, _Options_instances, "m", _Options_findDefaultTheme).call(this, "light")) === null || _e === void 0 ? void 0 : _e.name;
2583
+ this.defaultDarkTheme = (_d = Options_classPrivateFieldGet(this, _Options_instances, "m", _Options_findDefaultTheme).call(this, "dark")) === null || _d === void 0 ? void 0 : _d.name;
2584
+ this.defaultLightTheme = (_e = Options_classPrivateFieldGet(this, _Options_instances, "m", _Options_findDefaultTheme).call(this, "light")) === null || _e === void 0 ? void 0 : _e.name;
2545
2585
  }
2546
2586
  setTheme(name) {
2547
2587
  if (name) {
@@ -2550,7 +2590,7 @@
2550
2590
  this.load(chosenTheme.options);
2551
2591
  }
2552
2592
  } else {
2553
- 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");
2593
+ 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");
2554
2594
  if (defaultTheme) {
2555
2595
  this.load(defaultTheme.options);
2556
2596
  }
@@ -2563,13 +2603,26 @@
2563
2603
  return responsiveOptions === null || responsiveOptions === void 0 ? void 0 : responsiveOptions.maxWidth;
2564
2604
  }
2565
2605
  importPreset(preset) {
2566
- this.load(Plugins.getPreset(preset));
2606
+ this.load(Options_classPrivateFieldGet(this, _Options_engine, "f").plugins.getPreset(preset));
2567
2607
  }
2568
2608
  }
2569
- _Options_instances = new WeakSet, _Options_findDefaultTheme = function _Options_findDefaultTheme(mode) {
2609
+ _Options_engine = new WeakMap, _Options_instances = new WeakSet, _Options_findDefaultTheme = function _Options_findDefaultTheme(mode) {
2570
2610
  var _a;
2571
2611
  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"));
2572
2612
  };
2613
+ var Particle_classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
2614
+ if (kind === "m") throw new TypeError("Private method is not writable");
2615
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
2616
+ 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");
2617
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value),
2618
+ value;
2619
+ };
2620
+ var Particle_classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
2621
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
2622
+ 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");
2623
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2624
+ };
2625
+ var _Particle_engine;
2573
2626
  const fixOutMode = data => {
2574
2627
  if (isInArray(data.outMode, data.checkModes) || isInArray(data.outMode, data.checkModes)) {
2575
2628
  if (data.coord > data.maxCoord - data.radius * 2) {
@@ -2580,11 +2633,13 @@
2580
2633
  }
2581
2634
  };
2582
2635
  class Particle_Particle {
2583
- constructor(id, container, position, overrideOptions, group) {
2636
+ constructor(engine, id, container, position, overrideOptions, group) {
2584
2637
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
2585
2638
  this.id = id;
2586
2639
  this.container = container;
2587
2640
  this.group = group;
2641
+ _Particle_engine.set(this, void 0);
2642
+ Particle_classPrivateFieldSet(this, _Particle_engine, engine, "f");
2588
2643
  this.fill = true;
2589
2644
  this.close = true;
2590
2645
  this.lastPathTime = 0;
@@ -2678,7 +2733,7 @@
2678
2733
  this.sides = 24;
2679
2734
  let drawer = container.drawers.get(this.shape);
2680
2735
  if (!drawer) {
2681
- drawer = Plugins.getShapeDrawer(this.shape);
2736
+ drawer = Particle_classPrivateFieldGet(this, _Particle_engine, "f").plugins.getShapeDrawer(this.shape);
2682
2737
  if (drawer) {
2683
2738
  container.drawers.set(this.shape, drawer);
2684
2739
  }
@@ -2918,9 +2973,25 @@
2918
2973
  return life;
2919
2974
  }
2920
2975
  }
2976
+ _Particle_engine = new WeakMap;
2977
+ var Particles_classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
2978
+ if (kind === "m") throw new TypeError("Private method is not writable");
2979
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
2980
+ 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");
2981
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value),
2982
+ value;
2983
+ };
2984
+ var Particles_classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
2985
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
2986
+ 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");
2987
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2988
+ };
2989
+ var _Particles_engine;
2921
2990
  class Particles_Particles {
2922
- constructor(container) {
2991
+ constructor(engine, container) {
2923
2992
  this.container = container;
2993
+ _Particles_engine.set(this, void 0);
2994
+ Particles_classPrivateFieldSet(this, _Particles_engine, engine, "f");
2924
2995
  this.nextId = 0;
2925
2996
  this.array = [];
2926
2997
  this.zArray = [];
@@ -2932,11 +3003,11 @@
2932
3003
  links: new Map,
2933
3004
  triangles: new Map
2934
3005
  };
2935
- this.interactionManager = new InteractionManager(container);
3006
+ this.interactionManager = new InteractionManager(Particles_classPrivateFieldGet(this, _Particles_engine, "f"), container);
2936
3007
  const canvasSize = this.container.canvas.size;
2937
3008
  this.linksColors = new Map;
2938
3009
  this.quadTree = new QuadTree(new Rectangle(-canvasSize.width / 4, -canvasSize.height / 4, canvasSize.width * 3 / 2, canvasSize.height * 3 / 2), 4);
2939
- this.updaters = Plugins.getUpdaters(container, true);
3010
+ this.updaters = Particles_classPrivateFieldGet(this, _Particles_engine, "f").plugins.getUpdaters(container, true);
2940
3011
  }
2941
3012
  get count() {
2942
3013
  return this.array.length;
@@ -2950,7 +3021,7 @@
2950
3021
  this.freqs.links = new Map;
2951
3022
  this.freqs.triangles = new Map;
2952
3023
  let handled = false;
2953
- this.updaters = Plugins.getUpdaters(container, true);
3024
+ this.updaters = Particles_classPrivateFieldGet(this, _Particles_engine, "f").plugins.getUpdaters(container, true);
2954
3025
  this.interactionManager.init();
2955
3026
  for (const [, plugin] of container.plugins) {
2956
3027
  if (plugin.particlesInitialization !== undefined) {
@@ -3197,7 +3268,7 @@
3197
3268
  }
3198
3269
  pushParticle(position, overrideOptions, group, initializer) {
3199
3270
  try {
3200
- const particle = new Particle(this.nextId, this.container, position, overrideOptions, group);
3271
+ const particle = new Particle(Particles_classPrivateFieldGet(this, _Particles_engine, "f"), this.nextId, this.container, position, overrideOptions, group);
3201
3272
  let canAdd = true;
3202
3273
  if (initializer) {
3203
3274
  canAdd = initializer(particle);
@@ -3215,6 +3286,7 @@
3215
3286
  }
3216
3287
  }
3217
3288
  }
3289
+ _Particles_engine = new WeakMap;
3218
3290
  class Retina_Retina {
3219
3291
  constructor(container) {
3220
3292
  this.container = container;
@@ -3302,10 +3374,25 @@
3302
3374
  }
3303
3375
  }
3304
3376
  }
3377
+ var Container_classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
3378
+ if (kind === "m") throw new TypeError("Private method is not writable");
3379
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
3380
+ 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");
3381
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value),
3382
+ value;
3383
+ };
3384
+ var Container_classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
3385
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3386
+ 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");
3387
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
3388
+ };
3389
+ var _Container_engine;
3305
3390
  class Container_Container {
3306
- constructor(id, sourceOptions, ...presets) {
3391
+ constructor(engine, id, sourceOptions, ...presets) {
3307
3392
  this.id = id;
3308
- this.fpsLimit = 60;
3393
+ _Container_engine.set(this, void 0);
3394
+ Container_classPrivateFieldSet(this, _Container_engine, engine, "f");
3395
+ this.fpsLimit = 120;
3309
3396
  this.duration = 0;
3310
3397
  this.lifeTime = 0;
3311
3398
  this.firstStart = true;
@@ -3319,7 +3406,7 @@
3319
3406
  this._initialSourceOptions = sourceOptions;
3320
3407
  this.retina = new Retina(this);
3321
3408
  this.canvas = new Canvas(this);
3322
- this.particles = new Particles(this);
3409
+ this.particles = new Particles(Container_classPrivateFieldGet(this, _Container_engine, "f"), this);
3323
3410
  this.drawer = new FrameManager(this);
3324
3411
  this.presets = presets;
3325
3412
  this.pathGenerator = {
@@ -3348,8 +3435,8 @@
3348
3435
  this.plugins = new Map;
3349
3436
  this.drawers = new Map;
3350
3437
  this.density = 1;
3351
- this._options = new Options;
3352
- this.actualOptions = new Options;
3438
+ this._options = new Options(Container_classPrivateFieldGet(this, _Container_engine, "f"));
3439
+ this.actualOptions = new Options(Container_classPrivateFieldGet(this, _Container_engine, "f"));
3353
3440
  this.eventListeners = new EventListeners(this);
3354
3441
  if (typeof IntersectionObserver !== "undefined" && IntersectionObserver) {
3355
3442
  this.intersectionObserver = new IntersectionObserver((entries => this.intersectionManager(entries)));
@@ -3464,7 +3551,7 @@
3464
3551
  return this.start();
3465
3552
  }
3466
3553
  reset() {
3467
- this._options = new Options;
3554
+ this._options = new Options(Container_classPrivateFieldGet(this, _Container_engine, "f"));
3468
3555
  return this.refresh();
3469
3556
  }
3470
3557
  stop() {
@@ -3478,7 +3565,7 @@
3478
3565
  this.particles.clear();
3479
3566
  this.canvas.clear();
3480
3567
  if (this.interactivity.element instanceof HTMLElement && this.intersectionObserver) {
3481
- this.intersectionObserver.observe(this.interactivity.element);
3568
+ this.intersectionObserver.unobserve(this.interactivity.element);
3482
3569
  }
3483
3570
  for (const [, plugin] of this.plugins) {
3484
3571
  if (plugin.stop) {
@@ -3605,20 +3692,20 @@
3605
3692
  return false;
3606
3693
  }
3607
3694
  async init() {
3608
- this._options = new Options;
3695
+ this._options = new Options(Container_classPrivateFieldGet(this, _Container_engine, "f"));
3609
3696
  for (const preset of this.presets) {
3610
- this._options.load(Plugins.getPreset(preset));
3697
+ this._options.load(Container_classPrivateFieldGet(this, _Container_engine, "f").plugins.getPreset(preset));
3611
3698
  }
3612
- const shapes = Plugins.getSupportedShapes();
3699
+ const shapes = Container_classPrivateFieldGet(this, _Container_engine, "f").plugins.getSupportedShapes();
3613
3700
  for (const type of shapes) {
3614
- const drawer = Plugins.getShapeDrawer(type);
3701
+ const drawer = Container_classPrivateFieldGet(this, _Container_engine, "f").plugins.getShapeDrawer(type);
3615
3702
  if (drawer) {
3616
3703
  this.drawers.set(type, drawer);
3617
3704
  }
3618
3705
  }
3619
3706
  this._options.load(this._initialSourceOptions);
3620
3707
  this._options.load(this._sourceOptions);
3621
- this.actualOptions = new Options;
3708
+ this.actualOptions = new Options(Container_classPrivateFieldGet(this, _Container_engine, "f"));
3622
3709
  this.actualOptions.load(this._options);
3623
3710
  this.retina.init();
3624
3711
  this.canvas.init();
@@ -3628,8 +3715,8 @@
3628
3715
  this.zLayers = this.actualOptions.zLayers;
3629
3716
  this.duration = getRangeValue(this.actualOptions.duration);
3630
3717
  this.lifeTime = 0;
3631
- this.fpsLimit = this.actualOptions.fpsLimit > 0 ? this.actualOptions.fpsLimit : 60;
3632
- const availablePlugins = Plugins.getAvailablePlugins(this);
3718
+ this.fpsLimit = this.actualOptions.fpsLimit > 0 ? this.actualOptions.fpsLimit : 120;
3719
+ const availablePlugins = Container_classPrivateFieldGet(this, _Container_engine, "f").plugins.getAvailablePlugins(this);
3633
3720
  for (const [id, plugin] of availablePlugins) {
3634
3721
  this.plugins.set(id, plugin);
3635
3722
  }
@@ -3647,7 +3734,7 @@
3647
3734
  }
3648
3735
  const pathOptions = this.actualOptions.particles.move.path;
3649
3736
  if (pathOptions.generator) {
3650
- const customGenerator = Plugins.getPathGenerator(pathOptions.generator);
3737
+ const customGenerator = Container_classPrivateFieldGet(this, _Container_engine, "f").plugins.getPathGenerator(pathOptions.generator);
3651
3738
  if (customGenerator) {
3652
3739
  if (customGenerator.init) {
3653
3740
  this.pathGenerator.init = customGenerator.init;
@@ -3684,24 +3771,41 @@
3684
3771
  }
3685
3772
  }
3686
3773
  }
3687
- const tsParticlesDom = null && [];
3774
+ _Container_engine = new WeakMap;
3775
+ var Loader_classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
3776
+ if (kind === "m") throw new TypeError("Private method is not writable");
3777
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
3778
+ 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");
3779
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value),
3780
+ value;
3781
+ };
3782
+ var Loader_classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
3783
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3784
+ 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");
3785
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
3786
+ };
3787
+ var _Loader_engine;
3688
3788
  function fetchError(statusCode) {
3689
3789
  console.error(`Error tsParticles - fetch status: ${statusCode}`);
3690
3790
  console.error("Error tsParticles - File config not found");
3691
3791
  }
3692
3792
  class Loader {
3693
- static dom() {
3694
- return tsParticlesDom;
3793
+ constructor(engine) {
3794
+ _Loader_engine.set(this, void 0);
3795
+ Loader_classPrivateFieldSet(this, _Loader_engine, engine, "f");
3796
+ }
3797
+ dom() {
3798
+ return Loader_classPrivateFieldGet(this, _Loader_engine, "f").domArray;
3695
3799
  }
3696
- static domItem(index) {
3697
- const dom = Loader.dom();
3800
+ domItem(index) {
3801
+ const dom = this.dom();
3698
3802
  const item = dom[index];
3699
3803
  if (item && !item.destroyed) {
3700
3804
  return item;
3701
3805
  }
3702
3806
  dom.splice(index, 1);
3703
3807
  }
3704
- static async loadOptions(params) {
3808
+ async loadOptions(params) {
3705
3809
  var _a, _b, _c;
3706
3810
  const tagId = (_a = params.tagId) !== null && _a !== void 0 ? _a : `tsparticles${Math.floor(Math.random() * 1e4)}`;
3707
3811
  const {options: options, index: index} = params;
@@ -3712,10 +3816,10 @@
3712
3816
  (_c = document.querySelector("body")) === null || _c === void 0 ? void 0 : _c.append(domContainer);
3713
3817
  }
3714
3818
  const currentOptions = options instanceof Array ? itemFromArray(options, index) : options;
3715
- const dom = Loader.dom();
3819
+ const dom = this.dom();
3716
3820
  const oldIndex = dom.findIndex((v => v.id === tagId));
3717
3821
  if (oldIndex >= 0) {
3718
- const old = Loader.domItem(oldIndex);
3822
+ const old = this.domItem(oldIndex);
3719
3823
  if (old && !old.destroyed) {
3720
3824
  old.destroy();
3721
3825
  dom.splice(oldIndex, 1);
@@ -3738,7 +3842,7 @@
3738
3842
  domContainer.appendChild(canvasEl);
3739
3843
  }
3740
3844
  }
3741
- const newItem = new Container(tagId, currentOptions);
3845
+ const newItem = new Container(Loader_classPrivateFieldGet(this, _Loader_engine, "f"), tagId, currentOptions);
3742
3846
  if (oldIndex >= 0) {
3743
3847
  dom.splice(oldIndex, 0, newItem);
3744
3848
  } else {
@@ -3748,7 +3852,7 @@
3748
3852
  await newItem.start();
3749
3853
  return newItem;
3750
3854
  }
3751
- static async loadRemoteOptions(params) {
3855
+ async loadRemoteOptions(params) {
3752
3856
  const {url: jsonUrl, index: index} = params;
3753
3857
  const url = jsonUrl instanceof Array ? itemFromArray(jsonUrl, index) : jsonUrl;
3754
3858
  if (!url) {
@@ -3760,14 +3864,14 @@
3760
3864
  return;
3761
3865
  }
3762
3866
  const data = await response.json();
3763
- return await Loader.loadOptions({
3867
+ return this.loadOptions({
3764
3868
  tagId: params.tagId,
3765
3869
  element: params.element,
3766
3870
  index: index,
3767
3871
  options: data
3768
3872
  });
3769
3873
  }
3770
- static load(tagId, options, index) {
3874
+ load(tagId, options, index) {
3771
3875
  const params = {
3772
3876
  index: index
3773
3877
  };
@@ -3783,7 +3887,7 @@
3783
3887
  }
3784
3888
  return this.loadOptions(params);
3785
3889
  }
3786
- static async set(id, domContainer, options, index) {
3890
+ async set(id, domContainer, options, index) {
3787
3891
  const params = {
3788
3892
  index: index
3789
3893
  };
@@ -3804,7 +3908,7 @@
3804
3908
  }
3805
3909
  return this.loadOptions(params);
3806
3910
  }
3807
- static async loadJSON(tagId, jsonUrl, index) {
3911
+ async loadJSON(tagId, jsonUrl, index) {
3808
3912
  let url, id;
3809
3913
  if (typeof jsonUrl === "number" || jsonUrl === undefined) {
3810
3914
  url = tagId;
@@ -3812,13 +3916,13 @@
3812
3916
  id = tagId;
3813
3917
  url = jsonUrl;
3814
3918
  }
3815
- return await Loader.loadRemoteOptions({
3919
+ return this.loadRemoteOptions({
3816
3920
  tagId: id,
3817
3921
  url: url,
3818
3922
  index: index
3819
3923
  });
3820
3924
  }
3821
- static async setJSON(id, domContainer, jsonUrl, index) {
3925
+ async setJSON(id, domContainer, jsonUrl, index) {
3822
3926
  let url, newId, newIndex, element;
3823
3927
  if (id instanceof HTMLElement) {
3824
3928
  element = id;
@@ -3830,15 +3934,15 @@
3830
3934
  url = jsonUrl;
3831
3935
  newIndex = index;
3832
3936
  }
3833
- return await Loader.loadRemoteOptions({
3937
+ return this.loadRemoteOptions({
3834
3938
  tagId: newId,
3835
3939
  url: url,
3836
3940
  index: newIndex,
3837
3941
  element: element
3838
3942
  });
3839
3943
  }
3840
- static setOnClickHandler(callback) {
3841
- const dom = Loader.dom();
3944
+ setOnClickHandler(callback) {
3945
+ const dom = this.dom();
3842
3946
  if (dom.length === 0) {
3843
3947
  throw new Error("Can only set click handlers after calling tsParticles.load() or tsParticles.loadJSON()");
3844
3948
  }
@@ -3847,6 +3951,7 @@
3847
3951
  }
3848
3952
  }
3849
3953
  }
3954
+ _Loader_engine = new WeakMap;
3850
3955
  function NumberUtils_clamp(num, min, max) {
3851
3956
  return Math.min(Math.max(num, min), max);
3852
3957
  }