bard-legends-framework 0.10.9 → 0.12.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 (288) hide show
  1. package/dist/actions-performance.test.d.ts +1 -0
  2. package/dist/actions-performance.test.js +83 -0
  3. package/dist/game-entities/controller/controller.d.ts +2 -3
  4. package/dist/game-entities/controller/controller.js +9 -8
  5. package/dist/game-entities/controller/controller.test.js +2 -2
  6. package/dist/game-entities/entity/entity.d.ts +11 -9
  7. package/dist/game-entities/entity/entity.js +20 -16
  8. package/dist/game-entities/entity/entity.test.js +116 -147
  9. package/dist/game-entities/entity/helpers/entity-store.helper.d.ts +6 -9
  10. package/dist/game-entities/entity/helpers/entity-store.helper.js +22 -57
  11. package/dist/game-entities/entity/helpers/entity-store.helper.test.d.ts +1 -0
  12. package/dist/game-entities/entity/helpers/entity-store.helper.test.js +136 -0
  13. package/dist/game-entities/entity/helpers/entity-views.helper.d.ts +7 -7
  14. package/dist/game-entities/entity/helpers/entity-views.helper.js +28 -23
  15. package/dist/game-entities/entity/singleton-entity.d.ts +3 -3
  16. package/dist/game-entities/entity/singleton-entity.js +1 -1
  17. package/dist/game-entities/entity/singleton-entity.test.js +9 -31
  18. package/dist/game-entities/hard-reset.d.ts +5 -0
  19. package/dist/game-entities/hard-reset.js +14 -0
  20. package/dist/game-entities/index.d.ts +1 -3
  21. package/dist/game-entities/index.js +3 -7
  22. package/dist/game-entities/scene/scene.d.ts +15 -15
  23. package/dist/game-entities/scene/scene.js +61 -60
  24. package/dist/game-entities/scene/scene.test.js +97 -67
  25. package/dist/game-entities/service/service.d.ts +1 -4
  26. package/dist/game-entities/service/service.js +15 -14
  27. package/dist/game-entities/service/service.test.js +33 -38
  28. package/dist/game-entities/unit-test.helper.d.ts +5 -0
  29. package/dist/game-entities/unit-test.helper.js +14 -0
  30. package/dist/game-entities/update-cycle.d.ts +10 -9
  31. package/dist/game-entities/update-cycle.js +34 -23
  32. package/dist/game-entities/view/view.d.ts +10 -11
  33. package/dist/game-entities/view/view.js +17 -35
  34. package/dist/game-entities/view/view.test.js +73 -250
  35. package/dist/physics/entity-types/immovable-physics-entity.d.ts +2 -4
  36. package/dist/physics/entity-types/immovable-physics-entity.js +4 -6
  37. package/dist/physics/entity-types/movable-entity.d.ts +1 -1
  38. package/dist/physics/entity-types/movable-entity.js +6 -6
  39. package/dist/physics/entity-types/movable-physics-entity.d.ts +10 -11
  40. package/dist/physics/entity-types/movable-physics-entity.js +31 -32
  41. package/dist/physics/entity-types/physics-entity.d.ts +12 -15
  42. package/dist/physics/entity-types/physics-entity.js +30 -28
  43. package/dist/physics/interfaces.d.ts +6 -6
  44. package/dist/physics/interfaces.js +4 -4
  45. package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics-internal.controller.d.ts +16 -16
  46. package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics-internal.controller.js +22 -22
  47. package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics.controller.d.ts +20 -20
  48. package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics.controller.js +30 -30
  49. package/dist/physics/module//342/232/234/357/270/217gateways/dtos/requests.dto.d.ts +3 -3
  50. package/dist/physics/module//342/232/234/357/270/217gateways/physics-internal.gateway.d.ts +10 -10
  51. package/dist/physics/module//342/232/234/357/270/217gateways/physics-internal.gateway.js +16 -16
  52. package/dist/physics/module//342/232/234/357/270/217gateways/physics.gateway.d.ts +11 -11
  53. package/dist/physics/module//342/232/234/357/270/217gateways/physics.gateway.js +18 -18
  54. package/dist/physics/module//360/237/223/220services/collision/collisions.service.d.ts +5 -5
  55. package/dist/physics/module//360/237/223/220services/collision/collisions.service.js +17 -17
  56. package/dist/physics/module//360/237/223/220services/collision/hit-test.service.d.ts +4 -4
  57. package/dist/physics/module//360/237/223/220services/collision/hit-test.service.js +11 -11
  58. package/dist/physics/module//360/237/223/220services/collision/physics-body-group.service.d.ts +2 -2
  59. package/dist/physics/module//360/237/223/220services/collision/physics-body-group.service.js +4 -4
  60. package/dist/physics/module//360/237/223/220services/creation/border.service.d.ts +2 -2
  61. package/dist/physics/module//360/237/223/220services/creation/border.service.js +9 -9
  62. package/dist/physics/module//360/237/223/220services/creation/materials.service.d.ts +7 -7
  63. package/dist/physics/module//360/237/223/220services/creation/materials.service.js +17 -17
  64. package/dist/physics/module//360/237/223/220services/creation/physics-world.service.d.ts +11 -11
  65. package/dist/physics/module//360/237/223/220services/creation/physics-world.service.js +28 -27
  66. package/dist/physics/module//360/237/223/220services/creation/shape-creation.service.d.ts +4 -4
  67. package/dist/physics/module//360/237/223/220services/creation/shape-creation.service.js +13 -13
  68. package/dist/physics/module//360/237/223/220services/impact/eliptic-explosion.service.d.ts +9 -9
  69. package/dist/physics/module//360/237/223/220services/impact/eliptic-explosion.service.js +19 -19
  70. package/dist/physics/module//360/237/223/220services/impact/explosion.service.d.ts +9 -9
  71. package/dist/physics/module//360/237/223/220services/impact/explosion.service.js +20 -20
  72. package/dist/physics/module//360/237/223/220services/impact/ray-cast-hit-converter.d.ts +1 -1
  73. package/dist/physics/module//360/237/223/220services/impact/ray-cast-hit-converter.js +4 -4
  74. package/dist/physics/module//360/237/223/220services/path-finding/availability-grid-cache.service.d.ts +2 -2
  75. package/dist/physics/module//360/237/223/220services/path-finding/availability-grid-cache.service.js +3 -3
  76. package/dist/physics/module//360/237/223/220services/path-finding/availability-grid.service.d.ts +5 -5
  77. package/dist/physics/module//360/237/223/220services/path-finding/availability-grid.service.js +13 -13
  78. package/dist/physics/module//360/237/223/220services/path-finding/path-finder.service.d.ts +4 -4
  79. package/dist/physics/module//360/237/223/220services/path-finding/path-finder.service.js +13 -13
  80. package/dist/physics/module//360/237/223/220services/query/physics-query.service.d.ts +4 -4
  81. package/dist/physics/module//360/237/223/220services/query/physics-query.service.js +4 -4
  82. package/dist/physics/module//360/237/223/220services/ray-casting/ray-casting.service.d.ts +1 -4
  83. package/dist/physics/module//360/237/223/220services/ray-casting/ray-casting.service.js +7 -15
  84. package/dist/physics/module//360/237/223/220services/test-visuals/test-visuals.service.d.ts +9 -9
  85. package/dist/physics/module//360/237/223/220services/test-visuals/test-visuals.service.js +60 -49
  86. package/dist/physics/module//360/237/247/212entities/border.entity.d.ts +1 -1
  87. package/dist/physics/module//360/237/247/212entities/border.entity.js +3 -3
  88. package/dist/physics/module//360/237/247/212entities/physics-world.entity.js +2 -2
  89. package/dist/pixi/components/display-object-array.d.ts +5 -5
  90. package/dist/pixi/components/display-object-array.js +14 -14
  91. package/dist/pixi/components/helpers/smooth-scroller.d.ts +7 -7
  92. package/dist/pixi/components/helpers/smooth-scroller.js +23 -23
  93. package/dist/pixi/components/helpers/smooth-scroller.test.js +14 -14
  94. package/dist/pixi/components/menu/menu-entity.d.ts +14 -0
  95. package/dist/pixi/components/menu/menu-entity.js +48 -0
  96. package/dist/pixi/components/menu/menu.ui.d.ts +23 -0
  97. package/dist/pixi/components/menu/menu.ui.js +97 -0
  98. package/dist/pixi/components/mouse-wheel-listener.ui.d.ts +4 -3
  99. package/dist/pixi/components/mouse-wheel-listener.ui.js +15 -14
  100. package/dist/pixi/components/scroll-area.ui.d.ts +1 -1
  101. package/dist/pixi/components/scroll-area.ui.js +9 -9
  102. package/dist/pixi/components/scroll-mask.ui.d.ts +9 -8
  103. package/dist/pixi/components/scroll-mask.ui.js +25 -24
  104. package/dist/pixi/display-object/container-attributes.d.ts +24 -26
  105. package/dist/pixi/display-object/container-attributes.js +27 -28
  106. package/dist/pixi/display-object/container.d.ts +3 -6
  107. package/dist/pixi/display-object/container.js +2 -12
  108. package/dist/pixi/display-object/filters/base-filters/blur.filter.d.ts +9 -9
  109. package/dist/pixi/display-object/filters/base-filters/blur.filter.js +25 -25
  110. package/dist/pixi/display-object/filters/base-filters/expand-with-color.filter.d.ts +7 -7
  111. package/dist/pixi/display-object/filters/base-filters/expand-with-color.filter.js +17 -17
  112. package/dist/pixi/display-object/filters/composite-filters/glow-filter.d.ts +6 -6
  113. package/dist/pixi/display-object/filters/composite-filters/glow-filter.js +10 -11
  114. package/dist/pixi/display-object/filters/helpers/gaussian-values.helper.d.ts +2 -2
  115. package/dist/pixi/display-object/filters/helpers/gaussian-values.helper.js +5 -5
  116. package/dist/pixi/display-object/filters/templates/checking-neighbors.template.d.ts +5 -5
  117. package/dist/pixi/display-object/filters/templates/checking-neighbors.template.js +8 -8
  118. package/dist/pixi/display-object/filters/templates/plane.template.d.ts +5 -5
  119. package/dist/pixi/display-object/filters/templates/plane.template.js +7 -7
  120. package/dist/pixi/display-object/filters.d.ts +7 -7
  121. package/dist/pixi/display-object/filters.js +34 -34
  122. package/dist/pixi/display-object/index.d.ts +1 -1
  123. package/dist/pixi/display-object/objects/graphics/graphics.d.ts +9 -9
  124. package/dist/pixi/display-object/objects/graphics/graphics.js +25 -25
  125. package/dist/pixi/display-object/objects/placeholder.d.ts +1 -1
  126. package/dist/pixi/display-object/objects/placeholder.js +7 -7
  127. package/dist/pixi/display-object/objects/sprite/glow-sprite-generator.d.ts +9 -9
  128. package/dist/pixi/display-object/objects/sprite/glow-sprite-generator.js +29 -26
  129. package/dist/pixi/display-object/objects/sprite/sprite.d.ts +10 -9
  130. package/dist/pixi/display-object/objects/sprite/sprite.js +62 -53
  131. package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/pixi-text-style-converter.d.ts +4 -3
  132. package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.d.ts +6 -6
  133. package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.js +16 -16
  134. package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.test.js +28 -28
  135. package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/consistent-space-text-wrapper.d.ts +1 -1
  136. package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/consistent-space-text-wrapper.js +3 -3
  137. package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/rich-text-typewriter.d.ts +17 -17
  138. package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/rich-text-typewriter.js +62 -62
  139. package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/rich-text-typewriter.test.js +2 -2
  140. package/dist/pixi/display-object/objects/text/helpers/process-steps/3-data-out-converter/rich-text-data-out-converter.d.ts +3 -3
  141. package/dist/pixi/display-object/objects/text/helpers/process-steps/3-data-out-converter/rich-text-data-out-converter.js +6 -6
  142. package/dist/pixi/display-object/objects/text/helpers/process-steps/3-data-out-converter/rich-text-data-out-converter.test.js +12 -12
  143. package/dist/pixi/display-object/objects/text/helpers/rich-text-to-plane-text.d.ts +2 -2
  144. package/dist/pixi/display-object/objects/text/helpers/rich-text-to-plane-text.test.js +5 -5
  145. package/dist/pixi/display-object/objects/text/rich-text.d.ts +0 -1
  146. package/dist/pixi/display-object/objects/text/rich-text.js +0 -1
  147. package/dist/pixi/display-object/objects/text/text.d.ts +9 -10
  148. package/dist/pixi/display-object/objects/text/text.js +34 -35
  149. package/dist/pixi/game.d.ts +26 -17
  150. package/dist/pixi/game.js +53 -39
  151. package/dist/pixi/helpers/game-assets.d.ts +5 -5
  152. package/dist/pixi/helpers/game-assets.js +14 -11
  153. package/dist/pixi/helpers/position-conversion.helper.d.ts +4 -4
  154. package/dist/pixi/helpers/position-conversion.helper.js +3 -3
  155. package/dist/pixi/index.d.ts +3 -37
  156. package/dist/pixi/index.js +6 -22
  157. package/dist/pixi/modules/CAMERA/camera.d.ts +5 -4
  158. package/dist/pixi/modules/CAMERA/camera.js +9 -9
  159. package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/camera-view.gateway.d.ts +3 -2
  160. package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/camera-view.gateway.js +1 -1
  161. package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/controllers/camera-view.controller.d.ts +3 -2
  162. package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/controllers/camera-view.controller.js +5 -5
  163. package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/controllers/camera.controller.d.ts +3 -3
  164. package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/controllers/camera.controller.js +7 -7
  165. package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/dtos/requests.dto.d.ts +8 -8
  166. package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/dtos/requests.dto.js +8 -8
  167. package/dist/pixi/modules/CAMERA//360/237/223/220services/camera.service.d.ts +2 -2
  168. package/dist/pixi/modules/CAMERA//360/237/223/220services/camera.service.js +12 -12
  169. package/dist/pixi/modules/CAMERA//360/237/247/212entities/camera.entity.js +4 -4
  170. package/dist/pixi/modules/CAMERA//360/237/247/251views/camera.view.d.ts +17 -16
  171. package/dist/pixi/modules/CAMERA//360/237/247/251views/camera.view.js +50 -49
  172. package/dist/pixi/pixi-definitions.d.ts +38 -0
  173. package/dist/pixi/pixi-definitions.js +37 -0
  174. package/dist/pixi/services/keyboard/keyboard.d.ts +6 -4
  175. package/dist/pixi/services/keyboard/keyboard.js +15 -13
  176. package/dist/pixi/services/mouse/mouse-target-focus.service.d.ts +12 -11
  177. package/dist/pixi/services/mouse/mouse-target-focus.service.js +31 -30
  178. package/dist/pixi/services/mouse/mouse.service.d.ts +16 -6
  179. package/dist/pixi/services/mouse/mouse.service.js +42 -22
  180. package/dist/utilities/animator/animating-content/fade-in-content.d.ts +18 -0
  181. package/dist/utilities/animator/animating-content/fade-in-content.js +37 -0
  182. package/dist/utilities/animator/animating-content/fade-in-content.test.d.ts +1 -0
  183. package/dist/utilities/animator/animating-content/fade-in-content.test.js +10 -0
  184. package/dist/utilities/animator/animating-content/slide-in-content.d.ts +37 -0
  185. package/dist/utilities/animator/animating-content/slide-in-content.js +99 -0
  186. package/dist/utilities/animator/animating-content/slide-in-content.test.d.ts +1 -0
  187. package/dist/utilities/animator/animating-content/slide-in-content.test.js +10 -0
  188. package/dist/utilities/animator/animations.d.ts +45 -0
  189. package/dist/utilities/animator/animations.js +92 -0
  190. package/dist/utilities/animator/animator/animator.d.ts +44 -0
  191. package/dist/utilities/animator/animator/animator.js +234 -0
  192. package/dist/utilities/animator/animator/animator.memory-leak.test.d.ts +1 -0
  193. package/dist/utilities/animator/animator/animator.memory-leak.test.js +73 -0
  194. package/dist/utilities/animator/animator/animator.performance.test.d.ts +1 -0
  195. package/dist/utilities/animator/animator/animator.performance.test.js +116 -0
  196. package/dist/utilities/animator/animator/animator.test.d.ts +1 -0
  197. package/dist/utilities/animator/animator/animator.test.js +1046 -0
  198. package/dist/utilities/animator/animator.d.ts +60 -0
  199. package/dist/utilities/animator/animator.js +322 -0
  200. package/dist/utilities/animator/animator.performance.test.d.ts +1 -0
  201. package/dist/utilities/animator/animator.performance.test.js +46 -0
  202. package/dist/utilities/animator/animator.test.d.ts +1 -0
  203. package/dist/utilities/animator/animator.test.js +928 -0
  204. package/dist/utilities/animator/animator2/animator.d.ts +42 -0
  205. package/dist/utilities/animator/animator2/animator.js +222 -0
  206. package/dist/utilities/animator/animator2/animator.memory-leak.test.d.ts +1 -0
  207. package/dist/utilities/animator/animator2/animator.memory-leak.test.js +73 -0
  208. package/dist/utilities/animator/animator2/animator.performance.test.d.ts +1 -0
  209. package/dist/utilities/animator/animator2/animator.performance.test.js +65 -0
  210. package/dist/utilities/animator/animator2/animator.test.d.ts +1 -0
  211. package/dist/utilities/animator/animator2/animator.test.js +1007 -0
  212. package/dist/utilities/animator/animator_old/animator.d.ts +60 -0
  213. package/dist/utilities/animator/animator_old/animator.js +337 -0
  214. package/dist/utilities/animator/animator_old/animator.performance.test.d.ts +1 -0
  215. package/dist/utilities/animator/animator_old/animator.performance.test.js +121 -0
  216. package/dist/utilities/animator/animator_old/animator.test.d.ts +1 -0
  217. package/dist/utilities/animator/animator_old/animator.test.js +996 -0
  218. package/dist/utilities/animator/content-animations/fade-in/fade-in-content.d.ts +18 -0
  219. package/dist/utilities/animator/content-animations/fade-in/fade-in-content.js +37 -0
  220. package/dist/utilities/animator/content-animations/fade-in/fade-in-content.test.d.ts +1 -0
  221. package/dist/utilities/animator/content-animations/fade-in/fade-in-content.test.js +10 -0
  222. package/dist/utilities/animator/content-animations/fade-in/fade-in-state-animation.d.ts +38 -0
  223. package/dist/utilities/animator/content-animations/fade-in/fade-in-state-animation.js +208 -0
  224. package/dist/utilities/animator/content-animations/fade-in/fade-in-state-animation.test.d.ts +1 -0
  225. package/dist/utilities/animator/content-animations/fade-in/fade-in-state-animation.test.js +439 -0
  226. package/dist/utilities/animator/content-animations/slide/slide-in-content.d.ts +41 -0
  227. package/dist/utilities/animator/content-animations/slide/slide-in-content.js +107 -0
  228. package/dist/utilities/animator/content-animations/slide/slide-in-content.test.d.ts +1 -0
  229. package/dist/utilities/animator/content-animations/slide/slide-in-content.test.js +10 -0
  230. package/dist/utilities/animator/content-animations/slide/slide-state-animation.d.ts +24 -0
  231. package/dist/utilities/animator/content-animations/slide/slide-state-animation.js +138 -0
  232. package/dist/utilities/animator/content-animations/slide/slide-state-animation.test.d.ts +1 -0
  233. package/dist/utilities/animator/content-animations/slide/slide-state-animation.test.js +307 -0
  234. package/dist/utilities/animator/content-animations/slide/state-animation.d.ts +37 -0
  235. package/dist/utilities/animator/content-animations/slide/state-animation.js +170 -0
  236. package/dist/utilities/animator/content-animations/slide/state-animation.test.d.ts +1 -0
  237. package/dist/utilities/animator/content-animations/slide/state-animation.test.js +340 -0
  238. package/dist/utilities/animator/index.d.ts +7 -0
  239. package/dist/utilities/animator/index.js +24 -0
  240. package/dist/utilities/animator/state-animation/fade-in/fade-in-content.d.ts +18 -0
  241. package/dist/utilities/animator/state-animation/fade-in/fade-in-content.js +37 -0
  242. package/dist/utilities/animator/state-animation/fade-in/fade-in-content.test.d.ts +1 -0
  243. package/dist/utilities/animator/state-animation/fade-in/fade-in-content.test.js +10 -0
  244. package/dist/utilities/animator/state-animation/fade-in/fade-in-state-animation.d.ts +32 -0
  245. package/dist/utilities/animator/state-animation/fade-in/fade-in-state-animation.js +168 -0
  246. package/dist/utilities/animator/state-animation/fade-in/fade-in-state-animation.test.d.ts +1 -0
  247. package/dist/utilities/animator/state-animation/fade-in/fade-in-state-animation.test.js +431 -0
  248. package/dist/utilities/animator/state-animation/slide/slide-in-content.d.ts +37 -0
  249. package/dist/utilities/animator/state-animation/slide/slide-in-content.js +100 -0
  250. package/dist/utilities/animator/state-animation/slide/slide-in-content.test.d.ts +1 -0
  251. package/dist/utilities/animator/state-animation/slide/slide-in-content.test.js +10 -0
  252. package/dist/utilities/animator/state-animation/slide/slide-state-animation.d.ts +24 -0
  253. package/dist/utilities/animator/state-animation/slide/slide-state-animation.js +130 -0
  254. package/dist/utilities/animator/state-animation/slide/slide-state-animation.test.d.ts +1 -0
  255. package/dist/utilities/animator/state-animation/slide/slide-state-animation.test.js +301 -0
  256. package/dist/utilities/animator/state-animation/slide-state-animation.d.ts +24 -0
  257. package/dist/utilities/animator/state-animation/slide-state-animation.js +130 -0
  258. package/dist/utilities/animator/state-animation/slide-state-animation.test.d.ts +1 -0
  259. package/dist/utilities/animator/state-animation/slide-state-animation.test.js +301 -0
  260. package/dist/utilities/animator/state-animation/state-animation.d.ts +33 -0
  261. package/dist/utilities/animator/state-animation/state-animation.js +146 -0
  262. package/dist/utilities/animator/state-animation/state-animation.test.d.ts +1 -0
  263. package/dist/utilities/animator/state-animation/state-animation.test.js +335 -0
  264. package/dist/utilities/animator/state-animation/visit-disappear-state-animation.d.ts +32 -0
  265. package/dist/utilities/animator/state-animation/visit-disappear-state-animation.js +168 -0
  266. package/dist/utilities/animator/state-animation/visit-disappear-state-animation.test.d.ts +1 -0
  267. package/dist/utilities/animator/state-animation/visit-disappear-state-animation.test.js +431 -0
  268. package/dist/utilities/data-structures/vector-set/vector-set.d.ts +7 -0
  269. package/dist/utilities/data-structures/vector-set/vector-set.js +26 -0
  270. package/dist/utilities/delta-time/delta-time.d.ts +3 -0
  271. package/dist/utilities/delta-time/delta-time.js +10 -0
  272. package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.d.ts +6 -0
  273. package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.js +55 -0
  274. package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.test.d.ts +1 -0
  275. package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.test.js +100 -0
  276. package/dist/utilities/grid-algorithms/path-finder/path-finder.d.ts +8 -0
  277. package/dist/utilities/grid-algorithms/path-finder/path-finder.js +98 -0
  278. package/dist/utilities/grid-algorithms/path-finder/path-finder.test.d.ts +1 -0
  279. package/dist/utilities/grid-algorithms/path-finder/path-finder.test.js +155 -0
  280. package/dist/utilities/grid-algorithms/position-to-grid-position-converter.d.ts +6 -0
  281. package/dist/utilities/grid-algorithms/position-to-grid-position-converter.js +17 -0
  282. package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.d.ts +18 -0
  283. package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.js +129 -0
  284. package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.test.d.ts +1 -0
  285. package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.test.js +254 -0
  286. package/dist/utilities/index.d.ts +6 -6
  287. package/dist/utilities/index.js +6 -6
  288. package/package.json +8 -6
@@ -0,0 +1,1007 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const actions_lib_1 = require("actions-lib");
4
+ const helpers_lib_1 = require("helpers-lib");
5
+ const vitest_1 = require("vitest");
6
+ const game_entities_1 = require("../../../game-entities");
7
+ const animations_1 = require("../animations");
8
+ const animator_1 = require("./animator");
9
+ async function skipTime(duration = 1) {
10
+ await (0, helpers_lib_1.Wait)();
11
+ game_entities_1.UpdateCycle.triggerUpdateTick(duration);
12
+ }
13
+ (0, vitest_1.describe)('ANIMATOR', () => {
14
+ (0, vitest_1.beforeEach)(() => {
15
+ game_entities_1.BardLegendsHardReset.hardReset();
16
+ });
17
+ (0, vitest_1.describe)('Setup', () => {
18
+ (0, vitest_1.test)('type complains', () => {
19
+ let animator1 = new animator_1.Animator({ x: 0 }, 'x');
20
+ animator1.animate({ x: 1 }).attachToRoot();
21
+ let animator2 = new animator_1.Animator({ x: 0, y: 0, z: 'a', t: 0 }, ['x', 'y']);
22
+ animator2.animate({ x: 1, y: 2 }).attachToRoot();
23
+ try {
24
+ // @ts-expect-error should complain target has to be object
25
+ new animator_1.Animator('a', 'x');
26
+ // @ts-expect-error should complain target.y is not a number
27
+ new animator_1.Animator({ x: 0, y: 'a' }, 'y');
28
+ // @ts-expect-error should complain target.z does not exist
29
+ new animator_1.Animator({ x: 0, y: 'a' }, 'z');
30
+ let animator3 = new animator_1.Animator({ x: 0, y: 'a' }, 'x');
31
+ // @ts-expect-error should complain animate values should have all animatedProperties
32
+ animator3.animate({});
33
+ let animator4 = new animator_1.Animator({ x: 0, y: 0, z: 'a' }, ['x', 'y']);
34
+ // @ts-expect-error should complain animate values should have all animatedProperties
35
+ animator4.animate({ x: 1 });
36
+ // @ts-expect-error should complain z is not a number
37
+ new animator_1.Animator({ x: 0, y: 0, z: 'a' }, ['x', 'z']);
38
+ let animator5 = new animator_1.Animator({ x: 0, y: 0, z: 'a' }, ['x']);
39
+ // @ts-expect-error should complain y is not in the animatedProperties
40
+ animator5.animate({ x: 1, y: 2 });
41
+ }
42
+ catch { }
43
+ class Foo1 {
44
+ constructor() {
45
+ this.x = 0;
46
+ this.animator = new animator_1.Animator(this, 'x');
47
+ }
48
+ }
49
+ new Foo1();
50
+ class Foo2 {
51
+ constructor() {
52
+ this.x = 0;
53
+ this.y = 0;
54
+ this.animator = new animator_1.Animator(this, ['x', 'y']);
55
+ }
56
+ }
57
+ new Foo2();
58
+ });
59
+ (0, vitest_1.test)('should throw error if multiple animators decorate the same property', () => {
60
+ (0, vitest_1.expect)(() => {
61
+ let obj = { x: 0 };
62
+ new animator_1.Animator(obj, 'x');
63
+ new animator_1.Animator(obj, 'x');
64
+ }).toThrow(`Animator: target property is already animated! Target: "{\n "x": 0\n}", Property: "x"`);
65
+ });
66
+ (0, vitest_1.test)('when target is cleaned up from memory, it should be cleaned up from animated objects', async () => {
67
+ let obj = { x: 0 };
68
+ let animator = new animator_1.Animator(obj, 'x');
69
+ (0, vitest_1.expect)(animator).toBeDefined();
70
+ (0, vitest_1.expect)(animator_1.Animator['_animatedObjects'].has(obj)).toBeTruthy();
71
+ obj = undefined;
72
+ await helpers_lib_1.UnitTestHelper.forceGarbageCollection();
73
+ (0, vitest_1.expect)(animator_1.Animator['_animatedObjects'].has(obj)).toBeFalsy();
74
+ });
75
+ (0, vitest_1.test)('when an animator is cleaned up from memory, it should be cleaned up from animated properties', async () => {
76
+ let obj = { x: 0 };
77
+ let animator = new animator_1.Animator(obj, 'x');
78
+ (0, vitest_1.expect)(animator).toBeDefined();
79
+ (0, vitest_1.expect)(animator_1.Animator['_animatedObjects'].get(obj)?.has('x')).toBeTruthy();
80
+ animator = undefined;
81
+ await helpers_lib_1.UnitTestHelper.forceGarbageCollection();
82
+ (0, vitest_1.expect)(animator_1.Animator['_animatedObjects'].get(obj)).toBeTruthy();
83
+ (0, vitest_1.expect)(animator_1.Animator['_animatedObjects'].get(obj).has('x')).toBeFalsy();
84
+ (0, vitest_1.expect)(() => {
85
+ new animator_1.Animator(obj, 'x');
86
+ }).not.toThrow(`Animator: target property is already animated! Target: "{\n "x": 0\n}", Property: "x"`);
87
+ });
88
+ (0, vitest_1.test)('setting multiple update callbacks should throw error', () => {
89
+ let obj = { x: 0 };
90
+ let animator = new animator_1.Animator(obj, 'x');
91
+ animator.subscribe(() => { }).attachToRoot();
92
+ (0, vitest_1.expect)(() => {
93
+ animator.subscribe(() => { }).attachToRoot();
94
+ }).toThrow('Animator: subscribe is already set, there should be max one subscriber by design.');
95
+ });
96
+ });
97
+ (0, vitest_1.describe)('Animate', () => {
98
+ (0, vitest_1.test)('animate should not change the value before the update ticks', () => {
99
+ let obj = { x: 0 };
100
+ let animator = new animator_1.Animator(obj, 'x');
101
+ animator.animate({ x: 5 }).attachToRoot();
102
+ (0, vitest_1.expect)(obj.x).toEqual(0);
103
+ });
104
+ (0, vitest_1.test)('animate should not take action if the target value is the same', async () => {
105
+ let obj = { x: 0 };
106
+ let animator = new animator_1.Animator(obj, 'x', {
107
+ duration: 4,
108
+ animation: animations_1.Animations.lineer,
109
+ completionHandling: animator_1.AnimationsCompletionHandlingType.stayInCurrentState
110
+ });
111
+ animator.animate({ x: 0 }).attachToRoot();
112
+ await skipTime();
113
+ (0, vitest_1.expect)(obj.x).toEqual(0);
114
+ (0, vitest_1.expect)(animator.animating).toEqual(false);
115
+ });
116
+ (0, vitest_1.test)('animate to target in lineer', async () => {
117
+ let obj = { x: 0 };
118
+ let animator = new animator_1.Animator(obj, 'x', {
119
+ duration: 4,
120
+ animation: animations_1.Animations.lineer,
121
+ completionHandling: animator_1.AnimationsCompletionHandlingType.stayInCurrentState
122
+ });
123
+ animator.animate({ x: 4 }).attachToRoot();
124
+ await skipTime();
125
+ (0, vitest_1.expect)(obj.x).toEqual(1);
126
+ await skipTime();
127
+ (0, vitest_1.expect)(obj.x).toEqual(2);
128
+ await skipTime();
129
+ (0, vitest_1.expect)(obj.x).toEqual(3);
130
+ await skipTime();
131
+ (0, vitest_1.expect)(obj.x).toEqual(4);
132
+ });
133
+ (0, vitest_1.test)('animate to target in easeInOut starting from zero', async () => {
134
+ let obj = { x: 0 };
135
+ let animator = new animator_1.Animator(obj, 'x', {
136
+ duration: 4,
137
+ animation: animations_1.Animations.easeInOut,
138
+ completionHandling: animator_1.AnimationsCompletionHandlingType.stayInCurrentState
139
+ });
140
+ animator.animate({ x: 10 }).attachToRoot();
141
+ await skipTime();
142
+ (0, vitest_1.expect)(obj.x).toEqual(1.25);
143
+ await skipTime();
144
+ (0, vitest_1.expect)(obj.x).toEqual(5);
145
+ await skipTime();
146
+ (0, vitest_1.expect)(obj.x).toEqual(8.75);
147
+ await skipTime();
148
+ (0, vitest_1.expect)(obj.x).toEqual(10);
149
+ });
150
+ (0, vitest_1.test)('animate to target in easeInOut starting from different value than zero', async () => {
151
+ let obj = { x: 10 };
152
+ let animator = new animator_1.Animator(obj, 'x', {
153
+ duration: 4,
154
+ animation: animations_1.Animations.easeInOut,
155
+ completionHandling: animator_1.AnimationsCompletionHandlingType.stayInCurrentState
156
+ });
157
+ animator.animate({ x: 20 }).attachToRoot();
158
+ await skipTime();
159
+ (0, vitest_1.expect)(obj.x).toEqual(11.25);
160
+ await skipTime();
161
+ (0, vitest_1.expect)(obj.x).toEqual(15);
162
+ await skipTime();
163
+ (0, vitest_1.expect)(obj.x).toEqual(18.75);
164
+ await skipTime();
165
+ (0, vitest_1.expect)(obj.x).toEqual(20);
166
+ });
167
+ (0, vitest_1.test)('animate to target and return back', async () => {
168
+ let obj = { x: 0 };
169
+ let animator = new animator_1.Animator(obj, 'x', {
170
+ duration: 1,
171
+ animation: animations_1.Animations.lineer,
172
+ completionHandling: animator_1.AnimationsCompletionHandlingType.stayInCurrentState
173
+ });
174
+ animator.animate({ x: 4 }).attachToRoot();
175
+ await skipTime();
176
+ animator.animate({ x: 0 }).attachToRoot();
177
+ await skipTime();
178
+ (0, vitest_1.expect)(obj.x).toEqual(0);
179
+ });
180
+ (0, vitest_1.test)('animateing an object with getter/setter property', async () => {
181
+ class Foo {
182
+ constructor() {
183
+ this._x = 10;
184
+ }
185
+ get x() {
186
+ return this._x;
187
+ }
188
+ set x(value) {
189
+ this._x = value;
190
+ }
191
+ }
192
+ let obj = new Foo();
193
+ let animator = new animator_1.Animator(obj, ['x'], {
194
+ duration: 4,
195
+ animation: animations_1.Animations.easeInOut,
196
+ completionHandling: animator_1.AnimationsCompletionHandlingType.stayInCurrentState
197
+ });
198
+ animator.animate({ x: 20 }).attachToRoot();
199
+ await skipTime();
200
+ (0, vitest_1.expect)(obj.x).toEqual(11.25);
201
+ await skipTime();
202
+ (0, vitest_1.expect)(obj.x).toEqual(15);
203
+ await skipTime();
204
+ (0, vitest_1.expect)(obj.x).toEqual(18.75);
205
+ await skipTime();
206
+ (0, vitest_1.expect)(obj.x).toEqual(20);
207
+ });
208
+ (0, vitest_1.test)('animation event completion single property', async () => {
209
+ let completed = false;
210
+ let animator = new animator_1.Animator({ x: 0 }, 'x', {
211
+ duration: 2,
212
+ animation: animations_1.Animations.lineer,
213
+ completionHandling: animator_1.AnimationsCompletionHandlingType.stayInCurrentState
214
+ });
215
+ animator
216
+ .animate({ x: 1 })
217
+ .tap(() => {
218
+ completed = true;
219
+ })
220
+ .attachToRoot();
221
+ (0, vitest_1.expect)(completed).toBeFalsy();
222
+ await skipTime();
223
+ (0, vitest_1.expect)(completed).toBeFalsy();
224
+ await skipTime();
225
+ (0, vitest_1.expect)(completed).toBeTruthy();
226
+ });
227
+ (0, vitest_1.test)('animation event completion multiple properties', async () => {
228
+ let completed1 = false;
229
+ let animator = new animator_1.Animator({ x: 0, y: 0 }, ['x', 'y'], {
230
+ duration: 2,
231
+ animation: animations_1.Animations.lineer,
232
+ completionHandling: animator_1.AnimationsCompletionHandlingType.stayInCurrentState
233
+ });
234
+ animator
235
+ .animate({ x: 1, y: 1 })
236
+ .tap(() => {
237
+ completed1 = true;
238
+ })
239
+ .attachToRoot();
240
+ (0, vitest_1.expect)(completed1).toBeFalsy();
241
+ await skipTime();
242
+ (0, vitest_1.expect)(completed1).toBeFalsy();
243
+ await skipTime();
244
+ (0, vitest_1.expect)(completed1).toBeTruthy();
245
+ });
246
+ (0, vitest_1.test)('animate multiple properties', async () => {
247
+ let obj = { x: 0, y: 10 };
248
+ let animator = new animator_1.Animator(obj, ['x', 'y'], {
249
+ duration: 4,
250
+ animation: animations_1.Animations.easeInOut,
251
+ completionHandling: animator_1.AnimationsCompletionHandlingType.stayInCurrentState
252
+ });
253
+ animator.animate({ x: 10, y: 0 }).attachToRoot();
254
+ await skipTime();
255
+ (0, vitest_1.expect)(obj).toEqual({ x: 1.25, y: 8.75 });
256
+ await skipTime();
257
+ (0, vitest_1.expect)(obj).toEqual({ x: 5, y: 5 });
258
+ await skipTime();
259
+ (0, vitest_1.expect)(obj).toEqual({ x: 8.75, y: 1.25 });
260
+ await skipTime();
261
+ (0, vitest_1.expect)(obj).toEqual({ x: 10, y: 0 });
262
+ });
263
+ });
264
+ (0, vitest_1.describe)('Set', () => {
265
+ (0, vitest_1.test)('it should change the original value', async () => {
266
+ let obj = { x: 0, y: 1, z: 2 };
267
+ let animator = new animator_1.Animator(obj, ['x', 'y', 'z']);
268
+ animator.set({ x: 3, y: 4, z: 5 });
269
+ (0, vitest_1.expect)(obj).toEqual({ x: 3, y: 4, z: 5 });
270
+ });
271
+ });
272
+ (0, vitest_1.describe)('Overriding Animator Options', () => {
273
+ (0, vitest_1.test)('animate to target with overriden duration', async () => {
274
+ let obj = { x: 0 };
275
+ let animator = new animator_1.Animator(obj, 'x', { duration: 4, animation: animations_1.Animations.lineer });
276
+ animator.animate({ x: 4 }, { duration: 2 }).attachToRoot();
277
+ await skipTime();
278
+ (0, vitest_1.expect)(obj.x).toEqual(2);
279
+ });
280
+ (0, vitest_1.test)('animate to target with overriden instant duration', async () => {
281
+ let obj = { x: 0 };
282
+ let animator = new animator_1.Animator(obj, 'x', { duration: 4, animation: animations_1.Animations.lineer });
283
+ animator.animate({ x: 4 }, { duration: 0 }).attachToRoot();
284
+ await skipTime();
285
+ (0, vitest_1.expect)(obj.x).toEqual(4);
286
+ });
287
+ (0, vitest_1.test)('animate with custom values should override the default settings', async () => {
288
+ let obj = { x: 0 };
289
+ let animator = new animator_1.Animator(obj, 'x', { duration: 10, animation: animations_1.Animations.lineer });
290
+ animator.animate({ x: 10 }, { duration: 4, animation: animations_1.Animations.easeInOut }).attachToRoot();
291
+ await skipTime();
292
+ (0, vitest_1.expect)(obj).toEqual({ x: 1.25 });
293
+ await skipTime();
294
+ (0, vitest_1.expect)(obj).toEqual({ x: 5 });
295
+ await skipTime();
296
+ (0, vitest_1.expect)(obj).toEqual({ x: 8.75 });
297
+ await skipTime();
298
+ (0, vitest_1.expect)(obj).toEqual({ x: 10 });
299
+ });
300
+ });
301
+ (0, vitest_1.describe)('Subscribe', () => {
302
+ (0, vitest_1.test)('animate function triggering subscription callback', async () => {
303
+ let obj = { x: 0 };
304
+ let valueFromOnStep = 0;
305
+ let onStepCallCount = 0;
306
+ let animator = new animator_1.Animator(obj, 'x', {
307
+ duration: 4,
308
+ completionHandling: animator_1.AnimationsCompletionHandlingType.stayInCurrentState,
309
+ animation: animations_1.Animations.easeInOut
310
+ });
311
+ animator
312
+ .subscribe(item => {
313
+ valueFromOnStep = item.x;
314
+ onStepCallCount++;
315
+ })
316
+ .attachToRoot();
317
+ animator.animate({ x: 10 }).attachToRoot();
318
+ (0, vitest_1.expect)(valueFromOnStep).toEqual(0);
319
+ (0, vitest_1.expect)(onStepCallCount).toEqual(0);
320
+ await skipTime();
321
+ (0, vitest_1.expect)(onStepCallCount).toEqual(1);
322
+ (0, vitest_1.expect)(valueFromOnStep).toEqual(1.25);
323
+ await skipTime();
324
+ (0, vitest_1.expect)(onStepCallCount).toEqual(2);
325
+ (0, vitest_1.expect)(valueFromOnStep).toEqual(5);
326
+ await skipTime();
327
+ (0, vitest_1.expect)(onStepCallCount).toEqual(3);
328
+ (0, vitest_1.expect)(valueFromOnStep).toEqual(8.75);
329
+ await skipTime();
330
+ (0, vitest_1.expect)(onStepCallCount).toEqual(4);
331
+ (0, vitest_1.expect)(valueFromOnStep).toEqual(10);
332
+ await skipTime();
333
+ await skipTime();
334
+ await skipTime();
335
+ (0, vitest_1.expect)(onStepCallCount).toEqual(4);
336
+ });
337
+ (0, vitest_1.test)('set function triggering subscription callback', async () => {
338
+ let obj = { x: 0 };
339
+ let valueFromOnStep = 0;
340
+ let onStepCallCount = 0;
341
+ let animator = new animator_1.Animator(obj, 'x');
342
+ animator
343
+ .subscribe(item => {
344
+ valueFromOnStep = item.x;
345
+ onStepCallCount++;
346
+ })
347
+ .attachToRoot();
348
+ animator.set({ x: 1 });
349
+ (0, vitest_1.expect)(valueFromOnStep).toEqual(1);
350
+ (0, vitest_1.expect)(onStepCallCount).toEqual(1);
351
+ });
352
+ (0, vitest_1.test)('animate subscribe should not be triggered on update if there is no ongoing animation', async () => {
353
+ let onStepCallCount = 0;
354
+ let animator = new animator_1.Animator({ x: 0 }, 'x', { duration: 4, animation: animations_1.Animations.easeInOut });
355
+ animator
356
+ .subscribe(() => {
357
+ onStepCallCount++;
358
+ })
359
+ .attachToRoot();
360
+ await skipTime();
361
+ (0, vitest_1.expect)(onStepCallCount).toEqual(0);
362
+ });
363
+ (0, vitest_1.test)('complete animations should not trigger subscription if it is not animating', async () => {
364
+ let completed = false;
365
+ let animator = new animator_1.Animator({ x: 0 }, 'x');
366
+ animator
367
+ .subscribe(() => {
368
+ completed = true;
369
+ })
370
+ .attachToRoot();
371
+ animator.completeAnimation();
372
+ (0, vitest_1.expect)(completed).toBeFalsy();
373
+ });
374
+ (0, vitest_1.test)('complete animations should not trigger subscription if the value change is already triggered', async () => {
375
+ let obj = { x: 0 };
376
+ let heap = [];
377
+ let animator = new animator_1.Animator(obj, 'x', { duration: 2 });
378
+ animator.subscribe(value => heap.push(value.x)).attachToRoot();
379
+ animator.animate({ x: 1 }).attachToRoot();
380
+ await skipTime();
381
+ animator.completeAnimation();
382
+ (0, vitest_1.expect)(heap).toEqual([0.5]);
383
+ });
384
+ (0, vitest_1.test)('subscription should not be called if no change happens via 0 time pass', async () => {
385
+ let obj = { x: 0 };
386
+ let valueFromOnStep = 0;
387
+ let onStepCallCount = 0;
388
+ let animator = new animator_1.Animator(obj, 'x', { duration: 4 });
389
+ animator
390
+ .subscribe(item => {
391
+ valueFromOnStep = item.x;
392
+ onStepCallCount++;
393
+ })
394
+ .attachToRoot();
395
+ animator.animate({ x: 1 }).attachToRoot();
396
+ game_entities_1.UpdateCycle['_beforeSceneUpdateAction'].trigger({ time: 0, delta: 0 });
397
+ (0, vitest_1.expect)(valueFromOnStep).toEqual(0);
398
+ (0, vitest_1.expect)(onStepCallCount).toEqual(0);
399
+ });
400
+ (0, vitest_1.test)('set function should not trigger subscription if the value is the same', async () => {
401
+ let obj = { x: 0 };
402
+ let onStepCallCount = 0;
403
+ let animator = new animator_1.Animator(obj, 'x');
404
+ animator
405
+ .subscribe(() => {
406
+ onStepCallCount++;
407
+ })
408
+ .attachToRoot();
409
+ animator.set({ x: 0 });
410
+ (0, vitest_1.expect)(onStepCallCount).toEqual(0);
411
+ });
412
+ });
413
+ (0, vitest_1.describe)('Re Animate Handling', () => {
414
+ (0, vitest_1.describe)('Throw Error', () => {
415
+ (0, vitest_1.test)('animate', async () => {
416
+ let obj = { x: 0 };
417
+ let animator = new animator_1.Animator(obj, 'x', {
418
+ duration: 4,
419
+ reAnimateHandling: animator_1.ReAnimateHandlingType.throwError
420
+ });
421
+ animator.animate({ x: 1 }).attachToRoot();
422
+ (0, vitest_1.expect)(() => animator.animate({ x: 0 }).attachToRoot()).toThrow('Animator: new animation triggered while another is not complete yet.');
423
+ await skipTime();
424
+ (0, vitest_1.expect)(() => animator.animate({ x: 0 }).attachToRoot()).toThrow('Animator: new animation triggered while another is not complete yet.');
425
+ game_entities_1.UpdateCycle.triggerUpdateTick(3);
426
+ (0, vitest_1.expect)(() => animator.animate({ x: 0 }).attachToRoot()).not.toThrow('Animator: new animation triggered while another is not complete yet.');
427
+ });
428
+ (0, vitest_1.test)('set', async () => {
429
+ let obj = { x: 0 };
430
+ let animator = new animator_1.Animator(obj, 'x', { duration: 1, reAnimateHandling: animator_1.ReAnimateHandlingType.throwError });
431
+ animator.animate({ x: 1 }).attachToRoot();
432
+ animator.set({ x: 2 });
433
+ (0, vitest_1.expect)(obj.x).toEqual(2);
434
+ });
435
+ });
436
+ (0, vitest_1.describe)('Ignore New Animation', () => {
437
+ (0, vitest_1.test)('animate', async () => {
438
+ let obj = { x: 0 };
439
+ let animator = new animator_1.Animator(obj, 'x', {
440
+ duration: 4,
441
+ animation: animations_1.Animations.lineer,
442
+ reAnimateHandling: animator_1.ReAnimateHandlingType.ignoreNewAnimation
443
+ });
444
+ animator.animate({ x: 1 }).attachToRoot();
445
+ await skipTime();
446
+ (0, vitest_1.expect)(obj.x).toEqual(0.25);
447
+ animator.animate({ x: 0 }).attachToRoot();
448
+ await skipTime();
449
+ (0, vitest_1.expect)(obj.x).toEqual(0.5);
450
+ });
451
+ (0, vitest_1.test)('set', async () => {
452
+ let obj = { x: 0 };
453
+ let animator = new animator_1.Animator(obj, 'x', { duration: 1, reAnimateHandling: animator_1.ReAnimateHandlingType.ignoreNewAnimation });
454
+ animator.animate({ x: 1 }).attachToRoot();
455
+ animator.set({ x: 2 });
456
+ (0, vitest_1.expect)(obj.x).toEqual(2);
457
+ });
458
+ });
459
+ (0, vitest_1.describe)('Complete Previous', () => {
460
+ (0, vitest_1.test)('return to original', async () => {
461
+ let obj = { x: 0 };
462
+ let animator = new animator_1.Animator(obj, 'x', {
463
+ duration: 4,
464
+ animation: animations_1.Animations.lineer,
465
+ reAnimateHandling: animator_1.ReAnimateHandlingType.completePrevious,
466
+ completionHandling: animator_1.AnimationsCompletionHandlingType.returnToOriginal
467
+ });
468
+ animator.animate({ x: 1 }).attachToRoot();
469
+ await skipTime();
470
+ (0, vitest_1.expect)(obj.x).toEqual(0.25);
471
+ animator.animate({ x: 2 }).attachToRoot();
472
+ (0, vitest_1.expect)(obj.x).toEqual(0);
473
+ await skipTime();
474
+ (0, vitest_1.expect)(obj.x).toEqual(0.5);
475
+ });
476
+ (0, vitest_1.test)('stay in current', async () => {
477
+ let obj = { x: 0 };
478
+ let animator = new animator_1.Animator(obj, 'x', {
479
+ duration: 4,
480
+ animation: animations_1.Animations.lineer,
481
+ reAnimateHandling: animator_1.ReAnimateHandlingType.completePrevious,
482
+ completionHandling: animator_1.AnimationsCompletionHandlingType.stayInCurrentState
483
+ });
484
+ animator.animate({ x: 1 }).attachToRoot();
485
+ await skipTime();
486
+ (0, vitest_1.expect)(obj.x).toEqual(0.25);
487
+ animator.animate({ x: 1.25 }).attachToRoot();
488
+ (0, vitest_1.expect)(obj.x).toEqual(0.25);
489
+ await skipTime();
490
+ (0, vitest_1.expect)(obj.x).toEqual(0.5);
491
+ });
492
+ (0, vitest_1.test)('jump to end', async () => {
493
+ let obj = { x: 0 };
494
+ let animator = new animator_1.Animator(obj, 'x', {
495
+ duration: 4,
496
+ animation: animations_1.Animations.lineer,
497
+ reAnimateHandling: animator_1.ReAnimateHandlingType.completePrevious,
498
+ completionHandling: animator_1.AnimationsCompletionHandlingType.jumpToEnd
499
+ });
500
+ animator.animate({ x: 1 }).attachToRoot();
501
+ await skipTime();
502
+ (0, vitest_1.expect)(obj.x).toEqual(0.25);
503
+ animator.animate({ x: 0 }).attachToRoot();
504
+ (0, vitest_1.expect)(obj.x).toEqual(1);
505
+ await skipTime();
506
+ (0, vitest_1.expect)(obj.x).toEqual(0.75);
507
+ });
508
+ (0, vitest_1.test)('loop', async () => {
509
+ let obj = { x: 0 };
510
+ let animator = new animator_1.Animator(obj, 'x', {
511
+ duration: 4,
512
+ animation: animations_1.Animations.lineer,
513
+ reAnimateHandling: animator_1.ReAnimateHandlingType.completePrevious,
514
+ completionHandling: animator_1.AnimationsCompletionHandlingType.loop
515
+ });
516
+ animator.animate({ x: 1 }).attachToRoot();
517
+ await skipTime();
518
+ (0, vitest_1.expect)(obj.x).toEqual(0.25);
519
+ animator.animate({ x: 2 }).attachToRoot();
520
+ (0, vitest_1.expect)(obj.x).toEqual(0);
521
+ await skipTime();
522
+ (0, vitest_1.expect)(obj.x).toEqual(0.5);
523
+ });
524
+ (0, vitest_1.test)('set', async () => {
525
+ let obj = { x: 0 };
526
+ let animator = new animator_1.Animator(obj, 'x', {
527
+ duration: 4,
528
+ animation: animations_1.Animations.lineer,
529
+ reAnimateHandling: animator_1.ReAnimateHandlingType.completePrevious
530
+ });
531
+ animator.animate({ x: 4 }).attachToRoot();
532
+ await skipTime();
533
+ (0, vitest_1.expect)(obj.x).toEqual(1);
534
+ animator.set({ x: 1 });
535
+ await skipTime();
536
+ (0, vitest_1.expect)(obj.x).toEqual(1);
537
+ });
538
+ });
539
+ });
540
+ (0, vitest_1.describe)('Complete Animation Handling', () => {
541
+ (0, vitest_1.describe)('Return To Original', () => {
542
+ (0, vitest_1.test)('animate', async () => {
543
+ let obj = { x: 0 };
544
+ let animator = new animator_1.Animator(obj, 'x', {
545
+ duration: 1,
546
+ animation: animations_1.Animations.lineer,
547
+ completionHandling: animator_1.AnimationsCompletionHandlingType.returnToOriginal
548
+ });
549
+ animator.animate({ x: 1 }).attachToRoot();
550
+ await skipTime();
551
+ (0, vitest_1.expect)(obj.x).toEqual(0);
552
+ });
553
+ (0, vitest_1.test)('subscription', async () => {
554
+ let obj = { x: 0 };
555
+ let heap = [];
556
+ let animator = new animator_1.Animator(obj, 'x', {
557
+ duration: 4,
558
+ completionHandling: animator_1.AnimationsCompletionHandlingType.returnToOriginal
559
+ });
560
+ animator.subscribe(value => heap.push(value.x)).attachToRoot();
561
+ animator.animate({ x: 1 }).attachToRoot();
562
+ await skipTime();
563
+ heap = [];
564
+ animator.completeAnimation();
565
+ (0, vitest_1.expect)(heap).toEqual([0]);
566
+ });
567
+ (0, vitest_1.test)('complete animations function', async () => {
568
+ let obj = { x: 0 };
569
+ let completed = false;
570
+ let animator = new animator_1.Animator(obj, 'x', {
571
+ duration: 4,
572
+ animation: animations_1.Animations.lineer,
573
+ completionHandling: animator_1.AnimationsCompletionHandlingType.returnToOriginal
574
+ });
575
+ animator
576
+ .animate({ x: 1 })
577
+ .tap(() => {
578
+ completed = true;
579
+ })
580
+ .attachToRoot();
581
+ await skipTime();
582
+ (0, vitest_1.expect)(completed).toBeFalsy();
583
+ (0, vitest_1.expect)(obj.x).toEqual(0.25);
584
+ animator.completeAnimation();
585
+ (0, vitest_1.expect)(completed).toBeTruthy();
586
+ (0, vitest_1.expect)(obj.x).toEqual(0);
587
+ });
588
+ (0, vitest_1.test)('destroying', async () => {
589
+ let obj = { x: 0 };
590
+ let animator = new animator_1.Animator(obj, 'x', {
591
+ duration: 4,
592
+ animation: animations_1.Animations.lineer,
593
+ completionHandling: animator_1.AnimationsCompletionHandlingType.returnToOriginal
594
+ });
595
+ let animation = animator.animate({ x: 1 }).attachToRoot();
596
+ await skipTime();
597
+ (0, vitest_1.expect)(obj.x).toEqual(0.25);
598
+ (0, vitest_1.expect)(animator.animating).toBeTruthy();
599
+ animation.destroy();
600
+ (0, vitest_1.expect)(obj.x).toEqual(0);
601
+ (0, vitest_1.expect)(animator.animating).toBeFalsy();
602
+ await skipTime();
603
+ (0, vitest_1.expect)(obj.x).toEqual(0);
604
+ (0, vitest_1.expect)(animator.animating).toBeFalsy();
605
+ });
606
+ });
607
+ (0, vitest_1.describe)('Stay In Current State', () => {
608
+ (0, vitest_1.test)('animate', async () => {
609
+ let obj = { x: 0 };
610
+ let animator = new animator_1.Animator(obj, 'x');
611
+ animator
612
+ .animate({ x: 4 }, {
613
+ duration: 4,
614
+ animation: animations_1.Animations.lineer,
615
+ completionHandling: animator_1.AnimationsCompletionHandlingType.stayInCurrentState
616
+ })
617
+ .attachToRoot();
618
+ await skipTime();
619
+ (0, vitest_1.expect)(obj.x).toEqual(1);
620
+ animator.completeAnimation();
621
+ await skipTime();
622
+ (0, vitest_1.expect)(obj.x).toEqual(1);
623
+ });
624
+ (0, vitest_1.test)('subscription', async () => {
625
+ let obj = { x: 0 };
626
+ let heap = [];
627
+ let animator = new animator_1.Animator(obj, 'x', {
628
+ duration: 4,
629
+ completionHandling: animator_1.AnimationsCompletionHandlingType.stayInCurrentState
630
+ });
631
+ animator.subscribe(value => heap.push(value.x)).attachToRoot();
632
+ animator.animate({ x: 1 }).attachToRoot();
633
+ await skipTime();
634
+ heap = [];
635
+ animator.completeAnimation();
636
+ // should not be triggered when staying in the current state
637
+ (0, vitest_1.expect)(heap).toEqual([]);
638
+ });
639
+ (0, vitest_1.test)('complete animations function', async () => {
640
+ let obj = { x: 0 };
641
+ let completed = false;
642
+ let animator = new animator_1.Animator(obj, 'x', {
643
+ duration: 4,
644
+ animation: animations_1.Animations.lineer,
645
+ completionHandling: animator_1.AnimationsCompletionHandlingType.stayInCurrentState
646
+ });
647
+ animator
648
+ .animate({ x: 1 })
649
+ .tap(() => {
650
+ completed = true;
651
+ })
652
+ .attachToRoot();
653
+ await skipTime();
654
+ (0, vitest_1.expect)(completed).toBeFalsy();
655
+ (0, vitest_1.expect)(obj.x).toEqual(0.25);
656
+ animator.completeAnimation();
657
+ (0, vitest_1.expect)(completed).toBeTruthy();
658
+ (0, vitest_1.expect)(obj.x).toEqual(0.25);
659
+ });
660
+ (0, vitest_1.test)('destroying', async () => {
661
+ let obj = { x: 0 };
662
+ let animator = new animator_1.Animator(obj, 'x', {
663
+ duration: 4,
664
+ animation: animations_1.Animations.lineer,
665
+ completionHandling: animator_1.AnimationsCompletionHandlingType.stayInCurrentState
666
+ });
667
+ let animation = animator.animate({ x: 1 }).attachToRoot();
668
+ await skipTime();
669
+ (0, vitest_1.expect)(obj.x).toEqual(0.25);
670
+ (0, vitest_1.expect)(animator.animating).toBeTruthy();
671
+ animation.destroy();
672
+ (0, vitest_1.expect)(obj.x).toEqual(0.25);
673
+ (0, vitest_1.expect)(animator.animating).toBeFalsy();
674
+ await skipTime();
675
+ (0, vitest_1.expect)(obj.x).toEqual(0.25);
676
+ (0, vitest_1.expect)(animator.animating).toBeFalsy();
677
+ });
678
+ });
679
+ (0, vitest_1.describe)('Jump To End', () => {
680
+ (0, vitest_1.test)('animate', async () => {
681
+ let obj = { x: 0 };
682
+ let animator = new animator_1.Animator(obj, 'x');
683
+ animator
684
+ .animate({ x: 4 }, {
685
+ duration: 4,
686
+ animation: animations_1.Animations.lineer,
687
+ completionHandling: animator_1.AnimationsCompletionHandlingType.jumpToEnd
688
+ })
689
+ .attachToRoot();
690
+ await skipTime();
691
+ (0, vitest_1.expect)(obj.x).toEqual(1);
692
+ animator.completeAnimation();
693
+ await skipTime();
694
+ (0, vitest_1.expect)(obj.x).toEqual(4);
695
+ });
696
+ (0, vitest_1.test)('subscription', async () => {
697
+ let obj = { x: 0 };
698
+ let heap = [];
699
+ let animator = new animator_1.Animator(obj, 'x', { duration: 4, completionHandling: animator_1.AnimationsCompletionHandlingType.jumpToEnd });
700
+ animator.subscribe(value => heap.push(value.x)).attachToRoot();
701
+ animator.animate({ x: 1 }).attachToRoot();
702
+ await skipTime();
703
+ heap = [];
704
+ animator.completeAnimation();
705
+ (0, vitest_1.expect)(heap).toEqual([1]);
706
+ });
707
+ (0, vitest_1.test)('complete animations function', async () => {
708
+ let obj = { x: 0 };
709
+ let completed = false;
710
+ let animator = new animator_1.Animator(obj, 'x', {
711
+ duration: 4,
712
+ animation: animations_1.Animations.lineer,
713
+ completionHandling: animator_1.AnimationsCompletionHandlingType.jumpToEnd
714
+ });
715
+ animator
716
+ .animate({ x: 1 })
717
+ .tap(() => {
718
+ completed = true;
719
+ })
720
+ .attachToRoot();
721
+ await skipTime();
722
+ (0, vitest_1.expect)(completed).toBeFalsy();
723
+ (0, vitest_1.expect)(obj.x).toEqual(0.25);
724
+ animator.completeAnimation();
725
+ (0, vitest_1.expect)(completed).toBeTruthy();
726
+ (0, vitest_1.expect)(obj.x).toEqual(1);
727
+ });
728
+ (0, vitest_1.test)('destroying', async () => {
729
+ let obj = { x: 0 };
730
+ let animator = new animator_1.Animator(obj, 'x', {
731
+ duration: 4,
732
+ animation: animations_1.Animations.lineer,
733
+ completionHandling: animator_1.AnimationsCompletionHandlingType.jumpToEnd
734
+ });
735
+ let animation = animator.animate({ x: 1 }).attachToRoot();
736
+ await skipTime();
737
+ (0, vitest_1.expect)(obj.x).toEqual(0.25);
738
+ (0, vitest_1.expect)(animator.animating).toBeTruthy();
739
+ animation.destroy();
740
+ (0, vitest_1.expect)(obj.x).toEqual(1);
741
+ (0, vitest_1.expect)(animator.animating).toBeFalsy();
742
+ await skipTime();
743
+ (0, vitest_1.expect)(obj.x).toEqual(1);
744
+ (0, vitest_1.expect)(animator.animating).toBeFalsy();
745
+ });
746
+ });
747
+ (0, vitest_1.describe)('Loop', () => {
748
+ (0, vitest_1.test)('animate', async () => {
749
+ let obj = { x: 0 };
750
+ let animator = new animator_1.Animator(obj, 'x', {
751
+ duration: 4,
752
+ animation: animations_1.Animations.easeInOut,
753
+ completionHandling: animator_1.AnimationsCompletionHandlingType.loop
754
+ });
755
+ animator.animate({ x: 10 }).attachToRoot();
756
+ await skipTime();
757
+ (0, vitest_1.expect)(obj).toEqual({ x: 1.25 });
758
+ await skipTime();
759
+ (0, vitest_1.expect)(obj).toEqual({ x: 5 });
760
+ await skipTime();
761
+ (0, vitest_1.expect)(obj).toEqual({ x: 8.75 });
762
+ await skipTime();
763
+ (0, vitest_1.expect)(obj).toEqual({ x: 0 });
764
+ await skipTime();
765
+ (0, vitest_1.expect)(obj).toEqual({ x: 1.25 });
766
+ await skipTime();
767
+ (0, vitest_1.expect)(obj).toEqual({ x: 5 });
768
+ await skipTime();
769
+ (0, vitest_1.expect)(obj).toEqual({ x: 8.75 });
770
+ await skipTime();
771
+ (0, vitest_1.expect)(obj).toEqual({ x: 0 });
772
+ });
773
+ (0, vitest_1.test)('subscription', async () => {
774
+ let obj = { x: 0 };
775
+ let heap = [];
776
+ let animator = new animator_1.Animator(obj, 'x', { duration: 4, completionHandling: animator_1.AnimationsCompletionHandlingType.loop });
777
+ animator.subscribe(value => heap.push(value.x)).attachToRoot();
778
+ animator.animate({ x: 1 }).attachToRoot();
779
+ await skipTime();
780
+ heap = [];
781
+ animator.completeAnimation();
782
+ (0, vitest_1.expect)(heap).toEqual([0]);
783
+ });
784
+ (0, vitest_1.test)('complete animations function', async () => {
785
+ let obj = { x: 0 };
786
+ let completed = false;
787
+ let animator = new animator_1.Animator(obj, 'x', {
788
+ duration: 2,
789
+ animation: animations_1.Animations.lineer,
790
+ completionHandling: animator_1.AnimationsCompletionHandlingType.loop
791
+ });
792
+ animator
793
+ .animate({ x: 1 })
794
+ .tap(() => {
795
+ completed = true;
796
+ })
797
+ .attachToRoot();
798
+ await skipTime();
799
+ (0, vitest_1.expect)(completed).toBeFalsy();
800
+ (0, vitest_1.expect)(obj.x).toEqual(0.5);
801
+ await skipTime();
802
+ (0, vitest_1.expect)(completed).toBeFalsy();
803
+ (0, vitest_1.expect)(obj.x).toEqual(0);
804
+ await skipTime();
805
+ (0, vitest_1.expect)(completed).toBeFalsy();
806
+ (0, vitest_1.expect)(obj.x).toEqual(0.5);
807
+ animator.completeAnimation();
808
+ (0, vitest_1.expect)(completed).toBeTruthy();
809
+ (0, vitest_1.expect)(obj.x).toEqual(0); // loop always returns to original after it ends, during the loop or on complete animations
810
+ });
811
+ (0, vitest_1.test)('animate should still take action if the target value is the same', async () => {
812
+ let obj = { x: 0 };
813
+ let animator = new animator_1.Animator(obj, 'x', { duration: 4, completionHandling: animator_1.AnimationsCompletionHandlingType.loop });
814
+ animator.animate({ x: 0 }).attachToRoot();
815
+ await skipTime();
816
+ (0, vitest_1.expect)(obj.x).toEqual(0);
817
+ (0, vitest_1.expect)(animator.animating).toEqual(true);
818
+ });
819
+ (0, vitest_1.test)('destroying', async () => {
820
+ let obj = { x: 0 };
821
+ let animator = new animator_1.Animator(obj, 'x', {
822
+ duration: 4,
823
+ animation: animations_1.Animations.lineer,
824
+ completionHandling: animator_1.AnimationsCompletionHandlingType.loop
825
+ });
826
+ let animation = animator.animate({ x: 1 }).attachToRoot();
827
+ await skipTime();
828
+ (0, vitest_1.expect)(obj.x).toEqual(0.25);
829
+ (0, vitest_1.expect)(animator.animating).toBeTruthy();
830
+ animation.destroy();
831
+ (0, vitest_1.expect)(obj.x).toEqual(0);
832
+ (0, vitest_1.expect)(animator.animating).toBeFalsy();
833
+ await skipTime();
834
+ (0, vitest_1.expect)(obj.x).toEqual(0);
835
+ (0, vitest_1.expect)(animator.animating).toBeFalsy();
836
+ });
837
+ });
838
+ });
839
+ (0, vitest_1.describe)('Overriding Options', () => {
840
+ (0, vitest_1.test)('complete animations options overriden in animate', async () => {
841
+ let obj = { x: 0 };
842
+ let animator = new animator_1.Animator(obj, 'x', {
843
+ completionHandling: animator_1.AnimationsCompletionHandlingType.returnToOriginal
844
+ });
845
+ animator
846
+ .animate({ x: 4 }, {
847
+ duration: 4,
848
+ animation: animations_1.Animations.lineer,
849
+ completionHandling: animator_1.AnimationsCompletionHandlingType.jumpToEnd
850
+ })
851
+ .attachToRoot();
852
+ await skipTime();
853
+ (0, vitest_1.expect)(obj.x).toEqual(1);
854
+ animator.completeAnimation();
855
+ await skipTime();
856
+ (0, vitest_1.expect)(obj.x).toEqual(4);
857
+ });
858
+ (0, vitest_1.test)('complete animations options overriden in complete animations', async () => {
859
+ let obj = { x: 0 };
860
+ let animator = new animator_1.Animator(obj, 'x', {
861
+ completionHandling: animator_1.AnimationsCompletionHandlingType.returnToOriginal
862
+ });
863
+ animator
864
+ .animate({ x: 4 }, {
865
+ duration: 4,
866
+ animation: animations_1.Animations.lineer,
867
+ completionHandling: animator_1.AnimationsCompletionHandlingType.jumpToEnd
868
+ })
869
+ .attachToRoot();
870
+ await skipTime();
871
+ (0, vitest_1.expect)(obj.x).toEqual(1);
872
+ animator.completeAnimation(animator_1.AnimationsCompletionHandlingType.stayInCurrentState);
873
+ await skipTime();
874
+ (0, vitest_1.expect)(obj.x).toEqual(1);
875
+ });
876
+ });
877
+ (0, vitest_1.describe)('Animating Property', () => {
878
+ (0, vitest_1.test)('animating should be true if it is animating', async () => {
879
+ let animator = new animator_1.Animator({ x: 0 }, 'x', { duration: 1, animation: animations_1.Animations.lineer });
880
+ animator.animate({ x: 1 }).attachToRoot();
881
+ (0, vitest_1.expect)(animator.animating).toBeTruthy();
882
+ });
883
+ (0, vitest_1.test)('animating should be false if it is not animating', async () => {
884
+ let obj = { x: 0 };
885
+ let animator = new animator_1.Animator(obj, 'x', { duration: 1, animation: animations_1.Animations.lineer });
886
+ (0, vitest_1.expect)(animator.animating).toBeFalsy();
887
+ animator.animate({ x: 1 }).attachToRoot();
888
+ await skipTime();
889
+ (0, vitest_1.expect)(animator.animating).toBeFalsy();
890
+ });
891
+ });
892
+ (0, vitest_1.describe)('Edge Cases', () => {
893
+ (0, vitest_1.test)('reanimation triggered completion destroys the object should not make the new animation to throw error', async () => {
894
+ class AnimationObject extends actions_lib_1.Attachable {
895
+ constructor() {
896
+ super(...arguments);
897
+ this.scale = 1;
898
+ }
899
+ }
900
+ let object = new AnimationObject();
901
+ let animator = new animator_1.Animator(object, 'scale', {
902
+ duration: 4,
903
+ reAnimateHandling: animator_1.ReAnimateHandlingType.completePrevious,
904
+ completionHandling: animator_1.AnimationsCompletionHandlingType.stayInCurrentState
905
+ });
906
+ let completed1 = false;
907
+ let completed2 = false;
908
+ animator
909
+ .animate({ scale: 2 })
910
+ .tap(() => {
911
+ completed1 = true;
912
+ object.destroy();
913
+ })
914
+ .attach(object);
915
+ animator
916
+ .animate({ scale: 3 })
917
+ .tap(() => {
918
+ completed2 = true;
919
+ })
920
+ .attach(object);
921
+ (0, vitest_1.expect)(completed1).toBeTruthy();
922
+ (0, vitest_1.expect)(completed2).toBeFalsy();
923
+ });
924
+ (0, vitest_1.test)('reanimation triggered completion animates the same property should not interfier with the new animation', async () => {
925
+ class AnimationObject extends actions_lib_1.Attachable {
926
+ constructor() {
927
+ super(...arguments);
928
+ this.scale = 1;
929
+ }
930
+ }
931
+ let object = new AnimationObject().attachToRoot();
932
+ let animator = new animator_1.Animator(object, 'scale', {
933
+ duration: 4,
934
+ reAnimateHandling: animator_1.ReAnimateHandlingType.completePrevious,
935
+ completionHandling: animator_1.AnimationsCompletionHandlingType.stayInCurrentState
936
+ });
937
+ let animation1Complete = false;
938
+ let completed1 = false;
939
+ let completed2 = false;
940
+ animator
941
+ .animate({ scale: 2 })
942
+ .asyncMap(() => {
943
+ animation1Complete = true;
944
+ return animator.animate({ scale: 1 });
945
+ })
946
+ .tap(() => {
947
+ completed1 = true;
948
+ object.destroy();
949
+ })
950
+ .attach(object);
951
+ await skipTime();
952
+ animator
953
+ .animate({ scale: 1 })
954
+ .tap(() => {
955
+ completed2 = true;
956
+ })
957
+ .attach(object);
958
+ (0, vitest_1.expect)(animation1Complete).toBeTruthy();
959
+ (0, vitest_1.expect)(completed1).toBeFalsy();
960
+ (0, vitest_1.expect)(completed2).toBeTruthy();
961
+ game_entities_1.UpdateCycle.triggerUpdateTick(4);
962
+ (0, vitest_1.expect)(animation1Complete).toBeTruthy();
963
+ (0, vitest_1.expect)(completed1).toBeTruthy();
964
+ (0, vitest_1.expect)(completed2).toBeTruthy();
965
+ });
966
+ (0, vitest_1.test)('time passes more than the animation duration when completion is in loop', async () => {
967
+ let obj = { x: 0 };
968
+ let animator = new animator_1.Animator(obj, 'x', {
969
+ duration: 1,
970
+ animation: animations_1.Animations.lineer,
971
+ completionHandling: animator_1.AnimationsCompletionHandlingType.loop
972
+ });
973
+ animator.animate({ x: 1 }).attachToRoot();
974
+ await skipTime(10);
975
+ (0, vitest_1.expect)(obj.x).toEqual(0);
976
+ await skipTime(10.5);
977
+ (0, vitest_1.expect)(obj.x).toEqual(0.5);
978
+ });
979
+ (0, vitest_1.test)('animation chain waiting for another async event should not delay unsubcription', async () => {
980
+ let obj = { x: 0 };
981
+ let action = new actions_lib_1.Action();
982
+ let animator = new animator_1.Animator(obj, 'x', {
983
+ duration: 2,
984
+ animation: animations_1.Animations.lineer,
985
+ completionHandling: animator_1.AnimationsCompletionHandlingType.stayInCurrentState
986
+ });
987
+ let triggered = false;
988
+ animator
989
+ .animate({ x: 1 })
990
+ .asyncMap(() => action)
991
+ .tap(() => {
992
+ triggered = true;
993
+ })
994
+ .attachToRoot();
995
+ await skipTime(2);
996
+ (0, vitest_1.expect)(obj.x).toEqual(1);
997
+ await skipTime(1);
998
+ (0, vitest_1.expect)(obj.x).toEqual(1);
999
+ (0, vitest_1.expect)(triggered).toBeFalsy();
1000
+ action.trigger();
1001
+ (0, vitest_1.expect)(triggered).toBeTruthy();
1002
+ await skipTime(1);
1003
+ (0, vitest_1.expect)(obj.x).toEqual(1);
1004
+ });
1005
+ });
1006
+ });
1007
+ //# sourceMappingURL=animator.test.js.map