@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
@@ -1,8 +1,26 @@
1
+ import { __read, __spreadArray } from "tslib";
1
2
  import { Line as LineUtil, Polyline as PolylineUtil } from '@antv/g-math';
2
3
  import { isString } from '../../utils';
3
- export function parsePoints(points) {
4
- if (isString(points)) {
5
- return null;
4
+ /**
5
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/points
6
+ *
7
+ * @example
8
+ * points="100,10 250,150 200,110"
9
+ */
10
+
11
+ export function parsePoints(pointsOrStr, object) {
12
+ var points;
13
+
14
+ if (isString(pointsOrStr)) {
15
+ points = pointsOrStr.split(' ').map(function (pointStr) {
16
+ var _a = __read(pointStr.split(','), 2),
17
+ x = _a[0],
18
+ y = _a[1];
19
+
20
+ return [Number(x), Number(y)];
21
+ });
22
+ } else {
23
+ points = pointsOrStr;
6
24
  }
7
25
 
8
26
  var segments = [];
@@ -20,6 +38,18 @@ export function parsePoints(points) {
20
38
  segments.push(segmentT);
21
39
  }
22
40
  });
41
+ var minX = Math.min.apply(Math, __spreadArray([], __read(points.map(function (point) {
42
+ return point[0];
43
+ })), false));
44
+ var minY = Math.min.apply(Math, __spreadArray([], __read(points.map(function (point) {
45
+ return point[1];
46
+ })), false));
47
+
48
+ if (object) {
49
+ object.parsedStyle.defX = minX;
50
+ object.parsedStyle.defY = minY;
51
+ }
52
+
23
53
  return {
24
54
  points: points,
25
55
  totalLength: totalLength,
@@ -50,7 +50,7 @@ var transformFunctions = {
50
50
  */
51
51
 
52
52
  export function parseTransform(string) {
53
- string = string.toLowerCase().trim();
53
+ string = (string || 'none').toLowerCase().trim();
54
54
 
55
55
  if (string === 'none') {
56
56
  return [];
@@ -1,6 +1,7 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { singleton } from 'mana-syringe';
3
3
  import { dirtifyToRoot } from '../../services';
4
+ import { CSSKeywordValue } from '../cssom';
4
5
  /**
5
6
  * @see /zh/docs/api/basic/display-object#clippath
6
7
  * @example
@@ -25,7 +26,12 @@ function () {
25
26
  function CSSPropertyClipPath() {}
26
27
 
27
28
  CSSPropertyClipPath.prototype.calculator = function (name, oldClipPath, newClipPath, object) {
28
- // clear ref to old clip path
29
+ // unset
30
+ if (newClipPath instanceof CSSKeywordValue) {
31
+ newClipPath = null;
32
+ } // clear ref to old clip path
33
+
34
+
29
35
  if (oldClipPath && oldClipPath !== newClipPath && oldClipPath.style.clipPathTargets) {
30
36
  var index = oldClipPath.style.clipPathTargets.indexOf(object);
31
37
  oldClipPath.style.clipPathTargets.splice(index, 1);
@@ -3,7 +3,7 @@ import type { DisplayObject } from '../../display-objects';
3
3
  import { parseColor, mergeColors } from '../parser';
4
4
  import type { CSSGradientValue } from '../cssom';
5
5
  import { CSSKeywordValue, CSSRGB } from '../cssom';
6
- import type { StyleValueRegistry } from '../StyleValueRegistry';
6
+ import type { StyleValueRegistry } from '../interfaces';
7
7
  /**
8
8
  * opacity
9
9
  */
@@ -1,6 +1,6 @@
1
1
  import { CSSUnitValue } from '../cssom';
2
2
  import { mergeDimensions } from '../parser';
3
- import type { StyleValueRegistry } from '../StyleValueRegistry';
3
+ import type { StyleValueRegistry } from '../interfaces';
4
4
  import type { DisplayObject } from '../../display-objects';
5
5
  import type { CSSProperty } from '../CSSProperty';
6
6
  /**
@@ -1,20 +1,11 @@
1
1
  import type { DisplayObject } from '../../display-objects';
2
2
  import type { CSSProperty } from '../CSSProperty';
3
3
  import type { CSSUnitValue } from '../cssom';
4
- import { mergeDimensions } from '../parser';
5
4
  import { CSSPropertyLengthOrPercentage } from './CSSPropertyLengthOrPercentage';
6
5
  /**
7
6
  * local position
8
7
  */
9
8
  export declare class CSSPropertyLocalPosition extends CSSPropertyLengthOrPercentage implements Partial<CSSProperty<CSSUnitValue, CSSUnitValue>> {
10
- /**
11
- * <length> & <percentage>
12
- */
13
- parser: (css: string) => CSSUnitValue;
14
- /**
15
- * mix between CSS.px(x)
16
- */
17
- mixer: typeof mergeDimensions;
18
9
  /**
19
10
  * update local position
20
11
  */
@@ -1,7 +1,8 @@
1
- import { __decorate, __extends } from "tslib";
1
+ import { __decorate, __extends, __read } from "tslib";
2
2
  import { singleton } from 'mana-syringe';
3
- import { mergeDimensions, parseLengthOrPercentage } from '../parser';
4
3
  import { CSSPropertyLengthOrPercentage } from './CSSPropertyLengthOrPercentage';
4
+ import { isNil } from '../../utils';
5
+ import { Shape } from '../../types';
5
6
  /**
6
7
  * local position
7
8
  */
@@ -12,19 +13,7 @@ function (_super) {
12
13
  __extends(CSSPropertyLocalPosition, _super);
13
14
 
14
15
  function CSSPropertyLocalPosition() {
15
- var _this = _super !== null && _super.apply(this, arguments) || this;
16
- /**
17
- * <length> & <percentage>
18
- */
19
-
20
-
21
- _this.parser = parseLengthOrPercentage;
22
- /**
23
- * mix between CSS.px(x)
24
- */
25
-
26
- _this.mixer = mergeDimensions;
27
- return _this;
16
+ return _super !== null && _super.apply(this, arguments) || this;
28
17
  }
29
18
  /**
30
19
  * update local position
@@ -32,11 +21,66 @@ function (_super) {
32
21
 
33
22
 
34
23
  CSSPropertyLocalPosition.prototype.postProcessor = function (object) {
35
- var _a = object.parsedStyle,
36
- x = _a.x,
37
- y = _a.y,
38
- z = _a.z;
39
- object.setLocalPosition(x && x.value || 0, y && y.value || 0, z && z.value || 0);
24
+ var x;
25
+ var y;
26
+ var z;
27
+
28
+ switch (object.nodeName) {
29
+ case Shape.CIRCLE:
30
+ case Shape.ELLIPSE:
31
+ var _a = object.parsedStyle,
32
+ cx = _a.cx,
33
+ cy = _a.cy;
34
+
35
+ if (!isNil(cx)) {
36
+ x = cx.value;
37
+ }
38
+
39
+ if (!isNil(cy)) {
40
+ y = cy.value;
41
+ }
42
+
43
+ break;
44
+
45
+ case Shape.RECT:
46
+ case Shape.GROUP:
47
+ case Shape.IMAGE:
48
+ case Shape.HTML:
49
+ case Shape.TEXT:
50
+ case Shape.MESH:
51
+ if (!isNil(object.parsedStyle.x)) {
52
+ x = object.parsedStyle.x.value;
53
+ }
54
+
55
+ if (!isNil(object.parsedStyle.y)) {
56
+ y = object.parsedStyle.y.value;
57
+ }
58
+
59
+ break;
60
+
61
+ case Shape.LINE:
62
+ var _b = object.parsedStyle,
63
+ x1 = _b.x1,
64
+ x2 = _b.x2,
65
+ y1 = _b.y1,
66
+ y2 = _b.y2;
67
+ var minX = Math.min(x1.value, x2.value);
68
+ var minY = Math.min(y1.value, y2.value);
69
+ x = minX;
70
+ y = minY;
71
+ z = 0;
72
+ break;
73
+ }
74
+
75
+ object.parsedStyle.defX = x || 0;
76
+ object.parsedStyle.defY = y || 0;
77
+
78
+ var _c = __read(object.getLocalPosition(), 3),
79
+ ox = _c[0],
80
+ oy = _c[1],
81
+ oz = _c[2];
82
+
83
+ object.setLocalPosition(isNil(x) ? ox : x, isNil(y) ? oy : y, isNil(z) ? oz : z);
40
84
  };
41
85
 
42
86
  CSSPropertyLocalPosition = __decorate([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[];
@@ -16,7 +16,8 @@ function () {
16
16
  }
17
17
 
18
18
  CSSPropertyPath.prototype.calculator = function (name, oldParsed, parsed) {
19
- if (parsed instanceof CSSKeywordValue) {
19
+ // unset
20
+ if (parsed instanceof CSSKeywordValue && parsed.value === 'unset') {
20
21
  return {
21
22
  absolutePath: [],
22
23
  hasArc: false,
@@ -40,10 +41,11 @@ function () {
40
41
 
41
42
  CSSPropertyPath.prototype.postProcessor = function (object) {
42
43
  var _a = object.parsedStyle,
43
- x = _a.x,
44
- y = _a.y,
45
- z = _a.z;
46
- object.setLocalPosition(x && x.value || 0, y && y.value || 0, z && z.value || 0);
44
+ _b = _a.defX,
45
+ defX = _b === void 0 ? 0 : _b,
46
+ _c = _a.defY,
47
+ defY = _c === void 0 ? 0 : _c;
48
+ object.setLocalPosition(defX, defY);
47
49
  };
48
50
 
49
51
  CSSPropertyPath = __decorate([singleton()], CSSPropertyPath);
@@ -15,10 +15,9 @@ function () {
15
15
 
16
16
  CSSPropertyPoints.prototype.postProcessor = function (object) {
17
17
  var _a = object.parsedStyle,
18
- x = _a.x,
19
- y = _a.y,
20
- z = _a.z;
21
- object.setLocalPosition(x && x.value || 0, y && y.value || 0, z && z.value || 0);
18
+ defX = _a.defX,
19
+ defY = _a.defY;
20
+ object.setLocalPosition(defX, defY);
22
21
  };
23
22
 
24
23
  CSSPropertyPoints = __decorate([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
  }
@@ -1,6 +1,6 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { singleton } from 'mana-syringe';
3
- import { CSSKeywordValue, Opx, Odeg } from '../cssom';
3
+ import { Opx, Odeg } from '../cssom';
4
4
  import { parseTransform, mergeTransforms } from '../parser';
5
5
  /**
6
6
  * @see /zh/docs/api/animation#支持变换的属性
@@ -41,112 +41,84 @@ function () {
41
41
  this.mixer = mergeTransforms;
42
42
  }
43
43
 
44
- CSSPropertyTransform.prototype.calculator = function (name, oldValue, newValue, object) {
45
- if (newValue instanceof CSSKeywordValue) {
46
- newValue = [];
47
- } // const uniqTypes = uniq([
48
- // ...(oldValue || []).map(({ t }) => t),
49
- // ...(newValue || []).map(({ t }) => t),
50
- // ]);
44
+ CSSPropertyTransform.prototype.postProcessor = function (object) {
45
+ var _a = object.parsedStyle,
46
+ transform = _a.transform,
47
+ defX = _a.defX,
48
+ defY = _a.defY;
51
49
 
50
+ if (transform && transform.length) {
51
+ // reset transform
52
+ object.resetLocalTransform();
53
+ object.setLocalPosition(defX, defY);
54
+ transform.forEach(function (_a) {
55
+ var t = _a.t,
56
+ d = _a.d;
52
57
 
53
- newValue.forEach(function (transform) {
54
- var t = transform.t;
55
- var value = (newValue || []).find(function (o) {
56
- return o.t === t;
58
+ if (t === 'scale') {
59
+ // scale(1) scale(1, 1)
60
+ var newScale = d.map(function (s) {
61
+ return s.value;
62
+ }) || [1, 1];
63
+ object.scaleLocal(newScale[0], newScale[1], 1);
64
+ } else if (t === 'scalex') {
65
+ var newScale = d.map(function (s) {
66
+ return s.value;
67
+ }) || [1];
68
+ object.scaleLocal(newScale[0], 1, 1);
69
+ } else if (t === 'scaley') {
70
+ var newScale = d.map(function (s) {
71
+ return s.value;
72
+ }) || [1];
73
+ object.scaleLocal(1, newScale[0], 1);
74
+ } else if (t === 'scalez') {
75
+ var newScale = d.map(function (s) {
76
+ return s.value;
77
+ }) || [1];
78
+ object.scaleLocal(1, 1, newScale[0]);
79
+ } else if (t === 'scale3d') {
80
+ var newScale = d.map(function (s) {
81
+ return s.value;
82
+ }) || [1, 1, 1];
83
+ object.scaleLocal(newScale[0], newScale[1], newScale[2]);
84
+ } else if (t === 'translate') {
85
+ var newTranslation = d || [Opx, Opx];
86
+ object.translateLocal(newTranslation[0].value, newTranslation[1].value, 0);
87
+ } else if (t === 'translatex') {
88
+ var newTranslation = d || [Opx];
89
+ object.translateLocal(newTranslation[0].value, 0, 0);
90
+ } else if (t === 'translatey') {
91
+ var newTranslation = d || [Opx];
92
+ object.translateLocal(0, newTranslation[0].value, 0);
93
+ } else if (t === 'translatez') {
94
+ var newTranslation = d || [Opx];
95
+ object.translateLocal(0, 0, newTranslation[0].value);
96
+ } else if (t === 'translate3d') {
97
+ var newTranslation = d || [Opx, Opx, Opx];
98
+ object.translateLocal(newTranslation[0].value, newTranslation[1].value, newTranslation[2].value);
99
+ } else if (t === 'rotate') {
100
+ var newAngles = d || [Odeg];
101
+ object.rotateLocal(0, 0, newAngles[0].value);
102
+ } else if (t === 'rotatex') {
103
+ var newAngles = d || [Odeg];
104
+ object.rotateLocal(newAngles[0].value, 0, 0);
105
+ } else if (t === 'rotatey') {
106
+ var newAngles = d || [Odeg];
107
+ object.rotateLocal(0, newAngles[0].value, 0);
108
+ } else if (t === 'rotatez') {
109
+ var newAngles = d || [Odeg];
110
+ object.rotateLocal(0, 0, newAngles[0].value);
111
+ } else if (t === 'rotate3d') {// 暂不支持绕指定轴旋转
112
+ // const newAngles = value && value.d || [Odeg, Odeg, Odeg];
113
+ // const oldAngles = old && old.d || [Odeg, Odeg, Odeg];
114
+ // object.rotateLocal(
115
+ // newAngles[0].value - oldAngles[0].value,
116
+ // newAngles[1].value - oldAngles[1].value,
117
+ // newAngles[2].value - oldAngles[2].value,
118
+ // );
119
+ }
57
120
  });
58
- var old = (oldValue || []).find(function (o) {
59
- return o.t === t;
60
- });
61
-
62
- if (t === 'scale') {
63
- // scale(1) scale(1, 1)
64
- var newScale = value && value.d && value.d.map(function (s) {
65
- return s.value;
66
- }) || [1, 1];
67
- var oldScale = old && old.d && old.d.map(function (s) {
68
- return s.value;
69
- }) || [1, 1];
70
- object.scaleLocal(newScale[0] / oldScale[0], newScale[1] / oldScale[1], 1);
71
- } else if (t === 'scalex') {
72
- var newScale = value && value.d && value.d.map(function (s) {
73
- return s.value;
74
- }) || [1];
75
- var oldScale = old && old.d && old.d.map(function (s) {
76
- return s.value;
77
- }) || [1];
78
- object.scaleLocal(newScale[0] / oldScale[0], 1, 1);
79
- } else if (t === 'scaley') {
80
- var newScale = value && value.d && value.d.map(function (s) {
81
- return s.value;
82
- }) || [1];
83
- var oldScale = old && old.d && old.d.map(function (s) {
84
- return s.value;
85
- }) || [1];
86
- object.scaleLocal(1, newScale[0] / oldScale[0], 1);
87
- } else if (t === 'scalez') {
88
- var newScale = value && value.d && value.d.map(function (s) {
89
- return s.value;
90
- }) || [1];
91
- var oldScale = old && old.d && old.d.map(function (s) {
92
- return s.value;
93
- }) || [1];
94
- object.scaleLocal(1, 1, newScale[0] / oldScale[0]);
95
- } else if (t === 'scale3d') {
96
- var newScale = value && value.d && value.d.map(function (s) {
97
- return s.value;
98
- }) || [1, 1, 1];
99
- var oldScale = old && old.d && old.d.map(function (s) {
100
- return s.value;
101
- }) || [1, 1, 1];
102
- object.scaleLocal(newScale[0] / oldScale[0], newScale[1] / oldScale[1], newScale[2] / oldScale[2]);
103
- } else if (t === 'translate') {
104
- var newTranslation = value && value.d || [Opx, Opx];
105
- var oldTranslation = old && old.d || [Opx, Opx];
106
- object.translateLocal(newTranslation[0].value - oldTranslation[0].value, newTranslation[1].value - oldTranslation[1].value, 0);
107
- } else if (t === 'translatex') {
108
- var newTranslation = value && value.d || [Opx];
109
- var oldTranslation = old && old.d || [Opx];
110
- object.translateLocal(newTranslation[0].value - oldTranslation[0].value, 0, 0);
111
- } else if (t === 'translatey') {
112
- var newTranslation = value && value.d || [Opx];
113
- var oldTranslation = old && old.d || [Opx];
114
- object.translateLocal(0, newTranslation[0].value - oldTranslation[0].value, 0);
115
- } else if (t === 'translatez') {
116
- var newTranslation = value && value.d || [Opx];
117
- var oldTranslation = old && old.d || [Opx];
118
- object.translateLocal(0, 0, newTranslation[0].value - oldTranslation[0].value);
119
- } else if (t === 'translate3d') {
120
- var newTranslation = value && value.d || [Opx, Opx, Opx];
121
- var oldTranslation = old && old.d || [Opx, Opx, Opx];
122
- object.translateLocal(newTranslation[0].value - oldTranslation[0].value, newTranslation[1].value - oldTranslation[1].value, newTranslation[2].value - oldTranslation[2].value);
123
- } else if (t === 'rotate') {
124
- var newAngles = value && value.d || [Odeg];
125
- var oldAngles = old && old.d || [Odeg];
126
- object.rotateLocal(0, 0, newAngles[0].value - oldAngles[0].value);
127
- } else if (t === 'rotatex') {
128
- var newAngles = value && value.d || [Odeg];
129
- var oldAngles = old && old.d || [Odeg];
130
- object.rotateLocal(newAngles[0].value - oldAngles[0].value, 0, 0);
131
- } else if (t === 'rotatey') {
132
- var newAngles = value && value.d || [Odeg];
133
- var oldAngles = old && old.d || [Odeg];
134
- object.rotateLocal(0, newAngles[0].value - oldAngles[0].value, 0);
135
- } else if (t === 'rotatez') {
136
- var newAngles = value && value.d || [Odeg];
137
- var oldAngles = old && old.d || [Odeg];
138
- object.rotateLocal(0, 0, newAngles[0].value - oldAngles[0].value);
139
- } else if (t === 'rotate3d') {// 暂不支持绕指定轴旋转
140
- // const newAngles = value && value.d || [Odeg, Odeg, Odeg];
141
- // const oldAngles = old && old.d || [Odeg, Odeg, Odeg];
142
- // object.rotateLocal(
143
- // newAngles[0].value - oldAngles[0].value,
144
- // newAngles[1].value - oldAngles[1].value,
145
- // newAngles[2].value - oldAngles[2].value,
146
- // );
147
- }
148
- });
149
- return newValue;
121
+ }
150
122
  };
151
123
 
152
124
  CSSPropertyTransform = __decorate([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> {
@@ -18,6 +18,8 @@ function (_super) {
18
18
  return _super.call(this, __assign({
19
19
  type: Shape.CIRCLE,
20
20
  style: __assign({
21
+ cx: '',
22
+ cy: '',
21
23
  r: '',
22
24
  anchor: [0.5, 0.5],
23
25
  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
@@ -10,23 +10,21 @@ import { createVec3, decompose, formatAttribute, fromRotationTranslationScale, g
10
10
  import { dirtifyToRoot } from '../services';
11
11
  import { MutationEvent } from '../dom/MutationEvent';
12
12
  import { Rectangle } from '../shapes';
13
- import { StyleValueRegistry } from '../css/StyleValueRegistry';
14
- import { CSSUnitValue } from '../css';
13
+ import { StyleValueRegistry } from '../css/interfaces';
15
14
  var DEFAULT_STYLE_PROPS = {
16
- x: '',
17
- y: '',
18
- z: '',
19
15
  anchor: [0, 0],
20
16
  opacity: '',
21
17
  fillOpacity: '',
22
18
  strokeOpacity: '',
23
19
  fill: '',
24
20
  stroke: '',
21
+ transform: '',
25
22
  transformOrigin: '',
26
23
  visibility: '',
27
24
  pointerEvents: '',
28
25
  lineCap: '',
29
26
  lineJoin: '',
27
+ increasedLineWidthForHitTesting: '0',
30
28
  fontSize: '',
31
29
  fontFamily: '',
32
30
  fontStyle: '',
@@ -283,7 +281,6 @@ function (_super) {
283
281
  }
284
282
 
285
283
  this.sceneGraphService.setPosition(this, createVec3(position, y, z));
286
- this.syncLocalPosition();
287
284
  return this;
288
285
  };
289
286
  /**
@@ -301,7 +298,6 @@ function (_super) {
301
298
  }
302
299
 
303
300
  this.sceneGraphService.setLocalPosition(this, createVec3(position, y, z));
304
- this.syncLocalPosition();
305
301
  return this;
306
302
  };
307
303
  /**
@@ -319,7 +315,6 @@ function (_super) {
319
315
  }
320
316
 
321
317
  this.sceneGraphService.translate(this, createVec3(position, y, z));
322
- this.syncLocalPosition();
323
318
  return this;
324
319
  };
325
320
  /**
@@ -337,7 +332,6 @@ function (_super) {
337
332
  }
338
333
 
339
334
  this.sceneGraphService.translateLocal(this, createVec3(position, y, z));
340
- this.syncLocalPosition();
341
335
  return this;
342
336
  };
343
337
 
@@ -496,26 +490,13 @@ function (_super) {
496
490
  return this.sceneGraphService.getWorldTransform(this);
497
491
  };
498
492
 
499
- DisplayObject.prototype.resetLocalTransform = function () {
500
- this.sceneGraphService.resetLocalTransform(this);
493
+ DisplayObject.prototype.setLocalTransform = function (transform) {
494
+ this.sceneGraphService.setLocalTransform(this, transform);
495
+ return this;
501
496
  };
502
- /**
503
- * sync style.x/y when local position changed
504
- *
505
- * Mixins may not declare private/protected properties
506
- * however, you can use ES2020 private fields
507
- */
508
-
509
-
510
- DisplayObject.prototype.syncLocalPosition = function () {
511
- var localPosition = this.getLocalPosition();
512
- this.attributes.x = localPosition[0];
513
- this.attributes.y = localPosition[1];
514
- this.attributes.z = localPosition[2]; // should not affect computed style
515
497
 
516
- this.parsedStyle.x = new CSSUnitValue(this.attributes.x, 'px');
517
- this.parsedStyle.y = new CSSUnitValue(this.attributes.y, 'px');
518
- this.parsedStyle.z = new CSSUnitValue(this.attributes.z, 'px');
498
+ DisplayObject.prototype.resetLocalTransform = function () {
499
+ this.sceneGraphService.resetLocalTransform(this);
519
500
  }; // #endregion transformable
520
501
  // #region animatable
521
502
 
@@ -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
  }
@@ -18,6 +18,8 @@ function (_super) {
18
18
  return _super.call(this, __assign({
19
19
  type: Shape.ELLIPSE,
20
20
  style: __assign({
21
+ cx: '',
22
+ cy: '',
21
23
  rx: '',
22
24
  ry: '',
23
25
  anchor: [0.5, 0.5],