@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,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;
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.createGlyph = exports.Glyph = void 0;
6
6
 
7
- const graphic_1 = require("./graphic"), theme_1 = require("./theme"), constants_1 = require("./constants");
7
+ const graphic_1 = require("./graphic"), state_definition_compiler_1 = require("./state/state-definition-compiler"), theme_1 = require("./theme"), attribute_update_classifier_1 = require("./state/attribute-update-classifier"), constants_1 = require("./constants");
8
8
 
9
9
  class Glyph extends graphic_1.Graphic {
10
10
  constructor(params) {
@@ -12,13 +12,14 @@ class Glyph extends graphic_1.Graphic {
12
12
  this.subGraphic = [], this._onInit && this._onInit(this), this.valid = this.isValid();
13
13
  }
14
14
  setSubGraphic(subGraphic) {
15
+ var _a;
15
16
  this.detachSubGraphic(), this.subGraphic = subGraphic, subGraphic.forEach((g => {
16
- g.glyphHost = this, Object.setPrototypeOf(g.attribute, this.attribute);
17
- })), this.valid = this.isValid(), this.addUpdateBoundTag();
17
+ g.glyphHost = this, graphic_1.Graphic.bindGlyphAttributes(g, this.attribute);
18
+ })), this.valid = this.isValid(), this.addUpdateBoundTag(), null === (_a = this.subGraphicEncoder) || void 0 === _a || _a.call(this, this);
18
19
  }
19
20
  detachSubGraphic() {
20
21
  this.subGraphic.forEach((g => {
21
- g.glyphHost = null, Object.setPrototypeOf(g.attribute, {});
22
+ g.glyphHost = null, graphic_1.Graphic.bindGlyphAttributes(g, Object.prototype);
22
23
  }));
23
24
  }
24
25
  getSubGraphic() {
@@ -33,45 +34,34 @@ class Glyph extends graphic_1.Graphic {
33
34
  isValid() {
34
35
  return !0;
35
36
  }
36
- setAttribute(key, value, forceUpdateTag, context) {
37
- super.setAttribute(key, value, forceUpdateTag, context), this.subGraphic.forEach((g => {
38
- g.addUpdateShapeAndBoundsTag(), g.addUpdatePositionTag();
39
- }));
40
- }
41
- setAttributes(params, forceUpdateTag = !1, context) {
42
- super.setAttributes(params, forceUpdateTag, context), this.subGraphic.forEach((g => {
43
- g.addUpdateShapeAndBoundsTag(), g.addUpdatePositionTag();
44
- }));
45
- }
46
- translate(x, y) {
47
- return super.translate(x, y), this.subGraphic.forEach((g => {
48
- g.addUpdatePositionTag(), g.addUpdateBoundTag();
49
- })), this;
37
+ setSubGraphicEncoder(encoder) {
38
+ this.subGraphicEncoder = encoder, null == encoder || encoder(this);
50
39
  }
51
- translateTo(x, y) {
52
- return super.translateTo(x, y), this.subGraphic.forEach((g => {
53
- g.addUpdatePositionTag(), g.addUpdateBoundTag();
54
- })), this;
40
+ commitSubGraphicAttributes(subGraphic, patch, removedKeys, context) {
41
+ graphic_1.Graphic.commitDerivedAttributePatch(subGraphic, patch, removedKeys, context);
55
42
  }
56
- scale(scaleX, scaleY, scaleCenter) {
57
- return super.scale(scaleX, scaleY, scaleCenter), this.subGraphic.forEach((g => {
58
- g.addUpdatePositionTag(), g.addUpdateBoundTag();
59
- })), this;
43
+ onAttributeUpdate(context) {
44
+ var _a, _b;
45
+ this.glyphHost && graphic_1.Graphic.bindGlyphAttributes(this, this.glyphHost.attribute);
46
+ for (const child of this.subGraphic) graphic_1.Graphic.bindGlyphAttributes(child, this.attribute);
47
+ null === (_a = this.subGraphicEncoder) || void 0 === _a || _a.call(this, this, context),
48
+ (null == context ? void 0 : context.skipUpdateCallback) || null === (_b = this._onUpdate) || void 0 === _b || _b.call(this, this),
49
+ super.onAttributeUpdate(context);
60
50
  }
61
- scaleTo(scaleX, scaleY) {
62
- return super.scaleTo(scaleX, scaleY), this.subGraphic.forEach((g => {
63
- g.addUpdatePositionTag(), g.addUpdateBoundTag();
64
- })), this;
51
+ submitUpdateByCategory(category, forceUpdateTag = !1) {
52
+ super.submitUpdateByCategory(category, forceUpdateTag);
53
+ for (const child of this.subGraphic) forceUpdateTag || category & attribute_update_classifier_1.UpdateCategory.SHAPE ? child.addUpdateShapeAndBoundsTag() : category & attribute_update_classifier_1.UpdateCategory.BOUNDS && child.addUpdateBoundTag(),
54
+ category & attribute_update_classifier_1.UpdateCategory.PAINT && child.addUpdatePaintTag(),
55
+ (forceUpdateTag || category & attribute_update_classifier_1.UpdateCategory.TRANSFORM) && child.addUpdatePositionTag(),
56
+ (forceUpdateTag || category & attribute_update_classifier_1.UpdateCategory.LAYOUT) && child.addUpdateLayoutTag();
65
57
  }
66
- rotate(angle) {
67
- return super.rotate(angle), this.subGraphic.forEach((g => {
68
- g.addUpdatePositionTag(), g.addUpdateBoundTag();
69
- })), this;
58
+ commitBaseAttributesByTouchedKeys(params, forceUpdateTag = !1, context) {
59
+ this.commitBaseAttributesByCategory(params, forceUpdateTag, context);
70
60
  }
71
- rotateTo(angle) {
72
- return super.rotate(angle), this.subGraphic.forEach((g => {
73
- g.addUpdatePositionTag(), g.addUpdateBoundTag();
74
- })), this;
61
+ commitBaseAttributeBySingleKey(key, value, forceUpdateTag = !1, context) {
62
+ this.commitBaseAttributesByTouchedKeys({
63
+ [key]: value
64
+ }, forceUpdateTag, context);
75
65
  }
76
66
  getGraphicTheme() {
77
67
  return (0, theme_1.getTheme)(this).glyph;
@@ -87,36 +77,70 @@ class Glyph extends graphic_1.Graphic {
87
77
  return this.clearUpdateBoundTag(), bounds;
88
78
  }
89
79
  needUpdateTags(keys) {
80
+ for (const key of keys) if (this.needUpdateTag(key)) return !0;
90
81
  return !1;
91
82
  }
92
83
  needUpdateTag(key) {
84
+ if (attribute_update_classifier_1.ATTRIBUTE_CATEGORY[key] === attribute_update_classifier_1.UpdateCategory.PAINT) return !1;
85
+ for (const child of this.subGraphic) if (graphic_1.Graphic.needsShapeUpdate(child, key)) return !0;
93
86
  return !1;
94
87
  }
95
- useStates(states, hasAnimation) {
96
- var _a;
97
- if (!states.length) return void this.clearStates(hasAnimation);
98
- const previousStates = this.currentStates ? this.currentStates.slice() : [];
99
- if (!((null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) !== states.length || states.some(((stateName, index) => this.currentStates[index] !== stateName)))) return;
100
- this.stopStateAnimates(), this.stateSort && (states = states.sort(this.stateSort));
101
- const stateAttrs = {};
102
- states.forEach((stateName => {
103
- const attrs = this.glyphStateProxy ? this.glyphStateProxy(stateName, states) : this.glyphStates[stateName];
104
- attrs && Object.assign(stateAttrs, attrs.attributes);
105
- })), this.beforeStateUpdate(stateAttrs, previousStates, states, hasAnimation, !1) && (this.currentStates = states,
106
- this.applyStateAttrs(stateAttrs, states, hasAnimation));
107
- }
108
- clearStates(hasAnimation) {
109
- this.stopStateAnimates();
110
- const previousStates = this.currentStates ? this.currentStates.slice() : [];
111
- if (this.hasState() && this.normalAttrs) {
112
- if (!this.beforeStateUpdate(this.normalAttrs, previousStates, [], hasAnimation, !0)) return;
113
- this.currentStates = [], this.applyStateAttrs(this.normalAttrs, this.currentStates, hasAnimation, !0);
114
- } else this.currentStates = [];
88
+ hasLegacyStateDefinitions() {
89
+ if (this.glyphStateProxy) return !0;
90
+ for (const name in this.glyphStates) if (Object.prototype.hasOwnProperty.call(this.glyphStates, name)) return !0;
91
+ return !1;
92
+ }
93
+ syncSharedStateScopeBindingFromTree(markDirty = !0, inheritedSharedStateScope) {
94
+ return this.hasLegacyStateDefinitions() ? this.syncSharedStateScopeBinding(void 0, markDirty) : super.syncSharedStateScopeBindingFromTree(markDirty, inheritedSharedStateScope);
95
+ }
96
+ resolveEffectiveCompiledDefinitions(stateNames = []) {
97
+ var _a, _b;
98
+ if (!this.hasLegacyStateDefinitions()) return this.legacyDefinitions = void 0, this.legacyCompiledDefinitions = void 0,
99
+ super.resolveEffectiveCompiledDefinitions(stateNames);
100
+ this.syncSharedStateScopeBindingFromTree(!1);
101
+ let changed = !1;
102
+ if (!this.legacyDefinitions || this.legacyDefinitionsSource !== this.glyphStates || this.legacyProxySource !== this.glyphStateProxy) {
103
+ this.legacyDefinitionsSource = this.glyphStates, this.legacyProxySource = this.glyphStateProxy,
104
+ this.legacyDefinitions = {};
105
+ for (const name of Object.keys(null !== (_a = this.glyphStates) && void 0 !== _a ? _a : {})) this.legacyDefinitions[name] = this.createLegacyStateDefinition(name);
106
+ changed = !0;
107
+ }
108
+ if (this.glyphStateProxy) {
109
+ const addDefinition = name => {
110
+ Object.prototype.hasOwnProperty.call(this.legacyDefinitions, name) || (this.legacyDefinitions[name] = this.createLegacyStateDefinition(name),
111
+ changed = !0);
112
+ };
113
+ null === (_b = this.currentStates) || void 0 === _b || _b.forEach(addDefinition),
114
+ stateNames.forEach(addDefinition);
115
+ }
116
+ return changed && (this.legacyCompiledDefinitions = (new state_definition_compiler_1.StateDefinitionCompiler).compile(this.legacyDefinitions)),
117
+ {
118
+ compiledDefinitions: this.legacyCompiledDefinitions,
119
+ stateOrder: "input"
120
+ };
121
+ }
122
+ createLegacyStateDefinition(name) {
123
+ return this.glyphStateProxy ? {
124
+ name: name,
125
+ resolver: ({graphic: graphic, activeStates: activeStates}) => {
126
+ var _a;
127
+ return null === (_a = graphic.glyphStateProxy(name, activeStates)) || void 0 === _a ? void 0 : _a.attributes;
128
+ }
129
+ } : {
130
+ name: name,
131
+ patch: this.glyphStates[name].attributes
132
+ };
115
133
  }
116
134
  clone() {
117
135
  const glyph = new Glyph(Object.assign({}, this.attribute));
118
136
  return glyph.setSubGraphic(this.subGraphic.map((g => g.clone()))), glyph;
119
137
  }
138
+ release() {
139
+ super.release(), this.subGraphicEncoder = void 0, this._onUpdate = void 0, this.legacyDefinitions = void 0,
140
+ this.legacyCompiledDefinitions = void 0, this.legacyDefinitionsSource = void 0,
141
+ this.legacyProxySource = void 0, this.detachSubGraphic(), this.subGraphic.forEach((child => child.release())),
142
+ this.subGraphic = [];
143
+ }
120
144
  getNoWorkAnimateAttr() {
121
145
  return Glyph.NOWORK_ANIMATE_ATTR;
122
146
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/graphic/glyph.ts"],"names":[],"mappings":";;;AACA,uCAAyD;AASzD,mCAAmC;AACnC,2CAAgD;AAEhD,MAAa,KAAM,SAAQ,iBAA+B;IAsBxD,YAAY,MAAuC;QACjD,KAAK,CAAC,MAAM,CAAC,CAAC;QAtBhB,SAAI,GAAgB,OAAO,CAAC;QAuB1B,IAAI,CAAC,UAAU,GAAG,6BAAiB,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,E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AK,CAAC;IACf,CAAC;IAED,oBAAoB;QAClB,OAAO,KAAK,CAAC,mBAAmB,CAAC;IACnC,CAAC;;AA5OH,sBA6OC;AAzNQ,yBAAmB,GAAG,6BAAmB,CAAC;AA2NnD,SAAgB,WAAW,CAAC,UAAkC;IAC5D,OAAO,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC;AAC/B,CAAC;AAFD,kCAEC","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,uCAAyD;AASzD,iFAA4E;AAG5E,mCAAmC;AACnC,qFAAyF;AACzF,2CAAgD;AAEhD,MAAa,KAAM,SAAQ,iBAA+B;IA2BxD,YAAY,MAAuC;QACjD,KAAK,CAAC,MAAM,CAAC,CAAC;QA3BhB,SAAI,GAAgB,OAAO,CAAC;QA4B1B,IAAI,CAAC,UAAU,GAAG,6BAAiB,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,iBAAO,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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,IAAI,CAAC,SAAS,EAAG,CAAC;QAC/C,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACzD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO;QACL,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC;QACnC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC;QACnC,IAAI,CAAC,yBAAyB,GAAG,SAAS,CAAC;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;;AApRH,sBAqRC;AA5PQ,yBAAmB,GAAG,6BAAmB,CAAC;AA8PnD,SAAgB,WAAW,CAAC,UAAkC;IAC5D,OAAO,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC;AAC/B,CAAC;AAFD,kCAEC","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 { 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;
@@ -210,7 +210,7 @@ class Graphic extends node_tree_1.Node {
210
210
  this.localStateDefinitionsVersion = (null !== (_a = this.localStateDefinitionsVersion) && void 0 !== _a ? _a : 0) + 1),
211
211
  null !== (_b = this.localStateDefinitionsVersion) && void 0 !== _b ? _b : 0;
212
212
  }
213
- resolveEffectiveCompiledDefinitions() {
213
+ resolveEffectiveCompiledDefinitions(_stateNames) {
214
214
  this.syncSharedStateScopeBindingFromTree(!1);
215
215
  const boundScope = this.boundSharedStateScope;
216
216
  boundScope && ((0, shared_state_scope_1.ensureSharedStateScopeFresh)(boundScope),
@@ -337,7 +337,22 @@ class Graphic extends node_tree_1.Node {
337
337
  params && Object.keys(params).length && (this.canCommitBaseAttributesByTouchedKeys() ? this.commitBaseAttributesByTouchedKeys(params, !1, context) : (this.detachAttributeFromBaseAttributes(),
338
338
  this.applyBaseAttributes(params), this.commitBaseAttributeMutation(!1, context)));
339
339
  }
340
+ commitBaseAttributesByCategory(params, forceUpdateTag = !1, context) {
341
+ const base = this.getBaseAttributesStorage();
342
+ let category = attribute_update_classifier_1.UpdateCategory.NONE, hasKeys = !1;
343
+ for (const key in params) {
344
+ if (!Object.prototype.hasOwnProperty.call(params, key)) continue;
345
+ hasKeys = !0;
346
+ const prev = base[key], next = params[key];
347
+ prev !== next && (category = this.mergeAttributeDeltaCategory(category, key, prev, next)),
348
+ base[key] = next;
349
+ }
350
+ hasKeys && (this.attribute = base, this._baseAttributes = void 0, this.attributeMayContainTransientAttrs = !1,
351
+ this.valid = this.isValid(), this.submitUpdateByCategory(category, forceUpdateTag),
352
+ this.onAttributeUpdate(context));
353
+ }
340
354
  commitBaseAttributesByTouchedKeys(params, forceUpdateTag = !1, context) {
355
+ if (this.glyphHost) return void this.commitBaseAttributesByCategory(params, forceUpdateTag, context);
341
356
  const source = params, baseAttributes = this.getBaseAttributesStorage();
342
357
  let hasKeys = !1, needsShapeAndBounds = forceUpdateTag;
343
358
  for (const key in source) Object.prototype.hasOwnProperty.call(source, key) && (hasKeys = !0,
@@ -706,6 +721,9 @@ class Graphic extends node_tree_1.Node {
706
721
  }
707
722
  "background" === key ? this.loadImage(value, !0) : "texture" === key && isExternalTexture(value) ? this.loadImage(value, !1) : "shadowGraphic" === key && this.setShadowGraphic(value);
708
723
  }
724
+ static needsShapeUpdate(graphic, key) {
725
+ return graphic.needUpdateTag(key);
726
+ }
709
727
  needUpdateTags(keys, k = exports.GRAPHIC_UPDATE_TAG_KEY) {
710
728
  for (let i = 0; i < k.length; i++) {
711
729
  const attrKey = k[i];
@@ -828,8 +846,19 @@ class Graphic extends node_tree_1.Node {
828
846
  skewTo(b, c) {
829
847
  return this;
830
848
  }
849
+ static bindGlyphAttributes(graphic, inherited) {
850
+ Object.getPrototypeOf(graphic.attribute) !== inherited && Object.setPrototypeOf(graphic.attribute, inherited),
851
+ graphic._baseAttributes && Object.getPrototypeOf(graphic._baseAttributes) !== inherited && Object.setPrototypeOf(graphic._baseAttributes, inherited);
852
+ }
853
+ static commitDerivedAttributePatch(graphic, patch, removedKeys, context) {
854
+ if (!(null == removedKeys ? void 0 : removedKeys.length)) return void graphic.setAttributes(patch, !1, context);
855
+ graphic.detachAttributeFromBaseAttributes();
856
+ const base = graphic.getBaseAttributesStorage();
857
+ removedKeys.forEach((key => delete base[key])), graphic.applyBaseAttributes(patch),
858
+ graphic.commitBaseAttributeMutation(!1, context);
859
+ }
831
860
  onAttributeUpdate(context) {
832
- context && context.skipUpdateCallback || (this.getGraphicService().onAttributeUpdate(this),
861
+ this.glyphHost && Graphic.bindGlyphAttributes(this, this.glyphHost.attribute), context && context.skipUpdateCallback || (this.getGraphicService().onAttributeUpdate(this),
833
862
  this._emitCustomEvent("afterAttributeUpdate", context));
834
863
  }
835
864
  update(d) {
@@ -858,15 +887,20 @@ class Graphic extends node_tree_1.Node {
858
887
  return null === (_a = this.stateEngine) || void 0 === _a || _a.setResolveContext(this, stateResolveBaseAttrs),
859
888
  stateResolveBaseAttrs;
860
889
  }
861
- ensureStateEngine(stateResolveBaseAttrs = this.getStateResolveBaseAttrs()) {
862
- const {compiledDefinitions: compiledDefinitions} = this.resolveEffectiveCompiledDefinitions();
863
- return this.compiledStateDefinitions = compiledDefinitions, compiledDefinitions ? this.stateEngine && this.stateEngineCompiledDefinitions === compiledDefinitions && this.stateEngineStateSort === this.stateSort && this.stateEngineMergeMode === this.stateMergeMode || (this.stateEngine = new state_engine_1.StateEngine({
890
+ ensureStateEngine(stateResolveBaseAttrs, stateNames) {
891
+ var _a;
892
+ void 0 === stateResolveBaseAttrs && (stateResolveBaseAttrs = this.getStateResolveBaseAttrs()),
893
+ void 0 === stateNames && (stateNames = null !== (_a = this.currentStates) && void 0 !== _a ? _a : EMPTY_STATE_NAMES);
894
+ const {compiledDefinitions: compiledDefinitions, stateOrder: stateOrder} = this.resolveEffectiveCompiledDefinitions(stateNames);
895
+ return this.compiledStateDefinitions = compiledDefinitions, compiledDefinitions ? this.stateEngine && this.stateEngineCompiledDefinitions === compiledDefinitions && this.stateEngineStateSort === this.stateSort && this.stateEngineStateOrder === stateOrder && this.stateEngineMergeMode === this.stateMergeMode || (this.stateEngine = new state_engine_1.StateEngine({
864
896
  compiledDefinitions: compiledDefinitions,
865
897
  stateSort: this.stateSort,
898
+ stateOrder: stateOrder,
866
899
  mergeMode: this.stateMergeMode
867
900
  }), this.stateEngineCompiledDefinitions = compiledDefinitions, this.stateEngineStateSort = this.stateSort,
868
- this.stateEngineMergeMode = this.stateMergeMode) : (this.stateEngine = void 0, this.stateEngineCompiledDefinitions = void 0),
869
- this.syncStateResolveContext(stateResolveBaseAttrs), this.stateEngine && this.currentStates && !this.sameStateNames(this.stateEngine.activeStates, this.currentStates) && this.stateEngine.applyStates(this.currentStates),
901
+ this.stateEngineStateOrder = stateOrder, this.stateEngineMergeMode = this.stateMergeMode) : (this.stateEngine = void 0,
902
+ this.stateEngineCompiledDefinitions = void 0), this.syncStateResolveContext(stateResolveBaseAttrs),
903
+ this.stateEngine && this.currentStates && !this.sameStateNames(this.stateEngine.activeStates, this.currentStates) && this.stateEngine.applyStates(this.currentStates),
870
904
  this.stateEngine;
871
905
  }
872
906
  toGraphicStateTransition(result) {
@@ -895,7 +929,7 @@ class Graphic extends node_tree_1.Node {
895
929
  };
896
930
  }
897
931
  resolveUseStatesTransition(states, stateResolveBaseAttrs = this.getStateResolveBaseAttrs()) {
898
- const stateEngine = this.ensureStateEngine(stateResolveBaseAttrs);
932
+ const stateEngine = this.ensureStateEngine(stateResolveBaseAttrs, states);
899
933
  return stateEngine ? this.toGraphicStateTransition(stateEngine.applyStates(states)) : this.resolveLocalUseStatesTransition(states);
900
934
  }
901
935
  resolveClearStatesTransition() {
@@ -904,7 +938,7 @@ class Graphic extends node_tree_1.Node {
904
938
  }
905
939
  resolveAddStateTransition(stateName, keepCurrentStates) {
906
940
  var _a;
907
- const stateEngine = this.ensureStateEngine();
941
+ const stateEngine = this.ensureStateEngine(void 0, [ stateName ]);
908
942
  if (stateEngine) return this.toGraphicStateTransition(stateEngine.addState(stateName, keepCurrentStates));
909
943
  if (this.currentStates && this.currentStates.includes(stateName) && (keepCurrentStates || 1 === this.currentStates.length)) return {
910
944
  changed: !1,
@@ -927,7 +961,7 @@ class Graphic extends node_tree_1.Node {
927
961
  } : this.resolveLocalUseStatesTransition(nextStates);
928
962
  }
929
963
  resolveToggleStateTransition(stateName) {
930
- const stateEngine = this.ensureStateEngine();
964
+ const stateEngine = this.ensureStateEngine(void 0, [ stateName ]);
931
965
  if (stateEngine) return this.toGraphicStateTransition(stateEngine.toggleState(stateName));
932
966
  if (this.hasState(stateName)) return this.resolveRemoveStateTransition(stateName);
933
967
  const nextStates = this.currentStates ? this.currentStates.slice() : [];
@@ -935,7 +969,7 @@ class Graphic extends node_tree_1.Node {
935
969
  }
936
970
  resolveGraphicStateTransition(states, forceResolverRefresh = !1) {
937
971
  var _a;
938
- const stateResolveBaseAttrs = this.getStateResolveBaseAttrs(), stateEngine = this.ensureStateEngine(stateResolveBaseAttrs);
972
+ const stateResolveBaseAttrs = this.getStateResolveBaseAttrs(), stateEngine = this.ensureStateEngine(stateResolveBaseAttrs, states);
939
973
  forceResolverRefresh && (null == stateEngine || stateEngine.invalidateResolverCache());
940
974
  const transition = stateEngine ? this.toGraphicStateTransition(stateEngine.applyStates(states)) : this.resolveLocalUseStatesTransition(states), resolvedStateAttrs = this.stateEngine && this.compiledStateDefinitions ? Object.assign({}, this.stateEngine.resolvedPatch) : {};
941
975
  return {
@@ -1013,7 +1047,7 @@ class Graphic extends node_tree_1.Node {
1013
1047
  shouldSkipStateTransitionDefaultAttribute(_key, _targetAttrs) {
1014
1048
  return !1;
1015
1049
  }
1016
- stopStateAnimates(type = "end") {
1050
+ stopStateAnimates(type) {
1017
1051
  const stopAnimationState = this.stopAnimationState;
1018
1052
  if ("function" == typeof stopAnimationState) return void stopAnimationState.call(this, "state", type);
1019
1053
  if (!this.mayHaveTrackedAnimates()) return;