@antv/g 5.0.23-alpha.9 → 5.1.0

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 (256) hide show
  1. package/dist/index.umd.min.js +4 -3
  2. package/es/AbstractRenderer.d.ts +11 -0
  3. package/es/AbstractRenderer.js +17 -2
  4. package/es/Canvas.d.ts +1 -1
  5. package/es/Canvas.js +2 -0
  6. package/es/css/CSS.d.ts +2 -1
  7. package/es/css/CSS.js +6 -2
  8. package/es/css/CSSProperty.d.ts +3 -2
  9. package/es/css/StyleValueRegistry.d.ts +4 -2
  10. package/es/css/StyleValueRegistry.js +100 -95
  11. package/es/css/cssom/CSSNumericValue.js +1 -1
  12. package/es/css/index.d.ts +2 -1
  13. package/es/css/index.js +2 -1
  14. package/es/css/interfaces.d.ts +6 -0
  15. package/es/css/interfaces.js +2 -0
  16. package/es/css/layout/FragmentResult.d.ts +32 -0
  17. package/es/css/layout/FragmentResult.js +32 -0
  18. package/es/css/layout/LayoutChildren.d.ts +23 -0
  19. package/es/css/layout/LayoutChildren.js +55 -0
  20. package/es/css/layout/LayoutContext.d.ts +35 -0
  21. package/es/css/layout/LayoutContext.js +35 -0
  22. package/es/css/layout/LayoutDefinition.d.ts +20 -0
  23. package/es/css/layout/LayoutDefinition.js +9 -0
  24. package/es/css/layout/LayoutEdges.d.ts +24 -0
  25. package/es/css/layout/LayoutEdges.js +41 -0
  26. package/es/css/layout/LayoutEngine.d.ts +41 -0
  27. package/es/css/layout/LayoutEngine.js +332 -0
  28. package/es/css/layout/LayoutFragment.d.ts +26 -0
  29. package/es/css/layout/LayoutFragment.js +28 -0
  30. package/es/css/layout/LayoutObject.d.ts +46 -0
  31. package/es/css/layout/LayoutObject.js +172 -0
  32. package/es/css/layout/LayoutRegistry.d.ts +16 -0
  33. package/es/css/layout/LayoutRegistry.js +78 -0
  34. package/es/css/layout/LayoutWorkTask.d.ts +14 -0
  35. package/es/css/layout/LayoutWorkTask.js +1 -0
  36. package/es/css/layout/index.d.ts +11 -0
  37. package/es/css/layout/index.js +11 -0
  38. package/es/css/layout/types.d.ts +104 -0
  39. package/es/css/layout/types.js +66 -0
  40. package/es/css/parser/color.d.ts +1 -1
  41. package/es/css/parser/color.js +2 -2
  42. package/es/css/parser/dimension.js +5 -1
  43. package/es/css/parser/path.d.ts +2 -2
  44. package/es/css/parser/path.js +9 -2
  45. package/es/css/parser/points.d.ts +8 -1
  46. package/es/css/parser/points.js +33 -3
  47. package/es/css/parser/transform.js +1 -1
  48. package/es/css/properties/CSSPropertyClipPath.js +7 -1
  49. package/es/css/properties/CSSPropertyColor.d.ts +1 -1
  50. package/es/css/properties/CSSPropertyLengthOrPercentage.d.ts +1 -1
  51. package/es/css/properties/CSSPropertyLocalPosition.d.ts +0 -9
  52. package/es/css/properties/CSSPropertyLocalPosition.js +64 -20
  53. package/es/css/properties/CSSPropertyPath.d.ts +2 -2
  54. package/es/css/properties/CSSPropertyPath.js +7 -5
  55. package/es/css/properties/CSSPropertyPoints.js +3 -4
  56. package/es/css/properties/CSSPropertyTransform.d.ts +1 -1
  57. package/es/css/properties/CSSPropertyTransform.js +76 -104
  58. package/es/display-objects/Circle.d.ts +4 -0
  59. package/es/display-objects/Circle.js +2 -0
  60. package/es/display-objects/DisplayObject.d.ts +2 -9
  61. package/es/display-objects/DisplayObject.js +8 -27
  62. package/es/display-objects/Ellipse.d.ts +4 -0
  63. package/es/display-objects/Ellipse.js +2 -0
  64. package/es/display-objects/Group.d.ts +4 -0
  65. package/es/display-objects/Group.js +2 -0
  66. package/es/display-objects/HTML.d.ts +4 -4
  67. package/es/display-objects/HTML.js +5 -3
  68. package/es/display-objects/Image.d.ts +4 -0
  69. package/es/display-objects/Image.js +2 -0
  70. package/es/display-objects/Line.js +2 -0
  71. package/es/display-objects/Path.d.ts +2 -2
  72. package/es/display-objects/Polygon.js +1 -1
  73. package/es/display-objects/Polyline.js +1 -1
  74. package/es/display-objects/Rect.d.ts +6 -2
  75. package/es/display-objects/Rect.js +2 -0
  76. package/es/display-objects/Text.d.ts +4 -0
  77. package/es/display-objects/Text.js +2 -0
  78. package/es/dom/Document.js +2 -2
  79. package/es/dom/Element.js +1 -0
  80. package/es/global-module.js +91 -8
  81. package/es/index.d.ts +3 -0
  82. package/es/index.js +3 -0
  83. package/es/plugins/CullingPlugin.d.ts +1 -0
  84. package/es/plugins/CullingPlugin.js +8 -3
  85. package/es/plugins/DirtyCheckPlugin.d.ts +1 -0
  86. package/es/plugins/DirtyCheckPlugin.js +7 -2
  87. package/es/plugins/EventPlugin.d.ts +1 -0
  88. package/es/plugins/EventPlugin.js +14 -9
  89. package/es/plugins/PrepareRendererPlugin.d.ts +1 -0
  90. package/es/plugins/PrepareRendererPlugin.js +10 -5
  91. package/es/services/EventService.js +14 -10
  92. package/es/services/OffscreenCanvasCreator.d.ts +1 -1
  93. package/es/services/OffscreenCanvasCreator.js +1 -1
  94. package/es/services/RenderingService.d.ts +18 -18
  95. package/es/services/RenderingService.js +26 -23
  96. package/es/services/SceneGraphService.d.ts +2 -0
  97. package/es/services/SceneGraphService.js +12 -1
  98. package/es/services/aabb/CircleUpdater.d.ts +0 -2
  99. package/es/services/aabb/CircleUpdater.js +2 -6
  100. package/es/services/aabb/EllipseUpdater.d.ts +0 -2
  101. package/es/services/aabb/EllipseUpdater.js +2 -6
  102. package/es/services/aabb/LineUpdater.d.ts +0 -2
  103. package/es/services/aabb/LineUpdater.js +1 -3
  104. package/es/services/aabb/PathUpdater.d.ts +0 -2
  105. package/es/services/aabb/PathUpdater.js +1 -5
  106. package/es/services/aabb/PolylineUpdater.d.ts +0 -2
  107. package/es/services/aabb/PolylineUpdater.js +1 -3
  108. package/es/services/aabb/RectUpdater.d.ts +0 -2
  109. package/es/services/aabb/RectUpdater.js +1 -5
  110. package/es/services/aabb/TextUpdater.d.ts +7 -0
  111. package/es/services/aabb/TextUpdater.js +0 -4
  112. package/es/services/aabb/interfaces.d.ts +0 -3
  113. package/es/types.d.ts +12 -23
  114. package/es/types.js +1 -0
  115. package/es/utils/deferred.d.ts +43 -0
  116. package/es/utils/deferred.js +117 -0
  117. package/es/utils/dom.d.ts +2 -0
  118. package/es/utils/dom.js +8 -0
  119. package/es/utils/index.d.ts +2 -1
  120. package/es/utils/index.js +2 -1
  121. package/es/utils/interpolation.js +3 -9
  122. package/es/utils/math.js +4 -3
  123. package/es/utils/path.d.ts +2 -2
  124. package/es/utils/path.js +61 -24
  125. package/lib/AbstractRenderer.d.ts +11 -0
  126. package/lib/AbstractRenderer.js +17 -2
  127. package/lib/Canvas.d.ts +1 -1
  128. package/lib/Canvas.js +2 -0
  129. package/lib/css/CSS.d.ts +2 -1
  130. package/lib/css/CSS.js +9 -3
  131. package/lib/css/CSSProperty.d.ts +3 -2
  132. package/lib/css/StyleValueRegistry.d.ts +4 -2
  133. package/lib/css/StyleValueRegistry.js +104 -96
  134. package/lib/css/cssom/CSSNumericValue.js +17 -17
  135. package/lib/css/index.d.ts +2 -1
  136. package/lib/css/index.js +25 -12
  137. package/lib/css/interfaces.d.ts +6 -0
  138. package/lib/css/interfaces.js +12 -0
  139. package/lib/css/layout/FragmentResult.d.ts +32 -0
  140. package/lib/css/layout/FragmentResult.js +51 -0
  141. package/lib/css/layout/LayoutChildren.d.ts +23 -0
  142. package/lib/css/layout/LayoutChildren.js +72 -0
  143. package/lib/css/layout/LayoutContext.d.ts +35 -0
  144. package/lib/css/layout/LayoutContext.js +49 -0
  145. package/lib/css/layout/LayoutDefinition.d.ts +20 -0
  146. package/lib/css/layout/LayoutDefinition.js +16 -0
  147. package/lib/css/layout/LayoutEdges.d.ts +24 -0
  148. package/lib/css/layout/LayoutEdges.js +56 -0
  149. package/lib/css/layout/LayoutEngine.d.ts +41 -0
  150. package/lib/css/layout/LayoutEngine.js +345 -0
  151. package/lib/css/layout/LayoutFragment.d.ts +26 -0
  152. package/lib/css/layout/LayoutFragment.js +44 -0
  153. package/lib/css/layout/LayoutObject.d.ts +46 -0
  154. package/lib/css/layout/LayoutObject.js +182 -0
  155. package/lib/css/layout/LayoutRegistry.d.ts +16 -0
  156. package/lib/css/layout/LayoutRegistry.js +87 -0
  157. package/lib/css/layout/LayoutWorkTask.d.ts +14 -0
  158. package/lib/css/layout/LayoutWorkTask.js +5 -0
  159. package/lib/css/layout/index.d.ts +11 -0
  160. package/lib/css/layout/index.js +148 -0
  161. package/lib/css/layout/types.d.ts +104 -0
  162. package/lib/css/layout/types.js +74 -0
  163. package/lib/css/parser/color.d.ts +1 -1
  164. package/lib/css/parser/color.js +1 -1
  165. package/lib/css/parser/dimension.js +4 -0
  166. package/lib/css/parser/path.d.ts +2 -2
  167. package/lib/css/parser/path.js +9 -2
  168. package/lib/css/parser/points.d.ts +8 -1
  169. package/lib/css/parser/points.js +33 -3
  170. package/lib/css/parser/transform.js +1 -1
  171. package/lib/css/properties/CSSPropertyClipPath.js +8 -1
  172. package/lib/css/properties/CSSPropertyColor.d.ts +1 -1
  173. package/lib/css/properties/CSSPropertyLengthOrPercentage.d.ts +1 -1
  174. package/lib/css/properties/CSSPropertyLocalPosition.d.ts +0 -9
  175. package/lib/css/properties/CSSPropertyLocalPosition.js +65 -20
  176. package/lib/css/properties/CSSPropertyPath.d.ts +2 -2
  177. package/lib/css/properties/CSSPropertyPath.js +7 -5
  178. package/lib/css/properties/CSSPropertyPoints.js +3 -4
  179. package/lib/css/properties/CSSPropertyTransform.d.ts +1 -1
  180. package/lib/css/properties/CSSPropertyTransform.js +75 -103
  181. package/lib/display-objects/Circle.d.ts +4 -0
  182. package/lib/display-objects/Circle.js +2 -0
  183. package/lib/display-objects/DisplayObject.d.ts +2 -9
  184. package/lib/display-objects/DisplayObject.js +9 -29
  185. package/lib/display-objects/Ellipse.d.ts +4 -0
  186. package/lib/display-objects/Ellipse.js +2 -0
  187. package/lib/display-objects/Group.d.ts +4 -0
  188. package/lib/display-objects/Group.js +2 -0
  189. package/lib/display-objects/HTML.d.ts +4 -4
  190. package/lib/display-objects/HTML.js +5 -3
  191. package/lib/display-objects/Image.d.ts +4 -0
  192. package/lib/display-objects/Image.js +2 -0
  193. package/lib/display-objects/Line.js +2 -0
  194. package/lib/display-objects/Path.d.ts +2 -2
  195. package/lib/display-objects/Polygon.js +1 -1
  196. package/lib/display-objects/Polyline.js +1 -1
  197. package/lib/display-objects/Rect.d.ts +6 -2
  198. package/lib/display-objects/Rect.js +2 -0
  199. package/lib/display-objects/Text.d.ts +4 -0
  200. package/lib/display-objects/Text.js +2 -0
  201. package/lib/dom/Document.js +2 -2
  202. package/lib/dom/Element.js +1 -0
  203. package/lib/global-module.js +91 -6
  204. package/lib/index.d.ts +3 -0
  205. package/lib/index.js +7 -2
  206. package/lib/plugins/CullingPlugin.d.ts +1 -0
  207. package/lib/plugins/CullingPlugin.js +7 -3
  208. package/lib/plugins/DirtyCheckPlugin.d.ts +1 -0
  209. package/lib/plugins/DirtyCheckPlugin.js +6 -2
  210. package/lib/plugins/EventPlugin.d.ts +1 -0
  211. package/lib/plugins/EventPlugin.js +13 -9
  212. package/lib/plugins/PrepareRendererPlugin.d.ts +1 -0
  213. package/lib/plugins/PrepareRendererPlugin.js +9 -5
  214. package/lib/services/EventService.js +14 -10
  215. package/lib/services/OffscreenCanvasCreator.d.ts +1 -1
  216. package/lib/services/OffscreenCanvasCreator.js +1 -1
  217. package/lib/services/RenderingService.d.ts +18 -18
  218. package/lib/services/RenderingService.js +26 -23
  219. package/lib/services/SceneGraphService.d.ts +2 -0
  220. package/lib/services/SceneGraphService.js +15 -1
  221. package/lib/services/aabb/CircleUpdater.d.ts +0 -2
  222. package/lib/services/aabb/CircleUpdater.js +2 -6
  223. package/lib/services/aabb/EllipseUpdater.d.ts +0 -2
  224. package/lib/services/aabb/EllipseUpdater.js +2 -6
  225. package/lib/services/aabb/LineUpdater.d.ts +0 -2
  226. package/lib/services/aabb/LineUpdater.js +1 -3
  227. package/lib/services/aabb/PathUpdater.d.ts +0 -2
  228. package/lib/services/aabb/PathUpdater.js +1 -5
  229. package/lib/services/aabb/PolylineUpdater.d.ts +0 -2
  230. package/lib/services/aabb/PolylineUpdater.js +1 -3
  231. package/lib/services/aabb/RectUpdater.d.ts +0 -2
  232. package/lib/services/aabb/RectUpdater.js +1 -5
  233. package/lib/services/aabb/TextUpdater.d.ts +7 -0
  234. package/lib/services/aabb/TextUpdater.js +0 -4
  235. package/lib/services/aabb/interfaces.d.ts +0 -3
  236. package/lib/types.d.ts +12 -23
  237. package/lib/types.js +1 -0
  238. package/lib/utils/deferred.d.ts +43 -0
  239. package/lib/utils/deferred.js +131 -0
  240. package/lib/utils/dom.d.ts +2 -0
  241. package/lib/utils/dom.js +17 -0
  242. package/lib/utils/index.d.ts +2 -1
  243. package/lib/utils/index.js +17 -4
  244. package/lib/utils/interpolation.js +4 -10
  245. package/lib/utils/math.js +4 -3
  246. package/lib/utils/path.d.ts +2 -2
  247. package/lib/utils/path.js +55 -24
  248. package/package.json +4 -3
  249. package/es/css/LayoutRegistry.d.ts +0 -11
  250. package/es/css/LayoutRegistry.js +0 -22
  251. package/es/utils/hooks.d.ts +0 -280
  252. package/es/utils/hooks.js +0 -753
  253. package/lib/css/LayoutRegistry.d.ts +0 -11
  254. package/lib/css/LayoutRegistry.js +0 -30
  255. package/lib/utils/hooks.d.ts +0 -280
  256. package/lib/utils/hooks.js +0 -759
@@ -9,10 +9,12 @@ var _tslib = require("tslib");
9
9
 
10
10
  var _manaSyringe = require("mana-syringe");
11
11
 
12
- var _parser = require("../parser");
13
-
14
12
  var _CSSPropertyLengthOrPercentage = require("./CSSPropertyLengthOrPercentage");
15
13
 
14
+ var _utils = require("../../utils");
15
+
16
+ var _types = require("../../types");
17
+
16
18
  /**
17
19
  * local position
18
20
  */
@@ -22,19 +24,7 @@ function (_super) {
22
24
  (0, _tslib.__extends)(CSSPropertyLocalPosition, _super);
23
25
 
24
26
  function CSSPropertyLocalPosition() {
25
- var _this = _super !== null && _super.apply(this, arguments) || this;
26
- /**
27
- * <length> & <percentage>
28
- */
29
-
30
-
31
- _this.parser = _parser.parseLengthOrPercentage;
32
- /**
33
- * mix between CSS.px(x)
34
- */
35
-
36
- _this.mixer = _parser.mergeDimensions;
37
- return _this;
27
+ return _super !== null && _super.apply(this, arguments) || this;
38
28
  }
39
29
  /**
40
30
  * update local position
@@ -42,11 +32,66 @@ function (_super) {
42
32
 
43
33
 
44
34
  CSSPropertyLocalPosition.prototype.postProcessor = function (object) {
45
- var _a = object.parsedStyle,
46
- x = _a.x,
47
- y = _a.y,
48
- z = _a.z;
49
- object.setLocalPosition(x && x.value || 0, y && y.value || 0, z && z.value || 0);
35
+ var x;
36
+ var y;
37
+ var z;
38
+
39
+ switch (object.nodeName) {
40
+ case _types.Shape.CIRCLE:
41
+ case _types.Shape.ELLIPSE:
42
+ var _a = object.parsedStyle,
43
+ cx = _a.cx,
44
+ cy = _a.cy;
45
+
46
+ if (!(0, _utils.isNil)(cx)) {
47
+ x = cx.value;
48
+ }
49
+
50
+ if (!(0, _utils.isNil)(cy)) {
51
+ y = cy.value;
52
+ }
53
+
54
+ break;
55
+
56
+ case _types.Shape.RECT:
57
+ case _types.Shape.GROUP:
58
+ case _types.Shape.IMAGE:
59
+ case _types.Shape.HTML:
60
+ case _types.Shape.TEXT:
61
+ case _types.Shape.MESH:
62
+ if (!(0, _utils.isNil)(object.parsedStyle.x)) {
63
+ x = object.parsedStyle.x.value;
64
+ }
65
+
66
+ if (!(0, _utils.isNil)(object.parsedStyle.y)) {
67
+ y = object.parsedStyle.y.value;
68
+ }
69
+
70
+ break;
71
+
72
+ case _types.Shape.LINE:
73
+ var _b = object.parsedStyle,
74
+ x1 = _b.x1,
75
+ x2 = _b.x2,
76
+ y1 = _b.y1,
77
+ y2 = _b.y2;
78
+ var minX = Math.min(x1.value, x2.value);
79
+ var minY = Math.min(y1.value, y2.value);
80
+ x = minX;
81
+ y = minY;
82
+ z = 0;
83
+ break;
84
+ }
85
+
86
+ object.parsedStyle.defX = x || 0;
87
+ object.parsedStyle.defY = y || 0;
88
+
89
+ var _c = (0, _tslib.__read)(object.getLocalPosition(), 3),
90
+ ox = _c[0],
91
+ oy = _c[1],
92
+ oz = _c[2];
93
+
94
+ object.setLocalPosition((0, _utils.isNil)(x) ? ox : x, (0, _utils.isNil)(y) ? oy : y, (0, _utils.isNil)(z) ? oz : z);
50
95
  };
51
96
 
52
97
  CSSPropertyLocalPosition = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)()], CSSPropertyLocalPosition);
@@ -8,12 +8,12 @@ export declare class CSSPropertyPath implements Partial<CSSProperty<ParsedPathSt
8
8
  */
9
9
  parser: typeof parsePath;
10
10
  calculator(name: string, oldParsed: ParsedPathStyleProps['path'], parsed: ParsedPathStyleProps['path']): {
11
- absolutePath: import("../../types").PathCommand[];
11
+ absolutePath: import("../..").PathCommand[];
12
12
  hasArc: boolean;
13
13
  segments: import("../../display-objects").PathSegment[];
14
14
  polygons: [number, number][][];
15
15
  polylines: [number, number][][];
16
- curve: import("../../types").PathCommand[];
16
+ curve: import("../..").PathCommand[];
17
17
  totalLength: number;
18
18
  curveSegments: number[][];
19
19
  zCommandIndexes: number[];
@@ -27,7 +27,8 @@ function () {
27
27
  }
28
28
 
29
29
  CSSPropertyPath.prototype.calculator = function (name, oldParsed, parsed) {
30
- if (parsed instanceof _cssom.CSSKeywordValue) {
30
+ // unset
31
+ if (parsed instanceof _cssom.CSSKeywordValue && parsed.value === 'unset') {
31
32
  return {
32
33
  absolutePath: [],
33
34
  hasArc: false,
@@ -51,10 +52,11 @@ function () {
51
52
 
52
53
  CSSPropertyPath.prototype.postProcessor = function (object) {
53
54
  var _a = object.parsedStyle,
54
- x = _a.x,
55
- y = _a.y,
56
- z = _a.z;
57
- object.setLocalPosition(x && x.value || 0, y && y.value || 0, z && z.value || 0);
55
+ _b = _a.defX,
56
+ defX = _b === void 0 ? 0 : _b,
57
+ _c = _a.defY,
58
+ defY = _c === void 0 ? 0 : _c;
59
+ object.setLocalPosition(defX, defY);
58
60
  };
59
61
 
60
62
  CSSPropertyPath = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)()], CSSPropertyPath);
@@ -24,10 +24,9 @@ function () {
24
24
 
25
25
  CSSPropertyPoints.prototype.postProcessor = function (object) {
26
26
  var _a = object.parsedStyle,
27
- x = _a.x,
28
- y = _a.y,
29
- z = _a.z;
30
- object.setLocalPosition(x && x.value || 0, y && y.value || 0, z && z.value || 0);
27
+ defX = _a.defX,
28
+ defY = _a.defY;
29
+ object.setLocalPosition(defX, defY);
31
30
  };
32
31
 
33
32
  CSSPropertyPoints = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)()], CSSPropertyPoints);
@@ -34,5 +34,5 @@ import { parseTransform, mergeTransforms } from '../parser';
34
34
  export declare class CSSPropertyTransform implements Partial<CSSProperty<any[], any[]>> {
35
35
  parser: typeof parseTransform;
36
36
  mixer: typeof mergeTransforms;
37
- calculator(name: string, oldValue: any[], newValue: any[], object: DisplayObject): any[];
37
+ postProcessor(object: DisplayObject): void;
38
38
  }
@@ -51,112 +51,84 @@ function () {
51
51
  this.mixer = _parser.mergeTransforms;
52
52
  }
53
53
 
54
- CSSPropertyTransform.prototype.calculator = function (name, oldValue, newValue, object) {
55
- if (newValue instanceof _cssom.CSSKeywordValue) {
56
- newValue = [];
57
- } // const uniqTypes = uniq([
58
- // ...(oldValue || []).map(({ t }) => t),
59
- // ...(newValue || []).map(({ t }) => t),
60
- // ]);
54
+ CSSPropertyTransform.prototype.postProcessor = function (object) {
55
+ var _a = object.parsedStyle,
56
+ transform = _a.transform,
57
+ defX = _a.defX,
58
+ defY = _a.defY;
61
59
 
60
+ if (transform && transform.length) {
61
+ // reset transform
62
+ object.resetLocalTransform();
63
+ object.setLocalPosition(defX, defY);
64
+ transform.forEach(function (_a) {
65
+ var t = _a.t,
66
+ d = _a.d;
62
67
 
63
- newValue.forEach(function (transform) {
64
- var t = transform.t;
65
- var value = (newValue || []).find(function (o) {
66
- return o.t === t;
68
+ if (t === 'scale') {
69
+ // scale(1) scale(1, 1)
70
+ var newScale = d.map(function (s) {
71
+ return s.value;
72
+ }) || [1, 1];
73
+ object.scaleLocal(newScale[0], newScale[1], 1);
74
+ } else if (t === 'scalex') {
75
+ var newScale = d.map(function (s) {
76
+ return s.value;
77
+ }) || [1];
78
+ object.scaleLocal(newScale[0], 1, 1);
79
+ } else if (t === 'scaley') {
80
+ var newScale = d.map(function (s) {
81
+ return s.value;
82
+ }) || [1];
83
+ object.scaleLocal(1, newScale[0], 1);
84
+ } else if (t === 'scalez') {
85
+ var newScale = d.map(function (s) {
86
+ return s.value;
87
+ }) || [1];
88
+ object.scaleLocal(1, 1, newScale[0]);
89
+ } else if (t === 'scale3d') {
90
+ var newScale = d.map(function (s) {
91
+ return s.value;
92
+ }) || [1, 1, 1];
93
+ object.scaleLocal(newScale[0], newScale[1], newScale[2]);
94
+ } else if (t === 'translate') {
95
+ var newTranslation = d || [_cssom.Opx, _cssom.Opx];
96
+ object.translateLocal(newTranslation[0].value, newTranslation[1].value, 0);
97
+ } else if (t === 'translatex') {
98
+ var newTranslation = d || [_cssom.Opx];
99
+ object.translateLocal(newTranslation[0].value, 0, 0);
100
+ } else if (t === 'translatey') {
101
+ var newTranslation = d || [_cssom.Opx];
102
+ object.translateLocal(0, newTranslation[0].value, 0);
103
+ } else if (t === 'translatez') {
104
+ var newTranslation = d || [_cssom.Opx];
105
+ object.translateLocal(0, 0, newTranslation[0].value);
106
+ } else if (t === 'translate3d') {
107
+ var newTranslation = d || [_cssom.Opx, _cssom.Opx, _cssom.Opx];
108
+ object.translateLocal(newTranslation[0].value, newTranslation[1].value, newTranslation[2].value);
109
+ } else if (t === 'rotate') {
110
+ var newAngles = d || [_cssom.Odeg];
111
+ object.rotateLocal(0, 0, newAngles[0].value);
112
+ } else if (t === 'rotatex') {
113
+ var newAngles = d || [_cssom.Odeg];
114
+ object.rotateLocal(newAngles[0].value, 0, 0);
115
+ } else if (t === 'rotatey') {
116
+ var newAngles = d || [_cssom.Odeg];
117
+ object.rotateLocal(0, newAngles[0].value, 0);
118
+ } else if (t === 'rotatez') {
119
+ var newAngles = d || [_cssom.Odeg];
120
+ object.rotateLocal(0, 0, newAngles[0].value);
121
+ } else if (t === 'rotate3d') {// 暂不支持绕指定轴旋转
122
+ // const newAngles = value && value.d || [Odeg, Odeg, Odeg];
123
+ // const oldAngles = old && old.d || [Odeg, Odeg, Odeg];
124
+ // object.rotateLocal(
125
+ // newAngles[0].value - oldAngles[0].value,
126
+ // newAngles[1].value - oldAngles[1].value,
127
+ // newAngles[2].value - oldAngles[2].value,
128
+ // );
129
+ }
67
130
  });
68
- var old = (oldValue || []).find(function (o) {
69
- return o.t === t;
70
- });
71
-
72
- if (t === 'scale') {
73
- // scale(1) scale(1, 1)
74
- var newScale = value && value.d && value.d.map(function (s) {
75
- return s.value;
76
- }) || [1, 1];
77
- var oldScale = old && old.d && old.d.map(function (s) {
78
- return s.value;
79
- }) || [1, 1];
80
- object.scaleLocal(newScale[0] / oldScale[0], newScale[1] / oldScale[1], 1);
81
- } else if (t === 'scalex') {
82
- var newScale = value && value.d && value.d.map(function (s) {
83
- return s.value;
84
- }) || [1];
85
- var oldScale = old && old.d && old.d.map(function (s) {
86
- return s.value;
87
- }) || [1];
88
- object.scaleLocal(newScale[0] / oldScale[0], 1, 1);
89
- } else if (t === 'scaley') {
90
- var newScale = value && value.d && value.d.map(function (s) {
91
- return s.value;
92
- }) || [1];
93
- var oldScale = old && old.d && old.d.map(function (s) {
94
- return s.value;
95
- }) || [1];
96
- object.scaleLocal(1, newScale[0] / oldScale[0], 1);
97
- } else if (t === 'scalez') {
98
- var newScale = value && value.d && value.d.map(function (s) {
99
- return s.value;
100
- }) || [1];
101
- var oldScale = old && old.d && old.d.map(function (s) {
102
- return s.value;
103
- }) || [1];
104
- object.scaleLocal(1, 1, newScale[0] / oldScale[0]);
105
- } else if (t === 'scale3d') {
106
- var newScale = value && value.d && value.d.map(function (s) {
107
- return s.value;
108
- }) || [1, 1, 1];
109
- var oldScale = old && old.d && old.d.map(function (s) {
110
- return s.value;
111
- }) || [1, 1, 1];
112
- object.scaleLocal(newScale[0] / oldScale[0], newScale[1] / oldScale[1], newScale[2] / oldScale[2]);
113
- } else if (t === 'translate') {
114
- var newTranslation = value && value.d || [_cssom.Opx, _cssom.Opx];
115
- var oldTranslation = old && old.d || [_cssom.Opx, _cssom.Opx];
116
- object.translateLocal(newTranslation[0].value - oldTranslation[0].value, newTranslation[1].value - oldTranslation[1].value, 0);
117
- } else if (t === 'translatex') {
118
- var newTranslation = value && value.d || [_cssom.Opx];
119
- var oldTranslation = old && old.d || [_cssom.Opx];
120
- object.translateLocal(newTranslation[0].value - oldTranslation[0].value, 0, 0);
121
- } else if (t === 'translatey') {
122
- var newTranslation = value && value.d || [_cssom.Opx];
123
- var oldTranslation = old && old.d || [_cssom.Opx];
124
- object.translateLocal(0, newTranslation[0].value - oldTranslation[0].value, 0);
125
- } else if (t === 'translatez') {
126
- var newTranslation = value && value.d || [_cssom.Opx];
127
- var oldTranslation = old && old.d || [_cssom.Opx];
128
- object.translateLocal(0, 0, newTranslation[0].value - oldTranslation[0].value);
129
- } else if (t === 'translate3d') {
130
- var newTranslation = value && value.d || [_cssom.Opx, _cssom.Opx, _cssom.Opx];
131
- var oldTranslation = old && old.d || [_cssom.Opx, _cssom.Opx, _cssom.Opx];
132
- object.translateLocal(newTranslation[0].value - oldTranslation[0].value, newTranslation[1].value - oldTranslation[1].value, newTranslation[2].value - oldTranslation[2].value);
133
- } else if (t === 'rotate') {
134
- var newAngles = value && value.d || [_cssom.Odeg];
135
- var oldAngles = old && old.d || [_cssom.Odeg];
136
- object.rotateLocal(0, 0, newAngles[0].value - oldAngles[0].value);
137
- } else if (t === 'rotatex') {
138
- var newAngles = value && value.d || [_cssom.Odeg];
139
- var oldAngles = old && old.d || [_cssom.Odeg];
140
- object.rotateLocal(newAngles[0].value - oldAngles[0].value, 0, 0);
141
- } else if (t === 'rotatey') {
142
- var newAngles = value && value.d || [_cssom.Odeg];
143
- var oldAngles = old && old.d || [_cssom.Odeg];
144
- object.rotateLocal(0, newAngles[0].value - oldAngles[0].value, 0);
145
- } else if (t === 'rotatez') {
146
- var newAngles = value && value.d || [_cssom.Odeg];
147
- var oldAngles = old && old.d || [_cssom.Odeg];
148
- object.rotateLocal(0, 0, newAngles[0].value - oldAngles[0].value);
149
- } else if (t === 'rotate3d') {// 暂不支持绕指定轴旋转
150
- // const newAngles = value && value.d || [Odeg, Odeg, Odeg];
151
- // const oldAngles = old && old.d || [Odeg, Odeg, Odeg];
152
- // object.rotateLocal(
153
- // newAngles[0].value - oldAngles[0].value,
154
- // newAngles[1].value - oldAngles[1].value,
155
- // newAngles[2].value - oldAngles[2].value,
156
- // );
157
- }
158
- });
159
- return newValue;
131
+ }
160
132
  };
161
133
 
162
134
  CSSPropertyTransform = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)()], CSSPropertyTransform);
@@ -3,9 +3,13 @@ import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
3
3
  import { DisplayObject } from './DisplayObject';
4
4
  import type { CSSUnitValue } from '../css';
5
5
  export interface CircleStyleProps extends BaseStyleProps {
6
+ cx?: number | string;
7
+ cy?: number | string;
6
8
  r: number | string;
7
9
  }
8
10
  export interface ParsedCircleStyleProps extends ParsedBaseStyleProps {
11
+ cx: CSSUnitValue;
12
+ cy: CSSUnitValue;
9
13
  r: CSSUnitValue;
10
14
  }
11
15
  export declare class Circle extends DisplayObject<CircleStyleProps, ParsedCircleStyleProps> {
@@ -26,6 +26,8 @@ function (_super) {
26
26
  return _super.call(this, (0, _tslib.__assign)({
27
27
  type: _types.Shape.CIRCLE,
28
28
  style: (0, _tslib.__assign)({
29
+ cx: '',
30
+ cy: '',
29
31
  r: '',
30
32
  anchor: [0.5, 0.5],
31
33
  transformOrigin: 'center',
@@ -5,7 +5,6 @@ import { Element } from '../dom/Element';
5
5
  import type { DisplayObjectConfig, IChildNode } from '../dom/interfaces';
6
6
  import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
7
7
  import type { PropertyParseOptions } from '../css/StyleValueRegistry';
8
- import { StyleValueRegistry } from '../css/StyleValueRegistry';
9
8
  /**
10
9
  * prototype chains: DisplayObject -> Element -> Node -> EventTarget
11
10
  *
@@ -29,7 +28,7 @@ export declare class DisplayObject<StyleProps extends BaseStyleProps = any, Pars
29
28
  * contains style props in constructor's params, eg. fill, stroke...
30
29
  */
31
30
  config: DisplayObjectConfig<StyleProps>;
32
- styleValueRegistry: StyleValueRegistry;
31
+ styleValueRegistry: any;
33
32
  /**
34
33
  * push to active animations after calling `animate()`
35
34
  */
@@ -117,14 +116,8 @@ export declare class DisplayObject<StyleProps extends BaseStyleProps = any, Pars
117
116
  getLocalRotation(): quat;
118
117
  getLocalTransform(): mat4;
119
118
  getWorldTransform(): mat4;
119
+ setLocalTransform(transform: mat4): this;
120
120
  resetLocalTransform(): void;
121
- /**
122
- * sync style.x/y when local position changed
123
- *
124
- * Mixins may not declare private/protected properties
125
- * however, you can use ES2020 private fields
126
- */
127
- private syncLocalPosition;
128
121
  /**
129
122
  * returns an array of all Animation objects affecting this element
130
123
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAnimations
@@ -29,25 +29,22 @@ var _MutationEvent = require("../dom/MutationEvent");
29
29
 
30
30
  var _shapes = require("../shapes");
31
31
 
32
- var _StyleValueRegistry = require("../css/StyleValueRegistry");
33
-
34
- var _css = require("../css");
32
+ var _interfaces2 = require("../css/interfaces");
35
33
 
36
34
  var DEFAULT_STYLE_PROPS = {
37
- x: '',
38
- y: '',
39
- z: '',
40
35
  anchor: [0, 0],
41
36
  opacity: '',
42
37
  fillOpacity: '',
43
38
  strokeOpacity: '',
44
39
  fill: '',
45
40
  stroke: '',
41
+ transform: '',
46
42
  transformOrigin: '',
47
43
  visibility: '',
48
44
  pointerEvents: '',
49
45
  lineCap: '',
50
46
  lineJoin: '',
47
+ increasedLineWidthForHitTesting: '0',
51
48
  fontSize: '',
52
49
  fontFamily: '',
53
50
  fontStyle: '',
@@ -87,7 +84,7 @@ function (_super) {
87
84
  var _a, _b, _c;
88
85
 
89
86
  _this = _super.call(this) || this;
90
- _this.styleValueRegistry = _manaSyringe.GlobalContainer.get(_StyleValueRegistry.StyleValueRegistry);
87
+ _this.styleValueRegistry = _manaSyringe.GlobalContainer.get(_interfaces2.StyleValueRegistry);
91
88
  /**
92
89
  * push to active animations after calling `animate()`
93
90
  */
@@ -306,7 +303,6 @@ function (_super) {
306
303
  }
307
304
 
308
305
  this.sceneGraphService.setPosition(this, (0, _utils.createVec3)(position, y, z));
309
- this.syncLocalPosition();
310
306
  return this;
311
307
  };
312
308
  /**
@@ -324,7 +320,6 @@ function (_super) {
324
320
  }
325
321
 
326
322
  this.sceneGraphService.setLocalPosition(this, (0, _utils.createVec3)(position, y, z));
327
- this.syncLocalPosition();
328
323
  return this;
329
324
  };
330
325
  /**
@@ -342,7 +337,6 @@ function (_super) {
342
337
  }
343
338
 
344
339
  this.sceneGraphService.translate(this, (0, _utils.createVec3)(position, y, z));
345
- this.syncLocalPosition();
346
340
  return this;
347
341
  };
348
342
  /**
@@ -360,7 +354,6 @@ function (_super) {
360
354
  }
361
355
 
362
356
  this.sceneGraphService.translateLocal(this, (0, _utils.createVec3)(position, y, z));
363
- this.syncLocalPosition();
364
357
  return this;
365
358
  };
366
359
 
@@ -519,26 +512,13 @@ function (_super) {
519
512
  return this.sceneGraphService.getWorldTransform(this);
520
513
  };
521
514
 
522
- DisplayObject.prototype.resetLocalTransform = function () {
523
- this.sceneGraphService.resetLocalTransform(this);
515
+ DisplayObject.prototype.setLocalTransform = function (transform) {
516
+ this.sceneGraphService.setLocalTransform(this, transform);
517
+ return this;
524
518
  };
525
- /**
526
- * sync style.x/y when local position changed
527
- *
528
- * Mixins may not declare private/protected properties
529
- * however, you can use ES2020 private fields
530
- */
531
-
532
-
533
- DisplayObject.prototype.syncLocalPosition = function () {
534
- var localPosition = this.getLocalPosition();
535
- this.attributes.x = localPosition[0];
536
- this.attributes.y = localPosition[1];
537
- this.attributes.z = localPosition[2]; // should not affect computed style
538
519
 
539
- this.parsedStyle.x = new _css.CSSUnitValue(this.attributes.x, 'px');
540
- this.parsedStyle.y = new _css.CSSUnitValue(this.attributes.y, 'px');
541
- this.parsedStyle.z = new _css.CSSUnitValue(this.attributes.z, 'px');
520
+ DisplayObject.prototype.resetLocalTransform = function () {
521
+ this.sceneGraphService.resetLocalTransform(this);
542
522
  }; // #endregion transformable
543
523
  // #region animatable
544
524
 
@@ -3,10 +3,14 @@ import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
3
3
  import { DisplayObject } from './DisplayObject';
4
4
  import type { CSSUnitValue } from '../css';
5
5
  export interface EllipseStyleProps extends BaseStyleProps {
6
+ cx?: number | string;
7
+ cy?: number | string;
6
8
  rx: number | string;
7
9
  ry: number | string;
8
10
  }
9
11
  export interface ParsedEllipseStyleProps extends ParsedBaseStyleProps {
12
+ cx: CSSUnitValue;
13
+ cy: CSSUnitValue;
10
14
  rx: CSSUnitValue;
11
15
  ry: CSSUnitValue;
12
16
  }
@@ -26,6 +26,8 @@ function (_super) {
26
26
  return _super.call(this, (0, _tslib.__assign)({
27
27
  type: _types.Shape.ELLIPSE,
28
28
  style: (0, _tslib.__assign)({
29
+ cx: '',
30
+ cy: '',
29
31
  rx: '',
30
32
  ry: '',
31
33
  anchor: [0.5, 0.5],
@@ -3,10 +3,14 @@ import { DisplayObject } from './DisplayObject';
3
3
  import type { DisplayObjectConfig } from '../dom';
4
4
  import type { CSSUnitValue } from '../css';
5
5
  export interface GroupStyleProps extends BaseStyleProps {
6
+ x?: number | string;
7
+ y?: number | string;
6
8
  width?: number | string;
7
9
  height?: number | string;
8
10
  }
9
11
  export interface ParsedGroupStyleProps extends ParsedBaseStyleProps {
12
+ x: CSSUnitValue;
13
+ y: CSSUnitValue;
10
14
  width?: CSSUnitValue;
11
15
  height?: CSSUnitValue;
12
16
  }
@@ -36,6 +36,8 @@ function (_super) {
36
36
  return _super.call(this, (0, _tslib.__assign)({
37
37
  type: _types.Shape.GROUP,
38
38
  style: (0, _tslib.__assign)({
39
+ x: '',
40
+ y: '',
39
41
  width: '',
40
42
  height: ''
41
43
  }, style)
@@ -4,19 +4,19 @@ import type { DisplayObjectConfig } from '../dom';
4
4
  import { AABB } from '../shapes';
5
5
  import type { CSSUnitValue } from '../css';
6
6
  export interface HTMLStyleProps extends BaseStyleProps {
7
+ x?: number | string;
8
+ y?: number | string;
7
9
  innerHTML: string | HTMLElement;
8
10
  width: number;
9
11
  height: number;
10
- className?: string | string[];
11
- style?: string;
12
12
  }
13
13
  export interface ParsedHTMLStyleProps extends ParsedBaseStyleProps {
14
+ x: CSSUnitValue;
15
+ y: CSSUnitValue;
14
16
  $el: HTMLElement;
15
17
  innerHTML: string | HTMLElement;
16
18
  width: CSSUnitValue;
17
19
  height: CSSUnitValue;
18
- className?: string | string[];
19
- style?: string;
20
20
  }
21
21
  /**
22
22
  * HTML container
@@ -36,9 +36,11 @@ function (_super) {
36
36
  _this = _super.call(this, (0, _tslib.__assign)({
37
37
  type: _types.Shape.HTML,
38
38
  style: (0, _tslib.__assign)({
39
- innerHTML: '',
40
- className: '',
41
- style: ''
39
+ x: '',
40
+ y: '',
41
+ width: '',
42
+ height: '',
43
+ innerHTML: ''
42
44
  }, style)
43
45
  }, rest)) || this;
44
46
  _this.cullable.enable = false;
@@ -3,12 +3,16 @@ import { DisplayObject } from './DisplayObject';
3
3
  import type { DisplayObjectConfig } from '../dom';
4
4
  import type { CSSUnitValue } from '../css';
5
5
  export interface ImageStyleProps extends BaseStyleProps {
6
+ x?: number | string;
7
+ y?: number | string;
6
8
  img?: string | HTMLImageElement;
7
9
  src?: string | HTMLImageElement;
8
10
  width?: number | string;
9
11
  height?: number | string;
10
12
  }
11
13
  export interface ParsedImageStyleProps extends ParsedBaseStyleProps {
14
+ x: CSSUnitValue;
15
+ y: CSSUnitValue;
12
16
  img?: string | HTMLImageElement;
13
17
  src?: string | HTMLImageElement;
14
18
  width?: CSSUnitValue;
@@ -26,6 +26,8 @@ function (_super) {
26
26
  return _super.call(this, (0, _tslib.__assign)({
27
27
  type: _types.Shape.IMAGE,
28
28
  style: (0, _tslib.__assign)({
29
+ x: '',
30
+ y: '',
29
31
  img: '',
30
32
  width: '',
31
33
  height: '',
@@ -47,6 +47,7 @@ function (_super) {
47
47
  }
48
48
 
49
49
  Line.prototype.getPoint = function (ratio) {
50
+ // TODO: account for z1/z2 in 3D line
50
51
  var _a = this.parsedStyle,
51
52
  x1 = _a.x1,
52
53
  y1 = _a.y1,
@@ -59,6 +60,7 @@ function (_super) {
59
60
  };
60
61
 
61
62
  Line.prototype.getTotalLength = function () {
63
+ // TODO: account for z1/z2 in 3D line
62
64
  var _a = this.parsedStyle,
63
65
  x1 = _a.x1,
64
66
  y1 = _a.y1,
@@ -4,8 +4,8 @@ import type { DisplayObjectConfig } from '../dom';
4
4
  import { Point } from '../shapes';
5
5
  import type { Rectangle } from '../shapes/Rectangle';
6
6
  export interface PathStyleProps extends BaseStyleProps {
7
- path?: string | PathCommand[];
8
- d?: string | PathCommand[];
7
+ path?: string | PathCommand[] | DisplayObject;
8
+ d?: string | PathCommand[] | DisplayObject;
9
9
  }
10
10
  export interface PathSegment {
11
11
  command: PathCommand[0];