@antv/g 5.0.23-alpha.8 → 5.0.24

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 (150) 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/css/CSS.d.ts +2 -1
  6. package/es/css/CSS.js +6 -2
  7. package/es/css/CSSProperty.d.ts +1 -1
  8. package/es/css/StyleValueRegistry.d.ts +2 -1
  9. package/es/css/StyleValueRegistry.js +34 -25
  10. package/es/css/cssom/CSSNumericValue.js +1 -1
  11. package/es/css/index.d.ts +2 -1
  12. package/es/css/index.js +2 -1
  13. package/es/css/interfaces.d.ts +6 -0
  14. package/es/css/interfaces.js +2 -0
  15. package/es/css/layout/FragmentResult.d.ts +32 -0
  16. package/es/css/layout/FragmentResult.js +32 -0
  17. package/es/css/layout/LayoutChildren.d.ts +23 -0
  18. package/es/css/layout/LayoutChildren.js +55 -0
  19. package/es/css/layout/LayoutContext.d.ts +35 -0
  20. package/es/css/layout/LayoutContext.js +35 -0
  21. package/es/css/layout/LayoutDefinition.d.ts +20 -0
  22. package/es/css/layout/LayoutDefinition.js +9 -0
  23. package/es/css/layout/LayoutEdges.d.ts +24 -0
  24. package/es/css/layout/LayoutEdges.js +41 -0
  25. package/es/css/layout/LayoutEngine.d.ts +41 -0
  26. package/es/css/layout/LayoutEngine.js +332 -0
  27. package/es/css/layout/LayoutFragment.d.ts +26 -0
  28. package/es/css/layout/LayoutFragment.js +28 -0
  29. package/es/css/layout/LayoutObject.d.ts +46 -0
  30. package/es/css/layout/LayoutObject.js +172 -0
  31. package/es/css/layout/LayoutRegistry.d.ts +16 -0
  32. package/es/css/layout/LayoutRegistry.js +78 -0
  33. package/es/css/layout/LayoutWorkTask.d.ts +14 -0
  34. package/es/css/layout/LayoutWorkTask.js +1 -0
  35. package/es/css/layout/index.d.ts +11 -0
  36. package/es/css/layout/index.js +11 -0
  37. package/es/css/layout/types.d.ts +104 -0
  38. package/es/css/layout/types.js +66 -0
  39. package/es/css/parser/numeric.d.ts +1 -1
  40. package/es/css/parser/numeric.js +1 -1
  41. package/es/css/parser/transform.js +5 -4
  42. package/es/css/properties/CSSPropertyColor.d.ts +1 -1
  43. package/es/css/properties/CSSPropertyLengthOrPercentage.d.ts +1 -1
  44. package/es/display-objects/DisplayObject.d.ts +1 -2
  45. package/es/display-objects/DisplayObject.js +2 -1
  46. package/es/dom/Document.js +2 -2
  47. package/es/global-module.js +91 -8
  48. package/es/index.d.ts +3 -0
  49. package/es/index.js +3 -0
  50. package/es/plugins/CullingPlugin.d.ts +1 -0
  51. package/es/plugins/CullingPlugin.js +8 -3
  52. package/es/plugins/DirtyCheckPlugin.d.ts +1 -0
  53. package/es/plugins/DirtyCheckPlugin.js +7 -2
  54. package/es/plugins/EventPlugin.d.ts +1 -0
  55. package/es/plugins/EventPlugin.js +14 -9
  56. package/es/plugins/PrepareRendererPlugin.d.ts +1 -0
  57. package/es/plugins/PrepareRendererPlugin.js +10 -5
  58. package/es/services/EventService.js +4 -8
  59. package/es/services/OffscreenCanvasCreator.d.ts +1 -1
  60. package/es/services/OffscreenCanvasCreator.js +1 -1
  61. package/es/services/RenderingService.d.ts +18 -18
  62. package/es/services/RenderingService.js +26 -23
  63. package/es/services/SceneGraphService.js +3 -1
  64. package/es/types.d.ts +7 -5
  65. package/es/utils/deferred.d.ts +43 -0
  66. package/es/utils/deferred.js +117 -0
  67. package/es/utils/dom.d.ts +2 -0
  68. package/es/utils/dom.js +8 -0
  69. package/es/utils/index.d.ts +2 -1
  70. package/es/utils/index.js +2 -1
  71. package/es/utils/interpolation.js +1 -1
  72. package/lib/AbstractRenderer.d.ts +11 -0
  73. package/lib/AbstractRenderer.js +17 -2
  74. package/lib/Canvas.d.ts +1 -1
  75. package/lib/css/CSS.d.ts +2 -1
  76. package/lib/css/CSS.js +9 -3
  77. package/lib/css/CSSProperty.d.ts +1 -1
  78. package/lib/css/StyleValueRegistry.d.ts +2 -1
  79. package/lib/css/StyleValueRegistry.js +39 -27
  80. package/lib/css/cssom/CSSNumericValue.js +17 -17
  81. package/lib/css/index.d.ts +2 -1
  82. package/lib/css/index.js +25 -12
  83. package/lib/css/interfaces.d.ts +6 -0
  84. package/lib/css/interfaces.js +12 -0
  85. package/lib/css/layout/FragmentResult.d.ts +32 -0
  86. package/lib/css/layout/FragmentResult.js +51 -0
  87. package/lib/css/layout/LayoutChildren.d.ts +23 -0
  88. package/lib/css/layout/LayoutChildren.js +72 -0
  89. package/lib/css/layout/LayoutContext.d.ts +35 -0
  90. package/lib/css/layout/LayoutContext.js +49 -0
  91. package/lib/css/layout/LayoutDefinition.d.ts +20 -0
  92. package/lib/css/layout/LayoutDefinition.js +16 -0
  93. package/lib/css/layout/LayoutEdges.d.ts +24 -0
  94. package/lib/css/layout/LayoutEdges.js +56 -0
  95. package/lib/css/layout/LayoutEngine.d.ts +41 -0
  96. package/lib/css/layout/LayoutEngine.js +345 -0
  97. package/lib/css/layout/LayoutFragment.d.ts +26 -0
  98. package/lib/css/layout/LayoutFragment.js +44 -0
  99. package/lib/css/layout/LayoutObject.d.ts +46 -0
  100. package/lib/css/layout/LayoutObject.js +182 -0
  101. package/lib/css/layout/LayoutRegistry.d.ts +16 -0
  102. package/lib/css/layout/LayoutRegistry.js +87 -0
  103. package/lib/css/layout/LayoutWorkTask.d.ts +14 -0
  104. package/lib/css/layout/LayoutWorkTask.js +5 -0
  105. package/lib/css/layout/index.d.ts +11 -0
  106. package/lib/css/layout/index.js +148 -0
  107. package/lib/css/layout/types.d.ts +104 -0
  108. package/lib/css/layout/types.js +74 -0
  109. package/lib/css/parser/numeric.d.ts +1 -1
  110. package/lib/css/parser/numeric.js +4 -4
  111. package/lib/css/parser/transform.js +6 -4
  112. package/lib/css/properties/CSSPropertyColor.d.ts +1 -1
  113. package/lib/css/properties/CSSPropertyLengthOrPercentage.d.ts +1 -1
  114. package/lib/display-objects/DisplayObject.d.ts +1 -2
  115. package/lib/display-objects/DisplayObject.js +3 -2
  116. package/lib/dom/Document.js +2 -2
  117. package/lib/global-module.js +91 -6
  118. package/lib/index.d.ts +3 -0
  119. package/lib/index.js +7 -2
  120. package/lib/plugins/CullingPlugin.d.ts +1 -0
  121. package/lib/plugins/CullingPlugin.js +7 -3
  122. package/lib/plugins/DirtyCheckPlugin.d.ts +1 -0
  123. package/lib/plugins/DirtyCheckPlugin.js +6 -2
  124. package/lib/plugins/EventPlugin.d.ts +1 -0
  125. package/lib/plugins/EventPlugin.js +13 -9
  126. package/lib/plugins/PrepareRendererPlugin.d.ts +1 -0
  127. package/lib/plugins/PrepareRendererPlugin.js +9 -5
  128. package/lib/services/EventService.js +4 -8
  129. package/lib/services/OffscreenCanvasCreator.d.ts +1 -1
  130. package/lib/services/OffscreenCanvasCreator.js +1 -1
  131. package/lib/services/RenderingService.d.ts +18 -18
  132. package/lib/services/RenderingService.js +26 -23
  133. package/lib/services/SceneGraphService.js +3 -1
  134. package/lib/types.d.ts +7 -5
  135. package/lib/utils/deferred.d.ts +43 -0
  136. package/lib/utils/deferred.js +131 -0
  137. package/lib/utils/dom.d.ts +2 -0
  138. package/lib/utils/dom.js +17 -0
  139. package/lib/utils/index.d.ts +2 -1
  140. package/lib/utils/index.js +17 -4
  141. package/lib/utils/interpolation.js +2 -2
  142. package/package.json +4 -3
  143. package/es/css/LayoutRegistry.d.ts +0 -11
  144. package/es/css/LayoutRegistry.js +0 -22
  145. package/es/utils/hooks.d.ts +0 -280
  146. package/es/utils/hooks.js +0 -753
  147. package/lib/css/LayoutRegistry.d.ts +0 -11
  148. package/lib/css/LayoutRegistry.js +0 -30
  149. package/lib/utils/hooks.d.ts +0 -280
  150. package/lib/utils/hooks.js +0 -759
@@ -0,0 +1,16 @@
1
+ import type { LayoutDefinitionCtor } from './LayoutDefinition';
2
+ export declare class LayoutRegistry {
3
+ private static reservedLayout;
4
+ registry: Map<string, LayoutDefinitionCtor>;
5
+ get size(): number;
6
+ hasLayout(name: string): boolean;
7
+ /**
8
+ *
9
+ * @param name layout name, default to 'absolute'
10
+ * @returns layout object
11
+ */
12
+ getLayout(name?: string): LayoutDefinitionCtor;
13
+ updateLayout(name: string, layout: LayoutDefinitionCtor): void;
14
+ registerLayout(name: string, layout: LayoutDefinitionCtor): void;
15
+ deleteLayout(name: string): void;
16
+ }
@@ -0,0 +1,78 @@
1
+ import { __decorate } from "tslib";
2
+ import { singleton } from 'mana-syringe'; // export const LayoutContribution = Syringe.defineToken('LayoutContribution');
3
+ // // eslint-disable-next-line @typescript-eslint/no-redeclare
4
+ // export interface LayoutContribution {
5
+ // registerLayout: (layoutRegistry: LayoutRegistry) => void;
6
+ // }
7
+
8
+ var LayoutRegistry =
9
+ /** @class */
10
+ function () {
11
+ function LayoutRegistry() {
12
+ this.registry = new Map();
13
+ }
14
+
15
+ LayoutRegistry_1 = LayoutRegistry;
16
+ Object.defineProperty(LayoutRegistry.prototype, "size", {
17
+ get: function get() {
18
+ return this.registry.size;
19
+ },
20
+ enumerable: false,
21
+ configurable: true
22
+ });
23
+
24
+ LayoutRegistry.prototype.hasLayout = function (name) {
25
+ return this.registry.has(name);
26
+ };
27
+ /**
28
+ *
29
+ * @param name layout name, default to 'absolute'
30
+ * @returns layout object
31
+ */
32
+
33
+
34
+ LayoutRegistry.prototype.getLayout = function (name) {
35
+ if (name === void 0) {
36
+ name = 'absolute';
37
+ }
38
+
39
+ if (!this.hasLayout(name)) {
40
+ throw new Error("invalid layout property: ".concat(name));
41
+ }
42
+
43
+ return this.registry.get(name);
44
+ };
45
+
46
+ LayoutRegistry.prototype.updateLayout = function (name, layout) {
47
+ this.registry.set(name, layout);
48
+ };
49
+
50
+ LayoutRegistry.prototype.registerLayout = function (name, layout) {
51
+ if (name === '') {
52
+ throw new TypeError("layout name cant't be empty");
53
+ }
54
+
55
+ if (LayoutRegistry_1.reservedLayout.includes(name)) {
56
+ throw new Error("layout name '".concat(name, "' is a system reserved layout name, please use another name"));
57
+ }
58
+
59
+ if (this.hasLayout(name)) {
60
+ throw new Error("layout '".concat(name, "' already exist."));
61
+ }
62
+
63
+ this.registry.set(name, layout);
64
+ };
65
+
66
+ LayoutRegistry.prototype.deleteLayout = function (name) {
67
+ this.registry.delete(name);
68
+ };
69
+
70
+ var LayoutRegistry_1; // 系统保留的布局名称,外部用户不能使用
71
+ // private static reservedLayout = ['relative', 'absolute', 'fixed', 'flex', 'dagre', 'autolayout'];
72
+
73
+ LayoutRegistry.reservedLayout = [];
74
+ LayoutRegistry = LayoutRegistry_1 = __decorate([singleton()], LayoutRegistry);
75
+ return LayoutRegistry;
76
+ }();
77
+
78
+ export { LayoutRegistry };
@@ -0,0 +1,14 @@
1
+ import type { Deferred } from '../../utils';
2
+ import type { LayoutChildren } from './LayoutChildren';
3
+ import type { LayoutFragment } from './LayoutFragment';
4
+ import type { IntrinsicSizes, LayoutConstraints, LayoutTaskType } from './types';
5
+ export declare type LayoutWorkTask = {
6
+ layoutConstraints: LayoutConstraints;
7
+ layoutChild: LayoutChildren;
8
+ taskType: LayoutTaskType.Layout;
9
+ deferred: Deferred<LayoutFragment>;
10
+ } | {
11
+ layoutChild: LayoutChildren;
12
+ taskType: LayoutTaskType.IntrinsicSizes;
13
+ deferred: Deferred<IntrinsicSizes>;
14
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ export * from './FragmentResult';
2
+ export * from './LayoutChildren';
3
+ export * from './LayoutContext';
4
+ export * from './LayoutDefinition';
5
+ export * from './LayoutEdges';
6
+ export * from './LayoutEngine';
7
+ export * from './LayoutFragment';
8
+ export * from './LayoutRegistry';
9
+ export * from './LayoutWorkTask';
10
+ export * from './LayoutObject';
11
+ export * from './types';
@@ -0,0 +1,11 @@
1
+ export * from './FragmentResult';
2
+ export * from './LayoutChildren';
3
+ export * from './LayoutContext';
4
+ export * from './LayoutDefinition';
5
+ export * from './LayoutEdges';
6
+ export * from './LayoutEngine';
7
+ export * from './LayoutFragment';
8
+ export * from './LayoutRegistry';
9
+ export * from './LayoutWorkTask';
10
+ export * from './LayoutObject';
11
+ export * from './types';
@@ -0,0 +1,104 @@
1
+ export declare type ContextId = string;
2
+ export declare enum LayoutTaskType {
3
+ Layout = "layout",
4
+ IntrinsicSizes = "intrinsic-sizes"
5
+ }
6
+ export interface LayoutOptions {
7
+ /**
8
+ * = "block"
9
+ */
10
+ childDisplay: ChildDisplayType;
11
+ /**
12
+ * = "block-like
13
+ */
14
+ sizing: LayoutSizingMode;
15
+ }
16
+ declare enum ChildDisplayType {
17
+ 'block' = 0,
18
+ 'normal' = 1
19
+ }
20
+ declare enum LayoutSizingMode {
21
+ 'block-like' = 0,
22
+ 'manual' = 1
23
+ }
24
+ export interface IntrinsicSizes {
25
+ readonly minContentInlineSize: number;
26
+ readonly minContentBlockSize: number;
27
+ readonly maxContentInlineSize: number;
28
+ readonly maxContentBlockSize: number;
29
+ }
30
+ export interface LayoutConstraints<T = void> {
31
+ /**
32
+ * the available space the current layout must respect
33
+ */
34
+ readonly availableInlineSize: number;
35
+ readonly availableBlockSize: number;
36
+ /**
37
+ * require current layout must to be exact size
38
+ */
39
+ readonly fixedInlineSize?: number;
40
+ readonly fixedBlockSize?: number;
41
+ /**
42
+ * used to resolve percentage value
43
+ * Web developers should resolve any percentages against the percentage sizes.
44
+ * eg. `const value = constraints.percentageInlineSize * 0.5;`
45
+ */
46
+ readonly percentageInlineSize: number;
47
+ readonly percentageBlockSize: number;
48
+ readonly data: T;
49
+ }
50
+ export declare enum PropertyName {
51
+ LAYOUT = "display",
52
+ LEFT = "left",
53
+ TOP = "top",
54
+ BOTTOM = "bottom",
55
+ RIGHT = "right",
56
+ WIDTH = "width",
57
+ HEIGHT = "height",
58
+ MIN_WIDTH = "minWidth",
59
+ MAX_WIDTH = "maxWidth",
60
+ MIN_HEIGHT = "minHeight",
61
+ MAX_HEIGHT = "maxHeight",
62
+ BOX_SIZING = "boxSizing",
63
+ PADDING = "padding",
64
+ PADDING_TOP = "paddingTop",
65
+ PADDING_BOTTOM = "paddingBottom",
66
+ PADDING_START = "paddingLeft",
67
+ PADDING_END = "paddingRight",
68
+ MARGIN = "margin",
69
+ MARGIN_TOP = "marginTop",
70
+ MARGIN_BOTTOM = "marginBottom",
71
+ MARGIN_START = "marginLeft",
72
+ MARGIN_END = "marginRight",
73
+ BORDER = "border",
74
+ BORDER_TOP = "borderTop",
75
+ BORDER_BOTTOM = "borderBottom",
76
+ BORDER_START = "borderLeft",
77
+ BORDER_END = "borderRight",
78
+ FLEX_DIRECTION = "flexDirection",
79
+ FLEX_WRAP = "flexWrap",
80
+ FLEX_FLOW = "flexFlow",
81
+ ALIGN_ITEMS = "alignItems",
82
+ ALIGN_CONTENT = "alignContent",
83
+ JUSTIFY_CONTENT = "justifyContent",
84
+ FLEX = "flex",
85
+ ALIGN_SELF = "alignSelf",
86
+ FLEX_SHRINK = "flexShrink",
87
+ FLEX_BASIS = "flexBasis",
88
+ FLEX_GROW = "flexGrow",
89
+ OFFSET_WIDTH = "offsetWidth",
90
+ OFFSET_HEIGHT = "offsetHeight",
91
+ ORDER = "order"
92
+ }
93
+ export declare type MeasureFn = (width?: number, height?: number) => {
94
+ width: number;
95
+ height: number;
96
+ };
97
+ export interface ComputedLayout {
98
+ readonly width: number;
99
+ readonly height: number;
100
+ readonly x: number;
101
+ readonly y: number;
102
+ readonly children: ComputedLayout[];
103
+ }
104
+ export {};
@@ -0,0 +1,66 @@
1
+ export var LayoutTaskType;
2
+
3
+ (function (LayoutTaskType) {
4
+ LayoutTaskType["Layout"] = "layout";
5
+ LayoutTaskType["IntrinsicSizes"] = "intrinsic-sizes";
6
+ })(LayoutTaskType || (LayoutTaskType = {}));
7
+
8
+ var ChildDisplayType;
9
+
10
+ (function (ChildDisplayType) {
11
+ ChildDisplayType[ChildDisplayType["block"] = 0] = "block";
12
+ ChildDisplayType[ChildDisplayType["normal"] = 1] = "normal";
13
+ })(ChildDisplayType || (ChildDisplayType = {}));
14
+
15
+ var LayoutSizingMode;
16
+
17
+ (function (LayoutSizingMode) {
18
+ LayoutSizingMode[LayoutSizingMode["block-like"] = 0] = "block-like";
19
+ LayoutSizingMode[LayoutSizingMode["manual"] = 1] = "manual";
20
+ })(LayoutSizingMode || (LayoutSizingMode = {}));
21
+
22
+ export var PropertyName;
23
+
24
+ (function (PropertyName) {
25
+ PropertyName["LAYOUT"] = "display";
26
+ PropertyName["LEFT"] = "left";
27
+ PropertyName["TOP"] = "top";
28
+ PropertyName["BOTTOM"] = "bottom";
29
+ PropertyName["RIGHT"] = "right";
30
+ PropertyName["WIDTH"] = "width";
31
+ PropertyName["HEIGHT"] = "height";
32
+ PropertyName["MIN_WIDTH"] = "minWidth";
33
+ PropertyName["MAX_WIDTH"] = "maxWidth";
34
+ PropertyName["MIN_HEIGHT"] = "minHeight";
35
+ PropertyName["MAX_HEIGHT"] = "maxHeight";
36
+ PropertyName["BOX_SIZING"] = "boxSizing";
37
+ PropertyName["PADDING"] = "padding";
38
+ PropertyName["PADDING_TOP"] = "paddingTop";
39
+ PropertyName["PADDING_BOTTOM"] = "paddingBottom";
40
+ PropertyName["PADDING_START"] = "paddingLeft";
41
+ PropertyName["PADDING_END"] = "paddingRight";
42
+ PropertyName["MARGIN"] = "margin";
43
+ PropertyName["MARGIN_TOP"] = "marginTop";
44
+ PropertyName["MARGIN_BOTTOM"] = "marginBottom";
45
+ PropertyName["MARGIN_START"] = "marginLeft";
46
+ PropertyName["MARGIN_END"] = "marginRight";
47
+ PropertyName["BORDER"] = "border";
48
+ PropertyName["BORDER_TOP"] = "borderTop";
49
+ PropertyName["BORDER_BOTTOM"] = "borderBottom";
50
+ PropertyName["BORDER_START"] = "borderLeft";
51
+ PropertyName["BORDER_END"] = "borderRight";
52
+ PropertyName["FLEX_DIRECTION"] = "flexDirection";
53
+ PropertyName["FLEX_WRAP"] = "flexWrap";
54
+ PropertyName["FLEX_FLOW"] = "flexFlow";
55
+ PropertyName["ALIGN_ITEMS"] = "alignItems";
56
+ PropertyName["ALIGN_CONTENT"] = "alignContent";
57
+ PropertyName["JUSTIFY_CONTENT"] = "justifyContent";
58
+ PropertyName["FLEX"] = "flex";
59
+ PropertyName["ALIGN_SELF"] = "alignSelf";
60
+ PropertyName["FLEX_SHRINK"] = "flexShrink";
61
+ PropertyName["FLEX_BASIS"] = "flexBasis";
62
+ PropertyName["FLEX_GROW"] = "flexGrow";
63
+ PropertyName["OFFSET_WIDTH"] = "offsetWidth";
64
+ PropertyName["OFFSET_HEIGHT"] = "offsetHeight";
65
+ PropertyName["ORDER"] = "order";
66
+ })(PropertyName || (PropertyName = {}));
@@ -1,4 +1,4 @@
1
- import { CSSUnitValue } from '../cssom';
1
+ import { CSSUnitValue } from '../cssom/CSSNumericValue';
2
2
  export declare function numberToString(x: number): string;
3
3
  /**
4
4
  * parse string or number to CSSUnitValue(numeric)
@@ -1,5 +1,5 @@
1
1
  import { clamp, isString } from '../../utils';
2
- import { CSSUnitValue } from '../cssom';
2
+ import { CSSUnitValue } from '../cssom/CSSNumericValue';
3
3
  export function numberToString(x) {
4
4
  // scale(0.00000001) -> scale(0)
5
5
  // return x.toFixed(6).replace(/0+$/, '').replace(/\.$/, '');
@@ -2,6 +2,7 @@ import { UnitType } from '../cssom/types';
2
2
  import { CSSUnitValue, Opx, Odeg } from '../cssom/CSSNumericValue';
3
3
  import { mergeDimensions, parseAngle, parseLength, parseLengthOrPercentage } from './dimension';
4
4
  import { mergeNumbers, parseNumber } from './numeric';
5
+ import { CSS } from '../CSS';
5
6
  var _ = null;
6
7
 
7
8
  function cast(pattern) {
@@ -28,10 +29,10 @@ var transformFunctions = {
28
29
  rotatez: ['A'],
29
30
  rotate3d: ['NNNA'],
30
31
  // perspective: ['L'],
31
- scale: ['Nn', cast([_, _, new CSSUnitValue(1)]), id],
32
- scalex: ['N', cast([_, new CSSUnitValue(1), new CSSUnitValue(1)]), cast([_, new CSSUnitValue(1)])],
33
- scaley: ['N', cast([new CSSUnitValue(1), _, new CSSUnitValue(1)]), cast([new CSSUnitValue(1), _])],
34
- scalez: ['N', cast([new CSSUnitValue(1), new CSSUnitValue(1), _])],
32
+ scale: ['Nn', cast([_, _, CSS.number(1)]), id],
33
+ scalex: ['N', cast([_, CSS.number(1), CSS.number(1)]), cast([_, CSS.number(1)])],
34
+ scaley: ['N', cast([CSS.number(1), _, CSS.number(1)]), cast([CSS.number(1), _])],
35
+ scalez: ['N', cast([CSS.number(1), CSS.number(1), _])],
35
36
  scale3d: ['NNN', id],
36
37
  // skew: ['Aa', null, id],
37
38
  // skewx: ['A', null, cast([_, Odeg])],
@@ -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
  /**
@@ -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
  */
@@ -10,7 +10,7 @@ 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';
13
+ import { StyleValueRegistry } from '../css/interfaces';
14
14
  import { CSSUnitValue } from '../css';
15
15
  var DEFAULT_STYLE_PROPS = {
16
16
  x: '',
@@ -27,6 +27,7 @@ var DEFAULT_STYLE_PROPS = {
27
27
  pointerEvents: '',
28
28
  lineCap: '',
29
29
  lineJoin: '',
30
+ increasedLineWidthForHitTesting: '0',
30
31
  fontSize: '',
31
32
  fontFamily: '',
32
33
  fontStyle: '',
@@ -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,
@@ -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;