@antv/g 5.0.23-alpha.9 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.umd.min.js +4 -3
- 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/css/CSS.d.ts +2 -1
- package/es/css/CSS.js +6 -2
- package/es/css/CSSProperty.d.ts +3 -2
- package/es/css/StyleValueRegistry.d.ts +4 -2
- package/es/css/StyleValueRegistry.js +100 -95
- package/es/css/cssom/CSSNumericValue.js +1 -1
- package/es/css/index.d.ts +2 -1
- package/es/css/index.js +2 -1
- package/es/css/interfaces.d.ts +6 -0
- package/es/css/interfaces.js +2 -0
- 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/CSSPropertyColor.d.ts +1 -1
- package/es/css/properties/CSSPropertyLengthOrPercentage.d.ts +1 -1
- package/es/css/properties/CSSPropertyLocalPosition.d.ts +0 -9
- package/es/css/properties/CSSPropertyLocalPosition.js +64 -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/DisplayObject.d.ts +2 -9
- package/es/display-objects/DisplayObject.js +8 -27
- 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/Document.js +2 -2
- package/es/dom/Element.js +1 -0
- package/es/global-module.js +91 -8
- package/es/index.d.ts +3 -0
- package/es/index.js +3 -0
- package/es/plugins/CullingPlugin.d.ts +1 -0
- package/es/plugins/CullingPlugin.js +8 -3
- package/es/plugins/DirtyCheckPlugin.d.ts +1 -0
- package/es/plugins/DirtyCheckPlugin.js +7 -2
- package/es/plugins/EventPlugin.d.ts +1 -0
- package/es/plugins/EventPlugin.js +14 -9
- package/es/plugins/PrepareRendererPlugin.d.ts +1 -0
- package/es/plugins/PrepareRendererPlugin.js +10 -5
- package/es/services/EventService.js +14 -10
- package/es/services/OffscreenCanvasCreator.d.ts +1 -1
- package/es/services/OffscreenCanvasCreator.js +1 -1
- package/es/services/RenderingService.d.ts +18 -18
- package/es/services/RenderingService.js +26 -23
- package/es/services/SceneGraphService.d.ts +2 -0
- package/es/services/SceneGraphService.js +12 -1
- 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 +12 -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 -1
- package/es/utils/index.js +2 -1
- package/es/utils/interpolation.js +3 -9
- 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/css/CSS.d.ts +2 -1
- package/lib/css/CSS.js +9 -3
- package/lib/css/CSSProperty.d.ts +3 -2
- package/lib/css/StyleValueRegistry.d.ts +4 -2
- package/lib/css/StyleValueRegistry.js +104 -96
- package/lib/css/cssom/CSSNumericValue.js +17 -17
- package/lib/css/index.d.ts +2 -1
- package/lib/css/index.js +25 -12
- package/lib/css/interfaces.d.ts +6 -0
- package/lib/css/interfaces.js +12 -0
- 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/CSSPropertyColor.d.ts +1 -1
- package/lib/css/properties/CSSPropertyLengthOrPercentage.d.ts +1 -1
- package/lib/css/properties/CSSPropertyLocalPosition.d.ts +0 -9
- package/lib/css/properties/CSSPropertyLocalPosition.js +65 -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/DisplayObject.d.ts +2 -9
- package/lib/display-objects/DisplayObject.js +9 -29
- 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/Document.js +2 -2
- package/lib/dom/Element.js +1 -0
- package/lib/global-module.js +91 -6
- package/lib/index.d.ts +3 -0
- package/lib/index.js +7 -2
- package/lib/plugins/CullingPlugin.d.ts +1 -0
- package/lib/plugins/CullingPlugin.js +7 -3
- package/lib/plugins/DirtyCheckPlugin.d.ts +1 -0
- package/lib/plugins/DirtyCheckPlugin.js +6 -2
- package/lib/plugins/EventPlugin.d.ts +1 -0
- package/lib/plugins/EventPlugin.js +13 -9
- package/lib/plugins/PrepareRendererPlugin.d.ts +1 -0
- package/lib/plugins/PrepareRendererPlugin.js +9 -5
- package/lib/services/EventService.js +14 -10
- package/lib/services/OffscreenCanvasCreator.d.ts +1 -1
- package/lib/services/OffscreenCanvasCreator.js +1 -1
- package/lib/services/RenderingService.d.ts +18 -18
- package/lib/services/RenderingService.js +26 -23
- package/lib/services/SceneGraphService.d.ts +2 -0
- package/lib/services/SceneGraphService.js +15 -1
- 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 +12 -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 -1
- package/lib/utils/index.js +17 -4
- package/lib/utils/interpolation.js +4 -10
- 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 +4 -3
- package/es/css/LayoutRegistry.d.ts +0 -11
- package/es/css/LayoutRegistry.js +0 -22
- package/es/utils/hooks.d.ts +0 -280
- package/es/utils/hooks.js +0 -753
- package/lib/css/LayoutRegistry.d.ts +0 -11
- package/lib/css/LayoutRegistry.js +0 -30
- package/lib/utils/hooks.d.ts +0 -280
- package/lib/utils/hooks.js +0 -759
|
@@ -9,9 +9,9 @@ var _tslib = require("tslib");
|
|
|
9
9
|
|
|
10
10
|
var _manaSyringe = require("mana-syringe");
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _tapable = require("tapable");
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _interfaces = require("../css/interfaces");
|
|
15
15
|
|
|
16
16
|
var _dom = require("../dom");
|
|
17
17
|
|
|
@@ -19,6 +19,7 @@ var _RenderingContext = require("./RenderingContext");
|
|
|
19
19
|
|
|
20
20
|
var _SceneGraphService = require("./SceneGraphService");
|
|
21
21
|
|
|
22
|
+
// import { SyncHook, SyncWaterfallHook, AsyncParallelHook, AsyncSeriesWaterfallHook } from '../utils';
|
|
22
23
|
var RenderingPluginContribution = _manaSyringe.Syringe.defineToken('RenderingPluginContribution');
|
|
23
24
|
/**
|
|
24
25
|
* Use frame renderer implemented by `g-canvas/svg/webgl`, in every frame we do followings:
|
|
@@ -59,55 +60,55 @@ function () {
|
|
|
59
60
|
/**
|
|
60
61
|
* called before any frame rendered
|
|
61
62
|
*/
|
|
62
|
-
init: new
|
|
63
|
+
init: new _tapable.AsyncParallelHook(),
|
|
63
64
|
|
|
64
65
|
/**
|
|
65
66
|
* only dirty object which has sth changed will be rendered
|
|
66
67
|
*/
|
|
67
|
-
dirtycheck: new
|
|
68
|
+
dirtycheck: new _tapable.SyncWaterfallHook(['object']),
|
|
68
69
|
|
|
69
70
|
/**
|
|
70
71
|
* do culling
|
|
71
72
|
*/
|
|
72
|
-
cull: new
|
|
73
|
+
cull: new _tapable.SyncWaterfallHook(['object']),
|
|
73
74
|
|
|
74
75
|
/**
|
|
75
76
|
* called at beginning of each frame, won't get called if nothing to re-render
|
|
76
77
|
*/
|
|
77
|
-
beginFrame: new
|
|
78
|
+
beginFrame: new _tapable.SyncHook([]),
|
|
78
79
|
|
|
79
80
|
/**
|
|
80
81
|
* called before every dirty object get rendered
|
|
81
82
|
*/
|
|
82
|
-
beforeRender: new
|
|
83
|
+
beforeRender: new _tapable.SyncHook(['objectToRender']),
|
|
83
84
|
|
|
84
85
|
/**
|
|
85
86
|
* called when every dirty object rendering even it's culled
|
|
86
87
|
*/
|
|
87
|
-
render: new
|
|
88
|
+
render: new _tapable.SyncHook(['objectToRender']),
|
|
88
89
|
|
|
89
90
|
/**
|
|
90
91
|
* called after every dirty object get rendered
|
|
91
92
|
*/
|
|
92
|
-
afterRender: new
|
|
93
|
-
endFrame: new
|
|
94
|
-
destroy: new
|
|
93
|
+
afterRender: new _tapable.SyncHook(['objectToRender']),
|
|
94
|
+
endFrame: new _tapable.SyncHook([]),
|
|
95
|
+
destroy: new _tapable.SyncHook([]),
|
|
95
96
|
|
|
96
97
|
/**
|
|
97
|
-
* use async but faster method such as GPU-based picking in `g-plugin-
|
|
98
|
+
* use async but faster method such as GPU-based picking in `g-plugin-device-renderer`
|
|
98
99
|
*/
|
|
99
|
-
pick: new
|
|
100
|
+
pick: new _tapable.AsyncSeriesWaterfallHook(['result']),
|
|
100
101
|
|
|
101
102
|
/**
|
|
102
103
|
* used in event system
|
|
103
104
|
*/
|
|
104
|
-
pointerDown: new
|
|
105
|
-
pointerUp: new
|
|
106
|
-
pointerMove: new
|
|
107
|
-
pointerOut: new
|
|
108
|
-
pointerOver: new
|
|
109
|
-
|
|
110
|
-
|
|
105
|
+
pointerDown: new _tapable.SyncHook(['event']),
|
|
106
|
+
pointerUp: new _tapable.SyncHook(['event']),
|
|
107
|
+
pointerMove: new _tapable.SyncHook(['event']),
|
|
108
|
+
pointerOut: new _tapable.SyncHook(['event']),
|
|
109
|
+
pointerOver: new _tapable.SyncHook(['event']),
|
|
110
|
+
pointerWheel: new _tapable.SyncHook(['event']),
|
|
111
|
+
pointerCancel: new _tapable.SyncHook(['event'])
|
|
111
112
|
};
|
|
112
113
|
}
|
|
113
114
|
|
|
@@ -123,12 +124,14 @@ function () {
|
|
|
123
124
|
cache: false
|
|
124
125
|
}).forEach(function (plugin) {
|
|
125
126
|
plugin.apply(_this);
|
|
126
|
-
});
|
|
127
|
+
}); // await this.hooks.init.callPromise();
|
|
128
|
+
|
|
127
129
|
return [4
|
|
128
130
|
/*yield*/
|
|
129
|
-
, this.hooks.init.
|
|
131
|
+
, this.hooks.init.promise()];
|
|
130
132
|
|
|
131
133
|
case 1:
|
|
134
|
+
// await this.hooks.init.callPromise();
|
|
132
135
|
_a.sent();
|
|
133
136
|
|
|
134
137
|
this.inited = true;
|
|
@@ -233,7 +236,7 @@ function () {
|
|
|
233
236
|
(0, _tslib.__decorate)([(0, _manaSyringe.contrib)(RenderingPluginContribution), (0, _tslib.__metadata)("design:type", Object)], RenderingService.prototype, "renderingPluginProvider", void 0);
|
|
234
237
|
(0, _tslib.__decorate)([(0, _manaSyringe.inject)(_RenderingContext.RenderingContext), (0, _tslib.__metadata)("design:type", Object)], RenderingService.prototype, "renderingContext", void 0);
|
|
235
238
|
(0, _tslib.__decorate)([(0, _manaSyringe.inject)(_SceneGraphService.SceneGraphService), (0, _tslib.__metadata)("design:type", Object)], RenderingService.prototype, "sceneGraphService", void 0);
|
|
236
|
-
(0, _tslib.__decorate)([(0, _manaSyringe.inject)(
|
|
239
|
+
(0, _tslib.__decorate)([(0, _manaSyringe.inject)(_interfaces.StyleValueRegistry), (0, _tslib.__metadata)("design:type", Object)], RenderingService.prototype, "styleValueRegistry", void 0);
|
|
237
240
|
RenderingService = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)()], RenderingService);
|
|
238
241
|
return RenderingService;
|
|
239
242
|
}();
|
|
@@ -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
|
/**
|
|
@@ -607,6 +607,18 @@ function () {
|
|
|
607
607
|
return transform.localTransform;
|
|
608
608
|
};
|
|
609
609
|
|
|
610
|
+
DefaultSceneGraphService.prototype.setLocalTransform = function (element, transform) {
|
|
611
|
+
var t = _glMatrix.mat4.getTranslation(_glMatrix.vec3.create(), transform);
|
|
612
|
+
|
|
613
|
+
var r = _glMatrix.mat4.getRotation(_glMatrix.quat.create(), transform);
|
|
614
|
+
|
|
615
|
+
var s = _glMatrix.mat4.getScaling(_glMatrix.vec3.create(), transform);
|
|
616
|
+
|
|
617
|
+
this.setLocalScale(element, s);
|
|
618
|
+
this.setLocalPosition(element, t);
|
|
619
|
+
this.setLocalRotation(element, r);
|
|
620
|
+
};
|
|
621
|
+
|
|
610
622
|
DefaultSceneGraphService.prototype.resetLocalTransform = function (element) {
|
|
611
623
|
this.setLocalScale(element, [1, 1, 1]);
|
|
612
624
|
this.setLocalPosition(element, [0, 0, 0]);
|
|
@@ -854,7 +866,9 @@ function () {
|
|
|
854
866
|
};
|
|
855
867
|
|
|
856
868
|
(0, _tslib.__decorate)([(0, _manaSyringe.inject)(_SceneGraphSelector.SceneGraphSelectorFactory), (0, _tslib.__metadata)("design:type", Function)], DefaultSceneGraphService.prototype, "sceneGraphSelectorFactory", void 0);
|
|
857
|
-
DefaultSceneGraphService = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)(
|
|
869
|
+
DefaultSceneGraphService = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)({
|
|
870
|
+
token: SceneGraphService
|
|
871
|
+
})], DefaultSceneGraphService);
|
|
858
872
|
return DefaultSceneGraphService;
|
|
859
873
|
}();
|
|
860
874
|
|
|
@@ -19,16 +19,12 @@ function () {
|
|
|
19
19
|
function CircleUpdater() {}
|
|
20
20
|
|
|
21
21
|
CircleUpdater.prototype.update = function (parsedStyle, object) {
|
|
22
|
-
var r = parsedStyle.r
|
|
23
|
-
x = parsedStyle.x,
|
|
24
|
-
y = parsedStyle.y;
|
|
22
|
+
var r = parsedStyle.r;
|
|
25
23
|
var width = r.value * 2;
|
|
26
24
|
var height = r.value * 2;
|
|
27
25
|
return {
|
|
28
26
|
width: width,
|
|
29
|
-
height: height
|
|
30
|
-
x: x.value || 0,
|
|
31
|
-
y: y.value || 0
|
|
27
|
+
height: height
|
|
32
28
|
};
|
|
33
29
|
};
|
|
34
30
|
|
|
@@ -20,16 +20,12 @@ function () {
|
|
|
20
20
|
|
|
21
21
|
EllipseUpdater.prototype.update = function (parsedStyle, object) {
|
|
22
22
|
var rx = parsedStyle.rx,
|
|
23
|
-
ry = parsedStyle.ry
|
|
24
|
-
x = parsedStyle.x,
|
|
25
|
-
y = parsedStyle.y;
|
|
23
|
+
ry = parsedStyle.ry;
|
|
26
24
|
var width = rx.value * 2;
|
|
27
25
|
var height = ry.value * 2;
|
|
28
26
|
return {
|
|
29
27
|
width: width,
|
|
30
|
-
height: height
|
|
31
|
-
x: x.value || 0,
|
|
32
|
-
y: y.value || 0
|
|
28
|
+
height: height
|
|
33
29
|
};
|
|
34
30
|
};
|
|
35
31
|
|
|
@@ -21,15 +21,11 @@ function () {
|
|
|
21
21
|
PathUpdater.prototype.update = function (parsedStyle) {
|
|
22
22
|
var path = parsedStyle.path;
|
|
23
23
|
var _a = path.rect,
|
|
24
|
-
minX = _a.x,
|
|
25
|
-
minY = _a.y,
|
|
26
24
|
width = _a.width,
|
|
27
25
|
height = _a.height;
|
|
28
26
|
return {
|
|
29
27
|
width: width,
|
|
30
|
-
height: height
|
|
31
|
-
x: minX,
|
|
32
|
-
y: minY
|
|
28
|
+
height: height
|
|
33
29
|
};
|
|
34
30
|
};
|
|
35
31
|
|
|
@@ -24,8 +24,6 @@ function () {
|
|
|
24
24
|
|
|
25
25
|
RectUpdater.prototype.update = function (parsedStyle, object) {
|
|
26
26
|
var img = parsedStyle.img,
|
|
27
|
-
x = parsedStyle.x,
|
|
28
|
-
y = parsedStyle.y,
|
|
29
27
|
width = parsedStyle.width,
|
|
30
28
|
height = parsedStyle.height;
|
|
31
29
|
var contentWidth = 0;
|
|
@@ -64,9 +62,7 @@ function () {
|
|
|
64
62
|
|
|
65
63
|
return {
|
|
66
64
|
width: contentWidth,
|
|
67
|
-
height: contentHeight
|
|
68
|
-
x: x.value || 0,
|
|
69
|
-
y: y.value || 0
|
|
65
|
+
height: contentHeight
|
|
70
66
|
};
|
|
71
67
|
};
|
|
72
68
|
|
|
@@ -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
|
}
|
|
@@ -42,8 +42,6 @@ function () {
|
|
|
42
42
|
textAlign = parsedStyle.textAlign,
|
|
43
43
|
lineWidth = parsedStyle.lineWidth,
|
|
44
44
|
textBaseline = parsedStyle.textBaseline,
|
|
45
|
-
x = parsedStyle.x,
|
|
46
|
-
y = parsedStyle.y,
|
|
47
45
|
dx = parsedStyle.dx,
|
|
48
46
|
dy = parsedStyle.dy;
|
|
49
47
|
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;
|
|
@@ -133,8 +131,6 @@ function () {
|
|
|
133
131
|
return {
|
|
134
132
|
width: halfExtents[0] * 2,
|
|
135
133
|
height: halfExtents[1] * 2,
|
|
136
|
-
x: x.value || 0,
|
|
137
|
-
y: y.value || 0,
|
|
138
134
|
offsetX: lineXOffset,
|
|
139
135
|
offsetY: lineYOffset
|
|
140
136
|
};
|
package/lib/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
|
*/
|
|
@@ -120,6 +109,10 @@ export interface BaseStyleProps {
|
|
|
120
109
|
opacity?: number;
|
|
121
110
|
/** 线宽 */
|
|
122
111
|
lineWidth?: string | number;
|
|
112
|
+
/**
|
|
113
|
+
* increased line width when hitting test
|
|
114
|
+
*/
|
|
115
|
+
increasedLineWidthForHitTesting?: string | number;
|
|
123
116
|
/**
|
|
124
117
|
* 交互区域
|
|
125
118
|
*/
|
|
@@ -157,8 +150,9 @@ export interface BaseStyleProps {
|
|
|
157
150
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/miterLimit
|
|
158
151
|
*/
|
|
159
152
|
miterLimit?: number;
|
|
153
|
+
display?: string;
|
|
160
154
|
}
|
|
161
|
-
export interface ParsedBaseStyleProps extends Omit<BaseStyleProps, 'anchor' | 'x' | 'y' | 'z' | 'opacity' | 'strokeOpacity' | 'fillOpacity' | 'fill' | 'stroke' | 'lineWidth' | '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'> {
|
|
162
156
|
zIndex?: CSSUnitValue;
|
|
163
157
|
visibility?: CSSKeywordValue;
|
|
164
158
|
pointerEvents?: CSSKeywordValue;
|
|
@@ -172,13 +166,12 @@ export interface ParsedBaseStyleProps extends Omit<BaseStyleProps, 'anchor' | 'x
|
|
|
172
166
|
lineJoin?: CSSKeywordValue;
|
|
173
167
|
lineDashOffset?: CSSUnitValue;
|
|
174
168
|
anchor?: [CSSUnitValue, CSSUnitValue, CSSUnitValue];
|
|
169
|
+
transform: ParsedTransform[];
|
|
175
170
|
transformOrigin?: [CSSUnitValue, CSSUnitValue, CSSUnitValue];
|
|
176
|
-
x?: CSSUnitValue;
|
|
177
|
-
y?: CSSUnitValue;
|
|
178
|
-
z?: CSSUnitValue;
|
|
179
171
|
width?: CSSUnitValue;
|
|
180
172
|
height?: CSSUnitValue;
|
|
181
173
|
lineWidth?: CSSUnitValue;
|
|
174
|
+
increasedLineWidthForHitTesting?: CSSUnitValue;
|
|
182
175
|
/**
|
|
183
176
|
* x according to definition, eg. Line's x1/x2, Polyline's points
|
|
184
177
|
*/
|
|
@@ -210,10 +203,6 @@ export interface RendererConfig {
|
|
|
210
203
|
* enable auto rendering
|
|
211
204
|
*/
|
|
212
205
|
enableAutoRendering: boolean;
|
|
213
|
-
/**
|
|
214
|
-
* enable TAA in WebGL
|
|
215
|
-
*/
|
|
216
|
-
enableTAA: boolean;
|
|
217
206
|
}
|
|
218
207
|
export declare const CanvasConfig: Syringe.DefinedToken;
|
|
219
208
|
export interface CanvasConfig {
|
|
@@ -245,7 +234,7 @@ export interface CanvasConfig {
|
|
|
245
234
|
/**
|
|
246
235
|
* replace `new window.Image()`
|
|
247
236
|
*/
|
|
248
|
-
createImage?: () => HTMLImageElement;
|
|
237
|
+
createImage?: (src: string) => HTMLImageElement;
|
|
249
238
|
/**
|
|
250
239
|
* limits query
|
|
251
240
|
*/
|
package/lib/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 {};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.makeQuerablePromise = exports.equalSet = exports.ObjectTyped = exports.Deferred = void 0;
|
|
7
|
+
|
|
8
|
+
var _tslib = require("tslib");
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* This function allow you to modify a JS Promise by adding some status properties.
|
|
12
|
+
* Based on: http://stackoverflow.com/questions/21485545/is-there-a-way-to-tell-if-an-es6-promise-is-fulfilled-rejected-resolved
|
|
13
|
+
* But modified according to the specs of promises : https://promisesaplus.com/
|
|
14
|
+
*/
|
|
15
|
+
var makeQuerablePromise = function makeQuerablePromise(promise) {
|
|
16
|
+
// Don't modify any promise that has been already modified.
|
|
17
|
+
if (promise.isRejected || promise.isFulfilled) return promise; // Set initial state
|
|
18
|
+
|
|
19
|
+
var isPending = true;
|
|
20
|
+
var isRejected = false;
|
|
21
|
+
var isFulfilled = false;
|
|
22
|
+
var fullFilledValue; // Observe the promise, saving the fulfillment in a closure scope.
|
|
23
|
+
|
|
24
|
+
var result = promise.then(function (v) {
|
|
25
|
+
isFulfilled = true;
|
|
26
|
+
isPending = false;
|
|
27
|
+
fullFilledValue = v;
|
|
28
|
+
return v;
|
|
29
|
+
}, function (e) {
|
|
30
|
+
isRejected = true;
|
|
31
|
+
isPending = false;
|
|
32
|
+
throw e;
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
result.isFulfilled = function () {
|
|
36
|
+
return isFulfilled;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
result.isPending = function () {
|
|
40
|
+
return isPending;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
result.isRejected = function () {
|
|
44
|
+
return isRejected;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
result.getFullFilledValue = function () {
|
|
48
|
+
return fullFilledValue;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return result;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Simple implementation of the deferred pattern.
|
|
55
|
+
* An object that exposes a promise and functions to resolve and reject it.
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
exports.makeQuerablePromise = makeQuerablePromise;
|
|
60
|
+
|
|
61
|
+
var Deferred =
|
|
62
|
+
/** @class */
|
|
63
|
+
function () {
|
|
64
|
+
function Deferred() {
|
|
65
|
+
var _this = this;
|
|
66
|
+
|
|
67
|
+
this.promise = new Promise(function (resolve, reject) {
|
|
68
|
+
_this.resolve = resolve;
|
|
69
|
+
_this.reject = reject;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return Deferred;
|
|
74
|
+
}();
|
|
75
|
+
|
|
76
|
+
exports.Deferred = Deferred;
|
|
77
|
+
|
|
78
|
+
var equalSet = function equalSet(as, bs) {
|
|
79
|
+
var e_1, _a;
|
|
80
|
+
|
|
81
|
+
if (as.size !== bs.size) return false;
|
|
82
|
+
|
|
83
|
+
try {
|
|
84
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
85
|
+
for (var as_1 = (0, _tslib.__values)(as), as_1_1 = as_1.next(); !as_1_1.done; as_1_1 = as_1.next()) {
|
|
86
|
+
var a = as_1_1.value;
|
|
87
|
+
|
|
88
|
+
if (!bs.has(a)) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
} catch (e_1_1) {
|
|
93
|
+
e_1 = {
|
|
94
|
+
error: e_1_1
|
|
95
|
+
};
|
|
96
|
+
} finally {
|
|
97
|
+
try {
|
|
98
|
+
if (as_1_1 && !as_1_1.done && (_a = as_1.return)) _a.call(as_1);
|
|
99
|
+
} finally {
|
|
100
|
+
if (e_1) throw e_1.error;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return true;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Nicely typed aliases for some `Object` Methods
|
|
108
|
+
* - PSA: Don't mutate `yourObject`s
|
|
109
|
+
* - Numerical keys are BAD, resolve that issue upstream
|
|
110
|
+
* - Discussion: https://stackoverflow.com/a/65117465/565877
|
|
111
|
+
*/
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
exports.equalSet = equalSet;
|
|
115
|
+
var ObjectTyped = {
|
|
116
|
+
/**
|
|
117
|
+
* Object.keys, but with nice typing (`Array<keyof T>`)
|
|
118
|
+
*/
|
|
119
|
+
keys: Object.keys,
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Object.values, but with nice typing
|
|
123
|
+
*/
|
|
124
|
+
values: Object.values,
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Object.entries, but with nice typing
|
|
128
|
+
*/
|
|
129
|
+
entries: Object.entries
|
|
130
|
+
};
|
|
131
|
+
exports.ObjectTyped = ObjectTyped;
|
package/lib/utils/dom.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.setDOMSize = setDOMSize;
|
|
7
|
+
|
|
8
|
+
var _canvas = require("./canvas");
|
|
9
|
+
|
|
10
|
+
var PX_SUFFIX = 'px';
|
|
11
|
+
|
|
12
|
+
function setDOMSize($el, width, height) {
|
|
13
|
+
if (_canvas.isBrowser && $el.style) {
|
|
14
|
+
$el.style.width = width + PX_SUFFIX;
|
|
15
|
+
$el.style.height = height + PX_SUFFIX;
|
|
16
|
+
}
|
|
17
|
+
}
|
package/lib/utils/index.d.ts
CHANGED