@antv/g 5.0.13 → 5.0.16

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 (244) hide show
  1. package/dist/index.umd.min.js +18 -2
  2. package/es/Canvas.d.ts +3 -0
  3. package/es/Canvas.js +9 -9
  4. package/es/camera/Camera.d.ts +3 -2
  5. package/es/camera/Camera.js +16 -8
  6. package/es/canvas-module.js +11 -17
  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 +4 -2
  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 +4 -3
  14. package/es/display-objects/DisplayObject.js +80 -49
  15. package/es/display-objects/Ellipse.d.ts +6 -3
  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 +14 -9
  19. package/es/display-objects/HTML.d.ts +6 -1
  20. package/es/display-objects/HTML.js +10 -5
  21. package/es/display-objects/Image.d.ts +12 -7
  22. package/es/display-objects/Image.js +10 -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 +8 -5
  32. package/es/display-objects/Rect.js +9 -4
  33. package/es/display-objects/Text.d.ts +9 -6
  34. package/es/display-objects/Text.js +15 -10
  35. package/es/dom/Animation.js +1 -1
  36. package/es/dom/AnimationTimeline.js +1 -2
  37. package/es/dom/CustomElementRegistry.js +12 -12
  38. package/es/dom/Document.d.ts +1 -0
  39. package/es/dom/Document.js +21 -1
  40. package/es/dom/Element.d.ts +14 -9
  41. package/es/dom/Element.js +41 -14
  42. package/es/dom/EventTarget.d.ts +2 -2
  43. package/es/dom/EventTarget.js +4 -3
  44. package/es/dom/KeyframeList.js +1 -1
  45. package/es/dom/MutationEvent.d.ts +15 -0
  46. package/es/dom/MutationEvent.js +29 -0
  47. package/es/dom/MutationObserver.d.ts +36 -0
  48. package/es/dom/MutationObserver.js +413 -0
  49. package/es/dom/MutationRecord.d.ts +14 -0
  50. package/es/dom/MutationRecord.js +31 -0
  51. package/es/dom/Node.d.ts +35 -3
  52. package/es/dom/Node.js +184 -17
  53. package/es/dom/index.d.ts +3 -0
  54. package/es/dom/index.js +3 -0
  55. package/es/dom/interfaces.d.ts +36 -8
  56. package/es/dom/interfaces.js +23 -5
  57. package/es/global-module.d.ts +4 -1
  58. package/es/global-module.js +38 -80
  59. package/es/index.d.ts +1 -0
  60. package/es/index.js +1 -0
  61. package/es/plugins/CullingPlugin.d.ts +0 -2
  62. package/es/plugins/CullingPlugin.js +3 -24
  63. package/es/plugins/DirtyCheckPlugin.js +2 -2
  64. package/es/plugins/FrustumCullingStrategy.d.ts +1 -0
  65. package/es/plugins/FrustumCullingStrategy.js +40 -33
  66. package/es/plugins/PrepareRendererPlugin.js +21 -5
  67. package/es/property-handlers/aabb.js +22 -24
  68. package/es/property-handlers/anchor.js +2 -1
  69. package/es/property-handlers/color.js +5 -2
  70. package/es/property-handlers/dimension.d.ts +15 -2
  71. package/es/property-handlers/dimension.js +77 -8
  72. package/es/property-handlers/index.d.ts +3 -0
  73. package/es/property-handlers/index.js +4 -1
  74. package/es/property-handlers/inherit.d.ts +6 -0
  75. package/es/property-handlers/inherit.js +25 -0
  76. package/es/property-handlers/interfaces.d.ts +2 -2
  77. package/es/property-handlers/lineDash.d.ts +6 -1
  78. package/es/property-handlers/lineDash.js +23 -4
  79. package/es/property-handlers/offsetDistance.js +2 -2
  80. package/es/property-handlers/path.d.ts +1 -1
  81. package/es/property-handlers/text.d.ts +2 -0
  82. package/es/property-handlers/text.js +3 -0
  83. package/es/property-handlers/textTransform.d.ts +6 -0
  84. package/es/property-handlers/textTransform.js +19 -0
  85. package/es/services/EventService.js +3 -5
  86. package/es/services/RenderingContext.d.ts +5 -8
  87. package/es/services/RenderingContext.js +6 -7
  88. package/es/services/RenderingService.js +2 -8
  89. package/es/services/SceneGraphSelector.d.ts +3 -2
  90. package/es/services/SceneGraphSelector.js +8 -4
  91. package/es/services/SceneGraphService.d.ts +7 -14
  92. package/es/services/SceneGraphService.js +14 -82
  93. package/es/services/aabb/CircleUpdater.d.ts +2 -2
  94. package/es/services/aabb/CircleUpdater.js +21 -11
  95. package/es/services/aabb/EllipseUpdater.d.ts +2 -2
  96. package/es/services/aabb/EllipseUpdater.js +28 -13
  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.d.ts +2 -2
  101. package/es/services/aabb/RectUpdater.js +33 -17
  102. package/es/services/aabb/TextUpdater.js +19 -10
  103. package/es/services/aabb/interfaces.d.ts +1 -1
  104. package/es/services/aabb/interfaces.js +1 -1
  105. package/es/services/text/index.js +19 -21
  106. package/es/shapes/AABB.d.ts +1 -0
  107. package/es/shapes/AABB.js +8 -0
  108. package/es/types.d.ts +48 -27
  109. package/es/types.js +50 -31
  110. package/es/utils/custom-easing.js +1 -1
  111. package/es/utils/event.js +5 -3
  112. package/es/utils/index.d.ts +1 -0
  113. package/es/utils/index.js +2 -1
  114. package/es/utils/interpolation.d.ts +1 -0
  115. package/es/utils/interpolation.js +41 -8
  116. package/es/utils/path.d.ts +1 -1
  117. package/es/utils/path.js +16 -16
  118. package/es/utils/raf.d.ts +1 -1
  119. package/es/utils/raf.js +0 -2
  120. package/es/utils/string.d.ts +1 -0
  121. package/es/utils/string.js +9 -0
  122. package/es/utils/text.js +3 -3
  123. package/lib/Canvas.d.ts +3 -0
  124. package/lib/Canvas.js +7 -7
  125. package/lib/camera/Camera.d.ts +3 -2
  126. package/lib/camera/Camera.js +20 -10
  127. package/lib/canvas-module.js +10 -15
  128. package/lib/components/Transform.d.ts +0 -1
  129. package/lib/components/Transform.js +0 -1
  130. package/lib/display-objects/Circle.d.ts +4 -2
  131. package/lib/display-objects/Circle.js +7 -2
  132. package/lib/display-objects/CustomElement.d.ts +3 -2
  133. package/lib/display-objects/CustomElement.js +9 -6
  134. package/lib/display-objects/DisplayObject.d.ts +4 -3
  135. package/lib/display-objects/DisplayObject.js +79 -46
  136. package/lib/display-objects/Ellipse.d.ts +6 -3
  137. package/lib/display-objects/Ellipse.js +7 -2
  138. package/lib/display-objects/Group.d.ts +18 -2
  139. package/lib/display-objects/Group.js +13 -9
  140. package/lib/display-objects/HTML.d.ts +6 -1
  141. package/lib/display-objects/HTML.js +9 -5
  142. package/lib/display-objects/Image.d.ts +12 -7
  143. package/lib/display-objects/Image.js +9 -2
  144. package/lib/display-objects/Line.d.ts +1 -1
  145. package/lib/display-objects/Line.js +11 -3
  146. package/lib/display-objects/Path.d.ts +3 -2
  147. package/lib/display-objects/Path.js +9 -4
  148. package/lib/display-objects/Polygon.d.ts +1 -1
  149. package/lib/display-objects/Polygon.js +8 -2
  150. package/lib/display-objects/Polyline.d.ts +1 -1
  151. package/lib/display-objects/Polyline.js +9 -4
  152. package/lib/display-objects/Rect.d.ts +8 -5
  153. package/lib/display-objects/Rect.js +8 -3
  154. package/lib/display-objects/Text.d.ts +9 -6
  155. package/lib/display-objects/Text.js +14 -9
  156. package/lib/dom/Animation.js +1 -1
  157. package/lib/dom/AnimationTimeline.js +1 -2
  158. package/lib/dom/CustomElementRegistry.js +11 -11
  159. package/lib/dom/Document.d.ts +1 -0
  160. package/lib/dom/Document.js +22 -1
  161. package/lib/dom/Element.d.ts +14 -9
  162. package/lib/dom/Element.js +43 -14
  163. package/lib/dom/EventTarget.d.ts +2 -2
  164. package/lib/dom/EventTarget.js +4 -3
  165. package/lib/dom/KeyframeList.js +1 -1
  166. package/lib/dom/MutationEvent.d.ts +15 -0
  167. package/lib/dom/MutationEvent.js +37 -0
  168. package/lib/dom/MutationObserver.d.ts +36 -0
  169. package/lib/dom/MutationObserver.js +424 -0
  170. package/lib/dom/MutationRecord.d.ts +14 -0
  171. package/lib/dom/MutationRecord.js +38 -0
  172. package/lib/dom/Node.d.ts +35 -3
  173. package/lib/dom/Node.js +185 -16
  174. package/lib/dom/index.d.ts +3 -0
  175. package/lib/dom/index.js +39 -0
  176. package/lib/dom/interfaces.d.ts +36 -8
  177. package/lib/dom/interfaces.js +23 -5
  178. package/lib/global-module.d.ts +4 -1
  179. package/lib/global-module.js +44 -76
  180. package/lib/index.d.ts +1 -0
  181. package/lib/index.js +3 -1
  182. package/lib/plugins/CullingPlugin.d.ts +0 -2
  183. package/lib/plugins/CullingPlugin.js +2 -23
  184. package/lib/plugins/DirtyCheckPlugin.js +1 -1
  185. package/lib/plugins/FrustumCullingStrategy.d.ts +1 -0
  186. package/lib/plugins/FrustumCullingStrategy.js +41 -33
  187. package/lib/plugins/PrepareRendererPlugin.js +24 -4
  188. package/lib/property-handlers/aabb.js +21 -23
  189. package/lib/property-handlers/anchor.js +3 -1
  190. package/lib/property-handlers/color.js +6 -3
  191. package/lib/property-handlers/dimension.d.ts +15 -2
  192. package/lib/property-handlers/dimension.js +80 -7
  193. package/lib/property-handlers/index.d.ts +3 -0
  194. package/lib/property-handlers/index.js +39 -0
  195. package/lib/property-handlers/inherit.d.ts +6 -0
  196. package/lib/property-handlers/inherit.js +34 -0
  197. package/lib/property-handlers/interfaces.d.ts +2 -2
  198. package/lib/property-handlers/lineDash.d.ts +6 -1
  199. package/lib/property-handlers/lineDash.js +25 -4
  200. package/lib/property-handlers/offsetDistance.js +1 -1
  201. package/lib/property-handlers/path.d.ts +1 -1
  202. package/lib/property-handlers/text.d.ts +2 -0
  203. package/lib/property-handlers/text.js +10 -0
  204. package/lib/property-handlers/textTransform.d.ts +6 -0
  205. package/lib/property-handlers/textTransform.js +27 -0
  206. package/lib/services/EventService.js +3 -5
  207. package/lib/services/RenderingContext.d.ts +5 -8
  208. package/lib/services/RenderingContext.js +8 -9
  209. package/lib/services/RenderingService.js +1 -7
  210. package/lib/services/SceneGraphSelector.d.ts +3 -2
  211. package/lib/services/SceneGraphSelector.js +10 -3
  212. package/lib/services/SceneGraphService.d.ts +7 -14
  213. package/lib/services/SceneGraphService.js +15 -82
  214. package/lib/services/aabb/CircleUpdater.d.ts +2 -2
  215. package/lib/services/aabb/CircleUpdater.js +20 -10
  216. package/lib/services/aabb/EllipseUpdater.d.ts +2 -2
  217. package/lib/services/aabb/EllipseUpdater.js +27 -12
  218. package/lib/services/aabb/LineUpdater.js +1 -1
  219. package/lib/services/aabb/PathUpdater.js +1 -1
  220. package/lib/services/aabb/PolylineUpdater.js +2 -2
  221. package/lib/services/aabb/RectUpdater.d.ts +2 -2
  222. package/lib/services/aabb/RectUpdater.js +32 -16
  223. package/lib/services/aabb/TextUpdater.js +18 -9
  224. package/lib/services/aabb/interfaces.d.ts +1 -1
  225. package/lib/services/aabb/interfaces.js +1 -1
  226. package/lib/services/text/index.js +19 -21
  227. package/lib/shapes/AABB.d.ts +1 -0
  228. package/lib/shapes/AABB.js +8 -0
  229. package/lib/types.d.ts +48 -27
  230. package/lib/types.js +56 -35
  231. package/lib/utils/custom-easing.js +1 -1
  232. package/lib/utils/event.js +5 -3
  233. package/lib/utils/index.d.ts +1 -0
  234. package/lib/utils/index.js +13 -0
  235. package/lib/utils/interpolation.d.ts +1 -0
  236. package/lib/utils/interpolation.js +43 -7
  237. package/lib/utils/path.d.ts +1 -1
  238. package/lib/utils/path.js +15 -15
  239. package/lib/utils/raf.d.ts +1 -1
  240. package/lib/utils/raf.js +0 -2
  241. package/lib/utils/string.d.ts +1 -0
  242. package/lib/utils/string.js +16 -0
  243. package/lib/utils/text.js +3 -3
  244. package/package.json +6 -4
package/es/utils/path.js CHANGED
@@ -6,7 +6,7 @@ import { __read, __spreadArray } from "tslib";
6
6
 
7
7
  import { Cubic as CubicUtil } from '@antv/g-math';
8
8
  import { vec3 } from 'gl-matrix';
9
- import { SHAPE } from '../types';
9
+ import { Shape } from '../types';
10
10
 
11
11
  function midPoint(a, b, t) {
12
12
  var ax = a[0];
@@ -214,7 +214,7 @@ function commandsToPathString(commands, localTransform, anchor, parsedStyle) {
214
214
  if (cur[0] === 'M' || cur[0] === 'L') {
215
215
  var p = vec3.fromValues(cur[1] - x, cur[2] - y, 0);
216
216
  vec3.transformMat4(p, p, localTransform);
217
- path = "" + cur[0] + p[0] + "," + p[1];
217
+ path = "".concat(cur[0]).concat(p[0], ",").concat(p[1]);
218
218
  } else if (cur[0] === 'Z') {
219
219
  path = cur[0];
220
220
  } else if (cur[0] === 'C') {
@@ -224,11 +224,11 @@ function commandsToPathString(commands, localTransform, anchor, parsedStyle) {
224
224
  vec3.transformMat4(p1, p1, localTransform);
225
225
  vec3.transformMat4(p2, p2, localTransform);
226
226
  vec3.transformMat4(p3, p3, localTransform);
227
- path = "" + cur[0] + p1[0] + "," + p1[1] + "," + p2[0] + "," + p2[1] + "," + p3[0] + "," + p3[1];
227
+ path = "".concat(cur[0]).concat(p1[0], ",").concat(p1[1], ",").concat(p2[0], ",").concat(p2[1], ",").concat(p3[0], ",").concat(p3[1]);
228
228
  } else if (cur[0] === 'A') {
229
229
  var c = vec3.fromValues(cur[6] - x, cur[7] - y, 0);
230
230
  vec3.transformMat4(c, c, localTransform);
231
- path = "" + cur[0] + cur[1] + "," + cur[2] + "," + cur[3] + "," + cur[4] + "," + cur[5] + "," + c[0] + "," + c[1];
231
+ 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]);
232
232
  }
233
233
 
234
234
  return prev += path;
@@ -278,7 +278,7 @@ export function convertToPath(object) {
278
278
  var commands = [];
279
279
 
280
280
  switch (object.nodeName) {
281
- case SHAPE.Line:
281
+ case Shape.LINE:
282
282
  var _a = object.parsedStyle,
283
283
  x1 = _a.x1,
284
284
  y1 = _a.y1,
@@ -287,10 +287,10 @@ export function convertToPath(object) {
287
287
  commands = lineToCommands(x1, y1, x2, y2);
288
288
  break;
289
289
 
290
- case SHAPE.Circle:
290
+ case Shape.CIRCLE:
291
291
  {
292
292
  var _b = object.parsedStyle,
293
- r = _b.r,
293
+ r = _b.rInPixels,
294
294
  _c = _b.x,
295
295
  x_1 = _c === void 0 ? 0 : _c,
296
296
  _d = _b.y,
@@ -299,11 +299,11 @@ export function convertToPath(object) {
299
299
  break;
300
300
  }
301
301
 
302
- case SHAPE.Ellipse:
302
+ case Shape.ELLIPSE:
303
303
  {
304
304
  var _e = object.parsedStyle,
305
- rx = _e.rx,
306
- ry = _e.ry,
305
+ rx = _e.rxInPixels,
306
+ ry = _e.ryInPixels,
307
307
  _f = _e.x,
308
308
  x_2 = _f === void 0 ? 0 : _f,
309
309
  _g = _e.y,
@@ -312,23 +312,23 @@ export function convertToPath(object) {
312
312
  break;
313
313
  }
314
314
 
315
- case SHAPE.Polyline:
316
- case SHAPE.Polygon:
315
+ case Shape.POLYLINE:
316
+ case Shape.POLYGON:
317
317
  var points = object.parsedStyle.points;
318
318
  commands = polygonToCommands(points.points);
319
319
  break;
320
320
 
321
- case SHAPE.Rect:
321
+ case Shape.RECT:
322
322
  var _h = object.parsedStyle,
323
- width = _h.width,
324
- height = _h.height,
323
+ width = _h.widthInPixels,
324
+ height = _h.heightInPixels,
325
325
  x = _h.x,
326
326
  y = _h.y,
327
327
  radius = _h.radius;
328
328
  commands = rectToCommands(width, height, x, y, radius);
329
329
  break;
330
330
 
331
- case SHAPE.Path:
331
+ case Shape.PATH:
332
332
  commands = object.parsedStyle.path.curve;
333
333
  break;
334
334
  }
package/es/utils/raf.d.ts CHANGED
@@ -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/es/utils/raf.js CHANGED
@@ -1,5 +1,3 @@
1
- // import { requestAnimationFrame, cancelAnimationFrame } from 'request-animation-frame-polyfill';
2
- // export { requestAnimationFrame, cancelAnimationFrame };
3
1
  import { requestAnimationFrame as rAF, cancelAnimationFrame as cancelRAF } from 'request-animation-frame-polyfill';
4
2
  var requestAF = rAF;
5
3
  var cancelAF = cancelRAF;
@@ -0,0 +1 @@
1
+ export declare function camelCase(str?: string): string;
@@ -0,0 +1,9 @@
1
+ export function camelCase(str) {
2
+ if (str === void 0) {
3
+ str = '';
4
+ }
5
+
6
+ return str.replace(/-([a-z])/g, function (g) {
7
+ return g[1].toUpperCase();
8
+ });
9
+ }
package/es/utils/text.js CHANGED
@@ -7,7 +7,7 @@ export function toFontString(attributes) {
7
7
  fontVariant = attributes.fontVariant,
8
8
  fontWeight = attributes.fontWeight; // build canvas api font setting from individual components. Convert a numeric this.fontSize to px
9
9
 
10
- var fontSizeString = isNumber(fontSize) ? fontSize + "px" : fontSize; // Clean-up fontFamily property by quoting each font name
10
+ var fontSizeString = isNumber(fontSize) ? "".concat(fontSize, "px") : "".concat(fontSize.value).concat(fontSize.unit || 'px'); // Clean-up fontFamily property by quoting each font name
11
11
  // this will support font names with spaces
12
12
  // @ts-ignore
13
13
 
@@ -22,11 +22,11 @@ export function toFontString(attributes) {
22
22
  var fontFamily_1 = fontFamilies[i].trim(); // Check if font already contains strings
23
23
 
24
24
  if (!/([\"\'])[^\'\"]+\1/.test(fontFamily_1) && genericFontFamilies.indexOf(fontFamily_1) < 0) {
25
- fontFamily_1 = "\"" + fontFamily_1 + "\"";
25
+ fontFamily_1 = "\"".concat(fontFamily_1, "\"");
26
26
  }
27
27
 
28
28
  fontFamilies[i] = fontFamily_1;
29
29
  }
30
30
 
31
- return fontStyle + " " + fontVariant + " " + fontWeight + " " + fontSizeString + " " + fontFamilies.join(',');
31
+ return "".concat(fontStyle, " ").concat(fontVariant, " ").concat(fontWeight, " ").concat(fontSizeString, " ").concat(fontFamilies.join(','));
32
32
  }
package/lib/Canvas.d.ts CHANGED
@@ -73,6 +73,9 @@ export declare class Canvas extends EventTarget implements ICanvas {
73
73
  total: number;
74
74
  rendered: number;
75
75
  };
76
+ /**
77
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Window/getComputedStyle
78
+ */
76
79
  getComputedStyle(node: DisplayObject): any;
77
80
  get ready(): Promise<any>;
78
81
  destroy(destroyScenegraph?: boolean): void;
package/lib/Canvas.js CHANGED
@@ -131,11 +131,6 @@ function (_super) {
131
131
  * the root node in scene graph
132
132
  */
133
133
  root: this.document.documentElement,
134
-
135
- /**
136
- * removed render bounds
137
- */
138
- removedRenderBoundsList: [],
139
134
  renderReasons: new Set(),
140
135
  force: false,
141
136
  dirty: false
@@ -154,8 +149,8 @@ function (_super) {
154
149
  var camera = new _camera.Camera().setPosition(width / 2, height / 2, 500).setFocalPoint(width / 2, height / 2, 0).setOrthographic(width / -2, width / 2, height / 2, height / -2, 0.1, 1000); // redraw when camera changed
155
150
 
156
151
  var context = this.container.get(_RenderingContext.RenderingContext);
157
- camera.on(_camera.CAMERA_EVENT.Updated, function () {
158
- context.renderReasons.add(_RenderingContext.RENDER_REASON.CameraChanged);
152
+ camera.on(_camera.CameraEvent.UPDATED, function () {
153
+ context.renderReasons.add(_RenderingContext.RenderReason.CAMERA_CHANGED);
159
154
  }); // bind camera
160
155
 
161
156
  this.container.register({
@@ -208,6 +203,10 @@ function (_super) {
208
203
  Canvas.prototype.getStats = function () {
209
204
  return this.getRenderingService().getStats();
210
205
  };
206
+ /**
207
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Window/getComputedStyle
208
+ */
209
+
211
210
 
212
211
  Canvas.prototype.getComputedStyle = function (node) {
213
212
  return node.parsedStyle;
@@ -390,6 +389,7 @@ function (_super) {
390
389
  };
391
390
 
392
391
  Canvas.prototype.loadCommonContainerModule = function () {
392
+ this.container.unload(_canvasModule.containerModule);
393
393
  this.container.load(_canvasModule.containerModule, true);
394
394
  };
395
395
 
@@ -18,8 +18,8 @@ export declare enum CAMERA_PROJECTION_MODE {
18
18
  ORTHOGRAPHIC = "ORTHOGRAPHIC",
19
19
  PERSPECTIVE = "PERSPECTIVE"
20
20
  }
21
- export declare const CAMERA_EVENT: {
22
- Updated: string;
21
+ export declare const CameraEvent: {
22
+ UPDATED: string;
23
23
  };
24
24
  /**
25
25
  * 参考「WebGL Insights - 23.Designing Cameras for WebGL Applications」,基于 Responsible Camera 思路设计
@@ -277,4 +277,5 @@ export declare class Camera extends EventEmitter {
277
277
  */
278
278
  private _getDistance;
279
279
  private _getOrthoMatrix;
280
+ private triggerUpdate;
280
281
  }
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.DefaultCamera = exports.Camera = exports.CAMERA_TYPE = exports.CAMERA_TRACKING_MODE = exports.CAMERA_PROJECTION_MODE = exports.CAMERA_EVENT = void 0;
6
+ exports.DefaultCamera = exports.CameraEvent = exports.Camera = exports.CAMERA_TYPE = exports.CAMERA_TRACKING_MODE = exports.CAMERA_PROJECTION_MODE = void 0;
7
7
 
8
8
  var _tslib = require("tslib");
9
9
 
@@ -48,10 +48,10 @@ exports.CAMERA_PROJECTION_MODE = CAMERA_PROJECTION_MODE;
48
48
  CAMERA_PROJECTION_MODE["PERSPECTIVE"] = "PERSPECTIVE";
49
49
  })(CAMERA_PROJECTION_MODE || (exports.CAMERA_PROJECTION_MODE = CAMERA_PROJECTION_MODE = {}));
50
50
 
51
- var CAMERA_EVENT = {
52
- Updated: 'updated'
51
+ var CameraEvent = {
52
+ UPDATED: 'updated'
53
53
  };
54
- exports.CAMERA_EVENT = CAMERA_EVENT;
54
+ exports.CameraEvent = CameraEvent;
55
55
  var DEG_2_RAD = Math.PI / 180;
56
56
  var RAD_2_DEG = 180 / Math.PI;
57
57
  /**
@@ -437,7 +437,7 @@ function (_super) {
437
437
 
438
438
  _glMatrix.mat4.invert(this.projectionMatrixInverse, this.projectionMatrix);
439
439
 
440
- this.emit(CAMERA_EVENT.Updated);
440
+ this.triggerUpdate();
441
441
  return this;
442
442
  };
443
443
 
@@ -476,7 +476,7 @@ function (_super) {
476
476
 
477
477
  this._getOrthoMatrix();
478
478
 
479
- this.emit(CAMERA_EVENT.Updated);
479
+ this.triggerUpdate();
480
480
  return this;
481
481
  };
482
482
  /**
@@ -741,7 +741,7 @@ function (_super) {
741
741
 
742
742
  this._setPosition(pos);
743
743
 
744
- this.emit(CAMERA_EVENT.Updated);
744
+ this.triggerUpdate();
745
745
  return this;
746
746
  };
747
747
  /**
@@ -772,7 +772,7 @@ function (_super) {
772
772
  _glMatrix.vec3.add(this.focalPoint, pos, this.distanceVector);
773
773
  }
774
774
 
775
- this.emit(CAMERA_EVENT.Updated);
775
+ this.triggerUpdate();
776
776
  return this;
777
777
  };
778
778
 
@@ -853,7 +853,7 @@ function (_super) {
853
853
 
854
854
  _this.computeMatrix();
855
855
 
856
- _this.emit(CAMERA_EVENT.Updated);
856
+ _this.triggerUpdate();
857
857
 
858
858
  var dist = _glMatrix.vec3.dist(interFocalPoint, destFocalPoint_1) + _glMatrix.vec3.dist(interPosition, destPosition_1);
859
859
 
@@ -895,7 +895,7 @@ function (_super) {
895
895
 
896
896
  this._getOrthoMatrix();
897
897
 
898
- this.emit(CAMERA_EVENT.Updated);
898
+ this.triggerUpdate();
899
899
  };
900
900
  /**
901
901
  * 计算相机矩阵
@@ -1045,6 +1045,16 @@ function (_super) {
1045
1045
  _glMatrix.mat4.fromRotationTranslationScaleOrigin(this.orthoMatrix, rotZ, _glMatrix.vec3.fromValues((this.rright - this.left) / 2 - position[0], (this.top - this.bottom) / 2 - position[1], 0), _glMatrix.vec3.fromValues(this.zoom, this.zoom, 1), position);
1046
1046
  };
1047
1047
 
1048
+ Camera.prototype.triggerUpdate = function () {
1049
+ // update frustum
1050
+ var viewMatrix = this.getViewTransform();
1051
+
1052
+ var vpMatrix = _glMatrix.mat4.multiply(_glMatrix.mat4.create(), this.getPerspective(), viewMatrix);
1053
+
1054
+ this.getFrustum().extractFromVPMatrix(vpMatrix);
1055
+ this.emit(CameraEvent.UPDATED);
1056
+ };
1057
+
1048
1058
  Camera.ProjectionMode = {
1049
1059
  ORTHOGRAPHIC: 'ORTHOGRAPHIC',
1050
1060
  PERSPECTIVE: 'PERSPECTIVE'
@@ -19,28 +19,23 @@ var _services = require("./services");
19
19
 
20
20
  var _EventPlugin = require("./plugins/EventPlugin");
21
21
 
22
- var containerModule = (0, _manaSyringe.Module)(function (register, context) {
23
- if (context.container.isBound(_services.RenderingService)) {
24
- // remove rendering plugins
25
- context.container.remove(_services.RenderingPluginContribution);
26
- context.container.remove(_services.RenderingService);
27
- context.container.remove(_FrustumCullingStrategy.FrustumCullingStrategy);
28
- } else {
29
- _manaSyringe.Contribution.register(register, _services.RenderingPluginContribution, {
30
- cache: false
31
- }); // culling plugin
22
+ // import { CSSCalculatorPlugin } from './plugins/CSSStyleCalculator';
23
+ var containerModule = (0, _manaSyringe.Module)(function (register) {
24
+ _manaSyringe.Contribution.register(register, _services.RenderingPluginContribution, {
25
+ cache: false
26
+ }); // culling plugin
32
27
 
33
28
 
34
- _manaSyringe.Contribution.register(register, _CullingPlugin.CullingStrategyContribution, {
35
- cache: false
36
- });
37
- } // register built-in rendering plugins
29
+ _manaSyringe.Contribution.register(register, _CullingPlugin.CullingStrategyContribution, {
30
+ cache: false
31
+ }); // register built-in rendering plugins
38
32
 
39
33
 
40
34
  register(_services.RenderingService);
41
35
  register(_services.EventService);
42
36
  register(_EventPlugin.EventPlugin);
43
- register(_PrepareRendererPlugin.PrepareRendererPlugin);
37
+ register(_PrepareRendererPlugin.PrepareRendererPlugin); // register(CSSCalculatorPlugin);
38
+
44
39
  register(_DirtyCheckPlugin.DirtyCheckPlugin);
45
40
  register(_CullingPlugin.CullingPlugin);
46
41
  register(_FrustumCullingStrategy.FrustumCullingStrategy);
@@ -7,7 +7,6 @@ export declare class Transform {
7
7
  dirtyFlag: boolean;
8
8
  localDirtyFlag: boolean;
9
9
  frozen: boolean;
10
- graphDepth: number;
11
10
  /**
12
11
  * local space RTS
13
12
  */
@@ -17,7 +17,6 @@ function () {
17
17
  this.dirtyFlag = false;
18
18
  this.localDirtyFlag = false;
19
19
  this.frozen = false;
20
- this.graphDepth = 0;
21
20
  /**
22
21
  * local space RTS
23
22
  */
@@ -1,12 +1,14 @@
1
1
  import type { DisplayObjectConfig } from '../dom/interfaces';
2
2
  import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
3
3
  import { DisplayObject } from './DisplayObject';
4
+ import type { ParsedElement } from '../property-handlers';
4
5
  export interface CircleStyleProps extends BaseStyleProps {
5
6
  r: number;
6
7
  }
7
8
  export interface ParsedCircleStyleProps extends ParsedBaseStyleProps {
8
- r: number;
9
+ r: ParsedElement;
10
+ rInPixels: number;
9
11
  }
10
12
  export declare class Circle extends DisplayObject<CircleStyleProps, ParsedCircleStyleProps> {
11
- constructor({ style, ...rest }: DisplayObjectConfig<CircleStyleProps>);
13
+ constructor({ style, ...rest }?: DisplayObjectConfig<CircleStyleProps>);
12
14
  }
@@ -17,13 +17,18 @@ function (_super) {
17
17
  (0, _tslib.__extends)(Circle, _super);
18
18
 
19
19
  function Circle(_a) {
20
+ if (_a === void 0) {
21
+ _a = {};
22
+ }
23
+
20
24
  var style = _a.style,
21
25
  rest = (0, _tslib.__rest)(_a, ["style"]);
22
26
  return _super.call(this, (0, _tslib.__assign)({
23
- type: _types.SHAPE.Circle,
27
+ type: _types.Shape.CIRCLE,
24
28
  style: (0, _tslib.__assign)({
25
29
  r: 0,
26
- anchor: [0.5, 0.5]
30
+ anchor: [0.5, 0.5],
31
+ lineWidth: 0
27
32
  }, style)
28
33
  }, rest)) || this;
29
34
  }
@@ -1,11 +1,12 @@
1
1
  import { DisplayObject } from './DisplayObject';
2
2
  import type { DisplayObjectConfig } from '../dom/interfaces';
3
+ import type { BaseStyleProps } from '../types';
3
4
  /**
4
5
  * shadow root
5
6
  * @see https://yuque.antfin-inc.com/antv/czqvg5/pgqipg
6
7
  */
7
- export declare abstract class CustomElement<CustomElementStyleProps> extends DisplayObject<CustomElementStyleProps> {
8
- constructor(config: DisplayObjectConfig<CustomElementStyleProps>);
8
+ export declare abstract class CustomElement<CustomElementStyleProps extends BaseStyleProps> extends DisplayObject<CustomElementStyleProps> {
9
+ constructor(config?: DisplayObjectConfig<CustomElementStyleProps>);
9
10
  /**
10
11
  * fired after element insert into DOM tree
11
12
  */
@@ -21,6 +21,10 @@ function (_super) {
21
21
  (0, _tslib.__extends)(CustomElement, _super); // private shadowNodes: DisplayObject[] = [];
22
22
 
23
23
  function CustomElement(config) {
24
+ if (config === void 0) {
25
+ config = {};
26
+ }
27
+
24
28
  var _this = _super.call(this, config) || this;
25
29
 
26
30
  _this.handleMounted = function (e) {
@@ -64,20 +68,19 @@ function (_super) {
64
68
  return;
65
69
  }
66
70
 
67
- var _a = e.detail,
68
- attributeName = _a.attributeName,
69
- oldValue = _a.oldValue,
70
- newValue = _a.newValue;
71
+ var attrName = e.attrName,
72
+ prevValue = e.prevValue,
73
+ newValue = e.newValue;
71
74
 
72
75
  if (_this.attributeChangedCallback) {
73
- _this.attributeChangedCallback(attributeName, oldValue, newValue);
76
+ _this.attributeChangedCallback(attrName, prevValue, newValue);
74
77
  }
75
78
  }; // this.addEventListener(ElementEvent.CHILD_INSERTED, this.handleChildInserted);
76
79
  // this.addEventListener(ElementEvent.CHILD_REMOVED, this.handleChildRemoved);
77
80
 
78
81
 
79
82
  if (_this.attributeChangedCallback) {
80
- _this.addEventListener(_interfaces.ElementEvent.ATTRIBUTE_CHANGED, _this.handleAttributeChanged);
83
+ _this.addEventListener(_interfaces.ElementEvent.ATTR_MODIFIED, _this.handleAttributeChanged);
81
84
  }
82
85
 
83
86
  if (_this.connectedCallback) {
@@ -35,14 +35,15 @@ export declare class DisplayObject<StyleProps extends BaseStyleProps = any, Pars
35
35
  destroy(): void;
36
36
  cloneNode(deep?: boolean): this;
37
37
  private initAttributes;
38
- setAttribute<Key extends keyof StyleProps>(attributeName: Key, value: StyleProps[Key], force?: boolean): void;
38
+ setAttribute<Key extends keyof StyleProps>(name: Key, value: StyleProps[Key], force?: boolean): void;
39
39
  /**
40
40
  * parse property, eg.
41
41
  * * fill: 'red' => [1, 0, 0, 1]
42
42
  * * translateX: '10px' => { unit: 'px', value: 10 }
43
+ * * fontSize: '2em' => { unit: 'px', value: 32 }
43
44
  */
44
- private parseStyleProperty;
45
- private updateStyleProperty;
45
+ parseStyleProperty<Key extends keyof ParsedStyleProps>(name: Key, value: ParsedStyleProps[Key]): void;
46
+ updateStyleProperty<Key extends keyof ParsedStyleProps>(name: Key, oldParsedValue: ParsedStyleProps[Key], newParsedValue: ParsedStyleProps[Key]): void;
46
47
  /**
47
48
  * called when attributes get changed or initialized
48
49
  */