@visactor/vrender-core 1.1.10 → 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.
- package/cjs/graphic/glyph.d.ts +23 -11
- package/cjs/graphic/glyph.js +79 -58
- package/cjs/graphic/glyph.js.map +1 -1
- package/cjs/graphic/graphic.d.ts +7 -2
- package/cjs/graphic/graphic.js +43 -12
- package/cjs/graphic/graphic.js.map +1 -1
- package/cjs/graphic/state/state-definition.d.ts +1 -0
- package/cjs/graphic/state/state-definition.js.map +1 -1
- package/cjs/graphic/state/state-engine.d.ts +1 -0
- package/cjs/graphic/state/state-engine.js +2 -1
- package/cjs/graphic/state/state-engine.js.map +1 -1
- package/cjs/interface/graphic/glyph.d.ts +3 -1
- package/cjs/interface/graphic/glyph.js.map +1 -1
- package/dist/index.es.js +179 -102
- package/es/graphic/glyph.d.ts +23 -11
- package/es/graphic/glyph.js +81 -57
- package/es/graphic/glyph.js.map +1 -1
- package/es/graphic/graphic.d.ts +7 -2
- package/es/graphic/graphic.js +43 -12
- package/es/graphic/graphic.js.map +1 -1
- package/es/graphic/state/state-definition.d.ts +1 -0
- package/es/graphic/state/state-definition.js.map +1 -1
- package/es/graphic/state/state-engine.d.ts +1 -0
- package/es/graphic/state/state-engine.js +2 -1
- package/es/graphic/state/state-engine.js.map +1 -1
- package/es/interface/graphic/glyph.d.ts +3 -1
- package/es/interface/graphic/glyph.js.map +1 -1
- package/package.json +3 -3
package/cjs/graphic/glyph.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import type { AABBBounds, IAABBBounds
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
68
|
-
|
|
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;
|
package/cjs/graphic/glyph.js
CHANGED
|
@@ -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,
|
|
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,
|
|
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
|
-
|
|
37
|
-
|
|
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
|
-
|
|
52
|
-
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
g.addUpdatePositionTag(), g.addUpdateBoundTag();
|
|
69
|
-
})), this;
|
|
58
|
+
commitBaseAttributesByTouchedKeys(params, forceUpdateTag = !1, context) {
|
|
59
|
+
this.commitBaseAttributesByCategory(params, forceUpdateTag, context);
|
|
70
60
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
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;
|
|
@@ -92,31 +82,62 @@ class Glyph extends graphic_1.Graphic {
|
|
|
92
82
|
needUpdateTag(key) {
|
|
93
83
|
return !1;
|
|
94
84
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
this.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
85
|
+
hasLegacyStateDefinitions() {
|
|
86
|
+
if (this.glyphStateProxy) return !0;
|
|
87
|
+
for (const name in this.glyphStates) if (Object.prototype.hasOwnProperty.call(this.glyphStates, name)) return !0;
|
|
88
|
+
return !1;
|
|
89
|
+
}
|
|
90
|
+
syncSharedStateScopeBindingFromTree(markDirty = !0, inheritedSharedStateScope) {
|
|
91
|
+
return this.hasLegacyStateDefinitions() ? this.syncSharedStateScopeBinding(void 0, markDirty) : super.syncSharedStateScopeBindingFromTree(markDirty, inheritedSharedStateScope);
|
|
92
|
+
}
|
|
93
|
+
resolveEffectiveCompiledDefinitions(stateNames = []) {
|
|
94
|
+
var _a, _b;
|
|
95
|
+
if (!this.hasLegacyStateDefinitions()) return this.legacyDefinitions = void 0, this.legacyCompiledDefinitions = void 0,
|
|
96
|
+
super.resolveEffectiveCompiledDefinitions(stateNames);
|
|
97
|
+
this.syncSharedStateScopeBindingFromTree(!1);
|
|
98
|
+
let changed = !1;
|
|
99
|
+
if (!this.legacyDefinitions || this.legacyDefinitionsSource !== this.glyphStates || this.legacyProxySource !== this.glyphStateProxy) {
|
|
100
|
+
this.legacyDefinitionsSource = this.glyphStates, this.legacyProxySource = this.glyphStateProxy,
|
|
101
|
+
this.legacyDefinitions = {};
|
|
102
|
+
for (const name of Object.keys(null !== (_a = this.glyphStates) && void 0 !== _a ? _a : {})) this.legacyDefinitions[name] = this.createLegacyStateDefinition(name);
|
|
103
|
+
changed = !0;
|
|
104
|
+
}
|
|
105
|
+
if (this.glyphStateProxy) {
|
|
106
|
+
const addDefinition = name => {
|
|
107
|
+
Object.prototype.hasOwnProperty.call(this.legacyDefinitions, name) || (this.legacyDefinitions[name] = this.createLegacyStateDefinition(name),
|
|
108
|
+
changed = !0);
|
|
109
|
+
};
|
|
110
|
+
null === (_b = this.currentStates) || void 0 === _b || _b.forEach(addDefinition),
|
|
111
|
+
stateNames.forEach(addDefinition);
|
|
112
|
+
}
|
|
113
|
+
return changed && (this.legacyCompiledDefinitions = (new state_definition_compiler_1.StateDefinitionCompiler).compile(this.legacyDefinitions)),
|
|
114
|
+
{
|
|
115
|
+
compiledDefinitions: this.legacyCompiledDefinitions,
|
|
116
|
+
stateOrder: "input"
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
createLegacyStateDefinition(name) {
|
|
120
|
+
return this.glyphStateProxy ? {
|
|
121
|
+
name: name,
|
|
122
|
+
resolver: ({graphic: graphic, activeStates: activeStates}) => {
|
|
123
|
+
var _a;
|
|
124
|
+
return null === (_a = graphic.glyphStateProxy(name, activeStates)) || void 0 === _a ? void 0 : _a.attributes;
|
|
125
|
+
}
|
|
126
|
+
} : {
|
|
127
|
+
name: name,
|
|
128
|
+
patch: this.glyphStates[name].attributes
|
|
129
|
+
};
|
|
115
130
|
}
|
|
116
131
|
clone() {
|
|
117
132
|
const glyph = new Glyph(Object.assign({}, this.attribute));
|
|
118
133
|
return glyph.setSubGraphic(this.subGraphic.map((g => g.clone()))), glyph;
|
|
119
134
|
}
|
|
135
|
+
release() {
|
|
136
|
+
super.release(), this.subGraphicEncoder = void 0, this._onUpdate = void 0, this.legacyDefinitions = void 0,
|
|
137
|
+
this.legacyCompiledDefinitions = void 0, this.legacyDefinitionsSource = void 0,
|
|
138
|
+
this.legacyProxySource = void 0, this.detachSubGraphic(), this.subGraphic.forEach((child => child.release())),
|
|
139
|
+
this.subGraphic = [];
|
|
140
|
+
}
|
|
120
141
|
getNoWorkAnimateAttr() {
|
|
121
142
|
return Glyph.NOWORK_ANIMATE_ATTR;
|
|
122
143
|
}
|
package/cjs/graphic/glyph.js.map
CHANGED
|
@@ -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,EAAE,CAAC;QACxB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;YACrB,CAAC,CAAC,S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G,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,qFAAqE;AACrE,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,qDAAG,IAAI,CAAC,CAAC;IACjC,CAAC;IAES,gBAAgB;QACxB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;YA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AAS,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;;AAvQH,sBAwQC;AA/OQ,yBAAmB,GAAG,6BAAmB,CAAC;AAiPnD,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 { 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"]}
|
package/cjs/graphic/graphic.d.ts
CHANGED
|
@@ -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
|
|
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;
|
package/cjs/graphic/graphic.js
CHANGED
|
@@ -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,
|
|
@@ -828,8 +843,19 @@ class Graphic extends node_tree_1.Node {
|
|
|
828
843
|
skewTo(b, c) {
|
|
829
844
|
return this;
|
|
830
845
|
}
|
|
846
|
+
static bindGlyphAttributes(graphic, inherited) {
|
|
847
|
+
Object.getPrototypeOf(graphic.attribute) !== inherited && Object.setPrototypeOf(graphic.attribute, inherited),
|
|
848
|
+
graphic._baseAttributes && Object.getPrototypeOf(graphic._baseAttributes) !== inherited && Object.setPrototypeOf(graphic._baseAttributes, inherited);
|
|
849
|
+
}
|
|
850
|
+
static commitDerivedAttributePatch(graphic, patch, removedKeys, context) {
|
|
851
|
+
if (!(null == removedKeys ? void 0 : removedKeys.length)) return void graphic.setAttributes(patch, !1, context);
|
|
852
|
+
graphic.detachAttributeFromBaseAttributes();
|
|
853
|
+
const base = graphic.getBaseAttributesStorage();
|
|
854
|
+
removedKeys.forEach((key => delete base[key])), graphic.applyBaseAttributes(patch),
|
|
855
|
+
graphic.commitBaseAttributeMutation(!1, context);
|
|
856
|
+
}
|
|
831
857
|
onAttributeUpdate(context) {
|
|
832
|
-
context && context.skipUpdateCallback || (this.getGraphicService().onAttributeUpdate(this),
|
|
858
|
+
this.glyphHost && Graphic.bindGlyphAttributes(this, this.glyphHost.attribute), context && context.skipUpdateCallback || (this.getGraphicService().onAttributeUpdate(this),
|
|
833
859
|
this._emitCustomEvent("afterAttributeUpdate", context));
|
|
834
860
|
}
|
|
835
861
|
update(d) {
|
|
@@ -858,15 +884,20 @@ class Graphic extends node_tree_1.Node {
|
|
|
858
884
|
return null === (_a = this.stateEngine) || void 0 === _a || _a.setResolveContext(this, stateResolveBaseAttrs),
|
|
859
885
|
stateResolveBaseAttrs;
|
|
860
886
|
}
|
|
861
|
-
ensureStateEngine(stateResolveBaseAttrs
|
|
862
|
-
|
|
863
|
-
|
|
887
|
+
ensureStateEngine(stateResolveBaseAttrs, stateNames) {
|
|
888
|
+
var _a;
|
|
889
|
+
void 0 === stateResolveBaseAttrs && (stateResolveBaseAttrs = this.getStateResolveBaseAttrs()),
|
|
890
|
+
void 0 === stateNames && (stateNames = null !== (_a = this.currentStates) && void 0 !== _a ? _a : EMPTY_STATE_NAMES);
|
|
891
|
+
const {compiledDefinitions: compiledDefinitions, stateOrder: stateOrder} = this.resolveEffectiveCompiledDefinitions(stateNames);
|
|
892
|
+
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
893
|
compiledDefinitions: compiledDefinitions,
|
|
865
894
|
stateSort: this.stateSort,
|
|
895
|
+
stateOrder: stateOrder,
|
|
866
896
|
mergeMode: this.stateMergeMode
|
|
867
897
|
}), this.stateEngineCompiledDefinitions = compiledDefinitions, this.stateEngineStateSort = this.stateSort,
|
|
868
|
-
this.stateEngineMergeMode = this.stateMergeMode) : (this.stateEngine = void 0,
|
|
869
|
-
this.
|
|
898
|
+
this.stateEngineStateOrder = stateOrder, this.stateEngineMergeMode = this.stateMergeMode) : (this.stateEngine = void 0,
|
|
899
|
+
this.stateEngineCompiledDefinitions = void 0), this.syncStateResolveContext(stateResolveBaseAttrs),
|
|
900
|
+
this.stateEngine && this.currentStates && !this.sameStateNames(this.stateEngine.activeStates, this.currentStates) && this.stateEngine.applyStates(this.currentStates),
|
|
870
901
|
this.stateEngine;
|
|
871
902
|
}
|
|
872
903
|
toGraphicStateTransition(result) {
|
|
@@ -895,7 +926,7 @@ class Graphic extends node_tree_1.Node {
|
|
|
895
926
|
};
|
|
896
927
|
}
|
|
897
928
|
resolveUseStatesTransition(states, stateResolveBaseAttrs = this.getStateResolveBaseAttrs()) {
|
|
898
|
-
const stateEngine = this.ensureStateEngine(stateResolveBaseAttrs);
|
|
929
|
+
const stateEngine = this.ensureStateEngine(stateResolveBaseAttrs, states);
|
|
899
930
|
return stateEngine ? this.toGraphicStateTransition(stateEngine.applyStates(states)) : this.resolveLocalUseStatesTransition(states);
|
|
900
931
|
}
|
|
901
932
|
resolveClearStatesTransition() {
|
|
@@ -904,7 +935,7 @@ class Graphic extends node_tree_1.Node {
|
|
|
904
935
|
}
|
|
905
936
|
resolveAddStateTransition(stateName, keepCurrentStates) {
|
|
906
937
|
var _a;
|
|
907
|
-
const stateEngine = this.ensureStateEngine();
|
|
938
|
+
const stateEngine = this.ensureStateEngine(void 0, [ stateName ]);
|
|
908
939
|
if (stateEngine) return this.toGraphicStateTransition(stateEngine.addState(stateName, keepCurrentStates));
|
|
909
940
|
if (this.currentStates && this.currentStates.includes(stateName) && (keepCurrentStates || 1 === this.currentStates.length)) return {
|
|
910
941
|
changed: !1,
|
|
@@ -927,7 +958,7 @@ class Graphic extends node_tree_1.Node {
|
|
|
927
958
|
} : this.resolveLocalUseStatesTransition(nextStates);
|
|
928
959
|
}
|
|
929
960
|
resolveToggleStateTransition(stateName) {
|
|
930
|
-
const stateEngine = this.ensureStateEngine();
|
|
961
|
+
const stateEngine = this.ensureStateEngine(void 0, [ stateName ]);
|
|
931
962
|
if (stateEngine) return this.toGraphicStateTransition(stateEngine.toggleState(stateName));
|
|
932
963
|
if (this.hasState(stateName)) return this.resolveRemoveStateTransition(stateName);
|
|
933
964
|
const nextStates = this.currentStates ? this.currentStates.slice() : [];
|
|
@@ -935,7 +966,7 @@ class Graphic extends node_tree_1.Node {
|
|
|
935
966
|
}
|
|
936
967
|
resolveGraphicStateTransition(states, forceResolverRefresh = !1) {
|
|
937
968
|
var _a;
|
|
938
|
-
const stateResolveBaseAttrs = this.getStateResolveBaseAttrs(), stateEngine = this.ensureStateEngine(stateResolveBaseAttrs);
|
|
969
|
+
const stateResolveBaseAttrs = this.getStateResolveBaseAttrs(), stateEngine = this.ensureStateEngine(stateResolveBaseAttrs, states);
|
|
939
970
|
forceResolverRefresh && (null == stateEngine || stateEngine.invalidateResolverCache());
|
|
940
971
|
const transition = stateEngine ? this.toGraphicStateTransition(stateEngine.applyStates(states)) : this.resolveLocalUseStatesTransition(states), resolvedStateAttrs = this.stateEngine && this.compiledStateDefinitions ? Object.assign({}, this.stateEngine.resolvedPatch) : {};
|
|
941
972
|
return {
|
|
@@ -1013,7 +1044,7 @@ class Graphic extends node_tree_1.Node {
|
|
|
1013
1044
|
shouldSkipStateTransitionDefaultAttribute(_key, _targetAttrs) {
|
|
1014
1045
|
return !1;
|
|
1015
1046
|
}
|
|
1016
|
-
stopStateAnimates(type
|
|
1047
|
+
stopStateAnimates(type) {
|
|
1017
1048
|
const stopAnimationState = this.stopAnimationState;
|
|
1018
1049
|
if ("function" == typeof stopAnimationState) return void stopAnimationState.call(this, "state", type);
|
|
1019
1050
|
if (!this.mayHaveTrackedAnimates()) return;
|