@tsparticles/engine 4.0.0-alpha.3 → 4.0.0-alpha.5

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 (266) hide show
  1. package/794.min.js +2 -0
  2. package/794.min.js.LICENSE.txt +1 -0
  3. package/README.md +2 -5
  4. package/browser/Core/Canvas.js +3 -3
  5. package/browser/Core/Container.js +35 -155
  6. package/browser/Core/Engine.js +32 -78
  7. package/browser/Core/Particle.js +5 -10
  8. package/browser/Core/Particles.js +36 -25
  9. package/browser/Core/Utils/Constants.js +2 -2
  10. package/browser/Core/Utils/EventListeners.js +5 -250
  11. package/browser/Options/Classes/Options.js +7 -75
  12. package/browser/Options/Classes/Particles/ParticlesOptions.js +5 -11
  13. package/{esm/Options/Classes/Interactivity/Events → browser/Options/Classes}/ResizeEvent.js +1 -1
  14. package/browser/Utils/ColorUtils.js +7 -5
  15. package/browser/Utils/Utils.js +33 -36
  16. package/browser/exports.js +1 -21
  17. package/cjs/Core/Canvas.js +3 -3
  18. package/cjs/Core/Container.js +35 -155
  19. package/cjs/Core/Engine.js +32 -78
  20. package/cjs/Core/Particle.js +5 -10
  21. package/cjs/Core/Particles.js +36 -25
  22. package/cjs/Core/Utils/Constants.js +2 -2
  23. package/cjs/Core/Utils/EventListeners.js +5 -250
  24. package/cjs/Options/Classes/Options.js +7 -75
  25. package/cjs/Options/Classes/Particles/ParticlesOptions.js +5 -11
  26. package/cjs/Options/Classes/{Interactivity/Events/ResizeEvent.js → ResizeEvent.js} +1 -1
  27. package/cjs/Utils/ColorUtils.js +7 -5
  28. package/cjs/Utils/Utils.js +33 -36
  29. package/cjs/exports.js +1 -21
  30. package/dist_browser_Core_Container_js.js +6 -16
  31. package/esm/Core/Canvas.js +3 -3
  32. package/esm/Core/Container.js +35 -155
  33. package/esm/Core/Engine.js +32 -78
  34. package/esm/Core/Particle.js +5 -10
  35. package/esm/Core/Particles.js +36 -25
  36. package/esm/Core/Utils/Constants.js +2 -2
  37. package/esm/Core/Utils/EventListeners.js +5 -250
  38. package/esm/Options/Classes/Options.js +7 -75
  39. package/esm/Options/Classes/Particles/ParticlesOptions.js +5 -11
  40. package/{browser/Options/Classes/Interactivity/Events → esm/Options/Classes}/ResizeEvent.js +1 -1
  41. package/esm/Utils/ColorUtils.js +7 -5
  42. package/esm/Utils/Utils.js +33 -36
  43. package/esm/exports.js +1 -21
  44. package/package.json +1 -1
  45. package/report.html +1 -1
  46. package/tsparticles.engine.js +14 -206
  47. package/tsparticles.engine.min.js +1 -1
  48. package/tsparticles.engine.min.js.LICENSE.txt +1 -1
  49. package/types/Core/Container.d.ts +3 -15
  50. package/types/Core/Engine.d.ts +8 -19
  51. package/types/Core/Interfaces/IContainerPlugin.d.ts +8 -1
  52. package/types/Core/Interfaces/IPlugin.d.ts +5 -1
  53. package/types/Core/Particle.d.ts +0 -2
  54. package/types/Core/Particles.d.ts +1 -5
  55. package/types/Core/Utils/Constants.d.ts +2 -2
  56. package/types/Core/Utils/EventListeners.d.ts +0 -14
  57. package/types/Options/Classes/Options.d.ts +2 -11
  58. package/types/Options/Classes/Particles/ParticlesOptions.d.ts +0 -2
  59. package/types/Options/Classes/ResizeEvent.d.ts +9 -0
  60. package/types/Options/Interfaces/IOptions.d.ts +2 -8
  61. package/types/Options/Interfaces/Particles/IParticlesOptions.d.ts +0 -3
  62. package/types/Types/EngineInitializers.d.ts +10 -0
  63. package/types/Utils/Utils.d.ts +4 -6
  64. package/types/export-types.d.ts +3 -19
  65. package/types/exports.d.ts +1 -21
  66. package/umd/Core/Canvas.js +3 -3
  67. package/umd/Core/Container.js +35 -155
  68. package/umd/Core/Engine.js +33 -79
  69. package/umd/Core/Particle.js +6 -11
  70. package/umd/Core/Particles.js +37 -26
  71. package/umd/Core/Utils/Constants.js +3 -3
  72. package/umd/Core/Utils/EventListeners.js +7 -252
  73. package/umd/Options/Classes/Options.js +7 -75
  74. package/umd/Options/Classes/Particles/ParticlesOptions.js +5 -11
  75. package/umd/Options/Classes/{Interactivity/Events/ResizeEvent.js → ResizeEvent.js} +2 -2
  76. package/umd/Utils/ColorUtils.js +7 -5
  77. package/umd/Utils/Utils.js +34 -39
  78. package/umd/exports.js +2 -22
  79. package/638.min.js +0 -2
  80. package/638.min.js.LICENSE.txt +0 -1
  81. package/browser/Core/Interfaces/IMouseData.js +0 -1
  82. package/browser/Core/Interfaces/IParticlesInteractor.js +0 -1
  83. package/browser/Core/Utils/ExternalInteractorBase.js +0 -7
  84. package/browser/Core/Utils/InteractionManager.js +0 -60
  85. package/browser/Core/Utils/ParticlesInteractorBase.js +0 -7
  86. package/browser/Enums/InteractivityDetect.js +0 -6
  87. package/browser/Enums/Modes/ResponsiveMode.js +0 -5
  88. package/browser/Enums/Modes/ThemeMode.js +0 -6
  89. package/browser/Enums/Types/DivType.js +0 -5
  90. package/browser/Enums/Types/InteractorType.js +0 -5
  91. package/browser/Options/Classes/Interactivity/Events/ClickEvent.js +0 -18
  92. package/browser/Options/Classes/Interactivity/Events/DivEvent.js +0 -27
  93. package/browser/Options/Classes/Interactivity/Events/Events.js +0 -30
  94. package/browser/Options/Classes/Interactivity/Events/HoverEvent.js +0 -21
  95. package/browser/Options/Classes/Interactivity/Events/Parallax.js +0 -22
  96. package/browser/Options/Classes/Interactivity/Interactivity.js +0 -22
  97. package/browser/Options/Classes/Interactivity/Modes/Modes.js +0 -25
  98. package/browser/Options/Classes/ManualParticle.js +0 -21
  99. package/browser/Options/Classes/Responsive.js +0 -29
  100. package/browser/Options/Classes/Theme/Theme.js +0 -21
  101. package/browser/Options/Classes/Theme/ThemeDefault.js +0 -23
  102. package/browser/Options/Interfaces/IManualParticle.js +0 -1
  103. package/browser/Options/Interfaces/IResponsive.js +0 -1
  104. package/browser/Options/Interfaces/Interactivity/Events/IClickEvent.js +0 -1
  105. package/browser/Options/Interfaces/Interactivity/Events/IDivEvent.js +0 -1
  106. package/browser/Options/Interfaces/Interactivity/Events/IEvents.js +0 -1
  107. package/browser/Options/Interfaces/Interactivity/Events/IHoverEvent.js +0 -1
  108. package/browser/Options/Interfaces/Interactivity/Events/IParallax.js +0 -1
  109. package/browser/Options/Interfaces/Interactivity/IInteractivity.js +0 -1
  110. package/browser/Options/Interfaces/Interactivity/Modes/IModeDiv.js +0 -1
  111. package/browser/Options/Interfaces/Interactivity/Modes/IModes.js +0 -1
  112. package/browser/Options/Interfaces/Theme/ITheme.js +0 -1
  113. package/browser/Options/Interfaces/Theme/IThemeDefault.js +0 -1
  114. package/cjs/Core/Interfaces/IContainerInteractivity.js +0 -1
  115. package/cjs/Core/Interfaces/IExternalInteractor.js +0 -1
  116. package/cjs/Core/Interfaces/IInteractor.js +0 -1
  117. package/cjs/Core/Interfaces/IMouseData.js +0 -1
  118. package/cjs/Core/Interfaces/IParticlesInteractor.js +0 -1
  119. package/cjs/Core/Utils/ExternalInteractorBase.js +0 -7
  120. package/cjs/Core/Utils/InteractionManager.js +0 -60
  121. package/cjs/Core/Utils/ParticlesInteractorBase.js +0 -7
  122. package/cjs/Enums/InteractivityDetect.js +0 -6
  123. package/cjs/Enums/Modes/ResponsiveMode.js +0 -5
  124. package/cjs/Enums/Modes/ThemeMode.js +0 -6
  125. package/cjs/Enums/Types/DivType.js +0 -5
  126. package/cjs/Enums/Types/InteractorType.js +0 -5
  127. package/cjs/Options/Classes/Interactivity/Events/ClickEvent.js +0 -18
  128. package/cjs/Options/Classes/Interactivity/Events/DivEvent.js +0 -27
  129. package/cjs/Options/Classes/Interactivity/Events/Events.js +0 -30
  130. package/cjs/Options/Classes/Interactivity/Events/HoverEvent.js +0 -21
  131. package/cjs/Options/Classes/Interactivity/Events/Parallax.js +0 -22
  132. package/cjs/Options/Classes/Interactivity/Interactivity.js +0 -22
  133. package/cjs/Options/Classes/Interactivity/Modes/Modes.js +0 -25
  134. package/cjs/Options/Classes/ManualParticle.js +0 -21
  135. package/cjs/Options/Classes/Responsive.js +0 -29
  136. package/cjs/Options/Classes/Theme/Theme.js +0 -21
  137. package/cjs/Options/Classes/Theme/ThemeDefault.js +0 -23
  138. package/cjs/Options/Interfaces/IManualParticle.js +0 -1
  139. package/cjs/Options/Interfaces/IResponsive.js +0 -1
  140. package/cjs/Options/Interfaces/Interactivity/Events/IClickEvent.js +0 -1
  141. package/cjs/Options/Interfaces/Interactivity/Events/IDivEvent.js +0 -1
  142. package/cjs/Options/Interfaces/Interactivity/Events/IEvents.js +0 -1
  143. package/cjs/Options/Interfaces/Interactivity/Events/IHoverEvent.js +0 -1
  144. package/cjs/Options/Interfaces/Interactivity/Events/IParallax.js +0 -1
  145. package/cjs/Options/Interfaces/Interactivity/IInteractivity.js +0 -1
  146. package/cjs/Options/Interfaces/Interactivity/Modes/IModeDiv.js +0 -1
  147. package/cjs/Options/Interfaces/Interactivity/Modes/IModes.js +0 -1
  148. package/cjs/Options/Interfaces/Theme/ITheme.js +0 -1
  149. package/cjs/Options/Interfaces/Theme/IThemeDefault.js +0 -1
  150. package/esm/Core/Interfaces/IContainerInteractivity.js +0 -1
  151. package/esm/Core/Interfaces/IExternalInteractor.js +0 -1
  152. package/esm/Core/Interfaces/IInteractor.js +0 -1
  153. package/esm/Core/Interfaces/IMouseData.js +0 -1
  154. package/esm/Core/Interfaces/IParticlesInteractor.js +0 -1
  155. package/esm/Core/Utils/ExternalInteractorBase.js +0 -7
  156. package/esm/Core/Utils/InteractionManager.js +0 -60
  157. package/esm/Core/Utils/ParticlesInteractorBase.js +0 -7
  158. package/esm/Enums/InteractivityDetect.js +0 -6
  159. package/esm/Enums/Modes/ResponsiveMode.js +0 -5
  160. package/esm/Enums/Modes/ThemeMode.js +0 -6
  161. package/esm/Enums/Types/DivType.js +0 -5
  162. package/esm/Enums/Types/InteractorType.js +0 -5
  163. package/esm/Options/Classes/Interactivity/Events/ClickEvent.js +0 -18
  164. package/esm/Options/Classes/Interactivity/Events/DivEvent.js +0 -27
  165. package/esm/Options/Classes/Interactivity/Events/Events.js +0 -30
  166. package/esm/Options/Classes/Interactivity/Events/HoverEvent.js +0 -21
  167. package/esm/Options/Classes/Interactivity/Events/Parallax.js +0 -22
  168. package/esm/Options/Classes/Interactivity/Interactivity.js +0 -22
  169. package/esm/Options/Classes/Interactivity/Modes/Modes.js +0 -25
  170. package/esm/Options/Classes/ManualParticle.js +0 -21
  171. package/esm/Options/Classes/Responsive.js +0 -29
  172. package/esm/Options/Classes/Theme/Theme.js +0 -21
  173. package/esm/Options/Classes/Theme/ThemeDefault.js +0 -23
  174. package/esm/Options/Interfaces/IManualParticle.js +0 -1
  175. package/esm/Options/Interfaces/IResponsive.js +0 -1
  176. package/esm/Options/Interfaces/Interactivity/Events/IClickEvent.js +0 -1
  177. package/esm/Options/Interfaces/Interactivity/Events/IDivEvent.js +0 -1
  178. package/esm/Options/Interfaces/Interactivity/Events/IEvents.js +0 -1
  179. package/esm/Options/Interfaces/Interactivity/Events/IHoverEvent.js +0 -1
  180. package/esm/Options/Interfaces/Interactivity/Events/IParallax.js +0 -1
  181. package/esm/Options/Interfaces/Interactivity/IInteractivity.js +0 -1
  182. package/esm/Options/Interfaces/Interactivity/Modes/IModeDiv.js +0 -1
  183. package/esm/Options/Interfaces/Interactivity/Modes/IModes.js +0 -1
  184. package/esm/Options/Interfaces/Theme/ITheme.js +0 -1
  185. package/esm/Options/Interfaces/Theme/IThemeDefault.js +0 -1
  186. package/types/Core/Interfaces/IContainerInteractivity.d.ts +0 -6
  187. package/types/Core/Interfaces/IExternalInteractor.d.ts +0 -12
  188. package/types/Core/Interfaces/IInteractor.d.ts +0 -16
  189. package/types/Core/Interfaces/IMouseData.d.ts +0 -9
  190. package/types/Core/Interfaces/IParticlesInteractor.d.ts +0 -7
  191. package/types/Core/Utils/ExternalInteractorBase.d.ts +0 -15
  192. package/types/Core/Utils/InteractionManager.d.ts +0 -17
  193. package/types/Core/Utils/ParticlesInteractorBase.d.ts +0 -15
  194. package/types/Enums/InteractivityDetect.d.ts +0 -5
  195. package/types/Enums/Modes/ResponsiveMode.d.ts +0 -4
  196. package/types/Enums/Modes/ThemeMode.d.ts +0 -5
  197. package/types/Enums/Types/DivType.d.ts +0 -4
  198. package/types/Enums/Types/InteractorType.d.ts +0 -4
  199. package/types/Options/Classes/Interactivity/Events/ClickEvent.d.ts +0 -10
  200. package/types/Options/Classes/Interactivity/Events/DivEvent.d.ts +0 -13
  201. package/types/Options/Classes/Interactivity/Events/Events.d.ts +0 -16
  202. package/types/Options/Classes/Interactivity/Events/HoverEvent.d.ts +0 -12
  203. package/types/Options/Classes/Interactivity/Events/Parallax.d.ts +0 -10
  204. package/types/Options/Classes/Interactivity/Events/ResizeEvent.d.ts +0 -9
  205. package/types/Options/Classes/Interactivity/Interactivity.d.ts +0 -16
  206. package/types/Options/Classes/Interactivity/Modes/Modes.d.ts +0 -12
  207. package/types/Options/Classes/ManualParticle.d.ts +0 -10
  208. package/types/Options/Classes/Responsive.d.ts +0 -12
  209. package/types/Options/Classes/Theme/Theme.d.ts +0 -12
  210. package/types/Options/Classes/Theme/ThemeDefault.d.ts +0 -11
  211. package/types/Options/Interfaces/IManualParticle.d.ts +0 -7
  212. package/types/Options/Interfaces/IResponsive.d.ts +0 -7
  213. package/types/Options/Interfaces/Interactivity/Events/IClickEvent.d.ts +0 -5
  214. package/types/Options/Interfaces/Interactivity/Events/IDivEvent.d.ts +0 -8
  215. package/types/Options/Interfaces/Interactivity/Events/IEvents.d.ts +0 -11
  216. package/types/Options/Interfaces/Interactivity/Events/IHoverEvent.d.ts +0 -7
  217. package/types/Options/Interfaces/Interactivity/Events/IParallax.d.ts +0 -5
  218. package/types/Options/Interfaces/Interactivity/IInteractivity.d.ts +0 -9
  219. package/types/Options/Interfaces/Interactivity/Modes/IModeDiv.d.ts +0 -4
  220. package/types/Options/Interfaces/Interactivity/Modes/IModes.d.ts +0 -1
  221. package/types/Options/Interfaces/Theme/ITheme.d.ts +0 -7
  222. package/types/Options/Interfaces/Theme/IThemeDefault.d.ts +0 -6
  223. package/umd/Core/Interfaces/IExternalInteractor.js +0 -12
  224. package/umd/Core/Interfaces/IInteractor.js +0 -12
  225. package/umd/Core/Interfaces/IMouseData.js +0 -12
  226. package/umd/Core/Interfaces/IParticlesInteractor.js +0 -12
  227. package/umd/Core/Utils/ExternalInteractorBase.js +0 -21
  228. package/umd/Core/Utils/InteractionManager.js +0 -74
  229. package/umd/Core/Utils/ParticlesInteractorBase.js +0 -21
  230. package/umd/Enums/InteractivityDetect.js +0 -19
  231. package/umd/Enums/Modes/ResponsiveMode.js +0 -18
  232. package/umd/Enums/Modes/ThemeMode.js +0 -19
  233. package/umd/Enums/Types/DivType.js +0 -18
  234. package/umd/Enums/Types/InteractorType.js +0 -18
  235. package/umd/Options/Classes/Interactivity/Events/ClickEvent.js +0 -32
  236. package/umd/Options/Classes/Interactivity/Events/DivEvent.js +0 -41
  237. package/umd/Options/Classes/Interactivity/Events/Events.js +0 -44
  238. package/umd/Options/Classes/Interactivity/Events/HoverEvent.js +0 -35
  239. package/umd/Options/Classes/Interactivity/Events/Parallax.js +0 -36
  240. package/umd/Options/Classes/Interactivity/Interactivity.js +0 -36
  241. package/umd/Options/Classes/Interactivity/Modes/Modes.js +0 -39
  242. package/umd/Options/Classes/ManualParticle.js +0 -35
  243. package/umd/Options/Classes/Responsive.js +0 -43
  244. package/umd/Options/Classes/Theme/Theme.js +0 -35
  245. package/umd/Options/Classes/Theme/ThemeDefault.js +0 -37
  246. package/umd/Options/Interfaces/IManualParticle.js +0 -12
  247. package/umd/Options/Interfaces/IResponsive.js +0 -12
  248. package/umd/Options/Interfaces/Interactivity/Events/IClickEvent.js +0 -12
  249. package/umd/Options/Interfaces/Interactivity/Events/IDivEvent.js +0 -12
  250. package/umd/Options/Interfaces/Interactivity/Events/IEvents.js +0 -12
  251. package/umd/Options/Interfaces/Interactivity/Events/IHoverEvent.js +0 -12
  252. package/umd/Options/Interfaces/Interactivity/Events/IParallax.js +0 -12
  253. package/umd/Options/Interfaces/Interactivity/IInteractivity.js +0 -12
  254. package/umd/Options/Interfaces/Interactivity/Modes/IModeDiv.js +0 -12
  255. package/umd/Options/Interfaces/Interactivity/Modes/IModes.js +0 -12
  256. package/umd/Options/Interfaces/Theme/ITheme.js +0 -12
  257. package/umd/Options/Interfaces/Theme/IThemeDefault.js +0 -12
  258. /package/browser/Options/Interfaces/{Interactivity/Events/IResizeEvent.js → IResizeEvent.js} +0 -0
  259. /package/browser/{Core/Interfaces/IContainerInteractivity.js → Types/EngineInitializers.js} +0 -0
  260. /package/cjs/Options/Interfaces/{Interactivity/Events/IResizeEvent.js → IResizeEvent.js} +0 -0
  261. /package/{browser/Core/Interfaces/IExternalInteractor.js → cjs/Types/EngineInitializers.js} +0 -0
  262. /package/esm/Options/Interfaces/{Interactivity/Events/IResizeEvent.js → IResizeEvent.js} +0 -0
  263. /package/{browser/Core/Interfaces/IInteractor.js → esm/Types/EngineInitializers.js} +0 -0
  264. /package/types/Options/Interfaces/{Interactivity/Events/IResizeEvent.d.ts → IResizeEvent.d.ts} +0 -0
  265. /package/umd/Options/Interfaces/{Interactivity/Events/IResizeEvent.js → IResizeEvent.js} +0 -0
  266. /package/umd/{Core/Interfaces/IContainerInteractivity.js → Types/EngineInitializers.js} +0 -0
@@ -5,13 +5,10 @@ import { FullScreen } from "./FullScreen/FullScreen.js";
5
5
  import type { IOptionLoader } from "../Interfaces/IOptionLoader.js";
6
6
  import type { IOptions } from "../Interfaces/IOptions.js";
7
7
  import type { ISourceOptions } from "../../Types/ISourceOptions.js";
8
- import { Interactivity } from "./Interactivity/Interactivity.js";
9
- import { ManualParticle } from "./ManualParticle.js";
10
8
  import type { RangeValue } from "../../Types/RangeValue.js";
11
9
  import type { RecursivePartial } from "../../Types/RecursivePartial.js";
12
- import { Responsive } from "./Responsive.js";
10
+ import { ResizeEvent } from "./ResizeEvent.js";
13
11
  import type { SingleOrMultiple } from "../../Types/SingleOrMultiple.js";
14
- import { Theme } from "./Theme/Theme.js";
15
12
  interface DefaultThemes {
16
13
  dark?: string;
17
14
  light?: string;
@@ -28,26 +25,20 @@ export declare class Options implements IOptions, IOptionLoader<IOptions> {
28
25
  fpsLimit: number;
29
26
  readonly fullScreen: FullScreen;
30
27
  hdr: boolean;
31
- readonly interactivity: Interactivity;
32
28
  key?: string;
33
- manualParticles: ManualParticle[];
34
29
  name?: string;
35
30
  readonly particles: import("./Particles/ParticlesOptions.js").ParticlesOptions;
36
31
  pauseOnBlur: boolean;
37
32
  pauseOnOutsideViewport: boolean;
38
33
  preset?: SingleOrMultiple<string>;
39
- responsive: Responsive[];
34
+ readonly resize: ResizeEvent;
40
35
  smooth: boolean;
41
36
  style: RecursivePartial<CSSStyleDeclaration>;
42
- readonly themes: Theme[];
43
37
  zLayers: number;
44
38
  private readonly _container;
45
39
  private readonly _engine;
46
40
  constructor(engine: Engine, container: Container);
47
41
  load(data?: ISourceOptions): void;
48
- setResponsive(width: number, pxRatio: number, defaultOptions: IOptions): number | undefined;
49
- setTheme(name?: string): void;
50
- private readonly _findDefaultTheme;
51
42
  private readonly _importPreset;
52
43
  }
53
44
  export {};
@@ -2,7 +2,6 @@ import { AnimatableColor } from "../AnimatableColor.js";
2
2
  import type { Container } from "../../../Core/Container.js";
3
3
  import { Effect } from "./Effect/Effect.js";
4
4
  import type { Engine } from "../../../Core/Engine.js";
5
- import type { IInteractivity } from "../../Interfaces/Interactivity/IInteractivity.js";
6
5
  import type { IOptionLoader } from "../../Interfaces/IOptionLoader.js";
7
6
  import type { IParticlesOptions } from "../../Interfaces/Particles/IParticlesOptions.js";
8
7
  import { Move } from "./Move/Move.js";
@@ -22,7 +21,6 @@ export declare class ParticlesOptions implements IParticlesOptions, IOptionLoade
22
21
  color: AnimatableColor;
23
22
  readonly effect: Effect;
24
23
  readonly groups: ParticlesGroups;
25
- interactivity?: RecursivePartial<IInteractivity>;
26
24
  readonly move: Move;
27
25
  readonly number: ParticlesNumber;
28
26
  readonly opacity: Opacity;
@@ -0,0 +1,9 @@
1
+ import type { IOptionLoader } from "../Interfaces/IOptionLoader.js";
2
+ import type { IResizeEvent } from "../Interfaces/IResizeEvent.js";
3
+ import type { RecursivePartial } from "../../Types/RecursivePartial.js";
4
+ export declare class ResizeEvent implements IResizeEvent, IOptionLoader<IResizeEvent> {
5
+ delay: number;
6
+ enable: boolean;
7
+ constructor();
8
+ load(data?: RecursivePartial<IResizeEvent>): void;
9
+ }
@@ -1,10 +1,7 @@
1
1
  import type { IBackground } from "./Background/IBackground.js";
2
2
  import type { IFullScreen } from "./FullScreen/IFullScreen.js";
3
- import type { IInteractivity } from "./Interactivity/IInteractivity.js";
4
- import type { IManualParticle } from "./IManualParticle.js";
5
3
  import type { IParticlesOptions } from "./Particles/IParticlesOptions.js";
6
- import type { IResponsive } from "./IResponsive.js";
7
- import type { ITheme } from "./Theme/ITheme.js";
4
+ import type { IResizeEvent } from "./IResizeEvent.js";
8
5
  import type { RangeValue } from "../../Types/RangeValue.js";
9
6
  import type { RecursivePartial } from "../../Types/RecursivePartial.js";
10
7
  import type { SingleOrMultiple } from "../../Types/SingleOrMultiple.js";
@@ -19,17 +16,14 @@ export interface IOptions {
19
16
  fpsLimit: number;
20
17
  fullScreen: RecursivePartial<IFullScreen> | boolean;
21
18
  hdr: boolean;
22
- interactivity: IInteractivity;
23
19
  key?: string;
24
- manualParticles: IManualParticle[];
25
20
  name?: string;
26
21
  particles: IParticlesOptions;
27
22
  pauseOnBlur: boolean;
28
23
  pauseOnOutsideViewport: boolean;
29
24
  preset?: SingleOrMultiple<string>;
30
- responsive: IResponsive[];
25
+ resize: IResizeEvent;
31
26
  smooth: boolean;
32
27
  style: RecursivePartial<CSSStyleDeclaration>;
33
- themes: ITheme[];
34
28
  zLayers: number;
35
29
  }
@@ -1,6 +1,5 @@
1
1
  import type { IAnimatableColor } from "../IAnimatableColor.js";
2
2
  import type { IEffect } from "./Effect/IEffect.js";
3
- import type { IInteractivity } from "../Interactivity/IInteractivity.js";
4
3
  import type { IMove } from "./Move/IMove.js";
5
4
  import type { IOpacity } from "./Opacity/IOpacity.js";
6
5
  import type { IParticlesBounce } from "./Bounce/IParticlesBounce.js";
@@ -10,7 +9,6 @@ import type { ISize } from "./Size/ISize.js";
10
9
  import type { IStroke } from "./IStroke.js";
11
10
  import type { IZIndex } from "./ZIndex/IZIndex.js";
12
11
  import type { ParticlesGroups } from "../../../Types/ParticlesGroups.js";
13
- import type { RecursivePartial } from "../../../Types/RecursivePartial.js";
14
12
  import type { SingleOrMultiple } from "../../../Types/SingleOrMultiple.js";
15
13
  export interface IParticlesOptions {
16
14
  [name: string]: unknown;
@@ -18,7 +16,6 @@ export interface IParticlesOptions {
18
16
  color: IAnimatableColor;
19
17
  effect: IEffect;
20
18
  groups: ParticlesGroups;
21
- interactivity?: RecursivePartial<IInteractivity>;
22
19
  move: IMove;
23
20
  number: IParticlesNumber;
24
21
  opacity: IOpacity;
@@ -0,0 +1,10 @@
1
+ import type { Container } from "../Core/Container.js";
2
+ import type { IParticleMover } from "../Core/Interfaces/IParticleMover.js";
3
+ import type { IParticleUpdater } from "../Core/Interfaces/IParticleUpdater.js";
4
+ export type GenericInitializer<T> = (container: Container) => Promise<T>;
5
+ export type MoverInitializer = GenericInitializer<IParticleMover>;
6
+ export type UpdaterInitializer = GenericInitializer<IParticleUpdater>;
7
+ export interface Initializers {
8
+ movers: Map<string, MoverInitializer>;
9
+ updaters: Map<string, UpdaterInitializer>;
10
+ }
@@ -1,11 +1,11 @@
1
1
  import type { ICoordinates, ICoordinatesWithMode } from "../Core/Interfaces/ICoordinates.js";
2
2
  import type { IDimension, IDimensionWithMode } from "../Core/Interfaces/IDimension.js";
3
+ import type { Container } from "../Core/Container.js";
3
4
  import { DestroyType } from "../Enums/Types/DestroyType.js";
4
- import type { DivEvent } from "../Options/Classes/Interactivity/Events/DivEvent.js";
5
+ import type { GenericInitializer } from "../Types/EngineInitializers.js";
5
6
  import type { IBounds } from "../Core/Interfaces/IBounds.js";
6
7
  import type { ICircleBouncer } from "../Core/Interfaces/ICircleBouncer.js";
7
8
  import type { IDelta } from "../Core/Interfaces/IDelta.js";
8
- import type { IModeDiv } from "../Options/Interfaces/Interactivity/Modes/IModeDiv.js";
9
9
  import type { IParticleNumericValueAnimation } from "../Core/Interfaces/IParticleValueAnimation.js";
10
10
  import { OutModeDirection } from "../Enums/Directions/OutModeDirection.js";
11
11
  import type { Particle } from "../Core/Particle.js";
@@ -24,10 +24,6 @@ export declare function isPointInside(point: ICoordinates, size: IDimension, off
24
24
  export declare function areBoundsInside(bounds: IBounds, size: IDimension, offset: ICoordinates, direction?: OutModeDirection): boolean;
25
25
  export declare function calculateBounds(point: ICoordinates, radius: number): IBounds;
26
26
  export declare function deepExtend(destination: unknown, ...sources: unknown[]): unknown;
27
- export declare function isDivModeEnabled(mode: string, divs: SingleOrMultiple<DivEvent>): boolean;
28
- export declare function divModeExecute(mode: string, divs: SingleOrMultiple<DivEvent>, callback: (id: string, div: DivEvent) => void): void;
29
- export declare function singleDivModeExecute(div: DivEvent, callback: (selector: string, div: DivEvent) => void): void;
30
- export declare function divMode<T extends IModeDiv>(divs?: SingleOrMultiple<T>, element?: HTMLElement): T | undefined;
31
27
  export declare function circleBounceDataFromParticle(p: Particle): ICircleBouncer;
32
28
  export declare function circleBounce(p1: ICircleBouncer, p2: ICircleBouncer): void;
33
29
  export declare function executeOnSingleOrMultiple<T, U = void>(obj: SingleOrMultiple<T>, callback: (obj: T, index: number) => U): SingleOrMultiple<U>;
@@ -39,3 +35,5 @@ export declare function getSize(size: IDimensionWithMode, canvasSize: IDimension
39
35
  export declare function updateAnimation(particle: Particle, data: IParticleNumericValueAnimation, changeDirection: boolean, destroyType: DestroyType | keyof typeof DestroyType, delta: IDelta): void;
40
36
  export declare function cloneStyle(style: Partial<CSSStyleDeclaration>): CSSStyleDeclaration;
41
37
  export declare const getFullScreenStyle: (zIndex: number) => CSSStyleDeclaration;
38
+ export declare function manageListener(element: HTMLElement | Node | Window | MediaQueryList | typeof globalThis, event: string, handler: EventListenerOrEventListenerObject, add: boolean, options?: boolean | AddEventListenerOptions | EventListenerObject): void;
39
+ export declare function getItemsFromInitializer<TItem, TInitializer extends GenericInitializer<TItem>>(container: Container, map: Map<Container, TItem[]>, initializers: Map<string, TInitializer>, force?: boolean): Promise<TItem[]>;
@@ -3,7 +3,6 @@ export type * from "./Core/Interfaces/IBounds.js";
3
3
  export type * from "./Core/Interfaces/IBubbleParticleData.js";
4
4
  export type * from "./Core/Interfaces/ICircleBouncer.js";
5
5
  export type * from "./Core/Interfaces/IColorManager.js";
6
- export type * from "./Core/Interfaces/IContainerInteractivity.js";
7
6
  export type * from "./Core/Interfaces/IContainerPlugin.js";
8
7
  export type * from "./Core/Interfaces/ICoordinates.js";
9
8
  export type * from "./Core/Interfaces/IDelta.js";
@@ -11,10 +10,7 @@ export type * from "./Core/Interfaces/IDimension.js";
11
10
  export type * from "./Core/Interfaces/IDistance.js";
12
11
  export type * from "./Core/Interfaces/IDrawParticleParams.js";
13
12
  export type * from "./Core/Interfaces/IEffectDrawer.js";
14
- export type * from "./Core/Interfaces/IExternalInteractor.js";
15
- export type * from "./Core/Interfaces/IInteractor.js";
16
13
  export type * from "./Core/Interfaces/ILoadParams.js";
17
- export type * from "./Core/Interfaces/IMouseData.js";
18
14
  export type * from "./Core/Interfaces/IMovePathGenerator.js";
19
15
  export type * from "./Core/Interfaces/IParticleColorStyle.js";
20
16
  export type * from "./Core/Interfaces/IParticleHslAnimation.js";
@@ -25,7 +21,6 @@ export type * from "./Core/Interfaces/IParticleRoll.js";
25
21
  export type * from "./Core/Interfaces/IParticleTransformValues.js";
26
22
  export type * from "./Core/Interfaces/IParticleUpdater.js";
27
23
  export type * from "./Core/Interfaces/IParticleValueAnimation.js";
28
- export type * from "./Core/Interfaces/IParticlesInteractor.js";
29
24
  export type * from "./Core/Interfaces/IPlugin.js";
30
25
  export type * from "./Core/Interfaces/IPositionFromSizeParams.js";
31
26
  export type * from "./Core/Interfaces/IRangeValue.js";
@@ -40,21 +35,11 @@ export type * from "./Options/Interfaces/IAnimatableColor.js";
40
35
  export type * from "./Options/Interfaces/IAnimation.js";
41
36
  export type * from "./Options/Interfaces/IColorAnimation.js";
42
37
  export type * from "./Options/Interfaces/IHslAnimation.js";
43
- export type * from "./Options/Interfaces/IManualParticle.js";
44
38
  export type * from "./Options/Interfaces/IOptionLoader.js";
45
39
  export type * from "./Options/Interfaces/IOptions.js";
46
40
  export type * from "./Options/Interfaces/IOptionsColor.js";
47
- export type * from "./Options/Interfaces/IResponsive.js";
41
+ export type * from "./Options/Interfaces/IResizeEvent.js";
48
42
  export type * from "./Options/Interfaces/IValueWithRandom.js";
49
- export type * from "./Options/Interfaces/Interactivity/Events/IClickEvent.js";
50
- export type * from "./Options/Interfaces/Interactivity/Events/IDivEvent.js";
51
- export type * from "./Options/Interfaces/Interactivity/Events/IEvents.js";
52
- export type * from "./Options/Interfaces/Interactivity/Events/IHoverEvent.js";
53
- export type * from "./Options/Interfaces/Interactivity/Events/IParallax.js";
54
- export type * from "./Options/Interfaces/Interactivity/Events/IResizeEvent.js";
55
- export type * from "./Options/Interfaces/Interactivity/Modes/IModeDiv.js";
56
- export type * from "./Options/Interfaces/Interactivity/Modes/IModes.js";
57
- export type * from "./Options/Interfaces/Interactivity/IInteractivity.js";
58
43
  export type * from "./Options/Interfaces/Particles/Bounce/IParticlesBounce.js";
59
44
  export type * from "./Options/Interfaces/Particles/Effect/IEffect.js";
60
45
  export type * from "./Options/Interfaces/Particles/IParticlesOptions.js";
@@ -76,10 +61,10 @@ export type * from "./Options/Interfaces/Particles/Shape/IShape.js";
76
61
  export type * from "./Options/Interfaces/Particles/Size/ISize.js";
77
62
  export type * from "./Options/Interfaces/Particles/Size/ISizeAnimation.js";
78
63
  export type * from "./Options/Interfaces/Particles/ZIndex/IZIndex.js";
79
- export type * from "./Options/Interfaces/Theme/ITheme.js";
80
- export type * from "./Options/Interfaces/Theme/IThemeDefault.js";
81
64
  export type * from "./Types/CustomEventArgs.js";
82
65
  export type * from "./Types/CustomEventListener.js";
66
+ export type * from "./Types/EasingFunction.js";
67
+ export type * from "./Types/EngineInitializers.js";
83
68
  export type * from "./Types/ExportResult.js";
84
69
  export type * from "./Types/ISourceOptions.js";
85
70
  export type * from "./Types/ParticlesGroups.js";
@@ -89,7 +74,6 @@ export type * from "./Types/RecursivePartial.js";
89
74
  export type * from "./Types/ShapeData.js";
90
75
  export type * from "./Types/SingleOrMultiple.js";
91
76
  export type { EventListeners } from "./Core/Utils/EventListeners.js";
92
- export type { InteractionManager } from "./Core/Utils/InteractionManager.js";
93
77
  export type { QuadTree } from "./Core/Utils/QuadTree.js";
94
78
  export type { Canvas } from "./Core/Canvas.js";
95
79
  export type { Container } from "./Core/Container.js";
@@ -1,6 +1,4 @@
1
1
  export * from "./Core/Utils/Constants.js";
2
- export * from "./Core/Utils/ExternalInteractorBase.js";
3
- export * from "./Core/Utils/ParticlesInteractorBase.js";
4
2
  export * from "./Core/Utils/Point.js";
5
3
  export * from "./Core/Utils/Ranges.js";
6
4
  export * from "./Core/Utils/Vectors.js";
@@ -11,36 +9,20 @@ export * from "./Enums/Modes/AnimationMode.js";
11
9
  export * from "./Enums/Modes/LimitMode.js";
12
10
  export * from "./Enums/Modes/OutMode.js";
13
11
  export * from "./Enums/Modes/PixelMode.js";
14
- export * from "./Enums/Modes/ThemeMode.js";
15
- export * from "./Enums/Modes/ResponsiveMode.js";
16
12
  export * from "./Enums/Types/AlterType.js";
17
13
  export * from "./Enums/Types/DestroyType.js";
18
14
  export * from "./Enums/Types/GradientType.js";
19
- export * from "./Enums/Types/InteractorType.js";
20
15
  export * from "./Enums/Types/ParticleOutType.js";
21
16
  export * from "./Enums/Types/StartValueType.js";
22
- export * from "./Enums/Types/DivType.js";
23
17
  export * from "./Enums/Types/EasingType.js";
24
18
  export * from "./Enums/Types/EventType.js";
25
19
  export * from "./Enums/AnimationStatus.js";
26
- export * from "./Enums/InteractivityDetect.js";
27
20
  export * from "./Options/Classes/AnimatableColor.js";
28
21
  export * from "./Options/Classes/AnimationOptions.js";
29
22
  export * from "./Options/Classes/Background/Background.js";
30
23
  export * from "./Options/Classes/ColorAnimation.js";
31
24
  export * from "./Options/Classes/FullScreen/FullScreen.js";
32
25
  export * from "./Options/Classes/HslAnimation.js";
33
- export * from "./Options/Classes/Interactivity/Events/ClickEvent.js";
34
- export * from "./Options/Classes/Interactivity/Events/DivEvent.js";
35
- export * from "./Options/Classes/Interactivity/Events/ClickEvent.js";
36
- export * from "./Options/Classes/Interactivity/Events/DivEvent.js";
37
- export * from "./Options/Classes/Interactivity/Events/Events.js";
38
- export * from "./Options/Classes/Interactivity/Events/HoverEvent.js";
39
- export * from "./Options/Classes/Interactivity/Events/Parallax.js";
40
- export * from "./Options/Classes/Interactivity/Events/ResizeEvent.js";
41
- export * from "./Options/Classes/Interactivity/Interactivity.js";
42
- export * from "./Options/Classes/Interactivity/Modes/Modes.js";
43
- export * from "./Options/Classes/ManualParticle.js";
44
26
  export * from "./Options/Classes/Options.js";
45
27
  export * from "./Options/Classes/OptionsColor.js";
46
28
  export * from "./Options/Classes/Particles/Bounce/ParticlesBounce.js";
@@ -64,9 +46,7 @@ export * from "./Options/Classes/Particles/Shape/Shape.js";
64
46
  export * from "./Options/Classes/Particles/Size/Size.js";
65
47
  export * from "./Options/Classes/Particles/Size/SizeAnimation.js";
66
48
  export * from "./Options/Classes/Particles/ZIndex/ZIndex.js";
67
- export * from "./Options/Classes/Responsive.js";
68
- export * from "./Options/Classes/Theme/Theme.js";
69
- export * from "./Options/Classes/Theme/ThemeDefault.js";
49
+ export * from "./Options/Classes/ResizeEvent.js";
70
50
  export * from "./Options/Classes/ValueWithRandom.js";
71
51
  export * from "./Utils/CanvasUtils.js";
72
52
  export * from "./Utils/ColorUtils.js";
@@ -196,7 +196,7 @@
196
196
  }
197
197
  clear() {
198
198
  let pluginHandled = false;
199
- for (const plugin of this.container.plugins.values()) {
199
+ for (const plugin of this.container.plugins) {
200
200
  if (!pluginHandled && plugin.canvasClear) {
201
201
  pluginHandled = plugin.canvasClear();
202
202
  }
@@ -334,7 +334,7 @@
334
334
  }
335
335
  initPlugins() {
336
336
  this._resizePlugins = [];
337
- for (const plugin of this.container.plugins.values()) {
337
+ for (const plugin of this.container.plugins) {
338
338
  if (plugin.resize) {
339
339
  this._resizePlugins.push(plugin);
340
340
  }
@@ -392,7 +392,7 @@
392
392
  }
393
393
  paint() {
394
394
  let handled = false;
395
- for (const plugin of this.container.plugins.values()) {
395
+ for (const plugin of this.container.plugins) {
396
396
  if (handled) {
397
397
  break;
398
398
  }
@@ -4,7 +4,7 @@
4
4
  if (v !== undefined) module.exports = v;
5
5
  }
6
6
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "../Utils/MathUtils.js", "./Utils/Constants.js", "./Canvas.js", "./Utils/EventListeners.js", "../Enums/Types/EventType.js", "../Options/Classes/Options.js", "./Particles.js", "./Retina.js", "../Utils/LogUtils.js", "../Utils/OptionsUtils.js", "../Utils/Utils.js"], factory);
7
+ define(["require", "exports", "../Utils/MathUtils.js", "./Utils/Constants.js", "./Canvas.js", "./Utils/EventListeners.js", "../Enums/Types/EventType.js", "../Options/Classes/Options.js", "./Particles.js", "./Retina.js", "../Utils/LogUtils.js", "../Utils/OptionsUtils.js"], factory);
8
8
  }
9
9
  })(function (require, exports) {
10
10
  "use strict";
@@ -20,7 +20,6 @@
20
20
  const Retina_js_1 = require("./Retina.js");
21
21
  const LogUtils_js_1 = require("../Utils/LogUtils.js");
22
22
  const OptionsUtils_js_1 = require("../Utils/OptionsUtils.js");
23
- const Utils_js_1 = require("../Utils/Utils.js");
24
23
  function guardCheck(container) {
25
24
  return !container.destroyed;
26
25
  }
@@ -36,22 +35,6 @@
36
35
  class Container {
37
36
  constructor(engine, id, sourceOptions) {
38
37
  this._delta = { value: 0, factor: 0 };
39
- this._intersectionManager = entries => {
40
- if (!guardCheck(this) || !this.actualOptions.pauseOnOutsideViewport) {
41
- return;
42
- }
43
- for (const entry of entries) {
44
- if (entry.target !== this.interactivity.element) {
45
- continue;
46
- }
47
- if (entry.isIntersecting) {
48
- this.play();
49
- }
50
- else {
51
- this.pause();
52
- }
53
- }
54
- };
55
38
  this._nextFrame = (timestamp) => {
56
39
  try {
57
40
  if (!this._smooth &&
@@ -96,28 +79,18 @@
96
79
  this._lastFrameTime = 0;
97
80
  this.zLayers = 100;
98
81
  this.pageHidden = false;
99
- this._clickHandlers = new Map();
100
82
  this._sourceOptions = sourceOptions;
101
83
  this._initialSourceOptions = sourceOptions;
102
84
  this.retina = new Retina_js_1.Retina(this);
103
85
  this.canvas = new Canvas_js_1.Canvas(this, this._engine);
104
86
  this.particles = new Particles_js_1.Particles(this._engine, this);
105
87
  this.pathGenerators = new Map();
106
- this.interactivity = {
107
- mouse: {
108
- clicking: false,
109
- inside: false,
110
- },
111
- };
112
- this.plugins = new Map();
88
+ this.plugins = [];
113
89
  this.effectDrawers = new Map();
114
90
  this.shapeDrawers = new Map();
115
91
  this._options = loadContainerOptions(this._engine, this);
116
92
  this.actualOptions = loadContainerOptions(this._engine, this);
117
93
  this._eventListeners = new EventListeners_js_1.EventListeners(this);
118
- this._intersectionObserver = (0, Utils_js_1.safeIntersectionObserver)(entries => {
119
- this._intersectionManager(entries);
120
- });
121
94
  this._engine.dispatchEvent(EventType_js_1.EventType.containerBuilt, { container: this });
122
95
  }
123
96
  get animationStatus() {
@@ -129,77 +102,6 @@
129
102
  get sourceOptions() {
130
103
  return this._sourceOptions;
131
104
  }
132
- addClickHandler(callback) {
133
- if (!guardCheck(this)) {
134
- return;
135
- }
136
- const el = this.interactivity.element;
137
- if (!el) {
138
- return;
139
- }
140
- const clickOrTouchHandler = (e, pos, radius) => {
141
- if (!guardCheck(this)) {
142
- return;
143
- }
144
- const pxRatio = this.retina.pixelRatio, posRetina = {
145
- x: pos.x * pxRatio,
146
- y: pos.y * pxRatio,
147
- }, particles = this.particles.quadTree.queryCircle(posRetina, radius * pxRatio);
148
- callback(e, particles);
149
- }, clickHandler = (e) => {
150
- if (!guardCheck(this)) {
151
- return;
152
- }
153
- const mouseEvent = e, pos = {
154
- x: mouseEvent.offsetX || mouseEvent.clientX,
155
- y: mouseEvent.offsetY || mouseEvent.clientY,
156
- };
157
- clickOrTouchHandler(e, pos, Constants_js_1.clickRadius);
158
- }, touchStartHandler = () => {
159
- if (!guardCheck(this)) {
160
- return;
161
- }
162
- touched = true;
163
- touchMoved = false;
164
- }, touchMoveHandler = () => {
165
- if (!guardCheck(this)) {
166
- return;
167
- }
168
- touchMoved = true;
169
- }, touchEndHandler = (e) => {
170
- if (!guardCheck(this)) {
171
- return;
172
- }
173
- if (touched && !touchMoved) {
174
- const touchEvent = e, lastTouch = touchEvent.touches[touchEvent.touches.length - Constants_js_1.touchEndLengthOffset];
175
- if (!lastTouch) {
176
- return;
177
- }
178
- const element = this.canvas.element, canvasRect = element ? element.getBoundingClientRect() : undefined, pos = {
179
- x: lastTouch.clientX - (canvasRect ? canvasRect.left : Constants_js_1.minCoordinate),
180
- y: lastTouch.clientY - (canvasRect ? canvasRect.top : Constants_js_1.minCoordinate),
181
- };
182
- clickOrTouchHandler(e, pos, Math.max(lastTouch.radiusX, lastTouch.radiusY));
183
- }
184
- touched = false;
185
- touchMoved = false;
186
- }, touchCancelHandler = () => {
187
- if (!guardCheck(this)) {
188
- return;
189
- }
190
- touched = false;
191
- touchMoved = false;
192
- };
193
- let touched = false, touchMoved = false;
194
- this._clickHandlers.set("click", clickHandler);
195
- this._clickHandlers.set("touchstart", touchStartHandler);
196
- this._clickHandlers.set("touchmove", touchMoveHandler);
197
- this._clickHandlers.set("touchend", touchEndHandler);
198
- this._clickHandlers.set("touchcancel", touchCancelHandler);
199
- for (const [key, handler] of this._clickHandlers) {
200
- el.addEventListener(key, handler);
201
- }
202
- }
203
105
  addLifeTime(value) {
204
106
  this._lifeTime += value;
205
107
  }
@@ -213,21 +115,11 @@
213
115
  alive() {
214
116
  return !this._duration || this._lifeTime <= this._duration;
215
117
  }
216
- clearClickHandlers() {
217
- if (!guardCheck(this)) {
218
- return;
219
- }
220
- for (const [key, handler] of this._clickHandlers) {
221
- this.interactivity.element?.removeEventListener(key, handler);
222
- }
223
- this._clickHandlers.clear();
224
- }
225
118
  destroy(remove = true) {
226
119
  if (!guardCheck(this)) {
227
120
  return;
228
121
  }
229
122
  this.stop();
230
- this.clearClickHandlers();
231
123
  this.particles.destroy();
232
124
  this.canvas.destroy();
233
125
  for (const effectDrawer of this.effectDrawers.values()) {
@@ -238,10 +130,14 @@
238
130
  shapeDrawer.destroy?.(this);
239
131
  }
240
132
  this.shapeDrawers.clear();
133
+ for (const plugin of this.plugins) {
134
+ plugin.destroy?.();
135
+ }
136
+ this.plugins.length = 0;
241
137
  this._engine.clearPlugins(this);
242
138
  this.destroyed = true;
243
139
  if (remove) {
244
- const mainArr = this._engine.items, idx = mainArr.findIndex(t => t === this);
140
+ const mainArr = this._engine.items, idx = mainArr.indexOf(this);
245
141
  if (idx >= Constants_js_1.removeMinIndex) {
246
142
  mainArr.splice(idx, Constants_js_1.removeDeleteCount);
247
143
  }
@@ -265,7 +161,7 @@
265
161
  });
266
162
  }
267
163
  async export(type, options = {}) {
268
- for (const plugin of this.plugins.values()) {
164
+ for (const plugin of this.plugins) {
269
165
  if (!plugin.export) {
270
166
  continue;
271
167
  }
@@ -278,15 +174,6 @@
278
174
  (0, LogUtils_js_1.getLogger)().error(`Export plugin with type ${type} not found`);
279
175
  return undefined;
280
176
  }
281
- handleClickMode(mode) {
282
- if (!guardCheck(this)) {
283
- return;
284
- }
285
- this.particles.handleClickMode(mode);
286
- for (const plugin of this.plugins.values()) {
287
- plugin.handleClickMode?.(mode);
288
- }
289
- }
290
177
  async init() {
291
178
  if (!guardCheck(this)) {
292
179
  return;
@@ -305,12 +192,21 @@
305
192
  this.shapeDrawers.set(type, drawer);
306
193
  }
307
194
  }
195
+ const allContainerPlugins = new Map();
196
+ for (const plugin of this._engine.plugins) {
197
+ const containerPlugin = await plugin.getPlugin(this);
198
+ if (containerPlugin.preInit) {
199
+ await containerPlugin.preInit();
200
+ }
201
+ allContainerPlugins.set(plugin, containerPlugin);
202
+ }
308
203
  await this.particles.initPlugins();
309
204
  this._options = loadContainerOptions(this._engine, this, this._initialSourceOptions, this.sourceOptions);
310
205
  this.actualOptions = loadContainerOptions(this._engine, this, this._options);
311
- const availablePlugins = await this._engine.getAvailablePlugins(this);
312
- for (const [id, plugin] of availablePlugins) {
313
- this.plugins.set(id, plugin);
206
+ for (const [plugin, containerPlugin] of allContainerPlugins) {
207
+ if (plugin.needsPlugin(this.actualOptions)) {
208
+ this.plugins.push(containerPlugin);
209
+ }
314
210
  }
315
211
  this.retina.init();
316
212
  this.canvas.init();
@@ -325,30 +221,23 @@
325
221
  this._lifeTime = 0;
326
222
  this.fpsLimit = fpsLimit > Constants_js_1.minFpsLimit ? fpsLimit : Constants_js_1.defaultFpsLimit;
327
223
  this._smooth = smooth;
224
+ for (const plugin of this.plugins) {
225
+ await plugin.init?.();
226
+ }
328
227
  for (const drawer of this.effectDrawers.values()) {
329
228
  await drawer.init?.(this);
330
229
  }
331
230
  for (const drawer of this.shapeDrawers.values()) {
332
231
  await drawer.init?.(this);
333
232
  }
334
- for (const plugin of this.plugins.values()) {
335
- await plugin.init?.();
336
- }
337
233
  this._engine.dispatchEvent(EventType_js_1.EventType.containerInit, { container: this });
338
234
  await this.particles.init();
339
235
  this.particles.setDensity();
340
- for (const plugin of this.plugins.values()) {
236
+ for (const plugin of this.plugins) {
341
237
  plugin.particlesSetup?.();
342
238
  }
343
239
  this._engine.dispatchEvent(EventType_js_1.EventType.particlesSetup, { container: this });
344
240
  }
345
- async loadTheme(name) {
346
- if (!guardCheck(this)) {
347
- return;
348
- }
349
- this._currentTheme = name;
350
- await this.refresh();
351
- }
352
241
  pause() {
353
242
  if (!guardCheck(this)) {
354
243
  return;
@@ -360,7 +249,7 @@
360
249
  if (this._paused) {
361
250
  return;
362
251
  }
363
- for (const plugin of this.plugins.values()) {
252
+ for (const plugin of this.plugins) {
364
253
  plugin.pause?.();
365
254
  }
366
255
  if (!this.pageHidden) {
@@ -381,7 +270,7 @@
381
270
  this._paused = false;
382
271
  }
383
272
  if (needsUpdate) {
384
- for (const plugin of this.plugins.values()) {
273
+ for (const plugin of this.plugins) {
385
274
  if (plugin.play) {
386
275
  plugin.play();
387
276
  }
@@ -416,10 +305,7 @@
416
305
  await new Promise(resolve => {
417
306
  const start = async () => {
418
307
  this._eventListeners.addListeners();
419
- if (this.interactivity.element instanceof HTMLElement && this._intersectionObserver) {
420
- this._intersectionObserver.observe(this.interactivity.element);
421
- }
422
- for (const plugin of this.plugins.values()) {
308
+ for (const plugin of this.plugins) {
423
309
  await plugin.start?.();
424
310
  }
425
311
  this._engine.dispatchEvent(EventType_js_1.EventType.containerStarted, { container: this });
@@ -443,27 +329,21 @@
443
329
  this.pause();
444
330
  this.particles.clear();
445
331
  this.canvas.stop();
446
- if (this.interactivity.element instanceof HTMLElement && this._intersectionObserver) {
447
- this._intersectionObserver.unobserve(this.interactivity.element);
448
- }
449
- for (const plugin of this.plugins.values()) {
332
+ for (const plugin of this.plugins) {
450
333
  plugin.stop?.();
451
334
  }
452
- for (const key of this.plugins.keys()) {
453
- this.plugins.delete(key);
454
- }
335
+ this.plugins.length = 0;
455
336
  this._sourceOptions = this._options;
456
337
  this._engine.dispatchEvent(EventType_js_1.EventType.containerStopped, { container: this });
457
338
  }
458
339
  updateActualOptions() {
459
- this.actualOptions.responsive = [];
460
- const newMaxWidth = this.actualOptions.setResponsive(this.canvas.size.width, this.retina.pixelRatio, this._options);
461
- this.actualOptions.setTheme(this._currentTheme);
462
- if (this._responsiveMaxWidth === newMaxWidth) {
463
- return false;
340
+ let refresh = false;
341
+ for (const plugin of this.plugins) {
342
+ if (plugin.updateActualOptions) {
343
+ refresh = plugin.updateActualOptions() || refresh;
344
+ }
464
345
  }
465
- this._responsiveMaxWidth = newMaxWidth;
466
- return true;
346
+ return refresh;
467
347
  }
468
348
  }
469
349
  exports.Container = Container;