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
@@ -44,7 +44,7 @@
44
44
  }
45
45
  });
46
46
  class CircleShape {
47
- randomPosition(position, offset, fill) {
47
+ randomPosition(position, size, fill) {
48
48
  const generateTheta = (x, y) => {
49
49
  const u = Math.random() / 4;
50
50
  const theta = Math.atan(y / x * Math.tan(2 * Math.PI * u));
@@ -60,7 +60,7 @@
60
60
  }
61
61
  };
62
62
  const radius = (x, y, theta) => x * y / Math.sqrt((y * Math.cos(theta)) ** 2 + (x * Math.sin(theta)) ** 2);
63
- const [a, b] = [ offset.x / 2, offset.y / 2 ];
63
+ const [a, b] = [ size.width / 2, size.height / 2 ];
64
64
  const randomTheta = generateTheta(a, b), maxRadius = radius(a, b, randomTheta), randomRadius = fill ? maxRadius * Math.sqrt(Math.random()) : maxRadius;
65
65
  return {
66
66
  x: position.x + randomRadius * Math.cos(randomTheta),
@@ -531,15 +531,32 @@
531
531
  }
532
532
  }
533
533
  }
534
+ var __classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
535
+ if (kind === "m") throw new TypeError("Private method is not writable");
536
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
537
+ 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");
538
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value),
539
+ value;
540
+ };
541
+ var __classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
542
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
543
+ 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");
544
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
545
+ };
546
+ var _InteractionManager_engine;
534
547
  class InteractionManager_InteractionManager {
535
- constructor(container) {
548
+ constructor(engine, container) {
536
549
  this.container = container;
550
+ _InteractionManager_engine.set(this, void 0);
551
+ __classPrivateFieldSet(this, _InteractionManager_engine, engine, "f");
537
552
  this.externalInteractors = [];
538
553
  this.particleInteractors = [];
539
554
  this.init();
540
555
  }
541
556
  init() {
542
- const interactors = Plugins.getInteractors(this.container, true);
557
+ const interactors = __classPrivateFieldGet(this, _InteractionManager_engine, "f").plugins.getInteractors(this.container, true);
558
+ this.externalInteractors = [];
559
+ this.particleInteractors = [];
543
560
  for (const interactor of interactors) {
544
561
  switch (interactor.type) {
545
562
  case 0:
@@ -570,6 +587,7 @@
570
587
  }
571
588
  }
572
589
  }
590
+ _InteractionManager_engine = new WeakMap;
573
591
  function applyDistance(particle) {
574
592
  const initialPosition = particle.initialPosition;
575
593
  const {dx: dx, dy: dy} = getDistances(initialPosition, particle.position);
@@ -743,26 +761,38 @@
743
761
  return proximityFactor / slowFactor;
744
762
  }
745
763
  }
746
- const plugins = null && [];
747
- const interactorsInitializers = new Map;
748
- const updatersInitializers = new Map;
749
- const interactors = new Map;
750
- const updaters = new Map;
751
- const presets = new Map;
752
- const drawers = new Map;
753
- const pathGenerators = new Map;
754
- class Plugins_Plugins {
755
- static getPlugin(plugin) {
756
- return plugins.find((t => t.id === plugin));
764
+ var Plugins_classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
765
+ if (kind === "m") throw new TypeError("Private method is not writable");
766
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
767
+ 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");
768
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value),
769
+ value;
770
+ };
771
+ var _Plugins_engine;
772
+ class Plugins {
773
+ constructor(engine) {
774
+ _Plugins_engine.set(this, void 0);
775
+ Plugins_classPrivateFieldSet(this, _Plugins_engine, engine, "f");
776
+ this.plugins = [];
777
+ this.interactorsInitializers = new Map;
778
+ this.updatersInitializers = new Map;
779
+ this.interactors = new Map;
780
+ this.updaters = new Map;
781
+ this.presets = new Map;
782
+ this.drawers = new Map;
783
+ this.pathGenerators = new Map;
757
784
  }
758
- static addPlugin(plugin) {
759
- if (!Plugins_Plugins.getPlugin(plugin.id)) {
760
- plugins.push(plugin);
785
+ getPlugin(plugin) {
786
+ return this.plugins.find((t => t.id === plugin));
787
+ }
788
+ addPlugin(plugin) {
789
+ if (!this.getPlugin(plugin.id)) {
790
+ this.plugins.push(plugin);
761
791
  }
762
792
  }
763
- static getAvailablePlugins(container) {
793
+ getAvailablePlugins(container) {
764
794
  const res = new Map;
765
- for (const plugin of plugins) {
795
+ for (const plugin of this.plugins) {
766
796
  if (!plugin.needsPlugin(container.actualOptions)) {
767
797
  continue;
768
798
  }
@@ -770,61 +800,62 @@
770
800
  }
771
801
  return res;
772
802
  }
773
- static loadOptions(options, sourceOptions) {
774
- for (const plugin of plugins) {
803
+ loadOptions(options, sourceOptions) {
804
+ for (const plugin of this.plugins) {
775
805
  plugin.loadOptions(options, sourceOptions);
776
806
  }
777
807
  }
778
- static getPreset(preset) {
779
- return presets.get(preset);
808
+ getPreset(preset) {
809
+ return this.presets.get(preset);
780
810
  }
781
- static addPreset(presetKey, options, override = false) {
782
- if (override || !Plugins_Plugins.getPreset(presetKey)) {
783
- presets.set(presetKey, options);
811
+ addPreset(presetKey, options, override = false) {
812
+ if (override || !this.getPreset(presetKey)) {
813
+ this.presets.set(presetKey, options);
784
814
  }
785
815
  }
786
- static addShapeDrawer(type, drawer) {
787
- if (!Plugins_Plugins.getShapeDrawer(type)) {
788
- drawers.set(type, drawer);
816
+ addShapeDrawer(type, drawer) {
817
+ if (!this.getShapeDrawer(type)) {
818
+ this.drawers.set(type, drawer);
789
819
  }
790
820
  }
791
- static getShapeDrawer(type) {
792
- return drawers.get(type);
821
+ getShapeDrawer(type) {
822
+ return this.drawers.get(type);
793
823
  }
794
- static getSupportedShapes() {
795
- return drawers.keys();
824
+ getSupportedShapes() {
825
+ return this.drawers.keys();
796
826
  }
797
- static getPathGenerator(type) {
798
- return pathGenerators.get(type);
827
+ getPathGenerator(type) {
828
+ return this.pathGenerators.get(type);
799
829
  }
800
- static addPathGenerator(type, pathGenerator) {
801
- if (!Plugins_Plugins.getPathGenerator(type)) {
802
- pathGenerators.set(type, pathGenerator);
830
+ addPathGenerator(type, pathGenerator) {
831
+ if (!this.getPathGenerator(type)) {
832
+ this.pathGenerators.set(type, pathGenerator);
803
833
  }
804
834
  }
805
- static getInteractors(container, force = false) {
806
- let res = interactors.get(container);
835
+ getInteractors(container, force = false) {
836
+ let res = this.interactors.get(container);
807
837
  if (!res || force) {
808
- res = [ ...interactorsInitializers.values() ].map((t => t(container)));
809
- interactors.set(container, res);
838
+ res = [ ...this.interactorsInitializers.values() ].map((t => t(container)));
839
+ this.interactors.set(container, res);
810
840
  }
811
841
  return res;
812
842
  }
813
- static addInteractor(name, initInteractor) {
814
- interactorsInitializers.set(name, initInteractor);
843
+ addInteractor(name, initInteractor) {
844
+ this.interactorsInitializers.set(name, initInteractor);
815
845
  }
816
- static getUpdaters(container, force = false) {
817
- let res = updaters.get(container);
846
+ getUpdaters(container, force = false) {
847
+ let res = this.updaters.get(container);
818
848
  if (!res || force) {
819
- res = [ ...updatersInitializers.values() ].map((t => t(container)));
820
- updaters.set(container, res);
849
+ res = [ ...this.updatersInitializers.values() ].map((t => t(container)));
850
+ this.updaters.set(container, res);
821
851
  }
822
852
  return res;
823
853
  }
824
- static addParticleUpdater(name, initUpdater) {
825
- updatersInitializers.set(name, initUpdater);
854
+ addParticleUpdater(name, initUpdater) {
855
+ this.updatersInitializers.set(name, initUpdater);
826
856
  }
827
857
  }
858
+ _Plugins_engine = new WeakMap;
828
859
  class QuadTree_QuadTree {
829
860
  constructor(rectangle, capacity) {
830
861
  this.rectangle = rectangle;
@@ -2273,22 +2304,31 @@
2273
2304
  }
2274
2305
  }
2275
2306
  }
2276
- var __classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
2307
+ var Options_classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
2308
+ if (kind === "m") throw new TypeError("Private method is not writable");
2309
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
2310
+ 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");
2311
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value),
2312
+ value;
2313
+ };
2314
+ var Options_classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
2277
2315
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
2278
2316
  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");
2279
2317
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2280
2318
  };
2281
- var _Options_instances, _Options_findDefaultTheme;
2319
+ var _Options_instances, _Options_engine, _Options_findDefaultTheme;
2282
2320
  class Options_Options {
2283
- constructor() {
2321
+ constructor(engine) {
2284
2322
  _Options_instances.add(this);
2323
+ _Options_engine.set(this, void 0);
2324
+ Options_classPrivateFieldSet(this, _Options_engine, engine, "f");
2285
2325
  this.autoPlay = true;
2286
2326
  this.background = new Background;
2287
2327
  this.backgroundMask = new BackgroundMask;
2288
2328
  this.fullScreen = new FullScreen;
2289
2329
  this.detectRetina = true;
2290
2330
  this.duration = 0;
2291
- this.fpsLimit = 60;
2331
+ this.fpsLimit = 120;
2292
2332
  this.interactivity = new Interactivity;
2293
2333
  this.manualParticles = [];
2294
2334
  this.motion = new Motion;
@@ -2374,7 +2414,7 @@
2374
2414
  this.motion.load(data.motion);
2375
2415
  this.particles.load(data.particles);
2376
2416
  this.style = deepExtend(this.style, data.style);
2377
- Plugins.loadOptions(this, data);
2417
+ Options_classPrivateFieldGet(this, _Options_engine, "f").plugins.loadOptions(this, data);
2378
2418
  if (data.responsive !== undefined) {
2379
2419
  for (const responsive of data.responsive) {
2380
2420
  const optResponsive = new Responsive;
@@ -2390,8 +2430,8 @@
2390
2430
  this.themes.push(optTheme);
2391
2431
  }
2392
2432
  }
2393
- this.defaultDarkTheme = (_d = __classPrivateFieldGet(this, _Options_instances, "m", _Options_findDefaultTheme).call(this, "dark")) === null || _d === void 0 ? void 0 : _d.name;
2394
- this.defaultLightTheme = (_e = __classPrivateFieldGet(this, _Options_instances, "m", _Options_findDefaultTheme).call(this, "light")) === null || _e === void 0 ? void 0 : _e.name;
2433
+ this.defaultDarkTheme = (_d = Options_classPrivateFieldGet(this, _Options_instances, "m", _Options_findDefaultTheme).call(this, "dark")) === null || _d === void 0 ? void 0 : _d.name;
2434
+ this.defaultLightTheme = (_e = Options_classPrivateFieldGet(this, _Options_instances, "m", _Options_findDefaultTheme).call(this, "light")) === null || _e === void 0 ? void 0 : _e.name;
2395
2435
  }
2396
2436
  setTheme(name) {
2397
2437
  if (name) {
@@ -2400,7 +2440,7 @@
2400
2440
  this.load(chosenTheme.options);
2401
2441
  }
2402
2442
  } else {
2403
- 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");
2443
+ 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");
2404
2444
  if (defaultTheme) {
2405
2445
  this.load(defaultTheme.options);
2406
2446
  }
@@ -2413,13 +2453,26 @@
2413
2453
  return responsiveOptions === null || responsiveOptions === void 0 ? void 0 : responsiveOptions.maxWidth;
2414
2454
  }
2415
2455
  importPreset(preset) {
2416
- this.load(Plugins.getPreset(preset));
2456
+ this.load(Options_classPrivateFieldGet(this, _Options_engine, "f").plugins.getPreset(preset));
2417
2457
  }
2418
2458
  }
2419
- _Options_instances = new WeakSet, _Options_findDefaultTheme = function _Options_findDefaultTheme(mode) {
2459
+ _Options_engine = new WeakMap, _Options_instances = new WeakSet, _Options_findDefaultTheme = function _Options_findDefaultTheme(mode) {
2420
2460
  var _a;
2421
2461
  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"));
2422
2462
  };
2463
+ var Particle_classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
2464
+ if (kind === "m") throw new TypeError("Private method is not writable");
2465
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
2466
+ 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");
2467
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value),
2468
+ value;
2469
+ };
2470
+ var Particle_classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
2471
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
2472
+ 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");
2473
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2474
+ };
2475
+ var _Particle_engine;
2423
2476
  const fixOutMode = data => {
2424
2477
  if (isInArray(data.outMode, data.checkModes) || isInArray(data.outMode, data.checkModes)) {
2425
2478
  if (data.coord > data.maxCoord - data.radius * 2) {
@@ -2430,11 +2483,13 @@
2430
2483
  }
2431
2484
  };
2432
2485
  class Particle_Particle {
2433
- constructor(id, container, position, overrideOptions, group) {
2486
+ constructor(engine, id, container, position, overrideOptions, group) {
2434
2487
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
2435
2488
  this.id = id;
2436
2489
  this.container = container;
2437
2490
  this.group = group;
2491
+ _Particle_engine.set(this, void 0);
2492
+ Particle_classPrivateFieldSet(this, _Particle_engine, engine, "f");
2438
2493
  this.fill = true;
2439
2494
  this.close = true;
2440
2495
  this.lastPathTime = 0;
@@ -2528,7 +2583,7 @@
2528
2583
  this.sides = 24;
2529
2584
  let drawer = container.drawers.get(this.shape);
2530
2585
  if (!drawer) {
2531
- drawer = Plugins.getShapeDrawer(this.shape);
2586
+ drawer = Particle_classPrivateFieldGet(this, _Particle_engine, "f").plugins.getShapeDrawer(this.shape);
2532
2587
  if (drawer) {
2533
2588
  container.drawers.set(this.shape, drawer);
2534
2589
  }
@@ -2768,9 +2823,25 @@
2768
2823
  return life;
2769
2824
  }
2770
2825
  }
2826
+ _Particle_engine = new WeakMap;
2827
+ var Particles_classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
2828
+ if (kind === "m") throw new TypeError("Private method is not writable");
2829
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
2830
+ 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");
2831
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value),
2832
+ value;
2833
+ };
2834
+ var Particles_classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
2835
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
2836
+ 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");
2837
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2838
+ };
2839
+ var _Particles_engine;
2771
2840
  class Particles_Particles {
2772
- constructor(container) {
2841
+ constructor(engine, container) {
2773
2842
  this.container = container;
2843
+ _Particles_engine.set(this, void 0);
2844
+ Particles_classPrivateFieldSet(this, _Particles_engine, engine, "f");
2774
2845
  this.nextId = 0;
2775
2846
  this.array = [];
2776
2847
  this.zArray = [];
@@ -2782,11 +2853,11 @@
2782
2853
  links: new Map,
2783
2854
  triangles: new Map
2784
2855
  };
2785
- this.interactionManager = new InteractionManager(container);
2856
+ this.interactionManager = new InteractionManager(Particles_classPrivateFieldGet(this, _Particles_engine, "f"), container);
2786
2857
  const canvasSize = this.container.canvas.size;
2787
2858
  this.linksColors = new Map;
2788
2859
  this.quadTree = new QuadTree(new Rectangle(-canvasSize.width / 4, -canvasSize.height / 4, canvasSize.width * 3 / 2, canvasSize.height * 3 / 2), 4);
2789
- this.updaters = Plugins.getUpdaters(container, true);
2860
+ this.updaters = Particles_classPrivateFieldGet(this, _Particles_engine, "f").plugins.getUpdaters(container, true);
2790
2861
  }
2791
2862
  get count() {
2792
2863
  return this.array.length;
@@ -2800,7 +2871,7 @@
2800
2871
  this.freqs.links = new Map;
2801
2872
  this.freqs.triangles = new Map;
2802
2873
  let handled = false;
2803
- this.updaters = Plugins.getUpdaters(container, true);
2874
+ this.updaters = Particles_classPrivateFieldGet(this, _Particles_engine, "f").plugins.getUpdaters(container, true);
2804
2875
  this.interactionManager.init();
2805
2876
  for (const [, plugin] of container.plugins) {
2806
2877
  if (plugin.particlesInitialization !== undefined) {
@@ -3047,7 +3118,7 @@
3047
3118
  }
3048
3119
  pushParticle(position, overrideOptions, group, initializer) {
3049
3120
  try {
3050
- const particle = new Particle(this.nextId, this.container, position, overrideOptions, group);
3121
+ const particle = new Particle(Particles_classPrivateFieldGet(this, _Particles_engine, "f"), this.nextId, this.container, position, overrideOptions, group);
3051
3122
  let canAdd = true;
3052
3123
  if (initializer) {
3053
3124
  canAdd = initializer(particle);
@@ -3065,6 +3136,7 @@
3065
3136
  }
3066
3137
  }
3067
3138
  }
3139
+ _Particles_engine = new WeakMap;
3068
3140
  class Retina_Retina {
3069
3141
  constructor(container) {
3070
3142
  this.container = container;
@@ -3152,10 +3224,25 @@
3152
3224
  }
3153
3225
  }
3154
3226
  }
3227
+ var Container_classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
3228
+ if (kind === "m") throw new TypeError("Private method is not writable");
3229
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
3230
+ 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");
3231
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value),
3232
+ value;
3233
+ };
3234
+ var Container_classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
3235
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3236
+ 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");
3237
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
3238
+ };
3239
+ var _Container_engine;
3155
3240
  class Container_Container {
3156
- constructor(id, sourceOptions, ...presets) {
3241
+ constructor(engine, id, sourceOptions, ...presets) {
3157
3242
  this.id = id;
3158
- this.fpsLimit = 60;
3243
+ _Container_engine.set(this, void 0);
3244
+ Container_classPrivateFieldSet(this, _Container_engine, engine, "f");
3245
+ this.fpsLimit = 120;
3159
3246
  this.duration = 0;
3160
3247
  this.lifeTime = 0;
3161
3248
  this.firstStart = true;
@@ -3169,7 +3256,7 @@
3169
3256
  this._initialSourceOptions = sourceOptions;
3170
3257
  this.retina = new Retina(this);
3171
3258
  this.canvas = new Canvas(this);
3172
- this.particles = new Particles(this);
3259
+ this.particles = new Particles(Container_classPrivateFieldGet(this, _Container_engine, "f"), this);
3173
3260
  this.drawer = new FrameManager(this);
3174
3261
  this.presets = presets;
3175
3262
  this.pathGenerator = {
@@ -3198,8 +3285,8 @@
3198
3285
  this.plugins = new Map;
3199
3286
  this.drawers = new Map;
3200
3287
  this.density = 1;
3201
- this._options = new Options;
3202
- this.actualOptions = new Options;
3288
+ this._options = new Options(Container_classPrivateFieldGet(this, _Container_engine, "f"));
3289
+ this.actualOptions = new Options(Container_classPrivateFieldGet(this, _Container_engine, "f"));
3203
3290
  this.eventListeners = new EventListeners(this);
3204
3291
  if (typeof IntersectionObserver !== "undefined" && IntersectionObserver) {
3205
3292
  this.intersectionObserver = new IntersectionObserver((entries => this.intersectionManager(entries)));
@@ -3314,7 +3401,7 @@
3314
3401
  return this.start();
3315
3402
  }
3316
3403
  reset() {
3317
- this._options = new Options;
3404
+ this._options = new Options(Container_classPrivateFieldGet(this, _Container_engine, "f"));
3318
3405
  return this.refresh();
3319
3406
  }
3320
3407
  stop() {
@@ -3328,7 +3415,7 @@
3328
3415
  this.particles.clear();
3329
3416
  this.canvas.clear();
3330
3417
  if (this.interactivity.element instanceof HTMLElement && this.intersectionObserver) {
3331
- this.intersectionObserver.observe(this.interactivity.element);
3418
+ this.intersectionObserver.unobserve(this.interactivity.element);
3332
3419
  }
3333
3420
  for (const [, plugin] of this.plugins) {
3334
3421
  if (plugin.stop) {
@@ -3455,20 +3542,20 @@
3455
3542
  return false;
3456
3543
  }
3457
3544
  async init() {
3458
- this._options = new Options;
3545
+ this._options = new Options(Container_classPrivateFieldGet(this, _Container_engine, "f"));
3459
3546
  for (const preset of this.presets) {
3460
- this._options.load(Plugins.getPreset(preset));
3547
+ this._options.load(Container_classPrivateFieldGet(this, _Container_engine, "f").plugins.getPreset(preset));
3461
3548
  }
3462
- const shapes = Plugins.getSupportedShapes();
3549
+ const shapes = Container_classPrivateFieldGet(this, _Container_engine, "f").plugins.getSupportedShapes();
3463
3550
  for (const type of shapes) {
3464
- const drawer = Plugins.getShapeDrawer(type);
3551
+ const drawer = Container_classPrivateFieldGet(this, _Container_engine, "f").plugins.getShapeDrawer(type);
3465
3552
  if (drawer) {
3466
3553
  this.drawers.set(type, drawer);
3467
3554
  }
3468
3555
  }
3469
3556
  this._options.load(this._initialSourceOptions);
3470
3557
  this._options.load(this._sourceOptions);
3471
- this.actualOptions = new Options;
3558
+ this.actualOptions = new Options(Container_classPrivateFieldGet(this, _Container_engine, "f"));
3472
3559
  this.actualOptions.load(this._options);
3473
3560
  this.retina.init();
3474
3561
  this.canvas.init();
@@ -3478,8 +3565,8 @@
3478
3565
  this.zLayers = this.actualOptions.zLayers;
3479
3566
  this.duration = getRangeValue(this.actualOptions.duration);
3480
3567
  this.lifeTime = 0;
3481
- this.fpsLimit = this.actualOptions.fpsLimit > 0 ? this.actualOptions.fpsLimit : 60;
3482
- const availablePlugins = Plugins.getAvailablePlugins(this);
3568
+ this.fpsLimit = this.actualOptions.fpsLimit > 0 ? this.actualOptions.fpsLimit : 120;
3569
+ const availablePlugins = Container_classPrivateFieldGet(this, _Container_engine, "f").plugins.getAvailablePlugins(this);
3483
3570
  for (const [id, plugin] of availablePlugins) {
3484
3571
  this.plugins.set(id, plugin);
3485
3572
  }
@@ -3497,7 +3584,7 @@
3497
3584
  }
3498
3585
  const pathOptions = this.actualOptions.particles.move.path;
3499
3586
  if (pathOptions.generator) {
3500
- const customGenerator = Plugins.getPathGenerator(pathOptions.generator);
3587
+ const customGenerator = Container_classPrivateFieldGet(this, _Container_engine, "f").plugins.getPathGenerator(pathOptions.generator);
3501
3588
  if (customGenerator) {
3502
3589
  if (customGenerator.init) {
3503
3590
  this.pathGenerator.init = customGenerator.init;
@@ -3534,24 +3621,41 @@
3534
3621
  }
3535
3622
  }
3536
3623
  }
3537
- const tsParticlesDom = null && [];
3624
+ _Container_engine = new WeakMap;
3625
+ var Loader_classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
3626
+ if (kind === "m") throw new TypeError("Private method is not writable");
3627
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
3628
+ 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");
3629
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value),
3630
+ value;
3631
+ };
3632
+ var Loader_classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
3633
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3634
+ 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");
3635
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
3636
+ };
3637
+ var _Loader_engine;
3538
3638
  function fetchError(statusCode) {
3539
3639
  console.error(`Error tsParticles - fetch status: ${statusCode}`);
3540
3640
  console.error("Error tsParticles - File config not found");
3541
3641
  }
3542
3642
  class Loader {
3543
- static dom() {
3544
- return tsParticlesDom;
3643
+ constructor(engine) {
3644
+ _Loader_engine.set(this, void 0);
3645
+ Loader_classPrivateFieldSet(this, _Loader_engine, engine, "f");
3545
3646
  }
3546
- static domItem(index) {
3547
- const dom = Loader.dom();
3647
+ dom() {
3648
+ return Loader_classPrivateFieldGet(this, _Loader_engine, "f").domArray;
3649
+ }
3650
+ domItem(index) {
3651
+ const dom = this.dom();
3548
3652
  const item = dom[index];
3549
3653
  if (item && !item.destroyed) {
3550
3654
  return item;
3551
3655
  }
3552
3656
  dom.splice(index, 1);
3553
3657
  }
3554
- static async loadOptions(params) {
3658
+ async loadOptions(params) {
3555
3659
  var _a, _b, _c;
3556
3660
  const tagId = (_a = params.tagId) !== null && _a !== void 0 ? _a : `tsparticles${Math.floor(Math.random() * 1e4)}`;
3557
3661
  const {options: options, index: index} = params;
@@ -3562,10 +3666,10 @@
3562
3666
  (_c = document.querySelector("body")) === null || _c === void 0 ? void 0 : _c.append(domContainer);
3563
3667
  }
3564
3668
  const currentOptions = options instanceof Array ? itemFromArray(options, index) : options;
3565
- const dom = Loader.dom();
3669
+ const dom = this.dom();
3566
3670
  const oldIndex = dom.findIndex((v => v.id === tagId));
3567
3671
  if (oldIndex >= 0) {
3568
- const old = Loader.domItem(oldIndex);
3672
+ const old = this.domItem(oldIndex);
3569
3673
  if (old && !old.destroyed) {
3570
3674
  old.destroy();
3571
3675
  dom.splice(oldIndex, 1);
@@ -3588,7 +3692,7 @@
3588
3692
  domContainer.appendChild(canvasEl);
3589
3693
  }
3590
3694
  }
3591
- const newItem = new Container(tagId, currentOptions);
3695
+ const newItem = new Container(Loader_classPrivateFieldGet(this, _Loader_engine, "f"), tagId, currentOptions);
3592
3696
  if (oldIndex >= 0) {
3593
3697
  dom.splice(oldIndex, 0, newItem);
3594
3698
  } else {
@@ -3598,7 +3702,7 @@
3598
3702
  await newItem.start();
3599
3703
  return newItem;
3600
3704
  }
3601
- static async loadRemoteOptions(params) {
3705
+ async loadRemoteOptions(params) {
3602
3706
  const {url: jsonUrl, index: index} = params;
3603
3707
  const url = jsonUrl instanceof Array ? itemFromArray(jsonUrl, index) : jsonUrl;
3604
3708
  if (!url) {
@@ -3610,14 +3714,14 @@
3610
3714
  return;
3611
3715
  }
3612
3716
  const data = await response.json();
3613
- return await Loader.loadOptions({
3717
+ return this.loadOptions({
3614
3718
  tagId: params.tagId,
3615
3719
  element: params.element,
3616
3720
  index: index,
3617
3721
  options: data
3618
3722
  });
3619
3723
  }
3620
- static load(tagId, options, index) {
3724
+ load(tagId, options, index) {
3621
3725
  const params = {
3622
3726
  index: index
3623
3727
  };
@@ -3633,7 +3737,7 @@
3633
3737
  }
3634
3738
  return this.loadOptions(params);
3635
3739
  }
3636
- static async set(id, domContainer, options, index) {
3740
+ async set(id, domContainer, options, index) {
3637
3741
  const params = {
3638
3742
  index: index
3639
3743
  };
@@ -3654,7 +3758,7 @@
3654
3758
  }
3655
3759
  return this.loadOptions(params);
3656
3760
  }
3657
- static async loadJSON(tagId, jsonUrl, index) {
3761
+ async loadJSON(tagId, jsonUrl, index) {
3658
3762
  let url, id;
3659
3763
  if (typeof jsonUrl === "number" || jsonUrl === undefined) {
3660
3764
  url = tagId;
@@ -3662,13 +3766,13 @@
3662
3766
  id = tagId;
3663
3767
  url = jsonUrl;
3664
3768
  }
3665
- return await Loader.loadRemoteOptions({
3769
+ return this.loadRemoteOptions({
3666
3770
  tagId: id,
3667
3771
  url: url,
3668
3772
  index: index
3669
3773
  });
3670
3774
  }
3671
- static async setJSON(id, domContainer, jsonUrl, index) {
3775
+ async setJSON(id, domContainer, jsonUrl, index) {
3672
3776
  let url, newId, newIndex, element;
3673
3777
  if (id instanceof HTMLElement) {
3674
3778
  element = id;
@@ -3680,15 +3784,15 @@
3680
3784
  url = jsonUrl;
3681
3785
  newIndex = index;
3682
3786
  }
3683
- return await Loader.loadRemoteOptions({
3787
+ return this.loadRemoteOptions({
3684
3788
  tagId: newId,
3685
3789
  url: url,
3686
3790
  index: newIndex,
3687
3791
  element: element
3688
3792
  });
3689
3793
  }
3690
- static setOnClickHandler(callback) {
3691
- const dom = Loader.dom();
3794
+ setOnClickHandler(callback) {
3795
+ const dom = this.dom();
3692
3796
  if (dom.length === 0) {
3693
3797
  throw new Error("Can only set click handlers after calling tsParticles.load() or tsParticles.loadJSON()");
3694
3798
  }
@@ -3697,6 +3801,7 @@
3697
3801
  }
3698
3802
  }
3699
3803
  }
3804
+ _Loader_engine = new WeakMap;
3700
3805
  function NumberUtils_clamp(num, min, max) {
3701
3806
  return Math.min(Math.max(num, min), max);
3702
3807
  }
@@ -4932,6 +5037,7 @@
4932
5037
  if (data.direction !== undefined) {
4933
5038
  this.direction = data.direction;
4934
5039
  }
5040
+ this.domId = data.domId;
4935
5041
  if (data.fill !== undefined) {
4936
5042
  this.fill = data.fill;
4937
5043
  }
@@ -4961,21 +5067,7 @@
4961
5067
  }
4962
5068
  }
4963
5069
  }
4964
- const shapes = new Map;
4965
- class ShapeManager {
4966
- static addShape(name, drawer) {
4967
- if (!ShapeManager.getShape(name)) {
4968
- shapes.set(name, drawer);
4969
- }
4970
- }
4971
- static getShape(name) {
4972
- return shapes.get(name);
4973
- }
4974
- static getSupportedShapes() {
4975
- return shapes.keys();
4976
- }
4977
- }
4978
- var __classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
5070
+ var EmitterInstance_classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
4979
5071
  if (kind === "m") throw new TypeError("Private method is not writable");
4980
5072
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4981
5073
  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");
@@ -4987,15 +5079,17 @@
4987
5079
  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");
4988
5080
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
4989
5081
  };
4990
- var _EmitterInstance_firstSpawn, _EmitterInstance_startParticlesAdded;
5082
+ var _EmitterInstance_firstSpawn, _EmitterInstance_startParticlesAdded, _EmitterInstance_engine;
4991
5083
  class EmitterInstance {
4992
- constructor(emitters, container, options, position) {
5084
+ constructor(engine, emitters, container, options, position) {
4993
5085
  var _a, _b, _c, _d, _e, _f;
4994
5086
  var _g;
4995
5087
  this.emitters = emitters;
4996
5088
  this.container = container;
4997
5089
  _EmitterInstance_firstSpawn.set(this, void 0);
4998
5090
  _EmitterInstance_startParticlesAdded.set(this, void 0);
5091
+ _EmitterInstance_engine.set(this, void 0);
5092
+ EmitterInstance_classPrivateFieldSet(this, _EmitterInstance_engine, engine, "f");
4999
5093
  this.currentDuration = 0;
5000
5094
  this.currentEmitDelay = 0;
5001
5095
  this.currentSpawnDelay = 0;
@@ -5007,12 +5101,11 @@
5007
5101
  this.options.load(options);
5008
5102
  }
5009
5103
  this.spawnDelay = ((_a = this.options.life.delay) !== null && _a !== void 0 ? _a : 0) * 1e3 / this.container.retina.reduceFactor;
5010
- this.position = (_b = this.initialPosition) !== null && _b !== void 0 ? _b : this.calcPosition();
5011
5104
  this.name = this.options.name;
5012
- this.shape = ShapeManager.getShape(this.options.shape);
5105
+ this.shape = (_b = EmitterInstance_classPrivateFieldGet(this, _EmitterInstance_engine, "f").emitterShapeManager) === null || _b === void 0 ? void 0 : _b.getShape(this.options.shape);
5013
5106
  this.fill = this.options.fill;
5014
- __classPrivateFieldSet(this, _EmitterInstance_firstSpawn, !this.options.life.wait, "f");
5015
- __classPrivateFieldSet(this, _EmitterInstance_startParticlesAdded, false, "f");
5107
+ EmitterInstance_classPrivateFieldSet(this, _EmitterInstance_firstSpawn, !this.options.life.wait, "f");
5108
+ EmitterInstance_classPrivateFieldSet(this, _EmitterInstance_startParticlesAdded, false, "f");
5016
5109
  let particlesOptions = Utils_deepExtend({}, this.options.particles);
5017
5110
  particlesOptions !== null && particlesOptions !== void 0 ? particlesOptions : particlesOptions = {};
5018
5111
  (_c = particlesOptions.move) !== null && _c !== void 0 ? _c : particlesOptions.move = {};
@@ -5074,12 +5167,12 @@
5074
5167
  return;
5075
5168
  }
5076
5169
  if (EmitterInstance_classPrivateFieldGet(this, _EmitterInstance_firstSpawn, "f")) {
5077
- __classPrivateFieldSet(this, _EmitterInstance_firstSpawn, false, "f");
5170
+ EmitterInstance_classPrivateFieldSet(this, _EmitterInstance_firstSpawn, false, "f");
5078
5171
  this.currentSpawnDelay = (_a = this.spawnDelay) !== null && _a !== void 0 ? _a : 0;
5079
5172
  this.currentEmitDelay = (_b = this.emitDelay) !== null && _b !== void 0 ? _b : 0;
5080
5173
  }
5081
5174
  if (!EmitterInstance_classPrivateFieldGet(this, _EmitterInstance_startParticlesAdded, "f")) {
5082
- __classPrivateFieldSet(this, _EmitterInstance_startParticlesAdded, true, "f");
5175
+ EmitterInstance_classPrivateFieldSet(this, _EmitterInstance_startParticlesAdded, true, "f");
5083
5176
  this.emitParticles(this.options.startCount);
5084
5177
  }
5085
5178
  if (this.duration !== undefined) {
@@ -5118,6 +5211,36 @@
5118
5211
  }
5119
5212
  }
5120
5213
  }
5214
+ getPosition() {
5215
+ if (this.options.domId) {
5216
+ const container = this.container, element = document.getElementById(this.options.domId);
5217
+ if (element) {
5218
+ const elRect = element.getBoundingClientRect();
5219
+ return {
5220
+ x: (elRect.x + elRect.width / 2) * container.retina.pixelRatio,
5221
+ y: (elRect.y + elRect.height / 2) * container.retina.pixelRatio
5222
+ };
5223
+ }
5224
+ }
5225
+ return this.position;
5226
+ }
5227
+ getSize() {
5228
+ const container = this.container;
5229
+ if (this.options.domId) {
5230
+ const element = document.getElementById(this.options.domId);
5231
+ if (element) {
5232
+ const elRect = element.getBoundingClientRect();
5233
+ return {
5234
+ width: elRect.width * container.retina.pixelRatio,
5235
+ height: elRect.height * container.retina.pixelRatio
5236
+ };
5237
+ }
5238
+ }
5239
+ return {
5240
+ width: this.size.mode === "percent" ? container.canvas.size.width * this.size.width / 100 : this.size.width,
5241
+ height: this.size.mode === "percent" ? container.canvas.size.height * this.size.height / 100 : this.size.height
5242
+ };
5243
+ }
5121
5244
  prepareToDie() {
5122
5245
  var _a;
5123
5246
  if (this.paused) {
@@ -5150,11 +5273,8 @@
5150
5273
  emitParticles(quantity) {
5151
5274
  var _a, _b, _c;
5152
5275
  const container = this.container;
5153
- const position = this.position;
5154
- const offset = {
5155
- x: this.size.mode === "percent" ? container.canvas.size.width * this.size.width / 100 : this.size.width,
5156
- y: this.size.mode === "percent" ? container.canvas.size.height * this.size.height / 100 : this.size.height
5157
- };
5276
+ const position = this.getPosition();
5277
+ const size = this.getSize();
5158
5278
  for (let i = 0; i < quantity; i++) {
5159
5279
  const particlesOptions = Utils_deepExtend({}, this.particlesOptions);
5160
5280
  if (this.spawnColor) {
@@ -5172,7 +5292,10 @@
5172
5292
  particlesOptions.color.value = this.spawnColor;
5173
5293
  }
5174
5294
  }
5175
- const pPosition = (_c = (_b = this.shape) === null || _b === void 0 ? void 0 : _b.randomPosition(position, offset, this.fill)) !== null && _c !== void 0 ? _c : position;
5295
+ if (!position) {
5296
+ return;
5297
+ }
5298
+ const pPosition = (_c = (_b = this.shape) === null || _b === void 0 ? void 0 : _b.randomPosition(position, size, this.fill)) !== null && _c !== void 0 ? _c : position;
5176
5299
  container.particles.addParticle(pPosition, particlesOptions);
5177
5300
  }
5178
5301
  }
@@ -5189,10 +5312,26 @@
5189
5312
  return (initValue + colorSpeed * container.fpsLimit / emitFactor + colorOffset * 3.6) % maxValue;
5190
5313
  }
5191
5314
  }
5192
- _EmitterInstance_firstSpawn = new WeakMap, _EmitterInstance_startParticlesAdded = new WeakMap;
5315
+ _EmitterInstance_firstSpawn = new WeakMap, _EmitterInstance_startParticlesAdded = new WeakMap,
5316
+ _EmitterInstance_engine = new WeakMap;
5317
+ var Emitters_classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
5318
+ if (kind === "m") throw new TypeError("Private method is not writable");
5319
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5320
+ 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");
5321
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value),
5322
+ value;
5323
+ };
5324
+ var Emitters_classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
5325
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
5326
+ 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");
5327
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5328
+ };
5329
+ var _Emitters_engine;
5193
5330
  class Emitters {
5194
- constructor(container) {
5331
+ constructor(engine, container) {
5195
5332
  this.container = container;
5333
+ _Emitters_engine.set(this, void 0);
5334
+ Emitters_classPrivateFieldSet(this, _Emitters_engine, engine, "f");
5196
5335
  this.array = [];
5197
5336
  this.emitters = [];
5198
5337
  this.interactivityEmitters = [];
@@ -5304,7 +5443,7 @@
5304
5443
  addEmitter(options, position) {
5305
5444
  const emitterOptions = new Emitter;
5306
5445
  emitterOptions.load(options);
5307
- const emitter = new EmitterInstance(this, this.container, emitterOptions, position);
5446
+ const emitter = new EmitterInstance(Emitters_classPrivateFieldGet(this, _Emitters_engine, "f"), this, this.container, emitterOptions, position);
5308
5447
  this.array.push(emitter);
5309
5448
  return emitter;
5310
5449
  }
@@ -5315,18 +5454,46 @@
5315
5454
  }
5316
5455
  }
5317
5456
  }
5457
+ _Emitters_engine = new WeakMap;
5458
+ var ShapeManager_classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
5459
+ if (kind === "m") throw new TypeError("Private method is not writable");
5460
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5461
+ 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");
5462
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value),
5463
+ value;
5464
+ };
5465
+ var _ShapeManager_engine;
5466
+ const shapes = new Map;
5467
+ class ShapeManager {
5468
+ constructor(engine) {
5469
+ _ShapeManager_engine.set(this, void 0);
5470
+ ShapeManager_classPrivateFieldSet(this, _ShapeManager_engine, engine, "f");
5471
+ }
5472
+ addShape(name, drawer) {
5473
+ if (!this.getShape(name)) {
5474
+ shapes.set(name, drawer);
5475
+ }
5476
+ }
5477
+ getShape(name) {
5478
+ return shapes.get(name);
5479
+ }
5480
+ getSupportedShapes() {
5481
+ return shapes.keys();
5482
+ }
5483
+ }
5484
+ _ShapeManager_engine = new WeakMap;
5318
5485
  function randomSquareCoordinate(position, offset) {
5319
5486
  return position + offset * (Math.random() - .5);
5320
5487
  }
5321
5488
  class SquareShape {
5322
- randomPosition(position, offset, fill) {
5489
+ randomPosition(position, size, fill) {
5323
5490
  if (fill) {
5324
5491
  return {
5325
- x: randomSquareCoordinate(position.x, offset.x),
5326
- y: randomSquareCoordinate(position.y, offset.y)
5492
+ x: randomSquareCoordinate(position.x, size.width),
5493
+ y: randomSquareCoordinate(position.y, size.height)
5327
5494
  };
5328
5495
  } else {
5329
- const halfW = offset.x / 2, halfH = offset.y / 2, side = Math.floor(Math.random() * 4), v = (Math.random() - .5) * 2;
5496
+ const halfW = size.width / 2, halfH = size.height / 2, side = Math.floor(Math.random() * 4), v = (Math.random() - .5) * 2;
5330
5497
  switch (side) {
5331
5498
  case 0:
5332
5499
  return {
@@ -5356,12 +5523,27 @@
5356
5523
  }
5357
5524
  }
5358
5525
  }
5526
+ var Plugins_Emitters_classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
5527
+ if (kind === "m") throw new TypeError("Private method is not writable");
5528
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5529
+ 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");
5530
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value),
5531
+ value;
5532
+ };
5533
+ var Plugins_Emitters_classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {
5534
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
5535
+ 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");
5536
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5537
+ };
5538
+ var _EmittersPlugin_engine;
5359
5539
  class EmittersPlugin {
5360
- constructor() {
5540
+ constructor(engine) {
5541
+ _EmittersPlugin_engine.set(this, void 0);
5542
+ Plugins_Emitters_classPrivateFieldSet(this, _EmittersPlugin_engine, engine, "f");
5361
5543
  this.id = "emitters";
5362
5544
  }
5363
5545
  getPlugin(container) {
5364
- return new Emitters(container);
5546
+ return new Emitters(Plugins_Emitters_classPrivateFieldGet(this, _EmittersPlugin_engine, "f"), container);
5365
5547
  }
5366
5548
  needsPlugin(options) {
5367
5549
  var _a, _b, _c;
@@ -5410,14 +5592,19 @@
5410
5592
  }
5411
5593
  }
5412
5594
  }
5595
+ _EmittersPlugin_engine = new WeakMap;
5413
5596
  async function loadEmittersPlugin(engine) {
5414
- const plugin = new EmittersPlugin;
5415
- await engine.addPlugin(plugin);
5597
+ if (!engine.emitterShapeManager) {
5598
+ engine.emitterShapeManager = new ShapeManager(engine);
5599
+ }
5416
5600
  if (!engine.addEmitterShape) {
5417
5601
  engine.addEmitterShape = (name, shape) => {
5418
- ShapeManager.addShape(name, shape);
5602
+ var _a;
5603
+ (_a = engine.emitterShapeManager) === null || _a === void 0 ? void 0 : _a.addShape(name, shape);
5419
5604
  };
5420
5605
  }
5606
+ const plugin = new EmittersPlugin(engine);
5607
+ await engine.addPlugin(plugin);
5421
5608
  engine.addEmitterShape("circle", new CircleShape);
5422
5609
  engine.addEmitterShape("square", new SquareShape);
5423
5610
  }