@visactor/vrender-core 1.1.5 → 1.1.6-alpha.0

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.
@@ -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(): {
@@ -237,6 +239,7 @@ declare abstract class GraphicImpl<T extends Partial<IGraphicAttribute> = Partia
237
239
  }): void;
238
240
  hasState(stateName?: string): boolean;
239
241
  getState(stateName: string): Partial<T> | StateDefinition<T> | undefined;
242
+ setStateDefinitionsWithCompiled(definitions: StateDefinitionsInput<T>, compiledDefinitions: Map<string, CompiledStateDefinition<T>>): void;
240
243
  protected getStateResolveBaseAttrs(): Partial<T>;
241
244
  protected syncStateResolveContext(stateResolveBaseAttrs?: Partial<T>): Partial<T>;
242
245
  protected ensureStateEngine(stateResolveBaseAttrs?: Partial<T>): StateEngine<T>;
@@ -292,7 +295,7 @@ declare abstract class GraphicImpl<T extends Partial<IGraphicAttribute> = Partia
292
295
  }, resetScale?: boolean): [number, number];
293
296
  protected doUpdateLocalMatrix(): void;
294
297
  protected doUpdateGlobalMatrix(): void;
295
- setStage(stage?: IStage, layer?: ILayer): void;
298
+ setStage(stage?: IStage, layer?: ILayer, inheritedSharedStateScope?: SharedStateScope<Record<string, any>> | null): void;
296
299
  detachStageForRelease(): void;
297
300
  setStageToShadowRoot(stage?: IStage, layer?: ILayer): void;
298
301
  onAddStep(step: IStep): void;
@@ -144,9 +144,8 @@ class GraphicImpl extends node_tree_1.Node {
144
144
  }
145
145
  return null === (_a = this.stage) || void 0 === _a ? void 0 : _a.rootSharedStateScope;
146
146
  }
147
- syncSharedStateScopeBindingFromTree(markDirty = !0) {
147
+ syncSharedStateScopeBinding(nextScope, markDirty = !0) {
148
148
  var _a;
149
- const nextScope = this.resolveBoundSharedStateScope();
150
149
  return this.boundSharedStateScope === nextScope ? (this.syncSharedStateActiveRegistrations(),
151
150
  !1) : (this.boundSharedStateScope = nextScope, this.boundSharedStateRevision = void 0,
152
151
  this.compiledStateDefinitions = void 0, this.compiledStateDefinitionsCacheKey = void 0,
@@ -154,9 +153,13 @@ class GraphicImpl extends node_tree_1.Node {
154
153
  markDirty && (null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) && this.markSharedStateDirty(),
155
154
  !0);
156
155
  }
157
- syncSharedStateScopeBindingOnTreeChange(markDirty = !0) {
156
+ syncSharedStateScopeBindingFromTree(markDirty = !0, inheritedSharedStateScope) {
157
+ const nextScope = void 0 === inheritedSharedStateScope ? this.resolveBoundSharedStateScope() : null != inheritedSharedStateScope ? inheritedSharedStateScope : void 0;
158
+ return this.syncSharedStateScopeBinding(nextScope, markDirty);
159
+ }
160
+ syncSharedStateScopeBindingOnTreeChange(markDirty = !0, inheritedSharedStateScope) {
158
161
  var _a, _b;
159
- 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);
162
+ 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);
160
163
  }
161
164
  syncSharedStateActiveRegistrations() {
162
165
  var _a;
@@ -164,6 +167,7 @@ class GraphicImpl extends node_tree_1.Node {
164
167
  if (!(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) || !this.boundSharedStateScope) return (null == previousScopes ? void 0 : previousScopes.size) && (previousScopes.forEach((scope => {
165
168
  scope.subtreeActiveDescendants.delete(this);
166
169
  })), previousScopes.clear()), void (this.registeredActiveScopes = void 0);
170
+ if ((null == previousScopes ? void 0 : previousScopes.size) && this.isSharedStateScopeChainRegistered(previousScopes)) return;
167
171
  const nextScopes = new Set((0, shared_state_scope_1.collectSharedStateScopeChain)(this.boundSharedStateScope));
168
172
  null == previousScopes || previousScopes.forEach((scope => {
169
173
  nextScopes.has(scope) || scope.subtreeActiveDescendants.delete(this);
@@ -171,6 +175,14 @@ class GraphicImpl extends node_tree_1.Node {
171
175
  scope.subtreeActiveDescendants.add(this);
172
176
  })), this.registeredActiveScopes = nextScopes;
173
177
  }
178
+ isSharedStateScopeChainRegistered(previousScopes) {
179
+ let scope = this.boundSharedStateScope, scopeCount = 0;
180
+ for (;scope; ) {
181
+ if (!previousScopes.has(scope)) return !1;
182
+ scopeCount += 1, scope = scope.parentScope;
183
+ }
184
+ return scopeCount === previousScopes.size;
185
+ }
174
186
  clearSharedStateActiveRegistrations() {
175
187
  const previousScopes = this.registeredActiveScopes;
176
188
  previousScopes && (previousScopes.forEach((scope => {
@@ -181,8 +193,8 @@ class GraphicImpl extends node_tree_1.Node {
181
193
  this.sharedStateDirty = !0, (0, shared_state_refresh_1.enqueueGraphicSharedStateRefresh)(this.stage, this),
182
194
  (0, shared_state_refresh_1.scheduleStageSharedStateRefresh)(this.stage);
183
195
  }
184
- onParentSharedStateTreeChanged(stage, layer) {
185
- this.stage === stage && this.layer === layer ? this.syncSharedStateScopeBindingOnTreeChange() : this.setStage(stage, layer);
196
+ onParentSharedStateTreeChanged(stage, layer, inheritedSharedStateScope) {
197
+ this.stage === stage && this.layer === layer ? this.syncSharedStateScopeBindingOnTreeChange(!0, inheritedSharedStateScope) : this.setStage(stage, layer, inheritedSharedStateScope);
186
198
  }
187
199
  refreshSharedStateBeforeRender() {
188
200
  var _a;
@@ -832,6 +844,12 @@ class GraphicImpl extends node_tree_1.Node {
832
844
  var _a;
833
845
  return null === (_a = this.states) || void 0 === _a ? void 0 : _a[stateName];
834
846
  }
847
+ setStateDefinitionsWithCompiled(definitions, compiledDefinitions) {
848
+ var _a;
849
+ this.states = definitions, this.localStateDefinitionsSource !== definitions && (this.localStateDefinitionsSource = definitions,
850
+ this.localStateDefinitionsVersion = (null !== (_a = this.localStateDefinitionsVersion) && void 0 !== _a ? _a : 0) + 1),
851
+ this.compiledStateDefinitions = compiledDefinitions, this.compiledStateDefinitionsCacheKey = `local:${this.localStateDefinitionsVersion}`;
852
+ }
835
853
  getStateResolveBaseAttrs() {
836
854
  var _a;
837
855
  return null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : this.attribute;
@@ -1157,11 +1175,11 @@ class GraphicImpl extends node_tree_1.Node {
1157
1175
  this._globalTransMatrix.translate(scrollX, scrollY);
1158
1176
  }
1159
1177
  }
1160
- setStage(stage, layer) {
1178
+ setStage(stage, layer, inheritedSharedStateScope) {
1161
1179
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1162
1180
  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_1.application.graphicService, previousStage = this.stage;
1163
1181
  if (this.stage !== stage || this.layer !== layer) {
1164
- 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),
1182
+ 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),
1165
1183
  this.setStageToShadowRoot(stage, layer), this.mayHaveTrackedAnimates() && this.hasAnyTrackedAnimate()) {
1166
1184
  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 = [];
1167
1185
  this.visitTrackedAnimates((a => {
@@ -1179,7 +1197,7 @@ class GraphicImpl extends node_tree_1.Node {
1179
1197
  }
1180
1198
  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));
1181
1199
  }
1182
- ((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);
1200
+ ((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);
1183
1201
  }
1184
1202
  detachStageForRelease() {
1185
1203
  var _a, _b, _c;