@antv/g 5.0.23 → 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 (100) hide show
  1. package/dist/index.umd.min.js +3 -2
  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/components/Geometry.d.ts +0 -4
  6. package/es/css/CSS.d.ts +2 -1
  7. package/es/css/CSS.js +5 -1
  8. package/es/css/StyleValueRegistry.js +3 -16
  9. package/es/css/index.d.ts +1 -1
  10. package/es/css/index.js +1 -1
  11. package/es/css/layout/FragmentResult.d.ts +32 -0
  12. package/es/css/layout/FragmentResult.js +32 -0
  13. package/es/css/layout/LayoutChildren.d.ts +23 -0
  14. package/es/css/layout/LayoutChildren.js +55 -0
  15. package/es/css/layout/LayoutContext.d.ts +35 -0
  16. package/es/css/layout/LayoutContext.js +35 -0
  17. package/es/css/layout/LayoutDefinition.d.ts +20 -0
  18. package/es/css/layout/LayoutDefinition.js +9 -0
  19. package/es/css/layout/LayoutEdges.d.ts +24 -0
  20. package/es/css/layout/LayoutEdges.js +41 -0
  21. package/es/css/layout/LayoutEngine.d.ts +41 -0
  22. package/es/css/layout/LayoutEngine.js +332 -0
  23. package/es/css/layout/LayoutFragment.d.ts +26 -0
  24. package/es/css/layout/LayoutFragment.js +28 -0
  25. package/es/css/layout/LayoutObject.d.ts +46 -0
  26. package/es/css/layout/LayoutObject.js +172 -0
  27. package/es/css/layout/LayoutRegistry.d.ts +16 -0
  28. package/es/css/layout/LayoutRegistry.js +78 -0
  29. package/es/css/layout/LayoutWorkTask.d.ts +14 -0
  30. package/es/css/layout/LayoutWorkTask.js +1 -0
  31. package/es/css/layout/index.d.ts +11 -0
  32. package/es/css/layout/index.js +11 -0
  33. package/es/css/layout/types.d.ts +104 -0
  34. package/es/css/layout/types.js +66 -0
  35. package/es/global-module.js +87 -1
  36. package/es/index.d.ts +3 -0
  37. package/es/index.js +3 -0
  38. package/es/services/OffscreenCanvasCreator.d.ts +1 -1
  39. package/es/services/OffscreenCanvasCreator.js +1 -1
  40. package/es/services/RenderingService.d.ts +1 -1
  41. package/es/services/RenderingService.js +1 -1
  42. package/es/types.d.ts +1 -4
  43. package/es/utils/deferred.d.ts +43 -0
  44. package/es/utils/deferred.js +117 -0
  45. package/es/utils/dom.d.ts +2 -0
  46. package/es/utils/dom.js +8 -0
  47. package/es/utils/index.d.ts +2 -0
  48. package/es/utils/index.js +3 -1
  49. package/lib/AbstractRenderer.d.ts +11 -0
  50. package/lib/AbstractRenderer.js +17 -2
  51. package/lib/Canvas.d.ts +1 -1
  52. package/lib/components/Geometry.d.ts +0 -4
  53. package/lib/css/CSS.d.ts +2 -1
  54. package/lib/css/CSS.js +7 -1
  55. package/lib/css/StyleValueRegistry.js +3 -17
  56. package/lib/css/index.d.ts +1 -1
  57. package/lib/css/index.js +12 -12
  58. package/lib/css/layout/FragmentResult.d.ts +32 -0
  59. package/lib/css/layout/FragmentResult.js +51 -0
  60. package/lib/css/layout/LayoutChildren.d.ts +23 -0
  61. package/lib/css/layout/LayoutChildren.js +72 -0
  62. package/lib/css/layout/LayoutContext.d.ts +35 -0
  63. package/lib/css/layout/LayoutContext.js +49 -0
  64. package/lib/css/layout/LayoutDefinition.d.ts +20 -0
  65. package/lib/css/layout/LayoutDefinition.js +16 -0
  66. package/lib/css/layout/LayoutEdges.d.ts +24 -0
  67. package/lib/css/layout/LayoutEdges.js +56 -0
  68. package/lib/css/layout/LayoutEngine.d.ts +41 -0
  69. package/lib/css/layout/LayoutEngine.js +345 -0
  70. package/lib/css/layout/LayoutFragment.d.ts +26 -0
  71. package/lib/css/layout/LayoutFragment.js +44 -0
  72. package/lib/css/layout/LayoutObject.d.ts +46 -0
  73. package/lib/css/layout/LayoutObject.js +182 -0
  74. package/lib/css/layout/LayoutRegistry.d.ts +16 -0
  75. package/lib/css/layout/LayoutRegistry.js +87 -0
  76. package/lib/css/layout/LayoutWorkTask.d.ts +14 -0
  77. package/lib/css/layout/LayoutWorkTask.js +5 -0
  78. package/lib/css/layout/index.d.ts +11 -0
  79. package/lib/css/layout/index.js +148 -0
  80. package/lib/css/layout/types.d.ts +104 -0
  81. package/lib/css/layout/types.js +74 -0
  82. package/lib/global-module.js +89 -1
  83. package/lib/index.d.ts +3 -0
  84. package/lib/index.js +7 -2
  85. package/lib/services/OffscreenCanvasCreator.d.ts +1 -1
  86. package/lib/services/OffscreenCanvasCreator.js +1 -1
  87. package/lib/services/RenderingService.d.ts +1 -1
  88. package/lib/services/RenderingService.js +1 -1
  89. package/lib/types.d.ts +1 -4
  90. package/lib/utils/deferred.d.ts +43 -0
  91. package/lib/utils/deferred.js +131 -0
  92. package/lib/utils/dom.d.ts +2 -0
  93. package/lib/utils/dom.js +17 -0
  94. package/lib/utils/index.d.ts +2 -0
  95. package/lib/utils/index.js +26 -0
  96. package/package.json +3 -3
  97. package/es/css/LayoutRegistry.d.ts +0 -11
  98. package/es/css/LayoutRegistry.js +0 -22
  99. package/lib/css/LayoutRegistry.d.ts +0 -11
  100. package/lib/css/LayoutRegistry.js +0 -30
@@ -1,6 +1,7 @@
1
1
  import type { Syringe } from 'mana-syringe';
2
2
  import type { RendererConfig } from './types';
3
3
  export interface RendererPlugin {
4
+ name: string;
4
5
  init: (container: Syringe.Container) => void;
5
6
  destroy: (container: Syringe.Container) => void;
6
7
  }
@@ -10,6 +11,14 @@ export interface IRenderer {
10
11
  * register plugin at runtime
11
12
  */
12
13
  registerPlugin: (plugin: RendererPlugin) => void;
14
+ /**
15
+ * unregister plugin at runtime
16
+ */
17
+ unregisterPlugin: (plugin: RendererPlugin) => void;
18
+ /**
19
+ * get plugin by name
20
+ */
21
+ getPlugin: (name: string) => RendererPlugin;
13
22
  /**
14
23
  * return all registered plugins
15
24
  */
@@ -20,7 +29,9 @@ export declare class AbstractRenderer implements IRenderer {
20
29
  private config;
21
30
  constructor(config?: Partial<RendererConfig>);
22
31
  registerPlugin(plugin: RendererPlugin): void;
32
+ unregisterPlugin(plugin: RendererPlugin): void;
23
33
  getPlugins(): RendererPlugin[];
34
+ getPlugin(name: string): RendererPlugin;
24
35
  getConfig(): RendererConfig;
25
36
  setConfig(config: Partial<RendererConfig>): void;
26
37
  }
@@ -20,8 +20,7 @@ function () {
20
20
  * enable dirty rectangle rendering by default
21
21
  */
22
22
  enableDirtyRectangleRendering: true,
23
- enableDirtyRectangleRenderingDebug: false,
24
- enableTAA: false
23
+ enableDirtyRectangleRenderingDebug: false
25
24
  }, config);
26
25
  }
27
26
 
@@ -29,10 +28,26 @@ function () {
29
28
  this.plugins.push(plugin);
30
29
  };
31
30
 
31
+ AbstractRenderer.prototype.unregisterPlugin = function (plugin) {
32
+ var index = this.plugins.findIndex(function (p) {
33
+ return p === plugin;
34
+ });
35
+
36
+ if (index > -1) {
37
+ this.plugins.splice(index, 1);
38
+ }
39
+ };
40
+
32
41
  AbstractRenderer.prototype.getPlugins = function () {
33
42
  return this.plugins;
34
43
  };
35
44
 
45
+ AbstractRenderer.prototype.getPlugin = function (name) {
46
+ return this.plugins.find(function (plugin) {
47
+ return plugin.name === name;
48
+ });
49
+ };
50
+
36
51
  AbstractRenderer.prototype.getConfig = function () {
37
52
  return this.config;
38
53
  };
package/es/Canvas.d.ts CHANGED
@@ -96,7 +96,7 @@ export declare class Canvas extends EventTarget implements ICanvas {
96
96
  * get the root displayObject in scenegraph
97
97
  * @alias this.document.documentElement
98
98
  */
99
- getRoot(): import("./display-objects").Group;
99
+ getRoot(): import(".").Group;
100
100
  /**
101
101
  * get the camera of canvas
102
102
  */
@@ -9,8 +9,4 @@ export declare class Geometry {
9
9
  * including extra rendering effects, eg. shadowBlur filters(drop-shadow, blur)
10
10
  */
11
11
  renderBounds: AABB | undefined;
12
- /**
13
- * account for `hitArea` & `increasedLineWidthForHitTesting`
14
- */
15
- hitAreaBounds: AABB | undefined;
16
12
  }
package/es/css/CSS.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { CSSUnitValue } from './cssom';
2
+ import type { LayoutDefinitionCtor } from './layout';
2
3
  /**
3
4
  * @see https://developer.mozilla.org/en-US/docs/Web/API/CSS/RegisterProperty#parameters
4
5
  */
@@ -80,5 +81,5 @@ export declare const CSS: {
80
81
  * @see https://github.com/w3c/css-houdini-drafts/blob/main/css-layout-api/EXPLAINER.md
81
82
  * @see https://developer.mozilla.org/en-US/docs/Web/Guide/Houdini#css_layout_api
82
83
  */
83
- registerLayout: (name: string) => void;
84
+ registerLayout: (name: string, clazz: LayoutDefinitionCtor) => void;
84
85
  };
package/es/css/CSS.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { GlobalContainer } from 'mana-syringe';
2
2
  import { CSSUnitValue } from './cssom';
3
3
  import { StyleValueRegistry } from './interfaces';
4
+ import { LayoutRegistry } from './layout';
4
5
  /**
5
6
  * holds useful CSS-related methods.
6
7
  * @see https://developer.mozilla.org/en-US/docs/Web/API/CSS
@@ -109,5 +110,8 @@ export var CSS = {
109
110
  * @see https://github.com/w3c/css-houdini-drafts/blob/main/css-layout-api/EXPLAINER.md
110
111
  * @see https://developer.mozilla.org/en-US/docs/Web/Guide/Houdini#css_layout_api
111
112
  */
112
- registerLayout: function registerLayout(name) {}
113
+ registerLayout: function registerLayout(name, clazz) {
114
+ var layoutRegistry = GlobalContainer.get(LayoutRegistry);
115
+ layoutRegistry.registerLayout(name, clazz);
116
+ }
113
117
  };
@@ -142,7 +142,6 @@ export var BUILT_IN_PROPERTIES = [{
142
142
  inherited: true,
143
143
  defaultValue: '0',
144
144
  layoutDependent: true,
145
- alias: ['lineAppendWidth'],
146
145
  syntax: PropertySyntax.LENGTH_PERCENTAGE,
147
146
  handler: CSSPropertyLengthOrPercentage
148
147
  }, {
@@ -764,10 +763,6 @@ function () {
764
763
  geometry_1.renderBounds = new AABB();
765
764
  }
766
765
 
767
- if (!geometry_1.hitAreaBounds) {
768
- geometry_1.hitAreaBounds = new AABB();
769
- }
770
-
771
766
  var parsedStyle = object.parsedStyle;
772
767
 
773
768
  var _b = geometryUpdater.update(parsedStyle, object),
@@ -819,18 +814,10 @@ function () {
819
814
  var center = vec3.fromValues((1 - (anchor && anchor[0].value || 0) * 2) * halfExtents[0] + offsetX, (1 - (anchor && anchor[1].value || 0) * 2) * halfExtents[1] + offsetY, (1 - (anchor && ((_a = anchor[2]) === null || _a === void 0 ? void 0 : _a.value) || 0) * 2) * halfExtents[2] + offsetZ); // update geometry's AABB
820
815
 
821
816
  geometry_1.contentBounds.update(center, halfExtents);
817
+ var halfLineWidth = (((lineWidth === null || lineWidth === void 0 ? void 0 : lineWidth.value) || 0) + ((increasedLineWidthForHitTesting === null || increasedLineWidthForHitTesting === void 0 ? void 0 : increasedLineWidthForHitTesting.value) || 0)) / 2; // append border
822
818
 
823
- if (lineWidth) {
824
- // append border
825
- vec3.add(halfExtents, halfExtents, vec3.fromValues(lineWidth.value / 2, lineWidth.value / 2, 0));
826
- geometry_1.renderBounds.update(center, halfExtents);
827
- }
828
-
829
- if (increasedLineWidthForHitTesting) {
830
- vec3.add(halfExtents, halfExtents, vec3.fromValues(increasedLineWidthForHitTesting.value / 2, increasedLineWidthForHitTesting.value / 2, 0));
831
- geometry_1.hitAreaBounds.update(center, halfExtents);
832
- } // account for shadow, only support constant value now
833
-
819
+ vec3.add(halfExtents, halfExtents, vec3.fromValues(halfLineWidth, halfLineWidth, 0));
820
+ geometry_1.renderBounds.update(center, halfExtents); // account for shadow, only support constant value now
834
821
 
835
822
  if (shadowColor) {
836
823
  var _l = geometry_1.renderBounds,
package/es/css/index.d.ts CHANGED
@@ -5,7 +5,7 @@ export * from './interfaces';
5
5
  export * from './cssom';
6
6
  export * from './parser';
7
7
  export * from './properties';
8
+ export * from './layout';
8
9
  export * from './CSS';
9
10
  export * from './CSSProperty';
10
- export * from './LayoutRegistry';
11
11
  export * from './StyleValueRegistry';
package/es/css/index.js CHANGED
@@ -5,7 +5,7 @@ export * from './interfaces';
5
5
  export * from './cssom';
6
6
  export * from './parser';
7
7
  export * from './properties';
8
+ export * from './layout';
8
9
  export * from './CSS';
9
10
  export * from './CSSProperty';
10
- export * from './LayoutRegistry';
11
11
  export * from './StyleValueRegistry';
@@ -0,0 +1,32 @@
1
+ import { Syringe } from 'mana-syringe';
2
+ import { LayoutObject } from './LayoutObject';
3
+ import { LayoutContext } from './LayoutContext';
4
+ import type { LayoutFragment } from './LayoutFragment';
5
+ export declare const FragmentResultFactory: Syringe.DefinedToken;
6
+ export interface FragmentResultFactory {
7
+ (options: FragmentResultOptions): FragmentResult;
8
+ }
9
+ /**
10
+ * The web developer defined layout method can return either a FragmentResultOptions or a FragmentResult.
11
+ */
12
+ export declare const FragmentResultOptions: Syringe.DefinedToken;
13
+ export interface FragmentResultOptions<T = void> {
14
+ inlineSize: number;
15
+ blockSize: number;
16
+ autoBlockSize: number;
17
+ childFragments: LayoutFragment[];
18
+ data: T;
19
+ }
20
+ export declare const ContextNode: Syringe.DefinedToken;
21
+ export declare class FragmentResult<T = void> {
22
+ protected readonly _layoutContext: LayoutContext;
23
+ protected readonly _node: LayoutObject;
24
+ protected readonly options: FragmentResultOptions<T>;
25
+ private layoutContext;
26
+ readonly inlineSize: number;
27
+ readonly blockSize: number;
28
+ private node;
29
+ childFragments: LayoutFragment[];
30
+ data: T;
31
+ constructor(_layoutContext: LayoutContext, _node: LayoutObject, options: FragmentResultOptions<T>);
32
+ }
@@ -0,0 +1,32 @@
1
+ import { __decorate, __metadata, __param } from "tslib";
2
+ import { inject, injectable, Syringe } from 'mana-syringe';
3
+ import { LayoutObject } from './LayoutObject';
4
+ import { LayoutContext } from './LayoutContext';
5
+ export var FragmentResultFactory = Syringe.defineToken('FragmentResultFactory');
6
+ /**
7
+ * The web developer defined layout method can return either a FragmentResultOptions or a FragmentResult.
8
+ */
9
+
10
+ export var FragmentResultOptions = Syringe.defineToken('FragmentResultOptions');
11
+ export var ContextNode = Syringe.defineToken('contextNode');
12
+
13
+ var FragmentResult =
14
+ /** @class */
15
+ function () {
16
+ function FragmentResult(_layoutContext, _node, options) {
17
+ this._layoutContext = _layoutContext;
18
+ this._node = _node;
19
+ this.options = options;
20
+ this.layoutContext = _layoutContext;
21
+ this.inlineSize = options === null || options === void 0 ? void 0 : options.inlineSize;
22
+ this.blockSize = options === null || options === void 0 ? void 0 : options.blockSize;
23
+ this.childFragments = options === null || options === void 0 ? void 0 : options.childFragments;
24
+ this.data = options.data;
25
+ this.node = _node;
26
+ }
27
+
28
+ FragmentResult = __decorate([injectable(), __param(0, inject(LayoutContext)), __param(1, inject(ContextNode)), __param(2, inject(FragmentResultOptions)), __metadata("design:paramtypes", [LayoutContext, LayoutObject, Object])], FragmentResult);
29
+ return FragmentResult;
30
+ }();
31
+
32
+ export { FragmentResult };
@@ -0,0 +1,23 @@
1
+ import { Syringe } from 'mana-syringe';
2
+ import type { LayoutObject } from './LayoutObject';
3
+ import { LayoutContext } from './LayoutContext';
4
+ import type { LayoutFragment } from './LayoutFragment';
5
+ import type { IntrinsicSizes, LayoutConstraints } from './types';
6
+ export declare const LayoutChildrenFactory: Syringe.DefinedToken;
7
+ export interface LayoutChildrenFactory {
8
+ (options: LayoutChildrenOptions): LayoutChildren;
9
+ }
10
+ export declare const LayoutChildrenOptions: Syringe.DefinedToken;
11
+ export interface LayoutChildrenOptions {
12
+ node: LayoutObject;
13
+ }
14
+ export declare class LayoutChildren {
15
+ protected readonly _layoutContext: LayoutContext;
16
+ protected readonly options: LayoutChildrenOptions;
17
+ node: LayoutObject;
18
+ readonly styleMap: Map<string, any>;
19
+ layoutContext: LayoutContext;
20
+ constructor(_layoutContext: LayoutContext, options: LayoutChildrenOptions);
21
+ intrinsicSizes(): Promise<IntrinsicSizes>;
22
+ layoutNextFragment(constraints: LayoutConstraints): Promise<LayoutFragment>;
23
+ }
@@ -0,0 +1,55 @@
1
+ import { __decorate, __metadata, __param } from "tslib";
2
+ import { inject, injectable, Syringe } from 'mana-syringe';
3
+ import { Deferred } from '../../utils';
4
+ import { LayoutContext } from './LayoutContext';
5
+ import { LayoutTaskType } from './types';
6
+ export var LayoutChildrenFactory = Syringe.defineToken('LayoutChildrenFactory');
7
+ export var LayoutChildrenOptions = Syringe.defineToken('LayoutChildrenOptions');
8
+
9
+ var LayoutChildren =
10
+ /** @class */
11
+ function () {
12
+ function LayoutChildren(_layoutContext, options) {
13
+ this._layoutContext = _layoutContext;
14
+ this.options = options;
15
+ this.layoutContext = _layoutContext;
16
+ this.node = options.node;
17
+ this.styleMap = options.node.getAllStyle();
18
+ }
19
+
20
+ LayoutChildren.prototype.intrinsicSizes = function () {
21
+ // if (this.contextId !== this.layoutContext.contextId) {
22
+ // throw new Error('Invalid State: wrong layout context');
23
+ // }
24
+ var deferred = new Deferred();
25
+ this.layoutContext.appendWorkTask({
26
+ layoutChild: this,
27
+ taskType: LayoutTaskType.IntrinsicSizes,
28
+ deferred: deferred
29
+ });
30
+ return deferred.promise;
31
+ };
32
+
33
+ LayoutChildren.prototype.layoutNextFragment = function (constraints) {
34
+ // if (this.layoutContext.contextId !== this.layoutContext.contextId) {
35
+ // throw new Error('Invalid State: wrong layout context');
36
+ // }
37
+ if (this.layoutContext.mode === LayoutTaskType.IntrinsicSizes) {
38
+ throw new Error('Not Supported: cant call layoutNextFragment in intrinsicSizes');
39
+ }
40
+
41
+ var deferred = new Deferred();
42
+ this.layoutContext.appendWorkTask({
43
+ layoutConstraints: constraints,
44
+ layoutChild: this,
45
+ taskType: LayoutTaskType.Layout,
46
+ deferred: deferred
47
+ });
48
+ return deferred.promise;
49
+ };
50
+
51
+ LayoutChildren = __decorate([injectable(), __param(0, inject(LayoutContext)), __param(1, inject(LayoutChildrenOptions)), __metadata("design:paramtypes", [LayoutContext, Object])], LayoutChildren);
52
+ return LayoutChildren;
53
+ }();
54
+
55
+ export { LayoutChildren };
@@ -0,0 +1,35 @@
1
+ import { Syringe } from 'mana-syringe';
2
+ import type { LayoutWorkTask } from './LayoutWorkTask';
3
+ import type { LayoutTaskType } from './types';
4
+ import type { ContextId } from './types';
5
+ import type { FragmentResultFactory } from './FragmentResult';
6
+ import type { LayoutChildrenFactory } from './LayoutChildren';
7
+ import type { LayoutFragmentFactory } from './LayoutFragment';
8
+ export declare const LayoutContextFactory: Syringe.DefinedToken;
9
+ export interface LayoutContextFactory {
10
+ (options: {
11
+ mode: LayoutTaskType;
12
+ }): LayoutContext;
13
+ }
14
+ export declare const LayoutContextOptions: Syringe.DefinedToken;
15
+ export interface LayoutContextOptions {
16
+ mode: LayoutTaskType;
17
+ layoutChildrenFactory: LayoutChildrenFactory;
18
+ fragmentResultFactory: FragmentResultFactory;
19
+ layoutFragmentFactory: LayoutFragmentFactory;
20
+ }
21
+ /**
22
+ * 每次layout 有单独的 context
23
+ */
24
+ export declare class LayoutContext {
25
+ protected readonly options: LayoutContextOptions;
26
+ contextId: ContextId;
27
+ workQueue: LayoutWorkTask[];
28
+ mode: LayoutTaskType;
29
+ layoutChildrenFactory: LayoutChildrenFactory;
30
+ fragmentResultFactory: FragmentResultFactory;
31
+ layoutFragmentFactory: LayoutFragmentFactory;
32
+ constructor(options: LayoutContextOptions);
33
+ appendWorkTask(work: LayoutWorkTask): void;
34
+ clearWorkQueue(): void;
35
+ }
@@ -0,0 +1,35 @@
1
+ import { __decorate, __metadata, __param } from "tslib";
2
+ import { inject, singleton, Syringe } from 'mana-syringe';
3
+ export var LayoutContextFactory = Syringe.defineToken('LayoutContextFactory');
4
+ export var LayoutContextOptions = Syringe.defineToken('LayoutContextOptions');
5
+ var guid = 0;
6
+ /**
7
+ * 每次layout 有单独的 context
8
+ */
9
+
10
+ var LayoutContext =
11
+ /** @class */
12
+ function () {
13
+ function LayoutContext(options) {
14
+ this.options = options;
15
+ this.workQueue = [];
16
+ this.contextId = "".concat(guid++);
17
+ this.mode = options.mode;
18
+ this.layoutChildrenFactory = options.layoutChildrenFactory;
19
+ this.fragmentResultFactory = options.fragmentResultFactory;
20
+ this.layoutFragmentFactory = options.layoutFragmentFactory;
21
+ }
22
+
23
+ LayoutContext.prototype.appendWorkTask = function (work) {
24
+ this.workQueue.push(work);
25
+ };
26
+
27
+ LayoutContext.prototype.clearWorkQueue = function () {
28
+ this.workQueue = [];
29
+ };
30
+
31
+ LayoutContext = __decorate([singleton(), __param(0, inject(LayoutContextOptions)), __metadata("design:paramtypes", [Object])], LayoutContext);
32
+ return LayoutContext;
33
+ }();
34
+
35
+ export { LayoutContext };
@@ -0,0 +1,20 @@
1
+ import type { IntrinsicSizes, LayoutConstraints, LayoutOptions } from './types';
2
+ import type { FragmentResultOptions, FragmentResult } from './FragmentResult';
3
+ import type { LayoutChildren } from './LayoutChildren';
4
+ import type { LayoutEdges } from './LayoutEdges';
5
+ export declare abstract class AbstractLayoutDefinition {
6
+ static inputProperties: string[];
7
+ static childrenInputProperties: string[];
8
+ static layoutOptions: LayoutOptions;
9
+ abstract intrinsicSizes(children: LayoutChildren[], edges: LayoutEdges, styleMap: Map<string, any>): Promise<IntrinsicSizes>;
10
+ abstract layout(children: LayoutChildren[], edges: LayoutEdges, constraints: LayoutConstraints, styleMap: Map<string, any>): Promise<FragmentResultOptions | FragmentResult>;
11
+ }
12
+ /**
13
+ * internal use
14
+ */
15
+ export declare type LayoutDefinitionCtor = {
16
+ new (): AbstractLayoutDefinition;
17
+ inputProperties: string[];
18
+ childrenInputProperties: string[];
19
+ layoutOptions: LayoutOptions;
20
+ };
@@ -0,0 +1,9 @@
1
+ var AbstractLayoutDefinition =
2
+ /** @class */
3
+ function () {
4
+ function AbstractLayoutDefinition() {}
5
+
6
+ return AbstractLayoutDefinition;
7
+ }();
8
+
9
+ export { AbstractLayoutDefinition };
@@ -0,0 +1,24 @@
1
+ import { Syringe } from 'mana-syringe';
2
+ import type { LayoutObject } from './LayoutObject';
3
+ export declare const LayoutEdgesFactory: Syringe.DefinedToken;
4
+ export interface LayoutEdgesFactory {
5
+ (options: LayoutEdgesOptions): LayoutEdges;
6
+ }
7
+ export declare const LayoutEdgesOptions: Syringe.DefinedToken;
8
+ export interface LayoutEdgesOptions {
9
+ node: LayoutObject;
10
+ }
11
+ /**
12
+ * https://drafts.css-houdini.org/css-layout-api/#layoutedges
13
+ * the size of border, scrollbar, padding
14
+ */
15
+ export declare class LayoutEdges {
16
+ protected readonly options: LayoutEdgesOptions;
17
+ readonly inlineStart: number;
18
+ readonly inlineEnd: number;
19
+ readonly blockStart: number;
20
+ readonly blockEnd: number;
21
+ readonly inline: number;
22
+ readonly block: number;
23
+ constructor(options: LayoutEdgesOptions);
24
+ }
@@ -0,0 +1,41 @@
1
+ import { __decorate, __metadata, __param } from "tslib";
2
+ import { inject, injectable, Syringe } from 'mana-syringe';
3
+ import { PropertyName } from './types';
4
+ export var LayoutEdgesFactory = Syringe.defineToken('LayoutEdgesFactory');
5
+ export var LayoutEdgesOptions = Syringe.defineToken('LayoutEdgesOptions');
6
+ var SCROLLBAR_SIZES = [0, 0, 0, 0];
7
+ /**
8
+ * https://drafts.css-houdini.org/css-layout-api/#layoutedges
9
+ * the size of border, scrollbar, padding
10
+ */
11
+
12
+ var LayoutEdges =
13
+ /** @class */
14
+ function () {
15
+ function LayoutEdges(options) {
16
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
17
+
18
+ this.options = options;
19
+ var node = options.node;
20
+ var styleMap = node.getAllStyle();
21
+ var borderTopWidth = (_b = (_a = styleMap.get(PropertyName.PADDING_TOP)) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 0;
22
+ var borderRightWidth = (_d = (_c = styleMap.get(PropertyName.PADDING_END)) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : 0;
23
+ var borderBottomWidth = (_f = (_e = styleMap.get(PropertyName.PADDING_BOTTOM)) === null || _e === void 0 ? void 0 : _e.value) !== null && _f !== void 0 ? _f : 0;
24
+ var borderLeftWidth = (_h = (_g = styleMap.get(PropertyName.PADDING_START)) === null || _g === void 0 ? void 0 : _g.value) !== null && _h !== void 0 ? _h : 0;
25
+ var paddingTopWidth = (_k = (_j = styleMap.get(PropertyName.PADDING_TOP)) === null || _j === void 0 ? void 0 : _j.value) !== null && _k !== void 0 ? _k : 0;
26
+ var paddingRightWidth = (_m = (_l = styleMap.get(PropertyName.PADDING_END)) === null || _l === void 0 ? void 0 : _l.value) !== null && _m !== void 0 ? _m : 0;
27
+ var paddingBottomWidth = (_p = (_o = styleMap.get(PropertyName.PADDING_BOTTOM)) === null || _o === void 0 ? void 0 : _o.value) !== null && _p !== void 0 ? _p : 0;
28
+ var paddingLeftWidth = (_r = (_q = styleMap.get(PropertyName.PADDING_START)) === null || _q === void 0 ? void 0 : _q.value) !== null && _r !== void 0 ? _r : 0;
29
+ this.blockStart = borderTopWidth + SCROLLBAR_SIZES[0] + paddingTopWidth;
30
+ this.inlineStart = borderRightWidth + SCROLLBAR_SIZES[1] + paddingRightWidth;
31
+ this.blockEnd = borderBottomWidth + SCROLLBAR_SIZES[2] + paddingBottomWidth;
32
+ this.inlineEnd = borderLeftWidth + SCROLLBAR_SIZES[3] + paddingLeftWidth;
33
+ this.block = this.blockStart + this.blockEnd;
34
+ this.inline = this.inlineStart + this.inlineEnd;
35
+ }
36
+
37
+ LayoutEdges = __decorate([injectable(), __param(0, inject(LayoutEdgesOptions)), __metadata("design:paramtypes", [Object])], LayoutEdges);
38
+ return LayoutEdges;
39
+ }();
40
+
41
+ export { LayoutEdges };
@@ -0,0 +1,41 @@
1
+ import type { LayoutObject } from './LayoutObject';
2
+ import { LayoutRegistry } from './LayoutRegistry';
3
+ import type { IntrinsicSizes, LayoutConstraints } from './types';
4
+ import { LayoutContextFactory } from './LayoutContext';
5
+ import { LayoutEdgesFactory } from './LayoutEdges';
6
+ import type { LayoutWorkTask } from './LayoutWorkTask';
7
+ import type { LayoutFragmentOptions } from './LayoutFragment';
8
+ export declare class LayoutEngine {
9
+ protected readonly _layoutRegistry: LayoutRegistry;
10
+ protected readonly _layoutContextFactory: LayoutContextFactory;
11
+ protected readonly _layoutEdgesFactory: LayoutEdgesFactory;
12
+ protected layoutRegistry: LayoutRegistry;
13
+ protected layoutContextFactory: LayoutContextFactory;
14
+ protected layoutEdgesFactory: LayoutEdgesFactory;
15
+ constructor(_layoutRegistry: LayoutRegistry, _layoutContextFactory: LayoutContextFactory, _layoutEdgesFactory: LayoutEdgesFactory);
16
+ /**
17
+ * This function takes the root of the box-tree, a LayoutConstraints object, and compute the position of every node in the tree
18
+ * @param rootNode root node of the layout object tree
19
+ * @param rootPageConstraints layout constraints
20
+ * @returns
21
+ */
22
+ computeLayout(rootNode: LayoutObject, rootPageConstraints: LayoutConstraints): Promise<void>;
23
+ /**
24
+ * calculate intrinsicSize of node tree, use depth dirst / post order traversal
25
+ * @param rootNode
26
+ */
27
+ determineAllIntrinsicSizes(rootNode: LayoutObject): Promise<void>;
28
+ protected getLayoutDefinitionName(node: LayoutObject): any;
29
+ /**
30
+ * calculate the min/max content size of node
31
+ * @param node current layout object
32
+ * @param childNodes children of the current node
33
+ */
34
+ protected determineIntrinsicSizes(node: LayoutObject, childNodes: LayoutObject[]): Promise<void>;
35
+ protected invokeIntrinsicSizesCallback(layoutName: string, node: LayoutObject, childNodes: LayoutObject[]): Promise<void>;
36
+ protected calculateLayout(node: LayoutObject, childNodes: LayoutObject[], layoutConstraints: LayoutConstraints): Promise<void>;
37
+ protected invokeLayoutCallback(layoutName: string, node: LayoutObject, childNodes: LayoutObject[], layoutConstraints: LayoutConstraints): Promise<void>;
38
+ protected runWorkQueue<T>(promise: Promise<T>, workQueue: LayoutWorkTask[]): Generator<any, T, any>;
39
+ protected getNodeIntrisicSizes(node: LayoutObject): IntrinsicSizes;
40
+ protected getNodeFragment(node: LayoutObject, constraints: LayoutConstraints): LayoutFragmentOptions;
41
+ }