@visactor/vrender-kits 1.1.6-alpha.0 → 1.1.7

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.es.js CHANGED
@@ -4375,18 +4375,21 @@ class GradientParser {
4375
4375
  }
4376
4376
  }
4377
4377
 
4378
- function getScaledStroke(context, width, dpr) {
4378
+ function getScaledStrokeWithMatrix(matrix, width, dpr) {
4379
4379
  let strokeWidth = width;
4380
4380
  const {
4381
4381
  a: a,
4382
4382
  b: b,
4383
4383
  c: c,
4384
4384
  d: d
4385
- } = context.currentMatrix,
4385
+ } = matrix,
4386
4386
  scaleX = Math.sign(a) * Math.sqrt(a * a + b * b),
4387
4387
  scaleY = Math.sign(d) * Math.sqrt(c * c + d * d);
4388
4388
  return scaleX + scaleY === 0 ? 0 : (strokeWidth = strokeWidth / Math.abs(scaleX + scaleY) * 2 * dpr, strokeWidth);
4389
4389
  }
4390
+ function getScaledStroke(context, width, dpr) {
4391
+ return getScaledStrokeWithMatrix(context.currentMatrix, width, dpr);
4392
+ }
4390
4393
  function createColor(context, c, params, offsetX = 0, offsetY = 0) {
4391
4394
  var _a, _b, _c, _d;
4392
4395
  if (!c || !0 === c) return "black";
@@ -6287,7 +6290,7 @@ class Node extends EventEmitter {
6287
6290
  constructor() {
6288
6291
  super(), this._uid = Generator.GenAutoIncrementId(), this._firstChild = null, this._lastChild = null, this.parent = null, this._count = 1;
6289
6292
  }
6290
- onParentSharedStateTreeChanged(_stage, _layer, _inheritedSharedStateScope) {}
6293
+ onParentSharedStateTreeChanged(_stage, _layer) {}
6291
6294
  forEachChildren(cb, reverse = !1) {
6292
6295
  if (reverse) {
6293
6296
  let child = this._lastChild,
@@ -8384,7 +8387,7 @@ function normalizeNoAnimateAttrConfig(config) {
8384
8387
  }
8385
8388
  class StateTransitionOrchestrator {
8386
8389
  analyzeTransition(targetAttrs, hasAnimation, options = {}) {
8387
- var _a, _b;
8390
+ var _a, _b, _c, _d;
8388
8391
  const plan = {
8389
8392
  targetAttrs: Object.assign({}, targetAttrs),
8390
8393
  animateAttrs: {},
@@ -8393,10 +8396,17 @@ class StateTransitionOrchestrator {
8393
8396
  if (!hasAnimation) return plan;
8394
8397
  const noWorkAnimateAttr = Object.assign(Object.assign({}, null !== (_a = options.noWorkAnimateAttr) && void 0 !== _a ? _a : {}), normalizeNoAnimateAttrConfig(null === (_b = options.animateConfig) || void 0 === _b ? void 0 : _b.noAnimateAttrs)),
8395
8398
  isClear = !0 === options.isClear,
8396
- readDefaultAttribute = options.getDefaultAttribute,
8399
+ getDefaultAttribute = options.getDefaultAttribute,
8400
+ readDefaultAttribute = getDefaultAttribute,
8401
+ readStateTransitionDefaultAttribute = null !== (_c = options.getStateTransitionDefaultAttribute) && void 0 !== _c ? _c : getDefaultAttribute,
8397
8402
  shouldSkipDefaultAttribute = options.shouldSkipDefaultAttribute,
8398
- assignTransitionAttr = (key, value) => {
8399
- if (noWorkAnimateAttr[key]) plan.noAnimateAttrs[key] = value;else if (isClear && void 0 === value) {
8403
+ stateTransitionTargetAttrs = null !== (_d = options.stateTransitionTargetAttrs) && void 0 !== _d ? _d : targetAttrs,
8404
+ assignTransitionAttr = (key, value, isRemovedStateAttr = !1) => {
8405
+ if (noWorkAnimateAttr[key]) plan.noAnimateAttrs[key] = value;else if (isRemovedStateAttr && void 0 === value) {
8406
+ const defaultValue = null == readStateTransitionDefaultAttribute ? void 0 : readStateTransitionDefaultAttribute(key, stateTransitionTargetAttrs);
8407
+ if (void 0 === defaultValue && (null == shouldSkipDefaultAttribute ? void 0 : shouldSkipDefaultAttribute(key, stateTransitionTargetAttrs))) return;
8408
+ plan.animateAttrs[key] = defaultValue;
8409
+ } else if (isClear && void 0 === value) {
8400
8410
  if (null == shouldSkipDefaultAttribute ? void 0 : shouldSkipDefaultAttribute(key, targetAttrs)) return;
8401
8411
  plan.animateAttrs[key] = readDefaultAttribute(key);
8402
8412
  } else plan.animateAttrs[key] = value;
@@ -8408,7 +8418,7 @@ class StateTransitionOrchestrator {
8408
8418
  const extraAnimateAttrs = options.extraAnimateAttrs;
8409
8419
  if (extraAnimateAttrs) for (const key in extraAnimateAttrs) {
8410
8420
  const hasTargetAttr = Object.prototype.hasOwnProperty.call(targetAttrs, key);
8411
- !Object.prototype.hasOwnProperty.call(extraAnimateAttrs, key) || hasTargetAttr && void 0 !== targetAttrs[key] || assignTransitionAttr(key, extraAnimateAttrs[key]);
8421
+ !Object.prototype.hasOwnProperty.call(extraAnimateAttrs, key) || hasTargetAttr && void 0 !== targetAttrs[key] || assignTransitionAttr(key, extraAnimateAttrs[key], !0);
8412
8422
  }
8413
8423
  return plan;
8414
8424
  }
@@ -8440,9 +8450,11 @@ class StateTransitionOrchestrator {
8440
8450
  noWorkAnimateAttr: graphic.getNoWorkAnimateAttr(),
8441
8451
  isClear: !0,
8442
8452
  getDefaultAttribute: graphic.getDefaultAttribute.bind(graphic),
8453
+ getStateTransitionDefaultAttribute: options.getStateTransitionDefaultAttribute,
8443
8454
  shouldSkipDefaultAttribute: null !== (_a = options.shouldSkipDefaultAttribute) && void 0 !== _a ? _a : graphic.shouldSkipStateTransitionDefaultAttribute.bind(graphic),
8444
8455
  animateConfig: options.animateConfig,
8445
- extraAnimateAttrs: options.extraAnimateAttrs
8456
+ extraAnimateAttrs: options.extraAnimateAttrs,
8457
+ stateTransitionTargetAttrs: options.stateTransitionTargetAttrs
8446
8458
  });
8447
8459
  return this.applyTransition(graphic, plan, hasAnimation, options);
8448
8460
  }
@@ -8635,17 +8647,14 @@ class GraphicImpl extends Node {
8635
8647
  }
8636
8648
  return null === (_a = this.stage) || void 0 === _a ? void 0 : _a.rootSharedStateScope;
8637
8649
  }
8638
- syncSharedStateScopeBinding(nextScope, markDirty = !0) {
8650
+ syncSharedStateScopeBindingFromTree(markDirty = !0) {
8639
8651
  var _a;
8652
+ const nextScope = this.resolveBoundSharedStateScope();
8640
8653
  return this.boundSharedStateScope === nextScope ? (this.syncSharedStateActiveRegistrations(), !1) : (this.boundSharedStateScope = nextScope, this.boundSharedStateRevision = void 0, this.compiledStateDefinitions = void 0, this.compiledStateDefinitionsCacheKey = void 0, this.stateEngine = void 0, this.stateEngineCompiledDefinitions = void 0, this.syncSharedStateActiveRegistrations(), markDirty && (null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) && this.markSharedStateDirty(), !0);
8641
8654
  }
8642
- syncSharedStateScopeBindingFromTree(markDirty = !0, inheritedSharedStateScope) {
8643
- const nextScope = void 0 === inheritedSharedStateScope ? this.resolveBoundSharedStateScope() : null != inheritedSharedStateScope ? inheritedSharedStateScope : void 0;
8644
- return this.syncSharedStateScopeBinding(nextScope, markDirty);
8645
- }
8646
- syncSharedStateScopeBindingOnTreeChange(markDirty = !0, inheritedSharedStateScope) {
8655
+ syncSharedStateScopeBindingOnTreeChange(markDirty = !0) {
8647
8656
  var _a, _b;
8648
- 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, inheritedSharedStateScope);
8657
+ 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);
8649
8658
  }
8650
8659
  syncSharedStateActiveRegistrations() {
8651
8660
  var _a;
@@ -8653,7 +8662,6 @@ class GraphicImpl extends Node {
8653
8662
  if (!(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) || !this.boundSharedStateScope) return (null == previousScopes ? void 0 : previousScopes.size) && (previousScopes.forEach(scope => {
8654
8663
  scope.subtreeActiveDescendants.delete(this);
8655
8664
  }), previousScopes.clear()), void (this.registeredActiveScopes = void 0);
8656
- if ((null == previousScopes ? void 0 : previousScopes.size) && this.isSharedStateScopeChainRegistered(previousScopes)) return;
8657
8665
  const nextScopes = new Set(collectSharedStateScopeChain(this.boundSharedStateScope));
8658
8666
  null == previousScopes || previousScopes.forEach(scope => {
8659
8667
  nextScopes.has(scope) || scope.subtreeActiveDescendants.delete(this);
@@ -8661,15 +8669,6 @@ class GraphicImpl extends Node {
8661
8669
  scope.subtreeActiveDescendants.add(this);
8662
8670
  }), this.registeredActiveScopes = nextScopes;
8663
8671
  }
8664
- isSharedStateScopeChainRegistered(previousScopes) {
8665
- let scope = this.boundSharedStateScope,
8666
- scopeCount = 0;
8667
- for (; scope;) {
8668
- if (!previousScopes.has(scope)) return !1;
8669
- scopeCount += 1, scope = scope.parentScope;
8670
- }
8671
- return scopeCount === previousScopes.size;
8672
- }
8673
8672
  clearSharedStateActiveRegistrations() {
8674
8673
  const previousScopes = this.registeredActiveScopes;
8675
8674
  previousScopes && (previousScopes.forEach(scope => {
@@ -8679,8 +8678,8 @@ class GraphicImpl extends Node {
8679
8678
  markSharedStateDirty() {
8680
8679
  this.sharedStateDirty = !0, enqueueGraphicSharedStateRefresh(this.stage, this), scheduleStageSharedStateRefresh(this.stage);
8681
8680
  }
8682
- onParentSharedStateTreeChanged(stage, layer, inheritedSharedStateScope) {
8683
- this.stage === stage && this.layer === layer ? this.syncSharedStateScopeBindingOnTreeChange(!0, inheritedSharedStateScope) : this.setStage(stage, layer, inheritedSharedStateScope);
8681
+ onParentSharedStateTreeChanged(stage, layer) {
8682
+ this.stage === stage && this.layer === layer ? this.syncSharedStateScopeBindingOnTreeChange() : this.setStage(stage, layer);
8684
8683
  }
8685
8684
  refreshSharedStateBeforeRender() {
8686
8685
  var _a;
@@ -8730,21 +8729,20 @@ class GraphicImpl extends Node {
8730
8729
  }), snapshot) : snapshot;
8731
8730
  }
8732
8731
  buildRemovedStateAnimationAttrs(targetStateAttrs, previousResolvedStatePatch) {
8733
- const extraAttrs = {};
8734
- if (!previousResolvedStatePatch) return extraAttrs;
8732
+ if (!previousResolvedStatePatch) return;
8735
8733
  const snapshot = this.buildStaticAttributeSnapshot(),
8736
- staticTargetAttrs = snapshot;
8734
+ extraAttrs = {};
8737
8735
  return Object.keys(previousResolvedStatePatch).forEach(key => {
8738
8736
  const hasTargetAttr = Object.prototype.hasOwnProperty.call(targetStateAttrs, key);
8739
8737
  if (hasTargetAttr && void 0 !== targetStateAttrs[key]) return;
8740
8738
  const assignFallbackAttr = value => {
8741
- void 0 === value && this.shouldSkipStateTransitionDefaultAttribute(key, staticTargetAttrs) || (extraAttrs[key] = void 0 === value ? value : cloneAttributeValue(value));
8739
+ extraAttrs[key] = void 0 === value ? value : cloneAttributeValue(value);
8742
8740
  };
8743
- if (hasTargetAttr) assignFallbackAttr(this.getStateTransitionDefaultAttribute(key, staticTargetAttrs));else if (Object.prototype.hasOwnProperty.call(snapshot, key)) {
8744
- const snapshotValue = snapshot[key];
8745
- assignFallbackAttr(void 0 === snapshotValue ? this.getStateTransitionDefaultAttribute(key, staticTargetAttrs) : snapshotValue);
8746
- } else assignFallbackAttr(this.getStateTransitionDefaultAttribute(key, staticTargetAttrs));
8747
- }), extraAttrs;
8741
+ hasTargetAttr ? assignFallbackAttr(targetStateAttrs[key]) : Object.prototype.hasOwnProperty.call(snapshot, key) ? assignFallbackAttr(snapshot[key]) : assignFallbackAttr(void 0);
8742
+ }), {
8743
+ extraAttrs: extraAttrs,
8744
+ stateTransitionTargetAttrs: snapshot
8745
+ };
8748
8746
  }
8749
8747
  syncObjectToSnapshot(target, snapshot, excludedKeys) {
8750
8748
  const delta = new Map();
@@ -9331,10 +9329,6 @@ class GraphicImpl extends Node {
9331
9329
  var _a;
9332
9330
  return null === (_a = this.states) || void 0 === _a ? void 0 : _a[stateName];
9333
9331
  }
9334
- setStateDefinitionsWithCompiled(definitions, compiledDefinitions) {
9335
- var _a;
9336
- this.states = definitions, this.localStateDefinitionsSource !== definitions && (this.localStateDefinitionsSource = definitions, this.localStateDefinitionsVersion = (null !== (_a = this.localStateDefinitionsVersion) && void 0 !== _a ? _a : 0) + 1), this.compiledStateDefinitions = compiledDefinitions, this.compiledStateDefinitionsCacheKey = `local:${this.localStateDefinitionsVersion}`;
9337
- }
9338
9332
  getStateResolveBaseAttrs() {
9339
9333
  var _a;
9340
9334
  return null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : this.attribute;
@@ -9464,29 +9458,37 @@ class GraphicImpl extends Node {
9464
9458
  resolvedStateAttrs: resolvedStateAttrs
9465
9459
  } = this.resolveGraphicStateTransition(states, !0),
9466
9460
  patchChanged = !this.sameStatePatches(previousResolvedStatePatch, resolvedStateAttrs);
9467
- patchChanged && !this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !1) || (this.currentStates = transition.states, this.effectiveStates = [...effectiveStates], this.resolvedStatePatch = resolvedStateAttrs, this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(), patchChanged && (hasAnimation && animateSameStatePatchChange ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !1, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(), this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
9461
+ if ((!patchChanged || this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !1)) && (this.currentStates = transition.states, this.effectiveStates = [...effectiveStates], this.resolvedStatePatch = resolvedStateAttrs, this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(), patchChanged)) if (hasAnimation && animateSameStatePatchChange) {
9462
+ this._syncFinalAttributeFromStaticTruth();
9463
+ const removedStateAnimationAttrs = this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch);
9464
+ this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !1, void 0, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.extraAttrs, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.stateTransitionTargetAttrs);
9465
+ } else this.stopStateAnimates(), this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
9468
9466
  type: AttributeUpdateType.STATE
9469
9467
  }) : this.restoreAttributeFromStatePatchDelta(previousResolvedStatePatch, this.resolvedStatePatch, {
9470
9468
  type: AttributeUpdateType.STATE
9471
- }), this.emitStateUpdateEvent())));
9469
+ }), this.emitStateUpdateEvent();
9472
9470
  }
9473
9471
  resolveStateAnimateConfig(animateConfig) {
9474
9472
  var _a, _b, _c;
9475
9473
  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;
9476
9474
  }
9477
- applyStateAttrs(attrs, stateNames, hasAnimation, isClear, animateConfig, extraAnimateAttrs) {
9475
+ applyStateAttrs(attrs, stateNames, hasAnimation, isClear, animateConfig, extraAnimateAttrs, stateTransitionTargetAttrs) {
9478
9476
  const resolvedAnimateConfig = hasAnimation ? this.resolveStateAnimateConfig(animateConfig) : void 0,
9479
9477
  transitionOptions = resolvedAnimateConfig ? {
9480
9478
  animateConfig: resolvedAnimateConfig,
9481
9479
  extraAnimateAttrs: extraAnimateAttrs,
9482
- shouldSkipDefaultAttribute: this.shouldSkipStateTransitionDefaultAttribute.bind(this)
9480
+ getStateTransitionDefaultAttribute: this.getStateTransitionDefaultAttribute.bind(this),
9481
+ shouldSkipDefaultAttribute: this.shouldSkipStateTransitionDefaultAttribute.bind(this),
9482
+ stateTransitionTargetAttrs: stateTransitionTargetAttrs
9483
9483
  } : void 0;
9484
9484
  if (isClear) return void this.getStateTransitionOrchestrator().applyClearTransition(this, attrs, hasAnimation, transitionOptions);
9485
9485
  const plan = this.getStateTransitionOrchestrator().analyzeTransition(attrs, hasAnimation, {
9486
9486
  noWorkAnimateAttr: this.getNoWorkAnimateAttr(),
9487
9487
  animateConfig: resolvedAnimateConfig,
9488
9488
  extraAnimateAttrs: extraAnimateAttrs,
9489
- shouldSkipDefaultAttribute: this.shouldSkipStateTransitionDefaultAttribute.bind(this)
9489
+ getStateTransitionDefaultAttribute: this.getStateTransitionDefaultAttribute.bind(this),
9490
+ shouldSkipDefaultAttribute: this.shouldSkipStateTransitionDefaultAttribute.bind(this),
9491
+ stateTransitionTargetAttrs: stateTransitionTargetAttrs
9490
9492
  });
9491
9493
  this.getStateTransitionOrchestrator().applyTransition(this, plan, hasAnimation, transitionOptions);
9492
9494
  }
@@ -9513,11 +9515,15 @@ class GraphicImpl extends Node {
9513
9515
  transition = this.resolveClearStatesTransition();
9514
9516
  if (!transition.changed && 0 === previousStates.length) return this.currentStates = [], this.effectiveStates = [], this.resolvedStatePatch = void 0, this.sharedStateDirty = !1, void this.clearSharedStateActiveRegistrations();
9515
9517
  const resolvedStateAttrs = hasAnimation || this.hasCustomEvent("beforeStateUpdate") ? cloneAttributeValue(null !== (_b = this.baseAttributes) && void 0 !== _b ? _b : {}) : null !== (_c = this.baseAttributes) && void 0 !== _c ? _c : {};
9516
- 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(), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !0, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(), this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
9518
+ if (!transition.changed || this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !0)) if (this.currentStates = transition.states, this.effectiveStates = [], this.resolvedStatePatch = void 0, this.sharedStateDirty = !1, this.clearSharedStateActiveRegistrations(), hasAnimation) {
9519
+ this._syncFinalAttributeFromStaticTruth();
9520
+ const removedStateAnimationAttrs = this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch);
9521
+ this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !0, void 0, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.extraAttrs, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.stateTransitionTargetAttrs);
9522
+ } else this.stopStateAnimates(), this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
9517
9523
  type: AttributeUpdateType.STATE
9518
9524
  }) : this.restoreAttributeFromStatePatchDelta(previousResolvedStatePatch, void 0, {
9519
9525
  type: AttributeUpdateType.STATE
9520
- }), this.emitStateUpdateEvent()));
9526
+ }), this.emitStateUpdateEvent();
9521
9527
  }
9522
9528
  removeState(stateName, hasAnimation) {
9523
9529
  const transition = this.resolveRemoveStateTransition(stateName);
@@ -9558,11 +9564,15 @@ class GraphicImpl extends Node {
9558
9564
  effectiveStates: effectiveStates,
9559
9565
  resolvedStateAttrs: resolvedStateAttrs
9560
9566
  } = this.resolveGraphicStateTransition(states);
9561
- !transition.changed && this.sameStateNames(previousStates, transition.states) || this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !1) && (this.currentStates = transition.states, this.effectiveStates = [...effectiveStates], this.resolvedStatePatch = resolvedStateAttrs, this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !1, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(), this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
9567
+ if ((transition.changed || !this.sameStateNames(previousStates, transition.states)) && this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !1)) if (this.currentStates = transition.states, this.effectiveStates = [...effectiveStates], this.resolvedStatePatch = resolvedStateAttrs, this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(), hasAnimation) {
9568
+ this._syncFinalAttributeFromStaticTruth();
9569
+ const removedStateAnimationAttrs = this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch);
9570
+ this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !1, void 0, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.extraAttrs, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.stateTransitionTargetAttrs);
9571
+ } else this.stopStateAnimates(), this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
9562
9572
  type: AttributeUpdateType.STATE
9563
9573
  }) : this.restoreAttributeFromStatePatchDelta(previousResolvedStatePatch, this.resolvedStatePatch, {
9564
9574
  type: AttributeUpdateType.STATE
9565
- }), this.emitStateUpdateEvent()));
9575
+ }), this.emitStateUpdateEvent();
9566
9576
  }
9567
9577
  invalidateResolver() {
9568
9578
  var _a, _b;
@@ -9682,12 +9692,12 @@ class GraphicImpl extends Node {
9682
9692
  this._globalTransMatrix.translate(scrollX, scrollY);
9683
9693
  }
9684
9694
  }
9685
- setStage(stage, layer, inheritedSharedStateScope) {
9695
+ setStage(stage, layer) {
9686
9696
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
9687
9697
  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,
9688
9698
  previousStage = this.stage;
9689
9699
  if (this.stage !== stage || this.layer !== layer) {
9690
- 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, inheritedSharedStateScope), this.setStageToShadowRoot(stage, layer), this.mayHaveTrackedAnimates() && this.hasAnyTrackedAnimate()) {
9700
+ 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()) {
9691
9701
  const previousTimeline = null === (_f = null == previousStage ? void 0 : previousStage.getTimeline) || void 0 === _f ? void 0 : _f.call(previousStage),
9692
9702
  nextTimeline = null === (_g = null == stage ? void 0 : stage.getTimeline) || void 0 === _g ? void 0 : _g.call(stage),
9693
9703
  detachedStageAnimates = [];
@@ -9704,7 +9714,7 @@ class GraphicImpl extends Node {
9704
9714
  }
9705
9715
  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));
9706
9716
  }
9707
- ((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, inheritedSharedStateScope);
9717
+ ((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);
9708
9718
  }
9709
9719
  detachStageForRelease() {
9710
9720
  var _a, _b, _c;
@@ -10126,13 +10136,13 @@ class Group extends Graphic {
10126
10136
  child.setStage(null, null);
10127
10137
  }), this.addUpdateBoundTag();
10128
10138
  }
10129
- setStage(stage, layer, inheritedSharedStateScope) {
10139
+ setStage(stage, layer) {
10130
10140
  var _a, _b, _c, _d, _e, _f;
10131
10141
  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,
10132
10142
  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;
10133
- if (this.stage !== stage) return this.stage = stage, this.layer = layer, needsSharedStateTreeSync && (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingOnTreeChange(!0, inheritedSharedStateScope)), 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.notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope);
10143
+ 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.notifyChildrenSharedStateTreeChanged();
10134
10144
  const layerChanged = this.layer !== layer;
10135
- layerChanged && (this.layer = layer), needsSharedStateTreeSync ? (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingOnTreeChange(!0, inheritedSharedStateScope), this.notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope)) : layerChanged && this.notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope);
10145
+ layerChanged && (this.layer = layer), needsSharedStateTreeSync ? (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingOnTreeChange(!0), this.notifyChildrenSharedStateTreeChanged()) : layerChanged && this.notifyChildrenSharedStateTreeChanged();
10136
10146
  }
10137
10147
  addUpdatePositionTag() {
10138
10148
  super.addUpdatePositionTag(), this.forEachChildren(g => {
@@ -10191,26 +10201,17 @@ class Group extends Graphic {
10191
10201
  hasSharedStateDefinitions() {
10192
10202
  return !!this._sharedStateDefinitions && Object.keys(this._sharedStateDefinitions).length > 0;
10193
10203
  }
10194
- resolveChildSharedStateScope(inheritedSharedStateScope) {
10195
- var _a;
10196
- return this.sharedStateScope ? this.sharedStateScope : void 0 !== inheritedSharedStateScope ? inheritedSharedStateScope : null !== (_a = this.resolveBoundSharedStateScope()) && void 0 !== _a ? _a : null;
10197
- }
10198
- notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope) {
10199
- const childSharedStateScope = this.resolveChildSharedStateScope(inheritedSharedStateScope);
10204
+ notifyChildrenSharedStateTreeChanged() {
10200
10205
  this.forEachChildren(item => {
10201
- this.setStageToChild(item, childSharedStateScope);
10206
+ this.syncChildSharedStateTreeBinding(item);
10202
10207
  });
10203
10208
  }
10204
- setStageToChild(child, inheritedSharedStateScope) {
10205
- const graphic = child;
10206
- "function" != typeof graphic.setStage || child.onParentSharedStateTreeChanged !== Graphic.prototype.onParentSharedStateTreeChanged && child.onParentSharedStateTreeChanged !== Group.prototype.onParentSharedStateTreeChanged || graphic.stage === this.stage && graphic.layer === this.layer ? child.onParentSharedStateTreeChanged(this.stage, this.layer, inheritedSharedStateScope) : graphic.setStage(this.stage, this.layer, inheritedSharedStateScope);
10207
- }
10208
- syncChildSharedStateTreeBinding(child, inheritedSharedStateScope) {
10209
- void 0 === inheritedSharedStateScope && (inheritedSharedStateScope = this.resolveChildSharedStateScope()), this.setStageToChild(child, inheritedSharedStateScope);
10209
+ syncChildSharedStateTreeBinding(child) {
10210
+ child.onParentSharedStateTreeChanged(this.stage, this.layer);
10210
10211
  }
10211
- onParentSharedStateTreeChanged(stage, layer, inheritedSharedStateScope) {
10212
+ onParentSharedStateTreeChanged(stage, layer) {
10212
10213
  var _a;
10213
- this.stage === stage && this.layer === layer ? (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingOnTreeChange(!!(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length), inheritedSharedStateScope), this.notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope)) : this.setStage(stage, layer, inheritedSharedStateScope);
10214
+ 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);
10214
10215
  }
10215
10216
  }
10216
10217
  Group.NOWORK_ANIMATE_ATTR = NOWORK_ANIMATE_ATTR;
@@ -11700,8 +11701,15 @@ class Text extends Graphic {
11700
11701
  const b = this.AABBBounds;
11701
11702
  return this._OBBBounds.setValue(b.x1, b.y1, b.x2, b.y2), this._OBBBounds;
11702
11703
  }
11703
- this.obbText || (this.obbText = new Text({})), this.obbText.setAttributes(Object.assign(Object.assign({}, attribute), {
11704
- angle: 0
11704
+ this.obbText || (this.obbText = new Text({}));
11705
+ const {
11706
+ dx = 0,
11707
+ dy = 0
11708
+ } = attribute;
11709
+ this.obbText.setAttributes(Object.assign(Object.assign({}, attribute), {
11710
+ angle: 0,
11711
+ dx: 0,
11712
+ dy: 0
11705
11713
  }));
11706
11714
  const bounds1 = this.obbText.AABBBounds,
11707
11715
  {
@@ -11716,7 +11724,7 @@ class Text extends Graphic {
11716
11724
  x: x,
11717
11725
  y: y
11718
11726
  });
11719
- return this._OBBBounds.copy(bounds1), this._OBBBounds.translate(center.x - boundsCenter.x, center.y - boundsCenter.y), this._OBBBounds.angle = angle, this._OBBBounds;
11727
+ return this._OBBBounds.copy(bounds1), this._OBBBounds.translate(center.x - boundsCenter.x + dx, center.y - boundsCenter.y + dy), this._OBBBounds.angle = angle, this._OBBBounds;
11720
11728
  }
11721
11729
  updateAABBBounds(attribute, textTheme, aabbBounds) {
11722
11730
  const {
@@ -13584,8 +13592,8 @@ class RichText extends Graphic {
13584
13592
  clone() {
13585
13593
  return new RichText(Object.assign({}, this.attribute));
13586
13594
  }
13587
- setStage(stage, layer, inheritedSharedStateScope) {
13588
- super.setStage(stage, layer, inheritedSharedStateScope);
13595
+ setStage(stage, layer) {
13596
+ super.setStage(stage, layer);
13589
13597
  this.getFrameCache().icons.forEach(icon => {
13590
13598
  icon.setStage(stage, layer);
13591
13599
  });
@@ -14138,7 +14146,204 @@ function createArc3d(attributes) {
14138
14146
  return new Arc3d(attributes);
14139
14147
  }
14140
14148
 
14141
- const POLYGON_UPDATE_TAG_KEY = ["points", "cornerRadius", ...GRAPHIC_UPDATE_TAG_KEY];
14149
+ function drawPolygon(path, points, x, y) {
14150
+ if (points && points.length) {
14151
+ path.moveTo(points[0].x + x, points[0].y + y);
14152
+ for (let i = 1; i < points.length; i++) path.lineTo(points[i].x + x, points[i].y + y);
14153
+ }
14154
+ }
14155
+ function drawRoundedPolygon(path, points, x, y, cornerRadius, closePath = !0) {
14156
+ var _a;
14157
+ const normalized = normalizePolygonPoints(points, cornerRadius, closePath);
14158
+ if (normalized) return void drawRoundedPolygon(path, normalized.points, x, y, normalized.cornerRadius, closePath);
14159
+ if (points.length < 3) return void drawPolygon(path, points, x, y);
14160
+ let startI = 0,
14161
+ endI = points.length - 1;
14162
+ closePath || (startI += 1, endI -= 1, path.moveTo(points[0].x + x, points[0].y + y));
14163
+ for (let i = startI; i <= endI; i++) {
14164
+ const p1 = points[0 === i ? endI : (i - 1) % points.length],
14165
+ angularPoint = points[i % points.length],
14166
+ p2 = points[(i + 1) % points.length],
14167
+ dx1 = angularPoint.x - p1.x,
14168
+ dy1 = angularPoint.y - p1.y,
14169
+ dx2 = angularPoint.x - p2.x,
14170
+ dy2 = angularPoint.y - p2.y,
14171
+ angle = (Math.atan2(dy1, dx1) - Math.atan2(dy2, dx2)) / 2,
14172
+ tan = Math.abs(Math.tan(angle));
14173
+ let radius = Array.isArray(cornerRadius) ? null !== (_a = cornerRadius[i % points.length]) && void 0 !== _a ? _a : 0 : cornerRadius,
14174
+ segment = radius / tan;
14175
+ const length1 = getLength(dx1, dy1),
14176
+ length2 = getLength(dx2, dy2),
14177
+ length = Math.min(length1, length2);
14178
+ segment > length && (segment = length, radius = length * tan);
14179
+ const p1Cross = getProportionPoint(angularPoint, segment, length1, dx1, dy1),
14180
+ p2Cross = getProportionPoint(angularPoint, segment, length2, dx2, dy2),
14181
+ dx = 2 * angularPoint.x - p1Cross.x - p2Cross.x,
14182
+ dy = 2 * angularPoint.y - p1Cross.y - p2Cross.y,
14183
+ L = getLength(dx, dy),
14184
+ circlePoint = getProportionPoint(angularPoint, getLength(segment, radius), L, dx, dy);
14185
+ let startAngle = Math.atan2(p1Cross.y - circlePoint.y, p1Cross.x - circlePoint.x);
14186
+ const endAngle = Math.atan2(p2Cross.y - circlePoint.y, p2Cross.x - circlePoint.x);
14187
+ let sweepAngle = endAngle - startAngle;
14188
+ sweepAngle < 0 && (startAngle = endAngle, sweepAngle = -sweepAngle), sweepAngle > Math.PI && (sweepAngle -= Math.PI), 0 === i ? path.moveTo(p1Cross.x + x, p1Cross.y + y) : path.lineTo(p1Cross.x + x, p1Cross.y + y), sweepAngle && path.arcTo(angularPoint.x + x, angularPoint.y + y, p2Cross.x + x, p2Cross.y + y, radius), path.lineTo(p2Cross.x + x, p2Cross.y + y);
14189
+ }
14190
+ closePath || path.lineTo(points[endI + 1].x + x, points[endI + 1].y + y);
14191
+ }
14192
+ function getLength(dx, dy) {
14193
+ return Math.sqrt(dx * dx + dy * dy);
14194
+ }
14195
+ function getProportionPoint(point, segment, length, dx, dy) {
14196
+ const factor = segment / length;
14197
+ return {
14198
+ x: point.x - dx * factor,
14199
+ y: point.y - dy * factor
14200
+ };
14201
+ }
14202
+ function normalizePolygonPoints(points, cornerRadius, closePath = !0) {
14203
+ var _a;
14204
+ let hasDuplicate = !1;
14205
+ for (let i = 1; i < points.length; i++) if (isSamePoint(points[i - 1], points[i])) {
14206
+ hasDuplicate = !0;
14207
+ break;
14208
+ }
14209
+ if (!hasDuplicate && closePath && points.length > 1 && isSamePoint(points[0], points[points.length - 1]) && (hasDuplicate = !0), !hasDuplicate) return null;
14210
+ const normalizedPoints = [],
14211
+ normalizedCornerRadius = Array.isArray(cornerRadius) ? [] : null;
14212
+ for (let i = 0; i < points.length; i++) normalizedPoints.length && isSamePoint(normalizedPoints[normalizedPoints.length - 1], points[i]) || (normalizedPoints.push(points[i]), null == normalizedCornerRadius || normalizedCornerRadius.push(null !== (_a = cornerRadius[i]) && void 0 !== _a ? _a : 0));
14213
+ return closePath && normalizedPoints.length > 1 && isSamePoint(normalizedPoints[0], normalizedPoints[normalizedPoints.length - 1]) && (normalizedPoints.pop(), null == normalizedCornerRadius || normalizedCornerRadius.pop()), {
14214
+ points: normalizedPoints,
14215
+ cornerRadius: null != normalizedCornerRadius ? normalizedCornerRadius : cornerRadius
14216
+ };
14217
+ }
14218
+ function isSamePoint(a, b) {
14219
+ return a.x === b.x && a.y === b.y;
14220
+ }
14221
+ function getPolygonWinding(points) {
14222
+ let signedArea = 0;
14223
+ for (let i = 0; i < points.length; i++) {
14224
+ const current = points[i],
14225
+ next = points[(i + 1) % points.length];
14226
+ signedArea += current.x * next.y - next.x * current.y;
14227
+ }
14228
+ return signedArea > 0 ? 1 : -1;
14229
+ }
14230
+ function offsetPolygonPoints(points, distance, closePath = !0) {
14231
+ var _a;
14232
+ const n = null !== (_a = null == points ? void 0 : points.length) && void 0 !== _a ? _a : 0;
14233
+ if (n < 2 || closePath && n < 3 || !distance) return points;
14234
+ const sign = getPolygonWinding(points),
14235
+ edgeCount = closePath ? n : n - 1,
14236
+ lines = [];
14237
+ for (let i = 0; i < edgeCount; i++) {
14238
+ const cur = points[i],
14239
+ next = points[(i + 1) % n],
14240
+ dx = next.x - cur.x,
14241
+ dy = next.y - cur.y,
14242
+ len = Math.sqrt(dx * dx + dy * dy);
14243
+ if (!len) {
14244
+ lines.push(null);
14245
+ continue;
14246
+ }
14247
+ const offsetX = sign * dy * distance / len,
14248
+ offsetY = -sign * dx * distance / len;
14249
+ lines.push({
14250
+ x: cur.x + offsetX,
14251
+ y: cur.y + offsetY,
14252
+ dx: dx,
14253
+ dy: dy,
14254
+ len: len,
14255
+ offsetX: offsetX,
14256
+ offsetY: offsetY
14257
+ });
14258
+ }
14259
+ const prevLines = new Array(n);
14260
+ let prevLine = null;
14261
+ if (closePath) for (let i = edgeCount - 1; i >= 0; i--) if (lines[i]) {
14262
+ prevLine = lines[i];
14263
+ break;
14264
+ }
14265
+ for (let i = 0; i < n; i++) prevLines[i] = prevLine, i < edgeCount && lines[i] && (prevLine = lines[i]);
14266
+ const nextLines = new Array(n);
14267
+ let nextLine = null;
14268
+ if (closePath) for (let count = 0; count < edgeCount; count++) {
14269
+ const line = lines[(n - 1 + count) % edgeCount];
14270
+ if (line) {
14271
+ nextLine = line;
14272
+ break;
14273
+ }
14274
+ }
14275
+ for (let i = n - 1; i >= 0; i--) i < edgeCount && lines[i] && (nextLine = lines[i]), nextLines[i] = nextLine;
14276
+ const offsetPointByLine = (point, line) => ({
14277
+ x: point.x + line.offsetX,
14278
+ y: point.y + line.offsetY
14279
+ }),
14280
+ result = [];
14281
+ for (let i = 0; i < n; i++) {
14282
+ const prev = prevLines[i],
14283
+ cur = nextLines[i],
14284
+ line = prev || cur;
14285
+ if (!line) {
14286
+ result.push(points[i]);
14287
+ continue;
14288
+ }
14289
+ if (!prev || !cur) {
14290
+ result.push(offsetPointByLine(points[i], line));
14291
+ continue;
14292
+ }
14293
+ const denominator = prev.dx * cur.dy - prev.dy * cur.dx;
14294
+ if (Math.abs(denominator) <= 1e-12 * prev.len * cur.len) {
14295
+ result.push(offsetPointByLine(points[i], cur));
14296
+ continue;
14297
+ }
14298
+ const t = ((cur.x - prev.x) * cur.dy - (cur.y - prev.y) * cur.dx) / denominator,
14299
+ point = {
14300
+ x: prev.x + prev.dx * t,
14301
+ y: prev.y + prev.dy * t
14302
+ };
14303
+ result.push(Number.isFinite(point.x) && Number.isFinite(point.y) ? point : offsetPointByLine(points[i], cur));
14304
+ }
14305
+ return result;
14306
+ }
14307
+
14308
+ const getBoundsScaleMatrix = polygon => {
14309
+ var _a;
14310
+ const globalMatrix = polygon.globalTransMatrix,
14311
+ viewBoxMatrix = null === (_a = polygon.stage) || void 0 === _a ? void 0 : _a.window.getViewBoxTransform();
14312
+ return viewBoxMatrix ? {
14313
+ a: viewBoxMatrix.a * globalMatrix.a + viewBoxMatrix.c * globalMatrix.b,
14314
+ b: viewBoxMatrix.b * globalMatrix.a + viewBoxMatrix.d * globalMatrix.b,
14315
+ c: viewBoxMatrix.a * globalMatrix.c + viewBoxMatrix.c * globalMatrix.d,
14316
+ d: viewBoxMatrix.b * globalMatrix.c + viewBoxMatrix.d * globalMatrix.d
14317
+ } : globalMatrix;
14318
+ };
14319
+ const getPolygonBoundsScale = polygon => getScaledStrokeWithMatrix(getBoundsScaleMatrix(polygon), 1, 1);
14320
+ const updateBoundsOfPolygonOuterBorder = (attribute, polygonTheme, aabbBounds, polygon) => {
14321
+ const {
14322
+ outerBorder: outerBorder,
14323
+ points = polygonTheme.points,
14324
+ closePath = polygonTheme.closePath,
14325
+ shadowBlur = polygonTheme.shadowBlur,
14326
+ keepStrokeScale = polygonTheme.keepStrokeScale
14327
+ } = attribute;
14328
+ if (outerBorder && !1 !== outerBorder.visible) {
14329
+ const defaultOuterBorder = polygonTheme.outerBorder,
14330
+ {
14331
+ distance = defaultOuterBorder.distance,
14332
+ lineWidth = defaultOuterBorder.lineWidth,
14333
+ lineJoin = defaultOuterBorder.lineJoin,
14334
+ strokeBoundsBuffer = defaultOuterBorder.strokeBoundsBuffer
14335
+ } = outerBorder,
14336
+ boundsScale = getPolygonBoundsScale(polygon);
14337
+ let scaledDistance = distance;
14338
+ keepStrokeScale || (scaledDistance *= boundsScale), offsetPolygonPoints(points, scaledDistance, closePath).forEach(point => {
14339
+ aabbBounds.add(point.x, point.y);
14340
+ });
14341
+ boundStroke(aabbBounds, (shadowBlur * boundsScale + lineWidth * (keepStrokeScale ? 1 : boundsScale)) / 2, "miter" === lineJoin, strokeBoundsBuffer);
14342
+ }
14343
+ return aabbBounds;
14344
+ };
14345
+
14346
+ const POLYGON_UPDATE_TAG_KEY = ["points", "cornerRadius", "outerBorder", "keepStrokeScale", ...GRAPHIC_UPDATE_TAG_KEY];
14142
14347
  class Polygon extends Graphic {
14143
14348
  constructor(params) {
14144
14349
  super(params), this.type = "polygon", this.numberType = POLYGON_NUMBER_TYPE;
@@ -14155,6 +14360,16 @@ class Polygon extends Graphic {
14155
14360
  getGraphicTheme() {
14156
14361
  return getTheme(this).polygon;
14157
14362
  }
14363
+ tryUpdateAABBBounds() {
14364
+ const {
14365
+ outerBorder: outerBorder
14366
+ } = this.attribute;
14367
+ if (outerBorder && !1 !== outerBorder.visible) {
14368
+ const boundsScale = getPolygonBoundsScale(this);
14369
+ boundsScale !== this._outerBorderBoundsScale && (this._outerBorderBoundsScale = boundsScale, this.addUpdateBoundTag());
14370
+ } else this._outerBorderBoundsScale = void 0;
14371
+ return super.tryUpdateAABBBounds();
14372
+ }
14158
14373
  updateAABBBounds(attribute, polygonTheme, aabbBounds) {
14159
14374
  this.updatePathProxyAABBBounds(aabbBounds) || this.updatePolygonAABBBoundsImprecise(attribute, polygonTheme, aabbBounds), application.graphicService.updateTempAABBBounds(aabbBounds), this.widthWithoutTransform = aabbBounds.x2 - aabbBounds.x1, this.heightWithoutTransform = aabbBounds.y2 - aabbBounds.y1;
14160
14375
  const {
@@ -14168,7 +14383,7 @@ class Polygon extends Graphic {
14168
14383
  } = attribute;
14169
14384
  return points.forEach(p => {
14170
14385
  aabbBounds.add(p.x, p.y);
14171
- }), aabbBounds;
14386
+ }), updateBoundsOfPolygonOuterBorder(attribute, polygonTheme, aabbBounds, this), aabbBounds;
14172
14387
  }
14173
14388
  _interpolate(key, ratio, lastStepVal, nextStepVal, nextAttributes) {
14174
14389
  "points" === key && (nextAttributes.points = pointsInterpolation(lastStepVal, nextStepVal, ratio));
@@ -15096,22 +15311,26 @@ class DefaultRectRenderContribution {
15096
15311
  width: width,
15097
15312
  height: height
15098
15313
  } = rect.attribute;
15099
- width = (null != width ? width : x1 - x) || 0, height = (null != height ? height : y1 - y) || 0;
15100
- const renderBorder = (borderStyle, key) => {
15101
- const doStroke = !(!borderStyle || !borderStyle.stroke),
15102
- sign = "outerBorder" === key ? -1 : 1,
15103
- {
15104
- distance = rectAttribute[key].distance
15105
- } = borderStyle,
15106
- d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
15107
- nextX = x + sign * d,
15108
- nextY = y + sign * d,
15109
- dw = 2 * d;
15110
- if (0 === cornerRadius || isArray(cornerRadius) && cornerRadius.every(num => 0 === num) ? (context.beginPath(), context.rect(nextX, nextY, width - sign * dw, height - sign * dw)) : (context.beginPath(), createRectPath(context, nextX, nextY, width - sign * dw, height - sign * dw, cornerRadius, "bevel" !== cornerType)), context.setShadowBlendStyle && context.setShadowBlendStyle(rect, rect.attribute, rectAttribute), strokeCb) strokeCb(context, borderStyle, rectAttribute[key]);else if (doStroke) {
15111
- const lastOpacity = rectAttribute[key].opacity;
15112
- rectAttribute[key].opacity = opacity, context.setStrokeStyle(rect, borderStyle, (originX - x) / scaleX, (originY - y) / scaleY, rectAttribute[key]), rectAttribute[key].opacity = lastOpacity, context.stroke();
15113
- }
15114
- };
15314
+ width = (null != width ? width : x1 - originX) || 0, height = (null != height ? height : y1 - originY) || 0;
15315
+ const borderX = width < 0 ? x + width : x,
15316
+ borderY = height < 0 ? y + height : y,
15317
+ borderWidth = width < 0 ? -width : width,
15318
+ borderHeight = height < 0 ? -height : height,
15319
+ renderBorder = (borderStyle, key) => {
15320
+ const doStroke = !(!borderStyle || !borderStyle.stroke),
15321
+ sign = "outerBorder" === key ? -1 : 1,
15322
+ {
15323
+ distance = rectAttribute[key].distance
15324
+ } = borderStyle,
15325
+ d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
15326
+ nextX = borderX + sign * d,
15327
+ nextY = borderY + sign * d,
15328
+ dw = 2 * d;
15329
+ if (0 === cornerRadius || isArray(cornerRadius) && cornerRadius.every(num => 0 === num) ? (context.beginPath(), context.rect(nextX, nextY, borderWidth - sign * dw, borderHeight - sign * dw)) : (context.beginPath(), createRectPath(context, nextX, nextY, borderWidth - sign * dw, borderHeight - sign * dw, cornerRadius, "bevel" !== cornerType)), context.setShadowBlendStyle && context.setShadowBlendStyle(rect, rect.attribute, rectAttribute), strokeCb) strokeCb(context, borderStyle, rectAttribute[key]);else if (doStroke) {
15330
+ const lastOpacity = rectAttribute[key].opacity;
15331
+ rectAttribute[key].opacity = opacity, context.setStrokeStyle(rect, borderStyle, (originX - x) / scaleX, (originY - y) / scaleY, rectAttribute[key]), rectAttribute[key].opacity = lastOpacity, context.stroke();
15332
+ }
15333
+ };
15115
15334
  doOuterBorder && renderBorder(outerBorder, "outerBorder"), doInnerBorder && renderBorder(innerBorder, "innerBorder");
15116
15335
  }
15117
15336
  }
@@ -15528,7 +15747,8 @@ class DefaultIncrementalDrawContribution extends DefaultDrawContribution {
15528
15747
  }
15529
15748
 
15530
15749
  const DrawItemInterceptor = Symbol.for("DrawItemInterceptor");
15531
- const tempDirtyBounds = new AABBBounds(),
15750
+ const INTERACTIVE_POST_MATRIX = "_interactivePostMatrix",
15751
+ tempDirtyBounds = new AABBBounds(),
15532
15752
  tempBackupDirtyBounds = new AABBBounds();
15533
15753
  class ShadowRootDrawItemInterceptorContribution {
15534
15754
  constructor() {
@@ -15592,12 +15812,23 @@ class InteractiveDrawItemInterceptorContribution {
15592
15812
  beforeDrawItem(graphic, renderService, drawContext, drawContribution, params) {
15593
15813
  return !this.processing && (graphic.baseGraphic ? this.beforeDrawInteractive(graphic, renderService, drawContext, drawContribution, params) : this.beforeSetInteractive(graphic, renderService, drawContext, drawContribution, params));
15594
15814
  }
15815
+ resolveInteractivePostMatrix(graphic, interactiveGraphic) {
15816
+ const parent = graphic.parent;
15817
+ if (!parent) return graphic.attribute.postMatrix;
15818
+ let matrix = interactiveGraphic[INTERACTIVE_POST_MATRIX];
15819
+ matrix || (matrix = new Matrix(), interactiveGraphic[INTERACTIVE_POST_MATRIX] = matrix);
15820
+ const ancestorMatrix = parent.globalTransMatrix;
15821
+ matrix.setValue(ancestorMatrix.a, ancestorMatrix.b, ancestorMatrix.c, ancestorMatrix.d, ancestorMatrix.e, ancestorMatrix.f);
15822
+ const ownPostMatrix = graphic.attribute.postMatrix;
15823
+ return ownPostMatrix && matrix.multiply(ownPostMatrix.a, ownPostMatrix.b, ownPostMatrix.c, ownPostMatrix.d, ownPostMatrix.e, ownPostMatrix.f), matrix;
15824
+ }
15595
15825
  beforeSetInteractive(graphic, renderService, drawContext, drawContribution, params) {
15596
15826
  let interactiveGraphic = graphic.interactiveGraphic;
15597
15827
  if (graphic.attribute.globalZIndex) {
15598
15828
  interactiveGraphic || (interactiveGraphic = graphic.clone(), graphic.interactiveGraphic = interactiveGraphic, interactiveGraphic.baseGraphic = graphic), interactiveGraphic.setAttributes({
15599
15829
  globalZIndex: 0,
15600
- zIndex: graphic.attribute.globalZIndex
15830
+ zIndex: graphic.attribute.globalZIndex,
15831
+ postMatrix: this.resolveInteractivePostMatrix(graphic, interactiveGraphic)
15601
15832
  }, !1, {
15602
15833
  skipUpdateCallback: !0
15603
15834
  }), drawContext.stage.tryInitInteractiveLayer();
@@ -17346,64 +17577,69 @@ function bindPathRenderModule({
17346
17577
  }
17347
17578
  const pathModule = bindPathRenderModule;
17348
17579
 
17349
- function drawPolygon(path, points, x, y) {
17350
- if (points && points.length) {
17351
- path.moveTo(points[0].x + x, points[0].y + y);
17352
- for (let i = 1; i < points.length; i++) path.lineTo(points[i].x + x, points[i].y + y);
17580
+ const defaultPolygonTextureRenderContribution = defaultBaseTextureRenderContribution;
17581
+ const defaultPolygonBackgroundRenderContribution = defaultBaseBackgroundRenderContribution;
17582
+ class DefaultPolygonRenderContribution {
17583
+ constructor() {
17584
+ this.time = BaseRenderContributionTime.afterFillStroke, this.useStyle = !0, this.order = 0;
17353
17585
  }
17354
- }
17355
- function drawRoundedPolygon(path, points, x, y, cornerRadius, closePath = !0) {
17356
- var _a;
17357
- if (points.length < 3) return void drawPolygon(path, points, x, y);
17358
- let startI = 0,
17359
- endI = points.length - 1;
17360
- closePath || (startI += 1, endI -= 1, path.moveTo(points[0].x + x, points[0].y + y));
17361
- for (let i = startI; i <= endI; i++) {
17362
- const p1 = points[0 === i ? endI : (i - 1) % points.length],
17363
- angularPoint = points[i % points.length],
17364
- p2 = points[(i + 1) % points.length],
17365
- dx1 = angularPoint.x - p1.x,
17366
- dy1 = angularPoint.y - p1.y,
17367
- dx2 = angularPoint.x - p2.x,
17368
- dy2 = angularPoint.y - p2.y,
17369
- angle = (Math.atan2(dy1, dx1) - Math.atan2(dy2, dx2)) / 2,
17370
- tan = Math.abs(Math.tan(angle));
17371
- let radius = Array.isArray(cornerRadius) ? null !== (_a = cornerRadius[i % points.length]) && void 0 !== _a ? _a : 0 : cornerRadius,
17372
- segment = radius / tan;
17373
- const length1 = getLength(dx1, dy1),
17374
- length2 = getLength(dx2, dy2),
17375
- length = Math.min(length1, length2);
17376
- segment > length && (segment = length, radius = length * tan);
17377
- const p1Cross = getProportionPoint(angularPoint, segment, length1, dx1, dy1),
17378
- p2Cross = getProportionPoint(angularPoint, segment, length2, dx2, dy2),
17379
- dx = 2 * angularPoint.x - p1Cross.x - p2Cross.x,
17380
- dy = 2 * angularPoint.y - p1Cross.y - p2Cross.y,
17381
- L = getLength(dx, dy),
17382
- circlePoint = getProportionPoint(angularPoint, getLength(segment, radius), L, dx, dy);
17383
- let startAngle = Math.atan2(p1Cross.y - circlePoint.y, p1Cross.x - circlePoint.x);
17384
- const endAngle = Math.atan2(p2Cross.y - circlePoint.y, p2Cross.x - circlePoint.x);
17385
- let sweepAngle = endAngle - startAngle;
17386
- sweepAngle < 0 && (startAngle = endAngle, sweepAngle = -sweepAngle), sweepAngle > Math.PI && (sweepAngle -= Math.PI), 0 === i ? path.moveTo(p1Cross.x + x, p1Cross.y + y) : path.lineTo(p1Cross.x + x, p1Cross.y + y), sweepAngle && path.arcTo(angularPoint.x + x, angularPoint.y + y, p2Cross.x + x, p2Cross.y + y, radius), path.lineTo(p2Cross.x + x, p2Cross.y + y);
17586
+ drawShape(polygon, context, x, y, doFill, doStroke, fVisible, sVisible, polygonAttribute, drawContext, fillCb, strokeCb) {
17587
+ const {
17588
+ outerBorder: outerBorder,
17589
+ innerBorder: innerBorder
17590
+ } = polygon.attribute,
17591
+ doOuterBorder = outerBorder && !1 !== outerBorder.visible,
17592
+ doInnerBorder = innerBorder && !1 !== innerBorder.visible;
17593
+ if (!doOuterBorder && !doInnerBorder) return;
17594
+ const {
17595
+ points = polygonAttribute.points,
17596
+ cornerRadius = polygonAttribute.cornerRadius,
17597
+ opacity = polygonAttribute.opacity,
17598
+ x: originX = polygonAttribute.x,
17599
+ y: originY = polygonAttribute.y,
17600
+ scaleX = polygonAttribute.scaleX,
17601
+ scaleY = polygonAttribute.scaleY,
17602
+ keepStrokeScale = polygonAttribute.keepStrokeScale,
17603
+ closePath = polygonAttribute.closePath
17604
+ } = polygon.attribute,
17605
+ renderBorder = (borderStyle, key) => {
17606
+ var _a, _b;
17607
+ const doBorderStroke = !!borderStyle.stroke,
17608
+ distanceDirection = "outerBorder" === key ? 1 : -1,
17609
+ {
17610
+ distance = polygonAttribute[key].distance
17611
+ } = borderStyle,
17612
+ borderDistance = distanceDirection * (keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr)),
17613
+ normalized = normalizePolygonPoints(points, cornerRadius, closePath),
17614
+ normalizedPoints = null !== (_a = null == normalized ? void 0 : normalized.points) && void 0 !== _a ? _a : points,
17615
+ normalizedCornerRadius = null !== (_b = null == normalized ? void 0 : normalized.cornerRadius) && void 0 !== _b ? _b : cornerRadius,
17616
+ borderPoints = offsetPolygonPoints(normalizedPoints, borderDistance, closePath),
17617
+ winding = getPolygonWinding(normalizedPoints),
17618
+ borderCornerRadius = normalizedPoints.map((point, i) => {
17619
+ var _a;
17620
+ const radius = isArray(normalizedCornerRadius) ? null !== (_a = normalizedCornerRadius[i]) && void 0 !== _a ? _a : 0 : normalizedCornerRadius || 0;
17621
+ if (!closePath && (0 === i || i === normalizedPoints.length - 1) || normalizedPoints.length < 3) return radius;
17622
+ const prev = normalizedPoints[(i - 1 + normalizedPoints.length) % normalizedPoints.length],
17623
+ next = normalizedPoints[(i + 1) % normalizedPoints.length],
17624
+ cornerDirection = ((point.x - prev.x) * (next.y - point.y) - (point.y - prev.y) * (next.x - point.x)) * winding < 0 ? -1 : 1;
17625
+ return Math.max(0, radius + borderDistance * cornerDirection);
17626
+ }),
17627
+ noCorner = 0 === borderCornerRadius.length || borderCornerRadius.every(r => 0 === r);
17628
+ if (context.beginPath(), noCorner ? drawPolygon(context.camera ? context : context.nativeContext, borderPoints, x, y) : drawRoundedPolygon(context.camera ? context : context.nativeContext, borderPoints, x, y, borderCornerRadius, closePath), closePath && context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(polygon, polygon.attribute, polygonAttribute), strokeCb) strokeCb(context, borderStyle, polygonAttribute[key]);else if (doBorderStroke) {
17629
+ const lastOpacity = polygonAttribute[key].opacity,
17630
+ borderStyleWithStrokeScale = borderStyle,
17631
+ lastKeepStrokeScale = borderStyleWithStrokeScale.keepStrokeScale;
17632
+ polygonAttribute[key].opacity = opacity, borderStyleWithStrokeScale.keepStrokeScale = keepStrokeScale, context.setStrokeStyle(polygon, borderStyleWithStrokeScale, (originX - x) / scaleX, (originY - y) / scaleY, polygonAttribute[key]), polygonAttribute[key].opacity = lastOpacity, void 0 === lastKeepStrokeScale ? delete borderStyleWithStrokeScale.keepStrokeScale : borderStyleWithStrokeScale.keepStrokeScale = lastKeepStrokeScale, context.stroke();
17633
+ }
17634
+ };
17635
+ doOuterBorder && renderBorder(outerBorder, "outerBorder"), doInnerBorder && renderBorder(innerBorder, "innerBorder");
17387
17636
  }
17388
- closePath || path.lineTo(points[endI + 1].x + x, points[endI + 1].y + y);
17389
- }
17390
- function getLength(dx, dy) {
17391
- return Math.sqrt(dx * dx + dy * dy);
17392
- }
17393
- function getProportionPoint(point, segment, length, dx, dy) {
17394
- const factor = segment / length;
17395
- return {
17396
- x: point.x - dx * factor,
17397
- y: point.y - dy * factor
17398
- };
17399
17637
  }
17400
-
17401
- const defaultPolygonTextureRenderContribution = defaultBaseTextureRenderContribution;
17402
- const defaultPolygonBackgroundRenderContribution = defaultBaseBackgroundRenderContribution;
17638
+ const defaultPolygonRenderContribution = new DefaultPolygonRenderContribution();
17403
17639
 
17404
17640
  class DefaultCanvasPolygonRender extends BaseRender {
17405
17641
  constructor(graphicRenderContributions) {
17406
- super(), this.graphicRenderContributions = graphicRenderContributions, this.numberType = POLYGON_NUMBER_TYPE, this.builtinContributions = [defaultPolygonBackgroundRenderContribution, defaultPolygonTextureRenderContribution], this.init(graphicRenderContributions);
17642
+ super(), this.graphicRenderContributions = graphicRenderContributions, this.numberType = POLYGON_NUMBER_TYPE, this.builtinContributions = [defaultPolygonRenderContribution, defaultPolygonBackgroundRenderContribution, defaultPolygonTextureRenderContribution], this.init(graphicRenderContributions);
17407
17643
  }
17408
17644
  drawShape(polygon, context, x, y, drawContext, params, fillCb, strokeCb) {
17409
17645
  const polygonAttribute = getTheme(polygon, null == params ? void 0 : params.theme).polygon,
@@ -22832,6 +23068,8 @@ function getLynxRuntime(params) {
22832
23068
  var _a, _b;
22833
23069
  return (_b = (_a = params === null || params === void 0 ? void 0 : params.lynx) !== null && _a !== void 0 ? _a : params === null || params === void 0 ? void 0 : params.runtime) !== null && _b !== void 0 ? _b : getGlobalLynxRuntime();
22834
23070
  }
23071
+ const requestAnimationFrameBasedSTO = (callback) => rafBasedSto.call(callback);
23072
+ const cancelAnimationFrameBasedSTO = (handle) => rafBasedSto.clear(handle);
22835
23073
  function getLynxPixelRatio(params, runtime) {
22836
23074
  var _a, _b, _c, _d, _e;
22837
23075
  return (_e = (_d = (_a = params === null || params === void 0 ? void 0 : params.pixelRatio) !== null && _a !== void 0 ? _a : (_c = (_b = runtime === null || runtime === void 0 ? void 0 : runtime.getSystemInfoSync) === null || _b === void 0 ? void 0 : _b.call(runtime)) === null || _c === void 0 ? void 0 : _c.pixelRatio) !== null && _d !== void 0 ? _d : getGlobalSystemPixelRatio()) !== null && _e !== void 0 ? _e : 1;
@@ -22933,6 +23171,8 @@ class LynxEnvContribution extends BaseEnvContribution {
22933
23171
  this.canvasMap = new Map();
22934
23172
  this.freeCanvasList = [];
22935
23173
  this.canvasIdx = 0;
23174
+ this.requestAnimationFrame = requestAnimationFrameBasedSTO;
23175
+ this.cancelAnimationFrame = cancelAnimationFrameBasedSTO;
22936
23176
  this.supportsTouchEvents = true;
22937
23177
  try {
22938
23178
  this.supportsPointerEvents = !!globalThis.PointerEvent;
@@ -22945,10 +23185,20 @@ class LynxEnvContribution extends BaseEnvContribution {
22945
23185
  this.applyStyles = true;
22946
23186
  }
22947
23187
  configure(service, params = {}) {
23188
+ var _a, _b;
22948
23189
  if (service.env === this.type) {
22949
23190
  service.setActiveEnvContribution(this);
22950
23191
  this.lynxEnvParams = params;
22951
23192
  this.lynxRuntime = getLynxRuntime(params);
23193
+ if (typeof ((_a = this.lynxRuntime) === null || _a === void 0 ? void 0 : _a.requestAnimationFrame) === 'function' &&
23194
+ typeof ((_b = this.lynxRuntime) === null || _b === void 0 ? void 0 : _b.cancelAnimationFrame) === 'function') {
23195
+ this.requestAnimationFrame = this.lynxRuntime.requestAnimationFrame.bind(this.lynxRuntime);
23196
+ this.cancelAnimationFrame = this.lynxRuntime.cancelAnimationFrame.bind(this.lynxRuntime);
23197
+ }
23198
+ else {
23199
+ this.requestAnimationFrame = requestAnimationFrameBasedSTO;
23200
+ this.cancelAnimationFrame = cancelAnimationFrameBasedSTO;
23201
+ }
22952
23202
  }
22953
23203
  }
22954
23204
  getDynamicCanvasCount() {
@@ -23022,14 +23272,10 @@ class LynxEnvContribution extends BaseEnvContribution {
23022
23272
  return getLynxPixelRatio(undefined, this.lynxRuntime);
23023
23273
  }
23024
23274
  getRequestAnimationFrame() {
23025
- return function (callback) {
23026
- return rafBasedSto.call(callback);
23027
- };
23275
+ return this.requestAnimationFrame;
23028
23276
  }
23029
23277
  getCancelAnimationFrame() {
23030
- return (h) => {
23031
- rafBasedSto.clear(h);
23032
- };
23278
+ return this.cancelAnimationFrame;
23033
23279
  }
23034
23280
  mapToCanvasPoint(event) {
23035
23281
  var _a;