@visactor/vrender 1.1.4-alpha.0 → 1.1.4-alpha.2

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
@@ -2728,7 +2728,7 @@
2728
2728
  constructor() {
2729
2729
  super(), this._uid = Generator.GenAutoIncrementId(), this._firstChild = null, this._lastChild = null, this.parent = null, this._count = 1;
2730
2730
  }
2731
- onParentSharedStateTreeChanged(_stage, _layer) {}
2731
+ onParentSharedStateTreeChanged(_stage, _layer, _inheritedSharedStateScope) {}
2732
2732
  forEachChildren(cb, reverse = !1) {
2733
2733
  if (reverse) {
2734
2734
  let child = this._lastChild,
@@ -8038,6 +8038,8 @@
8038
8038
  this.graphic === graphic && this.baseAttributes === baseAttributes || this.invalidateResolverCache(), this.graphic = graphic, this.baseAttributes = baseAttributes;
8039
8039
  }
8040
8040
  applyStates(stateNames) {
8041
+ const singleStaticStateResult = this.tryApplySingleStaticState(stateNames);
8042
+ if (singleStaticStateResult) return singleStaticStateResult;
8041
8043
  const uniqueStates = Array.from(new Set(stateNames)),
8042
8044
  sortedStates = this.sortStates(uniqueStates),
8043
8045
  adjudicated = this.adjudicate(sortedStates),
@@ -8052,6 +8054,19 @@
8052
8054
  suppressed: [...this._suppressed]
8053
8055
  };
8054
8056
  }
8057
+ tryApplySingleStaticState(stateNames) {
8058
+ if (1 !== stateNames.length || "shallow" !== this.mergeMode) return;
8059
+ const stateName = stateNames[0],
8060
+ definition = this.compiledDefinitions.get(stateName);
8061
+ if (definition && (definition.hasResolver || definition.exclude.size || definition.suppress.size)) return;
8062
+ const changed = 1 !== this._activeStates.length || this._activeStates[0] !== stateName || 1 !== this._effectiveStates.length || this._effectiveStates[0] !== stateName || 0 !== this._suppressed.length;
8063
+ return this._activeStates = [stateName], this._effectiveStates = [stateName], this._suppressed = [], !changed && this.resolverCacheValid || (this.resolverPatchCache.clear(), this.resolverCacheKey = stateName, this.resolverCacheValid = !0, this._resolvedPatch = (null == definition ? void 0 : definition.patch) ? cloneValue(definition.patch) : {}), {
8064
+ changed: changed,
8065
+ activeStates: [...this._activeStates],
8066
+ effectiveStates: [...this._effectiveStates],
8067
+ suppressed: []
8068
+ };
8069
+ }
8055
8070
  addState(stateName, keepCurrentStates) {
8056
8071
  if (this._activeStates.includes(stateName) && (keepCurrentStates || 1 === this._activeStates.length)) return {
8057
8072
  changed: !1,
@@ -8426,12 +8441,12 @@
8426
8441
  cursor: 1,
8427
8442
  html: 1
8428
8443
  };
8429
- class Graphic extends Node {
8444
+ class GraphicImpl extends Node {
8430
8445
  static mixin(source) {
8431
8446
  const keys = Object.keys(source);
8432
8447
  for (let i = 0; i < keys.length; ++i) {
8433
8448
  const propertyName = keys[i];
8434
- Object.defineProperty(Graphic.prototype, propertyName, Object.getOwnPropertyDescriptor(source, propertyName));
8449
+ Object.defineProperty(this.prototype, propertyName, Object.getOwnPropertyDescriptor(source, propertyName));
8435
8450
  }
8436
8451
  }
8437
8452
  get AABBBounds() {
@@ -8487,14 +8502,17 @@
8487
8502
  }
8488
8503
  return null === (_a = this.stage) || void 0 === _a ? void 0 : _a.rootSharedStateScope;
8489
8504
  }
8490
- syncSharedStateScopeBindingFromTree(markDirty = !0) {
8505
+ syncSharedStateScopeBinding(nextScope, markDirty = !0) {
8491
8506
  var _a;
8492
- const nextScope = this.resolveBoundSharedStateScope();
8493
8507
  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);
8494
8508
  }
8495
- syncSharedStateScopeBindingOnTreeChange(markDirty = !0) {
8509
+ syncSharedStateScopeBindingFromTree(markDirty = !0, inheritedSharedStateScope) {
8510
+ const nextScope = void 0 === inheritedSharedStateScope ? this.resolveBoundSharedStateScope() : null != inheritedSharedStateScope ? inheritedSharedStateScope : void 0;
8511
+ return this.syncSharedStateScopeBinding(nextScope, markDirty);
8512
+ }
8513
+ syncSharedStateScopeBindingOnTreeChange(markDirty = !0, inheritedSharedStateScope) {
8496
8514
  var _a, _b;
8497
- 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);
8515
+ 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);
8498
8516
  }
8499
8517
  syncSharedStateActiveRegistrations() {
8500
8518
  var _a;
@@ -8502,6 +8520,7 @@
8502
8520
  if (!(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) || !this.boundSharedStateScope) return (null == previousScopes ? void 0 : previousScopes.size) && (previousScopes.forEach(scope => {
8503
8521
  scope.subtreeActiveDescendants.delete(this);
8504
8522
  }), previousScopes.clear()), void (this.registeredActiveScopes = void 0);
8523
+ if ((null == previousScopes ? void 0 : previousScopes.size) && this.isSharedStateScopeChainRegistered(previousScopes)) return;
8505
8524
  const nextScopes = new Set(collectSharedStateScopeChain(this.boundSharedStateScope));
8506
8525
  null == previousScopes || previousScopes.forEach(scope => {
8507
8526
  nextScopes.has(scope) || scope.subtreeActiveDescendants.delete(this);
@@ -8509,6 +8528,15 @@
8509
8528
  scope.subtreeActiveDescendants.add(this);
8510
8529
  }), this.registeredActiveScopes = nextScopes;
8511
8530
  }
8531
+ isSharedStateScopeChainRegistered(previousScopes) {
8532
+ let scope = this.boundSharedStateScope,
8533
+ scopeCount = 0;
8534
+ for (; scope;) {
8535
+ if (!previousScopes.has(scope)) return !1;
8536
+ scopeCount += 1, scope = scope.parentScope;
8537
+ }
8538
+ return scopeCount === previousScopes.size;
8539
+ }
8512
8540
  clearSharedStateActiveRegistrations() {
8513
8541
  const previousScopes = this.registeredActiveScopes;
8514
8542
  previousScopes && (previousScopes.forEach(scope => {
@@ -8518,8 +8546,8 @@
8518
8546
  markSharedStateDirty() {
8519
8547
  this.sharedStateDirty = !0, enqueueGraphicSharedStateRefresh(this.stage, this), scheduleStageSharedStateRefresh(this.stage);
8520
8548
  }
8521
- onParentSharedStateTreeChanged(stage, layer) {
8522
- this.stage === stage && this.layer === layer ? this.syncSharedStateScopeBindingOnTreeChange() : this.setStage(stage, layer);
8549
+ onParentSharedStateTreeChanged(stage, layer, inheritedSharedStateScope) {
8550
+ this.stage === stage && this.layer === layer ? this.syncSharedStateScopeBindingOnTreeChange(!0, inheritedSharedStateScope) : this.setStage(stage, layer, inheritedSharedStateScope);
8523
8551
  }
8524
8552
  refreshSharedStateBeforeRender() {
8525
8553
  var _a;
@@ -9170,6 +9198,10 @@
9170
9198
  var _a;
9171
9199
  return null === (_a = this.states) || void 0 === _a ? void 0 : _a[stateName];
9172
9200
  }
9201
+ setStateDefinitionsWithCompiled(definitions, compiledDefinitions) {
9202
+ var _a;
9203
+ 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}`;
9204
+ }
9173
9205
  getStateResolveBaseAttrs() {
9174
9206
  var _a;
9175
9207
  return null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : this.attribute;
@@ -9363,8 +9395,10 @@
9363
9395
  transition.changed && this.useStates(transition.states, hasAnimation);
9364
9396
  }
9365
9397
  addState(stateName, keepCurrentStates, hasAnimation) {
9366
- const transition = this.resolveAddStateTransition(stateName, keepCurrentStates);
9367
- transition.changed && this.useStates(transition.states, hasAnimation);
9398
+ const currentStates = this.currentStates;
9399
+ if ((null == currentStates ? void 0 : currentStates.includes(stateName)) && (keepCurrentStates || 1 === currentStates.length)) return;
9400
+ const nextStates = keepCurrentStates && (null == currentStates ? void 0 : currentStates.length) ? currentStates.concat([stateName]) : [stateName];
9401
+ this.useStates(nextStates, hasAnimation);
9368
9402
  }
9369
9403
  setStates(states, options) {
9370
9404
  var _a, _b, _c;
@@ -9517,12 +9551,12 @@
9517
9551
  this._globalTransMatrix.translate(scrollX, scrollY);
9518
9552
  }
9519
9553
  }
9520
- setStage(stage, layer) {
9554
+ setStage(stage, layer, inheritedSharedStateScope) {
9521
9555
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
9522
9556
  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,
9523
9557
  previousStage = this.stage;
9524
9558
  if (this.stage !== stage || this.layer !== layer) {
9525
- 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()) {
9559
+ 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()) {
9526
9560
  const previousTimeline = null === (_f = null == previousStage ? void 0 : previousStage.getTimeline) || void 0 === _f ? void 0 : _f.call(previousStage),
9527
9561
  nextTimeline = null === (_g = null == stage ? void 0 : stage.getTimeline) || void 0 === _g ? void 0 : _g.call(stage),
9528
9562
  detachedStageAnimates = [];
@@ -9539,7 +9573,7 @@
9539
9573
  }
9540
9574
  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));
9541
9575
  }
9542
- ((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);
9576
+ ((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);
9543
9577
  }
9544
9578
  detachStageForRelease() {
9545
9579
  var _a, _b, _c;
@@ -9670,13 +9704,26 @@
9670
9704
  return null;
9671
9705
  }
9672
9706
  }
9707
+ GraphicImpl.userSymbolMap = {};
9708
+ const GRAPHIC_CLASS_SYMBOL = Symbol.for("@visactor/vrender-core/graphic-class");
9709
+ function createGraphicClassState() {
9710
+ return {
9711
+ Graphic: GraphicImpl
9712
+ };
9713
+ }
9714
+ function getGraphicClassState() {
9715
+ var _a;
9716
+ const globalScope = globalThis;
9717
+ return null !== (_a = globalScope[GRAPHIC_CLASS_SYMBOL]) && void 0 !== _a || (globalScope[GRAPHIC_CLASS_SYMBOL] = createGraphicClassState()), globalScope[GRAPHIC_CLASS_SYMBOL];
9718
+ }
9719
+ const Graphic = getGraphicClassState().Graphic;
9673
9720
  function backgroundNotImage(image) {
9674
9721
  return "string" == typeof image ? !(image.startsWith("<svg") || isValidUrl$1(image) || image.includes("/") || isBase64$1(image)) : !(!image.fill && !image.stroke) || !("string" != typeof image.gradient || !Array.isArray(image.stops));
9675
9722
  }
9676
9723
  function isExternalTexture(texture) {
9677
9724
  return !!texture && ("string" == typeof texture ? !builtinTextureTypes.has(texture) && (texture.startsWith("<svg") || isValidUrl$1(texture) || texture.includes("/") || isBase64$1(texture)) : isObject$1(texture));
9678
9725
  }
9679
- Graphic.userSymbolMap = {}, Graphic.mixin(EventTarget);
9726
+ Graphic.mixin(EventTarget);
9680
9727
 
9681
9728
  const defaultThemeObj = {
9682
9729
  arc: DefaultArcAttribute,
@@ -11150,13 +11197,14 @@
11150
11197
  }) : fillStyle, setTextStyle(ctx, character);
11151
11198
  }
11152
11199
  function applyStrokeStyle(ctx, character) {
11200
+ var _a, _b;
11153
11201
  const strokeStyle = character && character.stroke || defaultFormatting.stroke;
11154
11202
  if (!strokeStyle) return void (ctx.globalAlpha = 0);
11155
11203
  const {
11156
11204
  strokeOpacity = 1,
11157
11205
  opacity = 1
11158
11206
  } = character;
11159
- ctx.globalAlpha = strokeOpacity * opacity, ctx.lineWidth = character && "number" == typeof character.lineWidth ? character.lineWidth : 1, ctx.strokeStyle = strokeStyle, setTextStyle(ctx, character);
11207
+ ctx.globalAlpha = strokeOpacity * opacity, ctx.lineWidth = character && "number" == typeof character.lineWidth ? character.lineWidth : 1, ctx.setLineDash(null !== (_a = character.lineDash) && void 0 !== _a ? _a : []), ctx.lineDashOffset = null !== (_b = character.lineDashOffset) && void 0 !== _b ? _b : 0, ctx.strokeStyle = strokeStyle, setTextStyle(ctx, character);
11160
11208
  }
11161
11209
  function getStrByWithCanvas(desc, width, character, guessIndex, needTestLetter) {
11162
11210
  if (desc.length <= 1) return 0;
@@ -12099,8 +12147,8 @@
12099
12147
  clone() {
12100
12148
  return new RichText(Object.assign({}, this.attribute));
12101
12149
  }
12102
- setStage(stage, layer) {
12103
- super.setStage(stage, layer);
12150
+ setStage(stage, layer, inheritedSharedStateScope) {
12151
+ super.setStage(stage, layer, inheritedSharedStateScope);
12104
12152
  this.getFrameCache().icons.forEach(icon => {
12105
12153
  icon.setStage(stage, layer);
12106
12154
  });
@@ -12771,17 +12819,17 @@
12771
12819
  }
12772
12820
  incrementalAppendChild(node) {
12773
12821
  const data = super.appendChild(node);
12774
- return data && this.syncChildSharedStateTreeBinding(data), this.addUpdateBoundTag(), this.getGraphicService().onAddIncremental(node, this, this.stage), data;
12822
+ return data && this.shouldSyncChildSharedStateTreeBinding(data) && this.syncChildSharedStateTreeBinding(data), this.addUpdateBoundTag(), this.getGraphicService().onAddIncremental(node, this, this.stage), data;
12775
12823
  }
12776
12824
  incrementalClearChild() {
12777
12825
  super.removeAllChild(), this.addUpdateBoundTag(), this.getGraphicService().onClearIncremental(this, this.stage);
12778
12826
  }
12779
12827
  _updateChildToStage(child) {
12780
- return child && this.syncChildSharedStateTreeBinding(child), this.addUpdateBoundTag(), child;
12828
+ return child && this.shouldSyncChildSharedStateTreeBinding(child) && this.syncChildSharedStateTreeBinding(child), this.addUpdateBoundTag(), child;
12781
12829
  }
12782
12830
  appendChild(node, addStage = !0) {
12783
12831
  const data = super.appendChild(node);
12784
- return data && addStage && this.syncChildSharedStateTreeBinding(data), this.addUpdateBoundTag(), data;
12832
+ return data && addStage && this.shouldSyncChildSharedStateTreeBinding(data) && this.syncChildSharedStateTreeBinding(data), this.addUpdateBoundTag(), data;
12785
12833
  }
12786
12834
  insertBefore(newNode, referenceNode) {
12787
12835
  return this._updateChildToStage(super.insertBefore(newNode, referenceNode));
@@ -12804,13 +12852,13 @@
12804
12852
  child.setStage(null, null);
12805
12853
  }), this.addUpdateBoundTag();
12806
12854
  }
12807
- setStage(stage, layer) {
12855
+ setStage(stage, layer, inheritedSharedStateScope) {
12808
12856
  var _a, _b, _c, _d, _e, _f;
12809
12857
  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,
12810
12858
  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;
12811
- 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();
12859
+ 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);
12812
12860
  const layerChanged = this.layer !== layer;
12813
- layerChanged && (this.layer = layer), needsSharedStateTreeSync ? (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingOnTreeChange(!0), this.notifyChildrenSharedStateTreeChanged()) : layerChanged && this.notifyChildrenSharedStateTreeChanged();
12861
+ layerChanged && (this.layer = layer), needsSharedStateTreeSync ? (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingOnTreeChange(!0, inheritedSharedStateScope), this.notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope)) : layerChanged && this.notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope);
12814
12862
  }
12815
12863
  addUpdatePositionTag() {
12816
12864
  super.addUpdatePositionTag(), this.forEachChildren(g => {
@@ -12869,17 +12917,29 @@
12869
12917
  hasSharedStateDefinitions() {
12870
12918
  return !!this._sharedStateDefinitions && Object.keys(this._sharedStateDefinitions).length > 0;
12871
12919
  }
12872
- notifyChildrenSharedStateTreeChanged() {
12920
+ resolveChildSharedStateScope(inheritedSharedStateScope) {
12921
+ var _a;
12922
+ return this.sharedStateScope ? this.sharedStateScope : void 0 !== inheritedSharedStateScope ? inheritedSharedStateScope : null !== (_a = this.resolveBoundSharedStateScope()) && void 0 !== _a ? _a : null;
12923
+ }
12924
+ notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope) {
12925
+ const childSharedStateScope = this.resolveChildSharedStateScope(inheritedSharedStateScope);
12873
12926
  this.forEachChildren(item => {
12874
- this.syncChildSharedStateTreeBinding(item);
12927
+ this.setStageToChild(item, childSharedStateScope);
12875
12928
  });
12876
12929
  }
12877
- syncChildSharedStateTreeBinding(child) {
12878
- child.onParentSharedStateTreeChanged(this.stage, this.layer);
12930
+ shouldSyncChildSharedStateTreeBinding(child) {
12931
+ return !(!this.stage && !this.layer) || child.onParentSharedStateTreeChanged !== Graphic.prototype.onParentSharedStateTreeChanged && child.onParentSharedStateTreeChanged !== Group.prototype.onParentSharedStateTreeChanged;
12932
+ }
12933
+ setStageToChild(child, inheritedSharedStateScope) {
12934
+ const graphic = child;
12935
+ "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);
12879
12936
  }
12880
- onParentSharedStateTreeChanged(stage, layer) {
12937
+ syncChildSharedStateTreeBinding(child, inheritedSharedStateScope) {
12938
+ void 0 === inheritedSharedStateScope && (inheritedSharedStateScope = this.resolveChildSharedStateScope()), this.setStageToChild(child, inheritedSharedStateScope);
12939
+ }
12940
+ onParentSharedStateTreeChanged(stage, layer, inheritedSharedStateScope) {
12881
12941
  var _a;
12882
- 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);
12942
+ 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);
12883
12943
  }
12884
12944
  }
12885
12945
  Group.NOWORK_ANIMATE_ATTR = NOWORK_ANIMATE_ATTR;
@@ -22997,6 +23057,7 @@
22997
23057
  FederatedWheelEvent: FederatedWheelEvent,
22998
23058
  FlexLayoutPlugin: FlexLayoutPlugin,
22999
23059
  GLYPH_NUMBER_TYPE: GLYPH_NUMBER_TYPE,
23060
+ GRAPHIC_CLASS_SYMBOL: GRAPHIC_CLASS_SYMBOL,
23000
23061
  GRAPHIC_REGISTRY_SYMBOL: GRAPHIC_REGISTRY_SYMBOL,
23001
23062
  GRAPHIC_UPDATE_TAG_KEY: GRAPHIC_UPDATE_TAG_KEY,
23002
23063
  GROUP_NUMBER_TYPE: GROUP_NUMBER_TYPE,
@@ -23284,6 +23345,7 @@
23284
23345
  getDefaultCharacterConfig: getDefaultCharacterConfig,
23285
23346
  getExtraModelMatrix: getExtraModelMatrix,
23286
23347
  getFactoryState: getFactoryState,
23348
+ getGraphicClassState: getGraphicClassState,
23287
23349
  getGraphicRegistryState: getGraphicRegistryState,
23288
23350
  getLegacyBindingContext: getLegacyBindingContext,
23289
23351
  getModelMatrix: getModelMatrix,
@@ -49929,7 +49991,7 @@
49929
49991
  loadDiscreteLegendComponent();
49930
49992
  class DiscreteLegend extends LegendBase {
49931
49993
  constructor(attributes, options) {
49932
- super((null == options ? void 0 : options.skipDefault) ? attributes : merge({}, DiscreteLegend.defaultAttributes, attributes)), this.name = "discreteLegend", this._itemsContainer = null, this._itemHeightByUser = void 0, this._itemHeight = 0, this._itemMaxWidth = 0, this._contentMaxHeight = 0, this._onHover = e => {
49994
+ super((null == options ? void 0 : options.skipDefault) ? attributes : merge({}, DiscreteLegend.defaultAttributes, attributes)), this.name = "discreteLegend", this._itemsContainer = null, this._itemHeightByUser = void 0, this._itemHeight = 0, this._itemMaxWidth = 0, this._contentMaxHeight = 0, this._stateDefinitionsCache = new WeakMap(), this._onHover = e => {
49933
49995
  const target = e.target;
49934
49996
  if (target && target.name && target.name.startsWith(exports.LEGEND_ELEMENT_NAME.item)) {
49935
49997
  const legendItem = target.delegate;
@@ -49977,7 +50039,7 @@
49977
50039
  };
49978
50040
  }
49979
50041
  render() {
49980
- super.render(), this._lastActiveItem = null;
50042
+ this._stateDefinitionsCache = new WeakMap(), super.render(), this._lastActiveItem = null;
49981
50043
  }
49982
50044
  setSelected(selectedData) {
49983
50045
  var _a;
@@ -50157,7 +50219,7 @@
50157
50219
  }), this._appendDataToShape(itemGroup, exports.LEGEND_ELEMENT_NAME.item, item, itemGroup)) : (itemGroup = graphicCreator.group(Object.assign({
50158
50220
  x: 0,
50159
50221
  y: 0
50160
- }, backgroundStyle.style)), this._appendDataToShape(itemGroup, exports.LEGEND_ELEMENT_NAME.item, item, itemGroup, backgroundStyle.state)), itemGroup.id = `${null != id ? id : label}-${index}`, itemGroup.addState(isSelected ? exports.LegendStateValue.selected : exports.LegendStateValue.unSelected);
50222
+ }, backgroundStyle.style)), this._appendDataToShape(itemGroup, exports.LEGEND_ELEMENT_NAME.item, item, itemGroup, backgroundStyle.state, backgroundStyle.reuseStateDefinitions)), itemGroup.id = `${null != id ? id : label}-${index}`, itemGroup.addState(isSelected ? exports.LegendStateValue.selected : exports.LegendStateValue.unSelected);
50161
50223
  const innerGroup = graphicCreator.group({
50162
50224
  x: 0,
50163
50225
  y: 0,
@@ -50172,15 +50234,21 @@
50172
50234
  const s = get$1(shapeStyle, "style.size", DEFAULT_SHAPE_SIZE);
50173
50235
  shapeSize = isArray$1(s) ? s[0] || 0 : s, shapeSpace = get$1(shapeAttr, "space", DEFAULT_SHAPE_SPACE);
50174
50236
  const itemShape = graphicCreator.symbol(Object.assign(Object.assign({
50175
- x: 0,
50176
- y: 0,
50177
- symbolType: "circle",
50178
- strokeBoundsBuffer: 0
50179
- }, shape), shapeStyle.style));
50180
- Object.keys(shapeStyle.state || {}).forEach(key => {
50181
- const color = shapeStyle.state[key].fill || shapeStyle.state[key].stroke;
50182
- shape.fill && isNil$1(shapeStyle.state[key].fill) && color && (shapeStyle.state[key].fill = color), shape.stroke && isNil$1(shapeStyle.state[key].stroke) && color && (shapeStyle.state[key].stroke = color);
50183
- }), this._appendDataToShape(itemShape, exports.LEGEND_ELEMENT_NAME.itemShape, item, itemGroup, shapeStyle.state), itemShape.addState(isSelected ? exports.LegendStateValue.selected : exports.LegendStateValue.unSelected), innerGroup.add(itemShape);
50237
+ x: 0,
50238
+ y: 0,
50239
+ symbolType: "circle",
50240
+ strokeBoundsBuffer: 0
50241
+ }, shape), shapeStyle.style)),
50242
+ shapeStateNeedsItemColor = Object.keys(shapeStyle.state || {}).some(key => {
50243
+ const state = shapeStyle.state[key];
50244
+ return !!(state.fill || state.stroke) && (!!shape.fill && isNil$1(state.fill) || !!shape.stroke && isNil$1(state.stroke));
50245
+ }),
50246
+ shapeStates = shapeStateNeedsItemColor ? merge({}, shapeStyle.state) : shapeStyle.state;
50247
+ Object.keys(shapeStates || {}).forEach(key => {
50248
+ const state = shapeStates[key],
50249
+ color = state.fill || state.stroke;
50250
+ shape.fill && isNil$1(state.fill) && color && (state.fill = color), shape.stroke && isNil$1(state.stroke) && color && (state.stroke = color);
50251
+ }), this._appendDataToShape(itemShape, exports.LEGEND_ELEMENT_NAME.itemShape, item, itemGroup, shapeStates, !shapeStateNeedsItemColor && !1 !== shapeStyle.reuseStateDefinitions), itemShape.addState(isSelected ? exports.LegendStateValue.selected : exports.LegendStateValue.unSelected), innerGroup.add(itemShape);
50184
50252
  }
50185
50253
  let focusSpace = 0;
50186
50254
  if (focus) {
@@ -50207,7 +50275,7 @@
50207
50275
  _originText: labelAttr.formatMethod ? label : void 0
50208
50276
  }),
50209
50277
  labelShape = createTextGraphicByType(labelAttributes);
50210
- this._appendDataToShape(labelShape, exports.LEGEND_ELEMENT_NAME.itemLabel, item, itemGroup, labelStyle.state), labelShape.addState(isSelected ? exports.LegendStateValue.selected : exports.LegendStateValue.unSelected), innerGroup.add(labelShape);
50278
+ this._appendDataToShape(labelShape, exports.LEGEND_ELEMENT_NAME.itemLabel, item, itemGroup, labelStyle.state, labelStyle.reuseStateDefinitions), labelShape.addState(isSelected ? exports.LegendStateValue.selected : exports.LegendStateValue.unSelected), innerGroup.add(labelShape);
50211
50279
  const labelSpace = get$1(labelAttr, "space", DEFAULT_LABEL_SPACE);
50212
50280
  if (isValid$1(value)) {
50213
50281
  const valueSpace = get$1(valueAttr, "space", focus ? DEFAULT_VALUE_SPACE : 0),
@@ -50223,7 +50291,7 @@
50223
50291
  _originText: valueAttr.formatMethod ? value : void 0
50224
50292
  }),
50225
50293
  valueShape = createTextGraphicByType(valueAttributes);
50226
- if (this._appendDataToShape(valueShape, exports.LEGEND_ELEMENT_NAME.itemValue, item, itemGroup, valueStyle.state), valueShape.addState(isSelected ? exports.LegendStateValue.selected : exports.LegendStateValue.unSelected), this._itemWidthByUser) {
50294
+ if (this._appendDataToShape(valueShape, exports.LEGEND_ELEMENT_NAME.itemValue, item, itemGroup, valueStyle.state, valueStyle.reuseStateDefinitions), valueShape.addState(isSelected ? exports.LegendStateValue.selected : exports.LegendStateValue.unSelected), this._itemWidthByUser) {
50227
50295
  const layoutWidth = this._itemWidthByUser - parsedPadding[1] - parsedPadding[3] - shapeSize - shapeSpace - labelSpace - focusSpace - valueSpace;
50228
50296
  this._autoEllipsis(autoEllipsisStrategy, layoutWidth, labelShape, valueShape), valueAttr.alignRight ? valueShape.setAttributes({
50229
50297
  textAlign: "right",
@@ -50299,6 +50367,7 @@
50299
50367
  }));
50300
50368
  }
50301
50369
  _updatePositionOfPager(renderStartY, compWidth, compHeight) {
50370
+ var _a;
50302
50371
  const {
50303
50372
  pager: pager
50304
50373
  } = this.attribute,
@@ -50306,18 +50375,24 @@
50306
50375
  totalPage: totalPage,
50307
50376
  isHorizontal: isHorizontal
50308
50377
  } = this._itemContext,
50309
- position = pager && pager.position || "middle";
50378
+ position = pager && pager.position || "middle",
50379
+ hugContent = !(!pager || !pager.hugContent),
50380
+ pagerSpace = null !== (_a = pager && pager.space) && void 0 !== _a ? _a : DEFAULT_PAGER_SPACE;
50310
50381
  if (this._pagerComponent.setTotal(totalPage), isHorizontal) {
50311
50382
  let y;
50312
- y = "start" === position ? renderStartY : "end" === position ? renderStartY + compHeight - this._pagerComponent.AABBBounds.height() / 2 : renderStartY + compHeight / 2 - this._pagerComponent.AABBBounds.height() / 2, this._pagerComponent.setAttributes({
50313
- x: compWidth - this._pagerComponent.AABBBounds.width(),
50383
+ y = "start" === position ? renderStartY : "end" === position ? renderStartY + compHeight - this._pagerComponent.AABBBounds.height() / 2 : renderStartY + compHeight / 2 - this._pagerComponent.AABBBounds.height() / 2;
50384
+ let x = compWidth - this._pagerComponent.AABBBounds.width();
50385
+ hugContent && (x = Math.max(0, Math.min(this._itemsContainer.AABBBounds.width() + pagerSpace, x))), this._pagerComponent.setAttributes({
50386
+ x: x,
50314
50387
  y: y
50315
50388
  });
50316
50389
  } else {
50317
50390
  let x;
50318
- x = "start" === position ? 0 : "end" === position ? compWidth - this._pagerComponent.AABBBounds.width() : (compWidth - this._pagerComponent.AABBBounds.width()) / 2, this._pagerComponent.setAttributes({
50391
+ x = "start" === position ? 0 : "end" === position ? compWidth - this._pagerComponent.AABBBounds.width() : (compWidth - this._pagerComponent.AABBBounds.width()) / 2;
50392
+ let y = compHeight - this._pagerComponent.AABBBounds.height();
50393
+ hugContent && (y = Math.max(0, Math.min(renderStartY + this._itemsContainer.AABBBounds.height() + pagerSpace, y))), this._pagerComponent.setAttributes({
50319
50394
  x: x,
50320
- y: compHeight - this._pagerComponent.AABBBounds.height()
50395
+ y: y
50321
50396
  });
50322
50397
  }
50323
50398
  }
@@ -50472,11 +50547,15 @@
50472
50547
  this._itemContext.totalPage = total, this._updatePositionOfPager(renderStartY, compWidth, compHeight);
50473
50548
  }
50474
50549
  defaultCurrent > 1 && (isHorizontal ? itemsContainer.setAttribute("y", -(defaultCurrent - 1) * (compHeight + spaceRow)) : itemsContainer.setAttribute("x", -(defaultCurrent - 1) * (compWidth + spaceCol)));
50550
+ const hugContent = !!pager.hugContent;
50551
+ let clipWidth = isHorizontal ? contentWidth : compWidth,
50552
+ clipHeight = isHorizontal ? compHeight : contentHeight;
50553
+ hugContent && (isHorizontal ? clipWidth = Math.max(0, Math.min(clipWidth, itemsContainer.AABBBounds.width())) : clipHeight = Math.max(0, Math.min(clipHeight, itemsContainer.AABBBounds.height())));
50475
50554
  const clipGroup = graphicCreator.group({
50476
50555
  x: 0,
50477
50556
  y: renderStartY,
50478
- width: isHorizontal ? contentWidth : compWidth,
50479
- height: isHorizontal ? compHeight : contentHeight,
50557
+ width: clipWidth,
50558
+ height: clipHeight,
50480
50559
  clip: !0,
50481
50560
  pickable: !1
50482
50561
  });
@@ -50642,8 +50721,17 @@
50642
50721
  item.hasState(exports.LegendStateValue.selected) && selectedData.push(item.data);
50643
50722
  }), selectedData;
50644
50723
  }
50645
- _appendDataToShape(shape, name, data, delegateShape, states = {}) {
50646
- shape.name = name, shape.data = data, shape.delegate = delegateShape, shape.states = merge({}, DEFAULT_STATES, states);
50724
+ _appendDataToShape(shape, name, data, delegateShape, states, reuseStateDefinitions = !0) {
50725
+ if (shape.name = name, shape.data = data, shape.delegate = delegateShape, !reuseStateDefinitions) return void (shape.states = merge({}, DEFAULT_STATES, states));
50726
+ const source = null != states ? states : DEFAULT_STATES,
50727
+ cached = this._stateDefinitionsCache.get(source);
50728
+ if (cached) return shape.states = cached.definitions, void shape.setStateDefinitionsWithCompiled(cached.definitions, cached.compiledDefinitions);
50729
+ const definitions = states ? merge({}, DEFAULT_STATES, states) : DEFAULT_STATES,
50730
+ entry = {
50731
+ definitions: definitions,
50732
+ compiledDefinitions: new StateDefinitionCompiler().compile(definitions)
50733
+ };
50734
+ this._stateDefinitionsCache.set(source, entry), shape.states = entry.definitions, shape.setStateDefinitionsWithCompiled(entry.definitions, entry.compiledDefinitions);
50647
50735
  }
50648
50736
  _dispatchLegendEvent(eventName, legendItem, event) {
50649
50737
  const currentSelectedItems = this._getSelectedLegends();
@@ -50660,12 +50748,17 @@
50660
50748
  }
50661
50749
  _handleStyle(config, item, isSelected, index, items) {
50662
50750
  const newConfig = {};
50663
- return config.style && (isFunction$1(config.style) ? newConfig.style = config.style(item, isSelected, index, items) : newConfig.style = config.style), config.state && (newConfig.state = {}, Object.keys(config.state).forEach(key => {
50664
- config.state[key] && (isFunction$1(config.state[key]) ? newConfig.state[key] = config.state[key](item, isSelected, index, items) : newConfig.state[key] = config.state[key]);
50665
- })), newConfig;
50751
+ if (config.style && (isFunction$1(config.style) ? newConfig.style = config.style(item, isSelected, index, items) : newConfig.style = config.style), config.state) {
50752
+ const stateKeys = Object.keys(config.state),
50753
+ hasStateFunction = stateKeys.some(key => isFunction$1(config.state[key]));
50754
+ newConfig.reuseStateDefinitions = !hasStateFunction, hasStateFunction ? (newConfig.state = {}, stateKeys.forEach(key => {
50755
+ config.state[key] && (newConfig.state[key] = isFunction$1(config.state[key]) ? config.state[key](item, isSelected, index, items) : config.state[key]);
50756
+ })) : newConfig.state = config.state;
50757
+ }
50758
+ return newConfig;
50666
50759
  }
50667
50760
  release() {
50668
- super.release(), this.removeAllEventListeners();
50761
+ this._stateDefinitionsCache = new WeakMap(), super.release(), this.removeAllEventListeners();
50669
50762
  }
50670
50763
  }
50671
50764
  DiscreteLegend.defaultAttributes = {
@@ -55547,7 +55640,7 @@
55547
55640
  return resolveLegacyApp().createStage(params);
55548
55641
  }
55549
55642
 
55550
- const version = "1.1.4-alpha.0";
55643
+ const version = "1.1.4-alpha.2";
55551
55644
 
55552
55645
  exports.AComponentAnimate = AComponentAnimate;
55553
55646
  exports.ACustomAnimate = ACustomAnimate;
@@ -55770,6 +55863,7 @@
55770
55863
  exports.Fragment = Fragment;
55771
55864
  exports.FromTo = FromTo;
55772
55865
  exports.GLYPH_NUMBER_TYPE = GLYPH_NUMBER_TYPE;
55866
+ exports.GRAPHIC_CLASS_SYMBOL = GRAPHIC_CLASS_SYMBOL;
55773
55867
  exports.GRAPHIC_REGISTRY_SYMBOL = GRAPHIC_REGISTRY_SYMBOL;
55774
55868
  exports.GRAPHIC_UPDATE_TAG_KEY = GRAPHIC_UPDATE_TAG_KEY;
55775
55869
  exports.GROUP_NUMBER_TYPE = GROUP_NUMBER_TYPE;
@@ -56272,6 +56366,7 @@
56272
56366
  exports.getElMap = getElMap;
56273
56367
  exports.getExtraModelMatrix = getExtraModelMatrix;
56274
56368
  exports.getFactoryState = getFactoryState;
56369
+ exports.getGraphicClassState = getGraphicClassState;
56275
56370
  exports.getGraphicRegistryState = getGraphicRegistryState;
56276
56371
  exports.getHorizontalPath = getHorizontalPath;
56277
56372
  exports.getLegacyBindingContext = getLegacyBindingContext;