@antv/g 5.0.23-alpha.8 → 5.0.24

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 (150) hide show
  1. package/dist/index.umd.min.js +4 -3
  2. package/es/AbstractRenderer.d.ts +11 -0
  3. package/es/AbstractRenderer.js +17 -2
  4. package/es/Canvas.d.ts +1 -1
  5. package/es/css/CSS.d.ts +2 -1
  6. package/es/css/CSS.js +6 -2
  7. package/es/css/CSSProperty.d.ts +1 -1
  8. package/es/css/StyleValueRegistry.d.ts +2 -1
  9. package/es/css/StyleValueRegistry.js +34 -25
  10. package/es/css/cssom/CSSNumericValue.js +1 -1
  11. package/es/css/index.d.ts +2 -1
  12. package/es/css/index.js +2 -1
  13. package/es/css/interfaces.d.ts +6 -0
  14. package/es/css/interfaces.js +2 -0
  15. package/es/css/layout/FragmentResult.d.ts +32 -0
  16. package/es/css/layout/FragmentResult.js +32 -0
  17. package/es/css/layout/LayoutChildren.d.ts +23 -0
  18. package/es/css/layout/LayoutChildren.js +55 -0
  19. package/es/css/layout/LayoutContext.d.ts +35 -0
  20. package/es/css/layout/LayoutContext.js +35 -0
  21. package/es/css/layout/LayoutDefinition.d.ts +20 -0
  22. package/es/css/layout/LayoutDefinition.js +9 -0
  23. package/es/css/layout/LayoutEdges.d.ts +24 -0
  24. package/es/css/layout/LayoutEdges.js +41 -0
  25. package/es/css/layout/LayoutEngine.d.ts +41 -0
  26. package/es/css/layout/LayoutEngine.js +332 -0
  27. package/es/css/layout/LayoutFragment.d.ts +26 -0
  28. package/es/css/layout/LayoutFragment.js +28 -0
  29. package/es/css/layout/LayoutObject.d.ts +46 -0
  30. package/es/css/layout/LayoutObject.js +172 -0
  31. package/es/css/layout/LayoutRegistry.d.ts +16 -0
  32. package/es/css/layout/LayoutRegistry.js +78 -0
  33. package/es/css/layout/LayoutWorkTask.d.ts +14 -0
  34. package/es/css/layout/LayoutWorkTask.js +1 -0
  35. package/es/css/layout/index.d.ts +11 -0
  36. package/es/css/layout/index.js +11 -0
  37. package/es/css/layout/types.d.ts +104 -0
  38. package/es/css/layout/types.js +66 -0
  39. package/es/css/parser/numeric.d.ts +1 -1
  40. package/es/css/parser/numeric.js +1 -1
  41. package/es/css/parser/transform.js +5 -4
  42. package/es/css/properties/CSSPropertyColor.d.ts +1 -1
  43. package/es/css/properties/CSSPropertyLengthOrPercentage.d.ts +1 -1
  44. package/es/display-objects/DisplayObject.d.ts +1 -2
  45. package/es/display-objects/DisplayObject.js +2 -1
  46. package/es/dom/Document.js +2 -2
  47. package/es/global-module.js +91 -8
  48. package/es/index.d.ts +3 -0
  49. package/es/index.js +3 -0
  50. package/es/plugins/CullingPlugin.d.ts +1 -0
  51. package/es/plugins/CullingPlugin.js +8 -3
  52. package/es/plugins/DirtyCheckPlugin.d.ts +1 -0
  53. package/es/plugins/DirtyCheckPlugin.js +7 -2
  54. package/es/plugins/EventPlugin.d.ts +1 -0
  55. package/es/plugins/EventPlugin.js +14 -9
  56. package/es/plugins/PrepareRendererPlugin.d.ts +1 -0
  57. package/es/plugins/PrepareRendererPlugin.js +10 -5
  58. package/es/services/EventService.js +4 -8
  59. package/es/services/OffscreenCanvasCreator.d.ts +1 -1
  60. package/es/services/OffscreenCanvasCreator.js +1 -1
  61. package/es/services/RenderingService.d.ts +18 -18
  62. package/es/services/RenderingService.js +26 -23
  63. package/es/services/SceneGraphService.js +3 -1
  64. package/es/types.d.ts +7 -5
  65. package/es/utils/deferred.d.ts +43 -0
  66. package/es/utils/deferred.js +117 -0
  67. package/es/utils/dom.d.ts +2 -0
  68. package/es/utils/dom.js +8 -0
  69. package/es/utils/index.d.ts +2 -1
  70. package/es/utils/index.js +2 -1
  71. package/es/utils/interpolation.js +1 -1
  72. package/lib/AbstractRenderer.d.ts +11 -0
  73. package/lib/AbstractRenderer.js +17 -2
  74. package/lib/Canvas.d.ts +1 -1
  75. package/lib/css/CSS.d.ts +2 -1
  76. package/lib/css/CSS.js +9 -3
  77. package/lib/css/CSSProperty.d.ts +1 -1
  78. package/lib/css/StyleValueRegistry.d.ts +2 -1
  79. package/lib/css/StyleValueRegistry.js +39 -27
  80. package/lib/css/cssom/CSSNumericValue.js +17 -17
  81. package/lib/css/index.d.ts +2 -1
  82. package/lib/css/index.js +25 -12
  83. package/lib/css/interfaces.d.ts +6 -0
  84. package/lib/css/interfaces.js +12 -0
  85. package/lib/css/layout/FragmentResult.d.ts +32 -0
  86. package/lib/css/layout/FragmentResult.js +51 -0
  87. package/lib/css/layout/LayoutChildren.d.ts +23 -0
  88. package/lib/css/layout/LayoutChildren.js +72 -0
  89. package/lib/css/layout/LayoutContext.d.ts +35 -0
  90. package/lib/css/layout/LayoutContext.js +49 -0
  91. package/lib/css/layout/LayoutDefinition.d.ts +20 -0
  92. package/lib/css/layout/LayoutDefinition.js +16 -0
  93. package/lib/css/layout/LayoutEdges.d.ts +24 -0
  94. package/lib/css/layout/LayoutEdges.js +56 -0
  95. package/lib/css/layout/LayoutEngine.d.ts +41 -0
  96. package/lib/css/layout/LayoutEngine.js +345 -0
  97. package/lib/css/layout/LayoutFragment.d.ts +26 -0
  98. package/lib/css/layout/LayoutFragment.js +44 -0
  99. package/lib/css/layout/LayoutObject.d.ts +46 -0
  100. package/lib/css/layout/LayoutObject.js +182 -0
  101. package/lib/css/layout/LayoutRegistry.d.ts +16 -0
  102. package/lib/css/layout/LayoutRegistry.js +87 -0
  103. package/lib/css/layout/LayoutWorkTask.d.ts +14 -0
  104. package/lib/css/layout/LayoutWorkTask.js +5 -0
  105. package/lib/css/layout/index.d.ts +11 -0
  106. package/lib/css/layout/index.js +148 -0
  107. package/lib/css/layout/types.d.ts +104 -0
  108. package/lib/css/layout/types.js +74 -0
  109. package/lib/css/parser/numeric.d.ts +1 -1
  110. package/lib/css/parser/numeric.js +4 -4
  111. package/lib/css/parser/transform.js +6 -4
  112. package/lib/css/properties/CSSPropertyColor.d.ts +1 -1
  113. package/lib/css/properties/CSSPropertyLengthOrPercentage.d.ts +1 -1
  114. package/lib/display-objects/DisplayObject.d.ts +1 -2
  115. package/lib/display-objects/DisplayObject.js +3 -2
  116. package/lib/dom/Document.js +2 -2
  117. package/lib/global-module.js +91 -6
  118. package/lib/index.d.ts +3 -0
  119. package/lib/index.js +7 -2
  120. package/lib/plugins/CullingPlugin.d.ts +1 -0
  121. package/lib/plugins/CullingPlugin.js +7 -3
  122. package/lib/plugins/DirtyCheckPlugin.d.ts +1 -0
  123. package/lib/plugins/DirtyCheckPlugin.js +6 -2
  124. package/lib/plugins/EventPlugin.d.ts +1 -0
  125. package/lib/plugins/EventPlugin.js +13 -9
  126. package/lib/plugins/PrepareRendererPlugin.d.ts +1 -0
  127. package/lib/plugins/PrepareRendererPlugin.js +9 -5
  128. package/lib/services/EventService.js +4 -8
  129. package/lib/services/OffscreenCanvasCreator.d.ts +1 -1
  130. package/lib/services/OffscreenCanvasCreator.js +1 -1
  131. package/lib/services/RenderingService.d.ts +18 -18
  132. package/lib/services/RenderingService.js +26 -23
  133. package/lib/services/SceneGraphService.js +3 -1
  134. package/lib/types.d.ts +7 -5
  135. package/lib/utils/deferred.d.ts +43 -0
  136. package/lib/utils/deferred.js +131 -0
  137. package/lib/utils/dom.d.ts +2 -0
  138. package/lib/utils/dom.js +17 -0
  139. package/lib/utils/index.d.ts +2 -1
  140. package/lib/utils/index.js +17 -4
  141. package/lib/utils/interpolation.js +2 -2
  142. package/package.json +4 -3
  143. package/es/css/LayoutRegistry.d.ts +0 -11
  144. package/es/css/LayoutRegistry.js +0 -22
  145. package/es/utils/hooks.d.ts +0 -280
  146. package/es/utils/hooks.js +0 -753
  147. package/lib/css/LayoutRegistry.d.ts +0 -11
  148. package/lib/css/LayoutRegistry.js +0 -30
  149. package/lib/utils/hooks.d.ts +0 -280
  150. package/lib/utils/hooks.js +0 -759
@@ -41,6 +41,8 @@ function () {
41
41
  };
42
42
  }
43
43
 
44
+ EventPlugin_1 = EventPlugin;
45
+
44
46
  EventPlugin.prototype.apply = function (renderingService) {
45
47
  var _this = this;
46
48
 
@@ -53,7 +55,7 @@ function () {
53
55
  case 0:
54
56
  return [4
55
57
  /*yield*/
56
- , this.renderingService.hooks.pick.callPromise({
58
+ , this.renderingService.hooks.pick.promise({
57
59
  position: position,
58
60
  picked: [],
59
61
  topmost: true // we only concern the topmost element
@@ -69,12 +71,12 @@ function () {
69
71
  });
70
72
  });
71
73
  });
72
- renderingService.hooks.pointerWheel.tap(function (nativeEvent) {
74
+ renderingService.hooks.pointerWheel.tap(EventPlugin_1.tag, function (nativeEvent) {
73
75
  var wheelEvent = _this.normalizeWheelEvent(nativeEvent);
74
76
 
75
77
  _this.eventService.mapEvent(wheelEvent);
76
78
  });
77
- renderingService.hooks.pointerDown.tap(function (nativeEvent) {
79
+ renderingService.hooks.pointerDown.tap(EventPlugin_1.tag, function (nativeEvent) {
78
80
  if (canvas.supportTouchEvent && nativeEvent.pointerType === 'touch') {
79
81
  return;
80
82
  }
@@ -95,7 +97,7 @@ function () {
95
97
 
96
98
  _this.setCursor(_this.eventService.cursor);
97
99
  });
98
- renderingService.hooks.pointerUp.tap(function (nativeEvent) {
100
+ renderingService.hooks.pointerUp.tap(EventPlugin_1.tag, function (nativeEvent) {
99
101
  if (canvas.supportTouchEvent && nativeEvent.pointerType === 'touch') return; // account for element in SVG
100
102
 
101
103
  var $element = _this.contextService.getDomElement();
@@ -114,10 +116,10 @@ function () {
114
116
 
115
117
  _this.setCursor(_this.eventService.cursor);
116
118
  });
117
- renderingService.hooks.pointerMove.tap(this.onPointerMove);
118
- renderingService.hooks.pointerOver.tap(this.onPointerMove);
119
- renderingService.hooks.pointerOut.tap(this.onPointerMove);
120
- renderingService.hooks.pointerCancel.tap(function (nativeEvent) {
119
+ renderingService.hooks.pointerMove.tap(EventPlugin_1.tag, this.onPointerMove);
120
+ renderingService.hooks.pointerOver.tap(EventPlugin_1.tag, this.onPointerMove);
121
+ renderingService.hooks.pointerOut.tap(EventPlugin_1.tag, this.onPointerMove);
122
+ renderingService.hooks.pointerCancel.tap(EventPlugin_1.tag, function (nativeEvent) {
121
123
  if (canvas.supportTouchEvent && nativeEvent.pointerType === 'touch') {
122
124
  return;
123
125
  }
@@ -350,6 +352,9 @@ function () {
350
352
  }
351
353
  };
352
354
 
355
+ var EventPlugin_1;
356
+ EventPlugin.tag = 'Event';
357
+
353
358
  __decorate([inject(CanvasConfig), __metadata("design:type", Object)], EventPlugin.prototype, "canvasConfig", void 0);
354
359
 
355
360
  __decorate([inject(ContextService), __metadata("design:type", Object)], EventPlugin.prototype, "contextService", void 0);
@@ -360,7 +365,7 @@ function () {
360
365
 
361
366
  __decorate([inject(EventService), __metadata("design:type", EventService)], EventPlugin.prototype, "eventService", void 0);
362
367
 
363
- EventPlugin = __decorate([singleton({
368
+ EventPlugin = EventPlugin_1 = __decorate([singleton({
364
369
  contrib: RenderingPluginContribution
365
370
  })], EventPlugin);
366
371
  return EventPlugin;
@@ -1,5 +1,6 @@
1
1
  import type { RenderingService, RenderingPlugin } from '../services';
2
2
  export declare class PrepareRendererPlugin implements RenderingPlugin {
3
+ static tag: string;
3
4
  private renderingContext;
4
5
  private styleValueRegistry;
5
6
  apply(renderingService: RenderingService): void;
@@ -1,6 +1,6 @@
1
1
  import { __awaiter, __decorate, __generator, __metadata } from "tslib";
2
2
  import { inject, singleton } from 'mana-syringe';
3
- import { StyleValueRegistry } from '../css';
3
+ import { StyleValueRegistry } from '../css/interfaces';
4
4
  import { ElementEvent } from '../dom';
5
5
  import { RenderingContext, RenderingPluginContribution, dirtifyToRoot } from '../services';
6
6
 
@@ -9,6 +9,8 @@ var PrepareRendererPlugin =
9
9
  function () {
10
10
  function PrepareRendererPlugin() {}
11
11
 
12
+ PrepareRendererPlugin_1 = PrepareRendererPlugin;
13
+
12
14
  PrepareRendererPlugin.prototype.apply = function (renderingService) {
13
15
  var _this = this;
14
16
 
@@ -37,7 +39,7 @@ function () {
37
39
  renderingService.dirtify();
38
40
  };
39
41
 
40
- renderingService.hooks.init.tapPromise(function () {
42
+ renderingService.hooks.init.tapPromise(PrepareRendererPlugin_1.tag, function () {
41
43
  return __awaiter(_this, void 0, void 0, function () {
42
44
  return __generator(this, function (_a) {
43
45
  this.renderingContext.root.addEventListener(ElementEvent.MOUNTED, handleMounted);
@@ -50,7 +52,7 @@ function () {
50
52
  });
51
53
  });
52
54
  });
53
- renderingService.hooks.destroy.tap(function () {
55
+ renderingService.hooks.destroy.tap(PrepareRendererPlugin_1.tag, function () {
54
56
  _this.renderingContext.root.removeEventListener(ElementEvent.MOUNTED, handleMounted);
55
57
 
56
58
  _this.renderingContext.root.removeEventListener(ElementEvent.UNMOUNTED, handleUnmounted);
@@ -61,11 +63,14 @@ function () {
61
63
  });
62
64
  };
63
65
 
66
+ var PrepareRendererPlugin_1;
67
+ PrepareRendererPlugin.tag = 'Prepare';
68
+
64
69
  __decorate([inject(RenderingContext), __metadata("design:type", Object)], PrepareRendererPlugin.prototype, "renderingContext", void 0);
65
70
 
66
- __decorate([inject(StyleValueRegistry), __metadata("design:type", StyleValueRegistry)], PrepareRendererPlugin.prototype, "styleValueRegistry", void 0);
71
+ __decorate([inject(StyleValueRegistry), __metadata("design:type", Object)], PrepareRendererPlugin.prototype, "styleValueRegistry", void 0);
67
72
 
68
- PrepareRendererPlugin = __decorate([singleton({
73
+ PrepareRendererPlugin = PrepareRendererPlugin_1 = __decorate([singleton({
69
74
  contrib: RenderingPluginContribution
70
75
  })], PrepareRendererPlugin);
71
76
  return PrepareRendererPlugin;
@@ -191,8 +191,7 @@ function (_super) {
191
191
  e = _a.sent();
192
192
  this.dispatchEvent(e, 'pointerdown');
193
193
 
194
- if (e.pointerType === 'touch') {
195
- this.dispatchEvent(e, 'touchstart');
194
+ if (e.pointerType === 'touch') {// this.dispatchEvent(e, 'touchstart');
196
195
  } else if (e.pointerType === 'mouse' || e.pointerType === 'pen') {
197
196
  isRightButton = e.button === 2;
198
197
  this.dispatchEvent(e, isRightButton ? 'rightdown' : 'mousedown');
@@ -230,8 +229,7 @@ function (_super) {
230
229
  e = _a.sent();
231
230
  this.dispatchEvent(e, 'pointerup');
232
231
 
233
- if (e.pointerType === 'touch') {
234
- this.dispatchEvent(e, 'touchend');
232
+ if (e.pointerType === 'touch') {// this.dispatchEvent(e, 'touchend');
235
233
  } else if (e.pointerType === 'mouse' || e.pointerType === 'pen') {
236
234
  isRightButton = e.button === 2;
237
235
  this.dispatchEvent(e, isRightButton ? 'rightup' : 'mouseup');
@@ -408,8 +406,7 @@ function (_super) {
408
406
  } // Then pointermove
409
407
 
410
408
 
411
- this.dispatchEvent(e, 'pointermove');
412
- if (e.pointerType === 'touch') this.dispatchEvent(e, 'touchmove');
409
+ this.dispatchEvent(e, 'pointermove'); // if (e.pointerType === 'touch') this.dispatchEvent(e, 'touchmove');
413
410
 
414
411
  if (isMouse) {
415
412
  this.dispatchEvent(e, 'mousemove');
@@ -565,8 +562,7 @@ function (_super) {
565
562
  e.currentTarget = currentTarget;
566
563
  this.notifyTarget(e, 'pointerupoutside');
567
564
 
568
- if (e.pointerType === 'touch') {
569
- this.notifyTarget(e, 'touchendoutside');
565
+ if (e.pointerType === 'touch') {// this.notifyTarget(e, 'touchendoutside');
570
566
  } else if (e.pointerType === 'mouse' || e.pointerType === 'pen') {
571
567
  this.notifyTarget(e, e.button === 2 ? 'rightupoutside' : 'mouseupoutside');
572
568
  }
@@ -3,7 +3,7 @@
3
3
  * used in following scenes:
4
4
  * - g `ctx.measureText`
5
5
  * - g-plugin-canvas-picker `ctx.isPointInPath`
6
- * - g-plugin-webgl-renderer `ctx.createLinearGradient` and generate texture
6
+ * - g-plugin-device-renderer `ctx.createLinearGradient` and generate texture
7
7
  */
8
8
  export declare class OffscreenCanvasCreator {
9
9
  private canvas;
@@ -4,7 +4,7 @@ import { singleton } from 'mana-syringe';
4
4
  * used in following scenes:
5
5
  * - g `ctx.measureText`
6
6
  * - g-plugin-canvas-picker `ctx.isPointInPath`
7
- * - g-plugin-webgl-renderer `ctx.createLinearGradient` and generate texture
7
+ * - g-plugin-device-renderer `ctx.createLinearGradient` and generate texture
8
8
  */
9
9
 
10
10
  var OffscreenCanvasCreator =
@@ -1,5 +1,5 @@
1
1
  import { Syringe } from 'mana-syringe';
2
- import { SyncHook, SyncWaterfallHook, AsyncParallelHook, AsyncSeriesWaterfallHook } from '../utils';
2
+ import { SyncHook, SyncWaterfallHook, AsyncParallelHook, AsyncSeriesWaterfallHook } from 'tapable';
3
3
  import type { DisplayObject } from '../display-objects';
4
4
  import type { CanvasConfig, EventPosition, InteractivePointerEvent } from '../types';
5
5
  export interface RenderingPlugin {
@@ -38,47 +38,47 @@ export declare class RenderingService {
38
38
  /**
39
39
  * called before any frame rendered
40
40
  */
41
- init: AsyncParallelHook<[], void>;
41
+ init: AsyncParallelHook<[], import("tapable").UnsetAdditionalOptions>;
42
42
  /**
43
43
  * only dirty object which has sth changed will be rendered
44
44
  */
45
- dirtycheck: SyncWaterfallHook<[DisplayObject<any, any>], DisplayObject<any, any>>;
45
+ dirtycheck: SyncWaterfallHook<[DisplayObject<any, any>], import("tapable").UnsetAdditionalOptions>;
46
46
  /**
47
47
  * do culling
48
48
  */
49
- cull: SyncWaterfallHook<[DisplayObject<any, any>], DisplayObject<any, any>>;
49
+ cull: SyncWaterfallHook<[DisplayObject<any, any>], import("tapable").UnsetAdditionalOptions>;
50
50
  /**
51
51
  * called at beginning of each frame, won't get called if nothing to re-render
52
52
  */
53
- beginFrame: SyncHook<[], void>;
53
+ beginFrame: SyncHook<[], void, import("tapable").UnsetAdditionalOptions>;
54
54
  /**
55
55
  * called before every dirty object get rendered
56
56
  */
57
- beforeRender: SyncHook<[DisplayObject<any, any>], void>;
57
+ beforeRender: SyncHook<[DisplayObject<any, any>], void, import("tapable").UnsetAdditionalOptions>;
58
58
  /**
59
59
  * called when every dirty object rendering even it's culled
60
60
  */
61
- render: SyncHook<[DisplayObject<any, any>], void>;
61
+ render: SyncHook<[DisplayObject<any, any>], void, import("tapable").UnsetAdditionalOptions>;
62
62
  /**
63
63
  * called after every dirty object get rendered
64
64
  */
65
- afterRender: SyncHook<[DisplayObject<any, any>], void>;
66
- endFrame: SyncHook<[], void>;
67
- destroy: SyncHook<[], void>;
65
+ afterRender: SyncHook<[DisplayObject<any, any>], void, import("tapable").UnsetAdditionalOptions>;
66
+ endFrame: SyncHook<[], void, import("tapable").UnsetAdditionalOptions>;
67
+ destroy: SyncHook<[], void, import("tapable").UnsetAdditionalOptions>;
68
68
  /**
69
- * use async but faster method such as GPU-based picking in `g-plugin-webgl-renderer`
69
+ * use async but faster method such as GPU-based picking in `g-plugin-device-renderer`
70
70
  */
71
71
  pick: AsyncSeriesWaterfallHook<[PickingResult], PickingResult>;
72
72
  /**
73
73
  * used in event system
74
74
  */
75
- pointerDown: SyncHook<[InteractivePointerEvent], void>;
76
- pointerUp: SyncHook<[InteractivePointerEvent], void>;
77
- pointerMove: SyncHook<[InteractivePointerEvent], void>;
78
- pointerOut: SyncHook<[InteractivePointerEvent], void>;
79
- pointerOver: SyncHook<[InteractivePointerEvent], void>;
80
- pointerCancel: SyncHook<[InteractivePointerEvent], void>;
81
- pointerWheel: SyncHook<[InteractivePointerEvent], void>;
75
+ pointerDown: SyncHook<[InteractivePointerEvent], void, import("tapable").UnsetAdditionalOptions>;
76
+ pointerUp: SyncHook<[InteractivePointerEvent], void, import("tapable").UnsetAdditionalOptions>;
77
+ pointerMove: SyncHook<[InteractivePointerEvent], void, import("tapable").UnsetAdditionalOptions>;
78
+ pointerOut: SyncHook<[InteractivePointerEvent], void, import("tapable").UnsetAdditionalOptions>;
79
+ pointerOver: SyncHook<[InteractivePointerEvent], void, import("tapable").UnsetAdditionalOptions>;
80
+ pointerWheel: SyncHook<[InteractivePointerEvent], void, import("tapable").UnsetAdditionalOptions>;
81
+ pointerCancel: SyncHook<[InteractivePointerEvent], void, import("tapable").UnsetAdditionalOptions>;
82
82
  };
83
83
  init(): Promise<void>;
84
84
  getStats(): {
@@ -1,7 +1,8 @@
1
1
  import { __awaiter, __decorate, __generator, __metadata } from "tslib";
2
- import { inject, singleton, contrib, Syringe, Contribution } from 'mana-syringe';
3
- import { SyncHook, SyncWaterfallHook, AsyncParallelHook, AsyncSeriesWaterfallHook } from '../utils';
4
- import { StyleValueRegistry } from '../css';
2
+ import { inject, singleton, contrib, Syringe, Contribution } from 'mana-syringe'; // import { SyncHook, SyncWaterfallHook, AsyncParallelHook, AsyncSeriesWaterfallHook } from '../utils';
3
+
4
+ import { SyncHook, SyncWaterfallHook, AsyncParallelHook, AsyncSeriesWaterfallHook } from 'tapable';
5
+ import { StyleValueRegistry } from '../css/interfaces';
5
6
  import { ElementEvent } from '../dom';
6
7
  import { RenderingContext, RenderReason } from './RenderingContext';
7
8
  import { SceneGraphService, sortByZIndex } from './SceneGraphService';
@@ -47,50 +48,50 @@ function () {
47
48
  /**
48
49
  * only dirty object which has sth changed will be rendered
49
50
  */
50
- dirtycheck: new SyncWaterfallHook(),
51
+ dirtycheck: new SyncWaterfallHook(['object']),
51
52
 
52
53
  /**
53
54
  * do culling
54
55
  */
55
- cull: new SyncWaterfallHook(),
56
+ cull: new SyncWaterfallHook(['object']),
56
57
 
57
58
  /**
58
59
  * called at beginning of each frame, won't get called if nothing to re-render
59
60
  */
60
- beginFrame: new SyncHook(),
61
+ beginFrame: new SyncHook([]),
61
62
 
62
63
  /**
63
64
  * called before every dirty object get rendered
64
65
  */
65
- beforeRender: new SyncHook(),
66
+ beforeRender: new SyncHook(['objectToRender']),
66
67
 
67
68
  /**
68
69
  * called when every dirty object rendering even it's culled
69
70
  */
70
- render: new SyncHook(),
71
+ render: new SyncHook(['objectToRender']),
71
72
 
72
73
  /**
73
74
  * called after every dirty object get rendered
74
75
  */
75
- afterRender: new SyncHook(),
76
- endFrame: new SyncHook(),
77
- destroy: new SyncHook(),
76
+ afterRender: new SyncHook(['objectToRender']),
77
+ endFrame: new SyncHook([]),
78
+ destroy: new SyncHook([]),
78
79
 
79
80
  /**
80
- * use async but faster method such as GPU-based picking in `g-plugin-webgl-renderer`
81
+ * use async but faster method such as GPU-based picking in `g-plugin-device-renderer`
81
82
  */
82
- pick: new AsyncSeriesWaterfallHook(),
83
+ pick: new AsyncSeriesWaterfallHook(['result']),
83
84
 
84
85
  /**
85
86
  * used in event system
86
87
  */
87
- pointerDown: new SyncHook(),
88
- pointerUp: new SyncHook(),
89
- pointerMove: new SyncHook(),
90
- pointerOut: new SyncHook(),
91
- pointerOver: new SyncHook(),
92
- pointerCancel: new SyncHook(),
93
- pointerWheel: new SyncHook()
88
+ pointerDown: new SyncHook(['event']),
89
+ pointerUp: new SyncHook(['event']),
90
+ pointerMove: new SyncHook(['event']),
91
+ pointerOut: new SyncHook(['event']),
92
+ pointerOver: new SyncHook(['event']),
93
+ pointerWheel: new SyncHook(['event']),
94
+ pointerCancel: new SyncHook(['event'])
94
95
  };
95
96
  }
96
97
 
@@ -106,12 +107,14 @@ function () {
106
107
  cache: false
107
108
  }).forEach(function (plugin) {
108
109
  plugin.apply(_this);
109
- });
110
+ }); // await this.hooks.init.callPromise();
111
+
110
112
  return [4
111
113
  /*yield*/
112
- , this.hooks.init.callPromise()];
114
+ , this.hooks.init.promise()];
113
115
 
114
116
  case 1:
117
+ // await this.hooks.init.callPromise();
115
118
  _a.sent();
116
119
 
117
120
  this.inited = true;
@@ -219,7 +222,7 @@ function () {
219
222
 
220
223
  __decorate([inject(SceneGraphService), __metadata("design:type", Object)], RenderingService.prototype, "sceneGraphService", void 0);
221
224
 
222
- __decorate([inject(StyleValueRegistry), __metadata("design:type", StyleValueRegistry)], RenderingService.prototype, "styleValueRegistry", void 0);
225
+ __decorate([inject(StyleValueRegistry), __metadata("design:type", Object)], RenderingService.prototype, "styleValueRegistry", void 0);
223
226
 
224
227
  RenderingService = __decorate([singleton()], RenderingService);
225
228
  return RenderingService;
@@ -801,7 +801,9 @@ function () {
801
801
 
802
802
  __decorate([inject(SceneGraphSelectorFactory), __metadata("design:type", Function)], DefaultSceneGraphService.prototype, "sceneGraphSelectorFactory", void 0);
803
803
 
804
- DefaultSceneGraphService = __decorate([singleton()], DefaultSceneGraphService);
804
+ DefaultSceneGraphService = __decorate([singleton({
805
+ token: SceneGraphService
806
+ })], DefaultSceneGraphService);
805
807
  return DefaultSceneGraphService;
806
808
  }();
807
809
 
package/es/types.d.ts CHANGED
@@ -120,6 +120,10 @@ export interface BaseStyleProps {
120
120
  opacity?: number;
121
121
  /** 线宽 */
122
122
  lineWidth?: string | number;
123
+ /**
124
+ * increased line width when hitting test
125
+ */
126
+ increasedLineWidthForHitTesting?: string | number;
123
127
  /**
124
128
  * 交互区域
125
129
  */
@@ -157,8 +161,9 @@ export interface BaseStyleProps {
157
161
  * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/miterLimit
158
162
  */
159
163
  miterLimit?: number;
164
+ display?: string;
160
165
  }
161
- export interface ParsedBaseStyleProps extends Omit<BaseStyleProps, 'anchor' | 'x' | 'y' | 'z' | 'opacity' | 'strokeOpacity' | 'fillOpacity' | 'fill' | 'stroke' | 'lineWidth' | 'lineJoin' | 'lineCap' | 'lineDash' | 'lineDashOffset' | 'path' | 'points' | 'shadowColor' | 'shadowBlur' | 'shadowOffsetX' | 'shadowOffsetY' | 'visibility' | 'pointerEvents' | 'zIndex' | 'transformOrigin' | 'textTransform'> {
166
+ export interface ParsedBaseStyleProps extends Omit<BaseStyleProps, 'anchor' | 'x' | 'y' | 'z' | 'opacity' | 'strokeOpacity' | 'fillOpacity' | 'fill' | 'stroke' | 'lineWidth' | 'increasedLineWidthForHitTesting' | 'lineJoin' | 'lineCap' | 'lineDash' | 'lineDashOffset' | 'path' | 'points' | 'shadowColor' | 'shadowBlur' | 'shadowOffsetX' | 'shadowOffsetY' | 'visibility' | 'pointerEvents' | 'zIndex' | 'transformOrigin' | 'textTransform'> {
162
167
  zIndex?: CSSUnitValue;
163
168
  visibility?: CSSKeywordValue;
164
169
  pointerEvents?: CSSKeywordValue;
@@ -179,6 +184,7 @@ export interface ParsedBaseStyleProps extends Omit<BaseStyleProps, 'anchor' | 'x
179
184
  width?: CSSUnitValue;
180
185
  height?: CSSUnitValue;
181
186
  lineWidth?: CSSUnitValue;
187
+ increasedLineWidthForHitTesting?: CSSUnitValue;
182
188
  /**
183
189
  * x according to definition, eg. Line's x1/x2, Polyline's points
184
190
  */
@@ -210,10 +216,6 @@ export interface RendererConfig {
210
216
  * enable auto rendering
211
217
  */
212
218
  enableAutoRendering: boolean;
213
- /**
214
- * enable TAA in WebGL
215
- */
216
- enableTAA: boolean;
217
219
  }
218
220
  export declare const CanvasConfig: Syringe.DefinedToken;
219
221
  export interface CanvasConfig {
@@ -0,0 +1,43 @@
1
+ interface PromiseStatus<T> {
2
+ isPending: () => boolean;
3
+ isRejected: () => boolean;
4
+ isFulfilled: () => boolean;
5
+ getFullFilledValue: () => T;
6
+ }
7
+ /**
8
+ * This function allow you to modify a JS Promise by adding some status properties.
9
+ * Based on: http://stackoverflow.com/questions/21485545/is-there-a-way-to-tell-if-an-es6-promise-is-fulfilled-rejected-resolved
10
+ * But modified according to the specs of promises : https://promisesaplus.com/
11
+ */
12
+ export declare const makeQuerablePromise: <T>(promise: Promise<T>) => PromiseStatus<T>;
13
+ /**
14
+ * Simple implementation of the deferred pattern.
15
+ * An object that exposes a promise and functions to resolve and reject it.
16
+ */
17
+ export declare class Deferred<T = void> {
18
+ resolve: (value: T | PromiseLike<T>) => void;
19
+ reject: (err?: any) => void;
20
+ promise: Promise<T>;
21
+ }
22
+ export declare const equalSet: (as: Set<any>, bs: Set<any>) => boolean;
23
+ /**
24
+ * Nicely typed aliases for some `Object` Methods
25
+ * - PSA: Don't mutate `yourObject`s
26
+ * - Numerical keys are BAD, resolve that issue upstream
27
+ * - Discussion: https://stackoverflow.com/a/65117465/565877
28
+ */
29
+ export declare const ObjectTyped: {
30
+ /**
31
+ * Object.keys, but with nice typing (`Array<keyof T>`)
32
+ */
33
+ keys: <T extends {}>(yourObject: T) => (keyof T)[];
34
+ /**
35
+ * Object.values, but with nice typing
36
+ */
37
+ values: <T_1 extends {}>(yourObject: T_1) => T_1[keyof T_1][];
38
+ /**
39
+ * Object.entries, but with nice typing
40
+ */
41
+ entries: <T_2 extends {}>(yourObject: T_2) => [keyof T_2, T_2[keyof T_2]][];
42
+ };
43
+ export {};
@@ -0,0 +1,117 @@
1
+ import { __values } from "tslib";
2
+ /**
3
+ * This function allow you to modify a JS Promise by adding some status properties.
4
+ * Based on: http://stackoverflow.com/questions/21485545/is-there-a-way-to-tell-if-an-es6-promise-is-fulfilled-rejected-resolved
5
+ * But modified according to the specs of promises : https://promisesaplus.com/
6
+ */
7
+
8
+ export var makeQuerablePromise = function makeQuerablePromise(promise) {
9
+ // Don't modify any promise that has been already modified.
10
+ if (promise.isRejected || promise.isFulfilled) return promise; // Set initial state
11
+
12
+ var isPending = true;
13
+ var isRejected = false;
14
+ var isFulfilled = false;
15
+ var fullFilledValue; // Observe the promise, saving the fulfillment in a closure scope.
16
+
17
+ var result = promise.then(function (v) {
18
+ isFulfilled = true;
19
+ isPending = false;
20
+ fullFilledValue = v;
21
+ return v;
22
+ }, function (e) {
23
+ isRejected = true;
24
+ isPending = false;
25
+ throw e;
26
+ });
27
+
28
+ result.isFulfilled = function () {
29
+ return isFulfilled;
30
+ };
31
+
32
+ result.isPending = function () {
33
+ return isPending;
34
+ };
35
+
36
+ result.isRejected = function () {
37
+ return isRejected;
38
+ };
39
+
40
+ result.getFullFilledValue = function () {
41
+ return fullFilledValue;
42
+ };
43
+
44
+ return result;
45
+ };
46
+ /**
47
+ * Simple implementation of the deferred pattern.
48
+ * An object that exposes a promise and functions to resolve and reject it.
49
+ */
50
+
51
+ var Deferred =
52
+ /** @class */
53
+ function () {
54
+ function Deferred() {
55
+ var _this = this;
56
+
57
+ this.promise = new Promise(function (resolve, reject) {
58
+ _this.resolve = resolve;
59
+ _this.reject = reject;
60
+ });
61
+ }
62
+
63
+ return Deferred;
64
+ }();
65
+
66
+ export { Deferred };
67
+ export var equalSet = function equalSet(as, bs) {
68
+ var e_1, _a;
69
+
70
+ if (as.size !== bs.size) return false;
71
+
72
+ try {
73
+ // eslint-disable-next-line no-restricted-syntax
74
+ for (var as_1 = __values(as), as_1_1 = as_1.next(); !as_1_1.done; as_1_1 = as_1.next()) {
75
+ var a = as_1_1.value;
76
+
77
+ if (!bs.has(a)) {
78
+ return false;
79
+ }
80
+ }
81
+ } catch (e_1_1) {
82
+ e_1 = {
83
+ error: e_1_1
84
+ };
85
+ } finally {
86
+ try {
87
+ if (as_1_1 && !as_1_1.done && (_a = as_1.return)) _a.call(as_1);
88
+ } finally {
89
+ if (e_1) throw e_1.error;
90
+ }
91
+ }
92
+
93
+ return true;
94
+ };
95
+ /**
96
+ * Nicely typed aliases for some `Object` Methods
97
+ * - PSA: Don't mutate `yourObject`s
98
+ * - Numerical keys are BAD, resolve that issue upstream
99
+ * - Discussion: https://stackoverflow.com/a/65117465/565877
100
+ */
101
+
102
+ export var ObjectTyped = {
103
+ /**
104
+ * Object.keys, but with nice typing (`Array<keyof T>`)
105
+ */
106
+ keys: Object.keys,
107
+
108
+ /**
109
+ * Object.values, but with nice typing
110
+ */
111
+ values: Object.values,
112
+
113
+ /**
114
+ * Object.entries, but with nice typing
115
+ */
116
+ entries: Object.entries
117
+ };
@@ -0,0 +1,2 @@
1
+ /// <reference types="offscreencanvas" />
2
+ export declare function setDOMSize($el: HTMLElement | OffscreenCanvas, width: number, height: number): void;
@@ -0,0 +1,8 @@
1
+ import { isBrowser } from './canvas';
2
+ var PX_SUFFIX = 'px';
3
+ export function setDOMSize($el, width, height) {
4
+ if (isBrowser && $el.style) {
5
+ $el.style.width = width + PX_SUFFIX;
6
+ $el.style.height = height + PX_SUFFIX;
7
+ }
8
+ }
@@ -6,4 +6,5 @@ export * from './text';
6
6
  export * from './string';
7
7
  export * from './event';
8
8
  export * from './canvas';
9
- export * from './hooks';
9
+ export * from './deferred';
10
+ export * from './dom';
package/es/utils/index.js CHANGED
@@ -6,4 +6,5 @@ export * from './text';
6
6
  export * from './string';
7
7
  export * from './event';
8
8
  export * from './canvas';
9
- export * from './hooks';
9
+ export * from './deferred';
10
+ export * from './dom';
@@ -1,6 +1,6 @@
1
1
  import { __read, __spreadArray } from "tslib";
2
2
  import { GlobalContainer } from 'mana-syringe';
3
- import { StyleValueRegistry } from '../css';
3
+ import { StyleValueRegistry } from '../css/interfaces';
4
4
  import { parseEasingFunction } from './animation';
5
5
  import { camelCase } from './string';
6
6
  export function convertEffectInput(keyframes, timing, target) {
@@ -1,6 +1,7 @@
1
1
  import type { Syringe } from 'mana-syringe';
2
2
  import type { RendererConfig } from './types';
3
3
  export interface RendererPlugin {
4
+ name: string;
4
5
  init: (container: Syringe.Container) => void;
5
6
  destroy: (container: Syringe.Container) => void;
6
7
  }
@@ -10,6 +11,14 @@ export interface IRenderer {
10
11
  * register plugin at runtime
11
12
  */
12
13
  registerPlugin: (plugin: RendererPlugin) => void;
14
+ /**
15
+ * unregister plugin at runtime
16
+ */
17
+ unregisterPlugin: (plugin: RendererPlugin) => void;
18
+ /**
19
+ * get plugin by name
20
+ */
21
+ getPlugin: (name: string) => RendererPlugin;
13
22
  /**
14
23
  * return all registered plugins
15
24
  */
@@ -20,7 +29,9 @@ export declare class AbstractRenderer implements IRenderer {
20
29
  private config;
21
30
  constructor(config?: Partial<RendererConfig>);
22
31
  registerPlugin(plugin: RendererPlugin): void;
32
+ unregisterPlugin(plugin: RendererPlugin): void;
23
33
  getPlugins(): RendererPlugin[];
34
+ getPlugin(name: string): RendererPlugin;
24
35
  getConfig(): RendererConfig;
25
36
  setConfig(config: Partial<RendererConfig>): void;
26
37
  }