@antv/g 5.0.14 → 5.0.17

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 (305) hide show
  1. package/es/AbstractRenderer.js +1 -3
  2. package/es/Canvas.d.ts +3 -0
  3. package/es/Canvas.js +10 -12
  4. package/es/DisplayObjectPool.js +1 -3
  5. package/es/camera/Camera.d.ts +3 -2
  6. package/es/camera/Camera.js +17 -11
  7. package/es/camera/Landmark.js +1 -3
  8. package/es/canvas-module.js +11 -17
  9. package/es/components/Cullable.js +1 -3
  10. package/es/components/Geometry.js +1 -3
  11. package/es/components/Renderable.js +1 -3
  12. package/es/components/Sortable.js +1 -3
  13. package/es/components/Transform.d.ts +0 -1
  14. package/es/components/Transform.js +1 -4
  15. package/es/display-objects/Circle.d.ts +4 -2
  16. package/es/display-objects/Circle.js +9 -6
  17. package/es/display-objects/CustomElement.d.ts +3 -2
  18. package/es/display-objects/CustomElement.js +10 -9
  19. package/es/display-objects/DisplayObject.d.ts +9 -3
  20. package/es/display-objects/DisplayObject.js +98 -50
  21. package/es/display-objects/Ellipse.d.ts +6 -3
  22. package/es/display-objects/Ellipse.js +9 -6
  23. package/es/display-objects/Group.d.ts +18 -2
  24. package/es/display-objects/Group.js +15 -12
  25. package/es/display-objects/HTML.d.ts +6 -1
  26. package/es/display-objects/HTML.js +8 -6
  27. package/es/display-objects/Image.d.ts +12 -7
  28. package/es/display-objects/Image.js +11 -6
  29. package/es/display-objects/Line.d.ts +1 -1
  30. package/es/display-objects/Line.js +13 -7
  31. package/es/display-objects/Path.d.ts +3 -2
  32. package/es/display-objects/Path.js +11 -8
  33. package/es/display-objects/Polygon.d.ts +1 -1
  34. package/es/display-objects/Polygon.js +10 -6
  35. package/es/display-objects/Polyline.d.ts +1 -1
  36. package/es/display-objects/Polyline.js +11 -8
  37. package/es/display-objects/Rect.d.ts +8 -5
  38. package/es/display-objects/Rect.js +10 -7
  39. package/es/display-objects/TSpan.d.ts +1 -0
  40. package/es/display-objects/TSpan.js +0 -0
  41. package/es/display-objects/Text.d.ts +32 -4
  42. package/es/display-objects/Text.js +71 -14
  43. package/es/dom/Animation.js +2 -4
  44. package/es/dom/AnimationEffectTiming.js +1 -3
  45. package/es/dom/AnimationEvent.js +1 -3
  46. package/es/dom/AnimationTimeline.js +2 -5
  47. package/es/dom/CustomElementRegistry.js +13 -15
  48. package/es/dom/CustomEvent.js +1 -3
  49. package/es/dom/Document.d.ts +2 -1
  50. package/es/dom/Document.js +23 -5
  51. package/es/dom/Element.d.ts +36 -9
  52. package/es/dom/Element.js +103 -15
  53. package/es/dom/EventTarget.d.ts +2 -2
  54. package/es/dom/EventTarget.js +3 -4
  55. package/es/dom/FederatedEvent.d.ts +5 -2
  56. package/es/dom/FederatedEvent.js +1 -3
  57. package/es/dom/FederatedMouseEvent.js +1 -3
  58. package/es/dom/FederatedPointerEvent.js +1 -3
  59. package/es/dom/FederatedWheelEvent.js +1 -3
  60. package/es/dom/KeyframeEffect.js +1 -3
  61. package/es/dom/MutationEvent.d.ts +15 -0
  62. package/es/dom/MutationEvent.js +27 -0
  63. package/es/dom/MutationObserver.d.ts +36 -0
  64. package/es/dom/MutationObserver.js +406 -0
  65. package/es/dom/MutationRecord.d.ts +14 -0
  66. package/es/dom/MutationRecord.js +29 -0
  67. package/es/dom/Node.d.ts +35 -3
  68. package/es/dom/Node.js +185 -20
  69. package/es/dom/index.d.ts +3 -0
  70. package/es/dom/index.js +3 -0
  71. package/es/dom/interfaces.d.ts +36 -8
  72. package/es/dom/interfaces.js +23 -5
  73. package/es/global-module.d.ts +4 -1
  74. package/es/global-module.js +36 -79
  75. package/es/index.d.ts +1 -0
  76. package/es/index.js +1 -0
  77. package/es/plugins/CullingPlugin.d.ts +0 -2
  78. package/es/plugins/CullingPlugin.js +4 -27
  79. package/es/plugins/DirtyCheckPlugin.js +3 -5
  80. package/es/plugins/EventPlugin.d.ts +2 -1
  81. package/es/plugins/EventPlugin.js +16 -8
  82. package/es/plugins/FrustumCullingStrategy.d.ts +1 -0
  83. package/es/plugins/FrustumCullingStrategy.js +40 -35
  84. package/es/plugins/PrepareRendererPlugin.js +22 -8
  85. package/es/property-handlers/aabb.js +22 -24
  86. package/es/property-handlers/anchor.js +2 -1
  87. package/es/property-handlers/color.js +3 -0
  88. package/es/property-handlers/dimension.d.ts +15 -2
  89. package/es/property-handlers/dimension.js +77 -8
  90. package/es/property-handlers/index.d.ts +3 -0
  91. package/es/property-handlers/index.js +4 -1
  92. package/es/property-handlers/inherit.d.ts +6 -0
  93. package/es/property-handlers/inherit.js +25 -0
  94. package/es/property-handlers/interfaces.d.ts +2 -2
  95. package/es/property-handlers/lineDash.d.ts +6 -1
  96. package/es/property-handlers/lineDash.js +23 -4
  97. package/es/property-handlers/offsetDistance.js +2 -2
  98. package/es/property-handlers/path.d.ts +1 -1
  99. package/es/property-handlers/text.d.ts +2 -0
  100. package/es/property-handlers/text.js +3 -0
  101. package/es/property-handlers/textTransform.d.ts +6 -0
  102. package/es/property-handlers/textTransform.js +19 -0
  103. package/es/services/EventService.js +2 -6
  104. package/es/services/RenderingContext.d.ts +5 -8
  105. package/es/services/RenderingContext.js +6 -7
  106. package/es/services/RenderingService.js +3 -11
  107. package/es/services/SceneGraphSelector.d.ts +3 -2
  108. package/es/services/SceneGraphSelector.js +9 -7
  109. package/es/services/SceneGraphService.d.ts +7 -14
  110. package/es/services/SceneGraphService.js +15 -85
  111. package/es/services/aabb/CircleUpdater.d.ts +2 -2
  112. package/es/services/aabb/CircleUpdater.js +22 -14
  113. package/es/services/aabb/EllipseUpdater.d.ts +2 -2
  114. package/es/services/aabb/EllipseUpdater.js +29 -16
  115. package/es/services/aabb/LineUpdater.js +3 -5
  116. package/es/services/aabb/PathUpdater.js +3 -5
  117. package/es/services/aabb/PolylineUpdater.js +4 -6
  118. package/es/services/aabb/RectUpdater.d.ts +2 -2
  119. package/es/services/aabb/RectUpdater.js +32 -21
  120. package/es/services/aabb/TextUpdater.js +20 -13
  121. package/es/services/text/OffscreenCanvasCreator.js +1 -3
  122. package/es/services/text/index.js +18 -22
  123. package/es/shapes/AABB.d.ts +1 -0
  124. package/es/shapes/AABB.js +9 -3
  125. package/es/shapes/BoundingSphere.js +1 -3
  126. package/es/shapes/Frustum.js +1 -3
  127. package/es/shapes/Plane.js +1 -3
  128. package/es/shapes/Point.js +1 -3
  129. package/es/shapes/Polygon.js +1 -3
  130. package/es/shapes/Ray.js +1 -3
  131. package/es/shapes/Rect.js +1 -3
  132. package/es/shapes/Rectangle.js +1 -3
  133. package/es/types.d.ts +48 -26
  134. package/es/types.js +50 -31
  135. package/es/utils/animation.js +1 -1
  136. package/es/utils/event.js +5 -3
  137. package/es/utils/index.d.ts +1 -0
  138. package/es/utils/index.js +2 -1
  139. package/es/utils/interpolation.d.ts +1 -0
  140. package/es/utils/interpolation.js +41 -8
  141. package/es/utils/path.d.ts +1 -1
  142. package/es/utils/path.js +13 -13
  143. package/es/utils/raf.d.ts +1 -1
  144. package/es/utils/raf.js +0 -2
  145. package/es/utils/string.d.ts +1 -0
  146. package/es/utils/string.js +9 -0
  147. package/es/utils/text.js +1 -1
  148. package/lib/AbstractRenderer.js +1 -3
  149. package/lib/Canvas.d.ts +3 -0
  150. package/lib/Canvas.js +9 -11
  151. package/lib/DisplayObjectPool.js +1 -3
  152. package/lib/camera/Camera.d.ts +3 -2
  153. package/lib/camera/Camera.js +21 -13
  154. package/lib/camera/Landmark.js +1 -3
  155. package/lib/canvas-module.js +10 -15
  156. package/lib/components/Cullable.js +2 -4
  157. package/lib/components/Geometry.js +1 -3
  158. package/lib/components/Renderable.js +1 -3
  159. package/lib/components/Sortable.js +1 -3
  160. package/lib/components/Transform.d.ts +0 -1
  161. package/lib/components/Transform.js +1 -4
  162. package/lib/display-objects/Circle.d.ts +4 -2
  163. package/lib/display-objects/Circle.js +8 -5
  164. package/lib/display-objects/CustomElement.d.ts +3 -2
  165. package/lib/display-objects/CustomElement.js +10 -9
  166. package/lib/display-objects/DisplayObject.d.ts +9 -3
  167. package/lib/display-objects/DisplayObject.js +98 -47
  168. package/lib/display-objects/Ellipse.d.ts +6 -3
  169. package/lib/display-objects/Ellipse.js +8 -5
  170. package/lib/display-objects/Group.d.ts +18 -2
  171. package/lib/display-objects/Group.js +14 -12
  172. package/lib/display-objects/HTML.d.ts +6 -1
  173. package/lib/display-objects/HTML.js +7 -5
  174. package/lib/display-objects/Image.d.ts +12 -7
  175. package/lib/display-objects/Image.js +10 -5
  176. package/lib/display-objects/Line.d.ts +1 -1
  177. package/lib/display-objects/Line.js +12 -6
  178. package/lib/display-objects/Path.d.ts +3 -2
  179. package/lib/display-objects/Path.js +10 -7
  180. package/lib/display-objects/Polygon.d.ts +1 -1
  181. package/lib/display-objects/Polygon.js +9 -5
  182. package/lib/display-objects/Polyline.d.ts +1 -1
  183. package/lib/display-objects/Polyline.js +10 -7
  184. package/lib/display-objects/Rect.d.ts +8 -5
  185. package/lib/display-objects/Rect.js +9 -6
  186. package/lib/display-objects/TSpan.d.ts +1 -0
  187. package/lib/display-objects/TSpan.js +1 -0
  188. package/lib/display-objects/Text.d.ts +32 -4
  189. package/lib/display-objects/Text.js +71 -13
  190. package/lib/dom/Animation.js +2 -4
  191. package/lib/dom/AnimationEffectTiming.js +1 -3
  192. package/lib/dom/AnimationEvent.js +1 -3
  193. package/lib/dom/AnimationTimeline.js +3 -6
  194. package/lib/dom/CustomElementRegistry.js +12 -14
  195. package/lib/dom/CustomEvent.js +1 -3
  196. package/lib/dom/Document.d.ts +2 -1
  197. package/lib/dom/Document.js +25 -6
  198. package/lib/dom/Element.d.ts +36 -9
  199. package/lib/dom/Element.js +105 -15
  200. package/lib/dom/EventTarget.d.ts +2 -2
  201. package/lib/dom/EventTarget.js +3 -4
  202. package/lib/dom/FederatedEvent.d.ts +5 -2
  203. package/lib/dom/FederatedEvent.js +1 -3
  204. package/lib/dom/FederatedMouseEvent.js +1 -3
  205. package/lib/dom/FederatedPointerEvent.js +1 -3
  206. package/lib/dom/FederatedWheelEvent.js +1 -3
  207. package/lib/dom/KeyframeEffect.js +2 -4
  208. package/lib/dom/MutationEvent.d.ts +15 -0
  209. package/lib/dom/MutationEvent.js +35 -0
  210. package/lib/dom/MutationObserver.d.ts +36 -0
  211. package/lib/dom/MutationObserver.js +417 -0
  212. package/lib/dom/MutationRecord.d.ts +14 -0
  213. package/lib/dom/MutationRecord.js +36 -0
  214. package/lib/dom/Node.d.ts +35 -3
  215. package/lib/dom/Node.js +186 -19
  216. package/lib/dom/index.d.ts +3 -0
  217. package/lib/dom/index.js +39 -0
  218. package/lib/dom/interfaces.d.ts +36 -8
  219. package/lib/dom/interfaces.js +23 -5
  220. package/lib/global-module.d.ts +4 -1
  221. package/lib/global-module.js +42 -76
  222. package/lib/index.d.ts +1 -0
  223. package/lib/index.js +2 -0
  224. package/lib/plugins/CullingPlugin.d.ts +0 -2
  225. package/lib/plugins/CullingPlugin.js +4 -27
  226. package/lib/plugins/DirtyCheckPlugin.js +2 -4
  227. package/lib/plugins/EventPlugin.d.ts +2 -1
  228. package/lib/plugins/EventPlugin.js +14 -8
  229. package/lib/plugins/FrustumCullingStrategy.d.ts +1 -0
  230. package/lib/plugins/FrustumCullingStrategy.js +41 -35
  231. package/lib/plugins/PrepareRendererPlugin.js +25 -7
  232. package/lib/property-handlers/aabb.js +21 -23
  233. package/lib/property-handlers/anchor.js +3 -1
  234. package/lib/property-handlers/color.js +5 -2
  235. package/lib/property-handlers/dimension.d.ts +15 -2
  236. package/lib/property-handlers/dimension.js +84 -12
  237. package/lib/property-handlers/index.d.ts +3 -0
  238. package/lib/property-handlers/index.js +39 -0
  239. package/lib/property-handlers/inherit.d.ts +6 -0
  240. package/lib/property-handlers/inherit.js +34 -0
  241. package/lib/property-handlers/interfaces.d.ts +2 -2
  242. package/lib/property-handlers/interfaces.js +1 -1
  243. package/lib/property-handlers/lineDash.d.ts +6 -1
  244. package/lib/property-handlers/lineDash.js +25 -4
  245. package/lib/property-handlers/numeric.js +3 -3
  246. package/lib/property-handlers/offsetDistance.js +1 -1
  247. package/lib/property-handlers/path.d.ts +1 -1
  248. package/lib/property-handlers/path.js +1 -1
  249. package/lib/property-handlers/text.d.ts +2 -0
  250. package/lib/property-handlers/text.js +10 -0
  251. package/lib/property-handlers/textTransform.d.ts +6 -0
  252. package/lib/property-handlers/textTransform.js +27 -0
  253. package/lib/property-handlers/transform.js +1 -1
  254. package/lib/services/EventService.js +2 -6
  255. package/lib/services/RenderingContext.d.ts +5 -8
  256. package/lib/services/RenderingContext.js +8 -9
  257. package/lib/services/RenderingService.js +2 -10
  258. package/lib/services/SceneGraphSelector.d.ts +3 -2
  259. package/lib/services/SceneGraphSelector.js +12 -7
  260. package/lib/services/SceneGraphService.d.ts +7 -14
  261. package/lib/services/SceneGraphService.js +18 -87
  262. package/lib/services/aabb/CircleUpdater.d.ts +2 -2
  263. package/lib/services/aabb/CircleUpdater.js +21 -13
  264. package/lib/services/aabb/EllipseUpdater.d.ts +2 -2
  265. package/lib/services/aabb/EllipseUpdater.js +28 -15
  266. package/lib/services/aabb/LineUpdater.js +2 -4
  267. package/lib/services/aabb/PathUpdater.js +2 -4
  268. package/lib/services/aabb/PolylineUpdater.js +3 -5
  269. package/lib/services/aabb/RectUpdater.d.ts +2 -2
  270. package/lib/services/aabb/RectUpdater.js +31 -20
  271. package/lib/services/aabb/TextUpdater.js +19 -12
  272. package/lib/services/aabb/index.js +10 -10
  273. package/lib/services/aabb/interfaces.js +1 -1
  274. package/lib/services/text/OffscreenCanvasCreator.js +1 -3
  275. package/lib/services/text/index.js +18 -22
  276. package/lib/shapes/AABB.d.ts +1 -0
  277. package/lib/shapes/AABB.js +9 -3
  278. package/lib/shapes/BoundingSphere.js +1 -3
  279. package/lib/shapes/Frustum.js +2 -4
  280. package/lib/shapes/Plane.js +1 -3
  281. package/lib/shapes/Point.js +1 -3
  282. package/lib/shapes/Polygon.js +1 -3
  283. package/lib/shapes/Ray.js +1 -3
  284. package/lib/shapes/Rect.js +1 -3
  285. package/lib/shapes/Rectangle.js +1 -3
  286. package/lib/types.d.ts +48 -26
  287. package/lib/types.js +56 -35
  288. package/lib/utils/animation.js +3 -4
  289. package/lib/utils/bezier-easing.js +1 -1
  290. package/lib/utils/custom-easing.js +1 -1
  291. package/lib/utils/event.js +7 -6
  292. package/lib/utils/index.d.ts +1 -0
  293. package/lib/utils/index.js +13 -0
  294. package/lib/utils/interpolation.d.ts +1 -0
  295. package/lib/utils/interpolation.js +43 -7
  296. package/lib/utils/math.js +5 -5
  297. package/lib/utils/path.d.ts +1 -1
  298. package/lib/utils/path.js +15 -15
  299. package/lib/utils/raf.d.ts +1 -1
  300. package/lib/utils/raf.js +1 -4
  301. package/lib/utils/string.d.ts +1 -0
  302. package/lib/utils/string.js +16 -0
  303. package/lib/utils/text.js +1 -1
  304. package/package.json +6 -4
  305. package/dist/index.umd.min.js +0 -15
@@ -15,16 +15,18 @@ var _DisplayObject = require("./DisplayObject");
15
15
 
16
16
  var _shapes = require("../shapes");
17
17
 
18
- var Line =
19
- /** @class */
20
- function (_super) {
18
+ var Line = function (_super) {
21
19
  (0, _tslib.__extends)(Line, _super);
22
20
 
23
21
  function Line(_a) {
22
+ if (_a === void 0) {
23
+ _a = {};
24
+ }
25
+
24
26
  var style = _a.style,
25
27
  rest = (0, _tslib.__rest)(_a, ["style"]);
26
28
  return _super.call(this, (0, _tslib.__assign)({
27
- type: _types.SHAPE.Line,
29
+ type: _types.Shape.LINE,
28
30
  style: (0, _tslib.__assign)({
29
31
  x1: 0,
30
32
  y1: 0,
@@ -32,8 +34,12 @@ function (_super) {
32
34
  y2: 0,
33
35
  z1: 0,
34
36
  z2: 0,
35
- lineJoin: _types.LINE_JOIN.Miter,
36
- lineCap: _types.LINE_CAP.Butt,
37
+ lineJoin: _types.LineJoin.MITER,
38
+ lineCap: _types.LineCap.BUTT,
39
+
40
+ /**
41
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/stroke-width
42
+ */
37
43
  lineWidth: 1,
38
44
  isBillboard: false
39
45
  }, style)
@@ -4,7 +4,8 @@ import type { DisplayObjectConfig } from '../dom';
4
4
  import { Point } from '../shapes';
5
5
  import type { Rect } from '../shapes/Rect';
6
6
  export interface PathStyleProps extends BaseStyleProps {
7
- path: string | PathCommand[];
7
+ path?: string | PathCommand[];
8
+ d?: string | PathCommand[];
8
9
  }
9
10
  export interface PathSegment {
10
11
  command: PathCommand[0];
@@ -30,7 +31,7 @@ export interface ParsedPathStyleProps {
30
31
  export declare class Path extends DisplayObject<PathStyleProps, {
31
32
  path: ParsedPathStyleProps;
32
33
  }> {
33
- constructor({ style, ...rest }: DisplayObjectConfig<PathStyleProps>);
34
+ constructor({ style, ...rest }?: DisplayObjectConfig<PathStyleProps>);
34
35
  getTotalLength(): number;
35
36
  /**
36
37
  * Get point according to ratio
@@ -17,21 +17,24 @@ var _gMath = require("@antv/g-math");
17
17
 
18
18
  var _util = require("@antv/util");
19
19
 
20
- var Path =
21
- /** @class */
22
- function (_super) {
20
+ var Path = function (_super) {
23
21
  (0, _tslib.__extends)(Path, _super);
24
22
 
25
23
  function Path(_a) {
24
+ if (_a === void 0) {
25
+ _a = {};
26
+ }
27
+
26
28
  var style = _a.style,
27
29
  rest = (0, _tslib.__rest)(_a, ["style"]);
28
30
  return _super.call(this, (0, _tslib.__assign)({
29
- type: _types.SHAPE.Path,
31
+ type: _types.Shape.PATH,
30
32
  style: (0, _tslib.__assign)({
31
33
  path: '',
32
- lineJoin: _types.LINE_JOIN.Miter,
33
- lineCap: _types.LINE_CAP.Butt,
34
- lineWidth: 1
34
+ lineJoin: _types.LineJoin.MITER,
35
+ lineCap: _types.LineCap.BUTT,
36
+ lineWidth: 1,
37
+ miterLimit: 4
35
38
  }, style)
36
39
  }, rest)) || this;
37
40
  }
@@ -5,5 +5,5 @@ export interface PolygonStyleProps extends BaseStyleProps {
5
5
  points: [number, number][];
6
6
  }
7
7
  export declare class Polygon extends DisplayObject<PolygonStyleProps, ParsedBaseStyleProps> {
8
- constructor({ style, ...rest }: DisplayObjectConfig<PolygonStyleProps>);
8
+ constructor({ style, ...rest }?: DisplayObjectConfig<PolygonStyleProps>);
9
9
  }
@@ -11,18 +11,22 @@ var _types = require("../types");
11
11
 
12
12
  var _DisplayObject = require("./DisplayObject");
13
13
 
14
- var Polygon =
15
- /** @class */
16
- function (_super) {
14
+ var Polygon = function (_super) {
17
15
  (0, _tslib.__extends)(Polygon, _super);
18
16
 
19
17
  function Polygon(_a) {
18
+ if (_a === void 0) {
19
+ _a = {};
20
+ }
21
+
20
22
  var style = _a.style,
21
23
  rest = (0, _tslib.__rest)(_a, ["style"]);
22
24
  return _super.call(this, (0, _tslib.__assign)({
23
- type: _types.SHAPE.Polygon,
25
+ type: _types.Shape.POLYGON,
24
26
  style: (0, _tslib.__assign)({
25
- points: []
27
+ points: [],
28
+ miterLimit: 4,
29
+ lineWidth: 1
26
30
  }, style)
27
31
  }, rest)) || this;
28
32
  }
@@ -11,7 +11,7 @@ export interface ParsedPolylineStyleProps {
11
11
  totalLength: number;
12
12
  }
13
13
  export declare class Polyline extends DisplayObject<PolylineStyleProps, ParsedBaseStyleProps> {
14
- constructor({ style, ...rest }: DisplayObjectConfig<PolylineStyleProps>);
14
+ constructor({ style, ...rest }?: DisplayObjectConfig<PolylineStyleProps>);
15
15
  getTotalLength(): number;
16
16
  getPoint(ratio: number): Point;
17
17
  getStartTangent(): number[][];
@@ -15,21 +15,24 @@ var _DisplayObject = require("./DisplayObject");
15
15
 
16
16
  var _shapes = require("../shapes");
17
17
 
18
- var Polyline =
19
- /** @class */
20
- function (_super) {
18
+ var Polyline = function (_super) {
21
19
  (0, _tslib.__extends)(Polyline, _super);
22
20
 
23
21
  function Polyline(_a) {
22
+ if (_a === void 0) {
23
+ _a = {};
24
+ }
25
+
24
26
  var style = _a.style,
25
27
  rest = (0, _tslib.__rest)(_a, ["style"]);
26
28
  return _super.call(this, (0, _tslib.__assign)({
27
- type: _types.SHAPE.Polyline,
29
+ type: _types.Shape.POLYLINE,
28
30
  style: (0, _tslib.__assign)({
29
31
  points: [],
30
- lineJoin: _types.LINE_JOIN.Miter,
31
- lineCap: _types.LINE_CAP.Butt,
32
- lineWidth: 1
32
+ lineJoin: _types.LineJoin.MITER,
33
+ lineCap: _types.LineCap.BUTT,
34
+ lineWidth: 1,
35
+ miterLimit: 4
33
36
  }, style)
34
37
  }, rest)) || this;
35
38
  }
@@ -1,16 +1,19 @@
1
1
  import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
2
2
  import { DisplayObject } from './DisplayObject';
3
3
  import type { DisplayObjectConfig } from '../dom';
4
+ import type { ParsedElement } from '../property-handlers';
4
5
  export interface RectStyleProps extends BaseStyleProps {
5
- width: number;
6
- height: number;
6
+ width: number | string;
7
+ height: number | string;
7
8
  radius?: number;
8
9
  }
9
10
  export interface ParsedRectStyleProps extends ParsedBaseStyleProps {
10
- width: number;
11
- height: number;
11
+ width: ParsedElement;
12
+ height: ParsedElement;
13
+ widthInPixels: number;
14
+ heightInPixels: number;
12
15
  radius?: number;
13
16
  }
14
17
  export declare class Rect extends DisplayObject<RectStyleProps, ParsedRectStyleProps> {
15
- constructor({ style, ...rest }: DisplayObjectConfig<RectStyleProps>);
18
+ constructor({ style, ...rest }?: DisplayObjectConfig<RectStyleProps>);
16
19
  }
@@ -11,19 +11,22 @@ var _types = require("../types");
11
11
 
12
12
  var _DisplayObject = require("./DisplayObject");
13
13
 
14
- var Rect =
15
- /** @class */
16
- function (_super) {
14
+ var Rect = function (_super) {
17
15
  (0, _tslib.__extends)(Rect, _super);
18
16
 
19
17
  function Rect(_a) {
18
+ if (_a === void 0) {
19
+ _a = {};
20
+ }
21
+
20
22
  var style = _a.style,
21
23
  rest = (0, _tslib.__rest)(_a, ["style"]);
22
24
  return _super.call(this, (0, _tslib.__assign)({
23
- type: _types.SHAPE.Rect,
25
+ type: _types.Shape.RECT,
24
26
  style: (0, _tslib.__assign)({
25
- width: 0,
26
- height: 0
27
+ width: 'auto',
28
+ height: 'auto',
29
+ lineWidth: 0
27
30
  }, style)
28
31
  }, rest)) || this;
29
32
  }
@@ -0,0 +1 @@
1
+
@@ -0,0 +1 @@
1
+ "use strict";
@@ -2,16 +2,17 @@ import type { TextMetrics } from '../services/text';
2
2
  import type { DisplayObjectConfig } from '../dom/interfaces';
3
3
  import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
4
4
  import { DisplayObject } from './DisplayObject';
5
+ import type { ParsedElement } from '../property-handlers';
5
6
  export interface TextStyleProps extends BaseStyleProps {
6
7
  text: string;
7
8
  /** 设置文本内容的当前对齐方式 */
8
- textAlign?: 'start' | 'center' | 'end' | 'left' | 'right';
9
+ textAlign?: 'inherit' | 'start' | 'center' | 'end' | 'left' | 'right';
9
10
  /** 设置在绘制文本时使用的当前文本基线 */
10
11
  textBaseline?: 'top' | 'hanging' | 'middle' | 'alphabetic' | 'ideographic' | 'bottom';
11
12
  /** 字体样式 */
12
13
  fontStyle?: 'normal' | 'italic' | 'oblique';
13
14
  /** 文本字体大小 */
14
- fontSize?: number;
15
+ fontSize?: number | string;
15
16
  /** 文本字体 */
16
17
  fontFamily?: string;
17
18
  /** 文本粗细 */
@@ -28,6 +29,8 @@ export interface TextStyleProps extends BaseStyleProps {
28
29
  wordWrapWidth?: number;
29
30
  dropShadow?: boolean;
30
31
  dropShadowDistance?: number;
32
+ dx?: number | string;
33
+ dy?: number | string;
31
34
  }
32
35
  export interface ParsedTextStyleProps extends ParsedBaseStyleProps {
33
36
  text: string;
@@ -38,7 +41,7 @@ export interface ParsedTextStyleProps extends ParsedBaseStyleProps {
38
41
  /** 字体样式 */
39
42
  fontStyle?: 'normal' | 'italic' | 'oblique';
40
43
  /** 文本字体大小 */
41
- fontSize?: number;
44
+ fontSize?: ParsedElement;
42
45
  /** 文本字体 */
43
46
  fontFamily?: string;
44
47
  /** 文本粗细 */
@@ -56,8 +59,33 @@ export interface ParsedTextStyleProps extends ParsedBaseStyleProps {
56
59
  dropShadow?: boolean;
57
60
  dropShadowDistance?: number;
58
61
  metrics?: TextMetrics;
62
+ dx?: ParsedElement;
63
+ dy?: ParsedElement;
59
64
  }
65
+ /**
66
+ * <text> @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextElement
67
+ */
60
68
  export declare class Text extends DisplayObject<TextStyleProps, ParsedTextStyleProps> {
61
- constructor({ style, ...rest }: DisplayObjectConfig<TextStyleProps>);
69
+ /**
70
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextContentElement#constants
71
+ */
72
+ LENGTHADJUST_SPACING: number;
73
+ LENGTHADJUST_SPACINGANDGLYPHS: number;
74
+ LENGTHADJUST_UNKNOWN: number;
75
+ constructor({ style, ...rest }?: DisplayObjectConfig<TextStyleProps>);
76
+ lengthAdjust: SVGAnimatedEnumeration;
77
+ textLength: SVGAnimatedLength;
78
+ getCharNumAtPosition(point?: DOMPointInit): number;
79
+ /**
80
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextContentElement
81
+ */
82
+ getComputedTextLength(): number;
83
+ getEndPositionOfChar(charnum: number): DOMPoint;
84
+ getExtentOfChar(charnum: number): DOMRect;
85
+ getNumberOfChars(): number;
86
+ getRotationOfChar(charnum: number): number;
87
+ getStartPositionOfChar(charnum: number): DOMPoint;
88
+ getSubStringLength(charnum: number, nchars: number): number;
89
+ selectSubString(charnum: number, nchars: number): void;
62
90
  getLineBoundingRects(): import("..").Rectangle[];
63
91
  }
@@ -11,24 +11,30 @@ var _types = require("../types");
11
11
 
12
12
  var _DisplayObject = require("./DisplayObject");
13
13
 
14
- var Text =
15
- /** @class */
16
- function (_super) {
14
+ /**
15
+ * <text> @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextElement
16
+ */
17
+ var Text = function (_super) {
17
18
  (0, _tslib.__extends)(Text, _super);
18
19
 
19
20
  function Text(_a) {
21
+ if (_a === void 0) {
22
+ _a = {};
23
+ }
24
+
20
25
  var style = _a.style,
21
26
  rest = (0, _tslib.__rest)(_a, ["style"]);
22
- return _super.call(this, (0, _tslib.__assign)({
23
- type: _types.SHAPE.Text,
27
+
28
+ var _this = _super.call(this, (0, _tslib.__assign)({
29
+ type: _types.Shape.TEXT,
24
30
  style: (0, _tslib.__assign)({
25
31
  text: '',
26
- fontSize: 12,
27
- fontFamily: 'sans-serif',
32
+ fontSize: 'inherit',
33
+ fontFamily: 'inherit',
28
34
  fontStyle: 'normal',
29
35
  fontWeight: 'normal',
30
36
  fontVariant: 'normal',
31
- textAlign: 'start',
37
+ textAlign: 'inherit',
32
38
  textBaseline: 'alphabetic',
33
39
  dropShadow: false,
34
40
  // dropShadowAlpha: 1,
@@ -39,20 +45,72 @@ function (_super) {
39
45
  fill: '#000',
40
46
  letterSpacing: 0,
41
47
  lineHeight: 0,
42
- lineJoin: _types.LINE_JOIN.Miter,
43
- lineCap: _types.LINE_CAP.Butt,
48
+ lineJoin: _types.LineJoin.MITER,
49
+ lineCap: _types.LineCap.BUTT,
44
50
  lineWidth: 0,
45
51
  miterLimit: 10,
46
- // padding: 0,
47
52
  stroke: '#000',
48
53
  whiteSpace: 'pre',
49
54
  wordWrap: false,
50
- wordWrapWidth: 100,
51
- leading: 0
55
+ wordWrapWidth: 0,
56
+ leading: 0,
57
+ dx: 0,
58
+ dy: 0
52
59
  }, style)
53
60
  }, rest)) || this;
61
+ /**
62
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextContentElement#constants
63
+ */
64
+
65
+
66
+ _this.LENGTHADJUST_SPACING = 1;
67
+ _this.LENGTHADJUST_SPACINGANDGLYPHS = 2;
68
+ _this.LENGTHADJUST_UNKNOWN = 0;
69
+ return _this;
54
70
  }
55
71
 
72
+ Text.prototype.getCharNumAtPosition = function (point) {
73
+ throw new Error('Method not implemented.');
74
+ };
75
+ /**
76
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextContentElement
77
+ */
78
+
79
+
80
+ Text.prototype.getComputedTextLength = function () {
81
+ var _a;
82
+
83
+ return ((_a = this.parsedStyle.metrics) === null || _a === void 0 ? void 0 : _a.maxLineWidth) || 0;
84
+ };
85
+
86
+ Text.prototype.getEndPositionOfChar = function (charnum) {
87
+ throw new Error('Method not implemented.');
88
+ };
89
+
90
+ Text.prototype.getExtentOfChar = function (charnum) {
91
+ throw new Error('Method not implemented.');
92
+ };
93
+
94
+ Text.prototype.getNumberOfChars = function () {
95
+ throw new Error('Method not implemented.');
96
+ };
97
+
98
+ Text.prototype.getRotationOfChar = function (charnum) {
99
+ throw new Error('Method not implemented.');
100
+ };
101
+
102
+ Text.prototype.getStartPositionOfChar = function (charnum) {
103
+ throw new Error('Method not implemented.');
104
+ };
105
+
106
+ Text.prototype.getSubStringLength = function (charnum, nchars) {
107
+ throw new Error('Method not implemented.');
108
+ };
109
+
110
+ Text.prototype.selectSubString = function (charnum, nchars) {
111
+ throw new Error('Method not implemented.');
112
+ };
113
+
56
114
  Text.prototype.getLineBoundingRects = function () {
57
115
  var _a;
58
116
 
@@ -12,9 +12,7 @@ var sequenceNumber = 0;
12
12
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Animation/Animation
13
13
  */
14
14
 
15
- var Animation =
16
- /** @class */
17
- function () {
15
+ var Animation = function () {
18
16
  function Animation(effect, timeline) {
19
17
  this.currentTimePending = false;
20
18
  /**
@@ -240,7 +238,7 @@ function () {
240
238
  get: function get() {
241
239
  var _a;
242
240
 
243
- return Number((_a = this.effect) === null || _a === void 0 ? void 0 : _a.getComputedTiming().activeDuration);
241
+ return Number((_a = this.effect) === null || _a === void 0 ? void 0 : _a.getComputedTiming().endTime);
244
242
  },
245
243
  enumerable: false,
246
244
  configurable: true
@@ -10,9 +10,7 @@ var _animation = require("../utils/animation");
10
10
  /**
11
11
  * @see https://developer.mozilla.org/en-US/docs/Web/API/EffectTiming
12
12
  */
13
- var AnimationEffectTiming =
14
- /** @class */
15
- function () {
13
+ var AnimationEffectTiming = function () {
16
14
  function AnimationEffectTiming() {
17
15
  /**
18
16
  * @see https://developer.mozilla.org/en-US/docs/Web/API/EffectTiming/delay
@@ -12,9 +12,7 @@ var _FederatedEvent = require("./FederatedEvent");
12
12
  /**
13
13
  * @see https://developer.mozilla.org/en-US/docs/Web/API/AnimationPlaybackEvent
14
14
  */
15
- var AnimationEvent =
16
- /** @class */
17
- function (_super) {
15
+ var AnimationEvent = function (_super) {
18
16
  (0, _tslib.__extends)(AnimationEvent, _super);
19
17
 
20
18
  function AnimationEvent(manager, target, currentTime, timelineTime) {
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.AnimationTimeline = void 0;
7
6
  exports.compareAnimations = compareAnimations;
7
+ exports.AnimationTimeline = void 0;
8
8
 
9
9
  var _tslib = require("tslib");
10
10
 
@@ -20,9 +20,7 @@ function compareAnimations(leftAnimation, rightAnimation) {
20
20
  */
21
21
 
22
22
 
23
- var AnimationTimeline =
24
- /** @class */
25
- function () {
23
+ var AnimationTimeline = function () {
26
24
  function AnimationTimeline() {
27
25
  var _this = this;
28
26
  /**
@@ -165,8 +163,7 @@ function () {
165
163
 
166
164
  this.rafCallbacks.push([id, f]);
167
165
  return id;
168
- }; // eslint-disable-next-line @typescript-eslint/ban-types
169
-
166
+ };
170
167
 
171
168
  AnimationTimeline.prototype.requestAnimationFrame = function (f) {
172
169
  var _this = this;
@@ -14,22 +14,20 @@ var _displayObjects = require("../display-objects");
14
14
  *
15
15
  * @see https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry
16
16
  */
17
- var CustomElementRegistry =
18
- /** @class */
19
- function () {
17
+ var CustomElementRegistry = function () {
20
18
  function CustomElementRegistry() {
21
19
  this.registry = {};
22
- this.define(_types.SHAPE.Circle, _displayObjects.Circle);
23
- this.define(_types.SHAPE.Ellipse, _displayObjects.Ellipse);
24
- this.define(_types.SHAPE.Rect, _displayObjects.Rect);
25
- this.define(_types.SHAPE.Image, _displayObjects.Image);
26
- this.define(_types.SHAPE.Line, _displayObjects.Line);
27
- this.define(_types.SHAPE.Group, _displayObjects.Group);
28
- this.define(_types.SHAPE.Path, _displayObjects.Path);
29
- this.define(_types.SHAPE.Polygon, _displayObjects.Polygon);
30
- this.define(_types.SHAPE.Polyline, _displayObjects.Polyline);
31
- this.define(_types.SHAPE.Text, _displayObjects.Text);
32
- this.define(_types.SHAPE.HTML, _displayObjects.HTML);
20
+ this.define(_types.Shape.CIRCLE, _displayObjects.Circle);
21
+ this.define(_types.Shape.ELLIPSE, _displayObjects.Ellipse);
22
+ this.define(_types.Shape.RECT, _displayObjects.Rect);
23
+ this.define(_types.Shape.IMAGE, _displayObjects.Image);
24
+ this.define(_types.Shape.LINE, _displayObjects.Line);
25
+ this.define(_types.Shape.GROUP, _displayObjects.Group);
26
+ this.define(_types.Shape.PATH, _displayObjects.Path);
27
+ this.define(_types.Shape.POLYGON, _displayObjects.Polygon);
28
+ this.define(_types.Shape.POLYLINE, _displayObjects.Polyline);
29
+ this.define(_types.Shape.TEXT, _displayObjects.Text);
30
+ this.define(_types.Shape.HTML, _displayObjects.HTML);
33
31
  }
34
32
 
35
33
  CustomElementRegistry.prototype.define = function (name, constructor) {
@@ -21,9 +21,7 @@ var _FederatedEvent = require("./FederatedEvent");
21
21
 
22
22
  circle.dispatchEvent(event);
23
23
  */
24
- var CustomEvent =
25
- /** @class */
26
- function (_super) {
24
+ var CustomEvent = function (_super) {
27
25
  (0, _tslib.__extends)(CustomEvent, _super); // eslint-disable-next-line @typescript-eslint/ban-types
28
26
 
29
27
  function CustomEvent(eventName, object) {
@@ -1,6 +1,6 @@
1
1
  import { Node } from './Node';
2
2
  import { AnimationTimeline } from './AnimationTimeline';
3
- import { Group } from '../display-objects/Group';
3
+ import { Group } from '../display-objects';
4
4
  import type { DisplayObject } from '../display-objects/DisplayObject';
5
5
  import type { IDocument, IElement, INode, ICanvas, DisplayObjectConfig } from './interfaces';
6
6
  import type { BaseStyleProps } from '../types';
@@ -34,6 +34,7 @@ export declare class Document extends Node implements IDocument {
34
34
  * @example const circle = document.createElement('circle', { style: { r: 10 } });
35
35
  */
36
36
  createElement<T extends DisplayObject<StyleProps>, StyleProps extends BaseStyleProps>(tagName: string, options: DisplayObjectConfig<StyleProps>): T;
37
+ createElementNS<T extends DisplayObject<StyleProps>, StyleProps extends BaseStyleProps>(namespaceURI: string, tagName: string, options: DisplayObjectConfig<StyleProps>): T;
37
38
  cloneNode(deep?: boolean): this;
38
39
  destroy(): void;
39
40
  /**
@@ -11,16 +11,16 @@ var _Node = require("./Node");
11
11
 
12
12
  var _AnimationTimeline = require("./AnimationTimeline");
13
13
 
14
- var _Group = require("../display-objects/Group");
14
+ var _displayObjects = require("../display-objects");
15
+
16
+ var _types = require("../types");
15
17
 
16
18
  /**
17
19
  * the entry of DOM tree
18
20
  * Document -> Node -> EventTarget
19
21
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Document
20
22
  */
21
- var Document =
22
- /** @class */
23
- function (_super) {
23
+ var Document = function (_super) {
24
24
  (0, _tslib.__extends)(Document, _super);
25
25
 
26
26
  function Document() {
@@ -37,8 +37,16 @@ function (_super) {
37
37
 
38
38
  _this.timeline = new _AnimationTimeline.AnimationTimeline(); // like <html> in DOM tree
39
39
 
40
- _this.documentElement = new _Group.Group({
41
- id: 'g-root'
40
+ _this.documentElement = new _displayObjects.Group({
41
+ id: 'g-root',
42
+ style: {
43
+ textAlign: _types.TextAlign.START,
44
+ fontSize: '16px',
45
+ fontFamily: 'sans-serif' // fontStyle: 'normal',
46
+ // fontWeight: 'normal',
47
+ // fontVariant: 'normal',
48
+
49
+ }
42
50
  });
43
51
  _this.documentElement.ownerDocument = _this;
44
52
  _this.documentElement.parentNode = _this;
@@ -79,8 +87,19 @@ function (_super) {
79
87
  */
80
88
 
81
89
  Document.prototype.createElement = function (tagName, options) {
90
+ // d3 will use <tspan>
82
91
  var clazz = this.defaultView.customElements.get(tagName);
92
+
93
+ if (!clazz) {
94
+ console.warn('Unsupported tagName: ', tagName);
95
+ clazz = tagName === 'tspan' ? _displayObjects.Text : _displayObjects.Group;
96
+ }
97
+
83
98
  return new clazz(options);
99
+ };
100
+
101
+ Document.prototype.createElementNS = function (namespaceURI, tagName, options) {
102
+ return this.createElement(tagName, options);
84
103
  }; // eslint-disable-next-line @typescript-eslint/no-unused-vars
85
104
 
86
105