@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
@@ -108,15 +108,28 @@ Object.keys(_canvas).forEach(function (key) {
108
108
  });
109
109
  });
110
110
 
111
- var _hooks = require("./hooks");
111
+ var _deferred = require("./deferred");
112
112
 
113
- Object.keys(_hooks).forEach(function (key) {
113
+ Object.keys(_deferred).forEach(function (key) {
114
114
  if (key === "default" || key === "__esModule") return;
115
- if (key in exports && exports[key] === _hooks[key]) return;
115
+ if (key in exports && exports[key] === _deferred[key]) return;
116
116
  Object.defineProperty(exports, key, {
117
117
  enumerable: true,
118
118
  get: function get() {
119
- return _hooks[key];
119
+ return _deferred[key];
120
+ }
121
+ });
122
+ });
123
+
124
+ var _dom = require("./dom");
125
+
126
+ Object.keys(_dom).forEach(function (key) {
127
+ if (key === "default" || key === "__esModule") return;
128
+ if (key in exports && exports[key] === _dom[key]) return;
129
+ Object.defineProperty(exports, key, {
130
+ enumerable: true,
131
+ get: function get() {
132
+ return _dom[key];
120
133
  }
121
134
  });
122
135
  });
@@ -10,7 +10,7 @@ var _tslib = require("tslib");
10
10
 
11
11
  var _manaSyringe = require("mana-syringe");
12
12
 
13
- var _css = require("../css");
13
+ var _interfaces = require("../css/interfaces");
14
14
 
15
15
  var _animation = require("./animation");
16
16
 
@@ -127,7 +127,7 @@ function propertyInterpolation(property, left, right, target) {
127
127
  var parsedLeft = left;
128
128
  var parsedRight = right;
129
129
 
130
- var registry = _manaSyringe.GlobalContainer.get(_css.StyleValueRegistry);
130
+ var registry = _manaSyringe.GlobalContainer.get(_interfaces.StyleValueRegistry);
131
131
 
132
132
  var metadata = registry.getMetadata(property);
133
133
 
@@ -136,8 +136,8 @@ function propertyInterpolation(property, left, right, target) {
136
136
 
137
137
  if (propertyHandler) {
138
138
  if (propertyHandler.parser) {
139
- parsedLeft = propertyHandler.parser(left);
140
- parsedRight = propertyHandler.parser(right);
139
+ parsedLeft = propertyHandler.parser(left, target);
140
+ parsedRight = propertyHandler.parser(right, target);
141
141
  } // if (propertyHandler.calculator) {
142
142
  // parsedLeft = propertyHandler.calculator(parsedLeft);
143
143
  // // parsedLeft = handler.calculator
@@ -199,12 +199,6 @@ var FORMAT_ATTR_MAP = {
199
199
  d: {
200
200
  alias: 'path'
201
201
  },
202
- cx: {
203
- alias: 'x'
204
- },
205
- cy: {
206
- alias: 'y'
207
- },
208
202
  strokeDasharray: {
209
203
  alias: 'lineDash'
210
204
  },
package/lib/utils/math.js CHANGED
@@ -236,8 +236,8 @@ function makePerspective(out, left, right, top, bottom, near, far) {
236
236
 
237
237
  function decompose(mat) {
238
238
  var row0x = mat[0];
239
- var row0y = mat[3];
240
- var row1x = mat[1];
239
+ var row0y = mat[1];
240
+ var row1x = mat[3];
241
241
  var row1y = mat[4]; // decompose 3x3 matrix
242
242
  // @see https://www.w3.org/TR/css-transforms-1/#decomposing-a-2d-matrix
243
243
 
@@ -267,6 +267,7 @@ function decompose(mat) {
267
267
  } // Compute rotation and renormalize matrix.
268
268
 
269
269
 
270
- var angle = Math.atan2(row0y, row0x);
270
+ var rotation = Math.atan2(row0y, row0x);
271
+ var angle = rad2deg(rotation);
271
272
  return [mat[6], mat[7], scalingX, scalingY, angle];
272
273
  }
@@ -1,4 +1,4 @@
1
- import type { DisplayObject } from '../display-objects';
1
+ import type { Circle, Ellipse, Line, Path, Polyline, Polygon, Rect } from '../display-objects';
2
2
  import type { PathCommand } from '../types';
3
3
  export declare function equalizeSegments(path1: PathCommand[], path2: PathCommand[], TL?: number): PathCommand[][];
4
4
  export declare function getDrawDirection(pathArray: PathCommand[]): boolean;
@@ -12,4 +12,4 @@ export declare function getRotatedCurve(a: PathCommand[], b: PathCommand[]): (st
12
12
  * * anchor
13
13
  * * lineWidth
14
14
  */
15
- export declare function convertToPath(object: DisplayObject): string;
15
+ export declare function convertToPath(object: Circle | Ellipse | Rect | Line | Polyline | Polygon | Path, applyLocalTransform?: boolean): string;
package/lib/utils/path.js CHANGED
@@ -223,18 +223,31 @@ function getRotatedCurve(a, b) {
223
223
  return rotations[computedIndex];
224
224
  }
225
225
 
226
- function commandsToPathString(commands, localTransform, anchor, parsedStyle) {
227
- var _a = parsedStyle.defX,
228
- defX = _a === void 0 ? 0 : _a,
229
- _b = parsedStyle.defY,
230
- defY = _b === void 0 ? 0 : _b;
226
+ function commandsToPathString(commands, object, applyLocalTransform) {
227
+ if (applyLocalTransform === void 0) {
228
+ applyLocalTransform = true;
229
+ }
230
+
231
+ var transform;
232
+
233
+ if (applyLocalTransform) {
234
+ transform = object.getLocalTransform();
235
+ }
236
+
237
+ var _a = object.parsedStyle,
238
+ _b = _a.defX,
239
+ defX = _b === void 0 ? 0 : _b,
240
+ _c = _a.defY,
241
+ defY = _c === void 0 ? 0 : _c;
231
242
  return commands.reduce(function (prev, cur) {
232
243
  var path = '';
233
244
 
234
245
  if (cur[0] === 'M' || cur[0] === 'L') {
235
246
  var p = _glMatrix.vec3.fromValues(cur[1] - defX, cur[2] - defY, 0);
236
247
 
237
- _glMatrix.vec3.transformMat4(p, p, localTransform);
248
+ if (applyLocalTransform) {
249
+ _glMatrix.vec3.transformMat4(p, p, transform);
250
+ }
238
251
 
239
252
  path = "".concat(cur[0]).concat(p[0], ",").concat(p[1]);
240
253
  } else if (cur[0] === 'Z') {
@@ -246,17 +259,21 @@ function commandsToPathString(commands, localTransform, anchor, parsedStyle) {
246
259
 
247
260
  var p3 = _glMatrix.vec3.fromValues(cur[5] - defX, cur[6] - defY, 0);
248
261
 
249
- _glMatrix.vec3.transformMat4(p1, p1, localTransform);
262
+ if (applyLocalTransform) {
263
+ _glMatrix.vec3.transformMat4(p1, p1, transform);
250
264
 
251
- _glMatrix.vec3.transformMat4(p2, p2, localTransform);
265
+ _glMatrix.vec3.transformMat4(p2, p2, transform);
252
266
 
253
- _glMatrix.vec3.transformMat4(p3, p3, localTransform);
267
+ _glMatrix.vec3.transformMat4(p3, p3, transform);
268
+ }
254
269
 
255
270
  path = "".concat(cur[0]).concat(p1[0], ",").concat(p1[1], ",").concat(p2[0], ",").concat(p2[1], ",").concat(p3[0], ",").concat(p3[1]);
256
271
  } else if (cur[0] === 'A') {
257
272
  var c = _glMatrix.vec3.fromValues(cur[6] - defX, cur[7] - defY, 0);
258
273
 
259
- _glMatrix.vec3.transformMat4(c, c, localTransform);
274
+ if (applyLocalTransform) {
275
+ _glMatrix.vec3.transformMat4(c, c, transform);
276
+ }
260
277
 
261
278
  path = "".concat(cur[0]).concat(cur[1], ",").concat(cur[2], ",").concat(cur[3], ",").concat(cur[4], ",").concat(cur[5], ",").concat(c[0], ",").concat(c[1]);
262
279
  }
@@ -280,10 +297,16 @@ function ellipseToCommands(rx, ry, cx, cy) {
280
297
  return [['M', left, cy], ['C', left, cy - dy, cx - dx, top, cx, top], ['C', cx + dx, top, right, cy - dy, right, cy], ['C', right, cy + dy, cx + dx, bottom, cx, bottom], ['C', cx - dx, bottom, left, cy + dy, left, cy], ['Z']];
281
298
  }
282
299
 
283
- function polygonToCommands(points) {
284
- return points.map(function (point, i) {
300
+ function polygonToCommands(points, closed) {
301
+ var result = points.map(function (point, i) {
285
302
  return [i === 0 ? 'M' : 'L', point[0], point[1]];
286
303
  });
304
+
305
+ if (closed) {
306
+ result.push(['Z']);
307
+ }
308
+
309
+ return result;
287
310
  }
288
311
 
289
312
  function rectToCommands(width, height, x, y, radius) {
@@ -302,9 +325,11 @@ function rectToCommands(width, height, x, y, radius) {
302
325
  */
303
326
 
304
327
 
305
- function convertToPath(object) {
306
- var localTransform = object.getLocalTransform();
307
- var anchor = object.style.anchor;
328
+ function convertToPath(object, applyLocalTransform) {
329
+ if (applyLocalTransform === void 0) {
330
+ applyLocalTransform = true;
331
+ }
332
+
308
333
  var commands = [];
309
334
 
310
335
  switch (object.nodeName) {
@@ -321,9 +346,9 @@ function convertToPath(object) {
321
346
  {
322
347
  var _b = object.parsedStyle,
323
348
  r = _b.r,
324
- x_1 = _b.x,
325
- y_1 = _b.y;
326
- commands = ellipseToCommands(r.value, r.value, x_1.value, y_1.value);
349
+ cx = _b.cx,
350
+ cy = _b.cy;
351
+ commands = ellipseToCommands(r.value, r.value, cx.value, cy.value);
327
352
  break;
328
353
  }
329
354
 
@@ -332,16 +357,16 @@ function convertToPath(object) {
332
357
  var _c = object.parsedStyle,
333
358
  rx = _c.rx,
334
359
  ry = _c.ry,
335
- x_2 = _c.x,
336
- y_2 = _c.y;
337
- commands = ellipseToCommands(rx.value, ry.value, x_2.value, y_2.value);
360
+ cx = _c.cx,
361
+ cy = _c.cy;
362
+ commands = ellipseToCommands(rx.value, ry.value, cx.value, cy.value);
338
363
  break;
339
364
  }
340
365
 
341
366
  case _types.Shape.POLYLINE:
342
367
  case _types.Shape.POLYGON:
343
368
  var points = object.parsedStyle.points;
344
- commands = polygonToCommands(points.points);
369
+ commands = polygonToCommands(points.points, object.nodeName === _types.Shape.POLYGON);
345
370
  break;
346
371
 
347
372
  case _types.Shape.RECT:
@@ -355,11 +380,17 @@ function convertToPath(object) {
355
380
  break;
356
381
 
357
382
  case _types.Shape.PATH:
358
- commands = object.parsedStyle.path.curve;
383
+ var _e = object.parsedStyle.path,
384
+ curve = _e.curve,
385
+ zCommandIndexes = _e.zCommandIndexes;
386
+ commands = (0, _tslib.__spreadArray)([], (0, _tslib.__read)(curve), false);
387
+ zCommandIndexes.forEach(function (zIndex, index) {
388
+ commands.splice(zIndex + index, 1, ['Z']);
389
+ });
359
390
  break;
360
391
  }
361
392
 
362
393
  if (commands.length) {
363
- return commandsToPathString(commands, localTransform, anchor, object.parsedStyle);
394
+ return commandsToPathString(commands, object, applyLocalTransform);
364
395
  }
365
396
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/g",
3
- "version": "5.0.23-alpha.9",
3
+ "version": "5.1.0",
4
4
  "description": "A core module including ECS and DI container.",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "homepage": "https://github.com/antvis/g#readme",
40
40
  "dependencies": {
41
- "@antv/g-math": "^1.0.20-alpha.9",
41
+ "@antv/g-math": "^1.1.0",
42
42
  "@antv/util": "^3.0.0",
43
43
  "@types/offscreencanvas": "^2019.6.4",
44
44
  "d3-color": "^1.4.0",
@@ -47,10 +47,11 @@
47
47
  "mana-syringe": "^0.3.0",
48
48
  "reflect-metadata": "^0.1.13",
49
49
  "request-animation-frame-polyfill": "^1.1.2",
50
+ "tapable": "^2.2.1",
50
51
  "tslib": "^2.3.1"
51
52
  },
52
53
  "scripts": {
53
54
  "umd": "webpack"
54
55
  },
55
- "gitHead": "8c28e04155e41a948c323161a35aeda63c2294a4"
56
+ "gitHead": "ffbd006ec52c899e53e84671ca160d49dd63f3e9"
56
57
  }
@@ -1,11 +0,0 @@
1
- /**
2
- *
3
- * @example
4
- *
5
- * // register layout
6
- * CSS.registerLayout('centering', class {});
7
- * // use with `display` property
8
- * group.style.display = 'layout(centering)';
9
- */
10
- export declare class LayoutRegistry {
11
- }
@@ -1,22 +0,0 @@
1
- import { __decorate } from "tslib";
2
- import { singleton } from 'mana-syringe';
3
- /**
4
- *
5
- * @example
6
- *
7
- * // register layout
8
- * CSS.registerLayout('centering', class {});
9
- * // use with `display` property
10
- * group.style.display = 'layout(centering)';
11
- */
12
-
13
- var LayoutRegistry =
14
- /** @class */
15
- function () {
16
- function LayoutRegistry() {}
17
-
18
- LayoutRegistry = __decorate([singleton()], LayoutRegistry);
19
- return LayoutRegistry;
20
- }();
21
-
22
- export { LayoutRegistry };
@@ -1,280 +0,0 @@
1
- /**
2
- * a lite tapable implementation
3
- * borrow from https://github.com/funnyecho/hamon
4
- */
5
- declare type Measure<T extends number> = T extends 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 ? T : never;
6
- declare type Append<T extends any[], U> = {
7
- 0: [U];
8
- 1: [T[0], U];
9
- 2: [T[0], T[1], U];
10
- 3: [T[0], T[1], T[2], U];
11
- 4: [T[0], T[1], T[2], T[3], U];
12
- 5: [T[0], T[1], T[2], T[3], T[4], U];
13
- 6: [T[0], T[1], T[2], T[3], T[4], T[5], U];
14
- 7: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], U];
15
- 8: [T[0], T[1], T[2], T[3], T[4], T[5], T[6], T[7], U];
16
- }[Measure<T['length']>];
17
- declare type AsArray<T> = T extends any[] ? T : [];
18
- declare type Callback<E, T> = (error?: E, result?: T) => void;
19
- declare type ITapID = string;
20
- declare type IHookBucketType = any;
21
- declare type IHookBucketHashcode<T> = (...args: AsArray<T>) => IHookBucketType;
22
- declare type IAsyncTapArgs<T, R> = Append<AsArray<T>, Callback<Error, R>>;
23
- declare type ISyncTapCallback<T, R> = (...args: AsArray<T>) => R;
24
- declare type IAsyncTapCallback<T, R> = (...args: IAsyncTapArgs<T, R>) => void;
25
- declare type IPromiseTapCallback<T, R> = (...args: AsArray<T>) => Promise<R>;
26
- export declare type ITapDestroy = () => void;
27
- interface ITapOptions<T, R> {
28
- fn: IAsyncTapCallback<T, R> | ISyncTapCallback<T, R>;
29
- bucket: string;
30
- }
31
- interface IInvokeSeriesObserver<T, R> {
32
- shouldBail?: boolean;
33
- shouldWaterfall?: boolean;
34
- onComplete?: (err: Error, result?: R) => void;
35
- }
36
- interface IInvokeParallelObserver<T, R> {
37
- shouldBail?: boolean;
38
- onComplete?: (err: Error, result?: R) => void;
39
- }
40
- interface IInvokeSynchronouslyObserver<T, R> {
41
- shouldBail?: boolean;
42
- shouldWaterfall?: boolean;
43
- }
44
- /**
45
- * Basic Hook Type
46
- *
47
- * @remarks
48
- * All subtype hooks are extends from `Hook` which provide the tapping and calling logic
49
- *
50
- * @param T - tuple types of calling arguments
51
- * @param R - returning value type of calling
52
- *
53
- * @public
54
- * */
55
- export declare abstract class Hook<T, R> {
56
- private tapIdSeed;
57
- /**
58
- * @internal
59
- * */
60
- protected readonly bucketHashcode: IHookBucketHashcode<T>;
61
- /**
62
- * @internal
63
- * */
64
- protected readonly presetTapBucket: Set<ITapID>;
65
- /**
66
- * @internal
67
- * */
68
- protected readonly tapBuckets: Map<IHookBucketType, Set<ITapID>>;
69
- /**
70
- * @internal
71
- * */
72
- protected readonly tapOptionsCache: Map<ITapID, ITapOptions<T, R>>;
73
- /**
74
- * @param bucketHashcode - calculate the hashcode value of calling arguments
75
- * */
76
- constructor(bucketHashcode?: IHookBucketHashcode<T>);
77
- /**
78
- * clear all tapping from hook
79
- *
80
- * @public
81
- * */
82
- exhaust(): void;
83
- /**
84
- * clear all tapping from hook
85
- *
86
- * @remarks
87
- * The same as `exhaust` {@link Hook.exhaust}
88
- *
89
- * @privateRemarks
90
- * call `exhaust`
91
- *
92
- * @public
93
- * */
94
- destroy(): void;
95
- /**
96
- * @internal
97
- * */
98
- protected insertSyncTap(fn: ISyncTapCallback<T, R>, bucket?: IHookBucketType): ITapDestroy;
99
- /**
100
- * @internal
101
- * */
102
- protected insertAsyncTap(fn: IAsyncTapCallback<T, R>, bucket?: IHookBucketType): ITapDestroy;
103
- /**
104
- * @internal
105
- * */
106
- protected insertPromiseTap(fn: IPromiseTapCallback<T, R | void>, bucket?: IHookBucketType): ITapDestroy;
107
- /**
108
- * @internal
109
- * */
110
- protected invokeSeries(args: AsArray<T>, observer?: IInvokeSeriesObserver<T, R>): void;
111
- /**
112
- * @internal
113
- * */
114
- protected invokeParallel(args: AsArray<T>, observer?: IInvokeParallelObserver<T, R>): void;
115
- /**
116
- * @internal
117
- * */
118
- protected invokeSynchronously(args: AsArray<T>, observer?: IInvokeSynchronouslyObserver<T, R>): R;
119
- /**
120
- * @internal
121
- * */
122
- protected getBucketTaps(args: AsArray<T>): Set<ITapOptions<T, R>>;
123
- /**
124
- * @internal
125
- * */
126
- private tapping;
127
- /**
128
- * @internal
129
- * */
130
- protected popoutTap(tapId: ITapID): void;
131
- /**
132
- * @internal
133
- * */
134
- private generateTapId;
135
- }
136
- /**
137
- * Abstract Sync Hook
138
- *
139
- * @remarks
140
- * Providing `tap` method for synchronous hooks
141
- *
142
- * @public
143
- * */
144
- export declare abstract class SyncTapHook<T, R> extends Hook<T, R> {
145
- /**
146
- * listen to hook
147
- *
148
- * @param fn - Listener callback
149
- * @param bucket - Listen to specified hashcode bucket
150
- * @returns The unTap function
151
- *
152
- * @public
153
- * */
154
- tap(fn: ISyncTapCallback<T, R>, bucket?: IHookBucketType): ITapDestroy;
155
- }
156
- /**
157
- * Abstract Async Hook
158
- *
159
- * @remarks
160
- * Providing `tapAsync` and `tapPromise` methods for asynchronous hooks
161
- *
162
- * @public
163
- * */
164
- export declare abstract class AsyncTapHook<T, R> extends Hook<T, R> {
165
- /**
166
- * listen to hook in async callback mode
167
- *
168
- * @param fn - Listener callback
169
- * The last argument of `fn` which named `cb` will be a function which signature is `(err?: Error, result?: T) => void`.
170
- * When error occur, pass the error to `cb` as first param and the `result` param should be void,
171
- * Otherwise, first param must be void.
172
- *
173
- * @param bucket - Listen to specified hashcode bucket
174
- * @returns The unTap function
175
- *
176
- * @public
177
- * */
178
- tapAsync(fn: IAsyncTapCallback<T, R>, bucket?: IHookBucketType): ITapDestroy;
179
- /**
180
- * listen to hook in async promise mode
181
- *
182
- * @param fn - Listener callback
183
- * When tapping success, return resolved promise.
184
- * Otherwise, throw error or return rejected promise.
185
- *
186
- * @param bucket - Listen to specified hashcode bucket
187
- * @returns The unTap function
188
- *
189
- * @public
190
- * */
191
- tapPromise(fn: IPromiseTapCallback<T, R | void>, bucket?: IHookBucketType): ITapDestroy;
192
- }
193
- /**
194
- * Synchronous Hook
195
- *
196
- * @remarks
197
- * Invoke listener Synchronously and return nothing
198
- *
199
- * @public
200
- * */
201
- export declare class SyncHook<T, R = void> extends SyncTapHook<T, R> {
202
- /**
203
- * call listener with `...args`
204
- *
205
- * @param args - rest parameters of calling arguments
206
- *
207
- * */
208
- call(...args: AsArray<T>): void;
209
- }
210
- /**
211
- * Synchronous Waterfall Hook
212
- *
213
- * @remarks
214
- * Invoke listener Synchronously.
215
- * Those non-undefined value returned from upstream listener, will waterfall to downstream as first element of arguments.
216
- * Calling return with waterfall value of last listener.
217
- *
218
- * @public
219
- * */
220
- export declare class SyncWaterfallHook<T, R> extends SyncTapHook<T, R> {
221
- /**
222
- * call listener with `...args`
223
- *
224
- * @param args - rest parameters of calling arguments
225
- * @returns waterfall value
226
- * */
227
- call(...args: AsArray<T>): R;
228
- }
229
- /**
230
- * Asynchronous Parallel Hook
231
- *
232
- * @remarks
233
- * Invoke listeners in parallel asynchronously
234
- *
235
- * @public
236
- * */
237
- export declare class AsyncParallelHook<T, R = void> extends AsyncTapHook<T, R> {
238
- /**
239
- * call listener with `...args` and `cb`
240
- *
241
- * @param args - rest parameters of calling arguments and `cb`
242
- * The signature of `cb` is `(err?: Error) => void`.
243
- * */
244
- callAsync(...args: IAsyncTapArgs<T, R>): void;
245
- /***
246
- * call listener with `...args`
247
- *
248
- * @param args - rest parameters of calling arguments
249
- * @returns Promise indicated whether calling succeed or failed
250
- * */
251
- callPromise(...args: AsArray<T>): Promise<R>;
252
- }
253
- /**
254
- * Asynchronous Waterfall Hook
255
- *
256
- * @remarks
257
- * Invoke listener in queue Asynchronously.
258
- * Those non-undefined value returned from upstream listener, will waterfall to downstream as first element of arguments.
259
- * Calling return with waterfall value of last listener.
260
- *
261
- * @public
262
- * */
263
- export declare class AsyncSeriesWaterfallHook<T, R> extends AsyncTapHook<T, R> {
264
- /**
265
- * call listener with `...args` and `cb`
266
- *
267
- * @param args - rest parameters of calling arguments and `cb`
268
- * The signature of `cb` is `(err?: Error) => void`.
269
- * */
270
- callAsync(...args: IAsyncTapArgs<T, R>): void;
271
- /***
272
- * call listener with `...args`
273
- *
274
- * @param args - rest parameters of calling arguments
275
- * @returns Promise indicated whether calling succeed or failed
276
- * If calling succeed, promise was resolved with waterfall value.
277
- * */
278
- callPromise(...args: AsArray<T>): Promise<R>;
279
- }
280
- export {};