@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
@@ -4,51 +4,84 @@
4
4
  if (v !== undefined) module.exports = v;
5
5
  }
6
6
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "../Utils/Utils", "./Canvas", "./Utils/EventListeners", "./Utils/FrameManager", "../Options/Classes/Options", "./Particles", "./Retina", "../Utils/NumberUtils", "../Utils/OptionsUtils"], factory);
7
+ define(["require", "exports", "./Canvas", "./Utils/EventListeners", "../Options/Classes/Options", "./Particles", "./Retina", "./Utils/Constants", "../Utils/Utils", "../Utils/NumberUtils", "../Utils/OptionsUtils"], factory);
8
8
  }
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.Container = void 0;
13
- const Utils_1 = require("../Utils/Utils");
14
13
  const Canvas_1 = require("./Canvas");
15
14
  const EventListeners_1 = require("./Utils/EventListeners");
16
- const FrameManager_1 = require("./Utils/FrameManager");
17
15
  const Options_1 = require("../Options/Classes/Options");
18
16
  const Particles_1 = require("./Particles");
19
17
  const Retina_1 = require("./Retina");
18
+ const Constants_1 = require("./Utils/Constants");
19
+ const Utils_1 = require("../Utils/Utils");
20
20
  const NumberUtils_1 = require("../Utils/NumberUtils");
21
21
  const OptionsUtils_1 = require("../Utils/OptionsUtils");
22
22
  function guardCheck(container) {
23
23
  return container && !container.destroyed;
24
24
  }
25
+ function initDelta(value, fpsLimit = 60, smooth = false) {
26
+ return {
27
+ value,
28
+ factor: smooth ? 60 / fpsLimit : (60 * value) / 1000,
29
+ };
30
+ }
25
31
  function loadContainerOptions(engine, container, ...sourceOptionsArr) {
26
32
  const options = new Options_1.Options(engine, container);
27
33
  (0, OptionsUtils_1.loadOptions)(options, ...sourceOptionsArr);
28
34
  return options;
29
35
  }
30
- const defaultPathGeneratorKey = "default", defaultPathGenerator = {
31
- generate: (p) => {
32
- const v = p.velocity.copy();
33
- v.angle += (v.length * Math.PI) / 180;
34
- return v;
35
- },
36
- init: () => {
37
- },
38
- update: () => {
39
- },
40
- reset: () => {
41
- },
42
- };
43
36
  class Container {
44
37
  constructor(engine, id, sourceOptions) {
45
38
  this.id = id;
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
+ (entry.isIntersecting ? this.play : this.pause)();
48
+ }
49
+ };
50
+ this._nextFrame = async (timestamp) => {
51
+ try {
52
+ if (!this.smooth &&
53
+ this.lastFrameTime !== undefined &&
54
+ timestamp < this.lastFrameTime + 1000 / this.fpsLimit) {
55
+ this.draw(false);
56
+ return;
57
+ }
58
+ this.lastFrameTime ??= timestamp;
59
+ const delta = initDelta(timestamp - this.lastFrameTime, this.fpsLimit, this.smooth);
60
+ this.addLifeTime(delta.value);
61
+ this.lastFrameTime = timestamp;
62
+ if (delta.value > 1000) {
63
+ this.draw(false);
64
+ return;
65
+ }
66
+ await this.particles.draw(delta);
67
+ if (!this.alive()) {
68
+ this.destroy();
69
+ return;
70
+ }
71
+ if (this.getAnimationStatus()) {
72
+ this.draw(false);
73
+ }
74
+ }
75
+ catch (e) {
76
+ (0, Utils_1.getLogger)().error(`${Constants_1.errorPrefix} in animation loop`, e);
77
+ }
78
+ };
46
79
  this._engine = engine;
47
80
  this.fpsLimit = 120;
48
81
  this.smooth = false;
49
82
  this._delay = 0;
50
- this.duration = 0;
51
- this.lifeTime = 0;
83
+ this._duration = 0;
84
+ this._lifeTime = 0;
52
85
  this._firstStart = true;
53
86
  this.started = false;
54
87
  this.destroyed = false;
@@ -61,7 +94,6 @@
61
94
  this.retina = new Retina_1.Retina(this);
62
95
  this.canvas = new Canvas_1.Canvas(this);
63
96
  this.particles = new Particles_1.Particles(this._engine, this);
64
- this.frameManager = new FrameManager_1.FrameManager(this);
65
97
  this.pathGenerators = new Map();
66
98
  this.interactivity = {
67
99
  mouse: {
@@ -162,13 +194,19 @@
162
194
  el.addEventListener("touchend", touchEndHandler);
163
195
  el.addEventListener("touchcancel", touchCancelHandler);
164
196
  }
197
+ addLifeTime(value) {
198
+ this._lifeTime += value;
199
+ }
165
200
  addPath(key, generator, override = false) {
166
201
  if (!guardCheck(this) || (!override && this.pathGenerators.has(key))) {
167
202
  return false;
168
203
  }
169
- this.pathGenerators.set(key, generator !== null && generator !== void 0 ? generator : defaultPathGenerator);
204
+ this.pathGenerators.set(key, generator);
170
205
  return true;
171
206
  }
207
+ alive() {
208
+ return !this._duration || this._lifeTime <= this._duration;
209
+ }
172
210
  destroy() {
173
211
  if (!guardCheck(this)) {
174
212
  return;
@@ -177,14 +215,12 @@
177
215
  this.particles.destroy();
178
216
  this.canvas.destroy();
179
217
  for (const [, drawer] of this.drawers) {
180
- if (drawer.destroy) {
181
- drawer.destroy(this);
182
- }
218
+ drawer.destroy && drawer.destroy(this);
183
219
  }
184
220
  for (const key of this.drawers.keys()) {
185
221
  this.drawers.delete(key);
186
222
  }
187
- this._engine.plugins.destroy(this);
223
+ this._engine.clearPlugins(this);
188
224
  this.destroyed = true;
189
225
  const mainArr = this._engine.dom(), idx = mainArr.findIndex((t) => t === this);
190
226
  if (idx >= 0) {
@@ -197,30 +233,26 @@
197
233
  return;
198
234
  }
199
235
  let refreshTime = force;
200
- this._drawAnimationFrame = (0, Utils_1.animate)()(async (timestamp) => {
236
+ this._drawAnimationFrame = requestAnimationFrame(async (timestamp) => {
201
237
  if (refreshTime) {
202
238
  this.lastFrameTime = undefined;
203
239
  refreshTime = false;
204
240
  }
205
- await this.frameManager.nextFrame(timestamp);
241
+ await this._nextFrame(timestamp);
206
242
  });
207
243
  }
208
- exportConfiguration() {
209
- return JSON.stringify(this.actualOptions, (key, value) => {
210
- if (key === "_engine" || key === "_container") {
211
- return;
244
+ async export(type, options = {}) {
245
+ for (const [, plugin] of this.plugins) {
246
+ if (!plugin.export) {
247
+ continue;
212
248
  }
213
- return value;
214
- }, 2);
215
- }
216
- exportImage(callback, type, quality) {
217
- const element = this.canvas.element;
218
- if (element) {
219
- element.toBlob(callback, type !== null && type !== void 0 ? type : "image/png", quality);
249
+ const res = await plugin.export(type, options);
250
+ if (!res.supported) {
251
+ continue;
252
+ }
253
+ return res.blob;
220
254
  }
221
- }
222
- exportImg(callback) {
223
- this.exportImage(callback);
255
+ (0, Utils_1.getLogger)().error(`${Constants_1.errorPrefix} - Export plugin with type ${type} not found`);
224
256
  }
225
257
  getAnimationStatus() {
226
258
  return !this._paused && !this.pageHidden && guardCheck(this);
@@ -231,53 +263,48 @@
231
263
  }
232
264
  this.particles.handleClickMode(mode);
233
265
  for (const [, plugin] of this.plugins) {
234
- if (plugin.handleClickMode) {
235
- plugin.handleClickMode(mode);
236
- }
266
+ plugin.handleClickMode && plugin.handleClickMode(mode);
237
267
  }
238
268
  }
239
269
  async init() {
240
270
  if (!guardCheck(this)) {
241
271
  return;
242
272
  }
243
- const shapes = this._engine.plugins.getSupportedShapes();
273
+ const shapes = this._engine.getSupportedShapes();
244
274
  for (const type of shapes) {
245
- const drawer = this._engine.plugins.getShapeDrawer(type);
275
+ const drawer = this._engine.getShapeDrawer(type);
246
276
  if (drawer) {
247
277
  this.drawers.set(type, drawer);
248
278
  }
249
279
  }
250
280
  this._options = loadContainerOptions(this._engine, this, this._initialSourceOptions, this.sourceOptions);
251
281
  this.actualOptions = loadContainerOptions(this._engine, this, this._options);
252
- const availablePlugins = this._engine.plugins.getAvailablePlugins(this);
282
+ const availablePlugins = this._engine.getAvailablePlugins(this);
253
283
  for (const [id, plugin] of availablePlugins) {
254
284
  this.plugins.set(id, plugin);
255
285
  }
256
286
  this.retina.init();
257
287
  await this.canvas.init();
288
+ this.updateActualOptions();
289
+ this.canvas.initBackground();
290
+ this.canvas.resize();
258
291
  this.zLayers = this.actualOptions.zLayers;
259
- this.duration = (0, NumberUtils_1.getRangeValue)(this.actualOptions.duration) * 1000;
292
+ this._duration = (0, NumberUtils_1.getRangeValue)(this.actualOptions.duration) * 1000;
260
293
  this._delay = (0, NumberUtils_1.getRangeValue)(this.actualOptions.delay) * 1000;
261
- this.lifeTime = 0;
294
+ this._lifeTime = 0;
262
295
  this.fpsLimit = this.actualOptions.fpsLimit > 0 ? this.actualOptions.fpsLimit : 120;
263
296
  this.smooth = this.actualOptions.smooth;
264
297
  for (const [, drawer] of this.drawers) {
265
- if (drawer.init) {
266
- await drawer.init(this);
267
- }
298
+ drawer.init && (await drawer.init(this));
268
299
  }
269
300
  for (const [, plugin] of this.plugins) {
270
- if (plugin.init) {
271
- await plugin.init();
272
- }
301
+ plugin.init && (await plugin.init());
273
302
  }
274
303
  this._engine.dispatchEvent("containerInit", { container: this });
275
304
  this.particles.init();
276
305
  this.particles.setDensity();
277
306
  for (const [, plugin] of this.plugins) {
278
- if (plugin.particlesSetup) {
279
- plugin.particlesSetup();
280
- }
307
+ plugin.particlesSetup && plugin.particlesSetup();
281
308
  }
282
309
  this._engine.dispatchEvent("particlesSetup", { container: this });
283
310
  }
@@ -293,16 +320,14 @@
293
320
  return;
294
321
  }
295
322
  if (this._drawAnimationFrame !== undefined) {
296
- (0, Utils_1.cancelAnimation)()(this._drawAnimationFrame);
323
+ cancelAnimationFrame(this._drawAnimationFrame);
297
324
  delete this._drawAnimationFrame;
298
325
  }
299
326
  if (this._paused) {
300
327
  return;
301
328
  }
302
329
  for (const [, plugin] of this.plugins) {
303
- if (plugin.pause) {
304
- plugin.pause();
305
- }
330
+ plugin.pause && plugin.pause();
306
331
  }
307
332
  if (!this.pageHidden) {
308
333
  this._paused = true;
@@ -342,37 +367,11 @@
342
367
  if (!guardCheck(this)) {
343
368
  return;
344
369
  }
370
+ this._initialSourceOptions = undefined;
345
371
  this._options = loadContainerOptions(this._engine, this);
372
+ this.actualOptions = loadContainerOptions(this._engine, this, this._options);
346
373
  return this.refresh();
347
374
  }
348
- setNoise(noiseOrGenerator, init, update) {
349
- if (!guardCheck(this)) {
350
- return;
351
- }
352
- this.setPath(noiseOrGenerator, init, update);
353
- }
354
- setPath(pathOrGenerator, init, update) {
355
- if (!pathOrGenerator || !guardCheck(this)) {
356
- return;
357
- }
358
- const pathGenerator = Object.assign({}, defaultPathGenerator);
359
- if (typeof pathOrGenerator === "function") {
360
- pathGenerator.generate = pathOrGenerator;
361
- if (init) {
362
- pathGenerator.init = init;
363
- }
364
- if (update) {
365
- pathGenerator.update = update;
366
- }
367
- }
368
- else {
369
- const oldGenerator = pathGenerator;
370
- pathGenerator.generate = pathOrGenerator.generate || oldGenerator.generate;
371
- pathGenerator.init = pathOrGenerator.init || oldGenerator.init;
372
- pathGenerator.update = pathOrGenerator.update || oldGenerator.update;
373
- }
374
- this.addPath(defaultPathGeneratorKey, pathGenerator, true);
375
- }
376
375
  async start() {
377
376
  if (!guardCheck(this) || this.started) {
378
377
  return;
@@ -386,9 +385,7 @@
386
385
  this._intersectionObserver.observe(this.interactivity.element);
387
386
  }
388
387
  for (const [, plugin] of this.plugins) {
389
- if (plugin.start) {
390
- await plugin.start();
391
- }
388
+ plugin.start && (await plugin.start());
392
389
  }
393
390
  this._engine.dispatchEvent("containerStarted", { container: this });
394
391
  this.play();
@@ -409,14 +406,12 @@
409
406
  this._eventListeners.removeListeners();
410
407
  this.pause();
411
408
  this.particles.clear();
412
- this.canvas.clear();
409
+ this.canvas.stop();
413
410
  if (this.interactivity.element instanceof HTMLElement && this._intersectionObserver) {
414
411
  this._intersectionObserver.unobserve(this.interactivity.element);
415
412
  }
416
413
  for (const [, plugin] of this.plugins) {
417
- if (plugin.stop) {
418
- plugin.stop();
419
- }
414
+ plugin.stop && plugin.stop();
420
415
  }
421
416
  for (const key of this.plugins.keys()) {
422
417
  this.plugins.delete(key);
@@ -434,17 +429,6 @@
434
429
  this.responsiveMaxWidth = newMaxWidth;
435
430
  return true;
436
431
  }
437
- _intersectionManager(entries) {
438
- if (!guardCheck(this) || !this.actualOptions.pauseOnOutsideViewport) {
439
- return;
440
- }
441
- for (const entry of entries) {
442
- if (entry.target !== this.interactivity.element) {
443
- continue;
444
- }
445
- (entry.isIntersecting ? this.play : this.pause)();
446
- }
447
- }
448
432
  }
449
433
  exports.Container = Container;
450
434
  });
@@ -0,0 +1,285 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports", "./Utils/Constants", "../Utils/Utils", "./Container", "../Utils/EventDispatcher", "../Utils/NumberUtils"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Engine = void 0;
13
+ const Constants_1 = require("./Utils/Constants");
14
+ const Utils_1 = require("../Utils/Utils");
15
+ const Container_1 = require("./Container");
16
+ const EventDispatcher_1 = require("../Utils/EventDispatcher");
17
+ const NumberUtils_1 = require("../Utils/NumberUtils");
18
+ function getItemsFromInitializer(container, map, initializers, force = false) {
19
+ let res = map.get(container);
20
+ if (!res || force) {
21
+ res = [...initializers.values()].map((t) => t(container));
22
+ map.set(container, res);
23
+ }
24
+ return res;
25
+ }
26
+ async function getDataFromUrl(data) {
27
+ const url = (0, Utils_1.itemFromSingleOrMultiple)(data.url, data.index);
28
+ if (!url) {
29
+ return data.fallback;
30
+ }
31
+ const response = await fetch(url);
32
+ if (response.ok) {
33
+ return response.json();
34
+ }
35
+ (0, Utils_1.getLogger)().error(`${Constants_1.errorPrefix} ${response.status} while retrieving config file`);
36
+ return data.fallback;
37
+ }
38
+ class Engine {
39
+ constructor() {
40
+ this._configs = new Map();
41
+ this._domArray = [];
42
+ this._eventDispatcher = new EventDispatcher_1.EventDispatcher();
43
+ this._initialized = false;
44
+ this.plugins = [];
45
+ this._initializers = {
46
+ interactors: new Map(),
47
+ movers: new Map(),
48
+ updaters: new Map(),
49
+ };
50
+ this.interactors = new Map();
51
+ this.movers = new Map();
52
+ this.updaters = new Map();
53
+ this.presets = new Map();
54
+ this.drawers = new Map();
55
+ this.pathGenerators = new Map();
56
+ }
57
+ get configs() {
58
+ const res = {};
59
+ for (const [name, config] of this._configs) {
60
+ res[name] = config;
61
+ }
62
+ return res;
63
+ }
64
+ get version() {
65
+ return "3.0.0-beta.0";
66
+ }
67
+ addConfig(nameOrConfig, config) {
68
+ if ((0, Utils_1.isString)(nameOrConfig)) {
69
+ if (config) {
70
+ config.name = nameOrConfig;
71
+ this._configs.set(nameOrConfig, config);
72
+ }
73
+ }
74
+ else {
75
+ this._configs.set(nameOrConfig.name ?? "default", nameOrConfig);
76
+ }
77
+ }
78
+ addEventListener(type, listener) {
79
+ this._eventDispatcher.addEventListener(type, listener);
80
+ }
81
+ async addInteractor(name, interactorInitializer, refresh = true) {
82
+ this._initializers.interactors.set(name, interactorInitializer);
83
+ await this.refresh(refresh);
84
+ }
85
+ async addMover(name, moverInitializer, refresh = true) {
86
+ this._initializers.movers.set(name, moverInitializer);
87
+ await this.refresh(refresh);
88
+ }
89
+ async addParticleUpdater(name, updaterInitializer, refresh = true) {
90
+ this._initializers.updaters.set(name, updaterInitializer);
91
+ await this.refresh(refresh);
92
+ }
93
+ async addPathGenerator(name, generator, refresh = true) {
94
+ !this.getPathGenerator(name) && this.pathGenerators.set(name, generator);
95
+ await this.refresh(refresh);
96
+ }
97
+ async addPlugin(plugin, refresh = true) {
98
+ !this.getPlugin(plugin.id) && this.plugins.push(plugin);
99
+ await this.refresh(refresh);
100
+ }
101
+ async addPreset(preset, options, override = false, refresh = true) {
102
+ (override || !this.getPreset(preset)) && this.presets.set(preset, options);
103
+ await this.refresh(refresh);
104
+ }
105
+ async addShape(shape, drawer, initOrRefresh, afterEffectOrRefresh, destroyOrRefresh, refresh = true) {
106
+ let customDrawer;
107
+ let realRefresh = refresh, realInit, realAfterEffect, realDestroy;
108
+ if ((0, Utils_1.isBoolean)(initOrRefresh)) {
109
+ realRefresh = initOrRefresh;
110
+ realInit = undefined;
111
+ }
112
+ else {
113
+ realInit = initOrRefresh;
114
+ }
115
+ if ((0, Utils_1.isBoolean)(afterEffectOrRefresh)) {
116
+ realRefresh = afterEffectOrRefresh;
117
+ realAfterEffect = undefined;
118
+ }
119
+ else {
120
+ realAfterEffect = afterEffectOrRefresh;
121
+ }
122
+ if ((0, Utils_1.isBoolean)(destroyOrRefresh)) {
123
+ realRefresh = destroyOrRefresh;
124
+ realDestroy = undefined;
125
+ }
126
+ else {
127
+ realDestroy = destroyOrRefresh;
128
+ }
129
+ if ((0, Utils_1.isFunction)(drawer)) {
130
+ customDrawer = {
131
+ afterEffect: realAfterEffect,
132
+ destroy: realDestroy,
133
+ draw: drawer,
134
+ init: realInit,
135
+ };
136
+ }
137
+ else {
138
+ customDrawer = drawer;
139
+ }
140
+ (0, Utils_1.executeOnSingleOrMultiple)(shape, (type) => {
141
+ !this.getShapeDrawer(type) && this.drawers.set(type, customDrawer);
142
+ });
143
+ await this.refresh(realRefresh);
144
+ }
145
+ clearPlugins(container) {
146
+ this.updaters.delete(container);
147
+ this.movers.delete(container);
148
+ this.interactors.delete(container);
149
+ }
150
+ dispatchEvent(type, args) {
151
+ this._eventDispatcher.dispatchEvent(type, args);
152
+ }
153
+ dom() {
154
+ return this._domArray;
155
+ }
156
+ domItem(index) {
157
+ const dom = this.dom(), item = dom[index];
158
+ if (!item || item.destroyed) {
159
+ dom.splice(index, 1);
160
+ return;
161
+ }
162
+ return item;
163
+ }
164
+ getAvailablePlugins(container) {
165
+ const res = new Map();
166
+ for (const plugin of this.plugins) {
167
+ plugin.needsPlugin(container.actualOptions) && res.set(plugin.id, plugin.getPlugin(container));
168
+ }
169
+ return res;
170
+ }
171
+ getInteractors(container, force = false) {
172
+ return getItemsFromInitializer(container, this.interactors, this._initializers.interactors, force);
173
+ }
174
+ getMovers(container, force = false) {
175
+ return getItemsFromInitializer(container, this.movers, this._initializers.movers, force);
176
+ }
177
+ getPathGenerator(type) {
178
+ return this.pathGenerators.get(type);
179
+ }
180
+ getPlugin(plugin) {
181
+ return this.plugins.find((t) => t.id === plugin);
182
+ }
183
+ getPreset(preset) {
184
+ return this.presets.get(preset);
185
+ }
186
+ getShapeDrawer(type) {
187
+ return this.drawers.get(type);
188
+ }
189
+ getSupportedShapes() {
190
+ return this.drawers.keys();
191
+ }
192
+ getUpdaters(container, force = false) {
193
+ return getItemsFromInitializer(container, this.updaters, this._initializers.updaters, force);
194
+ }
195
+ init() {
196
+ if (this._initialized) {
197
+ return;
198
+ }
199
+ this._initialized = true;
200
+ }
201
+ async load(params) {
202
+ 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;
203
+ let domContainer = params.element ?? document.getElementById(id);
204
+ if (!domContainer) {
205
+ domContainer = document.createElement("div");
206
+ domContainer.id = id;
207
+ document.body.append(domContainer);
208
+ }
209
+ const currentOptions = (0, Utils_1.itemFromSingleOrMultiple)(options, index), dom = this.dom(), oldIndex = dom.findIndex((v) => v.id === id);
210
+ if (oldIndex >= 0) {
211
+ const old = this.domItem(oldIndex);
212
+ if (old && !old.destroyed) {
213
+ old.destroy();
214
+ dom.splice(oldIndex, 1);
215
+ }
216
+ }
217
+ let canvasEl;
218
+ if (domContainer.tagName.toLowerCase() === "canvas") {
219
+ canvasEl = domContainer;
220
+ canvasEl.dataset[Constants_1.generatedAttribute] = "false";
221
+ }
222
+ else {
223
+ const existingCanvases = domContainer.getElementsByTagName("canvas");
224
+ if (existingCanvases.length) {
225
+ canvasEl = existingCanvases[0];
226
+ canvasEl.dataset[Constants_1.generatedAttribute] = "false";
227
+ }
228
+ else {
229
+ canvasEl = document.createElement("canvas");
230
+ canvasEl.dataset[Constants_1.generatedAttribute] = "true";
231
+ domContainer.appendChild(canvasEl);
232
+ }
233
+ }
234
+ if (!canvasEl.style.width) {
235
+ canvasEl.style.width = "100%";
236
+ }
237
+ if (!canvasEl.style.height) {
238
+ canvasEl.style.height = "100%";
239
+ }
240
+ const newItem = new Container_1.Container(this, id, currentOptions);
241
+ if (oldIndex >= 0) {
242
+ dom.splice(oldIndex, 0, newItem);
243
+ }
244
+ else {
245
+ dom.push(newItem);
246
+ }
247
+ newItem.canvas.loadCanvas(canvasEl);
248
+ await newItem.start();
249
+ return newItem;
250
+ }
251
+ loadOptions(options, sourceOptions) {
252
+ for (const plugin of this.plugins) {
253
+ plugin.loadOptions(options, sourceOptions);
254
+ }
255
+ }
256
+ loadParticlesOptions(container, options, ...sourceOptions) {
257
+ const updaters = this.updaters.get(container);
258
+ if (!updaters) {
259
+ return;
260
+ }
261
+ for (const updater of updaters) {
262
+ updater.loadOptions && updater.loadOptions(options, ...sourceOptions);
263
+ }
264
+ }
265
+ async refresh(refresh = true) {
266
+ if (!refresh) {
267
+ return;
268
+ }
269
+ this.dom().forEach((t) => t.refresh());
270
+ }
271
+ removeEventListener(type, listener) {
272
+ this._eventDispatcher.removeEventListener(type, listener);
273
+ }
274
+ setOnClickHandler(callback) {
275
+ const dom = this.dom();
276
+ if (!dom.length) {
277
+ throw new Error(`${Constants_1.errorPrefix} can only set click handlers after calling tsParticles.load()`);
278
+ }
279
+ for (const domItem of dom) {
280
+ domItem.addClickHandler(callback);
281
+ }
282
+ }
283
+ }
284
+ exports.Engine = Engine;
285
+ });