@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.
- package/dist/index.umd.min.js +3 -2
- package/es/AbstractRenderer.d.ts +11 -0
- package/es/AbstractRenderer.js +17 -2
- package/es/Canvas.d.ts +1 -1
- package/es/components/Geometry.d.ts +0 -4
- package/es/css/CSS.d.ts +2 -1
- package/es/css/CSS.js +5 -1
- package/es/css/StyleValueRegistry.js +3 -16
- package/es/css/index.d.ts +1 -1
- package/es/css/index.js +1 -1
- package/es/css/layout/FragmentResult.d.ts +32 -0
- package/es/css/layout/FragmentResult.js +32 -0
- package/es/css/layout/LayoutChildren.d.ts +23 -0
- package/es/css/layout/LayoutChildren.js +55 -0
- package/es/css/layout/LayoutContext.d.ts +35 -0
- package/es/css/layout/LayoutContext.js +35 -0
- package/es/css/layout/LayoutDefinition.d.ts +20 -0
- package/es/css/layout/LayoutDefinition.js +9 -0
- package/es/css/layout/LayoutEdges.d.ts +24 -0
- package/es/css/layout/LayoutEdges.js +41 -0
- package/es/css/layout/LayoutEngine.d.ts +41 -0
- package/es/css/layout/LayoutEngine.js +332 -0
- package/es/css/layout/LayoutFragment.d.ts +26 -0
- package/es/css/layout/LayoutFragment.js +28 -0
- package/es/css/layout/LayoutObject.d.ts +46 -0
- package/es/css/layout/LayoutObject.js +172 -0
- package/es/css/layout/LayoutRegistry.d.ts +16 -0
- package/es/css/layout/LayoutRegistry.js +78 -0
- package/es/css/layout/LayoutWorkTask.d.ts +14 -0
- package/es/css/layout/LayoutWorkTask.js +1 -0
- package/es/css/layout/index.d.ts +11 -0
- package/es/css/layout/index.js +11 -0
- package/es/css/layout/types.d.ts +104 -0
- package/es/css/layout/types.js +66 -0
- package/es/global-module.js +87 -1
- package/es/index.d.ts +3 -0
- package/es/index.js +3 -0
- package/es/services/OffscreenCanvasCreator.d.ts +1 -1
- package/es/services/OffscreenCanvasCreator.js +1 -1
- package/es/services/RenderingService.d.ts +1 -1
- package/es/services/RenderingService.js +1 -1
- package/es/types.d.ts +1 -4
- package/es/utils/deferred.d.ts +43 -0
- package/es/utils/deferred.js +117 -0
- package/es/utils/dom.d.ts +2 -0
- package/es/utils/dom.js +8 -0
- package/es/utils/index.d.ts +2 -0
- package/es/utils/index.js +3 -1
- package/lib/AbstractRenderer.d.ts +11 -0
- package/lib/AbstractRenderer.js +17 -2
- package/lib/Canvas.d.ts +1 -1
- package/lib/components/Geometry.d.ts +0 -4
- package/lib/css/CSS.d.ts +2 -1
- package/lib/css/CSS.js +7 -1
- package/lib/css/StyleValueRegistry.js +3 -17
- package/lib/css/index.d.ts +1 -1
- package/lib/css/index.js +12 -12
- package/lib/css/layout/FragmentResult.d.ts +32 -0
- package/lib/css/layout/FragmentResult.js +51 -0
- package/lib/css/layout/LayoutChildren.d.ts +23 -0
- package/lib/css/layout/LayoutChildren.js +72 -0
- package/lib/css/layout/LayoutContext.d.ts +35 -0
- package/lib/css/layout/LayoutContext.js +49 -0
- package/lib/css/layout/LayoutDefinition.d.ts +20 -0
- package/lib/css/layout/LayoutDefinition.js +16 -0
- package/lib/css/layout/LayoutEdges.d.ts +24 -0
- package/lib/css/layout/LayoutEdges.js +56 -0
- package/lib/css/layout/LayoutEngine.d.ts +41 -0
- package/lib/css/layout/LayoutEngine.js +345 -0
- package/lib/css/layout/LayoutFragment.d.ts +26 -0
- package/lib/css/layout/LayoutFragment.js +44 -0
- package/lib/css/layout/LayoutObject.d.ts +46 -0
- package/lib/css/layout/LayoutObject.js +182 -0
- package/lib/css/layout/LayoutRegistry.d.ts +16 -0
- package/lib/css/layout/LayoutRegistry.js +87 -0
- package/lib/css/layout/LayoutWorkTask.d.ts +14 -0
- package/lib/css/layout/LayoutWorkTask.js +5 -0
- package/lib/css/layout/index.d.ts +11 -0
- package/lib/css/layout/index.js +148 -0
- package/lib/css/layout/types.d.ts +104 -0
- package/lib/css/layout/types.js +74 -0
- package/lib/global-module.js +89 -1
- package/lib/index.d.ts +3 -0
- package/lib/index.js +7 -2
- package/lib/services/OffscreenCanvasCreator.d.ts +1 -1
- package/lib/services/OffscreenCanvasCreator.js +1 -1
- package/lib/services/RenderingService.d.ts +1 -1
- package/lib/services/RenderingService.js +1 -1
- package/lib/types.d.ts +1 -4
- package/lib/utils/deferred.d.ts +43 -0
- package/lib/utils/deferred.js +131 -0
- package/lib/utils/dom.d.ts +2 -0
- package/lib/utils/dom.js +17 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +26 -0
- package/package.json +3 -3
- package/es/css/LayoutRegistry.d.ts +0 -11
- package/es/css/LayoutRegistry.js +0 -22
- package/lib/css/LayoutRegistry.d.ts +0 -11
- package/lib/css/LayoutRegistry.js +0 -30
|
@@ -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 = {}));
|
package/es/global-module.js
CHANGED
|
@@ -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
5
|
import { CircleUpdater, EllipseUpdater, GeometryAABBUpdater, GeometryUpdaterFactory, LineUpdater, PathUpdater, PolylineUpdater, RectUpdater, TextUpdater, TextService, OffscreenCanvasCreator, DefaultSceneGraphService, DefaultSceneGraphSelector, SceneGraphSelector, SceneGraphSelectorFactory } from './services';
|
|
5
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
|
|
|
@@ -65,5 +67,89 @@ export var containerModule = Module(function (register) {
|
|
|
65
67
|
register(CSSPropertyPoints);
|
|
66
68
|
register(CSSPropertyClipPath);
|
|
67
69
|
register(CSSPropertyText);
|
|
68
|
-
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
|
+
});
|
|
69
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';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* used in following scenes:
|
|
4
4
|
* - g `ctx.measureText`
|
|
5
5
|
* - g-plugin-canvas-picker `ctx.isPointInPath`
|
|
6
|
-
* - g-plugin-
|
|
6
|
+
* - g-plugin-device-renderer `ctx.createLinearGradient` and generate texture
|
|
7
7
|
*/
|
|
8
8
|
export declare class OffscreenCanvasCreator {
|
|
9
9
|
private canvas;
|
|
@@ -4,7 +4,7 @@ import { singleton } from 'mana-syringe';
|
|
|
4
4
|
* used in following scenes:
|
|
5
5
|
* - g `ctx.measureText`
|
|
6
6
|
* - g-plugin-canvas-picker `ctx.isPointInPath`
|
|
7
|
-
* - g-plugin-
|
|
7
|
+
* - g-plugin-device-renderer `ctx.createLinearGradient` and generate texture
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
var OffscreenCanvasCreator =
|
|
@@ -66,7 +66,7 @@ export declare class RenderingService {
|
|
|
66
66
|
endFrame: SyncHook<[], void, import("tapable").UnsetAdditionalOptions>;
|
|
67
67
|
destroy: SyncHook<[], void, import("tapable").UnsetAdditionalOptions>;
|
|
68
68
|
/**
|
|
69
|
-
* use async but faster method such as GPU-based picking in `g-plugin-
|
|
69
|
+
* use async but faster method such as GPU-based picking in `g-plugin-device-renderer`
|
|
70
70
|
*/
|
|
71
71
|
pick: AsyncSeriesWaterfallHook<[PickingResult], PickingResult>;
|
|
72
72
|
/**
|
|
@@ -78,7 +78,7 @@ function () {
|
|
|
78
78
|
destroy: new SyncHook([]),
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
|
-
* use async but faster method such as GPU-based picking in `g-plugin-
|
|
81
|
+
* use async but faster method such as GPU-based picking in `g-plugin-device-renderer`
|
|
82
82
|
*/
|
|
83
83
|
pick: new AsyncSeriesWaterfallHook(['result']),
|
|
84
84
|
|
package/es/types.d.ts
CHANGED
|
@@ -161,6 +161,7 @@ export interface BaseStyleProps {
|
|
|
161
161
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/miterLimit
|
|
162
162
|
*/
|
|
163
163
|
miterLimit?: number;
|
|
164
|
+
display?: string;
|
|
164
165
|
}
|
|
165
166
|
export interface ParsedBaseStyleProps extends Omit<BaseStyleProps, 'anchor' | 'x' | 'y' | 'z' | 'opacity' | 'strokeOpacity' | 'fillOpacity' | 'fill' | 'stroke' | 'lineWidth' | 'increasedLineWidthForHitTesting' | 'lineJoin' | 'lineCap' | 'lineDash' | 'lineDashOffset' | 'path' | 'points' | 'shadowColor' | 'shadowBlur' | 'shadowOffsetX' | 'shadowOffsetY' | 'visibility' | 'pointerEvents' | 'zIndex' | 'transformOrigin' | 'textTransform'> {
|
|
166
167
|
zIndex?: CSSUnitValue;
|
|
@@ -215,10 +216,6 @@ export interface RendererConfig {
|
|
|
215
216
|
* enable auto rendering
|
|
216
217
|
*/
|
|
217
218
|
enableAutoRendering: boolean;
|
|
218
|
-
/**
|
|
219
|
-
* enable TAA in WebGL
|
|
220
|
-
*/
|
|
221
|
-
enableTAA: boolean;
|
|
222
219
|
}
|
|
223
220
|
export declare const CanvasConfig: Syringe.DefinedToken;
|
|
224
221
|
export interface CanvasConfig {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
interface PromiseStatus<T> {
|
|
2
|
+
isPending: () => boolean;
|
|
3
|
+
isRejected: () => boolean;
|
|
4
|
+
isFulfilled: () => boolean;
|
|
5
|
+
getFullFilledValue: () => T;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* This function allow you to modify a JS Promise by adding some status properties.
|
|
9
|
+
* Based on: http://stackoverflow.com/questions/21485545/is-there-a-way-to-tell-if-an-es6-promise-is-fulfilled-rejected-resolved
|
|
10
|
+
* But modified according to the specs of promises : https://promisesaplus.com/
|
|
11
|
+
*/
|
|
12
|
+
export declare const makeQuerablePromise: <T>(promise: Promise<T>) => PromiseStatus<T>;
|
|
13
|
+
/**
|
|
14
|
+
* Simple implementation of the deferred pattern.
|
|
15
|
+
* An object that exposes a promise and functions to resolve and reject it.
|
|
16
|
+
*/
|
|
17
|
+
export declare class Deferred<T = void> {
|
|
18
|
+
resolve: (value: T | PromiseLike<T>) => void;
|
|
19
|
+
reject: (err?: any) => void;
|
|
20
|
+
promise: Promise<T>;
|
|
21
|
+
}
|
|
22
|
+
export declare const equalSet: (as: Set<any>, bs: Set<any>) => boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Nicely typed aliases for some `Object` Methods
|
|
25
|
+
* - PSA: Don't mutate `yourObject`s
|
|
26
|
+
* - Numerical keys are BAD, resolve that issue upstream
|
|
27
|
+
* - Discussion: https://stackoverflow.com/a/65117465/565877
|
|
28
|
+
*/
|
|
29
|
+
export declare const ObjectTyped: {
|
|
30
|
+
/**
|
|
31
|
+
* Object.keys, but with nice typing (`Array<keyof T>`)
|
|
32
|
+
*/
|
|
33
|
+
keys: <T extends {}>(yourObject: T) => (keyof T)[];
|
|
34
|
+
/**
|
|
35
|
+
* Object.values, but with nice typing
|
|
36
|
+
*/
|
|
37
|
+
values: <T_1 extends {}>(yourObject: T_1) => T_1[keyof T_1][];
|
|
38
|
+
/**
|
|
39
|
+
* Object.entries, but with nice typing
|
|
40
|
+
*/
|
|
41
|
+
entries: <T_2 extends {}>(yourObject: T_2) => [keyof T_2, T_2[keyof T_2]][];
|
|
42
|
+
};
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { __values } from "tslib";
|
|
2
|
+
/**
|
|
3
|
+
* This function allow you to modify a JS Promise by adding some status properties.
|
|
4
|
+
* Based on: http://stackoverflow.com/questions/21485545/is-there-a-way-to-tell-if-an-es6-promise-is-fulfilled-rejected-resolved
|
|
5
|
+
* But modified according to the specs of promises : https://promisesaplus.com/
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export var makeQuerablePromise = function makeQuerablePromise(promise) {
|
|
9
|
+
// Don't modify any promise that has been already modified.
|
|
10
|
+
if (promise.isRejected || promise.isFulfilled) return promise; // Set initial state
|
|
11
|
+
|
|
12
|
+
var isPending = true;
|
|
13
|
+
var isRejected = false;
|
|
14
|
+
var isFulfilled = false;
|
|
15
|
+
var fullFilledValue; // Observe the promise, saving the fulfillment in a closure scope.
|
|
16
|
+
|
|
17
|
+
var result = promise.then(function (v) {
|
|
18
|
+
isFulfilled = true;
|
|
19
|
+
isPending = false;
|
|
20
|
+
fullFilledValue = v;
|
|
21
|
+
return v;
|
|
22
|
+
}, function (e) {
|
|
23
|
+
isRejected = true;
|
|
24
|
+
isPending = false;
|
|
25
|
+
throw e;
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
result.isFulfilled = function () {
|
|
29
|
+
return isFulfilled;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
result.isPending = function () {
|
|
33
|
+
return isPending;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
result.isRejected = function () {
|
|
37
|
+
return isRejected;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
result.getFullFilledValue = function () {
|
|
41
|
+
return fullFilledValue;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Simple implementation of the deferred pattern.
|
|
48
|
+
* An object that exposes a promise and functions to resolve and reject it.
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
var Deferred =
|
|
52
|
+
/** @class */
|
|
53
|
+
function () {
|
|
54
|
+
function Deferred() {
|
|
55
|
+
var _this = this;
|
|
56
|
+
|
|
57
|
+
this.promise = new Promise(function (resolve, reject) {
|
|
58
|
+
_this.resolve = resolve;
|
|
59
|
+
_this.reject = reject;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return Deferred;
|
|
64
|
+
}();
|
|
65
|
+
|
|
66
|
+
export { Deferred };
|
|
67
|
+
export var equalSet = function equalSet(as, bs) {
|
|
68
|
+
var e_1, _a;
|
|
69
|
+
|
|
70
|
+
if (as.size !== bs.size) return false;
|
|
71
|
+
|
|
72
|
+
try {
|
|
73
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
74
|
+
for (var as_1 = __values(as), as_1_1 = as_1.next(); !as_1_1.done; as_1_1 = as_1.next()) {
|
|
75
|
+
var a = as_1_1.value;
|
|
76
|
+
|
|
77
|
+
if (!bs.has(a)) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
} catch (e_1_1) {
|
|
82
|
+
e_1 = {
|
|
83
|
+
error: e_1_1
|
|
84
|
+
};
|
|
85
|
+
} finally {
|
|
86
|
+
try {
|
|
87
|
+
if (as_1_1 && !as_1_1.done && (_a = as_1.return)) _a.call(as_1);
|
|
88
|
+
} finally {
|
|
89
|
+
if (e_1) throw e_1.error;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return true;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Nicely typed aliases for some `Object` Methods
|
|
97
|
+
* - PSA: Don't mutate `yourObject`s
|
|
98
|
+
* - Numerical keys are BAD, resolve that issue upstream
|
|
99
|
+
* - Discussion: https://stackoverflow.com/a/65117465/565877
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
export var ObjectTyped = {
|
|
103
|
+
/**
|
|
104
|
+
* Object.keys, but with nice typing (`Array<keyof T>`)
|
|
105
|
+
*/
|
|
106
|
+
keys: Object.keys,
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Object.values, but with nice typing
|
|
110
|
+
*/
|
|
111
|
+
values: Object.values,
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Object.entries, but with nice typing
|
|
115
|
+
*/
|
|
116
|
+
entries: Object.entries
|
|
117
|
+
};
|
package/es/utils/dom.js
ADDED
package/es/utils/index.d.ts
CHANGED
package/es/utils/index.js
CHANGED
|
@@ -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
|
}
|
package/lib/AbstractRenderer.js
CHANGED
|
@@ -27,8 +27,7 @@ function () {
|
|
|
27
27
|
* enable dirty rectangle rendering by default
|
|
28
28
|
*/
|
|
29
29
|
enableDirtyRectangleRendering: true,
|
|
30
|
-
enableDirtyRectangleRenderingDebug: false
|
|
31
|
-
enableTAA: false
|
|
30
|
+
enableDirtyRectangleRenderingDebug: false
|
|
32
31
|
}, config);
|
|
33
32
|
}
|
|
34
33
|
|
|
@@ -36,10 +35,26 @@ function () {
|
|
|
36
35
|
this.plugins.push(plugin);
|
|
37
36
|
};
|
|
38
37
|
|
|
38
|
+
AbstractRenderer.prototype.unregisterPlugin = function (plugin) {
|
|
39
|
+
var index = this.plugins.findIndex(function (p) {
|
|
40
|
+
return p === plugin;
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
if (index > -1) {
|
|
44
|
+
this.plugins.splice(index, 1);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
39
48
|
AbstractRenderer.prototype.getPlugins = function () {
|
|
40
49
|
return this.plugins;
|
|
41
50
|
};
|
|
42
51
|
|
|
52
|
+
AbstractRenderer.prototype.getPlugin = function (name) {
|
|
53
|
+
return this.plugins.find(function (plugin) {
|
|
54
|
+
return plugin.name === name;
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
|
|
43
58
|
AbstractRenderer.prototype.getConfig = function () {
|
|
44
59
|
return this.config;
|
|
45
60
|
};
|
package/lib/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("
|
|
99
|
+
getRoot(): import(".").Group;
|
|
100
100
|
/**
|
|
101
101
|
* get the camera of canvas
|
|
102
102
|
*/
|