@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
package/dist/index.es.js CHANGED
@@ -9203,6 +9203,7 @@ class StateEngine {
9203
9203
  this.baseAttributes = {};
9204
9204
  this.compiledDefinitions = options.compiledDefinitions;
9205
9205
  this.stateSort = options.stateSort;
9206
+ this.stateOrder = options.stateOrder;
9206
9207
  this.mergeMode = (_a = options.mergeMode) !== null && _a !== void 0 ? _a : 'shallow';
9207
9208
  }
9208
9209
  get activeStates() {
@@ -9318,6 +9319,9 @@ class StateEngine {
9318
9319
  return this._activeStates.includes(stateName);
9319
9320
  }
9320
9321
  sortStates(states) {
9322
+ if (this.stateOrder === 'input') {
9323
+ return this.stateSort ? states.sort(this.stateSort) : states;
9324
+ }
9321
9325
  const withDefinition = [];
9322
9326
  const withoutDefinition = [];
9323
9327
  states.forEach(stateName => {
@@ -9471,6 +9475,8 @@ const ATTRIBUTE_CATEGORY = {
9471
9475
  shadowColor: UpdateCategory.PAINT,
9472
9476
  x: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
9473
9477
  y: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
9478
+ dx: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
9479
+ dy: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
9474
9480
  scaleX: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
9475
9481
  scaleY: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
9476
9482
  angle: UpdateCategory.TRANSFORM | UpdateCategory.BOUNDS,
@@ -10094,7 +10100,7 @@ class Graphic extends Node {
10094
10100
  }
10095
10101
  return (_b = this.localStateDefinitionsVersion) !== null && _b !== void 0 ? _b : 0;
10096
10102
  }
10097
- resolveEffectiveCompiledDefinitions() {
10103
+ resolveEffectiveCompiledDefinitions(_stateNames) {
10098
10104
  this.syncSharedStateScopeBindingFromTree(false);
10099
10105
  const boundScope = this.boundSharedStateScope;
10100
10106
  if (boundScope) {
@@ -10329,7 +10335,37 @@ class Graphic extends Node {
10329
10335
  this.applyBaseAttributes(params);
10330
10336
  this.commitBaseAttributeMutation(false, context);
10331
10337
  }
10338
+ commitBaseAttributesByCategory(params, forceUpdateTag = false, context) {
10339
+ const base = this.getBaseAttributesStorage();
10340
+ let category = UpdateCategory.NONE;
10341
+ let hasKeys = false;
10342
+ for (const key in params) {
10343
+ if (!Object.prototype.hasOwnProperty.call(params, key)) {
10344
+ continue;
10345
+ }
10346
+ hasKeys = true;
10347
+ const prev = base[key];
10348
+ const next = params[key];
10349
+ if (prev !== next) {
10350
+ category = this.mergeAttributeDeltaCategory(category, key, prev, next);
10351
+ }
10352
+ base[key] = next;
10353
+ }
10354
+ if (!hasKeys) {
10355
+ return;
10356
+ }
10357
+ this.attribute = base;
10358
+ this._baseAttributes = undefined;
10359
+ this.attributeMayContainTransientAttrs = false;
10360
+ this.valid = this.isValid();
10361
+ this.submitUpdateByCategory(category, forceUpdateTag);
10362
+ this.onAttributeUpdate(context);
10363
+ }
10332
10364
  commitBaseAttributesByTouchedKeys(params, forceUpdateTag = false, context) {
10365
+ if (this.glyphHost) {
10366
+ this.commitBaseAttributesByCategory(params, forceUpdateTag, context);
10367
+ return;
10368
+ }
10333
10369
  const source = params;
10334
10370
  const baseAttributes = this.getBaseAttributesStorage();
10335
10371
  let hasKeys = false;
@@ -11002,6 +11038,9 @@ class Graphic extends Node {
11002
11038
  this.setShadowGraphic(value);
11003
11039
  }
11004
11040
  }
11041
+ static needsShapeUpdate(graphic, key) {
11042
+ return graphic.needUpdateTag(key);
11043
+ }
11005
11044
  needUpdateTags(keys, k = GRAPHIC_UPDATE_TAG_KEY) {
11006
11045
  for (let i = 0; i < k.length; i++) {
11007
11046
  const attrKey = k[i];
@@ -11193,7 +11232,29 @@ class Graphic extends Node {
11193
11232
  skewTo(b, c) {
11194
11233
  return this;
11195
11234
  }
11235
+ static bindGlyphAttributes(graphic, inherited) {
11236
+ if (Object.getPrototypeOf(graphic.attribute) !== inherited) {
11237
+ Object.setPrototypeOf(graphic.attribute, inherited);
11238
+ }
11239
+ if (graphic._baseAttributes && Object.getPrototypeOf(graphic._baseAttributes) !== inherited) {
11240
+ Object.setPrototypeOf(graphic._baseAttributes, inherited);
11241
+ }
11242
+ }
11243
+ static commitDerivedAttributePatch(graphic, patch, removedKeys, context) {
11244
+ if (!(removedKeys === null || removedKeys === void 0 ? void 0 : removedKeys.length)) {
11245
+ graphic.setAttributes(patch, false, context);
11246
+ return;
11247
+ }
11248
+ graphic.detachAttributeFromBaseAttributes();
11249
+ const base = graphic.getBaseAttributesStorage();
11250
+ removedKeys.forEach(key => delete base[key]);
11251
+ graphic.applyBaseAttributes(patch);
11252
+ graphic.commitBaseAttributeMutation(false, context);
11253
+ }
11196
11254
  onAttributeUpdate(context) {
11255
+ if (this.glyphHost) {
11256
+ Graphic.bindGlyphAttributes(this, this.glyphHost.attribute);
11257
+ }
11197
11258
  if (context && context.skipUpdateCallback) {
11198
11259
  return;
11199
11260
  }
@@ -11242,8 +11303,11 @@ class Graphic extends Node {
11242
11303
  (_a = this.stateEngine) === null || _a === void 0 ? void 0 : _a.setResolveContext(this, stateResolveBaseAttrs);
11243
11304
  return stateResolveBaseAttrs;
11244
11305
  }
11245
- ensureStateEngine(stateResolveBaseAttrs = this.getStateResolveBaseAttrs()) {
11246
- const { compiledDefinitions } = this.resolveEffectiveCompiledDefinitions();
11306
+ ensureStateEngine(stateResolveBaseAttrs, stateNames) {
11307
+ var _a;
11308
+ if (stateResolveBaseAttrs === void 0) { stateResolveBaseAttrs = this.getStateResolveBaseAttrs(); }
11309
+ if (stateNames === void 0) { stateNames = (_a = this.currentStates) !== null && _a !== void 0 ? _a : EMPTY_STATE_NAMES; }
11310
+ const { compiledDefinitions, stateOrder } = this.resolveEffectiveCompiledDefinitions(stateNames);
11247
11311
  this.compiledStateDefinitions = compiledDefinitions;
11248
11312
  if (!compiledDefinitions) {
11249
11313
  this.stateEngine = undefined;
@@ -11252,14 +11316,17 @@ class Graphic extends Node {
11252
11316
  else if (!this.stateEngine ||
11253
11317
  this.stateEngineCompiledDefinitions !== compiledDefinitions ||
11254
11318
  this.stateEngineStateSort !== this.stateSort ||
11319
+ this.stateEngineStateOrder !== stateOrder ||
11255
11320
  this.stateEngineMergeMode !== this.stateMergeMode) {
11256
11321
  this.stateEngine = new StateEngine({
11257
11322
  compiledDefinitions,
11258
11323
  stateSort: this.stateSort,
11324
+ stateOrder,
11259
11325
  mergeMode: this.stateMergeMode
11260
11326
  });
11261
11327
  this.stateEngineCompiledDefinitions = compiledDefinitions;
11262
11328
  this.stateEngineStateSort = this.stateSort;
11329
+ this.stateEngineStateOrder = stateOrder;
11263
11330
  this.stateEngineMergeMode = this.stateMergeMode;
11264
11331
  }
11265
11332
  this.syncStateResolveContext(stateResolveBaseAttrs);
@@ -11300,7 +11367,7 @@ class Graphic extends Node {
11300
11367
  };
11301
11368
  }
11302
11369
  resolveUseStatesTransition(states, stateResolveBaseAttrs = this.getStateResolveBaseAttrs()) {
11303
- const stateEngine = this.ensureStateEngine(stateResolveBaseAttrs);
11370
+ const stateEngine = this.ensureStateEngine(stateResolveBaseAttrs, states);
11304
11371
  return stateEngine
11305
11372
  ? this.toGraphicStateTransition(stateEngine.applyStates(states))
11306
11373
  : this.resolveLocalUseStatesTransition(states);
@@ -11313,7 +11380,7 @@ class Graphic extends Node {
11313
11380
  }
11314
11381
  resolveAddStateTransition(stateName, keepCurrentStates) {
11315
11382
  var _a;
11316
- const stateEngine = this.ensureStateEngine();
11383
+ const stateEngine = this.ensureStateEngine(undefined, [stateName]);
11317
11384
  if (stateEngine) {
11318
11385
  return this.toGraphicStateTransition(stateEngine.addState(stateName, keepCurrentStates));
11319
11386
  }
@@ -11350,7 +11417,7 @@ class Graphic extends Node {
11350
11417
  return this.resolveLocalUseStatesTransition(nextStates);
11351
11418
  }
11352
11419
  resolveToggleStateTransition(stateName) {
11353
- const stateEngine = this.ensureStateEngine();
11420
+ const stateEngine = this.ensureStateEngine(undefined, [stateName]);
11354
11421
  if (stateEngine) {
11355
11422
  return this.toGraphicStateTransition(stateEngine.toggleState(stateName));
11356
11423
  }
@@ -11364,7 +11431,7 @@ class Graphic extends Node {
11364
11431
  resolveGraphicStateTransition(states, forceResolverRefresh = false) {
11365
11432
  var _a;
11366
11433
  const stateResolveBaseAttrs = this.getStateResolveBaseAttrs();
11367
- const stateEngine = this.ensureStateEngine(stateResolveBaseAttrs);
11434
+ const stateEngine = this.ensureStateEngine(stateResolveBaseAttrs, states);
11368
11435
  if (forceResolverRefresh) {
11369
11436
  stateEngine === null || stateEngine === void 0 ? void 0 : stateEngine.invalidateResolverCache();
11370
11437
  }
@@ -11493,7 +11560,7 @@ class Graphic extends Node {
11493
11560
  shouldSkipStateTransitionDefaultAttribute(_key, _targetAttrs) {
11494
11561
  return false;
11495
11562
  }
11496
- stopStateAnimates(type = 'end') {
11563
+ stopStateAnimates(type) {
11497
11564
  const stopAnimationState = this.stopAnimationState;
11498
11565
  if (typeof stopAnimationState === 'function') {
11499
11566
  stopAnimationState.call(this, 'state', type);
@@ -13758,19 +13825,21 @@ class Glyph extends Graphic {
13758
13825
  this.valid = this.isValid();
13759
13826
  }
13760
13827
  setSubGraphic(subGraphic) {
13828
+ var _a;
13761
13829
  this.detachSubGraphic();
13762
13830
  this.subGraphic = subGraphic;
13763
13831
  subGraphic.forEach(g => {
13764
13832
  g.glyphHost = this;
13765
- Object.setPrototypeOf(g.attribute, this.attribute);
13833
+ Graphic.bindGlyphAttributes(g, this.attribute);
13766
13834
  });
13767
13835
  this.valid = this.isValid();
13768
13836
  this.addUpdateBoundTag();
13837
+ (_a = this.subGraphicEncoder) === null || _a === void 0 ? void 0 : _a.call(this, this);
13769
13838
  }
13770
13839
  detachSubGraphic() {
13771
13840
  this.subGraphic.forEach(g => {
13772
13841
  g.glyphHost = null;
13773
- Object.setPrototypeOf(g.attribute, {});
13842
+ Graphic.bindGlyphAttributes(g, Object.prototype);
13774
13843
  });
13775
13844
  }
13776
13845
  getSubGraphic() {
@@ -13785,67 +13854,52 @@ class Glyph extends Graphic {
13785
13854
  isValid() {
13786
13855
  return true;
13787
13856
  }
13788
- setAttribute(key, value, forceUpdateTag, context) {
13789
- super.setAttribute(key, value, forceUpdateTag, context);
13790
- this.subGraphic.forEach(g => {
13791
- g.addUpdateShapeAndBoundsTag();
13792
- g.addUpdatePositionTag();
13793
- });
13794
- }
13795
- setAttributes(params, forceUpdateTag = false, context) {
13796
- super.setAttributes(params, forceUpdateTag, context);
13797
- this.subGraphic.forEach(g => {
13798
- g.addUpdateShapeAndBoundsTag();
13799
- g.addUpdatePositionTag();
13800
- });
13857
+ setSubGraphicEncoder(encoder) {
13858
+ this.subGraphicEncoder = encoder;
13859
+ encoder === null || encoder === void 0 ? void 0 : encoder(this);
13801
13860
  }
13802
- translate(x, y) {
13803
- super.translate(x, y);
13804
- this.subGraphic.forEach(g => {
13805
- g.addUpdatePositionTag();
13806
- g.addUpdateBoundTag();
13807
- });
13808
- return this;
13861
+ commitSubGraphicAttributes(subGraphic, patch, removedKeys, context) {
13862
+ Graphic.commitDerivedAttributePatch(subGraphic, patch, removedKeys, context);
13809
13863
  }
13810
- translateTo(x, y) {
13811
- super.translateTo(x, y);
13812
- this.subGraphic.forEach(g => {
13813
- g.addUpdatePositionTag();
13814
- g.addUpdateBoundTag();
13815
- });
13816
- return this;
13817
- }
13818
- scale(scaleX, scaleY, scaleCenter) {
13819
- super.scale(scaleX, scaleY, scaleCenter);
13820
- this.subGraphic.forEach(g => {
13821
- g.addUpdatePositionTag();
13822
- g.addUpdateBoundTag();
13823
- });
13824
- return this;
13864
+ onAttributeUpdate(context) {
13865
+ var _a, _b;
13866
+ if (this.glyphHost) {
13867
+ Graphic.bindGlyphAttributes(this, this.glyphHost.attribute);
13868
+ }
13869
+ for (const child of this.subGraphic) {
13870
+ Graphic.bindGlyphAttributes(child, this.attribute);
13871
+ }
13872
+ (_a = this.subGraphicEncoder) === null || _a === void 0 ? void 0 : _a.call(this, this, context);
13873
+ if (!(context === null || context === void 0 ? void 0 : context.skipUpdateCallback)) {
13874
+ (_b = this._onUpdate) === null || _b === void 0 ? void 0 : _b.call(this, this);
13875
+ }
13876
+ super.onAttributeUpdate(context);
13825
13877
  }
13826
- scaleTo(scaleX, scaleY) {
13827
- super.scaleTo(scaleX, scaleY);
13828
- this.subGraphic.forEach(g => {
13829
- g.addUpdatePositionTag();
13830
- g.addUpdateBoundTag();
13831
- });
13832
- return this;
13878
+ submitUpdateByCategory(category, forceUpdateTag = false) {
13879
+ super.submitUpdateByCategory(category, forceUpdateTag);
13880
+ for (const child of this.subGraphic) {
13881
+ if (forceUpdateTag || category & UpdateCategory.SHAPE) {
13882
+ child.addUpdateShapeAndBoundsTag();
13883
+ }
13884
+ else if (category & UpdateCategory.BOUNDS) {
13885
+ child.addUpdateBoundTag();
13886
+ }
13887
+ if (category & UpdateCategory.PAINT) {
13888
+ child.addUpdatePaintTag();
13889
+ }
13890
+ if (forceUpdateTag || category & UpdateCategory.TRANSFORM) {
13891
+ child.addUpdatePositionTag();
13892
+ }
13893
+ if (forceUpdateTag || category & UpdateCategory.LAYOUT) {
13894
+ child.addUpdateLayoutTag();
13895
+ }
13896
+ }
13833
13897
  }
13834
- rotate(angle) {
13835
- super.rotate(angle);
13836
- this.subGraphic.forEach(g => {
13837
- g.addUpdatePositionTag();
13838
- g.addUpdateBoundTag();
13839
- });
13840
- return this;
13898
+ commitBaseAttributesByTouchedKeys(params, forceUpdateTag = false, context) {
13899
+ this.commitBaseAttributesByCategory(params, forceUpdateTag, context);
13841
13900
  }
13842
- rotateTo(angle) {
13843
- super.rotate(angle);
13844
- this.subGraphic.forEach(g => {
13845
- g.addUpdatePositionTag();
13846
- g.addUpdateBoundTag();
13847
- });
13848
- return this;
13901
+ commitBaseAttributeBySingleKey(key, value, forceUpdateTag = false, context) {
13902
+ this.commitBaseAttributesByTouchedKeys({ [key]: value }, forceUpdateTag, context);
13849
13903
  }
13850
13904
  getGraphicTheme() {
13851
13905
  return getTheme(this).glyph;
@@ -13864,59 +13918,100 @@ class Glyph extends Graphic {
13864
13918
  return bounds;
13865
13919
  }
13866
13920
  needUpdateTags(keys) {
13921
+ for (const key of keys) {
13922
+ if (this.needUpdateTag(key)) {
13923
+ return true;
13924
+ }
13925
+ }
13867
13926
  return false;
13868
13927
  }
13869
13928
  needUpdateTag(key) {
13870
- return false;
13871
- }
13872
- useStates(states, hasAnimation) {
13873
- var _a;
13874
- if (!states.length) {
13875
- this.clearStates(hasAnimation);
13876
- return;
13929
+ if (ATTRIBUTE_CATEGORY[key] === UpdateCategory.PAINT) {
13930
+ return false;
13877
13931
  }
13878
- const previousStates = this.currentStates ? this.currentStates.slice() : [];
13879
- const isChange = ((_a = this.currentStates) === null || _a === void 0 ? void 0 : _a.length) !== states.length ||
13880
- states.some((stateName, index) => this.currentStates[index] !== stateName);
13881
- if (!isChange) {
13882
- return;
13932
+ for (const child of this.subGraphic) {
13933
+ if (Graphic.needsShapeUpdate(child, key)) {
13934
+ return true;
13935
+ }
13883
13936
  }
13884
- this.stopStateAnimates();
13885
- if (this.stateSort) {
13886
- states = states.sort(this.stateSort);
13937
+ return false;
13938
+ }
13939
+ hasLegacyStateDefinitions() {
13940
+ if (this.glyphStateProxy) {
13941
+ return true;
13887
13942
  }
13888
- const stateAttrs = {};
13889
- states.forEach(stateName => {
13890
- const attrs = this.glyphStateProxy ? this.glyphStateProxy(stateName, states) : this.glyphStates[stateName];
13891
- if (attrs) {
13892
- Object.assign(stateAttrs, attrs.attributes);
13943
+ for (const name in this.glyphStates) {
13944
+ if (Object.prototype.hasOwnProperty.call(this.glyphStates, name)) {
13945
+ return true;
13893
13946
  }
13894
- });
13895
- if (!this.beforeStateUpdate(stateAttrs, previousStates, states, hasAnimation, false)) {
13896
- return;
13897
13947
  }
13898
- this.currentStates = states;
13899
- this.applyStateAttrs(stateAttrs, states, hasAnimation);
13948
+ return false;
13900
13949
  }
13901
- clearStates(hasAnimation) {
13902
- this.stopStateAnimates();
13903
- const previousStates = this.currentStates ? this.currentStates.slice() : [];
13904
- if (this.hasState() && this.normalAttrs) {
13905
- if (!this.beforeStateUpdate(this.normalAttrs, previousStates, [], hasAnimation, true)) {
13906
- return;
13907
- }
13908
- this.currentStates = [];
13909
- this.applyStateAttrs(this.normalAttrs, this.currentStates, hasAnimation, true);
13950
+ syncSharedStateScopeBindingFromTree(markDirty = true, inheritedSharedStateScope) {
13951
+ return this.hasLegacyStateDefinitions()
13952
+ ? this.syncSharedStateScopeBinding(undefined, markDirty)
13953
+ : super.syncSharedStateScopeBindingFromTree(markDirty, inheritedSharedStateScope);
13954
+ }
13955
+ resolveEffectiveCompiledDefinitions(stateNames = []) {
13956
+ var _a, _b;
13957
+ if (!this.hasLegacyStateDefinitions()) {
13958
+ this.legacyDefinitions = undefined;
13959
+ this.legacyCompiledDefinitions = undefined;
13960
+ return super.resolveEffectiveCompiledDefinitions(stateNames);
13910
13961
  }
13911
- else {
13912
- this.currentStates = [];
13962
+ this.syncSharedStateScopeBindingFromTree(false);
13963
+ let changed = false;
13964
+ if (!this.legacyDefinitions ||
13965
+ this.legacyDefinitionsSource !== this.glyphStates ||
13966
+ this.legacyProxySource !== this.glyphStateProxy) {
13967
+ this.legacyDefinitionsSource = this.glyphStates;
13968
+ this.legacyProxySource = this.glyphStateProxy;
13969
+ this.legacyDefinitions = {};
13970
+ for (const name of Object.keys((_a = this.glyphStates) !== null && _a !== void 0 ? _a : {})) {
13971
+ this.legacyDefinitions[name] = this.createLegacyStateDefinition(name);
13972
+ }
13973
+ changed = true;
13974
+ }
13975
+ if (this.glyphStateProxy) {
13976
+ const addDefinition = (name) => {
13977
+ if (!Object.prototype.hasOwnProperty.call(this.legacyDefinitions, name)) {
13978
+ this.legacyDefinitions[name] = this.createLegacyStateDefinition(name);
13979
+ changed = true;
13980
+ }
13981
+ };
13982
+ (_b = this.currentStates) === null || _b === void 0 ? void 0 : _b.forEach(addDefinition);
13983
+ stateNames.forEach(addDefinition);
13984
+ }
13985
+ if (changed) {
13986
+ this.legacyCompiledDefinitions = new StateDefinitionCompiler().compile(this.legacyDefinitions);
13913
13987
  }
13988
+ return { compiledDefinitions: this.legacyCompiledDefinitions, stateOrder: 'input' };
13989
+ }
13990
+ createLegacyStateDefinition(name) {
13991
+ return this.glyphStateProxy
13992
+ ? {
13993
+ name,
13994
+ resolver: ({ graphic, activeStates }) => { var _a; return (_a = graphic.glyphStateProxy(name, activeStates)) === null || _a === void 0 ? void 0 : _a.attributes; }
13995
+ }
13996
+ : { name, patch: this.glyphStates[name].attributes };
13914
13997
  }
13915
13998
  clone() {
13916
13999
  const glyph = new Glyph(Object.assign({}, this.attribute));
13917
14000
  glyph.setSubGraphic(this.subGraphic.map(g => g.clone()));
13918
14001
  return glyph;
13919
14002
  }
14003
+ release() {
14004
+ super.release();
14005
+ this.subGraphicEncoder = undefined;
14006
+ this._onUpdate = undefined;
14007
+ this.legacyDefinitions = undefined;
14008
+ this.legacyCompiledDefinitions = undefined;
14009
+ this.legacyDefinitionsSource = undefined;
14010
+ this.legacyProxySource = undefined;
14011
+ this.detachSubGraphic();
14012
+ this.subGraphic.forEach(child => child.release());
14013
+ this.subGraphic = [];
14014
+ }
13920
14015
  getNoWorkAnimateAttr() {
13921
14016
  return Glyph.NOWORK_ANIMATE_ATTR;
13922
14017
  }
@@ -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;