@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
@@ -10,14 +10,11 @@ var _glMatrix = require("gl-matrix");
10
10
  /**
11
11
  * do RTS transformation for 2D/3D
12
12
  */
13
- var Transform =
14
- /** @class */
15
- function () {
13
+ var Transform = function () {
16
14
  function Transform() {
17
15
  this.dirtyFlag = false;
18
16
  this.localDirtyFlag = false;
19
17
  this.frozen = false;
20
- this.graphDepth = 0;
21
18
  /**
22
19
  * local space RTS
23
20
  */
@@ -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
  }
@@ -11,19 +11,22 @@ var _types = require("../types");
11
11
 
12
12
  var _DisplayObject = require("./DisplayObject");
13
13
 
14
- var Circle =
15
- /** @class */
16
- function (_super) {
14
+ var Circle = function (_super) {
17
15
  (0, _tslib.__extends)(Circle, _super);
18
16
 
19
17
  function Circle(_a) {
18
+ if (_a === void 0) {
19
+ _a = {};
20
+ }
21
+
20
22
  var style = _a.style,
21
23
  rest = (0, _tslib.__rest)(_a, ["style"]);
22
24
  return _super.call(this, (0, _tslib.__assign)({
23
- type: _types.SHAPE.Circle,
25
+ type: _types.Shape.CIRCLE,
24
26
  style: (0, _tslib.__assign)({
25
27
  r: 0,
26
- anchor: [0.5, 0.5]
28
+ anchor: [0.5, 0.5],
29
+ lineWidth: 0
27
30
  }, style)
28
31
  }, rest)) || this;
29
32
  }
@@ -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
  */
@@ -15,12 +15,14 @@ var _interfaces = require("../dom/interfaces");
15
15
  * shadow root
16
16
  * @see https://yuque.antfin-inc.com/antv/czqvg5/pgqipg
17
17
  */
18
- var CustomElement =
19
- /** @class */
20
- function (_super) {
18
+ var CustomElement = function (_super) {
21
19
  (0, _tslib.__extends)(CustomElement, _super); // private shadowNodes: DisplayObject[] = [];
22
20
 
23
21
  function CustomElement(config) {
22
+ if (config === void 0) {
23
+ config = {};
24
+ }
25
+
24
26
  var _this = _super.call(this, config) || this;
25
27
 
26
28
  _this.handleMounted = function (e) {
@@ -64,20 +66,19 @@ function (_super) {
64
66
  return;
65
67
  }
66
68
 
67
- var _a = e.detail,
68
- attributeName = _a.attributeName,
69
- oldValue = _a.oldValue,
70
- newValue = _a.newValue;
69
+ var attrName = e.attrName,
70
+ prevValue = e.prevValue,
71
+ newValue = e.newValue;
71
72
 
72
73
  if (_this.attributeChangedCallback) {
73
- _this.attributeChangedCallback(attributeName, oldValue, newValue);
74
+ _this.attributeChangedCallback(attrName, prevValue, newValue);
74
75
  }
75
76
  }; // this.addEventListener(ElementEvent.CHILD_INSERTED, this.handleChildInserted);
76
77
  // this.addEventListener(ElementEvent.CHILD_REMOVED, this.handleChildRemoved);
77
78
 
78
79
 
79
80
  if (_this.attributeChangedCallback) {
80
- _this.addEventListener(_interfaces.ElementEvent.ATTRIBUTE_CHANGED, _this.handleAttributeChanged);
81
+ _this.addEventListener(_interfaces.ElementEvent.ATTR_MODIFIED, _this.handleAttributeChanged);
81
82
  }
82
83
 
83
84
  if (_this.connectedCallback) {
@@ -35,18 +35,24 @@ 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
  */
49
50
  private changeAttribute;
51
+ /**
52
+ * returns different values than getBoundingClientRect(), as the latter returns value relative to the viewport
53
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGGraphicsElement/getBBox
54
+ */
55
+ getBBox(): DOMRect;
50
56
  setOrigin(position: vec3 | vec2 | number, y?: number, z?: number): this;
51
57
  getOrigin(): vec3;
52
58
  /**
@@ -27,8 +27,10 @@ var _globalModule = require("../global-module");
27
27
 
28
28
  var _services = require("../services");
29
29
 
30
- // import type { StylePropertyParser, StylePropertyUpdater } from '../property-handlers';
31
- // import { StylePropertyParserFactory, StylePropertyUpdaterFactory } from '../property-handlers';
30
+ var _MutationEvent = require("../dom/MutationEvent");
31
+
32
+ var _shapes = require("../shapes");
33
+
32
34
  var DEFAULT_STYLE_PROPS = {
33
35
  anchor: [0, 0, 0],
34
36
  origin: [0, 0, 0],
@@ -57,15 +59,8 @@ var DEFAULT_STYLE_PROPS = {
57
59
  * * attributeChanged
58
60
  */
59
61
 
60
- var DisplayObject =
61
- /** @class */
62
- function (_super) {
63
- (0, _tslib.__extends)(DisplayObject, _super); // stylePropertyUpdaterFactory = globalContainer.get<
64
- // <Key extends keyof StyleProps>(stylePropertyName: Key) => StylePropertyUpdater<any>[]
65
- // >(StylePropertyUpdaterFactory);
66
- // stylePropertyParserFactory = globalContainer.get<
67
- // <Key extends keyof ParsedStyleProps>(stylePropertyName: Key) => StylePropertyParser<any, any>
68
- // >(StylePropertyParserFactory);
62
+ var DisplayObject = function (_super) {
63
+ (0, _tslib.__extends)(DisplayObject, _super);
69
64
 
70
65
  function DisplayObject(config) {
71
66
  var _a, _b, _c;
@@ -85,17 +80,38 @@ function (_super) {
85
80
 
86
81
  _this.id = _this.config.id || '';
87
82
  _this.name = _this.config.name || '';
88
- _this.className = _this.config.className || '';
83
+
84
+ if (_this.config.className || _this.config.class) {
85
+ _this.className = _this.config.className || _this.config.class;
86
+ }
87
+
89
88
  _this.interactive = (_b = _this.config.interactive) !== null && _b !== void 0 ? _b : true;
90
- _this.nodeName = _this.config.type || _types.SHAPE.Group; // compatible with G 3.0
89
+ _this.nodeName = _this.config.type || _types.Shape.GROUP; // compatible with G 3.0
91
90
 
92
91
  _this.config.style = (0, _tslib.__assign)((0, _tslib.__assign)((0, _tslib.__assign)((0, _tslib.__assign)({}, DEFAULT_STYLE_PROPS), {
93
92
  zIndex: (_c = _this.config.zIndex) !== null && _c !== void 0 ? _c : 0,
94
93
  visibility: _this.config.visible === false ? 'hidden' : 'visible'
95
94
  }), _this.config.style), _this.config.attrs);
96
- _this.style = new Proxy(_this.attributes, {
97
- get: function get(_, prop) {
98
- return _this.getAttribute(prop);
95
+ _this.style = new Proxy((0, _tslib.__assign)((0, _tslib.__assign)({}, _this.attributes), {
96
+ setProperty: function setProperty(propertyName, value) {
97
+ _this.setAttribute(propertyName, value);
98
+ },
99
+ getPropertyValue: function getPropertyValue(propertyName) {
100
+ return _this.getAttribute(propertyName);
101
+ },
102
+ removeProperty: function removeProperty(propertyName) {
103
+ _this.removeAttribute(propertyName);
104
+ },
105
+ item: function item() {
106
+ return '';
107
+ }
108
+ }), {
109
+ get: function get(target, name) {
110
+ if (name in target) {
111
+ return target[name];
112
+ }
113
+
114
+ return _this.getAttribute(name);
99
115
  },
100
116
  set: function set(_, prop, value) {
101
117
  _this.setAttribute(prop, value);
@@ -132,7 +148,7 @@ function (_super) {
132
148
  name: this.name,
133
149
  className: this.name,
134
150
  interactive: this.interactive,
135
- style: (0, _tslib.__assign)({}, this.style)
151
+ style: (0, _tslib.__assign)({}, this.attributes)
136
152
  });
137
153
 
138
154
  if (deep) {
@@ -155,51 +171,62 @@ function (_super) {
155
171
  var renderable = this.renderable; // parse attributes first
156
172
 
157
173
  for (var attributeName in attributes) {
158
- var value = attributes[attributeName];
159
- this.attributes[attributeName] = value; // @ts-ignore
174
+ var _a = (0, _tslib.__read)((0, _utils.formatAttribute)(attributeName, attributes[attributeName]), 2),
175
+ name_1 = _a[0],
176
+ value = _a[1];
177
+
178
+ this.attributes[name_1] = value; // @ts-ignore
160
179
 
161
- this.parseStyleProperty(attributeName, value);
180
+ this.parseStyleProperty(name_1, value);
162
181
  }
163
182
 
164
183
  var priorities = {
165
- x: 1000,
166
- y: 1000
184
+ x: Infinity,
185
+ y: Infinity
167
186
  }; // update x, y at last
168
187
 
169
188
  var sortedNames = Object.keys(attributes).sort(function (a, b) {
170
189
  return (priorities[a] || 0) - (priorities[b] || 0);
171
190
  });
172
191
  sortedNames.forEach(function (attributeName) {
173
- // @ts-ignore
174
- _this.updateStyleProperty(attributeName, undefined, _this.parsedStyle[attributeName]);
192
+ var _a = (0, _tslib.__read)((0, _utils.formatAttribute)(attributeName, ''), 1),
193
+ name = _a[0]; // @ts-ignore
194
+
195
+
196
+ _this.updateStyleProperty(name, undefined, _this.parsedStyle[name]);
175
197
  }); // redraw at next frame
176
198
 
177
199
  renderable.dirty = true;
178
200
  };
179
201
 
180
- DisplayObject.prototype.setAttribute = function (attributeName, value, force) {
202
+ DisplayObject.prototype.setAttribute = function (name, value, force) {
181
203
  if (force === void 0) {
182
204
  force = false;
183
205
  }
184
206
 
185
- if (force || !(0, _util.isEqual)(value, this.attributes[attributeName]) || attributeName === 'transformOrigin' || attributeName === 'visibility' // will affect children
207
+ var _a = (0, _tslib.__read)((0, _utils.formatAttribute)(name, value), 2),
208
+ attributeName = _a[0],
209
+ attributeValue = _a[1];
210
+
211
+ if (force || !(0, _util.isEqual)(attributeValue, this.attributes[attributeName]) || attributeName === 'transformOrigin' || attributeName === 'visibility' // will affect children
186
212
  ) {
187
213
  if (attributeName === 'visibility') {
188
214
  // set value cascade
189
215
  this.forEach(function (object) {
190
- object.changeAttribute(attributeName, value);
216
+ object.changeAttribute(attributeName, attributeValue);
191
217
  });
192
218
  } else {
193
- this.changeAttribute(attributeName, value);
219
+ this.changeAttribute(attributeName, attributeValue);
194
220
  }
195
221
 
196
- _super.prototype.setAttribute.call(this, attributeName, value);
222
+ _super.prototype.setAttribute.call(this, attributeName, attributeValue);
197
223
  }
198
224
  };
199
225
  /**
200
226
  * parse property, eg.
201
227
  * * fill: 'red' => [1, 0, 0, 1]
202
228
  * * translateX: '10px' => { unit: 'px', value: 10 }
229
+ * * fontSize: '2em' => { unit: 'px', value: 32 }
203
230
  */
204
231
 
205
232
 
@@ -209,16 +236,14 @@ function (_super) {
209
236
 
210
237
  if (stylePropertyParser) {
211
238
  // @ts-ignore
212
- this.parsedStyle[name] = stylePropertyParser(value, this);
239
+ this.parsedStyle[name] = stylePropertyParser(value, this, name);
213
240
  } else {
214
241
  this.parsedStyle[name] = value;
215
242
  }
216
243
  };
217
244
 
218
245
  DisplayObject.prototype.updateStyleProperty = function (name, oldParsedValue, newParsedValue) {
219
- var _this = this; // update property, which may cause AABB re-calc
220
- // @ts-ignore
221
- // const stylePropertyUpdaters = this.stylePropertyUpdaterFactory(name);
246
+ var _this = this; // @ts-ignore
222
247
 
223
248
 
224
249
  var stylePropertyUpdaters = _globalModule.stylePropertyUpdaterFactory[name];
@@ -226,7 +251,7 @@ function (_super) {
226
251
  if (stylePropertyUpdaters) {
227
252
  stylePropertyUpdaters.forEach(function (updater) {
228
253
  // @ts-ignore
229
- updater(oldParsedValue, newParsedValue, _this, _this.sceneGraphService);
254
+ updater(oldParsedValue, newParsedValue, _this, _this.sceneGraphService, name);
230
255
  });
231
256
  }
232
257
  };
@@ -247,28 +272,54 @@ function (_super) {
247
272
 
248
273
  this.parseStyleProperty(name, value); // @ts-ignore
249
274
 
250
- this.updateStyleProperty(name, oldParsedValue, this.parsedStyle[name]); // inform clip path targets
275
+ var newParsedValue = this.parsedStyle[name]; // @ts-ignore
276
+
277
+ this.updateStyleProperty(name, oldParsedValue, newParsedValue); // inform clip path targets
251
278
 
252
279
  if (this.attributes.clipPathTargets && this.attributes.clipPathTargets.length) {
253
280
  this.attributes.clipPathTargets.forEach(function (target) {
254
- (0, _services.dirtifyToRoot)(target);
255
- target.emit(_interfaces.ElementEvent.ATTRIBUTE_CHANGED, {
256
- attributeName: 'clipPath',
257
- oldValue: _this,
258
- newValue: _this
259
- });
281
+ (0, _services.dirtifyToRoot)(target); // target.emit(ElementEvent.ATTR_MODIFIED, {
282
+ // attributeName: 'clipPath',
283
+ // oldValue: this,
284
+ // newValue: this,
285
+ // });
286
+
287
+ target.dispatchEvent(new _MutationEvent.MutationEvent(_interfaces.ElementEvent.ATTR_MODIFIED, target, _this, _this, 'clipPath', _MutationEvent.MutationEvent.MODIFICATION, _this, _this));
260
288
  });
261
289
  } // redraw at next frame
262
290
 
263
291
 
264
292
  renderable.dirty = true;
265
- this.emit(_interfaces.ElementEvent.ATTRIBUTE_CHANGED, {
266
- attributeName: name,
267
- oldValue: oldValue,
268
- newValue: value
269
- });
293
+ this.dispatchEvent(new _MutationEvent.MutationEvent(_interfaces.ElementEvent.ATTR_MODIFIED, this, oldValue, value, name, _MutationEvent.MutationEvent.MODIFICATION, oldParsedValue, newParsedValue)); // this.emit(ElementEvent.ATTR_MODIFIED, {
294
+ // attrName: name,
295
+ // attributeName: name,
296
+ // prevValue: oldValue,
297
+ // oldValue,
298
+ // newValue: value,
299
+ // oldParsedValue,
300
+ // newParsedValue,
301
+ // });
270
302
  }; // #region transformable
271
303
 
304
+ /**
305
+ * returns different values than getBoundingClientRect(), as the latter returns value relative to the viewport
306
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGGraphicsElement/getBBox
307
+ */
308
+
309
+
310
+ DisplayObject.prototype.getBBox = function () {
311
+ var aabb = this.getBounds();
312
+
313
+ var _a = (0, _tslib.__read)(aabb.getMin(), 2),
314
+ left = _a[0],
315
+ top = _a[1];
316
+
317
+ var _b = (0, _tslib.__read)(aabb.getMax(), 2),
318
+ right = _b[0],
319
+ bottom = _b[1];
320
+
321
+ return new _shapes.Rectangle(left, top, right - left, bottom - top);
322
+ };
272
323
 
273
324
  DisplayObject.prototype.setOrigin = function (position, y, z) {
274
325
  if (y === void 0) {
@@ -590,7 +641,7 @@ function (_super) {
590
641
 
591
642
  DisplayObject.prototype.isVisible = function () {
592
643
  var cullable = this.cullable;
593
- return this.style.visibility === 'visible' && (!cullable || cullable && !cullable.isCulled());
644
+ return this.getAttribute('visibility') === 'visible' && (!cullable || cullable && !cullable.isCulled());
594
645
  };
595
646
  /**
596
647
  * bring to front in current group
@@ -1,14 +1,17 @@
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 EllipseStyleProps extends BaseStyleProps {
5
6
  rx: number;
6
7
  ry: number;
7
8
  }
8
9
  export interface ParsedEllipseStyleProps extends ParsedBaseStyleProps {
9
- rx: number;
10
- ry: number;
10
+ rx: ParsedElement;
11
+ ry: ParsedElement;
12
+ rxInPixels: number;
13
+ ryInPixels: number;
11
14
  }
12
15
  export declare class Ellipse extends DisplayObject<EllipseStyleProps, ParsedEllipseStyleProps> {
13
- constructor({ style, ...rest }: DisplayObjectConfig<EllipseStyleProps>);
16
+ constructor({ style, ...rest }?: DisplayObjectConfig<EllipseStyleProps>);
14
17
  }
@@ -11,20 +11,23 @@ var _types = require("../types");
11
11
 
12
12
  var _DisplayObject = require("./DisplayObject");
13
13
 
14
- var Ellipse =
15
- /** @class */
16
- function (_super) {
14
+ var Ellipse = function (_super) {
17
15
  (0, _tslib.__extends)(Ellipse, _super);
18
16
 
19
17
  function Ellipse(_a) {
18
+ if (_a === void 0) {
19
+ _a = {};
20
+ }
21
+
20
22
  var style = _a.style,
21
23
  rest = (0, _tslib.__rest)(_a, ["style"]);
22
24
  return _super.call(this, (0, _tslib.__assign)({
23
- type: _types.SHAPE.Ellipse,
25
+ type: _types.Shape.ELLIPSE,
24
26
  style: (0, _tslib.__assign)({
25
27
  rx: 0,
26
28
  ry: 0,
27
- anchor: [0.5, 0.5]
29
+ anchor: [0.5, 0.5],
30
+ lineWidth: 0
28
31
  }, style)
29
32
  }, rest)) || this;
30
33
  }
@@ -1,6 +1,22 @@
1
- import type { BaseStyleProps } from '../types';
1
+ import type { BaseStyleProps, ParsedBaseStyleProps, TextAlign } from '../types';
2
2
  import { DisplayObject } from './DisplayObject';
3
3
  import type { DisplayObjectConfig } from '../dom';
4
+ import type { ParsedElement } from '../property-handlers';
5
+ export interface GroupStyleProps extends BaseStyleProps {
6
+ width?: number | string;
7
+ height?: number | string;
8
+ textAlign?: TextAlign | 'inherit';
9
+ fontSize?: number | string | 'inherit';
10
+ fontFamily?: string;
11
+ }
12
+ export interface ParsedGroupStyleProps extends ParsedBaseStyleProps {
13
+ width?: ParsedElement;
14
+ height?: ParsedElement;
15
+ widthInPixels?: number;
16
+ heightInPixels?: number;
17
+ textAlign?: TextAlign;
18
+ fontSize?: ParsedElement;
19
+ }
4
20
  export declare class Group extends DisplayObject {
5
- constructor(config?: DisplayObjectConfig<BaseStyleProps>);
21
+ constructor({ style, ...rest }?: DisplayObjectConfig<GroupStyleProps>);
6
22
  }
@@ -11,23 +11,25 @@ var _types = require("../types");
11
11
 
12
12
  var _DisplayObject = require("./DisplayObject");
13
13
 
14
- var Group =
15
- /** @class */
16
- function (_super) {
14
+ var Group = function (_super) {
17
15
  (0, _tslib.__extends)(Group, _super);
18
16
 
19
- function Group(config) {
20
- var _this = this;
17
+ function Group(_a) {
18
+ if (_a === void 0) {
19
+ _a = {};
20
+ }
21
21
 
22
- var _a = config || {},
23
- style = _a.style,
22
+ var style = _a.style,
24
23
  rest = (0, _tslib.__rest)(_a, ["style"]);
25
-
26
- _this = _super.call(this, (0, _tslib.__assign)({
27
- type: _types.SHAPE.Group,
28
- style: (0, _tslib.__assign)({}, style)
24
+ return _super.call(this, (0, _tslib.__assign)({
25
+ type: _types.Shape.GROUP,
26
+ style: (0, _tslib.__assign)({
27
+ width: 'auto',
28
+ height: 'auto',
29
+ textAlign: 'inherit',
30
+ fontSize: 'inherit'
31
+ }, style)
29
32
  }, rest)) || this;
30
- return _this;
31
33
  }
32
34
 
33
35
  return Group;
@@ -2,14 +2,19 @@ import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
2
2
  import { DisplayObject } from './DisplayObject';
3
3
  import type { DisplayObjectConfig } from '../dom';
4
4
  import { AABB } from '../shapes';
5
+ import type { ParsedElement } from '../property-handlers';
5
6
  export interface HTMLStyleProps extends BaseStyleProps {
6
7
  innerHTML: string | HTMLElement;
8
+ width: number;
9
+ height: number;
7
10
  className?: string | string[];
8
11
  style?: string;
9
12
  }
10
13
  export interface ParsedHTMLStyleProps extends ParsedBaseStyleProps {
11
14
  $el: HTMLElement;
12
15
  innerHTML: string | HTMLElement;
16
+ width: ParsedElement;
17
+ height: ParsedElement;
13
18
  className?: string | string[];
14
19
  style?: string;
15
20
  }
@@ -18,7 +23,7 @@ export interface ParsedHTMLStyleProps extends ParsedBaseStyleProps {
18
23
  * @see https://github.com/pmndrs/drei#html
19
24
  */
20
25
  export declare class HTML extends DisplayObject<HTMLStyleProps, ParsedHTMLStyleProps> {
21
- constructor({ style, ...rest }: DisplayObjectConfig<HTMLStyleProps>);
26
+ constructor({ style, ...rest }?: DisplayObjectConfig<HTMLStyleProps>);
22
27
  /**
23
28
  * return wrapper HTMLElement
24
29
  * * <div> in g-webgl/canvas
@@ -19,17 +19,19 @@ var _glMatrix = require("gl-matrix");
19
19
  * HTML container
20
20
  * @see https://github.com/pmndrs/drei#html
21
21
  */
22
- var HTML =
23
- /** @class */
24
- function (_super) {
22
+ var HTML = function (_super) {
25
23
  (0, _tslib.__extends)(HTML, _super);
26
24
 
27
25
  function HTML(_a) {
26
+ if (_a === void 0) {
27
+ _a = {};
28
+ }
29
+
28
30
  var style = _a.style,
29
31
  rest = (0, _tslib.__rest)(_a, ["style"]);
30
32
 
31
33
  var _this = _super.call(this, (0, _tslib.__assign)({
32
- type: _types.SHAPE.HTML,
34
+ type: _types.Shape.HTML,
33
35
  style: (0, _tslib.__assign)({
34
36
  innerHTML: '',
35
37
  className: '',
@@ -89,7 +91,7 @@ function (_super) {
89
91
 
90
92
  var bounds = this.getBounds();
91
93
 
92
- if (bounds) {
94
+ if (!_shapes.AABB.isEmpty(bounds)) {
93
95
  var localBounds = new _shapes.AABB();
94
96
  localBounds.setFromTransformedAABB(bounds, parentInvert);
95
97
  return localBounds;
@@ -1,16 +1,21 @@
1
1
  import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
2
2
  import { DisplayObject } from './DisplayObject';
3
3
  import type { DisplayObjectConfig } from '../dom';
4
+ import type { ParsedElement } from '../property-handlers';
4
5
  export interface ImageStyleProps extends BaseStyleProps {
5
- img: string | HTMLImageElement;
6
- width?: number;
7
- height?: number;
6
+ img?: string | HTMLImageElement;
7
+ src?: string | HTMLImageElement;
8
+ width?: number | string;
9
+ height?: number | string;
8
10
  }
9
11
  export interface ParsedImageStyleProps extends ParsedBaseStyleProps {
10
- img: string | HTMLImageElement;
11
- width?: number;
12
- height?: number;
12
+ img?: string | HTMLImageElement;
13
+ src?: string | HTMLImageElement;
14
+ width?: ParsedElement;
15
+ height?: ParsedElement;
16
+ widthInPixels?: number;
17
+ heightInPixels?: number;
13
18
  }
14
19
  export declare class Image extends DisplayObject<ImageStyleProps, ParsedImageStyleProps> {
15
- constructor({ style, ...rest }: DisplayObjectConfig<ImageStyleProps>);
20
+ constructor({ style, ...rest }?: DisplayObjectConfig<ImageStyleProps>);
16
21
  }
@@ -11,18 +11,23 @@ var _types = require("../types");
11
11
 
12
12
  var _DisplayObject = require("./DisplayObject");
13
13
 
14
- var Image =
15
- /** @class */
16
- function (_super) {
14
+ var Image = function (_super) {
17
15
  (0, _tslib.__extends)(Image, _super);
18
16
 
19
17
  function Image(_a) {
18
+ if (_a === void 0) {
19
+ _a = {};
20
+ }
21
+
20
22
  var style = _a.style,
21
23
  rest = (0, _tslib.__rest)(_a, ["style"]);
22
24
  return _super.call(this, (0, _tslib.__assign)({
23
- type: _types.SHAPE.Image,
25
+ type: _types.Shape.IMAGE,
24
26
  style: (0, _tslib.__assign)({
25
- img: ''
27
+ img: '',
28
+ width: 'auto',
29
+ height: 'auto',
30
+ lineWidth: 0
26
31
  }, style)
27
32
  }, rest)) || this;
28
33
  }
@@ -23,7 +23,7 @@ export interface ParsedLineStyleProps extends ParsedBaseStyleProps {
23
23
  isBillboard?: boolean;
24
24
  }
25
25
  export declare class Line extends DisplayObject<LineStyleProps, ParsedLineStyleProps> {
26
- constructor({ style, ...rest }: DisplayObjectConfig<LineStyleProps>);
26
+ constructor({ style, ...rest }?: DisplayObjectConfig<LineStyleProps>);
27
27
  getPoint(ratio: number): Point;
28
28
  getTotalLength(): number;
29
29
  }