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