@antv/g-lite 2.3.2 → 2.4.0
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.esm.js +178 -838
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +177 -838
- package/dist/index.js.map +1 -1
- package/dist/index.umd.min.js +11 -11
- package/dist/index.umd.min.js.map +1 -1
- package/package.json +1 -3
- package/types/Canvas.d.ts.map +1 -1
- package/types/components/RBushNode.d.ts +10 -0
- package/types/components/RBushNode.d.ts.map +1 -1
- package/types/css/StyleValueRegistry.d.ts.map +1 -1
- package/types/display-objects/DisplayObject.d.ts +1 -2
- package/types/display-objects/DisplayObject.d.ts.map +1 -1
- package/types/display-objects/Text.d.ts +5 -0
- package/types/display-objects/Text.d.ts.map +1 -1
- package/types/dom/CustomEvent.d.ts +6 -3
- package/types/dom/CustomEvent.d.ts.map +1 -1
- package/types/dom/Document.d.ts +2 -3
- package/types/dom/Document.d.ts.map +1 -1
- package/types/dom/Element.d.ts +22 -8
- package/types/dom/Element.d.ts.map +1 -1
- package/types/dom/EventTarget.d.ts +2 -2
- package/types/dom/EventTarget.d.ts.map +1 -1
- package/types/dom/MutationEvent.d.ts +3 -0
- package/types/dom/MutationEvent.d.ts.map +1 -1
- package/types/dom/MutationObserver.d.ts +19 -0
- package/types/dom/MutationObserver.d.ts.map +1 -0
- package/types/dom/index.d.ts +1 -0
- package/types/dom/index.d.ts.map +1 -1
- package/types/dom/interfaces.d.ts +0 -3
- package/types/dom/interfaces.d.ts.map +1 -1
- package/types/index.d.ts +0 -2
- package/types/index.d.ts.map +1 -1
- package/types/plugins/PrepareRendererPlugin.d.ts +5 -6
- package/types/plugins/PrepareRendererPlugin.d.ts.map +1 -1
- package/types/services/RenderingService.d.ts +4 -3
- package/types/services/RenderingService.d.ts.map +1 -1
- package/types/services/SceneGraphService.d.ts +19 -9
- package/types/services/SceneGraphService.d.ts.map +1 -1
- package/types/services/interfaces.d.ts +4 -3
- package/types/services/interfaces.d.ts.map +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @antv/g-lite
|
|
3
3
|
* @description A core module for rendering engine implements DOM API.
|
|
4
|
-
* @version 2.
|
|
5
|
-
* @date
|
|
4
|
+
* @version 2.4.0
|
|
5
|
+
* @date 10/13/2025, 7:00:43 AM
|
|
6
6
|
* @author AntVis
|
|
7
7
|
* @docs https://g.antv.antgroup.com/
|
|
8
8
|
*/
|
|
@@ -25,586 +25,6 @@ import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
|
25
25
|
import _createForOfIteratorHelper from '@babel/runtime/helpers/createForOfIteratorHelper';
|
|
26
26
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
27
27
|
|
|
28
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
29
|
-
|
|
30
|
-
var rbush = {exports: {}};
|
|
31
|
-
|
|
32
|
-
(function (module, exports) {
|
|
33
|
-
(function (global, factory) {
|
|
34
|
-
module.exports = factory() ;
|
|
35
|
-
}(commonjsGlobal, function () {
|
|
36
|
-
function quickselect(arr, k, left, right, compare) {
|
|
37
|
-
quickselectStep(arr, k, left || 0, right || (arr.length - 1), compare || defaultCompare);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function quickselectStep(arr, k, left, right, compare) {
|
|
41
|
-
|
|
42
|
-
while (right > left) {
|
|
43
|
-
if (right - left > 600) {
|
|
44
|
-
var n = right - left + 1;
|
|
45
|
-
var m = k - left + 1;
|
|
46
|
-
var z = Math.log(n);
|
|
47
|
-
var s = 0.5 * Math.exp(2 * z / 3);
|
|
48
|
-
var sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);
|
|
49
|
-
var newLeft = Math.max(left, Math.floor(k - m * s / n + sd));
|
|
50
|
-
var newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));
|
|
51
|
-
quickselectStep(arr, k, newLeft, newRight, compare);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
var t = arr[k];
|
|
55
|
-
var i = left;
|
|
56
|
-
var j = right;
|
|
57
|
-
|
|
58
|
-
swap(arr, left, k);
|
|
59
|
-
if (compare(arr[right], t) > 0) { swap(arr, left, right); }
|
|
60
|
-
|
|
61
|
-
while (i < j) {
|
|
62
|
-
swap(arr, i, j);
|
|
63
|
-
i++;
|
|
64
|
-
j--;
|
|
65
|
-
while (compare(arr[i], t) < 0) { i++; }
|
|
66
|
-
while (compare(arr[j], t) > 0) { j--; }
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (compare(arr[left], t) === 0) { swap(arr, left, j); }
|
|
70
|
-
else {
|
|
71
|
-
j++;
|
|
72
|
-
swap(arr, j, right);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (j <= k) { left = j + 1; }
|
|
76
|
-
if (k <= j) { right = j - 1; }
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function swap(arr, i, j) {
|
|
81
|
-
var tmp = arr[i];
|
|
82
|
-
arr[i] = arr[j];
|
|
83
|
-
arr[j] = tmp;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function defaultCompare(a, b) {
|
|
87
|
-
return a < b ? -1 : a > b ? 1 : 0;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
var RBush = function RBush(maxEntries) {
|
|
91
|
-
if ( maxEntries === void 0 ) maxEntries = 9;
|
|
92
|
-
|
|
93
|
-
// max entries in a node is 9 by default; min node fill is 40% for best performance
|
|
94
|
-
this._maxEntries = Math.max(4, maxEntries);
|
|
95
|
-
this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4));
|
|
96
|
-
this.clear();
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
RBush.prototype.all = function all () {
|
|
100
|
-
return this._all(this.data, []);
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
RBush.prototype.search = function search (bbox) {
|
|
104
|
-
var node = this.data;
|
|
105
|
-
var result = [];
|
|
106
|
-
|
|
107
|
-
if (!intersects(bbox, node)) { return result; }
|
|
108
|
-
|
|
109
|
-
var toBBox = this.toBBox;
|
|
110
|
-
var nodesToSearch = [];
|
|
111
|
-
|
|
112
|
-
while (node) {
|
|
113
|
-
for (var i = 0; i < node.children.length; i++) {
|
|
114
|
-
var child = node.children[i];
|
|
115
|
-
var childBBox = node.leaf ? toBBox(child) : child;
|
|
116
|
-
|
|
117
|
-
if (intersects(bbox, childBBox)) {
|
|
118
|
-
if (node.leaf) { result.push(child); }
|
|
119
|
-
else if (contains(bbox, childBBox)) { this._all(child, result); }
|
|
120
|
-
else { nodesToSearch.push(child); }
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
node = nodesToSearch.pop();
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return result;
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
RBush.prototype.collides = function collides (bbox) {
|
|
130
|
-
var node = this.data;
|
|
131
|
-
|
|
132
|
-
if (!intersects(bbox, node)) { return false; }
|
|
133
|
-
|
|
134
|
-
var nodesToSearch = [];
|
|
135
|
-
while (node) {
|
|
136
|
-
for (var i = 0; i < node.children.length; i++) {
|
|
137
|
-
var child = node.children[i];
|
|
138
|
-
var childBBox = node.leaf ? this.toBBox(child) : child;
|
|
139
|
-
|
|
140
|
-
if (intersects(bbox, childBBox)) {
|
|
141
|
-
if (node.leaf || contains(bbox, childBBox)) { return true; }
|
|
142
|
-
nodesToSearch.push(child);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
node = nodesToSearch.pop();
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return false;
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
RBush.prototype.load = function load (data) {
|
|
152
|
-
if (!(data && data.length)) { return this; }
|
|
153
|
-
|
|
154
|
-
if (data.length < this._minEntries) {
|
|
155
|
-
for (var i = 0; i < data.length; i++) {
|
|
156
|
-
this.insert(data[i]);
|
|
157
|
-
}
|
|
158
|
-
return this;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// recursively build the tree with the given data from scratch using OMT algorithm
|
|
162
|
-
var node = this._build(data.slice(), 0, data.length - 1, 0);
|
|
163
|
-
|
|
164
|
-
if (!this.data.children.length) {
|
|
165
|
-
// save as is if tree is empty
|
|
166
|
-
this.data = node;
|
|
167
|
-
|
|
168
|
-
} else if (this.data.height === node.height) {
|
|
169
|
-
// split root if trees have the same height
|
|
170
|
-
this._splitRoot(this.data, node);
|
|
171
|
-
|
|
172
|
-
} else {
|
|
173
|
-
if (this.data.height < node.height) {
|
|
174
|
-
// swap trees if inserted one is bigger
|
|
175
|
-
var tmpNode = this.data;
|
|
176
|
-
this.data = node;
|
|
177
|
-
node = tmpNode;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// insert the small tree into the large tree at appropriate level
|
|
181
|
-
this._insert(node, this.data.height - node.height - 1, true);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return this;
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
RBush.prototype.insert = function insert (item) {
|
|
188
|
-
if (item) { this._insert(item, this.data.height - 1); }
|
|
189
|
-
return this;
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
RBush.prototype.clear = function clear () {
|
|
193
|
-
this.data = createNode([]);
|
|
194
|
-
return this;
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
RBush.prototype.remove = function remove (item, equalsFn) {
|
|
198
|
-
if (!item) { return this; }
|
|
199
|
-
|
|
200
|
-
var node = this.data;
|
|
201
|
-
var bbox = this.toBBox(item);
|
|
202
|
-
var path = [];
|
|
203
|
-
var indexes = [];
|
|
204
|
-
var i, parent, goingUp;
|
|
205
|
-
|
|
206
|
-
// depth-first iterative tree traversal
|
|
207
|
-
while (node || path.length) {
|
|
208
|
-
|
|
209
|
-
if (!node) { // go up
|
|
210
|
-
node = path.pop();
|
|
211
|
-
parent = path[path.length - 1];
|
|
212
|
-
i = indexes.pop();
|
|
213
|
-
goingUp = true;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
if (node.leaf) { // check current node
|
|
217
|
-
var index = findItem(item, node.children, equalsFn);
|
|
218
|
-
|
|
219
|
-
if (index !== -1) {
|
|
220
|
-
// item found, remove the item and condense tree upwards
|
|
221
|
-
node.children.splice(index, 1);
|
|
222
|
-
path.push(node);
|
|
223
|
-
this._condense(path);
|
|
224
|
-
return this;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
if (!goingUp && !node.leaf && contains(node, bbox)) { // go down
|
|
229
|
-
path.push(node);
|
|
230
|
-
indexes.push(i);
|
|
231
|
-
i = 0;
|
|
232
|
-
parent = node;
|
|
233
|
-
node = node.children[0];
|
|
234
|
-
|
|
235
|
-
} else if (parent) { // go right
|
|
236
|
-
i++;
|
|
237
|
-
node = parent.children[i];
|
|
238
|
-
goingUp = false;
|
|
239
|
-
|
|
240
|
-
} else { node = null; } // nothing found
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
return this;
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
RBush.prototype.toBBox = function toBBox (item) { return item; };
|
|
247
|
-
|
|
248
|
-
RBush.prototype.compareMinX = function compareMinX (a, b) { return a.minX - b.minX; };
|
|
249
|
-
RBush.prototype.compareMinY = function compareMinY (a, b) { return a.minY - b.minY; };
|
|
250
|
-
|
|
251
|
-
RBush.prototype.toJSON = function toJSON () { return this.data; };
|
|
252
|
-
|
|
253
|
-
RBush.prototype.fromJSON = function fromJSON (data) {
|
|
254
|
-
this.data = data;
|
|
255
|
-
return this;
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
RBush.prototype._all = function _all (node, result) {
|
|
259
|
-
var nodesToSearch = [];
|
|
260
|
-
while (node) {
|
|
261
|
-
if (node.leaf) { result.push.apply(result, node.children); }
|
|
262
|
-
else { nodesToSearch.push.apply(nodesToSearch, node.children); }
|
|
263
|
-
|
|
264
|
-
node = nodesToSearch.pop();
|
|
265
|
-
}
|
|
266
|
-
return result;
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
RBush.prototype._build = function _build (items, left, right, height) {
|
|
270
|
-
|
|
271
|
-
var N = right - left + 1;
|
|
272
|
-
var M = this._maxEntries;
|
|
273
|
-
var node;
|
|
274
|
-
|
|
275
|
-
if (N <= M) {
|
|
276
|
-
// reached leaf level; return leaf
|
|
277
|
-
node = createNode(items.slice(left, right + 1));
|
|
278
|
-
calcBBox(node, this.toBBox);
|
|
279
|
-
return node;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
if (!height) {
|
|
283
|
-
// target height of the bulk-loaded tree
|
|
284
|
-
height = Math.ceil(Math.log(N) / Math.log(M));
|
|
285
|
-
|
|
286
|
-
// target number of root entries to maximize storage utilization
|
|
287
|
-
M = Math.ceil(N / Math.pow(M, height - 1));
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
node = createNode([]);
|
|
291
|
-
node.leaf = false;
|
|
292
|
-
node.height = height;
|
|
293
|
-
|
|
294
|
-
// split the items into M mostly square tiles
|
|
295
|
-
|
|
296
|
-
var N2 = Math.ceil(N / M);
|
|
297
|
-
var N1 = N2 * Math.ceil(Math.sqrt(M));
|
|
298
|
-
|
|
299
|
-
multiSelect(items, left, right, N1, this.compareMinX);
|
|
300
|
-
|
|
301
|
-
for (var i = left; i <= right; i += N1) {
|
|
302
|
-
|
|
303
|
-
var right2 = Math.min(i + N1 - 1, right);
|
|
304
|
-
|
|
305
|
-
multiSelect(items, i, right2, N2, this.compareMinY);
|
|
306
|
-
|
|
307
|
-
for (var j = i; j <= right2; j += N2) {
|
|
308
|
-
|
|
309
|
-
var right3 = Math.min(j + N2 - 1, right2);
|
|
310
|
-
|
|
311
|
-
// pack each entry recursively
|
|
312
|
-
node.children.push(this._build(items, j, right3, height - 1));
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
calcBBox(node, this.toBBox);
|
|
317
|
-
|
|
318
|
-
return node;
|
|
319
|
-
};
|
|
320
|
-
|
|
321
|
-
RBush.prototype._chooseSubtree = function _chooseSubtree (bbox, node, level, path) {
|
|
322
|
-
while (true) {
|
|
323
|
-
path.push(node);
|
|
324
|
-
|
|
325
|
-
if (node.leaf || path.length - 1 === level) { break; }
|
|
326
|
-
|
|
327
|
-
var minArea = Infinity;
|
|
328
|
-
var minEnlargement = Infinity;
|
|
329
|
-
var targetNode = (void 0);
|
|
330
|
-
|
|
331
|
-
for (var i = 0; i < node.children.length; i++) {
|
|
332
|
-
var child = node.children[i];
|
|
333
|
-
var area = bboxArea(child);
|
|
334
|
-
var enlargement = enlargedArea(bbox, child) - area;
|
|
335
|
-
|
|
336
|
-
// choose entry with the least area enlargement
|
|
337
|
-
if (enlargement < minEnlargement) {
|
|
338
|
-
minEnlargement = enlargement;
|
|
339
|
-
minArea = area < minArea ? area : minArea;
|
|
340
|
-
targetNode = child;
|
|
341
|
-
|
|
342
|
-
} else if (enlargement === minEnlargement) {
|
|
343
|
-
// otherwise choose one with the smallest area
|
|
344
|
-
if (area < minArea) {
|
|
345
|
-
minArea = area;
|
|
346
|
-
targetNode = child;
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
node = targetNode || node.children[0];
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
return node;
|
|
355
|
-
};
|
|
356
|
-
|
|
357
|
-
RBush.prototype._insert = function _insert (item, level, isNode) {
|
|
358
|
-
var bbox = isNode ? item : this.toBBox(item);
|
|
359
|
-
var insertPath = [];
|
|
360
|
-
|
|
361
|
-
// find the best node for accommodating the item, saving all nodes along the path too
|
|
362
|
-
var node = this._chooseSubtree(bbox, this.data, level, insertPath);
|
|
363
|
-
|
|
364
|
-
// put the item into the node
|
|
365
|
-
node.children.push(item);
|
|
366
|
-
extend(node, bbox);
|
|
367
|
-
|
|
368
|
-
// split on node overflow; propagate upwards if necessary
|
|
369
|
-
while (level >= 0) {
|
|
370
|
-
if (insertPath[level].children.length > this._maxEntries) {
|
|
371
|
-
this._split(insertPath, level);
|
|
372
|
-
level--;
|
|
373
|
-
} else { break; }
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
// adjust bboxes along the insertion path
|
|
377
|
-
this._adjustParentBBoxes(bbox, insertPath, level);
|
|
378
|
-
};
|
|
379
|
-
|
|
380
|
-
// split overflowed node into two
|
|
381
|
-
RBush.prototype._split = function _split (insertPath, level) {
|
|
382
|
-
var node = insertPath[level];
|
|
383
|
-
var M = node.children.length;
|
|
384
|
-
var m = this._minEntries;
|
|
385
|
-
|
|
386
|
-
this._chooseSplitAxis(node, m, M);
|
|
387
|
-
|
|
388
|
-
var splitIndex = this._chooseSplitIndex(node, m, M);
|
|
389
|
-
|
|
390
|
-
var newNode = createNode(node.children.splice(splitIndex, node.children.length - splitIndex));
|
|
391
|
-
newNode.height = node.height;
|
|
392
|
-
newNode.leaf = node.leaf;
|
|
393
|
-
|
|
394
|
-
calcBBox(node, this.toBBox);
|
|
395
|
-
calcBBox(newNode, this.toBBox);
|
|
396
|
-
|
|
397
|
-
if (level) { insertPath[level - 1].children.push(newNode); }
|
|
398
|
-
else { this._splitRoot(node, newNode); }
|
|
399
|
-
};
|
|
400
|
-
|
|
401
|
-
RBush.prototype._splitRoot = function _splitRoot (node, newNode) {
|
|
402
|
-
// split root node
|
|
403
|
-
this.data = createNode([node, newNode]);
|
|
404
|
-
this.data.height = node.height + 1;
|
|
405
|
-
this.data.leaf = false;
|
|
406
|
-
calcBBox(this.data, this.toBBox);
|
|
407
|
-
};
|
|
408
|
-
|
|
409
|
-
RBush.prototype._chooseSplitIndex = function _chooseSplitIndex (node, m, M) {
|
|
410
|
-
var index;
|
|
411
|
-
var minOverlap = Infinity;
|
|
412
|
-
var minArea = Infinity;
|
|
413
|
-
|
|
414
|
-
for (var i = m; i <= M - m; i++) {
|
|
415
|
-
var bbox1 = distBBox(node, 0, i, this.toBBox);
|
|
416
|
-
var bbox2 = distBBox(node, i, M, this.toBBox);
|
|
417
|
-
|
|
418
|
-
var overlap = intersectionArea(bbox1, bbox2);
|
|
419
|
-
var area = bboxArea(bbox1) + bboxArea(bbox2);
|
|
420
|
-
|
|
421
|
-
// choose distribution with minimum overlap
|
|
422
|
-
if (overlap < minOverlap) {
|
|
423
|
-
minOverlap = overlap;
|
|
424
|
-
index = i;
|
|
425
|
-
|
|
426
|
-
minArea = area < minArea ? area : minArea;
|
|
427
|
-
|
|
428
|
-
} else if (overlap === minOverlap) {
|
|
429
|
-
// otherwise choose distribution with minimum area
|
|
430
|
-
if (area < minArea) {
|
|
431
|
-
minArea = area;
|
|
432
|
-
index = i;
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
return index || M - m;
|
|
438
|
-
};
|
|
439
|
-
|
|
440
|
-
// sorts node children by the best axis for split
|
|
441
|
-
RBush.prototype._chooseSplitAxis = function _chooseSplitAxis (node, m, M) {
|
|
442
|
-
var compareMinX = node.leaf ? this.compareMinX : compareNodeMinX;
|
|
443
|
-
var compareMinY = node.leaf ? this.compareMinY : compareNodeMinY;
|
|
444
|
-
var xMargin = this._allDistMargin(node, m, M, compareMinX);
|
|
445
|
-
var yMargin = this._allDistMargin(node, m, M, compareMinY);
|
|
446
|
-
|
|
447
|
-
// if total distributions margin value is minimal for x, sort by minX,
|
|
448
|
-
// otherwise it's already sorted by minY
|
|
449
|
-
if (xMargin < yMargin) { node.children.sort(compareMinX); }
|
|
450
|
-
};
|
|
451
|
-
|
|
452
|
-
// total margin of all possible split distributions where each node is at least m full
|
|
453
|
-
RBush.prototype._allDistMargin = function _allDistMargin (node, m, M, compare) {
|
|
454
|
-
node.children.sort(compare);
|
|
455
|
-
|
|
456
|
-
var toBBox = this.toBBox;
|
|
457
|
-
var leftBBox = distBBox(node, 0, m, toBBox);
|
|
458
|
-
var rightBBox = distBBox(node, M - m, M, toBBox);
|
|
459
|
-
var margin = bboxMargin(leftBBox) + bboxMargin(rightBBox);
|
|
460
|
-
|
|
461
|
-
for (var i = m; i < M - m; i++) {
|
|
462
|
-
var child = node.children[i];
|
|
463
|
-
extend(leftBBox, node.leaf ? toBBox(child) : child);
|
|
464
|
-
margin += bboxMargin(leftBBox);
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
for (var i$1 = M - m - 1; i$1 >= m; i$1--) {
|
|
468
|
-
var child$1 = node.children[i$1];
|
|
469
|
-
extend(rightBBox, node.leaf ? toBBox(child$1) : child$1);
|
|
470
|
-
margin += bboxMargin(rightBBox);
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
return margin;
|
|
474
|
-
};
|
|
475
|
-
|
|
476
|
-
RBush.prototype._adjustParentBBoxes = function _adjustParentBBoxes (bbox, path, level) {
|
|
477
|
-
// adjust bboxes along the given tree path
|
|
478
|
-
for (var i = level; i >= 0; i--) {
|
|
479
|
-
extend(path[i], bbox);
|
|
480
|
-
}
|
|
481
|
-
};
|
|
482
|
-
|
|
483
|
-
RBush.prototype._condense = function _condense (path) {
|
|
484
|
-
// go through the path, removing empty nodes and updating bboxes
|
|
485
|
-
for (var i = path.length - 1, siblings = (void 0); i >= 0; i--) {
|
|
486
|
-
if (path[i].children.length === 0) {
|
|
487
|
-
if (i > 0) {
|
|
488
|
-
siblings = path[i - 1].children;
|
|
489
|
-
siblings.splice(siblings.indexOf(path[i]), 1);
|
|
490
|
-
|
|
491
|
-
} else { this.clear(); }
|
|
492
|
-
|
|
493
|
-
} else { calcBBox(path[i], this.toBBox); }
|
|
494
|
-
}
|
|
495
|
-
};
|
|
496
|
-
|
|
497
|
-
function findItem(item, items, equalsFn) {
|
|
498
|
-
if (!equalsFn) { return items.indexOf(item); }
|
|
499
|
-
|
|
500
|
-
for (var i = 0; i < items.length; i++) {
|
|
501
|
-
if (equalsFn(item, items[i])) { return i; }
|
|
502
|
-
}
|
|
503
|
-
return -1;
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
// calculate node's bbox from bboxes of its children
|
|
507
|
-
function calcBBox(node, toBBox) {
|
|
508
|
-
distBBox(node, 0, node.children.length, toBBox, node);
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
// min bounding rectangle of node children from k to p-1
|
|
512
|
-
function distBBox(node, k, p, toBBox, destNode) {
|
|
513
|
-
if (!destNode) { destNode = createNode(null); }
|
|
514
|
-
destNode.minX = Infinity;
|
|
515
|
-
destNode.minY = Infinity;
|
|
516
|
-
destNode.maxX = -Infinity;
|
|
517
|
-
destNode.maxY = -Infinity;
|
|
518
|
-
|
|
519
|
-
for (var i = k; i < p; i++) {
|
|
520
|
-
var child = node.children[i];
|
|
521
|
-
extend(destNode, node.leaf ? toBBox(child) : child);
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
return destNode;
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
function extend(a, b) {
|
|
528
|
-
a.minX = Math.min(a.minX, b.minX);
|
|
529
|
-
a.minY = Math.min(a.minY, b.minY);
|
|
530
|
-
a.maxX = Math.max(a.maxX, b.maxX);
|
|
531
|
-
a.maxY = Math.max(a.maxY, b.maxY);
|
|
532
|
-
return a;
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
function compareNodeMinX(a, b) { return a.minX - b.minX; }
|
|
536
|
-
function compareNodeMinY(a, b) { return a.minY - b.minY; }
|
|
537
|
-
|
|
538
|
-
function bboxArea(a) { return (a.maxX - a.minX) * (a.maxY - a.minY); }
|
|
539
|
-
function bboxMargin(a) { return (a.maxX - a.minX) + (a.maxY - a.minY); }
|
|
540
|
-
|
|
541
|
-
function enlargedArea(a, b) {
|
|
542
|
-
return (Math.max(b.maxX, a.maxX) - Math.min(b.minX, a.minX)) *
|
|
543
|
-
(Math.max(b.maxY, a.maxY) - Math.min(b.minY, a.minY));
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
function intersectionArea(a, b) {
|
|
547
|
-
var minX = Math.max(a.minX, b.minX);
|
|
548
|
-
var minY = Math.max(a.minY, b.minY);
|
|
549
|
-
var maxX = Math.min(a.maxX, b.maxX);
|
|
550
|
-
var maxY = Math.min(a.maxY, b.maxY);
|
|
551
|
-
|
|
552
|
-
return Math.max(0, maxX - minX) *
|
|
553
|
-
Math.max(0, maxY - minY);
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
function contains(a, b) {
|
|
557
|
-
return a.minX <= b.minX &&
|
|
558
|
-
a.minY <= b.minY &&
|
|
559
|
-
b.maxX <= a.maxX &&
|
|
560
|
-
b.maxY <= a.maxY;
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
function intersects(a, b) {
|
|
564
|
-
return b.minX <= a.maxX &&
|
|
565
|
-
b.minY <= a.maxY &&
|
|
566
|
-
b.maxX >= a.minX &&
|
|
567
|
-
b.maxY >= a.minY;
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
function createNode(children) {
|
|
571
|
-
return {
|
|
572
|
-
children: children,
|
|
573
|
-
height: 1,
|
|
574
|
-
leaf: true,
|
|
575
|
-
minX: Infinity,
|
|
576
|
-
minY: Infinity,
|
|
577
|
-
maxX: -Infinity,
|
|
578
|
-
maxY: -Infinity
|
|
579
|
-
};
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
// sort an array so that items come in groups of n unsorted items, with groups sorted between each other;
|
|
583
|
-
// combines selection algorithm with binary divide & conquer approach
|
|
584
|
-
|
|
585
|
-
function multiSelect(arr, left, right, n, compare) {
|
|
586
|
-
var stack = [left, right];
|
|
587
|
-
|
|
588
|
-
while (stack.length) {
|
|
589
|
-
right = stack.pop();
|
|
590
|
-
left = stack.pop();
|
|
591
|
-
|
|
592
|
-
if (right - left <= n) { continue; }
|
|
593
|
-
|
|
594
|
-
var mid = left + Math.ceil((right - left) / n / 2) * n;
|
|
595
|
-
quickselect(arr, mid, left, right, compare);
|
|
596
|
-
|
|
597
|
-
stack.push(left, mid, mid, right);
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
return RBush;
|
|
602
|
-
|
|
603
|
-
}));
|
|
604
|
-
}(rbush));
|
|
605
|
-
|
|
606
|
-
var RBush = rbush.exports;
|
|
607
|
-
|
|
608
28
|
var Shape = /*#__PURE__*/function (Shape) {
|
|
609
29
|
Shape["GROUP"] = "g";
|
|
610
30
|
Shape["FRAGMENT"] = "fragment";
|
|
@@ -7081,7 +6501,6 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
|
|
|
7081
6501
|
this.runtime.CSSPropertySyntaxFactory[PropertySyntax.TRANSFORM_ORIGIN].postProcessor(object);
|
|
7082
6502
|
}
|
|
7083
6503
|
if (needUpdateGeometry) {
|
|
7084
|
-
object.geometry.dirty = true;
|
|
7085
6504
|
object.dirty(true, true);
|
|
7086
6505
|
if (!options.forceUpdateGeometry) {
|
|
7087
6506
|
this.runtime.sceneGraphService.dirtyToRoot(object);
|
|
@@ -7891,9 +7310,9 @@ var AsyncSeriesWaterfallHook = /*#__PURE__*/function () {
|
|
|
7891
7310
|
return (_this$callbacks = this.callbacks)[0].apply(_this$callbacks, _args);
|
|
7892
7311
|
case 1:
|
|
7893
7312
|
result = _context.sent;
|
|
7894
|
-
i =
|
|
7313
|
+
i = 1;
|
|
7895
7314
|
case 2:
|
|
7896
|
-
if (!(i < this.callbacks.length
|
|
7315
|
+
if (!(i < this.callbacks.length)) {
|
|
7897
7316
|
_context.next = 5;
|
|
7898
7317
|
break;
|
|
7899
7318
|
}
|
|
@@ -7972,7 +7391,7 @@ var SyncWaterfallHook = /*#__PURE__*/function () {
|
|
|
7972
7391
|
var argsArr = arguments;
|
|
7973
7392
|
/* eslint-disable-next-line prefer-spread */
|
|
7974
7393
|
var result = this.callbacks[0].apply(undefined, argsArr);
|
|
7975
|
-
for (var i =
|
|
7394
|
+
for (var i = 1; i < this.callbacks.length; i++) {
|
|
7976
7395
|
var callback = this.callbacks[i];
|
|
7977
7396
|
// @ts-ignore
|
|
7978
7397
|
result = callback(result);
|
|
@@ -9058,7 +8477,8 @@ var FederatedWheelEvent = /*#__PURE__*/function (_FederatedMouseEvent) {
|
|
|
9058
8477
|
}(FederatedMouseEvent);
|
|
9059
8478
|
|
|
9060
8479
|
/**
|
|
9061
|
-
* @
|
|
8480
|
+
* @link https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent
|
|
8481
|
+
* @link https://developer.mozilla.org/en-US/docs/Web/Events/Creating_and_triggering_events
|
|
9062
8482
|
*
|
|
9063
8483
|
* @example
|
|
9064
8484
|
const event = new CustomEvent('build', { detail: { prop1: 'xx' } });
|
|
@@ -9070,15 +8490,15 @@ var FederatedWheelEvent = /*#__PURE__*/function (_FederatedMouseEvent) {
|
|
|
9070
8490
|
circle.dispatchEvent(event);
|
|
9071
8491
|
*/
|
|
9072
8492
|
var CustomEvent = /*#__PURE__*/function (_FederatedEvent) {
|
|
9073
|
-
function CustomEvent(eventName,
|
|
8493
|
+
function CustomEvent(eventName, options) {
|
|
9074
8494
|
var _this;
|
|
9075
8495
|
_classCallCheck(this, CustomEvent);
|
|
9076
8496
|
_this = _callSuper(this, CustomEvent, [null]);
|
|
9077
8497
|
_this.type = eventName;
|
|
9078
|
-
_this.detail =
|
|
8498
|
+
_this.detail = options === null || options === void 0 ? void 0 : options.detail;
|
|
9079
8499
|
|
|
9080
8500
|
// compatible with G 3.0
|
|
9081
|
-
Object.assign(_this,
|
|
8501
|
+
Object.assign(_this, options);
|
|
9082
8502
|
return _this;
|
|
9083
8503
|
}
|
|
9084
8504
|
_inherits(CustomEvent, _FederatedEvent);
|
|
@@ -9088,7 +8508,7 @@ var CustomEvent = /*#__PURE__*/function (_FederatedEvent) {
|
|
|
9088
8508
|
/**
|
|
9089
8509
|
* Objects that can receive events and may have listeners for them.
|
|
9090
8510
|
* eg. Element, Canvas, DisplayObject
|
|
9091
|
-
* @
|
|
8511
|
+
* @docs https://developer.mozilla.org/en-US/docs/Web/API/EventTarget
|
|
9092
8512
|
*/
|
|
9093
8513
|
var EventTarget = /*#__PURE__*/function () {
|
|
9094
8514
|
function EventTarget() {
|
|
@@ -9172,7 +8592,9 @@ var EventTarget = /*#__PURE__*/function () {
|
|
|
9172
8592
|
}, {
|
|
9173
8593
|
key: "emit",
|
|
9174
8594
|
value: function emit(eventName, object) {
|
|
9175
|
-
this.dispatchEvent(new CustomEvent(eventName,
|
|
8595
|
+
this.dispatchEvent(new CustomEvent(eventName, {
|
|
8596
|
+
detail: object
|
|
8597
|
+
}));
|
|
9176
8598
|
}
|
|
9177
8599
|
}, {
|
|
9178
8600
|
key: "dispatchEventToSelf",
|
|
@@ -10589,14 +10011,15 @@ var RenderingService = /*#__PURE__*/function () {
|
|
|
10589
10011
|
}
|
|
10590
10012
|
}, {
|
|
10591
10013
|
key: "render",
|
|
10592
|
-
value: function render(
|
|
10014
|
+
value: function render(canvas, frame, rerenderCallback) {
|
|
10593
10015
|
var _this2 = this;
|
|
10016
|
+
var canvasConfig = canvas.getConfig();
|
|
10017
|
+
var renderingContext = this.context.renderingContext;
|
|
10594
10018
|
this.stats.total = 0;
|
|
10595
10019
|
this.stats.rendered = 0;
|
|
10596
10020
|
this.zIndexCounter = 0;
|
|
10597
|
-
var renderingContext = this.context.renderingContext;
|
|
10598
10021
|
this.globalRuntime.sceneGraphService.syncHierarchy(renderingContext.root);
|
|
10599
|
-
this.globalRuntime.sceneGraphService.
|
|
10022
|
+
this.globalRuntime.sceneGraphService.notifyMutationObservers(canvas);
|
|
10600
10023
|
if (renderingContext.renderReasons.size && this.inited) {
|
|
10601
10024
|
// @ts-ignore
|
|
10602
10025
|
renderingContext.dirtyRectangleRenderingDisabled = this.disableDirtyRectangleRendering();
|
|
@@ -10708,11 +10131,11 @@ var RenderingService = /*#__PURE__*/function () {
|
|
|
10708
10131
|
value: function destroy() {
|
|
10709
10132
|
this.inited = false;
|
|
10710
10133
|
this.hooks.destroy.call();
|
|
10711
|
-
this.globalRuntime.sceneGraphService.
|
|
10134
|
+
this.globalRuntime.sceneGraphService.clearMutationObserverData();
|
|
10712
10135
|
}
|
|
10713
10136
|
}, {
|
|
10714
|
-
key: "
|
|
10715
|
-
value: function
|
|
10137
|
+
key: "dirty",
|
|
10138
|
+
value: function dirty() {
|
|
10716
10139
|
// need re-render
|
|
10717
10140
|
this.context.renderingContext.renderReasons.add(RenderReason.DISPLAY_OBJECT_CHANGED);
|
|
10718
10141
|
}
|
|
@@ -10914,6 +10337,9 @@ var ElementEvent = /*#__PURE__*/function (ElementEvent) {
|
|
|
10914
10337
|
|
|
10915
10338
|
// #region Canvas
|
|
10916
10339
|
|
|
10340
|
+
/**
|
|
10341
|
+
* @deprecated https://developer.chrome.com/blog/mutation-events-deprecation
|
|
10342
|
+
*/
|
|
10917
10343
|
var MutationEvent = /*#__PURE__*/function (_FederatedEvent) {
|
|
10918
10344
|
function MutationEvent(typeArg, relatedNode, prevValue, newValue, attrName, attrChange, prevParsedValue, newParsedValue) {
|
|
10919
10345
|
var _this;
|
|
@@ -10965,9 +10391,6 @@ var $setPosition_ParentInvertMatrix = mat4.create();
|
|
|
10965
10391
|
var $setEulerAngles_InvParentRot = quat$1.create();
|
|
10966
10392
|
var $rotateLocal = quat$1.create();
|
|
10967
10393
|
var $rotate_ParentInvertRotation = quat$1.create();
|
|
10968
|
-
var $triggerPendingEvents_detail = {
|
|
10969
|
-
affectChildren: true
|
|
10970
|
-
};
|
|
10971
10394
|
|
|
10972
10395
|
/**
|
|
10973
10396
|
* update transform in scene graph
|
|
@@ -10977,9 +10400,7 @@ var $triggerPendingEvents_detail = {
|
|
|
10977
10400
|
var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
10978
10401
|
function DefaultSceneGraphService(runtime) {
|
|
10979
10402
|
_classCallCheck(this, DefaultSceneGraphService);
|
|
10980
|
-
|
|
10981
|
-
this.pendingEvents = new Map();
|
|
10982
|
-
this.boundsChangedEvent = new CustomEvent(ElementEvent.BOUNDS_CHANGED);
|
|
10403
|
+
this.mutationsMap = new Map();
|
|
10983
10404
|
this.displayObjectDependencyMap = new WeakMap();
|
|
10984
10405
|
this.runtime = runtime;
|
|
10985
10406
|
}
|
|
@@ -11038,7 +10459,7 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11038
10459
|
}
|
|
11039
10460
|
if (isAttachToFragment) return;
|
|
11040
10461
|
if (isChildFragment) {
|
|
11041
|
-
this.
|
|
10462
|
+
this.dirtyFragment(child);
|
|
11042
10463
|
} else {
|
|
11043
10464
|
var transform = child.transformable;
|
|
11044
10465
|
if (transform) {
|
|
@@ -11466,22 +10887,12 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11466
10887
|
|
|
11467
10888
|
// #endregion transform
|
|
11468
10889
|
// #region bbox ----------------------------------------------------------------
|
|
11469
|
-
}, {
|
|
11470
|
-
key: "getTransformedGeometryBounds",
|
|
11471
|
-
value: function getTransformedGeometryBounds(element) {
|
|
11472
|
-
var render = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
11473
|
-
var existedAABB = arguments.length > 2 ? arguments[2] : undefined;
|
|
11474
|
-
var bounds = this.getGeometryBounds(element, render);
|
|
11475
|
-
if (!AABB.isEmpty(bounds)) {
|
|
11476
|
-
var aabb = existedAABB || new AABB();
|
|
11477
|
-
aabb.setFromTransformedAABB(bounds, this.getWorldTransform(element));
|
|
11478
|
-
return aabb;
|
|
11479
|
-
}
|
|
11480
|
-
return null;
|
|
11481
|
-
}
|
|
11482
10890
|
|
|
11483
10891
|
/**
|
|
11484
|
-
*
|
|
10892
|
+
* Get the geometry bounds of the element itself, excluding children.
|
|
10893
|
+
*
|
|
10894
|
+
* @param element - The element to get geometry bounds for
|
|
10895
|
+
* @param render - If true, returns render bounds (including strokes, etc.); otherwise returns content bounds
|
|
11485
10896
|
*/
|
|
11486
10897
|
}, {
|
|
11487
10898
|
key: "getGeometryBounds",
|
|
@@ -11497,6 +10908,27 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11497
10908
|
return bounds || new AABB();
|
|
11498
10909
|
}
|
|
11499
10910
|
|
|
10911
|
+
/**
|
|
10912
|
+
* Get the geometry bounds of the element itself in world space, excluding children.
|
|
10913
|
+
*
|
|
10914
|
+
* @param element - The element to get transformed geometry bounds for
|
|
10915
|
+
* @param render - If true, returns render bounds (including strokes, etc.); otherwise returns content bounds
|
|
10916
|
+
* @param existedAABB - Optional existing AABB to reuse
|
|
10917
|
+
*/
|
|
10918
|
+
}, {
|
|
10919
|
+
key: "getTransformedGeometryBounds",
|
|
10920
|
+
value: function getTransformedGeometryBounds(element) {
|
|
10921
|
+
var render = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
10922
|
+
var existedAABB = arguments.length > 2 ? arguments[2] : undefined;
|
|
10923
|
+
var bounds = this.getGeometryBounds(element, render);
|
|
10924
|
+
if (!AABB.isEmpty(bounds)) {
|
|
10925
|
+
var aabb = existedAABB || new AABB();
|
|
10926
|
+
aabb.setFromTransformedAABB(bounds, this.getWorldTransform(element));
|
|
10927
|
+
return aabb;
|
|
10928
|
+
}
|
|
10929
|
+
return null;
|
|
10930
|
+
}
|
|
10931
|
+
|
|
11500
10932
|
/**
|
|
11501
10933
|
* account for children in world space
|
|
11502
10934
|
*/
|
|
@@ -11697,12 +11129,12 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11697
11129
|
}, {
|
|
11698
11130
|
key: "dirtyWorldTransform",
|
|
11699
11131
|
value: function dirtyWorldTransform(element, transform) {
|
|
11700
|
-
this.
|
|
11132
|
+
this.dirtyWorldInternal(element, transform);
|
|
11701
11133
|
this.dirtyToRoot(element, true);
|
|
11702
11134
|
}
|
|
11703
11135
|
}, {
|
|
11704
|
-
key: "
|
|
11705
|
-
value: function
|
|
11136
|
+
key: "dirtyWorldInternal",
|
|
11137
|
+
value: function dirtyWorldInternal(element, transform) {
|
|
11706
11138
|
var _element$ownerDocumen3,
|
|
11707
11139
|
_this2 = this;
|
|
11708
11140
|
var enableAttributeUpdateOptimization = ((_element$ownerDocumen3 = element.ownerDocument) === null || _element$ownerDocumen3 === void 0 || (_element$ownerDocumen3 = _element$ownerDocumen3.defaultView) === null || _element$ownerDocumen3 === void 0 || (_element$ownerDocumen3 = _element$ownerDocumen3.getConfig()) === null || _element$ownerDocumen3 === void 0 || (_element$ownerDocumen3 = _element$ownerDocumen3.future) === null || _element$ownerDocumen3 === void 0 ? void 0 : _element$ownerDocumen3.experimentalAttributeUpdateOptimization) === true;
|
|
@@ -11712,7 +11144,7 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11712
11144
|
if (!enableAttributeUpdateOptimization) {
|
|
11713
11145
|
element.childNodes.forEach(function (child) {
|
|
11714
11146
|
var childTransform = child.transformable;
|
|
11715
|
-
_this2.
|
|
11147
|
+
_this2.dirtyWorldInternal(child, childTransform);
|
|
11716
11148
|
});
|
|
11717
11149
|
}
|
|
11718
11150
|
}
|
|
@@ -11740,11 +11172,25 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11740
11172
|
});
|
|
11741
11173
|
}
|
|
11742
11174
|
this.informDependentDisplayObjects(element);
|
|
11743
|
-
this.
|
|
11175
|
+
var mutation = this.mutationsMap.get(element);
|
|
11176
|
+
if (!mutation) {
|
|
11177
|
+
mutation = {
|
|
11178
|
+
type: 'attributes',
|
|
11179
|
+
target: element,
|
|
11180
|
+
_boundsChangeData: {
|
|
11181
|
+
affectChildren: affectChildren
|
|
11182
|
+
}
|
|
11183
|
+
};
|
|
11184
|
+
this.mutationsMap.set(element, mutation);
|
|
11185
|
+
} else {
|
|
11186
|
+
mutation._boundsChangeData = {
|
|
11187
|
+
affectChildren: mutation._boundsChangeData.affectChildren || affectChildren
|
|
11188
|
+
};
|
|
11189
|
+
}
|
|
11744
11190
|
}
|
|
11745
11191
|
}, {
|
|
11746
|
-
key: "
|
|
11747
|
-
value: function
|
|
11192
|
+
key: "dirtyFragment",
|
|
11193
|
+
value: function dirtyFragment(element) {
|
|
11748
11194
|
var _dirty3, _ref7;
|
|
11749
11195
|
var transform = element.transformable;
|
|
11750
11196
|
if (transform) {
|
|
@@ -11754,65 +11200,22 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11754
11200
|
(_dirty3 = (_ref7 = element).dirty) === null || _dirty3 === void 0 || _dirty3.call(_ref7, true, true);
|
|
11755
11201
|
var length = element.childNodes.length;
|
|
11756
11202
|
for (var i = 0; i < length; i++) {
|
|
11757
|
-
this.
|
|
11758
|
-
}
|
|
11759
|
-
if (element.nodeName === Shape.FRAGMENT) {
|
|
11760
|
-
this.pendingEvents.set(element, false);
|
|
11203
|
+
this.dirtyFragment(element.childNodes[i]);
|
|
11761
11204
|
}
|
|
11762
11205
|
}
|
|
11763
11206
|
}, {
|
|
11764
|
-
key: "
|
|
11765
|
-
value: function
|
|
11766
|
-
var
|
|
11767
|
-
|
|
11768
|
-
var enableCancelEventPropagation;
|
|
11769
|
-
var enableAttributeUpdateOptimization;
|
|
11770
|
-
var trigger = function trigger(element, detail) {
|
|
11771
|
-
if (!element.isConnected || triggered.has(element) || element.nodeName === Shape.FRAGMENT) {
|
|
11772
|
-
return;
|
|
11773
|
-
}
|
|
11774
|
-
_this3.boundsChangedEvent.detail = detail;
|
|
11775
|
-
_this3.boundsChangedEvent.target = element;
|
|
11776
|
-
if (element.isMutationObserved) {
|
|
11777
|
-
element.dispatchEvent(_this3.boundsChangedEvent);
|
|
11778
|
-
} else {
|
|
11779
|
-
if (enableCancelEventPropagation === undefined) {
|
|
11780
|
-
var _element$ownerDocumen5;
|
|
11781
|
-
enableCancelEventPropagation = ((_element$ownerDocumen5 = element.ownerDocument.defaultView) === null || _element$ownerDocumen5 === void 0 || (_element$ownerDocumen5 = _element$ownerDocumen5.getConfig()) === null || _element$ownerDocumen5 === void 0 || (_element$ownerDocumen5 = _element$ownerDocumen5.future) === null || _element$ownerDocumen5 === void 0 ? void 0 : _element$ownerDocumen5.experimentalCancelEventPropagation) === true;
|
|
11782
|
-
}
|
|
11783
|
-
element.ownerDocument.defaultView.dispatchEvent(_this3.boundsChangedEvent, true, enableCancelEventPropagation);
|
|
11784
|
-
}
|
|
11785
|
-
triggered.add(element);
|
|
11786
|
-
};
|
|
11787
|
-
this.pendingEvents.forEach(function (affectChildren, element) {
|
|
11788
|
-
if (element.nodeName === Shape.FRAGMENT) {
|
|
11789
|
-
return;
|
|
11790
|
-
}
|
|
11791
|
-
if (enableAttributeUpdateOptimization === undefined) {
|
|
11792
|
-
var _element$ownerDocumen6;
|
|
11793
|
-
enableAttributeUpdateOptimization = ((_element$ownerDocumen6 = element.ownerDocument) === null || _element$ownerDocumen6 === void 0 || (_element$ownerDocumen6 = _element$ownerDocumen6.defaultView) === null || _element$ownerDocumen6 === void 0 || (_element$ownerDocumen6 = _element$ownerDocumen6.getConfig()) === null || _element$ownerDocumen6 === void 0 || (_element$ownerDocumen6 = _element$ownerDocumen6.future) === null || _element$ownerDocumen6 === void 0 ? void 0 : _element$ownerDocumen6.experimentalAttributeUpdateOptimization) === true;
|
|
11794
|
-
}
|
|
11795
|
-
$triggerPendingEvents_detail.affectChildren = affectChildren;
|
|
11796
|
-
if (enableAttributeUpdateOptimization) {
|
|
11797
|
-
trigger(element, $triggerPendingEvents_detail);
|
|
11798
|
-
} else {
|
|
11799
|
-
// eslint-disable-next-line no-lonely-if
|
|
11800
|
-
if (affectChildren) {
|
|
11801
|
-
element.forEach(function (e) {
|
|
11802
|
-
trigger(e, $triggerPendingEvents_detail);
|
|
11803
|
-
});
|
|
11804
|
-
} else {
|
|
11805
|
-
trigger(element, $triggerPendingEvents_detail);
|
|
11806
|
-
}
|
|
11807
|
-
}
|
|
11207
|
+
key: "notifyMutationObservers",
|
|
11208
|
+
value: function notifyMutationObservers(canvas) {
|
|
11209
|
+
var event = new CustomEvent(ElementEvent.BOUNDS_CHANGED, {
|
|
11210
|
+
detail: Array.from(this.mutationsMap.values())
|
|
11808
11211
|
});
|
|
11809
|
-
|
|
11810
|
-
this.
|
|
11212
|
+
canvas.dispatchEvent(event, true, true);
|
|
11213
|
+
this.clearMutationObserverData();
|
|
11811
11214
|
}
|
|
11812
11215
|
}, {
|
|
11813
|
-
key: "
|
|
11814
|
-
value: function
|
|
11815
|
-
this.
|
|
11216
|
+
key: "clearMutationObserverData",
|
|
11217
|
+
value: function clearMutationObserverData() {
|
|
11218
|
+
this.mutationsMap.clear();
|
|
11816
11219
|
}
|
|
11817
11220
|
}, {
|
|
11818
11221
|
key: "updateDisplayObjectDependency",
|
|
@@ -11841,7 +11244,7 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11841
11244
|
key: "informDependentDisplayObjects",
|
|
11842
11245
|
value: function informDependentDisplayObjects(object) {
|
|
11843
11246
|
var _object$ownerDocument,
|
|
11844
|
-
|
|
11247
|
+
_this3 = this;
|
|
11845
11248
|
var dependencyMap = this.displayObjectDependencyMap.get(object);
|
|
11846
11249
|
if (!dependencyMap) {
|
|
11847
11250
|
return;
|
|
@@ -11849,11 +11252,11 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11849
11252
|
var enableCancelEventPropagation = (_object$ownerDocument = object.ownerDocument) === null || _object$ownerDocument === void 0 || (_object$ownerDocument = _object$ownerDocument.defaultView) === null || _object$ownerDocument === void 0 || (_object$ownerDocument = _object$ownerDocument.getConfig()) === null || _object$ownerDocument === void 0 || (_object$ownerDocument = _object$ownerDocument.future) === null || _object$ownerDocument === void 0 ? void 0 : _object$ownerDocument.experimentalCancelEventPropagation;
|
|
11850
11253
|
Object.keys(dependencyMap).forEach(function (name) {
|
|
11851
11254
|
dependencyMap[name].forEach(function (target) {
|
|
11852
|
-
|
|
11853
|
-
target.dispatchEvent(new MutationEvent(ElementEvent.ATTR_MODIFIED, target,
|
|
11255
|
+
_this3.dirtyToRoot(target, true);
|
|
11256
|
+
target.dispatchEvent(new MutationEvent(ElementEvent.ATTR_MODIFIED, target, _this3, _this3, name, MutationEvent.MODIFICATION, _this3, _this3), enableCancelEventPropagation, enableCancelEventPropagation);
|
|
11854
11257
|
if (target.isCustomElement && target.isConnected) {
|
|
11855
11258
|
if (target.attributeChangedCallback) {
|
|
11856
|
-
target.attributeChangedCallback(name,
|
|
11259
|
+
target.attributeChangedCallback(name, _this3, _this3);
|
|
11857
11260
|
}
|
|
11858
11261
|
}
|
|
11859
11262
|
});
|
|
@@ -12578,6 +11981,10 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
12578
11981
|
dirtyChildren: [],
|
|
12579
11982
|
dirtyReason: undefined
|
|
12580
11983
|
};
|
|
11984
|
+
/**
|
|
11985
|
+
* @deprecated Legacy property for RBush spatial indexing.
|
|
11986
|
+
* Will be removed in future versions.
|
|
11987
|
+
*/
|
|
12581
11988
|
_this.rBushNode = {
|
|
12582
11989
|
aabb: undefined
|
|
12583
11990
|
};
|
|
@@ -12633,16 +12040,23 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
12633
12040
|
key: "dirty",
|
|
12634
12041
|
value:
|
|
12635
12042
|
/**
|
|
12636
|
-
*
|
|
12637
|
-
*
|
|
12043
|
+
* Marks the element as dirty, indicating it needs re-rendering or relayout.
|
|
12044
|
+
*
|
|
12045
|
+
* @param styleFlag - Whether to update style state (default: true).
|
|
12046
|
+
* When true, sets `renderable.dirty` to true.
|
|
12047
|
+
* @param layoutFlag - Optional. When provided, updates layout-related dirty flags:
|
|
12048
|
+
* - `renderable.boundsDirty`
|
|
12049
|
+
* - `renderable.renderBoundsDirty`
|
|
12050
|
+
* - `geometry.dirty`
|
|
12638
12051
|
*/
|
|
12639
12052
|
function dirty() {
|
|
12640
|
-
var
|
|
12641
|
-
var
|
|
12642
|
-
this.renderable.dirty =
|
|
12643
|
-
if (
|
|
12644
|
-
this.renderable.boundsDirty =
|
|
12645
|
-
this.renderable.renderBoundsDirty =
|
|
12053
|
+
var styleFlag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
12054
|
+
var layoutFlag = arguments.length > 1 ? arguments[1] : undefined;
|
|
12055
|
+
this.renderable.dirty = styleFlag;
|
|
12056
|
+
if (layoutFlag !== undefined) {
|
|
12057
|
+
this.renderable.boundsDirty = layoutFlag;
|
|
12058
|
+
this.renderable.renderBoundsDirty = layoutFlag;
|
|
12059
|
+
this.geometry.dirty = layoutFlag;
|
|
12646
12060
|
}
|
|
12647
12061
|
}
|
|
12648
12062
|
}, {
|
|
@@ -13036,12 +12450,18 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
13036
12450
|
}, {
|
|
13037
12451
|
key: "getGeometryBounds",
|
|
13038
12452
|
value: function getGeometryBounds() {
|
|
13039
|
-
|
|
12453
|
+
var render = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
12454
|
+
return runtime.sceneGraphService.getGeometryBounds(this, render);
|
|
13040
12455
|
}
|
|
12456
|
+
|
|
12457
|
+
/**
|
|
12458
|
+
* get geometry bounds in world space, not accounting for children
|
|
12459
|
+
*/
|
|
13041
12460
|
}, {
|
|
13042
|
-
key: "
|
|
13043
|
-
value: function
|
|
13044
|
-
|
|
12461
|
+
key: "getTransformedGeometryBounds",
|
|
12462
|
+
value: function getTransformedGeometryBounds() {
|
|
12463
|
+
var render = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
12464
|
+
return runtime.sceneGraphService.getTransformedGeometryBounds(this, render);
|
|
13045
12465
|
}
|
|
13046
12466
|
|
|
13047
12467
|
/**
|
|
@@ -13052,6 +12472,11 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
13052
12472
|
value: function getBounds() {
|
|
13053
12473
|
return runtime.sceneGraphService.getBounds(this);
|
|
13054
12474
|
}
|
|
12475
|
+
}, {
|
|
12476
|
+
key: "getRenderBounds",
|
|
12477
|
+
value: function getRenderBounds() {
|
|
12478
|
+
return runtime.sceneGraphService.getBounds(this, true);
|
|
12479
|
+
}
|
|
13055
12480
|
|
|
13056
12481
|
/**
|
|
13057
12482
|
* get bounds in local space, account for children
|
|
@@ -13153,7 +12578,7 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
13153
12578
|
*/
|
|
13154
12579
|
}, {
|
|
13155
12580
|
key: "setAttribute",
|
|
13156
|
-
value: function setAttribute(attributeName, value
|
|
12581
|
+
value: function setAttribute(attributeName, value) {
|
|
13157
12582
|
this.attributes[attributeName] = value;
|
|
13158
12583
|
}
|
|
13159
12584
|
}, {
|
|
@@ -13387,9 +12812,6 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
|
|
|
13387
12812
|
|
|
13388
12813
|
// redraw at next frame
|
|
13389
12814
|
this.dirty();
|
|
13390
|
-
|
|
13391
|
-
// return;
|
|
13392
|
-
|
|
13393
12815
|
var newParsedValue = this.parsedStyle[name];
|
|
13394
12816
|
if (this.isConnected) {
|
|
13395
12817
|
attrModifiedEvent.relatedNode = this;
|
|
@@ -14956,7 +14378,7 @@ var Text = /*#__PURE__*/function (_DisplayObject) {
|
|
|
14956
14378
|
}
|
|
14957
14379
|
}]);
|
|
14958
14380
|
}(DisplayObject);
|
|
14959
|
-
Text.PARSED_STYLE_LIST = new Set([].concat(_toConsumableArray(DisplayObject.PARSED_STYLE_LIST), ['x', 'y', 'z', 'isBillboard', 'billboardRotation', 'isSizeAttenuation', 'text', 'textAlign', 'textBaseline', 'fontStyle', 'fontSize', 'fontFamily', 'fontWeight', 'fontVariant', 'lineHeight', 'letterSpacing', 'leading', 'wordWrap', 'wordWrapWidth', 'maxLines', 'textOverflow', 'isOverflowing', 'textPath', 'textDecorationLine', 'textDecorationColor', 'textDecorationStyle', 'textPathSide', 'textPathStartOffset', 'metrics', 'dx', 'dy']));
|
|
14381
|
+
Text.PARSED_STYLE_LIST = new Set([].concat(_toConsumableArray(DisplayObject.PARSED_STYLE_LIST), ['x', 'y', 'z', 'isBillboard', 'billboardRotation', 'isSizeAttenuation', 'text', 'textAlign', 'textBaseline', 'fontStyle', 'fontSize', 'fontFamily', 'fontWeight', 'fontVariant', 'lineHeight', 'letterSpacing', 'leading', 'wordWrap', 'wordWrapWidth', 'maxLines', 'textOverflow', 'isOverflowing', 'textPath', 'textDecorationLine', 'textDecorationColor', 'textDecorationStyle', 'textDecorationThickness', 'textPathSide', 'textPathStartOffset', 'metrics', 'dx', 'dy']));
|
|
14960
14382
|
|
|
14961
14383
|
/**
|
|
14962
14384
|
* canvas.customElements
|
|
@@ -15218,32 +14640,47 @@ var Document = /*#__PURE__*/function (_Node) {
|
|
|
15218
14640
|
}
|
|
15219
14641
|
|
|
15220
14642
|
/**
|
|
15221
|
-
* Picking 2D graphics
|
|
14643
|
+
* Picking 2D graphics by traversing elements and checking bounding boxes.
|
|
15222
14644
|
*/
|
|
15223
14645
|
}, {
|
|
15224
14646
|
key: "elementsFromBBox",
|
|
15225
14647
|
value: function elementsFromBBox(minX, minY, maxX, maxY) {
|
|
15226
|
-
var rBush = this.defaultView.context.rBushRoot;
|
|
15227
|
-
var rBushNodes = rBush.search({
|
|
15228
|
-
minX: minX,
|
|
15229
|
-
minY: minY,
|
|
15230
|
-
maxX: maxX,
|
|
15231
|
-
maxY: maxY
|
|
15232
|
-
});
|
|
15233
14648
|
var hitTestList = [];
|
|
15234
|
-
rBushNodes.forEach(function (_ref2) {
|
|
15235
|
-
var displayObject = _ref2.displayObject;
|
|
15236
|
-
var _displayObject$parsed = displayObject.parsedStyle.pointerEvents,
|
|
15237
|
-
pointerEvents = _displayObject$parsed === void 0 ? 'auto' : _displayObject$parsed;
|
|
15238
14649
|
|
|
15239
|
-
|
|
14650
|
+
// Traverse all elements in the document
|
|
14651
|
+
var _traverse = function traverse(node) {
|
|
14652
|
+
if (!node.isInteractive() || node.isCulled()) {
|
|
14653
|
+
return;
|
|
14654
|
+
}
|
|
14655
|
+
var _node$parsedStyle$poi = node.parsedStyle.pointerEvents,
|
|
14656
|
+
pointerEvents = _node$parsedStyle$poi === void 0 ? 'auto' : _node$parsedStyle$poi;
|
|
14657
|
+
|
|
14658
|
+
// Account for `visibility`
|
|
15240
14659
|
// @see https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events
|
|
15241
14660
|
var isVisibilityAffected = ['auto', 'visiblepainted', 'visiblefill', 'visiblestroke', 'visible'].includes(pointerEvents);
|
|
15242
|
-
if (
|
|
15243
|
-
|
|
14661
|
+
if (!isVisibilityAffected || node.isVisible()) {
|
|
14662
|
+
var bounds = node.getTransformedGeometryBounds(true);
|
|
14663
|
+
if (bounds && !AABB.isEmpty(bounds)) {
|
|
14664
|
+
if (bounds.max[0] >= minX && bounds.min[0] <= maxX && bounds.max[1] >= minY && bounds.min[1] <= maxY) {
|
|
14665
|
+
hitTestList.push(node);
|
|
14666
|
+
}
|
|
14667
|
+
}
|
|
15244
14668
|
}
|
|
15245
|
-
|
|
15246
|
-
|
|
14669
|
+
|
|
14670
|
+
// Traverse children if it's a container
|
|
14671
|
+
if (node.childNodes) {
|
|
14672
|
+
node.childNodes.forEach(function (child) {
|
|
14673
|
+
if (child instanceof DisplayObject) {
|
|
14674
|
+
_traverse(child);
|
|
14675
|
+
}
|
|
14676
|
+
});
|
|
14677
|
+
}
|
|
14678
|
+
};
|
|
14679
|
+
|
|
14680
|
+
// Start traversal from documentElement
|
|
14681
|
+
_traverse(this.documentElement);
|
|
14682
|
+
|
|
14683
|
+
// Sort by render order (z-index)
|
|
15247
14684
|
hitTestList.sort(function (a, b) {
|
|
15248
14685
|
return b.sortable.renderOrder - a.sortable.renderOrder;
|
|
15249
14686
|
});
|
|
@@ -15975,32 +15412,34 @@ var FrustumCullingStrategy = /*#__PURE__*/function () {
|
|
|
15975
15412
|
}]);
|
|
15976
15413
|
}();
|
|
15977
15414
|
|
|
15415
|
+
/**
|
|
15416
|
+
* PrepareRendererPlugin handles rendering preparation tasks
|
|
15417
|
+
* Simplified implementation focused on core rendering needs
|
|
15418
|
+
*/
|
|
15978
15419
|
var PrepareRendererPlugin = /*#__PURE__*/function () {
|
|
15979
15420
|
function PrepareRendererPlugin() {
|
|
15980
15421
|
_classCallCheck(this, PrepareRendererPlugin);
|
|
15981
|
-
this.
|
|
15422
|
+
this.mutationRecords = [];
|
|
15982
15423
|
this.isFirstTimeRendering = true;
|
|
15983
|
-
this.syncing = false;
|
|
15984
15424
|
this.isFirstTimeRenderingFinished = false;
|
|
15985
15425
|
}
|
|
15986
15426
|
return _createClass(PrepareRendererPlugin, [{
|
|
15987
15427
|
key: "apply",
|
|
15988
15428
|
value: function apply(context) {
|
|
15989
15429
|
var _this = this,
|
|
15990
|
-
_runtime$globalThis$r
|
|
15991
|
-
|
|
15992
|
-
|
|
15993
|
-
renderingService = context.renderingService,
|
|
15994
|
-
renderingContext = context.renderingContext,
|
|
15995
|
-
rBushRoot = context.rBushRoot;
|
|
15430
|
+
_runtime$globalThis$r;
|
|
15431
|
+
var renderingService = context.renderingService,
|
|
15432
|
+
renderingContext = context.renderingContext;
|
|
15996
15433
|
var canvas = renderingContext.root.ownerDocument.defaultView;
|
|
15997
|
-
this.rBush = rBushRoot;
|
|
15998
15434
|
var handleAttributeChanged = function handleAttributeChanged(e) {
|
|
15999
|
-
renderingService.
|
|
15435
|
+
renderingService.dirty();
|
|
16000
15436
|
};
|
|
16001
15437
|
var handleBoundsChanged = function handleBoundsChanged(e) {
|
|
16002
|
-
_this
|
|
16003
|
-
|
|
15438
|
+
var _this$mutationRecords;
|
|
15439
|
+
var records = e.detail;
|
|
15440
|
+
// Store mutation records for potential future processing
|
|
15441
|
+
(_this$mutationRecords = _this.mutationRecords).push.apply(_this$mutationRecords, _toConsumableArray(records));
|
|
15442
|
+
renderingService.dirty();
|
|
16004
15443
|
};
|
|
16005
15444
|
var handleMounted = function handleMounted(e) {
|
|
16006
15445
|
var object = e.target;
|
|
@@ -16010,13 +15449,10 @@ var PrepareRendererPlugin = /*#__PURE__*/function () {
|
|
|
16010
15449
|
};
|
|
16011
15450
|
var handleUnmounted = function handleUnmounted(e) {
|
|
16012
15451
|
var object = e.target;
|
|
16013
|
-
|
|
16014
|
-
|
|
16015
|
-
_this.rBush.remove(rBushNode.aabb);
|
|
16016
|
-
}
|
|
16017
|
-
_this.syncTasks["delete"](object);
|
|
15452
|
+
|
|
15453
|
+
// No spatial index cleanup needed
|
|
16018
15454
|
runtime.sceneGraphService.dirtyToRoot(object);
|
|
16019
|
-
renderingService.
|
|
15455
|
+
renderingService.dirty();
|
|
16020
15456
|
};
|
|
16021
15457
|
renderingService.hooks.init.tap(PrepareRendererPlugin.tag, function () {
|
|
16022
15458
|
canvas.addEventListener(ElementEvent.MOUNTED, handleMounted);
|
|
@@ -16029,109 +15465,20 @@ var PrepareRendererPlugin = /*#__PURE__*/function () {
|
|
|
16029
15465
|
canvas.removeEventListener(ElementEvent.UNMOUNTED, handleUnmounted);
|
|
16030
15466
|
canvas.removeEventListener(ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
16031
15467
|
canvas.removeEventListener(ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
|
|
16032
|
-
_this.
|
|
15468
|
+
_this.mutationRecords = [];
|
|
16033
15469
|
});
|
|
16034
15470
|
var ric = (_runtime$globalThis$r = runtime.globalThis.requestIdleCallback) !== null && _runtime$globalThis$r !== void 0 ? _runtime$globalThis$r : raf.bind(runtime.globalThis);
|
|
16035
|
-
var enableRICSyncRTree = ((_config$future = config.future) === null || _config$future === void 0 ? void 0 : _config$future.experimentalRICSyncRTree) === true;
|
|
16036
15471
|
renderingService.hooks.endFrame.tap(PrepareRendererPlugin.tag, function () {
|
|
16037
15472
|
if (_this.isFirstTimeRendering) {
|
|
16038
15473
|
_this.isFirstTimeRendering = false;
|
|
16039
|
-
_this.syncing = true;
|
|
16040
15474
|
ric(function () {
|
|
16041
|
-
_this.syncRTree(true);
|
|
16042
15475
|
_this.isFirstTimeRenderingFinished = true;
|
|
16043
15476
|
});
|
|
16044
|
-
} else if (enableRICSyncRTree && runtime.globalThis.requestIdleCallback && runtime.globalThis.cancelIdleCallback) {
|
|
16045
|
-
runtime.globalThis.cancelIdleCallback(_this.ricSyncRTreeId);
|
|
16046
|
-
_this.ricSyncRTreeId = runtime.globalThis.requestIdleCallback(function () {
|
|
16047
|
-
return _this.syncRTree();
|
|
16048
|
-
});
|
|
16049
|
-
} else {
|
|
16050
|
-
_this.syncRTree();
|
|
16051
15477
|
}
|
|
16052
|
-
});
|
|
16053
|
-
}
|
|
16054
|
-
}, {
|
|
16055
|
-
key: "syncNode",
|
|
16056
|
-
value: function syncNode(node) {
|
|
16057
|
-
var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
16058
|
-
if (!node.isConnected) return;
|
|
16059
|
-
var rBushNode = node.rBushNode;
|
|
16060
|
-
|
|
16061
|
-
// clear dirty node
|
|
16062
|
-
if (rBushNode.aabb) this.rBush.remove(rBushNode.aabb);
|
|
16063
|
-
var renderBounds = node.getRenderBounds();
|
|
16064
|
-
if (renderBounds) {
|
|
16065
|
-
var renderable = node.renderable;
|
|
16066
|
-
if (force) {
|
|
16067
|
-
if (!renderable.dirtyRenderBounds) {
|
|
16068
|
-
renderable.dirtyRenderBounds = new AABB();
|
|
16069
|
-
}
|
|
16070
|
-
// save last dirty aabb
|
|
16071
|
-
renderable.dirtyRenderBounds.update(renderBounds.center, renderBounds.halfExtents);
|
|
16072
|
-
}
|
|
16073
|
-
var _renderBounds$getMin = renderBounds.getMin(),
|
|
16074
|
-
_renderBounds$getMin2 = _slicedToArray(_renderBounds$getMin, 2),
|
|
16075
|
-
minX = _renderBounds$getMin2[0],
|
|
16076
|
-
minY = _renderBounds$getMin2[1];
|
|
16077
|
-
var _renderBounds$getMax = renderBounds.getMax(),
|
|
16078
|
-
_renderBounds$getMax2 = _slicedToArray(_renderBounds$getMax, 2),
|
|
16079
|
-
maxX = _renderBounds$getMax2[0],
|
|
16080
|
-
maxY = _renderBounds$getMax2[1];
|
|
16081
|
-
if (!rBushNode.aabb) {
|
|
16082
|
-
rBushNode.aabb = {};
|
|
16083
|
-
}
|
|
16084
|
-
rBushNode.aabb.displayObject = node;
|
|
16085
|
-
rBushNode.aabb.minX = minX;
|
|
16086
|
-
rBushNode.aabb.minY = minY;
|
|
16087
|
-
rBushNode.aabb.maxX = maxX;
|
|
16088
|
-
rBushNode.aabb.maxY = maxY;
|
|
16089
|
-
}
|
|
16090
|
-
if (rBushNode.aabb) {
|
|
16091
|
-
// TODO: NaN occurs when width/height of Rect is 0
|
|
16092
|
-
if (!isNaN(rBushNode.aabb.maxX) && !isNaN(rBushNode.aabb.maxX) && !isNaN(rBushNode.aabb.minX) && !isNaN(rBushNode.aabb.minY)) {
|
|
16093
|
-
return rBushNode.aabb;
|
|
16094
|
-
}
|
|
16095
|
-
}
|
|
16096
|
-
}
|
|
16097
|
-
}, {
|
|
16098
|
-
key: "syncRTree",
|
|
16099
|
-
value: function syncRTree() {
|
|
16100
|
-
var _this2 = this;
|
|
16101
|
-
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
16102
|
-
if (!force && (this.syncing || this.syncTasks.size === 0)) {
|
|
16103
|
-
return;
|
|
16104
|
-
}
|
|
16105
|
-
this.syncing = true;
|
|
16106
|
-
|
|
16107
|
-
// bounds changed, need re-inserting its children
|
|
16108
|
-
var bulk = [];
|
|
16109
|
-
var synced = new Set();
|
|
16110
|
-
var sync = function sync(node) {
|
|
16111
|
-
if (!synced.has(node) && node.renderable) {
|
|
16112
|
-
var aabb = _this2.syncNode(node, force);
|
|
16113
|
-
if (aabb) {
|
|
16114
|
-
bulk.push(aabb);
|
|
16115
|
-
synced.add(node);
|
|
16116
|
-
}
|
|
16117
|
-
}
|
|
16118
|
-
};
|
|
16119
|
-
this.syncTasks.forEach(function (affectChildren, node) {
|
|
16120
|
-
if (affectChildren) {
|
|
16121
|
-
node.forEach(sync);
|
|
16122
|
-
}
|
|
16123
|
-
var parent = node;
|
|
16124
|
-
while (parent) {
|
|
16125
|
-
sync(parent);
|
|
16126
|
-
parent = parent.parentElement;
|
|
16127
|
-
}
|
|
16128
|
-
});
|
|
16129
15478
|
|
|
16130
|
-
|
|
16131
|
-
|
|
16132
|
-
|
|
16133
|
-
bulk.length = 0;
|
|
16134
|
-
this.syncing = false;
|
|
15479
|
+
// Clear mutation records after each frame
|
|
15480
|
+
_this.mutationRecords = [];
|
|
15481
|
+
});
|
|
16135
15482
|
}
|
|
16136
15483
|
}]);
|
|
16137
15484
|
}();
|
|
@@ -16430,10 +15777,7 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16430
15777
|
this.getContextService().destroy();
|
|
16431
15778
|
|
|
16432
15779
|
// clear root after render service destroyed
|
|
16433
|
-
|
|
16434
|
-
// clear rbush
|
|
16435
|
-
this.context.rBushRoot.clear();
|
|
16436
|
-
}
|
|
15780
|
+
|
|
16437
15781
|
if (!skipTriggerEvent) {
|
|
16438
15782
|
this.dispatchEvent(new CustomEvent(CanvasEvent.AFTER_DESTROY), enableCancelEventPropagation, enableCancelEventPropagation);
|
|
16439
15783
|
}
|
|
@@ -16533,7 +15877,6 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16533
15877
|
value: function render(frame) {
|
|
16534
15878
|
var _this$getConfig$futur2,
|
|
16535
15879
|
_this4 = this;
|
|
16536
|
-
// console.log('render ----------------------');
|
|
16537
15880
|
if (frame) {
|
|
16538
15881
|
beforeRenderEvent.detail = frame;
|
|
16539
15882
|
afterRenderEvent.detail = frame;
|
|
@@ -16541,7 +15884,7 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16541
15884
|
var enableCancelEventPropagation = ((_this$getConfig$futur2 = this.getConfig().future) === null || _this$getConfig$futur2 === void 0 ? void 0 : _this$getConfig$futur2.experimentalCancelEventPropagation) === true;
|
|
16542
15885
|
this.dispatchEvent(beforeRenderEvent, enableCancelEventPropagation, enableCancelEventPropagation);
|
|
16543
15886
|
var renderingService = this.getRenderingService();
|
|
16544
|
-
renderingService.render(this
|
|
15887
|
+
renderingService.render(this, frame, function () {
|
|
16545
15888
|
// trigger actual rerender event
|
|
16546
15889
|
// @see https://github.com/antvis/G/issues/1268
|
|
16547
15890
|
_this4.dispatchEvent(rerenderEvent, enableCancelEventPropagation, enableCancelEventPropagation);
|
|
@@ -16571,9 +15914,6 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16571
15914
|
this.inited = false;
|
|
16572
15915
|
this.readyPromise = undefined;
|
|
16573
15916
|
|
|
16574
|
-
// FIXME: should re-create here?
|
|
16575
|
-
this.context.rBushRoot = new RBush();
|
|
16576
|
-
|
|
16577
15917
|
// reset rendering plugins
|
|
16578
15918
|
this.context.renderingPlugins = [];
|
|
16579
15919
|
this.context.renderingPlugins.push(new EventPlugin(), new PrepareRendererPlugin(),
|
|
@@ -16801,5 +16141,5 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16801
16141
|
}]);
|
|
16802
16142
|
}(EventTarget);
|
|
16803
16143
|
|
|
16804
|
-
export { AABB, AbstractRenderer, AbstractRendererPlugin, BUILT_IN_PROPERTIES, CSS, CSSGradientValue, CSSKeywordValue, CSSRGB, CSSStyleValue, CSSUnitValue, Camera, CameraEvent, CameraProjectionMode, CameraTrackingMode, CameraType, Canvas, CanvasEvent, Circle, CircleUpdater, ClipSpaceNearZ, CustomElement, CustomElementRegistry, CustomEvent, DefaultSceneGraphSelector, DefaultSceneGraphService, DisplayObject, Document, ERROR_MSG_METHOD_NOT_IMPLEMENTED, Element, ElementEvent, Ellipse, EllipseUpdater, EventService, EventTarget, FederatedEvent, FederatedMouseEvent, FederatedPointerEvent, FederatedWheelEvent, Fragment, Frustum, GradientType, Group, GroupUpdater, HTML, HTMLUpdater, Image, Line, LineUpdater, Mask, MutationEvent, Node, OffscreenCanvasCreator, Path, PathUpdater, Plane, Point, Polygon, Polyline, PolylineUpdater, PropertySyntax,
|
|
16144
|
+
export { AABB, AbstractRenderer, AbstractRendererPlugin, BUILT_IN_PROPERTIES, CSS, CSSGradientValue, CSSKeywordValue, CSSRGB, CSSStyleValue, CSSUnitValue, Camera, CameraEvent, CameraProjectionMode, CameraTrackingMode, CameraType, Canvas, CanvasEvent, Circle, CircleUpdater, ClipSpaceNearZ, CustomElement, CustomElementRegistry, CustomEvent, DefaultSceneGraphSelector, DefaultSceneGraphService, DisplayObject, Document, ERROR_MSG_METHOD_NOT_IMPLEMENTED, Element, ElementEvent, Ellipse, EllipseUpdater, EventService, EventTarget, FederatedEvent, FederatedMouseEvent, FederatedPointerEvent, FederatedWheelEvent, Fragment, Frustum, GradientType, Group, GroupUpdater, HTML, HTMLUpdater, Image, Line, LineUpdater, Mask, MutationEvent, Node, OffscreenCanvasCreator, Path, PathUpdater, Plane, Point, Polygon, Polyline, PolylineUpdater, PropertySyntax, Rect, RectUpdater, Rectangle, RenderReason, RenderingService, Shape, SortReason, Strategy, Text, TextService, TextUpdater, UnitType, attrModifiedEvent, computeLinearGradient, computeRadialGradient, convertToPath, createVec3, decompose, definedProps, deg2rad, deg2turn, destroyEvent, findClosestClipPathTarget, fromRotationTranslationScale, getAngle, getEuler, getOrCalculatePathTotalLength, grad2deg, insertedEvent, isBrowser, isCSSGradientValue, isCSSRGB, isCanvas, isDisplayObject, isFederatedEvent, isFillOrStrokeAffected, isPattern, mergeColors, parseColor, parseLength, parsePath, parseTransform, parsedTransformToMat4, propertyMetadataCache, rad2deg, removedEvent, resetEntityCounter, runtime, setDOMSize, translatePathToString, turn2deg, updateLocalTransform, updateWorldTransform };
|
|
16805
16145
|
//# sourceMappingURL=index.esm.js.map
|