@antv/g 5.0.2 → 5.0.3
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 +5 -4
- package/es/display-objects/CustomElement.d.ts +10 -11
- package/es/display-objects/CustomElement.js +20 -10
- package/es/dom/Document.d.ts +1 -1
- package/es/dom/Element.d.ts +9 -9
- package/es/dom/Node.d.ts +11 -11
- package/es/dom/interfaces.d.ts +9 -9
- package/lib/Canvas.d.ts +5 -4
- package/lib/display-objects/CustomElement.d.ts +10 -11
- package/lib/display-objects/CustomElement.js +20 -10
- package/lib/dom/Document.d.ts +1 -1
- package/lib/dom/Element.d.ts +9 -9
- package/lib/dom/Node.d.ts +11 -11
- package/lib/dom/interfaces.d.ts +9 -9
- package/package.json +3 -3
package/es/Canvas.d.ts
CHANGED
|
@@ -7,8 +7,9 @@ import { EventService } from './services/EventService';
|
|
|
7
7
|
import { Camera } from './camera';
|
|
8
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",
|
|
@@ -68,9 +69,9 @@ export declare class Canvas extends EventTarget implements ICanvas {
|
|
|
68
69
|
*/
|
|
69
70
|
changeSize(width: number, height: number): void;
|
|
70
71
|
resize(width: number, height: number): void;
|
|
71
|
-
appendChild<T extends
|
|
72
|
-
insertBefore<T extends
|
|
73
|
-
removeChild<T extends
|
|
72
|
+
appendChild<T extends IChildNode>(child: T, index?: number): T;
|
|
73
|
+
insertBefore<T extends IChildNode, N extends IChildNode>(newChild: T, refChild: N | null): T;
|
|
74
|
+
removeChild<T extends IChildNode>(child: T, destroy?: boolean): T;
|
|
74
75
|
removeChildren(destroy?: boolean): void;
|
|
75
76
|
render(): void;
|
|
76
77
|
private run;
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import { DisplayObject } from './DisplayObject';
|
|
2
2
|
import type { DisplayObjectConfig } from '../dom/interfaces';
|
|
3
|
-
export interface CustomElement<CustomElementStyleProps> {
|
|
4
|
-
/**
|
|
5
|
-
* fired after element insert into DOM tree
|
|
6
|
-
*/
|
|
7
|
-
connectedCallback?: () => void;
|
|
8
|
-
/**
|
|
9
|
-
* fired before element removed from DOM tree
|
|
10
|
-
*/
|
|
11
|
-
disconnectedCallback?: () => void;
|
|
12
|
-
attributeChangedCallback?: <Key extends keyof CustomElementStyleProps>(name: Key, oldValue: CustomElementStyleProps[Key], newValue: CustomElementStyleProps[Key]) => void;
|
|
13
|
-
}
|
|
14
3
|
/**
|
|
15
4
|
* shadow root
|
|
16
5
|
* @see https://yuque.antfin-inc.com/antv/czqvg5/pgqipg
|
|
17
6
|
*/
|
|
18
7
|
export declare abstract class CustomElement<CustomElementStyleProps> extends DisplayObject<CustomElementStyleProps> {
|
|
19
8
|
constructor(config: DisplayObjectConfig<CustomElementStyleProps>);
|
|
9
|
+
/**
|
|
10
|
+
* fired after element insert into DOM tree
|
|
11
|
+
*/
|
|
12
|
+
connectedCallback?(): void;
|
|
13
|
+
/**
|
|
14
|
+
* fired before element removed from DOM tree
|
|
15
|
+
*/
|
|
16
|
+
disconnectedCallback?(): void;
|
|
17
|
+
attributeChangedCallback?<Key extends keyof CustomElementStyleProps>(name: Key, oldValue: CustomElementStyleProps[Key], newValue: CustomElementStyleProps[Key]): void;
|
|
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) => {
|
|
@@ -63,11 +73,11 @@ function (_super) {
|
|
|
63
73
|
}
|
|
64
74
|
|
|
65
75
|
if (_this.connectedCallback) {
|
|
66
|
-
_this.addEventListener(ElementEvent.
|
|
76
|
+
_this.addEventListener(ElementEvent.MOUNTED, _this.handleMounted);
|
|
67
77
|
}
|
|
68
78
|
|
|
69
79
|
if (_this.disconnectedCallback) {
|
|
70
|
-
_this.addEventListener(ElementEvent.
|
|
80
|
+
_this.addEventListener(ElementEvent.UNMOUNTED, _this.handleUnmounted);
|
|
71
81
|
}
|
|
72
82
|
|
|
73
83
|
return _this;
|
package/es/dom/Document.d.ts
CHANGED
|
@@ -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/Element.d.ts
CHANGED
|
@@ -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 IChildNode, R extends IChildNode>(newChild: T, refChild: R | null): T;
|
|
55
|
+
replaceChild<N extends IChildNode, T extends IChildNode>(newChild: N, oldChild: T, destroy?: boolean): T;
|
|
56
|
+
removeChild<T extends IChildNode>(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: IChildNode[]): 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: IChildNode[]): 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: IChildNode[]): 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: IChildNode[]): 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: IChildNode[]): 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: IChildNode[]): void;
|
|
97
97
|
/**
|
|
98
98
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/remove
|
|
99
99
|
*/
|
package/es/dom/Node.d.ts
CHANGED
|
@@ -70,37 +70,37 @@ 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
|
*/
|
|
84
|
-
abstract appendChild<T extends
|
|
84
|
+
abstract appendChild<T extends IChildNode>(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 IChildNode, R extends IChildNode>(newChild: T, refChild: R | 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 IChildNode>(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<N extends IChildNode, T extends IChildNode>(newChild: N, 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 IChildNode>(other: T | null): boolean;
|
|
103
|
+
contains<T extends IChildNode>(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
|
@@ -95,11 +95,11 @@ export interface INode extends IEventTarget {
|
|
|
95
95
|
*/
|
|
96
96
|
readonly previousSibling: (IChildNode & INode) | null;
|
|
97
97
|
textContent: string | null;
|
|
98
|
-
appendChild: <T extends
|
|
98
|
+
appendChild: <T extends IChildNode>(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) => this;
|
|
103
103
|
/**
|
|
104
104
|
* Returns a bitmask indicating the position of other relative to node.
|
|
105
105
|
*/
|
|
@@ -107,7 +107,7 @@ export interface INode extends IEventTarget {
|
|
|
107
107
|
/**
|
|
108
108
|
* Returns true if other is an inclusive descendant of node, and false otherwise.
|
|
109
109
|
*/
|
|
110
|
-
contains: (other:
|
|
110
|
+
contains: <T extends IChildNode>(other: T | null) => boolean;
|
|
111
111
|
/**
|
|
112
112
|
* Returns node's root.
|
|
113
113
|
*/
|
|
@@ -124,7 +124,7 @@ export interface INode extends IEventTarget {
|
|
|
124
124
|
* Returns whether node has children.
|
|
125
125
|
*/
|
|
126
126
|
hasChildNodes: () => boolean;
|
|
127
|
-
insertBefore: <T extends
|
|
127
|
+
insertBefore: <T extends IChildNode, R extends IChildNode>(newChild: T, refChild: R | null) => T;
|
|
128
128
|
isDefaultNamespace: (namespace: string | null) => boolean;
|
|
129
129
|
/**
|
|
130
130
|
* Returns whether node and otherNode have the same properties.
|
|
@@ -137,8 +137,8 @@ export interface INode extends IEventTarget {
|
|
|
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
139
|
normalize: () => void;
|
|
140
|
-
removeChild: <T extends
|
|
141
|
-
replaceChild: <T extends
|
|
140
|
+
removeChild: <T extends IChildNode>(oldChild: T, destroy?: boolean) => T;
|
|
141
|
+
replaceChild: <T extends IChildNode, R extends IChildNode>(newChild: R, oldChild: T, destroy?: boolean) => T;
|
|
142
142
|
/**
|
|
143
143
|
* Destroy itself.
|
|
144
144
|
*/
|
|
@@ -193,13 +193,13 @@ 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:
|
|
196
|
+
after: (...nodes: IChildNode[]) => 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:
|
|
202
|
+
before: (...nodes: IChildNode[]) => void;
|
|
203
203
|
/**
|
|
204
204
|
* Removes node.
|
|
205
205
|
*/
|
|
@@ -209,7 +209,7 @@ export interface IChildNode extends INode {
|
|
|
209
209
|
*
|
|
210
210
|
* Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated.
|
|
211
211
|
*/
|
|
212
|
-
replaceWith: (...nodes:
|
|
212
|
+
replaceWith: (...nodes: IChildNode[]) => void;
|
|
213
213
|
}
|
|
214
214
|
export interface DisplayObjectConfig<StyleProps> {
|
|
215
215
|
/**
|
package/lib/Canvas.d.ts
CHANGED
|
@@ -7,8 +7,9 @@ import { EventService } from './services/EventService';
|
|
|
7
7
|
import { Camera } from './camera';
|
|
8
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",
|
|
@@ -68,9 +69,9 @@ export declare class Canvas extends EventTarget implements ICanvas {
|
|
|
68
69
|
*/
|
|
69
70
|
changeSize(width: number, height: number): void;
|
|
70
71
|
resize(width: number, height: number): void;
|
|
71
|
-
appendChild<T extends
|
|
72
|
-
insertBefore<T extends
|
|
73
|
-
removeChild<T extends
|
|
72
|
+
appendChild<T extends IChildNode>(child: T, index?: number): T;
|
|
73
|
+
insertBefore<T extends IChildNode, N extends IChildNode>(newChild: T, refChild: N | null): T;
|
|
74
|
+
removeChild<T extends IChildNode>(child: T, destroy?: boolean): T;
|
|
74
75
|
removeChildren(destroy?: boolean): void;
|
|
75
76
|
render(): void;
|
|
76
77
|
private run;
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import { DisplayObject } from './DisplayObject';
|
|
2
2
|
import type { DisplayObjectConfig } from '../dom/interfaces';
|
|
3
|
-
export interface CustomElement<CustomElementStyleProps> {
|
|
4
|
-
/**
|
|
5
|
-
* fired after element insert into DOM tree
|
|
6
|
-
*/
|
|
7
|
-
connectedCallback?: () => void;
|
|
8
|
-
/**
|
|
9
|
-
* fired before element removed from DOM tree
|
|
10
|
-
*/
|
|
11
|
-
disconnectedCallback?: () => void;
|
|
12
|
-
attributeChangedCallback?: <Key extends keyof CustomElementStyleProps>(name: Key, oldValue: CustomElementStyleProps[Key], newValue: CustomElementStyleProps[Key]) => void;
|
|
13
|
-
}
|
|
14
3
|
/**
|
|
15
4
|
* shadow root
|
|
16
5
|
* @see https://yuque.antfin-inc.com/antv/czqvg5/pgqipg
|
|
17
6
|
*/
|
|
18
7
|
export declare abstract class CustomElement<CustomElementStyleProps> extends DisplayObject<CustomElementStyleProps> {
|
|
19
8
|
constructor(config: DisplayObjectConfig<CustomElementStyleProps>);
|
|
9
|
+
/**
|
|
10
|
+
* fired after element insert into DOM tree
|
|
11
|
+
*/
|
|
12
|
+
connectedCallback?(): void;
|
|
13
|
+
/**
|
|
14
|
+
* fired before element removed from DOM tree
|
|
15
|
+
*/
|
|
16
|
+
disconnectedCallback?(): void;
|
|
17
|
+
attributeChangedCallback?<Key extends keyof CustomElementStyleProps>(name: Key, oldValue: CustomElementStyleProps[Key], newValue: CustomElementStyleProps[Key]): void;
|
|
20
18
|
private handleMounted;
|
|
19
|
+
private handleUnmounted;
|
|
21
20
|
private handleAttributeChanged;
|
|
22
21
|
}
|
|
@@ -23,14 +23,24 @@ function (_super) {
|
|
|
23
23
|
function CustomElement(config) {
|
|
24
24
|
var _this = _super.call(this, config) || this;
|
|
25
25
|
|
|
26
|
-
_this.handleMounted = function () {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
_this.connectedCallback
|
|
26
|
+
_this.handleMounted = function (e) {
|
|
27
|
+
if (e.target === e.currentTarget) {
|
|
28
|
+
// this.shadowNodes.forEach((node) => {
|
|
29
|
+
// // every child and its children should turn into a shadow node
|
|
30
|
+
// // a shadow node doesn't mean to be unrenderable, it's just unsearchable in scenegraph
|
|
31
|
+
// node.shadow = true;
|
|
32
|
+
// });
|
|
33
|
+
if (_this.connectedCallback) {
|
|
34
|
+
_this.connectedCallback();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
_this.handleUnmounted = function (e) {
|
|
40
|
+
if (e.target === e.currentTarget) {
|
|
41
|
+
if (_this.disconnectedCallback) {
|
|
42
|
+
_this.disconnectedCallback();
|
|
43
|
+
}
|
|
34
44
|
}
|
|
35
45
|
}; // private handleChildInserted = (e: FederatedEvent) => {
|
|
36
46
|
// (e.target as DisplayObject).forEach((node) => {
|
|
@@ -71,11 +81,11 @@ function (_super) {
|
|
|
71
81
|
}
|
|
72
82
|
|
|
73
83
|
if (_this.connectedCallback) {
|
|
74
|
-
_this.addEventListener(_interfaces.ElementEvent.
|
|
84
|
+
_this.addEventListener(_interfaces.ElementEvent.MOUNTED, _this.handleMounted);
|
|
75
85
|
}
|
|
76
86
|
|
|
77
87
|
if (_this.disconnectedCallback) {
|
|
78
|
-
_this.addEventListener(_interfaces.ElementEvent.
|
|
88
|
+
_this.addEventListener(_interfaces.ElementEvent.UNMOUNTED, _this.handleUnmounted);
|
|
79
89
|
}
|
|
80
90
|
|
|
81
91
|
return _this;
|
package/lib/dom/Document.d.ts
CHANGED
|
@@ -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/lib/dom/Element.d.ts
CHANGED
|
@@ -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 IChildNode, R extends IChildNode>(newChild: T, refChild: R | null): T;
|
|
55
|
+
replaceChild<N extends IChildNode, T extends IChildNode>(newChild: N, oldChild: T, destroy?: boolean): T;
|
|
56
|
+
removeChild<T extends IChildNode>(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: IChildNode[]): 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: IChildNode[]): 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: IChildNode[]): 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: IChildNode[]): 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: IChildNode[]): 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: IChildNode[]): void;
|
|
97
97
|
/**
|
|
98
98
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/remove
|
|
99
99
|
*/
|
package/lib/dom/Node.d.ts
CHANGED
|
@@ -70,37 +70,37 @@ 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
|
*/
|
|
84
|
-
abstract appendChild<T extends
|
|
84
|
+
abstract appendChild<T extends IChildNode>(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 IChildNode, R extends IChildNode>(newChild: T, refChild: R | 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 IChildNode>(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<N extends IChildNode, T extends IChildNode>(newChild: N, 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 IChildNode>(other: T | null): boolean;
|
|
103
|
+
contains<T extends IChildNode>(other: T | null): boolean;
|
|
104
104
|
getAncestor(n: number): INode | null;
|
|
105
105
|
forEach(callback: (o: INode) => void | boolean): void;
|
|
106
106
|
}
|
package/lib/dom/interfaces.d.ts
CHANGED
|
@@ -95,11 +95,11 @@ export interface INode extends IEventTarget {
|
|
|
95
95
|
*/
|
|
96
96
|
readonly previousSibling: (IChildNode & INode) | null;
|
|
97
97
|
textContent: string | null;
|
|
98
|
-
appendChild: <T extends
|
|
98
|
+
appendChild: <T extends IChildNode>(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) => this;
|
|
103
103
|
/**
|
|
104
104
|
* Returns a bitmask indicating the position of other relative to node.
|
|
105
105
|
*/
|
|
@@ -107,7 +107,7 @@ export interface INode extends IEventTarget {
|
|
|
107
107
|
/**
|
|
108
108
|
* Returns true if other is an inclusive descendant of node, and false otherwise.
|
|
109
109
|
*/
|
|
110
|
-
contains: (other:
|
|
110
|
+
contains: <T extends IChildNode>(other: T | null) => boolean;
|
|
111
111
|
/**
|
|
112
112
|
* Returns node's root.
|
|
113
113
|
*/
|
|
@@ -124,7 +124,7 @@ export interface INode extends IEventTarget {
|
|
|
124
124
|
* Returns whether node has children.
|
|
125
125
|
*/
|
|
126
126
|
hasChildNodes: () => boolean;
|
|
127
|
-
insertBefore: <T extends
|
|
127
|
+
insertBefore: <T extends IChildNode, R extends IChildNode>(newChild: T, refChild: R | null) => T;
|
|
128
128
|
isDefaultNamespace: (namespace: string | null) => boolean;
|
|
129
129
|
/**
|
|
130
130
|
* Returns whether node and otherNode have the same properties.
|
|
@@ -137,8 +137,8 @@ export interface INode extends IEventTarget {
|
|
|
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
139
|
normalize: () => void;
|
|
140
|
-
removeChild: <T extends
|
|
141
|
-
replaceChild: <T extends
|
|
140
|
+
removeChild: <T extends IChildNode>(oldChild: T, destroy?: boolean) => T;
|
|
141
|
+
replaceChild: <T extends IChildNode, R extends IChildNode>(newChild: R, oldChild: T, destroy?: boolean) => T;
|
|
142
142
|
/**
|
|
143
143
|
* Destroy itself.
|
|
144
144
|
*/
|
|
@@ -193,13 +193,13 @@ 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:
|
|
196
|
+
after: (...nodes: IChildNode[]) => 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:
|
|
202
|
+
before: (...nodes: IChildNode[]) => void;
|
|
203
203
|
/**
|
|
204
204
|
* Removes node.
|
|
205
205
|
*/
|
|
@@ -209,7 +209,7 @@ export interface IChildNode extends INode {
|
|
|
209
209
|
*
|
|
210
210
|
* Throws a "HierarchyRequestError" DOMException if the constraints of the node tree are violated.
|
|
211
211
|
*/
|
|
212
|
-
replaceWith: (...nodes:
|
|
212
|
+
replaceWith: (...nodes: IChildNode[]) => void;
|
|
213
213
|
}
|
|
214
214
|
export interface DisplayObjectConfig<StyleProps> {
|
|
215
215
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/g",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.3",
|
|
4
4
|
"description": "A core module including ECS and DI container.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://github.com/antvis/g#readme",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@antv/g-math": "^1.0.
|
|
40
|
+
"@antv/g-math": "^1.0.3",
|
|
41
41
|
"@antv/path-util": "^2.0.14",
|
|
42
42
|
"@antv/util": "^2.0.13",
|
|
43
43
|
"d3-color": "^1.4.0",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"scripts": {
|
|
51
51
|
"umd": "webpack"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "22662f42c5860f4a022dd5fcb33ba926f93f8b5c"
|
|
54
54
|
}
|