@visactor/vrender-core 1.1.10-alpha.0 → 1.1.11-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,9 @@
1
- import type { AABBBounds, IAABBBounds, IPointLike } from '@visactor/vutils';
1
+ import type { AABBBounds, IAABBBounds } from '@visactor/vutils';
2
2
  import { Graphic } from './graphic';
3
3
  import type { GraphicType, IGraphic, IGlyph, IGlyphGraphicAttribute, IGraphicAttribute, ISetAttributeContext } from '../interface';
4
+ import type { CompiledStateDefinition } from './state/state-definition';
5
+ import type { SharedStateScope } from './state/shared-state-scope';
6
+ import { UpdateCategory } from './state/attribute-update-classifier';
4
7
  export declare class Glyph extends Graphic<IGlyphGraphicAttribute> implements IGlyph {
5
8
  type: GraphicType;
6
9
  _onInit: (g: IGlyph) => void;
@@ -14,6 +17,11 @@ export declare class Glyph extends Graphic<IGlyphGraphicAttribute> implements IG
14
17
  subAttributes: Partial<IGraphicAttribute>[];
15
18
  };
16
19
  protected subGraphic: IGraphic[];
20
+ private subGraphicEncoder?;
21
+ private legacyDefinitionsSource?;
22
+ private legacyProxySource?;
23
+ private legacyDefinitions?;
24
+ private legacyCompiledDefinitions?;
17
25
  static NOWORK_ANIMATE_ATTR: {
18
26
  strokeSeg: number;
19
27
  boundsPadding: number;
@@ -51,22 +59,26 @@ export declare class Glyph extends Graphic<IGlyphGraphicAttribute> implements IG
51
59
  onInit(cb: (g: this) => void): void;
52
60
  onUpdate(cb: (g: this) => void): void;
53
61
  isValid(): boolean;
54
- setAttribute(key: string, value: any, forceUpdateTag?: boolean, context?: ISetAttributeContext): void;
55
- setAttributes(params: Partial<IGlyphGraphicAttribute>, forceUpdateTag?: boolean, context?: ISetAttributeContext): void;
56
- translate(x: number, y: number): this;
57
- translateTo(x: number, y: number): this;
58
- scale(scaleX: number, scaleY: number, scaleCenter?: IPointLike): this;
59
- scaleTo(scaleX: number, scaleY: number): this;
60
- rotate(angle: number): this;
61
- rotateTo(angle: number): this;
62
+ setSubGraphicEncoder(encoder?: (g: IGlyph, context?: ISetAttributeContext) => void): void;
63
+ commitSubGraphicAttributes(subGraphic: IGraphic, patch: Record<string, any>, removedKeys?: readonly string[], context?: ISetAttributeContext): void;
64
+ onAttributeUpdate(context?: ISetAttributeContext): void;
65
+ protected submitUpdateByCategory(category: UpdateCategory, forceUpdateTag?: boolean): void;
66
+ protected commitBaseAttributesByTouchedKeys(params: Partial<IGlyphGraphicAttribute>, forceUpdateTag?: boolean, context?: ISetAttributeContext): void;
67
+ protected commitBaseAttributeBySingleKey(key: string, value: any, forceUpdateTag?: boolean, context?: ISetAttributeContext): void;
62
68
  getGraphicTheme(): Required<IGlyphGraphicAttribute>;
63
69
  protected updateAABBBounds(attribute: IGlyphGraphicAttribute, theme: Required<IGlyphGraphicAttribute>, aabbBounds: IAABBBounds): import("@visactor/vutils").IBounds;
64
70
  protected doUpdateAABBBounds(): AABBBounds;
65
71
  protected needUpdateTags(keys: string[]): boolean;
66
72
  protected needUpdateTag(key: string): boolean;
67
- useStates(states: string[], hasAnimation?: boolean): void;
68
- clearStates(hasAnimation?: boolean): void;
73
+ protected hasLegacyStateDefinitions(): boolean;
74
+ protected syncSharedStateScopeBindingFromTree(markDirty?: boolean, inheritedSharedStateScope?: SharedStateScope<Record<string, any>> | null): boolean;
75
+ protected resolveEffectiveCompiledDefinitions(stateNames?: readonly string[]): {
76
+ compiledDefinitions?: Map<string, CompiledStateDefinition<IGlyphGraphicAttribute>>;
77
+ stateOrder?: "input";
78
+ };
79
+ private createLegacyStateDefinition;
69
80
  clone(): IGraphic<Partial<IGlyphGraphicAttribute>>;
81
+ release(): void;
70
82
  getNoWorkAnimateAttr(): Record<string, number>;
71
83
  }
72
84
  export declare function createGlyph(attributes: IGlyphGraphicAttribute): IGlyph;
@@ -1,7 +1,11 @@
1
1
  import { Graphic, NOWORK_ANIMATE_ATTR } from "./graphic";
2
2
 
3
+ import { StateDefinitionCompiler } from "./state/state-definition-compiler";
4
+
3
5
  import { getTheme } from "./theme";
4
6
 
7
+ import { UpdateCategory } from "./state/attribute-update-classifier";
8
+
5
9
  import { GLYPH_NUMBER_TYPE } from "./constants";
6
10
 
7
11
  export class Glyph extends Graphic {
@@ -10,13 +14,14 @@ export class Glyph extends Graphic {
10
14
  this._onInit && this._onInit(this), this.valid = this.isValid();
11
15
  }
12
16
  setSubGraphic(subGraphic) {
17
+ var _a;
13
18
  this.detachSubGraphic(), this.subGraphic = subGraphic, subGraphic.forEach((g => {
14
- g.glyphHost = this, Object.setPrototypeOf(g.attribute, this.attribute);
15
- })), this.valid = this.isValid(), this.addUpdateBoundTag();
19
+ g.glyphHost = this, Graphic.bindGlyphAttributes(g, this.attribute);
20
+ })), this.valid = this.isValid(), this.addUpdateBoundTag(), null === (_a = this.subGraphicEncoder) || void 0 === _a || _a.call(this, this);
16
21
  }
17
22
  detachSubGraphic() {
18
23
  this.subGraphic.forEach((g => {
19
- g.glyphHost = null, Object.setPrototypeOf(g.attribute, {});
24
+ g.glyphHost = null, Graphic.bindGlyphAttributes(g, Object.prototype);
20
25
  }));
21
26
  }
22
27
  getSubGraphic() {
@@ -31,45 +36,33 @@ export class Glyph extends Graphic {
31
36
  isValid() {
32
37
  return !0;
33
38
  }
34
- setAttribute(key, value, forceUpdateTag, context) {
35
- super.setAttribute(key, value, forceUpdateTag, context), this.subGraphic.forEach((g => {
36
- g.addUpdateShapeAndBoundsTag(), g.addUpdatePositionTag();
37
- }));
38
- }
39
- setAttributes(params, forceUpdateTag = !1, context) {
40
- super.setAttributes(params, forceUpdateTag, context), this.subGraphic.forEach((g => {
41
- g.addUpdateShapeAndBoundsTag(), g.addUpdatePositionTag();
42
- }));
39
+ setSubGraphicEncoder(encoder) {
40
+ this.subGraphicEncoder = encoder, null == encoder || encoder(this);
43
41
  }
44
- translate(x, y) {
45
- return super.translate(x, y), this.subGraphic.forEach((g => {
46
- g.addUpdatePositionTag(), g.addUpdateBoundTag();
47
- })), this;
42
+ commitSubGraphicAttributes(subGraphic, patch, removedKeys, context) {
43
+ Graphic.commitDerivedAttributePatch(subGraphic, patch, removedKeys, context);
48
44
  }
49
- translateTo(x, y) {
50
- return super.translateTo(x, y), this.subGraphic.forEach((g => {
51
- g.addUpdatePositionTag(), g.addUpdateBoundTag();
52
- })), this;
45
+ onAttributeUpdate(context) {
46
+ var _a, _b;
47
+ this.glyphHost && Graphic.bindGlyphAttributes(this, this.glyphHost.attribute);
48
+ for (const child of this.subGraphic) Graphic.bindGlyphAttributes(child, this.attribute);
49
+ null === (_a = this.subGraphicEncoder) || void 0 === _a || _a.call(this, this, context),
50
+ (null == context ? void 0 : context.skipUpdateCallback) || null === (_b = this._onUpdate) || void 0 === _b || _b.call(this, this),
51
+ super.onAttributeUpdate(context);
53
52
  }
54
- scale(scaleX, scaleY, scaleCenter) {
55
- return super.scale(scaleX, scaleY, scaleCenter), this.subGraphic.forEach((g => {
56
- g.addUpdatePositionTag(), g.addUpdateBoundTag();
57
- })), this;
53
+ submitUpdateByCategory(category, forceUpdateTag = !1) {
54
+ super.submitUpdateByCategory(category, forceUpdateTag);
55
+ for (const child of this.subGraphic) forceUpdateTag || category & UpdateCategory.SHAPE ? child.addUpdateShapeAndBoundsTag() : category & UpdateCategory.BOUNDS && child.addUpdateBoundTag(),
56
+ category & UpdateCategory.PAINT && child.addUpdatePaintTag(), (forceUpdateTag || category & UpdateCategory.TRANSFORM) && child.addUpdatePositionTag(),
57
+ (forceUpdateTag || category & UpdateCategory.LAYOUT) && child.addUpdateLayoutTag();
58
58
  }
59
- scaleTo(scaleX, scaleY) {
60
- return super.scaleTo(scaleX, scaleY), this.subGraphic.forEach((g => {
61
- g.addUpdatePositionTag(), g.addUpdateBoundTag();
62
- })), this;
59
+ commitBaseAttributesByTouchedKeys(params, forceUpdateTag = !1, context) {
60
+ this.commitBaseAttributesByCategory(params, forceUpdateTag, context);
63
61
  }
64
- rotate(angle) {
65
- return super.rotate(angle), this.subGraphic.forEach((g => {
66
- g.addUpdatePositionTag(), g.addUpdateBoundTag();
67
- })), this;
68
- }
69
- rotateTo(angle) {
70
- return super.rotate(angle), this.subGraphic.forEach((g => {
71
- g.addUpdatePositionTag(), g.addUpdateBoundTag();
72
- })), this;
62
+ commitBaseAttributeBySingleKey(key, value, forceUpdateTag = !1, context) {
63
+ this.commitBaseAttributesByTouchedKeys({
64
+ [key]: value
65
+ }, forceUpdateTag, context);
73
66
  }
74
67
  getGraphicTheme() {
75
68
  return getTheme(this).glyph;
@@ -90,31 +83,62 @@ export class Glyph extends Graphic {
90
83
  needUpdateTag(key) {
91
84
  return !1;
92
85
  }
93
- useStates(states, hasAnimation) {
94
- var _a;
95
- if (!states.length) return void this.clearStates(hasAnimation);
96
- const previousStates = this.currentStates ? this.currentStates.slice() : [];
97
- if (!((null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) !== states.length || states.some(((stateName, index) => this.currentStates[index] !== stateName)))) return;
98
- this.stopStateAnimates(), this.stateSort && (states = states.sort(this.stateSort));
99
- const stateAttrs = {};
100
- states.forEach((stateName => {
101
- const attrs = this.glyphStateProxy ? this.glyphStateProxy(stateName, states) : this.glyphStates[stateName];
102
- attrs && Object.assign(stateAttrs, attrs.attributes);
103
- })), this.beforeStateUpdate(stateAttrs, previousStates, states, hasAnimation, !1) && (this.currentStates = states,
104
- this.applyStateAttrs(stateAttrs, states, hasAnimation));
105
- }
106
- clearStates(hasAnimation) {
107
- this.stopStateAnimates();
108
- const previousStates = this.currentStates ? this.currentStates.slice() : [];
109
- if (this.hasState() && this.normalAttrs) {
110
- if (!this.beforeStateUpdate(this.normalAttrs, previousStates, [], hasAnimation, !0)) return;
111
- this.currentStates = [], this.applyStateAttrs(this.normalAttrs, this.currentStates, hasAnimation, !0);
112
- } else this.currentStates = [];
86
+ hasLegacyStateDefinitions() {
87
+ if (this.glyphStateProxy) return !0;
88
+ for (const name in this.glyphStates) if (Object.prototype.hasOwnProperty.call(this.glyphStates, name)) return !0;
89
+ return !1;
90
+ }
91
+ syncSharedStateScopeBindingFromTree(markDirty = !0, inheritedSharedStateScope) {
92
+ return this.hasLegacyStateDefinitions() ? this.syncSharedStateScopeBinding(void 0, markDirty) : super.syncSharedStateScopeBindingFromTree(markDirty, inheritedSharedStateScope);
93
+ }
94
+ resolveEffectiveCompiledDefinitions(stateNames = []) {
95
+ var _a, _b;
96
+ if (!this.hasLegacyStateDefinitions()) return this.legacyDefinitions = void 0, this.legacyCompiledDefinitions = void 0,
97
+ super.resolveEffectiveCompiledDefinitions(stateNames);
98
+ this.syncSharedStateScopeBindingFromTree(!1);
99
+ let changed = !1;
100
+ if (!this.legacyDefinitions || this.legacyDefinitionsSource !== this.glyphStates || this.legacyProxySource !== this.glyphStateProxy) {
101
+ this.legacyDefinitionsSource = this.glyphStates, this.legacyProxySource = this.glyphStateProxy,
102
+ this.legacyDefinitions = {};
103
+ for (const name of Object.keys(null !== (_a = this.glyphStates) && void 0 !== _a ? _a : {})) this.legacyDefinitions[name] = this.createLegacyStateDefinition(name);
104
+ changed = !0;
105
+ }
106
+ if (this.glyphStateProxy) {
107
+ const addDefinition = name => {
108
+ Object.prototype.hasOwnProperty.call(this.legacyDefinitions, name) || (this.legacyDefinitions[name] = this.createLegacyStateDefinition(name),
109
+ changed = !0);
110
+ };
111
+ null === (_b = this.currentStates) || void 0 === _b || _b.forEach(addDefinition),
112
+ stateNames.forEach(addDefinition);
113
+ }
114
+ return changed && (this.legacyCompiledDefinitions = (new StateDefinitionCompiler).compile(this.legacyDefinitions)),
115
+ {
116
+ compiledDefinitions: this.legacyCompiledDefinitions,
117
+ stateOrder: "input"
118
+ };
119
+ }
120
+ createLegacyStateDefinition(name) {
121
+ return this.glyphStateProxy ? {
122
+ name: name,
123
+ resolver: ({graphic: graphic, activeStates: activeStates}) => {
124
+ var _a;
125
+ return null === (_a = graphic.glyphStateProxy(name, activeStates)) || void 0 === _a ? void 0 : _a.attributes;
126
+ }
127
+ } : {
128
+ name: name,
129
+ patch: this.glyphStates[name].attributes
130
+ };
113
131
  }
114
132
  clone() {
115
133
  const glyph = new Glyph(Object.assign({}, this.attribute));
116
134
  return glyph.setSubGraphic(this.subGraphic.map((g => g.clone()))), glyph;
117
135
  }
136
+ release() {
137
+ super.release(), this.subGraphicEncoder = void 0, this._onUpdate = void 0, this.legacyDefinitions = void 0,
138
+ this.legacyCompiledDefinitions = void 0, this.legacyDefinitionsSource = void 0,
139
+ this.legacyProxySource = void 0, this.detachSubGraphic(), this.subGraphic.forEach((child => child.release())),
140
+ this.subGraphic = [];
141
+ }
118
142
  getNoWorkAnimateAttr() {
119
143
  return Glyph.NOWORK_ANIMATE_ATTR;
120
144
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/graphic/glyph.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AASzD,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,OAAO,KAAM,SAAQ,OAA+B;IAsBxD,YAAY,MAAuC;QACjD,KAAK,CAAC,MAAM,CAAC,CAAC;QAtBhB,SAAI,GAAgB,OAAO,CAAC;QAuB1B,IAAI,CAAC,UAAU,GAAG,iBAAiB,CAAC;QACpC,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;IAC9B,CAAC;IAED,aAAa,CAAC,UAAsB;QAClC,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;YACrB,CAAC,CAAC,SAAS,GAAG,IAAI,CAAC;YACnB,MAAM,CAAC,cAAc,CAAC,CAA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,CAAC,UAAU,CAAC,CAAC;AAC/B,CAAC","file":"glyph.js","sourcesContent":["import type { AABBBounds, IAABBBounds, IPointLike } from '@visactor/vutils';\nimport { Graphic, NOWORK_ANIMATE_ATTR } from './graphic';\nimport type {\n GraphicType,\n IGraphic,\n IGlyph,\n IGlyphGraphicAttribute,\n IGraphicAttribute,\n ISetAttributeContext\n} from '../interface';\nimport { getTheme } from './theme';\nimport { GLYPH_NUMBER_TYPE } from './constants';\n\nexport class Glyph extends Graphic<IGlyphGraphicAttribute> implements IGlyph {\n type: GraphicType = 'glyph';\n declare _onInit: (g: IGlyph) => void;\n declare _onUpdate: (g: IGlyph) => void;\n declare glyphStates?: Record<\n string,\n {\n attributes: Partial<IGlyphGraphicAttribute>;\n subAttributes: Partial<IGraphicAttribute>[];\n }\n >;\n declare glyphStateProxy?: (\n stateName: string,\n targetStates?: string[]\n ) => {\n attributes: Partial<IGlyphGraphicAttribute>;\n subAttributes: Partial<IGraphicAttribute>[];\n };\n protected declare subGraphic: IGraphic[];\n\n static NOWORK_ANIMATE_ATTR = NOWORK_ANIMATE_ATTR;\n\n constructor(params: Partial<IGlyphGraphicAttribute>) {\n super(params);\n this.numberType = GLYPH_NUMBER_TYPE;\n this.subGraphic = [];\n this._onInit && this._onInit(this);\n this.valid = this.isValid();\n }\n\n setSubGraphic(subGraphic: IGraphic[]) {\n this.detachSubGraphic();\n this.subGraphic = subGraphic;\n subGraphic.forEach(g => {\n g.glyphHost = this;\n Object.setPrototypeOf(g.attribute, this.attribute);\n });\n this.valid = this.isValid();\n this.addUpdateBoundTag();\n }\n\n protected detachSubGraphic() {\n this.subGraphic.forEach(g => {\n g.glyphHost = null;\n Object.setPrototypeOf(g.attribute, {});\n });\n }\n\n getSubGraphic() {\n return this.subGraphic;\n }\n\n onInit(cb: (g: this) => void): void {\n this._onInit = cb;\n }\n\n onUpdate(cb: (g: this) => void): void {\n this._onUpdate = cb;\n }\n\n isValid(): boolean {\n return true;\n }\n\n setAttribute(key: string, value: any, forceUpdateTag?: boolean, context?: ISetAttributeContext) {\n super.setAttribute(key, value, forceUpdateTag, context);\n this.subGraphic.forEach(g => {\n g.addUpdateShapeAndBoundsTag();\n g.addUpdatePositionTag();\n });\n }\n\n setAttributes(\n params: Partial<IGlyphGraphicAttribute>,\n forceUpdateTag: boolean = false,\n context?: ISetAttributeContext\n ) {\n super.setAttributes(params, forceUpdateTag, context);\n this.subGraphic.forEach(g => {\n g.addUpdateShapeAndBoundsTag();\n g.addUpdatePositionTag();\n });\n }\n\n translate(x: number, y: number) {\n super.translate(x, y);\n\n this.subGraphic.forEach(g => {\n g.addUpdatePositionTag();\n g.addUpdateBoundTag();\n });\n return this;\n }\n\n translateTo(x: number, y: number) {\n super.translateTo(x, y);\n\n this.subGraphic.forEach(g => {\n g.addUpdatePositionTag();\n g.addUpdateBoundTag();\n });\n return this;\n }\n\n scale(scaleX: number, scaleY: number, scaleCenter?: IPointLike) {\n super.scale(scaleX, scaleY, scaleCenter);\n\n this.subGraphic.forEach(g => {\n g.addUpdatePositionTag();\n g.addUpdateBoundTag();\n });\n return this;\n }\n\n scaleTo(scaleX: number, scaleY: number) {\n super.scaleTo(scaleX, scaleY);\n\n this.subGraphic.forEach(g => {\n g.addUpdatePositionTag();\n g.addUpdateBoundTag();\n });\n return this;\n }\n\n rotate(angle: number) {\n super.rotate(angle);\n\n this.subGraphic.forEach(g => {\n g.addUpdatePositionTag();\n g.addUpdateBoundTag();\n });\n return this;\n }\n\n rotateTo(angle: number) {\n super.rotate(angle);\n\n this.subGraphic.forEach(g => {\n g.addUpdatePositionTag();\n g.addUpdateBoundTag();\n });\n return this;\n }\n\n getGraphicTheme(): Required<IGlyphGraphicAttribute> {\n return getTheme(this as IGraphic).glyph;\n }\n\n protected updateAABBBounds(\n attribute: IGlyphGraphicAttribute,\n theme: Required<IGlyphGraphicAttribute>,\n aabbBounds: IAABBBounds\n ) {\n // 添加子节点\n this.getSubGraphic().forEach((node: IGraphic) => {\n aabbBounds.union(node.AABBBounds);\n });\n\n // glyph不需要计算AABBBounds\n // this.transformAABBBounds(attribute, aabbBounds, theme, graphic);\n return aabbBounds;\n }\n\n protected doUpdateAABBBounds(): AABBBounds {\n this.updateAABBBoundsStamp++;\n this._AABBBounds.clear();\n const bounds = this.updateAABBBounds(this.attribute, this.getGraphicTheme(), this._AABBBounds) as AABBBounds;\n this.clearUpdateBoundTag();\n return bounds;\n }\n\n protected needUpdateTags(keys: string[]): boolean {\n return false;\n }\n protected needUpdateTag(key: string): boolean {\n return false;\n }\n\n useStates(states: string[], hasAnimation?: boolean): void {\n if (!states.length) {\n this.clearStates(hasAnimation);\n return;\n }\n const previousStates = this.currentStates ? this.currentStates.slice() : [];\n\n const isChange =\n this.currentStates?.length !== states.length ||\n states.some((stateName, index) => this.currentStates[index] !== stateName);\n if (!isChange) {\n return;\n }\n\n this.stopStateAnimates();\n\n if (this.stateSort) {\n states = states.sort(this.stateSort);\n }\n const stateAttrs = {};\n states.forEach(stateName => {\n const attrs = this.glyphStateProxy ? this.glyphStateProxy(stateName, states) : this.glyphStates[stateName];\n\n if (attrs) {\n Object.assign(stateAttrs, attrs.attributes);\n }\n });\n\n if (!this.beforeStateUpdate(stateAttrs, previousStates, states, hasAnimation, false)) {\n return;\n }\n\n this.currentStates = states;\n this.applyStateAttrs(stateAttrs, states, hasAnimation);\n }\n\n clearStates(hasAnimation?: boolean) {\n this.stopStateAnimates();\n const previousStates = this.currentStates ? this.currentStates.slice() : [];\n if (this.hasState() && this.normalAttrs) {\n if (!this.beforeStateUpdate(this.normalAttrs, previousStates, [], hasAnimation, true)) {\n return;\n }\n this.currentStates = [];\n this.applyStateAttrs(this.normalAttrs, this.currentStates, hasAnimation, true);\n } else {\n this.currentStates = [];\n }\n }\n\n clone(): IGraphic<Partial<IGlyphGraphicAttribute>> {\n const glyph = new Glyph({ ...this.attribute });\n glyph.setSubGraphic(this.subGraphic.map(g => g.clone()));\n return glyph;\n }\n\n getNoWorkAnimateAttr(): Record<string, number> {\n return Glyph.NOWORK_ANIMATE_ATTR;\n }\n}\n\nexport function createGlyph(attributes: IGlyphGraphicAttribute): IGlyph {\n return new Glyph(attributes);\n}\n"]}
1
+ {"version":3,"sources":["../src/graphic/glyph.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AASzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAG5E,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,OAAO,KAAM,SAAQ,OAA+B;IA2BxD,YAAY,MAAuC;QACjD,KAAK,CAAC,MAAM,CAAC,CAAC;QA3BhB,SAAI,GAAgB,OAAO,CAAC;QA4B1B,IAAI,CAAC,UAAU,GAAG,iBAAiB,CAAC;QACpC,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;IAC9B,CAAC;IAED,aAAa,CAAC,UAAsB;;QAClC,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;YACrB,CAAC,CAAC,SAAS,GAAG,IAAI,CAAC;YACnB,OAAO,CAAC,mBAAmB,CAAC,CAAY,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC5B,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,MAAA,IAAI,CAAC,iBAAiB,qDAAG,IAAI,C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;QAC3C,IAAI,CAAC,uBAAuB,GAAG,SAAS,CAAC;QACzC,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC;QACnC,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAClD,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;IACvB,CAAC;IAED,oBAAoB;QAClB,OAAO,KAAK,CAAC,mBAAmB,CAAC;IACnC,CAAC;;AA9OM,yBAAmB,GAAG,mBAAmB,CAAC;AAiPnD,MAAM,UAAU,WAAW,CAAC,UAAkC;IAC5D,OAAO,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC;AAC/B,CAAC","file":"glyph.js","sourcesContent":["import type { AABBBounds, IAABBBounds } from '@visactor/vutils';\nimport { Graphic, NOWORK_ANIMATE_ATTR } from './graphic';\nimport type {\n GraphicType,\n IGraphic,\n IGlyph,\n IGlyphGraphicAttribute,\n IGraphicAttribute,\n ISetAttributeContext\n} from '../interface';\nimport { StateDefinitionCompiler } from './state/state-definition-compiler';\nimport type { CompiledStateDefinition, StateDefinition, StateDefinitionsInput } from './state/state-definition';\nimport type { SharedStateScope } from './state/shared-state-scope';\nimport { getTheme } from './theme';\nimport { UpdateCategory } from './state/attribute-update-classifier';\nimport { GLYPH_NUMBER_TYPE } from './constants';\n\nexport class Glyph extends Graphic<IGlyphGraphicAttribute> implements IGlyph {\n type: GraphicType = 'glyph';\n declare _onInit: (g: IGlyph) => void;\n declare _onUpdate: (g: IGlyph) => void;\n declare glyphStates?: Record<\n string,\n {\n attributes: Partial<IGlyphGraphicAttribute>;\n subAttributes: Partial<IGraphicAttribute>[];\n }\n >;\n declare glyphStateProxy?: (\n stateName: string,\n targetStates?: string[]\n ) => {\n attributes: Partial<IGlyphGraphicAttribute>;\n subAttributes: Partial<IGraphicAttribute>[];\n };\n protected declare subGraphic: IGraphic[];\n private subGraphicEncoder?: (g: IGlyph, context?: ISetAttributeContext) => void;\n private legacyDefinitionsSource?: Glyph['glyphStates'];\n private legacyProxySource?: Glyph['glyphStateProxy'];\n private legacyDefinitions?: StateDefinitionsInput<IGlyphGraphicAttribute>;\n private legacyCompiledDefinitions?: Map<string, CompiledStateDefinition<IGlyphGraphicAttribute>>;\n\n static NOWORK_ANIMATE_ATTR = NOWORK_ANIMATE_ATTR;\n\n constructor(params: Partial<IGlyphGraphicAttribute>) {\n super(params);\n this.numberType = GLYPH_NUMBER_TYPE;\n this.subGraphic = [];\n this._onInit && this._onInit(this);\n this.valid = this.isValid();\n }\n\n setSubGraphic(subGraphic: IGraphic[]) {\n this.detachSubGraphic();\n this.subGraphic = subGraphic;\n subGraphic.forEach(g => {\n g.glyphHost = this;\n Graphic.bindGlyphAttributes(g as Graphic, this.attribute);\n });\n this.valid = this.isValid();\n this.addUpdateBoundTag();\n this.subGraphicEncoder?.(this);\n }\n\n protected detachSubGraphic() {\n this.subGraphic.forEach(g => {\n g.glyphHost = null;\n Graphic.bindGlyphAttributes(g as Graphic, Object.prototype);\n });\n }\n\n getSubGraphic() {\n return this.subGraphic;\n }\n\n onInit(cb: (g: this) => void): void {\n this._onInit = cb;\n }\n\n onUpdate(cb: (g: this) => void): void {\n this._onUpdate = cb;\n }\n\n isValid(): boolean {\n return true;\n }\n\n setSubGraphicEncoder(encoder?: (g: IGlyph, context?: ISetAttributeContext) => void): void {\n this.subGraphicEncoder = encoder;\n encoder?.(this);\n }\n\n commitSubGraphicAttributes(\n subGraphic: IGraphic,\n patch: Record<string, any>,\n removedKeys?: readonly string[],\n context?: ISetAttributeContext\n ): void {\n Graphic.commitDerivedAttributePatch(subGraphic as Graphic, patch, removedKeys, context);\n }\n\n onAttributeUpdate(context?: ISetAttributeContext): void {\n if (this.glyphHost) {\n Graphic.bindGlyphAttributes(this, this.glyphHost.attribute);\n }\n for (const child of this.subGraphic) {\n Graphic.bindGlyphAttributes(child as Graphic, this.attribute);\n }\n this.subGraphicEncoder?.(this, context);\n if (!context?.skipUpdateCallback) {\n this._onUpdate?.(this);\n }\n super.onAttributeUpdate(context);\n }\n\n protected submitUpdateByCategory(category: UpdateCategory, forceUpdateTag: boolean = false): void {\n super.submitUpdateByCategory(category, forceUpdateTag);\n for (const child of this.subGraphic) {\n if (forceUpdateTag || category & UpdateCategory.SHAPE) {\n child.addUpdateShapeAndBoundsTag();\n } else if (category & UpdateCategory.BOUNDS) {\n child.addUpdateBoundTag();\n }\n if (category & UpdateCategory.PAINT) {\n child.addUpdatePaintTag();\n }\n if (forceUpdateTag || category & UpdateCategory.TRANSFORM) {\n child.addUpdatePositionTag();\n }\n if (forceUpdateTag || category & UpdateCategory.LAYOUT) {\n child.addUpdateLayoutTag();\n }\n }\n }\n\n // Glyph forwards inherited invalidation to children, so its base fast path must\n // classify changed keys too. Ordinary Graphic setters keep their existing path.\n protected commitBaseAttributesByTouchedKeys(\n params: Partial<IGlyphGraphicAttribute>,\n forceUpdateTag: boolean = false,\n context?: ISetAttributeContext\n ): void {\n this.commitBaseAttributesByCategory(params, forceUpdateTag, context);\n }\n\n protected commitBaseAttributeBySingleKey(\n key: string,\n value: any,\n forceUpdateTag: boolean = false,\n context?: ISetAttributeContext\n ): void {\n this.commitBaseAttributesByTouchedKeys({ [key]: value }, forceUpdateTag, context);\n }\n\n getGraphicTheme(): Required<IGlyphGraphicAttribute> {\n return getTheme(this as IGraphic).glyph;\n }\n\n protected updateAABBBounds(\n attribute: IGlyphGraphicAttribute,\n theme: Required<IGlyphGraphicAttribute>,\n aabbBounds: IAABBBounds\n ) {\n // 添加子节点\n this.getSubGraphic().forEach((node: IGraphic) => {\n aabbBounds.union(node.AABBBounds);\n });\n\n // glyph不需要计算AABBBounds\n // this.transformAABBBounds(attribute, aabbBounds, theme, graphic);\n return aabbBounds;\n }\n\n protected doUpdateAABBBounds(): AABBBounds {\n this.updateAABBBoundsStamp++;\n this._AABBBounds.clear();\n const bounds = this.updateAABBBounds(this.attribute, this.getGraphicTheme(), this._AABBBounds) as AABBBounds;\n this.clearUpdateBoundTag();\n return bounds;\n }\n\n protected needUpdateTags(keys: string[]): boolean {\n return false;\n }\n protected needUpdateTag(key: string): boolean {\n return false;\n }\n\n protected hasLegacyStateDefinitions(): boolean {\n if (this.glyphStateProxy) {\n return true;\n }\n for (const name in this.glyphStates) {\n if (Object.prototype.hasOwnProperty.call(this.glyphStates, name)) {\n return true;\n }\n }\n return false;\n }\n\n protected syncSharedStateScopeBindingFromTree(\n markDirty: boolean = true,\n inheritedSharedStateScope?: SharedStateScope<Record<string, any>> | null\n ): boolean {\n // Legacy Glyph definitions historically own the whole state surface.\n return this.hasLegacyStateDefinitions()\n ? this.syncSharedStateScopeBinding(undefined, markDirty)\n : super.syncSharedStateScopeBindingFromTree(markDirty, inheritedSharedStateScope);\n }\n\n protected resolveEffectiveCompiledDefinitions(stateNames: readonly string[] = []) {\n if (!this.hasLegacyStateDefinitions()) {\n this.legacyDefinitions = undefined;\n this.legacyCompiledDefinitions = undefined;\n return super.resolveEffectiveCompiledDefinitions(stateNames);\n }\n this.syncSharedStateScopeBindingFromTree(false);\n let changed = false;\n if (\n !this.legacyDefinitions ||\n this.legacyDefinitionsSource !== this.glyphStates ||\n this.legacyProxySource !== this.glyphStateProxy\n ) {\n this.legacyDefinitionsSource = this.glyphStates;\n this.legacyProxySource = this.glyphStateProxy;\n this.legacyDefinitions = {};\n for (const name of Object.keys(this.glyphStates ?? {})) {\n this.legacyDefinitions[name] = this.createLegacyStateDefinition(name);\n }\n changed = true;\n }\n if (this.glyphStateProxy) {\n const addDefinition = (name: string) => {\n if (!Object.prototype.hasOwnProperty.call(this.legacyDefinitions, name)) {\n this.legacyDefinitions[name] = this.createLegacyStateDefinition(name);\n changed = true;\n }\n };\n this.currentStates?.forEach(addDefinition);\n stateNames.forEach(addDefinition);\n }\n if (changed) {\n this.legacyCompiledDefinitions = new StateDefinitionCompiler<IGlyphGraphicAttribute>().compile(\n this.legacyDefinitions\n );\n }\n return { compiledDefinitions: this.legacyCompiledDefinitions, stateOrder: 'input' as const };\n }\n\n private createLegacyStateDefinition(name: string): StateDefinition<IGlyphGraphicAttribute> {\n return this.glyphStateProxy\n ? {\n name,\n resolver: ({ graphic, activeStates }) =>\n (graphic as Glyph).glyphStateProxy(name, activeStates as string[])?.attributes\n }\n : { name, patch: this.glyphStates[name].attributes };\n }\n\n clone(): IGraphic<Partial<IGlyphGraphicAttribute>> {\n const glyph = new Glyph({ ...this.attribute });\n glyph.setSubGraphic(this.subGraphic.map(g => g.clone()));\n return glyph;\n }\n\n release(): void {\n super.release();\n this.subGraphicEncoder = undefined;\n this._onUpdate = undefined;\n this.legacyDefinitions = undefined;\n this.legacyCompiledDefinitions = undefined;\n this.legacyDefinitionsSource = undefined;\n this.legacyProxySource = undefined;\n this.detachSubGraphic();\n this.subGraphic.forEach(child => child.release());\n this.subGraphic = [];\n }\n\n getNoWorkAnimateAttr(): Record<string, number> {\n return Glyph.NOWORK_ANIMATE_ATTR;\n }\n}\n\nexport function createGlyph(attributes: IGlyphGraphicAttribute): IGlyph {\n return new Glyph(attributes);\n}\n"]}
@@ -128,6 +128,7 @@ export declare abstract class Graphic<T extends Partial<IGraphicAttribute> = Par
128
128
  protected stateEngine?: StateEngine<T>;
129
129
  protected stateEngineCompiledDefinitions?: Map<string, CompiledStateDefinition<T>>;
130
130
  protected stateEngineStateSort?: (stateA: string, stateB: string) => number;
131
+ protected stateEngineStateOrder?: 'input';
131
132
  protected stateEngineMergeMode?: StateMergeMode;
132
133
  protected stateTransitionOrchestrator?: StateTransitionOrchestrator<T>;
133
134
  protected localStateDefinitionsSource?: StateDefinitionsInput<T>;
@@ -152,8 +153,9 @@ export declare abstract class Graphic<T extends Partial<IGraphicAttribute> = Par
152
153
  onParentSharedStateTreeChanged(stage?: IStage, layer?: ILayer, inheritedSharedStateScope?: SharedStateScope<Record<string, any>> | null): void;
153
154
  refreshSharedStateBeforeRender(): void;
154
155
  protected getLocalStatesVersion(): number;
155
- protected resolveEffectiveCompiledDefinitions(): {
156
+ protected resolveEffectiveCompiledDefinitions(_stateNames?: readonly string[]): {
156
157
  compiledDefinitions?: Map<string, CompiledStateDefinition<T>>;
158
+ stateOrder?: 'input';
157
159
  };
158
160
  protected recomputeCurrentStatePatch(): void;
159
161
  protected buildStaticAttributeSnapshot(): Partial<T>;
@@ -173,6 +175,7 @@ export declare abstract class Graphic<T extends Partial<IGraphicAttribute> = Par
173
175
  protected canCommitBaseAttributesByTouchedKeys(): boolean;
174
176
  protected detachAttributeFromBaseAttributes(): void;
175
177
  protected commitInternalBaseAttributes(params: Partial<T>, context?: ISetAttributeContext): void;
178
+ protected commitBaseAttributesByCategory(params: Partial<T>, forceUpdateTag?: boolean, context?: ISetAttributeContext): void;
176
179
  protected commitBaseAttributesByTouchedKeys(params: Partial<T>, forceUpdateTag?: boolean, context?: ISetAttributeContext): void;
177
180
  protected commitBaseAttributeBySingleKey(key: string, value: any, forceUpdateTag?: boolean, context?: ISetAttributeContext): void;
178
181
  protected applyBaseAttributes(params: Partial<T>): void;
@@ -235,6 +238,8 @@ export declare abstract class Graphic<T extends Partial<IGraphicAttribute> = Par
235
238
  rotate(angle: number, rotateCenter?: IPointLike): this;
236
239
  rotateTo(angle: number): this;
237
240
  skewTo(b: number, c: number): this;
241
+ protected static bindGlyphAttributes(graphic: Graphic, inherited: object): void;
242
+ protected static commitDerivedAttributePatch(graphic: Graphic, patch: Record<string, any>, removedKeys?: readonly string[], context?: ISetAttributeContext): void;
238
243
  onAttributeUpdate(context?: ISetAttributeContext): void;
239
244
  update(d?: {
240
245
  bounds: boolean;
@@ -245,7 +250,7 @@ export declare abstract class Graphic<T extends Partial<IGraphicAttribute> = Par
245
250
  setStateDefinitionsWithCompiled(definitions: StateDefinitionsInput<T>, compiledDefinitions: Map<string, CompiledStateDefinition<T>>): void;
246
251
  protected getStateResolveBaseAttrs(): Partial<T>;
247
252
  protected syncStateResolveContext(stateResolveBaseAttrs?: Partial<T>): Partial<T>;
248
- protected ensureStateEngine(stateResolveBaseAttrs?: Partial<T>): StateEngine<T>;
253
+ protected ensureStateEngine(stateResolveBaseAttrs?: Partial<T>, stateNames?: readonly string[]): StateEngine<T>;
249
254
  protected toGraphicStateTransition(result: StateTransitionResult): GraphicStateTransition;
250
255
  protected sortLocalStates(states: readonly string[]): string[];
251
256
  protected resolveLocalUseStatesTransition(states: readonly string[]): GraphicStateTransition;
@@ -247,7 +247,7 @@ export class Graphic extends Node {
247
247
  this.localStateDefinitionsVersion = (null !== (_a = this.localStateDefinitionsVersion) && void 0 !== _a ? _a : 0) + 1),
248
248
  null !== (_b = this.localStateDefinitionsVersion) && void 0 !== _b ? _b : 0;
249
249
  }
250
- resolveEffectiveCompiledDefinitions() {
250
+ resolveEffectiveCompiledDefinitions(_stateNames) {
251
251
  this.syncSharedStateScopeBindingFromTree(!1);
252
252
  const boundScope = this.boundSharedStateScope;
253
253
  boundScope && (ensureSharedStateScopeFresh(boundScope), this.boundSharedStateRevision = boundScope.revision);
@@ -372,7 +372,22 @@ export class Graphic extends Node {
372
372
  params && Object.keys(params).length && (this.canCommitBaseAttributesByTouchedKeys() ? this.commitBaseAttributesByTouchedKeys(params, !1, context) : (this.detachAttributeFromBaseAttributes(),
373
373
  this.applyBaseAttributes(params), this.commitBaseAttributeMutation(!1, context)));
374
374
  }
375
+ commitBaseAttributesByCategory(params, forceUpdateTag = !1, context) {
376
+ const base = this.getBaseAttributesStorage();
377
+ let category = UpdateCategory.NONE, hasKeys = !1;
378
+ for (const key in params) {
379
+ if (!Object.prototype.hasOwnProperty.call(params, key)) continue;
380
+ hasKeys = !0;
381
+ const prev = base[key], next = params[key];
382
+ prev !== next && (category = this.mergeAttributeDeltaCategory(category, key, prev, next)),
383
+ base[key] = next;
384
+ }
385
+ hasKeys && (this.attribute = base, this._baseAttributes = void 0, this.attributeMayContainTransientAttrs = !1,
386
+ this.valid = this.isValid(), this.submitUpdateByCategory(category, forceUpdateTag),
387
+ this.onAttributeUpdate(context));
388
+ }
375
389
  commitBaseAttributesByTouchedKeys(params, forceUpdateTag = !1, context) {
390
+ if (this.glyphHost) return void this.commitBaseAttributesByCategory(params, forceUpdateTag, context);
376
391
  const source = params, baseAttributes = this.getBaseAttributesStorage();
377
392
  let hasKeys = !1, needsShapeAndBounds = forceUpdateTag;
378
393
  for (const key in source) Object.prototype.hasOwnProperty.call(source, key) && (hasKeys = !0,
@@ -858,8 +873,19 @@ export class Graphic extends Node {
858
873
  skewTo(b, c) {
859
874
  return this;
860
875
  }
876
+ static bindGlyphAttributes(graphic, inherited) {
877
+ Object.getPrototypeOf(graphic.attribute) !== inherited && Object.setPrototypeOf(graphic.attribute, inherited),
878
+ graphic._baseAttributes && Object.getPrototypeOf(graphic._baseAttributes) !== inherited && Object.setPrototypeOf(graphic._baseAttributes, inherited);
879
+ }
880
+ static commitDerivedAttributePatch(graphic, patch, removedKeys, context) {
881
+ if (!(null == removedKeys ? void 0 : removedKeys.length)) return void graphic.setAttributes(patch, !1, context);
882
+ graphic.detachAttributeFromBaseAttributes();
883
+ const base = graphic.getBaseAttributesStorage();
884
+ removedKeys.forEach((key => delete base[key])), graphic.applyBaseAttributes(patch),
885
+ graphic.commitBaseAttributeMutation(!1, context);
886
+ }
861
887
  onAttributeUpdate(context) {
862
- context && context.skipUpdateCallback || (this.getGraphicService().onAttributeUpdate(this),
888
+ this.glyphHost && Graphic.bindGlyphAttributes(this, this.glyphHost.attribute), context && context.skipUpdateCallback || (this.getGraphicService().onAttributeUpdate(this),
863
889
  this._emitCustomEvent("afterAttributeUpdate", context));
864
890
  }
865
891
  update(d) {
@@ -888,15 +914,20 @@ export class Graphic extends Node {
888
914
  return null === (_a = this.stateEngine) || void 0 === _a || _a.setResolveContext(this, stateResolveBaseAttrs),
889
915
  stateResolveBaseAttrs;
890
916
  }
891
- ensureStateEngine(stateResolveBaseAttrs = this.getStateResolveBaseAttrs()) {
892
- const {compiledDefinitions: compiledDefinitions} = this.resolveEffectiveCompiledDefinitions();
893
- return this.compiledStateDefinitions = compiledDefinitions, compiledDefinitions ? this.stateEngine && this.stateEngineCompiledDefinitions === compiledDefinitions && this.stateEngineStateSort === this.stateSort && this.stateEngineMergeMode === this.stateMergeMode || (this.stateEngine = new StateEngine({
917
+ ensureStateEngine(stateResolveBaseAttrs, stateNames) {
918
+ var _a;
919
+ void 0 === stateResolveBaseAttrs && (stateResolveBaseAttrs = this.getStateResolveBaseAttrs()),
920
+ void 0 === stateNames && (stateNames = null !== (_a = this.currentStates) && void 0 !== _a ? _a : EMPTY_STATE_NAMES);
921
+ const {compiledDefinitions: compiledDefinitions, stateOrder: stateOrder} = this.resolveEffectiveCompiledDefinitions(stateNames);
922
+ return this.compiledStateDefinitions = compiledDefinitions, compiledDefinitions ? this.stateEngine && this.stateEngineCompiledDefinitions === compiledDefinitions && this.stateEngineStateSort === this.stateSort && this.stateEngineStateOrder === stateOrder && this.stateEngineMergeMode === this.stateMergeMode || (this.stateEngine = new StateEngine({
894
923
  compiledDefinitions: compiledDefinitions,
895
924
  stateSort: this.stateSort,
925
+ stateOrder: stateOrder,
896
926
  mergeMode: this.stateMergeMode
897
927
  }), this.stateEngineCompiledDefinitions = compiledDefinitions, this.stateEngineStateSort = this.stateSort,
898
- this.stateEngineMergeMode = this.stateMergeMode) : (this.stateEngine = void 0, this.stateEngineCompiledDefinitions = void 0),
899
- this.syncStateResolveContext(stateResolveBaseAttrs), this.stateEngine && this.currentStates && !this.sameStateNames(this.stateEngine.activeStates, this.currentStates) && this.stateEngine.applyStates(this.currentStates),
928
+ this.stateEngineStateOrder = stateOrder, this.stateEngineMergeMode = this.stateMergeMode) : (this.stateEngine = void 0,
929
+ this.stateEngineCompiledDefinitions = void 0), this.syncStateResolveContext(stateResolveBaseAttrs),
930
+ this.stateEngine && this.currentStates && !this.sameStateNames(this.stateEngine.activeStates, this.currentStates) && this.stateEngine.applyStates(this.currentStates),
900
931
  this.stateEngine;
901
932
  }
902
933
  toGraphicStateTransition(result) {
@@ -925,7 +956,7 @@ export class Graphic extends Node {
925
956
  };
926
957
  }
927
958
  resolveUseStatesTransition(states, stateResolveBaseAttrs = this.getStateResolveBaseAttrs()) {
928
- const stateEngine = this.ensureStateEngine(stateResolveBaseAttrs);
959
+ const stateEngine = this.ensureStateEngine(stateResolveBaseAttrs, states);
929
960
  return stateEngine ? this.toGraphicStateTransition(stateEngine.applyStates(states)) : this.resolveLocalUseStatesTransition(states);
930
961
  }
931
962
  resolveClearStatesTransition() {
@@ -934,7 +965,7 @@ export class Graphic extends Node {
934
965
  }
935
966
  resolveAddStateTransition(stateName, keepCurrentStates) {
936
967
  var _a;
937
- const stateEngine = this.ensureStateEngine();
968
+ const stateEngine = this.ensureStateEngine(void 0, [ stateName ]);
938
969
  if (stateEngine) return this.toGraphicStateTransition(stateEngine.addState(stateName, keepCurrentStates));
939
970
  if (this.currentStates && this.currentStates.includes(stateName) && (keepCurrentStates || 1 === this.currentStates.length)) return {
940
971
  changed: !1,
@@ -957,7 +988,7 @@ export class Graphic extends Node {
957
988
  } : this.resolveLocalUseStatesTransition(nextStates);
958
989
  }
959
990
  resolveToggleStateTransition(stateName) {
960
- const stateEngine = this.ensureStateEngine();
991
+ const stateEngine = this.ensureStateEngine(void 0, [ stateName ]);
961
992
  if (stateEngine) return this.toGraphicStateTransition(stateEngine.toggleState(stateName));
962
993
  if (this.hasState(stateName)) return this.resolveRemoveStateTransition(stateName);
963
994
  const nextStates = this.currentStates ? this.currentStates.slice() : [];
@@ -965,7 +996,7 @@ export class Graphic extends Node {
965
996
  }
966
997
  resolveGraphicStateTransition(states, forceResolverRefresh = !1) {
967
998
  var _a;
968
- const stateResolveBaseAttrs = this.getStateResolveBaseAttrs(), stateEngine = this.ensureStateEngine(stateResolveBaseAttrs);
999
+ const stateResolveBaseAttrs = this.getStateResolveBaseAttrs(), stateEngine = this.ensureStateEngine(stateResolveBaseAttrs, states);
969
1000
  forceResolverRefresh && (null == stateEngine || stateEngine.invalidateResolverCache());
970
1001
  const transition = stateEngine ? this.toGraphicStateTransition(stateEngine.applyStates(states)) : this.resolveLocalUseStatesTransition(states), resolvedStateAttrs = this.stateEngine && this.compiledStateDefinitions ? Object.assign({}, this.stateEngine.resolvedPatch) : {};
971
1002
  return {
@@ -1043,7 +1074,7 @@ export class Graphic extends Node {
1043
1074
  shouldSkipStateTransitionDefaultAttribute(_key, _targetAttrs) {
1044
1075
  return !1;
1045
1076
  }
1046
- stopStateAnimates(type = "end") {
1077
+ stopStateAnimates(type) {
1047
1078
  const stopAnimationState = this.stopAnimationState;
1048
1079
  if ("function" == typeof stopAnimationState) return void stopAnimationState.call(this, "state", type);
1049
1080
  if (!this.mayHaveTrackedAnimates()) return;