@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
@@ -5,12 +5,12 @@ import { DisplayObjectPool } from '../DisplayObjectPool';
5
5
  import { KeyframeEffect } from '../dom/KeyframeEffect';
6
6
  import { Element } from '../dom/Element';
7
7
  import { ElementEvent } from '../dom/interfaces';
8
- import { SHAPE } from '../types';
9
- import { createVec3, fromRotationTranslationScale, getEuler, rad2deg } from '../utils'; // import type { StylePropertyParser, StylePropertyUpdater } from '../property-handlers';
10
- // import { StylePropertyParserFactory, StylePropertyUpdaterFactory } from '../property-handlers';
11
-
8
+ import { Shape } from '../types';
9
+ import { createVec3, formatAttribute, fromRotationTranslationScale, getEuler, rad2deg } from '../utils';
12
10
  import { globalContainer, stylePropertyParserFactory, stylePropertyUpdaterFactory } from '../global-module';
13
11
  import { dirtifyToRoot } from '../services';
12
+ import { MutationEvent } from '../dom/MutationEvent';
13
+ import { Rectangle } from '../shapes';
14
14
  var DEFAULT_STYLE_PROPS = {
15
15
  anchor: [0, 0, 0],
16
16
  origin: [0, 0, 0],
@@ -39,16 +39,8 @@ var DEFAULT_STYLE_PROPS = {
39
39
  * * attributeChanged
40
40
  */
41
41
 
42
- var DisplayObject =
43
- /** @class */
44
- function (_super) {
45
- __extends(DisplayObject, _super); // stylePropertyUpdaterFactory = globalContainer.get<
46
- // <Key extends keyof StyleProps>(stylePropertyName: Key) => StylePropertyUpdater<any>[]
47
- // >(StylePropertyUpdaterFactory);
48
- // stylePropertyParserFactory = globalContainer.get<
49
- // <Key extends keyof ParsedStyleProps>(stylePropertyName: Key) => StylePropertyParser<any, any>
50
- // >(StylePropertyParserFactory);
51
-
42
+ var DisplayObject = function (_super) {
43
+ __extends(DisplayObject, _super);
52
44
 
53
45
  function DisplayObject(config) {
54
46
  var _a, _b, _c;
@@ -68,17 +60,38 @@ function (_super) {
68
60
 
69
61
  _this.id = _this.config.id || '';
70
62
  _this.name = _this.config.name || '';
71
- _this.className = _this.config.className || '';
63
+
64
+ if (_this.config.className || _this.config.class) {
65
+ _this.className = _this.config.className || _this.config.class;
66
+ }
67
+
72
68
  _this.interactive = (_b = _this.config.interactive) !== null && _b !== void 0 ? _b : true;
73
- _this.nodeName = _this.config.type || SHAPE.Group; // compatible with G 3.0
69
+ _this.nodeName = _this.config.type || Shape.GROUP; // compatible with G 3.0
74
70
 
75
71
  _this.config.style = __assign(__assign(__assign(__assign({}, DEFAULT_STYLE_PROPS), {
76
72
  zIndex: (_c = _this.config.zIndex) !== null && _c !== void 0 ? _c : 0,
77
73
  visibility: _this.config.visible === false ? 'hidden' : 'visible'
78
74
  }), _this.config.style), _this.config.attrs);
79
- _this.style = new Proxy(_this.attributes, {
80
- get: function get(_, prop) {
81
- return _this.getAttribute(prop);
75
+ _this.style = new Proxy(__assign(__assign({}, _this.attributes), {
76
+ setProperty: function setProperty(propertyName, value) {
77
+ _this.setAttribute(propertyName, value);
78
+ },
79
+ getPropertyValue: function getPropertyValue(propertyName) {
80
+ return _this.getAttribute(propertyName);
81
+ },
82
+ removeProperty: function removeProperty(propertyName) {
83
+ _this.removeAttribute(propertyName);
84
+ },
85
+ item: function item() {
86
+ return '';
87
+ }
88
+ }), {
89
+ get: function get(target, name) {
90
+ if (name in target) {
91
+ return target[name];
92
+ }
93
+
94
+ return _this.getAttribute(name);
82
95
  },
83
96
  set: function set(_, prop, value) {
84
97
  _this.setAttribute(prop, value);
@@ -113,7 +126,7 @@ function (_super) {
113
126
  name: this.name,
114
127
  className: this.name,
115
128
  interactive: this.interactive,
116
- style: __assign({}, this.style)
129
+ style: __assign({}, this.attributes)
117
130
  });
118
131
 
119
132
  if (deep) {
@@ -136,51 +149,62 @@ function (_super) {
136
149
  var renderable = this.renderable; // parse attributes first
137
150
 
138
151
  for (var attributeName in attributes) {
139
- var value = attributes[attributeName];
140
- this.attributes[attributeName] = value; // @ts-ignore
152
+ var _a = __read(formatAttribute(attributeName, attributes[attributeName]), 2),
153
+ name_1 = _a[0],
154
+ value = _a[1];
155
+
156
+ this.attributes[name_1] = value; // @ts-ignore
141
157
 
142
- this.parseStyleProperty(attributeName, value);
158
+ this.parseStyleProperty(name_1, value);
143
159
  }
144
160
 
145
161
  var priorities = {
146
- x: 1000,
147
- y: 1000
162
+ x: Infinity,
163
+ y: Infinity
148
164
  }; // update x, y at last
149
165
 
150
166
  var sortedNames = Object.keys(attributes).sort(function (a, b) {
151
167
  return (priorities[a] || 0) - (priorities[b] || 0);
152
168
  });
153
169
  sortedNames.forEach(function (attributeName) {
154
- // @ts-ignore
155
- _this.updateStyleProperty(attributeName, undefined, _this.parsedStyle[attributeName]);
170
+ var _a = __read(formatAttribute(attributeName, ''), 1),
171
+ name = _a[0]; // @ts-ignore
172
+
173
+
174
+ _this.updateStyleProperty(name, undefined, _this.parsedStyle[name]);
156
175
  }); // redraw at next frame
157
176
 
158
177
  renderable.dirty = true;
159
178
  };
160
179
 
161
- DisplayObject.prototype.setAttribute = function (attributeName, value, force) {
180
+ DisplayObject.prototype.setAttribute = function (name, value, force) {
162
181
  if (force === void 0) {
163
182
  force = false;
164
183
  }
165
184
 
166
- if (force || !isEqual(value, this.attributes[attributeName]) || attributeName === 'transformOrigin' || attributeName === 'visibility' // will affect children
185
+ var _a = __read(formatAttribute(name, value), 2),
186
+ attributeName = _a[0],
187
+ attributeValue = _a[1];
188
+
189
+ if (force || !isEqual(attributeValue, this.attributes[attributeName]) || attributeName === 'transformOrigin' || attributeName === 'visibility' // will affect children
167
190
  ) {
168
191
  if (attributeName === 'visibility') {
169
192
  // set value cascade
170
193
  this.forEach(function (object) {
171
- object.changeAttribute(attributeName, value);
194
+ object.changeAttribute(attributeName, attributeValue);
172
195
  });
173
196
  } else {
174
- this.changeAttribute(attributeName, value);
197
+ this.changeAttribute(attributeName, attributeValue);
175
198
  }
176
199
 
177
- _super.prototype.setAttribute.call(this, attributeName, value);
200
+ _super.prototype.setAttribute.call(this, attributeName, attributeValue);
178
201
  }
179
202
  };
180
203
  /**
181
204
  * parse property, eg.
182
205
  * * fill: 'red' => [1, 0, 0, 1]
183
206
  * * translateX: '10px' => { unit: 'px', value: 10 }
207
+ * * fontSize: '2em' => { unit: 'px', value: 32 }
184
208
  */
185
209
 
186
210
 
@@ -190,16 +214,14 @@ function (_super) {
190
214
 
191
215
  if (stylePropertyParser) {
192
216
  // @ts-ignore
193
- this.parsedStyle[name] = stylePropertyParser(value, this);
217
+ this.parsedStyle[name] = stylePropertyParser(value, this, name);
194
218
  } else {
195
219
  this.parsedStyle[name] = value;
196
220
  }
197
221
  };
198
222
 
199
223
  DisplayObject.prototype.updateStyleProperty = function (name, oldParsedValue, newParsedValue) {
200
- var _this = this; // update property, which may cause AABB re-calc
201
- // @ts-ignore
202
- // const stylePropertyUpdaters = this.stylePropertyUpdaterFactory(name);
224
+ var _this = this; // @ts-ignore
203
225
 
204
226
 
205
227
  var stylePropertyUpdaters = stylePropertyUpdaterFactory[name];
@@ -207,7 +229,7 @@ function (_super) {
207
229
  if (stylePropertyUpdaters) {
208
230
  stylePropertyUpdaters.forEach(function (updater) {
209
231
  // @ts-ignore
210
- updater(oldParsedValue, newParsedValue, _this, _this.sceneGraphService);
232
+ updater(oldParsedValue, newParsedValue, _this, _this.sceneGraphService, name);
211
233
  });
212
234
  }
213
235
  };
@@ -228,28 +250,54 @@ function (_super) {
228
250
 
229
251
  this.parseStyleProperty(name, value); // @ts-ignore
230
252
 
231
- this.updateStyleProperty(name, oldParsedValue, this.parsedStyle[name]); // inform clip path targets
253
+ var newParsedValue = this.parsedStyle[name]; // @ts-ignore
254
+
255
+ this.updateStyleProperty(name, oldParsedValue, newParsedValue); // inform clip path targets
232
256
 
233
257
  if (this.attributes.clipPathTargets && this.attributes.clipPathTargets.length) {
234
258
  this.attributes.clipPathTargets.forEach(function (target) {
235
- dirtifyToRoot(target);
236
- target.emit(ElementEvent.ATTRIBUTE_CHANGED, {
237
- attributeName: 'clipPath',
238
- oldValue: _this,
239
- newValue: _this
240
- });
259
+ dirtifyToRoot(target); // target.emit(ElementEvent.ATTR_MODIFIED, {
260
+ // attributeName: 'clipPath',
261
+ // oldValue: this,
262
+ // newValue: this,
263
+ // });
264
+
265
+ target.dispatchEvent(new MutationEvent(ElementEvent.ATTR_MODIFIED, target, _this, _this, 'clipPath', MutationEvent.MODIFICATION, _this, _this));
241
266
  });
242
267
  } // redraw at next frame
243
268
 
244
269
 
245
270
  renderable.dirty = true;
246
- this.emit(ElementEvent.ATTRIBUTE_CHANGED, {
247
- attributeName: name,
248
- oldValue: oldValue,
249
- newValue: value
250
- });
271
+ this.dispatchEvent(new MutationEvent(ElementEvent.ATTR_MODIFIED, this, oldValue, value, name, MutationEvent.MODIFICATION, oldParsedValue, newParsedValue)); // this.emit(ElementEvent.ATTR_MODIFIED, {
272
+ // attrName: name,
273
+ // attributeName: name,
274
+ // prevValue: oldValue,
275
+ // oldValue,
276
+ // newValue: value,
277
+ // oldParsedValue,
278
+ // newParsedValue,
279
+ // });
251
280
  }; // #region transformable
252
281
 
282
+ /**
283
+ * returns different values than getBoundingClientRect(), as the latter returns value relative to the viewport
284
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGGraphicsElement/getBBox
285
+ */
286
+
287
+
288
+ DisplayObject.prototype.getBBox = function () {
289
+ var aabb = this.getBounds();
290
+
291
+ var _a = __read(aabb.getMin(), 2),
292
+ left = _a[0],
293
+ top = _a[1];
294
+
295
+ var _b = __read(aabb.getMax(), 2),
296
+ right = _b[0],
297
+ bottom = _b[1];
298
+
299
+ return new Rectangle(left, top, right - left, bottom - top);
300
+ };
253
301
 
254
302
  DisplayObject.prototype.setOrigin = function (position, y, z) {
255
303
  if (y === void 0) {
@@ -571,7 +619,7 @@ function (_super) {
571
619
 
572
620
  DisplayObject.prototype.isVisible = function () {
573
621
  var cullable = this.cullable;
574
- return this.style.visibility === 'visible' && (!cullable || cullable && !cullable.isCulled());
622
+ return this.getAttribute('visibility') === 'visible' && (!cullable || cullable && !cullable.isCulled());
575
623
  };
576
624
  /**
577
625
  * 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
  }
@@ -1,22 +1,25 @@
1
1
  import { __assign, __extends, __rest } from "tslib";
2
- import { SHAPE } from '../types';
2
+ import { Shape } from '../types';
3
3
  import { DisplayObject } from './DisplayObject';
4
4
 
5
- var Ellipse =
6
- /** @class */
7
- function (_super) {
5
+ var Ellipse = function (_super) {
8
6
  __extends(Ellipse, _super);
9
7
 
10
8
  function Ellipse(_a) {
9
+ if (_a === void 0) {
10
+ _a = {};
11
+ }
12
+
11
13
  var style = _a.style,
12
14
  rest = __rest(_a, ["style"]);
13
15
 
14
16
  return _super.call(this, __assign({
15
- type: SHAPE.Ellipse,
17
+ type: Shape.ELLIPSE,
16
18
  style: __assign({
17
19
  rx: 0,
18
20
  ry: 0,
19
- anchor: [0.5, 0.5]
21
+ anchor: [0.5, 0.5],
22
+ lineWidth: 0
20
23
  }, style)
21
24
  }, rest)) || this;
22
25
  }
@@ -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
  }
@@ -1,24 +1,27 @@
1
1
  import { __assign, __extends, __rest } from "tslib";
2
- import { SHAPE } from '../types';
2
+ import { Shape } from '../types';
3
3
  import { DisplayObject } from './DisplayObject';
4
4
 
5
- var Group =
6
- /** @class */
7
- function (_super) {
5
+ var Group = function (_super) {
8
6
  __extends(Group, _super);
9
7
 
10
- function Group(config) {
11
- var _this = this;
8
+ function Group(_a) {
9
+ if (_a === void 0) {
10
+ _a = {};
11
+ }
12
12
 
13
- var _a = config || {},
14
- style = _a.style,
13
+ var style = _a.style,
15
14
  rest = __rest(_a, ["style"]);
16
15
 
17
- _this = _super.call(this, __assign({
18
- type: SHAPE.Group,
19
- style: __assign({}, style)
16
+ return _super.call(this, __assign({
17
+ type: Shape.GROUP,
18
+ style: __assign({
19
+ width: 'auto',
20
+ height: 'auto',
21
+ textAlign: 'inherit',
22
+ fontSize: 'inherit'
23
+ }, style)
20
24
  }, rest)) || this;
21
- return _this;
22
25
  }
23
26
 
24
27
  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
@@ -1,5 +1,5 @@
1
1
  import { __assign, __extends, __rest } from "tslib";
2
- import { SHAPE } from '../types';
2
+ import { Shape } from '../types';
3
3
  import { DisplayObject } from './DisplayObject';
4
4
  import { AABB } from '../shapes';
5
5
  import { mat4, vec3 } from 'gl-matrix';
@@ -8,17 +8,19 @@ import { mat4, vec3 } from 'gl-matrix';
8
8
  * @see https://github.com/pmndrs/drei#html
9
9
  */
10
10
 
11
- var HTML =
12
- /** @class */
13
- function (_super) {
11
+ var HTML = function (_super) {
14
12
  __extends(HTML, _super);
15
13
 
16
14
  function HTML(_a) {
15
+ if (_a === void 0) {
16
+ _a = {};
17
+ }
18
+
17
19
  var style = _a.style,
18
20
  rest = __rest(_a, ["style"]);
19
21
 
20
22
  var _this = _super.call(this, __assign({
21
- type: SHAPE.HTML,
23
+ type: Shape.HTML,
22
24
  style: __assign({
23
25
  innerHTML: '',
24
26
  className: '',
@@ -77,7 +79,7 @@ function (_super) {
77
79
  var parentInvert = mat4.invert(mat4.create(), this.parentNode.getWorldTransform());
78
80
  var bounds = this.getBounds();
79
81
 
80
- if (bounds) {
82
+ if (!AABB.isEmpty(bounds)) {
81
83
  var localBounds = new AABB();
82
84
  localBounds.setFromTransformedAABB(bounds, parentInvert);
83
85
  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
  }
@@ -1,20 +1,25 @@
1
1
  import { __assign, __extends, __rest } from "tslib";
2
- import { SHAPE } from '../types';
2
+ import { Shape } from '../types';
3
3
  import { DisplayObject } from './DisplayObject';
4
4
 
5
- var Image =
6
- /** @class */
7
- function (_super) {
5
+ var Image = function (_super) {
8
6
  __extends(Image, _super);
9
7
 
10
8
  function Image(_a) {
9
+ if (_a === void 0) {
10
+ _a = {};
11
+ }
12
+
11
13
  var style = _a.style,
12
14
  rest = __rest(_a, ["style"]);
13
15
 
14
16
  return _super.call(this, __assign({
15
- type: SHAPE.Image,
17
+ type: Shape.IMAGE,
16
18
  style: __assign({
17
- img: ''
19
+ img: '',
20
+ width: 'auto',
21
+ height: 'auto',
22
+ lineWidth: 0
18
23
  }, style)
19
24
  }, rest)) || this;
20
25
  }
@@ -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
  }
@@ -1,20 +1,22 @@
1
1
  import { __assign, __extends, __rest } from "tslib";
2
2
  import { Line as LineUtil } from '@antv/g-math';
3
- import { SHAPE, LINE_CAP, LINE_JOIN } from '../types';
3
+ import { Shape, LineCap, LineJoin } from '../types';
4
4
  import { DisplayObject } from './DisplayObject';
5
5
  import { Point } from '../shapes';
6
6
 
7
- var Line =
8
- /** @class */
9
- function (_super) {
7
+ var Line = function (_super) {
10
8
  __extends(Line, _super);
11
9
 
12
10
  function Line(_a) {
11
+ if (_a === void 0) {
12
+ _a = {};
13
+ }
14
+
13
15
  var style = _a.style,
14
16
  rest = __rest(_a, ["style"]);
15
17
 
16
18
  return _super.call(this, __assign({
17
- type: SHAPE.Line,
19
+ type: Shape.LINE,
18
20
  style: __assign({
19
21
  x1: 0,
20
22
  y1: 0,
@@ -22,8 +24,12 @@ function (_super) {
22
24
  y2: 0,
23
25
  z1: 0,
24
26
  z2: 0,
25
- lineJoin: LINE_JOIN.Miter,
26
- lineCap: LINE_CAP.Butt,
27
+ lineJoin: LineJoin.MITER,
28
+ lineCap: LineCap.BUTT,
29
+
30
+ /**
31
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/stroke-width
32
+ */
27
33
  lineWidth: 1,
28
34
  isBillboard: false
29
35
  }, style)
@@ -4,7 +4,8 @@ import type { DisplayObjectConfig } from '../dom';
4
4
  import { Point } from '../shapes';
5
5
  import type { Rect } from '../shapes/Rect';
6
6
  export interface PathStyleProps extends BaseStyleProps {
7
- path: string | PathCommand[];
7
+ path?: string | PathCommand[];
8
+ d?: string | PathCommand[];
8
9
  }
9
10
  export interface PathSegment {
10
11
  command: PathCommand[0];
@@ -30,7 +31,7 @@ export interface ParsedPathStyleProps {
30
31
  export declare class Path extends DisplayObject<PathStyleProps, {
31
32
  path: ParsedPathStyleProps;
32
33
  }> {
33
- constructor({ style, ...rest }: DisplayObjectConfig<PathStyleProps>);
34
+ constructor({ style, ...rest }?: DisplayObjectConfig<PathStyleProps>);
34
35
  getTotalLength(): number;
35
36
  /**
36
37
  * Get point according to ratio
@@ -1,26 +1,29 @@
1
1
  import { __assign, __extends, __rest } from "tslib";
2
- import { SHAPE, LINE_CAP, LINE_JOIN } from '../types';
2
+ import { Shape, LineCap, LineJoin } from '../types';
3
3
  import { DisplayObject } from './DisplayObject';
4
4
  import { Point } from '../shapes';
5
5
  import { Cubic as CubicUtil } from '@antv/g-math';
6
6
  import { isNil } from '@antv/util';
7
7
 
8
- var Path =
9
- /** @class */
10
- function (_super) {
8
+ var Path = function (_super) {
11
9
  __extends(Path, _super);
12
10
 
13
11
  function Path(_a) {
12
+ if (_a === void 0) {
13
+ _a = {};
14
+ }
15
+
14
16
  var style = _a.style,
15
17
  rest = __rest(_a, ["style"]);
16
18
 
17
19
  return _super.call(this, __assign({
18
- type: SHAPE.Path,
20
+ type: Shape.PATH,
19
21
  style: __assign({
20
22
  path: '',
21
- lineJoin: LINE_JOIN.Miter,
22
- lineCap: LINE_CAP.Butt,
23
- lineWidth: 1
23
+ lineJoin: LineJoin.MITER,
24
+ lineCap: LineCap.BUTT,
25
+ lineWidth: 1,
26
+ miterLimit: 4
24
27
  }, style)
25
28
  }, rest)) || this;
26
29
  }
@@ -5,5 +5,5 @@ export interface PolygonStyleProps extends BaseStyleProps {
5
5
  points: [number, number][];
6
6
  }
7
7
  export declare class Polygon extends DisplayObject<PolygonStyleProps, ParsedBaseStyleProps> {
8
- constructor({ style, ...rest }: DisplayObjectConfig<PolygonStyleProps>);
8
+ constructor({ style, ...rest }?: DisplayObjectConfig<PolygonStyleProps>);
9
9
  }
@@ -1,20 +1,24 @@
1
1
  import { __assign, __extends, __rest } from "tslib";
2
- import { SHAPE } from '../types';
2
+ import { Shape } from '../types';
3
3
  import { DisplayObject } from './DisplayObject';
4
4
 
5
- var Polygon =
6
- /** @class */
7
- function (_super) {
5
+ var Polygon = function (_super) {
8
6
  __extends(Polygon, _super);
9
7
 
10
8
  function Polygon(_a) {
9
+ if (_a === void 0) {
10
+ _a = {};
11
+ }
12
+
11
13
  var style = _a.style,
12
14
  rest = __rest(_a, ["style"]);
13
15
 
14
16
  return _super.call(this, __assign({
15
- type: SHAPE.Polygon,
17
+ type: Shape.POLYGON,
16
18
  style: __assign({
17
- points: []
19
+ points: [],
20
+ miterLimit: 4,
21
+ lineWidth: 1
18
22
  }, style)
19
23
  }, rest)) || this;
20
24
  }