@visactor/vrender-core 1.1.4-alpha.1 → 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.
Files changed (96) hide show
  1. package/cjs/common/bounds-context.js +1 -2
  2. package/cjs/common/custom-path2d.js +2 -1
  3. package/cjs/common/module-guard.js +1 -1
  4. package/cjs/common/morphing-utils.js +1 -1
  5. package/cjs/common/path-svg.js +1 -1
  6. package/cjs/common/performance-raf.js +1 -2
  7. package/cjs/common/polygon.js +2 -2
  8. package/cjs/common/rect-utils.js +1 -1
  9. package/cjs/common/render-area.js +1 -1
  10. package/cjs/common/render-command-list.js +1 -1
  11. package/cjs/common/render-curve.js +1 -1
  12. package/cjs/common/render-utils.js +1 -1
  13. package/cjs/common/seg-context.js +1 -1
  14. package/cjs/core/camera.js +1 -1
  15. package/cjs/core/constants.js +1 -1
  16. package/cjs/core/core-modules.js +2 -1
  17. package/cjs/core/global.js +1 -1
  18. package/cjs/core/graphic-utils.js +1 -1
  19. package/cjs/core/index.js +1 -1
  20. package/cjs/core/layer-service.js +1 -1
  21. package/cjs/core/layer.js +1 -1
  22. package/cjs/core/light.js +1 -1
  23. package/cjs/core/stage.js +1 -1
  24. package/cjs/core/window.js +1 -1
  25. package/cjs/graphic/graphic.d.ts +7 -4
  26. package/cjs/graphic/graphic.js +31 -11
  27. package/cjs/graphic/graphic.js.map +1 -1
  28. package/cjs/graphic/group.d.ts +7 -4
  29. package/cjs/graphic/group.js +31 -17
  30. package/cjs/graphic/group.js.map +1 -1
  31. package/cjs/graphic/node-tree.d.ts +2 -1
  32. package/cjs/graphic/node-tree.js +1 -1
  33. package/cjs/graphic/node-tree.js.map +1 -1
  34. package/cjs/graphic/richtext/utils.js +3 -0
  35. package/cjs/graphic/richtext/utils.js.map +1 -1
  36. package/cjs/graphic/richtext.d.ts +4 -1
  37. package/cjs/graphic/richtext.js +2 -2
  38. package/cjs/graphic/richtext.js.map +1 -1
  39. package/cjs/graphic/state/state-engine.d.ts +1 -0
  40. package/cjs/graphic/state/state-engine.js +17 -0
  41. package/cjs/graphic/state/state-engine.js.map +1 -1
  42. package/cjs/interface/graphic/richText.d.ts +2 -0
  43. package/cjs/interface/graphic/richText.js.map +1 -1
  44. package/cjs/interface/graphic.d.ts +1 -1
  45. package/cjs/interface/graphic.js.map +1 -1
  46. package/cjs/interface/node-tree.d.ts +2 -1
  47. package/cjs/interface/node-tree.js.map +1 -1
  48. package/dist/index.es.js +134 -36
  49. package/es/common/bounds-context.js +1 -2
  50. package/es/common/custom-path2d.js +2 -1
  51. package/es/common/module-guard.js +1 -1
  52. package/es/common/morphing-utils.js +1 -1
  53. package/es/common/path-svg.js +1 -1
  54. package/es/common/performance-raf.js +1 -2
  55. package/es/common/polygon.js +1 -1
  56. package/es/common/rect-utils.js +1 -1
  57. package/es/common/render-area.js +1 -1
  58. package/es/common/render-command-list.js +1 -1
  59. package/es/common/render-curve.js +1 -1
  60. package/es/common/render-utils.js +1 -1
  61. package/es/common/seg-context.js +1 -1
  62. package/es/core/camera.js +1 -1
  63. package/es/core/constants.js +1 -1
  64. package/es/core/core-modules.js +2 -1
  65. package/es/core/global.js +1 -1
  66. package/es/core/graphic-utils.js +1 -1
  67. package/es/core/index.js +1 -1
  68. package/es/core/layer-service.js +1 -1
  69. package/es/core/layer.js +1 -1
  70. package/es/core/light.js +1 -1
  71. package/es/core/stage.js +1 -1
  72. package/es/core/window.js +1 -1
  73. package/es/graphic/graphic.d.ts +7 -4
  74. package/es/graphic/graphic.js +31 -11
  75. package/es/graphic/graphic.js.map +1 -1
  76. package/es/graphic/group.d.ts +7 -4
  77. package/es/graphic/group.js +31 -17
  78. package/es/graphic/group.js.map +1 -1
  79. package/es/graphic/node-tree.d.ts +2 -1
  80. package/es/graphic/node-tree.js +1 -1
  81. package/es/graphic/node-tree.js.map +1 -1
  82. package/es/graphic/richtext/utils.js +3 -0
  83. package/es/graphic/richtext/utils.js.map +1 -1
  84. package/es/graphic/richtext.d.ts +4 -1
  85. package/es/graphic/richtext.js +2 -2
  86. package/es/graphic/richtext.js.map +1 -1
  87. package/es/graphic/state/state-engine.d.ts +1 -0
  88. package/es/graphic/state/state-engine.js +17 -0
  89. package/es/graphic/state/state-engine.js.map +1 -1
  90. package/es/interface/graphic/richText.d.ts +2 -0
  91. package/es/interface/graphic/richText.js.map +1 -1
  92. package/es/interface/graphic.d.ts +1 -1
  93. package/es/interface/graphic.js.map +1 -1
  94. package/es/interface/node-tree.d.ts +2 -1
  95. package/es/interface/node-tree.js.map +1 -1
  96. package/package.json +3 -3
package/es/core/camera.js CHANGED
@@ -66,4 +66,4 @@ export class OrthoCamera {
66
66
  export const registerOrthoCamera = () => {
67
67
  Factory.registerPlugin("OrthoCamera", OrthoCamera);
68
68
  };
69
- //# sourceMappingURL=camera.js.map
69
+ //# sourceMappingURL=camera.js.map
@@ -9,4 +9,4 @@ export const StaticLayerHandlerContribution = Symbol.for("StaticLayerHandlerCont
9
9
  export const DynamicLayerHandlerContribution = Symbol.for("DynamicLayerHandlerContribution");
10
10
 
11
11
  export const VirtualLayerHandlerContribution = Symbol.for("VirtualLayerHandlerContribution");
12
- //# sourceMappingURL=constants.js.map
12
+ //# sourceMappingURL=constants.js.map
@@ -20,4 +20,5 @@ export function bindCoreModules({bind: bind}) {
20
20
  bind(TransformUtil).to(DefaultTransformUtil).inSingletonScope(), bind(LayerService).to(DefaultLayerService).inSingletonScope();
21
21
  }
22
22
 
23
- export default bindCoreModules;
23
+ export default bindCoreModules;
24
+ //# sourceMappingURL=core-modules.js.map
package/es/core/global.js CHANGED
@@ -222,4 +222,4 @@ export class DefaultGlobal extends EventListenerManager {
222
222
  return this._env || this.setEnv("browser"), this.envContribution.copyToClipBoard(text);
223
223
  }
224
224
  }
225
- //# sourceMappingURL=global.js.map
225
+ //# sourceMappingURL=global.js.map
@@ -162,4 +162,4 @@ export class DefaultTransformUtil {
162
162
  return this;
163
163
  }
164
164
  }
165
- //# sourceMappingURL=graphic-utils.js.map
165
+ //# sourceMappingURL=graphic-utils.js.map
package/es/core/index.js CHANGED
@@ -15,4 +15,4 @@ export * from "./layer-service";
15
15
  export * from "./constants";
16
16
 
17
17
  export * from "../interface/core";
18
- //# sourceMappingURL=index.js.map
18
+ //# sourceMappingURL=index.js.map
@@ -76,4 +76,4 @@ export class DefaultLayerService {
76
76
  }
77
77
 
78
78
  DefaultLayerService.idprefix = "visactor_layer", DefaultLayerService.prefix_count = 0;
79
- //# sourceMappingURL=layer-service.js.map
79
+ //# sourceMappingURL=layer-service.js.map
package/es/core/layer.js CHANGED
@@ -112,4 +112,4 @@ export class Layer extends Group {
112
112
  }, params)), this.afterDrawCbs.forEach((c => c(this)));
113
113
  }
114
114
  }
115
- //# sourceMappingURL=layer.js.map
115
+ //# sourceMappingURL=layer.js.map
package/es/core/light.js CHANGED
@@ -23,4 +23,4 @@ export class DirectionalLight {
23
23
  export const registerDirectionalLight = () => {
24
24
  Factory.registerPlugin("DirectionalLight", DirectionalLight);
25
25
  };
26
- //# sourceMappingURL=light.js.map
26
+ //# sourceMappingURL=light.js.map
package/es/core/stage.js CHANGED
@@ -595,4 +595,4 @@ export class Stage extends Group {
595
595
  this.renderService.reInit(), this.pickerService.reInit();
596
596
  }
597
597
  }
598
- //# sourceMappingURL=stage.js.map
598
+ //# sourceMappingURL=stage.js.map
package/es/core/window.js CHANGED
@@ -150,4 +150,4 @@ export class DefaultWindow extends EventListenerManager {
150
150
  return this._handler.getTopLeft(baseWindow);
151
151
  }
152
152
  }
153
- //# sourceMappingURL=window.js.map
153
+ //# sourceMappingURL=window.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(): {
@@ -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;
@@ -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;
@@ -862,6 +874,12 @@ class GraphicImpl extends Node {
862
874
  var _a;
863
875
  return null === (_a = this.states) || void 0 === _a ? void 0 : _a[stateName];
864
876
  }
877
+ setStateDefinitionsWithCompiled(definitions, compiledDefinitions) {
878
+ var _a;
879
+ this.states = definitions, this.localStateDefinitionsSource !== definitions && (this.localStateDefinitionsSource = definitions,
880
+ this.localStateDefinitionsVersion = (null !== (_a = this.localStateDefinitionsVersion) && void 0 !== _a ? _a : 0) + 1),
881
+ this.compiledStateDefinitions = compiledDefinitions, this.compiledStateDefinitionsCacheKey = `local:${this.localStateDefinitionsVersion}`;
882
+ }
865
883
  getStateResolveBaseAttrs() {
866
884
  var _a;
867
885
  return null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : this.attribute;
@@ -1050,8 +1068,10 @@ class GraphicImpl extends Node {
1050
1068
  transition.changed && this.useStates(transition.states, hasAnimation);
1051
1069
  }
1052
1070
  addState(stateName, keepCurrentStates, hasAnimation) {
1053
- const transition = this.resolveAddStateTransition(stateName, keepCurrentStates);
1054
- transition.changed && this.useStates(transition.states, hasAnimation);
1071
+ const currentStates = this.currentStates;
1072
+ if ((null == currentStates ? void 0 : currentStates.includes(stateName)) && (keepCurrentStates || 1 === currentStates.length)) return;
1073
+ const nextStates = keepCurrentStates && (null == currentStates ? void 0 : currentStates.length) ? currentStates.concat([ stateName ]) : [ stateName ];
1074
+ this.useStates(nextStates, hasAnimation);
1055
1075
  }
1056
1076
  setStates(states, options) {
1057
1077
  var _a, _b, _c;
@@ -1186,11 +1206,11 @@ class GraphicImpl extends Node {
1186
1206
  this._globalTransMatrix.translate(scrollX, scrollY);
1187
1207
  }
1188
1208
  }
1189
- setStage(stage, layer) {
1209
+ setStage(stage, layer, inheritedSharedStateScope) {
1190
1210
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1191
1211
  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;
1192
1212
  if (this.stage !== stage || this.layer !== layer) {
1193
- 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),
1213
+ 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),
1194
1214
  this.setStageToShadowRoot(stage, layer), this.mayHaveTrackedAnimates() && this.hasAnyTrackedAnimate()) {
1195
1215
  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 = [];
1196
1216
  this.visitTrackedAnimates((a => {
@@ -1208,7 +1228,7 @@ class GraphicImpl extends Node {
1208
1228
  }
1209
1229
  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));
1210
1230
  }
1211
- ((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);
1231
+ ((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);
1212
1232
  }
1213
1233
  detachStageForRelease() {
1214
1234
  var _a, _b, _c;