@tsparticles/engine 3.0.0-alpha.0 → 3.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (336) hide show
  1. package/README.md +246 -211
  2. package/browser/Core/Canvas.js +271 -241
  3. package/browser/Core/Container.js +90 -106
  4. package/browser/Core/Engine.js +271 -0
  5. package/browser/Core/Particle.js +158 -162
  6. package/browser/Core/Particles.js +148 -134
  7. package/browser/Core/Retina.js +15 -13
  8. package/browser/Core/Utils/Circle.js +10 -6
  9. package/browser/Core/Utils/Constants.js +4 -3
  10. package/browser/Core/Utils/EventListeners.js +259 -220
  11. package/browser/Core/Utils/InteractionManager.js +6 -16
  12. package/browser/Core/Utils/QuadTree.js +14 -20
  13. package/browser/Core/Utils/Vector3d.js +17 -9
  14. package/browser/Options/Classes/AnimatableColor.js +2 -1
  15. package/browser/Options/Classes/AnimationOptions.js +7 -2
  16. package/browser/Options/Classes/BackgroundMask/BackgroundMask.js +2 -1
  17. package/browser/Options/Classes/ColorAnimation.js +4 -0
  18. package/browser/Options/Classes/Interactivity/Events/DivEvent.js +0 -24
  19. package/browser/Options/Classes/Interactivity/Events/Events.js +5 -24
  20. package/browser/Options/Classes/Interactivity/Interactivity.js +1 -8
  21. package/browser/Options/Classes/Interactivity/Modes/Modes.js +11 -8
  22. package/browser/Options/Classes/ManualParticle.js +5 -5
  23. package/browser/Options/Classes/Options.js +19 -39
  24. package/browser/Options/Classes/OptionsColor.js +3 -2
  25. package/browser/Options/Classes/Particles/Collisions/Collisions.js +5 -0
  26. package/browser/Options/Classes/Particles/Move/Move.js +11 -41
  27. package/browser/Options/Classes/Particles/Move/MoveAttract.js +9 -20
  28. package/browser/Options/Classes/Particles/Move/MoveTrail.js +2 -8
  29. package/browser/Options/Classes/Particles/Move/OutModes.js +4 -5
  30. package/browser/Options/Classes/Particles/Move/Spin.js +3 -1
  31. package/browser/Options/Classes/Particles/Number/ParticlesDensity.js +2 -21
  32. package/browser/Options/Classes/Particles/Number/ParticlesNumber.js +2 -9
  33. package/browser/Options/Classes/Particles/Opacity/Opacity.js +11 -7
  34. package/browser/Options/Classes/Particles/Opacity/OpacityAnimation.js +0 -9
  35. package/browser/Options/Classes/Particles/ParticlesOptions.js +6 -11
  36. package/browser/Options/Classes/Particles/Shape/Shape.js +9 -2
  37. package/browser/Options/Classes/Particles/Size/Size.js +11 -7
  38. package/browser/Options/Classes/Particles/Size/SizeAnimation.js +0 -9
  39. package/browser/Options/Classes/ValueWithRandom.js +4 -17
  40. package/browser/Utils/CanvasUtils.js +18 -54
  41. package/browser/Utils/ColorUtils.js +17 -19
  42. package/browser/Utils/EventDispatcher.js +7 -6
  43. package/browser/Utils/HslColorManager.js +2 -4
  44. package/browser/Utils/NumberUtils.js +41 -45
  45. package/browser/Utils/RgbColorManager.js +2 -4
  46. package/browser/Utils/Utils.js +150 -59
  47. package/browser/bundle.js +4 -96
  48. package/browser/export-types.js +97 -0
  49. package/browser/exports.js +89 -0
  50. package/browser/index.js +8 -198
  51. package/browser/init.js +12 -0
  52. package/cjs/Core/Canvas.js +269 -239
  53. package/cjs/Core/Container.js +90 -106
  54. package/cjs/Core/Engine.js +275 -0
  55. package/cjs/Core/Particle.js +157 -161
  56. package/cjs/Core/Particles.js +148 -134
  57. package/cjs/Core/Retina.js +15 -13
  58. package/cjs/Core/Utils/Circle.js +10 -6
  59. package/cjs/Core/Utils/Constants.js +5 -4
  60. package/cjs/Core/Utils/EventListeners.js +258 -219
  61. package/cjs/Core/Utils/InteractionManager.js +6 -16
  62. package/cjs/Core/Utils/QuadTree.js +14 -20
  63. package/cjs/Core/Utils/Vector3d.js +17 -9
  64. package/cjs/Options/Classes/AnimatableColor.js +2 -1
  65. package/cjs/Options/Classes/AnimationOptions.js +7 -2
  66. package/cjs/Options/Classes/BackgroundMask/BackgroundMask.js +2 -1
  67. package/cjs/Options/Classes/ColorAnimation.js +4 -0
  68. package/cjs/Options/Classes/Interactivity/Events/DivEvent.js +0 -24
  69. package/cjs/Options/Classes/Interactivity/Events/Events.js +5 -24
  70. package/cjs/Options/Classes/Interactivity/Interactivity.js +1 -8
  71. package/cjs/Options/Classes/Interactivity/Modes/Modes.js +11 -8
  72. package/cjs/Options/Classes/ManualParticle.js +5 -5
  73. package/cjs/Options/Classes/Options.js +18 -38
  74. package/cjs/Options/Classes/OptionsColor.js +3 -2
  75. package/cjs/Options/Classes/Particles/Collisions/Collisions.js +5 -0
  76. package/cjs/Options/Classes/Particles/Move/Move.js +11 -41
  77. package/cjs/Options/Classes/Particles/Move/MoveAttract.js +9 -20
  78. package/cjs/Options/Classes/Particles/Move/MoveTrail.js +2 -8
  79. package/cjs/Options/Classes/Particles/Move/OutModes.js +4 -5
  80. package/cjs/Options/Classes/Particles/Move/Spin.js +3 -1
  81. package/cjs/Options/Classes/Particles/Number/ParticlesDensity.js +2 -21
  82. package/cjs/Options/Classes/Particles/Number/ParticlesNumber.js +2 -9
  83. package/cjs/Options/Classes/Particles/Opacity/Opacity.js +10 -6
  84. package/cjs/Options/Classes/Particles/Opacity/OpacityAnimation.js +0 -9
  85. package/cjs/Options/Classes/Particles/ParticlesOptions.js +6 -11
  86. package/cjs/Options/Classes/Particles/Shape/Shape.js +9 -2
  87. package/cjs/Options/Classes/Particles/Size/Size.js +11 -7
  88. package/cjs/Options/Classes/Particles/Size/SizeAnimation.js +0 -9
  89. package/cjs/Options/Classes/ValueWithRandom.js +4 -17
  90. package/cjs/Utils/CanvasUtils.js +21 -58
  91. package/cjs/Utils/ColorUtils.js +16 -18
  92. package/cjs/Utils/EventDispatcher.js +7 -6
  93. package/cjs/Utils/HslColorManager.js +2 -4
  94. package/cjs/Utils/NumberUtils.js +41 -45
  95. package/cjs/Utils/RgbColorManager.js +2 -4
  96. package/cjs/Utils/Utils.js +163 -63
  97. package/cjs/bundle.js +4 -96
  98. package/cjs/export-types.js +113 -0
  99. package/cjs/exports.js +105 -0
  100. package/cjs/index.js +8 -198
  101. package/cjs/init.js +16 -0
  102. package/esm/Core/Canvas.js +271 -241
  103. package/esm/Core/Container.js +90 -106
  104. package/esm/Core/Engine.js +271 -0
  105. package/esm/Core/Particle.js +158 -162
  106. package/esm/Core/Particles.js +148 -134
  107. package/esm/Core/Retina.js +15 -13
  108. package/esm/Core/Utils/Circle.js +10 -6
  109. package/esm/Core/Utils/Constants.js +4 -3
  110. package/esm/Core/Utils/EventListeners.js +259 -220
  111. package/esm/Core/Utils/InteractionManager.js +6 -16
  112. package/esm/Core/Utils/QuadTree.js +14 -20
  113. package/esm/Core/Utils/Vector3d.js +17 -9
  114. package/esm/Options/Classes/AnimatableColor.js +2 -1
  115. package/esm/Options/Classes/AnimationOptions.js +7 -2
  116. package/esm/Options/Classes/BackgroundMask/BackgroundMask.js +2 -1
  117. package/esm/Options/Classes/ColorAnimation.js +4 -0
  118. package/esm/Options/Classes/Interactivity/Events/DivEvent.js +0 -24
  119. package/esm/Options/Classes/Interactivity/Events/Events.js +5 -24
  120. package/esm/Options/Classes/Interactivity/Interactivity.js +1 -8
  121. package/esm/Options/Classes/Interactivity/Modes/Modes.js +11 -8
  122. package/esm/Options/Classes/ManualParticle.js +5 -5
  123. package/esm/Options/Classes/Options.js +19 -39
  124. package/esm/Options/Classes/OptionsColor.js +3 -2
  125. package/esm/Options/Classes/Particles/Collisions/Collisions.js +5 -0
  126. package/esm/Options/Classes/Particles/Move/Move.js +11 -41
  127. package/esm/Options/Classes/Particles/Move/MoveAttract.js +9 -20
  128. package/esm/Options/Classes/Particles/Move/MoveTrail.js +2 -8
  129. package/esm/Options/Classes/Particles/Move/OutModes.js +4 -5
  130. package/esm/Options/Classes/Particles/Move/Spin.js +3 -1
  131. package/esm/Options/Classes/Particles/Number/ParticlesDensity.js +2 -21
  132. package/esm/Options/Classes/Particles/Number/ParticlesNumber.js +2 -9
  133. package/esm/Options/Classes/Particles/Opacity/Opacity.js +11 -7
  134. package/esm/Options/Classes/Particles/Opacity/OpacityAnimation.js +0 -9
  135. package/esm/Options/Classes/Particles/ParticlesOptions.js +6 -11
  136. package/esm/Options/Classes/Particles/Shape/Shape.js +9 -2
  137. package/esm/Options/Classes/Particles/Size/Size.js +11 -7
  138. package/esm/Options/Classes/Particles/Size/SizeAnimation.js +0 -9
  139. package/esm/Options/Classes/ValueWithRandom.js +4 -17
  140. package/esm/Utils/CanvasUtils.js +18 -54
  141. package/esm/Utils/ColorUtils.js +17 -19
  142. package/esm/Utils/EventDispatcher.js +7 -6
  143. package/esm/Utils/HslColorManager.js +2 -4
  144. package/esm/Utils/NumberUtils.js +41 -45
  145. package/esm/Utils/RgbColorManager.js +2 -4
  146. package/esm/Utils/Utils.js +150 -59
  147. package/esm/bundle.js +4 -96
  148. package/esm/export-types.js +97 -0
  149. package/esm/exports.js +89 -0
  150. package/esm/index.js +8 -198
  151. package/esm/init.js +12 -0
  152. package/package.json +17 -2
  153. package/report.html +4 -4
  154. package/scripts/install.js +90 -33
  155. package/tsparticles.engine.js +1848 -1961
  156. package/tsparticles.engine.min.js +1 -1
  157. package/tsparticles.engine.min.js.LICENSE.txt +1 -10
  158. package/types/Core/Canvas.d.ts +20 -16
  159. package/types/Core/Container.d.ts +10 -14
  160. package/types/Core/Engine.d.ts +71 -0
  161. package/types/Core/Interfaces/IContainerPlugin.d.ts +2 -0
  162. package/types/Core/Interfaces/ICoordinates.d.ts +5 -3
  163. package/types/Core/Interfaces/IDimension.d.ts +4 -0
  164. package/types/Core/Interfaces/IMovePathGenerator.d.ts +2 -1
  165. package/types/Core/Interfaces/IParticleUpdater.d.ts +0 -2
  166. package/types/Core/Interfaces/IParticleValueAnimation.d.ts +2 -0
  167. package/types/Core/Interfaces/IPlugin.d.ts +4 -3
  168. package/types/Core/Particle.d.ts +7 -7
  169. package/types/Core/Particles.d.ts +14 -10
  170. package/types/Core/Utils/Constants.d.ts +4 -3
  171. package/types/Core/Utils/EventListeners.d.ts +20 -14
  172. package/types/Core/Utils/InteractionManager.d.ts +1 -1
  173. package/types/Core/Utils/QuadTree.d.ts +2 -5
  174. package/types/Core/Utils/Vector3d.d.ts +2 -1
  175. package/types/Enums/Modes/AnimationMode.d.ts +6 -0
  176. package/types/Enums/Modes/{SizeMode.d.ts → PixelMode.d.ts} +1 -1
  177. package/types/Options/Classes/AnimationOptions.d.ts +3 -1
  178. package/types/Options/Classes/ColorAnimation.d.ts +1 -0
  179. package/types/Options/Classes/Interactivity/Events/DivEvent.d.ts +0 -6
  180. package/types/Options/Classes/Interactivity/Events/Events.d.ts +0 -6
  181. package/types/Options/Classes/Interactivity/Interactivity.d.ts +1 -3
  182. package/types/Options/Classes/Interactivity/Modes/Modes.d.ts +1 -1
  183. package/types/Options/Classes/ManualParticle.d.ts +2 -2
  184. package/types/Options/Classes/Options.d.ts +5 -12
  185. package/types/Options/Classes/Particles/Collisions/Collisions.d.ts +2 -0
  186. package/types/Options/Classes/Particles/Move/Move.d.ts +0 -11
  187. package/types/Options/Classes/Particles/Move/MoveAttract.d.ts +0 -4
  188. package/types/Options/Classes/Particles/Move/MoveCenter.d.ts +2 -2
  189. package/types/Options/Classes/Particles/Move/MoveTrail.d.ts +0 -3
  190. package/types/Options/Classes/Particles/Move/Spin.d.ts +2 -2
  191. package/types/Options/Classes/Particles/Number/ParticlesDensity.d.ts +0 -6
  192. package/types/Options/Classes/Particles/Number/ParticlesNumber.d.ts +0 -2
  193. package/types/Options/Classes/Particles/Opacity/Opacity.d.ts +4 -4
  194. package/types/Options/Classes/Particles/Opacity/OpacityAnimation.d.ts +0 -2
  195. package/types/Options/Classes/Particles/ParticlesOptions.d.ts +1 -1
  196. package/types/Options/Classes/Particles/Shape/Shape.d.ts +2 -0
  197. package/types/Options/Classes/Particles/Size/Size.d.ts +4 -4
  198. package/types/Options/Classes/Particles/Size/SizeAnimation.d.ts +0 -2
  199. package/types/Options/Classes/Responsive.d.ts +3 -3
  200. package/types/Options/Classes/Theme/Theme.d.ts +2 -2
  201. package/types/Options/Classes/ValueWithRandom.d.ts +2 -6
  202. package/types/Options/Interfaces/IAnimation.d.ts +3 -1
  203. package/types/Options/Interfaces/IManualParticle.d.ts +2 -2
  204. package/types/Options/Interfaces/IOptions.d.ts +1 -4
  205. package/types/Options/Interfaces/IResponsive.d.ts +4 -3
  206. package/types/Options/Interfaces/Interactivity/Events/IDivEvent.d.ts +0 -3
  207. package/types/Options/Interfaces/Interactivity/Events/IEvents.d.ts +0 -3
  208. package/types/Options/Interfaces/Interactivity/IInteractivity.d.ts +0 -1
  209. package/types/Options/Interfaces/Interactivity/Modes/IModeDiv.d.ts +0 -1
  210. package/types/Options/Interfaces/Particles/Collisions/ICollisions.d.ts +2 -0
  211. package/types/Options/Interfaces/Particles/IStroke.d.ts +2 -1
  212. package/types/Options/Interfaces/Particles/Move/IMove.d.ts +0 -5
  213. package/types/Options/Interfaces/Particles/Move/IMoveAttract.d.ts +0 -2
  214. package/types/Options/Interfaces/Particles/Move/IMoveTrail.d.ts +0 -2
  215. package/types/Options/Interfaces/Particles/Move/ISpin.d.ts +2 -2
  216. package/types/Options/Interfaces/Particles/Number/IParticlesDensity.d.ts +0 -3
  217. package/types/Options/Interfaces/Particles/Number/IParticlesNumber.d.ts +0 -1
  218. package/types/Options/Interfaces/Particles/Opacity/IOpacity.d.ts +0 -1
  219. package/types/Options/Interfaces/Particles/Opacity/IOpacityAnimation.d.ts +0 -1
  220. package/types/Options/Interfaces/Particles/Shape/IShape.d.ts +2 -0
  221. package/types/Options/Interfaces/Particles/Size/ISize.d.ts +0 -1
  222. package/types/Options/Interfaces/Particles/Size/ISizeAnimation.d.ts +0 -1
  223. package/types/Options/Interfaces/Theme/ITheme.d.ts +3 -2
  224. package/types/Types/ExportResult.d.ts +5 -0
  225. package/types/Utils/CanvasUtils.d.ts +2 -5
  226. package/types/Utils/OptionsUtils.d.ts +1 -1
  227. package/types/Utils/Utils.d.ts +22 -4
  228. package/types/bundle.d.ts +2 -90
  229. package/types/export-types.d.ts +107 -0
  230. package/types/exports.d.ts +89 -0
  231. package/types/index.d.ts +3 -203
  232. package/types/init.d.ts +2 -0
  233. package/umd/Core/Canvas.js +269 -239
  234. package/umd/Core/Container.js +91 -107
  235. package/umd/Core/Engine.js +285 -0
  236. package/umd/Core/Particle.js +158 -162
  237. package/umd/Core/Particles.js +149 -135
  238. package/umd/Core/Retina.js +15 -13
  239. package/umd/Core/Utils/Circle.js +11 -7
  240. package/umd/Core/Utils/Constants.js +5 -4
  241. package/umd/Core/Utils/EventListeners.js +258 -219
  242. package/umd/Core/Utils/InteractionManager.js +6 -16
  243. package/umd/Core/Utils/QuadTree.js +14 -20
  244. package/umd/Core/Utils/Vector3d.js +18 -10
  245. package/umd/Options/Classes/AnimatableColor.js +3 -2
  246. package/umd/Options/Classes/AnimationOptions.js +7 -2
  247. package/umd/Options/Classes/BackgroundMask/BackgroundMask.js +3 -2
  248. package/umd/Options/Classes/ColorAnimation.js +4 -0
  249. package/umd/Options/Classes/Interactivity/Events/DivEvent.js +1 -25
  250. package/umd/Options/Classes/Interactivity/Events/Events.js +6 -25
  251. package/umd/Options/Classes/Interactivity/Interactivity.js +1 -8
  252. package/umd/Options/Classes/Interactivity/Modes/Modes.js +11 -8
  253. package/umd/Options/Classes/ManualParticle.js +5 -5
  254. package/umd/Options/Classes/Options.js +18 -38
  255. package/umd/Options/Classes/OptionsColor.js +4 -3
  256. package/umd/Options/Classes/Particles/Collisions/Collisions.js +6 -1
  257. package/umd/Options/Classes/Particles/Move/Move.js +12 -42
  258. package/umd/Options/Classes/Particles/Move/MoveAttract.js +9 -20
  259. package/umd/Options/Classes/Particles/Move/MoveTrail.js +2 -8
  260. package/umd/Options/Classes/Particles/Move/OutModes.js +4 -5
  261. package/umd/Options/Classes/Particles/Move/Spin.js +3 -1
  262. package/umd/Options/Classes/Particles/Number/ParticlesDensity.js +2 -21
  263. package/umd/Options/Classes/Particles/Number/ParticlesNumber.js +2 -9
  264. package/umd/Options/Classes/Particles/Opacity/Opacity.js +10 -6
  265. package/umd/Options/Classes/Particles/Opacity/OpacityAnimation.js +0 -9
  266. package/umd/Options/Classes/Particles/ParticlesOptions.js +6 -11
  267. package/umd/Options/Classes/Particles/Shape/Shape.js +9 -2
  268. package/umd/Options/Classes/Particles/Size/Size.js +12 -8
  269. package/umd/Options/Classes/Particles/Size/SizeAnimation.js +0 -9
  270. package/umd/Options/Classes/ValueWithRandom.js +5 -18
  271. package/umd/Utils/CanvasUtils.js +21 -58
  272. package/umd/Utils/ColorUtils.js +16 -18
  273. package/umd/Utils/EventDispatcher.js +7 -6
  274. package/umd/Utils/HslColorManager.js +2 -4
  275. package/umd/Utils/NumberUtils.js +42 -46
  276. package/umd/Utils/RgbColorManager.js +2 -4
  277. package/umd/Utils/Utils.js +163 -63
  278. package/umd/bundle.js +5 -97
  279. package/umd/export-types.js +123 -0
  280. package/umd/exports.js +115 -0
  281. package/umd/index.js +9 -199
  282. package/umd/init.js +26 -0
  283. package/browser/Core/Utils/FrameManager.js +0 -42
  284. package/browser/Core/Utils/Plugins.js +0 -112
  285. package/browser/Options/Interfaces/Particles/Shape/IShapeValues.js +0 -1
  286. package/browser/Options/Interfaces/Particles/Shape/IStarShape.js +0 -1
  287. package/browser/engine.js +0 -175
  288. package/cjs/Core/Utils/FrameManager.js +0 -46
  289. package/cjs/Core/Utils/Plugins.js +0 -116
  290. package/cjs/Options/Interfaces/Particles/Shape/ICharacterShape.js +0 -2
  291. package/cjs/Options/Interfaces/Particles/Shape/IImageShape.js +0 -2
  292. package/cjs/Options/Interfaces/Particles/Shape/IPolygonShape.js +0 -2
  293. package/cjs/Options/Interfaces/Particles/Shape/IShapeValues.js +0 -17
  294. package/cjs/Options/Interfaces/Particles/Shape/IStarShape.js +0 -2
  295. package/cjs/engine.js +0 -179
  296. package/esm/Core/Interfaces/IParticleOverride.js +0 -1
  297. package/esm/Core/Interfaces/IParticlesMover.js +0 -1
  298. package/esm/Core/Utils/FrameManager.js +0 -42
  299. package/esm/Core/Utils/Plugins.js +0 -112
  300. package/esm/Enums/Modes/SizeMode.js +0 -1
  301. package/esm/Options/Interfaces/Particles/Shape/ICharacterShape.js +0 -1
  302. package/esm/Options/Interfaces/Particles/Shape/IImageShape.js +0 -1
  303. package/esm/Options/Interfaces/Particles/Shape/IPolygonShape.js +0 -1
  304. package/esm/Options/Interfaces/Particles/Shape/IShapeValues.js +0 -1
  305. package/esm/Options/Interfaces/Particles/Shape/IStarShape.js +0 -1
  306. package/esm/engine.js +0 -175
  307. package/types/Core/Interfaces/IParticleOverride.d.ts +0 -6
  308. package/types/Core/Interfaces/IParticlesMover.d.ts +0 -7
  309. package/types/Core/Utils/FrameManager.d.ts +0 -6
  310. package/types/Core/Utils/Plugins.d.ts +0 -51
  311. package/types/Options/Interfaces/Particles/Shape/ICharacterShape.d.ts +0 -8
  312. package/types/Options/Interfaces/Particles/Shape/IImageShape.d.ts +0 -8
  313. package/types/Options/Interfaces/Particles/Shape/IPolygonShape.d.ts +0 -5
  314. package/types/Options/Interfaces/Particles/Shape/IShapeValues.d.ts +0 -1
  315. package/types/Options/Interfaces/Particles/Shape/IStarShape.d.ts +0 -6
  316. package/types/engine.d.ts +0 -39
  317. package/umd/Core/Utils/FrameManager.js +0 -56
  318. package/umd/Core/Utils/Plugins.js +0 -126
  319. package/umd/Options/Interfaces/Particles/Shape/ICharacterShape.js +0 -12
  320. package/umd/Options/Interfaces/Particles/Shape/IImageShape.js +0 -12
  321. package/umd/Options/Interfaces/Particles/Shape/IPolygonShape.js +0 -12
  322. package/umd/Options/Interfaces/Particles/Shape/IShapeValues.js +0 -27
  323. package/umd/Options/Interfaces/Particles/Shape/IStarShape.js +0 -12
  324. package/umd/engine.js +0 -189
  325. /package/browser/{Core/Interfaces/IParticleOverride.js → Enums/Modes/AnimationMode.js} +0 -0
  326. /package/browser/{Core/Interfaces/IParticlesMover.js → Enums/Modes/PixelMode.js} +0 -0
  327. /package/browser/{Enums/Modes/SizeMode.js → Types/ExportResult.js} +0 -0
  328. /package/cjs/{Core/Interfaces/IParticleOverride.js → Enums/Modes/AnimationMode.js} +0 -0
  329. /package/cjs/{Core/Interfaces/IParticlesMover.js → Enums/Modes/PixelMode.js} +0 -0
  330. /package/cjs/{Enums/Modes/SizeMode.js → Types/ExportResult.js} +0 -0
  331. /package/{browser/Options/Interfaces/Particles/Shape/ICharacterShape.js → esm/Enums/Modes/AnimationMode.js} +0 -0
  332. /package/{browser/Options/Interfaces/Particles/Shape/IImageShape.js → esm/Enums/Modes/PixelMode.js} +0 -0
  333. /package/{browser/Options/Interfaces/Particles/Shape/IPolygonShape.js → esm/Types/ExportResult.js} +0 -0
  334. /package/umd/{Core/Interfaces/IParticleOverride.js → Enums/Modes/AnimationMode.js} +0 -0
  335. /package/umd/{Core/Interfaces/IParticlesMover.js → Enums/Modes/PixelMode.js} +0 -0
  336. /package/umd/{Enums/Modes/SizeMode.js → Types/ExportResult.js} +0 -0
@@ -1,45 +1,78 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Container = void 0;
4
- const Utils_1 = require("../Utils/Utils");
5
4
  const Canvas_1 = require("./Canvas");
6
5
  const EventListeners_1 = require("./Utils/EventListeners");
7
- const FrameManager_1 = require("./Utils/FrameManager");
8
6
  const Options_1 = require("../Options/Classes/Options");
9
7
  const Particles_1 = require("./Particles");
10
8
  const Retina_1 = require("./Retina");
9
+ const Constants_1 = require("./Utils/Constants");
10
+ const Utils_1 = require("../Utils/Utils");
11
11
  const NumberUtils_1 = require("../Utils/NumberUtils");
12
12
  const OptionsUtils_1 = require("../Utils/OptionsUtils");
13
13
  function guardCheck(container) {
14
14
  return container && !container.destroyed;
15
15
  }
16
+ function initDelta(value, fpsLimit = 60, smooth = false) {
17
+ return {
18
+ value,
19
+ factor: smooth ? 60 / fpsLimit : (60 * value) / 1000,
20
+ };
21
+ }
16
22
  function loadContainerOptions(engine, container, ...sourceOptionsArr) {
17
23
  const options = new Options_1.Options(engine, container);
18
24
  (0, OptionsUtils_1.loadOptions)(options, ...sourceOptionsArr);
19
25
  return options;
20
26
  }
21
- const defaultPathGeneratorKey = "default", defaultPathGenerator = {
22
- generate: (p) => {
23
- const v = p.velocity.copy();
24
- v.angle += (v.length * Math.PI) / 180;
25
- return v;
26
- },
27
- init: () => {
28
- },
29
- update: () => {
30
- },
31
- reset: () => {
32
- },
33
- };
34
27
  class Container {
35
28
  constructor(engine, id, sourceOptions) {
36
29
  this.id = id;
30
+ this._intersectionManager = (entries) => {
31
+ if (!guardCheck(this) || !this.actualOptions.pauseOnOutsideViewport) {
32
+ return;
33
+ }
34
+ for (const entry of entries) {
35
+ if (entry.target !== this.interactivity.element) {
36
+ continue;
37
+ }
38
+ (entry.isIntersecting ? this.play : this.pause)();
39
+ }
40
+ };
41
+ this._nextFrame = async (timestamp) => {
42
+ try {
43
+ if (!this.smooth &&
44
+ this.lastFrameTime !== undefined &&
45
+ timestamp < this.lastFrameTime + 1000 / this.fpsLimit) {
46
+ this.draw(false);
47
+ return;
48
+ }
49
+ this.lastFrameTime ??= timestamp;
50
+ const delta = initDelta(timestamp - this.lastFrameTime, this.fpsLimit, this.smooth);
51
+ this.addLifeTime(delta.value);
52
+ this.lastFrameTime = timestamp;
53
+ if (delta.value > 1000) {
54
+ this.draw(false);
55
+ return;
56
+ }
57
+ await this.particles.draw(delta);
58
+ if (!this.alive()) {
59
+ this.destroy();
60
+ return;
61
+ }
62
+ if (this.getAnimationStatus()) {
63
+ this.draw(false);
64
+ }
65
+ }
66
+ catch (e) {
67
+ (0, Utils_1.getLogger)().error(`${Constants_1.errorPrefix} in animation loop`, e);
68
+ }
69
+ };
37
70
  this._engine = engine;
38
71
  this.fpsLimit = 120;
39
72
  this.smooth = false;
40
73
  this._delay = 0;
41
- this.duration = 0;
42
- this.lifeTime = 0;
74
+ this._duration = 0;
75
+ this._lifeTime = 0;
43
76
  this._firstStart = true;
44
77
  this.started = false;
45
78
  this.destroyed = false;
@@ -52,7 +85,6 @@ class Container {
52
85
  this.retina = new Retina_1.Retina(this);
53
86
  this.canvas = new Canvas_1.Canvas(this);
54
87
  this.particles = new Particles_1.Particles(this._engine, this);
55
- this.frameManager = new FrameManager_1.FrameManager(this);
56
88
  this.pathGenerators = new Map();
57
89
  this.interactivity = {
58
90
  mouse: {
@@ -153,13 +185,19 @@ class Container {
153
185
  el.addEventListener("touchend", touchEndHandler);
154
186
  el.addEventListener("touchcancel", touchCancelHandler);
155
187
  }
188
+ addLifeTime(value) {
189
+ this._lifeTime += value;
190
+ }
156
191
  addPath(key, generator, override = false) {
157
192
  if (!guardCheck(this) || (!override && this.pathGenerators.has(key))) {
158
193
  return false;
159
194
  }
160
- this.pathGenerators.set(key, generator !== null && generator !== void 0 ? generator : defaultPathGenerator);
195
+ this.pathGenerators.set(key, generator);
161
196
  return true;
162
197
  }
198
+ alive() {
199
+ return !this._duration || this._lifeTime <= this._duration;
200
+ }
163
201
  destroy() {
164
202
  if (!guardCheck(this)) {
165
203
  return;
@@ -168,14 +206,12 @@ class Container {
168
206
  this.particles.destroy();
169
207
  this.canvas.destroy();
170
208
  for (const [, drawer] of this.drawers) {
171
- if (drawer.destroy) {
172
- drawer.destroy(this);
173
- }
209
+ drawer.destroy && drawer.destroy(this);
174
210
  }
175
211
  for (const key of this.drawers.keys()) {
176
212
  this.drawers.delete(key);
177
213
  }
178
- this._engine.plugins.destroy(this);
214
+ this._engine.clearPlugins(this);
179
215
  this.destroyed = true;
180
216
  const mainArr = this._engine.dom(), idx = mainArr.findIndex((t) => t === this);
181
217
  if (idx >= 0) {
@@ -188,30 +224,26 @@ class Container {
188
224
  return;
189
225
  }
190
226
  let refreshTime = force;
191
- this._drawAnimationFrame = (0, Utils_1.animate)()(async (timestamp) => {
227
+ this._drawAnimationFrame = requestAnimationFrame(async (timestamp) => {
192
228
  if (refreshTime) {
193
229
  this.lastFrameTime = undefined;
194
230
  refreshTime = false;
195
231
  }
196
- await this.frameManager.nextFrame(timestamp);
232
+ await this._nextFrame(timestamp);
197
233
  });
198
234
  }
199
- exportConfiguration() {
200
- return JSON.stringify(this.actualOptions, (key, value) => {
201
- if (key === "_engine" || key === "_container") {
202
- return;
235
+ async export(type, options = {}) {
236
+ for (const [, plugin] of this.plugins) {
237
+ if (!plugin.export) {
238
+ continue;
203
239
  }
204
- return value;
205
- }, 2);
206
- }
207
- exportImage(callback, type, quality) {
208
- const element = this.canvas.element;
209
- if (element) {
210
- element.toBlob(callback, type !== null && type !== void 0 ? type : "image/png", quality);
240
+ const res = await plugin.export(type, options);
241
+ if (!res.supported) {
242
+ continue;
243
+ }
244
+ return res.blob;
211
245
  }
212
- }
213
- exportImg(callback) {
214
- this.exportImage(callback);
246
+ (0, Utils_1.getLogger)().error(`${Constants_1.errorPrefix} - Export plugin with type ${type} not found`);
215
247
  }
216
248
  getAnimationStatus() {
217
249
  return !this._paused && !this.pageHidden && guardCheck(this);
@@ -222,53 +254,48 @@ class Container {
222
254
  }
223
255
  this.particles.handleClickMode(mode);
224
256
  for (const [, plugin] of this.plugins) {
225
- if (plugin.handleClickMode) {
226
- plugin.handleClickMode(mode);
227
- }
257
+ plugin.handleClickMode && plugin.handleClickMode(mode);
228
258
  }
229
259
  }
230
260
  async init() {
231
261
  if (!guardCheck(this)) {
232
262
  return;
233
263
  }
234
- const shapes = this._engine.plugins.getSupportedShapes();
264
+ const shapes = this._engine.getSupportedShapes();
235
265
  for (const type of shapes) {
236
- const drawer = this._engine.plugins.getShapeDrawer(type);
266
+ const drawer = this._engine.getShapeDrawer(type);
237
267
  if (drawer) {
238
268
  this.drawers.set(type, drawer);
239
269
  }
240
270
  }
241
271
  this._options = loadContainerOptions(this._engine, this, this._initialSourceOptions, this.sourceOptions);
242
272
  this.actualOptions = loadContainerOptions(this._engine, this, this._options);
243
- const availablePlugins = this._engine.plugins.getAvailablePlugins(this);
273
+ const availablePlugins = this._engine.getAvailablePlugins(this);
244
274
  for (const [id, plugin] of availablePlugins) {
245
275
  this.plugins.set(id, plugin);
246
276
  }
247
277
  this.retina.init();
248
278
  await this.canvas.init();
279
+ this.updateActualOptions();
280
+ this.canvas.initBackground();
281
+ this.canvas.resize();
249
282
  this.zLayers = this.actualOptions.zLayers;
250
- this.duration = (0, NumberUtils_1.getRangeValue)(this.actualOptions.duration) * 1000;
283
+ this._duration = (0, NumberUtils_1.getRangeValue)(this.actualOptions.duration) * 1000;
251
284
  this._delay = (0, NumberUtils_1.getRangeValue)(this.actualOptions.delay) * 1000;
252
- this.lifeTime = 0;
285
+ this._lifeTime = 0;
253
286
  this.fpsLimit = this.actualOptions.fpsLimit > 0 ? this.actualOptions.fpsLimit : 120;
254
287
  this.smooth = this.actualOptions.smooth;
255
288
  for (const [, drawer] of this.drawers) {
256
- if (drawer.init) {
257
- await drawer.init(this);
258
- }
289
+ drawer.init && (await drawer.init(this));
259
290
  }
260
291
  for (const [, plugin] of this.plugins) {
261
- if (plugin.init) {
262
- await plugin.init();
263
- }
292
+ plugin.init && (await plugin.init());
264
293
  }
265
294
  this._engine.dispatchEvent("containerInit", { container: this });
266
295
  this.particles.init();
267
296
  this.particles.setDensity();
268
297
  for (const [, plugin] of this.plugins) {
269
- if (plugin.particlesSetup) {
270
- plugin.particlesSetup();
271
- }
298
+ plugin.particlesSetup && plugin.particlesSetup();
272
299
  }
273
300
  this._engine.dispatchEvent("particlesSetup", { container: this });
274
301
  }
@@ -284,16 +311,14 @@ class Container {
284
311
  return;
285
312
  }
286
313
  if (this._drawAnimationFrame !== undefined) {
287
- (0, Utils_1.cancelAnimation)()(this._drawAnimationFrame);
314
+ cancelAnimationFrame(this._drawAnimationFrame);
288
315
  delete this._drawAnimationFrame;
289
316
  }
290
317
  if (this._paused) {
291
318
  return;
292
319
  }
293
320
  for (const [, plugin] of this.plugins) {
294
- if (plugin.pause) {
295
- plugin.pause();
296
- }
321
+ plugin.pause && plugin.pause();
297
322
  }
298
323
  if (!this.pageHidden) {
299
324
  this._paused = true;
@@ -333,37 +358,11 @@ class Container {
333
358
  if (!guardCheck(this)) {
334
359
  return;
335
360
  }
361
+ this._initialSourceOptions = undefined;
336
362
  this._options = loadContainerOptions(this._engine, this);
363
+ this.actualOptions = loadContainerOptions(this._engine, this, this._options);
337
364
  return this.refresh();
338
365
  }
339
- setNoise(noiseOrGenerator, init, update) {
340
- if (!guardCheck(this)) {
341
- return;
342
- }
343
- this.setPath(noiseOrGenerator, init, update);
344
- }
345
- setPath(pathOrGenerator, init, update) {
346
- if (!pathOrGenerator || !guardCheck(this)) {
347
- return;
348
- }
349
- const pathGenerator = Object.assign({}, defaultPathGenerator);
350
- if (typeof pathOrGenerator === "function") {
351
- pathGenerator.generate = pathOrGenerator;
352
- if (init) {
353
- pathGenerator.init = init;
354
- }
355
- if (update) {
356
- pathGenerator.update = update;
357
- }
358
- }
359
- else {
360
- const oldGenerator = pathGenerator;
361
- pathGenerator.generate = pathOrGenerator.generate || oldGenerator.generate;
362
- pathGenerator.init = pathOrGenerator.init || oldGenerator.init;
363
- pathGenerator.update = pathOrGenerator.update || oldGenerator.update;
364
- }
365
- this.addPath(defaultPathGeneratorKey, pathGenerator, true);
366
- }
367
366
  async start() {
368
367
  if (!guardCheck(this) || this.started) {
369
368
  return;
@@ -377,9 +376,7 @@ class Container {
377
376
  this._intersectionObserver.observe(this.interactivity.element);
378
377
  }
379
378
  for (const [, plugin] of this.plugins) {
380
- if (plugin.start) {
381
- await plugin.start();
382
- }
379
+ plugin.start && (await plugin.start());
383
380
  }
384
381
  this._engine.dispatchEvent("containerStarted", { container: this });
385
382
  this.play();
@@ -400,14 +397,12 @@ class Container {
400
397
  this._eventListeners.removeListeners();
401
398
  this.pause();
402
399
  this.particles.clear();
403
- this.canvas.clear();
400
+ this.canvas.stop();
404
401
  if (this.interactivity.element instanceof HTMLElement && this._intersectionObserver) {
405
402
  this._intersectionObserver.unobserve(this.interactivity.element);
406
403
  }
407
404
  for (const [, plugin] of this.plugins) {
408
- if (plugin.stop) {
409
- plugin.stop();
410
- }
405
+ plugin.stop && plugin.stop();
411
406
  }
412
407
  for (const key of this.plugins.keys()) {
413
408
  this.plugins.delete(key);
@@ -425,16 +420,5 @@ class Container {
425
420
  this.responsiveMaxWidth = newMaxWidth;
426
421
  return true;
427
422
  }
428
- _intersectionManager(entries) {
429
- if (!guardCheck(this) || !this.actualOptions.pauseOnOutsideViewport) {
430
- return;
431
- }
432
- for (const entry of entries) {
433
- if (entry.target !== this.interactivity.element) {
434
- continue;
435
- }
436
- (entry.isIntersecting ? this.play : this.pause)();
437
- }
438
- }
439
423
  }
440
424
  exports.Container = Container;
@@ -0,0 +1,275 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Engine = void 0;
4
+ const Constants_1 = require("./Utils/Constants");
5
+ const Utils_1 = require("../Utils/Utils");
6
+ const Container_1 = require("./Container");
7
+ const EventDispatcher_1 = require("../Utils/EventDispatcher");
8
+ const NumberUtils_1 = require("../Utils/NumberUtils");
9
+ function getItemsFromInitializer(container, map, initializers, force = false) {
10
+ let res = map.get(container);
11
+ if (!res || force) {
12
+ res = [...initializers.values()].map((t) => t(container));
13
+ map.set(container, res);
14
+ }
15
+ return res;
16
+ }
17
+ async function getDataFromUrl(data) {
18
+ const url = (0, Utils_1.itemFromSingleOrMultiple)(data.url, data.index);
19
+ if (!url) {
20
+ return data.fallback;
21
+ }
22
+ const response = await fetch(url);
23
+ if (response.ok) {
24
+ return response.json();
25
+ }
26
+ (0, Utils_1.getLogger)().error(`${Constants_1.errorPrefix} ${response.status} while retrieving config file`);
27
+ return data.fallback;
28
+ }
29
+ class Engine {
30
+ constructor() {
31
+ this._configs = new Map();
32
+ this._domArray = [];
33
+ this._eventDispatcher = new EventDispatcher_1.EventDispatcher();
34
+ this._initialized = false;
35
+ this.plugins = [];
36
+ this._initializers = {
37
+ interactors: new Map(),
38
+ movers: new Map(),
39
+ updaters: new Map(),
40
+ };
41
+ this.interactors = new Map();
42
+ this.movers = new Map();
43
+ this.updaters = new Map();
44
+ this.presets = new Map();
45
+ this.drawers = new Map();
46
+ this.pathGenerators = new Map();
47
+ }
48
+ get configs() {
49
+ const res = {};
50
+ for (const [name, config] of this._configs) {
51
+ res[name] = config;
52
+ }
53
+ return res;
54
+ }
55
+ get version() {
56
+ return "3.0.0-beta.0";
57
+ }
58
+ addConfig(nameOrConfig, config) {
59
+ if ((0, Utils_1.isString)(nameOrConfig)) {
60
+ if (config) {
61
+ config.name = nameOrConfig;
62
+ this._configs.set(nameOrConfig, config);
63
+ }
64
+ }
65
+ else {
66
+ this._configs.set(nameOrConfig.name ?? "default", nameOrConfig);
67
+ }
68
+ }
69
+ addEventListener(type, listener) {
70
+ this._eventDispatcher.addEventListener(type, listener);
71
+ }
72
+ async addInteractor(name, interactorInitializer, refresh = true) {
73
+ this._initializers.interactors.set(name, interactorInitializer);
74
+ await this.refresh(refresh);
75
+ }
76
+ async addMover(name, moverInitializer, refresh = true) {
77
+ this._initializers.movers.set(name, moverInitializer);
78
+ await this.refresh(refresh);
79
+ }
80
+ async addParticleUpdater(name, updaterInitializer, refresh = true) {
81
+ this._initializers.updaters.set(name, updaterInitializer);
82
+ await this.refresh(refresh);
83
+ }
84
+ async addPathGenerator(name, generator, refresh = true) {
85
+ !this.getPathGenerator(name) && this.pathGenerators.set(name, generator);
86
+ await this.refresh(refresh);
87
+ }
88
+ async addPlugin(plugin, refresh = true) {
89
+ !this.getPlugin(plugin.id) && this.plugins.push(plugin);
90
+ await this.refresh(refresh);
91
+ }
92
+ async addPreset(preset, options, override = false, refresh = true) {
93
+ (override || !this.getPreset(preset)) && this.presets.set(preset, options);
94
+ await this.refresh(refresh);
95
+ }
96
+ async addShape(shape, drawer, initOrRefresh, afterEffectOrRefresh, destroyOrRefresh, refresh = true) {
97
+ let customDrawer;
98
+ let realRefresh = refresh, realInit, realAfterEffect, realDestroy;
99
+ if ((0, Utils_1.isBoolean)(initOrRefresh)) {
100
+ realRefresh = initOrRefresh;
101
+ realInit = undefined;
102
+ }
103
+ else {
104
+ realInit = initOrRefresh;
105
+ }
106
+ if ((0, Utils_1.isBoolean)(afterEffectOrRefresh)) {
107
+ realRefresh = afterEffectOrRefresh;
108
+ realAfterEffect = undefined;
109
+ }
110
+ else {
111
+ realAfterEffect = afterEffectOrRefresh;
112
+ }
113
+ if ((0, Utils_1.isBoolean)(destroyOrRefresh)) {
114
+ realRefresh = destroyOrRefresh;
115
+ realDestroy = undefined;
116
+ }
117
+ else {
118
+ realDestroy = destroyOrRefresh;
119
+ }
120
+ if ((0, Utils_1.isFunction)(drawer)) {
121
+ customDrawer = {
122
+ afterEffect: realAfterEffect,
123
+ destroy: realDestroy,
124
+ draw: drawer,
125
+ init: realInit,
126
+ };
127
+ }
128
+ else {
129
+ customDrawer = drawer;
130
+ }
131
+ (0, Utils_1.executeOnSingleOrMultiple)(shape, (type) => {
132
+ !this.getShapeDrawer(type) && this.drawers.set(type, customDrawer);
133
+ });
134
+ await this.refresh(realRefresh);
135
+ }
136
+ clearPlugins(container) {
137
+ this.updaters.delete(container);
138
+ this.movers.delete(container);
139
+ this.interactors.delete(container);
140
+ }
141
+ dispatchEvent(type, args) {
142
+ this._eventDispatcher.dispatchEvent(type, args);
143
+ }
144
+ dom() {
145
+ return this._domArray;
146
+ }
147
+ domItem(index) {
148
+ const dom = this.dom(), item = dom[index];
149
+ if (!item || item.destroyed) {
150
+ dom.splice(index, 1);
151
+ return;
152
+ }
153
+ return item;
154
+ }
155
+ getAvailablePlugins(container) {
156
+ const res = new Map();
157
+ for (const plugin of this.plugins) {
158
+ plugin.needsPlugin(container.actualOptions) && res.set(plugin.id, plugin.getPlugin(container));
159
+ }
160
+ return res;
161
+ }
162
+ getInteractors(container, force = false) {
163
+ return getItemsFromInitializer(container, this.interactors, this._initializers.interactors, force);
164
+ }
165
+ getMovers(container, force = false) {
166
+ return getItemsFromInitializer(container, this.movers, this._initializers.movers, force);
167
+ }
168
+ getPathGenerator(type) {
169
+ return this.pathGenerators.get(type);
170
+ }
171
+ getPlugin(plugin) {
172
+ return this.plugins.find((t) => t.id === plugin);
173
+ }
174
+ getPreset(preset) {
175
+ return this.presets.get(preset);
176
+ }
177
+ getShapeDrawer(type) {
178
+ return this.drawers.get(type);
179
+ }
180
+ getSupportedShapes() {
181
+ return this.drawers.keys();
182
+ }
183
+ getUpdaters(container, force = false) {
184
+ return getItemsFromInitializer(container, this.updaters, this._initializers.updaters, force);
185
+ }
186
+ init() {
187
+ if (this._initialized) {
188
+ return;
189
+ }
190
+ this._initialized = true;
191
+ }
192
+ async load(params) {
193
+ const id = params.id ?? `tsparticles${Math.floor((0, NumberUtils_1.getRandom)() * 10000)}`, { index, url } = params, options = url ? await getDataFromUrl({ fallback: params.options, url, index }) : params.options;
194
+ let domContainer = params.element ?? document.getElementById(id);
195
+ if (!domContainer) {
196
+ domContainer = document.createElement("div");
197
+ domContainer.id = id;
198
+ document.body.append(domContainer);
199
+ }
200
+ const currentOptions = (0, Utils_1.itemFromSingleOrMultiple)(options, index), dom = this.dom(), oldIndex = dom.findIndex((v) => v.id === id);
201
+ if (oldIndex >= 0) {
202
+ const old = this.domItem(oldIndex);
203
+ if (old && !old.destroyed) {
204
+ old.destroy();
205
+ dom.splice(oldIndex, 1);
206
+ }
207
+ }
208
+ let canvasEl;
209
+ if (domContainer.tagName.toLowerCase() === "canvas") {
210
+ canvasEl = domContainer;
211
+ canvasEl.dataset[Constants_1.generatedAttribute] = "false";
212
+ }
213
+ else {
214
+ const existingCanvases = domContainer.getElementsByTagName("canvas");
215
+ if (existingCanvases.length) {
216
+ canvasEl = existingCanvases[0];
217
+ canvasEl.dataset[Constants_1.generatedAttribute] = "false";
218
+ }
219
+ else {
220
+ canvasEl = document.createElement("canvas");
221
+ canvasEl.dataset[Constants_1.generatedAttribute] = "true";
222
+ domContainer.appendChild(canvasEl);
223
+ }
224
+ }
225
+ if (!canvasEl.style.width) {
226
+ canvasEl.style.width = "100%";
227
+ }
228
+ if (!canvasEl.style.height) {
229
+ canvasEl.style.height = "100%";
230
+ }
231
+ const newItem = new Container_1.Container(this, id, currentOptions);
232
+ if (oldIndex >= 0) {
233
+ dom.splice(oldIndex, 0, newItem);
234
+ }
235
+ else {
236
+ dom.push(newItem);
237
+ }
238
+ newItem.canvas.loadCanvas(canvasEl);
239
+ await newItem.start();
240
+ return newItem;
241
+ }
242
+ loadOptions(options, sourceOptions) {
243
+ for (const plugin of this.plugins) {
244
+ plugin.loadOptions(options, sourceOptions);
245
+ }
246
+ }
247
+ loadParticlesOptions(container, options, ...sourceOptions) {
248
+ const updaters = this.updaters.get(container);
249
+ if (!updaters) {
250
+ return;
251
+ }
252
+ for (const updater of updaters) {
253
+ updater.loadOptions && updater.loadOptions(options, ...sourceOptions);
254
+ }
255
+ }
256
+ async refresh(refresh = true) {
257
+ if (!refresh) {
258
+ return;
259
+ }
260
+ this.dom().forEach((t) => t.refresh());
261
+ }
262
+ removeEventListener(type, listener) {
263
+ this._eventDispatcher.removeEventListener(type, listener);
264
+ }
265
+ setOnClickHandler(callback) {
266
+ const dom = this.dom();
267
+ if (!dom.length) {
268
+ throw new Error(`${Constants_1.errorPrefix} can only set click handlers after calling tsParticles.load()`);
269
+ }
270
+ for (const domItem of dom) {
271
+ domItem.addClickHandler(callback);
272
+ }
273
+ }
274
+ }
275
+ exports.Engine = Engine;