@visactor/vrender-core 1.1.0-alpha.4 → 1.1.0-alpha.6

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 (64) hide show
  1. package/cjs/allocator/bounds-allocate.js +1 -1
  2. package/cjs/allocator/canvas-allocate.js +1 -1
  3. package/cjs/allocator/constants.js +1 -1
  4. package/cjs/allocator/graphic-allocate.js +1 -1
  5. package/cjs/allocator/matrix-allocate.js +1 -1
  6. package/cjs/canvas/constants.js +1 -2
  7. package/cjs/color-string/index.js +2 -1
  8. package/cjs/common/event-transformer.js +1 -2
  9. package/cjs/common/generator.js +2 -1
  10. package/cjs/common/rect-utils.js +1 -1
  11. package/cjs/common/render-area.js +1 -1
  12. package/cjs/common/render-command-list.js +1 -1
  13. package/cjs/common/render-curve.js +1 -1
  14. package/cjs/common/render-utils.js +1 -1
  15. package/cjs/common/seg-context.js +1 -1
  16. package/cjs/common/simplify.js +1 -1
  17. package/cjs/common/sort.js +1 -1
  18. package/cjs/common/split-path.js +1 -1
  19. package/cjs/common/store.js +1 -1
  20. package/cjs/common/text.js +2 -1
  21. package/cjs/common/utils.js +1 -1
  22. package/cjs/core/graphic-utils.js +1 -1
  23. package/cjs/core/index.js +1 -1
  24. package/cjs/core/layer-service.js +1 -2
  25. package/cjs/core/layer.js +1 -1
  26. package/cjs/core/light.js +1 -1
  27. package/cjs/core/stage.js +1 -1
  28. package/cjs/core/window.js +1 -1
  29. package/cjs/graphic/graphic.d.ts +1 -0
  30. package/cjs/graphic/graphic.js +10 -2
  31. package/cjs/graphic/graphic.js.map +1 -1
  32. package/dist/index.es.js +20 -1
  33. package/es/allocator/bounds-allocate.js +1 -1
  34. package/es/allocator/canvas-allocate.js +1 -1
  35. package/es/allocator/constants.js +1 -1
  36. package/es/allocator/graphic-allocate.js +1 -1
  37. package/es/allocator/matrix-allocate.js +1 -1
  38. package/es/canvas/constants.js +1 -2
  39. package/es/color-string/index.js +2 -1
  40. package/es/common/event-transformer.js +1 -2
  41. package/es/common/generator.js +2 -1
  42. package/es/common/rect-utils.js +1 -1
  43. package/es/common/render-area.js +1 -1
  44. package/es/common/render-command-list.js +1 -1
  45. package/es/common/render-curve.js +1 -1
  46. package/es/common/render-utils.js +1 -1
  47. package/es/common/seg-context.js +1 -1
  48. package/es/common/simplify.js +1 -1
  49. package/es/common/sort.js +1 -1
  50. package/es/common/split-path.js +1 -1
  51. package/es/common/store.js +1 -1
  52. package/es/common/text.js +2 -1
  53. package/es/common/utils.js +1 -1
  54. package/es/core/graphic-utils.js +1 -1
  55. package/es/core/index.js +1 -1
  56. package/es/core/layer-service.js +1 -2
  57. package/es/core/layer.js +1 -1
  58. package/es/core/light.js +1 -1
  59. package/es/core/stage.js +1 -1
  60. package/es/core/window.js +1 -1
  61. package/es/graphic/graphic.d.ts +1 -0
  62. package/es/graphic/graphic.js +10 -2
  63. package/es/graphic/graphic.js.map +1 -1
  64. package/package.json +3 -3
package/dist/index.es.js CHANGED
@@ -10859,6 +10859,22 @@ class Graphic extends Node {
10859
10859
  });
10860
10860
  return snapshot;
10861
10861
  }
10862
+ buildStateAnimationTargetAttrs(resolvedStateAttrs, previousResolvedStatePatch) {
10863
+ const targetAttrs = cloneAttributeValue(resolvedStateAttrs);
10864
+ if (!previousResolvedStatePatch) {
10865
+ return targetAttrs;
10866
+ }
10867
+ const snapshot = this.buildStaticAttributeSnapshot();
10868
+ Object.keys(previousResolvedStatePatch).forEach(key => {
10869
+ if (Object.prototype.hasOwnProperty.call(targetAttrs, key)) {
10870
+ return;
10871
+ }
10872
+ targetAttrs[key] = Object.prototype.hasOwnProperty.call(snapshot, key)
10873
+ ? cloneAttributeValue(snapshot[key])
10874
+ : this.getDefaultAttribute(key);
10875
+ });
10876
+ return targetAttrs;
10877
+ }
10862
10878
  syncObjectToSnapshot(target, snapshot) {
10863
10879
  const delta = new Map();
10864
10880
  const keySet = new Set([...Object.keys(target), ...Object.keys(snapshot)]);
@@ -11668,6 +11684,9 @@ class Graphic extends Node {
11668
11684
  return;
11669
11685
  }
11670
11686
  const previousStates = this.currentStates ? this.currentStates.slice() : [];
11687
+ const previousResolvedStatePatch = this.resolvedStatePatch
11688
+ ? cloneAttributeValue(this.resolvedStatePatch)
11689
+ : undefined;
11671
11690
  const stateResolveBaseAttrs = ((_a = this.baseAttributes) !== null && _a !== void 0 ? _a : this.attribute);
11672
11691
  const stateModel = this.createStateModel();
11673
11692
  (_b = this.stateEngine) === null || _b === void 0 ? void 0 : _b.setResolveContext(this, stateResolveBaseAttrs);
@@ -11693,7 +11712,7 @@ class Graphic extends Node {
11693
11712
  });
11694
11713
  if (hasAnimation) {
11695
11714
  this._syncFinalAttributeFromStaticTruth();
11696
- this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation);
11715
+ this.applyStateAttrs(this.buildStateAnimationTargetAttrs(resolvedStateAttrs, previousResolvedStatePatch), transition.states, hasAnimation);
11697
11716
  }
11698
11717
  else {
11699
11718
  this.stopStateAnimates();
@@ -29,4 +29,4 @@ export class DefaultBoundsAllocate {
29
29
  }
30
30
 
31
31
  export const boundsAllocate = new DefaultBoundsAllocate;
32
- //# sourceMappingURL=bounds-allocate.js.map
32
+ //# sourceMappingURL=bounds-allocate.js.map
@@ -52,4 +52,4 @@ export class DefaultCanvasAllocate {
52
52
  }
53
53
 
54
54
  export const canvasAllocate = new DefaultCanvasAllocate;
55
- //# sourceMappingURL=canvas-allocate.js.map
55
+ //# sourceMappingURL=canvas-allocate.js.map
@@ -15,4 +15,4 @@ export const PathAllocate = Symbol.for("PathAllocate");
15
15
  export const SymbolAllocate = Symbol.for("SymbolAllocate");
16
16
 
17
17
  export const TextAllocate = Symbol.for("TextAllocate");
18
- //# sourceMappingURL=constants.js.map
18
+ //# sourceMappingURL=constants.js.map
@@ -152,4 +152,4 @@ export class DefaultGraphicMemoryManager {
152
152
  }
153
153
 
154
154
  export const defaultGraphicMemoryManager = new DefaultGraphicMemoryManager;
155
- //# sourceMappingURL=graphic-allocate.js.map
155
+ //# sourceMappingURL=graphic-allocate.js.map
@@ -68,4 +68,4 @@ export class DefaultMat4Allocate {
68
68
  export const matrixAllocate = new DefaultMatrixAllocate;
69
69
 
70
70
  export const mat4Allocate = new DefaultMat4Allocate;
71
- //# sourceMappingURL=matrix-allocate.js.map
71
+ //# sourceMappingURL=matrix-allocate.js.map
@@ -1,4 +1,3 @@
1
1
  export const CanvasFactory = Symbol.for("CanvasFactory");
2
2
 
3
- export const Context2dFactory = Symbol.for("Context2dFactory");
4
- //# sourceMappingURL=constants.js.map
3
+ export const Context2dFactory = Symbol.for("Context2dFactory");
@@ -2,4 +2,5 @@ export * from "./interpolate";
2
2
 
3
3
  export * from "./store";
4
4
 
5
- export * from "./colorName";
5
+ export * from "./colorName";
6
+ //# sourceMappingURL=index.js.map
@@ -113,5 +113,4 @@ export function mapToCanvasPointForCanvas(nativeEvent) {
113
113
  x: nativeEvent._canvasX || 0,
114
114
  y: nativeEvent._canvasY || 0
115
115
  };
116
- }
117
- //# sourceMappingURL=event-transformer.js.map
116
+ }
@@ -4,4 +4,5 @@ export class Generator {
4
4
  }
5
5
  }
6
6
 
7
- Generator.auto_increment_id = 0;
7
+ Generator.auto_increment_id = 0;
8
+ //# sourceMappingURL=generator.js.map
@@ -17,4 +17,4 @@ export const normalizeRectAttributes = attribute => {
17
17
  height: height
18
18
  };
19
19
  };
20
- //# sourceMappingURL=rect-utils.js.map
20
+ //# sourceMappingURL=rect-utils.js.map
@@ -61,4 +61,4 @@ function drawAreaBlock(path, topList, bottomList, params) {
61
61
  }
62
62
  path.closePath();
63
63
  }
64
- //# sourceMappingURL=render-area.js.map
64
+ //# sourceMappingURL=render-area.js.map
@@ -6,4 +6,4 @@ export function renderCommandList(commandList, context, x = 0, y = 0, sx = 1, sy
6
6
  commandFuncs[command[0]](command, context, x, y, sx, sy, z);
7
7
  }
8
8
  }
9
- //# sourceMappingURL=render-command-list.js.map
9
+ //# sourceMappingURL=render-command-list.js.map
@@ -93,4 +93,4 @@ export function drawIncrementalAreaSegments(path, lastSeg, segments, params) {
93
93
  path.closePath();
94
94
  }));
95
95
  }
96
- //# sourceMappingURL=render-curve.js.map
96
+ //# sourceMappingURL=render-curve.js.map
@@ -11,4 +11,4 @@ export function drawSegItem(ctx, curve, endPercent, params) {
11
11
  ctx.lineTo(offsetX + p.x, offsetY + p.y, offsetZ);
12
12
  }
13
13
  }
14
- //# sourceMappingURL=render-utils.js.map
14
+ //# sourceMappingURL=render-utils.js.map
@@ -91,4 +91,4 @@ export class ReflectSegContext extends SegContext {
91
91
  return super.clear();
92
92
  }
93
93
  }
94
- //# sourceMappingURL=seg-context.js.map
94
+ //# sourceMappingURL=seg-context.js.map
@@ -30,4 +30,4 @@ export function flatten_simplify(points, tolerance, highestQuality) {
30
30
  if (points.length <= 10) return points;
31
31
  return points = highestQuality ? points : simplifyRadialDist(points, void 0 !== tolerance ? tolerance * tolerance : 1);
32
32
  }
33
- //# sourceMappingURL=simplify.js.map
33
+ //# sourceMappingURL=simplify.js.map
package/es/common/sort.js CHANGED
@@ -94,4 +94,4 @@ export function findNextGraphic(graphic, id, defaultZIndex, reverse = !1) {
94
94
  !1)), reverse);
95
95
  return result;
96
96
  }
97
- //# sourceMappingURL=sort.js.map
97
+ //# sourceMappingURL=sort.js.map
@@ -248,4 +248,4 @@ export const splitPath = (path, count) => {
248
248
  }
249
249
  return res;
250
250
  };
251
- //# sourceMappingURL=split-path.js.map
251
+ //# sourceMappingURL=split-path.js.map
@@ -1,2 +1,2 @@
1
1
  class StageStore {}
2
- //# sourceMappingURL=store.js.map
2
+ //# sourceMappingURL=store.js.map
package/es/common/text.js CHANGED
@@ -23,4 +23,5 @@ export function textAttributesToStyle(attrs) {
23
23
  })), isValid(attrs.maxLineWidth) && (style["max-width"] = parsePxValue(attrs.maxLineWidth)),
24
24
  attrs.underline ? style["text-decoration"] = "underline" : attrs.lineThrough && (style["text-decoration"] = "line-through"),
25
25
  attrs.fill && isString(attrs.fill) && (style.color = attrs.fill), style;
26
- }
26
+ }
27
+ //# sourceMappingURL=text.js.map
@@ -148,4 +148,4 @@ export const calculateLineHeight = (lineHeight, fontSize) => {
148
148
  const _lh = _calculateLineHeight(lineHeight, fontSize);
149
149
  return isNaN(_lh) ? _lh : Math.max(fontSize, _lh);
150
150
  };
151
- //# sourceMappingURL=utils.js.map
151
+ //# sourceMappingURL=utils.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
@@ -75,5 +75,4 @@ export class DefaultLayerService {
75
75
  }
76
76
  }
77
77
 
78
- DefaultLayerService.idprefix = "visactor_layer", DefaultLayerService.prefix_count = 0;
79
- //# sourceMappingURL=layer-service.js.map
78
+ DefaultLayerService.idprefix = "visactor_layer", DefaultLayerService.prefix_count = 0;
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
@@ -605,4 +605,4 @@ export class Stage extends Group {
605
605
  this.renderService.reInit(), this.pickerService.reInit();
606
606
  }
607
607
  }
608
- //# sourceMappingURL=stage.js.map
608
+ //# 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
@@ -149,6 +149,7 @@ export declare abstract class Graphic<T extends Partial<IGraphicAttribute> = Par
149
149
  };
150
150
  protected recomputeCurrentStatePatch(): void;
151
151
  protected buildStaticAttributeSnapshot(): Partial<T>;
152
+ protected buildStateAnimationTargetAttrs(resolvedStateAttrs: Partial<T>, previousResolvedStatePatch?: Partial<T>): Partial<T>;
152
153
  protected syncObjectToSnapshot(target: Record<string, any>, snapshot: Record<string, any>): AttributeDelta;
153
154
  protected _syncAttribute(): AttributeDelta;
154
155
  protected _syncFinalAttributeFromStaticTruth(): void;
@@ -297,6 +297,14 @@ export class Graphic extends Node {
297
297
  "deep" === this.stateMergeMode && isPlainObjectValue(previousValue) && isPlainObjectValue(nextValue) ? snapshot[key] = deepMergeAttributeValue(previousValue, nextValue) : snapshot[key] = cloneAttributeValue(nextValue);
298
298
  })), snapshot) : snapshot;
299
299
  }
300
+ buildStateAnimationTargetAttrs(resolvedStateAttrs, previousResolvedStatePatch) {
301
+ const targetAttrs = cloneAttributeValue(resolvedStateAttrs);
302
+ if (!previousResolvedStatePatch) return targetAttrs;
303
+ const snapshot = this.buildStaticAttributeSnapshot();
304
+ return Object.keys(previousResolvedStatePatch).forEach((key => {
305
+ Object.prototype.hasOwnProperty.call(targetAttrs, key) || (targetAttrs[key] = Object.prototype.hasOwnProperty.call(snapshot, key) ? cloneAttributeValue(snapshot[key]) : this.getDefaultAttribute(key));
306
+ })), targetAttrs;
307
+ }
300
308
  syncObjectToSnapshot(target, snapshot) {
301
309
  const delta = new Map;
302
310
  return new Set([ ...Object.keys(target), ...Object.keys(snapshot) ]).forEach((key => {
@@ -778,7 +786,7 @@ export class Graphic extends Node {
778
786
  useStates(states, hasAnimation) {
779
787
  var _a, _b, _c, _d, _e;
780
788
  if (!states.length) return void this.clearStates(hasAnimation);
781
- const previousStates = this.currentStates ? this.currentStates.slice() : [], stateResolveBaseAttrs = null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : this.attribute, stateModel = this.createStateModel();
789
+ const previousStates = this.currentStates ? this.currentStates.slice() : [], previousResolvedStatePatch = this.resolvedStatePatch ? cloneAttributeValue(this.resolvedStatePatch) : void 0, stateResolveBaseAttrs = null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : this.attribute, stateModel = this.createStateModel();
782
790
  null === (_b = this.stateEngine) || void 0 === _b || _b.setResolveContext(this, stateResolveBaseAttrs);
783
791
  const transition = stateModel.useStates(states);
784
792
  if (!transition.changed && this.sameStateNames(previousStates, transition.states)) return;
@@ -789,7 +797,7 @@ export class Graphic extends Node {
789
797
  null === (_e = getStageStatePerfMonitor(this.stage)) || void 0 === _e || _e.recordEvent("state-commit", {
790
798
  graphicId: this._uid,
791
799
  targetStates: [ ...transition.states ]
792
- }), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation)) : (this.stopStateAnimates(),
800
+ }), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(this.buildStateAnimationTargetAttrs(resolvedStateAttrs, previousResolvedStatePatch), transition.states, hasAnimation)) : (this.stopStateAnimates(),
793
801
  this._restoreAttributeFromStaticTruth({
794
802
  type: AttributeUpdateType.STATE
795
803
  }), this._emitCustomEvent("afterStateUpdate", {