@tsparticles/engine 3.9.1 → 4.0.0-alpha.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 (431) hide show
  1. package/638.min.js +2 -0
  2. package/638.min.js.LICENSE.txt +1 -0
  3. package/browser/Core/Canvas.js +126 -181
  4. package/browser/Core/Container.js +22 -18
  5. package/browser/Core/Engine.js +64 -54
  6. package/browser/Core/Particle.js +43 -48
  7. package/browser/Core/Particles.js +33 -24
  8. package/browser/Core/Retina.js +2 -3
  9. package/browser/Core/Utils/Constants.js +2 -2
  10. package/browser/Core/Utils/EventListeners.js +74 -64
  11. package/browser/Core/Utils/QuadTree.js +1 -1
  12. package/browser/Core/Utils/Ranges.js +2 -2
  13. package/browser/Core/Utils/Vectors.js +15 -21
  14. package/browser/Options/Classes/AnimatableColor.js +3 -3
  15. package/browser/Options/Classes/AnimationOptions.js +1 -1
  16. package/browser/Options/Classes/ColorAnimation.js +1 -1
  17. package/browser/Options/Classes/Options.js +13 -10
  18. package/browser/Options/Classes/Particles/Move/Move.js +1 -4
  19. package/browser/Options/Classes/Particles/Move/MoveAngle.js +1 -1
  20. package/browser/Options/Classes/Particles/Move/MoveAttract.js +1 -1
  21. package/browser/Options/Classes/Particles/Move/MoveGravity.js +1 -1
  22. package/browser/Options/Classes/Particles/Move/Spin.js +1 -1
  23. package/browser/Options/Classes/Particles/ParticlesOptions.js +0 -6
  24. package/browser/Options/Classes/Particles/Stroke.js +1 -1
  25. package/browser/Options/Classes/ValueWithRandom.js +1 -1
  26. package/browser/Utils/CanvasUtils.js +65 -21
  27. package/browser/Utils/ColorUtils.js +61 -45
  28. package/browser/Utils/EventDispatcher.js +3 -1
  29. package/browser/Utils/LogUtils.js +22 -0
  30. package/browser/Utils/{NumberUtils.js → MathUtils.js} +14 -7
  31. package/browser/Utils/Utils.js +23 -125
  32. package/browser/bundle.js +3 -3
  33. package/browser/export-types.js +1 -99
  34. package/browser/exports.js +2 -9
  35. package/browser/index.js +3 -7
  36. package/browser/initEngine.js +4 -0
  37. package/cjs/Core/Canvas.js +136 -195
  38. package/cjs/Core/Container.js +57 -57
  39. package/cjs/Core/Engine.js +77 -71
  40. package/cjs/Core/Interfaces/Colors.js +1 -2
  41. package/cjs/Core/Interfaces/IBounds.js +1 -2
  42. package/cjs/Core/Interfaces/IBubbleParticleData.js +1 -2
  43. package/cjs/Core/Interfaces/ICircleBouncer.js +1 -2
  44. package/cjs/Core/Interfaces/IColorManager.js +1 -2
  45. package/cjs/Core/Interfaces/IContainerInteractivity.js +1 -2
  46. package/cjs/Core/Interfaces/IContainerPlugin.js +1 -2
  47. package/cjs/Core/Interfaces/ICoordinates.js +1 -2
  48. package/cjs/Core/Interfaces/IDelta.js +1 -2
  49. package/cjs/Core/Interfaces/IDimension.js +1 -2
  50. package/cjs/Core/Interfaces/IDistance.js +1 -2
  51. package/cjs/Core/Interfaces/IDrawParticleParams.js +1 -2
  52. package/cjs/Core/Interfaces/IEffectDrawer.js +1 -2
  53. package/cjs/Core/Interfaces/IExternalInteractor.js +1 -2
  54. package/cjs/Core/Interfaces/IInteractor.js +1 -2
  55. package/cjs/Core/Interfaces/ILoadParams.js +1 -2
  56. package/cjs/Core/Interfaces/IMouseData.js +1 -2
  57. package/cjs/Core/Interfaces/IMovePathGenerator.js +1 -2
  58. package/cjs/Core/Interfaces/IParticleColorStyle.js +1 -2
  59. package/cjs/Core/Interfaces/IParticleHslAnimation.js +1 -2
  60. package/cjs/Core/Interfaces/IParticleLife.js +1 -2
  61. package/cjs/Core/Interfaces/IParticleMover.js +1 -2
  62. package/cjs/Core/Interfaces/IParticleRetinaProps.js +1 -2
  63. package/cjs/Core/Interfaces/IParticleRoll.js +1 -2
  64. package/cjs/Core/Interfaces/IParticleTransformValues.js +1 -2
  65. package/cjs/Core/Interfaces/IParticleUpdater.js +1 -2
  66. package/cjs/Core/Interfaces/IParticleValueAnimation.js +1 -2
  67. package/cjs/Core/Interfaces/IParticlesInteractor.js +1 -2
  68. package/cjs/Core/Interfaces/IPlugin.js +1 -2
  69. package/cjs/Core/Interfaces/IPositionFromSizeParams.js +1 -2
  70. package/cjs/Core/Interfaces/IRangeValue.js +1 -2
  71. package/cjs/Core/Interfaces/IShapeDrawData.js +1 -2
  72. package/cjs/Core/Interfaces/IShapeDrawer.js +1 -2
  73. package/cjs/Core/Interfaces/IShapeValues.js +1 -2
  74. package/cjs/Core/Interfaces/ISlowParticleData.js +1 -2
  75. package/cjs/Core/Particle.js +99 -108
  76. package/cjs/Core/Particles.js +63 -58
  77. package/cjs/Core/Retina.js +13 -18
  78. package/cjs/Core/Utils/Constants.js +3 -7
  79. package/cjs/Core/Utils/EventListeners.js +94 -88
  80. package/cjs/Core/Utils/ExternalInteractorBase.js +3 -7
  81. package/cjs/Core/Utils/InteractionManager.js +4 -8
  82. package/cjs/Core/Utils/ParticlesInteractorBase.js +3 -7
  83. package/cjs/Core/Utils/Point.js +1 -5
  84. package/cjs/Core/Utils/QuadTree.js +10 -14
  85. package/cjs/Core/Utils/Ranges.js +14 -20
  86. package/cjs/Core/Utils/Vectors.js +24 -35
  87. package/cjs/Enums/AnimationStatus.js +2 -5
  88. package/cjs/Enums/Directions/MoveDirection.js +2 -5
  89. package/cjs/Enums/Directions/OutModeDirection.js +2 -5
  90. package/cjs/Enums/Directions/RotateDirection.js +2 -5
  91. package/cjs/Enums/InteractivityDetect.js +2 -5
  92. package/cjs/Enums/Modes/AnimationMode.js +2 -5
  93. package/cjs/Enums/Modes/LimitMode.js +2 -5
  94. package/cjs/Enums/Modes/OutMode.js +2 -5
  95. package/cjs/Enums/Modes/PixelMode.js +2 -5
  96. package/cjs/Enums/Modes/ResponsiveMode.js +2 -5
  97. package/cjs/Enums/Modes/ThemeMode.js +2 -5
  98. package/cjs/Enums/Types/AlterType.js +2 -5
  99. package/cjs/Enums/Types/DestroyType.js +2 -5
  100. package/cjs/Enums/Types/DivType.js +2 -5
  101. package/cjs/Enums/Types/EasingType.js +2 -5
  102. package/cjs/Enums/Types/EventType.js +2 -5
  103. package/cjs/Enums/Types/GradientType.js +2 -5
  104. package/cjs/Enums/Types/InteractorType.js +2 -5
  105. package/cjs/Enums/Types/ParticleOutType.js +2 -5
  106. package/cjs/Enums/Types/StartValueType.js +2 -5
  107. package/cjs/Options/Classes/AnimatableColor.js +10 -14
  108. package/cjs/Options/Classes/AnimationOptions.js +14 -19
  109. package/cjs/Options/Classes/Background/Background.js +6 -10
  110. package/cjs/Options/Classes/ColorAnimation.js +6 -10
  111. package/cjs/Options/Classes/FullScreen/FullScreen.js +3 -7
  112. package/cjs/Options/Classes/HslAnimation.js +7 -11
  113. package/cjs/Options/Classes/Interactivity/Events/ClickEvent.js +3 -7
  114. package/cjs/Options/Classes/Interactivity/Events/DivEvent.js +5 -9
  115. package/cjs/Options/Classes/Interactivity/Events/Events.js +14 -18
  116. package/cjs/Options/Classes/Interactivity/Events/HoverEvent.js +5 -9
  117. package/cjs/Options/Classes/Interactivity/Events/Parallax.js +3 -7
  118. package/cjs/Options/Classes/Interactivity/Events/ResizeEvent.js +3 -7
  119. package/cjs/Options/Classes/Interactivity/Interactivity.js +9 -13
  120. package/cjs/Options/Classes/Interactivity/Modes/Modes.js +3 -7
  121. package/cjs/Options/Classes/ManualParticle.js +10 -14
  122. package/cjs/Options/Classes/Options.js +41 -42
  123. package/cjs/Options/Classes/OptionsColor.js +5 -9
  124. package/cjs/Options/Classes/Particles/Bounce/ParticlesBounce.js +6 -10
  125. package/cjs/Options/Classes/Particles/Bounce/ParticlesBounceFactor.js +2 -6
  126. package/cjs/Options/Classes/Particles/Effect/Effect.js +5 -9
  127. package/cjs/Options/Classes/Particles/Move/Move.js +26 -33
  128. package/cjs/Options/Classes/Particles/Move/MoveAngle.js +6 -10
  129. package/cjs/Options/Classes/Particles/Move/MoveAttract.js +5 -9
  130. package/cjs/Options/Classes/Particles/Move/MoveCenter.js +5 -9
  131. package/cjs/Options/Classes/Particles/Move/MoveGravity.js +6 -10
  132. package/cjs/Options/Classes/Particles/Move/OutModes.js +5 -9
  133. package/cjs/Options/Classes/Particles/Move/Path/MovePath.js +7 -11
  134. package/cjs/Options/Classes/Particles/Move/Spin.js +7 -11
  135. package/cjs/Options/Classes/Particles/Number/ParticlesDensity.js +3 -7
  136. package/cjs/Options/Classes/Particles/Number/ParticlesNumber.js +7 -11
  137. package/cjs/Options/Classes/Particles/Number/ParticlesNumberLimit.js +5 -9
  138. package/cjs/Options/Classes/Particles/Opacity/Opacity.js +6 -10
  139. package/cjs/Options/Classes/Particles/Opacity/OpacityAnimation.js +6 -10
  140. package/cjs/Options/Classes/Particles/ParticlesOptions.js +29 -39
  141. package/cjs/Options/Classes/Particles/Shape/Shape.js +5 -9
  142. package/cjs/Options/Classes/Particles/Size/Size.js +6 -10
  143. package/cjs/Options/Classes/Particles/Size/SizeAnimation.js +6 -10
  144. package/cjs/Options/Classes/Particles/Stroke.js +8 -12
  145. package/cjs/Options/Classes/Particles/ZIndex/ZIndex.js +4 -8
  146. package/cjs/Options/Classes/Responsive.js +13 -17
  147. package/cjs/Options/Classes/Theme/Theme.js +7 -11
  148. package/cjs/Options/Classes/Theme/ThemeDefault.js +5 -9
  149. package/cjs/Options/Classes/ValueWithRandom.js +12 -18
  150. package/cjs/Options/Interfaces/Background/IBackground.js +1 -2
  151. package/cjs/Options/Interfaces/FullScreen/IFullScreen.js +1 -2
  152. package/cjs/Options/Interfaces/IAnimatable.js +1 -2
  153. package/cjs/Options/Interfaces/IAnimatableColor.js +1 -2
  154. package/cjs/Options/Interfaces/IAnimation.js +1 -2
  155. package/cjs/Options/Interfaces/IColorAnimation.js +1 -2
  156. package/cjs/Options/Interfaces/IHslAnimation.js +1 -2
  157. package/cjs/Options/Interfaces/IManualParticle.js +1 -2
  158. package/cjs/Options/Interfaces/IOptionLoader.js +1 -2
  159. package/cjs/Options/Interfaces/IOptions.js +1 -2
  160. package/cjs/Options/Interfaces/IOptionsColor.js +1 -2
  161. package/cjs/Options/Interfaces/IResponsive.js +1 -2
  162. package/cjs/Options/Interfaces/IValueWithRandom.js +1 -2
  163. package/cjs/Options/Interfaces/Interactivity/Events/IClickEvent.js +1 -2
  164. package/cjs/Options/Interfaces/Interactivity/Events/IDivEvent.js +1 -2
  165. package/cjs/Options/Interfaces/Interactivity/Events/IEvents.js +1 -2
  166. package/cjs/Options/Interfaces/Interactivity/Events/IHoverEvent.js +1 -2
  167. package/cjs/Options/Interfaces/Interactivity/Events/IParallax.js +1 -2
  168. package/cjs/Options/Interfaces/Interactivity/Events/IResizeEvent.js +1 -2
  169. package/cjs/Options/Interfaces/Interactivity/IInteractivity.js +1 -2
  170. package/cjs/Options/Interfaces/Interactivity/Modes/IModeDiv.js +1 -2
  171. package/cjs/Options/Interfaces/Interactivity/Modes/IModes.js +1 -2
  172. package/cjs/Options/Interfaces/Particles/Bounce/IParticlesBounce.js +1 -2
  173. package/cjs/Options/Interfaces/Particles/Effect/IEffect.js +1 -2
  174. package/cjs/Options/Interfaces/Particles/IParticlesOptions.js +1 -2
  175. package/cjs/Options/Interfaces/Particles/IStroke.js +1 -2
  176. package/cjs/Options/Interfaces/Particles/Move/IMove.js +1 -2
  177. package/cjs/Options/Interfaces/Particles/Move/IMoveAngle.js +1 -2
  178. package/cjs/Options/Interfaces/Particles/Move/IMoveAttract.js +1 -2
  179. package/cjs/Options/Interfaces/Particles/Move/IMoveCenter.js +1 -2
  180. package/cjs/Options/Interfaces/Particles/Move/IMoveGravity.js +1 -2
  181. package/cjs/Options/Interfaces/Particles/Move/IOutModes.js +1 -2
  182. package/cjs/Options/Interfaces/Particles/Move/ISpin.js +1 -2
  183. package/cjs/Options/Interfaces/Particles/Move/Path/IMovePath.js +1 -2
  184. package/cjs/Options/Interfaces/Particles/Number/IParticlesDensity.js +1 -2
  185. package/cjs/Options/Interfaces/Particles/Number/IParticlesNumber.js +1 -2
  186. package/cjs/Options/Interfaces/Particles/Number/IParticlesNumberLimit.js +1 -2
  187. package/cjs/Options/Interfaces/Particles/Opacity/IOpacity.js +1 -2
  188. package/cjs/Options/Interfaces/Particles/Opacity/IOpacityAnimation.js +1 -2
  189. package/cjs/Options/Interfaces/Particles/Shape/IShape.js +1 -2
  190. package/cjs/Options/Interfaces/Particles/Size/ISize.js +1 -2
  191. package/cjs/Options/Interfaces/Particles/Size/ISizeAnimation.js +1 -2
  192. package/cjs/Options/Interfaces/Particles/ZIndex/IZIndex.js +1 -2
  193. package/cjs/Options/Interfaces/Theme/ITheme.js +1 -2
  194. package/cjs/Options/Interfaces/Theme/IThemeDefault.js +1 -2
  195. package/cjs/Types/CustomEventArgs.js +1 -2
  196. package/cjs/Types/CustomEventListener.js +1 -2
  197. package/cjs/Types/EasingFunction.js +1 -2
  198. package/cjs/Types/ExportResult.js +1 -2
  199. package/cjs/Types/ISourceOptions.js +1 -2
  200. package/cjs/Types/ParticlesGroups.js +1 -2
  201. package/cjs/Types/PathOptions.js +1 -2
  202. package/cjs/Types/RangeValue.js +1 -2
  203. package/cjs/Types/RecursivePartial.js +1 -2
  204. package/cjs/Types/ShapeData.js +1 -2
  205. package/cjs/Types/SingleOrMultiple.js +1 -2
  206. package/cjs/Utils/CanvasUtils.js +86 -55
  207. package/cjs/Utils/ColorUtils.js +136 -141
  208. package/cjs/Utils/EventDispatcher.js +8 -10
  209. package/cjs/Utils/LogUtils.js +22 -0
  210. package/{esm/Utils/NumberUtils.js → cjs/Utils/MathUtils.js} +14 -7
  211. package/cjs/Utils/OptionsUtils.js +4 -8
  212. package/cjs/Utils/TypeUtils.js +7 -16
  213. package/cjs/Utils/Utils.js +104 -239
  214. package/cjs/bundle.js +5 -22
  215. package/cjs/export-types.js +1 -115
  216. package/cjs/exports.js +77 -100
  217. package/cjs/index.js +5 -26
  218. package/cjs/initEngine.js +4 -0
  219. package/dist_browser_Core_Container_js.js +102 -0
  220. package/esm/Core/Canvas.js +126 -181
  221. package/esm/Core/Container.js +22 -18
  222. package/esm/Core/Engine.js +64 -54
  223. package/esm/Core/Particle.js +43 -48
  224. package/esm/Core/Particles.js +33 -24
  225. package/esm/Core/Retina.js +2 -3
  226. package/esm/Core/Utils/Constants.js +2 -2
  227. package/esm/Core/Utils/EventListeners.js +74 -64
  228. package/esm/Core/Utils/QuadTree.js +1 -1
  229. package/esm/Core/Utils/Ranges.js +2 -2
  230. package/esm/Core/Utils/Vectors.js +15 -21
  231. package/esm/Enums/RangeType.js +5 -0
  232. package/esm/Options/Classes/AnimatableColor.js +3 -3
  233. package/esm/Options/Classes/AnimationOptions.js +1 -1
  234. package/esm/Options/Classes/ColorAnimation.js +1 -1
  235. package/esm/Options/Classes/Options.js +13 -10
  236. package/esm/Options/Classes/Particles/Move/Move.js +1 -4
  237. package/esm/Options/Classes/Particles/Move/MoveAngle.js +1 -1
  238. package/esm/Options/Classes/Particles/Move/MoveAttract.js +1 -1
  239. package/esm/Options/Classes/Particles/Move/MoveGravity.js +1 -1
  240. package/esm/Options/Classes/Particles/Move/Spin.js +1 -1
  241. package/esm/Options/Classes/Particles/ParticlesOptions.js +0 -6
  242. package/esm/Options/Classes/Particles/Stroke.js +1 -1
  243. package/esm/Options/Classes/ValueWithRandom.js +1 -1
  244. package/esm/Utils/CanvasUtils.js +65 -21
  245. package/esm/Utils/ColorUtils.js +61 -45
  246. package/esm/Utils/EventDispatcher.js +3 -1
  247. package/esm/Utils/LogUtils.js +22 -0
  248. package/esm/Utils/MathUtils.js +158 -0
  249. package/esm/Utils/Utils.js +23 -125
  250. package/esm/bundle.js +3 -3
  251. package/esm/export-types.js +1 -99
  252. package/esm/exports.js +2 -9
  253. package/esm/index.js +3 -7
  254. package/esm/initEngine.js +4 -0
  255. package/package.json +3 -2
  256. package/report.html +5 -4
  257. package/scripts/install.js +204 -118
  258. package/tsparticles.engine.js +492 -451
  259. package/tsparticles.engine.min.js +1 -1
  260. package/tsparticles.engine.min.js.LICENSE.txt +1 -1
  261. package/types/Core/Canvas.d.ts +6 -9
  262. package/types/Core/Container.d.ts +1 -0
  263. package/types/Core/Engine.d.ts +20 -16
  264. package/types/Core/Interfaces/Colors.d.ts +46 -2
  265. package/types/Core/Interfaces/IColorManager.d.ts +1 -1
  266. package/types/Core/Interfaces/IContainerPlugin.d.ts +4 -0
  267. package/types/Core/Interfaces/IDrawParticleParams.d.ts +0 -4
  268. package/types/Core/Interfaces/IEffectDrawer.d.ts +2 -1
  269. package/types/Core/Interfaces/IShapeDrawData.d.ts +2 -0
  270. package/types/Core/Interfaces/IShapeDrawer.d.ts +1 -0
  271. package/types/Core/Particle.d.ts +4 -5
  272. package/types/Core/Particles.d.ts +1 -1
  273. package/types/Core/Utils/Constants.d.ts +2 -2
  274. package/types/Core/Utils/EventListeners.d.ts +1 -0
  275. package/types/Core/Utils/Vectors.d.ts +3 -3
  276. package/types/Options/Classes/Options.d.ts +1 -2
  277. package/types/Options/Classes/OptionsColor.d.ts +2 -2
  278. package/types/Options/Classes/Particles/Move/Move.d.ts +0 -2
  279. package/types/Options/Classes/Particles/ParticlesOptions.d.ts +0 -4
  280. package/types/Options/Interfaces/IOptions.d.ts +1 -2
  281. package/types/Options/Interfaces/Particles/IParticlesOptions.d.ts +0 -4
  282. package/types/Options/Interfaces/Particles/Move/IMove.d.ts +0 -2
  283. package/types/Utils/CanvasUtils.d.ts +4 -1
  284. package/types/Utils/ColorUtils.d.ts +2 -2
  285. package/types/Utils/LogUtils.d.ts +11 -0
  286. package/types/Utils/{NumberUtils.d.ts → MathUtils.d.ts} +2 -1
  287. package/types/Utils/TypeUtils.d.ts +2 -2
  288. package/types/Utils/Utils.d.ts +4 -16
  289. package/types/export-types.d.ts +91 -101
  290. package/types/exports.d.ts +2 -9
  291. package/types/index.d.ts +1 -1
  292. package/types/initEngine.d.ts +2 -0
  293. package/umd/Core/Canvas.js +123 -178
  294. package/umd/Core/Container.js +25 -21
  295. package/umd/Core/Engine.js +97 -53
  296. package/umd/Core/Particle.js +54 -59
  297. package/umd/Core/Particles.js +33 -24
  298. package/umd/Core/Retina.js +9 -10
  299. package/umd/Core/Utils/Constants.js +3 -3
  300. package/umd/Core/Utils/EventListeners.js +72 -62
  301. package/umd/Core/Utils/QuadTree.js +3 -3
  302. package/umd/Core/Utils/Ranges.js +4 -4
  303. package/umd/Core/Utils/Vectors.js +15 -21
  304. package/umd/Options/Classes/AnimatableColor.js +3 -3
  305. package/umd/Options/Classes/AnimationOptions.js +6 -6
  306. package/umd/Options/Classes/ColorAnimation.js +3 -3
  307. package/umd/Options/Classes/Options.js +16 -13
  308. package/umd/Options/Classes/Particles/Move/Move.js +5 -8
  309. package/umd/Options/Classes/Particles/Move/MoveAngle.js +4 -4
  310. package/umd/Options/Classes/Particles/Move/MoveAttract.js +3 -3
  311. package/umd/Options/Classes/Particles/Move/MoveGravity.js +4 -4
  312. package/umd/Options/Classes/Particles/Move/Spin.js +3 -3
  313. package/umd/Options/Classes/Particles/ParticlesOptions.js +1 -7
  314. package/umd/Options/Classes/Particles/Stroke.js +4 -4
  315. package/umd/Options/Classes/ValueWithRandom.js +3 -3
  316. package/umd/Utils/CanvasUtils.js +69 -22
  317. package/umd/Utils/ColorUtils.js +72 -56
  318. package/umd/Utils/EventDispatcher.js +3 -1
  319. package/umd/Utils/LogUtils.js +36 -0
  320. package/umd/Utils/{NumberUtils.js → MathUtils.js} +16 -8
  321. package/umd/Utils/Utils.js +36 -141
  322. package/umd/bundle.js +4 -4
  323. package/umd/export-types.js +1 -114
  324. package/umd/exports.js +3 -10
  325. package/umd/index.js +4 -8
  326. package/umd/{init.js → initEngine.js} +3 -5
  327. package/browser/Core/Interfaces/IRectSideResult.js +0 -1
  328. package/browser/Core/Interfaces/ITrailFillData.js +0 -1
  329. package/browser/Enums/Modes/CollisionMode.js +0 -6
  330. package/browser/Options/Classes/BackgroundMask/BackgroundMask.js +0 -24
  331. package/browser/Options/Classes/BackgroundMask/BackgroundMaskCover.js +0 -21
  332. package/browser/Options/Classes/Particles/Collisions/Collisions.js +0 -33
  333. package/browser/Options/Classes/Particles/Collisions/CollisionsAbsorb.js +0 -14
  334. package/browser/Options/Classes/Particles/Collisions/CollisionsOverlap.js +0 -18
  335. package/browser/Options/Classes/Particles/Move/MoveTrail.js +0 -23
  336. package/browser/Options/Classes/Particles/Move/MoveTrailFill.js +0 -15
  337. package/browser/Options/Classes/Particles/Shadow.js +0 -35
  338. package/browser/Options/Interfaces/BackgroundMask/IBackgroundMask.js +0 -1
  339. package/browser/Options/Interfaces/BackgroundMask/IBackgroundMaskCover.js +0 -1
  340. package/browser/Options/Interfaces/Particles/Collisions/ICollisions.js +0 -1
  341. package/browser/Options/Interfaces/Particles/Collisions/ICollisionsAbsorb.js +0 -1
  342. package/browser/Options/Interfaces/Particles/Collisions/ICollisionsOverlap.js +0 -1
  343. package/browser/Options/Interfaces/Particles/IShadow.js +0 -1
  344. package/browser/Options/Interfaces/Particles/Move/IMoveTrail.js +0 -1
  345. package/browser/Options/Interfaces/Particles/Move/IMoveTrailFill.js +0 -1
  346. package/browser/init.js +0 -6
  347. package/cjs/Core/Interfaces/IRectSideResult.js +0 -2
  348. package/cjs/Core/Interfaces/ITrailFillData.js +0 -2
  349. package/cjs/Enums/Modes/CollisionMode.js +0 -9
  350. package/cjs/Options/Classes/BackgroundMask/BackgroundMask.js +0 -28
  351. package/cjs/Options/Classes/BackgroundMask/BackgroundMaskCover.js +0 -25
  352. package/cjs/Options/Classes/Particles/Collisions/Collisions.js +0 -37
  353. package/cjs/Options/Classes/Particles/Collisions/CollisionsAbsorb.js +0 -18
  354. package/cjs/Options/Classes/Particles/Collisions/CollisionsOverlap.js +0 -22
  355. package/cjs/Options/Classes/Particles/Move/MoveTrail.js +0 -27
  356. package/cjs/Options/Classes/Particles/Move/MoveTrailFill.js +0 -19
  357. package/cjs/Options/Classes/Particles/Shadow.js +0 -39
  358. package/cjs/Options/Interfaces/BackgroundMask/IBackgroundMask.js +0 -2
  359. package/cjs/Options/Interfaces/BackgroundMask/IBackgroundMaskCover.js +0 -2
  360. package/cjs/Options/Interfaces/Particles/Collisions/ICollisions.js +0 -2
  361. package/cjs/Options/Interfaces/Particles/Collisions/ICollisionsAbsorb.js +0 -2
  362. package/cjs/Options/Interfaces/Particles/Collisions/ICollisionsOverlap.js +0 -2
  363. package/cjs/Options/Interfaces/Particles/IShadow.js +0 -2
  364. package/cjs/Options/Interfaces/Particles/Move/IMoveTrail.js +0 -2
  365. package/cjs/Options/Interfaces/Particles/Move/IMoveTrailFill.js +0 -2
  366. package/cjs/Types/RangeType.js +0 -8
  367. package/cjs/Utils/NumberUtils.js +0 -177
  368. package/cjs/init.js +0 -9
  369. package/esm/Core/Interfaces/IRectSideResult.js +0 -1
  370. package/esm/Core/Interfaces/ITrailFillData.js +0 -1
  371. package/esm/Enums/Modes/CollisionMode.js +0 -6
  372. package/esm/Options/Classes/BackgroundMask/BackgroundMask.js +0 -24
  373. package/esm/Options/Classes/BackgroundMask/BackgroundMaskCover.js +0 -21
  374. package/esm/Options/Classes/Particles/Collisions/Collisions.js +0 -33
  375. package/esm/Options/Classes/Particles/Collisions/CollisionsAbsorb.js +0 -14
  376. package/esm/Options/Classes/Particles/Collisions/CollisionsOverlap.js +0 -18
  377. package/esm/Options/Classes/Particles/Move/MoveTrail.js +0 -23
  378. package/esm/Options/Classes/Particles/Move/MoveTrailFill.js +0 -15
  379. package/esm/Options/Classes/Particles/Shadow.js +0 -35
  380. package/esm/Options/Interfaces/BackgroundMask/IBackgroundMask.js +0 -1
  381. package/esm/Options/Interfaces/BackgroundMask/IBackgroundMaskCover.js +0 -1
  382. package/esm/Options/Interfaces/Particles/Collisions/ICollisions.js +0 -1
  383. package/esm/Options/Interfaces/Particles/Collisions/ICollisionsAbsorb.js +0 -1
  384. package/esm/Options/Interfaces/Particles/Collisions/ICollisionsOverlap.js +0 -1
  385. package/esm/Options/Interfaces/Particles/IShadow.js +0 -1
  386. package/esm/Options/Interfaces/Particles/Move/IMoveTrail.js +0 -1
  387. package/esm/Options/Interfaces/Particles/Move/IMoveTrailFill.js +0 -1
  388. package/esm/init.js +0 -6
  389. package/types/Core/Interfaces/IRectSideResult.d.ts +0 -5
  390. package/types/Core/Interfaces/ITrailFillData.d.ts +0 -6
  391. package/types/Enums/Modes/CollisionMode.d.ts +0 -5
  392. package/types/Options/Classes/BackgroundMask/BackgroundMask.d.ts +0 -11
  393. package/types/Options/Classes/BackgroundMask/BackgroundMaskCover.d.ts +0 -11
  394. package/types/Options/Classes/Particles/Collisions/Collisions.d.ts +0 -18
  395. package/types/Options/Classes/Particles/Collisions/CollisionsAbsorb.d.ts +0 -8
  396. package/types/Options/Classes/Particles/Collisions/CollisionsOverlap.d.ts +0 -9
  397. package/types/Options/Classes/Particles/Move/MoveTrail.d.ts +0 -11
  398. package/types/Options/Classes/Particles/Move/MoveTrailFill.d.ts +0 -9
  399. package/types/Options/Classes/Particles/Shadow.d.ts +0 -13
  400. package/types/Options/Interfaces/BackgroundMask/IBackgroundMask.d.ts +0 -8
  401. package/types/Options/Interfaces/BackgroundMask/IBackgroundMaskCover.d.ts +0 -6
  402. package/types/Options/Interfaces/Particles/Collisions/ICollisions.d.ts +0 -13
  403. package/types/Options/Interfaces/Particles/Collisions/ICollisionsAbsorb.d.ts +0 -3
  404. package/types/Options/Interfaces/Particles/Collisions/ICollisionsOverlap.d.ts +0 -4
  405. package/types/Options/Interfaces/Particles/IShadow.d.ts +0 -8
  406. package/types/Options/Interfaces/Particles/Move/IMoveTrail.d.ts +0 -6
  407. package/types/Options/Interfaces/Particles/Move/IMoveTrailFill.d.ts +0 -5
  408. package/types/init.d.ts +0 -2
  409. package/umd/Core/Interfaces/IRectSideResult.js +0 -12
  410. package/umd/Core/Interfaces/ITrailFillData.js +0 -12
  411. package/umd/Enums/Modes/CollisionMode.js +0 -19
  412. package/umd/Options/Classes/BackgroundMask/BackgroundMask.js +0 -38
  413. package/umd/Options/Classes/BackgroundMask/BackgroundMaskCover.js +0 -35
  414. package/umd/Options/Classes/Particles/Collisions/Collisions.js +0 -47
  415. package/umd/Options/Classes/Particles/Collisions/CollisionsAbsorb.js +0 -28
  416. package/umd/Options/Classes/Particles/Collisions/CollisionsOverlap.js +0 -32
  417. package/umd/Options/Classes/Particles/Move/MoveTrail.js +0 -37
  418. package/umd/Options/Classes/Particles/Move/MoveTrailFill.js +0 -29
  419. package/umd/Options/Classes/Particles/Shadow.js +0 -49
  420. package/umd/Options/Interfaces/BackgroundMask/IBackgroundMask.js +0 -12
  421. package/umd/Options/Interfaces/BackgroundMask/IBackgroundMaskCover.js +0 -12
  422. package/umd/Options/Interfaces/Particles/Collisions/ICollisions.js +0 -12
  423. package/umd/Options/Interfaces/Particles/Collisions/ICollisionsAbsorb.js +0 -12
  424. package/umd/Options/Interfaces/Particles/Collisions/ICollisionsOverlap.js +0 -12
  425. package/umd/Options/Interfaces/Particles/IShadow.js +0 -12
  426. package/umd/Options/Interfaces/Particles/Move/IMoveTrail.js +0 -12
  427. package/umd/Options/Interfaces/Particles/Move/IMoveTrailFill.js +0 -12
  428. /package/browser/{Types → Enums}/RangeType.js +0 -0
  429. /package/{esm/Types → cjs/Enums}/RangeType.js +0 -0
  430. /package/types/{Types → Enums}/RangeType.d.ts +0 -0
  431. /package/umd/{Types → Enums}/RangeType.js +0 -0
@@ -1,31 +1,29 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Container = void 0;
4
- const NumberUtils_js_1 = require("../Utils/NumberUtils.js");
5
- const Constants_js_1 = require("./Utils/Constants.js");
6
- const Utils_js_1 = require("../Utils/Utils.js");
7
- const Canvas_js_1 = require("./Canvas.js");
8
- const EventListeners_js_1 = require("./Utils/EventListeners.js");
9
- const EventType_js_1 = require("../Enums/Types/EventType.js");
10
- const Options_js_1 = require("../Options/Classes/Options.js");
11
- const Particles_js_1 = require("./Particles.js");
12
- const Retina_js_1 = require("./Retina.js");
13
- const OptionsUtils_js_1 = require("../Utils/OptionsUtils.js");
1
+ import { animate, cancelAnimation, getRangeValue } from "../Utils/MathUtils.js";
2
+ import { clickRadius, defaultFps, defaultFpsLimit, millisecondsToSeconds, minCoordinate, minFpsLimit, removeDeleteCount, removeMinIndex, touchEndLengthOffset, } from "./Utils/Constants.js";
3
+ import { Canvas } from "./Canvas.js";
4
+ import { EventListeners } from "./Utils/EventListeners.js";
5
+ import { EventType } from "../Enums/Types/EventType.js";
6
+ import { Options } from "../Options/Classes/Options.js";
7
+ import { Particles } from "./Particles.js";
8
+ import { Retina } from "./Retina.js";
9
+ import { getLogger } from "../Utils/LogUtils.js";
10
+ import { loadOptions } from "../Utils/OptionsUtils.js";
11
+ import { safeIntersectionObserver } from "../Utils/Utils.js";
14
12
  function guardCheck(container) {
15
- return container && !container.destroyed;
13
+ return !container.destroyed;
16
14
  }
17
- function initDelta(value, fpsLimit = Constants_js_1.defaultFps, smooth = false) {
15
+ function initDelta(value, fpsLimit = defaultFps, smooth = false) {
18
16
  return {
19
17
  value,
20
- factor: smooth ? Constants_js_1.defaultFps / fpsLimit : (Constants_js_1.defaultFps * value) / Constants_js_1.millisecondsToSeconds,
18
+ factor: smooth ? defaultFps / fpsLimit : (defaultFps * value) / millisecondsToSeconds,
21
19
  };
22
20
  }
23
21
  function loadContainerOptions(engine, container, ...sourceOptionsArr) {
24
- const options = new Options_js_1.Options(engine, container);
25
- (0, OptionsUtils_js_1.loadOptions)(options, ...sourceOptionsArr);
22
+ const options = new Options(engine, container);
23
+ loadOptions(options, ...sourceOptionsArr);
26
24
  return options;
27
25
  }
28
- class Container {
26
+ export class Container {
29
27
  constructor(engine, id, sourceOptions) {
30
28
  this._intersectionManager = entries => {
31
29
  if (!guardCheck(this) || !this.actualOptions.pauseOnOutsideViewport) {
@@ -36,7 +34,7 @@ class Container {
36
34
  continue;
37
35
  }
38
36
  if (entry.isIntersecting) {
39
- void this.play();
37
+ this.play();
40
38
  }
41
39
  else {
42
40
  this.pause();
@@ -47,7 +45,7 @@ class Container {
47
45
  try {
48
46
  if (!this._smooth &&
49
47
  this._lastFrameTime !== undefined &&
50
- timestamp < this._lastFrameTime + Constants_js_1.millisecondsToSeconds / this.fpsLimit) {
48
+ timestamp < this._lastFrameTime + millisecondsToSeconds / this.fpsLimit) {
51
49
  this.draw(false);
52
50
  return;
53
51
  }
@@ -55,11 +53,11 @@ class Container {
55
53
  const delta = initDelta(timestamp - this._lastFrameTime, this.fpsLimit, this._smooth);
56
54
  this.addLifeTime(delta.value);
57
55
  this._lastFrameTime = timestamp;
58
- if (delta.value > Constants_js_1.millisecondsToSeconds) {
56
+ if (delta.value > millisecondsToSeconds) {
59
57
  this.draw(false);
60
58
  return;
61
59
  }
62
- this.particles.draw(delta);
60
+ this.canvas.drawParticles(delta);
63
61
  if (!this.alive()) {
64
62
  this.destroy();
65
63
  return;
@@ -69,12 +67,13 @@ class Container {
69
67
  }
70
68
  }
71
69
  catch (e) {
72
- (0, Utils_js_1.getLogger)().error(`${Constants_js_1.errorPrefix} in animation loop`, e);
70
+ getLogger().error("error in animation loop", e);
73
71
  }
74
72
  };
75
73
  this._engine = engine;
76
74
  this.id = Symbol(id);
77
75
  this.fpsLimit = 120;
76
+ this.hdr = false;
78
77
  this._smooth = false;
79
78
  this._delay = 0;
80
79
  this._duration = 0;
@@ -89,9 +88,9 @@ class Container {
89
88
  this._clickHandlers = new Map();
90
89
  this._sourceOptions = sourceOptions;
91
90
  this._initialSourceOptions = sourceOptions;
92
- this.retina = new Retina_js_1.Retina(this);
93
- this.canvas = new Canvas_js_1.Canvas(this, this._engine);
94
- this.particles = new Particles_js_1.Particles(this._engine, this);
91
+ this.retina = new Retina(this);
92
+ this.canvas = new Canvas(this, this._engine);
93
+ this.particles = new Particles(this._engine, this);
95
94
  this.pathGenerators = new Map();
96
95
  this.interactivity = {
97
96
  mouse: {
@@ -104,9 +103,11 @@ class Container {
104
103
  this.shapeDrawers = new Map();
105
104
  this._options = loadContainerOptions(this._engine, this);
106
105
  this.actualOptions = loadContainerOptions(this._engine, this);
107
- this._eventListeners = new EventListeners_js_1.EventListeners(this);
108
- this._intersectionObserver = (0, Utils_js_1.safeIntersectionObserver)(entries => this._intersectionManager(entries));
109
- this._engine.dispatchEvent(EventType_js_1.EventType.containerBuilt, { container: this });
106
+ this._eventListeners = new EventListeners(this);
107
+ this._intersectionObserver = safeIntersectionObserver(entries => {
108
+ this._intersectionManager(entries);
109
+ });
110
+ this._engine.dispatchEvent(EventType.containerBuilt, { container: this });
110
111
  }
111
112
  get animationStatus() {
112
113
  return !this._paused && !this.pageHidden && guardCheck(this);
@@ -142,7 +143,7 @@ class Container {
142
143
  x: mouseEvent.offsetX || mouseEvent.clientX,
143
144
  y: mouseEvent.offsetY || mouseEvent.clientY,
144
145
  };
145
- clickOrTouchHandler(e, pos, Constants_js_1.clickRadius);
146
+ clickOrTouchHandler(e, pos, clickRadius);
146
147
  }, touchStartHandler = () => {
147
148
  if (!guardCheck(this)) {
148
149
  return;
@@ -159,17 +160,13 @@ class Container {
159
160
  return;
160
161
  }
161
162
  if (touched && !touchMoved) {
162
- const touchEvent = e;
163
- let lastTouch = touchEvent.touches[touchEvent.touches.length - Constants_js_1.touchEndLengthOffset];
163
+ const touchEvent = e, lastTouch = touchEvent.touches[touchEvent.touches.length - touchEndLengthOffset];
164
164
  if (!lastTouch) {
165
- lastTouch = touchEvent.changedTouches[touchEvent.changedTouches.length - Constants_js_1.touchEndLengthOffset];
166
- if (!lastTouch) {
167
- return;
168
- }
165
+ return;
169
166
  }
170
167
  const element = this.canvas.element, canvasRect = element ? element.getBoundingClientRect() : undefined, pos = {
171
- x: lastTouch.clientX - (canvasRect ? canvasRect.left : Constants_js_1.minCoordinate),
172
- y: lastTouch.clientY - (canvasRect ? canvasRect.top : Constants_js_1.minCoordinate),
168
+ x: lastTouch.clientX - (canvasRect ? canvasRect.left : minCoordinate),
169
+ y: lastTouch.clientY - (canvasRect ? canvasRect.top : minCoordinate),
173
170
  };
174
171
  clickOrTouchHandler(e, pos, Math.max(lastTouch.radiusX, lastTouch.radiusY));
175
172
  }
@@ -238,11 +235,11 @@ class Container {
238
235
  this.destroyed = true;
239
236
  if (remove) {
240
237
  const mainArr = this._engine.items, idx = mainArr.findIndex(t => t === this);
241
- if (idx >= Constants_js_1.removeMinIndex) {
242
- mainArr.splice(idx, Constants_js_1.removeDeleteCount);
238
+ if (idx >= removeMinIndex) {
239
+ mainArr.splice(idx, removeDeleteCount);
243
240
  }
244
241
  }
245
- this._engine.dispatchEvent(EventType_js_1.EventType.containerDestroyed, { container: this });
242
+ this._engine.dispatchEvent(EventType.containerDestroyed, { container: this });
246
243
  }
247
244
  draw(force) {
248
245
  if (!guardCheck(this)) {
@@ -256,7 +253,9 @@ class Container {
256
253
  }
257
254
  this._nextFrame(timestamp);
258
255
  };
259
- this._drawAnimationFrame = (0, NumberUtils_js_1.animate)(timestamp => frame(timestamp));
256
+ this._drawAnimationFrame = animate(timestamp => {
257
+ frame(timestamp);
258
+ });
260
259
  }
261
260
  async export(type, options = {}) {
262
261
  for (const plugin of this.plugins.values()) {
@@ -269,7 +268,8 @@ class Container {
269
268
  }
270
269
  return res.blob;
271
270
  }
272
- (0, Utils_js_1.getLogger)().error(`${Constants_js_1.errorPrefix} - Export plugin with type ${type} not found`);
271
+ getLogger().error(`Export plugin with type ${type} not found`);
272
+ return undefined;
273
273
  }
274
274
  handleClickMode(mode) {
275
275
  if (!guardCheck(this)) {
@@ -306,16 +306,17 @@ class Container {
306
306
  this.plugins.set(id, plugin);
307
307
  }
308
308
  this.retina.init();
309
- await this.canvas.init();
309
+ this.canvas.init();
310
310
  this.updateActualOptions();
311
311
  this.canvas.initBackground();
312
312
  this.canvas.resize();
313
- const { zLayers, duration, delay, fpsLimit, smooth } = this.actualOptions;
313
+ const { delay, duration, fpsLimit, hdr, smooth, zLayers } = this.actualOptions;
314
+ this.hdr = hdr;
314
315
  this.zLayers = zLayers;
315
- this._duration = (0, NumberUtils_js_1.getRangeValue)(duration) * Constants_js_1.millisecondsToSeconds;
316
- this._delay = (0, NumberUtils_js_1.getRangeValue)(delay) * Constants_js_1.millisecondsToSeconds;
316
+ this._duration = getRangeValue(duration) * millisecondsToSeconds;
317
+ this._delay = getRangeValue(delay) * millisecondsToSeconds;
317
318
  this._lifeTime = 0;
318
- this.fpsLimit = fpsLimit > Constants_js_1.minFpsLimit ? fpsLimit : Constants_js_1.defaultFpsLimit;
319
+ this.fpsLimit = fpsLimit > minFpsLimit ? fpsLimit : defaultFpsLimit;
319
320
  this._smooth = smooth;
320
321
  for (const drawer of this.effectDrawers.values()) {
321
322
  await drawer.init?.(this);
@@ -326,13 +327,13 @@ class Container {
326
327
  for (const plugin of this.plugins.values()) {
327
328
  await plugin.init?.();
328
329
  }
329
- this._engine.dispatchEvent(EventType_js_1.EventType.containerInit, { container: this });
330
+ this._engine.dispatchEvent(EventType.containerInit, { container: this });
330
331
  await this.particles.init();
331
332
  this.particles.setDensity();
332
333
  for (const plugin of this.plugins.values()) {
333
334
  plugin.particlesSetup?.();
334
335
  }
335
- this._engine.dispatchEvent(EventType_js_1.EventType.particlesSetup, { container: this });
336
+ this._engine.dispatchEvent(EventType.particlesSetup, { container: this });
336
337
  }
337
338
  async loadTheme(name) {
338
339
  if (!guardCheck(this)) {
@@ -346,7 +347,7 @@ class Container {
346
347
  return;
347
348
  }
348
349
  if (this._drawAnimationFrame !== undefined) {
349
- (0, NumberUtils_js_1.cancelAnimation)(this._drawAnimationFrame);
350
+ cancelAnimation(this._drawAnimationFrame);
350
351
  delete this._drawAnimationFrame;
351
352
  }
352
353
  if (this._paused) {
@@ -358,7 +359,7 @@ class Container {
358
359
  if (!this.pageHidden) {
359
360
  this._paused = true;
360
361
  }
361
- this._engine.dispatchEvent(EventType_js_1.EventType.containerPaused, { container: this });
362
+ this._engine.dispatchEvent(EventType.containerPaused, { container: this });
362
363
  }
363
364
  play(force) {
364
365
  if (!guardCheck(this)) {
@@ -379,7 +380,7 @@ class Container {
379
380
  }
380
381
  }
381
382
  }
382
- this._engine.dispatchEvent(EventType_js_1.EventType.containerPlay, { container: this });
383
+ this._engine.dispatchEvent(EventType.containerPlay, { container: this });
383
384
  this.draw(needsUpdate ?? false);
384
385
  }
385
386
  async refresh() {
@@ -414,7 +415,7 @@ class Container {
414
415
  for (const plugin of this.plugins.values()) {
415
416
  await plugin.start?.();
416
417
  }
417
- this._engine.dispatchEvent(EventType_js_1.EventType.containerStarted, { container: this });
418
+ this._engine.dispatchEvent(EventType.containerStarted, { container: this });
418
419
  this.play();
419
420
  resolve();
420
421
  };
@@ -445,7 +446,7 @@ class Container {
445
446
  this.plugins.delete(key);
446
447
  }
447
448
  this._sourceOptions = this._options;
448
- this._engine.dispatchEvent(EventType_js_1.EventType.containerStopped, { container: this });
449
+ this._engine.dispatchEvent(EventType.containerStopped, { container: this });
449
450
  }
450
451
  updateActualOptions() {
451
452
  this.actualOptions.responsive = [];
@@ -458,4 +459,3 @@ class Container {
458
459
  return true;
459
460
  }
460
461
  }
461
- exports.Container = Container;
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Engine = void 0;
4
- const Constants_js_1 = require("./Utils/Constants.js");
5
- const Utils_js_1 = require("../Utils/Utils.js");
6
- const Container_js_1 = require("./Container.js");
7
- const EventDispatcher_js_1 = require("../Utils/EventDispatcher.js");
8
- const EventType_js_1 = require("../Enums/Types/EventType.js");
9
- const NumberUtils_js_1 = require("../Utils/NumberUtils.js");
1
+ import { canvasFirstIndex, canvasTag, generatedAttribute, generatedFalse, generatedTrue, loadMinIndex, loadRandomFactor, none, one, removeDeleteCount, } from "./Utils/Constants.js";
2
+ import { itemFromSingleOrMultiple, safeDocument } from "../Utils/Utils.js";
3
+ import { EventDispatcher } from "../Utils/EventDispatcher.js";
4
+ import { EventType } from "../Enums/Types/EventType.js";
5
+ import { getLogger } from "../Utils/LogUtils.js";
6
+ import { getRandom } from "../Utils/MathUtils.js";
10
7
  async function getItemsFromInitializer(container, map, initializers, force = false) {
11
8
  let res = map.get(container);
12
9
  if (!res || force) {
@@ -16,7 +13,7 @@ async function getItemsFromInitializer(container, map, initializers, force = fal
16
13
  return res;
17
14
  }
18
15
  async function getDataFromUrl(data) {
19
- const url = (0, Utils_js_1.itemFromSingleOrMultiple)(data.url, data.index);
16
+ const url = itemFromSingleOrMultiple(data.url, data.index);
20
17
  if (!url) {
21
18
  return data.fallback;
22
19
  }
@@ -24,26 +21,24 @@ async function getDataFromUrl(data) {
24
21
  if (response.ok) {
25
22
  return (await response.json());
26
23
  }
27
- (0, Utils_js_1.getLogger)().error(`${Constants_js_1.errorPrefix} ${response.status} while retrieving config file`);
24
+ getLogger().error(`${response.status.toString()} while retrieving config file`);
28
25
  return data.fallback;
29
26
  }
30
27
  const getCanvasFromContainer = (domContainer) => {
31
28
  let canvasEl;
32
- if (domContainer instanceof HTMLCanvasElement || domContainer.tagName.toLowerCase() === Constants_js_1.canvasTag) {
29
+ if (domContainer instanceof HTMLCanvasElement || domContainer.tagName.toLowerCase() === canvasTag) {
33
30
  canvasEl = domContainer;
34
- if (!canvasEl.dataset[Constants_js_1.generatedAttribute]) {
35
- canvasEl.dataset[Constants_js_1.generatedAttribute] = Constants_js_1.generatedFalse;
36
- }
31
+ canvasEl.dataset[generatedAttribute] ??= generatedFalse;
37
32
  }
38
33
  else {
39
- const existingCanvases = domContainer.getElementsByTagName(Constants_js_1.canvasTag);
40
- if (existingCanvases.length) {
41
- canvasEl = existingCanvases[Constants_js_1.canvasFirstIndex];
42
- canvasEl.dataset[Constants_js_1.generatedAttribute] = Constants_js_1.generatedFalse;
34
+ const existingCanvases = domContainer.getElementsByTagName(canvasTag), foundCanvas = existingCanvases[canvasFirstIndex];
35
+ if (foundCanvas) {
36
+ canvasEl = foundCanvas;
37
+ canvasEl.dataset[generatedAttribute] = generatedFalse;
43
38
  }
44
39
  else {
45
- canvasEl = document.createElement(Constants_js_1.canvasTag);
46
- canvasEl.dataset[Constants_js_1.generatedAttribute] = Constants_js_1.generatedTrue;
40
+ canvasEl = safeDocument().createElement(canvasTag);
41
+ canvasEl.dataset[generatedAttribute] = generatedTrue;
47
42
  domContainer.appendChild(canvasEl);
48
43
  }
49
44
  }
@@ -56,22 +51,23 @@ const getCanvasFromContainer = (domContainer) => {
56
51
  }
57
52
  return canvasEl;
58
53
  }, getDomContainer = (id, source) => {
59
- let domContainer = source ?? document.getElementById(id);
54
+ let domContainer = source ?? safeDocument().getElementById(id);
60
55
  if (domContainer) {
61
56
  return domContainer;
62
57
  }
63
- domContainer = document.createElement("div");
58
+ domContainer = safeDocument().createElement("div");
64
59
  domContainer.id = id;
65
- domContainer.dataset[Constants_js_1.generatedAttribute] = Constants_js_1.generatedTrue;
66
- document.body.append(domContainer);
60
+ domContainer.dataset[generatedAttribute] = generatedTrue;
61
+ safeDocument().body.append(domContainer);
67
62
  return domContainer;
68
63
  };
69
- class Engine {
64
+ export class Engine {
70
65
  constructor() {
71
66
  this._configs = new Map();
72
67
  this._domArray = [];
73
- this._eventDispatcher = new EventDispatcher_js_1.EventDispatcher();
68
+ this._eventDispatcher = new EventDispatcher();
74
69
  this._initialized = false;
70
+ this._loadPromises = new Set();
75
71
  this.plugins = [];
76
72
  this.colorManagers = new Map();
77
73
  this.easingFunctions = new Map();
@@ -99,73 +95,65 @@ class Engine {
99
95
  return this._domArray;
100
96
  }
101
97
  get version() {
102
- return "3.9.1";
98
+ return "4.0.0-alpha.1";
103
99
  }
104
- async addColorManager(manager, refresh = true) {
100
+ addColorManager(manager) {
105
101
  this.colorManagers.set(manager.key, manager);
106
- await this.refresh(refresh);
107
102
  }
108
103
  addConfig(config) {
109
104
  const key = config.key ?? config.name ?? "default";
110
105
  this._configs.set(key, config);
111
- this._eventDispatcher.dispatchEvent(EventType_js_1.EventType.configAdded, { data: { name: key, config } });
106
+ this._eventDispatcher.dispatchEvent(EventType.configAdded, { data: { name: key, config } });
112
107
  }
113
- async addEasing(name, easing, refresh = true) {
114
- if (this.getEasing(name)) {
108
+ addEasing(name, easing) {
109
+ if (this.easingFunctions.get(name)) {
115
110
  return;
116
111
  }
117
112
  this.easingFunctions.set(name, easing);
118
- await this.refresh(refresh);
119
113
  }
120
- async addEffect(effect, drawer, refresh = true) {
121
- (0, Utils_js_1.executeOnSingleOrMultiple)(effect, type => {
122
- if (!this.getEffectDrawer(type)) {
123
- this.effectDrawers.set(type, drawer);
124
- }
125
- });
126
- await this.refresh(refresh);
114
+ addEffect(effect, drawer) {
115
+ if (this.getEffectDrawer(effect)) {
116
+ return;
117
+ }
118
+ this.effectDrawers.set(effect, drawer);
127
119
  }
128
120
  addEventListener(type, listener) {
129
121
  this._eventDispatcher.addEventListener(type, listener);
130
122
  }
131
- async addInteractor(name, interactorInitializer, refresh = true) {
123
+ addInteractor(name, interactorInitializer) {
132
124
  this._initializers.interactors.set(name, interactorInitializer);
133
- await this.refresh(refresh);
134
125
  }
135
- async addMover(name, moverInitializer, refresh = true) {
126
+ addMover(name, moverInitializer) {
136
127
  this._initializers.movers.set(name, moverInitializer);
137
- await this.refresh(refresh);
138
128
  }
139
- async addParticleUpdater(name, updaterInitializer, refresh = true) {
129
+ addParticleUpdater(name, updaterInitializer) {
140
130
  this._initializers.updaters.set(name, updaterInitializer);
141
- await this.refresh(refresh);
142
131
  }
143
- async addPathGenerator(name, generator, refresh = true) {
144
- if (!this.getPathGenerator(name)) {
145
- this.pathGenerators.set(name, generator);
132
+ addPathGenerator(name, generator) {
133
+ if (this.getPathGenerator(name)) {
134
+ return;
146
135
  }
147
- await this.refresh(refresh);
136
+ this.pathGenerators.set(name, generator);
148
137
  }
149
- async addPlugin(plugin, refresh = true) {
150
- if (!this.getPlugin(plugin.id)) {
151
- this.plugins.push(plugin);
138
+ addPlugin(plugin) {
139
+ if (this.getPlugin(plugin.id)) {
140
+ return;
152
141
  }
153
- await this.refresh(refresh);
142
+ this.plugins.push(plugin);
154
143
  }
155
- async addPreset(preset, options, override = false, refresh = true) {
156
- if (override || !this.getPreset(preset)) {
157
- this.presets.set(preset, options);
144
+ addPreset(preset, options, override = false) {
145
+ if (!(override || !this.getPreset(preset))) {
146
+ return;
158
147
  }
159
- await this.refresh(refresh);
148
+ this.presets.set(preset, options);
160
149
  }
161
- async addShape(drawer, refresh = true) {
150
+ addShape(drawer) {
162
151
  for (const validType of drawer.validTypes) {
163
152
  if (this.getShapeDrawer(validType)) {
164
153
  continue;
165
154
  }
166
155
  this.shapeDrawers.set(validType, drawer);
167
156
  }
168
- await this.refresh(refresh);
169
157
  }
170
158
  checkVersion(pluginVersion) {
171
159
  if (this.version === pluginVersion) {
@@ -229,24 +217,31 @@ class Engine {
229
217
  async getUpdaters(container, force = false) {
230
218
  return getItemsFromInitializer(container, this.updaters, this._initializers.updaters, force);
231
219
  }
232
- init() {
220
+ async init() {
233
221
  if (this._initialized) {
234
222
  return;
235
223
  }
224
+ for (const loadPromise of this._loadPromises) {
225
+ await loadPromise(this);
226
+ }
227
+ this._loadPromises.clear();
236
228
  this._initialized = true;
237
229
  }
238
230
  item(index) {
239
231
  const { items } = this, item = items[index];
240
- if (!item || item.destroyed) {
241
- items.splice(index, Constants_js_1.removeDeleteCount);
232
+ if (item?.destroyed) {
233
+ items.splice(index, removeDeleteCount);
242
234
  return;
243
235
  }
244
236
  return item;
245
237
  }
246
238
  async load(params) {
247
- const id = params.id ?? params.element?.id ?? `tsparticles${Math.floor((0, NumberUtils_js_1.getRandom)() * Constants_js_1.loadRandomFactor)}`, { 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_js_1.Container(this, id, currentOptions);
248
- if (oldIndex >= Constants_js_1.loadMinIndex) {
249
- const old = this.item(oldIndex), deleteCount = old ? Constants_js_1.one : Constants_js_1.none;
239
+ await this.init();
240
+ const { Container } = await import("./Container.js"), id = params.id ??
241
+ params.element?.id ??
242
+ `tsparticles${Math.floor(getRandom() * loadRandomFactor).toString()}`, { index, url } = params, options = url ? await getDataFromUrl({ fallback: params.options, url, index }) : params.options, currentOptions = itemFromSingleOrMultiple(options, index), { items } = this, oldIndex = items.findIndex(v => v.id.description === id), newItem = new Container(this, id, currentOptions);
243
+ if (oldIndex >= loadMinIndex) {
244
+ const old = this.item(oldIndex), deleteCount = old ? one : none;
250
245
  if (old && !old.destroyed) {
251
246
  old.destroy(false);
252
247
  }
@@ -261,7 +256,9 @@ class Engine {
261
256
  return newItem;
262
257
  }
263
258
  loadOptions(options, sourceOptions) {
264
- this.plugins.forEach(plugin => plugin.loadOptions?.(options, sourceOptions));
259
+ this.plugins.forEach(plugin => {
260
+ plugin.loadOptions(options, sourceOptions);
261
+ });
265
262
  }
266
263
  loadParticlesOptions(container, options, ...sourceOptions) {
267
264
  const updaters = this.updaters.get(container);
@@ -276,15 +273,24 @@ class Engine {
276
273
  }
277
274
  await Promise.all(this.items.map(t => t.refresh()));
278
275
  }
276
+ register(...loadPromises) {
277
+ if (this._initialized) {
278
+ throw new Error(`Register plugins can only be done before calling tsParticles.load()`);
279
+ }
280
+ for (const loadPromise of loadPromises) {
281
+ this._loadPromises.add(loadPromise);
282
+ }
283
+ }
279
284
  removeEventListener(type, listener) {
280
285
  this._eventDispatcher.removeEventListener(type, listener);
281
286
  }
282
287
  setOnClickHandler(callback) {
283
288
  const { items } = this;
284
289
  if (!items.length) {
285
- throw new Error(`${Constants_js_1.errorPrefix} can only set click handlers after calling tsParticles.load()`);
290
+ throw new Error("Click handlers can only be set after calling tsParticles.load()");
286
291
  }
287
- items.forEach(item => item.addClickHandler(callback));
292
+ items.forEach(item => {
293
+ item.addClickHandler(callback);
294
+ });
288
295
  }
289
296
  }
290
- exports.Engine = Engine;
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};