@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
@@ -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
  }
@@ -28,6 +28,8 @@ function (_super) {
28
28
  return _super.call(this, __assign({
29
29
  type: Shape.GROUP,
30
30
  style: __assign({
31
+ x: '',
32
+ y: '',
31
33
  width: '',
32
34
  height: ''
33
35
  }, 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
@@ -26,9 +26,11 @@ function (_super) {
26
26
  _this = _super.call(this, __assign({
27
27
  type: Shape.HTML,
28
28
  style: __assign({
29
- innerHTML: '',
30
- className: '',
31
- style: ''
29
+ x: '',
30
+ y: '',
31
+ width: '',
32
+ height: '',
33
+ innerHTML: ''
32
34
  }, style)
33
35
  }, rest)) || this;
34
36
  _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;
@@ -18,6 +18,8 @@ function (_super) {
18
18
  return _super.call(this, __assign({
19
19
  type: Shape.IMAGE,
20
20
  style: __assign({
21
+ x: '',
22
+ y: '',
21
23
  img: '',
22
24
  width: '',
23
25
  height: '',
@@ -37,6 +37,7 @@ function (_super) {
37
37
  }
38
38
 
39
39
  Line.prototype.getPoint = function (ratio) {
40
+ // TODO: account for z1/z2 in 3D line
40
41
  var _a = this.parsedStyle,
41
42
  x1 = _a.x1,
42
43
  y1 = _a.y1,
@@ -47,6 +48,7 @@ function (_super) {
47
48
  };
48
49
 
49
50
  Line.prototype.getTotalLength = function () {
51
+ // TODO: account for z1/z2 in 3D line
50
52
  var _a = this.parsedStyle,
51
53
  x1 = _a.x1,
52
54
  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];
@@ -18,7 +18,7 @@ function (_super) {
18
18
  return _super.call(this, __assign({
19
19
  type: Shape.POLYGON,
20
20
  style: __assign({
21
- points: [],
21
+ points: '',
22
22
  miterLimit: 4,
23
23
  lineWidth: 1
24
24
  }, style)
@@ -20,7 +20,7 @@ function (_super) {
20
20
  return _super.call(this, __assign({
21
21
  type: Shape.POLYLINE,
22
22
  style: __assign({
23
- points: [],
23
+ points: '',
24
24
  lineWidth: 1,
25
25
  miterLimit: 4
26
26
  }, style)
@@ -3,13 +3,17 @@ import { DisplayObject } from './DisplayObject';
3
3
  import type { DisplayObjectConfig } from '../dom';
4
4
  import type { CSSUnitValue } from '../css';
5
5
  export interface RectStyleProps extends BaseStyleProps {
6
+ x?: number | string;
7
+ y?: number | string;
6
8
  width: number | string;
7
9
  height: number | string;
8
10
  radius?: number | string;
9
11
  }
10
12
  export interface ParsedRectStyleProps extends ParsedBaseStyleProps {
11
- width?: CSSUnitValue;
12
- height?: CSSUnitValue;
13
+ x: CSSUnitValue;
14
+ y: CSSUnitValue;
15
+ width: CSSUnitValue;
16
+ height: CSSUnitValue;
13
17
  radius?: CSSUnitValue;
14
18
  }
15
19
  export declare class Rect extends DisplayObject<RectStyleProps, ParsedRectStyleProps> {
@@ -18,6 +18,8 @@ function (_super) {
18
18
  return _super.call(this, __assign({
19
19
  type: Shape.RECT,
20
20
  style: __assign({
21
+ x: '',
22
+ y: '',
21
23
  width: '',
22
24
  height: '',
23
25
  radius: '',
@@ -4,6 +4,8 @@ import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
4
4
  import { DisplayObject } from './DisplayObject';
5
5
  import type { CSSUnitValue, CSSGlobalKeywords, CSSKeywordValue } from '../css';
6
6
  export interface TextStyleProps extends BaseStyleProps {
7
+ x?: number | string;
8
+ y?: number | string;
7
9
  text: string;
8
10
  /** 设置文本内容的当前对齐方式 */
9
11
  textAlign?: CSSGlobalKeywords | 'start' | 'center' | 'end' | 'left' | 'right';
@@ -31,6 +33,8 @@ export interface TextStyleProps extends BaseStyleProps {
31
33
  dy?: number | string;
32
34
  }
33
35
  export interface ParsedTextStyleProps extends ParsedBaseStyleProps {
36
+ x: CSSUnitValue;
37
+ y: CSSUnitValue;
34
38
  text: string;
35
39
  /** 设置文本内容的当前对齐方式 */
36
40
  textAlign?: CSSKeywordValue;
@@ -23,6 +23,8 @@ function (_super) {
23
23
  _this = _super.call(this, __assign({
24
24
  type: Shape.TEXT,
25
25
  style: __assign({
26
+ x: '',
27
+ y: '',
26
28
  text: '',
27
29
  fontSize: '',
28
30
  fontFamily: '',
@@ -146,7 +146,7 @@ function (_super) {
146
146
  }), clientX = _c.x, clientY = _c.y;
147
147
  return [4
148
148
  /*yield*/
149
- , this.defaultView.getRenderingService().hooks.pick.callPromise({
149
+ , this.defaultView.getRenderingService().hooks.pick.promise({
150
150
  topmost: true,
151
151
  position: {
152
152
  x: x,
@@ -200,7 +200,7 @@ function (_super) {
200
200
  }), clientX = _c.x, clientY = _c.y;
201
201
  return [4
202
202
  /*yield*/
203
- , this.defaultView.getRenderingService().hooks.pick.callPromise({
203
+ , this.defaultView.getRenderingService().hooks.pick.promise({
204
204
  topmost: false,
205
205
  position: {
206
206
  x: x,
package/es/dom/Element.js CHANGED
@@ -541,6 +541,7 @@ function (_super) {
541
541
 
542
542
 
543
543
  Element.prototype.removeAttribute = function (attributeName) {
544
+ this.setAttribute(attributeName, null);
544
545
  delete this.attributes[attributeName];
545
546
  };
546
547
  /**
@@ -1,8 +1,10 @@
1
+ import { __assign } from "tslib";
1
2
  import { Module, injectable, decorate } from 'mana-syringe';
2
3
  import { EventEmitter } from 'eventemitter3';
3
4
  import { DisplayObjectPool } from './DisplayObjectPool';
4
- import { CircleUpdater, EllipseUpdater, GeometryAABBUpdater, GeometryUpdaterFactory, LineUpdater, PathUpdater, PolylineUpdater, RectUpdater, TextUpdater, TextService, OffscreenCanvasCreator, DefaultSceneGraphService, SceneGraphService, DefaultSceneGraphSelector, SceneGraphSelector, SceneGraphSelectorFactory } from './services';
5
- import { LayoutRegistry, StyleValueRegistry, CSSPropertyLocalPosition, CSSPropertyLengthOrPercentage, CSSPropertyAnchor, CSSPropertyClipPath, CSSPropertyColor, CSSPropertyFilter, CSSPropertyLineDash, CSSPropertyOffsetDistance, CSSPropertyOffsetPath, CSSPropertyOpacity, CSSPropertyPath, CSSPropertyPoints, CSSPropertyText, CSSPropertyTextTransform, CSSPropertyTransform, CSSPropertyTransformOrigin, CSSPropertyZIndex, CSSPropertyShadowBlur } from './css';
5
+ import { CircleUpdater, EllipseUpdater, GeometryAABBUpdater, GeometryUpdaterFactory, LineUpdater, PathUpdater, PolylineUpdater, RectUpdater, TextUpdater, TextService, OffscreenCanvasCreator, DefaultSceneGraphService, DefaultSceneGraphSelector, SceneGraphSelector, SceneGraphSelectorFactory } from './services';
6
+ import { LayoutRegistry, CSSPropertyLocalPosition, CSSPropertyLengthOrPercentage, CSSPropertyAnchor, CSSPropertyClipPath, CSSPropertyColor, CSSPropertyFilter, CSSPropertyLineDash, CSSPropertyOffsetDistance, CSSPropertyOffsetPath, CSSPropertyOpacity, CSSPropertyPath, CSSPropertyPoints, CSSPropertyText, CSSPropertyTextTransform, CSSPropertyTransform, CSSPropertyTransformOrigin, CSSPropertyZIndex, CSSPropertyShadowBlur, DefaultStyleValueRegistry } from './css';
7
+ import { ContextNode, FragmentResult, FragmentResultFactory, FragmentResultOptions, LayoutChildren, LayoutChildrenFactory, LayoutChildrenOptions, LayoutContext, LayoutContextFactory, LayoutContextOptions, LayoutEdges, LayoutEdgesFactory, LayoutEdgesOptions, LayoutEngine, LayoutFragment, LayoutFragmentFactory, LayoutFragmentOptions } from './css/layout';
6
8
  export var containerModule = Module(function (register) {
7
9
  decorate(injectable(), EventEmitter); // bind DisplayObject pool
8
10
 
@@ -18,10 +20,7 @@ export var containerModule = Module(function (register) {
18
20
  }
19
21
  }); // bind scenegraph service
20
22
 
21
- register({
22
- token: SceneGraphService,
23
- useClass: DefaultSceneGraphService
24
- }); // bind text service
23
+ register(DefaultSceneGraphService); // bind text service
25
24
 
26
25
  register(OffscreenCanvasCreator);
27
26
  register(TextService); // bind aabb updater
@@ -50,7 +49,7 @@ export var containerModule = Module(function (register) {
50
49
  }); // bind CSS property handlers
51
50
 
52
51
  register(LayoutRegistry);
53
- register(StyleValueRegistry);
52
+ register(DefaultStyleValueRegistry);
54
53
  register(CSSPropertyLengthOrPercentage);
55
54
  register(CSSPropertyLocalPosition);
56
55
  register(CSSPropertyOpacity);
@@ -68,5 +67,89 @@ export var containerModule = Module(function (register) {
68
67
  register(CSSPropertyPoints);
69
68
  register(CSSPropertyClipPath);
70
69
  register(CSSPropertyText);
71
- register(CSSPropertyTextTransform);
70
+ register(CSSPropertyTextTransform); // bind layout engine
71
+
72
+ register(LayoutEngine);
73
+ register(LayoutEdges);
74
+ register({
75
+ token: LayoutEdgesFactory,
76
+ useFactory: function useFactory(context) {
77
+ return function (options) {
78
+ var container = context.container.createChild();
79
+ container.register({
80
+ token: LayoutEdgesOptions,
81
+ useValue: options
82
+ });
83
+ return container.get(LayoutEdges);
84
+ };
85
+ }
86
+ });
87
+ register({
88
+ token: LayoutContextFactory,
89
+ useFactory: function useFactory(context) {
90
+ return function (options) {
91
+ var container = context.container.createChild();
92
+ container.register(LayoutContext);
93
+ container.register(LayoutChildren);
94
+ container.register({
95
+ token: LayoutChildrenFactory,
96
+ useFactory: function useFactory(childContext) {
97
+ return function (childOptions) {
98
+ var childContainer = childContext.container.createChild();
99
+ childContainer.register({
100
+ token: LayoutChildrenOptions,
101
+ useValue: childOptions
102
+ });
103
+ return childContainer.get(LayoutChildren);
104
+ };
105
+ }
106
+ });
107
+ container.register(FragmentResult);
108
+ container.register({
109
+ token: FragmentResultFactory,
110
+ useFactory: function useFactory(childContext) {
111
+ return function (childOptions, node) {
112
+ var childContainer = childContext.container.createChild();
113
+ childContainer.register({
114
+ token: FragmentResultOptions,
115
+ useValue: childOptions
116
+ });
117
+ childContainer.register({
118
+ token: ContextNode,
119
+ useValue: node
120
+ });
121
+ return childContainer.get(FragmentResult);
122
+ };
123
+ }
124
+ });
125
+ container.register(LayoutFragment);
126
+ container.register({
127
+ token: LayoutFragmentFactory,
128
+ useFactory: function useFactory(childContext) {
129
+ return function (childOptions) {
130
+ var childContainer = childContext.container.createChild();
131
+ childContainer.register({
132
+ token: LayoutFragmentOptions,
133
+ useValue: childOptions
134
+ });
135
+ return childContainer.get(LayoutFragment);
136
+ };
137
+ }
138
+ });
139
+ var layoutChildrenFactory = container.get(LayoutChildrenFactory);
140
+ var layoutFragmentFactory = container.get(LayoutFragmentFactory);
141
+ var fragmentResultFactory = container.get(FragmentResultFactory);
142
+ container.register({
143
+ token: LayoutContextOptions,
144
+ useValue: __assign(__assign({}, options), {
145
+ layoutChildrenFactory: layoutChildrenFactory,
146
+ layoutFragmentFactory: layoutFragmentFactory,
147
+ fragmentResultFactory: fragmentResultFactory
148
+ })
149
+ });
150
+ var layoutContext = container.get(LayoutContext);
151
+ return layoutContext;
152
+ };
153
+ }
154
+ });
72
155
  });
package/es/index.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import 'reflect-metadata';
2
2
  import * as ManaSyringe from 'mana-syringe';
3
+ import { LayoutEngine } from './css/layout';
3
4
  export { ManaSyringe };
5
+ declare const layoutEngine: LayoutEngine;
6
+ export { layoutEngine };
4
7
  export * from './types';
5
8
  export * from './css';
6
9
  export * from './dom';
package/es/index.js CHANGED
@@ -2,8 +2,11 @@ import 'reflect-metadata';
2
2
  import * as ManaSyringe from 'mana-syringe';
3
3
  import { containerModule as globalModule } from './global-module';
4
4
  import { GlobalContainer } from 'mana-syringe';
5
+ import { LayoutEngine } from './css/layout';
5
6
  export { ManaSyringe };
6
7
  GlobalContainer.load(globalModule);
8
+ var layoutEngine = GlobalContainer.get(LayoutEngine);
9
+ export { layoutEngine };
7
10
  export * from './types';
8
11
  export * from './css';
9
12
  export * from './dom';
@@ -11,6 +11,7 @@ export interface CullingStrategyContribution {
11
11
  * 2. other custom culling strategies, eg. frustum culling
12
12
  */
13
13
  export declare class CullingPlugin implements RenderingPlugin {
14
+ static tag: string;
14
15
  private strategyProvider;
15
16
  apply(renderingService: RenderingService): void;
16
17
  }
@@ -13,9 +13,11 @@ var CullingPlugin =
13
13
  function () {
14
14
  function CullingPlugin() {}
15
15
 
16
+ CullingPlugin_1 = CullingPlugin;
17
+
16
18
  CullingPlugin.prototype.apply = function (renderingService) {
17
19
  var strategies = this.strategyProvider.getContributions();
18
- renderingService.hooks.cull.tap(function (object) {
20
+ renderingService.hooks.cull.tap(CullingPlugin_1.tag, function (object) {
19
21
  if (object) {
20
22
  var cullable = object.cullable;
21
23
 
@@ -37,14 +39,17 @@ function () {
37
39
 
38
40
  return object;
39
41
  });
40
- renderingService.hooks.afterRender.tap(function (object) {
42
+ renderingService.hooks.afterRender.tap(CullingPlugin_1.tag, function (object) {
41
43
  object.cullable.visibilityPlaneMask = -1;
42
44
  });
43
45
  };
44
46
 
47
+ var CullingPlugin_1;
48
+ CullingPlugin.tag = 'Culling';
49
+
45
50
  __decorate([contrib(CullingStrategyContribution), __metadata("design:type", Object)], CullingPlugin.prototype, "strategyProvider", void 0);
46
51
 
47
- CullingPlugin = __decorate([singleton({
52
+ CullingPlugin = CullingPlugin_1 = __decorate([singleton({
48
53
  contrib: RenderingPluginContribution
49
54
  })], CullingPlugin);
50
55
  return CullingPlugin;
@@ -3,6 +3,7 @@ import type { RenderingService, RenderingPlugin } from '../services/RenderingSer
3
3
  * Filter dirty renderables and calculate the "dirty rectangle" which will be clear when frame began
4
4
  */
5
5
  export declare class DirtyCheckPlugin implements RenderingPlugin {
6
+ static tag: string;
6
7
  private canvasConfig;
7
8
  private renderingContext;
8
9
  apply(renderingService: RenderingService): void;
@@ -12,10 +12,12 @@ var DirtyCheckPlugin =
12
12
  function () {
13
13
  function DirtyCheckPlugin() {}
14
14
 
15
+ DirtyCheckPlugin_1 = DirtyCheckPlugin;
16
+
15
17
  DirtyCheckPlugin.prototype.apply = function (renderingService) {
16
18
  var _this = this;
17
19
 
18
- renderingService.hooks.dirtycheck.tap(function (object) {
20
+ renderingService.hooks.dirtycheck.tap(DirtyCheckPlugin_1.tag, function (object) {
19
21
  if (object) {
20
22
  var enableDirtyCheck = _this.canvasConfig.renderer.getConfig().enableDirtyCheck;
21
23
 
@@ -37,11 +39,14 @@ function () {
37
39
  });
38
40
  };
39
41
 
42
+ var DirtyCheckPlugin_1;
43
+ DirtyCheckPlugin.tag = 'DirtyCheck';
44
+
40
45
  __decorate([inject(CanvasConfig), __metadata("design:type", Object)], DirtyCheckPlugin.prototype, "canvasConfig", void 0);
41
46
 
42
47
  __decorate([inject(RenderingContext), __metadata("design:type", Object)], DirtyCheckPlugin.prototype, "renderingContext", void 0);
43
48
 
44
- DirtyCheckPlugin = __decorate([singleton({
49
+ DirtyCheckPlugin = DirtyCheckPlugin_1 = __decorate([singleton({
45
50
  contrib: RenderingPluginContribution
46
51
  })], DirtyCheckPlugin);
47
52
  return DirtyCheckPlugin;
@@ -7,6 +7,7 @@ import { RenderingService } from '../services';
7
7
  * also provide some extra events such as `drag`
8
8
  */
9
9
  export declare class EventPlugin implements RenderingPlugin {
10
+ static tag: string;
10
11
  private canvasConfig;
11
12
  private contextService;
12
13
  private renderingService;
@@ -41,6 +41,8 @@ function () {
41
41
  };
42
42
  }
43
43
 
44
+ EventPlugin_1 = EventPlugin;
45
+
44
46
  EventPlugin.prototype.apply = function (renderingService) {
45
47
  var _this = this;
46
48
 
@@ -53,7 +55,7 @@ function () {
53
55
  case 0:
54
56
  return [4
55
57
  /*yield*/
56
- , this.renderingService.hooks.pick.callPromise({
58
+ , this.renderingService.hooks.pick.promise({
57
59
  position: position,
58
60
  picked: [],
59
61
  topmost: true // we only concern the topmost element
@@ -69,12 +71,12 @@ function () {
69
71
  });
70
72
  });
71
73
  });
72
- renderingService.hooks.pointerWheel.tap(function (nativeEvent) {
74
+ renderingService.hooks.pointerWheel.tap(EventPlugin_1.tag, function (nativeEvent) {
73
75
  var wheelEvent = _this.normalizeWheelEvent(nativeEvent);
74
76
 
75
77
  _this.eventService.mapEvent(wheelEvent);
76
78
  });
77
- renderingService.hooks.pointerDown.tap(function (nativeEvent) {
79
+ renderingService.hooks.pointerDown.tap(EventPlugin_1.tag, function (nativeEvent) {
78
80
  if (canvas.supportTouchEvent && nativeEvent.pointerType === 'touch') {
79
81
  return;
80
82
  }
@@ -95,7 +97,7 @@ function () {
95
97
 
96
98
  _this.setCursor(_this.eventService.cursor);
97
99
  });
98
- renderingService.hooks.pointerUp.tap(function (nativeEvent) {
100
+ renderingService.hooks.pointerUp.tap(EventPlugin_1.tag, function (nativeEvent) {
99
101
  if (canvas.supportTouchEvent && nativeEvent.pointerType === 'touch') return; // account for element in SVG
100
102
 
101
103
  var $element = _this.contextService.getDomElement();
@@ -114,10 +116,10 @@ function () {
114
116
 
115
117
  _this.setCursor(_this.eventService.cursor);
116
118
  });
117
- renderingService.hooks.pointerMove.tap(this.onPointerMove);
118
- renderingService.hooks.pointerOver.tap(this.onPointerMove);
119
- renderingService.hooks.pointerOut.tap(this.onPointerMove);
120
- renderingService.hooks.pointerCancel.tap(function (nativeEvent) {
119
+ renderingService.hooks.pointerMove.tap(EventPlugin_1.tag, this.onPointerMove);
120
+ renderingService.hooks.pointerOver.tap(EventPlugin_1.tag, this.onPointerMove);
121
+ renderingService.hooks.pointerOut.tap(EventPlugin_1.tag, this.onPointerMove);
122
+ renderingService.hooks.pointerCancel.tap(EventPlugin_1.tag, function (nativeEvent) {
121
123
  if (canvas.supportTouchEvent && nativeEvent.pointerType === 'touch') {
122
124
  return;
123
125
  }
@@ -350,6 +352,9 @@ function () {
350
352
  }
351
353
  };
352
354
 
355
+ var EventPlugin_1;
356
+ EventPlugin.tag = 'Event';
357
+
353
358
  __decorate([inject(CanvasConfig), __metadata("design:type", Object)], EventPlugin.prototype, "canvasConfig", void 0);
354
359
 
355
360
  __decorate([inject(ContextService), __metadata("design:type", Object)], EventPlugin.prototype, "contextService", void 0);
@@ -360,7 +365,7 @@ function () {
360
365
 
361
366
  __decorate([inject(EventService), __metadata("design:type", EventService)], EventPlugin.prototype, "eventService", void 0);
362
367
 
363
- EventPlugin = __decorate([singleton({
368
+ EventPlugin = EventPlugin_1 = __decorate([singleton({
364
369
  contrib: RenderingPluginContribution
365
370
  })], EventPlugin);
366
371
  return EventPlugin;
@@ -1,5 +1,6 @@
1
1
  import type { RenderingService, RenderingPlugin } from '../services';
2
2
  export declare class PrepareRendererPlugin implements RenderingPlugin {
3
+ static tag: string;
3
4
  private renderingContext;
4
5
  private styleValueRegistry;
5
6
  apply(renderingService: RenderingService): void;
@@ -1,6 +1,6 @@
1
1
  import { __awaiter, __decorate, __generator, __metadata } from "tslib";
2
2
  import { inject, singleton } from 'mana-syringe';
3
- import { StyleValueRegistry } from '../css';
3
+ import { StyleValueRegistry } from '../css/interfaces';
4
4
  import { ElementEvent } from '../dom';
5
5
  import { RenderingContext, RenderingPluginContribution, dirtifyToRoot } from '../services';
6
6
 
@@ -9,6 +9,8 @@ var PrepareRendererPlugin =
9
9
  function () {
10
10
  function PrepareRendererPlugin() {}
11
11
 
12
+ PrepareRendererPlugin_1 = PrepareRendererPlugin;
13
+
12
14
  PrepareRendererPlugin.prototype.apply = function (renderingService) {
13
15
  var _this = this;
14
16
 
@@ -37,7 +39,7 @@ function () {
37
39
  renderingService.dirtify();
38
40
  };
39
41
 
40
- renderingService.hooks.init.tapPromise(function () {
42
+ renderingService.hooks.init.tapPromise(PrepareRendererPlugin_1.tag, function () {
41
43
  return __awaiter(_this, void 0, void 0, function () {
42
44
  return __generator(this, function (_a) {
43
45
  this.renderingContext.root.addEventListener(ElementEvent.MOUNTED, handleMounted);
@@ -50,7 +52,7 @@ function () {
50
52
  });
51
53
  });
52
54
  });
53
- renderingService.hooks.destroy.tap(function () {
55
+ renderingService.hooks.destroy.tap(PrepareRendererPlugin_1.tag, function () {
54
56
  _this.renderingContext.root.removeEventListener(ElementEvent.MOUNTED, handleMounted);
55
57
 
56
58
  _this.renderingContext.root.removeEventListener(ElementEvent.UNMOUNTED, handleUnmounted);
@@ -61,11 +63,14 @@ function () {
61
63
  });
62
64
  };
63
65
 
66
+ var PrepareRendererPlugin_1;
67
+ PrepareRendererPlugin.tag = 'Prepare';
68
+
64
69
  __decorate([inject(RenderingContext), __metadata("design:type", Object)], PrepareRendererPlugin.prototype, "renderingContext", void 0);
65
70
 
66
- __decorate([inject(StyleValueRegistry), __metadata("design:type", StyleValueRegistry)], PrepareRendererPlugin.prototype, "styleValueRegistry", void 0);
71
+ __decorate([inject(StyleValueRegistry), __metadata("design:type", Object)], PrepareRendererPlugin.prototype, "styleValueRegistry", void 0);
67
72
 
68
- PrepareRendererPlugin = __decorate([singleton({
73
+ PrepareRendererPlugin = PrepareRendererPlugin_1 = __decorate([singleton({
69
74
  contrib: RenderingPluginContribution
70
75
  })], PrepareRendererPlugin);
71
76
  return PrepareRendererPlugin;