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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/cjs/graphic/glyph.d.ts +23 -11
  2. package/cjs/graphic/glyph.js +82 -58
  3. package/cjs/graphic/glyph.js.map +1 -1
  4. package/cjs/graphic/graphic.d.ts +8 -2
  5. package/cjs/graphic/graphic.js +46 -12
  6. package/cjs/graphic/graphic.js.map +1 -1
  7. package/cjs/graphic/state/attribute-update-classifier.js +2 -0
  8. package/cjs/graphic/state/attribute-update-classifier.js.map +1 -1
  9. package/cjs/graphic/state/state-definition.d.ts +1 -0
  10. package/cjs/graphic/state/state-definition.js.map +1 -1
  11. package/cjs/graphic/state/state-engine.d.ts +1 -0
  12. package/cjs/graphic/state/state-engine.js +2 -1
  13. package/cjs/graphic/state/state-engine.js.map +1 -1
  14. package/cjs/interface/graphic/glyph.d.ts +3 -1
  15. package/cjs/interface/graphic/glyph.js.map +1 -1
  16. package/dist/index.es.js +197 -102
  17. package/es/graphic/glyph.d.ts +23 -11
  18. package/es/graphic/glyph.js +84 -57
  19. package/es/graphic/glyph.js.map +1 -1
  20. package/es/graphic/graphic.d.ts +8 -2
  21. package/es/graphic/graphic.js +46 -12
  22. package/es/graphic/graphic.js.map +1 -1
  23. package/es/graphic/state/attribute-update-classifier.js +2 -0
  24. package/es/graphic/state/attribute-update-classifier.js.map +1 -1
  25. package/es/graphic/state/state-definition.d.ts +1 -0
  26. package/es/graphic/state/state-definition.js.map +1 -1
  27. package/es/graphic/state/state-engine.d.ts +1 -0
  28. package/es/graphic/state/state-engine.js +2 -1
  29. package/es/graphic/state/state-engine.js.map +1 -1
  30. package/es/interface/graphic/glyph.d.ts +3 -1
  31. package/es/interface/graphic/glyph.js.map +1 -1
  32. package/package.json +3 -3
@@ -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 { ATTRIBUTE_CATEGORY, 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;
@@ -85,36 +78,70 @@ export class Glyph extends Graphic {
85
78
  return this.clearUpdateBoundTag(), bounds;
86
79
  }
87
80
  needUpdateTags(keys) {
81
+ for (const key of keys) if (this.needUpdateTag(key)) return !0;
88
82
  return !1;
89
83
  }
90
84
  needUpdateTag(key) {
85
+ if (ATTRIBUTE_CATEGORY[key] === UpdateCategory.PAINT) return !1;
86
+ for (const child of this.subGraphic) if (Graphic.needsShapeUpdate(child, key)) return !0;
91
87
  return !1;
92
88
  }
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 = [];
89
+ hasLegacyStateDefinitions() {
90
+ if (this.glyphStateProxy) return !0;
91
+ for (const name in this.glyphStates) if (Object.prototype.hasOwnProperty.call(this.glyphStates, name)) return !0;
92
+ return !1;
93
+ }
94
+ syncSharedStateScopeBindingFromTree(markDirty = !0, inheritedSharedStateScope) {
95
+ return this.hasLegacyStateDefinitions() ? this.syncSharedStateScopeBinding(void 0, markDirty) : super.syncSharedStateScopeBindingFromTree(markDirty, inheritedSharedStateScope);
96
+ }
97
+ resolveEffectiveCompiledDefinitions(stateNames = []) {
98
+ var _a, _b;
99
+ if (!this.hasLegacyStateDefinitions()) return this.legacyDefinitions = void 0, this.legacyCompiledDefinitions = void 0,
100
+ super.resolveEffectiveCompiledDefinitions(stateNames);
101
+ this.syncSharedStateScopeBindingFromTree(!1);
102
+ let changed = !1;
103
+ if (!this.legacyDefinitions || this.legacyDefinitionsSource !== this.glyphStates || this.legacyProxySource !== this.glyphStateProxy) {
104
+ this.legacyDefinitionsSource = this.glyphStates, this.legacyProxySource = this.glyphStateProxy,
105
+ this.legacyDefinitions = {};
106
+ for (const name of Object.keys(null !== (_a = this.glyphStates) && void 0 !== _a ? _a : {})) this.legacyDefinitions[name] = this.createLegacyStateDefinition(name);
107
+ changed = !0;
108
+ }
109
+ if (this.glyphStateProxy) {
110
+ const addDefinition = name => {
111
+ Object.prototype.hasOwnProperty.call(this.legacyDefinitions, name) || (this.legacyDefinitions[name] = this.createLegacyStateDefinition(name),
112
+ changed = !0);
113
+ };
114
+ null === (_b = this.currentStates) || void 0 === _b || _b.forEach(addDefinition),
115
+ stateNames.forEach(addDefinition);
116
+ }
117
+ return changed && (this.legacyCompiledDefinitions = (new StateDefinitionCompiler).compile(this.legacyDefinitions)),
118
+ {
119
+ compiledDefinitions: this.legacyCompiledDefinitions,
120
+ stateOrder: "input"
121
+ };
122
+ }
123
+ createLegacyStateDefinition(name) {
124
+ return this.glyphStateProxy ? {
125
+ name: name,
126
+ resolver: ({graphic: graphic, activeStates: activeStates}) => {
127
+ var _a;
128
+ return null === (_a = graphic.glyphStateProxy(name, activeStates)) || void 0 === _a ? void 0 : _a.attributes;
129
+ }
130
+ } : {
131
+ name: name,
132
+ patch: this.glyphStates[name].attributes
133
+ };
113
134
  }
114
135
  clone() {
115
136
  const glyph = new Glyph(Object.assign({}, this.attribute));
116
137
  return glyph.setSubGraphic(this.subGraphic.map((g => g.clone()))), glyph;
117
138
  }
139
+ release() {
140
+ super.release(), this.subGraphicEncoder = void 0, this._onUpdate = void 0, this.legacyDefinitions = void 0,
141
+ this.legacyCompiledDefinitions = void 0, this.legacyDefinitionsSource = void 0,
142
+ this.legacyProxySource = void 0, this.detachSubGraphic(), this.subGraphic.forEach((child => child.release())),
143
+ this.subGraphic = [];
144
+ }
118
145
  getNoWorkAnimateAttr() {
119
146
  return Glyph.NOWORK_ANIMATE_ATTR;
120
147
  }
@@ -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,IAA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AC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACzD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,oBAAoB;QAClB,OAAO,KAAK,CAAC,mBAAmB,CAAC;IACnC,CAAC;;AAxNM,yBAAmB,GAAG,mBAAmB,CAAC;AA2NnD,MAAM,UAAU,WAAW,CAAC,UAAkC;IAC5D,OAAO,IAAI,KAAK,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,kBAAkB,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACzF,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;YACr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_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 { ATTRIBUTE_CATEGORY, 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 for (const key of keys) {\n if (this.needUpdateTag(key)) {\n return true;\n }\n }\n return false;\n }\n protected needUpdateTag(key: string): boolean {\n if (ATTRIBUTE_CATEGORY[key] === UpdateCategory.PAINT) {\n return false;\n }\n for (const child of this.subGraphic) {\n if (Graphic.needsShapeUpdate(child as Graphic, key)) {\n return true;\n }\n }\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;
@@ -225,6 +228,7 @@ export declare abstract class Graphic<T extends Partial<IGraphicAttribute> = Par
225
228
  setAttributes(params: Partial<T>, forceUpdateTag?: boolean, context?: ISetAttributeContext): void;
226
229
  _setAttributes(params: Partial<T>, forceUpdateTag?: boolean, context?: ISetAttributeContext): void;
227
230
  setAttribute(key: string, value: any, forceUpdateTag?: boolean, context?: ISetAttributeContext): void;
231
+ protected static needsShapeUpdate(graphic: Graphic, key: string): boolean;
228
232
  protected needUpdateTags(keys: string[], k?: string[]): boolean;
229
233
  protected needUpdateTag(key: string, k?: string[]): boolean;
230
234
  initAttributes(params: T): void;
@@ -235,6 +239,8 @@ export declare abstract class Graphic<T extends Partial<IGraphicAttribute> = Par
235
239
  rotate(angle: number, rotateCenter?: IPointLike): this;
236
240
  rotateTo(angle: number): this;
237
241
  skewTo(b: number, c: number): this;
242
+ protected static bindGlyphAttributes(graphic: Graphic, inherited: object): void;
243
+ protected static commitDerivedAttributePatch(graphic: Graphic, patch: Record<string, any>, removedKeys?: readonly string[], context?: ISetAttributeContext): void;
238
244
  onAttributeUpdate(context?: ISetAttributeContext): void;
239
245
  update(d?: {
240
246
  bounds: boolean;
@@ -245,7 +251,7 @@ export declare abstract class Graphic<T extends Partial<IGraphicAttribute> = Par
245
251
  setStateDefinitionsWithCompiled(definitions: StateDefinitionsInput<T>, compiledDefinitions: Map<string, CompiledStateDefinition<T>>): void;
246
252
  protected getStateResolveBaseAttrs(): Partial<T>;
247
253
  protected syncStateResolveContext(stateResolveBaseAttrs?: Partial<T>): Partial<T>;
248
- protected ensureStateEngine(stateResolveBaseAttrs?: Partial<T>): StateEngine<T>;
254
+ protected ensureStateEngine(stateResolveBaseAttrs?: Partial<T>, stateNames?: readonly string[]): StateEngine<T>;
249
255
  protected toGraphicStateTransition(result: StateTransitionResult): GraphicStateTransition;
250
256
  protected sortLocalStates(states: readonly string[]): string[];
251
257
  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,
@@ -736,6 +751,9 @@ export class Graphic extends Node {
736
751
  }
737
752
  "background" === key ? this.loadImage(value, !0) : "texture" === key && isExternalTexture(value) ? this.loadImage(value, !1) : "shadowGraphic" === key && this.setShadowGraphic(value);
738
753
  }
754
+ static needsShapeUpdate(graphic, key) {
755
+ return graphic.needUpdateTag(key);
756
+ }
739
757
  needUpdateTags(keys, k = GRAPHIC_UPDATE_TAG_KEY) {
740
758
  for (let i = 0; i < k.length; i++) {
741
759
  const attrKey = k[i];
@@ -858,8 +876,19 @@ export class Graphic extends Node {
858
876
  skewTo(b, c) {
859
877
  return this;
860
878
  }
879
+ static bindGlyphAttributes(graphic, inherited) {
880
+ Object.getPrototypeOf(graphic.attribute) !== inherited && Object.setPrototypeOf(graphic.attribute, inherited),
881
+ graphic._baseAttributes && Object.getPrototypeOf(graphic._baseAttributes) !== inherited && Object.setPrototypeOf(graphic._baseAttributes, inherited);
882
+ }
883
+ static commitDerivedAttributePatch(graphic, patch, removedKeys, context) {
884
+ if (!(null == removedKeys ? void 0 : removedKeys.length)) return void graphic.setAttributes(patch, !1, context);
885
+ graphic.detachAttributeFromBaseAttributes();
886
+ const base = graphic.getBaseAttributesStorage();
887
+ removedKeys.forEach((key => delete base[key])), graphic.applyBaseAttributes(patch),
888
+ graphic.commitBaseAttributeMutation(!1, context);
889
+ }
861
890
  onAttributeUpdate(context) {
862
- context && context.skipUpdateCallback || (this.getGraphicService().onAttributeUpdate(this),
891
+ this.glyphHost && Graphic.bindGlyphAttributes(this, this.glyphHost.attribute), context && context.skipUpdateCallback || (this.getGraphicService().onAttributeUpdate(this),
863
892
  this._emitCustomEvent("afterAttributeUpdate", context));
864
893
  }
865
894
  update(d) {
@@ -888,15 +917,20 @@ export class Graphic extends Node {
888
917
  return null === (_a = this.stateEngine) || void 0 === _a || _a.setResolveContext(this, stateResolveBaseAttrs),
889
918
  stateResolveBaseAttrs;
890
919
  }
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({
920
+ ensureStateEngine(stateResolveBaseAttrs, stateNames) {
921
+ var _a;
922
+ void 0 === stateResolveBaseAttrs && (stateResolveBaseAttrs = this.getStateResolveBaseAttrs()),
923
+ void 0 === stateNames && (stateNames = null !== (_a = this.currentStates) && void 0 !== _a ? _a : EMPTY_STATE_NAMES);
924
+ const {compiledDefinitions: compiledDefinitions, stateOrder: stateOrder} = this.resolveEffectiveCompiledDefinitions(stateNames);
925
+ 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
926
  compiledDefinitions: compiledDefinitions,
895
927
  stateSort: this.stateSort,
928
+ stateOrder: stateOrder,
896
929
  mergeMode: this.stateMergeMode
897
930
  }), 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),
931
+ this.stateEngineStateOrder = stateOrder, this.stateEngineMergeMode = this.stateMergeMode) : (this.stateEngine = void 0,
932
+ this.stateEngineCompiledDefinitions = void 0), this.syncStateResolveContext(stateResolveBaseAttrs),
933
+ this.stateEngine && this.currentStates && !this.sameStateNames(this.stateEngine.activeStates, this.currentStates) && this.stateEngine.applyStates(this.currentStates),
900
934
  this.stateEngine;
901
935
  }
902
936
  toGraphicStateTransition(result) {
@@ -925,7 +959,7 @@ export class Graphic extends Node {
925
959
  };
926
960
  }
927
961
  resolveUseStatesTransition(states, stateResolveBaseAttrs = this.getStateResolveBaseAttrs()) {
928
- const stateEngine = this.ensureStateEngine(stateResolveBaseAttrs);
962
+ const stateEngine = this.ensureStateEngine(stateResolveBaseAttrs, states);
929
963
  return stateEngine ? this.toGraphicStateTransition(stateEngine.applyStates(states)) : this.resolveLocalUseStatesTransition(states);
930
964
  }
931
965
  resolveClearStatesTransition() {
@@ -934,7 +968,7 @@ export class Graphic extends Node {
934
968
  }
935
969
  resolveAddStateTransition(stateName, keepCurrentStates) {
936
970
  var _a;
937
- const stateEngine = this.ensureStateEngine();
971
+ const stateEngine = this.ensureStateEngine(void 0, [ stateName ]);
938
972
  if (stateEngine) return this.toGraphicStateTransition(stateEngine.addState(stateName, keepCurrentStates));
939
973
  if (this.currentStates && this.currentStates.includes(stateName) && (keepCurrentStates || 1 === this.currentStates.length)) return {
940
974
  changed: !1,
@@ -957,7 +991,7 @@ export class Graphic extends Node {
957
991
  } : this.resolveLocalUseStatesTransition(nextStates);
958
992
  }
959
993
  resolveToggleStateTransition(stateName) {
960
- const stateEngine = this.ensureStateEngine();
994
+ const stateEngine = this.ensureStateEngine(void 0, [ stateName ]);
961
995
  if (stateEngine) return this.toGraphicStateTransition(stateEngine.toggleState(stateName));
962
996
  if (this.hasState(stateName)) return this.resolveRemoveStateTransition(stateName);
963
997
  const nextStates = this.currentStates ? this.currentStates.slice() : [];
@@ -965,7 +999,7 @@ export class Graphic extends Node {
965
999
  }
966
1000
  resolveGraphicStateTransition(states, forceResolverRefresh = !1) {
967
1001
  var _a;
968
- const stateResolveBaseAttrs = this.getStateResolveBaseAttrs(), stateEngine = this.ensureStateEngine(stateResolveBaseAttrs);
1002
+ const stateResolveBaseAttrs = this.getStateResolveBaseAttrs(), stateEngine = this.ensureStateEngine(stateResolveBaseAttrs, states);
969
1003
  forceResolverRefresh && (null == stateEngine || stateEngine.invalidateResolverCache());
970
1004
  const transition = stateEngine ? this.toGraphicStateTransition(stateEngine.applyStates(states)) : this.resolveLocalUseStatesTransition(states), resolvedStateAttrs = this.stateEngine && this.compiledStateDefinitions ? Object.assign({}, this.stateEngine.resolvedPatch) : {};
971
1005
  return {
@@ -1043,7 +1077,7 @@ export class Graphic extends Node {
1043
1077
  shouldSkipStateTransitionDefaultAttribute(_key, _targetAttrs) {
1044
1078
  return !1;
1045
1079
  }
1046
- stopStateAnimates(type = "end") {
1080
+ stopStateAnimates(type) {
1047
1081
  const stopAnimationState = this.stopAnimationState;
1048
1082
  if ("function" == typeof stopAnimationState) return void stopAnimationState.call(this, "state", type);
1049
1083
  if (!this.mayHaveTrackedAnimates()) return;