@visactor/vrender-core 1.1.8-alpha.0 → 1.1.8-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.
Files changed (38) hide show
  1. package/cjs/allocator/bounds-allocate.js +1 -2
  2. package/cjs/animate/config.js +2 -1
  3. package/cjs/graphic/graphic.d.ts +8 -4
  4. package/cjs/graphic/graphic.js +36 -13
  5. package/cjs/graphic/graphic.js.map +1 -1
  6. package/cjs/graphic/group.d.ts +6 -4
  7. package/cjs/graphic/group.js +21 -11
  8. package/cjs/graphic/group.js.map +1 -1
  9. package/cjs/graphic/node-tree.d.ts +2 -1
  10. package/cjs/graphic/node-tree.js +1 -1
  11. package/cjs/graphic/node-tree.js.map +1 -1
  12. package/cjs/graphic/richtext.d.ts +2 -1
  13. package/cjs/graphic/richtext.js +2 -2
  14. package/cjs/graphic/richtext.js.map +1 -1
  15. package/cjs/interface/graphic.d.ts +1 -1
  16. package/cjs/interface/graphic.js.map +1 -1
  17. package/cjs/interface/node-tree.d.ts +2 -1
  18. package/cjs/interface/node-tree.js.map +1 -1
  19. package/dist/index.es.js +103 -27
  20. package/es/allocator/bounds-allocate.js +1 -2
  21. package/es/animate/config.js +2 -1
  22. package/es/graphic/graphic.d.ts +8 -4
  23. package/es/graphic/graphic.js +36 -13
  24. package/es/graphic/graphic.js.map +1 -1
  25. package/es/graphic/group.d.ts +6 -4
  26. package/es/graphic/group.js +21 -11
  27. package/es/graphic/group.js.map +1 -1
  28. package/es/graphic/node-tree.d.ts +2 -1
  29. package/es/graphic/node-tree.js +1 -1
  30. package/es/graphic/node-tree.js.map +1 -1
  31. package/es/graphic/richtext.d.ts +2 -1
  32. package/es/graphic/richtext.js +2 -2
  33. package/es/graphic/richtext.js.map +1 -1
  34. package/es/interface/graphic.d.ts +1 -1
  35. package/es/interface/graphic.js.map +1 -1
  36. package/es/interface/node-tree.d.ts +2 -1
  37. package/es/interface/node-tree.js.map +1 -1
  38. package/package.json +2 -2
package/dist/index.es.js CHANGED
@@ -711,7 +711,7 @@ class Node extends EventEmitter {
711
711
  this.parent = null;
712
712
  this._count = 1;
713
713
  }
714
- onParentSharedStateTreeChanged(_stage, _layer) {
714
+ onParentSharedStateTreeChanged(_stage, _layer, _inheritedSharedStateScope) {
715
715
  return;
716
716
  }
717
717
  forEachChildren(cb, reverse = false) {
@@ -9975,9 +9975,8 @@ class GraphicImpl extends Node {
9975
9975
  }
9976
9976
  return (_a = this.stage) === null || _a === void 0 ? void 0 : _a.rootSharedStateScope;
9977
9977
  }
9978
- syncSharedStateScopeBindingFromTree(markDirty = true) {
9978
+ syncSharedStateScopeBinding(nextScope, markDirty = true) {
9979
9979
  var _a;
9980
- const nextScope = this.resolveBoundSharedStateScope();
9981
9980
  if (this.boundSharedStateScope === nextScope) {
9982
9981
  this.syncSharedStateActiveRegistrations();
9983
9982
  return false;
@@ -9994,7 +9993,13 @@ class GraphicImpl extends Node {
9994
9993
  }
9995
9994
  return true;
9996
9995
  }
9997
- syncSharedStateScopeBindingOnTreeChange(markDirty = true) {
9996
+ syncSharedStateScopeBindingFromTree(markDirty = true, inheritedSharedStateScope) {
9997
+ const nextScope = inheritedSharedStateScope === undefined
9998
+ ? this.resolveBoundSharedStateScope()
9999
+ : inheritedSharedStateScope !== null && inheritedSharedStateScope !== void 0 ? inheritedSharedStateScope : undefined;
10000
+ return this.syncSharedStateScopeBinding(nextScope, markDirty);
10001
+ }
10002
+ syncSharedStateScopeBindingOnTreeChange(markDirty = true, inheritedSharedStateScope) {
9998
10003
  var _a, _b;
9999
10004
  if (!((_a = this.currentStates) === null || _a === void 0 ? void 0 : _a.length) &&
10000
10005
  !this.boundSharedStateScope &&
@@ -10002,7 +10007,7 @@ class GraphicImpl extends Node {
10002
10007
  !this.sharedStateDirty) {
10003
10008
  return false;
10004
10009
  }
10005
- return this.syncSharedStateScopeBindingFromTree(markDirty);
10010
+ return this.syncSharedStateScopeBindingFromTree(markDirty, inheritedSharedStateScope);
10006
10011
  }
10007
10012
  syncSharedStateActiveRegistrations() {
10008
10013
  var _a;
@@ -10017,6 +10022,9 @@ class GraphicImpl extends Node {
10017
10022
  this.registeredActiveScopes = undefined;
10018
10023
  return;
10019
10024
  }
10025
+ if ((previousScopes === null || previousScopes === void 0 ? void 0 : previousScopes.size) && this.isSharedStateScopeChainRegistered(previousScopes)) {
10026
+ return;
10027
+ }
10020
10028
  const nextScopes = new Set(collectSharedStateScopeChain(this.boundSharedStateScope));
10021
10029
  previousScopes === null || previousScopes === void 0 ? void 0 : previousScopes.forEach(scope => {
10022
10030
  if (!nextScopes.has(scope)) {
@@ -10028,6 +10036,18 @@ class GraphicImpl extends Node {
10028
10036
  });
10029
10037
  this.registeredActiveScopes = nextScopes;
10030
10038
  }
10039
+ isSharedStateScopeChainRegistered(previousScopes) {
10040
+ let scope = this.boundSharedStateScope;
10041
+ let scopeCount = 0;
10042
+ while (scope) {
10043
+ if (!previousScopes.has(scope)) {
10044
+ return false;
10045
+ }
10046
+ scopeCount += 1;
10047
+ scope = scope.parentScope;
10048
+ }
10049
+ return scopeCount === previousScopes.size;
10050
+ }
10031
10051
  clearSharedStateActiveRegistrations() {
10032
10052
  const previousScopes = this.registeredActiveScopes;
10033
10053
  if (previousScopes) {
@@ -10043,12 +10063,12 @@ class GraphicImpl extends Node {
10043
10063
  enqueueGraphicSharedStateRefresh(this.stage, this);
10044
10064
  scheduleStageSharedStateRefresh(this.stage);
10045
10065
  }
10046
- onParentSharedStateTreeChanged(stage, layer) {
10066
+ onParentSharedStateTreeChanged(stage, layer, inheritedSharedStateScope) {
10047
10067
  if (this.stage !== stage || this.layer !== layer) {
10048
- this.setStage(stage, layer);
10068
+ this.setStage(stage, layer, inheritedSharedStateScope);
10049
10069
  return;
10050
10070
  }
10051
- this.syncSharedStateScopeBindingOnTreeChange();
10071
+ this.syncSharedStateScopeBindingOnTreeChange(true, inheritedSharedStateScope);
10052
10072
  }
10053
10073
  refreshSharedStateBeforeRender() {
10054
10074
  var _a;
@@ -11203,6 +11223,16 @@ class GraphicImpl extends Node {
11203
11223
  var _a;
11204
11224
  return (_a = this.states) === null || _a === void 0 ? void 0 : _a[stateName];
11205
11225
  }
11226
+ setStateDefinitionsWithCompiled(definitions, compiledDefinitions) {
11227
+ var _a;
11228
+ this.states = definitions;
11229
+ if (this.localStateDefinitionsSource !== definitions) {
11230
+ this.localStateDefinitionsSource = definitions;
11231
+ this.localStateDefinitionsVersion = ((_a = this.localStateDefinitionsVersion) !== null && _a !== void 0 ? _a : 0) + 1;
11232
+ }
11233
+ this.compiledStateDefinitions = compiledDefinitions;
11234
+ this.compiledStateDefinitionsCacheKey = `local:${this.localStateDefinitionsVersion}`;
11235
+ }
11206
11236
  getStateResolveBaseAttrs() {
11207
11237
  var _a;
11208
11238
  return ((_a = this.baseAttributes) !== null && _a !== void 0 ? _a : this.attribute);
@@ -11379,6 +11409,17 @@ class GraphicImpl extends Node {
11379
11409
  }
11380
11410
  return true;
11381
11411
  }
11412
+ hasStatePatch(patch) {
11413
+ if (!patch) {
11414
+ return false;
11415
+ }
11416
+ for (const key in patch) {
11417
+ if (Object.prototype.hasOwnProperty.call(patch, key)) {
11418
+ return true;
11419
+ }
11420
+ }
11421
+ return false;
11422
+ }
11382
11423
  commitSameStatePatchRefresh(states, hasAnimation, animateSameStatePatchChange = false) {
11383
11424
  var _a;
11384
11425
  const previousStates = (_a = this.currentStates) !== null && _a !== void 0 ? _a : EMPTY_STATE_NAMES;
@@ -11494,6 +11535,10 @@ class GraphicImpl extends Node {
11494
11535
  this.resolvedStatePatch = undefined;
11495
11536
  this.sharedStateDirty = false;
11496
11537
  this.clearSharedStateActiveRegistrations();
11538
+ if (!this.attributeMayContainTransientAttrs && !this.hasStatePatch(previousResolvedStatePatch)) {
11539
+ this.emitStateUpdateEvent();
11540
+ return;
11541
+ }
11497
11542
  if (hasAnimation) {
11498
11543
  this._syncFinalAttributeFromStaticTruth();
11499
11544
  const removedStateAnimationAttrs = this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch);
@@ -11578,6 +11623,12 @@ class GraphicImpl extends Node {
11578
11623
  this.resolvedStatePatch = resolvedStateAttrs;
11579
11624
  this.sharedStateDirty = false;
11580
11625
  this.syncSharedStateActiveRegistrations();
11626
+ if (!this.attributeMayContainTransientAttrs &&
11627
+ !this.hasStatePatch(previousResolvedStatePatch) &&
11628
+ !this.hasStatePatch(resolvedStateAttrs)) {
11629
+ this.emitStateUpdateEvent();
11630
+ return;
11631
+ }
11581
11632
  if (hasAnimation) {
11582
11633
  this._syncFinalAttributeFromStaticTruth();
11583
11634
  const removedStateAnimationAttrs = this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch);
@@ -11768,7 +11819,7 @@ class GraphicImpl extends Node {
11768
11819
  this._globalTransMatrix.translate(scrollX, scrollY);
11769
11820
  }
11770
11821
  }
11771
- setStage(stage, layer) {
11822
+ setStage(stage, layer, inheritedSharedStateScope) {
11772
11823
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
11773
11824
  const graphicService = (_c = (_a = stage === null || stage === void 0 ? void 0 : stage.graphicService) !== null && _a !== void 0 ? _a : (_b = this.stage) === null || _b === void 0 ? void 0 : _b.graphicService) !== null && _c !== void 0 ? _c : application.graphicService;
11774
11825
  const previousStage = this.stage;
@@ -11779,7 +11830,7 @@ class GraphicImpl extends Node {
11779
11830
  this.boundSharedStateScope ||
11780
11831
  ((_e = this.registeredActiveScopes) === null || _e === void 0 ? void 0 : _e.size) ||
11781
11832
  this.sharedStateDirty) {
11782
- this.syncSharedStateScopeBindingOnTreeChange(true);
11833
+ this.syncSharedStateScopeBindingOnTreeChange(true, inheritedSharedStateScope);
11783
11834
  }
11784
11835
  this.setStageToShadowRoot(stage, layer);
11785
11836
  if (this.mayHaveTrackedAnimates() && this.hasAnyTrackedAnimate()) {
@@ -11829,7 +11880,7 @@ class GraphicImpl extends Node {
11829
11880
  this.boundSharedStateScope ||
11830
11881
  ((_k = this.registeredActiveScopes) === null || _k === void 0 ? void 0 : _k.size) ||
11831
11882
  this.sharedStateDirty) {
11832
- this.syncSharedStateScopeBindingOnTreeChange(true);
11883
+ this.syncSharedStateScopeBindingOnTreeChange(true, inheritedSharedStateScope);
11833
11884
  }
11834
11885
  }
11835
11886
  detachStageForRelease() {
@@ -15617,8 +15668,8 @@ class RichText extends Graphic {
15617
15668
  clone() {
15618
15669
  return new RichText(Object.assign({}, this.attribute));
15619
15670
  }
15620
- setStage(stage, layer) {
15621
- super.setStage(stage, layer);
15671
+ setStage(stage, layer, inheritedSharedStateScope) {
15672
+ super.setStage(stage, layer, inheritedSharedStateScope);
15622
15673
  const frameCache = this.getFrameCache();
15623
15674
  frameCache.icons.forEach(icon => {
15624
15675
  icon.setStage(stage, layer);
@@ -16539,7 +16590,7 @@ class Group extends Graphic {
16539
16590
  });
16540
16591
  this.addUpdateBoundTag();
16541
16592
  }
16542
- setStage(stage, layer) {
16593
+ setStage(stage, layer, inheritedSharedStateScope) {
16543
16594
  var _a, _b, _c, _d, _e, _f;
16544
16595
  const graphicService = (_c = (_a = stage === null || stage === void 0 ? void 0 : stage.graphicService) !== null && _a !== void 0 ? _a : (_b = this.stage) === null || _b === void 0 ? void 0 : _b.graphicService) !== null && _c !== void 0 ? _c : application.graphicService;
16545
16596
  const needsSharedStateTreeSync = this.hasSharedStateDefinitions() ||
@@ -16553,12 +16604,12 @@ class Group extends Graphic {
16553
16604
  this.layer = layer;
16554
16605
  if (needsSharedStateTreeSync) {
16555
16606
  this.ensureSharedStateScopeBound();
16556
- this.syncSharedStateScopeBindingOnTreeChange(true);
16607
+ this.syncSharedStateScopeBindingOnTreeChange(true, inheritedSharedStateScope);
16557
16608
  }
16558
16609
  this.setStageToShadowRoot(stage, layer);
16559
16610
  this._onSetStage && this._onSetStage(this, stage, layer);
16560
16611
  (_f = graphicService === null || graphicService === void 0 ? void 0 : graphicService.onSetStage) === null || _f === void 0 ? void 0 : _f.call(graphicService, this, stage);
16561
- this.notifyChildrenSharedStateTreeChanged();
16612
+ this.notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope);
16562
16613
  return;
16563
16614
  }
16564
16615
  const layerChanged = this.layer !== layer;
@@ -16567,11 +16618,11 @@ class Group extends Graphic {
16567
16618
  }
16568
16619
  if (needsSharedStateTreeSync) {
16569
16620
  this.ensureSharedStateScopeBound();
16570
- this.syncSharedStateScopeBindingOnTreeChange(true);
16571
- this.notifyChildrenSharedStateTreeChanged();
16621
+ this.syncSharedStateScopeBindingOnTreeChange(true, inheritedSharedStateScope);
16622
+ this.notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope);
16572
16623
  }
16573
16624
  else if (layerChanged) {
16574
- this.notifyChildrenSharedStateTreeChanged();
16625
+ this.notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope);
16575
16626
  }
16576
16627
  }
16577
16628
  addUpdatePositionTag() {
@@ -16666,23 +16717,48 @@ class Group extends Graphic {
16666
16717
  hasSharedStateDefinitions() {
16667
16718
  return !!this._sharedStateDefinitions && Object.keys(this._sharedStateDefinitions).length > 0;
16668
16719
  }
16669
- notifyChildrenSharedStateTreeChanged() {
16720
+ resolveChildSharedStateScope(inheritedSharedStateScope) {
16721
+ var _a;
16722
+ if (this.sharedStateScope) {
16723
+ return this.sharedStateScope;
16724
+ }
16725
+ if (inheritedSharedStateScope !== undefined) {
16726
+ return inheritedSharedStateScope;
16727
+ }
16728
+ return (_a = this.resolveBoundSharedStateScope()) !== null && _a !== void 0 ? _a : null;
16729
+ }
16730
+ notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope) {
16731
+ const childSharedStateScope = this.resolveChildSharedStateScope(inheritedSharedStateScope);
16670
16732
  this.forEachChildren(item => {
16671
- this.syncChildSharedStateTreeBinding(item);
16733
+ this.setStageToChild(item, childSharedStateScope);
16672
16734
  });
16673
16735
  }
16674
- syncChildSharedStateTreeBinding(child) {
16675
- child.onParentSharedStateTreeChanged(this.stage, this.layer);
16736
+ setStageToChild(child, inheritedSharedStateScope) {
16737
+ const graphic = child;
16738
+ if (typeof graphic.setStage === 'function' &&
16739
+ (child.onParentSharedStateTreeChanged === Graphic.prototype.onParentSharedStateTreeChanged ||
16740
+ child.onParentSharedStateTreeChanged === Group.prototype.onParentSharedStateTreeChanged) &&
16741
+ (graphic.stage !== this.stage || graphic.layer !== this.layer)) {
16742
+ graphic.setStage(this.stage, this.layer, inheritedSharedStateScope);
16743
+ return;
16744
+ }
16745
+ child.onParentSharedStateTreeChanged(this.stage, this.layer, inheritedSharedStateScope);
16746
+ }
16747
+ syncChildSharedStateTreeBinding(child, inheritedSharedStateScope) {
16748
+ if (inheritedSharedStateScope === undefined) {
16749
+ inheritedSharedStateScope = this.resolveChildSharedStateScope();
16750
+ }
16751
+ this.setStageToChild(child, inheritedSharedStateScope);
16676
16752
  }
16677
- onParentSharedStateTreeChanged(stage, layer) {
16753
+ onParentSharedStateTreeChanged(stage, layer, inheritedSharedStateScope) {
16678
16754
  var _a;
16679
16755
  if (this.stage !== stage || this.layer !== layer) {
16680
- this.setStage(stage, layer);
16756
+ this.setStage(stage, layer, inheritedSharedStateScope);
16681
16757
  return;
16682
16758
  }
16683
16759
  this.ensureSharedStateScopeBound();
16684
- this.syncSharedStateScopeBindingOnTreeChange(!!((_a = this.currentStates) === null || _a === void 0 ? void 0 : _a.length));
16685
- this.notifyChildrenSharedStateTreeChanged();
16760
+ this.syncSharedStateScopeBindingOnTreeChange(!!((_a = this.currentStates) === null || _a === void 0 ? void 0 : _a.length), inheritedSharedStateScope);
16761
+ this.notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope);
16686
16762
  }
16687
16763
  }
16688
16764
  Group.NOWORK_ANIMATE_ATTR = NOWORK_ANIMATE_ATTR;
@@ -28,5 +28,4 @@ export class DefaultBoundsAllocate {
28
28
  }
29
29
  }
30
30
 
31
- export const boundsAllocate = new DefaultBoundsAllocate;
32
- //# sourceMappingURL=bounds-allocate.js.map
31
+ export const boundsAllocate = new DefaultBoundsAllocate;
@@ -1,4 +1,5 @@
1
1
  export const DefaultStateAnimateConfig = {
2
2
  duration: 200,
3
3
  easing: "cubicOut"
4
- };
4
+ };
5
+ //# sourceMappingURL=config.js.map
@@ -142,12 +142,14 @@ declare abstract class GraphicImpl<T extends Partial<IGraphicAttribute> = Partia
142
142
  getAttributes(): T;
143
143
  protected getStateTransitionOrchestrator(): StateTransitionOrchestrator<T>;
144
144
  protected resolveBoundSharedStateScope(): SharedStateScope<T> | SharedStateScope<Record<string, any>> | undefined;
145
- protected syncSharedStateScopeBindingFromTree(markDirty?: boolean): boolean;
146
- protected syncSharedStateScopeBindingOnTreeChange(markDirty?: boolean): boolean;
145
+ protected syncSharedStateScopeBinding(nextScope: SharedStateScope<T> | SharedStateScope<Record<string, any>> | undefined, markDirty?: boolean): boolean;
146
+ protected syncSharedStateScopeBindingFromTree(markDirty?: boolean, inheritedSharedStateScope?: SharedStateScope<Record<string, any>> | null): boolean;
147
+ protected syncSharedStateScopeBindingOnTreeChange(markDirty?: boolean, inheritedSharedStateScope?: SharedStateScope<Record<string, any>> | null): boolean;
147
148
  protected syncSharedStateActiveRegistrations(): void;
149
+ protected isSharedStateScopeChainRegistered(previousScopes: Set<SharedStateScope<T>>): boolean;
148
150
  protected clearSharedStateActiveRegistrations(): void;
149
151
  protected markSharedStateDirty(): void;
150
- onParentSharedStateTreeChanged(stage?: IStage, layer?: ILayer): void;
152
+ onParentSharedStateTreeChanged(stage?: IStage, layer?: ILayer, inheritedSharedStateScope?: SharedStateScope<Record<string, any>> | null): void;
151
153
  refreshSharedStateBeforeRender(): void;
152
154
  protected getLocalStatesVersion(): number;
153
155
  protected resolveEffectiveCompiledDefinitions(): {
@@ -240,6 +242,7 @@ declare abstract class GraphicImpl<T extends Partial<IGraphicAttribute> = Partia
240
242
  }): void;
241
243
  hasState(stateName?: string): boolean;
242
244
  getState(stateName: string): Partial<T> | StateDefinition<T> | undefined;
245
+ setStateDefinitionsWithCompiled(definitions: StateDefinitionsInput<T>, compiledDefinitions: Map<string, CompiledStateDefinition<T>>): void;
243
246
  protected getStateResolveBaseAttrs(): Partial<T>;
244
247
  protected syncStateResolveContext(stateResolveBaseAttrs?: Partial<T>): Partial<T>;
245
248
  protected ensureStateEngine(stateResolveBaseAttrs?: Partial<T>): StateEngine<T>;
@@ -259,6 +262,7 @@ declare abstract class GraphicImpl<T extends Partial<IGraphicAttribute> = Partia
259
262
  shouldRefreshSameStatePatch: boolean;
260
263
  };
261
264
  protected sameStatePatches(left?: Partial<T>, right?: Partial<T>): boolean;
265
+ protected hasStatePatch(patch?: Partial<T>): boolean;
262
266
  protected commitSameStatePatchRefresh(states: string[], hasAnimation?: boolean, animateSameStatePatchChange?: boolean): void;
263
267
  protected resolveStateAnimateConfig(animateConfig?: IAnimateConfig): any;
264
268
  applyStateAttrs(attrs: Partial<T>, stateNames: string[], hasAnimation?: boolean, isClear?: boolean, animateConfig?: IAnimateConfig, extraAnimateAttrs?: Partial<T>, stateTransitionTargetAttrs?: Partial<T>): void;
@@ -295,7 +299,7 @@ declare abstract class GraphicImpl<T extends Partial<IGraphicAttribute> = Partia
295
299
  }, resetScale?: boolean): [number, number];
296
300
  protected doUpdateLocalMatrix(): void;
297
301
  protected doUpdateGlobalMatrix(): void;
298
- setStage(stage?: IStage, layer?: ILayer): void;
302
+ setStage(stage?: IStage, layer?: ILayer, inheritedSharedStateScope?: SharedStateScope<Record<string, any>> | null): void;
299
303
  detachStageForRelease(): void;
300
304
  setStageToShadowRoot(stage?: IStage, layer?: ILayer): void;
301
305
  onAddStep(step: IStep): void;
@@ -181,9 +181,8 @@ class GraphicImpl extends Node {
181
181
  }
182
182
  return null === (_a = this.stage) || void 0 === _a ? void 0 : _a.rootSharedStateScope;
183
183
  }
184
- syncSharedStateScopeBindingFromTree(markDirty = !0) {
184
+ syncSharedStateScopeBinding(nextScope, markDirty = !0) {
185
185
  var _a;
186
- const nextScope = this.resolveBoundSharedStateScope();
187
186
  return this.boundSharedStateScope === nextScope ? (this.syncSharedStateActiveRegistrations(),
188
187
  !1) : (this.boundSharedStateScope = nextScope, this.boundSharedStateRevision = void 0,
189
188
  this.compiledStateDefinitions = void 0, this.compiledStateDefinitionsCacheKey = void 0,
@@ -191,9 +190,13 @@ class GraphicImpl extends Node {
191
190
  markDirty && (null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) && this.markSharedStateDirty(),
192
191
  !0);
193
192
  }
194
- syncSharedStateScopeBindingOnTreeChange(markDirty = !0) {
193
+ syncSharedStateScopeBindingFromTree(markDirty = !0, inheritedSharedStateScope) {
194
+ const nextScope = void 0 === inheritedSharedStateScope ? this.resolveBoundSharedStateScope() : null != inheritedSharedStateScope ? inheritedSharedStateScope : void 0;
195
+ return this.syncSharedStateScopeBinding(nextScope, markDirty);
196
+ }
197
+ syncSharedStateScopeBindingOnTreeChange(markDirty = !0, inheritedSharedStateScope) {
195
198
  var _a, _b;
196
- 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);
199
+ 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);
197
200
  }
198
201
  syncSharedStateActiveRegistrations() {
199
202
  var _a;
@@ -201,6 +204,7 @@ class GraphicImpl extends Node {
201
204
  if (!(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) || !this.boundSharedStateScope) return (null == previousScopes ? void 0 : previousScopes.size) && (previousScopes.forEach((scope => {
202
205
  scope.subtreeActiveDescendants.delete(this);
203
206
  })), previousScopes.clear()), void (this.registeredActiveScopes = void 0);
207
+ if ((null == previousScopes ? void 0 : previousScopes.size) && this.isSharedStateScopeChainRegistered(previousScopes)) return;
204
208
  const nextScopes = new Set(collectSharedStateScopeChain(this.boundSharedStateScope));
205
209
  null == previousScopes || previousScopes.forEach((scope => {
206
210
  nextScopes.has(scope) || scope.subtreeActiveDescendants.delete(this);
@@ -208,6 +212,14 @@ class GraphicImpl extends Node {
208
212
  scope.subtreeActiveDescendants.add(this);
209
213
  })), this.registeredActiveScopes = nextScopes;
210
214
  }
215
+ isSharedStateScopeChainRegistered(previousScopes) {
216
+ let scope = this.boundSharedStateScope, scopeCount = 0;
217
+ for (;scope; ) {
218
+ if (!previousScopes.has(scope)) return !1;
219
+ scopeCount += 1, scope = scope.parentScope;
220
+ }
221
+ return scopeCount === previousScopes.size;
222
+ }
211
223
  clearSharedStateActiveRegistrations() {
212
224
  const previousScopes = this.registeredActiveScopes;
213
225
  previousScopes && (previousScopes.forEach((scope => {
@@ -218,8 +230,8 @@ class GraphicImpl extends Node {
218
230
  this.sharedStateDirty = !0, enqueueGraphicSharedStateRefresh(this.stage, this),
219
231
  scheduleStageSharedStateRefresh(this.stage);
220
232
  }
221
- onParentSharedStateTreeChanged(stage, layer) {
222
- this.stage === stage && this.layer === layer ? this.syncSharedStateScopeBindingOnTreeChange() : this.setStage(stage, layer);
233
+ onParentSharedStateTreeChanged(stage, layer, inheritedSharedStateScope) {
234
+ this.stage === stage && this.layer === layer ? this.syncSharedStateScopeBindingOnTreeChange(!0, inheritedSharedStateScope) : this.setStage(stage, layer, inheritedSharedStateScope);
223
235
  }
224
236
  refreshSharedStateBeforeRender() {
225
237
  var _a;
@@ -861,6 +873,12 @@ class GraphicImpl extends Node {
861
873
  var _a;
862
874
  return null === (_a = this.states) || void 0 === _a ? void 0 : _a[stateName];
863
875
  }
876
+ setStateDefinitionsWithCompiled(definitions, compiledDefinitions) {
877
+ var _a;
878
+ this.states = definitions, this.localStateDefinitionsSource !== definitions && (this.localStateDefinitionsSource = definitions,
879
+ this.localStateDefinitionsVersion = (null !== (_a = this.localStateDefinitionsVersion) && void 0 !== _a ? _a : 0) + 1),
880
+ this.compiledStateDefinitions = compiledDefinitions, this.compiledStateDefinitionsCacheKey = `local:${this.localStateDefinitionsVersion}`;
881
+ }
864
882
  getStateResolveBaseAttrs() {
865
883
  var _a;
866
884
  return null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : this.attribute;
@@ -975,6 +993,11 @@ class GraphicImpl extends Node {
975
993
  }
976
994
  return !0;
977
995
  }
996
+ hasStatePatch(patch) {
997
+ if (!patch) return !1;
998
+ for (const key in patch) if (Object.prototype.hasOwnProperty.call(patch, key)) return !0;
999
+ return !1;
1000
+ }
978
1001
  commitSameStatePatchRefresh(states, hasAnimation, animateSameStatePatchChange = !1) {
979
1002
  var _a;
980
1003
  const previousStates = null !== (_a = this.currentStates) && void 0 !== _a ? _a : EMPTY_STATE_NAMES, previousResolvedStatePatch = this.resolvedStatePatch, {transition: transition, effectiveStates: effectiveStates, resolvedStateAttrs: resolvedStateAttrs} = this.resolveGraphicStateTransition(states, !0), patchChanged = !this.sameStatePatches(previousResolvedStatePatch, resolvedStateAttrs);
@@ -1038,7 +1061,7 @@ class GraphicImpl extends Node {
1038
1061
  const resolvedStateAttrs = hasAnimation || this.hasCustomEvent("beforeStateUpdate") ? cloneAttributeValue(null !== (_b = this.baseAttributes) && void 0 !== _b ? _b : {}) : null !== (_c = this.baseAttributes) && void 0 !== _c ? _c : {};
1039
1062
  if (!transition.changed || this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !0)) if (this.currentStates = transition.states,
1040
1063
  this.effectiveStates = [], this.resolvedStatePatch = void 0, this.sharedStateDirty = !1,
1041
- this.clearSharedStateActiveRegistrations(), hasAnimation) {
1064
+ this.clearSharedStateActiveRegistrations(), this.attributeMayContainTransientAttrs || this.hasStatePatch(previousResolvedStatePatch)) if (hasAnimation) {
1042
1065
  this._syncFinalAttributeFromStaticTruth();
1043
1066
  const removedStateAnimationAttrs = this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch);
1044
1067
  this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !0, void 0, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.extraAttrs, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.stateTransitionTargetAttrs);
@@ -1046,7 +1069,7 @@ class GraphicImpl extends Node {
1046
1069
  type: AttributeUpdateType.STATE
1047
1070
  }) : this.restoreAttributeFromStatePatchDelta(previousResolvedStatePatch, void 0, {
1048
1071
  type: AttributeUpdateType.STATE
1049
- }), this.emitStateUpdateEvent();
1072
+ }), this.emitStateUpdateEvent(); else this.emitStateUpdateEvent();
1050
1073
  }
1051
1074
  removeState(stateName, hasAnimation) {
1052
1075
  const transition = this.resolveRemoveStateTransition(stateName);
@@ -1077,7 +1100,7 @@ class GraphicImpl extends Node {
1077
1100
  const previousStates = null !== (_a = this.currentStates) && void 0 !== _a ? _a : EMPTY_STATE_NAMES, previousResolvedStatePatch = this.resolvedStatePatch, {transition: transition, effectiveStates: effectiveStates, resolvedStateAttrs: resolvedStateAttrs} = this.resolveGraphicStateTransition(states);
1078
1101
  if ((transition.changed || !this.sameStateNames(previousStates, transition.states)) && this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !1)) if (this.currentStates = transition.states,
1079
1102
  this.effectiveStates = [ ...effectiveStates ], this.resolvedStatePatch = resolvedStateAttrs,
1080
- this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(), hasAnimation) {
1103
+ this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(), this.attributeMayContainTransientAttrs || this.hasStatePatch(previousResolvedStatePatch) || this.hasStatePatch(resolvedStateAttrs)) if (hasAnimation) {
1081
1104
  this._syncFinalAttributeFromStaticTruth();
1082
1105
  const removedStateAnimationAttrs = this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch);
1083
1106
  this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !1, void 0, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.extraAttrs, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.stateTransitionTargetAttrs);
@@ -1085,7 +1108,7 @@ class GraphicImpl extends Node {
1085
1108
  type: AttributeUpdateType.STATE
1086
1109
  }) : this.restoreAttributeFromStatePatchDelta(previousResolvedStatePatch, this.resolvedStatePatch, {
1087
1110
  type: AttributeUpdateType.STATE
1088
- }), this.emitStateUpdateEvent();
1111
+ }), this.emitStateUpdateEvent(); else this.emitStateUpdateEvent();
1089
1112
  }
1090
1113
  invalidateResolver() {
1091
1114
  var _a, _b;
@@ -1195,11 +1218,11 @@ class GraphicImpl extends Node {
1195
1218
  this._globalTransMatrix.translate(scrollX, scrollY);
1196
1219
  }
1197
1220
  }
1198
- setStage(stage, layer) {
1221
+ setStage(stage, layer, inheritedSharedStateScope) {
1199
1222
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1200
1223
  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, previousStage = this.stage;
1201
1224
  if (this.stage !== stage || this.layer !== layer) {
1202
- 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),
1225
+ 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),
1203
1226
  this.setStageToShadowRoot(stage, layer), this.mayHaveTrackedAnimates() && this.hasAnyTrackedAnimate()) {
1204
1227
  const previousTimeline = null === (_f = null == previousStage ? void 0 : previousStage.getTimeline) || void 0 === _f ? void 0 : _f.call(previousStage), nextTimeline = null === (_g = null == stage ? void 0 : stage.getTimeline) || void 0 === _g ? void 0 : _g.call(stage), detachedStageAnimates = [];
1205
1228
  this.visitTrackedAnimates((a => {
@@ -1217,7 +1240,7 @@ class GraphicImpl extends Node {
1217
1240
  }
1218
1241
  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));
1219
1242
  }
1220
- ((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);
1243
+ ((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);
1221
1244
  }
1222
1245
  detachStageForRelease() {
1223
1246
  var _a, _b, _c;