@antv/g 5.0.23-alpha.9 → 5.1.0

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 (256) 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/Canvas.js +2 -0
  6. package/es/css/CSS.d.ts +2 -1
  7. package/es/css/CSS.js +6 -2
  8. package/es/css/CSSProperty.d.ts +3 -2
  9. package/es/css/StyleValueRegistry.d.ts +4 -2
  10. package/es/css/StyleValueRegistry.js +100 -95
  11. package/es/css/cssom/CSSNumericValue.js +1 -1
  12. package/es/css/index.d.ts +2 -1
  13. package/es/css/index.js +2 -1
  14. package/es/css/interfaces.d.ts +6 -0
  15. package/es/css/interfaces.js +2 -0
  16. package/es/css/layout/FragmentResult.d.ts +32 -0
  17. package/es/css/layout/FragmentResult.js +32 -0
  18. package/es/css/layout/LayoutChildren.d.ts +23 -0
  19. package/es/css/layout/LayoutChildren.js +55 -0
  20. package/es/css/layout/LayoutContext.d.ts +35 -0
  21. package/es/css/layout/LayoutContext.js +35 -0
  22. package/es/css/layout/LayoutDefinition.d.ts +20 -0
  23. package/es/css/layout/LayoutDefinition.js +9 -0
  24. package/es/css/layout/LayoutEdges.d.ts +24 -0
  25. package/es/css/layout/LayoutEdges.js +41 -0
  26. package/es/css/layout/LayoutEngine.d.ts +41 -0
  27. package/es/css/layout/LayoutEngine.js +332 -0
  28. package/es/css/layout/LayoutFragment.d.ts +26 -0
  29. package/es/css/layout/LayoutFragment.js +28 -0
  30. package/es/css/layout/LayoutObject.d.ts +46 -0
  31. package/es/css/layout/LayoutObject.js +172 -0
  32. package/es/css/layout/LayoutRegistry.d.ts +16 -0
  33. package/es/css/layout/LayoutRegistry.js +78 -0
  34. package/es/css/layout/LayoutWorkTask.d.ts +14 -0
  35. package/es/css/layout/LayoutWorkTask.js +1 -0
  36. package/es/css/layout/index.d.ts +11 -0
  37. package/es/css/layout/index.js +11 -0
  38. package/es/css/layout/types.d.ts +104 -0
  39. package/es/css/layout/types.js +66 -0
  40. package/es/css/parser/color.d.ts +1 -1
  41. package/es/css/parser/color.js +2 -2
  42. package/es/css/parser/dimension.js +5 -1
  43. package/es/css/parser/path.d.ts +2 -2
  44. package/es/css/parser/path.js +9 -2
  45. package/es/css/parser/points.d.ts +8 -1
  46. package/es/css/parser/points.js +33 -3
  47. package/es/css/parser/transform.js +1 -1
  48. package/es/css/properties/CSSPropertyClipPath.js +7 -1
  49. package/es/css/properties/CSSPropertyColor.d.ts +1 -1
  50. package/es/css/properties/CSSPropertyLengthOrPercentage.d.ts +1 -1
  51. package/es/css/properties/CSSPropertyLocalPosition.d.ts +0 -9
  52. package/es/css/properties/CSSPropertyLocalPosition.js +64 -20
  53. package/es/css/properties/CSSPropertyPath.d.ts +2 -2
  54. package/es/css/properties/CSSPropertyPath.js +7 -5
  55. package/es/css/properties/CSSPropertyPoints.js +3 -4
  56. package/es/css/properties/CSSPropertyTransform.d.ts +1 -1
  57. package/es/css/properties/CSSPropertyTransform.js +76 -104
  58. package/es/display-objects/Circle.d.ts +4 -0
  59. package/es/display-objects/Circle.js +2 -0
  60. package/es/display-objects/DisplayObject.d.ts +2 -9
  61. package/es/display-objects/DisplayObject.js +8 -27
  62. package/es/display-objects/Ellipse.d.ts +4 -0
  63. package/es/display-objects/Ellipse.js +2 -0
  64. package/es/display-objects/Group.d.ts +4 -0
  65. package/es/display-objects/Group.js +2 -0
  66. package/es/display-objects/HTML.d.ts +4 -4
  67. package/es/display-objects/HTML.js +5 -3
  68. package/es/display-objects/Image.d.ts +4 -0
  69. package/es/display-objects/Image.js +2 -0
  70. package/es/display-objects/Line.js +2 -0
  71. package/es/display-objects/Path.d.ts +2 -2
  72. package/es/display-objects/Polygon.js +1 -1
  73. package/es/display-objects/Polyline.js +1 -1
  74. package/es/display-objects/Rect.d.ts +6 -2
  75. package/es/display-objects/Rect.js +2 -0
  76. package/es/display-objects/Text.d.ts +4 -0
  77. package/es/display-objects/Text.js +2 -0
  78. package/es/dom/Document.js +2 -2
  79. package/es/dom/Element.js +1 -0
  80. package/es/global-module.js +91 -8
  81. package/es/index.d.ts +3 -0
  82. package/es/index.js +3 -0
  83. package/es/plugins/CullingPlugin.d.ts +1 -0
  84. package/es/plugins/CullingPlugin.js +8 -3
  85. package/es/plugins/DirtyCheckPlugin.d.ts +1 -0
  86. package/es/plugins/DirtyCheckPlugin.js +7 -2
  87. package/es/plugins/EventPlugin.d.ts +1 -0
  88. package/es/plugins/EventPlugin.js +14 -9
  89. package/es/plugins/PrepareRendererPlugin.d.ts +1 -0
  90. package/es/plugins/PrepareRendererPlugin.js +10 -5
  91. package/es/services/EventService.js +14 -10
  92. package/es/services/OffscreenCanvasCreator.d.ts +1 -1
  93. package/es/services/OffscreenCanvasCreator.js +1 -1
  94. package/es/services/RenderingService.d.ts +18 -18
  95. package/es/services/RenderingService.js +26 -23
  96. package/es/services/SceneGraphService.d.ts +2 -0
  97. package/es/services/SceneGraphService.js +12 -1
  98. package/es/services/aabb/CircleUpdater.d.ts +0 -2
  99. package/es/services/aabb/CircleUpdater.js +2 -6
  100. package/es/services/aabb/EllipseUpdater.d.ts +0 -2
  101. package/es/services/aabb/EllipseUpdater.js +2 -6
  102. package/es/services/aabb/LineUpdater.d.ts +0 -2
  103. package/es/services/aabb/LineUpdater.js +1 -3
  104. package/es/services/aabb/PathUpdater.d.ts +0 -2
  105. package/es/services/aabb/PathUpdater.js +1 -5
  106. package/es/services/aabb/PolylineUpdater.d.ts +0 -2
  107. package/es/services/aabb/PolylineUpdater.js +1 -3
  108. package/es/services/aabb/RectUpdater.d.ts +0 -2
  109. package/es/services/aabb/RectUpdater.js +1 -5
  110. package/es/services/aabb/TextUpdater.d.ts +7 -0
  111. package/es/services/aabb/TextUpdater.js +0 -4
  112. package/es/services/aabb/interfaces.d.ts +0 -3
  113. package/es/types.d.ts +12 -23
  114. package/es/types.js +1 -0
  115. package/es/utils/deferred.d.ts +43 -0
  116. package/es/utils/deferred.js +117 -0
  117. package/es/utils/dom.d.ts +2 -0
  118. package/es/utils/dom.js +8 -0
  119. package/es/utils/index.d.ts +2 -1
  120. package/es/utils/index.js +2 -1
  121. package/es/utils/interpolation.js +3 -9
  122. package/es/utils/math.js +4 -3
  123. package/es/utils/path.d.ts +2 -2
  124. package/es/utils/path.js +61 -24
  125. package/lib/AbstractRenderer.d.ts +11 -0
  126. package/lib/AbstractRenderer.js +17 -2
  127. package/lib/Canvas.d.ts +1 -1
  128. package/lib/Canvas.js +2 -0
  129. package/lib/css/CSS.d.ts +2 -1
  130. package/lib/css/CSS.js +9 -3
  131. package/lib/css/CSSProperty.d.ts +3 -2
  132. package/lib/css/StyleValueRegistry.d.ts +4 -2
  133. package/lib/css/StyleValueRegistry.js +104 -96
  134. package/lib/css/cssom/CSSNumericValue.js +17 -17
  135. package/lib/css/index.d.ts +2 -1
  136. package/lib/css/index.js +25 -12
  137. package/lib/css/interfaces.d.ts +6 -0
  138. package/lib/css/interfaces.js +12 -0
  139. package/lib/css/layout/FragmentResult.d.ts +32 -0
  140. package/lib/css/layout/FragmentResult.js +51 -0
  141. package/lib/css/layout/LayoutChildren.d.ts +23 -0
  142. package/lib/css/layout/LayoutChildren.js +72 -0
  143. package/lib/css/layout/LayoutContext.d.ts +35 -0
  144. package/lib/css/layout/LayoutContext.js +49 -0
  145. package/lib/css/layout/LayoutDefinition.d.ts +20 -0
  146. package/lib/css/layout/LayoutDefinition.js +16 -0
  147. package/lib/css/layout/LayoutEdges.d.ts +24 -0
  148. package/lib/css/layout/LayoutEdges.js +56 -0
  149. package/lib/css/layout/LayoutEngine.d.ts +41 -0
  150. package/lib/css/layout/LayoutEngine.js +345 -0
  151. package/lib/css/layout/LayoutFragment.d.ts +26 -0
  152. package/lib/css/layout/LayoutFragment.js +44 -0
  153. package/lib/css/layout/LayoutObject.d.ts +46 -0
  154. package/lib/css/layout/LayoutObject.js +182 -0
  155. package/lib/css/layout/LayoutRegistry.d.ts +16 -0
  156. package/lib/css/layout/LayoutRegistry.js +87 -0
  157. package/lib/css/layout/LayoutWorkTask.d.ts +14 -0
  158. package/lib/css/layout/LayoutWorkTask.js +5 -0
  159. package/lib/css/layout/index.d.ts +11 -0
  160. package/lib/css/layout/index.js +148 -0
  161. package/lib/css/layout/types.d.ts +104 -0
  162. package/lib/css/layout/types.js +74 -0
  163. package/lib/css/parser/color.d.ts +1 -1
  164. package/lib/css/parser/color.js +1 -1
  165. package/lib/css/parser/dimension.js +4 -0
  166. package/lib/css/parser/path.d.ts +2 -2
  167. package/lib/css/parser/path.js +9 -2
  168. package/lib/css/parser/points.d.ts +8 -1
  169. package/lib/css/parser/points.js +33 -3
  170. package/lib/css/parser/transform.js +1 -1
  171. package/lib/css/properties/CSSPropertyClipPath.js +8 -1
  172. package/lib/css/properties/CSSPropertyColor.d.ts +1 -1
  173. package/lib/css/properties/CSSPropertyLengthOrPercentage.d.ts +1 -1
  174. package/lib/css/properties/CSSPropertyLocalPosition.d.ts +0 -9
  175. package/lib/css/properties/CSSPropertyLocalPosition.js +65 -20
  176. package/lib/css/properties/CSSPropertyPath.d.ts +2 -2
  177. package/lib/css/properties/CSSPropertyPath.js +7 -5
  178. package/lib/css/properties/CSSPropertyPoints.js +3 -4
  179. package/lib/css/properties/CSSPropertyTransform.d.ts +1 -1
  180. package/lib/css/properties/CSSPropertyTransform.js +75 -103
  181. package/lib/display-objects/Circle.d.ts +4 -0
  182. package/lib/display-objects/Circle.js +2 -0
  183. package/lib/display-objects/DisplayObject.d.ts +2 -9
  184. package/lib/display-objects/DisplayObject.js +9 -29
  185. package/lib/display-objects/Ellipse.d.ts +4 -0
  186. package/lib/display-objects/Ellipse.js +2 -0
  187. package/lib/display-objects/Group.d.ts +4 -0
  188. package/lib/display-objects/Group.js +2 -0
  189. package/lib/display-objects/HTML.d.ts +4 -4
  190. package/lib/display-objects/HTML.js +5 -3
  191. package/lib/display-objects/Image.d.ts +4 -0
  192. package/lib/display-objects/Image.js +2 -0
  193. package/lib/display-objects/Line.js +2 -0
  194. package/lib/display-objects/Path.d.ts +2 -2
  195. package/lib/display-objects/Polygon.js +1 -1
  196. package/lib/display-objects/Polyline.js +1 -1
  197. package/lib/display-objects/Rect.d.ts +6 -2
  198. package/lib/display-objects/Rect.js +2 -0
  199. package/lib/display-objects/Text.d.ts +4 -0
  200. package/lib/display-objects/Text.js +2 -0
  201. package/lib/dom/Document.js +2 -2
  202. package/lib/dom/Element.js +1 -0
  203. package/lib/global-module.js +91 -6
  204. package/lib/index.d.ts +3 -0
  205. package/lib/index.js +7 -2
  206. package/lib/plugins/CullingPlugin.d.ts +1 -0
  207. package/lib/plugins/CullingPlugin.js +7 -3
  208. package/lib/plugins/DirtyCheckPlugin.d.ts +1 -0
  209. package/lib/plugins/DirtyCheckPlugin.js +6 -2
  210. package/lib/plugins/EventPlugin.d.ts +1 -0
  211. package/lib/plugins/EventPlugin.js +13 -9
  212. package/lib/plugins/PrepareRendererPlugin.d.ts +1 -0
  213. package/lib/plugins/PrepareRendererPlugin.js +9 -5
  214. package/lib/services/EventService.js +14 -10
  215. package/lib/services/OffscreenCanvasCreator.d.ts +1 -1
  216. package/lib/services/OffscreenCanvasCreator.js +1 -1
  217. package/lib/services/RenderingService.d.ts +18 -18
  218. package/lib/services/RenderingService.js +26 -23
  219. package/lib/services/SceneGraphService.d.ts +2 -0
  220. package/lib/services/SceneGraphService.js +15 -1
  221. package/lib/services/aabb/CircleUpdater.d.ts +0 -2
  222. package/lib/services/aabb/CircleUpdater.js +2 -6
  223. package/lib/services/aabb/EllipseUpdater.d.ts +0 -2
  224. package/lib/services/aabb/EllipseUpdater.js +2 -6
  225. package/lib/services/aabb/LineUpdater.d.ts +0 -2
  226. package/lib/services/aabb/LineUpdater.js +1 -3
  227. package/lib/services/aabb/PathUpdater.d.ts +0 -2
  228. package/lib/services/aabb/PathUpdater.js +1 -5
  229. package/lib/services/aabb/PolylineUpdater.d.ts +0 -2
  230. package/lib/services/aabb/PolylineUpdater.js +1 -3
  231. package/lib/services/aabb/RectUpdater.d.ts +0 -2
  232. package/lib/services/aabb/RectUpdater.js +1 -5
  233. package/lib/services/aabb/TextUpdater.d.ts +7 -0
  234. package/lib/services/aabb/TextUpdater.js +0 -4
  235. package/lib/services/aabb/interfaces.d.ts +0 -3
  236. package/lib/types.d.ts +12 -23
  237. package/lib/types.js +1 -0
  238. package/lib/utils/deferred.d.ts +43 -0
  239. package/lib/utils/deferred.js +131 -0
  240. package/lib/utils/dom.d.ts +2 -0
  241. package/lib/utils/dom.js +17 -0
  242. package/lib/utils/index.d.ts +2 -1
  243. package/lib/utils/index.js +17 -4
  244. package/lib/utils/interpolation.js +4 -10
  245. package/lib/utils/math.js +4 -3
  246. package/lib/utils/path.d.ts +2 -2
  247. package/lib/utils/path.js +55 -24
  248. package/package.json +4 -3
  249. package/es/css/LayoutRegistry.d.ts +0 -11
  250. package/es/css/LayoutRegistry.js +0 -22
  251. package/es/utils/hooks.d.ts +0 -280
  252. package/es/utils/hooks.js +0 -753
  253. package/lib/css/LayoutRegistry.d.ts +0 -11
  254. package/lib/css/LayoutRegistry.js +0 -30
  255. package/lib/utils/hooks.d.ts +0 -280
  256. package/lib/utils/hooks.js +0 -759
@@ -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');
@@ -357,7 +355,11 @@ function (_super) {
357
355
  while (leaveEvent.target && !e.composedPath().includes(leaveEvent.target)) {
358
356
  leaveEvent.currentTarget = leaveEvent.target;
359
357
  this.notifyTarget(leaveEvent);
360
- if (isMouse) this.notifyTarget(leaveEvent, 'mouseleave');
358
+
359
+ if (isMouse) {
360
+ // console.error(leaveEvent.target);
361
+ this.notifyTarget(leaveEvent, 'mouseleave');
362
+ }
361
363
 
362
364
  if (Node.isNode(leaveEvent.target)) {
363
365
  leaveEvent.target = leaveEvent.target.parentNode;
@@ -408,8 +410,7 @@ function (_super) {
408
410
  } // Then pointermove
409
411
 
410
412
 
411
- this.dispatchEvent(e, 'pointermove');
412
- if (e.pointerType === 'touch') this.dispatchEvent(e, 'touchmove');
413
+ this.dispatchEvent(e, 'pointermove'); // if (e.pointerType === 'touch') this.dispatchEvent(e, 'touchmove');
413
414
 
414
415
  if (isMouse) {
415
416
  this.dispatchEvent(e, 'mousemove');
@@ -463,7 +464,11 @@ function (_super) {
463
464
  while (leaveEvent.target && leaveEvent.target !== (Node.isNode(this.rootTarget) && this.rootTarget.parentNode)) {
464
465
  leaveEvent.currentTarget = leaveEvent.target;
465
466
  this.notifyTarget(leaveEvent);
466
- if (isMouse) this.notifyTarget(leaveEvent, 'mouseleave');
467
+
468
+ if (isMouse) {
469
+ // console.error(leaveEvent.target, 'out');
470
+ this.notifyTarget(leaveEvent, 'mouseleave');
471
+ }
467
472
 
468
473
  if (Node.isNode(leaveEvent.target)) {
469
474
  leaveEvent.target = leaveEvent.target.parentNode;
@@ -565,8 +570,7 @@ function (_super) {
565
570
  e.currentTarget = currentTarget;
566
571
  this.notifyTarget(e, 'pointerupoutside');
567
572
 
568
- if (e.pointerType === 'touch') {
569
- this.notifyTarget(e, 'touchendoutside');
573
+ if (e.pointerType === 'touch') {// this.notifyTarget(e, 'touchendoutside');
570
574
  } else if (e.pointerType === 'mouse' || e.pointerType === 'pen') {
571
575
  this.notifyTarget(e, e.button === 2 ? 'rightupoutside' : 'mouseupoutside');
572
576
  }
@@ -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;
@@ -35,6 +35,7 @@ export interface SceneGraphService {
35
35
  getLocalRotation: (element: INode) => quat;
36
36
  getWorldTransform: (element: INode, transform?: Transform) => mat4;
37
37
  getLocalTransform: (element: INode, transform?: Transform) => mat4;
38
+ setLocalTransform: (element: INode, transform: mat4) => void;
38
39
  resetLocalTransform: (element: INode) => void;
39
40
  getBounds: (element: INode, render?: boolean) => AABB;
40
41
  getLocalBounds: (element: INode, render?: boolean) => AABB;
@@ -129,6 +130,7 @@ export declare class DefaultSceneGraphService implements SceneGraphService {
129
130
  getLocalRotation(element: INode): import("gl-matrix").vec4;
130
131
  getLocalScale(element: INode): vec3;
131
132
  getLocalTransform(element: INode): mat4;
133
+ setLocalTransform(element: INode, transform: mat4): void;
132
134
  resetLocalTransform(element: INode): void;
133
135
  private getTransformedGeometryBounds;
134
136
  /**
@@ -554,6 +554,15 @@ function () {
554
554
  return transform.localTransform;
555
555
  };
556
556
 
557
+ DefaultSceneGraphService.prototype.setLocalTransform = function (element, transform) {
558
+ var t = mat4.getTranslation(vec3.create(), transform);
559
+ var r = mat4.getRotation(quat.create(), transform);
560
+ var s = mat4.getScaling(vec3.create(), transform);
561
+ this.setLocalScale(element, s);
562
+ this.setLocalPosition(element, t);
563
+ this.setLocalRotation(element, r);
564
+ };
565
+
557
566
  DefaultSceneGraphService.prototype.resetLocalTransform = function (element) {
558
567
  this.setLocalScale(element, [1, 1, 1]);
559
568
  this.setLocalPosition(element, [0, 0, 0]);
@@ -801,7 +810,9 @@ function () {
801
810
 
802
811
  __decorate([inject(SceneGraphSelectorFactory), __metadata("design:type", Function)], DefaultSceneGraphService.prototype, "sceneGraphSelectorFactory", void 0);
803
812
 
804
- DefaultSceneGraphService = __decorate([singleton()], DefaultSceneGraphService);
813
+ DefaultSceneGraphService = __decorate([singleton({
814
+ token: SceneGraphService
815
+ })], DefaultSceneGraphService);
805
816
  return DefaultSceneGraphService;
806
817
  }();
807
818
 
@@ -4,7 +4,5 @@ export declare class CircleUpdater implements GeometryAABBUpdater<ParsedCircleSt
4
4
  update(parsedStyle: ParsedCircleStyleProps, object: Circle): {
5
5
  width: number;
6
6
  height: number;
7
- x: number;
8
- y: number;
9
7
  };
10
8
  }
@@ -9,16 +9,12 @@ function () {
9
9
  function CircleUpdater() {}
10
10
 
11
11
  CircleUpdater.prototype.update = function (parsedStyle, object) {
12
- var r = parsedStyle.r,
13
- x = parsedStyle.x,
14
- y = parsedStyle.y;
12
+ var r = parsedStyle.r;
15
13
  var width = r.value * 2;
16
14
  var height = r.value * 2;
17
15
  return {
18
16
  width: width,
19
- height: height,
20
- x: x.value || 0,
21
- y: y.value || 0
17
+ height: height
22
18
  };
23
19
  };
24
20
 
@@ -4,7 +4,5 @@ export declare class EllipseUpdater implements GeometryAABBUpdater<ParsedEllipse
4
4
  update(parsedStyle: ParsedEllipseStyleProps, object: Ellipse): {
5
5
  width: number;
6
6
  height: number;
7
- x: number;
8
- y: number;
9
7
  };
10
8
  }
@@ -10,16 +10,12 @@ function () {
10
10
 
11
11
  EllipseUpdater.prototype.update = function (parsedStyle, object) {
12
12
  var rx = parsedStyle.rx,
13
- ry = parsedStyle.ry,
14
- x = parsedStyle.x,
15
- y = parsedStyle.y;
13
+ ry = parsedStyle.ry;
16
14
  var width = rx.value * 2;
17
15
  var height = ry.value * 2;
18
16
  return {
19
17
  width: width,
20
- height: height,
21
- x: x.value || 0,
22
- y: y.value || 0
18
+ height: height
23
19
  };
24
20
  };
25
21
 
@@ -4,7 +4,5 @@ export declare class LineUpdater implements GeometryAABBUpdater<ParsedLineStyleP
4
4
  update(parsedStyle: ParsedLineStyleProps): {
5
5
  width: number;
6
6
  height: number;
7
- x: number;
8
- y: number;
9
7
  };
10
8
  }
@@ -21,9 +21,7 @@ function () {
21
21
  var height = maxY - minY;
22
22
  return {
23
23
  width: width,
24
- height: height,
25
- x: minX,
26
- y: minY
24
+ height: height
27
25
  };
28
26
  };
29
27
 
@@ -4,7 +4,5 @@ export declare class PathUpdater implements GeometryAABBUpdater<ParsedPathStyleP
4
4
  update(parsedStyle: ParsedPathStyleProps): {
5
5
  width: number;
6
6
  height: number;
7
- x: number;
8
- y: number;
9
7
  };
10
8
  }
@@ -11,15 +11,11 @@ function () {
11
11
  PathUpdater.prototype.update = function (parsedStyle) {
12
12
  var path = parsedStyle.path;
13
13
  var _a = path.rect,
14
- minX = _a.x,
15
- minY = _a.y,
16
14
  width = _a.width,
17
15
  height = _a.height;
18
16
  return {
19
17
  width: width,
20
- height: height,
21
- x: minX,
22
- y: minY
18
+ height: height
23
19
  };
24
20
  };
25
21
 
@@ -4,7 +4,5 @@ export declare class PolylineUpdater implements GeometryAABBUpdater<ParsedPolyli
4
4
  update(parsedStyle: ParsedPolylineStyleProps): {
5
5
  width: number;
6
6
  height: number;
7
- x: number;
8
- y: number;
9
7
  };
10
8
  }
@@ -27,9 +27,7 @@ function () {
27
27
  var height = maxY - minY;
28
28
  return {
29
29
  width: width,
30
- height: height,
31
- x: minX,
32
- y: minY
30
+ height: height
33
31
  };
34
32
  };
35
33
 
@@ -4,7 +4,5 @@ export declare class RectUpdater implements GeometryAABBUpdater<ParsedImageStyle
4
4
  update(parsedStyle: ParsedImageStyleProps, object: Image | Rect | Group): {
5
5
  width: number;
6
6
  height: number;
7
- x: number;
8
- y: number;
9
7
  };
10
8
  }
@@ -12,8 +12,6 @@ function () {
12
12
 
13
13
  RectUpdater.prototype.update = function (parsedStyle, object) {
14
14
  var img = parsedStyle.img,
15
- x = parsedStyle.x,
16
- y = parsedStyle.y,
17
15
  width = parsedStyle.width,
18
16
  height = parsedStyle.height;
19
17
  var contentWidth = 0;
@@ -52,9 +50,7 @@ function () {
52
50
 
53
51
  return {
54
52
  width: contentWidth,
55
- height: contentHeight,
56
- x: x.value || 0,
57
- y: y.value || 0
53
+ height: contentHeight
58
54
  };
59
55
  };
60
56
 
@@ -10,5 +10,12 @@ export declare class TextUpdater implements GeometryAABBUpdater<ParsedTextStyleP
10
10
  y: number;
11
11
  offsetX: number;
12
12
  offsetY: number;
13
+ } | {
14
+ width: number;
15
+ height: number;
16
+ offsetX: number;
17
+ offsetY: number;
18
+ x?: undefined;
19
+ y?: undefined;
13
20
  };
14
21
  }
@@ -29,8 +29,6 @@ function () {
29
29
  textAlign = parsedStyle.textAlign,
30
30
  lineWidth = parsedStyle.lineWidth,
31
31
  textBaseline = parsedStyle.textBaseline,
32
- x = parsedStyle.x,
33
- y = parsedStyle.y,
34
32
  dx = parsedStyle.dx,
35
33
  dy = parsedStyle.dy;
36
34
  var offscreenCanvas = (((_b = (_a = object === null || object === void 0 ? void 0 : object.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) === null || _b === void 0 ? void 0 : _b.getConfig()) || {}).offscreenCanvas;
@@ -119,8 +117,6 @@ function () {
119
117
  return {
120
118
  width: halfExtents[0] * 2,
121
119
  height: halfExtents[1] * 2,
122
- x: x.value || 0,
123
- y: y.value || 0,
124
120
  offsetX: lineXOffset,
125
121
  offsetY: lineYOffset
126
122
  };
@@ -8,9 +8,6 @@ export interface GeometryAABBUpdater<T extends ParsedBaseStyleProps = any> {
8
8
  width: number;
9
9
  height: number;
10
10
  depth?: number;
11
- x: number;
12
- y: number;
13
- z?: number;
14
11
  offsetX?: number;
15
12
  offsetY?: number;
16
13
  offsetZ?: number;
package/es/types.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  import type { vec2, vec3 } from 'gl-matrix';
3
3
  import type { DisplayObject } from './display-objects';
4
4
  import type { IRenderer } from './AbstractRenderer';
5
- import type { CSSGlobalKeywords, CSSGradientValue, CSSKeywordValue, CSSRGB, CSSUnitValue } from './css';
5
+ import type { CSSGlobalKeywords, CSSGradientValue, CSSKeywordValue, CSSRGB, CSSUnitValue, ParsedTransform } from './css';
6
6
  import { Syringe } from 'mana-syringe';
7
7
  export declare enum Shape {
8
8
  GROUP = "g",
@@ -15,7 +15,8 @@ export declare enum Shape {
15
15
  POLYGON = "polygon",
16
16
  TEXT = "text",
17
17
  PATH = "path",
18
- HTML = "html"
18
+ HTML = "html",
19
+ MESH = "mesh"
19
20
  }
20
21
  declare type ColorType = string | null;
21
22
  export interface EventPosition {
@@ -51,18 +52,6 @@ export declare enum TextAlign {
51
52
  }
52
53
  export interface BaseStyleProps {
53
54
  class?: string;
54
- /**
55
- * x in local space
56
- */
57
- x?: number | string;
58
- /**
59
- * y in local space
60
- */
61
- y?: number | string;
62
- /**
63
- * z in local space
64
- */
65
- z?: number | string;
66
55
  /**
67
56
  * @see https://developer.mozilla.org/en-US/docs/Web/CSS/transform
68
57
  */
@@ -120,6 +109,10 @@ export interface BaseStyleProps {
120
109
  opacity?: number;
121
110
  /** 线宽 */
122
111
  lineWidth?: string | number;
112
+ /**
113
+ * increased line width when hitting test
114
+ */
115
+ increasedLineWidthForHitTesting?: string | number;
123
116
  /**
124
117
  * 交互区域
125
118
  */
@@ -157,8 +150,9 @@ export interface BaseStyleProps {
157
150
  * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/miterLimit
158
151
  */
159
152
  miterLimit?: number;
153
+ display?: string;
160
154
  }
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'> {
155
+ 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' | 'transform' | 'transformOrigin' | 'textTransform'> {
162
156
  zIndex?: CSSUnitValue;
163
157
  visibility?: CSSKeywordValue;
164
158
  pointerEvents?: CSSKeywordValue;
@@ -172,13 +166,12 @@ export interface ParsedBaseStyleProps extends Omit<BaseStyleProps, 'anchor' | 'x
172
166
  lineJoin?: CSSKeywordValue;
173
167
  lineDashOffset?: CSSUnitValue;
174
168
  anchor?: [CSSUnitValue, CSSUnitValue, CSSUnitValue];
169
+ transform: ParsedTransform[];
175
170
  transformOrigin?: [CSSUnitValue, CSSUnitValue, CSSUnitValue];
176
- x?: CSSUnitValue;
177
- y?: CSSUnitValue;
178
- z?: CSSUnitValue;
179
171
  width?: CSSUnitValue;
180
172
  height?: CSSUnitValue;
181
173
  lineWidth?: CSSUnitValue;
174
+ increasedLineWidthForHitTesting?: CSSUnitValue;
182
175
  /**
183
176
  * x according to definition, eg. Line's x1/x2, Polyline's points
184
177
  */
@@ -210,10 +203,6 @@ export interface RendererConfig {
210
203
  * enable auto rendering
211
204
  */
212
205
  enableAutoRendering: boolean;
213
- /**
214
- * enable TAA in WebGL
215
- */
216
- enableTAA: boolean;
217
206
  }
218
207
  export declare const CanvasConfig: Syringe.DefinedToken;
219
208
  export interface CanvasConfig {
@@ -245,7 +234,7 @@ export interface CanvasConfig {
245
234
  /**
246
235
  * replace `new window.Image()`
247
236
  */
248
- createImage?: () => HTMLImageElement;
237
+ createImage?: (src: string) => HTMLImageElement;
249
238
  /**
250
239
  * limits query
251
240
  */
package/es/types.js CHANGED
@@ -13,6 +13,7 @@ export var Shape;
13
13
  Shape["TEXT"] = "text";
14
14
  Shape["PATH"] = "path";
15
15
  Shape["HTML"] = "html";
16
+ Shape["MESH"] = "mesh";
16
17
  })(Shape || (Shape = {}));
17
18
 
18
19
  export var LineCap;
@@ -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 {};