@antv/g 5.0.3 → 5.0.7
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.js +1 -1
- package/es/Canvas.d.ts +9 -0
- package/es/Canvas.js +16 -9
- package/es/camera/Camera.d.ts +2 -1
- package/es/camera/Camera.js +13 -5
- package/es/components/Sortable.d.ts +4 -0
- package/es/components/Sortable.js +5 -0
- package/es/display-objects/DisplayObject.d.ts +2 -5
- package/es/display-objects/DisplayObject.js +16 -9
- package/es/display-objects/Line.d.ts +6 -0
- package/es/display-objects/Line.js +7 -8
- package/es/display-objects/Path.js +3 -7
- package/es/display-objects/Polyline.js +3 -7
- package/es/display-objects/Text.js +3 -7
- package/es/dom/Element.d.ts +10 -10
- package/es/dom/Element.js +7 -4
- package/es/dom/Node.d.ts +7 -7
- package/es/dom/interfaces.d.ts +21 -17
- package/es/dom/interfaces.js +5 -0
- package/es/global-module.d.ts +4 -0
- package/es/global-module.js +58 -71
- package/es/plugins/FrustumCullingStrategy.js +3 -1
- package/es/property-handlers/localPosition.js +4 -2
- package/es/services/RenderingService.d.ts +6 -0
- package/es/services/RenderingService.js +29 -1
- package/es/services/SceneGraphService.js +4 -4
- package/es/types.d.ts +10 -3
- package/es/types.js +16 -0
- package/es/utils/interpolation.js +10 -7
- package/lib/Canvas.d.ts +9 -0
- package/lib/Canvas.js +16 -9
- package/lib/camera/Camera.d.ts +2 -1
- package/lib/camera/Camera.js +14 -5
- package/lib/components/Sortable.d.ts +4 -0
- package/lib/components/Sortable.js +5 -0
- package/lib/display-objects/DisplayObject.d.ts +2 -5
- package/lib/display-objects/DisplayObject.js +13 -8
- package/lib/display-objects/Line.d.ts +6 -0
- package/lib/display-objects/Line.js +6 -7
- package/lib/display-objects/Path.js +2 -6
- package/lib/display-objects/Polyline.js +2 -6
- package/lib/display-objects/Text.js +2 -6
- package/lib/dom/Element.d.ts +10 -10
- package/lib/dom/Element.js +7 -4
- package/lib/dom/Node.d.ts +7 -7
- package/lib/dom/interfaces.d.ts +21 -17
- package/lib/dom/interfaces.js +5 -0
- package/lib/global-module.d.ts +4 -0
- package/lib/global-module.js +58 -71
- package/lib/plugins/FrustumCullingStrategy.js +2 -0
- package/lib/property-handlers/localPosition.js +4 -2
- package/lib/services/RenderingService.d.ts +6 -0
- package/lib/services/RenderingService.js +30 -1
- package/lib/services/SceneGraphService.js +4 -4
- package/lib/types.d.ts +10 -3
- package/lib/types.js +19 -1
- package/lib/utils/interpolation.js +7 -9
- package/package.json +3 -3
package/es/Canvas.d.ts
CHANGED
|
@@ -42,6 +42,11 @@ export declare class Canvas extends EventTarget implements ICanvas {
|
|
|
42
42
|
* rAF in auto rendering
|
|
43
43
|
*/
|
|
44
44
|
private frameId?;
|
|
45
|
+
/**
|
|
46
|
+
* cache here since inversify's resolving is very slow
|
|
47
|
+
*/
|
|
48
|
+
private eventService;
|
|
49
|
+
private renderingService;
|
|
45
50
|
constructor(config: CanvasConfig);
|
|
46
51
|
private initRenderingContext;
|
|
47
52
|
private initDefaultCamera;
|
|
@@ -60,6 +65,10 @@ export declare class Canvas extends EventTarget implements ICanvas {
|
|
|
60
65
|
getEventService(): EventService;
|
|
61
66
|
getRenderingService(): RenderingService;
|
|
62
67
|
getRenderingContext(): RenderingContext;
|
|
68
|
+
getStats(): {
|
|
69
|
+
total: number;
|
|
70
|
+
rendered: number;
|
|
71
|
+
};
|
|
63
72
|
getComputedStyle(node: DisplayObject): any;
|
|
64
73
|
destroy(destroyScenegraph?: boolean): void;
|
|
65
74
|
/**
|
package/es/Canvas.js
CHANGED
|
@@ -50,9 +50,11 @@ function (_super) {
|
|
|
50
50
|
_this.customElements = new CustomElementRegistry();
|
|
51
51
|
cleanExistedCanvas(config.container, _this);
|
|
52
52
|
|
|
53
|
-
var mergedConfig = __assign(
|
|
53
|
+
var mergedConfig = __assign({
|
|
54
|
+
width: 300,
|
|
55
|
+
height: 150,
|
|
54
56
|
cursor: 'default'
|
|
55
|
-
});
|
|
57
|
+
}, config);
|
|
56
58
|
|
|
57
59
|
_this.initRenderingContext(mergedConfig);
|
|
58
60
|
|
|
@@ -98,8 +100,7 @@ function (_super) {
|
|
|
98
100
|
|
|
99
101
|
Canvas.prototype.initDefaultCamera = function (width, height) {
|
|
100
102
|
// set a default ortho camera
|
|
101
|
-
var camera = new Camera().setPosition(width / 2, height / 2, 500).setFocalPoint(width / 2, height / 2, 0)
|
|
102
|
-
.setOrthographic(width / -2, width / 2, height / -2, height / 2, 0.1, 1000); // redraw when camera changed
|
|
103
|
+
var camera = new Camera().setPosition(width / 2, height / 2, 500).setFocalPoint(width / 2, height / 2, 0).setOrthographic(width / -2, width / 2, height / 2, height / -2, 0.1, 1000); // redraw when camera changed
|
|
103
104
|
|
|
104
105
|
var context = this.container.get(RenderingContext);
|
|
105
106
|
camera.on(CAMERA_EVENT.Updated, function () {
|
|
@@ -142,17 +143,21 @@ function (_super) {
|
|
|
142
143
|
};
|
|
143
144
|
|
|
144
145
|
Canvas.prototype.getEventService = function () {
|
|
145
|
-
return this.
|
|
146
|
+
return this.eventService;
|
|
146
147
|
};
|
|
147
148
|
|
|
148
149
|
Canvas.prototype.getRenderingService = function () {
|
|
149
|
-
return this.
|
|
150
|
+
return this.renderingService;
|
|
150
151
|
};
|
|
151
152
|
|
|
152
153
|
Canvas.prototype.getRenderingContext = function () {
|
|
153
154
|
return this.container.get(RenderingContext);
|
|
154
155
|
};
|
|
155
156
|
|
|
157
|
+
Canvas.prototype.getStats = function () {
|
|
158
|
+
return this.getRenderingService().getStats();
|
|
159
|
+
};
|
|
160
|
+
|
|
156
161
|
Canvas.prototype.getComputedStyle = function (node) {
|
|
157
162
|
return node.parsedStyle;
|
|
158
163
|
};
|
|
@@ -203,9 +208,10 @@ function (_super) {
|
|
|
203
208
|
|
|
204
209
|
var camera = this.container.get(DefaultCamera);
|
|
205
210
|
var projectionMode = camera.getProjectionMode();
|
|
211
|
+
camera.setPosition(width / 2, height / 2, 500).setFocalPoint(width / 2, height / 2, 0);
|
|
206
212
|
|
|
207
213
|
if (projectionMode === CAMERA_PROJECTION_MODE.ORTHOGRAPHIC) {
|
|
208
|
-
camera.
|
|
214
|
+
camera.setOrthographic(width / -2, width / 2, height / 2, height / -2, camera.getNear(), camera.getFar());
|
|
209
215
|
} else {
|
|
210
216
|
camera.setAspect(width / height);
|
|
211
217
|
}
|
|
@@ -275,9 +281,10 @@ function (_super) {
|
|
|
275
281
|
this.loadRendererContainerModule(renderer); // init context
|
|
276
282
|
|
|
277
283
|
var contextService = this.container.get(ContextService);
|
|
278
|
-
|
|
284
|
+
this.renderingService = this.container.get(RenderingService);
|
|
285
|
+
this.eventService = this.container.get(EventService);
|
|
279
286
|
contextService.init();
|
|
280
|
-
renderingService.init().then(function () {
|
|
287
|
+
this.renderingService.init().then(function () {
|
|
281
288
|
_this.emit(CanvasEvent.READY, {});
|
|
282
289
|
});
|
|
283
290
|
|
package/es/camera/Camera.d.ts
CHANGED
|
@@ -129,6 +129,7 @@ export declare class Camera extends EventEmitter {
|
|
|
129
129
|
* ortho matrix for Canvas2D & SVG
|
|
130
130
|
*/
|
|
131
131
|
private orthoMatrix;
|
|
132
|
+
isOrtho(): boolean;
|
|
132
133
|
clone(): Camera;
|
|
133
134
|
getProjectionMode(): CAMERA_PROJECTION_MODE;
|
|
134
135
|
getPerspective(): mat4;
|
|
@@ -167,7 +168,7 @@ export declare class Camera extends EventEmitter {
|
|
|
167
168
|
* 设置相机矩阵
|
|
168
169
|
*/
|
|
169
170
|
setMatrix(matrix: mat4): this;
|
|
170
|
-
setFov(fov: number):
|
|
171
|
+
setFov(fov: number): this;
|
|
171
172
|
setAspect(aspect: number): this;
|
|
172
173
|
setNear(near: number): this;
|
|
173
174
|
setFar(far: number): this;
|
package/es/camera/Camera.js
CHANGED
|
@@ -136,7 +136,7 @@ function (_super) {
|
|
|
136
136
|
|
|
137
137
|
_this.fov = 30;
|
|
138
138
|
_this.near = 0.1;
|
|
139
|
-
_this.far =
|
|
139
|
+
_this.far = 1000;
|
|
140
140
|
_this.aspect = 1;
|
|
141
141
|
_this.projectionMatrix = mat4.create();
|
|
142
142
|
_this.projectionMatrixInverse = mat4.create();
|
|
@@ -163,6 +163,10 @@ function (_super) {
|
|
|
163
163
|
return _this;
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
+
Camera.prototype.isOrtho = function () {
|
|
167
|
+
return this.projectionMode === CAMERA_PROJECTION_MODE.ORTHOGRAPHIC;
|
|
168
|
+
};
|
|
169
|
+
|
|
166
170
|
Camera.prototype.clone = function () {
|
|
167
171
|
var camera = new Camera();
|
|
168
172
|
camera.setType(this.type, undefined); // camera.interactor = this.interactor;
|
|
@@ -297,6 +301,7 @@ function (_super) {
|
|
|
297
301
|
|
|
298
302
|
Camera.prototype.setFov = function (fov) {
|
|
299
303
|
this.setPerspective(this.near, this.far, fov, this.aspect);
|
|
304
|
+
return this;
|
|
300
305
|
};
|
|
301
306
|
|
|
302
307
|
Camera.prototype.setAspect = function (aspect) {
|
|
@@ -404,10 +409,11 @@ function (_super) {
|
|
|
404
409
|
top -= this.view.offsetY * height / fullHeight;
|
|
405
410
|
width *= this.view.width / fullWidth;
|
|
406
411
|
height *= this.view.height / fullHeight;
|
|
407
|
-
}
|
|
412
|
+
}
|
|
408
413
|
|
|
414
|
+
makePerspective(this.projectionMatrix, left, left + width, top, top - height, near, this.far); // flipY since the origin of OpenGL/WebGL is bottom-left compared with top-left in Canvas2D
|
|
409
415
|
|
|
410
|
-
|
|
416
|
+
mat4.scale(this.projectionMatrix, this.projectionMatrix, vec3.fromValues(1, -1, 1));
|
|
411
417
|
mat4.invert(this.projectionMatrixInverse, this.projectionMatrix);
|
|
412
418
|
this.emit(CAMERA_EVENT.Updated);
|
|
413
419
|
return this;
|
|
@@ -439,7 +445,9 @@ function (_super) {
|
|
|
439
445
|
bottom = top - scaleH * this.view.height;
|
|
440
446
|
}
|
|
441
447
|
|
|
442
|
-
mat4.ortho(this.projectionMatrix, left, right, bottom, top, near, far);
|
|
448
|
+
mat4.ortho(this.projectionMatrix, left, right, bottom, top, near, far); // flipY since the origin of OpenGL/WebGL is bottom-left compared with top-left in Canvas2D
|
|
449
|
+
|
|
450
|
+
mat4.scale(this.projectionMatrix, this.projectionMatrix, vec3.fromValues(1, -1, 1));
|
|
443
451
|
mat4.invert(this.projectionMatrixInverse, this.projectionMatrix);
|
|
444
452
|
|
|
445
453
|
this._getOrthoMatrix();
|
|
@@ -960,7 +968,7 @@ function (_super) {
|
|
|
960
968
|
|
|
961
969
|
var position = this.position;
|
|
962
970
|
var rotZ = quat.setAxisAngle(quat.create(), [0, 0, 1], -this.roll * Math.PI / 180);
|
|
963
|
-
mat4.fromRotationTranslationScaleOrigin(this.orthoMatrix, rotZ, vec3.fromValues((this.rright - this.left) / 2 - position[0], (this.
|
|
971
|
+
mat4.fromRotationTranslationScaleOrigin(this.orthoMatrix, rotZ, vec3.fromValues((this.rright - this.left) / 2 - position[0], (this.top - this.bottom) / 2 - position[1], 0), vec3.fromValues(this.zoom, this.zoom, 1), position);
|
|
964
972
|
};
|
|
965
973
|
|
|
966
974
|
Camera.ProjectionMode = {
|
|
@@ -2,9 +2,8 @@ import type { mat3, vec2 } from 'gl-matrix';
|
|
|
2
2
|
import { mat4, quat, vec3 } from 'gl-matrix';
|
|
3
3
|
import type { Animation } from '../dom/Animation';
|
|
4
4
|
import { Element } from '../dom/Element';
|
|
5
|
-
import type { DisplayObjectConfig,
|
|
5
|
+
import type { DisplayObjectConfig, IChildNode } from '../dom/interfaces';
|
|
6
6
|
import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
|
|
7
|
-
import type { StylePropertyParser, StylePropertyUpdater } from '../property-handlers';
|
|
8
7
|
/**
|
|
9
8
|
* prototype chains: DisplayObject -> Element -> Node -> EventTarget
|
|
10
9
|
*
|
|
@@ -32,8 +31,6 @@ export declare class DisplayObject<StyleProps extends BaseStyleProps = any, Pars
|
|
|
32
31
|
* push to active animations after calling `animate()`
|
|
33
32
|
*/
|
|
34
33
|
private activeAnimations;
|
|
35
|
-
stylePropertyUpdaterFactory: <Key extends keyof StyleProps>(stylePropertyName: Key) => StylePropertyUpdater<any>[];
|
|
36
|
-
stylePropertyParserFactory: <Key extends keyof ParsedStyleProps>(stylePropertyName: Key) => StylePropertyParser<any, any>;
|
|
37
34
|
constructor(config: DisplayObjectConfig<StyleProps>);
|
|
38
35
|
destroy(): void;
|
|
39
36
|
cloneNode(deep?: boolean): this;
|
|
@@ -193,7 +190,7 @@ export declare class DisplayObject<StyleProps extends BaseStyleProps = any, Pars
|
|
|
193
190
|
* compatible with G 3.0
|
|
194
191
|
* @deprecated
|
|
195
192
|
*/
|
|
196
|
-
add<T extends
|
|
193
|
+
add<T extends IChildNode>(child: T, index?: number): T;
|
|
197
194
|
/**
|
|
198
195
|
* @alias style.clipPath
|
|
199
196
|
* @deprecated
|
|
@@ -6,9 +6,10 @@ import { KeyframeEffect } from '../dom/KeyframeEffect';
|
|
|
6
6
|
import { Element } from '../dom/Element';
|
|
7
7
|
import { ElementEvent } from '../dom/interfaces';
|
|
8
8
|
import { SHAPE } from '../types';
|
|
9
|
-
import { createVec3, fromRotationTranslationScale, getEuler, rad2deg } from '../utils';
|
|
10
|
-
import { StylePropertyParserFactory, StylePropertyUpdaterFactory } from '../property-handlers';
|
|
11
|
-
|
|
9
|
+
import { createVec3, fromRotationTranslationScale, getEuler, rad2deg } from '../utils'; // import type { StylePropertyParser, StylePropertyUpdater } from '../property-handlers';
|
|
10
|
+
// import { StylePropertyParserFactory, StylePropertyUpdaterFactory } from '../property-handlers';
|
|
11
|
+
|
|
12
|
+
import { globalContainer, stylePropertyParserFactory, stylePropertyUpdaterFactory } from '../global-module';
|
|
12
13
|
import { dirtifyToRoot } from '../services';
|
|
13
14
|
var DEFAULT_STYLE_PROPS = {
|
|
14
15
|
anchor: [0, 0, 0],
|
|
@@ -39,7 +40,13 @@ var DEFAULT_STYLE_PROPS = {
|
|
|
39
40
|
var DisplayObject =
|
|
40
41
|
/** @class */
|
|
41
42
|
function (_super) {
|
|
42
|
-
__extends(DisplayObject, _super);
|
|
43
|
+
__extends(DisplayObject, _super); // stylePropertyUpdaterFactory = globalContainer.get<
|
|
44
|
+
// <Key extends keyof StyleProps>(stylePropertyName: Key) => StylePropertyUpdater<any>[]
|
|
45
|
+
// >(StylePropertyUpdaterFactory);
|
|
46
|
+
// stylePropertyParserFactory = globalContainer.get<
|
|
47
|
+
// <Key extends keyof ParsedStyleProps>(stylePropertyName: Key) => StylePropertyParser<any, any>
|
|
48
|
+
// >(StylePropertyParserFactory);
|
|
49
|
+
|
|
43
50
|
|
|
44
51
|
function DisplayObject(config) {
|
|
45
52
|
var _a, _b, _c;
|
|
@@ -50,9 +57,7 @@ function (_super) {
|
|
|
50
57
|
*/
|
|
51
58
|
|
|
52
59
|
|
|
53
|
-
_this.activeAnimations = [];
|
|
54
|
-
_this.stylePropertyUpdaterFactory = globalContainer.get(StylePropertyUpdaterFactory);
|
|
55
|
-
_this.stylePropertyParserFactory = globalContainer.get(StylePropertyParserFactory); // assign name, id to config
|
|
60
|
+
_this.activeAnimations = []; // assign name, id to config
|
|
56
61
|
// eg. group.get('name')
|
|
57
62
|
|
|
58
63
|
_this.config = config; // compatible with G 3.0
|
|
@@ -178,7 +183,8 @@ function (_super) {
|
|
|
178
183
|
|
|
179
184
|
|
|
180
185
|
DisplayObject.prototype.parseStyleProperty = function (name, value) {
|
|
181
|
-
|
|
186
|
+
// const stylePropertyParser = this.stylePropertyParserFactory(name);
|
|
187
|
+
var stylePropertyParser = stylePropertyParserFactory[name];
|
|
182
188
|
|
|
183
189
|
if (stylePropertyParser) {
|
|
184
190
|
// @ts-ignore
|
|
@@ -191,9 +197,10 @@ function (_super) {
|
|
|
191
197
|
DisplayObject.prototype.updateStyleProperty = function (name, oldParsedValue, newParsedValue) {
|
|
192
198
|
var _this = this; // update property, which may cause AABB re-calc
|
|
193
199
|
// @ts-ignore
|
|
200
|
+
// const stylePropertyUpdaters = this.stylePropertyUpdaterFactory(name);
|
|
194
201
|
|
|
195
202
|
|
|
196
|
-
var stylePropertyUpdaters =
|
|
203
|
+
var stylePropertyUpdaters = stylePropertyUpdaterFactory[name];
|
|
197
204
|
|
|
198
205
|
if (stylePropertyUpdaters) {
|
|
199
206
|
stylePropertyUpdaters.forEach(function (updater) {
|
|
@@ -7,14 +7,20 @@ export interface LineStyleProps extends BaseStyleProps {
|
|
|
7
7
|
y1: number;
|
|
8
8
|
x2: number;
|
|
9
9
|
y2: number;
|
|
10
|
+
z1?: number;
|
|
11
|
+
z2?: number;
|
|
12
|
+
isBillboard?: boolean;
|
|
10
13
|
}
|
|
11
14
|
export interface ParsedLineStyleProps extends ParsedBaseStyleProps {
|
|
12
15
|
x1: number;
|
|
13
16
|
y1: number;
|
|
14
17
|
x2: number;
|
|
15
18
|
y2: number;
|
|
19
|
+
z1?: number;
|
|
20
|
+
z2?: number;
|
|
16
21
|
defX: number;
|
|
17
22
|
defY: number;
|
|
23
|
+
isBillboard?: boolean;
|
|
18
24
|
}
|
|
19
25
|
export declare class Line extends DisplayObject<LineStyleProps, ParsedLineStyleProps> {
|
|
20
26
|
constructor({ style, ...rest }: DisplayObjectConfig<LineStyleProps>);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __assign, __extends, __rest } from "tslib";
|
|
2
2
|
import { Line as LineUtil } from '@antv/g-math';
|
|
3
|
-
import { SHAPE } from '../types';
|
|
3
|
+
import { SHAPE, LINE_CAP, LINE_JOIN } from '../types';
|
|
4
4
|
import { DisplayObject } from './DisplayObject';
|
|
5
5
|
import { Point } from '../shapes';
|
|
6
6
|
|
|
@@ -20,13 +20,12 @@ function (_super) {
|
|
|
20
20
|
y1: 0,
|
|
21
21
|
x2: 0,
|
|
22
22
|
y2: 0,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
,
|
|
26
|
-
lineCap:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
lineWidth: 1
|
|
23
|
+
z1: 0,
|
|
24
|
+
z2: 0,
|
|
25
|
+
lineJoin: LINE_JOIN.Miter,
|
|
26
|
+
lineCap: LINE_CAP.Butt,
|
|
27
|
+
lineWidth: 1,
|
|
28
|
+
isBillboard: false
|
|
30
29
|
}, style)
|
|
31
30
|
}, rest)) || this;
|
|
32
31
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __assign, __extends, __rest } from "tslib";
|
|
2
|
-
import { SHAPE } from '../types';
|
|
2
|
+
import { SHAPE, LINE_CAP, LINE_JOIN } from '../types';
|
|
3
3
|
import { DisplayObject } from './DisplayObject';
|
|
4
4
|
import { Point } from '../shapes';
|
|
5
5
|
import { Cubic as CubicUtil } from '@antv/g-math';
|
|
@@ -18,12 +18,8 @@ function (_super) {
|
|
|
18
18
|
type: SHAPE.Path,
|
|
19
19
|
style: __assign({
|
|
20
20
|
path: '',
|
|
21
|
-
lineJoin:
|
|
22
|
-
|
|
23
|
-
,
|
|
24
|
-
lineCap: "butt"
|
|
25
|
-
/* Butt */
|
|
26
|
-
,
|
|
21
|
+
lineJoin: LINE_JOIN.Miter,
|
|
22
|
+
lineCap: LINE_CAP.Butt,
|
|
27
23
|
lineWidth: 1
|
|
28
24
|
}, style)
|
|
29
25
|
}, rest)) || this;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __assign, __extends, __rest } from "tslib";
|
|
2
2
|
import { Line as LineUtil } from '@antv/g-math';
|
|
3
|
-
import { SHAPE } from '../types';
|
|
3
|
+
import { SHAPE, LINE_CAP, LINE_JOIN } from '../types';
|
|
4
4
|
import { DisplayObject } from './DisplayObject';
|
|
5
5
|
import { Point } from '../shapes';
|
|
6
6
|
|
|
@@ -17,12 +17,8 @@ function (_super) {
|
|
|
17
17
|
type: SHAPE.Polyline,
|
|
18
18
|
style: __assign({
|
|
19
19
|
points: [],
|
|
20
|
-
lineJoin:
|
|
21
|
-
|
|
22
|
-
,
|
|
23
|
-
lineCap: "butt"
|
|
24
|
-
/* Butt */
|
|
25
|
-
,
|
|
20
|
+
lineJoin: LINE_JOIN.Miter,
|
|
21
|
+
lineCap: LINE_CAP.Butt,
|
|
26
22
|
lineWidth: 1
|
|
27
23
|
}, style)
|
|
28
24
|
}, rest)) || this;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __assign, __extends, __rest } from "tslib";
|
|
2
|
-
import { SHAPE } from '../types';
|
|
2
|
+
import { SHAPE, LINE_JOIN, LINE_CAP } from '../types';
|
|
3
3
|
import { DisplayObject } from './DisplayObject';
|
|
4
4
|
|
|
5
5
|
var Text =
|
|
@@ -31,12 +31,8 @@ function (_super) {
|
|
|
31
31
|
fill: '#000',
|
|
32
32
|
letterSpacing: 0,
|
|
33
33
|
lineHeight: 0,
|
|
34
|
-
lineJoin:
|
|
35
|
-
|
|
36
|
-
,
|
|
37
|
-
lineCap: "butt"
|
|
38
|
-
/* Butt */
|
|
39
|
-
,
|
|
34
|
+
lineJoin: LINE_JOIN.Miter,
|
|
35
|
+
lineCap: LINE_CAP.Butt,
|
|
40
36
|
lineWidth: 0,
|
|
41
37
|
miterLimit: 10,
|
|
42
38
|
padding: 0,
|
package/es/dom/Element.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Cullable, Geometry, Renderable, Transform, Sortable } from '../componen
|
|
|
3
3
|
import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
|
|
4
4
|
import { Node } from './Node';
|
|
5
5
|
import type { AABB, Rectangle } from '../shapes';
|
|
6
|
-
import type { IEventTarget,
|
|
6
|
+
import type { IEventTarget, IElement, INode } from './interfaces';
|
|
7
7
|
/**
|
|
8
8
|
* Has following capabilities:
|
|
9
9
|
* * Node insert/remove, eg. appendChild, removeChild, remove...
|
|
@@ -51,9 +51,9 @@ export declare class Element<StyleProps extends BaseStyleProps = any, ParsedStyl
|
|
|
51
51
|
get previousSibling(): IElement | null;
|
|
52
52
|
cloneNode(deep?: boolean): this;
|
|
53
53
|
appendChild<T extends INode>(child: T, index?: number): T;
|
|
54
|
-
insertBefore<T extends
|
|
55
|
-
replaceChild<
|
|
56
|
-
removeChild<T extends
|
|
54
|
+
insertBefore<T extends INode>(newChild: T, refChild: INode | null): T;
|
|
55
|
+
replaceChild<T extends INode>(newChild: INode, oldChild: T, destroy?: boolean): T;
|
|
56
|
+
removeChild<T extends INode>(child: T, destroy?: boolean): T;
|
|
57
57
|
removeChildren(destroy?: boolean): void;
|
|
58
58
|
/**
|
|
59
59
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/matches
|
|
@@ -73,27 +73,27 @@ export declare class Element<StyleProps extends BaseStyleProps = any, ParsedStyl
|
|
|
73
73
|
/**
|
|
74
74
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/after
|
|
75
75
|
*/
|
|
76
|
-
after(...nodes:
|
|
76
|
+
after(...nodes: INode[]): void;
|
|
77
77
|
/**
|
|
78
78
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/before
|
|
79
79
|
*/
|
|
80
|
-
before(...nodes:
|
|
80
|
+
before(...nodes: INode[]): void;
|
|
81
81
|
/**
|
|
82
82
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/replaceWith
|
|
83
83
|
*/
|
|
84
|
-
replaceWith(...nodes:
|
|
84
|
+
replaceWith(...nodes: INode[]): void;
|
|
85
85
|
/**
|
|
86
86
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/append
|
|
87
87
|
*/
|
|
88
|
-
append(...nodes:
|
|
88
|
+
append(...nodes: INode[]): void;
|
|
89
89
|
/**
|
|
90
90
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/prepend
|
|
91
91
|
*/
|
|
92
|
-
prepend(...nodes:
|
|
92
|
+
prepend(...nodes: INode[]): void;
|
|
93
93
|
/**
|
|
94
94
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/replaceChildren
|
|
95
95
|
*/
|
|
96
|
-
replaceChildren(...nodes:
|
|
96
|
+
replaceChildren(...nodes: INode[]): void;
|
|
97
97
|
/**
|
|
98
98
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/remove
|
|
99
99
|
*/
|
package/es/dom/Element.js
CHANGED
|
@@ -298,6 +298,8 @@ function (_super) {
|
|
|
298
298
|
|
|
299
299
|
|
|
300
300
|
Element.prototype.before = function () {
|
|
301
|
+
var _a;
|
|
302
|
+
|
|
301
303
|
var nodes = [];
|
|
302
304
|
|
|
303
305
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
@@ -307,12 +309,13 @@ function (_super) {
|
|
|
307
309
|
if (this.parentNode) {
|
|
308
310
|
var index = this.parentNode.childNodes.indexOf(this);
|
|
309
311
|
|
|
310
|
-
var
|
|
311
|
-
first =
|
|
312
|
-
rest =
|
|
312
|
+
var _b = __read(nodes),
|
|
313
|
+
first = _b[0],
|
|
314
|
+
rest = _b.slice(1);
|
|
313
315
|
|
|
314
316
|
this.parentNode.appendChild(first, index);
|
|
315
|
-
|
|
317
|
+
|
|
318
|
+
(_a = first).after.apply(_a, __spreadArray([], __read(rest), false));
|
|
316
319
|
}
|
|
317
320
|
};
|
|
318
321
|
/**
|
package/es/dom/Node.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare abstract class Node extends EventTarget implements INode {
|
|
|
28
28
|
* Returns the children.
|
|
29
29
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Node/childNodes
|
|
30
30
|
*/
|
|
31
|
-
childNodes:
|
|
31
|
+
childNodes: IChildNode[];
|
|
32
32
|
/**
|
|
33
33
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Node/nodeType
|
|
34
34
|
*/
|
|
@@ -81,26 +81,26 @@ export declare abstract class Node extends EventTarget implements INode {
|
|
|
81
81
|
/**
|
|
82
82
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Node/appendChild
|
|
83
83
|
*/
|
|
84
|
-
abstract appendChild<T extends
|
|
84
|
+
abstract appendChild<T extends INode>(newChild: T, index?: number): T;
|
|
85
85
|
/**
|
|
86
86
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Node/insertBefore
|
|
87
87
|
*/
|
|
88
|
-
abstract insertBefore<T extends
|
|
88
|
+
abstract insertBefore<T extends INode>(newChild: T, refChild: INode | null): T;
|
|
89
89
|
/**
|
|
90
90
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Node/removeChild
|
|
91
91
|
*/
|
|
92
|
-
abstract removeChild<T extends
|
|
92
|
+
abstract removeChild<T extends INode>(child: T, destroy?: boolean): T;
|
|
93
93
|
/**
|
|
94
94
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Node/replaceChild
|
|
95
95
|
*/
|
|
96
|
-
abstract replaceChild<
|
|
96
|
+
abstract replaceChild<T extends INode>(newChild: INode, oldChild: T, destroy?: boolean): T;
|
|
97
97
|
abstract destroy(): void;
|
|
98
98
|
/**
|
|
99
99
|
* @deprecated
|
|
100
100
|
* @alias contains
|
|
101
101
|
*/
|
|
102
|
-
contain<T extends
|
|
103
|
-
contains<T extends
|
|
102
|
+
contain<T extends INode>(other: T | null): boolean;
|
|
103
|
+
contains<T extends INode>(other: T | null): boolean;
|
|
104
104
|
getAncestor(n: number): INode | null;
|
|
105
105
|
forEach(callback: (o: INode) => void | boolean): void;
|
|
106
106
|
}
|
package/es/dom/interfaces.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type EventEmitter from 'eventemitter3';
|
|
2
2
|
import type { AnimationTimeline } from './AnimationTimeline';
|
|
3
|
-
import type { BaseStyleProps,
|
|
3
|
+
import type { BaseStyleProps, SHAPE } from '../types';
|
|
4
4
|
import type { FederatedEvent } from './FederatedEvent';
|
|
5
5
|
import type { CustomElementRegistry } from './CustomElementRegistry';
|
|
6
6
|
import type { DisplayObject } from '..';
|
|
@@ -31,7 +31,11 @@ export declare enum ElementEvent {
|
|
|
31
31
|
CHILD_REMOVED = "child-removed",
|
|
32
32
|
MOUNTED = "mounted",
|
|
33
33
|
UNMOUNTED = "unmounted",
|
|
34
|
-
BOUNDS_CHANGED = "bounds-changed"
|
|
34
|
+
BOUNDS_CHANGED = "bounds-changed",
|
|
35
|
+
/**
|
|
36
|
+
* trigger when z-index changed
|
|
37
|
+
*/
|
|
38
|
+
RENDER_ORDER_CHANGED = "render-order-changed"
|
|
35
39
|
}
|
|
36
40
|
export interface IEventTarget {
|
|
37
41
|
emitter: EventEmitter;
|
|
@@ -52,11 +56,11 @@ export interface INode extends IEventTarget {
|
|
|
52
56
|
/**
|
|
53
57
|
* Returns the children.
|
|
54
58
|
*/
|
|
55
|
-
readonly childNodes:
|
|
59
|
+
readonly childNodes: IChildNode[];
|
|
56
60
|
/**
|
|
57
61
|
* Returns the first child.
|
|
58
62
|
*/
|
|
59
|
-
readonly firstChild:
|
|
63
|
+
readonly firstChild: IChildNode | null;
|
|
60
64
|
/**
|
|
61
65
|
* Returns true if node is connected and false otherwise.
|
|
62
66
|
*/
|
|
@@ -64,11 +68,11 @@ export interface INode extends IEventTarget {
|
|
|
64
68
|
/**
|
|
65
69
|
* Returns the last child.
|
|
66
70
|
*/
|
|
67
|
-
readonly lastChild:
|
|
71
|
+
readonly lastChild: IChildNode | null;
|
|
68
72
|
/**
|
|
69
73
|
* Returns the next sibling.
|
|
70
74
|
*/
|
|
71
|
-
readonly nextSibling:
|
|
75
|
+
readonly nextSibling: IChildNode | null;
|
|
72
76
|
/**
|
|
73
77
|
* Returns a string appropriate for the type of node.
|
|
74
78
|
*/
|
|
@@ -93,13 +97,13 @@ export interface INode extends IEventTarget {
|
|
|
93
97
|
/**
|
|
94
98
|
* Returns the previous sibling.
|
|
95
99
|
*/
|
|
96
|
-
readonly previousSibling:
|
|
100
|
+
readonly previousSibling: IChildNode | null;
|
|
97
101
|
textContent: string | null;
|
|
98
|
-
appendChild: <T extends
|
|
102
|
+
appendChild: <T extends INode>(newChild: T, index?: number) => T;
|
|
99
103
|
/**
|
|
100
104
|
* Returns a copy of node. If deep is true, the copy also includes the node's descendants.
|
|
101
105
|
*/
|
|
102
|
-
cloneNode: (deep?: boolean) =>
|
|
106
|
+
cloneNode: (deep?: boolean) => INode;
|
|
103
107
|
/**
|
|
104
108
|
* Returns a bitmask indicating the position of other relative to node.
|
|
105
109
|
*/
|
|
@@ -107,7 +111,7 @@ export interface INode extends IEventTarget {
|
|
|
107
111
|
/**
|
|
108
112
|
* Returns true if other is an inclusive descendant of node, and false otherwise.
|
|
109
113
|
*/
|
|
110
|
-
contains:
|
|
114
|
+
contains: (other: INode | null) => boolean;
|
|
111
115
|
/**
|
|
112
116
|
* Returns node's root.
|
|
113
117
|
*/
|
|
@@ -124,7 +128,7 @@ export interface INode extends IEventTarget {
|
|
|
124
128
|
* Returns whether node has children.
|
|
125
129
|
*/
|
|
126
130
|
hasChildNodes: () => boolean;
|
|
127
|
-
insertBefore: <T extends
|
|
131
|
+
insertBefore: <T extends INode>(newChild: T, refChild: INode | null) => T;
|
|
128
132
|
isDefaultNamespace: (namespace: string | null) => boolean;
|
|
129
133
|
/**
|
|
130
134
|
* Returns whether node and otherNode have the same properties.
|
|
@@ -137,8 +141,8 @@ export interface INode extends IEventTarget {
|
|
|
137
141
|
* Removes empty exclusive Text nodes and concatenates the data of remaining contiguous exclusive Text nodes into the first of their nodes.
|
|
138
142
|
*/
|
|
139
143
|
normalize: () => void;
|
|
140
|
-
removeChild: <T extends
|
|
141
|
-
replaceChild: <T extends
|
|
144
|
+
removeChild: <T extends INode>(oldChild: T, destroy?: boolean) => T;
|
|
145
|
+
replaceChild: <T extends INode>(newChild: INode, oldChild: T, destroy?: boolean) => T;
|
|
142
146
|
/**
|
|
143
147
|
* Destroy itself.
|
|
144
148
|
*/
|
|
@@ -193,13 +197,13 @@ export interface IChildNode extends INode {
|
|
|
193
197
|
*
|
|
194
198
|
* Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated.
|
|
195
199
|
*/
|
|
196
|
-
after: (...nodes:
|
|
200
|
+
after: (...nodes: INode[]) => void;
|
|
197
201
|
/**
|
|
198
202
|
* Inserts nodes just before node, while replacing strings in nodes with equivalent Text nodes.
|
|
199
203
|
*
|
|
200
204
|
* Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated.
|
|
201
205
|
*/
|
|
202
|
-
before: (...nodes:
|
|
206
|
+
before: (...nodes: INode[]) => void;
|
|
203
207
|
/**
|
|
204
208
|
* Removes node.
|
|
205
209
|
*/
|
|
@@ -209,7 +213,7 @@ export interface IChildNode extends INode {
|
|
|
209
213
|
*
|
|
210
214
|
* Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated.
|
|
211
215
|
*/
|
|
212
|
-
replaceWith: (...nodes:
|
|
216
|
+
replaceWith: (...nodes: INode[]) => void;
|
|
213
217
|
}
|
|
214
218
|
export interface DisplayObjectConfig<StyleProps> {
|
|
215
219
|
/**
|
|
@@ -250,7 +254,7 @@ export interface DisplayObjectConfig<StyleProps> {
|
|
|
250
254
|
*/
|
|
251
255
|
interactive?: boolean;
|
|
252
256
|
}
|
|
253
|
-
export interface IElement<StyleProps
|
|
257
|
+
export interface IElement<StyleProps = any, ParsedStyleProps = any> extends INode, IChildNode, IParentNode {
|
|
254
258
|
/**
|
|
255
259
|
* Returns the value of element's id content attribute. Can be set to change it.
|
|
256
260
|
*/
|