@antv/g 5.0.1 → 5.0.5
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/LICENSE +21 -0
- package/dist/index.umd.js +2 -2
- package/es/AbstractRenderer.d.ts +7 -7
- package/es/Canvas.d.ts +15 -5
- package/es/Canvas.js +10 -5
- package/es/camera/Camera.js +3 -5
- package/es/components/Geometry.d.ts +1 -1
- package/es/components/Renderable.d.ts +1 -1
- package/es/display-objects/CustomElement.d.ts +7 -8
- package/es/display-objects/CustomElement.js +24 -11
- package/es/display-objects/DisplayObject.d.ts +5 -7
- package/es/display-objects/DisplayObject.js +20 -12
- package/es/display-objects/Group.d.ts +1 -1
- package/es/display-objects/HTML.d.ts +1 -1
- package/es/display-objects/Image.d.ts +1 -1
- package/es/display-objects/Path.d.ts +1 -1
- package/es/display-objects/Polygon.d.ts +1 -1
- package/es/display-objects/Polyline.d.ts +1 -1
- package/es/display-objects/Text.d.ts +1 -1
- package/es/display-objects/Text.js +1 -1
- package/es/dom/Animation.js +9 -4
- package/es/dom/AnimationEffectTiming.d.ts +0 -1
- package/es/dom/AnimationTimeline.js +2 -1
- package/es/dom/CustomElementRegistry.d.ts +1 -1
- package/es/dom/CustomEvent.js +2 -1
- package/es/dom/Document.d.ts +3 -3
- package/es/dom/Document.js +13 -6
- package/es/dom/Element.d.ts +11 -12
- package/es/dom/Element.js +12 -8
- package/es/dom/EventTarget.js +1 -0
- package/es/dom/FederatedEvent.d.ts +1 -1
- package/es/dom/KeyframeEffect.js +1 -1
- package/es/dom/Node.d.ts +10 -10
- package/es/dom/Node.js +11 -5
- package/es/dom/interfaces.d.ts +63 -63
- package/es/global-module.d.ts +4 -0
- package/es/global-module.js +57 -69
- package/es/plugins/CullingPlugin.d.ts +3 -3
- package/es/plugins/DirtyCheckPlugin.d.ts +1 -1
- package/es/plugins/EventPlugin.d.ts +2 -1
- package/es/plugins/FrustumCullingStrategy.d.ts +1 -2
- package/es/plugins/FrustumCullingStrategy.js +31 -32
- package/es/plugins/PrepareRendererPlugin.d.ts +1 -1
- package/es/plugins/PrepareRendererPlugin.js +7 -20
- package/es/property-handlers/aabb.js +16 -19
- package/es/property-handlers/anchor.d.ts +2 -1
- package/es/property-handlers/anchor.js +2 -2
- package/es/property-handlers/clipPath.js +2 -2
- package/es/property-handlers/color.d.ts +3 -4
- package/es/property-handlers/color.js +2 -2
- package/es/property-handlers/filter.d.ts +3 -4
- package/es/property-handlers/filter.js +2 -2
- package/es/property-handlers/interfaces.d.ts +1 -1
- package/es/property-handlers/lineDash.d.ts +1 -2
- package/es/property-handlers/lineDash.js +1 -1
- package/es/property-handlers/path.d.ts +2 -3
- package/es/property-handlers/path.js +2 -2
- package/es/property-handlers/points.d.ts +1 -2
- package/es/property-handlers/points.js +1 -1
- package/es/property-handlers/transform.d.ts +1 -1
- package/es/property-handlers/transform.js +0 -5
- package/es/services/ContextService.d.ts +8 -8
- package/es/services/EventService.d.ts +2 -2
- package/es/services/RenderingContext.d.ts +2 -2
- package/es/services/RenderingService.d.ts +23 -18
- package/es/services/RenderingService.js +18 -4
- package/es/services/SceneGraphSelector.d.ts +5 -5
- package/es/services/SceneGraphSelector.js +3 -2
- package/es/services/SceneGraphService.d.ts +36 -34
- package/es/services/SceneGraphService.js +33 -4
- package/es/services/aabb/PathUpdater.d.ts +1 -2
- package/es/services/aabb/PathUpdater.js +1 -1
- package/es/services/aabb/interfaces.d.ts +1 -1
- package/es/services/text/index.js +1 -1
- package/es/shapes/AABB.d.ts +3 -2
- package/es/shapes/Frustum.d.ts +1 -1
- package/es/shapes/Polygon.d.ts +1 -1
- package/es/shapes/Ray.d.ts +3 -3
- package/es/types.d.ts +1 -2
- package/es/utils/custom-easing.d.ts +3 -5
- package/es/utils/custom-easing.js +2 -1
- package/es/utils/event.d.ts +1 -1
- package/es/utils/interpolation.js +16 -16
- package/es/utils/math.d.ts +2 -1
- package/es/utils/math.js +1 -2
- package/es/utils/path.d.ts +1 -1
- package/es/utils/path.js +4 -7
- package/es/utils/raf.js +2 -1
- package/lib/AbstractRenderer.d.ts +7 -7
- package/lib/Canvas.d.ts +15 -5
- package/lib/Canvas.js +10 -5
- package/lib/camera/Camera.js +4 -5
- package/lib/components/Geometry.d.ts +1 -1
- package/lib/components/Renderable.d.ts +1 -1
- package/lib/display-objects/CustomElement.d.ts +7 -8
- package/lib/display-objects/CustomElement.js +24 -11
- package/lib/display-objects/DisplayObject.d.ts +5 -7
- package/lib/display-objects/DisplayObject.js +19 -11
- package/lib/display-objects/Group.d.ts +1 -1
- package/lib/display-objects/HTML.d.ts +1 -1
- package/lib/display-objects/Image.d.ts +1 -1
- package/lib/display-objects/Path.d.ts +1 -1
- package/lib/display-objects/Polygon.d.ts +1 -1
- package/lib/display-objects/Polyline.d.ts +1 -1
- package/lib/display-objects/Text.d.ts +1 -1
- package/lib/display-objects/Text.js +1 -1
- package/lib/dom/Animation.js +9 -4
- package/lib/dom/AnimationEffectTiming.d.ts +0 -1
- package/lib/dom/AnimationTimeline.js +2 -1
- package/lib/dom/CustomElementRegistry.d.ts +1 -1
- package/lib/dom/CustomEvent.js +1 -1
- package/lib/dom/Document.d.ts +3 -3
- package/lib/dom/Document.js +13 -6
- package/lib/dom/Element.d.ts +11 -12
- package/lib/dom/Element.js +12 -8
- package/lib/dom/EventTarget.js +1 -0
- package/lib/dom/FederatedEvent.d.ts +1 -1
- package/lib/dom/KeyframeEffect.js +1 -1
- package/lib/dom/Node.d.ts +10 -10
- package/lib/dom/Node.js +11 -5
- package/lib/dom/interfaces.d.ts +63 -63
- package/lib/global-module.d.ts +4 -0
- package/lib/global-module.js +57 -69
- package/lib/plugins/CullingPlugin.d.ts +3 -3
- package/lib/plugins/DirtyCheckPlugin.d.ts +1 -1
- package/lib/plugins/EventPlugin.d.ts +2 -1
- package/lib/plugins/FrustumCullingStrategy.d.ts +1 -2
- package/lib/plugins/FrustumCullingStrategy.js +28 -30
- package/lib/plugins/PrepareRendererPlugin.d.ts +1 -1
- package/lib/plugins/PrepareRendererPlugin.js +6 -19
- package/lib/property-handlers/aabb.js +15 -19
- package/lib/property-handlers/anchor.d.ts +2 -1
- package/lib/property-handlers/anchor.js +2 -2
- package/lib/property-handlers/clipPath.js +2 -2
- package/lib/property-handlers/color.d.ts +3 -4
- package/lib/property-handlers/color.js +2 -2
- package/lib/property-handlers/filter.d.ts +3 -4
- package/lib/property-handlers/filter.js +2 -2
- package/lib/property-handlers/interfaces.d.ts +1 -1
- package/lib/property-handlers/lineDash.d.ts +1 -2
- package/lib/property-handlers/lineDash.js +1 -1
- package/lib/property-handlers/path.d.ts +2 -3
- package/lib/property-handlers/path.js +2 -2
- package/lib/property-handlers/points.d.ts +1 -2
- package/lib/property-handlers/points.js +1 -1
- package/lib/property-handlers/transform.d.ts +1 -1
- package/lib/property-handlers/transform.js +0 -4
- package/lib/services/ContextService.d.ts +8 -8
- package/lib/services/EventService.d.ts +2 -2
- package/lib/services/RenderingContext.d.ts +2 -2
- package/lib/services/RenderingService.d.ts +23 -18
- package/lib/services/RenderingService.js +18 -4
- package/lib/services/SceneGraphSelector.d.ts +5 -5
- package/lib/services/SceneGraphSelector.js +3 -2
- package/lib/services/SceneGraphService.d.ts +36 -34
- package/lib/services/SceneGraphService.js +35 -4
- package/lib/services/aabb/PathUpdater.d.ts +1 -2
- package/lib/services/aabb/PathUpdater.js +1 -1
- package/lib/services/aabb/interfaces.d.ts +1 -1
- package/lib/services/text/index.js +1 -1
- package/lib/shapes/AABB.d.ts +3 -2
- package/lib/shapes/Frustum.d.ts +1 -1
- package/lib/shapes/Polygon.d.ts +1 -1
- package/lib/shapes/Ray.d.ts +3 -3
- package/lib/types.d.ts +1 -2
- package/lib/utils/custom-easing.d.ts +3 -5
- package/lib/utils/custom-easing.js +2 -1
- package/lib/utils/event.d.ts +1 -1
- package/lib/utils/interpolation.js +13 -18
- package/lib/utils/math.d.ts +2 -1
- package/lib/utils/math.js +1 -2
- package/lib/utils/path.d.ts +2 -2
- package/lib/utils/path.js +4 -7
- package/lib/utils/raf.js +2 -1
- package/package.json +6 -6
- package/lib/dom/__tests__/utils/easing.d.ts +0 -14
- package/lib/dom/__tests__/utils/keyframe.d.ts +0 -38
package/es/AbstractRenderer.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { Syringe } from 'mana-syringe';
|
|
2
|
-
import { RendererConfig } from './types';
|
|
1
|
+
import type { Syringe } from 'mana-syringe';
|
|
2
|
+
import type { RendererConfig } from './types';
|
|
3
3
|
export interface RendererPlugin {
|
|
4
|
-
init(container: Syringe.Container)
|
|
5
|
-
destroy(container: Syringe.Container)
|
|
4
|
+
init: (container: Syringe.Container) => void;
|
|
5
|
+
destroy: (container: Syringe.Container) => void;
|
|
6
6
|
}
|
|
7
7
|
export interface IRenderer {
|
|
8
|
-
getConfig()
|
|
8
|
+
getConfig: () => RendererConfig;
|
|
9
9
|
/**
|
|
10
10
|
* register plugin at runtime
|
|
11
11
|
*/
|
|
12
|
-
registerPlugin(plugin: RendererPlugin)
|
|
12
|
+
registerPlugin: (plugin: RendererPlugin) => void;
|
|
13
13
|
/**
|
|
14
14
|
* return all registered plugins
|
|
15
15
|
*/
|
|
16
|
-
getPlugins()
|
|
16
|
+
getPlugins: () => RendererPlugin[];
|
|
17
17
|
}
|
|
18
18
|
export declare class AbstractRenderer implements IRenderer {
|
|
19
19
|
private plugins;
|
package/es/Canvas.d.ts
CHANGED
|
@@ -5,10 +5,11 @@ import { RenderingService } from './services/RenderingService';
|
|
|
5
5
|
import { RenderingContext } from './services/RenderingContext';
|
|
6
6
|
import { EventService } from './services/EventService';
|
|
7
7
|
import { Camera } from './camera';
|
|
8
|
-
import { AbstractRenderer } from './AbstractRenderer';
|
|
8
|
+
import type { AbstractRenderer } from './AbstractRenderer';
|
|
9
9
|
import type { PointLike } from './shapes';
|
|
10
|
+
import type { IChildNode } from './dom';
|
|
10
11
|
import { Document, EventTarget } from './dom';
|
|
11
|
-
import type {
|
|
12
|
+
import type { ICanvas } from './dom/interfaces';
|
|
12
13
|
import { CustomElementRegistry } from './dom/CustomElementRegistry';
|
|
13
14
|
export declare enum CanvasEvent {
|
|
14
15
|
READY = "ready",
|
|
@@ -41,6 +42,11 @@ export declare class Canvas extends EventTarget implements ICanvas {
|
|
|
41
42
|
* rAF in auto rendering
|
|
42
43
|
*/
|
|
43
44
|
private frameId?;
|
|
45
|
+
/**
|
|
46
|
+
* cache here since inversify's resolving is very slow
|
|
47
|
+
*/
|
|
48
|
+
private eventService;
|
|
49
|
+
private renderingService;
|
|
44
50
|
constructor(config: CanvasConfig);
|
|
45
51
|
private initRenderingContext;
|
|
46
52
|
private initDefaultCamera;
|
|
@@ -59,6 +65,10 @@ export declare class Canvas extends EventTarget implements ICanvas {
|
|
|
59
65
|
getEventService(): EventService;
|
|
60
66
|
getRenderingService(): RenderingService;
|
|
61
67
|
getRenderingContext(): RenderingContext;
|
|
68
|
+
getStats(): {
|
|
69
|
+
total: number;
|
|
70
|
+
rendered: number;
|
|
71
|
+
};
|
|
62
72
|
getComputedStyle(node: DisplayObject): any;
|
|
63
73
|
destroy(destroyScenegraph?: boolean): void;
|
|
64
74
|
/**
|
|
@@ -68,9 +78,9 @@ export declare class Canvas extends EventTarget implements ICanvas {
|
|
|
68
78
|
*/
|
|
69
79
|
changeSize(width: number, height: number): void;
|
|
70
80
|
resize(width: number, height: number): void;
|
|
71
|
-
appendChild<T extends
|
|
72
|
-
insertBefore<T extends
|
|
73
|
-
removeChild<T extends
|
|
81
|
+
appendChild<T extends IChildNode>(child: T, index?: number): T;
|
|
82
|
+
insertBefore<T extends IChildNode, N extends IChildNode>(newChild: T, refChild: N | null): T;
|
|
83
|
+
removeChild<T extends IChildNode>(child: T, destroy?: boolean): T;
|
|
74
84
|
removeChildren(destroy?: boolean): void;
|
|
75
85
|
render(): void;
|
|
76
86
|
private run;
|
package/es/Canvas.js
CHANGED
|
@@ -142,17 +142,21 @@ function (_super) {
|
|
|
142
142
|
};
|
|
143
143
|
|
|
144
144
|
Canvas.prototype.getEventService = function () {
|
|
145
|
-
return this.
|
|
145
|
+
return this.eventService;
|
|
146
146
|
};
|
|
147
147
|
|
|
148
148
|
Canvas.prototype.getRenderingService = function () {
|
|
149
|
-
return this.
|
|
149
|
+
return this.renderingService;
|
|
150
150
|
};
|
|
151
151
|
|
|
152
152
|
Canvas.prototype.getRenderingContext = function () {
|
|
153
153
|
return this.container.get(RenderingContext);
|
|
154
154
|
};
|
|
155
155
|
|
|
156
|
+
Canvas.prototype.getStats = function () {
|
|
157
|
+
return this.getRenderingService().getStats();
|
|
158
|
+
};
|
|
159
|
+
|
|
156
160
|
Canvas.prototype.getComputedStyle = function (node) {
|
|
157
161
|
return node.parsedStyle;
|
|
158
162
|
};
|
|
@@ -275,9 +279,10 @@ function (_super) {
|
|
|
275
279
|
this.loadRendererContainerModule(renderer); // init context
|
|
276
280
|
|
|
277
281
|
var contextService = this.container.get(ContextService);
|
|
278
|
-
|
|
282
|
+
this.renderingService = this.container.get(RenderingService);
|
|
283
|
+
this.eventService = this.container.get(EventService);
|
|
279
284
|
contextService.init();
|
|
280
|
-
renderingService.init().then(function () {
|
|
285
|
+
this.renderingService.init().then(function () {
|
|
281
286
|
_this.emit(CanvasEvent.READY, {});
|
|
282
287
|
});
|
|
283
288
|
|
|
@@ -291,7 +296,7 @@ function (_super) {
|
|
|
291
296
|
if (renderable) {
|
|
292
297
|
renderable.renderBoundsDirty = true;
|
|
293
298
|
renderable.boundsDirty = true;
|
|
294
|
-
renderable.dirty = true;
|
|
299
|
+
renderable.dirty = true;
|
|
295
300
|
}
|
|
296
301
|
}); // keep current scenegraph unchanged, just trigger mounted event
|
|
297
302
|
|
package/es/camera/Camera.js
CHANGED
|
@@ -842,15 +842,13 @@ function (_super) {
|
|
|
842
842
|
|
|
843
843
|
|
|
844
844
|
Camera.prototype.computeMatrix = function () {
|
|
845
|
-
|
|
846
|
-
var rotY; // 使用四元数描述 3D 旋转
|
|
845
|
+
// 使用四元数描述 3D 旋转
|
|
847
846
|
// @see https://xiaoiver.github.io/coding/2018/12/28/Camera-%E8%AE%BE%E8%AE%A1-%E4%B8%80.html
|
|
848
|
-
|
|
849
847
|
var rotZ = quat.setAxisAngle(quat.create(), [0, 0, 1], this.roll * DEG_2_RAD);
|
|
850
848
|
mat4.identity(this.matrix); // only consider HCS for EXPLORING and ORBITING cameras
|
|
851
849
|
|
|
852
|
-
rotX = quat.setAxisAngle(quat.create(), [1, 0, 0], (this.rotateWorld && this.type !== CAMERA_TYPE.TRACKING || this.type === CAMERA_TYPE.TRACKING ? 1 : -1) * this.elevation * DEG_2_RAD);
|
|
853
|
-
rotY = quat.setAxisAngle(quat.create(), [0, 1, 0], (this.rotateWorld && this.type !== CAMERA_TYPE.TRACKING || this.type === CAMERA_TYPE.TRACKING ? 1 : -1) * this.azimuth * DEG_2_RAD);
|
|
850
|
+
var rotX = quat.setAxisAngle(quat.create(), [1, 0, 0], (this.rotateWorld && this.type !== CAMERA_TYPE.TRACKING || this.type === CAMERA_TYPE.TRACKING ? 1 : -1) * this.elevation * DEG_2_RAD);
|
|
851
|
+
var rotY = quat.setAxisAngle(quat.create(), [0, 1, 0], (this.rotateWorld && this.type !== CAMERA_TYPE.TRACKING || this.type === CAMERA_TYPE.TRACKING ? 1 : -1) * this.azimuth * DEG_2_RAD);
|
|
854
852
|
var rotQ = quat.multiply(quat.create(), rotY, rotX);
|
|
855
853
|
rotQ = quat.multiply(quat.create(), rotQ, rotZ);
|
|
856
854
|
var rotMatrix = mat4.fromQuat(mat4.create(), rotQ);
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { DisplayObject } from './DisplayObject';
|
|
2
2
|
import type { DisplayObjectConfig } from '../dom/interfaces';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* shadow root
|
|
5
|
+
* @see https://yuque.antfin-inc.com/antv/czqvg5/pgqipg
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class CustomElement<CustomElementStyleProps> extends DisplayObject<CustomElementStyleProps> {
|
|
8
|
+
constructor(config: DisplayObjectConfig<CustomElementStyleProps>);
|
|
4
9
|
/**
|
|
5
10
|
* fired after element insert into DOM tree
|
|
6
11
|
*/
|
|
@@ -10,13 +15,7 @@ export interface CustomElement<CustomElementStyleProps> {
|
|
|
10
15
|
*/
|
|
11
16
|
disconnectedCallback?(): void;
|
|
12
17
|
attributeChangedCallback?<Key extends keyof CustomElementStyleProps>(name: Key, oldValue: CustomElementStyleProps[Key], newValue: CustomElementStyleProps[Key]): void;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* shadow root
|
|
16
|
-
* @see https://yuque.antfin-inc.com/antv/czqvg5/pgqipg
|
|
17
|
-
*/
|
|
18
|
-
export declare abstract class CustomElement<CustomElementStyleProps> extends DisplayObject<CustomElementStyleProps> {
|
|
19
|
-
constructor(config: DisplayObjectConfig<CustomElementStyleProps>);
|
|
20
18
|
private handleMounted;
|
|
19
|
+
private handleUnmounted;
|
|
21
20
|
private handleAttributeChanged;
|
|
22
21
|
}
|
|
@@ -15,14 +15,24 @@ function (_super) {
|
|
|
15
15
|
function CustomElement(config) {
|
|
16
16
|
var _this = _super.call(this, config) || this;
|
|
17
17
|
|
|
18
|
-
_this.handleMounted = function () {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
_this.connectedCallback
|
|
18
|
+
_this.handleMounted = function (e) {
|
|
19
|
+
if (e.target === e.currentTarget) {
|
|
20
|
+
// this.shadowNodes.forEach((node) => {
|
|
21
|
+
// // every child and its children should turn into a shadow node
|
|
22
|
+
// // a shadow node doesn't mean to be unrenderable, it's just unsearchable in scenegraph
|
|
23
|
+
// node.shadow = true;
|
|
24
|
+
// });
|
|
25
|
+
if (_this.connectedCallback) {
|
|
26
|
+
_this.connectedCallback();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
_this.handleUnmounted = function (e) {
|
|
32
|
+
if (e.target === e.currentTarget) {
|
|
33
|
+
if (_this.disconnectedCallback) {
|
|
34
|
+
_this.disconnectedCallback();
|
|
35
|
+
}
|
|
26
36
|
}
|
|
27
37
|
}; // private handleChildInserted = (e: FederatedEvent) => {
|
|
28
38
|
// (e.target as DisplayObject).forEach((node) => {
|
|
@@ -50,7 +60,10 @@ function (_super) {
|
|
|
50
60
|
attributeName = _a.attributeName,
|
|
51
61
|
oldValue = _a.oldValue,
|
|
52
62
|
newValue = _a.newValue;
|
|
53
|
-
|
|
63
|
+
|
|
64
|
+
if (_this.attributeChangedCallback) {
|
|
65
|
+
_this.attributeChangedCallback(attributeName, oldValue, newValue);
|
|
66
|
+
}
|
|
54
67
|
}; // this.addEventListener(ElementEvent.CHILD_INSERTED, this.handleChildInserted);
|
|
55
68
|
// this.addEventListener(ElementEvent.CHILD_REMOVED, this.handleChildRemoved);
|
|
56
69
|
|
|
@@ -60,11 +73,11 @@ function (_super) {
|
|
|
60
73
|
}
|
|
61
74
|
|
|
62
75
|
if (_this.connectedCallback) {
|
|
63
|
-
_this.addEventListener(ElementEvent.
|
|
76
|
+
_this.addEventListener(ElementEvent.MOUNTED, _this.handleMounted);
|
|
64
77
|
}
|
|
65
78
|
|
|
66
79
|
if (_this.disconnectedCallback) {
|
|
67
|
-
_this.addEventListener(ElementEvent.
|
|
80
|
+
_this.addEventListener(ElementEvent.UNMOUNTED, _this.handleUnmounted);
|
|
68
81
|
}
|
|
69
82
|
|
|
70
83
|
return _this;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { mat3,
|
|
2
|
-
import {
|
|
1
|
+
import type { mat3, vec2 } from 'gl-matrix';
|
|
2
|
+
import { mat4, quat, vec3 } from 'gl-matrix';
|
|
3
|
+
import type { Animation } from '../dom/Animation';
|
|
3
4
|
import { Element } from '../dom/Element';
|
|
4
|
-
import type { DisplayObjectConfig,
|
|
5
|
+
import type { DisplayObjectConfig, IChildNode } from '../dom/interfaces';
|
|
5
6
|
import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
|
|
6
|
-
import { StylePropertyParser, StylePropertyUpdater } from '../property-handlers';
|
|
7
7
|
/**
|
|
8
8
|
* prototype chains: DisplayObject -> Element -> Node -> EventTarget
|
|
9
9
|
*
|
|
@@ -31,8 +31,6 @@ export declare class DisplayObject<StyleProps extends BaseStyleProps = any, Pars
|
|
|
31
31
|
* push to active animations after calling `animate()`
|
|
32
32
|
*/
|
|
33
33
|
private activeAnimations;
|
|
34
|
-
stylePropertyUpdaterFactory: <Key extends keyof StyleProps>(stylePropertyName: Key) => StylePropertyUpdater<any>[];
|
|
35
|
-
stylePropertyParserFactory: <Key extends keyof ParsedStyleProps>(stylePropertyName: Key) => StylePropertyParser<any, any>;
|
|
36
34
|
constructor(config: DisplayObjectConfig<StyleProps>);
|
|
37
35
|
destroy(): void;
|
|
38
36
|
cloneNode(deep?: boolean): this;
|
|
@@ -192,7 +190,7 @@ export declare class DisplayObject<StyleProps extends BaseStyleProps = any, Pars
|
|
|
192
190
|
* compatible with G 3.0
|
|
193
191
|
* @deprecated
|
|
194
192
|
*/
|
|
195
|
-
add<T extends
|
|
193
|
+
add<T extends IChildNode>(child: T, index?: number): T;
|
|
196
194
|
/**
|
|
197
195
|
* @alias style.clipPath
|
|
198
196
|
* @deprecated
|
|
@@ -6,9 +6,11 @@ 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';
|
|
13
|
+
import { dirtifyToRoot } from '../services';
|
|
12
14
|
var DEFAULT_STYLE_PROPS = {
|
|
13
15
|
anchor: [0, 0, 0],
|
|
14
16
|
origin: [0, 0, 0],
|
|
@@ -38,20 +40,24 @@ var DEFAULT_STYLE_PROPS = {
|
|
|
38
40
|
var DisplayObject =
|
|
39
41
|
/** @class */
|
|
40
42
|
function (_super) {
|
|
41
|
-
__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
|
+
|
|
42
50
|
|
|
43
51
|
function DisplayObject(config) {
|
|
44
52
|
var _a, _b, _c;
|
|
45
53
|
|
|
46
|
-
var _this = _super.call(this
|
|
54
|
+
var _this = _super.call(this) || this;
|
|
47
55
|
/**
|
|
48
56
|
* push to active animations after calling `animate()`
|
|
49
57
|
*/
|
|
50
58
|
|
|
51
59
|
|
|
52
|
-
_this.activeAnimations = [];
|
|
53
|
-
_this.stylePropertyUpdaterFactory = globalContainer.get(StylePropertyUpdaterFactory);
|
|
54
|
-
_this.stylePropertyParserFactory = globalContainer.get(StylePropertyParserFactory); // assign name, id to config
|
|
60
|
+
_this.activeAnimations = []; // assign name, id to config
|
|
55
61
|
// eg. group.get('name')
|
|
56
62
|
|
|
57
63
|
_this.config = config; // compatible with G 3.0
|
|
@@ -177,7 +183,8 @@ function (_super) {
|
|
|
177
183
|
|
|
178
184
|
|
|
179
185
|
DisplayObject.prototype.parseStyleProperty = function (name, value) {
|
|
180
|
-
|
|
186
|
+
// const stylePropertyParser = this.stylePropertyParserFactory(name);
|
|
187
|
+
var stylePropertyParser = stylePropertyParserFactory[name];
|
|
181
188
|
|
|
182
189
|
if (stylePropertyParser) {
|
|
183
190
|
// @ts-ignore
|
|
@@ -190,9 +197,10 @@ function (_super) {
|
|
|
190
197
|
DisplayObject.prototype.updateStyleProperty = function (name, oldParsedValue, newParsedValue) {
|
|
191
198
|
var _this = this; // update property, which may cause AABB re-calc
|
|
192
199
|
// @ts-ignore
|
|
200
|
+
// const stylePropertyUpdaters = this.stylePropertyUpdaterFactory(name);
|
|
193
201
|
|
|
194
202
|
|
|
195
|
-
var stylePropertyUpdaters =
|
|
203
|
+
var stylePropertyUpdaters = stylePropertyUpdaterFactory[name];
|
|
196
204
|
|
|
197
205
|
if (stylePropertyUpdaters) {
|
|
198
206
|
stylePropertyUpdaters.forEach(function (updater) {
|
|
@@ -222,7 +230,7 @@ function (_super) {
|
|
|
222
230
|
|
|
223
231
|
if (this.attributes.clipPathTargets && this.attributes.clipPathTargets.length) {
|
|
224
232
|
this.attributes.clipPathTargets.forEach(function (target) {
|
|
225
|
-
target
|
|
233
|
+
dirtifyToRoot(target);
|
|
226
234
|
target.emit(ElementEvent.ATTRIBUTE_CHANGED, {
|
|
227
235
|
attributeName: 'clipPath',
|
|
228
236
|
oldValue: _this,
|
|
@@ -795,7 +803,7 @@ function (_super) {
|
|
|
795
803
|
sx = _b[0],
|
|
796
804
|
sy = _b[1];
|
|
797
805
|
|
|
798
|
-
var rotation = mat4.getRotation(quat.create(), transform);
|
|
806
|
+
var rotation = mat4.getRotation(quat.create(), transform); // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
799
807
|
|
|
800
808
|
var _c = __read(getEuler(vec3.create(), rotation), 3),
|
|
801
809
|
eux = _c[0],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BaseStyleProps } from '../types';
|
|
2
2
|
import { DisplayObject } from './DisplayObject';
|
|
3
|
-
import { DisplayObjectConfig } from '../dom';
|
|
3
|
+
import type { DisplayObjectConfig } from '../dom';
|
|
4
4
|
export declare class Group extends DisplayObject {
|
|
5
5
|
constructor(config?: DisplayObjectConfig<BaseStyleProps>);
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
|
|
2
2
|
import { DisplayObject } from './DisplayObject';
|
|
3
|
-
import { DisplayObjectConfig } from '../dom';
|
|
3
|
+
import type { DisplayObjectConfig } from '../dom';
|
|
4
4
|
import { AABB } from '../shapes';
|
|
5
5
|
export interface HTMLStyleProps extends BaseStyleProps {
|
|
6
6
|
innerHTML: string | HTMLElement;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
|
|
2
2
|
import { DisplayObject } from './DisplayObject';
|
|
3
|
-
import { DisplayObjectConfig } from '../dom';
|
|
3
|
+
import type { DisplayObjectConfig } from '../dom';
|
|
4
4
|
export interface ImageStyleProps extends BaseStyleProps {
|
|
5
5
|
img: string | HTMLImageElement;
|
|
6
6
|
width?: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BaseStyleProps, PathCommand } from '../types';
|
|
2
2
|
import { DisplayObject } from './DisplayObject';
|
|
3
|
-
import { DisplayObjectConfig } from '../dom';
|
|
3
|
+
import type { DisplayObjectConfig } from '../dom';
|
|
4
4
|
import { Point } from '../shapes';
|
|
5
5
|
import type { Rect } from '../shapes/Rect';
|
|
6
6
|
export interface PathStyleProps extends BaseStyleProps {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BaseStyleProps } from '../types';
|
|
2
2
|
import { DisplayObject } from './DisplayObject';
|
|
3
|
-
import { DisplayObjectConfig } from '../dom';
|
|
3
|
+
import type { DisplayObjectConfig } from '../dom';
|
|
4
4
|
import type { ParsedPolylineStyleProps } from './Polyline';
|
|
5
5
|
export interface PolygonStyleProps extends BaseStyleProps {
|
|
6
6
|
points: [number, number][];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BaseStyleProps } from '../types';
|
|
2
2
|
import { DisplayObject } from './DisplayObject';
|
|
3
|
-
import { DisplayObjectConfig } from '../dom';
|
|
3
|
+
import type { DisplayObjectConfig } from '../dom';
|
|
4
4
|
import { Point } from '../shapes';
|
|
5
5
|
export interface PolylineStyleProps extends BaseStyleProps {
|
|
6
6
|
points: [number, number][];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TextMetrics } from '../services/text';
|
|
1
|
+
import type { TextMetrics } from '../services/text';
|
|
2
2
|
import type { DisplayObjectConfig } from '../dom/interfaces';
|
|
3
3
|
import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
|
|
4
4
|
import { DisplayObject } from './DisplayObject';
|
|
@@ -52,7 +52,7 @@ function (_super) {
|
|
|
52
52
|
Text.prototype.getLineBoundingRects = function () {
|
|
53
53
|
var _a;
|
|
54
54
|
|
|
55
|
-
return (_a = this.parsedStyle.metrics) === null || _a === void 0 ? void 0 : _a.lineMetrics;
|
|
55
|
+
return ((_a = this.parsedStyle.metrics) === null || _a === void 0 ? void 0 : _a.lineMetrics) || [];
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
return Text;
|
package/es/dom/Animation.js
CHANGED
|
@@ -419,15 +419,18 @@ function () {
|
|
|
419
419
|
|
|
420
420
|
Animation.prototype.persist = function () {
|
|
421
421
|
throw new Error('Method not implemented.');
|
|
422
|
-
};
|
|
422
|
+
}; // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
423
|
+
|
|
423
424
|
|
|
424
425
|
Animation.prototype.addEventListener = function (type, listener, options) {
|
|
425
426
|
throw new Error('Method not implemented.');
|
|
426
|
-
};
|
|
427
|
+
}; // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
428
|
+
|
|
427
429
|
|
|
428
430
|
Animation.prototype.removeEventListener = function (type, listener, options) {
|
|
429
431
|
throw new Error('Method not implemented.');
|
|
430
|
-
};
|
|
432
|
+
}; // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
433
|
+
|
|
431
434
|
|
|
432
435
|
Animation.prototype.dispatchEvent = function (event) {
|
|
433
436
|
throw new Error('Method not implemented.');
|
|
@@ -476,7 +479,9 @@ function () {
|
|
|
476
479
|
if (this.onfinish) {
|
|
477
480
|
var event_1 = new AnimationEvent(null, this, this.currentTime, baseTime);
|
|
478
481
|
setTimeout(function () {
|
|
479
|
-
|
|
482
|
+
if (_this.onfinish) {
|
|
483
|
+
_this.onfinish(event_1);
|
|
484
|
+
}
|
|
480
485
|
});
|
|
481
486
|
}
|
|
482
487
|
|
package/es/dom/CustomEvent.js
CHANGED
|
@@ -16,7 +16,8 @@ import { FederatedEvent } from './FederatedEvent';
|
|
|
16
16
|
var CustomEvent =
|
|
17
17
|
/** @class */
|
|
18
18
|
function (_super) {
|
|
19
|
-
__extends(CustomEvent, _super);
|
|
19
|
+
__extends(CustomEvent, _super); // eslint-disable-next-line @typescript-eslint/ban-types
|
|
20
|
+
|
|
20
21
|
|
|
21
22
|
function CustomEvent(eventName, object) {
|
|
22
23
|
var _this = _super.call(this, null) || this;
|
package/es/dom/Document.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Node } from './Node';
|
|
2
2
|
import { AnimationTimeline } from './AnimationTimeline';
|
|
3
3
|
import { Group } from '../display-objects/Group';
|
|
4
|
-
import { DisplayObject } from '../display-objects/DisplayObject';
|
|
4
|
+
import type { DisplayObject } from '../display-objects/DisplayObject';
|
|
5
5
|
import type { IDocument, IElement, INode, ICanvas, DisplayObjectConfig } from './interfaces';
|
|
6
|
-
import { BaseStyleProps } from '../types';
|
|
6
|
+
import type { BaseStyleProps } from '../types';
|
|
7
7
|
/**
|
|
8
8
|
* the entry of DOM tree
|
|
9
9
|
* Document -> Node -> EventTarget
|
|
@@ -34,7 +34,7 @@ export declare class Document extends Node implements IDocument {
|
|
|
34
34
|
* @example const circle = document.createElement('circle', { style: { r: 10 } });
|
|
35
35
|
*/
|
|
36
36
|
createElement<T extends DisplayObject<StyleProps>, StyleProps extends BaseStyleProps>(tagName: string, options: DisplayObjectConfig<StyleProps>): T;
|
|
37
|
-
cloneNode(deep?: boolean):
|
|
37
|
+
cloneNode(deep?: boolean): this;
|
|
38
38
|
destroy(): void;
|
|
39
39
|
/**
|
|
40
40
|
* eg. Uncaught DOMException: Failed to execute 'appendChild' on 'Node': Only one element on document allowed.
|
package/es/dom/Document.js
CHANGED
|
@@ -71,7 +71,8 @@ function (_super) {
|
|
|
71
71
|
Document.prototype.createElement = function (tagName, options) {
|
|
72
72
|
var clazz = this.defaultView.customElements.get(tagName);
|
|
73
73
|
return new clazz(options);
|
|
74
|
-
};
|
|
74
|
+
}; // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
75
|
+
|
|
75
76
|
|
|
76
77
|
Document.prototype.cloneNode = function (deep) {
|
|
77
78
|
throw new Error('Method not implemented.');
|
|
@@ -87,23 +88,28 @@ function (_super) {
|
|
|
87
88
|
/**
|
|
88
89
|
* eg. Uncaught DOMException: Failed to execute 'appendChild' on 'Node': Only one element on document allowed.
|
|
89
90
|
*/
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
90
92
|
|
|
91
93
|
|
|
92
94
|
Document.prototype.appendChild = function (newChild, index) {
|
|
93
95
|
throw new Error('Use document.documentElement instead.');
|
|
94
|
-
};
|
|
96
|
+
}; // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
97
|
+
|
|
95
98
|
|
|
96
99
|
Document.prototype.insertBefore = function (newChild, refChild) {
|
|
97
100
|
throw new Error('Use document.documentElement instead.');
|
|
98
|
-
};
|
|
101
|
+
}; // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
102
|
+
|
|
99
103
|
|
|
100
104
|
Document.prototype.removeChild = function (oldChild, destroy) {
|
|
101
105
|
throw new Error('Use document.documentElement instead.');
|
|
102
|
-
};
|
|
106
|
+
}; // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
107
|
+
|
|
103
108
|
|
|
104
109
|
Document.prototype.replaceChild = function (newChild, oldChild, destroy) {
|
|
105
110
|
throw new Error('Use document.documentElement instead.');
|
|
106
|
-
};
|
|
111
|
+
}; // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
112
|
+
|
|
107
113
|
|
|
108
114
|
Document.prototype.append = function () {
|
|
109
115
|
var nodes = [];
|
|
@@ -113,7 +119,8 @@ function (_super) {
|
|
|
113
119
|
}
|
|
114
120
|
|
|
115
121
|
throw new Error('Use document.documentElement instead.');
|
|
116
|
-
};
|
|
122
|
+
}; // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
123
|
+
|
|
117
124
|
|
|
118
125
|
Document.prototype.prepend = function () {
|
|
119
126
|
var nodes = [];
|
package/es/dom/Element.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { SceneGraphService } from '../services/SceneGraphService';
|
|
2
2
|
import { Cullable, Geometry, Renderable, Transform, Sortable } from '../components';
|
|
3
|
-
import { BaseStyleProps, ParsedBaseStyleProps } from '../types';
|
|
3
|
+
import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
|
|
4
4
|
import { Node } from './Node';
|
|
5
|
-
import { AABB, Rectangle } from '../shapes';
|
|
6
|
-
import type {
|
|
5
|
+
import type { AABB, Rectangle } from '../shapes';
|
|
6
|
+
import type { IEventTarget, IElement, INode } from './interfaces';
|
|
7
7
|
/**
|
|
8
8
|
* Has following capabilities:
|
|
9
9
|
* * Node insert/remove, eg. appendChild, removeChild, remove...
|
|
@@ -19,7 +19,6 @@ export declare class Element<StyleProps extends BaseStyleProps = any, ParsedStyl
|
|
|
19
19
|
transformable: Transform;
|
|
20
20
|
sortable: Sortable;
|
|
21
21
|
geometry: Geometry;
|
|
22
|
-
constructor(config: DisplayObjectConfig<StyleProps>);
|
|
23
22
|
/**
|
|
24
23
|
* used with `getElementById()`
|
|
25
24
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/id
|
|
@@ -52,8 +51,8 @@ export declare class Element<StyleProps extends BaseStyleProps = any, ParsedStyl
|
|
|
52
51
|
get previousSibling(): IElement | null;
|
|
53
52
|
cloneNode(deep?: boolean): this;
|
|
54
53
|
appendChild<T extends INode>(child: T, index?: number): T;
|
|
55
|
-
insertBefore<T extends INode>(newChild: T, refChild:
|
|
56
|
-
replaceChild<T extends INode
|
|
54
|
+
insertBefore<T extends INode>(newChild: T, refChild: INode | null): T;
|
|
55
|
+
replaceChild<T extends INode>(newChild: INode, oldChild: T, destroy?: boolean): T;
|
|
57
56
|
removeChild<T extends INode>(child: T, destroy?: boolean): T;
|
|
58
57
|
removeChildren(destroy?: boolean): void;
|
|
59
58
|
/**
|
|
@@ -74,27 +73,27 @@ export declare class Element<StyleProps extends BaseStyleProps = any, ParsedStyl
|
|
|
74
73
|
/**
|
|
75
74
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/after
|
|
76
75
|
*/
|
|
77
|
-
after(...nodes:
|
|
76
|
+
after(...nodes: INode[]): void;
|
|
78
77
|
/**
|
|
79
78
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/before
|
|
80
79
|
*/
|
|
81
|
-
before(...nodes:
|
|
80
|
+
before(...nodes: INode[]): void;
|
|
82
81
|
/**
|
|
83
82
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/replaceWith
|
|
84
83
|
*/
|
|
85
|
-
replaceWith(...nodes:
|
|
84
|
+
replaceWith(...nodes: INode[]): void;
|
|
86
85
|
/**
|
|
87
86
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/append
|
|
88
87
|
*/
|
|
89
|
-
append(...nodes:
|
|
88
|
+
append(...nodes: INode[]): void;
|
|
90
89
|
/**
|
|
91
90
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/prepend
|
|
92
91
|
*/
|
|
93
|
-
prepend(...nodes:
|
|
92
|
+
prepend(...nodes: INode[]): void;
|
|
94
93
|
/**
|
|
95
94
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/replaceChildren
|
|
96
95
|
*/
|
|
97
|
-
replaceChildren(...nodes:
|
|
96
|
+
replaceChildren(...nodes: INode[]): void;
|
|
98
97
|
/**
|
|
99
98
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/remove
|
|
100
99
|
*/
|