@visactor/vrender-core 1.1.0-alpha.1 → 1.1.0-alpha.10

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.
@@ -204,4 +204,5 @@ class EmptyContext2d {
204
204
  }
205
205
  }
206
206
 
207
- exports.EmptyContext2d = EmptyContext2d;
207
+ exports.EmptyContext2d = EmptyContext2d;
208
+ //# sourceMappingURL=empty-context.js.map
@@ -18,5 +18,4 @@ var __createBinding = this && this.__createBinding || (Object.create ? function(
18
18
  Object.defineProperty(exports, "__esModule", {
19
19
  value: !0
20
20
  }), __exportStar(require("./interpolate"), exports), __exportStar(require("./store"), exports),
21
- __exportStar(require("./colorName"), exports);
22
- //# sourceMappingURL=index.js.map
21
+ __exportStar(require("./colorName"), exports);
@@ -3,4 +3,4 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.ApplicationContribution = void 0, exports.ApplicationContribution = Symbol("ApplicationContribution");
6
- //# sourceMappingURL=application.js.map
6
+ //# sourceMappingURL=application.js.map
@@ -81,4 +81,4 @@ class AppContext {
81
81
  }
82
82
 
83
83
  exports.AppContext = AppContext;
84
- //# sourceMappingURL=app-context.js.map
84
+ //# sourceMappingURL=app-context.js.map
@@ -149,6 +149,7 @@ export declare abstract class Graphic<T extends Partial<IGraphicAttribute> = Par
149
149
  };
150
150
  protected recomputeCurrentStatePatch(): void;
151
151
  protected buildStaticAttributeSnapshot(): Partial<T>;
152
+ protected buildRemovedStateAnimationAttrs(targetStateAttrs: Partial<T>, previousResolvedStatePatch?: Partial<T>): Partial<T>;
152
153
  protected syncObjectToSnapshot(target: Record<string, any>, snapshot: Record<string, any>): AttributeDelta;
153
154
  protected _syncAttribute(): AttributeDelta;
154
155
  protected _syncFinalAttributeFromStaticTruth(): void;
@@ -210,8 +211,10 @@ export declare abstract class Graphic<T extends Partial<IGraphicAttribute> = Par
210
211
  getState(stateName: string): Partial<T> | StateDefinition<T> | undefined;
211
212
  protected createStateModel(): StateModel<T>;
212
213
  protected resolveStateAnimateConfig(animateConfig?: IAnimateConfig): any;
213
- applyStateAttrs(attrs: Partial<T>, stateNames: string[], hasAnimation?: boolean, isClear?: boolean, animateConfig?: IAnimateConfig): void;
214
+ applyStateAttrs(attrs: Partial<T>, stateNames: string[], hasAnimation?: boolean, isClear?: boolean, animateConfig?: IAnimateConfig, extraAnimateAttrs?: Partial<T>): void;
214
215
  updateNormalAttrs(stateAttrs: Partial<T>): void;
216
+ protected getStateTransitionDefaultAttribute(key: string, targetAttrs?: Partial<T>): any;
217
+ protected shouldSkipStateTransitionDefaultAttribute(_key: string, _targetAttrs?: Partial<T>): boolean;
215
218
  protected stopStateAnimates(type?: 'start' | 'end'): void;
216
219
  private getNormalAttribute;
217
220
  clearStates(hasAnimation?: boolean): void;
@@ -212,11 +212,11 @@ class Graphic extends node_tree_1.Node {
212
212
  stateProxyModeKey: this.stateProxy ? "legacy-all" : "none"
213
213
  };
214
214
  }
215
- const sharedCompiledDefinitions = boundScope.effectiveCompiledDefinitions;
215
+ const sharedCompiledDefinitions = boundScope.effectiveCompiledDefinitions, sharedStateProxyModeKey = this.stateProxy ? "shared-missing-only" : "none", sharedStateProxyEligibility = this.stateProxy ? stateName => !sharedCompiledDefinitions.has(stateName) : void 0;
216
216
  if (!hasStates) return this.localFallbackCompiledDefinitions = void 0, {
217
217
  compiledDefinitions: sharedCompiledDefinitions,
218
- stateProxyModeKey: this.stateProxy ? "shared-disabled" : "none",
219
- stateProxyEligibility: this.stateProxy ? () => !1 : void 0
218
+ stateProxyModeKey: sharedStateProxyModeKey,
219
+ stateProxyEligibility: sharedStateProxyEligibility
220
220
  };
221
221
  const localStates = this.states, missingLocalStateDefinitions = {}, missingStateNames = [];
222
222
  if (Object.keys(localStates).forEach((stateName => {
@@ -225,15 +225,15 @@ class Graphic extends node_tree_1.Node {
225
225
  })), !missingStateNames.length) return this.localFallbackCompiledDefinitions = void 0,
226
226
  {
227
227
  compiledDefinitions: sharedCompiledDefinitions,
228
- stateProxyModeKey: this.stateProxy ? "shared-disabled" : "none",
229
- stateProxyEligibility: this.stateProxy ? () => !1 : void 0
228
+ stateProxyModeKey: sharedStateProxyModeKey,
229
+ stateProxyEligibility: sharedStateProxyEligibility
230
230
  };
231
231
  const localStatesVersion = this.getLocalStatesVersion(), stateProxyModeKey = this.stateProxy ? `missing:${missingStateNames.sort().join("|")}` : "none", cacheKey = `shared:${boundScope.revision}:fallback:${localStatesVersion}:${stateProxyModeKey}`;
232
232
  return this.localFallbackCompiledDefinitions && this.compiledStateDefinitionsCacheKey === cacheKey || (this.localFallbackCompiledDefinitions = (new state_definition_compiler_1.StateDefinitionCompiler).compile(Object.assign(Object.assign({}, boundScope.effectiveSourceDefinitions), missingLocalStateDefinitions)),
233
233
  this.compiledStateDefinitionsCacheKey = cacheKey), {
234
234
  compiledDefinitions: this.localFallbackCompiledDefinitions,
235
235
  stateProxyModeKey: stateProxyModeKey,
236
- stateProxyEligibility: this.stateProxy ? stateName => !sharedCompiledDefinitions.has(stateName) : void 0
236
+ stateProxyEligibility: sharedStateProxyEligibility
237
237
  };
238
238
  }
239
239
  recomputeCurrentStatePatch() {
@@ -254,6 +254,22 @@ class Graphic extends node_tree_1.Node {
254
254
  "deep" === this.stateMergeMode && isPlainObjectValue(previousValue) && isPlainObjectValue(nextValue) ? snapshot[key] = deepMergeAttributeValue(previousValue, nextValue) : snapshot[key] = cloneAttributeValue(nextValue);
255
255
  })), snapshot) : snapshot;
256
256
  }
257
+ buildRemovedStateAnimationAttrs(targetStateAttrs, previousResolvedStatePatch) {
258
+ const extraAttrs = {};
259
+ if (!previousResolvedStatePatch) return extraAttrs;
260
+ const snapshot = this.buildStaticAttributeSnapshot(), staticTargetAttrs = snapshot;
261
+ return Object.keys(previousResolvedStatePatch).forEach((key => {
262
+ const hasTargetAttr = Object.prototype.hasOwnProperty.call(targetStateAttrs, key);
263
+ if (hasTargetAttr && void 0 !== targetStateAttrs[key]) return;
264
+ const assignFallbackAttr = value => {
265
+ void 0 === value && this.shouldSkipStateTransitionDefaultAttribute(key, staticTargetAttrs) || (extraAttrs[key] = void 0 === value ? value : cloneAttributeValue(value));
266
+ };
267
+ if (hasTargetAttr) assignFallbackAttr(this.getStateTransitionDefaultAttribute(key, staticTargetAttrs)); else if (Object.prototype.hasOwnProperty.call(snapshot, key)) {
268
+ const snapshotValue = snapshot[key];
269
+ assignFallbackAttr(void 0 === snapshotValue ? this.getStateTransitionDefaultAttribute(key, staticTargetAttrs) : snapshotValue);
270
+ } else assignFallbackAttr(this.getStateTransitionDefaultAttribute(key, staticTargetAttrs));
271
+ })), extraAttrs;
272
+ }
257
273
  syncObjectToSnapshot(target, snapshot) {
258
274
  const delta = new Map;
259
275
  return new Set([ ...Object.keys(target), ...Object.keys(snapshot) ]).forEach((key => {
@@ -681,20 +697,30 @@ class Graphic extends node_tree_1.Node {
681
697
  var _a, _b, _c;
682
698
  return null !== (_c = null !== (_a = null != animateConfig ? animateConfig : this.stateAnimateConfig) && void 0 !== _a ? _a : null === (_b = this.context) || void 0 === _b ? void 0 : _b.stateAnimateConfig) && void 0 !== _c ? _c : config_2.DefaultStateAnimateConfig;
683
699
  }
684
- applyStateAttrs(attrs, stateNames, hasAnimation, isClear, animateConfig) {
700
+ applyStateAttrs(attrs, stateNames, hasAnimation, isClear, animateConfig, extraAnimateAttrs) {
685
701
  const resolvedAnimateConfig = hasAnimation ? this.resolveStateAnimateConfig(animateConfig) : void 0, transitionOptions = resolvedAnimateConfig ? {
686
- animateConfig: resolvedAnimateConfig
702
+ animateConfig: resolvedAnimateConfig,
703
+ extraAnimateAttrs: extraAnimateAttrs,
704
+ shouldSkipDefaultAttribute: this.shouldSkipStateTransitionDefaultAttribute.bind(this)
687
705
  } : void 0;
688
706
  if (isClear) return void this.getStateTransitionOrchestrator().applyClearTransition(this, attrs, hasAnimation, stateNames, transitionOptions);
689
707
  const plan = this.getStateTransitionOrchestrator().analyzeTransition({}, attrs, stateNames, hasAnimation, {
690
708
  noWorkAnimateAttr: this.getNoWorkAnimateAttr(),
691
- animateConfig: resolvedAnimateConfig
709
+ animateConfig: resolvedAnimateConfig,
710
+ extraAnimateAttrs: extraAnimateAttrs,
711
+ shouldSkipDefaultAttribute: this.shouldSkipStateTransitionDefaultAttribute.bind(this)
692
712
  });
693
713
  this.getStateTransitionOrchestrator().applyTransition(this, plan, hasAnimation, transitionOptions);
694
714
  }
695
715
  updateNormalAttrs(stateAttrs) {
696
716
  this._deprecatedNormalAttrsView = cloneAttributeValue(this.baseAttributes);
697
717
  }
718
+ getStateTransitionDefaultAttribute(key, targetAttrs) {
719
+ return this.getDefaultAttribute(key);
720
+ }
721
+ shouldSkipStateTransitionDefaultAttribute(_key, _targetAttrs) {
722
+ return !1;
723
+ }
698
724
  stopStateAnimates(type = "end") {
699
725
  const stopAnimationState = this.stopAnimationState;
700
726
  if ("function" == typeof stopAnimationState) return void stopAnimationState.call(this, "state", type);
@@ -710,7 +736,7 @@ class Graphic extends node_tree_1.Node {
710
736
  }
711
737
  clearStates(hasAnimation) {
712
738
  var _a, _b, _c;
713
- const previousStates = this.currentStates ? this.currentStates.slice() : [], transition = this.createStateModel().clearStates();
739
+ const previousStates = this.currentStates ? this.currentStates.slice() : [], previousResolvedStatePatch = this.resolvedStatePatch ? cloneAttributeValue(this.resolvedStatePatch) : void 0, transition = this.createStateModel().clearStates();
714
740
  if (!transition.changed && 0 === previousStates.length) return this.currentStates = [],
715
741
  this.effectiveStates = [], this.resolvedStatePatch = void 0, this.sharedStateDirty = !1,
716
742
  void this.clearSharedStateActiveRegistrations();
@@ -721,7 +747,7 @@ class Graphic extends node_tree_1.Node {
721
747
  null === (_c = (0, state_perf_monitor_1.getStageStatePerfMonitor)(this.stage)) || void 0 === _c || _c.recordEvent("state-commit", {
722
748
  graphicId: this._uid,
723
749
  targetStates: []
724
- }), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !0)) : (this.stopStateAnimates(),
750
+ }), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !0, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(),
725
751
  this._restoreAttributeFromStaticTruth({
726
752
  type: enums_1.AttributeUpdateType.STATE
727
753
  }), this._emitCustomEvent("afterStateUpdate", {
@@ -743,7 +769,7 @@ class Graphic extends node_tree_1.Node {
743
769
  useStates(states, hasAnimation) {
744
770
  var _a, _b, _c, _d, _e;
745
771
  if (!states.length) return void this.clearStates(hasAnimation);
746
- const previousStates = this.currentStates ? this.currentStates.slice() : [], stateResolveBaseAttrs = null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : this.attribute, stateModel = this.createStateModel();
772
+ const previousStates = this.currentStates ? this.currentStates.slice() : [], previousResolvedStatePatch = this.resolvedStatePatch ? cloneAttributeValue(this.resolvedStatePatch) : void 0, stateResolveBaseAttrs = null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : this.attribute, stateModel = this.createStateModel();
747
773
  null === (_b = this.stateEngine) || void 0 === _b || _b.setResolveContext(this, stateResolveBaseAttrs);
748
774
  const transition = stateModel.useStates(states);
749
775
  if (!transition.changed && this.sameStateNames(previousStates, transition.states)) return;
@@ -755,7 +781,7 @@ class Graphic extends node_tree_1.Node {
755
781
  null === (_e = (0, state_perf_monitor_1.getStageStatePerfMonitor)(this.stage)) || void 0 === _e || _e.recordEvent("state-commit", {
756
782
  graphicId: this._uid,
757
783
  targetStates: [ ...transition.states ]
758
- }), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation)) : (this.stopStateAnimates(),
784
+ }), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !1, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(),
759
785
  this._restoreAttributeFromStaticTruth({
760
786
  type: enums_1.AttributeUpdateType.STATE
761
787
  }), this._emitCustomEvent("afterStateUpdate", {