@antv/g 5.0.15 → 5.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.umd.min.js +18 -2
- package/es/Canvas.d.ts +3 -0
- package/es/Canvas.js +8 -9
- package/es/camera/Camera.d.ts +3 -2
- package/es/camera/Camera.js +16 -8
- package/es/canvas-module.js +4 -2
- package/es/components/Transform.d.ts +0 -1
- package/es/components/Transform.js +0 -1
- package/es/display-objects/Circle.d.ts +1 -1
- package/es/display-objects/Circle.js +8 -3
- package/es/display-objects/CustomElement.d.ts +3 -2
- package/es/display-objects/CustomElement.js +9 -6
- package/es/display-objects/DisplayObject.d.ts +4 -3
- package/es/display-objects/DisplayObject.js +77 -50
- package/es/display-objects/Ellipse.d.ts +1 -1
- package/es/display-objects/Ellipse.js +8 -3
- package/es/display-objects/Group.d.ts +18 -2
- package/es/display-objects/Group.js +11 -9
- package/es/display-objects/HTML.d.ts +1 -1
- package/es/display-objects/HTML.js +9 -4
- package/es/display-objects/Image.d.ts +5 -3
- package/es/display-objects/Image.js +8 -3
- package/es/display-objects/Line.d.ts +1 -1
- package/es/display-objects/Line.js +12 -4
- package/es/display-objects/Path.d.ts +3 -2
- package/es/display-objects/Path.js +10 -5
- package/es/display-objects/Polygon.d.ts +1 -1
- package/es/display-objects/Polygon.js +9 -3
- package/es/display-objects/Polyline.d.ts +1 -1
- package/es/display-objects/Polyline.js +10 -5
- package/es/display-objects/Rect.d.ts +1 -1
- package/es/display-objects/Rect.js +8 -3
- package/es/display-objects/Text.d.ts +9 -4
- package/es/display-objects/Text.js +14 -9
- package/es/dom/Animation.js +1 -1
- package/es/dom/AnimationTimeline.js +1 -2
- package/es/dom/CustomElementRegistry.js +12 -12
- package/es/dom/Document.d.ts +1 -0
- package/es/dom/Document.js +21 -1
- package/es/dom/Element.d.ts +10 -5
- package/es/dom/Element.js +41 -15
- package/es/dom/EventTarget.d.ts +2 -2
- package/es/dom/EventTarget.js +4 -3
- package/es/dom/KeyframeList.js +1 -1
- package/es/dom/MutationEvent.d.ts +15 -0
- package/es/dom/MutationEvent.js +29 -0
- package/es/dom/MutationObserver.d.ts +36 -0
- package/es/dom/MutationObserver.js +413 -0
- package/es/dom/MutationRecord.d.ts +14 -0
- package/es/dom/MutationRecord.js +31 -0
- package/es/dom/Node.d.ts +35 -3
- package/es/dom/Node.js +184 -17
- package/es/dom/index.d.ts +3 -0
- package/es/dom/index.js +3 -0
- package/es/dom/interfaces.d.ts +36 -8
- package/es/dom/interfaces.js +23 -5
- package/es/global-module.d.ts +1 -0
- package/es/global-module.js +11 -13
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/plugins/CullingPlugin.d.ts +0 -2
- package/es/plugins/CullingPlugin.js +3 -24
- package/es/plugins/DirtyCheckPlugin.js +2 -2
- package/es/plugins/FrustumCullingStrategy.d.ts +1 -0
- package/es/plugins/FrustumCullingStrategy.js +40 -33
- package/es/plugins/PrepareRendererPlugin.js +21 -5
- package/es/property-handlers/aabb.js +19 -20
- package/es/property-handlers/color.js +5 -2
- package/es/property-handlers/dimension.d.ts +15 -3
- package/es/property-handlers/dimension.js +50 -9
- package/es/property-handlers/index.d.ts +3 -0
- package/es/property-handlers/index.js +4 -1
- package/es/property-handlers/inherit.d.ts +6 -0
- package/es/property-handlers/inherit.js +25 -0
- package/es/property-handlers/interfaces.d.ts +2 -2
- package/es/property-handlers/lineDash.d.ts +6 -1
- package/es/property-handlers/lineDash.js +23 -4
- package/es/property-handlers/offsetDistance.js +2 -2
- package/es/property-handlers/text.d.ts +2 -0
- package/es/property-handlers/text.js +3 -0
- package/es/property-handlers/textTransform.d.ts +6 -0
- package/es/property-handlers/textTransform.js +19 -0
- package/es/services/EventService.js +3 -5
- package/es/services/RenderingContext.d.ts +5 -8
- package/es/services/RenderingContext.js +6 -7
- package/es/services/RenderingService.js +2 -8
- package/es/services/SceneGraphSelector.d.ts +3 -2
- package/es/services/SceneGraphSelector.js +8 -4
- package/es/services/SceneGraphService.d.ts +0 -7
- package/es/services/SceneGraphService.js +9 -77
- package/es/services/aabb/CircleUpdater.js +3 -3
- package/es/services/aabb/EllipseUpdater.js +2 -2
- package/es/services/aabb/LineUpdater.js +2 -2
- package/es/services/aabb/PathUpdater.js +2 -2
- package/es/services/aabb/PolylineUpdater.js +3 -3
- package/es/services/aabb/RectUpdater.js +4 -4
- package/es/services/aabb/TextUpdater.js +19 -10
- package/es/services/text/index.js +19 -21
- package/es/types.d.ts +48 -24
- package/es/types.js +50 -31
- package/es/utils/custom-easing.js +1 -1
- package/es/utils/event.js +5 -3
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.js +2 -1
- package/es/utils/interpolation.d.ts +1 -0
- package/es/utils/interpolation.js +41 -8
- package/es/utils/path.js +11 -11
- package/es/utils/raf.d.ts +1 -1
- package/es/utils/raf.js +0 -2
- package/es/utils/string.d.ts +1 -0
- package/es/utils/string.js +9 -0
- package/es/utils/text.js +3 -3
- package/lib/Canvas.d.ts +3 -0
- package/lib/Canvas.js +6 -7
- package/lib/camera/Camera.d.ts +3 -2
- package/lib/camera/Camera.js +20 -10
- package/lib/canvas-module.js +3 -1
- package/lib/components/Transform.d.ts +0 -1
- package/lib/components/Transform.js +0 -1
- package/lib/display-objects/Circle.d.ts +1 -1
- package/lib/display-objects/Circle.js +7 -2
- package/lib/display-objects/CustomElement.d.ts +3 -2
- package/lib/display-objects/CustomElement.js +9 -6
- package/lib/display-objects/DisplayObject.d.ts +4 -3
- package/lib/display-objects/DisplayObject.js +76 -47
- package/lib/display-objects/Ellipse.d.ts +1 -1
- package/lib/display-objects/Ellipse.js +7 -2
- package/lib/display-objects/Group.d.ts +18 -2
- package/lib/display-objects/Group.js +10 -9
- package/lib/display-objects/HTML.d.ts +1 -1
- package/lib/display-objects/HTML.js +8 -4
- package/lib/display-objects/Image.d.ts +5 -3
- package/lib/display-objects/Image.js +7 -2
- package/lib/display-objects/Line.d.ts +1 -1
- package/lib/display-objects/Line.js +11 -3
- package/lib/display-objects/Path.d.ts +3 -2
- package/lib/display-objects/Path.js +9 -4
- package/lib/display-objects/Polygon.d.ts +1 -1
- package/lib/display-objects/Polygon.js +8 -2
- package/lib/display-objects/Polyline.d.ts +1 -1
- package/lib/display-objects/Polyline.js +9 -4
- package/lib/display-objects/Rect.d.ts +1 -1
- package/lib/display-objects/Rect.js +7 -2
- package/lib/display-objects/Text.d.ts +9 -4
- package/lib/display-objects/Text.js +13 -8
- package/lib/dom/Animation.js +1 -1
- package/lib/dom/AnimationTimeline.js +1 -2
- package/lib/dom/CustomElementRegistry.js +11 -11
- package/lib/dom/Document.d.ts +1 -0
- package/lib/dom/Document.js +22 -1
- package/lib/dom/Element.d.ts +10 -5
- package/lib/dom/Element.js +43 -15
- package/lib/dom/EventTarget.d.ts +2 -2
- package/lib/dom/EventTarget.js +4 -3
- package/lib/dom/KeyframeList.js +1 -1
- package/lib/dom/MutationEvent.d.ts +15 -0
- package/lib/dom/MutationEvent.js +37 -0
- package/lib/dom/MutationObserver.d.ts +36 -0
- package/lib/dom/MutationObserver.js +424 -0
- package/lib/dom/MutationRecord.d.ts +14 -0
- package/lib/dom/MutationRecord.js +38 -0
- package/lib/dom/Node.d.ts +35 -3
- package/lib/dom/Node.js +185 -16
- package/lib/dom/index.d.ts +3 -0
- package/lib/dom/index.js +39 -0
- package/lib/dom/interfaces.d.ts +36 -8
- package/lib/dom/interfaces.js +23 -5
- package/lib/global-module.d.ts +1 -0
- package/lib/global-module.js +12 -8
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -1
- package/lib/plugins/CullingPlugin.d.ts +0 -2
- package/lib/plugins/CullingPlugin.js +2 -23
- package/lib/plugins/DirtyCheckPlugin.js +1 -1
- package/lib/plugins/FrustumCullingStrategy.d.ts +1 -0
- package/lib/plugins/FrustumCullingStrategy.js +41 -33
- package/lib/plugins/PrepareRendererPlugin.js +24 -4
- package/lib/property-handlers/aabb.js +18 -19
- package/lib/property-handlers/color.js +6 -3
- package/lib/property-handlers/dimension.d.ts +15 -3
- package/lib/property-handlers/dimension.js +50 -8
- package/lib/property-handlers/index.d.ts +3 -0
- package/lib/property-handlers/index.js +39 -0
- package/lib/property-handlers/inherit.d.ts +6 -0
- package/lib/property-handlers/inherit.js +34 -0
- package/lib/property-handlers/interfaces.d.ts +2 -2
- package/lib/property-handlers/lineDash.d.ts +6 -1
- package/lib/property-handlers/lineDash.js +25 -4
- package/lib/property-handlers/offsetDistance.js +1 -1
- package/lib/property-handlers/text.d.ts +2 -0
- package/lib/property-handlers/text.js +10 -0
- package/lib/property-handlers/textTransform.d.ts +6 -0
- package/lib/property-handlers/textTransform.js +27 -0
- package/lib/services/EventService.js +3 -5
- package/lib/services/RenderingContext.d.ts +5 -8
- package/lib/services/RenderingContext.js +8 -9
- package/lib/services/RenderingService.js +1 -7
- package/lib/services/SceneGraphSelector.d.ts +3 -2
- package/lib/services/SceneGraphSelector.js +10 -3
- package/lib/services/SceneGraphService.d.ts +0 -7
- package/lib/services/SceneGraphService.js +10 -77
- package/lib/services/aabb/CircleUpdater.js +2 -2
- package/lib/services/aabb/EllipseUpdater.js +1 -1
- package/lib/services/aabb/LineUpdater.js +1 -1
- package/lib/services/aabb/PathUpdater.js +1 -1
- package/lib/services/aabb/PolylineUpdater.js +2 -2
- package/lib/services/aabb/RectUpdater.js +3 -3
- package/lib/services/aabb/TextUpdater.js +18 -9
- package/lib/services/text/index.js +19 -21
- package/lib/types.d.ts +48 -24
- package/lib/types.js +56 -35
- package/lib/utils/custom-easing.js +1 -1
- package/lib/utils/event.js +5 -3
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +13 -0
- package/lib/utils/interpolation.d.ts +1 -0
- package/lib/utils/interpolation.js +43 -7
- package/lib/utils/path.js +10 -10
- package/lib/utils/raf.d.ts +1 -1
- package/lib/utils/raf.js +0 -2
- package/lib/utils/string.d.ts +1 -0
- package/lib/utils/string.js +16 -0
- package/lib/utils/text.js +3 -3
- package/package.json +5 -3
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var MutationRecord =
|
|
2
|
+
/** @class */
|
|
3
|
+
function () {
|
|
4
|
+
function MutationRecord(type, target) {
|
|
5
|
+
this.type = type;
|
|
6
|
+
this.target = target;
|
|
7
|
+
this.addedNodes = [];
|
|
8
|
+
this.attributeName = null;
|
|
9
|
+
this.attributeNamespace = null;
|
|
10
|
+
this.nextSibling = null;
|
|
11
|
+
this.oldValue = null;
|
|
12
|
+
this.previousSibling = null;
|
|
13
|
+
this.removedNodes = [];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
MutationRecord.copy = function (original) {
|
|
17
|
+
var record = new MutationRecord(original.type, original.target);
|
|
18
|
+
record.addedNodes = original.addedNodes.slice();
|
|
19
|
+
record.removedNodes = original.removedNodes.slice();
|
|
20
|
+
record.previousSibling = original.previousSibling;
|
|
21
|
+
record.nextSibling = original.nextSibling;
|
|
22
|
+
record.attributeName = original.attributeName;
|
|
23
|
+
record.attributeNamespace = original.attributeNamespace;
|
|
24
|
+
record.oldValue = original.oldValue;
|
|
25
|
+
return record;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return MutationRecord;
|
|
29
|
+
}();
|
|
30
|
+
|
|
31
|
+
export { MutationRecord };
|
package/es/dom/Node.d.ts
CHANGED
|
@@ -4,6 +4,31 @@ import type { IEventTarget, IElement, INode, IChildNode, IParentNode, IDocument
|
|
|
4
4
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Node
|
|
5
5
|
*/
|
|
6
6
|
export declare abstract class Node extends EventTarget implements INode {
|
|
7
|
+
/**
|
|
8
|
+
* Both nodes are in different documents or different trees in the same document.
|
|
9
|
+
*/
|
|
10
|
+
static DOCUMENT_POSITION_DISCONNECTED: number;
|
|
11
|
+
/**
|
|
12
|
+
* otherNode precedes the node in either a pre-order depth-first traversal
|
|
13
|
+
* of a tree containing both (e.g., as an ancestor or previous sibling or a descendant of a previous sibling or previous sibling of an ancestor) or (if they are disconnected) in an arbitrary but consistent ordering.
|
|
14
|
+
*/
|
|
15
|
+
static DOCUMENT_POSITION_PRECEDING: number;
|
|
16
|
+
/**
|
|
17
|
+
* otherNode follows the node in either a pre-order depth-first traversal of a tree containing both (e.g., as a descendant or following sibling or a descendant of a following sibling or following sibling of an ancestor) or (if they are disconnected) in an arbitrary but consistent ordering.
|
|
18
|
+
*/
|
|
19
|
+
static DOCUMENT_POSITION_FOLLOWING: number;
|
|
20
|
+
/**
|
|
21
|
+
* otherNode is an ancestor of the node.
|
|
22
|
+
*/
|
|
23
|
+
static DOCUMENT_POSITION_CONTAINS: number;
|
|
24
|
+
/**
|
|
25
|
+
* otherNode is a descendant of the node.
|
|
26
|
+
*/
|
|
27
|
+
static DOCUMENT_POSITION_CONTAINED_BY: number;
|
|
28
|
+
/**
|
|
29
|
+
* The result relies upon arbitrary and/or implementation-specific behavior and is not guaranteed to be portable.
|
|
30
|
+
*/
|
|
31
|
+
static DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number;
|
|
7
32
|
static isNode(target: IEventTarget | INode): target is INode;
|
|
8
33
|
shadow: boolean;
|
|
9
34
|
/**
|
|
@@ -44,14 +69,16 @@ export declare abstract class Node extends EventTarget implements INode {
|
|
|
44
69
|
/**
|
|
45
70
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Node/textContent
|
|
46
71
|
*/
|
|
47
|
-
textContent: string
|
|
72
|
+
get textContent(): string;
|
|
73
|
+
set textContent(content: string);
|
|
48
74
|
/**
|
|
49
75
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Node/getRootNode
|
|
50
76
|
*/
|
|
51
|
-
getRootNode(
|
|
77
|
+
getRootNode(opts?: {
|
|
78
|
+
composed?: boolean;
|
|
79
|
+
}): INode;
|
|
52
80
|
hasChildNodes(): boolean;
|
|
53
81
|
isDefaultNamespace(namespace: string | null): boolean;
|
|
54
|
-
compareDocumentPosition(other: INode): number;
|
|
55
82
|
lookupNamespaceURI(prefix: string | null): string | null;
|
|
56
83
|
lookupPrefix(namespace: string | null): string | null;
|
|
57
84
|
normalize(): void;
|
|
@@ -74,6 +101,11 @@ export declare abstract class Node extends EventTarget implements INode {
|
|
|
74
101
|
get previousSibling(): IChildNode | null;
|
|
75
102
|
get firstChild(): IChildNode | null;
|
|
76
103
|
get lastChild(): IChildNode | null;
|
|
104
|
+
/**
|
|
105
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition
|
|
106
|
+
* @see https://github.com/b-fuze/deno-dom/blob/master/src/dom/node.ts#L338
|
|
107
|
+
*/
|
|
108
|
+
compareDocumentPosition(other: INode): number;
|
|
77
109
|
/**
|
|
78
110
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Node/cloneNode
|
|
79
111
|
*/
|
package/es/dom/Node.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { __extends } from "tslib";
|
|
1
|
+
import { __extends, __values } from "tslib";
|
|
2
|
+
import { Shape } from '..'; // import { Text } from '../display-objects/Text';
|
|
3
|
+
|
|
2
4
|
import { EventTarget } from './EventTarget';
|
|
3
5
|
/**
|
|
4
6
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Node
|
|
@@ -55,11 +57,6 @@ function (_super) {
|
|
|
55
57
|
*/
|
|
56
58
|
|
|
57
59
|
_this.nodeValue = null;
|
|
58
|
-
/**
|
|
59
|
-
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Node/textContent
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
|
-
_this.textContent = null;
|
|
63
60
|
/**
|
|
64
61
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/ParentNode
|
|
65
62
|
*/
|
|
@@ -71,20 +68,86 @@ function (_super) {
|
|
|
71
68
|
Node.isNode = function (target) {
|
|
72
69
|
return !!target.childNodes;
|
|
73
70
|
};
|
|
71
|
+
|
|
72
|
+
Object.defineProperty(Node.prototype, "textContent", {
|
|
73
|
+
/**
|
|
74
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Node/textContent
|
|
75
|
+
*/
|
|
76
|
+
get: function get() {
|
|
77
|
+
var e_1, _a;
|
|
78
|
+
|
|
79
|
+
var out = '';
|
|
80
|
+
|
|
81
|
+
if (this.nodeName === Shape.TEXT) {
|
|
82
|
+
// @ts-ignore
|
|
83
|
+
out += this.style.text;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
try {
|
|
87
|
+
for (var _b = __values(this.childNodes), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
88
|
+
var child = _c.value;
|
|
89
|
+
|
|
90
|
+
if (child.nodeName === Shape.TEXT) {
|
|
91
|
+
out += child.nodeValue;
|
|
92
|
+
} else {
|
|
93
|
+
out += child.textContent;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
} catch (e_1_1) {
|
|
97
|
+
e_1 = {
|
|
98
|
+
error: e_1_1
|
|
99
|
+
};
|
|
100
|
+
} finally {
|
|
101
|
+
try {
|
|
102
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
103
|
+
} finally {
|
|
104
|
+
if (e_1) throw e_1.error;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return out;
|
|
109
|
+
},
|
|
110
|
+
set: function set(content) {
|
|
111
|
+
var _this = this; // remove all children
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
this.childNodes.slice().forEach(function (child) {
|
|
115
|
+
_this.removeChild(child, true);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
if (this.nodeName === Shape.TEXT) {
|
|
119
|
+
// @ts-ignore
|
|
120
|
+
this.style.text = "".concat(content);
|
|
121
|
+
} else {// this.appendChild(
|
|
122
|
+
// new Text({
|
|
123
|
+
// style: {
|
|
124
|
+
// text: content,
|
|
125
|
+
// },
|
|
126
|
+
// }),
|
|
127
|
+
// );
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
enumerable: false,
|
|
131
|
+
configurable: true
|
|
132
|
+
});
|
|
74
133
|
/**
|
|
75
134
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Node/getRootNode
|
|
76
135
|
*/
|
|
77
136
|
|
|
137
|
+
Node.prototype.getRootNode = function (opts) {
|
|
138
|
+
if (opts === void 0) {
|
|
139
|
+
opts = {};
|
|
140
|
+
}
|
|
78
141
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
142
|
+
if (this.parentNode) {
|
|
143
|
+
return this.parentNode.getRootNode(opts);
|
|
144
|
+
}
|
|
82
145
|
|
|
83
|
-
|
|
84
|
-
|
|
146
|
+
if (opts.composed && this.host) {
|
|
147
|
+
return this.host.getRootNode(opts);
|
|
85
148
|
}
|
|
86
149
|
|
|
87
|
-
return
|
|
150
|
+
return this;
|
|
88
151
|
};
|
|
89
152
|
|
|
90
153
|
Node.prototype.hasChildNodes = function () {
|
|
@@ -97,11 +160,6 @@ function (_super) {
|
|
|
97
160
|
}; // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
98
161
|
|
|
99
162
|
|
|
100
|
-
Node.prototype.compareDocumentPosition = function (other) {
|
|
101
|
-
throw new Error('Method not implemented.');
|
|
102
|
-
}; // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
103
|
-
|
|
104
|
-
|
|
105
163
|
Node.prototype.lookupNamespaceURI = function (prefix) {
|
|
106
164
|
throw new Error('Method not implemented.');
|
|
107
165
|
}; // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -174,11 +232,89 @@ function (_super) {
|
|
|
174
232
|
enumerable: false,
|
|
175
233
|
configurable: true
|
|
176
234
|
});
|
|
235
|
+
/**
|
|
236
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition
|
|
237
|
+
* @see https://github.com/b-fuze/deno-dom/blob/master/src/dom/node.ts#L338
|
|
238
|
+
*/
|
|
239
|
+
|
|
240
|
+
Node.prototype.compareDocumentPosition = function (other) {
|
|
241
|
+
var _a;
|
|
242
|
+
|
|
243
|
+
if (other === this) {
|
|
244
|
+
// same node
|
|
245
|
+
return 0;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (!(other instanceof Node)) {
|
|
249
|
+
throw new TypeError('Node.compareDocumentPosition: Argument 1 does not implement interface Node.');
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
var node1Root = other; // eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
253
|
+
|
|
254
|
+
var node2Root = this;
|
|
255
|
+
var node1Hierarchy = [node1Root];
|
|
256
|
+
var node2Hierarchy = [node2Root];
|
|
257
|
+
|
|
258
|
+
while ((_a = node1Root.parentNode) !== null && _a !== void 0 ? _a : node2Root.parentNode) {
|
|
259
|
+
node1Root = node1Root.parentNode ? (node1Hierarchy.push(node1Root.parentNode), node1Root.parentNode) : node1Root;
|
|
260
|
+
node2Root = node2Root.parentNode ? (node2Hierarchy.push(node2Root.parentNode), node2Root.parentNode) : node2Root;
|
|
261
|
+
} // Check if they don't share the same root node
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
if (node1Root !== node2Root) {
|
|
265
|
+
return Node.DOCUMENT_POSITION_DISCONNECTED | Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | Node.DOCUMENT_POSITION_PRECEDING;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
var longerHierarchy = node1Hierarchy.length > node2Hierarchy.length ? node1Hierarchy : node2Hierarchy;
|
|
269
|
+
var shorterHierarchy = longerHierarchy === node1Hierarchy ? node2Hierarchy : node1Hierarchy; // Check if either is a container of the other
|
|
270
|
+
|
|
271
|
+
if (longerHierarchy[longerHierarchy.length - shorterHierarchy.length] === shorterHierarchy[0]) {
|
|
272
|
+
return longerHierarchy === node1Hierarchy ? // other is a child of this
|
|
273
|
+
Node.DOCUMENT_POSITION_CONTAINED_BY | Node.DOCUMENT_POSITION_FOLLOWING : // this is a child of other
|
|
274
|
+
Node.DOCUMENT_POSITION_CONTAINS | Node.DOCUMENT_POSITION_PRECEDING;
|
|
275
|
+
} // Find their first common ancestor and see whether they
|
|
276
|
+
// are preceding or following
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
var longerStart = longerHierarchy.length - shorterHierarchy.length;
|
|
280
|
+
|
|
281
|
+
for (var i = shorterHierarchy.length - 1; i >= 0; i--) {
|
|
282
|
+
var shorterHierarchyNode = shorterHierarchy[i];
|
|
283
|
+
var longerHierarchyNode = longerHierarchy[longerStart + i]; // We found the first common ancestor
|
|
284
|
+
|
|
285
|
+
if (longerHierarchyNode !== shorterHierarchyNode) {
|
|
286
|
+
var siblings = shorterHierarchyNode.parentNode.childNodes;
|
|
287
|
+
|
|
288
|
+
if (siblings.indexOf(shorterHierarchyNode) < siblings.indexOf(longerHierarchyNode)) {
|
|
289
|
+
// Shorter is before longer
|
|
290
|
+
if (shorterHierarchy === node1Hierarchy) {
|
|
291
|
+
// Other is before this
|
|
292
|
+
return Node.DOCUMENT_POSITION_PRECEDING;
|
|
293
|
+
} else {
|
|
294
|
+
// This is before other
|
|
295
|
+
return Node.DOCUMENT_POSITION_FOLLOWING;
|
|
296
|
+
}
|
|
297
|
+
} else {
|
|
298
|
+
// Longer is before shorter
|
|
299
|
+
if (longerHierarchy === node1Hierarchy) {
|
|
300
|
+
// Other is before this
|
|
301
|
+
return Node.DOCUMENT_POSITION_PRECEDING;
|
|
302
|
+
} else {
|
|
303
|
+
// Other is after this
|
|
304
|
+
return Node.DOCUMENT_POSITION_FOLLOWING;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
return Node.DOCUMENT_POSITION_FOLLOWING;
|
|
311
|
+
};
|
|
177
312
|
/**
|
|
178
313
|
* @deprecated
|
|
179
314
|
* @alias contains
|
|
180
315
|
*/
|
|
181
316
|
|
|
317
|
+
|
|
182
318
|
Node.prototype.contain = function (other) {
|
|
183
319
|
return this.contains(other);
|
|
184
320
|
};
|
|
@@ -213,7 +349,38 @@ function (_super) {
|
|
|
213
349
|
});
|
|
214
350
|
}
|
|
215
351
|
};
|
|
352
|
+
/**
|
|
353
|
+
* Both nodes are in different documents or different trees in the same document.
|
|
354
|
+
*/
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
Node.DOCUMENT_POSITION_DISCONNECTED = 1;
|
|
358
|
+
/**
|
|
359
|
+
* otherNode precedes the node in either a pre-order depth-first traversal
|
|
360
|
+
* of a tree containing both (e.g., as an ancestor or previous sibling or a descendant of a previous sibling or previous sibling of an ancestor) or (if they are disconnected) in an arbitrary but consistent ordering.
|
|
361
|
+
*/
|
|
362
|
+
|
|
363
|
+
Node.DOCUMENT_POSITION_PRECEDING = 2;
|
|
364
|
+
/**
|
|
365
|
+
* otherNode follows the node in either a pre-order depth-first traversal of a tree containing both (e.g., as a descendant or following sibling or a descendant of a following sibling or following sibling of an ancestor) or (if they are disconnected) in an arbitrary but consistent ordering.
|
|
366
|
+
*/
|
|
367
|
+
|
|
368
|
+
Node.DOCUMENT_POSITION_FOLLOWING = 4;
|
|
369
|
+
/**
|
|
370
|
+
* otherNode is an ancestor of the node.
|
|
371
|
+
*/
|
|
372
|
+
|
|
373
|
+
Node.DOCUMENT_POSITION_CONTAINS = 8;
|
|
374
|
+
/**
|
|
375
|
+
* otherNode is a descendant of the node.
|
|
376
|
+
*/
|
|
377
|
+
|
|
378
|
+
Node.DOCUMENT_POSITION_CONTAINED_BY = 16;
|
|
379
|
+
/**
|
|
380
|
+
* The result relies upon arbitrary and/or implementation-specific behavior and is not guaranteed to be portable.
|
|
381
|
+
*/
|
|
216
382
|
|
|
383
|
+
Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 32;
|
|
217
384
|
return Node;
|
|
218
385
|
}(EventTarget);
|
|
219
386
|
|
package/es/dom/index.d.ts
CHANGED
|
@@ -11,6 +11,9 @@ export * from './Animation';
|
|
|
11
11
|
export * from './AnimationEvent';
|
|
12
12
|
export * from './AnimationEffectTiming';
|
|
13
13
|
export * from './CustomEvent';
|
|
14
|
+
export * from './MutationEvent';
|
|
15
|
+
export * from './MutationObserver';
|
|
16
|
+
export * from './MutationRecord';
|
|
14
17
|
export * from './KeyframeEffect';
|
|
15
18
|
export * from './KeyframeList';
|
|
16
19
|
export * from './AnimationTimeline';
|
package/es/dom/index.js
CHANGED
|
@@ -11,6 +11,9 @@ export * from './Animation';
|
|
|
11
11
|
export * from './AnimationEvent';
|
|
12
12
|
export * from './AnimationEffectTiming';
|
|
13
13
|
export * from './CustomEvent';
|
|
14
|
+
export * from './MutationEvent';
|
|
15
|
+
export * from './MutationObserver';
|
|
16
|
+
export * from './MutationRecord';
|
|
14
17
|
export * from './KeyframeEffect';
|
|
15
18
|
export * from './KeyframeList';
|
|
16
19
|
export * from './AnimationTimeline';
|
package/es/dom/interfaces.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type EventEmitter from 'eventemitter3';
|
|
2
2
|
import type { AnimationTimeline } from './AnimationTimeline';
|
|
3
|
-
import type { BaseStyleProps,
|
|
3
|
+
import type { BaseStyleProps, Shape } from '../types';
|
|
4
4
|
import type { FederatedEvent } from './FederatedEvent';
|
|
5
5
|
import type { CustomElementRegistry } from './CustomElementRegistry';
|
|
6
6
|
import type { DisplayObject } from '..';
|
|
@@ -9,28 +9,43 @@ import type { Camera } from '../camera';
|
|
|
9
9
|
import type { ContextService } from '../services';
|
|
10
10
|
/**
|
|
11
11
|
* built-in events for element
|
|
12
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/MutationEvent
|
|
13
|
+
*
|
|
14
|
+
* TODO: use MutationObserver instead
|
|
15
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
|
|
12
16
|
*/
|
|
13
17
|
export declare enum ElementEvent {
|
|
14
18
|
DESTROY = "destroy",
|
|
15
|
-
|
|
19
|
+
/**
|
|
20
|
+
* @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMAttrModified
|
|
21
|
+
*/
|
|
22
|
+
ATTR_MODIFIED = "DOMAttrModified",
|
|
16
23
|
/**
|
|
17
24
|
* it has been inserted
|
|
25
|
+
* @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMNodeInserted
|
|
18
26
|
*/
|
|
19
|
-
INSERTED = "
|
|
27
|
+
INSERTED = "DOMNodeInserted",
|
|
20
28
|
/**
|
|
21
29
|
* it has had a child inserted
|
|
22
30
|
*/
|
|
23
31
|
CHILD_INSERTED = "child-inserted",
|
|
24
32
|
/**
|
|
25
|
-
* it
|
|
33
|
+
* it is being removed
|
|
34
|
+
* @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMNodeRemoved
|
|
26
35
|
*/
|
|
27
36
|
REMOVED = "removed",
|
|
28
37
|
/**
|
|
29
38
|
* it has had a child removed
|
|
30
39
|
*/
|
|
31
40
|
CHILD_REMOVED = "child-removed",
|
|
32
|
-
|
|
33
|
-
|
|
41
|
+
/**
|
|
42
|
+
* @see https://www.w3.org/TR/DOM-Level-3-Events/#domnodeinsertedintodocument
|
|
43
|
+
*/
|
|
44
|
+
MOUNTED = "DOMNodeInsertedIntoDocument",
|
|
45
|
+
/**
|
|
46
|
+
* @see https://www.w3.org/TR/DOM-Level-3-Events/#domnoderemovedfromdocument
|
|
47
|
+
*/
|
|
48
|
+
UNMOUNTED = "DOMNodeRemovedFromDocument",
|
|
34
49
|
BOUNDS_CHANGED = "bounds-changed",
|
|
35
50
|
/**
|
|
36
51
|
* trigger when z-index changed
|
|
@@ -222,6 +237,10 @@ export interface DisplayObjectConfig<StyleProps> {
|
|
|
222
237
|
*/
|
|
223
238
|
id?: string;
|
|
224
239
|
name?: string;
|
|
240
|
+
/**
|
|
241
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/className
|
|
242
|
+
*/
|
|
243
|
+
class?: string;
|
|
225
244
|
className?: string;
|
|
226
245
|
/**
|
|
227
246
|
* all styles properties, not read-only
|
|
@@ -234,7 +253,7 @@ export interface DisplayObjectConfig<StyleProps> {
|
|
|
234
253
|
* @deprecated
|
|
235
254
|
*/
|
|
236
255
|
attrs?: StyleProps;
|
|
237
|
-
type?:
|
|
256
|
+
type?: Shape | string;
|
|
238
257
|
/**
|
|
239
258
|
* @deprecated use `style.zIndex` instead
|
|
240
259
|
*/
|
|
@@ -276,7 +295,7 @@ export interface IElement<StyleProps = any, ParsedStyleProps = any> extends INod
|
|
|
276
295
|
* compatible with `style`
|
|
277
296
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style
|
|
278
297
|
*/
|
|
279
|
-
style: StyleProps
|
|
298
|
+
style: StyleProps & ICSSStyleDeclaration<StyleProps>;
|
|
280
299
|
parsedStyle: ParsedStyleProps;
|
|
281
300
|
getElementById: <E extends IElement = IElement>(id: string) => E | null;
|
|
282
301
|
getElementsByName: <E extends IElement = IElement>(name: string) => E[];
|
|
@@ -313,6 +332,15 @@ export interface IDocument extends INode, IParentNode {
|
|
|
313
332
|
*/
|
|
314
333
|
createElement: <T extends DisplayObject<StyleProps>, StyleProps extends BaseStyleProps>(tagName: string, options: DisplayObjectConfig<StyleProps>) => T;
|
|
315
334
|
}
|
|
335
|
+
/**
|
|
336
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/CSSStyleDeclaration
|
|
337
|
+
*/
|
|
338
|
+
export interface ICSSStyleDeclaration<StyleProps> {
|
|
339
|
+
setProperty: <Key extends keyof StyleProps>(propertyName: Key, value: StyleProps[Key], priority?: string) => void;
|
|
340
|
+
getPropertyValue: (propertyName: keyof StyleProps) => StyleProps[keyof StyleProps] | undefined;
|
|
341
|
+
removeProperty: (propertyName: keyof StyleProps) => void;
|
|
342
|
+
item: (index: number) => string;
|
|
343
|
+
}
|
|
316
344
|
export interface ICanvas extends IEventTarget {
|
|
317
345
|
document: IDocument;
|
|
318
346
|
customElements: CustomElementRegistry;
|
package/es/dom/interfaces.js
CHANGED
|
@@ -1,23 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* built-in events for element
|
|
3
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/MutationEvent
|
|
4
|
+
*
|
|
5
|
+
* TODO: use MutationObserver instead
|
|
6
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
|
|
3
7
|
*/
|
|
4
8
|
export var ElementEvent;
|
|
5
9
|
|
|
6
10
|
(function (ElementEvent) {
|
|
7
11
|
ElementEvent["DESTROY"] = "destroy";
|
|
8
|
-
|
|
12
|
+
/**
|
|
13
|
+
* @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMAttrModified
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
ElementEvent["ATTR_MODIFIED"] = "DOMAttrModified";
|
|
9
17
|
/**
|
|
10
18
|
* it has been inserted
|
|
19
|
+
* @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMNodeInserted
|
|
11
20
|
*/
|
|
12
21
|
|
|
13
|
-
ElementEvent["INSERTED"] = "
|
|
22
|
+
ElementEvent["INSERTED"] = "DOMNodeInserted";
|
|
14
23
|
/**
|
|
15
24
|
* it has had a child inserted
|
|
16
25
|
*/
|
|
17
26
|
|
|
18
27
|
ElementEvent["CHILD_INSERTED"] = "child-inserted";
|
|
19
28
|
/**
|
|
20
|
-
* it
|
|
29
|
+
* it is being removed
|
|
30
|
+
* @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMNodeRemoved
|
|
21
31
|
*/
|
|
22
32
|
|
|
23
33
|
ElementEvent["REMOVED"] = "removed";
|
|
@@ -26,8 +36,16 @@ export var ElementEvent;
|
|
|
26
36
|
*/
|
|
27
37
|
|
|
28
38
|
ElementEvent["CHILD_REMOVED"] = "child-removed";
|
|
29
|
-
|
|
30
|
-
|
|
39
|
+
/**
|
|
40
|
+
* @see https://www.w3.org/TR/DOM-Level-3-Events/#domnodeinsertedintodocument
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
ElementEvent["MOUNTED"] = "DOMNodeInsertedIntoDocument";
|
|
44
|
+
/**
|
|
45
|
+
* @see https://www.w3.org/TR/DOM-Level-3-Events/#domnoderemovedfromdocument
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
ElementEvent["UNMOUNTED"] = "DOMNodeRemovedFromDocument";
|
|
31
49
|
ElementEvent["BOUNDS_CHANGED"] = "bounds-changed";
|
|
32
50
|
/**
|
|
33
51
|
* trigger when z-index changed
|
package/es/global-module.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Interpolatable, StylePropertyParser, StylePropertyMerger, StylePropertyUpdater } from './property-handlers';
|
|
2
2
|
export declare const globalContainer: import("mana-syringe").Container;
|
|
3
|
+
export declare const INHERIT_PROPERTIES: string[];
|
|
3
4
|
export declare const stylePropertyParserFactory: Record<string, StylePropertyParser<any, any>>;
|
|
4
5
|
export declare const stylePropertyUpdaterFactory: Record<string, StylePropertyUpdater<any>[]>;
|
|
5
6
|
export declare const stylePropertyMergerFactory: Record<string, StylePropertyMerger<any, any>>;
|
package/es/global-module.js
CHANGED
|
@@ -7,12 +7,10 @@ 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 { parseLengthOrPercent, mergeDimensions } from './property-handlers';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
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';
|
|
15
|
-
export var globalContainer = GlobalContainer;
|
|
10
|
+
import { clampedMergeNumbers, parseNumber, mergeColors, parseColor, updateGeometry, updateLocalPosition, updateOffsetPath, updateClipPath, updateZIndex, updateOffsetDistance, updateOrigin, updateTransform, updateTransformOrigin, updateText, parseTransform, mergeTransforms, parsePath, parsePoints, mergePaths, mergeNumbers, mergeNumberLists, parseFilter, updateAnchor, parseLineDash, parseLengthOrPercent, mergeDimensions, updateTextTransform, updateInherit } from './property-handlers';
|
|
11
|
+
export var globalContainer = GlobalContainer; // some properties support 'inherit' value
|
|
12
|
+
|
|
13
|
+
export var INHERIT_PROPERTIES = ['textAlign', 'fontSize', 'fontFamily', 'fontWeight', 'fontStyle'];
|
|
16
14
|
export var stylePropertyParserFactory = {};
|
|
17
15
|
export var stylePropertyUpdaterFactory = {};
|
|
18
16
|
export var stylePropertyMergerFactory = {};
|
|
@@ -43,10 +41,7 @@ export var containerModule = Module(function (register) {
|
|
|
43
41
|
|
|
44
42
|
register(DisplayObjectPool); // bind Selector
|
|
45
43
|
|
|
46
|
-
register(
|
|
47
|
-
token: SceneGraphSelector,
|
|
48
|
-
useClass: DefaultSceneGraphSelector
|
|
49
|
-
});
|
|
44
|
+
register(DefaultSceneGraphSelector);
|
|
50
45
|
register({
|
|
51
46
|
token: SceneGraphSelectorFactory,
|
|
52
47
|
useFactory: function useFactory(context) {
|
|
@@ -88,13 +83,14 @@ export var containerModule = Module(function (register) {
|
|
|
88
83
|
}); // bind handlers for properties
|
|
89
84
|
|
|
90
85
|
addPropertiesHandler(['opacity', 'fillOpacity', 'strokeOpacity', 'offsetDistance'], parseNumber, clampedMergeNumbers(0, 1), undefined);
|
|
91
|
-
addPropertiesHandler(['
|
|
86
|
+
addPropertiesHandler(['shadowBlur'], parseNumber, clampedMergeNumbers(0, Infinity), undefined); // support percent
|
|
92
87
|
|
|
93
|
-
addPropertiesHandler(['r', 'rx', 'ry', 'width', 'height'], parseLengthOrPercent, // @ts-ignore
|
|
88
|
+
addPropertiesHandler(['r', 'rx', 'ry', 'width', 'height', 'fontSize', 'lineWidth', 'dx', 'dy'], parseLengthOrPercent, // @ts-ignore
|
|
94
89
|
mergeDimensions, undefined);
|
|
95
90
|
addPropertiesHandler(['lineDash'], parseLineDash, // @ts-ignore
|
|
96
91
|
mergeNumberLists, undefined);
|
|
97
92
|
addPropertiesHandler(['x1', 'x2', 'y1', 'y2', 'lineDashOffset', 'shadowOffsetX', 'shadowOffsetY'], parseNumber, mergeNumbers, undefined);
|
|
93
|
+
addPropertiesHandler(INHERIT_PROPERTIES, undefined, undefined, updateInherit);
|
|
98
94
|
addPropertiesHandler(['x1', 'x2', 'y1', 'y2', 'r', 'rx', 'ry', 'width', 'height', 'path', 'points', 'text', 'shadowBlur', 'shadowOffsetX', 'shadowOffsetY', 'lineWidth', 'filter', 'font', 'fontSize', 'fontFamily', 'fontStyle', 'fontWeight', 'fontVariant', 'lineHeight', 'letterSpacing', // 'padding',
|
|
99
95
|
'wordWrap', 'wordWrapWidth', 'leading', 'textBaseline', 'textAlign', 'whiteSpace'], undefined, undefined, updateGeometry);
|
|
100
96
|
addPropertiesHandler(['fill', 'stroke', 'shadowColor'], parseColor, mergeColors, undefined);
|
|
@@ -106,7 +102,9 @@ export var containerModule = Module(function (register) {
|
|
|
106
102
|
|
|
107
103
|
addPropertyHandler('transformOrigin', undefined, undefined, updateTransformOrigin); // @ts-ignore
|
|
108
104
|
|
|
109
|
-
addPropertyHandler('transform', parseTransform, mergeTransforms, updateTransform);
|
|
105
|
+
addPropertyHandler('transform', parseTransform, mergeTransforms, updateTransform);
|
|
106
|
+
addPropertyHandler('text', undefined, undefined, updateText);
|
|
107
|
+
addPropertyHandler('textTransform', undefined, undefined, updateTextTransform); // Path.path
|
|
110
108
|
// @ts-ignore
|
|
111
109
|
|
|
112
110
|
addPropertyHandler('path', parsePath, mergePaths, undefined); // Polyline.points Polygon.points
|
package/es/index.d.ts
CHANGED
package/es/index.js
CHANGED
|
@@ -12,8 +12,6 @@ export interface CullingStrategyContribution {
|
|
|
12
12
|
*/
|
|
13
13
|
export declare class CullingPlugin implements RenderingPlugin {
|
|
14
14
|
static tag: string;
|
|
15
|
-
private canvasConfig;
|
|
16
15
|
private strategyProvider;
|
|
17
|
-
private renderingContext;
|
|
18
16
|
apply(renderingService: RenderingService): void;
|
|
19
17
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import {
|
|
2
|
+
import { singleton, contrib, Syringe, Contribution } from 'mana-syringe';
|
|
3
3
|
import { RenderingPluginContribution } from '../services/RenderingService';
|
|
4
|
-
import { RenderingContext, RENDER_REASON } from '../services/RenderingContext';
|
|
5
|
-
import { CanvasConfig } from '../types';
|
|
6
4
|
export var CullingStrategyContribution = Syringe.defineToken('CullingStrategyContribution');
|
|
7
5
|
/**
|
|
8
6
|
* apply following rules:
|
|
@@ -18,8 +16,6 @@ function () {
|
|
|
18
16
|
CullingPlugin_1 = CullingPlugin;
|
|
19
17
|
|
|
20
18
|
CullingPlugin.prototype.apply = function (renderingService) {
|
|
21
|
-
var _this = this;
|
|
22
|
-
|
|
23
19
|
var strategies = this.strategyProvider.getContributions();
|
|
24
20
|
renderingService.hooks.prepare.tap(CullingPlugin_1.tag, function (object) {
|
|
25
21
|
if (object) {
|
|
@@ -36,22 +32,9 @@ function () {
|
|
|
36
32
|
|
|
37
33
|
if (object.isVisible()) {
|
|
38
34
|
return object;
|
|
39
|
-
} else {
|
|
40
|
-
// Those invisible objects which get renderred in last frame should be saved for later use.
|
|
41
|
-
var enableDirtyRectangleRendering = _this.canvasConfig.renderer.getConfig().enableDirtyRectangleRendering;
|
|
42
|
-
|
|
43
|
-
if (enableDirtyRectangleRendering) {
|
|
44
|
-
var removedRenderBounds = object.getRenderBounds();
|
|
45
|
-
|
|
46
|
-
if (removedRenderBounds) {
|
|
47
|
-
_this.renderingContext.removedRenderBoundsList.push(removedRenderBounds);
|
|
48
|
-
|
|
49
|
-
_this.renderingContext.renderReasons.add(RENDER_REASON.DisplayObjectRemoved);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return null;
|
|
54
35
|
}
|
|
36
|
+
|
|
37
|
+
return null;
|
|
55
38
|
}
|
|
56
39
|
|
|
57
40
|
return object;
|
|
@@ -64,12 +47,8 @@ function () {
|
|
|
64
47
|
var CullingPlugin_1;
|
|
65
48
|
CullingPlugin.tag = 'CullingPlugin';
|
|
66
49
|
|
|
67
|
-
__decorate([inject(CanvasConfig), __metadata("design:type", Object)], CullingPlugin.prototype, "canvasConfig", void 0);
|
|
68
|
-
|
|
69
50
|
__decorate([contrib(CullingStrategyContribution), __metadata("design:type", Object)], CullingPlugin.prototype, "strategyProvider", void 0);
|
|
70
51
|
|
|
71
|
-
__decorate([inject(RenderingContext), __metadata("design:type", Object)], CullingPlugin.prototype, "renderingContext", void 0);
|
|
72
|
-
|
|
73
52
|
CullingPlugin = CullingPlugin_1 = __decorate([singleton({
|
|
74
53
|
contrib: RenderingPluginContribution
|
|
75
54
|
})], CullingPlugin);
|