@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.
@@ -255,11 +255,11 @@ export class Graphic extends Node {
255
255
  stateProxyModeKey: this.stateProxy ? "legacy-all" : "none"
256
256
  };
257
257
  }
258
- const sharedCompiledDefinitions = boundScope.effectiveCompiledDefinitions;
258
+ const sharedCompiledDefinitions = boundScope.effectiveCompiledDefinitions, sharedStateProxyModeKey = this.stateProxy ? "shared-missing-only" : "none", sharedStateProxyEligibility = this.stateProxy ? stateName => !sharedCompiledDefinitions.has(stateName) : void 0;
259
259
  if (!hasStates) return this.localFallbackCompiledDefinitions = void 0, {
260
260
  compiledDefinitions: sharedCompiledDefinitions,
261
- stateProxyModeKey: this.stateProxy ? "shared-disabled" : "none",
262
- stateProxyEligibility: this.stateProxy ? () => !1 : void 0
261
+ stateProxyModeKey: sharedStateProxyModeKey,
262
+ stateProxyEligibility: sharedStateProxyEligibility
263
263
  };
264
264
  const localStates = this.states, missingLocalStateDefinitions = {}, missingStateNames = [];
265
265
  if (Object.keys(localStates).forEach((stateName => {
@@ -268,15 +268,15 @@ export class Graphic extends Node {
268
268
  })), !missingStateNames.length) return this.localFallbackCompiledDefinitions = void 0,
269
269
  {
270
270
  compiledDefinitions: sharedCompiledDefinitions,
271
- stateProxyModeKey: this.stateProxy ? "shared-disabled" : "none",
272
- stateProxyEligibility: this.stateProxy ? () => !1 : void 0
271
+ stateProxyModeKey: sharedStateProxyModeKey,
272
+ stateProxyEligibility: sharedStateProxyEligibility
273
273
  };
274
274
  const localStatesVersion = this.getLocalStatesVersion(), stateProxyModeKey = this.stateProxy ? `missing:${missingStateNames.sort().join("|")}` : "none", cacheKey = `shared:${boundScope.revision}:fallback:${localStatesVersion}:${stateProxyModeKey}`;
275
275
  return this.localFallbackCompiledDefinitions && this.compiledStateDefinitionsCacheKey === cacheKey || (this.localFallbackCompiledDefinitions = (new StateDefinitionCompiler).compile(Object.assign(Object.assign({}, boundScope.effectiveSourceDefinitions), missingLocalStateDefinitions)),
276
276
  this.compiledStateDefinitionsCacheKey = cacheKey), {
277
277
  compiledDefinitions: this.localFallbackCompiledDefinitions,
278
278
  stateProxyModeKey: stateProxyModeKey,
279
- stateProxyEligibility: this.stateProxy ? stateName => !sharedCompiledDefinitions.has(stateName) : void 0
279
+ stateProxyEligibility: sharedStateProxyEligibility
280
280
  };
281
281
  }
282
282
  recomputeCurrentStatePatch() {
@@ -297,6 +297,22 @@ export class Graphic extends Node {
297
297
  "deep" === this.stateMergeMode && isPlainObjectValue(previousValue) && isPlainObjectValue(nextValue) ? snapshot[key] = deepMergeAttributeValue(previousValue, nextValue) : snapshot[key] = cloneAttributeValue(nextValue);
298
298
  })), snapshot) : snapshot;
299
299
  }
300
+ buildRemovedStateAnimationAttrs(targetStateAttrs, previousResolvedStatePatch) {
301
+ const extraAttrs = {};
302
+ if (!previousResolvedStatePatch) return extraAttrs;
303
+ const snapshot = this.buildStaticAttributeSnapshot(), staticTargetAttrs = snapshot;
304
+ return Object.keys(previousResolvedStatePatch).forEach((key => {
305
+ const hasTargetAttr = Object.prototype.hasOwnProperty.call(targetStateAttrs, key);
306
+ if (hasTargetAttr && void 0 !== targetStateAttrs[key]) return;
307
+ const assignFallbackAttr = value => {
308
+ void 0 === value && this.shouldSkipStateTransitionDefaultAttribute(key, staticTargetAttrs) || (extraAttrs[key] = void 0 === value ? value : cloneAttributeValue(value));
309
+ };
310
+ if (hasTargetAttr) assignFallbackAttr(this.getStateTransitionDefaultAttribute(key, staticTargetAttrs)); else if (Object.prototype.hasOwnProperty.call(snapshot, key)) {
311
+ const snapshotValue = snapshot[key];
312
+ assignFallbackAttr(void 0 === snapshotValue ? this.getStateTransitionDefaultAttribute(key, staticTargetAttrs) : snapshotValue);
313
+ } else assignFallbackAttr(this.getStateTransitionDefaultAttribute(key, staticTargetAttrs));
314
+ })), extraAttrs;
315
+ }
300
316
  syncObjectToSnapshot(target, snapshot) {
301
317
  const delta = new Map;
302
318
  return new Set([ ...Object.keys(target), ...Object.keys(snapshot) ]).forEach((key => {
@@ -716,20 +732,30 @@ export class Graphic extends Node {
716
732
  var _a, _b, _c;
717
733
  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 : DefaultStateAnimateConfig;
718
734
  }
719
- applyStateAttrs(attrs, stateNames, hasAnimation, isClear, animateConfig) {
735
+ applyStateAttrs(attrs, stateNames, hasAnimation, isClear, animateConfig, extraAnimateAttrs) {
720
736
  const resolvedAnimateConfig = hasAnimation ? this.resolveStateAnimateConfig(animateConfig) : void 0, transitionOptions = resolvedAnimateConfig ? {
721
- animateConfig: resolvedAnimateConfig
737
+ animateConfig: resolvedAnimateConfig,
738
+ extraAnimateAttrs: extraAnimateAttrs,
739
+ shouldSkipDefaultAttribute: this.shouldSkipStateTransitionDefaultAttribute.bind(this)
722
740
  } : void 0;
723
741
  if (isClear) return void this.getStateTransitionOrchestrator().applyClearTransition(this, attrs, hasAnimation, stateNames, transitionOptions);
724
742
  const plan = this.getStateTransitionOrchestrator().analyzeTransition({}, attrs, stateNames, hasAnimation, {
725
743
  noWorkAnimateAttr: this.getNoWorkAnimateAttr(),
726
- animateConfig: resolvedAnimateConfig
744
+ animateConfig: resolvedAnimateConfig,
745
+ extraAnimateAttrs: extraAnimateAttrs,
746
+ shouldSkipDefaultAttribute: this.shouldSkipStateTransitionDefaultAttribute.bind(this)
727
747
  });
728
748
  this.getStateTransitionOrchestrator().applyTransition(this, plan, hasAnimation, transitionOptions);
729
749
  }
730
750
  updateNormalAttrs(stateAttrs) {
731
751
  this._deprecatedNormalAttrsView = cloneAttributeValue(this.baseAttributes);
732
752
  }
753
+ getStateTransitionDefaultAttribute(key, targetAttrs) {
754
+ return this.getDefaultAttribute(key);
755
+ }
756
+ shouldSkipStateTransitionDefaultAttribute(_key, _targetAttrs) {
757
+ return !1;
758
+ }
733
759
  stopStateAnimates(type = "end") {
734
760
  const stopAnimationState = this.stopAnimationState;
735
761
  if ("function" == typeof stopAnimationState) return void stopAnimationState.call(this, "state", type);
@@ -745,7 +771,7 @@ export class Graphic extends Node {
745
771
  }
746
772
  clearStates(hasAnimation) {
747
773
  var _a, _b, _c;
748
- const previousStates = this.currentStates ? this.currentStates.slice() : [], transition = this.createStateModel().clearStates();
774
+ const previousStates = this.currentStates ? this.currentStates.slice() : [], previousResolvedStatePatch = this.resolvedStatePatch ? cloneAttributeValue(this.resolvedStatePatch) : void 0, transition = this.createStateModel().clearStates();
749
775
  if (!transition.changed && 0 === previousStates.length) return this.currentStates = [],
750
776
  this.effectiveStates = [], this.resolvedStatePatch = void 0, this.sharedStateDirty = !1,
751
777
  void this.clearSharedStateActiveRegistrations();
@@ -756,7 +782,7 @@ export class Graphic extends Node {
756
782
  null === (_c = getStageStatePerfMonitor(this.stage)) || void 0 === _c || _c.recordEvent("state-commit", {
757
783
  graphicId: this._uid,
758
784
  targetStates: []
759
- }), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !0)) : (this.stopStateAnimates(),
785
+ }), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !0, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(),
760
786
  this._restoreAttributeFromStaticTruth({
761
787
  type: AttributeUpdateType.STATE
762
788
  }), this._emitCustomEvent("afterStateUpdate", {
@@ -778,7 +804,7 @@ export class Graphic extends Node {
778
804
  useStates(states, hasAnimation) {
779
805
  var _a, _b, _c, _d, _e;
780
806
  if (!states.length) return void this.clearStates(hasAnimation);
781
- const previousStates = this.currentStates ? this.currentStates.slice() : [], stateResolveBaseAttrs = null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : this.attribute, stateModel = this.createStateModel();
807
+ 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();
782
808
  null === (_b = this.stateEngine) || void 0 === _b || _b.setResolveContext(this, stateResolveBaseAttrs);
783
809
  const transition = stateModel.useStates(states);
784
810
  if (!transition.changed && this.sameStateNames(previousStates, transition.states)) return;
@@ -789,7 +815,7 @@ export class Graphic extends Node {
789
815
  null === (_e = getStageStatePerfMonitor(this.stage)) || void 0 === _e || _e.recordEvent("state-commit", {
790
816
  graphicId: this._uid,
791
817
  targetStates: [ ...transition.states ]
792
- }), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation)) : (this.stopStateAnimates(),
818
+ }), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !1, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(),
793
819
  this._restoreAttributeFromStaticTruth({
794
820
  type: AttributeUpdateType.STATE
795
821
  }), this._emitCustomEvent("afterStateUpdate", {