@tsparticles/engine 4.0.0-alpha.8 → 4.0.0-beta.1

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 (307) hide show
  1. package/155.min.js +1 -0
  2. package/README.md +41 -28
  3. package/browser/Core/CanvasManager.js +303 -0
  4. package/browser/Core/Container.js +134 -101
  5. package/browser/Core/Engine.js +29 -162
  6. package/browser/Core/Particle.js +197 -183
  7. package/browser/Core/ParticlesManager.js +363 -0
  8. package/browser/Core/RenderManager.js +303 -0
  9. package/browser/Core/Retina.js +6 -6
  10. package/browser/Core/Utils/Constants.js +2 -2
  11. package/browser/Core/Utils/EventListeners.js +67 -63
  12. package/browser/Core/Utils/PluginManager.js +145 -0
  13. package/browser/Core/Utils/Ranges.js +29 -10
  14. package/browser/Core/Utils/SpatialHashGrid.js +102 -0
  15. package/browser/Core/Utils/Vectors.js +17 -18
  16. package/browser/Options/Classes/AnimatableColor.js +1 -0
  17. package/browser/Options/Classes/AnimationOptions.js +8 -0
  18. package/browser/Options/Classes/Background/Background.js +6 -0
  19. package/browser/Options/Classes/ColorAnimation.js +12 -1
  20. package/browser/Options/Classes/FullScreen/FullScreen.js +2 -0
  21. package/browser/Options/Classes/HslAnimation.js +4 -5
  22. package/browser/Options/Classes/Options.js +67 -8
  23. package/browser/Options/Classes/OptionsColor.js +1 -0
  24. package/browser/Options/Classes/Particles/Bounce/ParticlesBounce.js +2 -0
  25. package/browser/Options/Classes/Particles/Effect/Effect.js +3 -4
  26. package/browser/Options/Classes/Particles/Fill.js +28 -0
  27. package/browser/Options/Classes/Particles/Move/Move.js +17 -3
  28. package/browser/Options/Classes/Particles/Move/MoveAngle.js +2 -0
  29. package/browser/Options/Classes/Particles/Move/MoveCenter.js +4 -0
  30. package/browser/Options/Classes/Particles/Move/MoveGravity.js +4 -0
  31. package/browser/Options/Classes/Particles/Move/OutModes.js +5 -0
  32. package/browser/Options/Classes/Particles/Move/Path/MovePath.js +5 -0
  33. package/browser/Options/Classes/Particles/Move/Spin.js +3 -0
  34. package/browser/Options/Classes/Particles/Number/ParticlesDensity.js +3 -0
  35. package/browser/Options/Classes/Particles/Number/ParticlesNumber.js +3 -0
  36. package/browser/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -0
  37. package/browser/Options/Classes/Particles/Opacity/Opacity.js +1 -0
  38. package/browser/Options/Classes/Particles/Opacity/OpacityAnimation.js +1 -0
  39. package/browser/Options/Classes/Particles/ParticlesOptions.js +29 -9
  40. package/browser/Options/Classes/Particles/Shape/Shape.js +3 -4
  41. package/browser/Options/Classes/Particles/Size/Size.js +1 -0
  42. package/browser/Options/Classes/Particles/Size/SizeAnimation.js +1 -0
  43. package/browser/Options/Classes/Particles/Stroke.js +3 -0
  44. package/browser/Options/Classes/Particles/ZIndex/ZIndex.js +3 -0
  45. package/browser/Options/Classes/ResizeEvent.js +2 -0
  46. package/browser/Options/Classes/ValueWithRandom.js +3 -4
  47. package/browser/Utils/CanvasUtils.js +44 -51
  48. package/browser/Utils/ColorUtils.js +51 -40
  49. package/browser/Utils/EventDispatcher.js +1 -0
  50. package/browser/Utils/LogUtils.js +1 -0
  51. package/browser/Utils/MathUtils.js +12 -7
  52. package/browser/Utils/OptionsUtils.js +2 -2
  53. package/browser/Utils/Utils.js +109 -31
  54. package/browser/exports.js +1 -2
  55. package/cjs/Core/CanvasManager.js +303 -0
  56. package/cjs/Core/Container.js +134 -101
  57. package/cjs/Core/Engine.js +29 -162
  58. package/cjs/Core/Particle.js +197 -183
  59. package/cjs/Core/ParticlesManager.js +363 -0
  60. package/cjs/Core/RenderManager.js +303 -0
  61. package/cjs/Core/Retina.js +6 -6
  62. package/cjs/Core/Utils/Constants.js +2 -2
  63. package/cjs/Core/Utils/EventListeners.js +67 -63
  64. package/cjs/Core/Utils/PluginManager.js +145 -0
  65. package/cjs/Core/Utils/Ranges.js +29 -10
  66. package/cjs/Core/Utils/SpatialHashGrid.js +102 -0
  67. package/cjs/Core/Utils/Vectors.js +17 -18
  68. package/cjs/Options/Classes/AnimatableColor.js +1 -0
  69. package/cjs/Options/Classes/AnimationOptions.js +8 -0
  70. package/cjs/Options/Classes/Background/Background.js +6 -0
  71. package/cjs/Options/Classes/ColorAnimation.js +12 -1
  72. package/cjs/Options/Classes/FullScreen/FullScreen.js +2 -0
  73. package/cjs/Options/Classes/HslAnimation.js +4 -5
  74. package/cjs/Options/Classes/Options.js +67 -8
  75. package/cjs/Options/Classes/OptionsColor.js +1 -0
  76. package/cjs/Options/Classes/Particles/Bounce/ParticlesBounce.js +2 -0
  77. package/cjs/Options/Classes/Particles/Effect/Effect.js +3 -4
  78. package/cjs/Options/Classes/Particles/Fill.js +28 -0
  79. package/cjs/Options/Classes/Particles/Move/Move.js +17 -3
  80. package/cjs/Options/Classes/Particles/Move/MoveAngle.js +2 -0
  81. package/cjs/Options/Classes/Particles/Move/MoveCenter.js +4 -0
  82. package/cjs/Options/Classes/Particles/Move/MoveGravity.js +4 -0
  83. package/cjs/Options/Classes/Particles/Move/OutModes.js +5 -0
  84. package/cjs/Options/Classes/Particles/Move/Path/MovePath.js +5 -0
  85. package/cjs/Options/Classes/Particles/Move/Spin.js +3 -0
  86. package/cjs/Options/Classes/Particles/Number/ParticlesDensity.js +3 -0
  87. package/cjs/Options/Classes/Particles/Number/ParticlesNumber.js +3 -0
  88. package/cjs/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -0
  89. package/cjs/Options/Classes/Particles/Opacity/Opacity.js +1 -0
  90. package/cjs/Options/Classes/Particles/Opacity/OpacityAnimation.js +1 -0
  91. package/cjs/Options/Classes/Particles/ParticlesOptions.js +29 -9
  92. package/cjs/Options/Classes/Particles/Shape/Shape.js +3 -4
  93. package/cjs/Options/Classes/Particles/Size/Size.js +1 -0
  94. package/cjs/Options/Classes/Particles/Size/SizeAnimation.js +1 -0
  95. package/cjs/Options/Classes/Particles/Stroke.js +3 -0
  96. package/cjs/Options/Classes/Particles/ZIndex/ZIndex.js +3 -0
  97. package/cjs/Options/Classes/ResizeEvent.js +2 -0
  98. package/cjs/Options/Classes/ValueWithRandom.js +3 -4
  99. package/cjs/Utils/CanvasUtils.js +44 -51
  100. package/cjs/Utils/ColorUtils.js +51 -40
  101. package/cjs/Utils/EventDispatcher.js +1 -0
  102. package/cjs/Utils/LogUtils.js +1 -0
  103. package/cjs/Utils/MathUtils.js +12 -7
  104. package/cjs/Utils/OptionsUtils.js +2 -2
  105. package/cjs/Utils/Utils.js +109 -31
  106. package/cjs/exports.js +1 -2
  107. package/dist_browser_Core_Container_js.js +30 -20
  108. package/esm/Core/CanvasManager.js +303 -0
  109. package/esm/Core/Container.js +134 -101
  110. package/esm/Core/Engine.js +29 -162
  111. package/esm/Core/Particle.js +197 -183
  112. package/esm/Core/ParticlesManager.js +363 -0
  113. package/esm/Core/RenderManager.js +303 -0
  114. package/esm/Core/Retina.js +6 -6
  115. package/esm/Core/Utils/Constants.js +2 -2
  116. package/esm/Core/Utils/EventListeners.js +67 -63
  117. package/esm/Core/Utils/PluginManager.js +145 -0
  118. package/esm/Core/Utils/Ranges.js +29 -10
  119. package/esm/Core/Utils/SpatialHashGrid.js +102 -0
  120. package/esm/Core/Utils/Vectors.js +17 -18
  121. package/esm/Options/Classes/AnimatableColor.js +1 -0
  122. package/esm/Options/Classes/AnimationOptions.js +8 -0
  123. package/esm/Options/Classes/Background/Background.js +6 -0
  124. package/esm/Options/Classes/ColorAnimation.js +12 -1
  125. package/esm/Options/Classes/FullScreen/FullScreen.js +2 -0
  126. package/esm/Options/Classes/HslAnimation.js +4 -5
  127. package/esm/Options/Classes/Options.js +67 -8
  128. package/esm/Options/Classes/OptionsColor.js +1 -0
  129. package/esm/Options/Classes/Particles/Bounce/ParticlesBounce.js +2 -0
  130. package/esm/Options/Classes/Particles/Effect/Effect.js +3 -4
  131. package/esm/Options/Classes/Particles/Fill.js +28 -0
  132. package/esm/Options/Classes/Particles/Move/Move.js +17 -3
  133. package/esm/Options/Classes/Particles/Move/MoveAngle.js +2 -0
  134. package/esm/Options/Classes/Particles/Move/MoveCenter.js +4 -0
  135. package/esm/Options/Classes/Particles/Move/MoveGravity.js +4 -0
  136. package/esm/Options/Classes/Particles/Move/OutModes.js +5 -0
  137. package/esm/Options/Classes/Particles/Move/Path/MovePath.js +5 -0
  138. package/esm/Options/Classes/Particles/Move/Spin.js +3 -0
  139. package/esm/Options/Classes/Particles/Number/ParticlesDensity.js +3 -0
  140. package/esm/Options/Classes/Particles/Number/ParticlesNumber.js +3 -0
  141. package/esm/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -0
  142. package/esm/Options/Classes/Particles/Opacity/Opacity.js +1 -0
  143. package/esm/Options/Classes/Particles/Opacity/OpacityAnimation.js +1 -0
  144. package/esm/Options/Classes/Particles/ParticlesOptions.js +29 -9
  145. package/esm/Options/Classes/Particles/Shape/Shape.js +3 -4
  146. package/esm/Options/Classes/Particles/Size/Size.js +1 -0
  147. package/esm/Options/Classes/Particles/Size/SizeAnimation.js +1 -0
  148. package/esm/Options/Classes/Particles/Stroke.js +3 -0
  149. package/esm/Options/Classes/Particles/ZIndex/ZIndex.js +3 -0
  150. package/esm/Options/Classes/ResizeEvent.js +2 -0
  151. package/esm/Options/Classes/ValueWithRandom.js +3 -4
  152. package/esm/Utils/CanvasUtils.js +44 -51
  153. package/esm/Utils/ColorUtils.js +51 -40
  154. package/esm/Utils/EventDispatcher.js +1 -0
  155. package/esm/Utils/LogUtils.js +1 -0
  156. package/esm/Utils/MathUtils.js +12 -7
  157. package/esm/Utils/OptionsUtils.js +2 -2
  158. package/esm/Utils/Utils.js +109 -31
  159. package/esm/exports.js +1 -2
  160. package/package.json +1 -1
  161. package/report.html +84 -29
  162. package/scripts/install.js +4 -20
  163. package/tsparticles.engine.js +98 -86
  164. package/tsparticles.engine.min.js +2 -2
  165. package/types/Core/CanvasManager.d.ts +39 -0
  166. package/types/Core/Container.d.ts +29 -14
  167. package/types/Core/Engine.d.ts +2 -61
  168. package/types/Core/Interfaces/IColorManager.d.ts +0 -1
  169. package/types/Core/Interfaces/IContainerPlugin.d.ts +10 -8
  170. package/types/Core/Interfaces/IDrawParticleParams.d.ts +2 -1
  171. package/types/Core/Interfaces/IPalette.d.ts +7 -0
  172. package/types/Core/Interfaces/IParticleOpacityData.d.ts +1 -0
  173. package/types/Core/Interfaces/IParticleRetinaProps.d.ts +4 -4
  174. package/types/Core/Interfaces/IParticleUpdater.d.ts +2 -1
  175. package/types/Core/Interfaces/IParticleValueAnimation.d.ts +3 -3
  176. package/types/Core/Interfaces/IShapeDrawData.d.ts +10 -1
  177. package/types/Core/Interfaces/IShapeDrawer.d.ts +0 -1
  178. package/types/Core/Interfaces/IShapeValues.d.ts +0 -1
  179. package/types/Core/Particle.d.ts +7 -11
  180. package/types/Core/{Particles.d.ts → ParticlesManager.d.ts} +15 -14
  181. package/types/Core/RenderManager.d.ts +49 -0
  182. package/types/Core/Retina.d.ts +0 -2
  183. package/types/Core/Utils/Constants.d.ts +2 -2
  184. package/types/Core/Utils/PluginManager.d.ts +62 -0
  185. package/types/Core/Utils/Ranges.d.ts +4 -1
  186. package/types/Core/Utils/SpatialHashGrid.d.ts +25 -0
  187. package/types/Core/Utils/Vectors.d.ts +8 -10
  188. package/types/Options/Classes/ColorAnimation.d.ts +3 -1
  189. package/types/Options/Classes/HslAnimation.d.ts +3 -4
  190. package/types/Options/Classes/Options.d.ts +5 -3
  191. package/types/Options/Classes/Particles/Effect/Effect.d.ts +0 -1
  192. package/types/Options/Classes/Particles/Fill.d.ts +12 -0
  193. package/types/Options/Classes/Particles/Move/Move.d.ts +0 -2
  194. package/types/Options/Classes/Particles/ParticlesOptions.d.ts +5 -5
  195. package/types/Options/Classes/Particles/Shape/Shape.d.ts +0 -1
  196. package/types/Options/Classes/ValueWithRandom.d.ts +0 -1
  197. package/types/Options/Interfaces/IColorAnimation.d.ts +2 -0
  198. package/types/Options/Interfaces/IOptions.d.ts +1 -0
  199. package/types/Options/Interfaces/Particles/Effect/IEffect.d.ts +0 -1
  200. package/types/Options/Interfaces/Particles/IFill.d.ts +9 -0
  201. package/types/Options/Interfaces/Particles/IParticlesOptions.d.ts +2 -2
  202. package/types/Options/Interfaces/Particles/IStroke.d.ts +2 -2
  203. package/types/Options/Interfaces/Particles/Move/IMove.d.ts +0 -2
  204. package/types/Options/Interfaces/Particles/Shape/IShape.d.ts +0 -1
  205. package/types/Types/CanvasContextType.d.ts +1 -0
  206. package/types/Types/EngineInitializers.d.ts +6 -3
  207. package/types/Utils/CanvasUtils.d.ts +13 -16
  208. package/types/Utils/ColorUtils.d.ts +11 -10
  209. package/types/Utils/LogUtils.d.ts +1 -0
  210. package/types/Utils/MathUtils.d.ts +2 -0
  211. package/types/Utils/OptionsUtils.d.ts +2 -2
  212. package/types/Utils/Utils.d.ts +8 -1
  213. package/types/export-types.d.ts +7 -7
  214. package/types/exports.d.ts +1 -2
  215. package/umd/Core/CanvasManager.js +317 -0
  216. package/umd/Core/Container.js +134 -101
  217. package/umd/Core/Engine.js +28 -161
  218. package/umd/Core/Particle.js +198 -184
  219. package/umd/Core/{Particles.js → ParticlesManager.js} +186 -167
  220. package/umd/Core/RenderManager.js +317 -0
  221. package/umd/Core/Retina.js +6 -6
  222. package/umd/Core/Utils/Constants.js +3 -3
  223. package/umd/Core/Utils/EventListeners.js +67 -63
  224. package/umd/Core/Utils/PluginManager.js +159 -0
  225. package/umd/Core/Utils/Ranges.js +28 -9
  226. package/umd/Core/Utils/SpatialHashGrid.js +116 -0
  227. package/umd/Core/Utils/Vectors.js +17 -18
  228. package/umd/Options/Classes/AnimatableColor.js +1 -0
  229. package/umd/Options/Classes/AnimationOptions.js +8 -0
  230. package/umd/Options/Classes/Background/Background.js +6 -0
  231. package/umd/Options/Classes/ColorAnimation.js +12 -1
  232. package/umd/Options/Classes/FullScreen/FullScreen.js +2 -0
  233. package/umd/Options/Classes/HslAnimation.js +5 -6
  234. package/umd/Options/Classes/Options.js +67 -8
  235. package/umd/Options/Classes/OptionsColor.js +1 -0
  236. package/umd/Options/Classes/Particles/Bounce/ParticlesBounce.js +2 -0
  237. package/umd/Options/Classes/Particles/Effect/Effect.js +3 -4
  238. package/umd/Options/Classes/Particles/Fill.js +42 -0
  239. package/umd/Options/Classes/Particles/Move/Move.js +18 -4
  240. package/umd/Options/Classes/Particles/Move/MoveAngle.js +2 -0
  241. package/umd/Options/Classes/Particles/Move/MoveCenter.js +4 -0
  242. package/umd/Options/Classes/Particles/Move/MoveGravity.js +4 -0
  243. package/umd/Options/Classes/Particles/Move/OutModes.js +5 -0
  244. package/umd/Options/Classes/Particles/Move/Path/MovePath.js +5 -0
  245. package/umd/Options/Classes/Particles/Move/Spin.js +3 -0
  246. package/umd/Options/Classes/Particles/Number/ParticlesDensity.js +3 -0
  247. package/umd/Options/Classes/Particles/Number/ParticlesNumber.js +3 -0
  248. package/umd/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -0
  249. package/umd/Options/Classes/Particles/Opacity/Opacity.js +1 -0
  250. package/umd/Options/Classes/Particles/Opacity/OpacityAnimation.js +1 -0
  251. package/umd/Options/Classes/Particles/ParticlesOptions.js +30 -10
  252. package/umd/Options/Classes/Particles/Shape/Shape.js +3 -4
  253. package/umd/Options/Classes/Particles/Size/Size.js +1 -0
  254. package/umd/Options/Classes/Particles/Size/SizeAnimation.js +1 -0
  255. package/umd/Options/Classes/Particles/Stroke.js +3 -0
  256. package/umd/Options/Classes/Particles/ZIndex/ZIndex.js +3 -0
  257. package/umd/Options/Classes/ResizeEvent.js +2 -0
  258. package/umd/Options/Classes/ValueWithRandom.js +3 -4
  259. package/umd/Utils/CanvasUtils.js +44 -53
  260. package/umd/Utils/ColorUtils.js +51 -39
  261. package/umd/Utils/EventDispatcher.js +1 -0
  262. package/umd/Utils/LogUtils.js +1 -0
  263. package/umd/Utils/MathUtils.js +14 -7
  264. package/umd/Utils/OptionsUtils.js +2 -2
  265. package/umd/Utils/Utils.js +111 -32
  266. package/umd/exports.js +2 -3
  267. package/794.min.js +0 -2
  268. package/794.min.js.LICENSE.txt +0 -1
  269. package/browser/Core/Canvas.js +0 -469
  270. package/browser/Core/Particles.js +0 -344
  271. package/browser/Core/Utils/Point.js +0 -6
  272. package/browser/Core/Utils/QuadTree.js +0 -59
  273. package/browser/Options/Classes/Particles/Move/MoveAttract.js +0 -33
  274. package/cjs/Core/Canvas.js +0 -469
  275. package/cjs/Core/Particles.js +0 -344
  276. package/cjs/Core/Utils/Point.js +0 -6
  277. package/cjs/Core/Utils/QuadTree.js +0 -59
  278. package/cjs/Options/Classes/Particles/Move/MoveAttract.js +0 -33
  279. package/esm/Core/Canvas.js +0 -469
  280. package/esm/Core/Particles.js +0 -344
  281. package/esm/Core/Utils/Point.js +0 -6
  282. package/esm/Core/Utils/QuadTree.js +0 -59
  283. package/esm/Options/Classes/Particles/Move/MoveAttract.js +0 -33
  284. package/tsparticles.engine.min.js.LICENSE.txt +0 -1
  285. package/types/Core/Canvas.d.ts +0 -55
  286. package/types/Core/Interfaces/IMovePathGenerator.d.ts +0 -10
  287. package/types/Core/Interfaces/IParticleMover.d.ts +0 -7
  288. package/types/Core/Utils/Point.d.ts +0 -7
  289. package/types/Core/Utils/QuadTree.d.ts +0 -18
  290. package/types/Options/Classes/Particles/Move/MoveAttract.d.ts +0 -12
  291. package/types/Options/Interfaces/Particles/Move/IMoveAttract.d.ts +0 -7
  292. package/umd/Core/Canvas.js +0 -483
  293. package/umd/Core/Utils/Point.js +0 -20
  294. package/umd/Core/Utils/QuadTree.js +0 -73
  295. package/umd/Options/Classes/Particles/Move/MoveAttract.js +0 -47
  296. /package/browser/Core/Interfaces/{IMovePathGenerator.js → IPalette.js} +0 -0
  297. /package/browser/{Core/Interfaces/IParticleMover.js → Options/Interfaces/Particles/IFill.js} +0 -0
  298. /package/browser/{Options/Interfaces/Particles/Move/IMoveAttract.js → Types/CanvasContextType.js} +0 -0
  299. /package/cjs/Core/Interfaces/{IMovePathGenerator.js → IPalette.js} +0 -0
  300. /package/cjs/{Core/Interfaces/IParticleMover.js → Options/Interfaces/Particles/IFill.js} +0 -0
  301. /package/cjs/{Options/Interfaces/Particles/Move/IMoveAttract.js → Types/CanvasContextType.js} +0 -0
  302. /package/esm/Core/Interfaces/{IMovePathGenerator.js → IPalette.js} +0 -0
  303. /package/esm/{Core/Interfaces/IParticleMover.js → Options/Interfaces/Particles/IFill.js} +0 -0
  304. /package/esm/{Options/Interfaces/Particles/Move/IMoveAttract.js → Types/CanvasContextType.js} +0 -0
  305. /package/umd/Core/Interfaces/{IMovePathGenerator.js → IPalette.js} +0 -0
  306. /package/umd/{Core/Interfaces/IParticleMover.js → Options/Interfaces/Particles/IFill.js} +0 -0
  307. /package/umd/{Options/Interfaces/Particles/Move/IMoveAttract.js → Types/CanvasContextType.js} +0 -0
@@ -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"], factory);
7
+ define(["require", "exports", "../Utils/MathUtils.js", "./Utils/Constants.js", "./CanvasManager.js", "./Utils/EventListeners.js", "../Enums/Types/EventType.js", "../Options/Classes/Options.js", "./ParticlesManager.js", "./Retina.js", "../Utils/LogUtils.js", "../Utils/OptionsUtils.js"], factory);
8
8
  }
9
9
  })(function (require, exports) {
10
10
  "use strict";
@@ -12,11 +12,11 @@
12
12
  exports.Container = void 0;
13
13
  const MathUtils_js_1 = require("../Utils/MathUtils.js");
14
14
  const Constants_js_1 = require("./Utils/Constants.js");
15
- const Canvas_js_1 = require("./Canvas.js");
15
+ const CanvasManager_js_1 = require("./CanvasManager.js");
16
16
  const EventListeners_js_1 = require("./Utils/EventListeners.js");
17
17
  const EventType_js_1 = require("../Enums/Types/EventType.js");
18
18
  const Options_js_1 = require("../Options/Classes/Options.js");
19
- const Particles_js_1 = require("./Particles.js");
19
+ const ParticlesManager_js_1 = require("./ParticlesManager.js");
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");
@@ -27,44 +27,52 @@
27
27
  delta.value = value;
28
28
  delta.factor = smooth ? Constants_js_1.defaultFps / fpsLimit : (Constants_js_1.defaultFps * value) / Constants_js_1.millisecondsToSeconds;
29
29
  }
30
- function loadContainerOptions(engine, container, ...sourceOptionsArr) {
31
- const options = new Options_js_1.Options(engine, container);
30
+ function loadContainerOptions(pluginManager, container, ...sourceOptionsArr) {
31
+ const options = new Options_js_1.Options(pluginManager, container);
32
32
  (0, OptionsUtils_js_1.loadOptions)(options, ...sourceOptionsArr);
33
33
  return options;
34
34
  }
35
35
  class Container {
36
- constructor(engine, id, sourceOptions) {
37
- this._delta = { value: 0, factor: 0 };
38
- this._nextFrame = (timestamp) => {
39
- try {
40
- if (!this._smooth &&
41
- this._lastFrameTime !== undefined &&
42
- timestamp < this._lastFrameTime + Constants_js_1.millisecondsToSeconds / this.fpsLimit) {
43
- this.draw(false);
44
- return;
45
- }
46
- this._lastFrameTime ??= timestamp;
47
- updateDelta(this._delta, timestamp - this._lastFrameTime, this.fpsLimit, this._smooth);
48
- this.addLifeTime(this._delta.value);
49
- this._lastFrameTime = timestamp;
50
- if (this._delta.value > Constants_js_1.millisecondsToSeconds) {
51
- this.draw(false);
52
- return;
53
- }
54
- this.canvas.drawParticles(this._delta);
55
- if (!this.alive()) {
56
- this.destroy();
57
- return;
58
- }
59
- if (this.animationStatus) {
60
- this.draw(false);
61
- }
62
- }
63
- catch (e) {
64
- (0, LogUtils_js_1.getLogger)().error("error in animation loop", e);
65
- }
66
- };
67
- this._engine = engine;
36
+ actualOptions;
37
+ canvas;
38
+ destroyed;
39
+ effectDrawers;
40
+ fpsLimit;
41
+ hdr;
42
+ id;
43
+ pageHidden;
44
+ particleCreatedPlugins;
45
+ particleDestroyedPlugins;
46
+ particlePositionPlugins;
47
+ particleUpdaters;
48
+ particles;
49
+ plugins;
50
+ retina;
51
+ shapeDrawers;
52
+ started;
53
+ zLayers;
54
+ _delay;
55
+ _delayTimeout;
56
+ _delta = { value: 0, factor: 0 };
57
+ _dispatchCallback;
58
+ _drawAnimationFrame;
59
+ _duration;
60
+ _eventListeners;
61
+ _firstStart;
62
+ _initialSourceOptions;
63
+ _lastFrameTime;
64
+ _lifeTime;
65
+ _onDestroy;
66
+ _options;
67
+ _paused;
68
+ _pluginManager;
69
+ _smooth;
70
+ _sourceOptions;
71
+ constructor(params) {
72
+ const { dispatchCallback, pluginManager, id, onDestroy, sourceOptions } = params;
73
+ this._pluginManager = pluginManager;
74
+ this._dispatchCallback = dispatchCallback;
75
+ this._onDestroy = onDestroy;
68
76
  this.id = Symbol(id);
69
77
  this.fpsLimit = 120;
70
78
  this.hdr = false;
@@ -81,17 +89,20 @@
81
89
  this.pageHidden = false;
82
90
  this._sourceOptions = sourceOptions;
83
91
  this._initialSourceOptions = sourceOptions;
84
- this.retina = new Retina_js_1.Retina(this);
85
- this.canvas = new Canvas_js_1.Canvas(this, this._engine);
86
- this.particles = new Particles_js_1.Particles(this._engine, this);
87
- this.pathGenerators = new Map();
88
- this.plugins = [];
89
92
  this.effectDrawers = new Map();
90
93
  this.shapeDrawers = new Map();
91
- this._options = loadContainerOptions(this._engine, this);
92
- this.actualOptions = loadContainerOptions(this._engine, this);
94
+ this.particleUpdaters = [];
95
+ this.retina = new Retina_js_1.Retina(this);
96
+ this.canvas = new CanvasManager_js_1.CanvasManager(this._pluginManager, this);
97
+ this.particles = new ParticlesManager_js_1.ParticlesManager(this._pluginManager, this);
98
+ this.plugins = [];
99
+ this.particleDestroyedPlugins = [];
100
+ this.particleCreatedPlugins = [];
101
+ this.particlePositionPlugins = [];
102
+ this._options = loadContainerOptions(this._pluginManager, this);
103
+ this.actualOptions = loadContainerOptions(this._pluginManager, this);
93
104
  this._eventListeners = new EventListeners_js_1.EventListeners(this);
94
- this._engine.dispatchEvent(EventType_js_1.EventType.containerBuilt, { container: this });
105
+ this.dispatchEvent(EventType_js_1.EventType.containerBuilt);
95
106
  }
96
107
  get animationStatus() {
97
108
  return !this._paused && !this.pageHidden && guardCheck(this);
@@ -105,13 +116,6 @@
105
116
  addLifeTime(value) {
106
117
  this._lifeTime += value;
107
118
  }
108
- addPath(key, generator, override = false) {
109
- if (!guardCheck(this) || (!override && this.pathGenerators.has(key))) {
110
- return false;
111
- }
112
- this.pathGenerators.set(key, generator);
113
- return true;
114
- }
115
119
  alive() {
116
120
  return !this._duration || this._lifeTime <= this._duration;
117
121
  }
@@ -122,42 +126,41 @@
122
126
  this.stop();
123
127
  this.particles.destroy();
124
128
  this.canvas.destroy();
125
- for (const effectDrawer of this.effectDrawers.values()) {
129
+ for (const [, effectDrawer] of this.effectDrawers) {
126
130
  effectDrawer.destroy?.(this);
127
131
  }
128
- this.effectDrawers.clear();
129
- for (const shapeDrawer of this.shapeDrawers.values()) {
132
+ for (const [, shapeDrawer] of this.shapeDrawers) {
130
133
  shapeDrawer.destroy?.(this);
131
134
  }
132
- this.shapeDrawers.clear();
133
135
  for (const plugin of this.plugins) {
134
136
  plugin.destroy?.();
135
137
  }
138
+ this.effectDrawers = new Map();
139
+ this.shapeDrawers = new Map();
140
+ this.particleUpdaters = [];
136
141
  this.plugins.length = 0;
137
- this._engine.clearPlugins(this);
142
+ this._pluginManager.clearPlugins(this);
138
143
  this.destroyed = true;
139
- if (remove) {
140
- const mainArr = this._engine.items, idx = mainArr.indexOf(this);
141
- if (idx >= Constants_js_1.removeMinIndex) {
142
- mainArr.splice(idx, Constants_js_1.removeDeleteCount);
143
- }
144
- }
145
- this._engine.dispatchEvent(EventType_js_1.EventType.containerDestroyed, { container: this });
144
+ this._onDestroy(remove);
145
+ this.dispatchEvent(EventType_js_1.EventType.containerDestroyed);
146
+ }
147
+ dispatchEvent(type, data) {
148
+ this._dispatchCallback(type, {
149
+ container: this,
150
+ data,
151
+ });
146
152
  }
147
153
  draw(force) {
148
154
  if (!guardCheck(this)) {
149
155
  return;
150
156
  }
151
157
  let refreshTime = force;
152
- const frame = (timestamp) => {
158
+ this._drawAnimationFrame = (0, MathUtils_js_1.animate)((timestamp) => {
153
159
  if (refreshTime) {
154
160
  this._lastFrameTime = undefined;
155
161
  refreshTime = false;
156
162
  }
157
163
  this._nextFrame(timestamp);
158
- };
159
- this._drawAnimationFrame = (0, MathUtils_js_1.animate)(timestamp => {
160
- frame(timestamp);
161
164
  });
162
165
  }
163
166
  async export(type, options = {}) {
@@ -178,34 +181,33 @@
178
181
  if (!guardCheck(this)) {
179
182
  return;
180
183
  }
181
- const effects = this._engine.getSupportedEffects();
182
- for (const type of effects) {
183
- const drawer = this._engine.getEffectDrawer(type);
184
- if (drawer) {
185
- this.effectDrawers.set(type, drawer);
186
- }
187
- }
188
- const shapes = this._engine.getSupportedShapes();
189
- for (const type of shapes) {
190
- const drawer = this._engine.getShapeDrawer(type);
191
- if (drawer) {
192
- this.shapeDrawers.set(type, drawer);
193
- }
194
- }
195
184
  const allContainerPlugins = new Map();
196
- for (const plugin of this._engine.plugins) {
185
+ for (const plugin of this._pluginManager.plugins) {
197
186
  const containerPlugin = await plugin.getPlugin(this);
198
187
  if (containerPlugin.preInit) {
199
188
  await containerPlugin.preInit();
200
189
  }
201
190
  allContainerPlugins.set(plugin, containerPlugin);
202
191
  }
203
- await this.particles.initPlugins();
204
- this._options = loadContainerOptions(this._engine, this, this._initialSourceOptions, this.sourceOptions);
205
- this.actualOptions = loadContainerOptions(this._engine, this, this._options);
192
+ await this.initDrawersAndUpdaters();
193
+ this._options = loadContainerOptions(this._pluginManager, this, this._initialSourceOptions, this.sourceOptions);
194
+ this.actualOptions = loadContainerOptions(this._pluginManager, this, this._options);
195
+ this.plugins.length = 0;
196
+ this.particleDestroyedPlugins.length = 0;
197
+ this.particleCreatedPlugins.length = 0;
198
+ this.particlePositionPlugins.length = 0;
206
199
  for (const [plugin, containerPlugin] of allContainerPlugins) {
207
200
  if (plugin.needsPlugin(this.actualOptions)) {
208
201
  this.plugins.push(containerPlugin);
202
+ if (containerPlugin.particleCreated) {
203
+ this.particleCreatedPlugins.push(containerPlugin);
204
+ }
205
+ if (containerPlugin.particleDestroyed) {
206
+ this.particleDestroyedPlugins.push(containerPlugin);
207
+ }
208
+ if (containerPlugin.particlePosition) {
209
+ this.particlePositionPlugins.push(containerPlugin);
210
+ }
209
211
  }
210
212
  }
211
213
  this.retina.init();
@@ -224,19 +226,19 @@
224
226
  for (const plugin of this.plugins) {
225
227
  await plugin.init?.();
226
228
  }
227
- for (const drawer of this.effectDrawers.values()) {
228
- await drawer.init?.(this);
229
- }
230
- for (const drawer of this.shapeDrawers.values()) {
231
- await drawer.init?.(this);
232
- }
233
- this._engine.dispatchEvent(EventType_js_1.EventType.containerInit, { container: this });
234
229
  await this.particles.init();
230
+ this.dispatchEvent(EventType_js_1.EventType.containerInit);
235
231
  this.particles.setDensity();
236
232
  for (const plugin of this.plugins) {
237
233
  plugin.particlesSetup?.();
238
234
  }
239
- this._engine.dispatchEvent(EventType_js_1.EventType.particlesSetup, { container: this });
235
+ this.dispatchEvent(EventType_js_1.EventType.particlesSetup);
236
+ }
237
+ async initDrawersAndUpdaters() {
238
+ const pluginManager = this._pluginManager;
239
+ this.effectDrawers = await pluginManager.getEffectDrawers(this, true);
240
+ this.shapeDrawers = await pluginManager.getShapeDrawers(this, true);
241
+ this.particleUpdaters = await pluginManager.getUpdaters(this, true);
240
242
  }
241
243
  pause() {
242
244
  if (!guardCheck(this)) {
@@ -255,7 +257,7 @@
255
257
  if (!this.pageHidden) {
256
258
  this._paused = true;
257
259
  }
258
- this._engine.dispatchEvent(EventType_js_1.EventType.containerPaused, { container: this });
260
+ this.dispatchEvent(EventType_js_1.EventType.containerPaused);
259
261
  }
260
262
  play(force) {
261
263
  if (!guardCheck(this)) {
@@ -276,7 +278,7 @@
276
278
  }
277
279
  }
278
280
  }
279
- this._engine.dispatchEvent(EventType_js_1.EventType.containerPlay, { container: this });
281
+ this.dispatchEvent(EventType_js_1.EventType.containerPlay);
280
282
  this.draw(needsUpdate ?? false);
281
283
  }
282
284
  async refresh() {
@@ -292,8 +294,8 @@
292
294
  }
293
295
  this._initialSourceOptions = sourceOptions;
294
296
  this._sourceOptions = sourceOptions;
295
- this._options = loadContainerOptions(this._engine, this, this._initialSourceOptions, this.sourceOptions);
296
- this.actualOptions = loadContainerOptions(this._engine, this, this._options);
297
+ this._options = loadContainerOptions(this._pluginManager, this, this._initialSourceOptions, this.sourceOptions);
298
+ this.actualOptions = loadContainerOptions(this._pluginManager, this, this._options);
297
299
  return this.refresh();
298
300
  }
299
301
  async start() {
@@ -308,7 +310,7 @@
308
310
  for (const plugin of this.plugins) {
309
311
  await plugin.start?.();
310
312
  }
311
- this._engine.dispatchEvent(EventType_js_1.EventType.containerStarted, { container: this });
313
+ this.dispatchEvent(EventType_js_1.EventType.containerStarted);
312
314
  this.play();
313
315
  resolve();
314
316
  };
@@ -332,9 +334,11 @@
332
334
  for (const plugin of this.plugins) {
333
335
  plugin.stop?.();
334
336
  }
335
- this.plugins.length = 0;
337
+ this.particleCreatedPlugins.length = 0;
338
+ this.particleDestroyedPlugins.length = 0;
339
+ this.particlePositionPlugins.length = 0;
336
340
  this._sourceOptions = this._options;
337
- this._engine.dispatchEvent(EventType_js_1.EventType.containerStopped, { container: this });
341
+ this.dispatchEvent(EventType_js_1.EventType.containerStopped);
338
342
  }
339
343
  updateActualOptions() {
340
344
  let refresh = false;
@@ -345,6 +349,35 @@
345
349
  }
346
350
  return refresh;
347
351
  }
352
+ _nextFrame = (timestamp) => {
353
+ try {
354
+ if (!this._smooth &&
355
+ this._lastFrameTime !== undefined &&
356
+ timestamp < this._lastFrameTime + Constants_js_1.millisecondsToSeconds / this.fpsLimit) {
357
+ this.draw(false);
358
+ return;
359
+ }
360
+ this._lastFrameTime ??= timestamp;
361
+ updateDelta(this._delta, timestamp - this._lastFrameTime, this.fpsLimit, this._smooth);
362
+ this.addLifeTime(this._delta.value);
363
+ this._lastFrameTime = timestamp;
364
+ if (this._delta.value > Constants_js_1.millisecondsToSeconds) {
365
+ this.draw(false);
366
+ return;
367
+ }
368
+ this.canvas.render.drawParticles(this._delta);
369
+ if (!this.alive()) {
370
+ this.destroy();
371
+ return;
372
+ }
373
+ if (this.animationStatus) {
374
+ this.draw(false);
375
+ }
376
+ }
377
+ catch (e) {
378
+ (0, LogUtils_js_1.getLogger)().error("error in animation loop", e);
379
+ }
380
+ };
348
381
  }
349
382
  exports.Container = Container;
350
383
  });
@@ -37,7 +37,7 @@ var __importStar = (this && this.__importStar) || (function () {
37
37
  if (v !== undefined) module.exports = v;
38
38
  }
39
39
  else if (typeof define === "function" && define.amd) {
40
- define(["require", "exports", "./Utils/Constants.js", "../Utils/Utils.js", "../Utils/EventDispatcher.js", "../Enums/Types/EventType.js", "../Utils/LogUtils.js", "../Utils/MathUtils.js"], factory);
40
+ define(["require", "exports", "./Utils/Constants.js", "../Utils/Utils.js", "../Utils/EventDispatcher.js", "./Utils/PluginManager.js", "../Utils/LogUtils.js", "../Utils/MathUtils.js"], factory);
41
41
  }
42
42
  })(function (require, exports) {
43
43
  "use strict";
@@ -47,7 +47,7 @@ var __importStar = (this && this.__importStar) || (function () {
47
47
  const Constants_js_1 = require("./Utils/Constants.js");
48
48
  const Utils_js_1 = require("../Utils/Utils.js");
49
49
  const EventDispatcher_js_1 = require("../Utils/EventDispatcher.js");
50
- const EventType_js_1 = require("../Enums/Types/EventType.js");
50
+ const PluginManager_js_1 = require("./Utils/PluginManager.js");
51
51
  const LogUtils_js_1 = require("../Utils/LogUtils.js");
52
52
  const MathUtils_js_1 = require("../Utils/MathUtils.js");
53
53
  const fullPercent = "100%";
@@ -91,163 +91,41 @@ var __importStar = (this && this.__importStar) || (function () {
91
91
  if (domContainer) {
92
92
  return domContainer;
93
93
  }
94
- domContainer = documentSafe.createElement("div");
94
+ domContainer = documentSafe.createElement("canvas");
95
95
  domContainer.id = id;
96
96
  domContainer.dataset[Constants_js_1.generatedAttribute] = Constants_js_1.generatedTrue;
97
97
  documentSafe.body.append(domContainer);
98
98
  return domContainer;
99
99
  };
100
100
  class Engine {
101
- constructor() {
102
- this._configs = new Map();
103
- this._domArray = [];
104
- this._eventDispatcher = new EventDispatcher_js_1.EventDispatcher();
105
- this._initialized = false;
106
- this._isRunningLoaders = false;
107
- this._loadPromises = new Set();
108
- this._allLoadersSet = new Set();
109
- this._executedSet = new Set();
110
- this.plugins = [];
111
- this.colorManagers = new Map();
112
- this.easingFunctions = new Map();
113
- this._initializers = {
114
- movers: new Map(),
115
- updaters: new Map(),
116
- };
117
- this.movers = new Map();
118
- this.updaters = new Map();
119
- this.presets = new Map();
120
- this.effectDrawers = new Map();
121
- this.shapeDrawers = new Map();
122
- this.pathGenerators = new Map();
123
- }
124
- get configs() {
125
- const res = {};
126
- for (const [name, config] of this._configs) {
127
- res[name] = config;
128
- }
129
- return res;
130
- }
101
+ pluginManager = new PluginManager_js_1.PluginManager(this);
102
+ _domArray = [];
103
+ _eventDispatcher = new EventDispatcher_js_1.EventDispatcher();
104
+ _initialized = false;
131
105
  get items() {
132
106
  return this._domArray;
133
107
  }
134
108
  get version() {
135
- return "4.0.0-alpha.8";
136
- }
137
- addColorManager(manager) {
138
- this.colorManagers.set(manager.key, manager);
139
- }
140
- addConfig(config) {
141
- const key = config.key ?? config.name ?? "default";
142
- this._configs.set(key, config);
143
- this._eventDispatcher.dispatchEvent(EventType_js_1.EventType.configAdded, { data: { name: key, config } });
144
- }
145
- addEasing(name, easing) {
146
- if (this.easingFunctions.get(name)) {
147
- return;
148
- }
149
- this.easingFunctions.set(name, easing);
150
- }
151
- addEffect(effect, drawer) {
152
- if (this.getEffectDrawer(effect)) {
153
- return;
154
- }
155
- this.effectDrawers.set(effect, drawer);
109
+ return "4.0.0-beta.1";
156
110
  }
157
111
  addEventListener(type, listener) {
158
112
  this._eventDispatcher.addEventListener(type, listener);
159
113
  }
160
- addMover(name, moverInitializer) {
161
- this._initializers.movers.set(name, moverInitializer);
162
- }
163
- addParticleUpdater(name, updaterInitializer) {
164
- this._initializers.updaters.set(name, updaterInitializer);
165
- }
166
- addPathGenerator(name, generator) {
167
- if (this.getPathGenerator(name)) {
168
- return;
169
- }
170
- this.pathGenerators.set(name, generator);
171
- }
172
- addPlugin(plugin) {
173
- if (this.getPlugin(plugin.id)) {
174
- return;
175
- }
176
- this.plugins.push(plugin);
177
- }
178
- addPreset(preset, options, override = false) {
179
- if (!(override || !this.getPreset(preset))) {
180
- return;
181
- }
182
- this.presets.set(preset, options);
183
- }
184
- addShape(drawer) {
185
- for (const validType of drawer.validTypes) {
186
- if (this.getShapeDrawer(validType)) {
187
- continue;
188
- }
189
- this.shapeDrawers.set(validType, drawer);
190
- }
191
- }
192
114
  checkVersion(pluginVersion) {
193
115
  if (this.version === pluginVersion) {
194
116
  return;
195
117
  }
196
118
  throw new Error(`The tsParticles version is different from the loaded plugins version. Engine version: ${this.version}. Plugin version: ${pluginVersion}`);
197
119
  }
198
- clearPlugins(container) {
199
- this.updaters.delete(container);
200
- this.movers.delete(container);
201
- }
202
120
  dispatchEvent(type, args) {
203
121
  this._eventDispatcher.dispatchEvent(type, args);
204
122
  }
205
- getEasing(name) {
206
- return this.easingFunctions.get(name) ?? ((value) => value);
207
- }
208
- getEffectDrawer(type) {
209
- return this.effectDrawers.get(type);
210
- }
211
- async getMovers(container, force = false) {
212
- return (0, Utils_js_1.getItemsFromInitializer)(container, this.movers, this._initializers.movers, force);
213
- }
214
- getPathGenerator(type) {
215
- return this.pathGenerators.get(type);
216
- }
217
- getPlugin(plugin) {
218
- return this.plugins.find(t => t.id === plugin);
219
- }
220
- getPreset(preset) {
221
- return this.presets.get(preset);
222
- }
223
- getShapeDrawer(type) {
224
- return this.shapeDrawers.get(type);
225
- }
226
- getSupportedEffects() {
227
- return this.effectDrawers.keys();
228
- }
229
- getSupportedShapes() {
230
- return this.shapeDrawers.keys();
231
- }
232
- async getUpdaters(container, force = false) {
233
- return (0, Utils_js_1.getItemsFromInitializer)(container, this.updaters, this._initializers.updaters, force);
234
- }
235
123
  async init() {
236
- if (this._initialized || this._isRunningLoaders)
124
+ if (this._initialized) {
237
125
  return;
238
- this._isRunningLoaders = true;
239
- this._executedSet = new Set();
240
- this._allLoadersSet = new Set(this._loadPromises);
241
- try {
242
- for (const loader of this._allLoadersSet) {
243
- await this._runLoader(loader, this._executedSet, this._allLoadersSet);
244
- }
245
- }
246
- finally {
247
- this._loadPromises.clear();
248
- this._isRunningLoaders = false;
249
- this._initialized = true;
250
126
  }
127
+ await this.pluginManager.init();
128
+ this._initialized = true;
251
129
  }
252
130
  item(index) {
253
131
  const { items } = this, item = items[index];
@@ -259,7 +137,23 @@ var __importStar = (this && this.__importStar) || (function () {
259
137
  }
260
138
  async load(params) {
261
139
  await this.init();
262
- const { Container } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./Container.js"))) : new Promise((resolve_1, reject_1) => { require(["./Container.js"], resolve_1, reject_1); }).then(__importStar)), id = params.id ?? params.element?.id ?? `tsparticles${Math.floor((0, MathUtils_js_1.getRandom)() * Constants_js_1.loadRandomFactor).toString()}`, { index, url } = params, options = url ? await getDataFromUrl({ fallback: params.options, url, index }) : params.options, currentOptions = (0, Utils_js_1.itemFromSingleOrMultiple)(options, index), { items } = this, oldIndex = items.findIndex(v => v.id.description === id), newItem = new Container(this, id, currentOptions);
140
+ const { Container } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./Container.js"))) : new Promise((resolve_1, reject_1) => { require(["./Container.js"], resolve_1, reject_1); }).then(__importStar)), id = params.id ?? params.element?.id ?? `tsparticles${Math.floor((0, MathUtils_js_1.getRandom)() * Constants_js_1.loadRandomFactor).toString()}`, { index, url } = params, options = url ? await getDataFromUrl({ fallback: params.options, url, index }) : params.options, currentOptions = (0, Utils_js_1.itemFromSingleOrMultiple)(options, index), { items } = this, oldIndex = items.findIndex(v => v.id.description === id), newItem = new Container({
141
+ dispatchCallback: (eventType, args) => {
142
+ this.dispatchEvent(eventType, args);
143
+ },
144
+ id,
145
+ onDestroy: (remove) => {
146
+ if (!remove) {
147
+ return;
148
+ }
149
+ const mainArr = this.items, idx = mainArr.indexOf(newItem);
150
+ if (idx >= Constants_js_1.removeMinIndex) {
151
+ mainArr.splice(idx, Constants_js_1.removeDeleteCount);
152
+ }
153
+ },
154
+ pluginManager: this.pluginManager,
155
+ sourceOptions: currentOptions,
156
+ });
263
157
  if (oldIndex >= Constants_js_1.loadMinIndex) {
264
158
  const old = this.item(oldIndex), deleteCount = old ? Constants_js_1.one : Constants_js_1.none;
265
159
  if (old && !old.destroyed) {
@@ -275,42 +169,15 @@ var __importStar = (this && this.__importStar) || (function () {
275
169
  await newItem.start();
276
170
  return newItem;
277
171
  }
278
- loadParticlesOptions(container, options, ...sourceOptions) {
279
- const updaters = this.updaters.get(container);
280
- if (!updaters) {
281
- return;
282
- }
283
- updaters.forEach(updater => updater.loadOptions?.(options, ...sourceOptions));
284
- }
285
172
  async refresh(refresh = true) {
286
173
  if (!refresh) {
287
174
  return;
288
175
  }
289
176
  await Promise.all(this.items.map(t => t.refresh()));
290
177
  }
291
- async register(...loaders) {
292
- if (this._initialized) {
293
- throw new Error("Register plugins can only be done before calling tsParticles.load()");
294
- }
295
- for (const loader of loaders) {
296
- if (this._isRunningLoaders) {
297
- await this._runLoader(loader, this._executedSet, this._allLoadersSet);
298
- }
299
- else {
300
- this._loadPromises.add(loader);
301
- }
302
- }
303
- }
304
178
  removeEventListener(type, listener) {
305
179
  this._eventDispatcher.removeEventListener(type, listener);
306
180
  }
307
- async _runLoader(loader, executed, allLoaders) {
308
- if (executed.has(loader))
309
- return;
310
- executed.add(loader);
311
- allLoaders.add(loader);
312
- await loader(this);
313
- }
314
181
  }
315
182
  exports.Engine = Engine;
316
183
  });