@antv/g 5.0.23 → 5.1.1
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/Canvas.js +2 -0
- 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/CSSProperty.d.ts +2 -1
- package/es/css/StyleValueRegistry.d.ts +2 -1
- package/es/css/StyleValueRegistry.js +71 -88
- 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/css/parser/color.d.ts +1 -1
- package/es/css/parser/color.js +2 -2
- package/es/css/parser/dimension.js +5 -1
- package/es/css/parser/path.d.ts +2 -2
- package/es/css/parser/path.js +9 -2
- package/es/css/parser/points.d.ts +8 -1
- package/es/css/parser/points.js +33 -3
- package/es/css/parser/transform.js +1 -1
- package/es/css/properties/CSSPropertyClipPath.js +7 -1
- package/es/css/properties/CSSPropertyLocalPosition.d.ts +0 -9
- package/es/css/properties/CSSPropertyLocalPosition.js +59 -20
- package/es/css/properties/CSSPropertyPath.d.ts +2 -2
- package/es/css/properties/CSSPropertyPath.js +7 -5
- package/es/css/properties/CSSPropertyPoints.js +3 -4
- package/es/css/properties/CSSPropertyTransform.d.ts +1 -1
- package/es/css/properties/CSSPropertyTransform.js +76 -104
- package/es/display-objects/Circle.d.ts +4 -0
- package/es/display-objects/Circle.js +2 -0
- package/es/display-objects/CustomElement.d.ts +6 -2
- package/es/display-objects/CustomElement.js +15 -5
- package/es/display-objects/DisplayObject.d.ts +1 -7
- package/es/display-objects/DisplayObject.js +6 -26
- package/es/display-objects/Ellipse.d.ts +4 -0
- package/es/display-objects/Ellipse.js +2 -0
- package/es/display-objects/Group.d.ts +4 -0
- package/es/display-objects/Group.js +2 -0
- package/es/display-objects/HTML.d.ts +4 -4
- package/es/display-objects/HTML.js +5 -3
- package/es/display-objects/Image.d.ts +4 -0
- package/es/display-objects/Image.js +2 -0
- package/es/display-objects/Line.js +2 -0
- package/es/display-objects/Path.d.ts +2 -2
- package/es/display-objects/Polygon.js +1 -1
- package/es/display-objects/Polyline.js +1 -1
- package/es/display-objects/Rect.d.ts +6 -2
- package/es/display-objects/Rect.js +2 -0
- package/es/display-objects/Text.d.ts +4 -0
- package/es/display-objects/Text.js +2 -0
- package/es/dom/Element.js +1 -0
- package/es/global-module.js +87 -1
- package/es/index.d.ts +3 -0
- package/es/index.js +3 -0
- package/es/services/EventService.js +10 -2
- 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/services/SceneGraphService.d.ts +2 -0
- package/es/services/SceneGraphService.js +9 -0
- package/es/services/aabb/CircleUpdater.d.ts +0 -2
- package/es/services/aabb/CircleUpdater.js +2 -6
- package/es/services/aabb/EllipseUpdater.d.ts +0 -2
- package/es/services/aabb/EllipseUpdater.js +2 -6
- package/es/services/aabb/LineUpdater.d.ts +0 -2
- package/es/services/aabb/LineUpdater.js +1 -3
- package/es/services/aabb/PathUpdater.d.ts +0 -2
- package/es/services/aabb/PathUpdater.js +1 -5
- package/es/services/aabb/PolylineUpdater.d.ts +0 -2
- package/es/services/aabb/PolylineUpdater.js +1 -3
- package/es/services/aabb/RectUpdater.d.ts +0 -2
- package/es/services/aabb/RectUpdater.js +1 -5
- package/es/services/aabb/TextUpdater.d.ts +7 -0
- package/es/services/aabb/TextUpdater.js +0 -4
- package/es/services/aabb/interfaces.d.ts +0 -3
- package/es/types.d.ts +7 -23
- package/es/types.js +1 -0
- 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/es/utils/interpolation.js +2 -8
- package/es/utils/math.js +4 -3
- package/es/utils/path.d.ts +2 -2
- package/es/utils/path.js +61 -24
- package/lib/AbstractRenderer.d.ts +11 -0
- package/lib/AbstractRenderer.js +17 -2
- package/lib/Canvas.d.ts +1 -1
- package/lib/Canvas.js +2 -0
- 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/CSSProperty.d.ts +2 -1
- package/lib/css/StyleValueRegistry.d.ts +2 -1
- package/lib/css/StyleValueRegistry.js +70 -88
- 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/css/parser/color.d.ts +1 -1
- package/lib/css/parser/color.js +1 -1
- package/lib/css/parser/dimension.js +4 -0
- package/lib/css/parser/path.d.ts +2 -2
- package/lib/css/parser/path.js +9 -2
- package/lib/css/parser/points.d.ts +8 -1
- package/lib/css/parser/points.js +33 -3
- package/lib/css/parser/transform.js +1 -1
- package/lib/css/properties/CSSPropertyClipPath.js +8 -1
- package/lib/css/properties/CSSPropertyLocalPosition.d.ts +0 -9
- package/lib/css/properties/CSSPropertyLocalPosition.js +60 -20
- package/lib/css/properties/CSSPropertyPath.d.ts +2 -2
- package/lib/css/properties/CSSPropertyPath.js +7 -5
- package/lib/css/properties/CSSPropertyPoints.js +3 -4
- package/lib/css/properties/CSSPropertyTransform.d.ts +1 -1
- package/lib/css/properties/CSSPropertyTransform.js +75 -103
- package/lib/display-objects/Circle.d.ts +4 -0
- package/lib/display-objects/Circle.js +2 -0
- package/lib/display-objects/CustomElement.d.ts +6 -2
- package/lib/display-objects/CustomElement.js +13 -4
- package/lib/display-objects/DisplayObject.d.ts +1 -7
- package/lib/display-objects/DisplayObject.js +6 -27
- package/lib/display-objects/Ellipse.d.ts +4 -0
- package/lib/display-objects/Ellipse.js +2 -0
- package/lib/display-objects/Group.d.ts +4 -0
- package/lib/display-objects/Group.js +2 -0
- package/lib/display-objects/HTML.d.ts +4 -4
- package/lib/display-objects/HTML.js +5 -3
- package/lib/display-objects/Image.d.ts +4 -0
- package/lib/display-objects/Image.js +2 -0
- package/lib/display-objects/Line.js +2 -0
- package/lib/display-objects/Path.d.ts +2 -2
- package/lib/display-objects/Polygon.js +1 -1
- package/lib/display-objects/Polyline.js +1 -1
- package/lib/display-objects/Rect.d.ts +6 -2
- package/lib/display-objects/Rect.js +2 -0
- package/lib/display-objects/Text.d.ts +4 -0
- package/lib/display-objects/Text.js +2 -0
- package/lib/dom/Element.js +1 -0
- package/lib/global-module.js +89 -1
- package/lib/index.d.ts +3 -0
- package/lib/index.js +7 -2
- package/lib/services/EventService.js +10 -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/services/SceneGraphService.d.ts +2 -0
- package/lib/services/SceneGraphService.js +12 -0
- package/lib/services/aabb/CircleUpdater.d.ts +0 -2
- package/lib/services/aabb/CircleUpdater.js +2 -6
- package/lib/services/aabb/EllipseUpdater.d.ts +0 -2
- package/lib/services/aabb/EllipseUpdater.js +2 -6
- package/lib/services/aabb/LineUpdater.d.ts +0 -2
- package/lib/services/aabb/LineUpdater.js +1 -3
- package/lib/services/aabb/PathUpdater.d.ts +0 -2
- package/lib/services/aabb/PathUpdater.js +1 -5
- package/lib/services/aabb/PolylineUpdater.d.ts +0 -2
- package/lib/services/aabb/PolylineUpdater.js +1 -3
- package/lib/services/aabb/RectUpdater.d.ts +0 -2
- package/lib/services/aabb/RectUpdater.js +1 -5
- package/lib/services/aabb/TextUpdater.d.ts +7 -0
- package/lib/services/aabb/TextUpdater.js +0 -4
- package/lib/services/aabb/interfaces.d.ts +0 -3
- package/lib/types.d.ts +7 -23
- package/lib/types.js +1 -0
- 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/lib/utils/interpolation.js +2 -8
- package/lib/utils/math.js +4 -3
- package/lib/utils/path.d.ts +2 -2
- package/lib/utils/path.js +55 -24
- 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
|
@@ -4,8 +4,8 @@ import type { DisplayObjectConfig } from '../dom';
|
|
|
4
4
|
import { Point } from '../shapes';
|
|
5
5
|
import type { Rectangle } from '../shapes/Rectangle';
|
|
6
6
|
export interface PathStyleProps extends BaseStyleProps {
|
|
7
|
-
path?: string | PathCommand[];
|
|
8
|
-
d?: string | PathCommand[];
|
|
7
|
+
path?: string | PathCommand[] | DisplayObject;
|
|
8
|
+
d?: string | PathCommand[] | DisplayObject;
|
|
9
9
|
}
|
|
10
10
|
export interface PathSegment {
|
|
11
11
|
command: PathCommand[0];
|
|
@@ -3,13 +3,17 @@ import { DisplayObject } from './DisplayObject';
|
|
|
3
3
|
import type { DisplayObjectConfig } from '../dom';
|
|
4
4
|
import type { CSSUnitValue } from '../css';
|
|
5
5
|
export interface RectStyleProps extends BaseStyleProps {
|
|
6
|
+
x?: number | string;
|
|
7
|
+
y?: number | string;
|
|
6
8
|
width: number | string;
|
|
7
9
|
height: number | string;
|
|
8
10
|
radius?: number | string;
|
|
9
11
|
}
|
|
10
12
|
export interface ParsedRectStyleProps extends ParsedBaseStyleProps {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
x: CSSUnitValue;
|
|
14
|
+
y: CSSUnitValue;
|
|
15
|
+
width: CSSUnitValue;
|
|
16
|
+
height: CSSUnitValue;
|
|
13
17
|
radius?: CSSUnitValue;
|
|
14
18
|
}
|
|
15
19
|
export declare class Rect extends DisplayObject<RectStyleProps, ParsedRectStyleProps> {
|
|
@@ -4,6 +4,8 @@ import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
|
|
|
4
4
|
import { DisplayObject } from './DisplayObject';
|
|
5
5
|
import type { CSSUnitValue, CSSGlobalKeywords, CSSKeywordValue } from '../css';
|
|
6
6
|
export interface TextStyleProps extends BaseStyleProps {
|
|
7
|
+
x?: number | string;
|
|
8
|
+
y?: number | string;
|
|
7
9
|
text: string;
|
|
8
10
|
/** 设置文本内容的当前对齐方式 */
|
|
9
11
|
textAlign?: CSSGlobalKeywords | 'start' | 'center' | 'end' | 'left' | 'right';
|
|
@@ -31,6 +33,8 @@ export interface TextStyleProps extends BaseStyleProps {
|
|
|
31
33
|
dy?: number | string;
|
|
32
34
|
}
|
|
33
35
|
export interface ParsedTextStyleProps extends ParsedBaseStyleProps {
|
|
36
|
+
x: CSSUnitValue;
|
|
37
|
+
y: CSSUnitValue;
|
|
34
38
|
text: string;
|
|
35
39
|
/** 设置文本内容的当前对齐方式 */
|
|
36
40
|
textAlign?: CSSKeywordValue;
|
package/es/dom/Element.js
CHANGED
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';
|
|
@@ -355,7 +355,11 @@ function (_super) {
|
|
|
355
355
|
while (leaveEvent.target && !e.composedPath().includes(leaveEvent.target)) {
|
|
356
356
|
leaveEvent.currentTarget = leaveEvent.target;
|
|
357
357
|
this.notifyTarget(leaveEvent);
|
|
358
|
-
|
|
358
|
+
|
|
359
|
+
if (isMouse) {
|
|
360
|
+
// console.error(leaveEvent.target);
|
|
361
|
+
this.notifyTarget(leaveEvent, 'mouseleave');
|
|
362
|
+
}
|
|
359
363
|
|
|
360
364
|
if (Node.isNode(leaveEvent.target)) {
|
|
361
365
|
leaveEvent.target = leaveEvent.target.parentNode;
|
|
@@ -460,7 +464,11 @@ function (_super) {
|
|
|
460
464
|
while (leaveEvent.target && leaveEvent.target !== (Node.isNode(this.rootTarget) && this.rootTarget.parentNode)) {
|
|
461
465
|
leaveEvent.currentTarget = leaveEvent.target;
|
|
462
466
|
this.notifyTarget(leaveEvent);
|
|
463
|
-
|
|
467
|
+
|
|
468
|
+
if (isMouse) {
|
|
469
|
+
// console.error(leaveEvent.target, 'out');
|
|
470
|
+
this.notifyTarget(leaveEvent, 'mouseleave');
|
|
471
|
+
}
|
|
464
472
|
|
|
465
473
|
if (Node.isNode(leaveEvent.target)) {
|
|
466
474
|
leaveEvent.target = leaveEvent.target.parentNode;
|
|
@@ -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
|
|
|
@@ -35,6 +35,7 @@ export interface SceneGraphService {
|
|
|
35
35
|
getLocalRotation: (element: INode) => quat;
|
|
36
36
|
getWorldTransform: (element: INode, transform?: Transform) => mat4;
|
|
37
37
|
getLocalTransform: (element: INode, transform?: Transform) => mat4;
|
|
38
|
+
setLocalTransform: (element: INode, transform: mat4) => void;
|
|
38
39
|
resetLocalTransform: (element: INode) => void;
|
|
39
40
|
getBounds: (element: INode, render?: boolean) => AABB;
|
|
40
41
|
getLocalBounds: (element: INode, render?: boolean) => AABB;
|
|
@@ -129,6 +130,7 @@ export declare class DefaultSceneGraphService implements SceneGraphService {
|
|
|
129
130
|
getLocalRotation(element: INode): import("gl-matrix").vec4;
|
|
130
131
|
getLocalScale(element: INode): vec3;
|
|
131
132
|
getLocalTransform(element: INode): mat4;
|
|
133
|
+
setLocalTransform(element: INode, transform: mat4): void;
|
|
132
134
|
resetLocalTransform(element: INode): void;
|
|
133
135
|
private getTransformedGeometryBounds;
|
|
134
136
|
/**
|
|
@@ -554,6 +554,15 @@ function () {
|
|
|
554
554
|
return transform.localTransform;
|
|
555
555
|
};
|
|
556
556
|
|
|
557
|
+
DefaultSceneGraphService.prototype.setLocalTransform = function (element, transform) {
|
|
558
|
+
var t = mat4.getTranslation(vec3.create(), transform);
|
|
559
|
+
var r = mat4.getRotation(quat.create(), transform);
|
|
560
|
+
var s = mat4.getScaling(vec3.create(), transform);
|
|
561
|
+
this.setLocalScale(element, s);
|
|
562
|
+
this.setLocalPosition(element, t);
|
|
563
|
+
this.setLocalRotation(element, r);
|
|
564
|
+
};
|
|
565
|
+
|
|
557
566
|
DefaultSceneGraphService.prototype.resetLocalTransform = function (element) {
|
|
558
567
|
this.setLocalScale(element, [1, 1, 1]);
|
|
559
568
|
this.setLocalPosition(element, [0, 0, 0]);
|
|
@@ -9,16 +9,12 @@ function () {
|
|
|
9
9
|
function CircleUpdater() {}
|
|
10
10
|
|
|
11
11
|
CircleUpdater.prototype.update = function (parsedStyle, object) {
|
|
12
|
-
var r = parsedStyle.r
|
|
13
|
-
x = parsedStyle.x,
|
|
14
|
-
y = parsedStyle.y;
|
|
12
|
+
var r = parsedStyle.r;
|
|
15
13
|
var width = r.value * 2;
|
|
16
14
|
var height = r.value * 2;
|
|
17
15
|
return {
|
|
18
16
|
width: width,
|
|
19
|
-
height: height
|
|
20
|
-
x: x.value || 0,
|
|
21
|
-
y: y.value || 0
|
|
17
|
+
height: height
|
|
22
18
|
};
|
|
23
19
|
};
|
|
24
20
|
|
|
@@ -10,16 +10,12 @@ function () {
|
|
|
10
10
|
|
|
11
11
|
EllipseUpdater.prototype.update = function (parsedStyle, object) {
|
|
12
12
|
var rx = parsedStyle.rx,
|
|
13
|
-
ry = parsedStyle.ry
|
|
14
|
-
x = parsedStyle.x,
|
|
15
|
-
y = parsedStyle.y;
|
|
13
|
+
ry = parsedStyle.ry;
|
|
16
14
|
var width = rx.value * 2;
|
|
17
15
|
var height = ry.value * 2;
|
|
18
16
|
return {
|
|
19
17
|
width: width,
|
|
20
|
-
height: height
|
|
21
|
-
x: x.value || 0,
|
|
22
|
-
y: y.value || 0
|
|
18
|
+
height: height
|
|
23
19
|
};
|
|
24
20
|
};
|
|
25
21
|
|
|
@@ -11,15 +11,11 @@ function () {
|
|
|
11
11
|
PathUpdater.prototype.update = function (parsedStyle) {
|
|
12
12
|
var path = parsedStyle.path;
|
|
13
13
|
var _a = path.rect,
|
|
14
|
-
minX = _a.x,
|
|
15
|
-
minY = _a.y,
|
|
16
14
|
width = _a.width,
|
|
17
15
|
height = _a.height;
|
|
18
16
|
return {
|
|
19
17
|
width: width,
|
|
20
|
-
height: height
|
|
21
|
-
x: minX,
|
|
22
|
-
y: minY
|
|
18
|
+
height: height
|
|
23
19
|
};
|
|
24
20
|
};
|
|
25
21
|
|
|
@@ -12,8 +12,6 @@ function () {
|
|
|
12
12
|
|
|
13
13
|
RectUpdater.prototype.update = function (parsedStyle, object) {
|
|
14
14
|
var img = parsedStyle.img,
|
|
15
|
-
x = parsedStyle.x,
|
|
16
|
-
y = parsedStyle.y,
|
|
17
15
|
width = parsedStyle.width,
|
|
18
16
|
height = parsedStyle.height;
|
|
19
17
|
var contentWidth = 0;
|
|
@@ -52,9 +50,7 @@ function () {
|
|
|
52
50
|
|
|
53
51
|
return {
|
|
54
52
|
width: contentWidth,
|
|
55
|
-
height: contentHeight
|
|
56
|
-
x: x.value || 0,
|
|
57
|
-
y: y.value || 0
|
|
53
|
+
height: contentHeight
|
|
58
54
|
};
|
|
59
55
|
};
|
|
60
56
|
|
|
@@ -10,5 +10,12 @@ export declare class TextUpdater implements GeometryAABBUpdater<ParsedTextStyleP
|
|
|
10
10
|
y: number;
|
|
11
11
|
offsetX: number;
|
|
12
12
|
offsetY: number;
|
|
13
|
+
} | {
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
offsetX: number;
|
|
17
|
+
offsetY: number;
|
|
18
|
+
x?: undefined;
|
|
19
|
+
y?: undefined;
|
|
13
20
|
};
|
|
14
21
|
}
|
|
@@ -29,8 +29,6 @@ function () {
|
|
|
29
29
|
textAlign = parsedStyle.textAlign,
|
|
30
30
|
lineWidth = parsedStyle.lineWidth,
|
|
31
31
|
textBaseline = parsedStyle.textBaseline,
|
|
32
|
-
x = parsedStyle.x,
|
|
33
|
-
y = parsedStyle.y,
|
|
34
32
|
dx = parsedStyle.dx,
|
|
35
33
|
dy = parsedStyle.dy;
|
|
36
34
|
var offscreenCanvas = (((_b = (_a = object === null || object === void 0 ? void 0 : object.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) === null || _b === void 0 ? void 0 : _b.getConfig()) || {}).offscreenCanvas;
|
|
@@ -119,8 +117,6 @@ function () {
|
|
|
119
117
|
return {
|
|
120
118
|
width: halfExtents[0] * 2,
|
|
121
119
|
height: halfExtents[1] * 2,
|
|
122
|
-
x: x.value || 0,
|
|
123
|
-
y: y.value || 0,
|
|
124
120
|
offsetX: lineXOffset,
|
|
125
121
|
offsetY: lineYOffset
|
|
126
122
|
};
|
package/es/types.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { vec2, vec3 } from 'gl-matrix';
|
|
3
3
|
import type { DisplayObject } from './display-objects';
|
|
4
4
|
import type { IRenderer } from './AbstractRenderer';
|
|
5
|
-
import type { CSSGlobalKeywords, CSSGradientValue, CSSKeywordValue, CSSRGB, CSSUnitValue } from './css';
|
|
5
|
+
import type { CSSGlobalKeywords, CSSGradientValue, CSSKeywordValue, CSSRGB, CSSUnitValue, ParsedTransform } from './css';
|
|
6
6
|
import { Syringe } from 'mana-syringe';
|
|
7
7
|
export declare enum Shape {
|
|
8
8
|
GROUP = "g",
|
|
@@ -15,7 +15,8 @@ export declare enum Shape {
|
|
|
15
15
|
POLYGON = "polygon",
|
|
16
16
|
TEXT = "text",
|
|
17
17
|
PATH = "path",
|
|
18
|
-
HTML = "html"
|
|
18
|
+
HTML = "html",
|
|
19
|
+
MESH = "mesh"
|
|
19
20
|
}
|
|
20
21
|
declare type ColorType = string | null;
|
|
21
22
|
export interface EventPosition {
|
|
@@ -51,18 +52,6 @@ export declare enum TextAlign {
|
|
|
51
52
|
}
|
|
52
53
|
export interface BaseStyleProps {
|
|
53
54
|
class?: string;
|
|
54
|
-
/**
|
|
55
|
-
* x in local space
|
|
56
|
-
*/
|
|
57
|
-
x?: number | string;
|
|
58
|
-
/**
|
|
59
|
-
* y in local space
|
|
60
|
-
*/
|
|
61
|
-
y?: number | string;
|
|
62
|
-
/**
|
|
63
|
-
* z in local space
|
|
64
|
-
*/
|
|
65
|
-
z?: number | string;
|
|
66
55
|
/**
|
|
67
56
|
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/transform
|
|
68
57
|
*/
|
|
@@ -161,8 +150,9 @@ export interface BaseStyleProps {
|
|
|
161
150
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/miterLimit
|
|
162
151
|
*/
|
|
163
152
|
miterLimit?: number;
|
|
153
|
+
display?: string;
|
|
164
154
|
}
|
|
165
|
-
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'> {
|
|
155
|
+
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' | 'transform' | 'transformOrigin' | 'textTransform'> {
|
|
166
156
|
zIndex?: CSSUnitValue;
|
|
167
157
|
visibility?: CSSKeywordValue;
|
|
168
158
|
pointerEvents?: CSSKeywordValue;
|
|
@@ -176,10 +166,8 @@ export interface ParsedBaseStyleProps extends Omit<BaseStyleProps, 'anchor' | 'x
|
|
|
176
166
|
lineJoin?: CSSKeywordValue;
|
|
177
167
|
lineDashOffset?: CSSUnitValue;
|
|
178
168
|
anchor?: [CSSUnitValue, CSSUnitValue, CSSUnitValue];
|
|
169
|
+
transform: ParsedTransform[];
|
|
179
170
|
transformOrigin?: [CSSUnitValue, CSSUnitValue, CSSUnitValue];
|
|
180
|
-
x?: CSSUnitValue;
|
|
181
|
-
y?: CSSUnitValue;
|
|
182
|
-
z?: CSSUnitValue;
|
|
183
171
|
width?: CSSUnitValue;
|
|
184
172
|
height?: CSSUnitValue;
|
|
185
173
|
lineWidth?: CSSUnitValue;
|
|
@@ -215,10 +203,6 @@ export interface RendererConfig {
|
|
|
215
203
|
* enable auto rendering
|
|
216
204
|
*/
|
|
217
205
|
enableAutoRendering: boolean;
|
|
218
|
-
/**
|
|
219
|
-
* enable TAA in WebGL
|
|
220
|
-
*/
|
|
221
|
-
enableTAA: boolean;
|
|
222
206
|
}
|
|
223
207
|
export declare const CanvasConfig: Syringe.DefinedToken;
|
|
224
208
|
export interface CanvasConfig {
|
|
@@ -250,7 +234,7 @@ export interface CanvasConfig {
|
|
|
250
234
|
/**
|
|
251
235
|
* replace `new window.Image()`
|
|
252
236
|
*/
|
|
253
|
-
createImage?: () => HTMLImageElement;
|
|
237
|
+
createImage?: (src: string) => HTMLImageElement;
|
|
254
238
|
/**
|
|
255
239
|
* limits query
|
|
256
240
|
*/
|
package/es/types.js
CHANGED
|
@@ -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 {};
|