tsparticles 1.39.3 → 1.40.0

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 +27 -12
  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 +3 -1
  10. package/Core/Utils/InteractionManager.js +17 -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 +13 -6
  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 +29 -13
  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 +3 -1
  43. package/browser/Core/Utils/InteractionManager.js +17 -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 +13 -6
  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 +28 -13
  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 +3 -1
  79. package/esm/Core/Utils/InteractionManager.js +17 -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 +13 -6
  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 +1 -1
  105. package/report.html +2 -2
  106. package/report.slim.html +2 -2
  107. package/tsparticles.engine.js +221 -114
  108. package/tsparticles.engine.min.js +2 -2
  109. package/tsparticles.interaction.external.attract.js +199 -96
  110. package/tsparticles.interaction.external.attract.min.js +2 -2
  111. package/tsparticles.interaction.external.bounce.js +199 -96
  112. package/tsparticles.interaction.external.bounce.min.js +2 -2
  113. package/tsparticles.interaction.external.bubble.js +199 -96
  114. package/tsparticles.interaction.external.bubble.min.js +2 -2
  115. package/tsparticles.interaction.external.connect.js +199 -96
  116. package/tsparticles.interaction.external.connect.min.js +2 -2
  117. package/tsparticles.interaction.external.grab.js +199 -96
  118. package/tsparticles.interaction.external.grab.min.js +2 -2
  119. package/tsparticles.interaction.external.repulse.js +199 -96
  120. package/tsparticles.interaction.external.repulse.min.js +2 -2
  121. package/tsparticles.interaction.external.trail.js +199 -96
  122. package/tsparticles.interaction.external.trail.min.js +2 -2
  123. package/tsparticles.interaction.particles.attract.js +199 -96
  124. package/tsparticles.interaction.particles.attract.min.js +2 -2
  125. package/tsparticles.interaction.particles.collisions.js +199 -96
  126. package/tsparticles.interaction.particles.collisions.min.js +2 -2
  127. package/tsparticles.interaction.particles.links.js +199 -96
  128. package/tsparticles.interaction.particles.links.min.js +2 -2
  129. package/tsparticles.js +341 -152
  130. package/tsparticles.min.js +2 -2
  131. package/tsparticles.pathseg.min.js +1 -1
  132. package/tsparticles.plugins.absorbers.js +199 -96
  133. package/tsparticles.plugins.absorbers.min.js +2 -2
  134. package/tsparticles.plugins.emitters.js +324 -139
  135. package/tsparticles.plugins.emitters.min.js +2 -2
  136. package/tsparticles.plugins.polygonMask.js +199 -96
  137. package/tsparticles.plugins.polygonMask.min.js +2 -2
  138. package/tsparticles.shape.circle.min.js +1 -1
  139. package/tsparticles.shape.image.js +202 -99
  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 +199 -96
  146. package/tsparticles.shape.text.min.js +2 -2
  147. package/tsparticles.slim.js +221 -114
  148. package/tsparticles.slim.min.js +2 -2
  149. package/tsparticles.updater.angle.js +199 -96
  150. package/tsparticles.updater.angle.min.js +2 -2
  151. package/tsparticles.updater.color.js +199 -96
  152. package/tsparticles.updater.color.min.js +2 -2
  153. package/tsparticles.updater.life.js +199 -96
  154. package/tsparticles.updater.life.min.js +2 -2
  155. package/tsparticles.updater.opacity.js +199 -96
  156. package/tsparticles.updater.opacity.min.js +2 -2
  157. package/tsparticles.updater.outModes.js +199 -96
  158. package/tsparticles.updater.outModes.min.js +2 -2
  159. package/tsparticles.updater.roll.js +199 -96
  160. package/tsparticles.updater.roll.min.js +2 -2
  161. package/tsparticles.updater.size.js +199 -96
  162. package/tsparticles.updater.size.min.js +2 -2
  163. package/tsparticles.updater.strokeColor.js +199 -96
  164. package/tsparticles.updater.strokeColor.min.js +2 -2
  165. package/tsparticles.updater.tilt.js +199 -96
  166. package/tsparticles.updater.tilt.min.js +2 -2
  167. package/tsparticles.updater.wobble.js +199 -96
  168. package/tsparticles.updater.wobble.min.js +2 -2
@@ -1,16 +1,29 @@
1
- import { Plugins } from "../Utils";
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ 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");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ 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");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _InteractionManager_engine;
2
13
  /**
3
14
  * @category Core
4
15
  */
5
16
  export class InteractionManager {
6
- constructor(container) {
17
+ constructor(engine, container) {
7
18
  this.container = container;
19
+ _InteractionManager_engine.set(this, void 0);
20
+ __classPrivateFieldSet(this, _InteractionManager_engine, engine, "f");
8
21
  this.externalInteractors = [];
9
22
  this.particleInteractors = [];
10
23
  this.init();
11
24
  }
12
25
  init() {
13
- const interactors = Plugins.getInteractors(this.container, true);
26
+ const interactors = __classPrivateFieldGet(this, _InteractionManager_engine, "f").plugins.getInteractors(this.container, true);
14
27
  this.externalInteractors = [];
15
28
  this.particleInteractors = [];
16
29
  for (const interactor of interactors) {
@@ -43,3 +56,4 @@ export class InteractionManager {
43
56
  }
44
57
  }
45
58
  }
59
+ _InteractionManager_engine = new WeakMap();
@@ -1,25 +1,39 @@
1
1
  import type { IContainerPlugin, IInteractor, IMovePathGenerator, IParticleUpdater, IPlugin, IShapeDrawer } from "../Interfaces";
2
2
  import type { Container } from "../Container";
3
+ import type { Engine } from "../../engine";
3
4
  import type { IOptions } from "../../Options/Interfaces/IOptions";
4
5
  import type { Options } from "../../Options/Classes/Options";
5
6
  import type { RecursivePartial } from "../../Types";
7
+ declare type InteractorInitializer = (container: Container) => IInteractor;
8
+ declare type UpdaterInitializer = (container: Container) => IParticleUpdater;
6
9
  /**
7
10
  * @category Utils
8
11
  */
9
12
  export declare class Plugins {
10
- static getPlugin(plugin: string): IPlugin | undefined;
11
- static addPlugin(plugin: IPlugin): void;
12
- static getAvailablePlugins(container: Container): Map<string, IContainerPlugin>;
13
- static loadOptions(options: Options, sourceOptions: RecursivePartial<IOptions>): void;
14
- static getPreset(preset: string): RecursivePartial<IOptions> | undefined;
15
- static addPreset(presetKey: string, options: RecursivePartial<IOptions>, override?: boolean): void;
16
- static addShapeDrawer(type: string, drawer: IShapeDrawer): void;
17
- static getShapeDrawer(type: string): IShapeDrawer | undefined;
18
- static getSupportedShapes(): IterableIterator<string>;
19
- static getPathGenerator(type: string): IMovePathGenerator | undefined;
20
- static addPathGenerator(type: string, pathGenerator: IMovePathGenerator): void;
21
- static getInteractors(container: Container, force?: boolean): IInteractor[];
22
- static addInteractor(name: string, initInteractor: (container: Container) => IInteractor): void;
23
- static getUpdaters(container: Container, force?: boolean): IParticleUpdater[];
24
- static addParticleUpdater(name: string, initUpdater: (container: Container) => IParticleUpdater): void;
13
+ #private;
14
+ readonly plugins: IPlugin[];
15
+ readonly interactorsInitializers: Map<string, InteractorInitializer>;
16
+ readonly updatersInitializers: Map<string, UpdaterInitializer>;
17
+ readonly interactors: Map<Container, IInteractor[]>;
18
+ readonly updaters: Map<Container, IParticleUpdater[]>;
19
+ readonly presets: Map<string, RecursivePartial<IOptions>>;
20
+ readonly drawers: Map<string, IShapeDrawer>;
21
+ readonly pathGenerators: Map<string, IMovePathGenerator>;
22
+ constructor(engine: Engine);
23
+ getPlugin(plugin: string): IPlugin | undefined;
24
+ addPlugin(plugin: IPlugin): void;
25
+ getAvailablePlugins(container: Container): Map<string, IContainerPlugin>;
26
+ loadOptions(options: Options, sourceOptions: RecursivePartial<IOptions>): void;
27
+ getPreset(preset: string): RecursivePartial<IOptions> | undefined;
28
+ addPreset(presetKey: string, options: RecursivePartial<IOptions>, override?: boolean): void;
29
+ addShapeDrawer(type: string, drawer: IShapeDrawer): void;
30
+ getShapeDrawer(type: string): IShapeDrawer | undefined;
31
+ getSupportedShapes(): IterableIterator<string>;
32
+ getPathGenerator(type: string): IMovePathGenerator | undefined;
33
+ addPathGenerator(type: string, pathGenerator: IMovePathGenerator): void;
34
+ getInteractors(container: Container, force?: boolean): IInteractor[];
35
+ addInteractor(name: string, initInteractor: (container: Container) => IInteractor): void;
36
+ getUpdaters(container: Container, force?: boolean): IParticleUpdater[];
37
+ addParticleUpdater(name: string, initUpdater: (container: Container) => IParticleUpdater): void;
25
38
  }
39
+ export {};
@@ -1,26 +1,37 @@
1
- const plugins = [];
2
- const interactorsInitializers = new Map();
3
- const updatersInitializers = new Map();
4
- const interactors = new Map();
5
- const updaters = new Map();
6
- const presets = new Map();
7
- const drawers = new Map();
8
- const pathGenerators = new Map();
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ 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");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var _Plugins_engine;
9
8
  /**
10
9
  * @category Utils
11
10
  */
12
11
  export class Plugins {
13
- static getPlugin(plugin) {
14
- return plugins.find((t) => t.id === plugin);
12
+ constructor(engine) {
13
+ _Plugins_engine.set(this, void 0);
14
+ __classPrivateFieldSet(this, _Plugins_engine, engine, "f");
15
+ this.plugins = [];
16
+ this.interactorsInitializers = new Map();
17
+ this.updatersInitializers = new Map();
18
+ this.interactors = new Map();
19
+ this.updaters = new Map();
20
+ this.presets = new Map();
21
+ this.drawers = new Map();
22
+ this.pathGenerators = new Map();
15
23
  }
16
- static addPlugin(plugin) {
17
- if (!Plugins.getPlugin(plugin.id)) {
18
- plugins.push(plugin);
24
+ getPlugin(plugin) {
25
+ return this.plugins.find((t) => t.id === plugin);
26
+ }
27
+ addPlugin(plugin) {
28
+ if (!this.getPlugin(plugin.id)) {
29
+ this.plugins.push(plugin);
19
30
  }
20
31
  }
21
- static getAvailablePlugins(container) {
32
+ getAvailablePlugins(container) {
22
33
  const res = new Map();
23
- for (const plugin of plugins) {
34
+ for (const plugin of this.plugins) {
24
35
  if (!plugin.needsPlugin(container.actualOptions)) {
25
36
  continue;
26
37
  }
@@ -28,58 +39,59 @@ export class Plugins {
28
39
  }
29
40
  return res;
30
41
  }
31
- static loadOptions(options, sourceOptions) {
32
- for (const plugin of plugins) {
42
+ loadOptions(options, sourceOptions) {
43
+ for (const plugin of this.plugins) {
33
44
  plugin.loadOptions(options, sourceOptions);
34
45
  }
35
46
  }
36
- static getPreset(preset) {
37
- return presets.get(preset);
47
+ getPreset(preset) {
48
+ return this.presets.get(preset);
38
49
  }
39
- static addPreset(presetKey, options, override = false) {
40
- if (override || !Plugins.getPreset(presetKey)) {
41
- presets.set(presetKey, options);
50
+ addPreset(presetKey, options, override = false) {
51
+ if (override || !this.getPreset(presetKey)) {
52
+ this.presets.set(presetKey, options);
42
53
  }
43
54
  }
44
- static addShapeDrawer(type, drawer) {
45
- if (!Plugins.getShapeDrawer(type)) {
46
- drawers.set(type, drawer);
55
+ addShapeDrawer(type, drawer) {
56
+ if (!this.getShapeDrawer(type)) {
57
+ this.drawers.set(type, drawer);
47
58
  }
48
59
  }
49
- static getShapeDrawer(type) {
50
- return drawers.get(type);
60
+ getShapeDrawer(type) {
61
+ return this.drawers.get(type);
51
62
  }
52
- static getSupportedShapes() {
53
- return drawers.keys();
63
+ getSupportedShapes() {
64
+ return this.drawers.keys();
54
65
  }
55
- static getPathGenerator(type) {
56
- return pathGenerators.get(type);
66
+ getPathGenerator(type) {
67
+ return this.pathGenerators.get(type);
57
68
  }
58
- static addPathGenerator(type, pathGenerator) {
59
- if (!Plugins.getPathGenerator(type)) {
60
- pathGenerators.set(type, pathGenerator);
69
+ addPathGenerator(type, pathGenerator) {
70
+ if (!this.getPathGenerator(type)) {
71
+ this.pathGenerators.set(type, pathGenerator);
61
72
  }
62
73
  }
63
- static getInteractors(container, force = false) {
64
- let res = interactors.get(container);
74
+ getInteractors(container, force = false) {
75
+ let res = this.interactors.get(container);
65
76
  if (!res || force) {
66
- res = [...interactorsInitializers.values()].map((t) => t(container));
67
- interactors.set(container, res);
77
+ res = [...this.interactorsInitializers.values()].map((t) => t(container));
78
+ this.interactors.set(container, res);
68
79
  }
69
80
  return res;
70
81
  }
71
- static addInteractor(name, initInteractor) {
72
- interactorsInitializers.set(name, initInteractor);
82
+ addInteractor(name, initInteractor) {
83
+ this.interactorsInitializers.set(name, initInteractor);
73
84
  }
74
- static getUpdaters(container, force = false) {
75
- let res = updaters.get(container);
85
+ getUpdaters(container, force = false) {
86
+ let res = this.updaters.get(container);
76
87
  if (!res || force) {
77
- res = [...updatersInitializers.values()].map((t) => t(container));
78
- updaters.set(container, res);
88
+ res = [...this.updatersInitializers.values()].map((t) => t(container));
89
+ this.updaters.set(container, res);
79
90
  }
80
91
  return res;
81
92
  }
82
- static addParticleUpdater(name, initUpdater) {
83
- updatersInitializers.set(name, initUpdater);
93
+ addParticleUpdater(name, initUpdater) {
94
+ this.updatersInitializers.set(name, initUpdater);
84
95
  }
85
96
  }
97
+ _Plugins_engine = new WeakMap();
@@ -1,6 +1,7 @@
1
1
  import type { RangeValue, RecursivePartial } from "../../Types";
2
2
  import { Background } from "./Background/Background";
3
3
  import { BackgroundMask } from "./BackgroundMask/BackgroundMask";
4
+ import type { Engine } from "../../engine";
4
5
  import { FullScreen } from "./FullScreen/FullScreen";
5
6
  import type { IOptionLoader } from "../Interfaces/IOptionLoader";
6
7
  import type { IOptions } from "../Interfaces/IOptions";
@@ -65,7 +66,7 @@ export declare class Options implements IOptions, IOptionLoader<IOptions> {
65
66
  defaultDarkTheme?: string;
66
67
  defaultLightTheme?: string;
67
68
  [name: string]: unknown;
68
- constructor();
69
+ constructor(engine: Engine);
69
70
  /**
70
71
  * This methods loads the source object in the current instance
71
72
  * @param data the source data to load into the instance
@@ -1,9 +1,15 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ 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");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
1
7
  var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
8
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
9
  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");
4
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
11
  };
6
- var _Options_instances, _Options_findDefaultTheme;
12
+ var _Options_instances, _Options_engine, _Options_findDefaultTheme;
7
13
  import { Background } from "./Background/Background";
8
14
  import { BackgroundMask } from "./BackgroundMask/BackgroundMask";
9
15
  import { FullScreen } from "./FullScreen/FullScreen";
@@ -11,7 +17,6 @@ import { Interactivity } from "./Interactivity/Interactivity";
11
17
  import { ManualParticle } from "./ManualParticle";
12
18
  import { Motion } from "./Motion/Motion";
13
19
  import { ParticlesOptions } from "./Particles/ParticlesOptions";
14
- import { Plugins } from "../../Core";
15
20
  import { Responsive } from "./Responsive";
16
21
  import { Theme } from "./Theme/Theme";
17
22
  import { deepExtend } from "../../Utils";
@@ -20,8 +25,10 @@ import { deepExtend } from "../../Utils";
20
25
  * @category Options
21
26
  */
22
27
  export class Options {
23
- constructor() {
28
+ constructor(engine) {
24
29
  _Options_instances.add(this);
30
+ _Options_engine.set(this, void 0);
31
+ __classPrivateFieldSet(this, _Options_engine, engine, "f");
25
32
  this.autoPlay = true;
26
33
  this.background = new Background();
27
34
  this.backgroundMask = new BackgroundMask();
@@ -142,7 +149,7 @@ export class Options {
142
149
  this.motion.load(data.motion);
143
150
  this.particles.load(data.particles);
144
151
  this.style = deepExtend(this.style, data.style);
145
- Plugins.loadOptions(this, data);
152
+ __classPrivateFieldGet(this, _Options_engine, "f").plugins.loadOptions(this, data);
146
153
  if (data.responsive !== undefined) {
147
154
  for (const responsive of data.responsive) {
148
155
  const optResponsive = new Responsive();
@@ -184,10 +191,10 @@ export class Options {
184
191
  return responsiveOptions === null || responsiveOptions === void 0 ? void 0 : responsiveOptions.maxWidth;
185
192
  }
186
193
  importPreset(preset) {
187
- this.load(Plugins.getPreset(preset));
194
+ this.load(__classPrivateFieldGet(this, _Options_engine, "f").plugins.getPreset(preset));
188
195
  }
189
196
  }
190
- _Options_instances = new WeakSet(), _Options_findDefaultTheme = function _Options_findDefaultTheme(mode) {
197
+ _Options_engine = new WeakMap(), _Options_instances = new WeakSet(), _Options_findDefaultTheme = function _Options_findDefaultTheme(mode) {
191
198
  var _a;
192
199
  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" /* any */));
193
200
  };
@@ -1,6 +1,7 @@
1
- import type { Container, ICoordinates, IDelta, IHsl } from "../../Core";
1
+ import type { Container, ICoordinates, IDelta, IDimension, IHsl } from "../../Core";
2
2
  import { Emitter } from "./Options/Classes/Emitter";
3
3
  import type { Emitters } from "./Emitters";
4
+ import type { EmittersEngine } from "./EmittersEngine";
4
5
  import type { IEmitter } from "./Options/Interfaces/IEmitter";
5
6
  import type { IEmitterSize } from "./Options/Interfaces/IEmitterSize";
6
7
  import type { RecursivePartial } from "../../Types";
@@ -11,7 +12,7 @@ export declare class EmitterInstance {
11
12
  #private;
12
13
  private readonly emitters;
13
14
  private readonly container;
14
- position: ICoordinates;
15
+ position?: ICoordinates;
15
16
  size: IEmitterSize;
16
17
  options: Emitter;
17
18
  spawnColor?: IHsl;
@@ -29,13 +30,15 @@ export declare class EmitterInstance {
29
30
  private readonly shape?;
30
31
  private readonly initialPosition?;
31
32
  private readonly particlesOptions;
32
- constructor(emitters: Emitters, container: Container, options: RecursivePartial<IEmitter>, position?: ICoordinates);
33
+ constructor(engine: EmittersEngine, emitters: Emitters, container: Container, options: RecursivePartial<IEmitter>, position?: ICoordinates);
33
34
  externalPlay(): void;
34
35
  externalPause(): void;
35
36
  play(): void;
36
37
  pause(): void;
37
38
  resize(): void;
38
39
  update(delta: IDelta): void;
40
+ getPosition(): ICoordinates | undefined;
41
+ getSize(): IDimension;
39
42
  private prepareToDie;
40
43
  private destroy;
41
44
  private calcPosition;
@@ -9,22 +9,23 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  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");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _EmitterInstance_firstSpawn, _EmitterInstance_startParticlesAdded;
12
+ var _EmitterInstance_firstSpawn, _EmitterInstance_startParticlesAdded, _EmitterInstance_engine;
13
13
  import { colorToHsl, deepExtend, getRangeValue, isPointInside, randomInRange } from "../../Utils";
14
14
  import { Emitter } from "./Options/Classes/Emitter";
15
15
  import { EmitterSize } from "./Options/Classes/EmitterSize";
16
- import { ShapeManager } from "./ShapeManager";
17
16
  /**
18
17
  * @category Emitters Plugin
19
18
  */
20
19
  export class EmitterInstance {
21
- constructor(emitters, container, options, position) {
20
+ constructor(engine, emitters, container, options, position) {
22
21
  var _a, _b, _c, _d, _e, _f;
23
22
  var _g;
24
23
  this.emitters = emitters;
25
24
  this.container = container;
26
25
  _EmitterInstance_firstSpawn.set(this, void 0);
27
26
  _EmitterInstance_startParticlesAdded.set(this, void 0);
27
+ _EmitterInstance_engine.set(this, void 0);
28
+ __classPrivateFieldSet(this, _EmitterInstance_engine, engine, "f");
28
29
  this.currentDuration = 0;
29
30
  this.currentEmitDelay = 0;
30
31
  this.currentSpawnDelay = 0;
@@ -37,9 +38,8 @@ export class EmitterInstance {
37
38
  this.options.load(options);
38
39
  }
39
40
  this.spawnDelay = (((_a = this.options.life.delay) !== null && _a !== void 0 ? _a : 0) * 1000) / this.container.retina.reduceFactor;
40
- this.position = (_b = this.initialPosition) !== null && _b !== void 0 ? _b : this.calcPosition();
41
41
  this.name = this.options.name;
42
- this.shape = ShapeManager.getShape(this.options.shape);
42
+ this.shape = (_b = __classPrivateFieldGet(this, _EmitterInstance_engine, "f").emitterShapeManager) === null || _b === void 0 ? void 0 : _b.getShape(this.options.shape);
43
43
  this.fill = this.options.fill;
44
44
  __classPrivateFieldSet(this, _EmitterInstance_firstSpawn, !this.options.life.wait, "f");
45
45
  __classPrivateFieldSet(this, _EmitterInstance_startParticlesAdded, false, "f");
@@ -155,6 +155,40 @@ export class EmitterInstance {
155
155
  }
156
156
  }
157
157
  }
158
+ getPosition() {
159
+ if (this.options.domId) {
160
+ const container = this.container, element = document.getElementById(this.options.domId);
161
+ if (element) {
162
+ const elRect = element.getBoundingClientRect();
163
+ return {
164
+ x: (elRect.x + elRect.width / 2) * container.retina.pixelRatio,
165
+ y: (elRect.y + elRect.height / 2) * container.retina.pixelRatio,
166
+ };
167
+ }
168
+ }
169
+ return this.position;
170
+ }
171
+ getSize() {
172
+ const container = this.container;
173
+ if (this.options.domId) {
174
+ const element = document.getElementById(this.options.domId);
175
+ if (element) {
176
+ const elRect = element.getBoundingClientRect();
177
+ return {
178
+ width: elRect.width * container.retina.pixelRatio,
179
+ height: elRect.height * container.retina.pixelRatio,
180
+ };
181
+ }
182
+ }
183
+ return {
184
+ width: this.size.mode === "percent" /* percent */
185
+ ? (container.canvas.size.width * this.size.width) / 100
186
+ : this.size.width,
187
+ height: this.size.mode === "percent" /* percent */
188
+ ? (container.canvas.size.height * this.size.height) / 100
189
+ : this.size.height,
190
+ };
191
+ }
158
192
  prepareToDie() {
159
193
  var _a;
160
194
  if (this.paused) {
@@ -190,15 +224,8 @@ export class EmitterInstance {
190
224
  emitParticles(quantity) {
191
225
  var _a, _b, _c;
192
226
  const container = this.container;
193
- const position = this.position;
194
- const offset = {
195
- x: this.size.mode === "percent" /* percent */
196
- ? (container.canvas.size.width * this.size.width) / 100
197
- : this.size.width,
198
- y: this.size.mode === "percent" /* percent */
199
- ? (container.canvas.size.height * this.size.height) / 100
200
- : this.size.height,
201
- };
227
+ const position = this.getPosition();
228
+ const size = this.getSize();
202
229
  for (let i = 0; i < quantity; i++) {
203
230
  const particlesOptions = deepExtend({}, this.particlesOptions);
204
231
  if (this.spawnColor) {
@@ -217,7 +244,10 @@ export class EmitterInstance {
217
244
  particlesOptions.color.value = this.spawnColor;
218
245
  }
219
246
  }
220
- const pPosition = (_c = (_b = this.shape) === null || _b === void 0 ? void 0 : _b.randomPosition(position, offset, this.fill)) !== null && _c !== void 0 ? _c : position;
247
+ if (!position) {
248
+ return;
249
+ }
250
+ const pPosition = (_c = (_b = this.shape) === null || _b === void 0 ? void 0 : _b.randomPosition(position, size, this.fill)) !== null && _c !== void 0 ? _c : position;
221
251
  container.particles.addParticle(pPosition, particlesOptions);
222
252
  }
223
253
  }
@@ -234,4 +264,4 @@ export class EmitterInstance {
234
264
  return (initValue + (colorSpeed * container.fpsLimit) / emitFactor + colorOffset * 3.6) % maxValue;
235
265
  }
236
266
  }
237
- _EmitterInstance_firstSpawn = new WeakMap(), _EmitterInstance_startParticlesAdded = new WeakMap();
267
+ _EmitterInstance_firstSpawn = new WeakMap(), _EmitterInstance_startParticlesAdded = new WeakMap(), _EmitterInstance_engine = new WeakMap();
@@ -2,6 +2,7 @@ import type { Container, IContainerPlugin, ICoordinates, IDelta } from "../../Co
2
2
  import type { RecursivePartial, SingleOrMultiple } from "../../Types";
3
3
  import { Emitter } from "./Options/Classes/Emitter";
4
4
  import { EmitterInstance } from "./EmitterInstance";
5
+ import type { EmittersEngine } from "./EmittersEngine";
5
6
  import type { IEmitter } from "./Options/Interfaces/IEmitter";
6
7
  import type { IEmitterOptions } from "./Options/Interfaces/IEmitterOptions";
7
8
  import type { IOptions } from "../../Options/Interfaces/IOptions";
@@ -9,11 +10,12 @@ import type { IOptions } from "../../Options/Interfaces/IOptions";
9
10
  * @category Emitters Plugin
10
11
  */
11
12
  export declare class Emitters implements IContainerPlugin {
13
+ #private;
12
14
  private readonly container;
13
15
  array: EmitterInstance[];
14
16
  emitters: SingleOrMultiple<Emitter>;
15
17
  interactivityEmitters: SingleOrMultiple<Emitter>;
16
- constructor(container: Container);
18
+ constructor(engine: EmittersEngine, container: Container);
17
19
  init(options?: RecursivePartial<IOptions & IEmitterOptions>): void;
18
20
  play(): void;
19
21
  pause(): void;
@@ -1,3 +1,15 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ 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");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ 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");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _Emitters_engine;
1
13
  import { deepExtend, itemFromArray } from "../../Utils";
2
14
  import { Emitter } from "./Options/Classes/Emitter";
3
15
  import { EmitterInstance } from "./EmitterInstance";
@@ -5,8 +17,10 @@ import { EmitterInstance } from "./EmitterInstance";
5
17
  * @category Emitters Plugin
6
18
  */
7
19
  export class Emitters {
8
- constructor(container) {
20
+ constructor(engine, container) {
9
21
  this.container = container;
22
+ _Emitters_engine.set(this, void 0);
23
+ __classPrivateFieldSet(this, _Emitters_engine, engine, "f");
10
24
  this.array = [];
11
25
  this.emitters = [];
12
26
  this.interactivityEmitters = [];
@@ -124,7 +138,7 @@ export class Emitters {
124
138
  addEmitter(options, position) {
125
139
  const emitterOptions = new Emitter();
126
140
  emitterOptions.load(options);
127
- const emitter = new EmitterInstance(this, this.container, emitterOptions, position);
141
+ const emitter = new EmitterInstance(__classPrivateFieldGet(this, _Emitters_engine, "f"), this, this.container, emitterOptions, position);
128
142
  this.array.push(emitter);
129
143
  return emitter;
130
144
  }
@@ -135,3 +149,4 @@ export class Emitters {
135
149
  }
136
150
  }
137
151
  }
152
+ _Emitters_engine = new WeakMap();
@@ -1,5 +1,7 @@
1
1
  import type { Engine } from "../../engine";
2
2
  import type { IEmitterShape } from "./IEmitterShape";
3
- export declare type EmittersMain = Engine & {
3
+ import type { ShapeManager } from "./ShapeManager";
4
+ export declare type EmittersEngine = Engine & {
5
+ emitterShapeManager?: ShapeManager;
4
6
  addEmitterShape?: (name: string, shape: IEmitterShape) => void;
5
7
  };
@@ -1,4 +1,4 @@
1
- import type { ICoordinates } from "../../Core";
1
+ import type { ICoordinates, IDimension } from "../../Core";
2
2
  export interface IEmitterShape {
3
- randomPosition(position: ICoordinates, offset: ICoordinates, fill: boolean): ICoordinates;
3
+ randomPosition(position: ICoordinates, size: IDimension, fill: boolean): ICoordinates;
4
4
  }
@@ -17,6 +17,7 @@ export declare class Emitter implements IEmitter, IOptionLoader<IEmitter> {
17
17
  autoPlay: boolean;
18
18
  size?: EmitterSize;
19
19
  direction?: MoveDirection | keyof typeof MoveDirection | MoveDirectionAlt | number;
20
+ domId?: string;
20
21
  fill: boolean;
21
22
  life: EmitterLife;
22
23
  name?: string;
@@ -32,6 +32,7 @@ export class Emitter {
32
32
  if (data.direction !== undefined) {
33
33
  this.direction = data.direction;
34
34
  }
35
+ this.domId = data.domId;
35
36
  if (data.fill !== undefined) {
36
37
  this.fill = data.fill;
37
38
  }
@@ -25,6 +25,10 @@ export interface IEmitter {
25
25
  * The direction of the emitted particles, [[MoveDirection]] is the enum used for values
26
26
  */
27
27
  direction?: MoveDirection | keyof typeof MoveDirection | MoveDirectionAlt | number;
28
+ /**
29
+ * Using this id to link the emitter to an HTML element
30
+ */
31
+ domId?: string;
28
32
  /**
29
33
  * Sets if the particles will spawn at the emitter perimeter or inside the area
30
34
  */
@@ -1,6 +1,9 @@
1
+ import type { Engine } from "../../engine";
1
2
  import type { IEmitterShape } from "./IEmitterShape";
2
3
  export declare class ShapeManager {
3
- static addShape(name: string, drawer: IEmitterShape): void;
4
- static getShape(name: string): IEmitterShape | undefined;
5
- static getSupportedShapes(): IterableIterator<string>;
4
+ #private;
5
+ constructor(engine: Engine);
6
+ addShape(name: string, drawer: IEmitterShape): void;
7
+ getShape(name: string): IEmitterShape | undefined;
8
+ getSupportedShapes(): IterableIterator<string>;
6
9
  }
@@ -1,14 +1,26 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ 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");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var _ShapeManager_engine;
1
8
  const shapes = new Map();
2
9
  export class ShapeManager {
3
- static addShape(name, drawer) {
4
- if (!ShapeManager.getShape(name)) {
10
+ constructor(engine) {
11
+ _ShapeManager_engine.set(this, void 0);
12
+ __classPrivateFieldSet(this, _ShapeManager_engine, engine, "f");
13
+ }
14
+ addShape(name, drawer) {
15
+ if (!this.getShape(name)) {
5
16
  shapes.set(name, drawer);
6
17
  }
7
18
  }
8
- static getShape(name) {
19
+ getShape(name) {
9
20
  return shapes.get(name);
10
21
  }
11
- static getSupportedShapes() {
22
+ getSupportedShapes() {
12
23
  return shapes.keys();
13
24
  }
14
25
  }
26
+ _ShapeManager_engine = new WeakMap();
@@ -1,5 +1,5 @@
1
- import type { ICoordinates } from "../../../../Core";
1
+ import type { ICoordinates, IDimension } from "../../../../Core";
2
2
  import type { IEmitterShape } from "../../IEmitterShape";
3
3
  export declare class CircleShape implements IEmitterShape {
4
- randomPosition(position: ICoordinates, offset: ICoordinates, fill: boolean): ICoordinates;
4
+ randomPosition(position: ICoordinates, size: IDimension, fill: boolean): ICoordinates;
5
5
  }