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

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 (72) hide show
  1. package/cjs/common/diff.js +1 -2
  2. package/cjs/common/event-transformer.js +2 -1
  3. package/cjs/common/rect-utils.js +1 -1
  4. package/cjs/common/render-area.js +1 -1
  5. package/cjs/common/render-command-list.js +1 -1
  6. package/cjs/common/render-curve.js +1 -1
  7. package/cjs/common/render-utils.js +1 -1
  8. package/cjs/common/seg-context.js +1 -2
  9. package/cjs/common/simplify.js +1 -1
  10. package/cjs/common/sort.js +1 -1
  11. package/cjs/common/split-path.js +1 -1
  12. package/cjs/common/store.js +1 -1
  13. package/cjs/common/text.js +1 -1
  14. package/cjs/common/utils.js +1 -1
  15. package/cjs/core/camera.js +1 -1
  16. package/cjs/core/constants.js +1 -1
  17. package/cjs/core/core-modules.js +1 -1
  18. package/cjs/core/global-module.js +2 -0
  19. package/cjs/core/global.js +1 -1
  20. package/cjs/core/graphic-utils.js +1 -1
  21. package/cjs/core/index.js +1 -1
  22. package/cjs/core/layer-service.js +2 -1
  23. package/cjs/core/layer.js +1 -1
  24. package/cjs/core/light.js +1 -1
  25. package/cjs/core/stage.js +1 -1
  26. package/cjs/core/window.js +1 -1
  27. package/cjs/graphic/graphic.d.ts +4 -2
  28. package/cjs/graphic/graphic.js +30 -12
  29. package/cjs/graphic/graphic.js.map +1 -1
  30. package/cjs/graphic/rect.d.ts +2 -0
  31. package/cjs/graphic/rect.js +44 -0
  32. package/cjs/graphic/rect.js.map +1 -1
  33. package/cjs/graphic/state/state-transition-orchestrator.d.ts +5 -0
  34. package/cjs/graphic/state/state-transition-orchestrator.js +17 -5
  35. package/cjs/graphic/state/state-transition-orchestrator.js.map +1 -1
  36. package/dist/index.es.js +131 -21
  37. package/es/common/diff.js +1 -2
  38. package/es/common/event-transformer.js +2 -1
  39. package/es/common/rect-utils.js +1 -1
  40. package/es/common/render-area.js +1 -1
  41. package/es/common/render-command-list.js +1 -1
  42. package/es/common/render-curve.js +1 -1
  43. package/es/common/render-utils.js +1 -1
  44. package/es/common/seg-context.js +1 -2
  45. package/es/common/simplify.js +1 -1
  46. package/es/common/sort.js +1 -1
  47. package/es/common/split-path.js +1 -1
  48. package/es/common/store.js +1 -1
  49. package/es/common/text.js +1 -1
  50. package/es/common/utils.js +1 -1
  51. package/es/core/camera.js +1 -1
  52. package/es/core/constants.js +1 -1
  53. package/es/core/core-modules.js +1 -1
  54. package/es/core/global-module.js +2 -0
  55. package/es/core/global.js +1 -1
  56. package/es/core/graphic-utils.js +1 -1
  57. package/es/core/index.js +1 -1
  58. package/es/core/layer-service.js +2 -1
  59. package/es/core/layer.js +1 -1
  60. package/es/core/light.js +1 -1
  61. package/es/core/stage.js +1 -1
  62. package/es/core/window.js +1 -1
  63. package/es/graphic/graphic.d.ts +4 -2
  64. package/es/graphic/graphic.js +30 -12
  65. package/es/graphic/graphic.js.map +1 -1
  66. package/es/graphic/rect.d.ts +2 -0
  67. package/es/graphic/rect.js +44 -0
  68. package/es/graphic/rect.js.map +1 -1
  69. package/es/graphic/state/state-transition-orchestrator.d.ts +5 -0
  70. package/es/graphic/state/state-transition-orchestrator.js +17 -5
  71. package/es/graphic/state/state-transition-orchestrator.js.map +1 -1
  72. package/package.json +3 -3
@@ -16,5 +16,4 @@ function diff(oldAttrs, newAttrs, getAttr) {
16
16
  return diffObj;
17
17
  }
18
18
 
19
- exports.diff = diff;
20
- //# sourceMappingURL=diff.js.map
19
+ exports.diff = diff;
@@ -123,4 +123,5 @@ function mapToCanvasPointForCanvas(nativeEvent) {
123
123
 
124
124
  exports.createEventTransformer = createEventTransformer, exports.createCanvasEventTransformer = createCanvasEventTransformer,
125
125
  exports.registerWindowEventTransformer = registerWindowEventTransformer, exports.registerGlobalEventTransformer = registerGlobalEventTransformer,
126
- exports.transformPointForCanvas = transformPointForCanvas, exports.mapToCanvasPointForCanvas = mapToCanvasPointForCanvas;
126
+ exports.transformPointForCanvas = transformPointForCanvas, exports.mapToCanvasPointForCanvas = mapToCanvasPointForCanvas;
127
+ //# sourceMappingURL=event-transformer.js.map
@@ -24,4 +24,4 @@ const vutils_1 = require("@visactor/vutils"), normalizeRectAttributes = attribut
24
24
  };
25
25
 
26
26
  exports.normalizeRectAttributes = normalizeRectAttributes;
27
- //# sourceMappingURL=rect-utils.js.map
27
+ //# sourceMappingURL=rect-utils.js.map
@@ -61,5 +61,5 @@ function drawAreaBlock(path, topList, bottomList, params) {
61
61
  path.closePath();
62
62
  }
63
63
 
64
- exports.drawAreaSegments = drawAreaSegments;
65
64
  //# sourceMappingURL=render-area.js.map
65
+ exports.drawAreaSegments = drawAreaSegments;
@@ -14,4 +14,4 @@ function renderCommandList(commandList, context, x = 0, y = 0, sx = 1, sy = 1, z
14
14
  }
15
15
 
16
16
  exports.renderCommandList = renderCommandList;
17
- //# sourceMappingURL=render-command-list.js.map
17
+ //# sourceMappingURL=render-command-list.js.map
@@ -99,4 +99,4 @@ function drawIncrementalAreaSegments(path, lastSeg, segments, params) {
99
99
 
100
100
  exports.drawSegments = drawSegments, exports.drawIncrementalSegments = drawIncrementalSegments,
101
101
  exports.drawIncrementalAreaSegments = drawIncrementalAreaSegments;
102
- //# sourceMappingURL=render-curve.js.map
102
+ //# sourceMappingURL=render-curve.js.map
@@ -19,4 +19,4 @@ function drawSegItem(ctx, curve, endPercent, params) {
19
19
  }
20
20
 
21
21
  exports.drawSegItem = drawSegItem;
22
- //# sourceMappingURL=render-utils.js.map
22
+ //# sourceMappingURL=render-utils.js.map
@@ -94,5 +94,4 @@ class ReflectSegContext extends SegContext {
94
94
  }
95
95
  }
96
96
 
97
- exports.ReflectSegContext = ReflectSegContext;
98
- //# sourceMappingURL=seg-context.js.map
97
+ exports.ReflectSegContext = ReflectSegContext;
@@ -36,4 +36,4 @@ function flatten_simplify(points, tolerance, highestQuality) {
36
36
  Object.defineProperty(exports, "__esModule", {
37
37
  value: !0
38
38
  }), exports.flatten_simplify = void 0, exports.flatten_simplify = flatten_simplify;
39
- //# sourceMappingURL=simplify.js.map
39
+ //# sourceMappingURL=simplify.js.map
@@ -101,4 +101,4 @@ Object.defineProperty(exports, "__esModule", {
101
101
  value: !0
102
102
  }), exports.findNextGraphic = exports.foreachAsync = exports.foreach = void 0, exports.foreach = foreach,
103
103
  exports.foreachAsync = foreachAsync, exports.findNextGraphic = findNextGraphic;
104
- //# sourceMappingURL=sort.js.map
104
+ //# sourceMappingURL=sort.js.map
@@ -269,4 +269,4 @@ const splitPath = (path, count) => {
269
269
  };
270
270
 
271
271
  exports.splitPath = splitPath;
272
- //# sourceMappingURL=split-path.js.map
272
+ //# sourceMappingURL=split-path.js.map
@@ -1,2 +1,2 @@
1
1
  class StageStore {}
2
- //# sourceMappingURL=store.js.map
2
+ //# sourceMappingURL=store.js.map
@@ -34,4 +34,4 @@ function textAttributesToStyle(attrs) {
34
34
 
35
35
  exports.textDrawOffsetY = textDrawOffsetY, exports.textDrawOffsetX = textDrawOffsetX,
36
36
  exports.textLayoutOffsetY = textLayoutOffsetY, exports.textAttributesToStyle = textAttributesToStyle;
37
- //# sourceMappingURL=text.js.map
37
+ //# sourceMappingURL=text.js.map
@@ -163,4 +163,4 @@ const calculateLineHeight = (lineHeight, fontSize) => {
163
163
  };
164
164
 
165
165
  exports.calculateLineHeight = calculateLineHeight;
166
- //# sourceMappingURL=utils.js.map
166
+ //# sourceMappingURL=utils.js.map
@@ -71,4 +71,4 @@ const registerOrthoCamera = () => {
71
71
  };
72
72
 
73
73
  exports.registerOrthoCamera = registerOrthoCamera;
74
- //# sourceMappingURL=camera.js.map
74
+ //# sourceMappingURL=camera.js.map
@@ -7,4 +7,4 @@ exports.TransformUtil = Symbol.for("TransformUtil"), exports.GraphicUtil = Symbo
7
7
  exports.LayerService = Symbol.for("LayerService"), exports.StaticLayerHandlerContribution = Symbol.for("StaticLayerHandlerContribution"),
8
8
  exports.DynamicLayerHandlerContribution = Symbol.for("DynamicLayerHandlerContribution"),
9
9
  exports.VirtualLayerHandlerContribution = Symbol.for("VirtualLayerHandlerContribution");
10
- //# sourceMappingURL=constants.js.map
10
+ //# sourceMappingURL=constants.js.map
@@ -16,4 +16,4 @@ function bindCoreModules({bind: bind}) {
16
16
  }
17
17
 
18
18
  exports.bindCoreModules = bindCoreModules, exports.default = bindCoreModules;
19
- //# sourceMappingURL=core-modules.js.map
19
+ //# sourceMappingURL=core-modules.js.map
@@ -1 +1,3 @@
1
+
2
+
1
3
  //# sourceMappingURL=global-module.js.map
@@ -222,4 +222,4 @@ class DefaultGlobal extends event_listener_manager_1.EventListenerManager {
222
222
  }
223
223
 
224
224
  exports.DefaultGlobal = DefaultGlobal;
225
- //# sourceMappingURL=global.js.map
225
+ //# sourceMappingURL=global.js.map
@@ -162,4 +162,4 @@ class DefaultTransformUtil {
162
162
  }
163
163
 
164
164
  exports.DefaultTransformUtil = DefaultTransformUtil;
165
- //# sourceMappingURL=graphic-utils.js.map
165
+ //# sourceMappingURL=graphic-utils.js.map
package/cjs/core/index.js CHANGED
@@ -22,4 +22,4 @@ __exportStar(require("./layer"), exports), __exportStar(require("./stage"), expo
22
22
  __exportStar(require("./graphic-utils"), exports), __exportStar(require("./contributions"), exports),
23
23
  __exportStar(require("./layer-service"), exports), __exportStar(require("./constants"), exports),
24
24
  __exportStar(require("../interface/core"), exports);
25
- //# sourceMappingURL=index.js.map
25
+ //# sourceMappingURL=index.js.map
@@ -80,4 +80,5 @@ class DefaultLayerService {
80
80
  }
81
81
 
82
82
  exports.DefaultLayerService = DefaultLayerService, DefaultLayerService.idprefix = "visactor_layer",
83
- DefaultLayerService.prefix_count = 0;
83
+ DefaultLayerService.prefix_count = 0;
84
+ //# sourceMappingURL=layer-service.js.map
package/cjs/core/layer.js CHANGED
@@ -116,4 +116,4 @@ class Layer extends group_1.Group {
116
116
  }
117
117
 
118
118
  exports.Layer = Layer;
119
- //# sourceMappingURL=layer.js.map
119
+ //# sourceMappingURL=layer.js.map
package/cjs/core/light.js CHANGED
@@ -29,4 +29,4 @@ const registerDirectionalLight = () => {
29
29
  };
30
30
 
31
31
  exports.registerDirectionalLight = registerDirectionalLight;
32
- //# sourceMappingURL=light.js.map
32
+ //# sourceMappingURL=light.js.map
package/cjs/core/stage.js CHANGED
@@ -571,4 +571,4 @@ class Stage extends group_1.Group {
571
571
  }
572
572
 
573
573
  exports.Stage = Stage;
574
- //# sourceMappingURL=stage.js.map
574
+ //# sourceMappingURL=stage.js.map
@@ -150,4 +150,4 @@ class DefaultWindow extends event_listener_manager_1.EventListenerManager {
150
150
  }
151
151
 
152
152
  exports.DefaultWindow = DefaultWindow;
153
- //# sourceMappingURL=window.js.map
153
+ //# sourceMappingURL=window.js.map
@@ -149,7 +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
+ protected buildRemovedStateAnimationAttrs(targetStateAttrs: Partial<T>, previousResolvedStatePatch?: Partial<T>): Partial<T>;
153
153
  protected syncObjectToSnapshot(target: Record<string, any>, snapshot: Record<string, any>): AttributeDelta;
154
154
  protected _syncAttribute(): AttributeDelta;
155
155
  protected _syncFinalAttributeFromStaticTruth(): void;
@@ -211,8 +211,10 @@ export declare abstract class Graphic<T extends Partial<IGraphicAttribute> = Par
211
211
  getState(stateName: string): Partial<T> | StateDefinition<T> | undefined;
212
212
  protected createStateModel(): StateModel<T>;
213
213
  protected resolveStateAnimateConfig(animateConfig?: IAnimateConfig): any;
214
- applyStateAttrs(attrs: Partial<T>, stateNames: string[], hasAnimation?: boolean, isClear?: boolean, animateConfig?: IAnimateConfig): void;
214
+ applyStateAttrs(attrs: Partial<T>, stateNames: string[], hasAnimation?: boolean, isClear?: boolean, animateConfig?: IAnimateConfig, extraAnimateAttrs?: Partial<T>): void;
215
215
  updateNormalAttrs(stateAttrs: Partial<T>): void;
216
+ protected getStateTransitionDefaultAttribute(key: string, targetAttrs?: Partial<T>): any;
217
+ protected shouldSkipStateTransitionDefaultAttribute(_key: string, _targetAttrs?: Partial<T>): boolean;
216
218
  protected stopStateAnimates(type?: 'start' | 'end'): void;
217
219
  private getNormalAttribute;
218
220
  clearStates(hasAnimation?: boolean): void;
@@ -254,13 +254,21 @@ class Graphic extends node_tree_1.Node {
254
254
  "deep" === this.stateMergeMode && isPlainObjectValue(previousValue) && isPlainObjectValue(nextValue) ? snapshot[key] = deepMergeAttributeValue(previousValue, nextValue) : snapshot[key] = cloneAttributeValue(nextValue);
255
255
  })), snapshot) : snapshot;
256
256
  }
257
- buildStateAnimationTargetAttrs(resolvedStateAttrs, previousResolvedStatePatch) {
258
- const targetAttrs = cloneAttributeValue(resolvedStateAttrs);
259
- if (!previousResolvedStatePatch) return targetAttrs;
260
- const snapshot = this.buildStaticAttributeSnapshot();
257
+ buildRemovedStateAnimationAttrs(targetStateAttrs, previousResolvedStatePatch) {
258
+ const extraAttrs = {};
259
+ if (!previousResolvedStatePatch) return extraAttrs;
260
+ const snapshot = this.buildStaticAttributeSnapshot(), staticTargetAttrs = snapshot;
261
261
  return Object.keys(previousResolvedStatePatch).forEach((key => {
262
- Object.prototype.hasOwnProperty.call(targetAttrs, key) || (targetAttrs[key] = Object.prototype.hasOwnProperty.call(snapshot, key) ? cloneAttributeValue(snapshot[key]) : this.getDefaultAttribute(key));
263
- })), targetAttrs;
262
+ const hasTargetAttr = Object.prototype.hasOwnProperty.call(targetStateAttrs, key);
263
+ if (hasTargetAttr && void 0 !== targetStateAttrs[key]) return;
264
+ const assignFallbackAttr = value => {
265
+ void 0 === value && this.shouldSkipStateTransitionDefaultAttribute(key, staticTargetAttrs) || (extraAttrs[key] = void 0 === value ? value : cloneAttributeValue(value));
266
+ };
267
+ if (hasTargetAttr) assignFallbackAttr(this.getStateTransitionDefaultAttribute(key, staticTargetAttrs)); else if (Object.prototype.hasOwnProperty.call(snapshot, key)) {
268
+ const snapshotValue = snapshot[key];
269
+ assignFallbackAttr(void 0 === snapshotValue ? this.getStateTransitionDefaultAttribute(key, staticTargetAttrs) : snapshotValue);
270
+ } else assignFallbackAttr(this.getStateTransitionDefaultAttribute(key, staticTargetAttrs));
271
+ })), extraAttrs;
264
272
  }
265
273
  syncObjectToSnapshot(target, snapshot) {
266
274
  const delta = new Map;
@@ -689,20 +697,30 @@ class Graphic extends node_tree_1.Node {
689
697
  var _a, _b, _c;
690
698
  return null !== (_c = null !== (_a = null != animateConfig ? animateConfig : this.stateAnimateConfig) && void 0 !== _a ? _a : null === (_b = this.context) || void 0 === _b ? void 0 : _b.stateAnimateConfig) && void 0 !== _c ? _c : config_2.DefaultStateAnimateConfig;
691
699
  }
692
- applyStateAttrs(attrs, stateNames, hasAnimation, isClear, animateConfig) {
700
+ applyStateAttrs(attrs, stateNames, hasAnimation, isClear, animateConfig, extraAnimateAttrs) {
693
701
  const resolvedAnimateConfig = hasAnimation ? this.resolveStateAnimateConfig(animateConfig) : void 0, transitionOptions = resolvedAnimateConfig ? {
694
- animateConfig: resolvedAnimateConfig
702
+ animateConfig: resolvedAnimateConfig,
703
+ extraAnimateAttrs: extraAnimateAttrs,
704
+ shouldSkipDefaultAttribute: this.shouldSkipStateTransitionDefaultAttribute.bind(this)
695
705
  } : void 0;
696
706
  if (isClear) return void this.getStateTransitionOrchestrator().applyClearTransition(this, attrs, hasAnimation, stateNames, transitionOptions);
697
707
  const plan = this.getStateTransitionOrchestrator().analyzeTransition({}, attrs, stateNames, hasAnimation, {
698
708
  noWorkAnimateAttr: this.getNoWorkAnimateAttr(),
699
- animateConfig: resolvedAnimateConfig
709
+ animateConfig: resolvedAnimateConfig,
710
+ extraAnimateAttrs: extraAnimateAttrs,
711
+ shouldSkipDefaultAttribute: this.shouldSkipStateTransitionDefaultAttribute.bind(this)
700
712
  });
701
713
  this.getStateTransitionOrchestrator().applyTransition(this, plan, hasAnimation, transitionOptions);
702
714
  }
703
715
  updateNormalAttrs(stateAttrs) {
704
716
  this._deprecatedNormalAttrsView = cloneAttributeValue(this.baseAttributes);
705
717
  }
718
+ getStateTransitionDefaultAttribute(key, targetAttrs) {
719
+ return this.getDefaultAttribute(key);
720
+ }
721
+ shouldSkipStateTransitionDefaultAttribute(_key, _targetAttrs) {
722
+ return !1;
723
+ }
706
724
  stopStateAnimates(type = "end") {
707
725
  const stopAnimationState = this.stopAnimationState;
708
726
  if ("function" == typeof stopAnimationState) return void stopAnimationState.call(this, "state", type);
@@ -718,7 +736,7 @@ class Graphic extends node_tree_1.Node {
718
736
  }
719
737
  clearStates(hasAnimation) {
720
738
  var _a, _b, _c;
721
- const previousStates = this.currentStates ? this.currentStates.slice() : [], transition = this.createStateModel().clearStates();
739
+ const previousStates = this.currentStates ? this.currentStates.slice() : [], previousResolvedStatePatch = this.resolvedStatePatch ? cloneAttributeValue(this.resolvedStatePatch) : void 0, transition = this.createStateModel().clearStates();
722
740
  if (!transition.changed && 0 === previousStates.length) return this.currentStates = [],
723
741
  this.effectiveStates = [], this.resolvedStatePatch = void 0, this.sharedStateDirty = !1,
724
742
  void this.clearSharedStateActiveRegistrations();
@@ -729,7 +747,7 @@ class Graphic extends node_tree_1.Node {
729
747
  null === (_c = (0, state_perf_monitor_1.getStageStatePerfMonitor)(this.stage)) || void 0 === _c || _c.recordEvent("state-commit", {
730
748
  graphicId: this._uid,
731
749
  targetStates: []
732
- }), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !0)) : (this.stopStateAnimates(),
750
+ }), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !0, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(),
733
751
  this._restoreAttributeFromStaticTruth({
734
752
  type: enums_1.AttributeUpdateType.STATE
735
753
  }), this._emitCustomEvent("afterStateUpdate", {
@@ -763,7 +781,7 @@ class Graphic extends node_tree_1.Node {
763
781
  null === (_e = (0, state_perf_monitor_1.getStageStatePerfMonitor)(this.stage)) || void 0 === _e || _e.recordEvent("state-commit", {
764
782
  graphicId: this._uid,
765
783
  targetStates: [ ...transition.states ]
766
- }), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(this.buildStateAnimationTargetAttrs(resolvedStateAttrs, previousResolvedStatePatch), transition.states, hasAnimation)) : (this.stopStateAnimates(),
784
+ }), hasAnimation ? (this._syncFinalAttributeFromStaticTruth(), this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !1, void 0, this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch))) : (this.stopStateAnimates(),
767
785
  this._restoreAttributeFromStaticTruth({
768
786
  type: enums_1.AttributeUpdateType.STATE
769
787
  }), this._emitCustomEvent("afterStateUpdate", {