@visactor/vrender-animate 0.22.4 → 0.23.0-alpha.2

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 (41) hide show
  1. package/cjs/custom/growAngle.js +2 -1
  2. package/cjs/custom/growRadius.js +1 -2
  3. package/es/custom/growAngle.js +2 -1
  4. package/es/custom/growRadius.js +1 -2
  5. package/package.json +15 -15
  6. package/cjs/custom/scale-in.d.ts +0 -13
  7. package/cjs/custom/scale-in.js +0 -57
  8. package/cjs/custom/scale-in.js.map +0 -1
  9. package/cjs/interpolate/executor.d.ts +0 -66
  10. package/cjs/interpolate/executor.js +0 -6
  11. package/cjs/interpolate/executor.js.map +0 -1
  12. package/cjs/intreface/state.d.ts +0 -35
  13. package/cjs/intreface/state.js +0 -6
  14. package/cjs/intreface/state.js.map +0 -1
  15. package/cjs/state/animation-state-machine.d.ts +0 -22
  16. package/cjs/state/animation-state-machine.js +0 -53
  17. package/cjs/state/animation-state-machine.js.map +0 -1
  18. package/cjs/state/animation-state-queue.d.ts +0 -24
  19. package/cjs/state/animation-state-queue.js +0 -66
  20. package/cjs/state/animation-state-queue.js.map +0 -1
  21. package/cjs/state/animation-state-registry.d.ts +0 -14
  22. package/cjs/state/animation-state-registry.js +0 -53
  23. package/cjs/state/animation-state-registry.js.map +0 -1
  24. package/es/custom/scale-in.d.ts +0 -13
  25. package/es/custom/scale-in.js +0 -49
  26. package/es/custom/scale-in.js.map +0 -1
  27. package/es/interpolate/executor.d.ts +0 -66
  28. package/es/interpolate/executor.js +0 -2
  29. package/es/interpolate/executor.js.map +0 -1
  30. package/es/intreface/state.d.ts +0 -35
  31. package/es/intreface/state.js +0 -2
  32. package/es/intreface/state.js.map +0 -1
  33. package/es/state/animation-state-machine.d.ts +0 -22
  34. package/es/state/animation-state-machine.js +0 -47
  35. package/es/state/animation-state-machine.js.map +0 -1
  36. package/es/state/animation-state-queue.d.ts +0 -24
  37. package/es/state/animation-state-queue.js +0 -58
  38. package/es/state/animation-state-queue.js.map +0 -1
  39. package/es/state/animation-state-registry.d.ts +0 -14
  40. package/es/state/animation-state-registry.js +0 -45
  41. package/es/state/animation-state-registry.js.map +0 -1
@@ -137,4 +137,5 @@ class GrowAngleOut extends GworPointsBase {
137
137
  }
138
138
  }
139
139
 
140
- exports.GrowAngleOut = GrowAngleOut;
140
+ exports.GrowAngleOut = GrowAngleOut;
141
+ //# sourceMappingURL=growAngle.js.map
@@ -109,5 +109,4 @@ class GrowRadiusOut extends GworPointsBase {
109
109
  }
110
110
  }
111
111
 
112
- exports.GrowRadiusOut = GrowRadiusOut;
113
- //# sourceMappingURL=growRadius.js.map
112
+ exports.GrowRadiusOut = GrowRadiusOut;
@@ -129,4 +129,5 @@ export class GrowAngleOut extends GworPointsBase {
129
129
  this.props = to, this.propKeys = Object.keys(to).filter((key => null != to[key])),
130
130
  this.animate.reSyncProps(), this.from = fromAttrs, this.to = to, this.target.setAttributes(fromAttrs);
131
131
  }
132
- }
132
+ }
133
+ //# sourceMappingURL=growAngle.js.map
@@ -101,5 +101,4 @@ export class GrowRadiusOut extends GworPointsBase {
101
101
  this.props = to, this.propKeys = Object.keys(to).filter((key => null != to[key])),
102
102
  this.animate.reSyncProps(), this.from = fromAttrs, this.to = to, this.target.setAttributes(fromAttrs);
103
103
  }
104
- }
105
- //# sourceMappingURL=growRadius.js.map
104
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visactor/vrender-animate",
3
- "version": "0.22.4",
3
+ "version": "0.23.0-alpha.2",
4
4
  "description": "",
5
5
  "sideEffects": false,
6
6
  "main": "cjs/index.js",
@@ -11,22 +11,11 @@
11
11
  "es",
12
12
  "dist"
13
13
  ],
14
- "scripts": {
15
- "compile": "tsc --noEmit",
16
- "eslint": "eslint --debug --fix src/",
17
- "build": "cross-env DEBUG='Bundler*' bundle",
18
- "dev": "cross-env DEBUG='Bundler*' bundle --clean -f es -w",
19
- "start": "vite ./vite",
20
- "test": ""
21
- },
22
14
  "dependencies": {
23
15
  "@visactor/vutils": "~0.19.4",
24
- "@visactor/vrender-core": "workspace:0.22.4"
16
+ "@visactor/vrender-core": "0.23.0-alpha.2"
25
17
  },
26
18
  "devDependencies": {
27
- "@internal/bundler": "workspace:*",
28
- "@internal/eslint-config": "workspace:*",
29
- "@internal/ts-config": "workspace:*",
30
19
  "@rushstack/eslint-patch": "~1.1.4",
31
20
  "canvas": "2.11.2",
32
21
  "node-fetch": "2.6.6",
@@ -39,7 +28,10 @@
39
28
  "eslint": "~8.18.0",
40
29
  "vite": "3.2.6",
41
30
  "typescript": "4.9.5",
42
- "cross-env": "^7.0.3"
31
+ "cross-env": "^7.0.3",
32
+ "@internal/bundler": "0.0.1",
33
+ "@internal/eslint-config": "0.0.1",
34
+ "@internal/ts-config": "0.0.1"
43
35
  },
44
36
  "keywords": [
45
37
  "VisActor",
@@ -68,5 +60,13 @@
68
60
  "import": "./es/index.js",
69
61
  "require": "./cjs/index.js"
70
62
  }
63
+ },
64
+ "scripts": {
65
+ "compile": "tsc --noEmit",
66
+ "eslint": "eslint --debug --fix src/",
67
+ "build": "cross-env DEBUG='Bundler*' bundle",
68
+ "dev": "cross-env DEBUG='Bundler*' bundle --clean -f es -w",
69
+ "start": "vite ./vite",
70
+ "test": ""
71
71
  }
72
- }
72
+ }
@@ -1,13 +0,0 @@
1
- import type { IAnimate, IStep } from '../intreface/animate';
2
- import type { EasingType } from '../intreface/easing';
3
- import { ACustomAnimate } from './custom-animate';
4
- export interface IScaleAnimationOptions {
5
- direction?: 'x' | 'y' | 'xy';
6
- }
7
- export declare class ScaleIn extends ACustomAnimate<Record<string, number>> {
8
- valid: boolean;
9
- constructor(from: null, to: null, duration: number, easing: EasingType, params?: IScaleAnimationOptions);
10
- onFirstRun(): void;
11
- onEnd(cb?: (animate: IAnimate, step: IStep) => void): void;
12
- onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
13
- }
@@ -1,57 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: !0
5
- }), exports.ScaleIn = void 0;
6
-
7
- const custom_animate_1 = require("./custom-animate");
8
-
9
- class ScaleIn extends custom_animate_1.ACustomAnimate {
10
- constructor(from, to, duration, easing, params) {
11
- super(from, to, duration, easing, params);
12
- }
13
- onFirstRun() {
14
- var _a, _b, _c, _d, _e;
15
- let from, to;
16
- const attrs = this.target.getAttributes();
17
- switch (null === (_a = this.params) || void 0 === _a ? void 0 : _a.direction) {
18
- case "x":
19
- from = {
20
- scaleX: 0
21
- }, to = {
22
- scaleX: null !== (_b = null == attrs ? void 0 : attrs.scaleX) && void 0 !== _b ? _b : 1
23
- };
24
- break;
25
-
26
- case "y":
27
- from = {
28
- scaleY: 0
29
- }, to = {
30
- scaleY: null !== (_c = null == attrs ? void 0 : attrs.scaleY) && void 0 !== _c ? _c : 1
31
- };
32
- break;
33
-
34
- default:
35
- from = {
36
- scaleX: 0,
37
- scaleY: 0
38
- }, to = {
39
- scaleX: null !== (_d = null == attrs ? void 0 : attrs.scaleX) && void 0 !== _d ? _d : 1,
40
- scaleY: null !== (_e = null == attrs ? void 0 : attrs.scaleY) && void 0 !== _e ? _e : 1
41
- };
42
- }
43
- this.props = to, this.propKeys = Object.keys(to), this.animate.reSyncProps(), this.from = from,
44
- this.to = to;
45
- }
46
- onEnd(cb) {
47
- super.onEnd(cb);
48
- }
49
- onUpdate(end, ratio, out) {
50
- this.valid && (this.propKeys.forEach((key => {
51
- out[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
52
- })), this.target.setAttributes(out));
53
- }
54
- }
55
-
56
- exports.ScaleIn = ScaleIn;
57
- //# sourceMappingURL=scale-in.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/custom/scale-in.ts"],"names":[],"mappings":";;;AAEA,qDAAkD;AAWlD,MAAa,OAAQ,SAAQ,+BAAsC;IAGjE,YAAY,IAAU,EAAE,EAAQ,EAAE,QAAgB,EAAE,MAAkB,EAA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,EAAE,CAAC;IACf,CAAC;IAED,KAAK,CAAC,EAA6C;QACjD,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAClB,CAAC;IAED,QAAQ,CAAC,GAAY,EAAE,KAAa,EAAE,GAAwB;QAC5D,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACf,OAAO;SACR;QAED,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAC1B,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;QACtE,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;CACF;AAlDD,0BAkDC","file":"scale-in.js","sourcesContent":["import type { IAnimate, IStep } from '../intreface/animate';\nimport type { EasingType } from '../intreface/easing';\nimport { ACustomAnimate } from './custom-animate';\n\nexport interface IScaleAnimationOptions {\n direction?: 'x' | 'y' | 'xy';\n}\n\n/**\n * 文本输入动画,实现类似打字机的字符逐个显示效果\n * 支持通过beforeText和afterText参数添加前缀和后缀\n * 支持通过showCursor参数显示光标,cursorChar自定义光标字符\n */\nexport class ScaleIn extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: IScaleAnimationOptions) {\n super(from, to, duration, easing, params);\n }\n\n onFirstRun(): void {\n let from: Record<string, number>;\n let to: Record<string, number>;\n // 获取当前的数据\n const attrs = this.target.getAttributes();\n switch (this.params?.direction) {\n case 'x':\n from = { scaleX: 0 };\n to = { scaleX: attrs?.scaleX ?? 1 };\n break;\n case 'y':\n from = { scaleY: 0 };\n to = { scaleY: attrs?.scaleY ?? 1 };\n break;\n case 'xy':\n default:\n from = { scaleX: 0, scaleY: 0 };\n to = {\n scaleX: attrs?.scaleX ?? 1,\n scaleY: attrs?.scaleY ?? 1\n };\n }\n this.props = to;\n this.propKeys = Object.keys(to);\n this.animate.reSyncProps();\n this.from = from;\n this.to = to;\n }\n\n onEnd(cb?: (animate: IAnimate, step: IStep) => void): void {\n super.onEnd(cb);\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n if (!this.valid) {\n return;\n }\n\n this.propKeys.forEach(key => {\n out[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;\n });\n this.target.setAttributes(out);\n }\n}\n"]}
@@ -1,66 +0,0 @@
1
- import type { IGraphic } from '@visactor/vrender-core';
2
- import type { EasingType } from '../intreface/easing';
3
- import type { ACustomAnimate } from '../custom/custom-animate';
4
- export type MarkFunctionCallback<T> = (datum: any, graphic: IGraphic, parameters: any) => T;
5
- export type MarkFunctionValueType<T> = MarkFunctionCallback<T> | T;
6
- interface IAnimationParameters {
7
- [key: string]: any;
8
- }
9
- export type IAnimationChannelFunction = (datum: any, element: IGraphic, parameters: IAnimationParameters) => any;
10
- export type IAnimationChannelAttrs = Record<string, {
11
- from?: any | IAnimationChannelFunction;
12
- to?: any | IAnimationChannelFunction;
13
- }>;
14
- export type IAnimationChannelAttributes = string[];
15
- export type IAnimationChannelInterpolator = (ratio: number, from: any, to: any, nextAttributes: any, datum: any, element: IGraphic, parameters: IAnimationParameters) => boolean | void;
16
- export interface IAnimationCustomConstructor {
17
- new (from: any, to: any, duration: number, ease: EasingType, parameters?: any): ACustomAnimate<any>;
18
- }
19
- export interface IAnimationEffect {
20
- type?: string;
21
- channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;
22
- custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;
23
- customParameters?: MarkFunctionValueType<any>;
24
- easing?: EasingType;
25
- options?: MarkFunctionValueType<any>;
26
- }
27
- export interface IAnimationTimeSlice {
28
- effects: IAnimationEffect | IAnimationEffect[];
29
- duration?: MarkFunctionValueType<number>;
30
- delay?: MarkFunctionValueType<number>;
31
- delayAfter?: MarkFunctionValueType<number>;
32
- }
33
- export interface IAnimationControlOptions {
34
- stopWhenStateChange?: boolean;
35
- immediatelyApply?: boolean;
36
- ignoreLoopFinalAttributes?: boolean;
37
- }
38
- export interface IAnimationTypeConfig {
39
- type?: string;
40
- channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;
41
- custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;
42
- customParameters?: MarkFunctionValueType<any>;
43
- easing?: EasingType;
44
- delay?: MarkFunctionValueType<number>;
45
- delayAfter?: MarkFunctionValueType<number>;
46
- duration?: MarkFunctionValueType<number>;
47
- oneByOne?: MarkFunctionValueType<boolean | number>;
48
- startTime?: MarkFunctionValueType<number>;
49
- totalTime?: MarkFunctionValueType<number>;
50
- loop?: boolean | number;
51
- options?: MarkFunctionValueType<any>;
52
- controlOptions?: IAnimationControlOptions;
53
- }
54
- export interface IAnimationTimeline {
55
- id?: string;
56
- timeSlices: IAnimationTimeSlice | IAnimationTimeSlice[];
57
- startTime?: MarkFunctionValueType<number>;
58
- totalTime?: MarkFunctionValueType<number>;
59
- oneByOne?: MarkFunctionValueType<number | boolean>;
60
- loop?: MarkFunctionValueType<number | boolean>;
61
- partitioner?: MarkFunctionCallback<boolean>;
62
- sort?: (datumA: any, datumB: any, elementA: IGraphic, elementB: IGraphic, parameters: any) => number;
63
- controlOptions?: IAnimationControlOptions;
64
- }
65
- export type IAnimationConfig = IAnimationTimeline | IAnimationTypeConfig;
66
- export {};
@@ -1,6 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: !0
5
- });
6
- //# sourceMappingURL=executor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/interpolate/executor.ts"],"names":[],"mappings":"","file":"executor.js","sourcesContent":["import type { IGraphic } from '@visactor/vrender-core';\nimport type { EasingType } from '../intreface/easing';\nimport type { ACustomAnimate } from '../custom/custom-animate';\n\nexport type MarkFunctionCallback<T> = (datum: any, graphic: IGraphic, parameters: any) => T;\nexport type MarkFunctionValueType<T> = MarkFunctionCallback<T> | T;\n\ninterface IAnimationParameters {\n [key: string]: any;\n}\n\n/**\n * 动画 channel 配置\n */\nexport type IAnimationChannelFunction = (datum: any, element: IGraphic, parameters: IAnimationParameters) => any;\n\n/**\n * 动画 channel 属性配置\n */\nexport type IAnimationChannelAttrs = Record<\n string,\n {\n from?: any | IAnimationChannelFunction;\n to?: any | IAnimationChannelFunction;\n }\n>;\nexport type IAnimationChannelAttributes = string[];\n\n/**\n * 动画 channel 插值器\n */\nexport type IAnimationChannelInterpolator = (\n ratio: number,\n from: any,\n to: any,\n nextAttributes: any,\n datum: any,\n element: IGraphic,\n parameters: IAnimationParameters\n) => boolean | void;\n\n/**\n * 动画 custom 构造器\n */\nexport interface IAnimationCustomConstructor {\n new (from: any, to: any, duration: number, ease: EasingType, parameters?: any): ACustomAnimate<any>;\n}\n\nexport interface IAnimationEffect {\n /** 动画类型 */\n type?: string;\n /** 动画 channel 配置 */\n channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;\n /** 动画 自定义插值 配置 */\n custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;\n /** 动画 custom 参数配置 */\n customParameters?: MarkFunctionValueType<any>;\n /** 动画 easing 配置 */\n easing?: EasingType;\n /** options暂时没有处理 */\n options?: MarkFunctionValueType<any>;\n}\n\nexport interface IAnimationTimeSlice {\n /** 动画效果 */\n effects: IAnimationEffect | IAnimationEffect[];\n /** 动画时长 */\n duration?: MarkFunctionValueType<number>;\n /** 延迟delay后执行动画 */\n delay?: MarkFunctionValueType<number>;\n /** effect动画后再延迟delayAfter结束这个周期 */\n delayAfter?: MarkFunctionValueType<number>;\n}\n\nexport interface IAnimationControlOptions {\n /** 当动画状态变更时清空动画 */\n stopWhenStateChange?: boolean;\n /** 是否立即应用动画初始状态 */\n immediatelyApply?: boolean;\n /** encode 计算图元最终状态时是否忽略循环动画 */\n ignoreLoopFinalAttributes?: boolean;\n}\n\n/**\n * 动画 config 简化配置\n */\nexport interface IAnimationTypeConfig {\n /** 动画类型 */\n type?: string;\n /** 动画 channel 配置 */\n channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;\n /** 动画 自定义插值 配置 */\n custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;\n /** 动画 custom 参数配置 */\n customParameters?: MarkFunctionValueType<any>;\n /** 动画 easing 配置 */\n easing?: EasingType;\n /** 动画 delay 配置 */\n delay?: MarkFunctionValueType<number>;\n /** 动画 delayAfter 配置 */\n delayAfter?: MarkFunctionValueType<number>;\n /** 动画 duration 配置 */\n duration?: MarkFunctionValueType<number>;\n /** 动画 oneByOne 配置(是否依次执行) */\n oneByOne?: MarkFunctionValueType<boolean | number>;\n /** 动画 startTime 配置 */\n startTime?: MarkFunctionValueType<number>;\n /** 动画 totalTime 配置 */\n totalTime?: MarkFunctionValueType<number>;\n /** loop: true 无限循环; loop: 正整数,表示循环的次数 */\n loop?: boolean | number;\n /** 动画 effect 配置项 */\n options?: MarkFunctionValueType<any>;\n /** 动画执行相关控制配置项 */\n controlOptions?: IAnimationControlOptions;\n}\n\n/**\n * 动画 timeline 完整配置,一条时间线内的动画单元只能串行\n * 多个timeline是可以并行的\n * 考虑到同一图元不能在多个timeline上,所以timeline不应该提供数组配置的能力\n */\nexport interface IAnimationTimeline {\n /** 为了方便动画编排,用户可以设置 id 用于识别时间线 */\n id?: string;\n /** 时间切片 */\n timeSlices: IAnimationTimeSlice | IAnimationTimeSlice[];\n /** 动画开始的相对时间,可以为负数 */\n startTime?: MarkFunctionValueType<number>;\n /** 动画时长 */\n totalTime?: MarkFunctionValueType<number>;\n /** 动画依次执行的延迟 */\n oneByOne?: MarkFunctionValueType<number | boolean>;\n /** loop: true 无限循环; loop: 正整数,表示循环的次数 */\n loop?: MarkFunctionValueType<number | boolean>;\n /** 对图元元素进行划分,和过滤类似,但是不同时间线不能同时作用在相同的元素上 */\n partitioner?: MarkFunctionCallback<boolean>;\n /** 对同一时间线上的元素进行排序 */\n sort?: (datumA: any, datumB: any, elementA: IGraphic, elementB: IGraphic, parameters: any) => number;\n /** 动画执行相关控制配置项 */\n controlOptions?: IAnimationControlOptions;\n}\n\n/**\n * 动画配置\n */\nexport type IAnimationConfig = IAnimationTimeline | IAnimationTypeConfig;\n"]}
@@ -1,35 +0,0 @@
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
- }
@@ -1,6 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: !0
5
- });
6
- //# sourceMappingURL=state.js.map
@@ -1 +0,0 @@
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"]}
@@ -1,22 +0,0 @@
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 {};
@@ -1,53 +0,0 @@
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
@@ -1 +0,0 @@
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;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I,CAAC,QAAQ,CAAC,gBAAgB,EAAE,CAAC;IAC1C,CAAC;CACF;AAvFD,sDAuFC","file":"animation-state-machine.js","sourcesContent":["import type { IGraphic, IGroup } from '@visactor/vrender-core';\nimport type {\n AnimationStateEventType,\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"]}
@@ -1,24 +0,0 @@
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
- }
@@ -1,66 +0,0 @@
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
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AK,CAAC;IAC/B,CAAC;IAKD,aAAa,CAAC,KAAa;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"]}
@@ -1,14 +0,0 @@
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
- }
@@ -1,53 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/state/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AE,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"]}
@@ -1,13 +0,0 @@
1
- import type { IAnimate, IStep } from '../intreface/animate';
2
- import type { EasingType } from '../intreface/easing';
3
- import { ACustomAnimate } from './custom-animate';
4
- export interface IScaleAnimationOptions {
5
- direction?: 'x' | 'y' | 'xy';
6
- }
7
- export declare class ScaleIn extends ACustomAnimate<Record<string, number>> {
8
- valid: boolean;
9
- constructor(from: null, to: null, duration: number, easing: EasingType, params?: IScaleAnimationOptions);
10
- onFirstRun(): void;
11
- onEnd(cb?: (animate: IAnimate, step: IStep) => void): void;
12
- onUpdate(end: boolean, ratio: number, out: Record<string, any>): void;
13
- }
@@ -1,49 +0,0 @@
1
- import { ACustomAnimate } from "./custom-animate";
2
-
3
- export class ScaleIn extends ACustomAnimate {
4
- constructor(from, to, duration, easing, params) {
5
- super(from, to, duration, easing, params);
6
- }
7
- onFirstRun() {
8
- var _a, _b, _c, _d, _e;
9
- let from, to;
10
- const attrs = this.target.getAttributes();
11
- switch (null === (_a = this.params) || void 0 === _a ? void 0 : _a.direction) {
12
- case "x":
13
- from = {
14
- scaleX: 0
15
- }, to = {
16
- scaleX: null !== (_b = null == attrs ? void 0 : attrs.scaleX) && void 0 !== _b ? _b : 1
17
- };
18
- break;
19
-
20
- case "y":
21
- from = {
22
- scaleY: 0
23
- }, to = {
24
- scaleY: null !== (_c = null == attrs ? void 0 : attrs.scaleY) && void 0 !== _c ? _c : 1
25
- };
26
- break;
27
-
28
- default:
29
- from = {
30
- scaleX: 0,
31
- scaleY: 0
32
- }, to = {
33
- scaleX: null !== (_d = null == attrs ? void 0 : attrs.scaleX) && void 0 !== _d ? _d : 1,
34
- scaleY: null !== (_e = null == attrs ? void 0 : attrs.scaleY) && void 0 !== _e ? _e : 1
35
- };
36
- }
37
- this.props = to, this.propKeys = Object.keys(to), this.animate.reSyncProps(), this.from = from,
38
- this.to = to;
39
- }
40
- onEnd(cb) {
41
- super.onEnd(cb);
42
- }
43
- onUpdate(end, ratio, out) {
44
- this.valid && (this.propKeys.forEach((key => {
45
- out[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
46
- })), this.target.setAttributes(out));
47
- }
48
- }
49
- //# sourceMappingURL=scale-in.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/custom/scale-in.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAWlD,MAAM,OAAO,OAAQ,SAAQ,cAAsC;IAGjE,YAAY,IAAU,EAAE,EAAQ,EAAE,QAAgB,EAAE,MAAkB,EAAE,MAA+B;QACrG,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,CAAC;IAED,UAAU;;QACR,IAAI,IAA4B,CAAC;QACjC,IAAI,EAA0B,CAAC;QAE/B,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;QAC1C,QAAQ,MAAA,IAAI,CAAC,MAAM,0CAAE,SAAS,EAAE;YAC9B,KAAK,GAAG;gBACN,IAAI,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;gBACrB,EAAE,GAAG,EAAE,MAAM,EAAE,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,mCAAI,CAAC,EAAE,CAAC;gBACpC,MAAM;YACR,KAAK,GAAG;gBACN,IAAI,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;gBACrB,EAAE,GAAG,EAAE,MAAM,EAAE,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,mCAAI,CAAC,EAAE,CAAC;gBACpC,MAAM;YACR,KAAK,IAAI,CAAC;YACV;gBACE,IAAI,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;gBAChC,EAAE,GAAG;oBACH,MAAM,EAAE,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,mCAAI,CAAC;oBAC1B,MAAM,EAAE,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,mCAAI,CAAC;iBAC3B,CAAC;SACL;QACD,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAChC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;IAED,KAAK,CAAC,EAA6C;QACjD,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAClB,CAAC;IAED,QAAQ,CAAC,GAAY,EAAE,KAAa,EAAE,GAAwB;QAC5D,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACf,OAAO;SACR;QAED,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAC1B,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;QACtE,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;CACF","file":"scale-in.js","sourcesContent":["import type { IAnimate, IStep } from '../intreface/animate';\nimport type { EasingType } from '../intreface/easing';\nimport { ACustomAnimate } from './custom-animate';\n\nexport interface IScaleAnimationOptions {\n direction?: 'x' | 'y' | 'xy';\n}\n\n/**\n * 文本输入动画,实现类似打字机的字符逐个显示效果\n * 支持通过beforeText和afterText参数添加前缀和后缀\n * 支持通过showCursor参数显示光标,cursorChar自定义光标字符\n */\nexport class ScaleIn extends ACustomAnimate<Record<string, number>> {\n declare valid: boolean;\n\n constructor(from: null, to: null, duration: number, easing: EasingType, params?: IScaleAnimationOptions) {\n super(from, to, duration, easing, params);\n }\n\n onFirstRun(): void {\n let from: Record<string, number>;\n let to: Record<string, number>;\n // 获取当前的数据\n const attrs = this.target.getAttributes();\n switch (this.params?.direction) {\n case 'x':\n from = { scaleX: 0 };\n to = { scaleX: attrs?.scaleX ?? 1 };\n break;\n case 'y':\n from = { scaleY: 0 };\n to = { scaleY: attrs?.scaleY ?? 1 };\n break;\n case 'xy':\n default:\n from = { scaleX: 0, scaleY: 0 };\n to = {\n scaleX: attrs?.scaleX ?? 1,\n scaleY: attrs?.scaleY ?? 1\n };\n }\n this.props = to;\n this.propKeys = Object.keys(to);\n this.animate.reSyncProps();\n this.from = from;\n this.to = to;\n }\n\n onEnd(cb?: (animate: IAnimate, step: IStep) => void): void {\n super.onEnd(cb);\n }\n\n onUpdate(end: boolean, ratio: number, out: Record<string, any>): void {\n if (!this.valid) {\n return;\n }\n\n this.propKeys.forEach(key => {\n out[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;\n });\n this.target.setAttributes(out);\n }\n}\n"]}
@@ -1,66 +0,0 @@
1
- import type { IGraphic } from '@visactor/vrender-core';
2
- import type { EasingType } from '../intreface/easing';
3
- import type { ACustomAnimate } from '../custom/custom-animate';
4
- export type MarkFunctionCallback<T> = (datum: any, graphic: IGraphic, parameters: any) => T;
5
- export type MarkFunctionValueType<T> = MarkFunctionCallback<T> | T;
6
- interface IAnimationParameters {
7
- [key: string]: any;
8
- }
9
- export type IAnimationChannelFunction = (datum: any, element: IGraphic, parameters: IAnimationParameters) => any;
10
- export type IAnimationChannelAttrs = Record<string, {
11
- from?: any | IAnimationChannelFunction;
12
- to?: any | IAnimationChannelFunction;
13
- }>;
14
- export type IAnimationChannelAttributes = string[];
15
- export type IAnimationChannelInterpolator = (ratio: number, from: any, to: any, nextAttributes: any, datum: any, element: IGraphic, parameters: IAnimationParameters) => boolean | void;
16
- export interface IAnimationCustomConstructor {
17
- new (from: any, to: any, duration: number, ease: EasingType, parameters?: any): ACustomAnimate<any>;
18
- }
19
- export interface IAnimationEffect {
20
- type?: string;
21
- channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;
22
- custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;
23
- customParameters?: MarkFunctionValueType<any>;
24
- easing?: EasingType;
25
- options?: MarkFunctionValueType<any>;
26
- }
27
- export interface IAnimationTimeSlice {
28
- effects: IAnimationEffect | IAnimationEffect[];
29
- duration?: MarkFunctionValueType<number>;
30
- delay?: MarkFunctionValueType<number>;
31
- delayAfter?: MarkFunctionValueType<number>;
32
- }
33
- export interface IAnimationControlOptions {
34
- stopWhenStateChange?: boolean;
35
- immediatelyApply?: boolean;
36
- ignoreLoopFinalAttributes?: boolean;
37
- }
38
- export interface IAnimationTypeConfig {
39
- type?: string;
40
- channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;
41
- custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;
42
- customParameters?: MarkFunctionValueType<any>;
43
- easing?: EasingType;
44
- delay?: MarkFunctionValueType<number>;
45
- delayAfter?: MarkFunctionValueType<number>;
46
- duration?: MarkFunctionValueType<number>;
47
- oneByOne?: MarkFunctionValueType<boolean | number>;
48
- startTime?: MarkFunctionValueType<number>;
49
- totalTime?: MarkFunctionValueType<number>;
50
- loop?: boolean | number;
51
- options?: MarkFunctionValueType<any>;
52
- controlOptions?: IAnimationControlOptions;
53
- }
54
- export interface IAnimationTimeline {
55
- id?: string;
56
- timeSlices: IAnimationTimeSlice | IAnimationTimeSlice[];
57
- startTime?: MarkFunctionValueType<number>;
58
- totalTime?: MarkFunctionValueType<number>;
59
- oneByOne?: MarkFunctionValueType<number | boolean>;
60
- loop?: MarkFunctionValueType<number | boolean>;
61
- partitioner?: MarkFunctionCallback<boolean>;
62
- sort?: (datumA: any, datumB: any, elementA: IGraphic, elementB: IGraphic, parameters: any) => number;
63
- controlOptions?: IAnimationControlOptions;
64
- }
65
- export type IAnimationConfig = IAnimationTimeline | IAnimationTypeConfig;
66
- export {};
@@ -1,2 +0,0 @@
1
- export { };
2
- //# sourceMappingURL=executor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/interpolate/executor.ts"],"names":[],"mappings":"","file":"executor.js","sourcesContent":["import type { IGraphic } from '@visactor/vrender-core';\nimport type { EasingType } from '../intreface/easing';\nimport type { ACustomAnimate } from '../custom/custom-animate';\n\nexport type MarkFunctionCallback<T> = (datum: any, graphic: IGraphic, parameters: any) => T;\nexport type MarkFunctionValueType<T> = MarkFunctionCallback<T> | T;\n\ninterface IAnimationParameters {\n [key: string]: any;\n}\n\n/**\n * 动画 channel 配置\n */\nexport type IAnimationChannelFunction = (datum: any, element: IGraphic, parameters: IAnimationParameters) => any;\n\n/**\n * 动画 channel 属性配置\n */\nexport type IAnimationChannelAttrs = Record<\n string,\n {\n from?: any | IAnimationChannelFunction;\n to?: any | IAnimationChannelFunction;\n }\n>;\nexport type IAnimationChannelAttributes = string[];\n\n/**\n * 动画 channel 插值器\n */\nexport type IAnimationChannelInterpolator = (\n ratio: number,\n from: any,\n to: any,\n nextAttributes: any,\n datum: any,\n element: IGraphic,\n parameters: IAnimationParameters\n) => boolean | void;\n\n/**\n * 动画 custom 构造器\n */\nexport interface IAnimationCustomConstructor {\n new (from: any, to: any, duration: number, ease: EasingType, parameters?: any): ACustomAnimate<any>;\n}\n\nexport interface IAnimationEffect {\n /** 动画类型 */\n type?: string;\n /** 动画 channel 配置 */\n channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;\n /** 动画 自定义插值 配置 */\n custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;\n /** 动画 custom 参数配置 */\n customParameters?: MarkFunctionValueType<any>;\n /** 动画 easing 配置 */\n easing?: EasingType;\n /** options暂时没有处理 */\n options?: MarkFunctionValueType<any>;\n}\n\nexport interface IAnimationTimeSlice {\n /** 动画效果 */\n effects: IAnimationEffect | IAnimationEffect[];\n /** 动画时长 */\n duration?: MarkFunctionValueType<number>;\n /** 延迟delay后执行动画 */\n delay?: MarkFunctionValueType<number>;\n /** effect动画后再延迟delayAfter结束这个周期 */\n delayAfter?: MarkFunctionValueType<number>;\n}\n\nexport interface IAnimationControlOptions {\n /** 当动画状态变更时清空动画 */\n stopWhenStateChange?: boolean;\n /** 是否立即应用动画初始状态 */\n immediatelyApply?: boolean;\n /** encode 计算图元最终状态时是否忽略循环动画 */\n ignoreLoopFinalAttributes?: boolean;\n}\n\n/**\n * 动画 config 简化配置\n */\nexport interface IAnimationTypeConfig {\n /** 动画类型 */\n type?: string;\n /** 动画 channel 配置 */\n channel?: IAnimationChannelAttrs | IAnimationChannelAttributes;\n /** 动画 自定义插值 配置 */\n custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor;\n /** 动画 custom 参数配置 */\n customParameters?: MarkFunctionValueType<any>;\n /** 动画 easing 配置 */\n easing?: EasingType;\n /** 动画 delay 配置 */\n delay?: MarkFunctionValueType<number>;\n /** 动画 delayAfter 配置 */\n delayAfter?: MarkFunctionValueType<number>;\n /** 动画 duration 配置 */\n duration?: MarkFunctionValueType<number>;\n /** 动画 oneByOne 配置(是否依次执行) */\n oneByOne?: MarkFunctionValueType<boolean | number>;\n /** 动画 startTime 配置 */\n startTime?: MarkFunctionValueType<number>;\n /** 动画 totalTime 配置 */\n totalTime?: MarkFunctionValueType<number>;\n /** loop: true 无限循环; loop: 正整数,表示循环的次数 */\n loop?: boolean | number;\n /** 动画 effect 配置项 */\n options?: MarkFunctionValueType<any>;\n /** 动画执行相关控制配置项 */\n controlOptions?: IAnimationControlOptions;\n}\n\n/**\n * 动画 timeline 完整配置,一条时间线内的动画单元只能串行\n * 多个timeline是可以并行的\n * 考虑到同一图元不能在多个timeline上,所以timeline不应该提供数组配置的能力\n */\nexport interface IAnimationTimeline {\n /** 为了方便动画编排,用户可以设置 id 用于识别时间线 */\n id?: string;\n /** 时间切片 */\n timeSlices: IAnimationTimeSlice | IAnimationTimeSlice[];\n /** 动画开始的相对时间,可以为负数 */\n startTime?: MarkFunctionValueType<number>;\n /** 动画时长 */\n totalTime?: MarkFunctionValueType<number>;\n /** 动画依次执行的延迟 */\n oneByOne?: MarkFunctionValueType<number | boolean>;\n /** loop: true 无限循环; loop: 正整数,表示循环的次数 */\n loop?: MarkFunctionValueType<number | boolean>;\n /** 对图元元素进行划分,和过滤类似,但是不同时间线不能同时作用在相同的元素上 */\n partitioner?: MarkFunctionCallback<boolean>;\n /** 对同一时间线上的元素进行排序 */\n sort?: (datumA: any, datumB: any, elementA: IGraphic, elementB: IGraphic, parameters: any) => number;\n /** 动画执行相关控制配置项 */\n controlOptions?: IAnimationControlOptions;\n}\n\n/**\n * 动画配置\n */\nexport type IAnimationConfig = IAnimationTimeline | IAnimationTypeConfig;\n"]}
@@ -1,35 +0,0 @@
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
- }
@@ -1,2 +0,0 @@
1
- export { };
2
- //# sourceMappingURL=state.js.map
@@ -1 +0,0 @@
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"]}
@@ -1,22 +0,0 @@
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 {};
@@ -1,47 +0,0 @@
1
- import { AnimationStateRegistry } from "./animation-state-registry";
2
-
3
- import { AnimationStateQueue } from "./animation-state-queue";
4
-
5
- export class AnimationStateMachine {
6
- constructor(target, executor) {
7
- this.target = target, this.executor = executor, this.eventListeners = new Map, this.registry = new AnimationStateRegistry,
8
- this.stateQueue = new AnimationStateQueue(target, this.registry, executor, this.handleStateEvent.bind(this));
9
- }
10
- applyState(state) {
11
- this.stateQueue.enqueue(state);
12
- }
13
- registerState(config, rule) {
14
- this.registry.register(config, rule);
15
- }
16
- getActiveState() {
17
- return this.stateQueue.getActiveState();
18
- }
19
- reset() {
20
- this.stateQueue.cancel();
21
- }
22
- on(event, callback) {
23
- var _a;
24
- this.eventListeners.has(event) || this.eventListeners.set(event, new Set), null === (_a = this.eventListeners.get(event)) || void 0 === _a || _a.add(callback);
25
- }
26
- off(event, callback) {
27
- const listeners = this.eventListeners.get(event);
28
- listeners && listeners.delete(callback);
29
- }
30
- handleStateEvent(event, state) {
31
- const listeners = this.eventListeners.get(event);
32
- listeners && listeners.forEach((callback => {
33
- try {
34
- callback(state, this.target);
35
- } catch (error) {
36
- console.error(`Error in animation state event listener for ${event}:`, error);
37
- }
38
- }));
39
- }
40
- hasState(state) {
41
- return !!this.registry.getState(state);
42
- }
43
- getRegisteredStates() {
44
- return this.registry.getAllStateNames();
45
- }
46
- }
47
- //# sourceMappingURL=animation-state-machine.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/state/animation-state-machine.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAQ9D,MAAM,OAAO,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,sBAAsB,EAAE,CAAC;QAC7C,IAAI,CAAC,UAAU,GAAG,IAAI,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,EA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AAC,MAAM,CAAC,CAAC;iBAC9B;gBAAC,OAAO,KAAK,EAAE;oBACd,OAAO,CAAC,KAAK,CAAC,+CAA+C,KAAK,GAAG,EAAE,KAAK,CAAC,CAAC;iBAC/E;YACH,CAAC,CAAC,CAAC;SACJ;IACH,CAAC;IAKD,QAAQ,CAAC,KAAa;QACpB,OAAO,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;IAKD,mBAAmB;QACjB,OAAO,IAAI,CAAC,QAAQ,CAAC,gBAAgB,EAAE,CAAC;IAC1C,CAAC;CACF","file":"animation-state-machine.js","sourcesContent":["import type { IGraphic, IGroup } from '@visactor/vrender-core';\nimport type {\n AnimationStateEventType,\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"]}
@@ -1,24 +0,0 @@
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
- }
@@ -1,58 +0,0 @@
1
- import { isArray } from "@visactor/vutils";
2
-
3
- export class AnimationStateQueue {
4
- constructor(target, registry, executor, onStateChange) {
5
- this.target = target, this.registry = registry, this.executor = executor, this.onStateChange = onStateChange,
6
- this.queue = [], this.activeState = null, this.activeAnimation = null, this.processingQueue = !1;
7
- }
8
- enqueue(states) {
9
- if (isArray(states)) for (const state of states) this.queue.push(state); else this.queue.push(states);
10
- this.processingQueue || this.processNextState();
11
- }
12
- processNextState() {
13
- if (0 === this.queue.length || this.processingQueue) return;
14
- this.processingQueue = !0;
15
- const nextState = this.queue[0];
16
- this.canApplyState(nextState) ? (this.queue.shift(), this.activeState && this.registry.hasConflict(this.activeState, nextState) ? this.registry.canInterrupt(this.activeState, nextState) ? (this.interruptCurrentState(),
17
- this.applyState(nextState)) : (this.onStateChange("stateReject", nextState), this.processingQueue = !1,
18
- this.processNextState()) : this.applyState(nextState)) : (this.queue.shift(), this.onStateChange("stateReject", nextState),
19
- this.processingQueue = !1, this.processNextState());
20
- }
21
- applyState(state) {
22
- const stateConfig = this.registry.getState(state);
23
- if (!stateConfig) return console.warn(`Animation state "${state}" not found`), this.processingQueue = !1,
24
- void this.processNextState();
25
- this.activeState = state, this.onStateChange("stateStart", state), this.activeAnimation = this.executor.executeItem(stateConfig.animation, this.target),
26
- this.activeAnimation ? this.activeAnimation.onEnd((() => {
27
- this.onAnimationComplete();
28
- })) : this.onAnimationComplete();
29
- }
30
- onAnimationComplete() {
31
- if (this.activeState) {
32
- const completedState = this.activeState;
33
- this.onStateChange("stateEnd", completedState);
34
- const transitionDelay = this.registry.getTransitionDelay(completedState);
35
- this.activeState = null, this.activeAnimation = null, this.processingQueue = !1,
36
- transitionDelay > 0 ? setTimeout((() => {
37
- this.processNextState();
38
- }), transitionDelay) : this.processNextState();
39
- }
40
- }
41
- interruptCurrentState() {
42
- this.activeState && this.activeAnimation && (this.onStateChange("stateInterrupt", this.activeState),
43
- this.activeAnimation.stop("end"), this.activeAnimation = null, this.activeState = null);
44
- }
45
- cancel() {
46
- this.interruptCurrentState(), this.queue = [], this.processingQueue = !1;
47
- }
48
- canApplyState(state) {
49
- return !!this.registry.getState(state) && (!this.activeState || (!this.registry.hasConflict(this.activeState, state) || this.registry.canInterrupt(this.activeState, state)));
50
- }
51
- getActiveState() {
52
- return this.activeState;
53
- }
54
- getPendingStates() {
55
- return [ ...this.queue ];
56
- }
57
- }
58
- //# sourceMappingURL=animation-state-queue.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/state/animation-state-queue.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAK3C,MAAM,OAAO,mBAAmB;IAM9B,YACU,MAAyB,EACzB,QAAgC,EAChC,QAAyB,EACzB,aAA2G;QAH3G,WAAM,GAAN,MAAM,CAAmB;QACzB,aAAQ,GAAR,QAAQ,CAAwB;QAChC,aAAQ,GAAR,QAAQ,CAAiB;QACzB,kBAAa,GAAb,aAAa,CAA8F;QAT7G,UAAK,GAAa,EAAE,CAAC;QACrB,gBAAW,GAAkB,IAAI,CAAC;QAClC,oBAAe,GAAoB,IAAI,CAAC;QACxC,oBAAe,GAAY,KAAK,CAAC;IAOtC,CAAC;IAKJ,OAAO,CAAC,MAAyB;QAC/B,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE;YAEnB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;gBAC1B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACxB;SACF;aAAM;YACL,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SACzB;QAGD,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;YACzB,IAAI,CAAC,gBAAgB,EAAE,CAAC;SACzB;IACH,CAAC;IAKD,gBAAgB;QACd,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,eAAe,EAAE;YACnD,OAAO;SACR;QAED,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;QAC5B,MAAM,SAAS,GAAG,IAAI,CAAC,KA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e,GAAG,IAAI,CAAC;YAC5B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;SACzB;IACH,CAAC;IAKD,MAAM;QAEJ,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAG7B,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;IAC/B,CAAC;IAKD,aAAa,CAAC,KAAa;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","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"]}
@@ -1,14 +0,0 @@
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
- }
@@ -1,45 +0,0 @@
1
- export class AnimationStateRegistry {
2
- constructor() {
3
- this.states = new Map, this.rules = new Map;
4
- }
5
- register(state, rule) {
6
- var _a;
7
- const {name: name} = state;
8
- name ? (this.states.set(name, Object.assign(Object.assign({}, state), {
9
- priority: null !== (_a = state.priority) && void 0 !== _a ? _a : 0
10
- })), rule && this.rules.set(name, rule)) : console.warn("Animation state must have a name");
11
- }
12
- getState(name) {
13
- return this.states.get(name);
14
- }
15
- getRule(name) {
16
- return this.rules.get(name);
17
- }
18
- hasConflict(stateA, stateB) {
19
- var _a, _b;
20
- if (stateA === stateB) return !1;
21
- const ruleA = this.getRule(stateA), ruleB = this.getRule(stateB);
22
- 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));
23
- }
24
- canInterrupt(stateA, stateB) {
25
- var _a, _b, _c;
26
- const ruleA = this.getRule(stateA), stateAConfig = this.getState(stateA), stateBConfig = this.getState(stateB);
27
- 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));
28
- }
29
- isQueueable(state) {
30
- const rule = this.getRule(state);
31
- return !!(null == rule ? void 0 : rule.queueable);
32
- }
33
- getTransitionDelay(state) {
34
- var _a;
35
- const rule = this.getRule(state);
36
- return null !== (_a = null == rule ? void 0 : rule.transitionDelay) && void 0 !== _a ? _a : 0;
37
- }
38
- getAllStateNames() {
39
- return Array.from(this.states.keys());
40
- }
41
- clear() {
42
- this.states.clear(), this.rules.clear();
43
- }
44
- }
45
-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C,MAAM,CAAC,KAAK,EAAE,CAAC;QACpB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;CACF","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"]}