@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
@@ -3,9 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.SceneGraphService = exports.DefaultSceneGraphService = void 0;
7
- exports.dirtifyToRoot = dirtifyToRoot;
8
6
  exports.sortByZIndex = sortByZIndex;
7
+ exports.dirtifyToRoot = dirtifyToRoot;
8
+ exports.DefaultSceneGraphService = exports.SceneGraphService = void 0;
9
9
 
10
10
  var _tslib = require("tslib");
11
11
 
@@ -21,6 +21,8 @@ var _SceneGraphSelector = require("./SceneGraphSelector");
21
21
 
22
22
  var _interfaces = require("../dom/interfaces");
23
23
 
24
+ var _MutationEvent = require("../dom/MutationEvent");
25
+
24
26
  function sortByZIndex(o1, o2) {
25
27
  var zIndex1 = Number(o1.style.zIndex);
26
28
  var zIndex2 = Number(o2.style.zIndex);
@@ -71,9 +73,7 @@ var SceneGraphService = 'SceneGraphService';
71
73
 
72
74
  exports.SceneGraphService = SceneGraphService;
73
75
 
74
- var DefaultSceneGraphService =
75
- /** @class */
76
- function () {
76
+ var DefaultSceneGraphService = function () {
77
77
  function DefaultSceneGraphService() {
78
78
  var _this = this;
79
79
  /**
@@ -366,9 +366,9 @@ function () {
366
366
 
367
367
  if (sortable) {
368
368
  sortable.dirty = true;
369
- }
369
+ } // this.updateGraphDepth(child);
370
+
370
371
 
371
- this.updateGraphDepth(child);
372
372
  var transform = child.transformable;
373
373
 
374
374
  if (transform) {
@@ -416,60 +416,6 @@ function () {
416
416
  child.parentNode = null;
417
417
  }
418
418
  };
419
- /**
420
- * compare two display objects by hierarchy-index and z-index
421
- *
422
- * use materialized path
423
- * @see https://stackoverflow.com/questions/31470730/comparing-tree-nodes
424
- */
425
- // sort = (object1: INode, object2: INode): number => {
426
- // if (!object1.parentNode) {
427
- // return -1;
428
- // }
429
- // if (!object2.parentNode) {
430
- // return 1;
431
- // }
432
- // const hierarchyDiff =
433
- // (object1 as Element).transformable.graphDepth - (object2 as Element).transformable.graphDepth;
434
- // let o1 = object1;
435
- // let o2 = object2;
436
- // if (hierarchyDiff < 0) {
437
- // o2 = object2.getAncestor(-hierarchyDiff)!;
438
- // if (o2 === o1) {
439
- // return -1;
440
- // }
441
- // } else if (hierarchyDiff > 0) {
442
- // o1 = object1.getAncestor(hierarchyDiff)!;
443
- // if (o2 === o1) {
444
- // return 1;
445
- // }
446
- // }
447
- // while (o1 && o2 && o1.parentNode !== o2.parentNode) {
448
- // o1 = o1.parentNode!;
449
- // o2 = o2.parentNode!;
450
- // }
451
- // const parent = o1.parentNode;
452
- // if (parent) {
453
- // const parentSortable = (parent as Element).sortable;
454
- // if (parentSortable) {
455
- // // no need to re-sort, use cached sorted children
456
- // if (!parentSortable.sorted) {
457
- // parentSortable.sorted = (parent.childNodes as IElement[]).slice();
458
- // }
459
- // if (parentSortable.dirty) {
460
- // parentSortable.sorted = (parent.childNodes as IElement[]).slice().sort(sortByZIndex);
461
- // // parentSortable.sorted.forEach(
462
- // // (child, i) => ((child as Element).sortable.lastSortedIndex = i),
463
- // // );
464
- // parentSortable.dirty = false;
465
- // }
466
- // // return (o1 as Element).sortable.lastSortedIndex - (o2 as Element).sortable.lastSortedIndex;
467
- // return parentSortable.sorted.indexOf(o1) - parentSortable.sorted.indexOf(o2);
468
- // }
469
- // }
470
- // return -1;
471
- // };
472
-
473
419
 
474
420
  DefaultSceneGraphService.prototype.getOrigin = function (element) {
475
421
  return element.transformable.origin;
@@ -668,7 +614,7 @@ function () {
668
614
 
669
615
  var bounds = this.getGeometryBounds(element, render);
670
616
 
671
- if (bounds) {
617
+ if (!_shapes.AABB.isEmpty(bounds)) {
672
618
  var aabb = new _shapes.AABB();
673
619
  aabb.setFromTransformedAABB(bounds, this.getWorldTransform(element));
674
620
  return aabb;
@@ -688,7 +634,7 @@ function () {
688
634
 
689
635
  var geometry = element.geometry;
690
636
  var bounds = render ? geometry.renderBounds : geometry.contentBounds || null;
691
- return bounds && new _shapes.AABB(bounds.center, bounds.halfExtents) || null;
637
+ return bounds && new _shapes.AABB(bounds.center, bounds.halfExtents) || new _shapes.AABB();
692
638
  };
693
639
  /**
694
640
  * account for children in world space
@@ -762,7 +708,7 @@ function () {
762
708
  renderable.boundsDirty = false;
763
709
  }
764
710
 
765
- return aabb || null;
711
+ return aabb || new _shapes.AABB();
766
712
  };
767
713
  /**
768
714
  * account for children in local space
@@ -779,7 +725,7 @@ function () {
779
725
 
780
726
  var bounds = this.getBounds(element);
781
727
 
782
- if (bounds) {
728
+ if (!_shapes.AABB.isEmpty(bounds)) {
783
729
  var localBounds = new _shapes.AABB();
784
730
  localBounds.setFromTransformedAABB(bounds, parentInvert);
785
731
  return localBounds;
@@ -795,7 +741,7 @@ function () {
795
741
  var aabb;
796
742
  var bounds = this.getGeometryBounds(element);
797
743
 
798
- if (bounds) {
744
+ if (!_shapes.AABB.isEmpty(bounds)) {
799
745
  aabb = new _shapes.AABB(); // apply transformation to aabb
800
746
 
801
747
  aabb.setFromTransformedAABB(bounds, this.getWorldTransform(element));
@@ -839,13 +785,14 @@ function () {
839
785
  renderable.boundsDirty = true;
840
786
  renderable.dirty = true;
841
787
  } // model matrix changed
788
+ // element.emit(ElementEvent.ATTR_MODIFIED, {
789
+ // attributeName: 'modelMatrix',
790
+ // oldValue: null,
791
+ // newValue: null,
792
+ // });
842
793
 
843
794
 
844
- element.emit(_interfaces.ElementEvent.ATTRIBUTE_CHANGED, {
845
- attributeName: 'modelMatrix',
846
- oldValue: null,
847
- newValue: null
848
- });
795
+ element.dispatchEvent(new _MutationEvent.MutationEvent(_interfaces.ElementEvent.ATTR_MODIFIED, element, null, null, 'modelMatrix', _MutationEvent.MutationEvent.MODIFICATION, null, null));
849
796
  }
850
797
  };
851
798
 
@@ -892,22 +839,6 @@ function () {
892
839
  }
893
840
  };
894
841
 
895
- DefaultSceneGraphService.prototype.updateGraphDepth = function (element) {
896
- var transform = element.transformable;
897
-
898
- if (element.parentNode) {
899
- transform.graphDepth = element.parentNode.transformable.graphDepth + 1;
900
- } else {
901
- transform.graphDepth = 0;
902
- }
903
-
904
- var children = element.childNodes;
905
-
906
- for (var i = 0; i < children.length; i++) {
907
- this.updateGraphDepth(children[i]);
908
- }
909
- };
910
-
911
842
  DefaultSceneGraphService.prototype.unfreezeParentToRoot = function (child) {
912
843
  var p = child.parentNode;
913
844
 
@@ -1,7 +1,7 @@
1
1
  import { GeometryAABBUpdater } from './interfaces';
2
- import type { ParsedCircleStyleProps } from '../../display-objects/Circle';
2
+ import type { Circle, ParsedCircleStyleProps } from '../../display-objects/Circle';
3
3
  export declare class CircleUpdater implements GeometryAABBUpdater<ParsedCircleStyleProps> {
4
- update(parsedStyle: ParsedCircleStyleProps): {
4
+ update(parsedStyle: ParsedCircleStyleProps, object: Circle): {
5
5
  width: number;
6
6
  height: number;
7
7
  x: number;
@@ -13,21 +13,29 @@ var _interfaces = require("./interfaces");
13
13
 
14
14
  var _types = require("../../types");
15
15
 
16
- var CircleUpdater =
17
- /** @class */
18
- function () {
16
+ var CircleUpdater = function () {
19
17
  function CircleUpdater() {}
20
18
 
21
- CircleUpdater.prototype.update = function (parsedStyle) {
22
- var _a = parsedStyle.r,
23
- r = _a === void 0 ? 0 : _a,
24
- _b = parsedStyle.x,
25
- x = _b === void 0 ? 0 : _b,
26
- _c = parsedStyle.y,
27
- y = _c === void 0 ? 0 : _c;
19
+ CircleUpdater.prototype.update = function (parsedStyle, object) {
20
+ var r = parsedStyle.r,
21
+ _a = parsedStyle.x,
22
+ x = _a === void 0 ? 0 : _a,
23
+ _b = parsedStyle.y,
24
+ y = _b === void 0 ? 0 : _b;
25
+ var unit = r.unit,
26
+ value = r.value;
27
+ var width = 0;
28
+ var height = 0; // absolute unit
29
+
30
+ if (unit === '' || unit === 'px') {
31
+ width = value * 2;
32
+ height = value * 2;
33
+ }
34
+
35
+ object.parsedStyle.rInPixels = width / 2;
28
36
  return {
29
- width: r * 2,
30
- height: r * 2,
37
+ width: width,
38
+ height: height,
31
39
  x: x,
32
40
  y: y
33
41
  };
@@ -36,7 +44,7 @@ function () {
36
44
  CircleUpdater = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)({
37
45
  token: {
38
46
  token: _interfaces.GeometryAABBUpdater,
39
- named: _types.SHAPE.Circle
47
+ named: _types.Shape.CIRCLE
40
48
  }
41
49
  })], CircleUpdater);
42
50
  return CircleUpdater;
@@ -1,7 +1,7 @@
1
1
  import { GeometryAABBUpdater } from './interfaces';
2
- import type { ParsedEllipseStyleProps } from '../../display-objects/Ellipse';
2
+ import type { Ellipse, ParsedEllipseStyleProps } from '../../display-objects/Ellipse';
3
3
  export declare class EllipseUpdater implements GeometryAABBUpdater<ParsedEllipseStyleProps> {
4
- update(parsedStyle: ParsedEllipseStyleProps): {
4
+ update(parsedStyle: ParsedEllipseStyleProps, object: Ellipse): {
5
5
  width: number;
6
6
  height: number;
7
7
  x: number;
@@ -13,23 +13,36 @@ var _interfaces = require("./interfaces");
13
13
 
14
14
  var _types = require("../../types");
15
15
 
16
- var EllipseUpdater =
17
- /** @class */
18
- function () {
16
+ var EllipseUpdater = function () {
19
17
  function EllipseUpdater() {}
20
18
 
21
- EllipseUpdater.prototype.update = function (parsedStyle) {
22
- var _a = parsedStyle.rx,
23
- rx = _a === void 0 ? 0 : _a,
24
- _b = parsedStyle.ry,
25
- ry = _b === void 0 ? 0 : _b,
26
- _c = parsedStyle.x,
27
- x = _c === void 0 ? 0 : _c,
28
- _d = parsedStyle.y,
29
- y = _d === void 0 ? 0 : _d;
19
+ EllipseUpdater.prototype.update = function (parsedStyle, object) {
20
+ var rx = parsedStyle.rx,
21
+ ry = parsedStyle.ry,
22
+ _a = parsedStyle.x,
23
+ x = _a === void 0 ? 0 : _a,
24
+ _b = parsedStyle.y,
25
+ y = _b === void 0 ? 0 : _b;
26
+ var rxUnit = rx.unit,
27
+ rxValue = rx.value;
28
+ var ryUnit = ry.unit,
29
+ ryValue = ry.value;
30
+ var width = 0;
31
+ var height = 0;
32
+
33
+ if (rxUnit === '' || rxUnit === 'px') {
34
+ width = rxValue * 2;
35
+ }
36
+
37
+ if (ryUnit === '' || ryUnit === 'px') {
38
+ height = ryValue * 2;
39
+ }
40
+
41
+ object.parsedStyle.rxInPixels = width / 2;
42
+ object.parsedStyle.ryInPixels = height / 2;
30
43
  return {
31
- width: rx * 2,
32
- height: ry * 2,
44
+ width: width,
45
+ height: height,
33
46
  x: x,
34
47
  y: y
35
48
  };
@@ -38,7 +51,7 @@ function () {
38
51
  EllipseUpdater = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)({
39
52
  token: {
40
53
  token: _interfaces.GeometryAABBUpdater,
41
- named: _types.SHAPE.Ellipse
54
+ named: _types.Shape.ELLIPSE
42
55
  }
43
56
  })], EllipseUpdater);
44
57
  return EllipseUpdater;
@@ -13,9 +13,7 @@ var _interfaces = require("./interfaces");
13
13
 
14
14
  var _types = require("../../types");
15
15
 
16
- var LineUpdater =
17
- /** @class */
18
- function () {
16
+ var LineUpdater = function () {
19
17
  function LineUpdater() {}
20
18
 
21
19
  LineUpdater.prototype.update = function (parsedStyle) {
@@ -40,7 +38,7 @@ function () {
40
38
  LineUpdater = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)({
41
39
  token: {
42
40
  token: _interfaces.GeometryAABBUpdater,
43
- named: _types.SHAPE.Line
41
+ named: _types.Shape.LINE
44
42
  }
45
43
  })], LineUpdater);
46
44
  return LineUpdater;
@@ -13,9 +13,7 @@ var _interfaces = require("./interfaces");
13
13
 
14
14
  var _types = require("../../types");
15
15
 
16
- var PathUpdater =
17
- /** @class */
18
- function () {
16
+ var PathUpdater = function () {
19
17
  function PathUpdater() {}
20
18
 
21
19
  PathUpdater.prototype.update = function (parsedStyle) {
@@ -36,7 +34,7 @@ function () {
36
34
  PathUpdater = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)({
37
35
  token: {
38
36
  token: _interfaces.GeometryAABBUpdater,
39
- named: _types.SHAPE.Path
37
+ named: _types.Shape.PATH
40
38
  }
41
39
  })], PathUpdater);
42
40
  return PathUpdater;
@@ -13,9 +13,7 @@ var _interfaces = require("./interfaces");
13
13
 
14
14
  var _types = require("../../types");
15
15
 
16
- var PolylineUpdater =
17
- /** @class */
18
- function () {
16
+ var PolylineUpdater = function () {
19
17
  function PolylineUpdater() {}
20
18
 
21
19
  PolylineUpdater.prototype.update = function (parsedStyle) {
@@ -46,10 +44,10 @@ function () {
46
44
  PolylineUpdater = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)({
47
45
  token: [{
48
46
  token: _interfaces.GeometryAABBUpdater,
49
- named: _types.SHAPE.Polyline
47
+ named: _types.Shape.POLYLINE
50
48
  }, {
51
49
  token: _interfaces.GeometryAABBUpdater,
52
- named: _types.SHAPE.Polygon
50
+ named: _types.Shape.POLYGON
53
51
  }]
54
52
  })], PolylineUpdater);
55
53
  return PolylineUpdater;
@@ -1,7 +1,7 @@
1
1
  import { GeometryAABBUpdater } from './interfaces';
2
- import type { ParsedImageStyleProps } from '../../display-objects/Image';
2
+ import type { Image, ParsedImageStyleProps } from '../../display-objects/Image';
3
3
  export declare class RectUpdater implements GeometryAABBUpdater<ParsedImageStyleProps> {
4
- update(attributes: ParsedImageStyleProps): {
4
+ update(parsedStyle: ParsedImageStyleProps, object: Image): {
5
5
  width: number;
6
6
  height: number;
7
7
  x: number;
@@ -15,37 +15,48 @@ var _interfaces = require("./interfaces");
15
15
 
16
16
  var _types = require("../../types");
17
17
 
18
- var RectUpdater =
19
- /** @class */
20
- function () {
18
+ var RectUpdater = function () {
21
19
  function RectUpdater() {}
22
20
 
23
- RectUpdater.prototype.update = function (attributes) {
24
- var img = attributes.img,
25
- _a = attributes.x,
21
+ RectUpdater.prototype.update = function (parsedStyle, object) {
22
+ var img = parsedStyle.img,
23
+ _a = parsedStyle.x,
26
24
  x = _a === void 0 ? 0 : _a,
27
- _b = attributes.y,
25
+ _b = parsedStyle.y,
28
26
  y = _b === void 0 ? 0 : _b,
29
- _c = attributes.width,
30
- width = _c === void 0 ? 0 : _c,
31
- _d = attributes.height,
32
- height = _d === void 0 ? 0 : _d;
33
- var contentWidth;
34
- var contentHeight; // resize with HTMLImageElement's size
27
+ width = parsedStyle.width,
28
+ height = parsedStyle.height;
29
+ var contentWidth = 0;
30
+ var contentHeight = 0;
31
+ var widthUnit = width.unit,
32
+ widthValue = width.value;
33
+ var heightUnit = height.unit,
34
+ heightValue = height.value;
35
+
36
+ if (widthUnit === '' || widthUnit === 'px') {
37
+ contentWidth = widthValue;
38
+ }
39
+
40
+ if (heightUnit === '' || heightUnit === 'px') {
41
+ contentHeight = heightValue;
42
+ } // resize with HTMLImageElement's size
43
+
35
44
 
36
45
  if (img && !(0, _util.isString)(img)) {
37
- if (!attributes.width) {
46
+ if (!contentWidth) {
38
47
  contentWidth = img.width;
39
48
  }
40
49
 
41
- if (!attributes.height) {
50
+ if (!contentHeight) {
42
51
  contentHeight = img.height;
43
52
  }
44
53
  }
45
54
 
55
+ object.parsedStyle.widthInPixels = contentWidth;
56
+ object.parsedStyle.heightInPixels = contentHeight;
46
57
  return {
47
- width: contentWidth || width,
48
- height: contentHeight || height,
58
+ width: contentWidth,
59
+ height: contentHeight,
49
60
  x: x,
50
61
  y: y
51
62
  };
@@ -54,13 +65,13 @@ function () {
54
65
  RectUpdater = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)({
55
66
  token: [{
56
67
  token: _interfaces.GeometryAABBUpdater,
57
- named: _types.SHAPE.Rect
68
+ named: _types.Shape.RECT
58
69
  }, {
59
70
  token: _interfaces.GeometryAABBUpdater,
60
- named: _types.SHAPE.Image
71
+ named: _types.Shape.IMAGE
61
72
  }, {
62
73
  token: _interfaces.GeometryAABBUpdater,
63
- named: _types.SHAPE.Group
74
+ named: _types.Shape.GROUP
64
75
  }]
65
76
  })], RectUpdater);
66
77
  return RectUpdater;
@@ -17,22 +17,21 @@ var _text = require("../text");
17
17
 
18
18
  var _types = require("../../types");
19
19
 
20
- var TextUpdater =
21
- /** @class */
22
- function () {
20
+ var TextUpdater = function () {
23
21
  function TextUpdater() {}
24
22
 
25
23
  TextUpdater.prototype.update = function (parsedStyle) {
26
24
  var _a = parsedStyle.text,
27
25
  text = _a === void 0 ? '' : _a,
28
26
  textAlign = parsedStyle.textAlign,
29
- _b = parsedStyle.lineWidth,
30
- lineWidth = _b === void 0 ? 0 : _b,
27
+ lineWidth = parsedStyle.lineWidth,
31
28
  textBaseline = parsedStyle.textBaseline,
32
- _c = parsedStyle.x,
33
- x = _c === void 0 ? 0 : _c,
34
- _d = parsedStyle.y,
35
- y = _d === void 0 ? 0 : _d;
29
+ _b = parsedStyle.x,
30
+ x = _b === void 0 ? 0 : _b,
31
+ _c = parsedStyle.y,
32
+ y = _c === void 0 ? 0 : _c,
33
+ dx = parsedStyle.dx,
34
+ dy = parsedStyle.dy;
36
35
  var metrics = this.textService.measureText(text, parsedStyle);
37
36
  parsedStyle.metrics = metrics;
38
37
  var width = metrics.width,
@@ -47,10 +46,10 @@ function () {
47
46
  var lineXOffset = 0;
48
47
 
49
48
  if (textAlign === 'center') {
50
- lineXOffset = lineWidth / 2;
49
+ lineXOffset = lineWidth.value / 2;
51
50
  anchor = [0.5, 1];
52
51
  } else if (textAlign === 'right' || textAlign === 'end') {
53
- lineXOffset = lineWidth;
52
+ lineXOffset = lineWidth.value;
54
53
  anchor = [1, 1];
55
54
  } // update anchor
56
55
 
@@ -70,6 +69,14 @@ function () {
70
69
  } // TODO: ideographic & bottom
71
70
 
72
71
 
72
+ if (dx && dx.unit === 'px') {
73
+ lineXOffset += dx.value;
74
+ }
75
+
76
+ if (dy && dy.unit === 'px') {
77
+ lineYOffset += dy.value;
78
+ }
79
+
73
80
  return {
74
81
  width: halfExtents[0] * 2,
75
82
  height: halfExtents[1] * 2,
@@ -84,7 +91,7 @@ function () {
84
91
  TextUpdater = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)({
85
92
  token: {
86
93
  token: _interfaces.GeometryAABBUpdater,
87
- named: _types.SHAPE.Text
94
+ named: _types.Shape.TEXT
88
95
  }
89
96
  })], TextUpdater);
90
97
  return TextUpdater;
@@ -24,34 +24,34 @@ Object.defineProperty(exports, "EllipseUpdater", {
24
24
  return _EllipseUpdater.EllipseUpdater;
25
25
  }
26
26
  });
27
- Object.defineProperty(exports, "LineUpdater", {
27
+ Object.defineProperty(exports, "RectUpdater", {
28
28
  enumerable: true,
29
29
  get: function get() {
30
- return _LineUpdater.LineUpdater;
30
+ return _RectUpdater.RectUpdater;
31
31
  }
32
32
  });
33
- Object.defineProperty(exports, "PathUpdater", {
33
+ Object.defineProperty(exports, "TextUpdater", {
34
34
  enumerable: true,
35
35
  get: function get() {
36
- return _PathUpdater.PathUpdater;
36
+ return _TextUpdater.TextUpdater;
37
37
  }
38
38
  });
39
- Object.defineProperty(exports, "PolylineUpdater", {
39
+ Object.defineProperty(exports, "LineUpdater", {
40
40
  enumerable: true,
41
41
  get: function get() {
42
- return _PolylineUpdater.PolylineUpdater;
42
+ return _LineUpdater.LineUpdater;
43
43
  }
44
44
  });
45
- Object.defineProperty(exports, "RectUpdater", {
45
+ Object.defineProperty(exports, "PolylineUpdater", {
46
46
  enumerable: true,
47
47
  get: function get() {
48
- return _RectUpdater.RectUpdater;
48
+ return _PolylineUpdater.PolylineUpdater;
49
49
  }
50
50
  });
51
- Object.defineProperty(exports, "TextUpdater", {
51
+ Object.defineProperty(exports, "PathUpdater", {
52
52
  enumerable: true,
53
53
  get: function get() {
54
- return _TextUpdater.TextUpdater;
54
+ return _PathUpdater.PathUpdater;
55
55
  }
56
56
  });
57
57
 
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.GeometryUpdaterFactory = exports.GeometryAABBUpdater = void 0;
6
+ exports.GeometryAABBUpdater = exports.GeometryUpdaterFactory = void 0;
7
7
  var GeometryUpdaterFactory = 'GeometryUpdaterFactory';
8
8
  exports.GeometryUpdaterFactory = GeometryUpdaterFactory;
9
9
  var GeometryAABBUpdater = 'GeometryAABBUpdater';
@@ -9,9 +9,7 @@ var _tslib = require("tslib");
9
9
 
10
10
  var _manaSyringe = require("mana-syringe");
11
11
 
12
- var OffscreenCanvasCreator =
13
- /** @class */
14
- function () {
12
+ var OffscreenCanvasCreator = function () {
15
13
  function OffscreenCanvasCreator() {}
16
14
 
17
15
  OffscreenCanvasCreator.prototype.getOrCreateCanvas = function () {