@visactor/vrender-core 1.1.0-alpha.18 → 1.1.0-alpha.19

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.
@@ -245,7 +245,9 @@ export declare abstract class Graphic<T extends Partial<IGraphicAttribute> = Par
245
245
  }): void;
246
246
  hasState(stateName?: string): boolean;
247
247
  getState(stateName: string): Partial<T> | StateDefinition<T> | undefined;
248
- protected createStateModel(): StateModel<T>;
248
+ protected getStateResolveBaseAttrs(): Partial<T>;
249
+ protected syncStateResolveContext(stateResolveBaseAttrs?: Partial<T>): Partial<T>;
250
+ protected createStateModel(stateResolveBaseAttrs?: Partial<T>): StateModel<T>;
249
251
  protected resolveSimpleLocalStateTransition(states: string[], previousStates: readonly string[]): {
250
252
  changed: boolean;
251
253
  states: string[];
@@ -248,12 +248,10 @@ class Graphic extends node_tree_1.Node {
248
248
  };
249
249
  }
250
250
  recomputeCurrentStatePatch() {
251
- var _a, _b, _c, _d;
251
+ var _a, _b;
252
252
  if (!(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length)) return this.effectiveStates = [],
253
253
  this.resolvedStatePatch = void 0, void this.syncSharedStateActiveRegistrations();
254
- const stateResolveBaseAttrs = null !== (_b = this.baseAttributes) && void 0 !== _b ? _b : this.attribute, stateModel = this.createStateModel();
255
- null === (_c = this.stateEngine) || void 0 === _c || _c.setResolveContext(this, stateResolveBaseAttrs);
256
- const transition = stateModel.useStates(this.currentStates), effectiveStates = null !== (_d = transition.effectiveStates) && void 0 !== _d ? _d : transition.states, resolvedStateAttrs = this.stateEngine && this.compiledStateDefinitions ? Object.assign({}, this.stateEngine.resolvedPatch) : this.getStateStyleResolver(this.stateMergeMode).resolve(stateResolveBaseAttrs, this.states, this.stateProxy, transition.states, this.stateSort);
254
+ const stateResolveBaseAttrs = this.getStateResolveBaseAttrs(), transition = this.createStateModel(stateResolveBaseAttrs).useStates(this.currentStates), effectiveStates = null !== (_b = transition.effectiveStates) && void 0 !== _b ? _b : transition.states, resolvedStateAttrs = this.stateEngine && this.compiledStateDefinitions ? Object.assign({}, this.stateEngine.resolvedPatch) : this.getStateStyleResolver(this.stateMergeMode).resolve(stateResolveBaseAttrs, this.states, this.stateProxy, transition.states, this.stateSort);
257
255
  this.currentStates = transition.states, this.effectiveStates = [ ...effectiveStates ],
258
256
  this.resolvedStatePatch = resolvedStateAttrs, this.syncSharedStateActiveRegistrations();
259
257
  }
@@ -843,7 +841,16 @@ class Graphic extends node_tree_1.Node {
843
841
  var _a;
844
842
  return null === (_a = this.states) || void 0 === _a ? void 0 : _a[stateName];
845
843
  }
846
- createStateModel() {
844
+ getStateResolveBaseAttrs() {
845
+ var _a;
846
+ return null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : this.attribute;
847
+ }
848
+ syncStateResolveContext(stateResolveBaseAttrs = this.getStateResolveBaseAttrs()) {
849
+ var _a;
850
+ return null === (_a = this.stateEngine) || void 0 === _a || _a.setResolveContext(this, stateResolveBaseAttrs),
851
+ stateResolveBaseAttrs;
852
+ }
853
+ createStateModel(stateResolveBaseAttrs = this.getStateResolveBaseAttrs()) {
847
854
  const {compiledDefinitions: compiledDefinitions, stateProxyEligibility: stateProxyEligibility, stateProxyModeKey: stateProxyModeKey} = this.resolveEffectiveCompiledDefinitions();
848
855
  return this.compiledStateDefinitions = compiledDefinitions, compiledDefinitions ? this.stateEngine && this.stateEngineCompiledDefinitions === compiledDefinitions && this.stateEngineStateProxy === this.stateProxy && this.stateEngineStateSort === this.stateSort && this.stateEngineMergeMode === this.stateMergeMode && this.stateEngineStateProxyModeKey === stateProxyModeKey || (this.stateEngine = new state_engine_1.StateEngine({
849
856
  compiledDefinitions: compiledDefinitions,
@@ -856,7 +863,7 @@ class Graphic extends node_tree_1.Node {
856
863
  this.stateEngineStateSort = this.stateSort, this.stateEngineMergeMode = this.stateMergeMode,
857
864
  this.stateEngineStateProxyModeKey = stateProxyModeKey) : (this.stateEngine = void 0,
858
865
  this.stateEngineCompiledDefinitions = void 0, this.stateEngineStateProxyModeKey = void 0),
859
- new state_model_1.StateModel({
866
+ this.syncStateResolveContext(stateResolveBaseAttrs), new state_model_1.StateModel({
860
867
  states: this.states,
861
868
  currentStates: this.currentStates,
862
869
  stateSort: this.stateSort,
@@ -918,19 +925,18 @@ class Graphic extends node_tree_1.Node {
918
925
  };
919
926
  }
920
927
  resolveGraphicStateTransition(states, previousStates, forceResolverRefresh = !1) {
921
- var _a, _b, _c, _d;
928
+ var _a, _b;
922
929
  let transition = this.resolveSimpleLocalStateTransition(states, previousStates);
923
930
  const isSimpleLocalTransition = !!transition;
924
931
  let resolvedStateAttrs;
925
932
  if (transition) resolvedStateAttrs = transition.resolvedStateAttrs; else {
926
- const stateResolveBaseAttrs = null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : this.attribute, stateModel = this.createStateModel();
927
- null === (_b = this.stateEngine) || void 0 === _b || _b.setResolveContext(this, stateResolveBaseAttrs),
928
- forceResolverRefresh && (null === (_c = this.stateEngine) || void 0 === _c || _c.invalidateResolverCache()),
933
+ const stateResolveBaseAttrs = this.getStateResolveBaseAttrs(), stateModel = this.createStateModel(stateResolveBaseAttrs);
934
+ forceResolverRefresh && (null === (_a = this.stateEngine) || void 0 === _a || _a.invalidateResolverCache()),
929
935
  transition = stateModel.useStates(states), resolvedStateAttrs = this.stateEngine && this.compiledStateDefinitions ? Object.assign({}, this.stateEngine.resolvedPatch) : this.getStateStyleResolver(this.stateMergeMode).resolve(stateResolveBaseAttrs, this.states, this.stateProxy, transition.states, this.stateSort);
930
936
  }
931
937
  return {
932
938
  transition: transition,
933
- effectiveStates: null !== (_d = transition.effectiveStates) && void 0 !== _d ? _d : transition.states,
939
+ effectiveStates: null !== (_b = transition.effectiveStates) && void 0 !== _b ? _b : transition.states,
934
940
  resolvedStateAttrs: resolvedStateAttrs,
935
941
  isSimpleLocalTransition: isSimpleLocalTransition
936
942
  };
@@ -1087,10 +1093,10 @@ class Graphic extends node_tree_1.Node {
1087
1093
  }
1088
1094
  }
1089
1095
  invalidateResolver() {
1090
- var _a, _b, _c;
1096
+ var _a, _b;
1091
1097
  if (!this.stateEngine || !(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) || !this.compiledStateDefinitions) return;
1092
- const stateResolveBaseAttrs = null !== (_b = this.baseAttributes) && void 0 !== _b ? _b : this.attribute;
1093
- this.stateEngine.setResolveContext(this, stateResolveBaseAttrs), this.resolverEpoch = (null !== (_c = this.resolverEpoch) && void 0 !== _c ? _c : 0) + 1,
1098
+ this.syncStateResolveContext();
1099
+ this.resolverEpoch = (null !== (_b = this.resolverEpoch) && void 0 !== _b ? _b : 0) + 1,
1094
1100
  this.stateEngine.invalidateResolverCache();
1095
1101
  const transition = this.stateEngine.applyStates(this.currentStates), resolvedStateAttrs = Object.assign({}, this.stateEngine.resolvedPatch);
1096
1102
  this.effectiveStates = [ ...transition.effectiveStates ], this.resolvedStatePatch = resolvedStateAttrs,