@visactor/vrender-core 1.1.11-alpha.0 → 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.
- package/cjs/graphic/glyph.js +3 -0
- package/cjs/graphic/glyph.js.map +1 -1
- package/cjs/graphic/graphic.d.ts +1 -0
- package/cjs/graphic/graphic.js +3 -0
- package/cjs/graphic/graphic.js.map +1 -1
- package/cjs/graphic/state/attribute-update-classifier.js +2 -0
- package/cjs/graphic/state/attribute-update-classifier.js.map +1 -1
- package/dist/index.es.js +18 -0
- package/es/graphic/glyph.js +4 -1
- package/es/graphic/glyph.js.map +1 -1
- package/es/graphic/graphic.d.ts +1 -0
- package/es/graphic/graphic.js +3 -0
- package/es/graphic/graphic.js.map +1 -1
- package/es/graphic/state/attribute-update-classifier.js +2 -0
- package/es/graphic/state/attribute-update-classifier.js.map +1 -1
- package/package.json +2 -2
|
@@ -23,6 +23,8 @@ function(UpdateCategory) {
|
|
|
23
23
|
shadowColor: UpdateCategory.PAINT,
|
|
24
24
|
x: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
25
25
|
y: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
26
|
+
dx: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
27
|
+
dy: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
26
28
|
scaleX: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
27
29
|
scaleY: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
28
30
|
angle: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graphic/state/attribute-update-classifier.ts"],"names":[],"mappings":";;;AAAA,IAAY,cAQX;AARD,WAAY,cAAc;IACxB,mDAAQ,CAAA;IACR,qDAAc,CAAA;IACd,qDAAc,CAAA;IACd,uDAAe,CAAA;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,CAAC,mCAAI,cAAc,CAAC,KAAK,CAAC;AACzD,CAAC;AAPD,wDAOC;AAED,SAAgB,iCAAiC,CAAC,GAAW;;IAC3D,IAAI,GAAG,KAAK,QAAQ,EAAE;QACpB,OAAO,cAAc,CAAC,KAAK,GAAG,cAAc,CAAC,MAAM,GAAG,cAAc,CAAC,IAAI,CAAC;KAC3E;IAED,IAAI,GAAG,KAAK,YAAY,EAAE;QACxB,OAAO,cAAc,CAAC,KAAK,GAAG,cAAc,CAAC,MAAM,CAAC;KACrD;IAED,OAAO,MAAA,0BAAkB,CAAC,GAAG,CAAC,mCAAI,cAAc,CAAC,KAAK,CAAC;AACzD,CAAC;AAVD,8EAUC;AAED,SAAgB,oBAAoB,CAAC,IAAsB;IACzD,IAAI,QAAQ,GAAG,cAAc,CAAC,IAAI,CAAC;IACnC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;QACtB,QAAQ,IAAI,iCAAiC,CAAC,GAAG,CAAC,CAAC;KACpD;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAND,oDAMC","file":"attribute-update-classifier.js","sourcesContent":["export enum UpdateCategory {\n NONE = 0,\n PAINT = 1 << 0,\n SHAPE = 1 << 1,\n BOUNDS = 1 << 2,\n TRANSFORM = 1 << 3,\n LAYOUT = 1 << 4,\n PICK = 1 << 5\n}\n\ntype AttributeDeltaClassifier = (prev: unknown, next: unknown) => UpdateCategory;\n\nexport const ATTRIBUTE_CATEGORY: Record<string, UpdateCategory> = {\n fill: UpdateCategory.PAINT,\n opacity: UpdateCategory.PAINT,\n fillOpacity: UpdateCategory.PAINT,\n strokeOpacity: UpdateCategory.PAINT,\n lineDash: UpdateCategory.PAINT,\n lineDashOffset: UpdateCategory.PAINT,\n lineCap: UpdateCategory.PAINT,\n lineJoin: UpdateCategory.PAINT,\n miterLimit: UpdateCategory.PAINT,\n shadowColor: UpdateCategory.PAINT,\n x: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,\n y: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,\n scaleX: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,\n scaleY: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,\n angle: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,\n anchor: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,\n anchor3d: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,\n postMatrix: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,\n layout: UpdateCategory.LAYOUT,\n zIndex: UpdateCategory.PAINT,\n visible: UpdateCategory.PAINT | UpdateCategory.PICK,\n lineWidth: UpdateCategory.SHAPE | UpdateCategory.BOUNDS | UpdateCategory.PICK,\n width: UpdateCategory.SHAPE | UpdateCategory.BOUNDS,\n height: UpdateCategory.SHAPE | UpdateCategory.BOUNDS\n};\n\nconst ATTRIBUTE_DELTA_CLASSIFIER: Record<string, AttributeDeltaClassifier> = {\n stroke: (prev, next) => {\n const prevEnabled = prev != null && prev !== false;\n const nextEnabled = next != null && next !== false;\n if (prevEnabled !== nextEnabled) {\n return UpdateCategory.PAINT | UpdateCategory.BOUNDS | UpdateCategory.PICK;\n }\n return UpdateCategory.PAINT;\n },\n shadowBlur: (prev, next) => {\n const prevBlur = Number(prev ?? 0);\n const nextBlur = Number(next ?? 0);\n if (prevBlur !== nextBlur && (prevBlur > 0 || nextBlur > 0)) {\n return UpdateCategory.PAINT | UpdateCategory.BOUNDS;\n }\n return UpdateCategory.PAINT;\n }\n};\n\nexport function classifyAttributeDelta(key: string, prev: unknown, next: unknown): UpdateCategory {\n const dynamicClassifier = ATTRIBUTE_DELTA_CLASSIFIER[key];\n if (dynamicClassifier) {\n return dynamicClassifier(prev, next);\n }\n\n return ATTRIBUTE_CATEGORY[key] ?? UpdateCategory.PAINT;\n}\n\nexport function classifyAffectedKeyConservatively(key: string): UpdateCategory {\n if (key === 'stroke') {\n return UpdateCategory.PAINT | UpdateCategory.BOUNDS | UpdateCategory.PICK;\n }\n\n if (key === 'shadowBlur') {\n return UpdateCategory.PAINT | UpdateCategory.BOUNDS;\n }\n\n return ATTRIBUTE_CATEGORY[key] ?? UpdateCategory.PAINT;\n}\n\nexport function classifyAffectedKeys(keys: Iterable<string>): UpdateCategory {\n let category = UpdateCategory.NONE;\n for (const key of keys) {\n category |= classifyAffectedKeyConservatively(key);\n }\n return category;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/graphic/state/attribute-update-classifier.ts"],"names":[],"mappings":";;;AAAA,IAAY,cAQX;AARD,WAAY,cAAc;IACxB,mDAAQ,CAAA;IACR,qDAAc,CAAA;IACd,qDAAc,CAAA;IACd,uDAAe,CAAA;IACf,6DAAkB,CAAA;IAClB,wDAAe,CAAA;IACf,oDAAa,CAAA;AACf,CAAC,EARW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAQzB;AAIY,QAAA,kBAAkB,GAAmC;IAChE,IAAI,EAAE,cAAc,CAAC,KAAK;IAC1B,OAAO,EAAE,cAAc,CAAC,KAAK;IAC7B,WAAW,EAAE,cAAc,CAAC,KAAK;IACjC,aAAa,EAAE,cAAc,CAAC,KAAK;IACnC,QAAQ,EAAE,cAAc,CAAC,KAAK;IAC9B,cAAc,EAAE,cAAc,CAAC,KAAK;IACpC,OAAO,EAAE,cAAc,CAAC,KAAK;IAC7B,QAAQ,EAAE,cAAc,CAAC,KAAK;IAC9B,UAAU,EAAE,cAAc,CAAC,KAAK;IAChC,WAAW,EAAE,cAAc,CAAC,KAAK;IACjC,CAAC,EAAE,cAAc,CAAC,SAAS,GAAG,cAAc,CAAC,MAAM;IACnD,CAAC,EAAE,cAAc,CAAC,SAAS,GAAG,cAAc,CAAC,MAAM;IACnD,EAAE,EAAE,cAAc,CAAC,SAAS,GAAG,cAAc,CAAC,MAAM;IACpD,EAAE,EAAE,cAAc,CAAC,SAAS,GAAG,cAAc,CAAC,MAAM;IACpD,MAAM,EAAE,cAAc,CAAC,SAAS,GAAG,cAAc,CAAC,MAAM;IACxD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ateCategory {\n NONE = 0,\n PAINT = 1 << 0,\n SHAPE = 1 << 1,\n BOUNDS = 1 << 2,\n TRANSFORM = 1 << 3,\n LAYOUT = 1 << 4,\n PICK = 1 << 5\n}\n\ntype AttributeDeltaClassifier = (prev: unknown, next: unknown) => UpdateCategory;\n\nexport const ATTRIBUTE_CATEGORY: Record<string, UpdateCategory> = {\n fill: UpdateCategory.PAINT,\n opacity: UpdateCategory.PAINT,\n fillOpacity: UpdateCategory.PAINT,\n strokeOpacity: UpdateCategory.PAINT,\n lineDash: UpdateCategory.PAINT,\n lineDashOffset: UpdateCategory.PAINT,\n lineCap: UpdateCategory.PAINT,\n lineJoin: UpdateCategory.PAINT,\n miterLimit: UpdateCategory.PAINT,\n shadowColor: UpdateCategory.PAINT,\n x: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,\n y: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,\n dx: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,\n dy: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,\n scaleX: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,\n scaleY: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,\n angle: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,\n anchor: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,\n anchor3d: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,\n postMatrix: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,\n layout: UpdateCategory.LAYOUT,\n zIndex: UpdateCategory.PAINT,\n visible: UpdateCategory.PAINT | UpdateCategory.PICK,\n lineWidth: UpdateCategory.SHAPE | UpdateCategory.BOUNDS | UpdateCategory.PICK,\n width: UpdateCategory.SHAPE | UpdateCategory.BOUNDS,\n height: UpdateCategory.SHAPE | UpdateCategory.BOUNDS\n};\n\nconst ATTRIBUTE_DELTA_CLASSIFIER: Record<string, AttributeDeltaClassifier> = {\n stroke: (prev, next) => {\n const prevEnabled = prev != null && prev !== false;\n const nextEnabled = next != null && next !== false;\n if (prevEnabled !== nextEnabled) {\n return UpdateCategory.PAINT | UpdateCategory.BOUNDS | UpdateCategory.PICK;\n }\n return UpdateCategory.PAINT;\n },\n shadowBlur: (prev, next) => {\n const prevBlur = Number(prev ?? 0);\n const nextBlur = Number(next ?? 0);\n if (prevBlur !== nextBlur && (prevBlur > 0 || nextBlur > 0)) {\n return UpdateCategory.PAINT | UpdateCategory.BOUNDS;\n }\n return UpdateCategory.PAINT;\n }\n};\n\nexport function classifyAttributeDelta(key: string, prev: unknown, next: unknown): UpdateCategory {\n const dynamicClassifier = ATTRIBUTE_DELTA_CLASSIFIER[key];\n if (dynamicClassifier) {\n return dynamicClassifier(prev, next);\n }\n\n return ATTRIBUTE_CATEGORY[key] ?? UpdateCategory.PAINT;\n}\n\nexport function classifyAffectedKeyConservatively(key: string): UpdateCategory {\n if (key === 'stroke') {\n return UpdateCategory.PAINT | UpdateCategory.BOUNDS | UpdateCategory.PICK;\n }\n\n if (key === 'shadowBlur') {\n return UpdateCategory.PAINT | UpdateCategory.BOUNDS;\n }\n\n return ATTRIBUTE_CATEGORY[key] ?? UpdateCategory.PAINT;\n}\n\nexport function classifyAffectedKeys(keys: Iterable<string>): UpdateCategory {\n let category = UpdateCategory.NONE;\n for (const key of keys) {\n category |= classifyAffectedKeyConservatively(key);\n }\n return category;\n}\n"]}
|
package/dist/index.es.js
CHANGED
|
@@ -9475,6 +9475,8 @@ const ATTRIBUTE_CATEGORY = {
|
|
|
9475
9475
|
shadowColor: UpdateCategory.PAINT,
|
|
9476
9476
|
x: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
9477
9477
|
y: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
9478
|
+
dx: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
9479
|
+
dy: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
9478
9480
|
scaleX: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
9479
9481
|
scaleY: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
9480
9482
|
angle: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
|
|
@@ -11036,6 +11038,9 @@ class Graphic extends Node {
|
|
|
11036
11038
|
this.setShadowGraphic(value);
|
|
11037
11039
|
}
|
|
11038
11040
|
}
|
|
11041
|
+
static needsShapeUpdate(graphic, key) {
|
|
11042
|
+
return graphic.needUpdateTag(key);
|
|
11043
|
+
}
|
|
11039
11044
|
needUpdateTags(keys, k = GRAPHIC_UPDATE_TAG_KEY) {
|
|
11040
11045
|
for (let i = 0; i < k.length; i++) {
|
|
11041
11046
|
const attrKey = k[i];
|
|
@@ -13913,9 +13918,22 @@ class Glyph extends Graphic {
|
|
|
13913
13918
|
return bounds;
|
|
13914
13919
|
}
|
|
13915
13920
|
needUpdateTags(keys) {
|
|
13921
|
+
for (const key of keys) {
|
|
13922
|
+
if (this.needUpdateTag(key)) {
|
|
13923
|
+
return true;
|
|
13924
|
+
}
|
|
13925
|
+
}
|
|
13916
13926
|
return false;
|
|
13917
13927
|
}
|
|
13918
13928
|
needUpdateTag(key) {
|
|
13929
|
+
if (ATTRIBUTE_CATEGORY[key] === UpdateCategory.PAINT) {
|
|
13930
|
+
return false;
|
|
13931
|
+
}
|
|
13932
|
+
for (const child of this.subGraphic) {
|
|
13933
|
+
if (Graphic.needsShapeUpdate(child, key)) {
|
|
13934
|
+
return true;
|
|
13935
|
+
}
|
|
13936
|
+
}
|
|
13919
13937
|
return false;
|
|
13920
13938
|
}
|
|
13921
13939
|
hasLegacyStateDefinitions() {
|
package/es/graphic/glyph.js
CHANGED
|
@@ -4,7 +4,7 @@ import { StateDefinitionCompiler } from "./state/state-definition-compiler";
|
|
|
4
4
|
|
|
5
5
|
import { getTheme } from "./theme";
|
|
6
6
|
|
|
7
|
-
import { UpdateCategory } from "./state/attribute-update-classifier";
|
|
7
|
+
import { ATTRIBUTE_CATEGORY, UpdateCategory } from "./state/attribute-update-classifier";
|
|
8
8
|
|
|
9
9
|
import { GLYPH_NUMBER_TYPE } from "./constants";
|
|
10
10
|
|
|
@@ -78,9 +78,12 @@ export class Glyph extends Graphic {
|
|
|
78
78
|
return this.clearUpdateBoundTag(), bounds;
|
|
79
79
|
}
|
|
80
80
|
needUpdateTags(keys) {
|
|
81
|
+
for (const key of keys) if (this.needUpdateTag(key)) return !0;
|
|
81
82
|
return !1;
|
|
82
83
|
}
|
|
83
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;
|
|
84
87
|
return !1;
|
|
85
88
|
}
|
|
86
89
|
hasLegacyStateDefinitions() {
|
package/es/graphic/glyph.js.map
CHANGED
|
@@ -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,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAG5E,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,OAAO,KAAM,SAAQ,OAA+B;IA2BxD,YAAY,MAAuC;QACjD,KAAK,CAAC,MAAM,CAAC,CAAC;QA3BhB,SAAI,GAAgB,OAAO,CAAC;QA4B1B,IAAI,CAAC,UAAU,GAAG,iBAAiB,CAAC;QACpC,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,EAA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K;QACH,MAAM,KAAK,GAAG,IAAI,KAAK,mBAAM,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;;AA9OM,yBAAmB,GAAG,mBAAmB,CAAC;AAiPnD,MAAM,UAAU,WAAW,CAAC,UAAkC;IAC5D,OAAO,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC;AAC/B,CAAC","file":"glyph.js","sourcesContent":["import type { AABBBounds, IAABBBounds } from '@visactor/vutils';\nimport { Graphic, NOWORK_ANIMATE_ATTR } from './graphic';\nimport type {\n GraphicType,\n IGraphic,\n IGlyph,\n IGlyphGraphicAttribute,\n IGraphicAttribute,\n ISetAttributeContext\n} from '../interface';\nimport { StateDefinitionCompiler } from './state/state-definition-compiler';\nimport type { CompiledStateDefinition, StateDefinition, StateDefinitionsInput } from './state/state-definition';\nimport type { SharedStateScope } from './state/shared-state-scope';\nimport { getTheme } from './theme';\nimport { UpdateCategory } from './state/attribute-update-classifier';\nimport { GLYPH_NUMBER_TYPE } from './constants';\n\nexport class Glyph extends Graphic<IGlyphGraphicAttribute> implements IGlyph {\n type: GraphicType = 'glyph';\n declare _onInit: (g: IGlyph) => void;\n declare _onUpdate: (g: IGlyph) => void;\n declare glyphStates?: Record<\n string,\n {\n attributes: Partial<IGlyphGraphicAttribute>;\n subAttributes: Partial<IGraphicAttribute>[];\n }\n >;\n declare glyphStateProxy?: (\n stateName: string,\n targetStates?: string[]\n ) => {\n attributes: Partial<IGlyphGraphicAttribute>;\n subAttributes: Partial<IGraphicAttribute>[];\n };\n protected declare subGraphic: IGraphic[];\n private subGraphicEncoder?: (g: IGlyph, context?: ISetAttributeContext) => void;\n private legacyDefinitionsSource?: Glyph['glyphStates'];\n private legacyProxySource?: Glyph['glyphStateProxy'];\n private legacyDefinitions?: StateDefinitionsInput<IGlyphGraphicAttribute>;\n private legacyCompiledDefinitions?: Map<string, CompiledStateDefinition<IGlyphGraphicAttribute>>;\n\n static NOWORK_ANIMATE_ATTR = NOWORK_ANIMATE_ATTR;\n\n constructor(params: Partial<IGlyphGraphicAttribute>) {\n super(params);\n this.numberType = GLYPH_NUMBER_TYPE;\n this.subGraphic = [];\n this._onInit && this._onInit(this);\n this.valid = this.isValid();\n }\n\n setSubGraphic(subGraphic: IGraphic[]) {\n this.detachSubGraphic();\n this.subGraphic = subGraphic;\n subGraphic.forEach(g => {\n g.glyphHost = this;\n Graphic.bindGlyphAttributes(g as Graphic, this.attribute);\n });\n this.valid = this.isValid();\n this.addUpdateBoundTag();\n this.subGraphicEncoder?.(this);\n }\n\n protected detachSubGraphic() {\n this.subGraphic.forEach(g => {\n g.glyphHost = null;\n Graphic.bindGlyphAttributes(g as Graphic, Object.prototype);\n });\n }\n\n getSubGraphic() {\n return this.subGraphic;\n }\n\n onInit(cb: (g: this) => void): void {\n this._onInit = cb;\n }\n\n onUpdate(cb: (g: this) => void): void {\n this._onUpdate = cb;\n }\n\n isValid(): boolean {\n return true;\n }\n\n setSubGraphicEncoder(encoder?: (g: IGlyph, context?: ISetAttributeContext) => void): void {\n this.subGraphicEncoder = encoder;\n encoder?.(this);\n }\n\n commitSubGraphicAttributes(\n subGraphic: IGraphic,\n patch: Record<string, any>,\n removedKeys?: readonly string[],\n context?: ISetAttributeContext\n ): void {\n Graphic.commitDerivedAttributePatch(subGraphic as Graphic, patch, removedKeys, context);\n }\n\n onAttributeUpdate(context?: ISetAttributeContext): void {\n if (this.glyphHost) {\n Graphic.bindGlyphAttributes(this, this.glyphHost.attribute);\n }\n for (const child of this.subGraphic) {\n Graphic.bindGlyphAttributes(child as Graphic, this.attribute);\n }\n this.subGraphicEncoder?.(this, context);\n if (!context?.skipUpdateCallback) {\n this._onUpdate?.(this);\n }\n super.onAttributeUpdate(context);\n }\n\n protected submitUpdateByCategory(category: UpdateCategory, forceUpdateTag: boolean = false): void {\n super.submitUpdateByCategory(category, forceUpdateTag);\n for (const child of this.subGraphic) {\n if (forceUpdateTag || category & UpdateCategory.SHAPE) {\n child.addUpdateShapeAndBoundsTag();\n } else if (category & UpdateCategory.BOUNDS) {\n child.addUpdateBoundTag();\n }\n if (category & UpdateCategory.PAINT) {\n child.addUpdatePaintTag();\n }\n if (forceUpdateTag || category & UpdateCategory.TRANSFORM) {\n child.addUpdatePositionTag();\n }\n if (forceUpdateTag || category & UpdateCategory.LAYOUT) {\n child.addUpdateLayoutTag();\n }\n }\n }\n\n // Glyph forwards inherited invalidation to children, so its base fast path must\n // classify changed keys too. Ordinary Graphic setters keep their existing path.\n protected commitBaseAttributesByTouchedKeys(\n params: Partial<IGlyphGraphicAttribute>,\n forceUpdateTag: boolean = false,\n context?: ISetAttributeContext\n ): void {\n this.commitBaseAttributesByCategory(params, forceUpdateTag, context);\n }\n\n protected commitBaseAttributeBySingleKey(\n key: string,\n value: any,\n forceUpdateTag: boolean = false,\n context?: ISetAttributeContext\n ): void {\n this.commitBaseAttributesByTouchedKeys({ [key]: value }, forceUpdateTag, context);\n }\n\n getGraphicTheme(): Required<IGlyphGraphicAttribute> {\n return getTheme(this as IGraphic).glyph;\n }\n\n protected updateAABBBounds(\n attribute: IGlyphGraphicAttribute,\n theme: Required<IGlyphGraphicAttribute>,\n aabbBounds: IAABBBounds\n ) {\n // 添加子节点\n this.getSubGraphic().forEach((node: IGraphic) => {\n aabbBounds.union(node.AABBBounds);\n });\n\n // glyph不需要计算AABBBounds\n // this.transformAABBBounds(attribute, aabbBounds, theme, graphic);\n return aabbBounds;\n }\n\n protected doUpdateAABBBounds(): AABBBounds {\n this.updateAABBBoundsStamp++;\n this._AABBBounds.clear();\n const bounds = this.updateAABBBounds(this.attribute, this.getGraphicTheme(), this._AABBBounds) as AABBBounds;\n this.clearUpdateBoundTag();\n return bounds;\n }\n\n protected needUpdateTags(keys: string[]): boolean {\n return false;\n }\n protected needUpdateTag(key: string): boolean {\n return false;\n }\n\n protected hasLegacyStateDefinitions(): boolean {\n if (this.glyphStateProxy) {\n return true;\n }\n for (const name in this.glyphStates) {\n if (Object.prototype.hasOwnProperty.call(this.glyphStates, name)) {\n return true;\n }\n }\n return false;\n }\n\n protected syncSharedStateScopeBindingFromTree(\n markDirty: boolean = true,\n inheritedSharedStateScope?: SharedStateScope<Record<string, any>> | null\n ): boolean {\n // Legacy Glyph definitions historically own the whole state surface.\n return this.hasLegacyStateDefinitions()\n ? this.syncSharedStateScopeBinding(undefined, markDirty)\n : super.syncSharedStateScopeBindingFromTree(markDirty, inheritedSharedStateScope);\n }\n\n protected resolveEffectiveCompiledDefinitions(stateNames: readonly string[] = []) {\n if (!this.hasLegacyStateDefinitions()) {\n this.legacyDefinitions = undefined;\n this.legacyCompiledDefinitions = undefined;\n return super.resolveEffectiveCompiledDefinitions(stateNames);\n }\n this.syncSharedStateScopeBindingFromTree(false);\n let changed = false;\n if (\n !this.legacyDefinitions ||\n this.legacyDefinitionsSource !== this.glyphStates ||\n this.legacyProxySource !== this.glyphStateProxy\n ) {\n this.legacyDefinitionsSource = this.glyphStates;\n this.legacyProxySource = this.glyphStateProxy;\n this.legacyDefinitions = {};\n for (const name of Object.keys(this.glyphStates ?? {})) {\n this.legacyDefinitions[name] = this.createLegacyStateDefinition(name);\n }\n changed = true;\n }\n if (this.glyphStateProxy) {\n const addDefinition = (name: string) => {\n if (!Object.prototype.hasOwnProperty.call(this.legacyDefinitions, name)) {\n this.legacyDefinitions[name] = this.createLegacyStateDefinition(name);\n changed = true;\n }\n };\n this.currentStates?.forEach(addDefinition);\n stateNames.forEach(addDefinition);\n }\n if (changed) {\n this.legacyCompiledDefinitions = new StateDefinitionCompiler<IGlyphGraphicAttribute>().compile(\n this.legacyDefinitions\n );\n }\n return { compiledDefinitions: this.legacyCompiledDefinitions, stateOrder: 'input' as const };\n }\n\n private createLegacyStateDefinition(name: string): StateDefinition<IGlyphGraphicAttribute> {\n return this.glyphStateProxy\n ? {\n name,\n resolver: ({ graphic, activeStates }) =>\n (graphic as Glyph).glyphStateProxy(name, activeStates as string[])?.attributes\n }\n : { name, patch: this.glyphStates[name].attributes };\n }\n\n clone(): IGraphic<Partial<IGlyphGraphicAttribute>> {\n const glyph = new Glyph({ ...this.attribute });\n glyph.setSubGraphic(this.subGraphic.map(g => g.clone()));\n return glyph;\n }\n\n release(): void {\n super.release();\n this.subGraphicEncoder = undefined;\n this._onUpdate = undefined;\n this.legacyDefinitions = undefined;\n this.legacyCompiledDefinitions = undefined;\n this.legacyDefinitionsSource = undefined;\n this.legacyProxySource = undefined;\n this.detachSubGraphic();\n this.subGraphic.forEach(child => child.release());\n this.subGraphic = [];\n }\n\n getNoWorkAnimateAttr(): Record<string, number> {\n return Glyph.NOWORK_ANIMATE_ATTR;\n }\n}\n\nexport function createGlyph(attributes: IGlyphGraphicAttribute): IGlyph {\n return new Glyph(attributes);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/graphic/glyph.ts"],"names":[],"mappings":"AACA,O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AC;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;;AA3PM,yBAAmB,GAAG,mBAAmB,CAAC;AA8PnD,MAAM,UAAU,WAAW,CAAC,UAAkC;IAC5D,OAAO,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC;AAC/B,CAAC","file":"glyph.js","sourcesContent":["import type { AABBBounds, IAABBBounds } from '@visactor/vutils';\nimport { Graphic, NOWORK_ANIMATE_ATTR } from './graphic';\nimport type {\n GraphicType,\n IGraphic,\n IGlyph,\n IGlyphGraphicAttribute,\n IGraphicAttribute,\n ISetAttributeContext\n} from '../interface';\nimport { StateDefinitionCompiler } from './state/state-definition-compiler';\nimport type { CompiledStateDefinition, StateDefinition, StateDefinitionsInput } from './state/state-definition';\nimport type { SharedStateScope } from './state/shared-state-scope';\nimport { getTheme } from './theme';\nimport { 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"]}
|
package/es/graphic/graphic.d.ts
CHANGED
|
@@ -228,6 +228,7 @@ export declare abstract class Graphic<T extends Partial<IGraphicAttribute> = Par
|
|
|
228
228
|
setAttributes(params: Partial<T>, forceUpdateTag?: boolean, context?: ISetAttributeContext): void;
|
|
229
229
|
_setAttributes(params: Partial<T>, forceUpdateTag?: boolean, context?: ISetAttributeContext): void;
|
|
230
230
|
setAttribute(key: string, value: any, forceUpdateTag?: boolean, context?: ISetAttributeContext): void;
|
|
231
|
+
protected static needsShapeUpdate(graphic: Graphic, key: string): boolean;
|
|
231
232
|
protected needUpdateTags(keys: string[], k?: string[]): boolean;
|
|
232
233
|
protected needUpdateTag(key: string, k?: string[]): boolean;
|
|
233
234
|
initAttributes(params: T): void;
|
package/es/graphic/graphic.js
CHANGED
|
@@ -751,6 +751,9 @@ export class Graphic extends Node {
|
|
|
751
751
|
}
|
|
752
752
|
"background" === key ? this.loadImage(value, !0) : "texture" === key && isExternalTexture(value) ? this.loadImage(value, !1) : "shadowGraphic" === key && this.setShadowGraphic(value);
|
|
753
753
|
}
|
|
754
|
+
static needsShapeUpdate(graphic, key) {
|
|
755
|
+
return graphic.needUpdateTag(key);
|
|
756
|
+
}
|
|
754
757
|
needUpdateTags(keys, k = GRAPHIC_UPDATE_TAG_KEY) {
|
|
755
758
|
for (let i = 0; i < k.length; i++) {
|
|
756
759
|
const attrKey = k[i];
|