@visactor/vrender 1.1.0-alpha.16 → 1.1.0-alpha.17

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/dist/index.js CHANGED
@@ -8214,6 +8214,12 @@
8214
8214
  function getStageStatePerfMonitor(stage) {
8215
8215
  if (stage) return stage[STAGE_PERF_MONITOR];
8216
8216
  }
8217
+ function getActiveStageStatePerfMonitor(stage) {
8218
+ var _a;
8219
+ if (!stage) return;
8220
+ const current = getStageStatePerfMonitor(stage);
8221
+ return current || (!0 === (null === (_a = stage.statePerfConfig) || void 0 === _a ? void 0 : _a.enabled) ? ensureStageStatePerfMonitor(stage) : void 0);
8222
+ }
8217
8223
 
8218
8224
  function isPlainObject$1(value) {
8219
8225
  return null != value && "object" == typeof value && !Array.isArray(value);
@@ -8309,7 +8315,7 @@
8309
8315
  }
8310
8316
  invalidateResolverCache() {
8311
8317
  var _a, _b;
8312
- this.resolverPatchCache.clear(), this.resolverCacheKey = "", this.resolverCacheValid = !1, null === (_b = getStageStatePerfMonitor(null === (_a = this.graphic) || void 0 === _a ? void 0 : _a.stage)) || void 0 === _b || _b.recordResolver("invalidations");
8318
+ this.resolverPatchCache.clear(), this.resolverCacheKey = "", this.resolverCacheValid = !1, null === (_b = getActiveStageStatePerfMonitor(null === (_a = this.graphic) || void 0 === _a ? void 0 : _a.stage)) || void 0 === _b || _b.recordResolver("invalidations");
8313
8319
  }
8314
8320
  hasState(stateName) {
8315
8321
  return !!this._activeStates.length && (null == stateName || this._activeStates.includes(stateName));
@@ -8356,7 +8362,7 @@
8356
8362
  }
8357
8363
  recomputePatch(effectiveStates) {
8358
8364
  var _a;
8359
- const perfMonitor = getStageStatePerfMonitor(null === (_a = this.graphic) || void 0 === _a ? void 0 : _a.stage),
8365
+ const perfMonitor = getActiveStageStatePerfMonitor(null === (_a = this.graphic) || void 0 === _a ? void 0 : _a.stage),
8360
8366
  patchStart = perfMonitor ? performance.now() : 0;
8361
8367
  let resolverCost = 0;
8362
8368
  const cacheKey = effectiveStates.join(","),
@@ -8604,32 +8610,6 @@
8604
8610
  }
8605
8611
  }), resolvedAttrs;
8606
8612
  }
8607
- resolveWithCompiled(normalAttrs, compiledDefinitions, stateProxy, effectiveStates, resolvedPatch) {
8608
- var _a, _b;
8609
- const mergeMode = null !== (_a = this.options.mergeMode) && void 0 !== _a ? _a : "shallow",
8610
- resolvedAttrs = null !== (_b = cloneValue(resolvedPatch)) && void 0 !== _b ? _b : {};
8611
- return effectiveStates.forEach(stateName => {
8612
- const proxyPatch = null == stateProxy ? void 0 : stateProxy(stateName, effectiveStates);
8613
- null != proxyPatch && Object.keys(proxyPatch).forEach(key => {
8614
- const nextValue = proxyPatch[key],
8615
- hasCompiledDefinition = compiledDefinitions.has(stateName);
8616
- if ("deep" === mergeMode && isPlainObject(nextValue) && (isPlainObject(resolvedAttrs[key]) || !hasCompiledDefinition && isPlainObject(normalAttrs[key]))) {
8617
- const baseValue = isPlainObject(resolvedAttrs[key]) ? resolvedAttrs[key] : isPlainObject(normalAttrs[key]) ? normalAttrs[key] : {};
8618
- resolvedAttrs[key] = deepMerge(baseValue, nextValue);
8619
- } else resolvedAttrs[key] = cloneValue(nextValue);
8620
- });
8621
- }), resolvedAttrs;
8622
- }
8623
- computeNormalAttrsBackup(normalAttrs, targetAttrs, finalAttribute) {
8624
- const nextNormalAttrs = {},
8625
- nextTargetAttrs = Object.assign({}, targetAttrs);
8626
- for (const key in targetAttrs) Object.prototype.hasOwnProperty.call(targetAttrs, key) && (nextNormalAttrs[key] = cloneValue(normalAttrs && key in normalAttrs ? normalAttrs[key] : finalAttribute[key]));
8627
- if (normalAttrs) for (const key in normalAttrs) Object.prototype.hasOwnProperty.call(normalAttrs, key) && !(key in targetAttrs) && (nextTargetAttrs[key] = cloneValue(normalAttrs[key]));
8628
- return {
8629
- attrs: nextTargetAttrs,
8630
- normalAttrs: nextNormalAttrs
8631
- };
8632
- }
8633
8613
  }
8634
8614
 
8635
8615
  function hasOwnKeys(value) {
@@ -8764,7 +8744,7 @@
8764
8744
  }
8765
8745
  function ensureSharedStateScopeFresh(scope) {
8766
8746
  var _a;
8767
- if (scope) return null === (_a = getStageStatePerfMonitor(scope.ownerStage)) || void 0 === _a || _a.recordRefresh("ensureFreshCalls"), scope.parentScope && ensureSharedStateScopeFresh(scope.parentScope), (scope.dirty || scope.parentScope && scope.parentRevisionAtBuild !== scope.parentScope.revision) && rebuildSharedStateScope(scope), scope;
8747
+ if (scope) return null === (_a = getActiveStageStatePerfMonitor(scope.ownerStage)) || void 0 === _a || _a.recordRefresh("ensureFreshCalls"), scope.parentScope && ensureSharedStateScopeFresh(scope.parentScope), (scope.dirty || scope.parentScope && scope.parentRevisionAtBuild !== scope.parentScope.revision) && rebuildSharedStateScope(scope), scope;
8768
8748
  }
8769
8749
  function collectSharedStateScopeChain(scope) {
8770
8750
  const chain = [];
@@ -8775,7 +8755,7 @@
8775
8755
 
8776
8756
  function scheduleStageSharedStateRefresh(stage) {
8777
8757
  var _a;
8778
- stage && "released" !== stage.releaseStatus && (null === (_a = getStageStatePerfMonitor(stage)) || void 0 === _a || _a.recordRefresh("renderScheduled"), stage.renderNextFrame());
8758
+ stage && "released" !== stage.releaseStatus && (null === (_a = getActiveStageStatePerfMonitor(stage)) || void 0 === _a || _a.recordRefresh("renderScheduled"), stage.renderNextFrame());
8779
8759
  }
8780
8760
  function enqueueGraphicSharedStateRefresh(stage, graphic) {
8781
8761
  var _a;
@@ -8783,7 +8763,7 @@
8783
8763
  const pending = null !== (_a = stage._pendingSharedStateRefreshGraphics) && void 0 !== _a ? _a : stage._pendingSharedStateRefreshGraphics = new Set();
8784
8764
  if (!pending.has(graphic)) {
8785
8765
  pending.add(graphic);
8786
- const perfMonitor = getStageStatePerfMonitor(stage);
8766
+ const perfMonitor = getActiveStageStatePerfMonitor(stage);
8787
8767
  null == perfMonitor || perfMonitor.recordRefresh("queuedGraphics"), null == perfMonitor || perfMonitor.recordAllocation("refreshQueuePushes");
8788
8768
  }
8789
8769
  }
@@ -8798,7 +8778,7 @@
8798
8778
  function flushStageSharedStateRefresh(stage) {
8799
8779
  const pending = stage._pendingSharedStateRefreshGraphics;
8800
8780
  if (!pending || !pending.size) return;
8801
- const perfMonitor = getStageStatePerfMonitor(stage),
8781
+ const perfMonitor = getActiveStageStatePerfMonitor(stage),
8802
8782
  start = perfMonitor ? performance.now() : 0,
8803
8783
  graphics = Array.from(pending.values());
8804
8784
  pending.clear(), null == perfMonitor || perfMonitor.recordRefresh("flushedGraphics", graphics.length), graphics.forEach(graphic => {
@@ -8820,9 +8800,12 @@
8820
8800
  tempConstantScaleXYKey = ["scaleX", "scaleY"],
8821
8801
  tempConstantAngleKey = ["angle"],
8822
8802
  builtinTextureTypes = new Set(["circle", "diamond", "rect", "vertical-line", "horizontal-line", "bias-lr", "bias-rl", "grid", "wave"]),
8823
- point = new Point();
8803
+ FULL_STATE_DEFINITION_KEYS = new Set(["name", "patch", "priority", "exclude", "suppress", "resolver", "declaredAffectedKeys"]),
8804
+ point = new Point(),
8805
+ EMPTY_STATE_NAMES = [],
8806
+ BROAD_UPDATE_CATEGORY = UpdateCategory.PAINT | UpdateCategory.SHAPE | UpdateCategory.BOUNDS | UpdateCategory.TRANSFORM | UpdateCategory.LAYOUT;
8824
8807
  function isPlainObjectValue(value) {
8825
- return "object" == typeof value && null != value && !isArray$1(value);
8808
+ return "object" == typeof value && null != value && !Array.isArray(value);
8826
8809
  }
8827
8810
  function cloneAttributeValue(value) {
8828
8811
  if (!isPlainObjectValue(value)) return value;
@@ -8833,12 +8816,6 @@
8833
8816
  clone[key] = isPlainObjectValue(nextValue) ? cloneAttributeValue(nextValue) : nextValue;
8834
8817
  }), clone;
8835
8818
  }
8836
- function cloneSimpleAttributeRecord(value) {
8837
- return isPlainObjectValue(value) ? Object.assign({}, value) : value;
8838
- }
8839
- function shouldUseSimpleAttributeFastPath(value) {
8840
- return !!isPlainObjectValue(value) && !Object.keys(value).some(key => isPlainObjectValue(value[key]));
8841
- }
8842
8819
  function cloneAttributeSurface(value) {
8843
8820
  if (!isPlainObjectValue(value)) return value;
8844
8821
  const source = value,
@@ -8848,6 +8825,9 @@
8848
8825
  clone[key] = isPlainObjectValue(nextValue) ? Object.assign({}, nextValue) : nextValue;
8849
8826
  }), clone;
8850
8827
  }
8828
+ function areAttributeValuesEqual(left, right) {
8829
+ return left === right || !!(isPlainObjectValue(left) || isPlainObjectValue(right) || Array.isArray(left) || Array.isArray(right)) && isEqual(left, right);
8830
+ }
8851
8831
  function deepMergeAttributeValue(base, value) {
8852
8832
  var _a;
8853
8833
  const result = null !== (_a = cloneAttributeValue(base)) && void 0 !== _a ? _a : {};
@@ -8910,18 +8890,24 @@
8910
8890
  get globalTransMatrix() {
8911
8891
  return this.tryUpdateGlobalTransMatrix(!0);
8912
8892
  }
8893
+ get baseAttributes() {
8894
+ var _a;
8895
+ return null !== (_a = this._baseAttributes) && void 0 !== _a ? _a : this.attribute;
8896
+ }
8897
+ set baseAttributes(value) {
8898
+ value !== this.attribute ? this._baseAttributes = value : this._baseAttributes = void 0;
8899
+ }
8913
8900
  constructor(params = {}) {
8914
8901
  var _a;
8915
- super(), this.resolverEpoch = 0, this._AABBBounds = new AABBBounds(), this._updateTag = exports.UpdateTag.INIT;
8916
- const useSimpleAttributeFastPath = shouldUseSimpleAttributeFastPath(params),
8917
- initialBaseAttributes = useSimpleAttributeFastPath ? cloneSimpleAttributeRecord(params) : cloneAttributeValue(params);
8918
- this.baseAttributes = initialBaseAttributes, this.attribute = useSimpleAttributeFastPath ? cloneSimpleAttributeRecord(initialBaseAttributes) : cloneAttributeSurface(initialBaseAttributes), this.valid = this.isValid(), this.updateAABBBoundsStamp = 0, params.background && this.loadImage(null !== (_a = params.background.background) && void 0 !== _a ? _a : params.background, !0), isExternalTexture(params.texture) && this.loadImage(params.texture, !1), params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic);
8902
+ super(), this._AABBBounds = new AABBBounds(), this._updateTag = exports.UpdateTag.INIT, this.attribute = params, this.valid = this.isValid(), this.updateAABBBoundsStamp = 0, params.background && this.loadImage(null !== (_a = params.background.background) && void 0 !== _a ? _a : params.background, !0), params.texture && isExternalTexture(params.texture) && this.loadImage(params.texture, !1), params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic);
8919
8903
  }
8920
8904
  get normalAttrs() {
8921
8905
  return this.baseAttributes;
8922
8906
  }
8923
- set normalAttrs(value) {
8924
- this._deprecatedNormalAttrsView = null != value ? value : void 0;
8907
+ set normalAttrs(_value) {}
8908
+ getBaseAttributesStorage() {
8909
+ var _a;
8910
+ return null !== (_a = this._baseAttributes) && void 0 !== _a ? _a : this.attribute;
8925
8911
  }
8926
8912
  getGraphicService() {
8927
8913
  var _a, _b;
@@ -8952,10 +8938,18 @@
8952
8938
  const nextScope = this.resolveBoundSharedStateScope();
8953
8939
  return this.boundSharedStateScope === nextScope ? (this.syncSharedStateActiveRegistrations(), !1) : (this.boundSharedStateScope = nextScope, this.boundSharedStateRevision = void 0, this.localFallbackCompiledDefinitions = void 0, this.compiledStateDefinitions = void 0, this.compiledStateDefinitionsCacheKey = void 0, this.stateEngine = void 0, this.stateEngineCompiledDefinitions = void 0, this.stateEngineStateProxyModeKey = void 0, this.syncSharedStateActiveRegistrations(), markDirty && (null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) && this.markSharedStateDirty(), !0);
8954
8940
  }
8955
- syncSharedStateActiveRegistrations() {
8941
+ syncSharedStateScopeBindingOnTreeChange(markDirty = !0) {
8956
8942
  var _a, _b;
8957
- const nextScopes = (null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) && this.boundSharedStateScope ? new Set(collectSharedStateScopeChain(this.boundSharedStateScope)) : new Set();
8958
- (null !== (_b = this.registeredActiveScopes) && void 0 !== _b ? _b : new Set()).forEach(scope => {
8943
+ return !!((null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) || this.boundSharedStateScope || (null === (_b = this.registeredActiveScopes) || void 0 === _b ? void 0 : _b.size) || this.sharedStateDirty) && this.syncSharedStateScopeBindingFromTree(markDirty);
8944
+ }
8945
+ syncSharedStateActiveRegistrations() {
8946
+ var _a;
8947
+ const previousScopes = this.registeredActiveScopes;
8948
+ if (!(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) || !this.boundSharedStateScope) return (null == previousScopes ? void 0 : previousScopes.size) && (previousScopes.forEach(scope => {
8949
+ scope.subtreeActiveDescendants.delete(this);
8950
+ }), previousScopes.clear()), void (this.registeredActiveScopes = void 0);
8951
+ const nextScopes = new Set(collectSharedStateScopeChain(this.boundSharedStateScope));
8952
+ null == previousScopes || previousScopes.forEach(scope => {
8959
8953
  nextScopes.has(scope) || scope.subtreeActiveDescendants.delete(this);
8960
8954
  }), nextScopes.forEach(scope => {
8961
8955
  scope.subtreeActiveDescendants.add(this);
@@ -8971,15 +8965,13 @@
8971
8965
  this.sharedStateDirty = !0, enqueueGraphicSharedStateRefresh(this.stage, this), scheduleStageSharedStateRefresh(this.stage);
8972
8966
  }
8973
8967
  onParentSharedStateTreeChanged(stage, layer) {
8974
- this.stage === stage && this.layer === layer ? this.syncSharedStateScopeBindingFromTree() : this.setStage(stage, layer);
8968
+ this.stage === stage && this.layer === layer ? this.syncSharedStateScopeBindingOnTreeChange() : this.setStage(stage, layer);
8975
8969
  }
8976
8970
  refreshSharedStateBeforeRender() {
8977
8971
  var _a;
8978
8972
  (null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) ? (this.syncSharedStateScopeBindingFromTree(!1), this.boundSharedStateScope && ensureSharedStateScopeFresh(this.boundSharedStateScope), this.recomputeCurrentStatePatch(), this.stopStateAnimates(), this._restoreAttributeFromStaticTruth({
8979
8973
  type: exports.AttributeUpdateType.STATE
8980
- }), this._emitCustomEvent("afterStateUpdate", {
8981
- type: exports.AttributeUpdateType.STATE
8982
- }), this.sharedStateDirty = !1) : this.sharedStateDirty = !1;
8974
+ }), this.emitStateUpdateEvent(), this.sharedStateDirty = !1) : this.sharedStateDirty = !1;
8983
8975
  }
8984
8976
  getLocalStatesVersion() {
8985
8977
  var _a, _b;
@@ -9037,7 +9029,7 @@
9037
9029
  const transition = stateModel.useStates(this.currentStates),
9038
9030
  effectiveStates = null !== (_d = transition.effectiveStates) && void 0 !== _d ? _d : transition.states,
9039
9031
  resolvedStateAttrs = this.stateEngine && this.compiledStateDefinitions ? Object.assign({}, this.stateEngine.resolvedPatch) : this.getStateStyleResolver(this.stateMergeMode).resolve(stateResolveBaseAttrs, this.states, this.stateProxy, transition.states, this.stateSort);
9040
- this.currentStates = transition.states, this.effectiveStates = [...effectiveStates], this.resolvedStatePatch = Object.assign({}, resolvedStateAttrs), this.syncSharedStateActiveRegistrations();
9032
+ this.currentStates = transition.states, this.effectiveStates = [...effectiveStates], this.resolvedStatePatch = resolvedStateAttrs, this.syncSharedStateActiveRegistrations();
9041
9033
  }
9042
9034
  buildStaticAttributeSnapshot() {
9043
9035
  var _a;
@@ -9076,16 +9068,17 @@
9076
9068
  next: void 0
9077
9069
  }), delete target[key]));
9078
9070
  const nextValue = snapshot[key];
9079
- isEqual(previousValue, nextValue) || (delta.set(key, {
9071
+ areAttributeValuesEqual(previousValue, nextValue) || (delta.set(key, {
9080
9072
  prev: previousValue,
9081
9073
  next: nextValue
9082
9074
  }), target[key] = cloneAttributeValue(nextValue));
9083
9075
  }), delta;
9084
9076
  }
9085
9077
  _syncAttribute() {
9078
+ this.attribute === this.baseAttributes && this.resolvedStatePatch && this.detachAttributeFromBaseAttributes();
9086
9079
  const snapshot = this.buildStaticAttributeSnapshot(),
9087
9080
  delta = this.syncObjectToSnapshot(this.attribute, snapshot);
9088
- return this.valid = this.isValid(), delta;
9081
+ return this.valid = this.isValid(), this.attributeMayContainTransientAttrs = !1, delta;
9089
9082
  }
9090
9083
  _syncFinalAttributeFromStaticTruth() {
9091
9084
  const target = this.finalAttribute;
@@ -9093,47 +9086,146 @@
9093
9086
  const snapshot = this.buildStaticAttributeSnapshot();
9094
9087
  this.syncObjectToSnapshot(target, snapshot);
9095
9088
  }
9096
- submitUpdateByDelta(delta, forceUpdateTag = !1) {
9089
+ mergeAttributeDeltaCategory(category, key, prev, next) {
9090
+ var _a;
9091
+ let nextCategory = "stroke" === key || "shadowBlur" === key ? classifyAttributeDelta(key, prev, next) : null !== (_a = ATTRIBUTE_CATEGORY[key]) && void 0 !== _a ? _a : UpdateCategory.PAINT;
9092
+ return nextCategory & UpdateCategory.PICK && (nextCategory |= UpdateCategory.BOUNDS), nextCategory === UpdateCategory.PAINT && this.needUpdateTag(key) && (nextCategory = UpdateCategory.SHAPE | UpdateCategory.BOUNDS), category | nextCategory;
9093
+ }
9094
+ submitUpdateByCategory(category, forceUpdateTag = !1) {
9097
9095
  var _a;
9098
9096
  if (forceUpdateTag) return this.addUpdateShapeAndBoundsTag(), this.addUpdatePositionTag(), void this.addUpdateLayoutTag();
9097
+ if (category !== UpdateCategory.NONE) {
9098
+ const stage = this.stage;
9099
+ stage && (null === (_a = getActiveStageStatePerfMonitor(stage)) || void 0 === _a || _a.recordCategory(category));
9100
+ }
9101
+ (category & BROAD_UPDATE_CATEGORY) !== BROAD_UPDATE_CATEGORY ? (category & UpdateCategory.SHAPE ? this.addUpdateShapeAndBoundsTag() : category & UpdateCategory.BOUNDS && this.addUpdateBoundTag(), category & UpdateCategory.PAINT && this.addUpdatePaintTag(), category & UpdateCategory.TRANSFORM && this.addUpdatePositionTag(), category & UpdateCategory.LAYOUT && this.addUpdateLayoutTag()) : this.addBroadUpdateTag();
9102
+ }
9103
+ submitUpdateByDelta(delta, forceUpdateTag = !1) {
9099
9104
  let category = UpdateCategory.NONE;
9100
9105
  delta.forEach((entry, key) => {
9101
- let nextCategory = classifyAttributeDelta(key, entry.prev, entry.next);
9102
- nextCategory & UpdateCategory.PICK && (nextCategory |= UpdateCategory.BOUNDS), nextCategory === UpdateCategory.PAINT && this.needUpdateTag(key) && (nextCategory = UpdateCategory.SHAPE | UpdateCategory.BOUNDS), category |= nextCategory;
9103
- }), category !== UpdateCategory.NONE && (null === (_a = getStageStatePerfMonitor(this.stage)) || void 0 === _a || _a.recordCategory(category)), category & UpdateCategory.SHAPE ? this.addUpdateShapeAndBoundsTag() : category & UpdateCategory.BOUNDS && this.addUpdateBoundTag(), category & UpdateCategory.PAINT && this.addUpdatePaintTag(), category & UpdateCategory.TRANSFORM && this.addUpdatePositionTag(), category & UpdateCategory.LAYOUT && this.addUpdateLayoutTag();
9106
+ category = this.mergeAttributeDeltaCategory(category, key, entry.prev, entry.next);
9107
+ }), this.submitUpdateByCategory(category, forceUpdateTag);
9108
+ }
9109
+ submitTouchedKeyUpdate(keys, forceUpdateTag = !1) {
9110
+ this.submitTouchedUpdate(forceUpdateTag || this.needUpdateTags(keys));
9111
+ }
9112
+ submitTouchedUpdate(needsShapeAndBounds) {
9113
+ !this.updateShapeAndBoundsTagSetted() && needsShapeAndBounds ? this.addUpdateShapeAndBoundsTag() : this.addUpdateBoundTag(), this.addUpdatePositionTag(), this.addUpdateLayoutTag();
9104
9114
  }
9105
9115
  commitBaseAttributeMutation(forceUpdateTag = !1, context) {
9106
- var _a, _b;
9107
- (null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) && (this.resolverEpoch += 1, null === (_b = this.stateEngine) || void 0 === _b || _b.invalidateResolverCache(), this.recomputeCurrentStatePatch());
9116
+ var _a, _b, _c;
9117
+ (null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) && (this.resolverEpoch = (null !== (_b = this.resolverEpoch) && void 0 !== _b ? _b : 0) + 1, null === (_c = this.stateEngine) || void 0 === _c || _c.invalidateResolverCache(), this.recomputeCurrentStatePatch());
9108
9118
  const delta = this._syncAttribute();
9109
9119
  this.submitUpdateByDelta(delta, forceUpdateTag), this.onAttributeUpdate(context);
9110
9120
  }
9121
+ canCommitBaseAttributesByTouchedKeys() {
9122
+ var _a, _b;
9123
+ return !((null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) || this.resolvedStatePatch || this.attributeMayContainTransientAttrs) && (!(null === (_b = this.animates) || void 0 === _b ? void 0 : _b.size) && !this._animationStateManager || !this.hasAnyTrackedAnimate());
9124
+ }
9125
+ detachAttributeFromBaseAttributes() {
9126
+ this.attribute === this.baseAttributes && (this._baseAttributes = this.attribute, this.attribute = cloneAttributeSurface(this.attribute));
9127
+ }
9128
+ commitInternalBaseAttributes(params, context) {
9129
+ params && Object.keys(params).length && (this.canCommitBaseAttributesByTouchedKeys() ? this.commitBaseAttributesByTouchedKeys(params, !1, context) : (this.detachAttributeFromBaseAttributes(), this.applyBaseAttributes(params), this.commitBaseAttributeMutation(!1, context)));
9130
+ }
9131
+ commitBaseAttributesByTouchedKeys(params, forceUpdateTag = !1, context) {
9132
+ const source = params,
9133
+ baseAttributes = this.getBaseAttributesStorage();
9134
+ let hasKeys = !1,
9135
+ needsShapeAndBounds = forceUpdateTag;
9136
+ for (const key in source) Object.prototype.hasOwnProperty.call(source, key) && (hasKeys = !0, baseAttributes[key] = source[key], !needsShapeAndBounds && this.needUpdateTag(key) && (needsShapeAndBounds = !0));
9137
+ hasKeys && (this.attribute = baseAttributes, this._baseAttributes = void 0, this.valid = this.isValid(), this.attributeMayContainTransientAttrs = !1, this.submitTouchedUpdate(needsShapeAndBounds), this.onAttributeUpdate(context));
9138
+ }
9139
+ commitBaseAttributeBySingleKey(key, value, forceUpdateTag = !1, context) {
9140
+ this.getBaseAttributesStorage()[key] = value, this.attribute = this.getBaseAttributesStorage(), this._baseAttributes = void 0, this.valid = this.isValid(), this.attributeMayContainTransientAttrs = !1, this.submitTouchedUpdate(forceUpdateTag || this.needUpdateTag(key)), this.onAttributeUpdate(context);
9141
+ }
9111
9142
  applyBaseAttributes(params) {
9112
9143
  const keys = Object.keys(params);
9113
9144
  for (let i = 0; i < keys.length; i++) {
9114
9145
  const key = keys[i];
9115
- this.baseAttributes[key] = cloneAttributeValue(params[key]);
9146
+ this.getBaseAttributesStorage()[key] = params[key];
9116
9147
  }
9117
9148
  }
9149
+ applyAnimationTransientAttributes(params, forceUpdateTag = !1, context) {
9150
+ const source = params;
9151
+ let target,
9152
+ needsShapeAndBounds = forceUpdateTag;
9153
+ for (const key in source) Object.prototype.hasOwnProperty.call(source, key) && (target || (this.detachAttributeFromBaseAttributes(), target = this.attribute), target[key] = source[key], !needsShapeAndBounds && this.needUpdateTag(key) && (needsShapeAndBounds = !0));
9154
+ target && (this.attributeMayContainTransientAttrs = !0, this.valid = this.isValid(), this.submitTouchedUpdate(needsShapeAndBounds), this.onAttributeUpdate(context));
9155
+ }
9118
9156
  applyTransientAttributes(params, forceUpdateTag = !1, context) {
9157
+ this.detachAttributeFromBaseAttributes();
9119
9158
  const delta = new Map(),
9120
9159
  keys = Object.keys(params);
9121
9160
  for (let i = 0; i < keys.length; i++) {
9122
9161
  const key = keys[i],
9123
9162
  previousValue = this.attribute[key],
9124
9163
  nextValue = params[key];
9125
- isEqual(previousValue, nextValue) || (delta.set(key, {
9164
+ areAttributeValuesEqual(previousValue, nextValue) || (delta.set(key, {
9126
9165
  prev: previousValue,
9127
9166
  next: nextValue
9128
- }), this.attribute[key] = cloneAttributeValue(nextValue));
9167
+ }), this.attribute[key] = nextValue);
9129
9168
  }
9130
- this.valid = this.isValid(), this.submitUpdateByDelta(delta, forceUpdateTag), this.onAttributeUpdate(context);
9169
+ delta.size && (this.attributeMayContainTransientAttrs = !0), this.valid = this.isValid(), this.submitUpdateByDelta(delta, forceUpdateTag), this.onAttributeUpdate(context);
9131
9170
  }
9132
9171
  _restoreAttributeFromStaticTruth(context) {
9133
9172
  this._syncFinalAttributeFromStaticTruth();
9134
9173
  const delta = this._syncAttribute();
9135
9174
  this.submitUpdateByDelta(delta), this.onAttributeUpdate(context);
9136
9175
  }
9176
+ collectStatePatchDeltaKeys(previousPatch, nextPatch) {
9177
+ const keys = previousPatch ? Object.keys(previousPatch) : [];
9178
+ if (!nextPatch) return keys;
9179
+ for (const key in nextPatch) Object.prototype.hasOwnProperty.call(nextPatch, key) && !Object.prototype.hasOwnProperty.call(null != previousPatch ? previousPatch : {}, key) && keys.push(key);
9180
+ return keys;
9181
+ }
9182
+ getStaticTruthValueForStateKey(key, nextPatch) {
9183
+ var _a;
9184
+ const baseAttributes = null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : {},
9185
+ patch = nextPatch;
9186
+ if (patch && Object.prototype.hasOwnProperty.call(patch, key)) {
9187
+ const patchValue = patch[key],
9188
+ baseValue = baseAttributes[key];
9189
+ return "deep" === this.stateMergeMode && isPlainObjectValue(baseValue) && isPlainObjectValue(patchValue) ? {
9190
+ hasValue: !0,
9191
+ value: deepMergeAttributeValue(baseValue, patchValue)
9192
+ } : {
9193
+ hasValue: !0,
9194
+ value: patchValue
9195
+ };
9196
+ }
9197
+ return Object.prototype.hasOwnProperty.call(baseAttributes, key) ? {
9198
+ hasValue: !0,
9199
+ value: baseAttributes[key]
9200
+ } : {
9201
+ hasValue: !1,
9202
+ value: void 0
9203
+ };
9204
+ }
9205
+ syncStatePatchDeltaToTarget(target, keys, nextPatch, collectCategory = !1) {
9206
+ let category = UpdateCategory.NONE;
9207
+ for (let i = 0; i < keys.length; i++) {
9208
+ const key = keys[i],
9209
+ previousValue = target[key],
9210
+ next = this.getStaticTruthValueForStateKey(key, nextPatch);
9211
+ if (!next.hasValue) {
9212
+ Object.prototype.hasOwnProperty.call(target, key) && (delete target[key], collectCategory && (category = this.mergeAttributeDeltaCategory(category, key, previousValue, void 0)));
9213
+ continue;
9214
+ }
9215
+ if (areAttributeValuesEqual(previousValue, next.value)) continue;
9216
+ const nextValue = cloneAttributeValue(next.value);
9217
+ target[key] = nextValue, collectCategory && (category = this.mergeAttributeDeltaCategory(category, key, previousValue, nextValue));
9218
+ }
9219
+ return category;
9220
+ }
9221
+ restoreAttributeFromStatePatchDelta(previousPatch, nextPatch, context) {
9222
+ this.detachAttributeFromBaseAttributes();
9223
+ const keys = this.collectStatePatchDeltaKeys(previousPatch, nextPatch),
9224
+ finalAttribute = this.finalAttribute;
9225
+ finalAttribute && this.syncStatePatchDeltaToTarget(finalAttribute, keys, nextPatch, !1);
9226
+ const category = this.syncStatePatchDeltaToTarget(this.attribute, keys, nextPatch, !0);
9227
+ this.valid = this.isValid(), this.attributeMayContainTransientAttrs = !1, this.submitUpdateByCategory(category), this.onAttributeUpdate(context);
9228
+ }
9137
9229
  setMode(mode) {
9138
9230
  "3d" === mode ? this.set3dMode() : this.set2dMode();
9139
9231
  }
@@ -9156,7 +9248,7 @@
9156
9248
  return point;
9157
9249
  }
9158
9250
  onAnimateBind(animate) {
9159
- this._emitCustomEvent("animate-bind", animate);
9251
+ this.detachAttributeFromBaseAttributes(), this._emitCustomEvent("animate-bind", animate);
9160
9252
  }
9161
9253
  visitTrackedAnimates(cb) {
9162
9254
  const hook = this.forEachTrackedAnimate;
@@ -9169,8 +9261,22 @@
9169
9261
  const getTrackedAnimates = this.getTrackedAnimates;
9170
9262
  return "function" == typeof getTrackedAnimates ? getTrackedAnimates.call(this).size > 0 : !!(null === (_a = this.animates) || void 0 === _a ? void 0 : _a.size);
9171
9263
  }
9264
+ mayHaveTrackedAnimates() {
9265
+ var _a;
9266
+ return !!(null === (_a = this.animates) || void 0 === _a ? void 0 : _a.size) || !!this._animationStateManager;
9267
+ }
9172
9268
  tryUpdateAABBBounds() {
9269
+ if (!(this.shadowRoot || this._updateTag & exports.UpdateTag.UPDATE_BOUNDS)) return this._AABBBounds;
9173
9270
  const full = "imprecise" === this.attribute.boundsMode;
9271
+ if (!this.shadowRoot) {
9272
+ const graphicService = this.getGraphicService(),
9273
+ graphicTheme = this.getGraphicTheme();
9274
+ if (!graphicService.validCheck(this.attribute, graphicTheme, this._AABBBounds, this)) return this._AABBBounds;
9275
+ if (!this.valid) return this._AABBBounds.clear(), this._AABBBounds;
9276
+ graphicService.beforeUpdateAABBBounds(this, this.stage, !0, this._AABBBounds);
9277
+ const bounds = this.doUpdateAABBBounds(full, graphicTheme);
9278
+ return graphicService.afterUpdateAABBBounds(this, this.stage, this._AABBBounds, this, !0), "empty" === this.attribute.boundsMode && bounds.clear(), bounds;
9279
+ }
9174
9280
  if (!this.shouldUpdateAABBBounds()) return this._AABBBounds;
9175
9281
  if (!this.valid) return this._AABBBounds.clear(), this._AABBBounds;
9176
9282
  this.getGraphicService().beforeUpdateAABBBounds(this, this.stage, !0, this._AABBBounds);
@@ -9243,14 +9349,14 @@
9243
9349
  const _parsedPath = new CustomSymbolClass(symbolType, cache);
9244
9350
  return Graphic.userSymbolMap[symbolType] = _parsedPath, _parsedPath;
9245
9351
  }
9246
- doUpdateAABBBounds(full) {
9352
+ doUpdateAABBBounds(full, graphicTheme) {
9247
9353
  this.updateAABBBoundsStamp++;
9248
- const graphicTheme = this.getGraphicTheme();
9354
+ const resolvedGraphicTheme = null != graphicTheme ? graphicTheme : this.getGraphicTheme();
9249
9355
  this._AABBBounds.clear();
9250
9356
  const attribute = this.attribute,
9251
- bounds = this.updateAABBBounds(attribute, graphicTheme, this._AABBBounds, full),
9357
+ bounds = this.updateAABBBounds(attribute, resolvedGraphicTheme, this._AABBBounds, full),
9252
9358
  {
9253
- boundsPadding = graphicTheme.boundsPadding
9359
+ boundsPadding = resolvedGraphicTheme.boundsPadding
9254
9360
  } = attribute,
9255
9361
  paddingArray = parsePadding(boundsPadding);
9256
9362
  return paddingArray && bounds.expand(paddingArray), this.clearUpdateBoundTag(), bounds;
@@ -9359,18 +9465,22 @@
9359
9465
  return fromAttrs;
9360
9466
  }
9361
9467
  setAttributes(params, forceUpdateTag = !1, context) {
9362
- params && ((params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params).background && this.loadImage(params.background, !0), isExternalTexture(params.texture) && this.loadImage(params.texture, !1), params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._setAttributes(params, forceUpdateTag, context));
9468
+ params && ((params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params).background && this.loadImage(params.background, !0), params.texture && isExternalTexture(params.texture) && this.loadImage(params.texture, !1), params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._setAttributes(params, forceUpdateTag, context));
9363
9469
  }
9364
9470
  _setAttributes(params, forceUpdateTag = !1, context) {
9365
- this.applyBaseAttributes(params), this.commitBaseAttributeMutation(forceUpdateTag, context);
9471
+ this.canCommitBaseAttributesByTouchedKeys() ? this.commitBaseAttributesByTouchedKeys(params, forceUpdateTag, context) : (this.detachAttributeFromBaseAttributes(), this.applyBaseAttributes(params), this.commitBaseAttributeMutation(forceUpdateTag, context));
9366
9472
  }
9367
9473
  setAttribute(key, value, forceUpdateTag, context) {
9368
9474
  const params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate({
9369
9475
  [key]: value
9370
9476
  }, this.attribute, key, context);
9371
- params ? this._setAttributes(params, forceUpdateTag, context) : (this.applyBaseAttributes({
9372
- [key]: value
9373
- }), this.commitBaseAttributeMutation(!!forceUpdateTag, context)), "background" === key ? this.loadImage(value, !0) : "texture" === key && isExternalTexture(value) ? this.loadImage(value, !1) : "shadowGraphic" === key && this.setShadowGraphic(value);
9477
+ if (params) this._setAttributes(params, forceUpdateTag, context);else if (this.canCommitBaseAttributesByTouchedKeys()) this.commitBaseAttributeBySingleKey(key, value, !!forceUpdateTag, context);else {
9478
+ const nextAttrs = {
9479
+ [key]: value
9480
+ };
9481
+ this.applyBaseAttributes(nextAttrs), this.commitBaseAttributeMutation(!!forceUpdateTag, context);
9482
+ }
9483
+ "background" === key ? this.loadImage(value, !0) : "texture" === key && isExternalTexture(value) ? this.loadImage(value, !1) : "shadowGraphic" === key && this.setShadowGraphic(value);
9374
9484
  }
9375
9485
  needUpdateTags(keys, k = GRAPHIC_UPDATE_TAG_KEY) {
9376
9486
  for (let i = 0; i < k.length; i++) {
@@ -9389,7 +9499,7 @@
9389
9499
  const context = {
9390
9500
  type: exports.AttributeUpdateType.INIT
9391
9501
  };
9392
- params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params, this.baseAttributes = cloneAttributeValue(params), this.attribute || (this.attribute = {}), this.resolvedStatePatch = void 0, this._syncAttribute(), params.background && this.loadImage(params.background, !0), isExternalTexture(params.texture) && this.loadImage(params.texture, !1), params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._updateTag = exports.UpdateTag.INIT, this.valid = this.isValid(), this.onAttributeUpdate(context);
9502
+ params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params, this.attribute = params, this._baseAttributes = void 0, this.resolvedStatePatch = void 0, this.attributeMayContainTransientAttrs = !1, this.valid = this.isValid(), params.background && this.loadImage(params.background, !0), params.texture && isExternalTexture(params.texture) && this.loadImage(params.texture, !1), params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._updateTag = exports.UpdateTag.INIT, this.valid = this.isValid(), this.onAttributeUpdate(context);
9393
9503
  }
9394
9504
  translate(x, y) {
9395
9505
  var _a, _b;
@@ -9401,10 +9511,15 @@
9401
9511
  x: x,
9402
9512
  y: y
9403
9513
  }, this.attribute, tempConstantXYKey, context);
9404
- params && (x = params.x, y = params.y, delete params.x, delete params.y, this.applyBaseAttributes(params));
9514
+ params && (x = params.x, y = params.y, delete params.x, delete params.y);
9405
9515
  const attribute = this.baseAttributes,
9406
- postMatrix = attribute.postMatrix;
9407
- return postMatrix ? application.transformUtil.fromMatrix(postMatrix, postMatrix).translate(x, y) : (attribute.x = (null !== (_a = attribute.x) && void 0 !== _a ? _a : DefaultTransform.x) + x, attribute.y = (null !== (_b = attribute.y) && void 0 !== _b ? _b : DefaultTransform.y) + y), this.commitBaseAttributeMutation(!1, context), this;
9516
+ postMatrix = attribute.postMatrix,
9517
+ nextAttrs = params || {};
9518
+ if (postMatrix) {
9519
+ const nextPostMatrix = postMatrix.clone();
9520
+ application.transformUtil.fromMatrix(nextPostMatrix, nextPostMatrix).translate(x, y), nextAttrs.postMatrix = nextPostMatrix;
9521
+ } else nextAttrs.x = (null !== (_a = attribute.x) && void 0 !== _a ? _a : DefaultTransform.x) + x, nextAttrs.y = (null !== (_b = attribute.y) && void 0 !== _b ? _b : DefaultTransform.y) + y;
9522
+ return this.commitInternalBaseAttributes(nextAttrs, context), this;
9408
9523
  }
9409
9524
  translateTo(x, y) {
9410
9525
  const attribute = this.baseAttributes;
@@ -9416,7 +9531,10 @@
9416
9531
  x: x,
9417
9532
  y: y
9418
9533
  }, this.attribute, tempConstantXYKey, context);
9419
- return params ? (this.applyBaseAttributes(params), this.commitBaseAttributeMutation(!1, context), this) : (attribute.x = x, attribute.y = y, this.commitBaseAttributeMutation(!1, context), this);
9534
+ return params ? (this.commitInternalBaseAttributes(params, context), this) : (this.commitInternalBaseAttributes({
9535
+ x: x,
9536
+ y: y
9537
+ }, context), this);
9420
9538
  }
9421
9539
  scale(scaleX, scaleY, scaleCenter) {
9422
9540
  var _a, _b;
@@ -9429,15 +9547,16 @@
9429
9547
  scaleY: scaleY,
9430
9548
  scaleCenter: scaleCenter
9431
9549
  }, this.attribute, tempConstantScaleXYKey, context);
9432
- params && (scaleX = params.scaleX, scaleY = params.scaleY, delete params.scaleX, delete params.scaleY, this.applyBaseAttributes(params));
9433
- const attribute = this.baseAttributes;
9550
+ params && (scaleX = params.scaleX, scaleY = params.scaleY, delete params.scaleX, delete params.scaleY);
9551
+ const attribute = this.baseAttributes,
9552
+ nextAttrs = params || {};
9434
9553
  if (scaleCenter) {
9435
9554
  let {
9436
9555
  postMatrix: postMatrix
9437
- } = this.attribute;
9438
- postMatrix || (postMatrix = new Matrix(), attribute.postMatrix = postMatrix), application.transformUtil.fromMatrix(postMatrix, postMatrix).scale(scaleX, scaleY, scaleCenter);
9439
- } else attribute.scaleX = (null !== (_a = attribute.scaleX) && void 0 !== _a ? _a : DefaultTransform.scaleX) * scaleX, attribute.scaleY = (null !== (_b = attribute.scaleY) && void 0 !== _b ? _b : DefaultTransform.scaleY) * scaleY;
9440
- return this.commitBaseAttributeMutation(!1, context), this;
9556
+ } = this.baseAttributes;
9557
+ postMatrix = postMatrix ? postMatrix.clone() : new Matrix(), application.transformUtil.fromMatrix(postMatrix, postMatrix).scale(scaleX, scaleY, scaleCenter), nextAttrs.postMatrix = postMatrix;
9558
+ } else nextAttrs.scaleX = (null !== (_a = attribute.scaleX) && void 0 !== _a ? _a : DefaultTransform.scaleX) * scaleX, nextAttrs.scaleY = (null !== (_b = attribute.scaleY) && void 0 !== _b ? _b : DefaultTransform.scaleY) * scaleY;
9559
+ return this.commitInternalBaseAttributes(nextAttrs, context), this;
9441
9560
  }
9442
9561
  scaleTo(scaleX, scaleY) {
9443
9562
  const attribute = this.baseAttributes;
@@ -9449,7 +9568,10 @@
9449
9568
  scaleX: scaleX,
9450
9569
  scaleY: scaleY
9451
9570
  }, this.attribute, tempConstantScaleXYKey, context);
9452
- return params ? (this.applyBaseAttributes(params), this.commitBaseAttributeMutation(!1, context), this) : (attribute.scaleX = scaleX, attribute.scaleY = scaleY, this.commitBaseAttributeMutation(!1, context), this);
9571
+ return params ? (this.commitInternalBaseAttributes(params, context), this) : (this.commitInternalBaseAttributes({
9572
+ scaleX: scaleX,
9573
+ scaleY: scaleY
9574
+ }, context), this);
9453
9575
  }
9454
9576
  rotate(angle, rotateCenter) {
9455
9577
  var _a;
@@ -9461,24 +9583,26 @@
9461
9583
  angle: angle,
9462
9584
  rotateCenter: rotateCenter
9463
9585
  }, this.attribute, tempConstantAngleKey, context);
9464
- params && (delete params.angle, this.applyBaseAttributes(params));
9465
- const attribute = this.baseAttributes;
9586
+ params && delete params.angle;
9587
+ const attribute = this.baseAttributes,
9588
+ nextAttrs = params || {};
9466
9589
  if (rotateCenter) {
9467
9590
  let {
9468
9591
  postMatrix: postMatrix
9469
9592
  } = this.baseAttributes;
9470
- postMatrix || (postMatrix = new Matrix(), this.baseAttributes.postMatrix = postMatrix), application.transformUtil.fromMatrix(postMatrix, postMatrix).rotate(angle, rotateCenter);
9471
- } else attribute.angle = (null !== (_a = attribute.angle) && void 0 !== _a ? _a : DefaultTransform.angle) + angle;
9472
- return this.commitBaseAttributeMutation(!1, context), this;
9593
+ postMatrix = postMatrix ? postMatrix.clone() : new Matrix(), application.transformUtil.fromMatrix(postMatrix, postMatrix).rotate(angle, rotateCenter), nextAttrs.postMatrix = postMatrix;
9594
+ } else nextAttrs.angle = (null !== (_a = attribute.angle) && void 0 !== _a ? _a : DefaultTransform.angle) + angle;
9595
+ return this.commitInternalBaseAttributes(nextAttrs, context), this;
9473
9596
  }
9474
9597
  rotateTo(angle) {
9475
- const attribute = this.baseAttributes;
9476
- if (attribute.angle === angle) return this;
9598
+ if (this.baseAttributes.angle === angle) return this;
9477
9599
  const context = {
9478
9600
  type: exports.AttributeUpdateType.ROTATE_TO
9479
9601
  },
9480
9602
  params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(angle, this.attribute, tempConstantAngleKey, context);
9481
- return params ? (this.applyBaseAttributes(params), this.commitBaseAttributeMutation(!1, context), this) : (attribute.angle = angle, this.commitBaseAttributeMutation(!1, context), this);
9603
+ return params ? (this.commitInternalBaseAttributes(params, context), this) : (this.commitInternalBaseAttributes({
9604
+ angle: angle
9605
+ }, context), this);
9482
9606
  }
9483
9607
  skewTo(b, c) {
9484
9608
  return this;
@@ -9517,6 +9641,67 @@
9517
9641
  stateEngine: this.stateEngine
9518
9642
  });
9519
9643
  }
9644
+ resolveSimpleLocalStateTransition(states, previousStates) {
9645
+ var _a;
9646
+ if (!this.states || this.stateProxy || this.stateSort || "deep" === this.stateMergeMode || this.parent || (null === (_a = this.stage) || void 0 === _a ? void 0 : _a.rootSharedStateScope) || this.boundSharedStateScope) return null;
9647
+ if (1 === states.length) {
9648
+ const stateName = states[0],
9649
+ hasDefinition = Object.prototype.hasOwnProperty.call(this.states, stateName),
9650
+ nextStates = [stateName],
9651
+ changed = !this.sameStateNames(previousStates, nextStates),
9652
+ resolvedStateAttrs = {};
9653
+ if (hasDefinition) {
9654
+ const attrs = this.states[stateName];
9655
+ if (null != attrs) {
9656
+ if (!isPlainObjectValue(attrs)) return null;
9657
+ const keys = Object.keys(attrs);
9658
+ for (let keyIndex = 0; keyIndex < keys.length; keyIndex++) {
9659
+ const key = keys[keyIndex];
9660
+ if (FULL_STATE_DEFINITION_KEYS.has(key)) return null;
9661
+ const attrValue = attrs[key];
9662
+ resolvedStateAttrs[key] = isPlainObjectValue(attrValue) ? cloneAttributeValue(attrValue) : attrValue;
9663
+ }
9664
+ }
9665
+ }
9666
+ return {
9667
+ changed: changed,
9668
+ states: nextStates,
9669
+ effectiveStates: nextStates,
9670
+ resolvedStateAttrs: resolvedStateAttrs
9671
+ };
9672
+ }
9673
+ const uniqueStates = Array.from(new Set(states)),
9674
+ withDefinition = [],
9675
+ withoutDefinition = [];
9676
+ for (let i = 0; i < uniqueStates.length; i++) {
9677
+ const stateName = uniqueStates[i];
9678
+ Object.prototype.hasOwnProperty.call(this.states, stateName) ? withDefinition.push(stateName) : withoutDefinition.push(stateName);
9679
+ }
9680
+ withDefinition.sort((left, right) => left.localeCompare(right));
9681
+ const nextStates = withDefinition.concat(withoutDefinition),
9682
+ changed = !this.sameStateNames(previousStates, nextStates),
9683
+ resolvedStateAttrs = {};
9684
+ for (let i = 0; i < nextStates.length; i++) {
9685
+ const stateName = nextStates[i];
9686
+ if (!Object.prototype.hasOwnProperty.call(this.states, stateName)) continue;
9687
+ const attrs = this.states[stateName];
9688
+ if (null == attrs) continue;
9689
+ if (!isPlainObjectValue(attrs)) return null;
9690
+ const keys = Object.keys(attrs);
9691
+ for (let keyIndex = 0; keyIndex < keys.length; keyIndex++) {
9692
+ const key = keys[keyIndex];
9693
+ if (FULL_STATE_DEFINITION_KEYS.has(key)) return null;
9694
+ const attrValue = attrs[key];
9695
+ resolvedStateAttrs[key] = isPlainObjectValue(attrValue) ? cloneAttributeValue(attrValue) : attrValue;
9696
+ }
9697
+ }
9698
+ return {
9699
+ changed: changed,
9700
+ states: nextStates,
9701
+ effectiveStates: nextStates,
9702
+ resolvedStateAttrs: resolvedStateAttrs
9703
+ };
9704
+ }
9520
9705
  resolveStateAnimateConfig(animateConfig) {
9521
9706
  var _a, _b, _c;
9522
9707
  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;
@@ -9537,9 +9722,7 @@
9537
9722
  });
9538
9723
  this.getStateTransitionOrchestrator().applyTransition(this, plan, hasAnimation, transitionOptions);
9539
9724
  }
9540
- updateNormalAttrs(stateAttrs) {
9541
- this._deprecatedNormalAttrsView = cloneAttributeValue(this.baseAttributes);
9542
- }
9725
+ updateNormalAttrs(_stateAttrs) {}
9543
9726
  getStateTransitionDefaultAttribute(key, targetAttrs) {
9544
9727
  return this.getDefaultAttribute(key);
9545
9728
  }
@@ -9549,6 +9732,7 @@
9549
9732
  stopStateAnimates(type = "end") {
9550
9733
  const stopAnimationState = this.stopAnimationState;
9551
9734
  if ("function" == typeof stopAnimationState) return void stopAnimationState.call(this, "state", type);
9735
+ if (!this.mayHaveTrackedAnimates()) return;
9552
9736
  const stateAnimates = [];
9553
9737
  this.visitTrackedAnimates(animate => {
9554
9738
  animate.stateNames && stateAnimates.push(animate);
@@ -9561,19 +9745,25 @@
9561
9745
  }
9562
9746
  clearStates(hasAnimation) {
9563
9747
  var _a, _b, _c;
9564
- const previousStates = this.currentStates ? this.currentStates.slice() : [],
9565
- previousResolvedStatePatch = this.resolvedStatePatch ? cloneAttributeValue(this.resolvedStatePatch) : void 0,
9748
+ const previousStates = null !== (_a = this.currentStates) && void 0 !== _a ? _a : EMPTY_STATE_NAMES,
9749
+ previousResolvedStatePatch = this.resolvedStatePatch,
9566
9750
  transition = this.createStateModel().clearStates();
9567
9751
  if (!transition.changed && 0 === previousStates.length) return this.currentStates = [], this.effectiveStates = [], this.resolvedStatePatch = void 0, this.sharedStateDirty = !1, void this.clearSharedStateActiveRegistrations();
9568
- const resolvedStateAttrs = cloneAttributeValue(null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : {});
9569
- transition.changed && !this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !0) || (this.currentStates = transition.states, this.effectiveStates = [], this.resolvedStatePatch = void 0, this.sharedStateDirty = !1, this.clearSharedStateActiveRegistrations(), null === (_b = getStageStatePerfMonitor(this.stage)) || void 0 === _b || _b.incrementCounter("stateCommits"), null === (_c = getStageStatePerfMonitor(this.stage)) || void 0 === _c || _c.recordEvent("state-commit", {
9570
- graphicId: this._uid,
9571
- targetStates: []
9572
- }), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !0, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(), this._restoreAttributeFromStaticTruth({
9573
- type: exports.AttributeUpdateType.STATE
9574
- }), this._emitCustomEvent("afterStateUpdate", {
9575
- type: exports.AttributeUpdateType.STATE
9576
- })));
9752
+ const resolvedStateAttrs = hasAnimation || this.hasCustomEvent("beforeStateUpdate") ? cloneAttributeValue(null !== (_b = this.baseAttributes) && void 0 !== _b ? _b : {}) : null !== (_c = this.baseAttributes) && void 0 !== _c ? _c : {};
9753
+ if (!transition.changed || this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !0)) {
9754
+ if (this.currentStates = transition.states, this.effectiveStates = [], this.resolvedStatePatch = void 0, this.sharedStateDirty = !1, this.clearSharedStateActiveRegistrations(), this.stage) {
9755
+ const perfMonitor = getActiveStageStatePerfMonitor(this.stage);
9756
+ null == perfMonitor || perfMonitor.incrementCounter("stateCommits"), null == perfMonitor || perfMonitor.recordEvent("state-commit", {
9757
+ graphicId: this._uid,
9758
+ targetStates: []
9759
+ });
9760
+ }
9761
+ hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !0, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(), this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
9762
+ type: exports.AttributeUpdateType.STATE
9763
+ }) : this.restoreAttributeFromStatePatchDelta(previousResolvedStatePatch, void 0, {
9764
+ type: exports.AttributeUpdateType.STATE
9765
+ }), this.emitStateUpdateEvent());
9766
+ }
9577
9767
  }
9578
9768
  removeState(stateName, hasAnimation) {
9579
9769
  const transition = this.createStateModel().removeState(stateName);
@@ -9587,39 +9777,58 @@
9587
9777
  const transition = this.createStateModel().addState(stateName, keepCurrentStates);
9588
9778
  transition.changed && this.useStates(transition.states, hasAnimation);
9589
9779
  }
9780
+ setStates(states, hasAnimation) {
9781
+ var _a, _b, _c;
9782
+ const nextStates = (null == states ? void 0 : states.length) ? states : EMPTY_STATE_NAMES,
9783
+ hasCurrentState = !!((null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) || (null === (_b = this.effectiveStates) || void 0 === _b ? void 0 : _b.length) || this.resolvedStatePatch || (null === (_c = this.registeredActiveScopes) || void 0 === _c ? void 0 : _c.size));
9784
+ if (nextStates.length) this.sameStateNames(this.currentStates, nextStates) ? this.sharedStateDirty && this.refreshSharedStateBeforeRender() : this.useStates(nextStates, hasAnimation);else {
9785
+ if (!hasCurrentState && !this.sharedStateDirty) return;
9786
+ this.clearStates(hasAnimation);
9787
+ }
9788
+ }
9590
9789
  useStates(states, hasAnimation) {
9591
- var _a, _b, _c, _d, _e;
9790
+ var _a, _b, _c, _d;
9592
9791
  if (!states.length) return void this.clearStates(hasAnimation);
9593
- const previousStates = this.currentStates ? this.currentStates.slice() : [],
9594
- previousResolvedStatePatch = this.resolvedStatePatch ? cloneAttributeValue(this.resolvedStatePatch) : void 0,
9595
- stateResolveBaseAttrs = null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : this.attribute,
9596
- stateModel = this.createStateModel();
9597
- null === (_b = this.stateEngine) || void 0 === _b || _b.setResolveContext(this, stateResolveBaseAttrs);
9598
- const transition = stateModel.useStates(states);
9599
- if (!transition.changed && this.sameStateNames(previousStates, transition.states)) return;
9600
- const effectiveStates = null !== (_c = transition.effectiveStates) && void 0 !== _c ? _c : transition.states,
9792
+ const previousStates = null !== (_a = this.currentStates) && void 0 !== _a ? _a : EMPTY_STATE_NAMES,
9793
+ previousResolvedStatePatch = this.resolvedStatePatch;
9794
+ let transition = this.resolveSimpleLocalStateTransition(states, previousStates);
9795
+ const isSimpleLocalTransition = !!transition;
9796
+ let resolvedStateAttrs;
9797
+ if (transition) {
9798
+ if (!transition.changed) return;
9799
+ resolvedStateAttrs = transition.resolvedStateAttrs;
9800
+ } else {
9801
+ const stateResolveBaseAttrs = null !== (_b = this.baseAttributes) && void 0 !== _b ? _b : this.attribute,
9802
+ stateModel = this.createStateModel();
9803
+ if (null === (_c = this.stateEngine) || void 0 === _c || _c.setResolveContext(this, stateResolveBaseAttrs), transition = stateModel.useStates(states), !transition.changed && this.sameStateNames(previousStates, transition.states)) return;
9601
9804
  resolvedStateAttrs = this.stateEngine && this.compiledStateDefinitions ? Object.assign({}, this.stateEngine.resolvedPatch) : this.getStateStyleResolver(this.stateMergeMode).resolve(stateResolveBaseAttrs, this.states, this.stateProxy, transition.states, this.stateSort);
9602
- this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !1) && (this.currentStates = transition.states, this.effectiveStates = [...effectiveStates], this.resolvedStatePatch = Object.assign({}, resolvedStateAttrs), this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(), null === (_d = getStageStatePerfMonitor(this.stage)) || void 0 === _d || _d.incrementCounter("stateCommits"), null === (_e = getStageStatePerfMonitor(this.stage)) || void 0 === _e || _e.recordEvent("state-commit", {
9603
- graphicId: this._uid,
9604
- targetStates: [...transition.states]
9605
- }), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !1, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(), this._restoreAttributeFromStaticTruth({
9606
- type: exports.AttributeUpdateType.STATE
9607
- }), this._emitCustomEvent("afterStateUpdate", {
9608
- type: exports.AttributeUpdateType.STATE
9609
- })));
9805
+ }
9806
+ const effectiveStates = null !== (_d = transition.effectiveStates) && void 0 !== _d ? _d : transition.states;
9807
+ if (this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !1)) {
9808
+ if (this.currentStates = transition.states, this.effectiveStates = isSimpleLocalTransition ? effectiveStates : [...effectiveStates], this.resolvedStatePatch = resolvedStateAttrs, this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(), this.stage) {
9809
+ const perfMonitor = getActiveStageStatePerfMonitor(this.stage);
9810
+ null == perfMonitor || perfMonitor.incrementCounter("stateCommits"), null == perfMonitor || perfMonitor.recordEvent("state-commit", {
9811
+ graphicId: this._uid,
9812
+ targetStates: [...transition.states]
9813
+ });
9814
+ }
9815
+ hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !1, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(), this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
9816
+ type: exports.AttributeUpdateType.STATE
9817
+ }) : this.restoreAttributeFromStatePatchDelta(previousResolvedStatePatch, this.resolvedStatePatch, {
9818
+ type: exports.AttributeUpdateType.STATE
9819
+ }), this.emitStateUpdateEvent());
9820
+ }
9610
9821
  }
9611
9822
  invalidateResolver() {
9612
- var _a, _b;
9823
+ var _a, _b, _c;
9613
9824
  if (!this.stateEngine || !(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) || !this.compiledStateDefinitions) return;
9614
9825
  const stateResolveBaseAttrs = null !== (_b = this.baseAttributes) && void 0 !== _b ? _b : this.attribute;
9615
- this.stateEngine.setResolveContext(this, stateResolveBaseAttrs), this.resolverEpoch += 1, this.stateEngine.invalidateResolverCache();
9826
+ this.stateEngine.setResolveContext(this, stateResolveBaseAttrs), this.resolverEpoch = (null !== (_c = this.resolverEpoch) && void 0 !== _c ? _c : 0) + 1, this.stateEngine.invalidateResolverCache();
9616
9827
  const transition = this.stateEngine.applyStates(this.currentStates),
9617
9828
  resolvedStateAttrs = Object.assign({}, this.stateEngine.resolvedPatch);
9618
- this.effectiveStates = [...transition.effectiveStates], this.resolvedStatePatch = Object.assign({}, resolvedStateAttrs), this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(), this.stopStateAnimates(), this._restoreAttributeFromStaticTruth({
9619
- type: exports.AttributeUpdateType.STATE
9620
- }), this._emitCustomEvent("afterStateUpdate", {
9829
+ this.effectiveStates = [...transition.effectiveStates], this.resolvedStatePatch = resolvedStateAttrs, this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(), this.stopStateAnimates(), this._restoreAttributeFromStaticTruth({
9621
9830
  type: exports.AttributeUpdateType.STATE
9622
- });
9831
+ }), this.emitStateUpdateEvent();
9623
9832
  }
9624
9833
  sameStateNames(left, right) {
9625
9834
  const normalizedLeft = null != left ? left : [],
@@ -9640,6 +9849,9 @@
9640
9849
  addUpdateShapeAndBoundsTag() {
9641
9850
  this._updateTag |= exports.UpdateTag.UPDATE_SHAPE_AND_BOUNDS, this.parent && this.parent.addChildUpdateBoundTag(), this.glyphHost && this.glyphHost.addUpdateBoundTag();
9642
9851
  }
9852
+ addBroadUpdateTag() {
9853
+ this.shadowRoot && this.shadowRoot.addUpdateGlobalPositionTag(), this._updateTag |= exports.UpdateTag.UPDATE_SHAPE_AND_BOUNDS | exports.UpdateTag.UPDATE_PAINT | exports.UpdateTag.UPDATE_GLOBAL_LOCAL_MATRIX | exports.UpdateTag.UPDATE_LAYOUT, this.parent && this.parent.addChildUpdateBoundTag(), this.glyphHost && this.glyphHost.addUpdateBoundTag();
9854
+ }
9643
9855
  updateShapeAndBoundsTagSetted() {
9644
9856
  return (this._updateTag & exports.UpdateTag.UPDATE_SHAPE_AND_BOUNDS) === exports.UpdateTag.UPDATE_SHAPE_AND_BOUNDS;
9645
9857
  }
@@ -9727,13 +9939,13 @@
9727
9939
  }
9728
9940
  }
9729
9941
  setStage(stage, layer) {
9730
- var _a, _b, _c, _d, _e, _f, _g, _h;
9942
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
9731
9943
  const graphicService = null !== (_c = null !== (_a = null == stage ? void 0 : stage.graphicService) && void 0 !== _a ? _a : null === (_b = this.stage) || void 0 === _b ? void 0 : _b.graphicService) && void 0 !== _c ? _c : application.graphicService,
9732
9944
  previousStage = this.stage;
9733
9945
  if (this.stage !== stage || this.layer !== layer) {
9734
- if (this.stage = stage, this.layer = layer, this.syncSharedStateScopeBindingFromTree(!!(null === (_d = this.currentStates) || void 0 === _d ? void 0 : _d.length)), this.setStageToShadowRoot(stage, layer), this.hasAnyTrackedAnimate()) {
9735
- const previousTimeline = null === (_e = null == previousStage ? void 0 : previousStage.getTimeline) || void 0 === _e ? void 0 : _e.call(previousStage),
9736
- nextTimeline = null === (_f = null == stage ? void 0 : stage.getTimeline) || void 0 === _f ? void 0 : _f.call(stage),
9946
+ if (this.stage = stage, this.layer = layer, ((null === (_d = this.currentStates) || void 0 === _d ? void 0 : _d.length) || this.boundSharedStateScope || (null === (_e = this.registeredActiveScopes) || void 0 === _e ? void 0 : _e.size) || this.sharedStateDirty) && this.syncSharedStateScopeBindingOnTreeChange(!0), this.setStageToShadowRoot(stage, layer), this.mayHaveTrackedAnimates() && this.hasAnyTrackedAnimate()) {
9947
+ const previousTimeline = null === (_f = null == previousStage ? void 0 : previousStage.getTimeline) || void 0 === _f ? void 0 : _f.call(previousStage),
9948
+ nextTimeline = null === (_g = null == stage ? void 0 : stage.getTimeline) || void 0 === _g ? void 0 : _g.call(stage),
9737
9949
  detachedStageAnimates = [];
9738
9950
  this.visitTrackedAnimates(a => {
9739
9951
  (!!previousTimeline && a.timeline === previousTimeline || a.timeline.isGlobal) && (nextTimeline ? a.timeline !== nextTimeline && (previousTimeline && a.timeline === previousTimeline && previousTimeline.removeAnimate(a, !1), a.setTimeline(nextTimeline), nextTimeline.addAnimate(a)) : previousTimeline && a.timeline === previousTimeline && (previousTimeline.removeAnimate(a, !1), detachedStageAnimates.push(a)));
@@ -9746,9 +9958,13 @@
9746
9958
  type: exports.AttributeUpdateType.ANIMATE_END
9747
9959
  }));
9748
9960
  }
9749
- return this._onSetStage && this._onSetStage(this, stage, layer), void (null === (_g = null == graphicService ? void 0 : graphicService.onSetStage) || void 0 === _g || _g.call(graphicService, this, stage));
9961
+ return this._onSetStage && this._onSetStage(this, stage, layer), void (null === (_h = null == graphicService ? void 0 : graphicService.onSetStage) || void 0 === _h || _h.call(graphicService, this, stage));
9750
9962
  }
9751
- this.syncSharedStateScopeBindingFromTree(!!(null === (_h = this.currentStates) || void 0 === _h ? void 0 : _h.length));
9963
+ ((null === (_j = this.currentStates) || void 0 === _j ? void 0 : _j.length) || this.boundSharedStateScope || (null === (_k = this.registeredActiveScopes) || void 0 === _k ? void 0 : _k.size) || this.sharedStateDirty) && this.syncSharedStateScopeBindingOnTreeChange(!0);
9964
+ }
9965
+ detachStageForRelease() {
9966
+ var _a, _b, _c;
9967
+ (null === (_a = this.registeredActiveScopes) || void 0 === _a ? void 0 : _a.size) && this.clearSharedStateActiveRegistrations(), (this.mayHaveTrackedAnimates() || this.shadowRoot) && this.stopAnimates(), this.boundSharedStateScope = void 0, this.boundSharedStateRevision = void 0, this.localFallbackCompiledDefinitions = void 0, this.compiledStateDefinitions = void 0, this.compiledStateDefinitionsCacheKey = void 0, this.stateEngine = void 0, this.stateEngineCompiledDefinitions = void 0, this.stateEngineStateProxyModeKey = void 0, this.sharedStateDirty = !1, this.stage = null, this.layer = null, this.shadowRoot && (null === (_c = (_b = this.shadowRoot).detachStageForRelease) || void 0 === _c || _c.call(_b));
9752
9968
  }
9753
9969
  setStageToShadowRoot(stage, layer) {
9754
9970
  this.shadowRoot && this.shadowRoot.setStage(stage, layer);
@@ -9815,6 +10031,7 @@
9815
10031
  res && (res.state = "fail", cb && cb());
9816
10032
  }
9817
10033
  _stopAnimates() {
10034
+ if (!this.mayHaveTrackedAnimates()) return;
9818
10035
  const animates = [];
9819
10036
  this.visitTrackedAnimates(animate => {
9820
10037
  animates.push(animate);
@@ -9828,14 +10045,17 @@
9828
10045
  });
9829
10046
  }
9830
10047
  release() {
9831
- var _a, _b, _c;
9832
- this.releaseStatus = "released", this.clearSharedStateActiveRegistrations(), this.stopAnimates();
9833
- const graphicService = null !== (_b = null === (_a = this.stage) || void 0 === _a ? void 0 : _a.graphicService) && void 0 !== _b ? _b : application.graphicService;
9834
- null === (_c = null == graphicService ? void 0 : graphicService.onRelease) || void 0 === _c || _c.call(graphicService, this), super.release();
10048
+ var _a, _b, _c, _d;
10049
+ this.releaseStatus = "released", (null === (_a = this.registeredActiveScopes) || void 0 === _a ? void 0 : _a.size) && this.clearSharedStateActiveRegistrations(), (this.mayHaveTrackedAnimates() || this.shadowRoot) && this.stopAnimates();
10050
+ const graphicService = null !== (_c = null === (_b = this.stage) || void 0 === _b ? void 0 : _b.graphicService) && void 0 !== _c ? _c : application.graphicService;
10051
+ null === (_d = null == graphicService ? void 0 : graphicService.onRelease) || void 0 === _d || _d.call(graphicService, this), super.release();
10052
+ }
10053
+ hasCustomEvent(type) {
10054
+ return !!this._events && type in this._events;
9835
10055
  }
9836
10056
  _dispatchCustomEvent(type, context) {
9837
10057
  var _a, _b;
9838
- if (this._events && type in this._events) {
10058
+ if (this.hasCustomEvent(type)) {
9839
10059
  const changeEvent = new CustomEvent(type, context);
9840
10060
  changeEvent.bubbles = !1;
9841
10061
  const manager = null === (_b = null === (_a = this.stage) || void 0 === _a ? void 0 : _a.eventSystem) || void 0 === _b ? void 0 : _b.manager;
@@ -9844,7 +10064,7 @@
9844
10064
  return !0;
9845
10065
  }
9846
10066
  beforeStateUpdate(attrs, prevStates, nextStates, hasAnimation, isClear) {
9847
- return this._dispatchCustomEvent("beforeStateUpdate", {
10067
+ return !this.hasCustomEvent("beforeStateUpdate") || this._dispatchCustomEvent("beforeStateUpdate", {
9848
10068
  type: exports.AttributeUpdateType.STATE,
9849
10069
  attrs: Object.assign({}, attrs),
9850
10070
  prevStates: prevStates.slice(),
@@ -9853,6 +10073,11 @@
9853
10073
  isClear: !!isClear
9854
10074
  });
9855
10075
  }
10076
+ emitStateUpdateEvent() {
10077
+ this.hasCustomEvent("afterStateUpdate") && this._emitCustomEvent("afterStateUpdate", {
10078
+ type: exports.AttributeUpdateType.STATE
10079
+ });
10080
+ }
9856
10081
  _emitCustomEvent(type, context) {
9857
10082
  this._dispatchCustomEvent(type, context);
9858
10083
  }
@@ -12859,13 +13084,15 @@
12859
13084
  }(exports.GroupUpdateAABBBoundsMode || (exports.GroupUpdateAABBBoundsMode = {}));
12860
13085
  class Group extends Graphic {
12861
13086
  constructor(params) {
12862
- super(params), this.type = "group", this.parent = null, this.isContainer = !0, this.numberType = GROUP_NUMBER_TYPE, this._childUpdateTag = exports.UpdateTag.UPDATE_BOUNDS;
13087
+ super(params), this.type = "group", this.parent = null, this.isContainer = !0, this._hasSharedStateDefinitions = !1, this.numberType = GROUP_NUMBER_TYPE, this._childUpdateTag = exports.UpdateTag.UPDATE_BOUNDS;
12863
13088
  }
12864
13089
  get sharedStateDefinitions() {
12865
13090
  return this._sharedStateDefinitions;
12866
13091
  }
12867
13092
  set sharedStateDefinitions(value) {
12868
- this._sharedStateDefinitions !== value && (this._sharedStateDefinitions = value, this.ensureSharedStateScopeBound(), this.sharedStateScope && (setSharedStateScopeLocalDefinitions(this.sharedStateScope, value), markScopeActiveDescendantsDirty(this.sharedStateScope, this.stage)));
13093
+ if (this._sharedStateDefinitions === value) return;
13094
+ const previousScope = this.sharedStateScope;
13095
+ this._sharedStateDefinitions = value, this._hasSharedStateDefinitions = !!value && Object.keys(value).length > 0, this.ensureSharedStateScopeBound(), this.sharedStateScope && (setSharedStateScopeLocalDefinitions(this.sharedStateScope, value), markScopeActiveDescendantsDirty(this.sharedStateScope, this.stage)), previousScope !== this.sharedStateScope && this.notifyChildrenSharedStateTreeChanged();
12869
13096
  }
12870
13097
  setMode(mode) {
12871
13098
  "3d" === mode ? this.set3dMode() : this.set2dMode();
@@ -12990,9 +13217,10 @@
12990
13217
  insertInto(newNode, idx) {
12991
13218
  return this._updateChildToStage(super.insertInto(newNode, idx));
12992
13219
  }
12993
- removeChild(child) {
13220
+ removeChild(child, highPerformance = !1) {
13221
+ var _a;
12994
13222
  const data = super.removeChild(child);
12995
- return this.getGraphicService().onRemove(child), child.setStage(null, null), this.addUpdateBoundTag(), data;
13223
+ return data ? highPerformance ? (null === (_a = child.detachStageForRelease) || void 0 === _a || _a.call(child), data) : (this.getGraphicService().onRemove(child), child.setStage(null, null), this.addUpdateBoundTag(), data) : data;
12996
13224
  }
12997
13225
  removeAllChild(deep = !1) {
12998
13226
  const children = this.children.slice();
@@ -13004,11 +13232,13 @@
13004
13232
  }
13005
13233
  setStage(stage, layer) {
13006
13234
  var _a, _b, _c, _d, _e, _f;
13007
- const graphicService = null !== (_c = null !== (_a = null == stage ? void 0 : stage.graphicService) && void 0 !== _a ? _a : null === (_b = this.stage) || void 0 === _b ? void 0 : _b.graphicService) && void 0 !== _c ? _c : application.graphicService;
13008
- if (this.stage !== stage) return this.stage = stage, this.layer = layer, this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingFromTree(!!(null === (_d = this.currentStates) || void 0 === _d ? void 0 : _d.length)), this.setStageToShadowRoot(stage, layer), this._onSetStage && this._onSetStage(this, stage, layer), null === (_e = null == graphicService ? void 0 : graphicService.onSetStage) || void 0 === _e || _e.call(graphicService, this, stage), void this.forEachChildren(item => {
13235
+ const graphicService = null !== (_c = null !== (_a = null == stage ? void 0 : stage.graphicService) && void 0 !== _a ? _a : null === (_b = this.stage) || void 0 === _b ? void 0 : _b.graphicService) && void 0 !== _c ? _c : application.graphicService,
13236
+ needsSharedStateTreeSync = this._hasSharedStateDefinitions || this.sharedStateScope || (null === (_d = this.currentStates) || void 0 === _d ? void 0 : _d.length) || this.boundSharedStateScope || (null === (_e = this.registeredActiveScopes) || void 0 === _e ? void 0 : _e.size) || this.sharedStateDirty;
13237
+ if (this.stage !== stage) return this.stage = stage, this.layer = layer, needsSharedStateTreeSync && (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingOnTreeChange(!0)), this.setStageToShadowRoot(stage, layer), this._onSetStage && this._onSetStage(this, stage, layer), null === (_f = null == graphicService ? void 0 : graphicService.onSetStage) || void 0 === _f || _f.call(graphicService, this, stage), void this.forEachChildren(item => {
13009
13238
  item.setStage(stage, this.layer);
13010
13239
  });
13011
- this.layer !== layer && (this.layer = layer), this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingFromTree(!!(null === (_f = this.currentStates) || void 0 === _f ? void 0 : _f.length)), this.forEachChildren(item => {
13240
+ const layerChanged = this.layer !== layer;
13241
+ layerChanged && (this.layer = layer), needsSharedStateTreeSync ? (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingOnTreeChange(!0), this.notifyChildrenSharedStateTreeChanged()) : layerChanged && this.forEachChildren(item => {
13012
13242
  item.onParentSharedStateTreeChanged && item.onParentSharedStateTreeChanged(stage, this.layer);
13013
13243
  });
13014
13244
  }
@@ -13055,15 +13285,29 @@
13055
13285
  g.release(all);
13056
13286
  }), super.release();
13057
13287
  }
13288
+ detachStageForRelease() {
13289
+ super.detachStageForRelease(), this.sharedStateScope = void 0, this.forEachChildren(item => {
13290
+ var _a;
13291
+ null === (_a = item.detachStageForRelease) || void 0 === _a || _a.call(item);
13292
+ });
13293
+ }
13058
13294
  ensureSharedStateScopeBound() {
13059
13295
  var _a, _b, _c;
13296
+ if (!this.hasSharedStateDefinitions()) return void (this.sharedStateScope = void 0);
13060
13297
  const parentScope = null !== (_b = null === (_a = this.parent) || void 0 === _a ? void 0 : _a.sharedStateScope) && void 0 !== _b ? _b : null === (_c = this.stage) || void 0 === _c ? void 0 : _c.rootSharedStateScope;
13061
13298
  this.sharedStateScope ? (this.sharedStateScope.ownerGroup = this, this.sharedStateScope.ownerStage = this.stage, setSharedStateScopeParent(this.sharedStateScope, parentScope), this.sharedStateScope.localStateDefinitions !== this._sharedStateDefinitions && setSharedStateScopeLocalDefinitions(this.sharedStateScope, this._sharedStateDefinitions)) : this.sharedStateScope = createGroupSharedStateScope(this, parentScope, this._sharedStateDefinitions);
13062
13299
  }
13300
+ hasSharedStateDefinitions() {
13301
+ return this._hasSharedStateDefinitions;
13302
+ }
13303
+ notifyChildrenSharedStateTreeChanged() {
13304
+ this.forEachChildren(item => {
13305
+ item.onParentSharedStateTreeChanged && item.onParentSharedStateTreeChanged(this.stage, this.layer);
13306
+ });
13307
+ }
13063
13308
  onParentSharedStateTreeChanged(stage, layer) {
13064
- this.stage === stage && this.layer === layer ? (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingFromTree(), this.forEachChildren(item => {
13065
- item.onParentSharedStateTreeChanged && item.onParentSharedStateTreeChanged(stage, this.layer);
13066
- })) : this.setStage(stage, layer);
13309
+ var _a;
13310
+ this.stage === stage && this.layer === layer ? (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingOnTreeChange(!!(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length)), this.notifyChildrenSharedStateTreeChanged()) : this.setStage(stage, layer);
13067
13311
  }
13068
13312
  }
13069
13313
  Group.NOWORK_ANIMATE_ATTR = NOWORK_ANIMATE_ATTR;
@@ -13411,7 +13655,10 @@
13411
13655
  beforeUpdateAABBBounds: new SyncHook(["graphic", "stage", "willUpdate", "aabbBounds"]),
13412
13656
  afterUpdateAABBBounds: new SyncHook(["graphic", "stage", "aabbBounds", "globalAABBBounds", "selfChange"]),
13413
13657
  clearAABBBounds: new SyncHook(["graphic", "stage", "aabbBounds"])
13414
- }, this.tempAABBBounds1 = new AABBBounds(), this.tempAABBBounds2 = new AABBBounds();
13658
+ }, this.tempAABBBounds1 = new AABBBounds(), this.tempAABBBounds2 = new AABBBounds(), this.tempAABBBoundsResult = {
13659
+ tb1: this.tempAABBBounds1,
13660
+ tb2: this.tempAABBBounds2
13661
+ };
13415
13662
  }
13416
13663
  onAttributeUpdate(graphic) {
13417
13664
  this.hooks.onAttributeUpdate.taps.length && this.hooks.onAttributeUpdate.call(graphic);
@@ -13511,10 +13758,7 @@
13511
13758
  updateTempAABBBounds(aabbBounds) {
13512
13759
  const tb1 = this.tempAABBBounds1,
13513
13760
  tb2 = this.tempAABBBounds2;
13514
- return tb1.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), tb2.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), {
13515
- tb1: tb1,
13516
- tb2: tb2
13517
- };
13761
+ return tb1.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), tb2.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), this.tempAABBBoundsResult;
13518
13762
  }
13519
13763
  }
13520
13764
 
@@ -14856,7 +15100,7 @@
14856
15100
  const globalBounds = new AABBBounds();
14857
15101
  class DirtyBoundsPlugin {
14858
15102
  constructor() {
14859
- this.name = "DirtyBoundsPlugin", this.activeEvent = "onRegister", this._uid = Generator.GenAutoIncrementId(), this.key = this.name + this._uid, this.handlePaintOnlyUpdate = graphic => {
15103
+ this.name = "DirtyBoundsPlugin", this.activeEvent = "onRegister", this._uid = Generator.GenAutoIncrementId(), this.key = this.name + this._uid, this.dirtyBoundsHooksRegistered = !1, this.handlePaintOnlyUpdate = graphic => {
14860
15104
  var _a, _b, _c, _d;
14861
15105
  const stage = this.pluginService.stage;
14862
15106
  if (!stage || stage !== graphic.stage || !stage.renderCount) return;
@@ -14876,12 +15120,13 @@
14876
15120
  owner._AABBBounds && "function" == typeof owner._AABBBounds.empty && !owner._AABBBounds.empty() || "function" != typeof owner.doUpdateAABBBounds || owner.doUpdateAABBBounds("imprecise" === (null === (_a = owner.attribute) || void 0 === _a ? void 0 : _a.boundsMode));
14877
15121
  return owner._globalAABBBounds && "function" == typeof owner._globalAABBBounds.empty && !owner._globalAABBBounds.empty() || "function" != typeof owner.tryUpdateGlobalAABBBounds || owner.tryUpdateGlobalAABBBounds(), null !== (_b = owner._globalAABBBounds) && void 0 !== _b ? _b : owner.globalAABBBounds;
14878
15122
  }
14879
- activate(context) {
14880
- this.pluginService = context, context.stage.hooks.afterRender.tap(this.key, stage => {
14881
- stage && stage === this.pluginService.stage && stage.dirtyBounds.clear();
14882
- });
14883
- const stage = this.pluginService.stage;
14884
- stage && (stage.graphicService.hooks.onAttributeUpdate.tap(this.key, this.handlePaintOnlyUpdate), stage.graphicService.hooks.beforeUpdateAABBBounds.tap(this.key, (graphic, stage, willUpdate, bounds) => {
15123
+ getRemoveDirtyBounds(graphic) {
15124
+ var _a;
15125
+ const cachedBounds = (null !== (_a = graphic.glyphHost) && void 0 !== _a ? _a : graphic)._globalAABBBounds;
15126
+ if (cachedBounds && "function" == typeof cachedBounds.empty && !cachedBounds.empty()) return cachedBounds;
15127
+ }
15128
+ registerDirtyBoundsHooks(stage) {
15129
+ this.dirtyBoundsHooksRegistered || (stage.graphicService.hooks.onAttributeUpdate.tap(this.key, this.handlePaintOnlyUpdate), stage.graphicService.hooks.beforeUpdateAABBBounds.tap(this.key, (graphic, stage, willUpdate, bounds) => {
14885
15130
  graphic.glyphHost && (graphic = graphic.glyphHost), stage && stage === this.pluginService.stage && stage.renderCount && (graphic.isContainer && !graphic.shouldSelfChangeUpdateAABBBounds() || willUpdate && (globalBounds.setValue(bounds.x1, bounds.y1, bounds.x2, bounds.y2), stage.dirty(globalBounds, graphic.parent && graphic.parent.globalTransMatrix)));
14886
15131
  }), stage.graphicService.hooks.afterUpdateAABBBounds.tap(this.key, (graphic, stage, bounds, params, selfChange) => {
14887
15132
  stage && stage === this.pluginService.stage && stage.renderCount && (graphic.isContainer && !selfChange || stage.dirty(params.globalAABBBounds));
@@ -14889,12 +15134,21 @@
14889
15134
  stage && stage === this.pluginService.stage && stage.renderCount && stage && stage.dirty(bounds);
14890
15135
  }), stage.graphicService.hooks.onRemove.tap(this.key, graphic => {
14891
15136
  const stage = graphic.stage;
14892
- stage && stage === this.pluginService.stage && stage.renderCount && stage && stage.dirty(graphic.globalAABBBounds);
14893
- }));
15137
+ if (!stage || stage !== this.pluginService.stage || !stage.renderCount) return;
15138
+ const bounds = this.getRemoveDirtyBounds(graphic);
15139
+ bounds && !bounds.empty() && stage.dirty(bounds);
15140
+ }), this.dirtyBoundsHooksRegistered = !0);
15141
+ }
15142
+ activate(context) {
15143
+ this.pluginService = context, context.stage.hooks.afterRender.tap(this.key, stage => {
15144
+ stage && stage === this.pluginService.stage && (stage.dirtyBounds.clear(), this.registerDirtyBoundsHooks(stage));
15145
+ });
15146
+ const stage = this.pluginService.stage;
15147
+ stage && stage.renderCount && this.registerDirtyBoundsHooks(stage);
14894
15148
  }
14895
15149
  deactivate(context) {
14896
15150
  const stage = this.pluginService.stage;
14897
- stage && (stage.graphicService.hooks.onAttributeUpdate.taps = stage.graphicService.hooks.onAttributeUpdate.taps.filter(item => item.name !== this.key), stage.graphicService.hooks.beforeUpdateAABBBounds.taps = stage.graphicService.hooks.beforeUpdateAABBBounds.taps.filter(item => item.name !== this.key), stage.graphicService.hooks.afterUpdateAABBBounds.taps = stage.graphicService.hooks.afterUpdateAABBBounds.taps.filter(item => item.name !== this.key), stage.graphicService.hooks.clearAABBBounds.taps = stage.graphicService.hooks.clearAABBBounds.taps.filter(item => item.name !== this.key), stage.hooks.afterRender.taps = stage.hooks.afterRender.taps.filter(item => item.name !== this.key), stage.graphicService.hooks.onRemove.taps = stage.graphicService.hooks.onRemove.taps.filter(item => item.name !== this.key));
15151
+ stage && (stage.graphicService.hooks.onAttributeUpdate.taps = stage.graphicService.hooks.onAttributeUpdate.taps.filter(item => item.name !== this.key), this.dirtyBoundsHooksRegistered = !1, stage.graphicService.hooks.beforeUpdateAABBBounds.taps = stage.graphicService.hooks.beforeUpdateAABBBounds.taps.filter(item => item.name !== this.key), stage.graphicService.hooks.afterUpdateAABBBounds.taps = stage.graphicService.hooks.afterUpdateAABBBounds.taps.filter(item => item.name !== this.key), stage.graphicService.hooks.clearAABBBounds.taps = stage.graphicService.hooks.clearAABBBounds.taps.filter(item => item.name !== this.key), stage.hooks.afterRender.taps = stage.hooks.afterRender.taps.filter(item => item.name !== this.key), stage.graphicService.hooks.onRemove.taps = stage.graphicService.hooks.onRemove.taps.filter(item => item.name !== this.key));
14898
15152
  }
14899
15153
  }
14900
15154
 
@@ -15250,7 +15504,7 @@
15250
15504
  ticker.bindStage(this), this._ticker && this._ticker.removeListener("tick", this.afterTickCb), ticker.addTimeline(this.timeline), this._ticker = ticker, this._ticker.on("tick", this.afterTickCb);
15251
15505
  }
15252
15506
  constructor(params = {}, deps = {}) {
15253
- var _a, _b, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
15507
+ var _a, _b, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
15254
15508
  super({}), this.tickedBeforeRender = !0, this._onVisibleChange = visible => {
15255
15509
  if (!(this._skipRender < 0)) if (visible) {
15256
15510
  if (this.dirtyBounds) {
@@ -15260,7 +15514,8 @@
15260
15514
  this._skipRender > 1 && this.renderNextFrame(), this._skipRender = 0;
15261
15515
  } else this._skipRender = 1;
15262
15516
  }, this.beforeRender = stage => {
15263
- flushStageSharedStateRefresh(this), this._beforeRenderList.forEach(cb => cb(stage));
15517
+ const pendingSharedRefresh = this._pendingSharedStateRefreshGraphics;
15518
+ (null == pendingSharedRefresh ? void 0 : pendingSharedRefresh.size) && flushStageSharedStateRefresh(this), this._beforeRenderList.forEach(cb => cb(stage));
15264
15519
  }, this.afterClearScreen = drawParams => {
15265
15520
  this._afterClearScreen && this._afterClearScreen(drawParams);
15266
15521
  }, this.afterClearRect = drawParams => {
@@ -15285,14 +15540,17 @@
15285
15540
  canvas: params.canvas
15286
15541
  }), this.state = "normal", this.renderCount = 0, this.tryInitEventSystem(), this._background = null !== (_w = params.background) && void 0 !== _w ? _w : DefaultConfig.BACKGROUND, this.stage = this, this.appendChild(this.layerService.createLayer(this, {
15287
15542
  main: !0
15288
- })), this.nextFrameRenderLayerSet = new Set(), this.willNextFrameRender = !1, ensureStageStatePerfMonitor(this), this._stateBatchScheduler = new StateBatchScheduler(this, ensureStageStatePerfMonitor(this)), this.rootSharedStateScope = createRootSharedStateScope(this, null === (_x = this.theme) || void 0 === _x ? void 0 : _x.stateDefinitions), this.theme.onStateDefinitionsChange = () => {
15543
+ })), this.nextFrameRenderLayerSet = new Set(), this.willNextFrameRender = !1, this.theme.onStateDefinitionsChange = () => {
15289
15544
  var _a;
15290
- this.rootSharedStateScope && (setRootSharedStateScopeThemeDefinitions(this.rootSharedStateScope, null === (_a = this.theme) || void 0 === _a ? void 0 : _a.stateDefinitions), markScopeActiveDescendantsDirty(this.rootSharedStateScope, this));
15545
+ const definitions = null === (_a = this.theme) || void 0 === _a ? void 0 : _a.stateDefinitions;
15546
+ if (!definitions || !Object.keys(definitions).length) return void (this.rootSharedStateScope && (setRootSharedStateScopeThemeDefinitions(this.rootSharedStateScope, definitions), markScopeActiveDescendantsDirty(this.rootSharedStateScope, this)));
15547
+ const rootScope = this.ensureRootSharedStateScope(definitions);
15548
+ setRootSharedStateScopeThemeDefinitions(rootScope, definitions), markScopeActiveDescendantsDirty(rootScope, this);
15291
15549
  }, this.renderStyle = params.renderStyle, params.autoRender && this.enableAutoRender(), params.autoRefresh && this.enableAutoRefresh(), !1 === params.disableDirtyBounds && this.enableDirtyBounds(), params.enableHtmlAttribute && this.enableHtmlAttribute(params.enableHtmlAttribute), params.ReactDOM && this.enableReactAttribute(params.ReactDOM), params.enableLayout && this.enableLayout(), this.hooks.beforeRender.tap("constructor", this.beforeRender), this.hooks.afterRender.tap("constructor", this.afterRender), params.beforeRender && this._beforeRenderList.push(params.beforeRender), params.afterRender && this._afterRenderList.push(params.afterRender), this.hooks.afterClearScreen.tap("constructor", this.afterClearScreen), this.hooks.afterClearRect.tap("constructor", this.afterClearRect), this._afterClearScreen = params.afterClearScreen, this._afterClearRect = params.afterClearRect, this.supportInteractiveLayer = !1 !== params.interactiveLayer, params.optimize || (params.optimize = {
15292
15550
  tickRenderMode: "effect"
15293
15551
  }), this.optmize(params.optimize), params.background && isString$1(this._background) && this._background.includes("/") && this.setAttributes({
15294
15552
  background: this._background
15295
- }), this.initAnimate(params), this.rafId = null !== (_y = params.rafId) && void 0 !== _y ? _y : Math.floor(6 * Math.random());
15553
+ }), this.initAnimate(params), this.rafId = null !== (_x = params.rafId) && void 0 !== _x ? _x : Math.floor(6 * Math.random());
15296
15554
  }
15297
15555
  initAnimate(params) {
15298
15556
  var _a;
@@ -15552,8 +15810,14 @@
15552
15810
  this._doRenderInThisFrame(), this.willNextFrameRender = !1;
15553
15811
  }));
15554
15812
  }
15813
+ ensureRootSharedStateScope(themeStateDefinitions) {
15814
+ return this.rootSharedStateScope ? (this.rootSharedStateScope.ownerStage = this, this.rootSharedStateScope) : (this.rootSharedStateScope = createRootSharedStateScope(this, themeStateDefinitions), this.rootSharedStateScope);
15815
+ }
15816
+ getStateBatchScheduler() {
15817
+ return this._stateBatchScheduler || (this._stateBatchScheduler = new StateBatchScheduler(this, ensureStageStatePerfMonitor(this))), this._stateBatchScheduler;
15818
+ }
15555
15819
  scheduleStateBatch(graphics, targetStates) {
15556
- this._stateBatchScheduler.schedule(graphics, targetStates);
15820
+ this.getStateBatchScheduler().schedule(graphics, targetStates);
15557
15821
  }
15558
15822
  getStatePerfSnapshot() {
15559
15823
  return ensureStageStatePerfMonitor(this).getSnapshot();
@@ -18054,7 +18318,11 @@
18054
18318
  };
18055
18319
  class BaseRender {
18056
18320
  init(contributions) {
18057
- contributions && (this._renderContribitions = contributions.getContributions()), this._renderContribitions || (this._renderContribitions = []), this.builtinContributions || (this.builtinContributions = []), this.builtinContributions.push(defaultBaseClipRenderBeforeContribution), this.builtinContributions.push(defaultBaseClipRenderAfterContribution), this.builtinContributions.forEach(item => this._renderContribitions.push(item)), this._renderContribitions.length && (this._renderContribitions.sort((a, b) => b.order - a.order), this._beforeRenderContribitions = this._renderContribitions.filter(c => c.time === exports.BaseRenderContributionTime.beforeFillStroke), this._afterRenderContribitions = this._renderContribitions.filter(c => c.time === exports.BaseRenderContributionTime.afterFillStroke));
18321
+ this.builtinContributions || (this.builtinContributions = []), this._renderContribitions = contributions ? contributions.getContributions().slice() : [];
18322
+ const addContribution = item => {
18323
+ this._renderContribitions.includes(item) || this._renderContribitions.push(item);
18324
+ };
18325
+ this.builtinContributions.forEach(addContribution), addContribution(defaultBaseClipRenderBeforeContribution), addContribution(defaultBaseClipRenderAfterContribution), this._renderContribitions.length ? (this._renderContribitions.sort((a, b) => b.order - a.order), this._beforeRenderContribitions = this._renderContribitions.filter(c => c.time === exports.BaseRenderContributionTime.beforeFillStroke), this._afterRenderContribitions = this._renderContribitions.filter(c => c.time === exports.BaseRenderContributionTime.afterFillStroke)) : (this._beforeRenderContribitions = [], this._afterRenderContribitions = []);
18058
18326
  }
18059
18327
  reInit() {
18060
18328
  this.init(this.graphicRenderContributions);
@@ -23103,8 +23371,8 @@
23103
23371
  graphic.glyphHost && (graphic = graphic.glyphHost), stage && stage === this.pluginService.stage && graphic.isContainer && !this.skipBoundsTrigger && _tempBounds.copy(bounds);
23104
23372
  }), stage.graphicService.hooks.afterUpdateAABBBounds.tap(this.key, (graphic, stage, bounds, params, selfChange) => {
23105
23373
  stage && stage === this.pluginService.stage && graphic.isContainer && !this.skipBoundsTrigger && (_tempBounds.equals(bounds) || this.tryLayout(graphic, !1));
23106
- }), stage.graphicService.hooks.onSetStage.tap(this.key, graphic => {
23107
- graphic.glyphHost && (graphic = graphic.glyphHost), this.tryLayout(graphic, !1);
23374
+ }), stage.graphicService.hooks.onSetStage.tap(this.key, (graphic, nextStage) => {
23375
+ nextStage && nextStage === this.pluginService.stage && (graphic.glyphHost && (graphic = graphic.glyphHost), this.tryLayout(graphic, !1));
23108
23376
  }));
23109
23377
  }
23110
23378
  deactivate(context) {
@@ -23667,7 +23935,6 @@
23667
23935
  segments: segments,
23668
23936
  shouldClipImageByLayout: shouldClipImageByLayout,
23669
23937
  shouldUseMat4: shouldUseMat4,
23670
- shouldUseSimpleAttributeFastPath: shouldUseSimpleAttributeFastPath,
23671
23938
  snapLength: snapLength,
23672
23939
  splitArc: splitArc,
23673
23940
  splitArea: splitArea,
@@ -32467,25 +32734,56 @@
32467
32734
  }
32468
32735
 
32469
32736
  const animateUpdateContext = {
32470
- type: exports.AttributeUpdateType.ANIMATE_UPDATE
32471
- };
32737
+ type: exports.AttributeUpdateType.ANIMATE_UPDATE
32738
+ },
32739
+ animateBindContext = {
32740
+ type: exports.AttributeUpdateType.ANIMATE_BIND
32741
+ },
32742
+ animateStartContext = {
32743
+ type: exports.AttributeUpdateType.ANIMATE_START
32744
+ };
32745
+ function getAnimationContext(type) {
32746
+ switch (type) {
32747
+ case exports.AttributeUpdateType.ANIMATE_UPDATE:
32748
+ return animateUpdateContext;
32749
+ case exports.AttributeUpdateType.ANIMATE_BIND:
32750
+ return animateBindContext;
32751
+ case exports.AttributeUpdateType.ANIMATE_START:
32752
+ return animateStartContext;
32753
+ default:
32754
+ return {
32755
+ type: type
32756
+ };
32757
+ }
32758
+ }
32759
+ function prepareAnimationFrameAttribute(target) {
32760
+ const transientTarget = target;
32761
+ return transientTarget.attribute || (transientTarget.attribute = {}), transientTarget.attribute === transientTarget.baseAttributes && "function" == typeof transientTarget.detachAttributeFromBaseAttributes && transientTarget.detachAttributeFromBaseAttributes(), transientTarget.attributeMayContainTransientAttrs = !0, transientTarget.attribute;
32762
+ }
32763
+ function commitAnimationFrameAttribute(target) {
32764
+ var _a, _b;
32765
+ null === (_b = (_a = target).onAttributeUpdate) || void 0 === _b || _b.call(_a, animateUpdateContext);
32766
+ }
32472
32767
  function applyAnimationFrameAttributes(target, attributes) {
32473
- var _a;
32474
32768
  if (!attributes) return;
32475
- const transientTarget = target;
32476
- transientTarget.attribute || (transientTarget.attribute = {});
32477
- const targetAttribute = transientTarget.attribute;
32769
+ const targetAttribute = prepareAnimationFrameAttribute(target);
32478
32770
  for (const key in attributes) Object.prototype.hasOwnProperty.call(attributes, key) && (targetAttribute[key] = attributes[key]);
32479
- null === (_a = transientTarget.onAttributeUpdate) || void 0 === _a || _a.call(transientTarget, animateUpdateContext);
32771
+ commitAnimationFrameAttribute(target);
32772
+ }
32773
+ function applyAnimationFrameNumberAttributes(target, keys, from, to, ratio) {
32774
+ const targetAttribute = prepareAnimationFrameAttribute(target);
32775
+ for (let i = 0; i < keys.length; i++) {
32776
+ const key = keys[i];
32777
+ targetAttribute[key] = from[key] + (to[key] - from[key]) * ratio;
32778
+ }
32779
+ commitAnimationFrameAttribute(target);
32480
32780
  }
32481
32781
  function applyAnimationTransientAttributes(target, attributes, type = exports.AttributeUpdateType.ANIMATE_UPDATE) {
32482
32782
  var _a;
32483
32783
  if (!attributes) return;
32484
- const context = {
32485
- type: type
32486
- },
32784
+ const context = getAnimationContext(type),
32487
32785
  transientTarget = target;
32488
- "function" != typeof transientTarget.applyTransientAttributes ? "function" != typeof transientTarget.setAttributesAndPreventAnimate ? (transientTarget.attribute || (transientTarget.attribute = {}), Object.assign(transientTarget.attribute, attributes), null === (_a = transientTarget.onAttributeUpdate) || void 0 === _a || _a.call(transientTarget, context)) : transientTarget.setAttributesAndPreventAnimate(attributes, !1, context) : transientTarget.applyTransientAttributes(attributes, !1, context);
32786
+ "function" != typeof transientTarget.applyAnimationTransientAttributes ? "function" != typeof transientTarget.applyTransientAttributes ? "function" != typeof transientTarget.setAttributesAndPreventAnimate ? (transientTarget.attribute || (transientTarget.attribute = {}), Object.assign(transientTarget.attribute, attributes), null === (_a = transientTarget.onAttributeUpdate) || void 0 === _a || _a.call(transientTarget, context)) : transientTarget.setAttributesAndPreventAnimate(attributes, !1, context) : transientTarget.applyTransientAttributes(attributes, !1, context) : transientTarget.applyAnimationTransientAttributes(attributes, !1, context);
32489
32787
  }
32490
32788
  function applyAppearStartAttributes(target, attributes) {
32491
32789
  applyAnimationTransientAttributes(target, attributes, exports.AttributeUpdateType.ANIMATE_BIND);
@@ -32882,7 +33180,7 @@
32882
33180
  bind(target) {
32883
33181
  this.target = target;
32884
33182
  const trackerTarget = this.target;
32885
- return "function" == typeof trackerTarget.trackAnimate ? trackerTarget.trackAnimate(this) : (this.target.animates || (this.target.animates = new Map()), this.target.animates.set(this.id, this)), this.onRemove(() => {
33183
+ return "function" == typeof trackerTarget.detachAttributeFromBaseAttributes && trackerTarget.detachAttributeFromBaseAttributes(), "function" == typeof trackerTarget.trackAnimate ? trackerTarget.trackAnimate(this) : (this.target.animates || (this.target.animates = new Map()), this.target.animates.set(this.id, this)), this.onRemove(() => {
32886
33184
  this.stop(), this.__skipRestoreStaticAttributeOnRemove || "function" != typeof trackerTarget.restoreStaticAttribute || trackerTarget.restoreStaticAttribute(), "function" == typeof trackerTarget.untrackAnimate ? trackerTarget.untrackAnimate(this.id) : this.target.animates.delete(this.id);
32887
33185
  }), this.target.onAnimateBind && !this.slience && this.target.onAnimateBind(this), this.target.animationAttribute || (this.target.animationAttribute = {}), this;
32888
33186
  }
@@ -33378,6 +33676,33 @@
33378
33676
  cb();
33379
33677
  });
33380
33678
  }
33679
+ getActiveAttrKeys() {
33680
+ const keys = [];
33681
+ for (let i = 0; i < this._animates.length; i++) {
33682
+ const animate = this._animates[i];
33683
+ if (animate.status === exports.AnimateStatus.END) continue;
33684
+ const endProps = animate.getEndProps();
33685
+ if (endProps) for (const key in endProps) Object.prototype.hasOwnProperty.call(endProps, key) && keys.indexOf(key) < 0 && keys.push(key);
33686
+ }
33687
+ return keys;
33688
+ }
33689
+ hasActiveAttrs() {
33690
+ for (let i = 0; i < this._animates.length; i++) {
33691
+ const animate = this._animates[i];
33692
+ if (animate.status === exports.AnimateStatus.END) continue;
33693
+ const endProps = animate.getEndProps();
33694
+ if (endProps) for (const key in endProps) if (Object.prototype.hasOwnProperty.call(endProps, key)) return !0;
33695
+ }
33696
+ return !1;
33697
+ }
33698
+ preventAttrs(keys) {
33699
+ if (!(null == keys ? void 0 : keys.length)) return this.hasActiveAttrs();
33700
+ for (let i = 0; i < this._animates.length; i++) {
33701
+ const animate = this._animates[i];
33702
+ animate.status !== exports.AnimateStatus.END && animate.preventAttrs(keys);
33703
+ }
33704
+ return this.hasActiveAttrs();
33705
+ }
33381
33706
  _trackAnimation(animate) {
33382
33707
  this._animates.push(animate), this._activeCount++, 1 !== this._activeCount || this._started || (this._started = !0, this.onStart()), animate.onEnd(() => {
33383
33708
  this._activeCount--;
@@ -33683,8 +34008,22 @@
33683
34008
  hasTrackedAnimate() {
33684
34009
  return this.trackedAnimates.size > 0;
33685
34010
  }
34011
+ hasStateInfo(list, target) {
34012
+ for (let i = 0; i < list.length; i++) if (list[i] === target) return !0;
34013
+ return !1;
34014
+ }
34015
+ takeOverUpdateAttrs(nextState, currentStates, shouldStopState) {
34016
+ if (nextState.state !== AnimationStates.UPDATE || !currentStates.length) return;
34017
+ const nextKeys = nextState.executor.getActiveAttrKeys();
34018
+ if (nextKeys.length) for (let i = 0; i < currentStates.length; i++) {
34019
+ const currentState = currentStates[i];
34020
+ currentState.state !== AnimationStates.UPDATE || currentState === nextState || this.hasStateInfo(shouldStopState, currentState) || currentState.executor.preventAttrs(nextKeys) || (currentState.executor.stop(null, !1), shouldStopState.push(currentState));
34021
+ }
34022
+ }
33686
34023
  applyState(nextState, animationConfig, callback) {
34024
+ var _a;
33687
34025
  const registry = AnimationTransitionRegistry.getInstance(),
34026
+ currentStateList = null !== (_a = this.stateList) && void 0 !== _a ? _a : [],
33688
34027
  shouldStopState = [],
33689
34028
  shouldApplyState = [];
33690
34029
  if (this.stateList && this.stateList.length ? nextState.forEach((state, index) => {
@@ -33692,14 +34031,14 @@
33692
34031
  allowTransition: !0,
33693
34032
  stopOriginalTransition: !0
33694
34033
  };
33695
- this.stateList.forEach(currState => {
34034
+ currentStateList.forEach(currState => {
33696
34035
  const _result = registry.isTransitionAllowed(currState.state, state, this.graphic);
33697
34036
  result.allowTransition = result.allowTransition && _result.allowTransition;
33698
34037
  }), result.allowTransition && (shouldApplyState.push({
33699
34038
  state: state,
33700
34039
  animationConfig: isArray$1(animationConfig[index]) ? animationConfig[index].map(item => item.animation) : animationConfig[index].animation,
33701
34040
  executor: new AnimateExecutor(this.graphic)
33702
- }), this.stateList.forEach(currState => {
34041
+ }), currentStateList.forEach(currState => {
33703
34042
  registry.isTransitionAllowed(currState.state, state, this.graphic).stopOriginalTransition && shouldStopState.push(currState);
33704
34043
  }));
33705
34044
  }) : nextState.forEach((state, index) => {
@@ -33711,12 +34050,18 @@
33711
34050
  }), shouldStopState.forEach(state => {
33712
34051
  state.executor.stop(null, !1);
33713
34052
  }), shouldApplyState.length) {
33714
- shouldApplyState[0].executor.execute(shouldApplyState[0].animationConfig);
34053
+ shouldApplyState[0].executor.execute(shouldApplyState[0].animationConfig), this.takeOverUpdateAttrs(shouldApplyState[0], currentStateList, shouldStopState);
33715
34054
  for (let i = 0; i < shouldApplyState.length; i++) {
33716
34055
  const nextState = shouldApplyState[i + 1],
33717
34056
  currentState = shouldApplyState[i];
33718
34057
  currentState.executor.onEnd(() => {
33719
- nextState && nextState.executor.execute(nextState.animationConfig), this.stateList = this.stateList.filter(state => state !== currentState), i === shouldApplyState.length - 1 && callback && callback(!1);
34058
+ var _a;
34059
+ if (nextState) {
34060
+ nextState.executor.execute(nextState.animationConfig);
34061
+ const stoppedStates = [];
34062
+ this.takeOverUpdateAttrs(nextState, null !== (_a = this.stateList) && void 0 !== _a ? _a : [], stoppedStates), stoppedStates.length && this.stateList && (this.stateList = this.stateList.filter(state => !this.hasStateInfo(stoppedStates, state)));
34063
+ }
34064
+ this.stateList = this.stateList.filter(state => state !== currentState), i === shouldApplyState.length - 1 && callback && callback(!1);
33720
34065
  });
33721
34066
  }
33722
34067
  } else callback && callback(!0);
@@ -35214,10 +35559,7 @@
35214
35559
  super.onEnd(cb);
35215
35560
  }
35216
35561
  onUpdate(end, ratio, out) {
35217
- const attrs = {};
35218
- this.propKeys.forEach(key => {
35219
- attrs[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
35220
- }), applyAnimationFrameAttributes(this.target, attrs), this.target.addUpdatePositionTag(), this.target.addUpdateShapeAndBoundsTag();
35562
+ applyAnimationFrameNumberAttributes(this.target, this.propKeys, this.from, this.to, ratio), this.target.addUpdatePositionTag(), this.target.addUpdateShapeAndBoundsTag();
35221
35563
  }
35222
35564
  }
35223
35565
  function growHeightOutIndividual(graphic, options, animationParameters) {
@@ -35275,10 +35617,7 @@
35275
35617
  super.onEnd(cb);
35276
35618
  }
35277
35619
  onUpdate(end, ratio, out) {
35278
- const attrs = {};
35279
- this.propKeys.forEach(key => {
35280
- attrs[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
35281
- }), applyAnimationFrameAttributes(this.target, attrs), this.target.addUpdatePositionTag(), this.target.addUpdateShapeAndBoundsTag();
35620
+ applyAnimationFrameNumberAttributes(this.target, this.propKeys, this.from, this.to, ratio), this.target.addUpdatePositionTag(), this.target.addUpdateShapeAndBoundsTag();
35282
35621
  }
35283
35622
  }
35284
35623
 
@@ -35688,10 +36027,7 @@
35688
36027
  super.onEnd(cb);
35689
36028
  }
35690
36029
  onUpdate(end, ratio, out) {
35691
- const attrs = {};
35692
- this.propKeys.forEach(key => {
35693
- attrs[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
35694
- }), applyAnimationFrameAttributes(this.target, attrs), this.target.addUpdatePositionTag(), this.target.addUpdateShapeAndBoundsTag();
36030
+ applyAnimationFrameNumberAttributes(this.target, this.propKeys, this.from, this.to, ratio), this.target.addUpdatePositionTag(), this.target.addUpdateShapeAndBoundsTag();
35695
36031
  }
35696
36032
  }
35697
36033
  class GrowWidthOut extends ACustomAnimate {
@@ -35711,10 +36047,7 @@
35711
36047
  super.onEnd(cb);
35712
36048
  }
35713
36049
  onUpdate(end, ratio, out) {
35714
- const attrs = {};
35715
- this.propKeys.forEach(key => {
35716
- attrs[key] = this.from[key] + (this.to[key] - this.from[key]) * ratio;
35717
- }), applyAnimationFrameAttributes(this.target, attrs), this.target.addUpdatePositionTag(), this.target.addUpdateShapeAndBoundsTag();
36050
+ applyAnimationFrameNumberAttributes(this.target, this.propKeys, this.from, this.to, ratio), this.target.addUpdatePositionTag(), this.target.addUpdateShapeAndBoundsTag();
35718
36051
  }
35719
36052
  }
35720
36053
 
@@ -41086,6 +41419,33 @@
41086
41419
  });
41087
41420
  }
41088
41421
 
41422
+ function collectTrackedAnimates(graphic, animates = [], visited = new Set()) {
41423
+ var _a, _b, _c, _d, _e;
41424
+ const trackedAnimates = null !== (_c = null === (_b = (_a = graphic).getTrackedAnimates) || void 0 === _b ? void 0 : _b.call(_a)) && void 0 !== _c ? _c : graphic.animates;
41425
+ return null == trackedAnimates || trackedAnimates.forEach(animate => {
41426
+ animate && !visited.has(animate) && (visited.add(animate), animates.push(animate));
41427
+ }), null === (_e = (_d = graphic).forEachChildren) || void 0 === _e || _e.call(_d, child => {
41428
+ collectTrackedAnimates(child, animates, visited);
41429
+ }), animates;
41430
+ }
41431
+ function appendExitReleaseCallback(state, callback) {
41432
+ callback && (null == state || state.onComplete.push(callback));
41433
+ }
41434
+ function runExitReleaseCallbacks(callbacks) {
41435
+ callbacks.forEach(callback => {
41436
+ callback();
41437
+ });
41438
+ }
41439
+ function bindExitReleaseAnimates(exitAnimates, getState, finalize) {
41440
+ const finish = animate => {
41441
+ const state = getState();
41442
+ state && !state.finalized && state.pendingAnimates.has(animate) && (state.pendingAnimates.delete(animate), state.pendingAnimates.size || finalize());
41443
+ };
41444
+ exitAnimates.forEach(animate => {
41445
+ animate.onEnd(() => finish(animate)), animate.onRemove(() => finish(animate));
41446
+ });
41447
+ }
41448
+
41089
41449
  const DefaultAxisAnimation = {
41090
41450
  type: "default",
41091
41451
  duration: 300,
@@ -41117,12 +41477,65 @@
41117
41477
  });
41118
41478
  return this.add(offscreenGroup), this._renderInner(offscreenGroup), this.removeChild(offscreenGroup), this.attribute = currentAttribute, offscreenGroup.AABBBounds;
41119
41479
  }
41480
+ _finalizeExitRelease() {
41481
+ var _a, _b;
41482
+ const state = this._exitReleaseState;
41483
+ if (null == state ? void 0 : state.finalized) return;
41484
+ state && (state.finalized = !0);
41485
+ const parent = this.parent,
41486
+ removeFromParent = !!(null == state ? void 0 : state.removeFromParent),
41487
+ callbacks = null !== (_a = null == state ? void 0 : state.onComplete) && void 0 !== _a ? _a : [];
41488
+ this._exitReleaseState = void 0, this._prevInnerView = null, this._innerView = null, this.axisLabelsContainer = null, this.axisContainer = null, this.removeAllChild(!0), super.release(!0), removeFromParent && (null === (_b = null != parent ? parent : this.parent) || void 0 === _b || _b.removeChild(this)), runExitReleaseCallbacks(callbacks);
41489
+ }
41490
+ _runExitAnimationBeforeRelease(options = {}) {
41491
+ var _a, _b, _c;
41492
+ if (this._exitReleaseState && !this._exitReleaseState.finalized) return this._exitReleaseState.removeFromParent = this._exitReleaseState.removeFromParent || !!options.removeFromParent, appendExitReleaseCallback(this._exitReleaseState, options.onComplete), !0;
41493
+ if (!this.stage || !1 === this.attribute.animation || !1 === this.attribute.animationExit || !this._innerView) return !1;
41494
+ if (this._prepare(), !(null === (_a = this._animationConfig) || void 0 === _a ? void 0 : _a.exit)) return !1;
41495
+ const exitTargets = new Set();
41496
+ if (traverseGroup(this._innerView, el => {
41497
+ "group" !== el.type && exitTargets.add(el);
41498
+ }), !exitTargets.size) return !1;
41499
+ const existingAnimates = collectTrackedAnimates(this),
41500
+ {
41501
+ delay = 0,
41502
+ duration = DefaultAxisAnimation.duration,
41503
+ easing = DefaultAxisAnimation.easing
41504
+ } = this._animationConfig.exit;
41505
+ exitTargets.forEach(target => {
41506
+ var _a, _b, _c;
41507
+ const startAttrs = {
41508
+ opacity: null !== (_a = target.attribute.opacity) && void 0 !== _a ? _a : 1,
41509
+ fillOpacity: null !== (_b = target.attribute.fillOpacity) && void 0 !== _b ? _b : 1,
41510
+ strokeOpacity: null !== (_c = target.attribute.strokeOpacity) && void 0 !== _c ? _c : 1
41511
+ },
41512
+ endAttrs = {
41513
+ opacity: 0,
41514
+ fillOpacity: 0,
41515
+ strokeOpacity: 0
41516
+ };
41517
+ commitUpdateAnimationTarget(target, endAttrs, startAttrs), target.animate().wait(delay).to(endAttrs, duration, easing);
41518
+ });
41519
+ const exitAnimates = collectTrackedAnimates(this).filter(animate => !existingAnimates.includes(animate));
41520
+ if (!exitAnimates.length) return !1;
41521
+ this.setAttribute("childrenPickable", !1), null === (_c = (_b = this._innerView).removeAllEventListeners) || void 0 === _c || _c.call(_b), this.releaseStatus = "willRelease";
41522
+ const pendingAnimates = new Set(exitAnimates);
41523
+ return this._exitReleaseState = {
41524
+ pendingAnimates: pendingAnimates,
41525
+ finalized: !1,
41526
+ removeFromParent: !!options.removeFromParent,
41527
+ onComplete: options.onComplete ? [options.onComplete] : []
41528
+ }, bindExitReleaseAnimates(exitAnimates, () => this._exitReleaseState, () => this._finalizeExitRelease()), !0;
41529
+ }
41530
+ releaseWithExitAnimation(options = {}) {
41531
+ return "released" !== this.releaseStatus && this._runExitAnimationBeforeRelease(options);
41532
+ }
41120
41533
  render() {
41121
- this._prepare(), this._prevInnerView = this._innerView && getElMap(this._innerView), this.removeAllChild(!0), this._innerView = graphicCreator.group({
41534
+ this._exitReleaseState || (this._prepare(), this._prevInnerView = this._innerView && getElMap(this._innerView), this.removeAllChild(!0), this._innerView = graphicCreator.group({
41122
41535
  x: 0,
41123
41536
  y: 0,
41124
41537
  pickable: !1
41125
- }), this.add(this._innerView), this._renderInner(this._innerView), this._bindEvent(), this.runAnimation();
41538
+ }), this.add(this._innerView), this._renderInner(this._innerView), this._bindEvent(), this.runAnimation());
41126
41539
  }
41127
41540
  _prepare() {
41128
41541
  this._prepareAnimate(DefaultAxisAnimation);
@@ -41454,8 +41867,8 @@
41454
41867
  });
41455
41868
  }
41456
41869
  }
41457
- release() {
41458
- super.release(), this._prevInnerView = null, this._innerView = null;
41870
+ release(all) {
41871
+ this._exitReleaseState ? this._finalizeExitRelease() : (all && this.removeAllChild(!0), super.release(all), all && this.removeAllChild(!0), this._prevInnerView = null, this._innerView = null);
41459
41872
  }
41460
41873
  }
41461
41874
 
@@ -42370,8 +42783,8 @@
42370
42783
  const orient = this.attribute.orient;
42371
42784
  return "left" === orient || "right" === orient ? this.attribute.width ? this.attribute.width : (this.attribute.maxWidth && (offset = Math.min(offset, this.attribute.maxWidth)), this.attribute.minWidth && (offset = Math.max(offset, this.attribute.minWidth)), offset) : offset;
42372
42785
  }
42373
- release() {
42374
- super.release(), this._breaks = null;
42786
+ release(all) {
42787
+ super.release(all), this._breaks = null;
42375
42788
  }
42376
42789
  }
42377
42790
  LineAxis.defaultAttributes = DEFAULT_AXIS_THEME, mixin(LineAxis, LineAxisMixin);
@@ -44343,6 +44756,14 @@
44343
44756
  }
44344
44757
  return t;
44345
44758
  };
44759
+ function cloneAttributeSnapshot(value) {
44760
+ if (!isObject$1(value) || isArray$1(value)) return value;
44761
+ const snapshot = {};
44762
+ return Object.keys(value).forEach(key => {
44763
+ const nextValue = value[key];
44764
+ snapshot[key] = isObject$1(nextValue) && !isArray$1(nextValue) ? cloneAttributeSnapshot(nextValue) : nextValue;
44765
+ }), snapshot;
44766
+ }
44346
44767
  loadLabelComponent();
44347
44768
  class LabelBase extends AnimateComponent {
44348
44769
  setBitmap(bitmap) {
@@ -44407,11 +44828,56 @@
44407
44828
  return baseMark && baseMark.getAttributes(!0).fill && lineGraphic.setAttribute("stroke", baseMark.getAttributes(!0).fill), this.attribute.line && !isEmpty(this.attribute.line.style) && lineGraphic.setAttributes(this.attribute.line.style), this._setStatesOfLabelLine(lineGraphic), lineGraphic;
44408
44829
  }
44409
44830
  }
44831
+ _finalizeExitRelease() {
44832
+ var _a, _b, _c, _d;
44833
+ const state = this._exitReleaseState;
44834
+ if (null == state ? void 0 : state.finalized) return;
44835
+ state && (state.finalized = !0);
44836
+ const parent = this.parent,
44837
+ removeFromParent = !!(null == state ? void 0 : state.removeFromParent),
44838
+ callbacks = null !== (_a = null == state ? void 0 : state.onComplete) && void 0 !== _a ? _a : [];
44839
+ this._exitReleaseState = void 0, this._graphicToText = new Map(), null === (_b = this._idToGraphic) || void 0 === _b || _b.clear(), null === (_c = this._idToPoint) || void 0 === _c || _c.clear(), this._baseMarks = void 0, this.removeAllChild(!0), super.release(!0), removeFromParent && (null === (_d = null != parent ? parent : this.parent) || void 0 === _d || _d.removeChild(this)), runExitReleaseCallbacks(callbacks);
44840
+ }
44841
+ _runExitAnimationBeforeRelease(options = {}) {
44842
+ var _a, _b;
44843
+ if (this._exitReleaseState && !this._exitReleaseState.finalized) return this._exitReleaseState.removeFromParent = this._exitReleaseState.removeFromParent || !!options.removeFromParent, appendExitReleaseCallback(this._exitReleaseState, options.onComplete), !0;
44844
+ if (!this.stage || !1 === this.attribute.animation || !1 === this.attribute.animationExit || !(null === (_a = this._graphicToText) || void 0 === _a ? void 0 : _a.size)) return !1;
44845
+ if (this._prepareAnimate(DefaultLabelAnimation), !(null === (_b = this._animationConfig) || void 0 === _b ? void 0 : _b.exit)) return !1;
44846
+ const exitTargets = new Set();
44847
+ if (this._graphicToText.forEach(label => {
44848
+ (null == label ? void 0 : label.text) && exitTargets.add(label.text), (null == label ? void 0 : label.labelLine) && exitTargets.add(label.labelLine);
44849
+ }), !exitTargets.size) return !1;
44850
+ const existingAnimates = collectTrackedAnimates(this);
44851
+ exitTargets.forEach(target => {
44852
+ var _a;
44853
+ target.applyAnimationState(["exit"], [{
44854
+ name: "exit",
44855
+ animation: Object.assign(Object.assign({}, this._animationConfig.exit), {
44856
+ type: null !== (_a = this._animationConfig.exit.type) && void 0 !== _a ? _a : "fadeOut",
44857
+ selfOnly: !0
44858
+ })
44859
+ }]);
44860
+ });
44861
+ const exitAnimates = collectTrackedAnimates(this).filter(animate => !existingAnimates.includes(animate));
44862
+ if (!exitAnimates.length) return !1;
44863
+ this.setAttribute("childrenPickable", !1), this.releaseStatus = "willRelease";
44864
+ const pendingAnimates = new Set(exitAnimates);
44865
+ return this._exitReleaseState = {
44866
+ pendingAnimates: pendingAnimates,
44867
+ finalized: !1,
44868
+ removeFromParent: !!options.removeFromParent,
44869
+ onComplete: options.onComplete ? [options.onComplete] : []
44870
+ }, bindExitReleaseAnimates(exitAnimates, () => this._exitReleaseState, () => this._finalizeExitRelease()), !0;
44871
+ }
44872
+ releaseWithExitAnimation(options = {}) {
44873
+ return "released" !== this.releaseStatus && this._runExitAnimationBeforeRelease(options);
44874
+ }
44410
44875
  render() {
44876
+ if (this._exitReleaseState) return;
44411
44877
  if (this._prepare(), isNil$1(this._idToGraphic) || this._isCollectionBase && isNil$1(this._idToPoint)) return;
44412
44878
  const markAttributeList = [];
44413
44879
  !1 !== this._enableAnimation && this._baseMarks.forEach(mark => {
44414
- markAttributeList.push(mark.attribute), mark.initAttributes(mark.getAttributes(!0));
44880
+ markAttributeList.push(cloneAttributeSnapshot(mark.attribute)), mark.initAttributes(mark.getAttributes(!0));
44415
44881
  });
44416
44882
  const {
44417
44883
  overlap: overlap,
@@ -44977,6 +45443,10 @@
44977
45443
  _canPlaceInside(textBound, shapeBound) {
44978
45444
  return !(!textBound || !shapeBound) && shapeBound.encloses(textBound);
44979
45445
  }
45446
+ release(all) {
45447
+ var _a, _b;
45448
+ this._exitReleaseState ? this._finalizeExitRelease() : (all && this.removeAllChild(!0), super.release(all), this._graphicToText = new Map(), null === (_a = this._idToGraphic) || void 0 === _a || _a.clear(), null === (_b = this._idToPoint) || void 0 === _b || _b.clear(), this._baseMarks = void 0);
45449
+ }
44980
45450
  setLocation(point) {
44981
45451
  this.translateTo(point.x, point.y);
44982
45452
  }
@@ -45746,6 +46216,7 @@
45746
46216
  }
45747
46217
  render() {
45748
46218
  var _a;
46219
+ if (this._exitReleaseState) return;
45749
46220
  const {
45750
46221
  dataLabels: dataLabels,
45751
46222
  size: size
@@ -45780,6 +46251,47 @@
45780
46251
  currentComponentMap.get(key) || this.removeChild(cp);
45781
46252
  }), this._componentMap = currentComponentMap;
45782
46253
  }
46254
+ _finalizeExitRelease() {
46255
+ var _a, _b, _c;
46256
+ const state = this._exitReleaseState;
46257
+ if (null == state ? void 0 : state.finalized) return;
46258
+ state && (state.finalized = !0);
46259
+ const parent = this.parent,
46260
+ removeFromParent = !!(null == state ? void 0 : state.removeFromParent),
46261
+ callbacks = null !== (_a = null == state ? void 0 : state.onComplete) && void 0 !== _a ? _a : [];
46262
+ this._exitReleaseState = void 0, null === (_b = this._componentMap) || void 0 === _b || _b.clear(), this.removeAllChild(!0), super.release(!0), removeFromParent && (null === (_c = null != parent ? parent : this.parent) || void 0 === _c || _c.removeChild(this)), runExitReleaseCallbacks(callbacks);
46263
+ }
46264
+ releaseWithExitAnimation(options = {}) {
46265
+ var _a;
46266
+ if ("released" === this.releaseStatus) return !1;
46267
+ if (this._exitReleaseState && !this._exitReleaseState.finalized) return this._exitReleaseState.removeFromParent = this._exitReleaseState.removeFromParent || !!options.removeFromParent, appendExitReleaseCallback(this._exitReleaseState, options.onComplete), !0;
46268
+ if (!this.stage || !(null === (_a = this._componentMap) || void 0 === _a ? void 0 : _a.size)) return !1;
46269
+ const state = {
46270
+ pendingCount: 0,
46271
+ finalized: !1,
46272
+ removeFromParent: !!options.removeFromParent,
46273
+ onComplete: options.onComplete ? [options.onComplete] : []
46274
+ },
46275
+ exitingComponents = [],
46276
+ fallbackComponents = [];
46277
+ let initializing = !0;
46278
+ const finish = () => {
46279
+ state.finalized || (state.pendingCount -= 1, state.pendingCount <= 0 && !initializing && this._finalizeExitRelease());
46280
+ };
46281
+ return this._exitReleaseState = state, this._componentMap.forEach(component => {
46282
+ state.pendingCount += 1;
46283
+ component.releaseWithExitAnimation({
46284
+ removeFromParent: !1,
46285
+ onComplete: finish
46286
+ }) ? exitingComponents.push(component) : (state.pendingCount -= 1, fallbackComponents.push(component));
46287
+ }), exitingComponents.length ? (fallbackComponents.forEach(component => {
46288
+ component.release(!0), this.removeChild(component);
46289
+ }), this.setAttribute("childrenPickable", !1), this.releaseStatus = "willRelease", initializing = !1, state.pendingCount <= 0 && this._finalizeExitRelease(), !0) : (this._exitReleaseState = void 0, !1);
46290
+ }
46291
+ release(all) {
46292
+ var _a;
46293
+ this._exitReleaseState ? this._finalizeExitRelease() : (all && this.removeAllChild(!0), super.release(all), null === (_a = this._componentMap) || void 0 === _a || _a.clear());
46294
+ }
45783
46295
  setLocation(point) {
45784
46296
  this.translateTo(point.x, point.y);
45785
46297
  }
@@ -47413,14 +47925,51 @@
47413
47925
  y: clipInRange ? -(null !== (_b = limitRect.y) && void 0 !== _b ? _b : 0) : 0
47414
47926
  });
47415
47927
  }
47416
- render() {
47928
+ _finalizeExitRelease() {
47929
+ var _a, _b;
47930
+ const state = this._exitReleaseState;
47931
+ if (null == state ? void 0 : state.finalized) return;
47932
+ state && (state.finalized = !0);
47933
+ const parent = this.parent,
47934
+ removeFromParent = !!(null == state ? void 0 : state.removeFromParent),
47935
+ releaseSelf = !!(null == state ? void 0 : state.releaseSelf),
47936
+ callbacks = null !== (_a = null == state ? void 0 : state.onComplete) && void 0 !== _a ? _a : [];
47937
+ this._exitReleaseState = void 0, this._releaseEvent(), this._container = null, this._containerClip = null, this.removeAllChild(!0), releaseSelf && (super.release(!0), removeFromParent && (null === (_b = null != parent ? parent : this.parent) || void 0 === _b || _b.removeChild(this))), runExitReleaseCallbacks(callbacks);
47938
+ }
47939
+ _runExitAnimationBeforeCleanup(options = {}) {
47417
47940
  var _a;
47941
+ const releaseSelf = !!options.releaseSelf;
47942
+ if (this._exitReleaseState && !this._exitReleaseState.finalized) return this._exitReleaseState.releaseSelf = this._exitReleaseState.releaseSelf || releaseSelf, this._exitReleaseState.removeFromParent = this._exitReleaseState.removeFromParent || !!options.removeFromParent, appendExitReleaseCallback(this._exitReleaseState, options.onComplete), !0;
47943
+ if (!this.stage || !1 === this.attribute.animation || !1 === this.attribute.animationExit || !this._container) return !1;
47944
+ if (this.transAnimationConfig(), !(null === (_a = this._animationConfig) || void 0 === _a ? void 0 : _a.exit)) return !1;
47945
+ const existingAnimates = collectTrackedAnimates(this);
47946
+ this.markerAnimate("exit");
47947
+ const exitAnimates = collectTrackedAnimates(this).filter(animate => !existingAnimates.includes(animate));
47948
+ if (!exitAnimates.length) return !1;
47949
+ this._releaseEvent(), this.setAttribute("childrenPickable", !1), releaseSelf && (this.releaseStatus = "willRelease");
47950
+ const pendingAnimates = new Set(exitAnimates);
47951
+ return this._exitReleaseState = {
47952
+ pendingAnimates: pendingAnimates,
47953
+ finalized: !1,
47954
+ releaseSelf: releaseSelf,
47955
+ removeFromParent: !!options.removeFromParent,
47956
+ onComplete: options.onComplete ? [options.onComplete] : []
47957
+ }, bindExitReleaseAnimates(exitAnimates, () => this._exitReleaseState, () => this._finalizeExitRelease()), !0;
47958
+ }
47959
+ releaseWithExitAnimation(options = {}) {
47960
+ return "released" !== this.releaseStatus && this._runExitAnimationBeforeCleanup(Object.assign(Object.assign({}, options), {
47961
+ releaseSelf: !0
47962
+ }));
47963
+ }
47964
+ render() {
47965
+ var _a, _b;
47966
+ if (null === (_a = this._exitReleaseState) || void 0 === _a ? void 0 : _a.releaseSelf) return;
47418
47967
  this.transAnimationConfig(), this.setAttribute("pickable", !1);
47419
- const markerVisible = null === (_a = this.attribute.visible) || void 0 === _a || _a;
47420
- !1 === this.attribute.interactive && this.setAttribute("childrenPickable", !1), markerVisible && this.isValidPoints() ? this._container ? (this._updateContainer(), this.updateMarker(), this.markerAnimate("update")) : (this._initContainer(), this.initMarker(this._container), this.markerAnimate("enter")) : (this.markerAnimate("exit"), this._container = null, this.removeAllChild(!0)), this._releaseEvent(), this._bindEvent();
47968
+ const markerVisible = null === (_b = this.attribute.visible) || void 0 === _b || _b;
47969
+ !1 === this.attribute.interactive && this.setAttribute("childrenPickable", !1), markerVisible && this.isValidPoints() ? (this._exitReleaseState && this._finalizeExitRelease(), this._container ? (this._updateContainer(), this.updateMarker(), this.markerAnimate("update")) : (this._initContainer(), this.initMarker(this._container), this.markerAnimate("enter"))) : this._runExitAnimationBeforeCleanup() || (this._container = null, this._containerClip = null, this.removeAllChild(!0)), this._releaseEvent(), this._bindEvent();
47421
47970
  }
47422
- release() {
47423
- this.markerAnimate("exit"), super.release(), this._releaseEvent(), this._container = null;
47971
+ release(all) {
47972
+ this._exitReleaseState ? this._finalizeExitRelease() : (!1 !== this.attribute.animation && !1 !== this.attribute.animationExit && this.markerAnimate("exit"), all && this.removeAllChild(!0), super.release(all), this._releaseEvent(), this._container = null, this._containerClip = null);
47424
47973
  }
47425
47974
  }
47426
47975
 
@@ -49683,7 +50232,10 @@
49683
50232
  const innerGroupHeight = innerGroupBounds.height(),
49684
50233
  itemGroupWidth = isValid$1(this.attribute.item.width) ? this.attribute.item.width : innerGroupWidth + parsedPadding[1] + parsedPadding[3],
49685
50234
  itemGroupHeight = this._itemHeightByUser || innerGroupHeight + parsedPadding[0] + parsedPadding[2];
49686
- return itemGroup.attribute.width = itemGroupWidth, itemGroup.attribute.height = itemGroupHeight, focusShape && focusShape.setAttribute("visible", !1), innerGroup.translateTo(-innerGroupBounds.x1 + parsedPadding[3], -innerGroupBounds.y1 + parsedPadding[0]), itemGroup;
50235
+ return itemGroup.setAttributes({
50236
+ width: itemGroupWidth,
50237
+ height: itemGroupHeight
50238
+ }), focusShape && focusShape.setAttribute("visible", !1), innerGroup.translateTo(-innerGroupBounds.x1 + parsedPadding[3], -innerGroupBounds.y1 + parsedPadding[0]), itemGroup;
49687
50239
  }
49688
50240
  _createPager(compStyle) {
49689
50241
  var _a, _b;
@@ -51320,7 +51872,11 @@
51320
51872
  subTextBoundsWidth = this._subTitle ? this._subTitle.AABBBounds.width() : 0;
51321
51873
  let totalWidth = Math.max(mainTextBoundsWidth, subTextBoundsWidth),
51322
51874
  totalHeight = mainTextBoundsHeight + (null !== (_q = subtextStyle.height) && void 0 !== _q ? _q : subTextBoundsHeight);
51323
- if (isValid$1(width) && (totalWidth = width), isValid$1(height) && (totalHeight = height), isValid$1(minWidth) && totalWidth < minWidth && (totalWidth = minWidth), isValid$1(maxWidth) && totalWidth > maxWidth && (totalWidth = maxWidth), isValid$1(minHeight) && totalHeight < minHeight && (totalHeight = minHeight), isValid$1(maxHeight) && totalHeight > maxHeight && (totalHeight = maxHeight), group.attribute.width = totalWidth, group.attribute.height = totalHeight, group.attribute.boundsPadding = parsedPadding, this._mainTitle) {
51875
+ if (isValid$1(width) && (totalWidth = width), isValid$1(height) && (totalHeight = height), isValid$1(minWidth) && totalWidth < minWidth && (totalWidth = minWidth), isValid$1(maxWidth) && totalWidth > maxWidth && (totalWidth = maxWidth), isValid$1(minHeight) && totalHeight < minHeight && (totalHeight = minHeight), isValid$1(maxHeight) && totalHeight > maxHeight && (totalHeight = maxHeight), group.setAttributes({
51876
+ width: totalWidth,
51877
+ height: totalHeight,
51878
+ boundsPadding: parsedPadding
51879
+ }), this._mainTitle) {
51324
51880
  if (isValid$1(align) || isValid$1(textStyle.align)) {
51325
51881
  const mainTitleAlign = textStyle.align ? textStyle.align : align,
51326
51882
  mainTitleWidth = null !== (_r = textStyle.width) && void 0 !== _r ? _r : totalWidth;
@@ -54682,7 +55238,7 @@
54682
55238
  return resolveLegacyApp().createStage(params);
54683
55239
  }
54684
55240
 
54685
- const version = "1.1.0-alpha.16";
55241
+ const version = "1.1.0-alpha.17";
54686
55242
 
54687
55243
  exports.AComponentAnimate = AComponentAnimate;
54688
55244
  exports.ACustomAnimate = ACustomAnimate;
@@ -55607,7 +56163,6 @@
55607
56163
  exports.setPoptipTheme = setPoptipTheme;
55608
56164
  exports.shouldClipImageByLayout = shouldClipImageByLayout;
55609
56165
  exports.shouldUseMat4 = shouldUseMat4;
55610
- exports.shouldUseSimpleAttributeFastPath = shouldUseSimpleAttributeFastPath;
55611
56166
  exports.smartInvertStrategy = smartInvertStrategy;
55612
56167
  exports.snakeWave = snakeWave;
55613
56168
  exports.snapLength = snapLength;