@visactor/vrender-core 1.1.7 → 1.1.8-alpha.1

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 +2 -1
  2. package/cjs/animate/config.js +1 -2
  3. package/cjs/graphic/graphic.d.ts +7 -4
  4. package/cjs/graphic/graphic.js +27 -9
  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 +82 -27
  20. package/es/allocator/bounds-allocate.js +2 -1
  21. package/es/animate/config.js +1 -2
  22. package/es/graphic/graphic.d.ts +7 -4
  23. package/es/graphic/graphic.js +27 -9
  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 +3 -3
@@ -34,4 +34,5 @@ class DefaultBoundsAllocate {
34
34
  }
35
35
  }
36
36
 
37
- exports.DefaultBoundsAllocate = DefaultBoundsAllocate, exports.boundsAllocate = new DefaultBoundsAllocate;
37
+ exports.DefaultBoundsAllocate = DefaultBoundsAllocate, exports.boundsAllocate = new DefaultBoundsAllocate;
38
+ //# sourceMappingURL=bounds-allocate.js.map
@@ -5,5 +5,4 @@ Object.defineProperty(exports, "__esModule", {
5
5
  }), exports.DefaultStateAnimateConfig = void 0, exports.DefaultStateAnimateConfig = {
6
6
  duration: 200,
7
7
  easing: "cubicOut"
8
- };
9
- //# sourceMappingURL=config.js.map
8
+ };
@@ -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>;
@@ -295,7 +298,7 @@ declare abstract class GraphicImpl<T extends Partial<IGraphicAttribute> = Partia
295
298
  }, resetScale?: boolean): [number, number];
296
299
  protected doUpdateLocalMatrix(): void;
297
300
  protected doUpdateGlobalMatrix(): void;
298
- setStage(stage?: IStage, layer?: ILayer): void;
301
+ setStage(stage?: IStage, layer?: ILayer, inheritedSharedStateScope?: SharedStateScope<Record<string, any>> | null): void;
299
302
  detachStageForRelease(): void;
300
303
  setStageToShadowRoot(stage?: IStage, layer?: ILayer): void;
301
304
  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;
@@ -831,6 +843,12 @@ class GraphicImpl extends node_tree_1.Node {
831
843
  var _a;
832
844
  return null === (_a = this.states) || void 0 === _a ? void 0 : _a[stateName];
833
845
  }
846
+ setStateDefinitionsWithCompiled(definitions, compiledDefinitions) {
847
+ var _a;
848
+ this.states = definitions, this.localStateDefinitionsSource !== definitions && (this.localStateDefinitionsSource = definitions,
849
+ this.localStateDefinitionsVersion = (null !== (_a = this.localStateDefinitionsVersion) && void 0 !== _a ? _a : 0) + 1),
850
+ this.compiledStateDefinitions = compiledDefinitions, this.compiledStateDefinitionsCacheKey = `local:${this.localStateDefinitionsVersion}`;
851
+ }
834
852
  getStateResolveBaseAttrs() {
835
853
  var _a;
836
854
  return null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : this.attribute;
@@ -1166,11 +1184,11 @@ class GraphicImpl extends node_tree_1.Node {
1166
1184
  this._globalTransMatrix.translate(scrollX, scrollY);
1167
1185
  }
1168
1186
  }
1169
- setStage(stage, layer) {
1187
+ setStage(stage, layer, inheritedSharedStateScope) {
1170
1188
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1171
1189
  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;
1172
1190
  if (this.stage !== stage || this.layer !== layer) {
1173
- 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),
1191
+ 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),
1174
1192
  this.setStageToShadowRoot(stage, layer), this.mayHaveTrackedAnimates() && this.hasAnyTrackedAnimate()) {
1175
1193
  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 = [];
1176
1194
  this.visitTrackedAnimates((a => {
@@ -1188,7 +1206,7 @@ class GraphicImpl extends node_tree_1.Node {
1188
1206
  }
1189
1207
  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));
1190
1208
  }
1191
- ((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);
1209
+ ((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);
1192
1210
  }
1193
1211
  detachStageForRelease() {
1194
1212
  var _a, _b, _c;