@antv/g 5.0.15 → 5.0.18

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 (236) hide show
  1. package/dist/index.umd.min.js +18 -2
  2. package/es/Canvas.d.ts +7 -1
  3. package/es/Canvas.js +9 -10
  4. package/es/camera/Camera.d.ts +3 -2
  5. package/es/camera/Camera.js +16 -8
  6. package/es/canvas-module.js +4 -2
  7. package/es/components/Transform.d.ts +0 -1
  8. package/es/components/Transform.js +0 -1
  9. package/es/display-objects/Circle.d.ts +1 -1
  10. package/es/display-objects/Circle.js +8 -3
  11. package/es/display-objects/CustomElement.d.ts +3 -2
  12. package/es/display-objects/CustomElement.js +9 -6
  13. package/es/display-objects/DisplayObject.d.ts +9 -3
  14. package/es/display-objects/DisplayObject.js +97 -50
  15. package/es/display-objects/Ellipse.d.ts +1 -1
  16. package/es/display-objects/Ellipse.js +8 -3
  17. package/es/display-objects/Group.d.ts +18 -2
  18. package/es/display-objects/Group.js +11 -9
  19. package/es/display-objects/HTML.d.ts +1 -1
  20. package/es/display-objects/HTML.js +9 -4
  21. package/es/display-objects/Image.d.ts +5 -3
  22. package/es/display-objects/Image.js +8 -3
  23. package/es/display-objects/Line.d.ts +1 -1
  24. package/es/display-objects/Line.js +12 -4
  25. package/es/display-objects/Path.d.ts +3 -2
  26. package/es/display-objects/Path.js +10 -5
  27. package/es/display-objects/Polygon.d.ts +1 -1
  28. package/es/display-objects/Polygon.js +9 -3
  29. package/es/display-objects/Polyline.d.ts +1 -1
  30. package/es/display-objects/Polyline.js +10 -5
  31. package/es/display-objects/Rect.d.ts +1 -1
  32. package/es/display-objects/Rect.js +8 -3
  33. package/es/display-objects/Text.d.ts +32 -4
  34. package/es/display-objects/Text.js +70 -10
  35. package/es/dom/Animation.js +2 -2
  36. package/es/dom/AnimationTimeline.js +1 -2
  37. package/es/dom/CustomElementRegistry.js +12 -12
  38. package/es/dom/Document.d.ts +2 -1
  39. package/es/dom/Document.js +22 -2
  40. package/es/dom/Element.d.ts +38 -5
  41. package/es/dom/Element.js +115 -16
  42. package/es/dom/EventTarget.d.ts +2 -2
  43. package/es/dom/EventTarget.js +4 -3
  44. package/es/dom/FederatedEvent.d.ts +4 -1
  45. package/es/dom/KeyframeList.js +1 -1
  46. package/es/dom/MutationEvent.d.ts +15 -0
  47. package/es/dom/MutationEvent.js +29 -0
  48. package/es/dom/MutationObserver.d.ts +36 -0
  49. package/es/dom/MutationObserver.js +413 -0
  50. package/es/dom/MutationRecord.d.ts +14 -0
  51. package/es/dom/MutationRecord.js +31 -0
  52. package/es/dom/Node.d.ts +35 -3
  53. package/es/dom/Node.js +184 -17
  54. package/es/dom/index.d.ts +3 -0
  55. package/es/dom/index.js +3 -0
  56. package/es/dom/interfaces.d.ts +39 -8
  57. package/es/dom/interfaces.js +23 -5
  58. package/es/global-module.d.ts +1 -0
  59. package/es/global-module.js +11 -13
  60. package/es/index.d.ts +1 -0
  61. package/es/index.js +1 -0
  62. package/es/plugins/CullingPlugin.d.ts +0 -2
  63. package/es/plugins/CullingPlugin.js +3 -24
  64. package/es/plugins/DirtyCheckPlugin.js +2 -2
  65. package/es/plugins/EventPlugin.d.ts +1 -0
  66. package/es/plugins/EventPlugin.js +15 -5
  67. package/es/plugins/FrustumCullingStrategy.d.ts +1 -0
  68. package/es/plugins/FrustumCullingStrategy.js +41 -33
  69. package/es/plugins/PrepareRendererPlugin.js +21 -5
  70. package/es/property-handlers/aabb.js +19 -20
  71. package/es/property-handlers/color.js +5 -2
  72. package/es/property-handlers/dimension.d.ts +15 -3
  73. package/es/property-handlers/dimension.js +50 -9
  74. package/es/property-handlers/index.d.ts +3 -0
  75. package/es/property-handlers/index.js +4 -1
  76. package/es/property-handlers/inherit.d.ts +6 -0
  77. package/es/property-handlers/inherit.js +25 -0
  78. package/es/property-handlers/interfaces.d.ts +2 -2
  79. package/es/property-handlers/lineDash.d.ts +6 -1
  80. package/es/property-handlers/lineDash.js +23 -4
  81. package/es/property-handlers/offsetDistance.js +2 -2
  82. package/es/property-handlers/text.d.ts +2 -0
  83. package/es/property-handlers/text.js +3 -0
  84. package/es/property-handlers/textTransform.d.ts +6 -0
  85. package/es/property-handlers/textTransform.js +19 -0
  86. package/es/services/EventService.js +11 -7
  87. package/es/services/RenderingContext.d.ts +5 -8
  88. package/es/services/RenderingContext.js +6 -7
  89. package/es/services/RenderingService.d.ts +12 -2
  90. package/es/services/RenderingService.js +23 -12
  91. package/es/services/SceneGraphSelector.d.ts +3 -2
  92. package/es/services/SceneGraphSelector.js +8 -4
  93. package/es/services/SceneGraphService.d.ts +0 -7
  94. package/es/services/SceneGraphService.js +17 -87
  95. package/es/services/aabb/CircleUpdater.js +3 -3
  96. package/es/services/aabb/EllipseUpdater.js +2 -2
  97. package/es/services/aabb/LineUpdater.js +2 -2
  98. package/es/services/aabb/PathUpdater.js +2 -2
  99. package/es/services/aabb/PolylineUpdater.js +3 -3
  100. package/es/services/aabb/RectUpdater.js +4 -4
  101. package/es/services/aabb/TextUpdater.js +31 -10
  102. package/es/services/text/index.js +19 -21
  103. package/es/shapes/AABB.js +5 -0
  104. package/es/types.d.ts +48 -24
  105. package/es/types.js +50 -31
  106. package/es/utils/animation.js +1 -1
  107. package/es/utils/custom-easing.js +1 -1
  108. package/es/utils/event.js +7 -4
  109. package/es/utils/index.d.ts +2 -0
  110. package/es/utils/index.js +3 -1
  111. package/es/utils/interpolation.d.ts +1 -0
  112. package/es/utils/interpolation.js +41 -8
  113. package/es/utils/path.js +11 -11
  114. package/es/utils/raf.d.ts +1 -1
  115. package/es/utils/raf.js +0 -2
  116. package/es/utils/string.d.ts +1 -0
  117. package/es/utils/string.js +9 -0
  118. package/es/utils/text.js +3 -3
  119. package/lib/Canvas.d.ts +7 -1
  120. package/lib/Canvas.js +7 -8
  121. package/lib/camera/Camera.d.ts +3 -2
  122. package/lib/camera/Camera.js +20 -10
  123. package/lib/canvas-module.js +3 -1
  124. package/lib/components/Transform.d.ts +0 -1
  125. package/lib/components/Transform.js +0 -1
  126. package/lib/display-objects/Circle.d.ts +1 -1
  127. package/lib/display-objects/Circle.js +7 -2
  128. package/lib/display-objects/CustomElement.d.ts +3 -2
  129. package/lib/display-objects/CustomElement.js +9 -6
  130. package/lib/display-objects/DisplayObject.d.ts +9 -3
  131. package/lib/display-objects/DisplayObject.js +97 -47
  132. package/lib/display-objects/Ellipse.d.ts +1 -1
  133. package/lib/display-objects/Ellipse.js +7 -2
  134. package/lib/display-objects/Group.d.ts +18 -2
  135. package/lib/display-objects/Group.js +10 -9
  136. package/lib/display-objects/HTML.d.ts +1 -1
  137. package/lib/display-objects/HTML.js +8 -4
  138. package/lib/display-objects/Image.d.ts +5 -3
  139. package/lib/display-objects/Image.js +7 -2
  140. package/lib/display-objects/Line.d.ts +1 -1
  141. package/lib/display-objects/Line.js +11 -3
  142. package/lib/display-objects/Path.d.ts +3 -2
  143. package/lib/display-objects/Path.js +9 -4
  144. package/lib/display-objects/Polygon.d.ts +1 -1
  145. package/lib/display-objects/Polygon.js +8 -2
  146. package/lib/display-objects/Polyline.d.ts +1 -1
  147. package/lib/display-objects/Polyline.js +9 -4
  148. package/lib/display-objects/Rect.d.ts +1 -1
  149. package/lib/display-objects/Rect.js +7 -2
  150. package/lib/display-objects/Text.d.ts +32 -4
  151. package/lib/display-objects/Text.js +69 -9
  152. package/lib/dom/Animation.js +2 -2
  153. package/lib/dom/AnimationTimeline.js +1 -2
  154. package/lib/dom/CustomElementRegistry.js +11 -11
  155. package/lib/dom/Document.d.ts +2 -1
  156. package/lib/dom/Document.js +24 -3
  157. package/lib/dom/Element.d.ts +38 -5
  158. package/lib/dom/Element.js +117 -16
  159. package/lib/dom/EventTarget.d.ts +2 -2
  160. package/lib/dom/EventTarget.js +4 -3
  161. package/lib/dom/FederatedEvent.d.ts +4 -1
  162. package/lib/dom/KeyframeList.js +1 -1
  163. package/lib/dom/MutationEvent.d.ts +15 -0
  164. package/lib/dom/MutationEvent.js +37 -0
  165. package/lib/dom/MutationObserver.d.ts +36 -0
  166. package/lib/dom/MutationObserver.js +424 -0
  167. package/lib/dom/MutationRecord.d.ts +14 -0
  168. package/lib/dom/MutationRecord.js +38 -0
  169. package/lib/dom/Node.d.ts +35 -3
  170. package/lib/dom/Node.js +185 -16
  171. package/lib/dom/index.d.ts +3 -0
  172. package/lib/dom/index.js +39 -0
  173. package/lib/dom/interfaces.d.ts +39 -8
  174. package/lib/dom/interfaces.js +23 -5
  175. package/lib/global-module.d.ts +1 -0
  176. package/lib/global-module.js +12 -8
  177. package/lib/index.d.ts +1 -0
  178. package/lib/index.js +3 -1
  179. package/lib/plugins/CullingPlugin.d.ts +0 -2
  180. package/lib/plugins/CullingPlugin.js +2 -23
  181. package/lib/plugins/DirtyCheckPlugin.js +1 -1
  182. package/lib/plugins/EventPlugin.d.ts +1 -0
  183. package/lib/plugins/EventPlugin.js +13 -5
  184. package/lib/plugins/FrustumCullingStrategy.d.ts +1 -0
  185. package/lib/plugins/FrustumCullingStrategy.js +42 -33
  186. package/lib/plugins/PrepareRendererPlugin.js +24 -4
  187. package/lib/property-handlers/aabb.js +18 -19
  188. package/lib/property-handlers/color.js +6 -3
  189. package/lib/property-handlers/dimension.d.ts +15 -3
  190. package/lib/property-handlers/dimension.js +50 -8
  191. package/lib/property-handlers/index.d.ts +3 -0
  192. package/lib/property-handlers/index.js +39 -0
  193. package/lib/property-handlers/inherit.d.ts +6 -0
  194. package/lib/property-handlers/inherit.js +34 -0
  195. package/lib/property-handlers/interfaces.d.ts +2 -2
  196. package/lib/property-handlers/lineDash.d.ts +6 -1
  197. package/lib/property-handlers/lineDash.js +25 -4
  198. package/lib/property-handlers/offsetDistance.js +1 -1
  199. package/lib/property-handlers/text.d.ts +2 -0
  200. package/lib/property-handlers/text.js +10 -0
  201. package/lib/property-handlers/textTransform.d.ts +6 -0
  202. package/lib/property-handlers/textTransform.js +27 -0
  203. package/lib/services/EventService.js +11 -7
  204. package/lib/services/RenderingContext.d.ts +5 -8
  205. package/lib/services/RenderingContext.js +8 -9
  206. package/lib/services/RenderingService.d.ts +12 -2
  207. package/lib/services/RenderingService.js +23 -11
  208. package/lib/services/SceneGraphSelector.d.ts +3 -2
  209. package/lib/services/SceneGraphSelector.js +10 -3
  210. package/lib/services/SceneGraphService.d.ts +0 -7
  211. package/lib/services/SceneGraphService.js +18 -91
  212. package/lib/services/aabb/CircleUpdater.js +2 -2
  213. package/lib/services/aabb/EllipseUpdater.js +1 -1
  214. package/lib/services/aabb/LineUpdater.js +1 -1
  215. package/lib/services/aabb/PathUpdater.js +1 -1
  216. package/lib/services/aabb/PolylineUpdater.js +2 -2
  217. package/lib/services/aabb/RectUpdater.js +3 -3
  218. package/lib/services/aabb/TextUpdater.js +30 -9
  219. package/lib/services/text/index.js +19 -21
  220. package/lib/shapes/AABB.js +5 -0
  221. package/lib/types.d.ts +48 -24
  222. package/lib/types.js +56 -35
  223. package/lib/utils/animation.js +1 -1
  224. package/lib/utils/custom-easing.js +1 -1
  225. package/lib/utils/event.js +7 -4
  226. package/lib/utils/index.d.ts +2 -0
  227. package/lib/utils/index.js +26 -0
  228. package/lib/utils/interpolation.d.ts +1 -0
  229. package/lib/utils/interpolation.js +43 -7
  230. package/lib/utils/path.js +10 -10
  231. package/lib/utils/raf.d.ts +1 -1
  232. package/lib/utils/raf.js +0 -2
  233. package/lib/utils/string.d.ts +1 -0
  234. package/lib/utils/string.js +16 -0
  235. package/lib/utils/text.js +3 -3
  236. package/package.json +5 -3
@@ -36,8 +36,8 @@ var regexCannotStartJaJp = /[)\]}〕〉》」』】〙〗〟'"⦆»ヽヾー
36
36
  var regexCannotEndJaJp = /[([{〔〈《「『【〘〖〝'"⦅«—...‥〳〴〵]/;
37
37
  var regexCannotStartKoKr = /[!%),.:;?\]}¢°'"†‡℃〆〈《「『〕!%),.:;?]}]/;
38
38
  var regexCannotEndKoKr = /[$([{£¥'"々〇〉》」〔$([{⦆¥₩#]/;
39
- var regexCannotStart = new RegExp(regexCannotStartZhCn.source + "|" + regexCannotStartZhTw.source + "|" + regexCannotStartJaJp.source + "|" + regexCannotStartKoKr.source);
40
- var regexCannotEnd = new RegExp(regexCannotEndZhCn.source + "|" + regexCannotEndZhTw.source + "|" + regexCannotEndJaJp.source + "|" + regexCannotEndKoKr.source);
39
+ var regexCannotStart = new RegExp("".concat(regexCannotStartZhCn.source, "|").concat(regexCannotStartZhTw.source, "|").concat(regexCannotStartJaJp.source, "|").concat(regexCannotStartKoKr.source));
40
+ var regexCannotEnd = new RegExp("".concat(regexCannotEndZhCn.source, "|").concat(regexCannotEndZhTw.source, "|").concat(regexCannotEndJaJp.source, "|").concat(regexCannotEndKoKr.source));
41
41
 
42
42
  var TextService =
43
43
  /** @class */
@@ -104,7 +104,7 @@ function () {
104
104
  context.textBaseline = 'alphabetic';
105
105
  context.fillStyle = '#000';
106
106
  context.fillText(metricsString, 0, baseline);
107
- var imagedata = context.getImageData(0, 0, width, height).data;
107
+ var imagedata = context.getImageData(0, 0, width || 1, height || 1).data;
108
108
  var pixels = imagedata.length;
109
109
  var line = width * 4;
110
110
  var i = 0;
@@ -152,29 +152,27 @@ function () {
152
152
  };
153
153
 
154
154
  TextService.prototype.measureText = function (text, attributes) {
155
- var _a = attributes.fontSize,
156
- fontSize = _a === void 0 ? 0 : _a,
155
+ var fontSize = attributes.fontSize,
157
156
  wordWrap = attributes.wordWrap,
158
- _b = attributes.lineHeight,
159
- strokeHeight = _b === void 0 ? 0 : _b,
160
- _c = attributes.lineWidth,
161
- lineWidth = _c === void 0 ? 0 : _c,
157
+ _a = attributes.lineHeight,
158
+ strokeHeight = _a === void 0 ? 0 : _a,
159
+ lineWidth = attributes.lineWidth,
162
160
  textBaseline = attributes.textBaseline,
163
161
  textAlign = attributes.textAlign,
164
- _d = attributes.letterSpacing,
165
- letterSpacing = _d === void 0 ? 0 : _d,
162
+ _b = attributes.letterSpacing,
163
+ letterSpacing = _b === void 0 ? 0 : _b,
166
164
  dropShadow = attributes.dropShadow,
167
- _e = attributes.dropShadowDistance,
168
- dropShadowDistance = _e === void 0 ? 0 : _e,
169
- _f = attributes.leading,
170
- leading = _f === void 0 ? 0 : _f;
165
+ _c = attributes.dropShadowDistance,
166
+ dropShadowDistance = _c === void 0 ? 0 : _c,
167
+ _d = attributes.leading,
168
+ leading = _d === void 0 ? 0 : _d;
171
169
  var font = (0, _text.toFontString)(attributes);
172
170
  var fontProperties = this.measureFont(font); // fallback in case UA disallow canvas data extraction
173
171
  // (toDataURI, getImageData functions)
174
172
 
175
173
  if (fontProperties.fontSize === 0) {
176
- fontProperties.fontSize = fontSize;
177
- fontProperties.ascent = fontSize;
174
+ fontProperties.fontSize = fontSize.value;
175
+ fontProperties.ascent = fontSize.value;
178
176
  }
179
177
 
180
178
  var context = this.offscreenCanvas.getOrCreateContext();
@@ -190,14 +188,14 @@ function () {
190
188
  maxLineWidth = Math.max(maxLineWidth, lineWidth_1);
191
189
  }
192
190
 
193
- var width = maxLineWidth + lineWidth;
191
+ var width = maxLineWidth + lineWidth.value;
194
192
 
195
193
  if (dropShadow) {
196
194
  width += dropShadowDistance;
197
195
  }
198
196
 
199
- var lineHeight = strokeHeight || fontProperties.fontSize + lineWidth;
200
- var height = Math.max(lineHeight, fontProperties.fontSize + lineWidth) + (lines.length - 1) * (lineHeight + leading);
197
+ var lineHeight = strokeHeight || fontProperties.fontSize + lineWidth.value;
198
+ var height = Math.max(lineHeight, fontProperties.fontSize + lineWidth.value) + (lines.length - 1) * (lineHeight + leading);
201
199
 
202
200
  if (dropShadow) {
203
201
  height += dropShadowDistance;
@@ -233,7 +231,7 @@ function () {
233
231
  offsetX -= width;
234
232
  }
235
233
 
236
- return new _shapes.Rectangle(offsetX - lineWidth / 2, offsetY + i * lineHeight, width + lineWidth, lineHeight);
234
+ return new _shapes.Rectangle(offsetX - lineWidth.value / 2, offsetY + i * lineHeight, width + lineWidth.value, lineHeight);
237
235
  })
238
236
  };
239
237
  };
@@ -59,6 +59,11 @@ function () {
59
59
  return;
60
60
  }
61
61
 
62
+ if (AABB.isEmpty(this)) {
63
+ this.setMinMax(aabb.getMin(), aabb.getMax());
64
+ return;
65
+ }
66
+
62
67
  var tc = this.center;
63
68
  var tcx = tc[0];
64
69
  var tcy = tc[1];
package/lib/types.d.ts CHANGED
@@ -2,19 +2,19 @@
2
2
  import type { vec2, vec3 } from 'gl-matrix';
3
3
  import type { ParsedPathStyleProps, ParsedPolylineStyleProps } from './display-objects';
4
4
  import type { DisplayObject } from './display-objects';
5
- import type { ParsedColorStyleProperty } from './property-handlers';
5
+ import type { ParsedColorStyleProperty, ParsedElement } from './property-handlers';
6
6
  import type { IRenderer } from './AbstractRenderer';
7
- export declare enum SHAPE {
8
- Group = "group",
9
- Circle = "circle",
10
- Ellipse = "ellipse",
11
- Image = "image",
12
- Rect = "rect",
13
- Line = "line",
14
- Polyline = "polyline",
15
- Polygon = "polygon",
16
- Text = "text",
17
- Path = "path",
7
+ export declare enum Shape {
8
+ GROUP = "g",
9
+ CIRCLE = "circle",
10
+ ELLIPSE = "ellipse",
11
+ IMAGE = "image",
12
+ RECT = "rect",
13
+ LINE = "line",
14
+ POLYLINE = "polyline",
15
+ POLYGON = "polygon",
16
+ TEXT = "text",
17
+ PATH = "path",
18
18
  HTML = "html"
19
19
  }
20
20
  declare type ColorType = string | null;
@@ -26,17 +26,31 @@ export interface EventPosition {
26
26
  x: number;
27
27
  y: number;
28
28
  }
29
- export declare enum LINE_CAP {
30
- Butt = "butt",
31
- Round = "round",
32
- Square = "square"
29
+ export declare enum LineCap {
30
+ BUTT = "butt",
31
+ ROUND = "round",
32
+ SQUARE = "square"
33
33
  }
34
- export declare enum LINE_JOIN {
35
- Bevel = "bevel",
36
- Round = "round",
37
- Miter = "miter"
34
+ export declare enum LineJoin {
35
+ BEVEL = "bevel",
36
+ ROUND = "round",
37
+ MITER = "miter"
38
+ }
39
+ export declare enum TextTransform {
40
+ CAPITALIZE = "capitalize",
41
+ UPPERCASE = "uppercase",
42
+ LOWERCASE = "lowercase",
43
+ NONE = "none"
44
+ }
45
+ export declare enum TextAlign {
46
+ START = "start",
47
+ CENTER = "center",
48
+ END = "end",
49
+ LEFT = "left",
50
+ RIGHT = "right"
38
51
  }
39
52
  export interface BaseStyleProps {
53
+ class?: string;
40
54
  /**
41
55
  * x in local space
42
56
  */
@@ -100,11 +114,11 @@ export interface BaseStyleProps {
100
114
  /** 整体透明度 */
101
115
  opacity?: number;
102
116
  /** 线宽 */
103
- lineWidth?: number;
117
+ lineWidth?: string | number;
104
118
  /** 指定如何绘制每一条线段末端 */
105
- lineCap?: LINE_CAP;
119
+ lineCap?: LineCap;
106
120
  /** 用来设置2个长度不为0的相连部分(线段,圆弧,曲线)如何连接在一起的属性(长度为0的变形部分,其指定的末端和控制点在同一位置,会被忽略) */
107
- lineJoin?: LINE_JOIN;
121
+ lineJoin?: LineJoin;
108
122
  /**
109
123
  * 设置线的虚线样式,可以指定一个数组。一组描述交替绘制线段和间距(坐标空间单位)长度的数字。 如果数组元素的数量是奇数, 数组的元素会被复制并重复。例如, [5, 15, 25] 会变成 [5, 15, 25, 5, 15, 25]。这个属性取决于浏览器是否支持 setLineDash() 函数。
110
124
  */
@@ -126,14 +140,23 @@ export interface BaseStyleProps {
126
140
  * @see https://developer.mozilla.org/en-US/docs/Web/CSS/filter
127
141
  */
128
142
  filter?: string;
143
+ /**
144
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/text-transform
145
+ */
146
+ textTransform?: TextTransform;
147
+ /**
148
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/miterLimit
149
+ */
150
+ miterLimit?: number;
129
151
  }
130
- export interface ParsedBaseStyleProps extends Omit<BaseStyleProps, 'fill' | 'stroke' | 'path' | 'points'> {
152
+ export interface ParsedBaseStyleProps extends Omit<BaseStyleProps, 'fill' | 'stroke' | 'path' | 'points' | 'lineWidth' | 'shadowColor'> {
131
153
  fill?: ParsedColorStyleProperty;
132
154
  stroke?: ParsedColorStyleProperty;
133
155
  path?: ParsedPathStyleProps;
134
156
  points?: ParsedPolylineStyleProps;
135
157
  x?: number;
136
158
  y?: number;
159
+ lineWidth?: ParsedElement;
137
160
  /**
138
161
  * x according to definition, eg. Line's x1/x2, Polyline's points
139
162
  */
@@ -144,6 +167,7 @@ export interface ParsedBaseStyleProps extends Omit<BaseStyleProps, 'fill' | 'str
144
167
  */
145
168
  offsetX?: number;
146
169
  offsetY?: number;
170
+ shadowColor?: ParsedColorStyleProperty;
147
171
  }
148
172
  export declare type Cursor = 'auto' | 'default' | 'none' | 'context-menu' | 'help' | 'pointer' | 'progress' | 'wait' | 'cell' | 'crosshair' | 'text' | 'vertical-text' | 'alias' | 'copy' | 'move' | 'no-drop' | 'not-allowed' | 'grab' | 'grabbing' | 'all-scroll' | 'col-resize' | 'row-resize' | 'n-resize' | 'e-resize' | 's-resize' | 'w-resize' | 'ne-resize' | 'nw-resize' | 'se-resize' | 'sw-resize' | 'ew-resize' | 'ns-resize' | 'nesw-resize' | 'nwse-resize' | 'zoom-in' | 'zoom-out';
149
173
  export interface RendererConfig {
package/lib/types.js CHANGED
@@ -3,41 +3,62 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.SHAPE = exports.LINE_JOIN = exports.LINE_CAP = exports.CanvasConfig = void 0;
7
- var SHAPE;
8
- exports.SHAPE = SHAPE;
9
-
10
- (function (SHAPE) {
11
- SHAPE["Group"] = "group";
12
- SHAPE["Circle"] = "circle";
13
- SHAPE["Ellipse"] = "ellipse";
14
- SHAPE["Image"] = "image";
15
- SHAPE["Rect"] = "rect";
16
- SHAPE["Line"] = "line";
17
- SHAPE["Polyline"] = "polyline";
18
- SHAPE["Polygon"] = "polygon";
19
- SHAPE["Text"] = "text";
20
- SHAPE["Path"] = "path";
21
- SHAPE["HTML"] = "html";
22
- })(SHAPE || (exports.SHAPE = SHAPE = {}));
23
-
24
- var LINE_CAP;
25
- exports.LINE_CAP = LINE_CAP;
26
-
27
- (function (LINE_CAP) {
28
- LINE_CAP["Butt"] = "butt";
29
- LINE_CAP["Round"] = "round";
30
- LINE_CAP["Square"] = "square";
31
- })(LINE_CAP || (exports.LINE_CAP = LINE_CAP = {}));
32
-
33
- var LINE_JOIN;
34
- exports.LINE_JOIN = LINE_JOIN;
35
-
36
- (function (LINE_JOIN) {
37
- LINE_JOIN["Bevel"] = "bevel";
38
- LINE_JOIN["Round"] = "round";
39
- LINE_JOIN["Miter"] = "miter";
40
- })(LINE_JOIN || (exports.LINE_JOIN = LINE_JOIN = {}));
6
+ exports.TextTransform = exports.TextAlign = exports.Shape = exports.LineJoin = exports.LineCap = exports.CanvasConfig = void 0;
7
+ var Shape;
8
+ exports.Shape = Shape;
9
+
10
+ (function (Shape) {
11
+ Shape["GROUP"] = "g";
12
+ Shape["CIRCLE"] = "circle";
13
+ Shape["ELLIPSE"] = "ellipse";
14
+ Shape["IMAGE"] = "image";
15
+ Shape["RECT"] = "rect";
16
+ Shape["LINE"] = "line";
17
+ Shape["POLYLINE"] = "polyline";
18
+ Shape["POLYGON"] = "polygon";
19
+ Shape["TEXT"] = "text";
20
+ Shape["PATH"] = "path";
21
+ Shape["HTML"] = "html";
22
+ })(Shape || (exports.Shape = Shape = {}));
23
+
24
+ var LineCap;
25
+ exports.LineCap = LineCap;
26
+
27
+ (function (LineCap) {
28
+ LineCap["BUTT"] = "butt";
29
+ LineCap["ROUND"] = "round";
30
+ LineCap["SQUARE"] = "square";
31
+ })(LineCap || (exports.LineCap = LineCap = {}));
32
+
33
+ var LineJoin;
34
+ exports.LineJoin = LineJoin;
35
+
36
+ (function (LineJoin) {
37
+ LineJoin["BEVEL"] = "bevel";
38
+ LineJoin["ROUND"] = "round";
39
+ LineJoin["MITER"] = "miter";
40
+ })(LineJoin || (exports.LineJoin = LineJoin = {}));
41
+
42
+ var TextTransform;
43
+ exports.TextTransform = TextTransform;
44
+
45
+ (function (TextTransform) {
46
+ TextTransform["CAPITALIZE"] = "capitalize";
47
+ TextTransform["UPPERCASE"] = "uppercase";
48
+ TextTransform["LOWERCASE"] = "lowercase";
49
+ TextTransform["NONE"] = "none";
50
+ })(TextTransform || (exports.TextTransform = TextTransform = {}));
51
+
52
+ var TextAlign;
53
+ exports.TextAlign = TextAlign;
54
+
55
+ (function (TextAlign) {
56
+ TextAlign["START"] = "start";
57
+ TextAlign["CENTER"] = "center";
58
+ TextAlign["END"] = "end";
59
+ TextAlign["LEFT"] = "left";
60
+ TextAlign["RIGHT"] = "right";
61
+ })(TextAlign || (exports.TextAlign = TextAlign = {}));
41
62
 
42
63
  var CanvasConfig = 'CanvasConfig';
43
64
  exports.CanvasConfig = CanvasConfig;
@@ -100,7 +100,7 @@ function calculatePhase(activeDuration, localTime, timing) {
100
100
  return PhaseNone;
101
101
  }
102
102
 
103
- var endTime = timing.delay + activeDuration + timing.endDelay;
103
+ var endTime = timing.endTime;
104
104
 
105
105
  if (localTime < Math.min(timing.delay, endTime)) {
106
106
  return PhaseBefore;
@@ -14,7 +14,7 @@ var _bezierEasing = require("./bezier-easing");
14
14
  */
15
15
  var convertToDash = function convertToDash(str) {
16
16
  str = str.replace(/([A-Z])/g, function (letter) {
17
- return "-" + letter.toLowerCase();
17
+ return "-".concat(letter.toLowerCase());
18
18
  }); // Remove first dash
19
19
 
20
20
  return str.charAt(0) === '-' ? str.substr(1) : str;
@@ -12,10 +12,11 @@ exports.supportsTouchEvents = exports.supportsPointerEvents = void 0;
12
12
  var _util = require("@antv/util");
13
13
 
14
14
  // use `self` instead of `window`, account for non-window contexts, such as in Web Workers
15
+ // @see https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/globalThis
15
16
  // @see https://developer.mozilla.org/en-US/docs/Web/API/Window/self
16
- var supportsTouchEvents = !!self.TouchEvent;
17
+ var supportsTouchEvents = !!globalThis.TouchEvent;
17
18
  exports.supportsTouchEvents = supportsTouchEvents;
18
- var supportsPointerEvents = !!self.PointerEvent;
19
+ var supportsPointerEvents = !!globalThis.PointerEvent;
19
20
  exports.supportsPointerEvents = supportsPointerEvents;
20
21
  var MOUSE_POINTER_ID = 1;
21
22
  exports.MOUSE_POINTER_ID = MOUSE_POINTER_ID;
@@ -33,7 +34,7 @@ function isTouchEvent(event) {
33
34
  }
34
35
 
35
36
  function isMouseEvent(event) {
36
- return !self.MouseEvent || event instanceof MouseEvent && (!supportsPointerEvents || !(event instanceof self.PointerEvent));
37
+ return !globalThis.MouseEvent || event instanceof MouseEvent && (!supportsPointerEvents || !(event instanceof globalThis.PointerEvent));
37
38
  }
38
39
  /**
39
40
  * borrow from pixi/events
@@ -45,7 +46,9 @@ function normalizeToPointerEvent(event) {
45
46
 
46
47
  if (isTouchEvent(event)) {
47
48
  for (var i = 0; i < event.changedTouches.length; i++) {
48
- var touch = event.changedTouches[i];
49
+ var touch = event.changedTouches[i]; // use changedTouches instead of touches since touchend has no touches
50
+ // @see https://stackoverflow.com/a/10079076
51
+
49
52
  if ((0, _util.isUndefined)(touch.button)) touch.button = event.touches.length ? 1 : 0;
50
53
  if ((0, _util.isUndefined)(touch.buttons)) touch.buttons = event.touches.length ? 1 : 0;
51
54
 
@@ -3,3 +3,5 @@ export * from './interpolation';
3
3
  export * from './path';
4
4
  export * from './raf';
5
5
  export * from './text';
6
+ export * from './string';
7
+ export * from './event';
@@ -67,4 +67,30 @@ Object.keys(_text).forEach(function (key) {
67
67
  return _text[key];
68
68
  }
69
69
  });
70
+ });
71
+
72
+ var _string = require("./string");
73
+
74
+ Object.keys(_string).forEach(function (key) {
75
+ if (key === "default" || key === "__esModule") return;
76
+ if (key in exports && exports[key] === _string[key]) return;
77
+ Object.defineProperty(exports, key, {
78
+ enumerable: true,
79
+ get: function get() {
80
+ return _string[key];
81
+ }
82
+ });
83
+ });
84
+
85
+ var _event = require("./event");
86
+
87
+ Object.keys(_event).forEach(function (key) {
88
+ if (key === "default" || key === "__esModule") return;
89
+ if (key in exports && exports[key] === _event[key]) return;
90
+ Object.defineProperty(exports, key, {
91
+ enumerable: true,
92
+ get: function get() {
93
+ return _event[key];
94
+ }
95
+ });
70
96
  });
@@ -1,3 +1,4 @@
1
1
  import type { AnimationEffectTiming } from '../dom';
2
2
  import type { IElement } from '../dom/interfaces';
3
3
  export declare function convertEffectInput(keyframes: ComputedKeyframe[], timing: AnimationEffectTiming, target: IElement | null): (target: IElement, fraction: number) => void;
4
+ export declare function formatAttribute(name: string, value: any): [string, any];
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.convertEffectInput = convertEffectInput;
7
+ exports.formatAttribute = formatAttribute;
7
8
 
8
9
  var _tslib = require("tslib");
9
10
 
@@ -11,10 +12,8 @@ var _globalModule = require("../global-module");
11
12
 
12
13
  var _animation = require("./animation");
13
14
 
14
- // import {
15
- // StylePropertyMergerFactory,
16
- // StylePropertyParserFactory,
17
- // } from '../property-handlers/interfaces';
15
+ var _string = require("./string");
16
+
18
17
  function convertEffectInput(keyframes, timing, target) {
19
18
  var propertySpecificKeyframeGroups = makePropertySpecificKeyframeGroups(keyframes, timing);
20
19
  var interpolations = makeInterpolations(propertySpecificKeyframeGroups, target);
@@ -130,9 +129,9 @@ function propertyInterpolation(property, left, right, target) {
130
129
 
131
130
  if (parser) {
132
131
  // @ts-ignore
133
- parsedLeft = parser(left, target); // @ts-ignore
132
+ parsedLeft = parser(left, target, property); // @ts-ignore
134
133
 
135
- parsedRight = parser(right, target);
134
+ parsedRight = parser(right, target, property);
136
135
  } // merger [left, right, n2string()]
137
136
 
138
137
 
@@ -189,4 +188,41 @@ convertToString) {
189
188
  return function (f) {
190
189
  return convertToString(interpolate(from, to, f));
191
190
  };
192
- };
191
+ };
192
+
193
+ var FORMAT_ATTR_MAP = {
194
+ d: {
195
+ alias: 'path'
196
+ },
197
+ cx: {
198
+ alias: 'x'
199
+ },
200
+ cy: {
201
+ alias: 'y'
202
+ },
203
+ strokeDasharray: {
204
+ alias: 'lineDash'
205
+ },
206
+ strokeWidth: {
207
+ alias: 'lineWidth'
208
+ },
209
+ textAnchor: {
210
+ alias: 'textAlign',
211
+ values: {
212
+ middle: 'center'
213
+ }
214
+ },
215
+ src: {
216
+ alias: 'img'
217
+ }
218
+ };
219
+
220
+ function formatAttribute(name, value) {
221
+ var _a;
222
+
223
+ var attributeName = (0, _string.camelCase)(name);
224
+ var map = FORMAT_ATTR_MAP[attributeName];
225
+ attributeName = (map === null || map === void 0 ? void 0 : map.alias) || attributeName;
226
+ var attributeValue = ((_a = map === null || map === void 0 ? void 0 : map.values) === null || _a === void 0 ? void 0 : _a[value]) || value;
227
+ return [attributeName, attributeValue];
228
+ }
package/lib/utils/path.js CHANGED
@@ -234,7 +234,7 @@ function commandsToPathString(commands, localTransform, anchor, parsedStyle) {
234
234
 
235
235
  _glMatrix.vec3.transformMat4(p, p, localTransform);
236
236
 
237
- path = "" + cur[0] + p[0] + "," + p[1];
237
+ path = "".concat(cur[0]).concat(p[0], ",").concat(p[1]);
238
238
  } else if (cur[0] === 'Z') {
239
239
  path = cur[0];
240
240
  } else if (cur[0] === 'C') {
@@ -250,13 +250,13 @@ function commandsToPathString(commands, localTransform, anchor, parsedStyle) {
250
250
 
251
251
  _glMatrix.vec3.transformMat4(p3, p3, localTransform);
252
252
 
253
- path = "" + cur[0] + p1[0] + "," + p1[1] + "," + p2[0] + "," + p2[1] + "," + p3[0] + "," + p3[1];
253
+ path = "".concat(cur[0]).concat(p1[0], ",").concat(p1[1], ",").concat(p2[0], ",").concat(p2[1], ",").concat(p3[0], ",").concat(p3[1]);
254
254
  } else if (cur[0] === 'A') {
255
255
  var c = _glMatrix.vec3.fromValues(cur[6] - x, cur[7] - y, 0);
256
256
 
257
257
  _glMatrix.vec3.transformMat4(c, c, localTransform);
258
258
 
259
- path = "" + cur[0] + cur[1] + "," + cur[2] + "," + cur[3] + "," + cur[4] + "," + cur[5] + "," + c[0] + "," + c[1];
259
+ 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]);
260
260
  }
261
261
 
262
262
  return prev += path;
@@ -306,7 +306,7 @@ function convertToPath(object) {
306
306
  var commands = [];
307
307
 
308
308
  switch (object.nodeName) {
309
- case _types.SHAPE.Line:
309
+ case _types.Shape.LINE:
310
310
  var _a = object.parsedStyle,
311
311
  x1 = _a.x1,
312
312
  y1 = _a.y1,
@@ -315,7 +315,7 @@ function convertToPath(object) {
315
315
  commands = lineToCommands(x1, y1, x2, y2);
316
316
  break;
317
317
 
318
- case _types.SHAPE.Circle:
318
+ case _types.Shape.CIRCLE:
319
319
  {
320
320
  var _b = object.parsedStyle,
321
321
  r = _b.rInPixels,
@@ -327,7 +327,7 @@ function convertToPath(object) {
327
327
  break;
328
328
  }
329
329
 
330
- case _types.SHAPE.Ellipse:
330
+ case _types.Shape.ELLIPSE:
331
331
  {
332
332
  var _e = object.parsedStyle,
333
333
  rx = _e.rxInPixels,
@@ -340,13 +340,13 @@ function convertToPath(object) {
340
340
  break;
341
341
  }
342
342
 
343
- case _types.SHAPE.Polyline:
344
- case _types.SHAPE.Polygon:
343
+ case _types.Shape.POLYLINE:
344
+ case _types.Shape.POLYGON:
345
345
  var points = object.parsedStyle.points;
346
346
  commands = polygonToCommands(points.points);
347
347
  break;
348
348
 
349
- case _types.SHAPE.Rect:
349
+ case _types.Shape.RECT:
350
350
  var _h = object.parsedStyle,
351
351
  width = _h.widthInPixels,
352
352
  height = _h.heightInPixels,
@@ -356,7 +356,7 @@ function convertToPath(object) {
356
356
  commands = rectToCommands(width, height, x, y, radius);
357
357
  break;
358
358
 
359
- case _types.SHAPE.Path:
359
+ case _types.Shape.PATH:
360
360
  commands = object.parsedStyle.path.curve;
361
361
  break;
362
362
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * use user-defined raf instead of requestAnimationFrame
3
3
  */
4
- export declare function patch(requestAFPatch: (callback: Function) => number, cancelAFPatch: (id: number) => void): void;
4
+ export declare function patch(requestAFPatch: (callback: (timestamp: number) => void) => number, cancelAFPatch: (id: number) => void): void;
5
5
  export declare const requestAnimationFrame: (callback: Function) => number;
6
6
  export declare const cancelAnimationFrame: (id: number) => void;
package/lib/utils/raf.js CHANGED
@@ -9,8 +9,6 @@ exports.requestAnimationFrame = void 0;
9
9
 
10
10
  var _requestAnimationFramePolyfill = require("request-animation-frame-polyfill");
11
11
 
12
- // import { requestAnimationFrame, cancelAnimationFrame } from 'request-animation-frame-polyfill';
13
- // export { requestAnimationFrame, cancelAnimationFrame };
14
12
  var requestAF = _requestAnimationFramePolyfill.requestAnimationFrame;
15
13
  var cancelAF = _requestAnimationFramePolyfill.cancelAnimationFrame;
16
14
  /**
@@ -0,0 +1 @@
1
+ export declare function camelCase(str?: string): string;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.camelCase = camelCase;
7
+
8
+ function camelCase(str) {
9
+ if (str === void 0) {
10
+ str = '';
11
+ }
12
+
13
+ return str.replace(/-([a-z])/g, function (g) {
14
+ return g[1].toUpperCase();
15
+ });
16
+ }
package/lib/utils/text.js CHANGED
@@ -16,7 +16,7 @@ function toFontString(attributes) {
16
16
  fontVariant = attributes.fontVariant,
17
17
  fontWeight = attributes.fontWeight; // build canvas api font setting from individual components. Convert a numeric this.fontSize to px
18
18
 
19
- var fontSizeString = (0, _util.isNumber)(fontSize) ? fontSize + "px" : fontSize; // Clean-up fontFamily property by quoting each font name
19
+ var fontSizeString = (0, _util.isNumber)(fontSize) ? "".concat(fontSize, "px") : "".concat(fontSize.value).concat(fontSize.unit || 'px'); // Clean-up fontFamily property by quoting each font name
20
20
  // this will support font names with spaces
21
21
  // @ts-ignore
22
22
 
@@ -31,11 +31,11 @@ function toFontString(attributes) {
31
31
  var fontFamily_1 = fontFamilies[i].trim(); // Check if font already contains strings
32
32
 
33
33
  if (!/([\"\'])[^\'\"]+\1/.test(fontFamily_1) && genericFontFamilies.indexOf(fontFamily_1) < 0) {
34
- fontFamily_1 = "\"" + fontFamily_1 + "\"";
34
+ fontFamily_1 = "\"".concat(fontFamily_1, "\"");
35
35
  }
36
36
 
37
37
  fontFamilies[i] = fontFamily_1;
38
38
  }
39
39
 
40
- return fontStyle + " " + fontVariant + " " + fontWeight + " " + fontSizeString + " " + fontFamilies.join(',');
40
+ return "".concat(fontStyle, " ").concat(fontVariant, " ").concat(fontWeight, " ").concat(fontSizeString, " ").concat(fontFamilies.join(','));
41
41
  }