@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
|
@@ -31,18 +31,14 @@ var _shapes = require("../shapes");
|
|
|
31
31
|
|
|
32
32
|
var _interfaces2 = require("../css/interfaces");
|
|
33
33
|
|
|
34
|
-
var _css = require("../css");
|
|
35
|
-
|
|
36
34
|
var DEFAULT_STYLE_PROPS = {
|
|
37
|
-
x: '',
|
|
38
|
-
y: '',
|
|
39
|
-
z: '',
|
|
40
35
|
anchor: [0, 0],
|
|
41
36
|
opacity: '',
|
|
42
37
|
fillOpacity: '',
|
|
43
38
|
strokeOpacity: '',
|
|
44
39
|
fill: '',
|
|
45
40
|
stroke: '',
|
|
41
|
+
transform: '',
|
|
46
42
|
transformOrigin: '',
|
|
47
43
|
visibility: '',
|
|
48
44
|
pointerEvents: '',
|
|
@@ -307,7 +303,6 @@ function (_super) {
|
|
|
307
303
|
}
|
|
308
304
|
|
|
309
305
|
this.sceneGraphService.setPosition(this, (0, _utils.createVec3)(position, y, z));
|
|
310
|
-
this.syncLocalPosition();
|
|
311
306
|
return this;
|
|
312
307
|
};
|
|
313
308
|
/**
|
|
@@ -325,7 +320,6 @@ function (_super) {
|
|
|
325
320
|
}
|
|
326
321
|
|
|
327
322
|
this.sceneGraphService.setLocalPosition(this, (0, _utils.createVec3)(position, y, z));
|
|
328
|
-
this.syncLocalPosition();
|
|
329
323
|
return this;
|
|
330
324
|
};
|
|
331
325
|
/**
|
|
@@ -343,7 +337,6 @@ function (_super) {
|
|
|
343
337
|
}
|
|
344
338
|
|
|
345
339
|
this.sceneGraphService.translate(this, (0, _utils.createVec3)(position, y, z));
|
|
346
|
-
this.syncLocalPosition();
|
|
347
340
|
return this;
|
|
348
341
|
};
|
|
349
342
|
/**
|
|
@@ -361,7 +354,6 @@ function (_super) {
|
|
|
361
354
|
}
|
|
362
355
|
|
|
363
356
|
this.sceneGraphService.translateLocal(this, (0, _utils.createVec3)(position, y, z));
|
|
364
|
-
this.syncLocalPosition();
|
|
365
357
|
return this;
|
|
366
358
|
};
|
|
367
359
|
|
|
@@ -520,26 +512,13 @@ function (_super) {
|
|
|
520
512
|
return this.sceneGraphService.getWorldTransform(this);
|
|
521
513
|
};
|
|
522
514
|
|
|
523
|
-
DisplayObject.prototype.
|
|
524
|
-
this.sceneGraphService.
|
|
515
|
+
DisplayObject.prototype.setLocalTransform = function (transform) {
|
|
516
|
+
this.sceneGraphService.setLocalTransform(this, transform);
|
|
517
|
+
return this;
|
|
525
518
|
};
|
|
526
|
-
/**
|
|
527
|
-
* sync style.x/y when local position changed
|
|
528
|
-
*
|
|
529
|
-
* Mixins may not declare private/protected properties
|
|
530
|
-
* however, you can use ES2020 private fields
|
|
531
|
-
*/
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
DisplayObject.prototype.syncLocalPosition = function () {
|
|
535
|
-
var localPosition = this.getLocalPosition();
|
|
536
|
-
this.attributes.x = localPosition[0];
|
|
537
|
-
this.attributes.y = localPosition[1];
|
|
538
|
-
this.attributes.z = localPosition[2]; // should not affect computed style
|
|
539
519
|
|
|
540
|
-
|
|
541
|
-
this.
|
|
542
|
-
this.parsedStyle.z = new _css.CSSUnitValue(this.attributes.z, 'px');
|
|
520
|
+
DisplayObject.prototype.resetLocalTransform = function () {
|
|
521
|
+
this.sceneGraphService.resetLocalTransform(this);
|
|
543
522
|
}; // #endregion transformable
|
|
544
523
|
// #region animatable
|
|
545
524
|
|
|
@@ -3,10 +3,14 @@ import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
|
|
|
3
3
|
import { DisplayObject } from './DisplayObject';
|
|
4
4
|
import type { CSSUnitValue } from '../css';
|
|
5
5
|
export interface EllipseStyleProps extends BaseStyleProps {
|
|
6
|
+
cx?: number | string;
|
|
7
|
+
cy?: number | string;
|
|
6
8
|
rx: number | string;
|
|
7
9
|
ry: number | string;
|
|
8
10
|
}
|
|
9
11
|
export interface ParsedEllipseStyleProps extends ParsedBaseStyleProps {
|
|
12
|
+
cx: CSSUnitValue;
|
|
13
|
+
cy: CSSUnitValue;
|
|
10
14
|
rx: CSSUnitValue;
|
|
11
15
|
ry: CSSUnitValue;
|
|
12
16
|
}
|
|
@@ -3,10 +3,14 @@ import { DisplayObject } from './DisplayObject';
|
|
|
3
3
|
import type { DisplayObjectConfig } from '../dom';
|
|
4
4
|
import type { CSSUnitValue } from '../css';
|
|
5
5
|
export interface GroupStyleProps extends BaseStyleProps {
|
|
6
|
+
x?: number | string;
|
|
7
|
+
y?: number | string;
|
|
6
8
|
width?: number | string;
|
|
7
9
|
height?: number | string;
|
|
8
10
|
}
|
|
9
11
|
export interface ParsedGroupStyleProps extends ParsedBaseStyleProps {
|
|
12
|
+
x: CSSUnitValue;
|
|
13
|
+
y: CSSUnitValue;
|
|
10
14
|
width?: CSSUnitValue;
|
|
11
15
|
height?: CSSUnitValue;
|
|
12
16
|
}
|
|
@@ -4,19 +4,19 @@ import type { DisplayObjectConfig } from '../dom';
|
|
|
4
4
|
import { AABB } from '../shapes';
|
|
5
5
|
import type { CSSUnitValue } from '../css';
|
|
6
6
|
export interface HTMLStyleProps extends BaseStyleProps {
|
|
7
|
+
x?: number | string;
|
|
8
|
+
y?: number | string;
|
|
7
9
|
innerHTML: string | HTMLElement;
|
|
8
10
|
width: number;
|
|
9
11
|
height: number;
|
|
10
|
-
className?: string | string[];
|
|
11
|
-
style?: string;
|
|
12
12
|
}
|
|
13
13
|
export interface ParsedHTMLStyleProps extends ParsedBaseStyleProps {
|
|
14
|
+
x: CSSUnitValue;
|
|
15
|
+
y: CSSUnitValue;
|
|
14
16
|
$el: HTMLElement;
|
|
15
17
|
innerHTML: string | HTMLElement;
|
|
16
18
|
width: CSSUnitValue;
|
|
17
19
|
height: CSSUnitValue;
|
|
18
|
-
className?: string | string[];
|
|
19
|
-
style?: string;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
* HTML container
|
|
@@ -36,9 +36,11 @@ function (_super) {
|
|
|
36
36
|
_this = _super.call(this, (0, _tslib.__assign)({
|
|
37
37
|
type: _types.Shape.HTML,
|
|
38
38
|
style: (0, _tslib.__assign)({
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
x: '',
|
|
40
|
+
y: '',
|
|
41
|
+
width: '',
|
|
42
|
+
height: '',
|
|
43
|
+
innerHTML: ''
|
|
42
44
|
}, style)
|
|
43
45
|
}, rest)) || this;
|
|
44
46
|
_this.cullable.enable = false;
|
|
@@ -3,12 +3,16 @@ import { DisplayObject } from './DisplayObject';
|
|
|
3
3
|
import type { DisplayObjectConfig } from '../dom';
|
|
4
4
|
import type { CSSUnitValue } from '../css';
|
|
5
5
|
export interface ImageStyleProps extends BaseStyleProps {
|
|
6
|
+
x?: number | string;
|
|
7
|
+
y?: number | string;
|
|
6
8
|
img?: string | HTMLImageElement;
|
|
7
9
|
src?: string | HTMLImageElement;
|
|
8
10
|
width?: number | string;
|
|
9
11
|
height?: number | string;
|
|
10
12
|
}
|
|
11
13
|
export interface ParsedImageStyleProps extends ParsedBaseStyleProps {
|
|
14
|
+
x: CSSUnitValue;
|
|
15
|
+
y: CSSUnitValue;
|
|
12
16
|
img?: string | HTMLImageElement;
|
|
13
17
|
src?: string | HTMLImageElement;
|
|
14
18
|
width?: CSSUnitValue;
|
|
@@ -47,6 +47,7 @@ function (_super) {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
Line.prototype.getPoint = function (ratio) {
|
|
50
|
+
// TODO: account for z1/z2 in 3D line
|
|
50
51
|
var _a = this.parsedStyle,
|
|
51
52
|
x1 = _a.x1,
|
|
52
53
|
y1 = _a.y1,
|
|
@@ -59,6 +60,7 @@ function (_super) {
|
|
|
59
60
|
};
|
|
60
61
|
|
|
61
62
|
Line.prototype.getTotalLength = function () {
|
|
63
|
+
// TODO: account for z1/z2 in 3D line
|
|
62
64
|
var _a = this.parsedStyle,
|
|
63
65
|
x1 = _a.x1,
|
|
64
66
|
y1 = _a.y1,
|
|
@@ -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/lib/dom/Element.js
CHANGED
package/lib/global-module.js
CHANGED
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.containerModule = void 0;
|
|
7
7
|
|
|
8
|
+
var _tslib = require("tslib");
|
|
9
|
+
|
|
8
10
|
var _manaSyringe = require("mana-syringe");
|
|
9
11
|
|
|
10
12
|
var _eventemitter = require("eventemitter3");
|
|
@@ -15,6 +17,8 @@ var _services = require("./services");
|
|
|
15
17
|
|
|
16
18
|
var _css = require("./css");
|
|
17
19
|
|
|
20
|
+
var _layout = require("./css/layout");
|
|
21
|
+
|
|
18
22
|
var containerModule = (0, _manaSyringe.Module)(function (register) {
|
|
19
23
|
(0, _manaSyringe.decorate)((0, _manaSyringe.injectable)(), _eventemitter.EventEmitter); // bind DisplayObject pool
|
|
20
24
|
|
|
@@ -77,6 +81,90 @@ var containerModule = (0, _manaSyringe.Module)(function (register) {
|
|
|
77
81
|
register(_css.CSSPropertyPoints);
|
|
78
82
|
register(_css.CSSPropertyClipPath);
|
|
79
83
|
register(_css.CSSPropertyText);
|
|
80
|
-
register(_css.CSSPropertyTextTransform);
|
|
84
|
+
register(_css.CSSPropertyTextTransform); // bind layout engine
|
|
85
|
+
|
|
86
|
+
register(_layout.LayoutEngine);
|
|
87
|
+
register(_layout.LayoutEdges);
|
|
88
|
+
register({
|
|
89
|
+
token: _layout.LayoutEdgesFactory,
|
|
90
|
+
useFactory: function useFactory(context) {
|
|
91
|
+
return function (options) {
|
|
92
|
+
var container = context.container.createChild();
|
|
93
|
+
container.register({
|
|
94
|
+
token: _layout.LayoutEdgesOptions,
|
|
95
|
+
useValue: options
|
|
96
|
+
});
|
|
97
|
+
return container.get(_layout.LayoutEdges);
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
register({
|
|
102
|
+
token: _layout.LayoutContextFactory,
|
|
103
|
+
useFactory: function useFactory(context) {
|
|
104
|
+
return function (options) {
|
|
105
|
+
var container = context.container.createChild();
|
|
106
|
+
container.register(_layout.LayoutContext);
|
|
107
|
+
container.register(_layout.LayoutChildren);
|
|
108
|
+
container.register({
|
|
109
|
+
token: _layout.LayoutChildrenFactory,
|
|
110
|
+
useFactory: function useFactory(childContext) {
|
|
111
|
+
return function (childOptions) {
|
|
112
|
+
var childContainer = childContext.container.createChild();
|
|
113
|
+
childContainer.register({
|
|
114
|
+
token: _layout.LayoutChildrenOptions,
|
|
115
|
+
useValue: childOptions
|
|
116
|
+
});
|
|
117
|
+
return childContainer.get(_layout.LayoutChildren);
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
container.register(_layout.FragmentResult);
|
|
122
|
+
container.register({
|
|
123
|
+
token: _layout.FragmentResultFactory,
|
|
124
|
+
useFactory: function useFactory(childContext) {
|
|
125
|
+
return function (childOptions, node) {
|
|
126
|
+
var childContainer = childContext.container.createChild();
|
|
127
|
+
childContainer.register({
|
|
128
|
+
token: _layout.FragmentResultOptions,
|
|
129
|
+
useValue: childOptions
|
|
130
|
+
});
|
|
131
|
+
childContainer.register({
|
|
132
|
+
token: _layout.ContextNode,
|
|
133
|
+
useValue: node
|
|
134
|
+
});
|
|
135
|
+
return childContainer.get(_layout.FragmentResult);
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
container.register(_layout.LayoutFragment);
|
|
140
|
+
container.register({
|
|
141
|
+
token: _layout.LayoutFragmentFactory,
|
|
142
|
+
useFactory: function useFactory(childContext) {
|
|
143
|
+
return function (childOptions) {
|
|
144
|
+
var childContainer = childContext.container.createChild();
|
|
145
|
+
childContainer.register({
|
|
146
|
+
token: _layout.LayoutFragmentOptions,
|
|
147
|
+
useValue: childOptions
|
|
148
|
+
});
|
|
149
|
+
return childContainer.get(_layout.LayoutFragment);
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
var layoutChildrenFactory = container.get(_layout.LayoutChildrenFactory);
|
|
154
|
+
var layoutFragmentFactory = container.get(_layout.LayoutFragmentFactory);
|
|
155
|
+
var fragmentResultFactory = container.get(_layout.FragmentResultFactory);
|
|
156
|
+
container.register({
|
|
157
|
+
token: _layout.LayoutContextOptions,
|
|
158
|
+
useValue: (0, _tslib.__assign)((0, _tslib.__assign)({}, options), {
|
|
159
|
+
layoutChildrenFactory: layoutChildrenFactory,
|
|
160
|
+
layoutFragmentFactory: layoutFragmentFactory,
|
|
161
|
+
fragmentResultFactory: fragmentResultFactory
|
|
162
|
+
})
|
|
163
|
+
});
|
|
164
|
+
var layoutContext = container.get(_layout.LayoutContext);
|
|
165
|
+
return layoutContext;
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
});
|
|
81
169
|
});
|
|
82
170
|
exports.containerModule = containerModule;
|
package/lib/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/lib/index.js
CHANGED
|
@@ -6,9 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
var _exportNames = {
|
|
9
|
+
layoutEngine: true,
|
|
9
10
|
ManaSyringe: true
|
|
10
11
|
};
|
|
11
|
-
exports.ManaSyringe = void 0;
|
|
12
|
+
exports.layoutEngine = exports.ManaSyringe = void 0;
|
|
12
13
|
|
|
13
14
|
require("reflect-metadata");
|
|
14
15
|
|
|
@@ -18,6 +19,8 @@ exports.ManaSyringe = ManaSyringe;
|
|
|
18
19
|
|
|
19
20
|
var _globalModule = require("./global-module");
|
|
20
21
|
|
|
22
|
+
var _layout = require("./css/layout");
|
|
23
|
+
|
|
21
24
|
var _types = require("./types");
|
|
22
25
|
|
|
23
26
|
Object.keys(_types).forEach(function (key) {
|
|
@@ -190,4 +193,6 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
190
193
|
|
|
191
194
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
192
195
|
|
|
193
|
-
ManaSyringe.GlobalContainer.load(_globalModule.containerModule);
|
|
196
|
+
ManaSyringe.GlobalContainer.load(_globalModule.containerModule);
|
|
197
|
+
var layoutEngine = ManaSyringe.GlobalContainer.get(_layout.LayoutEngine);
|
|
198
|
+
exports.layoutEngine = layoutEngine;
|
|
@@ -376,7 +376,11 @@ function (_super) {
|
|
|
376
376
|
while (leaveEvent.target && !e.composedPath().includes(leaveEvent.target)) {
|
|
377
377
|
leaveEvent.currentTarget = leaveEvent.target;
|
|
378
378
|
this.notifyTarget(leaveEvent);
|
|
379
|
-
|
|
379
|
+
|
|
380
|
+
if (isMouse) {
|
|
381
|
+
// console.error(leaveEvent.target);
|
|
382
|
+
this.notifyTarget(leaveEvent, 'mouseleave');
|
|
383
|
+
}
|
|
380
384
|
|
|
381
385
|
if (_Node.Node.isNode(leaveEvent.target)) {
|
|
382
386
|
leaveEvent.target = leaveEvent.target.parentNode;
|
|
@@ -481,7 +485,11 @@ function (_super) {
|
|
|
481
485
|
while (leaveEvent.target && leaveEvent.target !== (_Node.Node.isNode(this.rootTarget) && this.rootTarget.parentNode)) {
|
|
482
486
|
leaveEvent.currentTarget = leaveEvent.target;
|
|
483
487
|
this.notifyTarget(leaveEvent);
|
|
484
|
-
|
|
488
|
+
|
|
489
|
+
if (isMouse) {
|
|
490
|
+
// console.error(leaveEvent.target, 'out');
|
|
491
|
+
this.notifyTarget(leaveEvent, 'mouseleave');
|
|
492
|
+
}
|
|
485
493
|
|
|
486
494
|
if (_Node.Node.isNode(leaveEvent.target)) {
|
|
487
495
|
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;
|
|
@@ -13,7 +13,7 @@ var _manaSyringe = require("mana-syringe");
|
|
|
13
13
|
* used in following scenes:
|
|
14
14
|
* - g `ctx.measureText`
|
|
15
15
|
* - g-plugin-canvas-picker `ctx.isPointInPath`
|
|
16
|
-
* - g-plugin-
|
|
16
|
+
* - g-plugin-device-renderer `ctx.createLinearGradient` and generate texture
|
|
17
17
|
*/
|
|
18
18
|
var OffscreenCanvasCreator =
|
|
19
19
|
/** @class */
|
|
@@ -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
|
/**
|
|
@@ -95,7 +95,7 @@ function () {
|
|
|
95
95
|
destroy: new _tapable.SyncHook([]),
|
|
96
96
|
|
|
97
97
|
/**
|
|
98
|
-
* 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`
|
|
99
99
|
*/
|
|
100
100
|
pick: new _tapable.AsyncSeriesWaterfallHook(['result']),
|
|
101
101
|
|
|
@@ -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]);
|
|
@@ -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
|
|