@visactor/vrender-animate 0.22.4

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 (303) hide show
  1. package/README.md +177 -0
  2. package/cjs/animate-extension.d.ts +15 -0
  3. package/cjs/animate-extension.js +46 -0
  4. package/cjs/animate-extension.js.map +1 -0
  5. package/cjs/animate.d.ts +71 -0
  6. package/cjs/animate.js +210 -0
  7. package/cjs/animate.js.map +1 -0
  8. package/cjs/custom/clip-graphic.d.ts +53 -0
  9. package/cjs/custom/clip-graphic.js +146 -0
  10. package/cjs/custom/clip-graphic.js.map +1 -0
  11. package/cjs/custom/clip.d.ts +13 -0
  12. package/cjs/custom/clip.js +24 -0
  13. package/cjs/custom/clip.js.map +1 -0
  14. package/cjs/custom/common.d.ts +22 -0
  15. package/cjs/custom/common.js +58 -0
  16. package/cjs/custom/common.js.map +1 -0
  17. package/cjs/custom/custom-animate.d.ts +15 -0
  18. package/cjs/custom/custom-animate.js +25 -0
  19. package/cjs/custom/custom-animate.js.map +1 -0
  20. package/cjs/custom/fade.d.ts +13 -0
  21. package/cjs/custom/fade.js +24 -0
  22. package/cjs/custom/fade.js.map +1 -0
  23. package/cjs/custom/group-fade.d.ts +16 -0
  24. package/cjs/custom/group-fade.js +66 -0
  25. package/cjs/custom/group-fade.js.map +1 -0
  26. package/cjs/custom/growAngle.d.ts +37 -0
  27. package/cjs/custom/growAngle.js +140 -0
  28. package/cjs/custom/growAngle.js.map +1 -0
  29. package/cjs/custom/growCenter.d.ts +17 -0
  30. package/cjs/custom/growCenter.js +161 -0
  31. package/cjs/custom/growCenter.js.map +1 -0
  32. package/cjs/custom/growHeight.d.ts +36 -0
  33. package/cjs/custom/growHeight.js +154 -0
  34. package/cjs/custom/growHeight.js.map +1 -0
  35. package/cjs/custom/growPoints.d.ts +52 -0
  36. package/cjs/custom/growPoints.js +227 -0
  37. package/cjs/custom/growPoints.js.map +1 -0
  38. package/cjs/custom/growRadius.d.ts +41 -0
  39. package/cjs/custom/growRadius.js +113 -0
  40. package/cjs/custom/growRadius.js.map +1 -0
  41. package/cjs/custom/growWidth.d.ts +36 -0
  42. package/cjs/custom/growWidth.js +154 -0
  43. package/cjs/custom/growWidth.js.map +1 -0
  44. package/cjs/custom/input-text.d.ts +29 -0
  45. package/cjs/custom/input-text.js +45 -0
  46. package/cjs/custom/input-text.js.map +1 -0
  47. package/cjs/custom/number.d.ts +25 -0
  48. package/cjs/custom/number.js +102 -0
  49. package/cjs/custom/number.js.map +1 -0
  50. package/cjs/custom/register.d.ts +1 -0
  51. package/cjs/custom/register.js +35 -0
  52. package/cjs/custom/register.js.map +1 -0
  53. package/cjs/custom/scale-in.d.ts +13 -0
  54. package/cjs/custom/scale-in.js +57 -0
  55. package/cjs/custom/scale-in.js.map +1 -0
  56. package/cjs/custom/scale.d.ts +20 -0
  57. package/cjs/custom/scale.js +106 -0
  58. package/cjs/custom/scale.js.map +1 -0
  59. package/cjs/custom/sphere.d.ts +20 -0
  60. package/cjs/custom/sphere.js +26 -0
  61. package/cjs/custom/sphere.js.map +1 -0
  62. package/cjs/custom/state.d.ts +13 -0
  63. package/cjs/custom/state.js +25 -0
  64. package/cjs/custom/state.js.map +1 -0
  65. package/cjs/custom/tag-points.d.ts +26 -0
  66. package/cjs/custom/tag-points.js +81 -0
  67. package/cjs/custom/tag-points.js.map +1 -0
  68. package/cjs/custom/update.d.ts +14 -0
  69. package/cjs/custom/update.js +26 -0
  70. package/cjs/custom/update.js.map +1 -0
  71. package/cjs/executor/animate-executor.d.ts +36 -0
  72. package/cjs/executor/animate-executor.js +177 -0
  73. package/cjs/executor/animate-executor.js.map +1 -0
  74. package/cjs/executor/executor.d.ts +69 -0
  75. package/cjs/executor/executor.js +6 -0
  76. package/cjs/executor/executor.js.map +1 -0
  77. package/cjs/index.d.ts +25 -0
  78. package/cjs/index.js +214 -0
  79. package/cjs/index.js.map +1 -0
  80. package/cjs/interpolate/executor.d.ts +66 -0
  81. package/cjs/interpolate/executor.js +6 -0
  82. package/cjs/interpolate/executor.js.map +1 -0
  83. package/cjs/interpolate/number.d.ts +1 -0
  84. package/cjs/interpolate/number.js +10 -0
  85. package/cjs/interpolate/number.js.map +1 -0
  86. package/cjs/interpolate/store.d.ts +32 -0
  87. package/cjs/interpolate/store.js +96 -0
  88. package/cjs/interpolate/store.js.map +1 -0
  89. package/cjs/intreface/animate.d.ts +91 -0
  90. package/cjs/intreface/animate.js +10 -0
  91. package/cjs/intreface/animate.js.map +1 -0
  92. package/cjs/intreface/easing.d.ts +3 -0
  93. package/cjs/intreface/easing.js +6 -0
  94. package/cjs/intreface/easing.js.map +1 -0
  95. package/cjs/intreface/state.d.ts +35 -0
  96. package/cjs/intreface/state.js +6 -0
  97. package/cjs/intreface/state.js.map +1 -0
  98. package/cjs/intreface/ticker.d.ts +37 -0
  99. package/cjs/intreface/ticker.js +10 -0
  100. package/cjs/intreface/ticker.js.map +1 -0
  101. package/cjs/intreface/timeline.d.ts +17 -0
  102. package/cjs/intreface/timeline.js +6 -0
  103. package/cjs/intreface/timeline.js.map +1 -0
  104. package/cjs/intreface/type.d.ts +13 -0
  105. package/cjs/intreface/type.js +15 -0
  106. package/cjs/intreface/type.js.map +1 -0
  107. package/cjs/register.d.ts +1 -0
  108. package/cjs/register.js +19 -0
  109. package/cjs/register.js.map +1 -0
  110. package/cjs/state/animation-state-machine.d.ts +22 -0
  111. package/cjs/state/animation-state-machine.js +53 -0
  112. package/cjs/state/animation-state-machine.js.map +1 -0
  113. package/cjs/state/animation-state-queue.d.ts +24 -0
  114. package/cjs/state/animation-state-queue.js +66 -0
  115. package/cjs/state/animation-state-queue.js.map +1 -0
  116. package/cjs/state/animation-state-registry.d.ts +14 -0
  117. package/cjs/state/animation-state-registry.js +53 -0
  118. package/cjs/state/animation-state-registry.js.map +1 -0
  119. package/cjs/state/animation-state.d.ts +25 -0
  120. package/cjs/state/animation-state.js +80 -0
  121. package/cjs/state/animation-state.js.map +1 -0
  122. package/cjs/state/animation-states-registry.d.ts +17 -0
  123. package/cjs/state/animation-states-registry.js +95 -0
  124. package/cjs/state/animation-states-registry.js.map +1 -0
  125. package/cjs/state/graphic-extension.d.ts +12 -0
  126. package/cjs/state/graphic-extension.js +37 -0
  127. package/cjs/state/graphic-extension.js.map +1 -0
  128. package/cjs/state/index.d.ts +3 -0
  129. package/cjs/state/index.js +22 -0
  130. package/cjs/state/index.js.map +1 -0
  131. package/cjs/state/types.d.ts +11 -0
  132. package/cjs/state/types.js +6 -0
  133. package/cjs/state/types.js.map +1 -0
  134. package/cjs/step.d.ts +49 -0
  135. package/cjs/step.js +124 -0
  136. package/cjs/step.js.map +1 -0
  137. package/cjs/ticker/default-ticker.d.ts +39 -0
  138. package/cjs/ticker/default-ticker.js +133 -0
  139. package/cjs/ticker/default-ticker.js.map +1 -0
  140. package/cjs/ticker/manual-ticker.d.ts +6 -0
  141. package/cjs/ticker/manual-ticker.js +37 -0
  142. package/cjs/ticker/manual-ticker.js.map +1 -0
  143. package/cjs/timeline.d.ts +34 -0
  144. package/cjs/timeline.js +84 -0
  145. package/cjs/timeline.js.map +1 -0
  146. package/cjs/utils/easing-func.d.ts +1 -0
  147. package/cjs/utils/easing-func.js +16 -0
  148. package/cjs/utils/easing-func.js.map +1 -0
  149. package/cjs/utils/easing.d.ts +49 -0
  150. package/cjs/utils/easing.js +141 -0
  151. package/cjs/utils/easing.js.map +1 -0
  152. package/dist/index.es.js +3824 -0
  153. package/es/animate-extension.d.ts +15 -0
  154. package/es/animate-extension.js +42 -0
  155. package/es/animate-extension.js.map +1 -0
  156. package/es/animate.d.ts +71 -0
  157. package/es/animate.js +207 -0
  158. package/es/animate.js.map +1 -0
  159. package/es/custom/clip-graphic.d.ts +53 -0
  160. package/es/custom/clip-graphic.js +134 -0
  161. package/es/custom/clip-graphic.js.map +1 -0
  162. package/es/custom/clip.d.ts +13 -0
  163. package/es/custom/clip.js +14 -0
  164. package/es/custom/clip.js.map +1 -0
  165. package/es/custom/common.d.ts +22 -0
  166. package/es/custom/common.js +48 -0
  167. package/es/custom/common.js.map +1 -0
  168. package/es/custom/custom-animate.d.ts +15 -0
  169. package/es/custom/custom-animate.js +17 -0
  170. package/es/custom/custom-animate.js.map +1 -0
  171. package/es/custom/fade.d.ts +13 -0
  172. package/es/custom/fade.js +14 -0
  173. package/es/custom/fade.js.map +1 -0
  174. package/es/custom/group-fade.d.ts +16 -0
  175. package/es/custom/group-fade.js +56 -0
  176. package/es/custom/group-fade.js.map +1 -0
  177. package/es/custom/growAngle.d.ts +37 -0
  178. package/es/custom/growAngle.js +132 -0
  179. package/es/custom/growAngle.js.map +1 -0
  180. package/es/custom/growCenter.d.ts +17 -0
  181. package/es/custom/growCenter.js +155 -0
  182. package/es/custom/growCenter.js.map +1 -0
  183. package/es/custom/growHeight.d.ts +36 -0
  184. package/es/custom/growHeight.js +144 -0
  185. package/es/custom/growHeight.js.map +1 -0
  186. package/es/custom/growPoints.d.ts +52 -0
  187. package/es/custom/growPoints.js +219 -0
  188. package/es/custom/growPoints.js.map +1 -0
  189. package/es/custom/growRadius.d.ts +41 -0
  190. package/es/custom/growRadius.js +105 -0
  191. package/es/custom/growRadius.js.map +1 -0
  192. package/es/custom/growWidth.d.ts +36 -0
  193. package/es/custom/growWidth.js +144 -0
  194. package/es/custom/growWidth.js.map +1 -0
  195. package/es/custom/input-text.d.ts +29 -0
  196. package/es/custom/input-text.js +37 -0
  197. package/es/custom/input-text.js.map +1 -0
  198. package/es/custom/number.d.ts +25 -0
  199. package/es/custom/number.js +94 -0
  200. package/es/custom/number.js.map +1 -0
  201. package/es/custom/register.d.ts +1 -0
  202. package/es/custom/register.js +39 -0
  203. package/es/custom/register.js.map +1 -0
  204. package/es/custom/scale-in.d.ts +13 -0
  205. package/es/custom/scale-in.js +49 -0
  206. package/es/custom/scale-in.js.map +1 -0
  207. package/es/custom/scale.d.ts +20 -0
  208. package/es/custom/scale.js +96 -0
  209. package/es/custom/scale.js.map +1 -0
  210. package/es/custom/sphere.d.ts +20 -0
  211. package/es/custom/sphere.js +20 -0
  212. package/es/custom/sphere.js.map +1 -0
  213. package/es/custom/state.d.ts +13 -0
  214. package/es/custom/state.js +17 -0
  215. package/es/custom/state.js.map +1 -0
  216. package/es/custom/tag-points.d.ts +26 -0
  217. package/es/custom/tag-points.js +77 -0
  218. package/es/custom/tag-points.js.map +1 -0
  219. package/es/custom/update.d.ts +14 -0
  220. package/es/custom/update.js +18 -0
  221. package/es/custom/update.js.map +1 -0
  222. package/es/executor/animate-executor.d.ts +36 -0
  223. package/es/executor/animate-executor.js +169 -0
  224. package/es/executor/animate-executor.js.map +1 -0
  225. package/es/executor/executor.d.ts +69 -0
  226. package/es/executor/executor.js +2 -0
  227. package/es/executor/executor.js.map +1 -0
  228. package/es/index.d.ts +25 -0
  229. package/es/index.js +50 -0
  230. package/es/index.js.map +1 -0
  231. package/es/interpolate/executor.d.ts +66 -0
  232. package/es/interpolate/executor.js +2 -0
  233. package/es/interpolate/executor.js.map +1 -0
  234. package/es/interpolate/number.d.ts +1 -0
  235. package/es/interpolate/number.js +4 -0
  236. package/es/interpolate/number.js.map +1 -0
  237. package/es/interpolate/store.d.ts +32 -0
  238. package/es/interpolate/store.js +88 -0
  239. package/es/interpolate/store.js.map +1 -0
  240. package/es/intreface/animate.d.ts +91 -0
  241. package/es/intreface/animate.js +6 -0
  242. package/es/intreface/animate.js.map +1 -0
  243. package/es/intreface/easing.d.ts +3 -0
  244. package/es/intreface/easing.js +2 -0
  245. package/es/intreface/easing.js.map +1 -0
  246. package/es/intreface/state.d.ts +35 -0
  247. package/es/intreface/state.js +2 -0
  248. package/es/intreface/state.js.map +1 -0
  249. package/es/intreface/ticker.d.ts +37 -0
  250. package/es/intreface/ticker.js +6 -0
  251. package/es/intreface/ticker.js.map +1 -0
  252. package/es/intreface/timeline.d.ts +17 -0
  253. package/es/intreface/timeline.js +2 -0
  254. package/es/intreface/timeline.js.map +1 -0
  255. package/es/intreface/type.d.ts +13 -0
  256. package/es/intreface/type.js +14 -0
  257. package/es/intreface/type.js.map +1 -0
  258. package/es/register.d.ts +1 -0
  259. package/es/register.js +20 -0
  260. package/es/register.js.map +1 -0
  261. package/es/state/animation-state-machine.d.ts +22 -0
  262. package/es/state/animation-state-machine.js +47 -0
  263. package/es/state/animation-state-machine.js.map +1 -0
  264. package/es/state/animation-state-queue.d.ts +24 -0
  265. package/es/state/animation-state-queue.js +58 -0
  266. package/es/state/animation-state-queue.js.map +1 -0
  267. package/es/state/animation-state-registry.d.ts +14 -0
  268. package/es/state/animation-state-registry.js +45 -0
  269. package/es/state/animation-state-registry.js.map +1 -0
  270. package/es/state/animation-state.d.ts +25 -0
  271. package/es/state/animation-state.js +72 -0
  272. package/es/state/animation-state.js.map +1 -0
  273. package/es/state/animation-states-registry.d.ts +17 -0
  274. package/es/state/animation-states-registry.js +87 -0
  275. package/es/state/animation-states-registry.js.map +1 -0
  276. package/es/state/graphic-extension.d.ts +12 -0
  277. package/es/state/graphic-extension.js +29 -0
  278. package/es/state/graphic-extension.js.map +1 -0
  279. package/es/state/index.d.ts +3 -0
  280. package/es/state/index.js +6 -0
  281. package/es/state/index.js.map +1 -0
  282. package/es/state/types.d.ts +11 -0
  283. package/es/state/types.js +2 -0
  284. package/es/state/types.js.map +1 -0
  285. package/es/step.d.ts +49 -0
  286. package/es/step.js +120 -0
  287. package/es/step.js.map +1 -0
  288. package/es/ticker/default-ticker.d.ts +39 -0
  289. package/es/ticker/default-ticker.js +129 -0
  290. package/es/ticker/default-ticker.js.map +1 -0
  291. package/es/ticker/manual-ticker.d.ts +6 -0
  292. package/es/ticker/manual-ticker.js +29 -0
  293. package/es/ticker/manual-ticker.js.map +1 -0
  294. package/es/timeline.d.ts +34 -0
  295. package/es/timeline.js +79 -0
  296. package/es/timeline.js.map +1 -0
  297. package/es/utils/easing-func.d.ts +1 -0
  298. package/es/utils/easing-func.js +8 -0
  299. package/es/utils/easing-func.js.map +1 -0
  300. package/es/utils/easing.d.ts +49 -0
  301. package/es/utils/easing.js +134 -0
  302. package/es/utils/easing.js.map +1 -0
  303. package/package.json +72 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/intreface/animate.ts"],"names":[],"mappings":";;;AAmKA,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,iDAAe,CAAA;IACf,6EAA6B,CAAA;AAC/B,CAAC,EAHW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAGtB","file":"animate.js","sourcesContent":["import type { IGraphic } from '@visactor/vrender-core';\nimport type { EasingType, EasingTypeFunc } from './easing';\nimport type { AnimateStatus, IAnimateStepType } from './type';\nimport type { ITimeline } from './timeline';\n\nexport interface ICustomAnimate extends IStep {\n type: IAnimateStepType;\n}\n\nexport interface IStep {\n type: IAnimateStepType;\n prev?: IStep;\n // 持续时间\n duration: number;\n // 链表,下一个\n next?: IStep;\n // 属性\n props?: Record<string, any>;\n // 解析后的属性(用于性能优化,避免每次tick都解析)\n fromParsedProps?: Record<string, any>;\n toParsedProps?: Record<string, any>;\n fromProps?: Record<string, any>;\n // 解析后的属性列表(用于性能优化,避免每次tick都解析)\n propKeys?: string[];\n // 缓动函数\n easing?: EasingTypeFunc;\n\n // 添加一个\n append: (step: IStep) => void;\n // 获取上一个props,用于完成这次的fromValue 和 toValue的插值\n getLastProps: () => any;\n\n animate: IAnimate;\n\n // 设置持续时间\n setDuration: (duration: number, updateDownstream?: boolean) => void;\n // 获取持续时间\n getDuration: () => number;\n // 确定插值更新函数(在开始的时候就确定,避免每次tick都解析)\n determineInterpolateUpdateFunction: () => void;\n\n // 设置开始时间\n setStartTime: (time: number, updateDownstream?: boolean) => void;\n // 获取开始时间\n getStartTime: () => number;\n\n bind: (target: IGraphic, animate: IAnimate) => void;\n // 在第一次绑定到Animate的时候触发\n onBind: () => void;\n // 第一次执行的时候调用\n onFirstRun: () => void;\n // 开始执行的时候调用(如果有循环,那每个周期都会调用)\n onStart: () => void;\n // 结束执行的时候调用(如果有循环,那每个周期都会调用)\n onEnd: (cb?: (animate: IAnimate, step: IStep) => void) => void;\n // 更新执行的时候调用(如果有循环,那每个周期都会调用)\n update: (end: boolean, ratio: number, out: Record<string, any>) => void;\n onUpdate: (end: boolean, ratio: number, out: Record<string, any>) => void;\n\n getEndProps: () => Record<string, any> | void;\n getFromProps: () => Record<string, any> | void;\n getMergedEndProps: () => Record<string, any> | void;\n\n // 屏蔽自身属性,会直接从props等内容里删除掉\n deleteSelfAttr: (key: string) => void;\n}\n\nexport interface IAnimate {\n readonly id: string | number;\n status: AnimateStatus;\n target: IGraphic;\n priority: number;\n interpolateUpdateFunction:\n | ((from: Record<string, any>, to: Record<string, any>, ratio: number, step: IStep, target: IGraphic) => void)\n | null;\n\n _onStart?: (() => void)[];\n _onFrame?: ((step: IStep, ratio: number) => void)[];\n _onEnd?: (() => void)[];\n _onRemove?: (() => void)[];\n\n getStartProps: () => Record<string, any>;\n getEndProps: () => Record<string, any>;\n\n // 设置timeline\n setTimeline: (timeline: ITimeline) => void;\n // 获取timeline\n getTimeline: () => ITimeline;\n readonly timeline: ITimeline;\n\n bind: (target: IGraphic) => this;\n to: (props: Record<string, any>, duration: number, easing: EasingType) => this;\n from: (props: Record<string, any>, duration: number, easing: EasingType) => this;\n pause: () => void;\n resume: () => void;\n onStart: (cb?: () => void) => void;\n onEnd: (cb?: () => void) => void;\n onFrame: (cb: (step: IStep, ratio: number) => void) => void;\n onRemove: (cb?: () => void) => void;\n // 屏蔽属性\n preventAttr: (key: string) => void;\n // 屏蔽属性\n preventAttrs: (key: string[]) => void;\n // 属性是否合法\n validAttr: (key: string) => boolean;\n\n runCb: (cb: (a: IAnimate, step: IStep) => void) => IAnimate;\n\n // 自定义插值,返回false表示没有匹配上\n customInterpolate: (\n key: string,\n ratio: number,\n from: any,\n to: any,\n target: IGraphic,\n ret: Record<string, any>\n ) => boolean;\n play: (customAnimate: ICustomAnimate) => this;\n\n getFromValue: () => Record<string, any>;\n getToValue: () => Record<string, any>;\n // 停止,可以设置停止后设置target的属性为开始的值(fromValue),还是结束的值(toValue)\n stop: (type?: 'start' | 'end' | Record<string, any>) => void;\n /** 打上END标志,下一帧被删除 */\n release: () => void;\n // 获取持续的时长\n getDuration: () => number;\n getTotalDuration: () => number;\n // 获取动画开始时间(注意并不是子动画的startAt)\n getStartTime: () => number;\n // 等待delay\n wait: (delay: number) => this;\n\n /* 动画编排 */\n // 所有动画结束后执行\n afterAll: (list: IAnimate[]) => this;\n // 在某个动画结束后执行\n after: (animate: IAnimate) => this;\n // 并行执行\n parallel: (animate: IAnimate) => this;\n\n getLoop: () => number;\n\n // 反转动画\n // reversed: (r: boolean) => IAnimate;\n // 循环动画\n loop: (n: number | boolean) => IAnimate;\n // 反弹动画\n bounce: (b: boolean) => IAnimate;\n\n advance: (delta: number) => void;\n\n // 设置开始时间(startAt之前是完全不会进入动画生命周期的)\n // 它和wait不一样,如果调用的是wait,wait过程中还算是一个动画阶段,只是空的阶段,而startAt之前是完全不会进入动画生命周期的\n startAt: (t: number) => IAnimate;\n\n // 重新同步和计算props,用于内部某些step发生了变更后,重新计算自身\n reSyncProps: () => void;\n\n // 更新duration\n updateDuration: () => void;\n}\n\nexport enum AnimateMode {\n NORMAL = 0b0000,\n SET_ATTR_IMMEDIATELY = 0b0001\n}\n"]}
@@ -0,0 +1,3 @@
1
+ export type EasingTypeStr = 'linear' | 'quadIn' | 'quadOut' | 'quadInOut' | 'quadInOut' | 'cubicIn' | 'cubicOut' | 'cubicInOut' | 'quartIn' | 'quartOut' | 'quartInOut' | 'quintIn' | 'quintOut' | 'quintInOut' | 'backIn' | 'backOut' | 'backInOut' | 'circIn' | 'circOut' | 'circInOut' | 'bounceOut' | 'bounceIn' | 'bounceInOut' | 'elasticIn' | 'elasticOut' | 'elasticInOut' | 'sineIn' | 'sineOut' | 'sineInOut' | 'expoIn' | 'expoOut' | 'expoInOut' | 'easeInOutQuad' | 'easeOutElastic' | 'easeInOutElastic' | '';
2
+ export type EasingTypeFunc = (t: number) => number;
3
+ export type EasingType = EasingTypeStr | EasingTypeFunc;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ });
6
+ //# sourceMappingURL=easing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/intreface/easing.ts"],"names":[],"mappings":"","file":"easing.js","sourcesContent":["export type EasingTypeStr =\n | 'linear'\n | 'quadIn'\n | 'quadOut'\n | 'quadInOut'\n | 'quadInOut'\n | 'cubicIn'\n | 'cubicOut'\n | 'cubicInOut'\n | 'quartIn'\n | 'quartOut'\n | 'quartInOut'\n | 'quintIn'\n | 'quintOut'\n | 'quintInOut'\n | 'backIn'\n | 'backOut'\n | 'backInOut'\n | 'circIn'\n | 'circOut'\n | 'circInOut'\n | 'bounceOut'\n | 'bounceIn'\n | 'bounceInOut'\n | 'elasticIn'\n | 'elasticOut'\n | 'elasticInOut'\n | 'sineIn'\n | 'sineOut'\n | 'sineInOut'\n | 'expoIn'\n | 'expoOut'\n | 'expoInOut'\n // @since 0.21.0\n | 'easeInOutQuad'\n | 'easeOutElastic'\n | 'easeInOutElastic'\n | '';\nexport type EasingTypeFunc = (t: number) => number;\n\nexport type EasingType = EasingTypeStr | EasingTypeFunc;\n"]}
@@ -0,0 +1,35 @@
1
+ import type { IAnimationTypeConfig } from '../executor/executor';
2
+ import type { IGraphic, IGroup } from '@visactor/vrender-core';
3
+ export interface IAnimationStateConfig {
4
+ name: string;
5
+ animation: IAnimationTypeConfig;
6
+ priority?: number;
7
+ }
8
+ export interface IAnimationStateRule {
9
+ conflicts?: string[];
10
+ interruptibleBy?: string[];
11
+ queueable?: boolean;
12
+ transitionDelay?: number;
13
+ }
14
+ export interface IAnimationStateMachine {
15
+ applyState: (state: string | string[]) => void;
16
+ registerState: (config: IAnimationStateConfig, rule?: IAnimationStateRule) => void;
17
+ getActiveState: () => string | null;
18
+ reset: () => void;
19
+ on: (event: AnimationStateEventType, callback: (state: string, target: IGraphic | IGroup) => void) => void;
20
+ off: (event: AnimationStateEventType, callback: (state: string, target: IGraphic | IGroup) => void) => void;
21
+ }
22
+ export type AnimationStateEventType = 'stateStart' | 'stateEnd' | 'stateInterrupt' | 'stateReject';
23
+ export interface IAnimationStateRegistry {
24
+ register: (state: IAnimationStateConfig, rule?: IAnimationStateRule) => void;
25
+ getState: (name: string) => IAnimationStateConfig | undefined;
26
+ getRule: (name: string) => IAnimationStateRule | undefined;
27
+ hasConflict: (stateA: string, stateB: string) => boolean;
28
+ }
29
+ export interface IAnimationStateQueue {
30
+ enqueue: (states: string | string[]) => void;
31
+ processNextState: () => void;
32
+ onAnimationComplete: () => void;
33
+ cancel: () => void;
34
+ canApplyState: (state: string) => boolean;
35
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ });
6
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/intreface/state.ts"],"names":[],"mappings":"","file":"state.js","sourcesContent":["import type { IAnimationTypeConfig } from '../executor/executor';\nimport type { IAnimate } from './animate';\nimport type { IGraphic, IGroup } from '@visactor/vrender-core';\n\n/**\n * Animation state configuration\n */\nexport interface IAnimationStateConfig {\n /** State name */\n name: string;\n /** Animation configuration for this state */\n animation: IAnimationTypeConfig;\n /** Priority of this state (higher overrides lower when there's a conflict) */\n priority?: number;\n}\n\n/**\n * Rules for animation state behaviors\n */\nexport interface IAnimationStateRule {\n /** States that cannot run simultaneously with this state */\n conflicts?: string[];\n /** States that can interrupt this state */\n interruptibleBy?: string[];\n /** Whether this state can be queued */\n queueable?: boolean;\n /** Duration to wait before executing next state (if queueable) */\n transitionDelay?: number;\n}\n\n/**\n * Animation state machine interface\n */\nexport interface IAnimationStateMachine {\n /** Apply a state or sequence of states */\n applyState: (state: string | string[]) => void;\n\n /** Register new state animations and rules */\n registerState: (config: IAnimationStateConfig, rule?: IAnimationStateRule) => void;\n\n /** Get current active state */\n getActiveState: () => string | null;\n\n /** Cancel all animations and clear queue */\n reset: () => void;\n\n /** Add event listener for state events */\n on: (event: AnimationStateEventType, callback: (state: string, target: IGraphic | IGroup) => void) => void;\n\n /** Remove event listener */\n off: (event: AnimationStateEventType, callback: (state: string, target: IGraphic | IGroup) => void) => void;\n}\n\n/**\n * Animation state event types\n */\nexport type AnimationStateEventType = 'stateStart' | 'stateEnd' | 'stateInterrupt' | 'stateReject';\n\n/**\n * Animation state registry interface\n */\nexport interface IAnimationStateRegistry {\n /** Register a state with its animation config and rules */\n register: (state: IAnimationStateConfig, rule?: IAnimationStateRule) => void;\n\n /** Get state configuration by name */\n getState: (name: string) => IAnimationStateConfig | undefined;\n\n /** Get state rule by name */\n getRule: (name: string) => IAnimationStateRule | undefined;\n\n /** Check if two states conflict with each other */\n hasConflict: (stateA: string, stateB: string) => boolean;\n}\n\n/**\n * Animation state queue interface\n */\nexport interface IAnimationStateQueue {\n /** Add state(s) to queue */\n enqueue: (states: string | string[]) => void;\n\n /** Process the next state in queue */\n processNextState: () => void;\n\n /** Called when current animation completes */\n onAnimationComplete: () => void;\n\n /** Cancel current state and clear queue */\n cancel: () => void;\n\n /** Check if we can apply a specific state now */\n canApplyState: (state: string) => boolean;\n}\n"]}
@@ -0,0 +1,37 @@
1
+ import type { EventEmitter } from '@visactor/vutils';
2
+ import type { ITimeline } from './timeline';
3
+ export type TickerMode = 'raf' | 'timeout' | 'manual';
4
+ export declare enum STATUS {
5
+ INITIAL = 0,
6
+ RUNNING = 1,
7
+ PAUSE = 2
8
+ }
9
+ export interface ITickHandler {
10
+ tick: (interval: number, cb: (handler: ITickHandler) => void) => void;
11
+ tickTo?: (t: number, cb: (handler: ITickHandler, params?: {
12
+ once: boolean;
13
+ }) => void) => void;
14
+ getTime: () => number;
15
+ release: () => void;
16
+ }
17
+ export interface ITickerHandlerStatic {
18
+ new (): ITickHandler;
19
+ }
20
+ export interface ITicker extends EventEmitter {
21
+ setFPS?: (fps: number) => void;
22
+ setInterval?: (interval: number) => void;
23
+ getFPS?: () => number;
24
+ getInterval?: () => number;
25
+ tick: (interval: number) => void;
26
+ tickAt?: (time: number) => void;
27
+ pause: () => boolean;
28
+ resume: () => boolean;
29
+ start: (force?: boolean) => boolean;
30
+ stop: () => void;
31
+ addTimeline: (timeline: ITimeline) => void;
32
+ remTimeline: (timeline: ITimeline) => void;
33
+ trySyncTickStatus: () => void;
34
+ getTimelines: () => ITimeline[];
35
+ release: () => void;
36
+ autoStop: boolean;
37
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ var STATUS;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: !0
7
+ }), exports.STATUS = void 0, function(STATUS) {
8
+ STATUS[STATUS.INITIAL = 0] = "INITIAL", STATUS[STATUS.RUNNING = 1] = "RUNNING",
9
+ STATUS[STATUS.PAUSE = 2] = "PAUSE";
10
+ }(STATUS = exports.STATUS || (exports.STATUS = {}));
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/intreface/ticker.ts"],"names":[],"mappings":";;;AASA,IAAY,MAIX;AAJD,WAAY,MAAM;IAChB,yCAAW,CAAA;IACX,yCAAW,CAAA;IACX,qCAAS,CAAA;AACX,CAAC,EAJW,MAAM,GAAN,cAAM,KAAN,cAAM,QAIjB","file":"ticker.js","sourcesContent":["/**\n * Ticker Types for Animation Graph\n */\n\nimport type { EventEmitter } from '@visactor/vutils';\nimport type { ITimeline } from './timeline';\n\nexport type TickerMode = 'raf' | 'timeout' | 'manual';\n\nexport enum STATUS {\n INITIAL = 0, // initial represents initial state\n RUNNING = 1, // running represents executing\n PAUSE = 2 // PAUSE represents tick continues but functions are not executed\n}\n\nexport interface ITickHandler {\n /**\n * Start executing tick\n * @param interval Delay in ms\n * @param cb Callback to execute\n */\n tick: (interval: number, cb: (handler: ITickHandler) => void) => void;\n tickTo?: (t: number, cb: (handler: ITickHandler, params?: { once: boolean }) => void) => void;\n getTime: () => number; // Get current time\n release: () => void;\n}\n\nexport interface ITickerHandlerStatic {\n new (): ITickHandler;\n}\n\nexport interface ITicker extends EventEmitter {\n setFPS?: (fps: number) => void;\n setInterval?: (interval: number) => void;\n getFPS?: () => number;\n getInterval?: () => number;\n tick: (interval: number) => void;\n tickAt?: (time: number) => void;\n pause: () => boolean;\n resume: () => boolean;\n /**\n * Start ticking, if force is true, start regardless;\n * otherwise, don't start if timeline is empty\n */\n start: (force?: boolean) => boolean;\n stop: () => void;\n addTimeline: (timeline: ITimeline) => void;\n remTimeline: (timeline: ITimeline) => void;\n trySyncTickStatus: () => void;\n getTimelines: () => ITimeline[];\n release: () => void;\n\n // Whether to automatically stop, default is true\n autoStop: boolean;\n}\n"]}
@@ -0,0 +1,17 @@
1
+ import type { IAnimate } from './animate';
2
+ export interface ITimeline {
3
+ id: number;
4
+ isGlobal?: boolean;
5
+ animateCount: number;
6
+ addAnimate: (animate: IAnimate) => void;
7
+ removeAnimate: (animate: IAnimate, release?: boolean) => void;
8
+ tick: (delta: number) => void;
9
+ clear: () => void;
10
+ pause: () => void;
11
+ resume: () => void;
12
+ getTotalDuration: () => number;
13
+ getPlaySpeed: () => number;
14
+ setPlaySpeed: (speed: number) => void;
15
+ getPlayState: () => 'playing' | 'paused' | 'stopped';
16
+ isRunning: () => boolean;
17
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ });
6
+ //# sourceMappingURL=timeline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/intreface/timeline.ts"],"names":[],"mappings":"","file":"timeline.js","sourcesContent":["import type { IAnimate } from './animate';\n\nexport interface ITimeline {\n id: number;\n isGlobal?: boolean;\n // 包含的动画数量(animate数组的数量),包含所有动画\n animateCount: number;\n // 添加动画\n addAnimate: (animate: IAnimate) => void;\n // 移除动画\n removeAnimate: (animate: IAnimate, release?: boolean) => void;\n // 更新动画\n tick: (delta: number) => void;\n // 清除动画\n clear: () => void;\n // 暂停动画\n pause: () => void;\n // 恢复动画\n resume: () => void;\n // 获取动画总时长\n getTotalDuration: () => number;\n // 获取动画的播放速度\n getPlaySpeed: () => number;\n // 设置动画的播放速度\n setPlaySpeed: (speed: number) => void;\n // 获取动画的播放状态\n getPlayState: () => 'playing' | 'paused' | 'stopped';\n // 获取动画是否正在运行\n isRunning: () => boolean;\n}\n"]}
@@ -0,0 +1,13 @@
1
+ export declare enum AnimateStepType {
2
+ wait = "wait",
3
+ from = "from",
4
+ to = "to",
5
+ customAnimate = "customAnimate"
6
+ }
7
+ export declare enum AnimateStatus {
8
+ INITIAL = 0,
9
+ RUNNING = 1,
10
+ PAUSED = 2,
11
+ END = 3
12
+ }
13
+ export type IAnimateStepType = keyof typeof AnimateStepType;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ var AnimateStepType, AnimateStatus;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: !0
7
+ }), exports.AnimateStatus = exports.AnimateStepType = void 0, function(AnimateStepType) {
8
+ AnimateStepType.wait = "wait", AnimateStepType.from = "from", AnimateStepType.to = "to",
9
+ AnimateStepType.customAnimate = "customAnimate";
10
+ }(AnimateStepType = exports.AnimateStepType || (exports.AnimateStepType = {})),
11
+ function(AnimateStatus) {
12
+ AnimateStatus[AnimateStatus.INITIAL = 0] = "INITIAL", AnimateStatus[AnimateStatus.RUNNING = 1] = "RUNNING",
13
+ AnimateStatus[AnimateStatus.PAUSED = 2] = "PAUSED", AnimateStatus[AnimateStatus.END = 3] = "END";
14
+ }(AnimateStatus = exports.AnimateStatus || (exports.AnimateStatus = {}));
15
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/intreface/type.ts"],"names":[],"mappings":";;;AAAA,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,gCAAa,CAAA;IACb,gCAAa,CAAA;IACb,4BAAS,CAAA;IACT,kDAA+B,CAAA;AACjC,CAAC,EALW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAK1B;AAED,IAAY,aAKX;AALD,WAAY,aAAa;IACvB,uDAAW,CAAA;IACX,uDAAW,CAAA;IACX,qDAAU,CAAA;IACV,+CAAO,CAAA;AACT,CAAC,EALW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAKxB","file":"type.js","sourcesContent":["export enum AnimateStepType {\n wait = 'wait',\n from = 'from',\n to = 'to',\n customAnimate = 'customAnimate'\n}\n\nexport enum AnimateStatus {\n INITIAL = 0,\n RUNNING = 1,\n PAUSED = 2,\n END = 3\n}\n\nexport type IAnimateStepType = keyof typeof AnimateStepType;\n"]}
@@ -0,0 +1 @@
1
+ export declare function registerAnimate(): void;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.registerAnimate = void 0;
6
+
7
+ const vrender_core_1 = require("@visactor/vrender-core"), animate_1 = require("./animate"), timeline_1 = require("./timeline"), default_ticker_1 = require("./ticker/default-ticker"), vutils_1 = require("@visactor/vutils"), graphic_extension_1 = require("./state/graphic-extension"), animate_extension_1 = require("./animate-extension");
8
+
9
+ function registerAnimate() {
10
+ vrender_core_1.Graphic.Animate || (vrender_core_1.Graphic.Animate = animate_1.Animate),
11
+ vrender_core_1.Graphic.Timeline || (vrender_core_1.Graphic.Timeline = timeline_1.DefaultTimeline),
12
+ vrender_core_1.Graphic.defaultTimeline || (vrender_core_1.Graphic.defaultTimeline = timeline_1.defaultTimeline),
13
+ vrender_core_1.Graphic.Ticker || (vrender_core_1.Graphic.Ticker = default_ticker_1.DefaultTicker),
14
+ (0, vutils_1.mixin)(vrender_core_1.Graphic, graphic_extension_1.GraphicStateExtension),
15
+ (0, vutils_1.mixin)(vrender_core_1.Graphic, animate_extension_1.AnimateExtension);
16
+ }
17
+
18
+ exports.registerAnimate = registerAnimate;
19
+ //# sourceMappingURL=register.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/register.ts"],"names":[],"mappings":";;;AAAA,yDAAiD;AACjD,uCAAoC;AACpC,yCAA8D;AAC9D,4DAAwD;AACxD,6CAAyC;AACzC,iEAAkE;AAClE,2DAAuD;AAEvD,SAAgB,eAAe;IAC7B,IAAI,CAAE,sBAAe,CAAC,OAAO,EAAE;QAC5B,sBAAe,CAAC,OAAO,GAAG,iBAAO,CAAC;KACpC;IACD,IAAI,CAAE,sBAAe,CAAC,QAAQ,EAAE;QAC7B,sBAAe,CAAC,QAAQ,GAAG,0BAAe,CAAC;KAC7C;IACD,IAAI,CAAE,sBAAe,CAAC,eAAe,EAAE;QACpC,sBAAe,CAAC,eAAe,GAAG,0BAAe,CAAC;KACpD;IACD,IAAI,CAAE,sBAAe,CAAC,MAAM,EAAE;QAC3B,sBAAe,CAAC,MAAM,GAAG,8BAAa,CAAC;KACzC;IAGD,IAAA,cAAK,EAAC,sBAAO,EAAE,yCAAqB,CAAC,CAAC;IACtC,IAAA,cAAK,EAAC,sBAAO,EAAE,oCAAgB,CAAC,CAAC;AACnC,CAAC;AAjBD,0CAiBC","file":"register.js","sourcesContent":["import { Graphic } from '@visactor/vrender-core';\nimport { Animate } from './animate';\nimport { defaultTimeline, DefaultTimeline } from './timeline';\nimport { DefaultTicker } from './ticker/default-ticker';\nimport { mixin } from '@visactor/vutils';\nimport { GraphicStateExtension } from './state/graphic-extension';\nimport { AnimateExtension } from './animate-extension';\n\nexport function registerAnimate() {\n if (!(Graphic as any).Animate) {\n (Graphic as any).Animate = Animate;\n }\n if (!(Graphic as any).Timeline) {\n (Graphic as any).Timeline = DefaultTimeline;\n }\n if (!(Graphic as any).defaultTimeline) {\n (Graphic as any).defaultTimeline = defaultTimeline;\n }\n if (!(Graphic as any).Ticker) {\n (Graphic as any).Ticker = DefaultTicker;\n }\n\n // Mix in animation state methods to Graphic prototype\n mixin(Graphic, GraphicStateExtension);\n mixin(Graphic, AnimateExtension);\n}\n"]}
@@ -0,0 +1,22 @@
1
+ import type { IGraphic, IGroup } from '@visactor/vrender-core';
2
+ import type { AnimationStateEventType, IAnimationStateConfig, IAnimationStateRule, IAnimationStateMachine } from '../intreface/state';
3
+ import type { AnimateExecutor } from '../executor/animate-executor';
4
+ type StateEventCallback = (state: string, target: IGraphic | IGroup) => void;
5
+ export declare class AnimationStateMachine implements IAnimationStateMachine {
6
+ private target;
7
+ private executor;
8
+ private registry;
9
+ private stateQueue;
10
+ private eventListeners;
11
+ constructor(target: IGraphic | IGroup, executor: AnimateExecutor);
12
+ applyState(state: string | string[]): void;
13
+ registerState(config: IAnimationStateConfig, rule?: IAnimationStateRule): void;
14
+ getActiveState(): string | null;
15
+ reset(): void;
16
+ on(event: AnimationStateEventType, callback: StateEventCallback): void;
17
+ off(event: AnimationStateEventType, callback: StateEventCallback): void;
18
+ private handleStateEvent;
19
+ hasState(state: string): boolean;
20
+ getRegisteredStates(): string[];
21
+ }
22
+ export {};
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.AnimationStateMachine = void 0;
6
+
7
+ const animation_state_registry_1 = require("./animation-state-registry"), animation_state_queue_1 = require("./animation-state-queue");
8
+
9
+ class AnimationStateMachine {
10
+ constructor(target, executor) {
11
+ this.target = target, this.executor = executor, this.eventListeners = new Map, this.registry = new animation_state_registry_1.AnimationStateRegistry,
12
+ this.stateQueue = new animation_state_queue_1.AnimationStateQueue(target, this.registry, executor, this.handleStateEvent.bind(this));
13
+ }
14
+ applyState(state) {
15
+ this.stateQueue.enqueue(state);
16
+ }
17
+ registerState(config, rule) {
18
+ this.registry.register(config, rule);
19
+ }
20
+ getActiveState() {
21
+ return this.stateQueue.getActiveState();
22
+ }
23
+ reset() {
24
+ this.stateQueue.cancel();
25
+ }
26
+ on(event, callback) {
27
+ var _a;
28
+ this.eventListeners.has(event) || this.eventListeners.set(event, new Set), null === (_a = this.eventListeners.get(event)) || void 0 === _a || _a.add(callback);
29
+ }
30
+ off(event, callback) {
31
+ const listeners = this.eventListeners.get(event);
32
+ listeners && listeners.delete(callback);
33
+ }
34
+ handleStateEvent(event, state) {
35
+ const listeners = this.eventListeners.get(event);
36
+ listeners && listeners.forEach((callback => {
37
+ try {
38
+ callback(state, this.target);
39
+ } catch (error) {
40
+ console.error(`Error in animation state event listener for ${event}:`, error);
41
+ }
42
+ }));
43
+ }
44
+ hasState(state) {
45
+ return !!this.registry.getState(state);
46
+ }
47
+ getRegisteredStates() {
48
+ return this.registry.getAllStateNames();
49
+ }
50
+ }
51
+
52
+ exports.AnimationStateMachine = AnimationStateMachine;
53
+ //# sourceMappingURL=animation-state-machine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/state/animation-state-machine.ts"],"names":[],"mappings":";;;AAOA,yEAAoE;AACpE,mEAA8D;AAQ9D,MAAa,qBAAqB;IAKhC,YAAoB,MAAyB,EAAU,QAAyB;QAA5D,WAAM,GAAN,MAAM,CAAmB;QAAU,aAAQ,GAAR,QAAQ,CAAiB;QAFxE,mBAAc,GAA0D,IAAI,GAAG,EAAE,CAAC;QAGxF,IAAI,CAAC,QAAQ,GAAG,IAAI,iDAAsB,EAAE,CAAC;QAC7C,IAAI,CAAC,UAAU,GAAG,IAAI,2CAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/G,CAAC;IAKD,UAAU,CAAC,KAAwB;QACjC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAKD,aAAa,CAAC,MAA6B,EAAE,IAA0B;QACrE,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACvC,CAAC;IAKD,cAAc;QACZ,OAAO,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC;IAC1C,CAAC;IAKD,KAAK;QACH,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;IAC3B,CAAC;IAKD,EAA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ateEventType,\n IAnimationStateConfig,\n IAnimationStateRule,\n IAnimationStateMachine\n} from '../intreface/state';\nimport { AnimationStateRegistry } from './animation-state-registry';\nimport { AnimationStateQueue } from './animation-state-queue';\nimport type { AnimateExecutor } from '../executor/animate-executor';\n\ntype StateEventCallback = (state: string, target: IGraphic | IGroup) => void;\n\n/**\n * State machine for managing animation states and transitions\n */\nexport class AnimationStateMachine implements IAnimationStateMachine {\n private registry: AnimationStateRegistry;\n private stateQueue: AnimationStateQueue;\n private eventListeners: Map<AnimationStateEventType, Set<StateEventCallback>> = new Map();\n\n constructor(private target: IGraphic | IGroup, private executor: AnimateExecutor) {\n this.registry = new AnimationStateRegistry();\n this.stateQueue = new AnimationStateQueue(target, this.registry, executor, this.handleStateEvent.bind(this));\n }\n\n /**\n * Apply a state or sequence of states\n */\n applyState(state: string | string[]): void {\n this.stateQueue.enqueue(state);\n }\n\n /**\n * Register new state animations and rules\n */\n registerState(config: IAnimationStateConfig, rule?: IAnimationStateRule): void {\n this.registry.register(config, rule);\n }\n\n /**\n * Get current active state\n */\n getActiveState(): string | null {\n return this.stateQueue.getActiveState();\n }\n\n /**\n * Cancel all animations and clear queue\n */\n reset(): void {\n this.stateQueue.cancel();\n }\n\n /**\n * Add event listener for state events\n */\n on(event: AnimationStateEventType, callback: StateEventCallback): void {\n if (!this.eventListeners.has(event)) {\n this.eventListeners.set(event, new Set());\n }\n this.eventListeners.get(event)?.add(callback);\n }\n\n /**\n * Remove event listener\n */\n off(event: AnimationStateEventType, callback: StateEventCallback): void {\n const listeners = this.eventListeners.get(event);\n if (listeners) {\n listeners.delete(callback);\n }\n }\n\n /**\n * Handle state change events from the queue\n */\n private handleStateEvent(event: 'stateStart' | 'stateEnd' | 'stateInterrupt' | 'stateReject', state: string): void {\n const listeners = this.eventListeners.get(event);\n if (listeners) {\n listeners.forEach(callback => {\n try {\n callback(state, this.target);\n } catch (error) {\n console.error(`Error in animation state event listener for ${event}:`, error);\n }\n });\n }\n }\n\n /**\n * Check if a specific state is registered\n */\n hasState(state: string): boolean {\n return !!this.registry.getState(state);\n }\n\n /**\n * Get all registered state names\n */\n getRegisteredStates(): string[] {\n return this.registry.getAllStateNames();\n }\n}\n"]}
@@ -0,0 +1,24 @@
1
+ import type { IGraphic, IGroup } from '@visactor/vrender-core';
2
+ import type { IAnimationStateQueue } from '../intreface/state';
3
+ import type { AnimationStateRegistry } from './animation-state-registry';
4
+ import type { AnimateExecutor } from '../executor/animate-executor';
5
+ export declare class AnimationStateQueue implements IAnimationStateQueue {
6
+ private target;
7
+ private registry;
8
+ private executor;
9
+ private onStateChange;
10
+ private queue;
11
+ private activeState;
12
+ private activeAnimation;
13
+ private processingQueue;
14
+ constructor(target: IGraphic | IGroup, registry: AnimationStateRegistry, executor: AnimateExecutor, onStateChange: (event: 'stateStart' | 'stateEnd' | 'stateInterrupt' | 'stateReject', state: string) => void);
15
+ enqueue(states: string | string[]): void;
16
+ processNextState(): void;
17
+ private applyState;
18
+ onAnimationComplete(): void;
19
+ private interruptCurrentState;
20
+ cancel(): void;
21
+ canApplyState(state: string): boolean;
22
+ getActiveState(): string | null;
23
+ getPendingStates(): string[];
24
+ }
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.AnimationStateQueue = void 0;
6
+
7
+ const vutils_1 = require("@visactor/vutils");
8
+
9
+ class AnimationStateQueue {
10
+ constructor(target, registry, executor, onStateChange) {
11
+ this.target = target, this.registry = registry, this.executor = executor, this.onStateChange = onStateChange,
12
+ this.queue = [], this.activeState = null, this.activeAnimation = null, this.processingQueue = !1;
13
+ }
14
+ enqueue(states) {
15
+ if ((0, vutils_1.isArray)(states)) for (const state of states) this.queue.push(state); else this.queue.push(states);
16
+ this.processingQueue || this.processNextState();
17
+ }
18
+ processNextState() {
19
+ if (0 === this.queue.length || this.processingQueue) return;
20
+ this.processingQueue = !0;
21
+ const nextState = this.queue[0];
22
+ this.canApplyState(nextState) ? (this.queue.shift(), this.activeState && this.registry.hasConflict(this.activeState, nextState) ? this.registry.canInterrupt(this.activeState, nextState) ? (this.interruptCurrentState(),
23
+ this.applyState(nextState)) : (this.onStateChange("stateReject", nextState), this.processingQueue = !1,
24
+ this.processNextState()) : this.applyState(nextState)) : (this.queue.shift(), this.onStateChange("stateReject", nextState),
25
+ this.processingQueue = !1, this.processNextState());
26
+ }
27
+ applyState(state) {
28
+ const stateConfig = this.registry.getState(state);
29
+ if (!stateConfig) return console.warn(`Animation state "${state}" not found`), this.processingQueue = !1,
30
+ void this.processNextState();
31
+ this.activeState = state, this.onStateChange("stateStart", state), this.activeAnimation = this.executor.executeItem(stateConfig.animation, this.target),
32
+ this.activeAnimation ? this.activeAnimation.onEnd((() => {
33
+ this.onAnimationComplete();
34
+ })) : this.onAnimationComplete();
35
+ }
36
+ onAnimationComplete() {
37
+ if (this.activeState) {
38
+ const completedState = this.activeState;
39
+ this.onStateChange("stateEnd", completedState);
40
+ const transitionDelay = this.registry.getTransitionDelay(completedState);
41
+ this.activeState = null, this.activeAnimation = null, this.processingQueue = !1,
42
+ transitionDelay > 0 ? setTimeout((() => {
43
+ this.processNextState();
44
+ }), transitionDelay) : this.processNextState();
45
+ }
46
+ }
47
+ interruptCurrentState() {
48
+ this.activeState && this.activeAnimation && (this.onStateChange("stateInterrupt", this.activeState),
49
+ this.activeAnimation.stop("end"), this.activeAnimation = null, this.activeState = null);
50
+ }
51
+ cancel() {
52
+ this.interruptCurrentState(), this.queue = [], this.processingQueue = !1;
53
+ }
54
+ canApplyState(state) {
55
+ return !!this.registry.getState(state) && (!this.activeState || (!this.registry.hasConflict(this.activeState, state) || this.registry.canInterrupt(this.activeState, state)));
56
+ }
57
+ getActiveState() {
58
+ return this.activeState;
59
+ }
60
+ getPendingStates() {
61
+ return [ ...this.queue ];
62
+ }
63
+ }
64
+
65
+ exports.AnimationStateQueue = AnimationStateQueue;
66
+ //# sourceMappingURL=animation-state-queue.js.map
@@ -0,0 +1 @@
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a;QAEzB,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAClD,IAAI,CAAC,WAAW,EAAE;YAChB,OAAO,KAAK,CAAC;SACd;QAGD,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACrB,OAAO,IAAI,CAAC;SACb;QAGD,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,EAAE;YACtD,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;SAC5D;QAGD,OAAO,IAAI,CAAC;IACd,CAAC;IAKD,cAAc;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAKD,gBAAgB;QACd,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;CACF;AA/LD,kDA+LC","file":"animation-state-queue.js","sourcesContent":["import type { IGraphic, IGroup } from '@visactor/vrender-core';\nimport type { IAnimate } from '../intreface/animate';\nimport type { IAnimationStateQueue } from '../intreface/state';\nimport type { AnimationStateRegistry } from './animation-state-registry';\nimport type { AnimateExecutor } from '../executor/animate-executor';\nimport { isArray } from '@visactor/vutils';\n\n/**\n * Queue for managing sequential animation states\n */\nexport class AnimationStateQueue implements IAnimationStateQueue {\n private queue: string[] = [];\n private activeState: string | null = null;\n private activeAnimation: IAnimate | null = null;\n private processingQueue: boolean = false;\n\n constructor(\n private target: IGraphic | IGroup,\n private registry: AnimationStateRegistry,\n private executor: AnimateExecutor,\n private onStateChange: (event: 'stateStart' | 'stateEnd' | 'stateInterrupt' | 'stateReject', state: string) => void\n ) {}\n\n /**\n * Add state(s) to queue\n */\n enqueue(states: string | string[]): void {\n if (isArray(states)) {\n // For array of states, add them to the queue in sequence\n for (const state of states) {\n this.queue.push(state);\n }\n } else {\n this.queue.push(states);\n }\n\n // If not already processing, start processing the queue\n if (!this.processingQueue) {\n this.processNextState();\n }\n }\n\n /**\n * Process the next state in queue\n */\n processNextState(): void {\n if (this.queue.length === 0 || this.processingQueue) {\n return;\n }\n\n this.processingQueue = true;\n const nextState = this.queue[0];\n\n // Check if we can apply this state now\n if (this.canApplyState(nextState)) {\n // Remove the state from the queue\n this.queue.shift();\n\n // If there's an active state that conflicts, we need to handle it\n if (this.activeState && this.registry.hasConflict(this.activeState, nextState)) {\n // Check if new state can interrupt current state\n if (this.registry.canInterrupt(this.activeState, nextState)) {\n // Interrupt current animation\n this.interruptCurrentState();\n this.applyState(nextState);\n } else {\n // Cannot interrupt, reject the state\n this.onStateChange('stateReject', nextState);\n this.processingQueue = false;\n this.processNextState(); // Continue with the next state\n }\n } else {\n // No conflict, apply the state\n this.applyState(nextState);\n }\n } else {\n // Cannot apply this state right now, reject it\n this.queue.shift();\n this.onStateChange('stateReject', nextState);\n this.processingQueue = false;\n this.processNextState(); // Continue with the next state\n }\n }\n\n /**\n * Apply a state animation\n */\n private applyState(state: string): void {\n const stateConfig = this.registry.getState(state);\n if (!stateConfig) {\n console.warn(`Animation state \"${state}\" not found`);\n this.processingQueue = false;\n this.processNextState();\n return;\n }\n\n this.activeState = state;\n this.onStateChange('stateStart', state);\n\n // Create and execute the animation\n this.activeAnimation = this.executor.executeItem(stateConfig.animation, this.target);\n\n // Register completion callback\n if (this.activeAnimation) {\n this.activeAnimation.onEnd(() => {\n this.onAnimationComplete();\n });\n } else {\n // If no animation was created, consider it completed immediately\n this.onAnimationComplete();\n }\n }\n\n /**\n * Called when current animation completes\n */\n onAnimationComplete(): void {\n if (this.activeState) {\n const completedState = this.activeState;\n this.onStateChange('stateEnd', completedState);\n\n // Apply transition delay if configured\n const transitionDelay = this.registry.getTransitionDelay(completedState);\n\n this.activeState = null;\n this.activeAnimation = null;\n this.processingQueue = false;\n\n if (transitionDelay > 0) {\n // Wait before processing next state\n setTimeout(() => {\n this.processNextState();\n }, transitionDelay);\n } else {\n // Process next state immediately\n this.processNextState();\n }\n }\n }\n\n /**\n * Interrupt the current state animation\n */\n private interruptCurrentState(): void {\n if (this.activeState && this.activeAnimation) {\n this.onStateChange('stateInterrupt', this.activeState);\n this.activeAnimation.stop('end'); // Stop at end state to avoid visual jumps\n this.activeAnimation = null;\n this.activeState = null;\n }\n }\n\n /**\n * Cancel current state and clear queue\n */\n cancel(): void {\n // Interrupt current animation if any\n this.interruptCurrentState();\n\n // Clear the queue\n this.queue = [];\n this.processingQueue = false;\n }\n\n /**\n * Check if we can apply a specific state now\n */\n canApplyState(state: string): boolean {\n // Check if the state is registered\n const stateConfig = this.registry.getState(state);\n if (!stateConfig) {\n return false;\n }\n\n // If there's no active state, we can apply\n if (!this.activeState) {\n return true;\n }\n\n // Check if there's a conflict and if we can resolve it\n if (this.registry.hasConflict(this.activeState, state)) {\n return this.registry.canInterrupt(this.activeState, state);\n }\n\n // No conflict, we can apply\n return true;\n }\n\n /**\n * Get the currently active state\n */\n getActiveState(): string | null {\n return this.activeState;\n }\n\n /**\n * Get the pending states in the queue\n */\n getPendingStates(): string[] {\n return [...this.queue];\n }\n}\n"]}
@@ -0,0 +1,14 @@
1
+ import type { IAnimationStateConfig, IAnimationStateRegistry, IAnimationStateRule } from '../intreface/state';
2
+ export declare class AnimationStateRegistry implements IAnimationStateRegistry {
3
+ private states;
4
+ private rules;
5
+ register(state: IAnimationStateConfig, rule?: IAnimationStateRule): void;
6
+ getState(name: string): IAnimationStateConfig | undefined;
7
+ getRule(name: string): IAnimationStateRule | undefined;
8
+ hasConflict(stateA: string, stateB: string): boolean;
9
+ canInterrupt(stateA: string, stateB: string): boolean;
10
+ isQueueable(state: string): boolean;
11
+ getTransitionDelay(state: string): number;
12
+ getAllStateNames(): string[];
13
+ clear(): void;
14
+ }
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.AnimationStateRegistry = void 0;
6
+
7
+ class AnimationStateRegistry {
8
+ constructor() {
9
+ this.states = new Map, this.rules = new Map;
10
+ }
11
+ register(state, rule) {
12
+ var _a;
13
+ const {name: name} = state;
14
+ name ? (this.states.set(name, Object.assign(Object.assign({}, state), {
15
+ priority: null !== (_a = state.priority) && void 0 !== _a ? _a : 0
16
+ })), rule && this.rules.set(name, rule)) : console.warn("Animation state must have a name");
17
+ }
18
+ getState(name) {
19
+ return this.states.get(name);
20
+ }
21
+ getRule(name) {
22
+ return this.rules.get(name);
23
+ }
24
+ hasConflict(stateA, stateB) {
25
+ var _a, _b;
26
+ if (stateA === stateB) return !1;
27
+ const ruleA = this.getRule(stateA), ruleB = this.getRule(stateB);
28
+ return !!(null === (_a = null == ruleA ? void 0 : ruleA.conflicts) || void 0 === _a ? void 0 : _a.includes(stateB)) || !!(null === (_b = null == ruleB ? void 0 : ruleB.conflicts) || void 0 === _b ? void 0 : _b.includes(stateA));
29
+ }
30
+ canInterrupt(stateA, stateB) {
31
+ var _a, _b, _c;
32
+ const ruleA = this.getRule(stateA), stateAConfig = this.getState(stateA), stateBConfig = this.getState(stateB);
33
+ return !!(stateAConfig && stateBConfig && (null !== (_a = stateBConfig.priority) && void 0 !== _a ? _a : 0) > (null !== (_b = stateAConfig.priority) && void 0 !== _b ? _b : 0)) || !!(null === (_c = null == ruleA ? void 0 : ruleA.interruptibleBy) || void 0 === _c ? void 0 : _c.includes(stateB));
34
+ }
35
+ isQueueable(state) {
36
+ const rule = this.getRule(state);
37
+ return !!(null == rule ? void 0 : rule.queueable);
38
+ }
39
+ getTransitionDelay(state) {
40
+ var _a;
41
+ const rule = this.getRule(state);
42
+ return null !== (_a = null == rule ? void 0 : rule.transitionDelay) && void 0 !== _a ? _a : 0;
43
+ }
44
+ getAllStateNames() {
45
+ return Array.from(this.states.keys());
46
+ }
47
+ clear() {
48
+ this.states.clear(), this.rules.clear();
49
+ }
50
+ }
51
+
52
+ exports.AnimationStateRegistry = AnimationStateRegistry;
53
+ //# sourceMappingURL=animation-state-registry.js.map
@@ -0,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,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;CACF;AA5GD,wDA4GC","file":"animation-state-registry.js","sourcesContent":["import type { IAnimationStateConfig, IAnimationStateRegistry, IAnimationStateRule } from '../intreface/state';\n\n/**\n * Registry for animation states and their rules\n */\nexport class AnimationStateRegistry implements IAnimationStateRegistry {\n private states: Map<string, IAnimationStateConfig> = new Map();\n private rules: Map<string, IAnimationStateRule> = new Map();\n\n /**\n * Register a state with its animation config and rules\n */\n register(state: IAnimationStateConfig, rule?: IAnimationStateRule): void {\n const { name } = state;\n\n if (!name) {\n console.warn('Animation state must have a name');\n return;\n }\n\n this.states.set(name, {\n ...state,\n priority: state.priority ?? 0\n });\n\n if (rule) {\n this.rules.set(name, rule);\n }\n }\n\n /**\n * Get state configuration by name\n */\n getState(name: string): IAnimationStateConfig | undefined {\n return this.states.get(name);\n }\n\n /**\n * Get state rule by name\n */\n getRule(name: string): IAnimationStateRule | undefined {\n return this.rules.get(name);\n }\n\n /**\n * Check if two states conflict with each other\n */\n hasConflict(stateA: string, stateB: string): boolean {\n if (stateA === stateB) {\n return false; // Same state doesn't conflict with itself\n }\n\n const ruleA = this.getRule(stateA);\n const ruleB = this.getRule(stateB);\n\n if (ruleA?.conflicts?.includes(stateB)) {\n return true;\n }\n\n if (ruleB?.conflicts?.includes(stateA)) {\n return true;\n }\n\n return false;\n }\n\n /**\n * Check if stateB can interrupt stateA\n */\n canInterrupt(stateA: string, stateB: string): boolean {\n const ruleA = this.getRule(stateA);\n const stateAConfig = this.getState(stateA);\n const stateBConfig = this.getState(stateB);\n\n // Higher priority can always interrupt\n if (stateAConfig && stateBConfig && (stateBConfig.priority ?? 0) > (stateAConfig.priority ?? 0)) {\n return true;\n }\n\n // Check if explicitly interruptible\n return !!ruleA?.interruptibleBy?.includes(stateB);\n }\n\n /**\n * Check if a state is queueable\n */\n isQueueable(state: string): boolean {\n const rule = this.getRule(state);\n return !!rule?.queueable;\n }\n\n /**\n * Get transition delay for a state\n */\n getTransitionDelay(state: string): number {\n const rule = this.getRule(state);\n return rule?.transitionDelay ?? 0;\n }\n\n /**\n * Get all registered state names\n */\n getAllStateNames(): string[] {\n return Array.from(this.states.keys());\n }\n\n /**\n * Clear all registered states and rules\n */\n clear(): void {\n this.states.clear();\n this.rules.clear();\n }\n}\n"]}
@@ -0,0 +1,25 @@
1
+ import type { IGraphic } from '@visactor/vrender-core';
2
+ import type { IAnimationState } from './types';
3
+ import type { IAnimationConfig } from '../executor/executor';
4
+ import { AnimateExecutor } from '../executor/animate-executor';
5
+ export declare class AnimationStateStore {
6
+ graphic: IGraphic;
7
+ constructor(graphic: IGraphic);
8
+ states?: Map<string, IAnimationState>;
9
+ registerState(state: IAnimationState): void;
10
+ clearStates(): void;
11
+ }
12
+ interface IStateInfo {
13
+ state: string;
14
+ animationConfig: IAnimationConfig;
15
+ executor: AnimateExecutor;
16
+ }
17
+ export declare class AnimationStateManager {
18
+ protected graphic: IGraphic;
19
+ stateList: IStateInfo[] | null;
20
+ constructor(graphic: IGraphic);
21
+ applyState(nextState: string[], animationConfig: IAnimationState[], callback?: (empty?: boolean) => void): void;
22
+ stopState(state: string, type?: 'start' | 'end' | Record<string, any>): void;
23
+ clearState(): void;
24
+ }
25
+ export {};