@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/dom/Element.js
CHANGED
|
@@ -18,8 +18,8 @@ var Element =
|
|
|
18
18
|
function (_super) {
|
|
19
19
|
__extends(Element, _super);
|
|
20
20
|
|
|
21
|
-
function Element(
|
|
22
|
-
var _this = _super.
|
|
21
|
+
function Element() {
|
|
22
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
23
23
|
|
|
24
24
|
_this.sceneGraphService = globalContainer.get(SceneGraphService);
|
|
25
25
|
_this.entity = entityCounter++;
|
|
@@ -129,7 +129,7 @@ function (_super) {
|
|
|
129
129
|
},
|
|
130
130
|
enumerable: false,
|
|
131
131
|
configurable: true
|
|
132
|
-
});
|
|
132
|
+
}); // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
133
133
|
|
|
134
134
|
Element.prototype.cloneNode = function (deep) {
|
|
135
135
|
throw new Error('Method not implemented.');
|
|
@@ -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
|
/**
|
|
@@ -476,7 +479,8 @@ function (_super) {
|
|
|
476
479
|
*/
|
|
477
480
|
|
|
478
481
|
|
|
479
|
-
Element.prototype.setAttribute = function (attributeName, value,
|
|
482
|
+
Element.prototype.setAttribute = function (attributeName, value, // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
483
|
+
force) {
|
|
480
484
|
if (force === void 0) {
|
|
481
485
|
force = false;
|
|
482
486
|
}
|
package/es/dom/EventTarget.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Point } from '../shapes/Point';
|
|
2
2
|
import type { EventService } from '../services';
|
|
3
|
-
import { IEventTarget } from './interfaces';
|
|
3
|
+
import type { IEventTarget } from './interfaces';
|
|
4
4
|
/**
|
|
5
5
|
* An DOM-compatible synthetic event implementation that is "forwarded" on behalf of an original
|
|
6
6
|
* FederatedEvent or native {@link https://dom.spec.whatwg.org/#event Event}.
|
package/es/dom/KeyframeEffect.js
CHANGED
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
|
*/
|
|
@@ -48,7 +48,7 @@ export declare abstract class Node extends EventTarget implements INode {
|
|
|
48
48
|
/**
|
|
49
49
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Node/getRootNode
|
|
50
50
|
*/
|
|
51
|
-
getRootNode(
|
|
51
|
+
getRootNode(): INode;
|
|
52
52
|
hasChildNodes(): boolean;
|
|
53
53
|
isDefaultNamespace(namespace: string | null): boolean;
|
|
54
54
|
compareDocumentPosition(other: INode): number;
|
|
@@ -70,14 +70,14 @@ export declare abstract class Node extends EventTarget implements INode {
|
|
|
70
70
|
*/
|
|
71
71
|
get parent(): INode | null;
|
|
72
72
|
get parentElement(): IElement | null;
|
|
73
|
-
get nextSibling():
|
|
74
|
-
get previousSibling():
|
|
75
|
-
get firstChild():
|
|
76
|
-
get lastChild():
|
|
73
|
+
get nextSibling(): IChildNode | null;
|
|
74
|
+
get previousSibling(): IChildNode | null;
|
|
75
|
+
get firstChild(): IChildNode | null;
|
|
76
|
+
get lastChild(): IChildNode | null;
|
|
77
77
|
/**
|
|
78
78
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Node/cloneNode
|
|
79
79
|
*/
|
|
80
|
-
abstract cloneNode(deep?: boolean):
|
|
80
|
+
abstract cloneNode(deep?: boolean): this;
|
|
81
81
|
/**
|
|
82
82
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Node/appendChild
|
|
83
83
|
*/
|
|
@@ -93,14 +93,14 @@ export declare abstract class Node extends EventTarget implements INode {
|
|
|
93
93
|
/**
|
|
94
94
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Node/replaceChild
|
|
95
95
|
*/
|
|
96
|
-
abstract replaceChild<T extends INode
|
|
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(other:
|
|
103
|
-
contains(other:
|
|
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/Node.js
CHANGED
|
@@ -76,7 +76,8 @@ function (_super) {
|
|
|
76
76
|
*/
|
|
77
77
|
|
|
78
78
|
|
|
79
|
-
Node.prototype.getRootNode = function (
|
|
79
|
+
Node.prototype.getRootNode = function () {
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
80
81
|
var temp = this;
|
|
81
82
|
|
|
82
83
|
while (temp.parentNode) {
|
|
@@ -88,19 +89,23 @@ function (_super) {
|
|
|
88
89
|
|
|
89
90
|
Node.prototype.hasChildNodes = function () {
|
|
90
91
|
return this.childNodes.length > 0;
|
|
91
|
-
};
|
|
92
|
+
}; // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
93
|
+
|
|
92
94
|
|
|
93
95
|
Node.prototype.isDefaultNamespace = function (namespace) {
|
|
94
96
|
throw new Error('Method not implemented.');
|
|
95
|
-
};
|
|
97
|
+
}; // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
98
|
+
|
|
96
99
|
|
|
97
100
|
Node.prototype.compareDocumentPosition = function (other) {
|
|
98
101
|
throw new Error('Method not implemented.');
|
|
99
|
-
};
|
|
102
|
+
}; // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
103
|
+
|
|
100
104
|
|
|
101
105
|
Node.prototype.lookupNamespaceURI = function (prefix) {
|
|
102
106
|
throw new Error('Method not implemented.');
|
|
103
|
-
};
|
|
107
|
+
}; // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
108
|
+
|
|
104
109
|
|
|
105
110
|
Node.prototype.lookupPrefix = function (namespace) {
|
|
106
111
|
throw new Error('Method not implemented.');
|
|
@@ -190,6 +195,7 @@ function (_super) {
|
|
|
190
195
|
};
|
|
191
196
|
|
|
192
197
|
Node.prototype.getAncestor = function (n) {
|
|
198
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
193
199
|
var temp = this;
|
|
194
200
|
|
|
195
201
|
while (n > 0 && temp) {
|
package/es/dom/interfaces.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import EventEmitter from 'eventemitter3';
|
|
1
|
+
import type EventEmitter from 'eventemitter3';
|
|
2
2
|
import type { AnimationTimeline } from './AnimationTimeline';
|
|
3
|
-
import { BaseStyleProps,
|
|
3
|
+
import type { BaseStyleProps, SHAPE } from '../types';
|
|
4
4
|
import type { FederatedEvent } from './FederatedEvent';
|
|
5
|
-
import { CustomElementRegistry } from './CustomElementRegistry';
|
|
6
|
-
import { DisplayObject } from '..';
|
|
5
|
+
import type { CustomElementRegistry } from './CustomElementRegistry';
|
|
6
|
+
import type { DisplayObject } from '..';
|
|
7
7
|
import type { PointLike } from '../shapes';
|
|
8
8
|
import type { Camera } from '../camera';
|
|
9
|
-
import { ContextService } from '../services';
|
|
9
|
+
import type { ContextService } from '../services';
|
|
10
10
|
/**
|
|
11
11
|
* built-in events for element
|
|
12
12
|
*/
|
|
@@ -35,13 +35,13 @@ export declare enum ElementEvent {
|
|
|
35
35
|
}
|
|
36
36
|
export interface IEventTarget {
|
|
37
37
|
emitter: EventEmitter;
|
|
38
|
-
on(type: string, listener: EventListenerOrEventListenerObject | ((...args: any[]) => void), options?: boolean | AddEventListenerOptions)
|
|
39
|
-
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions)
|
|
40
|
-
off(type: string, listener: EventListenerOrEventListenerObject | ((...args: any[]) => void), options?: boolean | AddEventListenerOptions)
|
|
41
|
-
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions)
|
|
42
|
-
removeAllEventListeners()
|
|
43
|
-
dispatchEvent<T extends FederatedEvent>(e: T)
|
|
44
|
-
emit(eventName: string, object: object)
|
|
38
|
+
on: (type: string, listener: EventListenerOrEventListenerObject | ((...args: any[]) => void), options?: boolean | AddEventListenerOptions) => this;
|
|
39
|
+
addEventListener: (type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => this;
|
|
40
|
+
off: (type: string, listener: EventListenerOrEventListenerObject | ((...args: any[]) => void), options?: boolean | AddEventListenerOptions) => this;
|
|
41
|
+
removeEventListener: (type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => this;
|
|
42
|
+
removeAllEventListeners: () => void;
|
|
43
|
+
dispatchEvent: <T extends FederatedEvent>(e: T) => boolean;
|
|
44
|
+
emit: (eventName: string, object: object) => void;
|
|
45
45
|
}
|
|
46
46
|
export interface INode extends IEventTarget {
|
|
47
47
|
shadow: boolean;
|
|
@@ -52,11 +52,11 @@ export interface INode extends IEventTarget {
|
|
|
52
52
|
/**
|
|
53
53
|
* Returns the children.
|
|
54
54
|
*/
|
|
55
|
-
readonly childNodes:
|
|
55
|
+
readonly childNodes: IChildNode[];
|
|
56
56
|
/**
|
|
57
57
|
* Returns the first child.
|
|
58
58
|
*/
|
|
59
|
-
readonly firstChild:
|
|
59
|
+
readonly firstChild: IChildNode | null;
|
|
60
60
|
/**
|
|
61
61
|
* Returns true if node is connected and false otherwise.
|
|
62
62
|
*/
|
|
@@ -64,11 +64,11 @@ export interface INode extends IEventTarget {
|
|
|
64
64
|
/**
|
|
65
65
|
* Returns the last child.
|
|
66
66
|
*/
|
|
67
|
-
readonly lastChild:
|
|
67
|
+
readonly lastChild: IChildNode | null;
|
|
68
68
|
/**
|
|
69
69
|
* Returns the next sibling.
|
|
70
70
|
*/
|
|
71
|
-
readonly nextSibling:
|
|
71
|
+
readonly nextSibling: IChildNode | null;
|
|
72
72
|
/**
|
|
73
73
|
* Returns a string appropriate for the type of node.
|
|
74
74
|
*/
|
|
@@ -93,56 +93,56 @@ export interface INode extends IEventTarget {
|
|
|
93
93
|
/**
|
|
94
94
|
* Returns the previous sibling.
|
|
95
95
|
*/
|
|
96
|
-
readonly previousSibling:
|
|
96
|
+
readonly previousSibling: IChildNode | null;
|
|
97
97
|
textContent: string | null;
|
|
98
|
-
appendChild<T extends INode>(newChild: T, index?: number)
|
|
98
|
+
appendChild: <T extends INode>(newChild: T, index?: number) => T;
|
|
99
99
|
/**
|
|
100
100
|
* Returns a copy of node. If deep is true, the copy also includes the node's descendants.
|
|
101
101
|
*/
|
|
102
|
-
cloneNode(deep?: boolean)
|
|
102
|
+
cloneNode: (deep?: boolean) => INode;
|
|
103
103
|
/**
|
|
104
104
|
* Returns a bitmask indicating the position of other relative to node.
|
|
105
105
|
*/
|
|
106
|
-
compareDocumentPosition(other: INode)
|
|
106
|
+
compareDocumentPosition: (other: INode) => number;
|
|
107
107
|
/**
|
|
108
108
|
* Returns true if other is an inclusive descendant of node, and false otherwise.
|
|
109
109
|
*/
|
|
110
|
-
contains(other: INode | null)
|
|
110
|
+
contains: (other: INode | null) => boolean;
|
|
111
111
|
/**
|
|
112
112
|
* Returns node's root.
|
|
113
113
|
*/
|
|
114
|
-
getRootNode(options?: GetRootNodeOptions)
|
|
114
|
+
getRootNode: (options?: GetRootNodeOptions) => INode;
|
|
115
115
|
/**
|
|
116
116
|
* Returns node's ancestor.
|
|
117
117
|
*/
|
|
118
|
-
getAncestor(n: number)
|
|
118
|
+
getAncestor: (n: number) => INode | null;
|
|
119
119
|
/**
|
|
120
120
|
* Traverse in sub tree.
|
|
121
121
|
*/
|
|
122
|
-
forEach(callback: (o: INode) => void | boolean)
|
|
122
|
+
forEach: (callback: (o: INode) => void | boolean) => void;
|
|
123
123
|
/**
|
|
124
124
|
* Returns whether node has children.
|
|
125
125
|
*/
|
|
126
|
-
hasChildNodes()
|
|
127
|
-
insertBefore<T extends INode>(newChild: T, refChild: INode | null)
|
|
128
|
-
isDefaultNamespace(namespace: string | null)
|
|
126
|
+
hasChildNodes: () => boolean;
|
|
127
|
+
insertBefore: <T extends INode>(newChild: T, refChild: INode | null) => T;
|
|
128
|
+
isDefaultNamespace: (namespace: string | null) => boolean;
|
|
129
129
|
/**
|
|
130
130
|
* Returns whether node and otherNode have the same properties.
|
|
131
131
|
*/
|
|
132
|
-
isEqualNode(otherNode: INode | null)
|
|
133
|
-
isSameNode(otherNode: INode | null)
|
|
134
|
-
lookupNamespaceURI(prefix: string | null)
|
|
135
|
-
lookupPrefix(namespace: string | null)
|
|
132
|
+
isEqualNode: (otherNode: INode | null) => boolean;
|
|
133
|
+
isSameNode: (otherNode: INode | null) => boolean;
|
|
134
|
+
lookupNamespaceURI: (prefix: string | null) => string | null;
|
|
135
|
+
lookupPrefix: (namespace: string | null) => string | null;
|
|
136
136
|
/**
|
|
137
137
|
* Removes empty exclusive Text nodes and concatenates the data of remaining contiguous exclusive Text nodes into the first of their nodes.
|
|
138
138
|
*/
|
|
139
|
-
normalize()
|
|
140
|
-
removeChild<T extends INode>(oldChild: T, destroy?: boolean)
|
|
141
|
-
replaceChild<T extends INode
|
|
139
|
+
normalize: () => void;
|
|
140
|
+
removeChild: <T extends INode>(oldChild: T, destroy?: boolean) => T;
|
|
141
|
+
replaceChild: <T extends INode>(newChild: INode, oldChild: T, destroy?: boolean) => T;
|
|
142
142
|
/**
|
|
143
143
|
* Destroy itself.
|
|
144
144
|
*/
|
|
145
|
-
destroy()
|
|
145
|
+
destroy: () => void;
|
|
146
146
|
}
|
|
147
147
|
export interface IParentNode {
|
|
148
148
|
readonly childElementCount: number;
|
|
@@ -163,29 +163,29 @@ export interface IParentNode {
|
|
|
163
163
|
*
|
|
164
164
|
* Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated.
|
|
165
165
|
*/
|
|
166
|
-
append(...nodes: INode[])
|
|
166
|
+
append: (...nodes: INode[]) => void;
|
|
167
167
|
/**
|
|
168
168
|
* Inserts nodes before the first child of node, while replacing strings in nodes with equivalent Text nodes.
|
|
169
169
|
*
|
|
170
170
|
* Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated.
|
|
171
171
|
*/
|
|
172
|
-
prepend(...nodes: INode[])
|
|
172
|
+
prepend: (...nodes: INode[]) => void;
|
|
173
173
|
/**
|
|
174
174
|
* Returns the first element that is a descendant of node that matches selectors.
|
|
175
175
|
*/
|
|
176
|
-
querySelector<E extends IElement = IElement>(selectors: string)
|
|
176
|
+
querySelector: <E extends IElement = IElement>(selectors: string) => E | null;
|
|
177
177
|
/**
|
|
178
178
|
* Returns all element descendants of node that match selectors.
|
|
179
179
|
*/
|
|
180
|
-
querySelectorAll<E extends IElement = IElement>(selectors: string)
|
|
180
|
+
querySelectorAll: <E extends IElement = IElement>(selectors: string) => E[];
|
|
181
181
|
/**
|
|
182
182
|
* Similar to querySelector, use custom filter instead of selectors.
|
|
183
183
|
*/
|
|
184
|
-
find<E extends IElement = IElement>(filter: (node: E) => boolean)
|
|
184
|
+
find: <E extends IElement = IElement>(filter: (node: E) => boolean) => E | null;
|
|
185
185
|
/**
|
|
186
186
|
* Similar to querySelectorAll, use custom filter instead of selectors.
|
|
187
187
|
*/
|
|
188
|
-
findAll<E extends IElement = IElement>(filter: (node: E) => boolean)
|
|
188
|
+
findAll: <E extends IElement = IElement>(filter: (node: E) => boolean) => E[];
|
|
189
189
|
}
|
|
190
190
|
export interface IChildNode extends INode {
|
|
191
191
|
/**
|
|
@@ -193,23 +193,23 @@ export interface IChildNode extends INode {
|
|
|
193
193
|
*
|
|
194
194
|
* Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated.
|
|
195
195
|
*/
|
|
196
|
-
after(...nodes: INode[])
|
|
196
|
+
after: (...nodes: INode[]) => void;
|
|
197
197
|
/**
|
|
198
198
|
* Inserts nodes just before node, while replacing strings in nodes with equivalent Text nodes.
|
|
199
199
|
*
|
|
200
200
|
* Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated.
|
|
201
201
|
*/
|
|
202
|
-
before(...nodes: INode[])
|
|
202
|
+
before: (...nodes: INode[]) => void;
|
|
203
203
|
/**
|
|
204
204
|
* Removes node.
|
|
205
205
|
*/
|
|
206
|
-
remove()
|
|
206
|
+
remove: () => void;
|
|
207
207
|
/**
|
|
208
208
|
* Replaces node with nodes, while replacing strings in nodes with equivalent Text nodes.
|
|
209
209
|
*
|
|
210
210
|
* Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated.
|
|
211
211
|
*/
|
|
212
|
-
replaceWith(...nodes: INode[])
|
|
212
|
+
replaceWith: (...nodes: INode[]) => void;
|
|
213
213
|
}
|
|
214
214
|
export interface DisplayObjectConfig<StyleProps> {
|
|
215
215
|
/**
|
|
@@ -250,7 +250,7 @@ export interface DisplayObjectConfig<StyleProps> {
|
|
|
250
250
|
*/
|
|
251
251
|
interactive?: boolean;
|
|
252
252
|
}
|
|
253
|
-
export interface IElement<StyleProps
|
|
253
|
+
export interface IElement<StyleProps = any, ParsedStyleProps = any> extends INode, IChildNode, IParentNode {
|
|
254
254
|
/**
|
|
255
255
|
* Returns the value of element's id content attribute. Can be set to change it.
|
|
256
256
|
*/
|
|
@@ -274,24 +274,24 @@ export interface IElement<StyleProps extends BaseStyleProps = any, ParsedStylePr
|
|
|
274
274
|
*/
|
|
275
275
|
style: StyleProps;
|
|
276
276
|
parsedStyle: ParsedStyleProps;
|
|
277
|
-
getElementById<E extends IElement = IElement>(id: string)
|
|
278
|
-
getElementsByName<E extends IElement = IElement>(name: string)
|
|
279
|
-
getElementsByClassName<E extends IElement = IElement>(className: string)
|
|
280
|
-
getElementsByTagName<E extends IElement = IElement>(tagName: string)
|
|
277
|
+
getElementById: <E extends IElement = IElement>(id: string) => E | null;
|
|
278
|
+
getElementsByName: <E extends IElement = IElement>(name: string) => E[];
|
|
279
|
+
getElementsByClassName: <E extends IElement = IElement>(className: string) => E[];
|
|
280
|
+
getElementsByTagName: <E extends IElement = IElement>(tagName: string) => E[];
|
|
281
281
|
scrollLeft: number;
|
|
282
282
|
scrollTop: number;
|
|
283
283
|
/**
|
|
284
284
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute
|
|
285
285
|
*/
|
|
286
|
-
setAttribute<Key extends keyof StyleProps>(attributeName: Key, value: StyleProps[Key], force?: boolean)
|
|
286
|
+
setAttribute: <Key extends keyof StyleProps>(attributeName: Key, value: StyleProps[Key], force?: boolean) => void;
|
|
287
287
|
/**
|
|
288
288
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttribute
|
|
289
289
|
*/
|
|
290
|
-
getAttribute(attributeName: keyof StyleProps)
|
|
290
|
+
getAttribute: (attributeName: keyof StyleProps) => StyleProps[keyof StyleProps] | undefined;
|
|
291
291
|
/**
|
|
292
292
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/removeAttribute
|
|
293
293
|
*/
|
|
294
|
-
removeAttribute(attributeName: keyof StyleProps)
|
|
294
|
+
removeAttribute: (attributeName: keyof StyleProps) => void;
|
|
295
295
|
}
|
|
296
296
|
export interface IDocument extends INode, IParentNode {
|
|
297
297
|
/**
|
|
@@ -307,18 +307,18 @@ export interface IDocument extends INode, IParentNode {
|
|
|
307
307
|
/**
|
|
308
308
|
* Creates an instance of the element for the specified tag.
|
|
309
309
|
*/
|
|
310
|
-
createElement<T extends DisplayObject<StyleProps>, StyleProps extends BaseStyleProps>(tagName: string, options: DisplayObjectConfig<StyleProps>)
|
|
310
|
+
createElement: <T extends DisplayObject<StyleProps>, StyleProps extends BaseStyleProps>(tagName: string, options: DisplayObjectConfig<StyleProps>) => T;
|
|
311
311
|
}
|
|
312
312
|
export interface ICanvas extends IEventTarget {
|
|
313
313
|
document: IDocument;
|
|
314
314
|
customElements: CustomElementRegistry;
|
|
315
|
-
render()
|
|
316
|
-
destroy(destroyScenegraph?: boolean)
|
|
317
|
-
resize(width: number, height: number)
|
|
318
|
-
getCamera()
|
|
319
|
-
getContextService()
|
|
320
|
-
client2Viewport(client: PointLike)
|
|
321
|
-
viewport2Client(viewport: PointLike)
|
|
322
|
-
canvas2Viewport(canvas: PointLike)
|
|
323
|
-
viewport2Canvas(viewport: PointLike)
|
|
315
|
+
render: () => void;
|
|
316
|
+
destroy: (destroyScenegraph?: boolean) => void;
|
|
317
|
+
resize: (width: number, height: number) => void;
|
|
318
|
+
getCamera: () => Camera;
|
|
319
|
+
getContextService: () => ContextService<unknown>;
|
|
320
|
+
client2Viewport: (client: PointLike) => PointLike;
|
|
321
|
+
viewport2Client: (viewport: PointLike) => PointLike;
|
|
322
|
+
canvas2Viewport: (canvas: PointLike) => PointLike;
|
|
323
|
+
viewport2Canvas: (viewport: PointLike) => PointLike;
|
|
324
324
|
}
|
package/es/global-module.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
+
import type { StylePropertyParser, StylePropertyMerger, StylePropertyUpdater } from './property-handlers';
|
|
1
2
|
export declare const globalContainer: import("mana-syringe").Container;
|
|
3
|
+
export declare const stylePropertyParserFactory: Record<string, StylePropertyParser<any, any>>;
|
|
4
|
+
export declare const stylePropertyUpdaterFactory: Record<string, StylePropertyUpdater<any>[]>;
|
|
5
|
+
export declare const stylePropertyMergerFactory: Record<string, StylePropertyMerger<any, any>>;
|
|
2
6
|
export declare const containerModule: import("mana-syringe").SyringeModule;
|
package/es/global-module.js
CHANGED
|
@@ -7,8 +7,14 @@ import { TextService } from './services/text';
|
|
|
7
7
|
import { TextUpdater } from './services/aabb/TextUpdater';
|
|
8
8
|
import { OffscreenCanvasCreator } from './services/text/OffscreenCanvasCreator';
|
|
9
9
|
import { DefaultSceneGraphSelector, SceneGraphSelector, SceneGraphSelectorFactory } from './services/SceneGraphSelector';
|
|
10
|
-
import {
|
|
10
|
+
import { // StylePropertyParserFactory,
|
|
11
|
+
// StylePropertyUpdaterFactory,
|
|
12
|
+
// StylePropertyMergerFactory,
|
|
13
|
+
clampedMergeNumbers, parseNumber, mergeColors, parseColor, updateGeometry, updateLocalPosition, updateOffsetPath, updateClipPath, updateZIndex, updateOffsetDistance, updateOrigin, updateTransform, updateTransformOrigin, parseTransform, mergeTransforms, parsePath, parsePoints, mergePaths, mergeNumbers, mergeNumberLists, parseFilter, updateAnchor, parseLineDash } from './property-handlers';
|
|
11
14
|
export var globalContainer = GlobalContainer;
|
|
15
|
+
export var stylePropertyParserFactory = {};
|
|
16
|
+
export var stylePropertyUpdaterFactory = {};
|
|
17
|
+
export var stylePropertyMergerFactory = {};
|
|
12
18
|
export var containerModule = Module(function (register) {
|
|
13
19
|
decorate(injectable(), EventEmitter); // bind DisplayObject pool
|
|
14
20
|
|
|
@@ -56,83 +62,65 @@ export var containerModule = Module(function (register) {
|
|
|
56
62
|
return cache[tagName];
|
|
57
63
|
};
|
|
58
64
|
}
|
|
59
|
-
}); // bind style property handlers
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
return cache[propertyName];
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
});
|
|
65
|
+
}); // // bind style property handlers
|
|
66
|
+
// register({
|
|
67
|
+
// token: StylePropertyParserFactory,
|
|
68
|
+
// useFactory: (context) => {
|
|
69
|
+
// const cache = {};
|
|
70
|
+
// return (propertyName: string) => {
|
|
71
|
+
// if (!cache[propertyName]) {
|
|
72
|
+
// if (context.container.isBoundNamed(StylePropertyParser, propertyName)) {
|
|
73
|
+
// cache[propertyName] = context.container.getNamed(StylePropertyParser, propertyName);
|
|
74
|
+
// }
|
|
75
|
+
// }
|
|
76
|
+
// return cache[propertyName];
|
|
77
|
+
// };
|
|
78
|
+
// },
|
|
79
|
+
// });
|
|
80
|
+
// register({
|
|
81
|
+
// token: StylePropertyUpdaterFactory,
|
|
82
|
+
// useFactory: (context) => {
|
|
83
|
+
// const cache = {};
|
|
84
|
+
// return (propertyName: string) => {
|
|
85
|
+
// if (!cache[propertyName]) {
|
|
86
|
+
// if (context.container.isBoundNamed(StylePropertyUpdater, propertyName)) {
|
|
87
|
+
// cache[propertyName] = context.container.getAllNamed(StylePropertyUpdater, propertyName);
|
|
88
|
+
// }
|
|
89
|
+
// }
|
|
90
|
+
// return cache[propertyName];
|
|
91
|
+
// };
|
|
92
|
+
// },
|
|
93
|
+
// });
|
|
94
|
+
// register({
|
|
95
|
+
// token: StylePropertyMergerFactory,
|
|
96
|
+
// useFactory: (context) => {
|
|
97
|
+
// const cache = {};
|
|
98
|
+
// return (propertyName: string) => {
|
|
99
|
+
// if (!cache[propertyName]) {
|
|
100
|
+
// if (context.container.isBoundNamed(StylePropertyMerger, propertyName)) {
|
|
101
|
+
// cache[propertyName] = context.container.getNamed(StylePropertyMerger, propertyName);
|
|
102
|
+
// }
|
|
103
|
+
// }
|
|
104
|
+
// return cache[propertyName];
|
|
105
|
+
// };
|
|
106
|
+
// },
|
|
107
|
+
// });
|
|
106
108
|
|
|
107
109
|
function addPropertyHandler(property, parser, merger, updater) {
|
|
108
110
|
if (parser) {
|
|
109
|
-
register({
|
|
110
|
-
token: {
|
|
111
|
-
token: StylePropertyParser,
|
|
112
|
-
named: property
|
|
113
|
-
},
|
|
114
|
-
useValue: parser
|
|
115
|
-
});
|
|
111
|
+
stylePropertyParserFactory[property] = parser; // register({ token: { token: StylePropertyParser, named: property }, useValue: parser });
|
|
116
112
|
}
|
|
117
113
|
|
|
118
114
|
if (merger) {
|
|
119
|
-
register({
|
|
120
|
-
token: {
|
|
121
|
-
token: StylePropertyMerger,
|
|
122
|
-
named: property
|
|
123
|
-
},
|
|
124
|
-
useValue: merger
|
|
125
|
-
});
|
|
115
|
+
stylePropertyMergerFactory[property] = merger; // register({ token: { token: StylePropertyMerger, named: property }, useValue: merger });
|
|
126
116
|
}
|
|
127
117
|
|
|
128
118
|
if (updater) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
useValue: updater
|
|
135
|
-
});
|
|
119
|
+
if (!stylePropertyUpdaterFactory[property]) {
|
|
120
|
+
stylePropertyUpdaterFactory[property] = [];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
stylePropertyUpdaterFactory[property].push(updater); // register({ token: { token: StylePropertyUpdater, named: property }, useValue: updater });
|
|
136
124
|
}
|
|
137
125
|
}
|
|
138
126
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Syringe } from 'mana-syringe';
|
|
2
|
-
import { DisplayObject } from '../display-objects/DisplayObject';
|
|
3
|
-
import { RenderingService, RenderingPlugin } from '../services/RenderingService';
|
|
2
|
+
import type { DisplayObject } from '../display-objects/DisplayObject';
|
|
3
|
+
import type { RenderingService, RenderingPlugin } from '../services/RenderingService';
|
|
4
4
|
export declare const CullingStrategyContribution: Syringe.DefinedToken;
|
|
5
5
|
export interface CullingStrategyContribution {
|
|
6
|
-
isVisible(object: DisplayObject)
|
|
6
|
+
isVisible: (object: DisplayObject) => boolean;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* apply following rules:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RenderingService, RenderingPlugin } from '../services/RenderingService';
|
|
1
|
+
import type { RenderingService, RenderingPlugin } from '../services/RenderingService';
|
|
2
2
|
/**
|
|
3
3
|
* Filter dirty renderables and calculate the "dirty rectangle" which will be clear when frame began
|
|
4
4
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { RenderingPlugin
|
|
1
|
+
import type { RenderingPlugin } from '../services';
|
|
2
|
+
import { RenderingService } from '../services';
|
|
2
3
|
/**
|
|
3
4
|
* support mouse & touch events
|
|
4
5
|
* @see https://github.com/pixijs/pixi.js/blob/dev/packages/interaction/README.md
|