@antv/g-lite 2.3.1 → 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 +362 -867
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +361 -867
- 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/TextService.d.ts +6 -0
- package/types/services/TextService.d.ts.map +1 -1
- package/types/services/interfaces.d.ts +4 -3
- package/types/services/interfaces.d.ts.map +1 -1
- package/types/utils/LRU.d.ts +36 -0
- package/types/utils/LRU.d.ts.map +1 -0
- package/types/utils/text.d.ts +1 -1
- package/types/utils/text.d.ts.map +1 -1
- package/types/utils/transform-mat4.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);
|
|
@@ -7986,7 +7405,7 @@ var SyncWaterfallHook = /*#__PURE__*/function () {
|
|
|
7986
7405
|
|
|
7987
7406
|
var genericFontFamilies = ['serif', 'sans-serif', 'monospace', 'cursive', 'fantasy', 'system-ui'];
|
|
7988
7407
|
var stringRegExp = /([\"\'])[^\'\"]+\1/;
|
|
7989
|
-
function
|
|
7408
|
+
function getFontAttr(attributes) {
|
|
7990
7409
|
var _attributes$fontSize = attributes.fontSize,
|
|
7991
7410
|
fontSize = _attributes$fontSize === void 0 ? 16 : _attributes$fontSize,
|
|
7992
7411
|
_attributes$fontFamil = attributes.fontFamily,
|
|
@@ -7997,6 +7416,21 @@ function toFontString(attributes) {
|
|
|
7997
7416
|
fontVariant = _attributes$fontVaria === void 0 ? 'normal' : _attributes$fontVaria,
|
|
7998
7417
|
_attributes$fontWeigh = attributes.fontWeight,
|
|
7999
7418
|
fontWeight = _attributes$fontWeigh === void 0 ? 'normal' : _attributes$fontWeigh;
|
|
7419
|
+
return {
|
|
7420
|
+
fontSize: fontSize,
|
|
7421
|
+
fontFamily: fontFamily,
|
|
7422
|
+
fontStyle: fontStyle,
|
|
7423
|
+
fontVariant: fontVariant,
|
|
7424
|
+
fontWeight: fontWeight
|
|
7425
|
+
};
|
|
7426
|
+
}
|
|
7427
|
+
var toFontString = memoize(function toFontStringRaw(attributes) {
|
|
7428
|
+
var _getFontAttr = getFontAttr(attributes),
|
|
7429
|
+
fontSize = _getFontAttr.fontSize,
|
|
7430
|
+
fontFamily = _getFontAttr.fontFamily,
|
|
7431
|
+
fontStyle = _getFontAttr.fontStyle,
|
|
7432
|
+
fontVariant = _getFontAttr.fontVariant,
|
|
7433
|
+
fontWeight = _getFontAttr.fontWeight;
|
|
8000
7434
|
|
|
8001
7435
|
// build canvas api font setting from individual components. Convert a numeric this.fontSize to px
|
|
8002
7436
|
// const fontSizeString: string = isNumber(fontSize) ? `${fontSize}px` : fontSize.toString();
|
|
@@ -8015,8 +7449,27 @@ function toFontString(attributes) {
|
|
|
8015
7449
|
fontFamilies[i] = _fontFamily;
|
|
8016
7450
|
}
|
|
8017
7451
|
return "".concat(fontStyle, " ").concat(fontVariant, " ").concat(fontWeight, " ").concat(fontSizeString, " ").concat(fontFamilies.join(','));
|
|
8018
|
-
}
|
|
7452
|
+
}, function (attributes) {
|
|
7453
|
+
var _getFontAttr2 = getFontAttr(attributes),
|
|
7454
|
+
fontSize = _getFontAttr2.fontSize,
|
|
7455
|
+
fontFamily = _getFontAttr2.fontFamily,
|
|
7456
|
+
fontStyle = _getFontAttr2.fontStyle,
|
|
7457
|
+
fontVariant = _getFontAttr2.fontVariant,
|
|
7458
|
+
fontWeight = _getFontAttr2.fontWeight;
|
|
7459
|
+
return "".concat(fontStyle, "_").concat(fontVariant, "_").concat(fontWeight, "_").concat(fontSize, "_").concat(fontFamily);
|
|
7460
|
+
});
|
|
8019
7461
|
|
|
7462
|
+
/**
|
|
7463
|
+
* Minimum scaling limit
|
|
7464
|
+
*
|
|
7465
|
+
* When `scale` is 0, the matrix will become an irreversible matrix,
|
|
7466
|
+
* and `NaN` will appear during matrix calculation and decomposition,
|
|
7467
|
+
* causing exceptions
|
|
7468
|
+
*/
|
|
7469
|
+
var MIN_SCALE = 0.000001;
|
|
7470
|
+
var clampScale = function clampScale(item) {
|
|
7471
|
+
return Math.max(item, MIN_SCALE);
|
|
7472
|
+
};
|
|
8020
7473
|
function createSkewMatrix(skewMatrix, skewX, skewY) {
|
|
8021
7474
|
// Create an identity matrix
|
|
8022
7475
|
mat4.identity(skewMatrix);
|
|
@@ -8030,19 +7483,29 @@ var $mat4_1 = mat4.create();
|
|
|
8030
7483
|
var $mat4_2 = mat4.create();
|
|
8031
7484
|
var parser = {
|
|
8032
7485
|
scale: function scale(d) {
|
|
8033
|
-
mat4.fromScaling($mat4_1, [d[0].value, d[1].value, 1])
|
|
7486
|
+
mat4.fromScaling($mat4_1, [d[0].value, d[1].value, 1].map(function (item) {
|
|
7487
|
+
return clampScale(item);
|
|
7488
|
+
}));
|
|
8034
7489
|
},
|
|
8035
7490
|
scaleX: function scaleX(d) {
|
|
8036
|
-
mat4.fromScaling($mat4_1, [d[0].value, 1, 1])
|
|
7491
|
+
mat4.fromScaling($mat4_1, [d[0].value, 1, 1].map(function (item) {
|
|
7492
|
+
return clampScale(item);
|
|
7493
|
+
}));
|
|
8037
7494
|
},
|
|
8038
7495
|
scaleY: function scaleY(d) {
|
|
8039
|
-
mat4.fromScaling($mat4_1, [1, d[0].value, 1])
|
|
7496
|
+
mat4.fromScaling($mat4_1, [1, d[0].value, 1].map(function (item) {
|
|
7497
|
+
return clampScale(item);
|
|
7498
|
+
}));
|
|
8040
7499
|
},
|
|
8041
7500
|
scaleZ: function scaleZ(d) {
|
|
8042
|
-
mat4.fromScaling($mat4_1, [1, 1, d[0].value])
|
|
7501
|
+
mat4.fromScaling($mat4_1, [1, 1, d[0].value].map(function (item) {
|
|
7502
|
+
return clampScale(item);
|
|
7503
|
+
}));
|
|
8043
7504
|
},
|
|
8044
7505
|
scale3d: function scale3d(d) {
|
|
8045
|
-
mat4.fromScaling($mat4_1, [d[0].value, d[1].value, d[2].value])
|
|
7506
|
+
mat4.fromScaling($mat4_1, [d[0].value, d[1].value, d[2].value].map(function (item) {
|
|
7507
|
+
return clampScale(item);
|
|
7508
|
+
}));
|
|
8046
7509
|
},
|
|
8047
7510
|
translate: function translate(d) {
|
|
8048
7511
|
mat4.fromTranslation($mat4_1, [d[0].value, d[1].value, 0]);
|
|
@@ -9014,7 +8477,8 @@ var FederatedWheelEvent = /*#__PURE__*/function (_FederatedMouseEvent) {
|
|
|
9014
8477
|
}(FederatedMouseEvent);
|
|
9015
8478
|
|
|
9016
8479
|
/**
|
|
9017
|
-
* @
|
|
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
|
|
9018
8482
|
*
|
|
9019
8483
|
* @example
|
|
9020
8484
|
const event = new CustomEvent('build', { detail: { prop1: 'xx' } });
|
|
@@ -9026,15 +8490,15 @@ var FederatedWheelEvent = /*#__PURE__*/function (_FederatedMouseEvent) {
|
|
|
9026
8490
|
circle.dispatchEvent(event);
|
|
9027
8491
|
*/
|
|
9028
8492
|
var CustomEvent = /*#__PURE__*/function (_FederatedEvent) {
|
|
9029
|
-
function CustomEvent(eventName,
|
|
8493
|
+
function CustomEvent(eventName, options) {
|
|
9030
8494
|
var _this;
|
|
9031
8495
|
_classCallCheck(this, CustomEvent);
|
|
9032
8496
|
_this = _callSuper(this, CustomEvent, [null]);
|
|
9033
8497
|
_this.type = eventName;
|
|
9034
|
-
_this.detail =
|
|
8498
|
+
_this.detail = options === null || options === void 0 ? void 0 : options.detail;
|
|
9035
8499
|
|
|
9036
8500
|
// compatible with G 3.0
|
|
9037
|
-
Object.assign(_this,
|
|
8501
|
+
Object.assign(_this, options);
|
|
9038
8502
|
return _this;
|
|
9039
8503
|
}
|
|
9040
8504
|
_inherits(CustomEvent, _FederatedEvent);
|
|
@@ -9044,7 +8508,7 @@ var CustomEvent = /*#__PURE__*/function (_FederatedEvent) {
|
|
|
9044
8508
|
/**
|
|
9045
8509
|
* Objects that can receive events and may have listeners for them.
|
|
9046
8510
|
* eg. Element, Canvas, DisplayObject
|
|
9047
|
-
* @
|
|
8511
|
+
* @docs https://developer.mozilla.org/en-US/docs/Web/API/EventTarget
|
|
9048
8512
|
*/
|
|
9049
8513
|
var EventTarget = /*#__PURE__*/function () {
|
|
9050
8514
|
function EventTarget() {
|
|
@@ -9128,7 +8592,9 @@ var EventTarget = /*#__PURE__*/function () {
|
|
|
9128
8592
|
}, {
|
|
9129
8593
|
key: "emit",
|
|
9130
8594
|
value: function emit(eventName, object) {
|
|
9131
|
-
this.dispatchEvent(new CustomEvent(eventName,
|
|
8595
|
+
this.dispatchEvent(new CustomEvent(eventName, {
|
|
8596
|
+
detail: object
|
|
8597
|
+
}));
|
|
9132
8598
|
}
|
|
9133
8599
|
}, {
|
|
9134
8600
|
key: "dispatchEventToSelf",
|
|
@@ -10545,14 +10011,15 @@ var RenderingService = /*#__PURE__*/function () {
|
|
|
10545
10011
|
}
|
|
10546
10012
|
}, {
|
|
10547
10013
|
key: "render",
|
|
10548
|
-
value: function render(
|
|
10014
|
+
value: function render(canvas, frame, rerenderCallback) {
|
|
10549
10015
|
var _this2 = this;
|
|
10016
|
+
var canvasConfig = canvas.getConfig();
|
|
10017
|
+
var renderingContext = this.context.renderingContext;
|
|
10550
10018
|
this.stats.total = 0;
|
|
10551
10019
|
this.stats.rendered = 0;
|
|
10552
10020
|
this.zIndexCounter = 0;
|
|
10553
|
-
var renderingContext = this.context.renderingContext;
|
|
10554
10021
|
this.globalRuntime.sceneGraphService.syncHierarchy(renderingContext.root);
|
|
10555
|
-
this.globalRuntime.sceneGraphService.
|
|
10022
|
+
this.globalRuntime.sceneGraphService.notifyMutationObservers(canvas);
|
|
10556
10023
|
if (renderingContext.renderReasons.size && this.inited) {
|
|
10557
10024
|
// @ts-ignore
|
|
10558
10025
|
renderingContext.dirtyRectangleRenderingDisabled = this.disableDirtyRectangleRendering();
|
|
@@ -10664,11 +10131,11 @@ var RenderingService = /*#__PURE__*/function () {
|
|
|
10664
10131
|
value: function destroy() {
|
|
10665
10132
|
this.inited = false;
|
|
10666
10133
|
this.hooks.destroy.call();
|
|
10667
|
-
this.globalRuntime.sceneGraphService.
|
|
10134
|
+
this.globalRuntime.sceneGraphService.clearMutationObserverData();
|
|
10668
10135
|
}
|
|
10669
10136
|
}, {
|
|
10670
|
-
key: "
|
|
10671
|
-
value: function
|
|
10137
|
+
key: "dirty",
|
|
10138
|
+
value: function dirty() {
|
|
10672
10139
|
// need re-render
|
|
10673
10140
|
this.context.renderingContext.renderReasons.add(RenderReason.DISPLAY_OBJECT_CHANGED);
|
|
10674
10141
|
}
|
|
@@ -10870,6 +10337,9 @@ var ElementEvent = /*#__PURE__*/function (ElementEvent) {
|
|
|
10870
10337
|
|
|
10871
10338
|
// #region Canvas
|
|
10872
10339
|
|
|
10340
|
+
/**
|
|
10341
|
+
* @deprecated https://developer.chrome.com/blog/mutation-events-deprecation
|
|
10342
|
+
*/
|
|
10873
10343
|
var MutationEvent = /*#__PURE__*/function (_FederatedEvent) {
|
|
10874
10344
|
function MutationEvent(typeArg, relatedNode, prevValue, newValue, attrName, attrChange, prevParsedValue, newParsedValue) {
|
|
10875
10345
|
var _this;
|
|
@@ -10921,9 +10391,6 @@ var $setPosition_ParentInvertMatrix = mat4.create();
|
|
|
10921
10391
|
var $setEulerAngles_InvParentRot = quat$1.create();
|
|
10922
10392
|
var $rotateLocal = quat$1.create();
|
|
10923
10393
|
var $rotate_ParentInvertRotation = quat$1.create();
|
|
10924
|
-
var $triggerPendingEvents_detail = {
|
|
10925
|
-
affectChildren: true
|
|
10926
|
-
};
|
|
10927
10394
|
|
|
10928
10395
|
/**
|
|
10929
10396
|
* update transform in scene graph
|
|
@@ -10933,9 +10400,7 @@ var $triggerPendingEvents_detail = {
|
|
|
10933
10400
|
var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
10934
10401
|
function DefaultSceneGraphService(runtime) {
|
|
10935
10402
|
_classCallCheck(this, DefaultSceneGraphService);
|
|
10936
|
-
|
|
10937
|
-
this.pendingEvents = new Map();
|
|
10938
|
-
this.boundsChangedEvent = new CustomEvent(ElementEvent.BOUNDS_CHANGED);
|
|
10403
|
+
this.mutationsMap = new Map();
|
|
10939
10404
|
this.displayObjectDependencyMap = new WeakMap();
|
|
10940
10405
|
this.runtime = runtime;
|
|
10941
10406
|
}
|
|
@@ -10994,7 +10459,7 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
10994
10459
|
}
|
|
10995
10460
|
if (isAttachToFragment) return;
|
|
10996
10461
|
if (isChildFragment) {
|
|
10997
|
-
this.
|
|
10462
|
+
this.dirtyFragment(child);
|
|
10998
10463
|
} else {
|
|
10999
10464
|
var transform = child.transformable;
|
|
11000
10465
|
if (transform) {
|
|
@@ -11422,22 +10887,12 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11422
10887
|
|
|
11423
10888
|
// #endregion transform
|
|
11424
10889
|
// #region bbox ----------------------------------------------------------------
|
|
11425
|
-
}, {
|
|
11426
|
-
key: "getTransformedGeometryBounds",
|
|
11427
|
-
value: function getTransformedGeometryBounds(element) {
|
|
11428
|
-
var render = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
11429
|
-
var existedAABB = arguments.length > 2 ? arguments[2] : undefined;
|
|
11430
|
-
var bounds = this.getGeometryBounds(element, render);
|
|
11431
|
-
if (!AABB.isEmpty(bounds)) {
|
|
11432
|
-
var aabb = existedAABB || new AABB();
|
|
11433
|
-
aabb.setFromTransformedAABB(bounds, this.getWorldTransform(element));
|
|
11434
|
-
return aabb;
|
|
11435
|
-
}
|
|
11436
|
-
return null;
|
|
11437
|
-
}
|
|
11438
10890
|
|
|
11439
10891
|
/**
|
|
11440
|
-
*
|
|
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
|
|
11441
10896
|
*/
|
|
11442
10897
|
}, {
|
|
11443
10898
|
key: "getGeometryBounds",
|
|
@@ -11453,6 +10908,27 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11453
10908
|
return bounds || new AABB();
|
|
11454
10909
|
}
|
|
11455
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
|
+
|
|
11456
10932
|
/**
|
|
11457
10933
|
* account for children in world space
|
|
11458
10934
|
*/
|
|
@@ -11653,12 +11129,12 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11653
11129
|
}, {
|
|
11654
11130
|
key: "dirtyWorldTransform",
|
|
11655
11131
|
value: function dirtyWorldTransform(element, transform) {
|
|
11656
|
-
this.
|
|
11132
|
+
this.dirtyWorldInternal(element, transform);
|
|
11657
11133
|
this.dirtyToRoot(element, true);
|
|
11658
11134
|
}
|
|
11659
11135
|
}, {
|
|
11660
|
-
key: "
|
|
11661
|
-
value: function
|
|
11136
|
+
key: "dirtyWorldInternal",
|
|
11137
|
+
value: function dirtyWorldInternal(element, transform) {
|
|
11662
11138
|
var _element$ownerDocumen3,
|
|
11663
11139
|
_this2 = this;
|
|
11664
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;
|
|
@@ -11668,7 +11144,7 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11668
11144
|
if (!enableAttributeUpdateOptimization) {
|
|
11669
11145
|
element.childNodes.forEach(function (child) {
|
|
11670
11146
|
var childTransform = child.transformable;
|
|
11671
|
-
_this2.
|
|
11147
|
+
_this2.dirtyWorldInternal(child, childTransform);
|
|
11672
11148
|
});
|
|
11673
11149
|
}
|
|
11674
11150
|
}
|
|
@@ -11696,11 +11172,25 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11696
11172
|
});
|
|
11697
11173
|
}
|
|
11698
11174
|
this.informDependentDisplayObjects(element);
|
|
11699
|
-
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
|
+
}
|
|
11700
11190
|
}
|
|
11701
11191
|
}, {
|
|
11702
|
-
key: "
|
|
11703
|
-
value: function
|
|
11192
|
+
key: "dirtyFragment",
|
|
11193
|
+
value: function dirtyFragment(element) {
|
|
11704
11194
|
var _dirty3, _ref7;
|
|
11705
11195
|
var transform = element.transformable;
|
|
11706
11196
|
if (transform) {
|
|
@@ -11710,65 +11200,22 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11710
11200
|
(_dirty3 = (_ref7 = element).dirty) === null || _dirty3 === void 0 || _dirty3.call(_ref7, true, true);
|
|
11711
11201
|
var length = element.childNodes.length;
|
|
11712
11202
|
for (var i = 0; i < length; i++) {
|
|
11713
|
-
this.
|
|
11714
|
-
}
|
|
11715
|
-
if (element.nodeName === Shape.FRAGMENT) {
|
|
11716
|
-
this.pendingEvents.set(element, false);
|
|
11203
|
+
this.dirtyFragment(element.childNodes[i]);
|
|
11717
11204
|
}
|
|
11718
11205
|
}
|
|
11719
11206
|
}, {
|
|
11720
|
-
key: "
|
|
11721
|
-
value: function
|
|
11722
|
-
var
|
|
11723
|
-
|
|
11724
|
-
var enableCancelEventPropagation;
|
|
11725
|
-
var enableAttributeUpdateOptimization;
|
|
11726
|
-
var trigger = function trigger(element, detail) {
|
|
11727
|
-
if (!element.isConnected || triggered.has(element) || element.nodeName === Shape.FRAGMENT) {
|
|
11728
|
-
return;
|
|
11729
|
-
}
|
|
11730
|
-
_this3.boundsChangedEvent.detail = detail;
|
|
11731
|
-
_this3.boundsChangedEvent.target = element;
|
|
11732
|
-
if (element.isMutationObserved) {
|
|
11733
|
-
element.dispatchEvent(_this3.boundsChangedEvent);
|
|
11734
|
-
} else {
|
|
11735
|
-
if (enableCancelEventPropagation === undefined) {
|
|
11736
|
-
var _element$ownerDocumen5;
|
|
11737
|
-
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;
|
|
11738
|
-
}
|
|
11739
|
-
element.ownerDocument.defaultView.dispatchEvent(_this3.boundsChangedEvent, true, enableCancelEventPropagation);
|
|
11740
|
-
}
|
|
11741
|
-
triggered.add(element);
|
|
11742
|
-
};
|
|
11743
|
-
this.pendingEvents.forEach(function (affectChildren, element) {
|
|
11744
|
-
if (element.nodeName === Shape.FRAGMENT) {
|
|
11745
|
-
return;
|
|
11746
|
-
}
|
|
11747
|
-
if (enableAttributeUpdateOptimization === undefined) {
|
|
11748
|
-
var _element$ownerDocumen6;
|
|
11749
|
-
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;
|
|
11750
|
-
}
|
|
11751
|
-
$triggerPendingEvents_detail.affectChildren = affectChildren;
|
|
11752
|
-
if (enableAttributeUpdateOptimization) {
|
|
11753
|
-
trigger(element, $triggerPendingEvents_detail);
|
|
11754
|
-
} else {
|
|
11755
|
-
// eslint-disable-next-line no-lonely-if
|
|
11756
|
-
if (affectChildren) {
|
|
11757
|
-
element.forEach(function (e) {
|
|
11758
|
-
trigger(e, $triggerPendingEvents_detail);
|
|
11759
|
-
});
|
|
11760
|
-
} else {
|
|
11761
|
-
trigger(element, $triggerPendingEvents_detail);
|
|
11762
|
-
}
|
|
11763
|
-
}
|
|
11207
|
+
key: "notifyMutationObservers",
|
|
11208
|
+
value: function notifyMutationObservers(canvas) {
|
|
11209
|
+
var event = new CustomEvent(ElementEvent.BOUNDS_CHANGED, {
|
|
11210
|
+
detail: Array.from(this.mutationsMap.values())
|
|
11764
11211
|
});
|
|
11765
|
-
|
|
11766
|
-
this.
|
|
11212
|
+
canvas.dispatchEvent(event, true, true);
|
|
11213
|
+
this.clearMutationObserverData();
|
|
11767
11214
|
}
|
|
11768
11215
|
}, {
|
|
11769
|
-
key: "
|
|
11770
|
-
value: function
|
|
11771
|
-
this.
|
|
11216
|
+
key: "clearMutationObserverData",
|
|
11217
|
+
value: function clearMutationObserverData() {
|
|
11218
|
+
this.mutationsMap.clear();
|
|
11772
11219
|
}
|
|
11773
11220
|
}, {
|
|
11774
11221
|
key: "updateDisplayObjectDependency",
|
|
@@ -11797,7 +11244,7 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11797
11244
|
key: "informDependentDisplayObjects",
|
|
11798
11245
|
value: function informDependentDisplayObjects(object) {
|
|
11799
11246
|
var _object$ownerDocument,
|
|
11800
|
-
|
|
11247
|
+
_this3 = this;
|
|
11801
11248
|
var dependencyMap = this.displayObjectDependencyMap.get(object);
|
|
11802
11249
|
if (!dependencyMap) {
|
|
11803
11250
|
return;
|
|
@@ -11805,11 +11252,11 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11805
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;
|
|
11806
11253
|
Object.keys(dependencyMap).forEach(function (name) {
|
|
11807
11254
|
dependencyMap[name].forEach(function (target) {
|
|
11808
|
-
|
|
11809
|
-
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);
|
|
11810
11257
|
if (target.isCustomElement && target.isConnected) {
|
|
11811
11258
|
if (target.attributeChangedCallback) {
|
|
11812
|
-
target.attributeChangedCallback(name,
|
|
11259
|
+
target.attributeChangedCallback(name, _this3, _this3);
|
|
11813
11260
|
}
|
|
11814
11261
|
}
|
|
11815
11262
|
});
|
|
@@ -11818,6 +11265,94 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
11818
11265
|
}]);
|
|
11819
11266
|
}();
|
|
11820
11267
|
|
|
11268
|
+
/**
|
|
11269
|
+
* A classic LRU (Least Recently Used) cache implementation.
|
|
11270
|
+
* It evicts the least recently used item when the cache is full.
|
|
11271
|
+
*
|
|
11272
|
+
* It uses a Map for O(1) key-based access
|
|
11273
|
+
* to maintain the usage order of items.
|
|
11274
|
+
*
|
|
11275
|
+
* 通过利用 JavaScript 内置 Map 的特性(按插入顺序迭代),我们不再需要手动维护一个双向链表
|
|
11276
|
+
*/
|
|
11277
|
+
var LRU = /*#__PURE__*/function () {
|
|
11278
|
+
function LRU(capacity) {
|
|
11279
|
+
_classCallCheck(this, LRU);
|
|
11280
|
+
if (capacity <= 0) {
|
|
11281
|
+
throw new Error('LRU capacity must be a positive number.');
|
|
11282
|
+
}
|
|
11283
|
+
this.capacity = capacity;
|
|
11284
|
+
// Using a Map directly simplifies the implementation significantly.
|
|
11285
|
+
// A Map in modern JS engines iterates in insertion order, which is exactly what we need.
|
|
11286
|
+
this.cache = new Map();
|
|
11287
|
+
}
|
|
11288
|
+
|
|
11289
|
+
/**
|
|
11290
|
+
* Retrieves an item from the cache. Marks the item as recently used.
|
|
11291
|
+
* @param key The key of the item to retrieve.
|
|
11292
|
+
* @returns The value of the item, or undefined if not found.
|
|
11293
|
+
*/
|
|
11294
|
+
return _createClass(LRU, [{
|
|
11295
|
+
key: "get",
|
|
11296
|
+
value: function get(key) {
|
|
11297
|
+
if (!this.cache.has(key)) {
|
|
11298
|
+
return undefined;
|
|
11299
|
+
}
|
|
11300
|
+
|
|
11301
|
+
// Get the value.
|
|
11302
|
+
var value = this.cache.get(key);
|
|
11303
|
+
|
|
11304
|
+
// Mark as recently used by deleting and re-setting the key.
|
|
11305
|
+
// This moves the key to the end of the Map's internal order.
|
|
11306
|
+
this.cache["delete"](key);
|
|
11307
|
+
this.cache.set(key, value);
|
|
11308
|
+
return value;
|
|
11309
|
+
}
|
|
11310
|
+
|
|
11311
|
+
/**
|
|
11312
|
+
* Adds or updates an item in the cache. Marks the item as recently used.
|
|
11313
|
+
* If the cache is full, it removes the least recently used item.
|
|
11314
|
+
* @param key The key of the item.
|
|
11315
|
+
* @param value The value of the item.
|
|
11316
|
+
*/
|
|
11317
|
+
}, {
|
|
11318
|
+
key: "put",
|
|
11319
|
+
value: function put(key, value) {
|
|
11320
|
+
// If the key already exists, delete it first to ensure it's moved to the end.
|
|
11321
|
+
if (this.cache.has(key)) {
|
|
11322
|
+
this.cache["delete"](key);
|
|
11323
|
+
}
|
|
11324
|
+
|
|
11325
|
+
// Add the new item. It will be the most recently used.
|
|
11326
|
+
this.cache.set(key, value);
|
|
11327
|
+
|
|
11328
|
+
// Check if the cache has exceeded its capacity.
|
|
11329
|
+
if (this.cache.size > this.capacity) {
|
|
11330
|
+
// Evict the least recently used item, which is the first one in the Map's iteration order.
|
|
11331
|
+
var leastRecentlyUsedKey = this.cache.keys().next().value;
|
|
11332
|
+
this.cache["delete"](leastRecentlyUsedKey);
|
|
11333
|
+
}
|
|
11334
|
+
}
|
|
11335
|
+
|
|
11336
|
+
/**
|
|
11337
|
+
* Returns the current number of items in the cache.
|
|
11338
|
+
*/
|
|
11339
|
+
}, {
|
|
11340
|
+
key: "len",
|
|
11341
|
+
value: function len() {
|
|
11342
|
+
return this.cache.size;
|
|
11343
|
+
}
|
|
11344
|
+
|
|
11345
|
+
/**
|
|
11346
|
+
* Clears all items from the cache.
|
|
11347
|
+
*/
|
|
11348
|
+
}, {
|
|
11349
|
+
key: "clear",
|
|
11350
|
+
value: function clear() {
|
|
11351
|
+
this.cache.clear();
|
|
11352
|
+
}
|
|
11353
|
+
}]);
|
|
11354
|
+
}();
|
|
11355
|
+
|
|
11821
11356
|
var TEXT_METRICS = {
|
|
11822
11357
|
MetricsString: '|ÉqÅ',
|
|
11823
11358
|
BaselineSymbol: 'M',
|
|
@@ -11904,10 +11439,16 @@ var TextService = /*#__PURE__*/function () {
|
|
|
11904
11439
|
return next;
|
|
11905
11440
|
};
|
|
11906
11441
|
this.runtime = runtime;
|
|
11442
|
+
this.charWidthCache = new LRU(100);
|
|
11907
11443
|
}
|
|
11908
11444
|
return _createClass(TextService, [{
|
|
11909
11445
|
key: "measureFont",
|
|
11910
11446
|
value:
|
|
11447
|
+
/**
|
|
11448
|
+
* A global cache for character widths, keyed by font string.
|
|
11449
|
+
* e.g. { '16px Arial': { 'a': 8, 'b': 9 } }
|
|
11450
|
+
*/
|
|
11451
|
+
|
|
11911
11452
|
/**
|
|
11912
11453
|
* Calculates the ascent, descent and fontSize of a given font-style.
|
|
11913
11454
|
*/
|
|
@@ -12129,9 +11670,19 @@ var TextService = /*#__PURE__*/function () {
|
|
|
12129
11670
|
var currentLineWidth = 0;
|
|
12130
11671
|
// @see https://github.com/antvis/G/issues/1932
|
|
12131
11672
|
var prevLineLastCharIndex = -1;
|
|
12132
|
-
|
|
12133
|
-
|
|
12134
|
-
|
|
11673
|
+
|
|
11674
|
+
// --- 优化核心 ---
|
|
11675
|
+
// 1. 获取或创建当前字体对应的字符缓存
|
|
11676
|
+
var font = toFontString(parsedStyle);
|
|
11677
|
+
var charCache = this.charWidthCache.get(font);
|
|
11678
|
+
if (!charCache) {
|
|
11679
|
+
charCache = new LRU(500);
|
|
11680
|
+
this.charWidthCache.put(font, charCache);
|
|
11681
|
+
}
|
|
11682
|
+
|
|
11683
|
+
// 2. calcWidth 现在直接使用持久化的 charCache
|
|
11684
|
+
var calcWidth = function calcWidth(_char2) {
|
|
11685
|
+
return _this2.getFromCache(_char2, letterSpacing, charCache, context);
|
|
12135
11686
|
};
|
|
12136
11687
|
var ellipsisWidth = calcWidth(ellipsis);
|
|
12137
11688
|
|
|
@@ -12177,11 +11728,11 @@ var TextService = /*#__PURE__*/function () {
|
|
|
12177
11728
|
lines[lineIndex] = result.lineTxt + ellipsis;
|
|
12178
11729
|
}
|
|
12179
11730
|
for (var i = 0; i < chars.length; i++) {
|
|
12180
|
-
var
|
|
11731
|
+
var _char3 = chars[i];
|
|
12181
11732
|
var prevChar = chars[i - 1];
|
|
12182
11733
|
var nextChar = chars[i + 1];
|
|
12183
|
-
var charWidth = calcWidth(
|
|
12184
|
-
if (this.isNewline(
|
|
11734
|
+
var charWidth = calcWidth(_char3);
|
|
11735
|
+
if (this.isNewline(_char3)) {
|
|
12185
11736
|
// exceed maxLines, break immediately
|
|
12186
11737
|
if (currentLineIndex + 1 >= maxLines) {
|
|
12187
11738
|
if (i < chars.length - 1) {
|
|
@@ -12211,10 +11762,10 @@ var TextService = /*#__PURE__*/function () {
|
|
|
12211
11762
|
break;
|
|
12212
11763
|
}
|
|
12213
11764
|
i = result.txtLastCharIndex + 1;
|
|
12214
|
-
|
|
11765
|
+
_char3 = chars[i];
|
|
12215
11766
|
prevChar = chars[i - 1];
|
|
12216
11767
|
nextChar = chars[i + 1];
|
|
12217
|
-
charWidth = calcWidth(
|
|
11768
|
+
charWidth = calcWidth(_char3);
|
|
12218
11769
|
}
|
|
12219
11770
|
if (currentLineIndex + 1 >= maxLines) {
|
|
12220
11771
|
appendEllipsis(currentLineIndex, i - 1);
|
|
@@ -12225,38 +11776,38 @@ var TextService = /*#__PURE__*/function () {
|
|
|
12225
11776
|
currentLineIndex += 1;
|
|
12226
11777
|
currentLineWidth = 0;
|
|
12227
11778
|
lines[currentLineIndex] = '';
|
|
12228
|
-
if (this.isBreakingSpace(
|
|
11779
|
+
if (this.isBreakingSpace(_char3)) {
|
|
12229
11780
|
continue;
|
|
12230
11781
|
}
|
|
12231
|
-
if (!this.canBreakInLastChar(
|
|
11782
|
+
if (!this.canBreakInLastChar(_char3)) {
|
|
12232
11783
|
lines = this.trimToBreakable(lines);
|
|
12233
11784
|
currentLineWidth = this.sumTextWidthByCache(lines[currentLineIndex] || '', calcWidth);
|
|
12234
11785
|
}
|
|
12235
|
-
if (this.shouldBreakByKinsokuShorui(
|
|
11786
|
+
if (this.shouldBreakByKinsokuShorui(_char3, nextChar)) {
|
|
12236
11787
|
lines = this.trimByKinsokuShorui(lines);
|
|
12237
11788
|
currentLineWidth += calcWidth(prevChar || '');
|
|
12238
11789
|
}
|
|
12239
11790
|
}
|
|
12240
11791
|
currentLineWidth += charWidth;
|
|
12241
|
-
lines[currentLineIndex] +=
|
|
11792
|
+
lines[currentLineIndex] += _char3;
|
|
12242
11793
|
}
|
|
12243
11794
|
return lines.join('\n');
|
|
12244
11795
|
}
|
|
12245
11796
|
}, {
|
|
12246
11797
|
key: "isBreakingSpace",
|
|
12247
|
-
value: function isBreakingSpace(
|
|
12248
|
-
if (typeof
|
|
11798
|
+
value: function isBreakingSpace(_char4) {
|
|
11799
|
+
if (typeof _char4 !== 'string') {
|
|
12249
11800
|
return false;
|
|
12250
11801
|
}
|
|
12251
|
-
return TEXT_METRICS.BreakingSpaces.indexOf(
|
|
11802
|
+
return TEXT_METRICS.BreakingSpaces.indexOf(_char4.charCodeAt(0)) >= 0;
|
|
12252
11803
|
}
|
|
12253
11804
|
}, {
|
|
12254
11805
|
key: "isNewline",
|
|
12255
|
-
value: function isNewline(
|
|
12256
|
-
if (typeof
|
|
11806
|
+
value: function isNewline(_char5) {
|
|
11807
|
+
if (typeof _char5 !== 'string') {
|
|
12257
11808
|
return false;
|
|
12258
11809
|
}
|
|
12259
|
-
return TEXT_METRICS.Newlines.indexOf(
|
|
11810
|
+
return TEXT_METRICS.Newlines.indexOf(_char5.charCodeAt(0)) >= 0;
|
|
12260
11811
|
}
|
|
12261
11812
|
}, {
|
|
12262
11813
|
key: "trimToBreakable",
|
|
@@ -12275,8 +11826,8 @@ var TextService = /*#__PURE__*/function () {
|
|
|
12275
11826
|
}
|
|
12276
11827
|
}, {
|
|
12277
11828
|
key: "canBreakInLastChar",
|
|
12278
|
-
value: function canBreakInLastChar(
|
|
12279
|
-
if (
|
|
11829
|
+
value: function canBreakInLastChar(_char6) {
|
|
11830
|
+
if (_char6 && LATIN_REGEX.test(_char6)) return false;
|
|
12280
11831
|
return true;
|
|
12281
11832
|
}
|
|
12282
11833
|
}, {
|
|
@@ -12297,15 +11848,21 @@ var TextService = /*#__PURE__*/function () {
|
|
|
12297
11848
|
}, {
|
|
12298
11849
|
key: "getFromCache",
|
|
12299
11850
|
value: function getFromCache(key, letterSpacing, cache, context) {
|
|
12300
|
-
var width = cache
|
|
11851
|
+
var width = cache.get(key);
|
|
12301
11852
|
if (typeof width !== 'number') {
|
|
12302
11853
|
var spacing = key.length * letterSpacing;
|
|
12303
11854
|
var metrics = context.measureText(key);
|
|
12304
11855
|
width = metrics.width + spacing;
|
|
12305
|
-
cache
|
|
11856
|
+
cache.put(key, width);
|
|
12306
11857
|
}
|
|
12307
11858
|
return width;
|
|
12308
11859
|
}
|
|
11860
|
+
}, {
|
|
11861
|
+
key: "clearCache",
|
|
11862
|
+
value: function clearCache() {
|
|
11863
|
+
this.fontMetricsCache = {};
|
|
11864
|
+
this.charWidthCache.clear();
|
|
11865
|
+
}
|
|
12309
11866
|
}]);
|
|
12310
11867
|
}();
|
|
12311
11868
|
|
|
@@ -12424,6 +11981,10 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
12424
11981
|
dirtyChildren: [],
|
|
12425
11982
|
dirtyReason: undefined
|
|
12426
11983
|
};
|
|
11984
|
+
/**
|
|
11985
|
+
* @deprecated Legacy property for RBush spatial indexing.
|
|
11986
|
+
* Will be removed in future versions.
|
|
11987
|
+
*/
|
|
12427
11988
|
_this.rBushNode = {
|
|
12428
11989
|
aabb: undefined
|
|
12429
11990
|
};
|
|
@@ -12479,16 +12040,23 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
12479
12040
|
key: "dirty",
|
|
12480
12041
|
value:
|
|
12481
12042
|
/**
|
|
12482
|
-
*
|
|
12483
|
-
*
|
|
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`
|
|
12484
12051
|
*/
|
|
12485
12052
|
function dirty() {
|
|
12486
|
-
var
|
|
12487
|
-
var
|
|
12488
|
-
this.renderable.dirty =
|
|
12489
|
-
if (
|
|
12490
|
-
this.renderable.boundsDirty =
|
|
12491
|
-
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;
|
|
12492
12060
|
}
|
|
12493
12061
|
}
|
|
12494
12062
|
}, {
|
|
@@ -12882,12 +12450,18 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
12882
12450
|
}, {
|
|
12883
12451
|
key: "getGeometryBounds",
|
|
12884
12452
|
value: function getGeometryBounds() {
|
|
12885
|
-
|
|
12453
|
+
var render = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
12454
|
+
return runtime.sceneGraphService.getGeometryBounds(this, render);
|
|
12886
12455
|
}
|
|
12456
|
+
|
|
12457
|
+
/**
|
|
12458
|
+
* get geometry bounds in world space, not accounting for children
|
|
12459
|
+
*/
|
|
12887
12460
|
}, {
|
|
12888
|
-
key: "
|
|
12889
|
-
value: function
|
|
12890
|
-
|
|
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);
|
|
12891
12465
|
}
|
|
12892
12466
|
|
|
12893
12467
|
/**
|
|
@@ -12898,6 +12472,11 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
12898
12472
|
value: function getBounds() {
|
|
12899
12473
|
return runtime.sceneGraphService.getBounds(this);
|
|
12900
12474
|
}
|
|
12475
|
+
}, {
|
|
12476
|
+
key: "getRenderBounds",
|
|
12477
|
+
value: function getRenderBounds() {
|
|
12478
|
+
return runtime.sceneGraphService.getBounds(this, true);
|
|
12479
|
+
}
|
|
12901
12480
|
|
|
12902
12481
|
/**
|
|
12903
12482
|
* get bounds in local space, account for children
|
|
@@ -12999,7 +12578,7 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
12999
12578
|
*/
|
|
13000
12579
|
}, {
|
|
13001
12580
|
key: "setAttribute",
|
|
13002
|
-
value: function setAttribute(attributeName, value
|
|
12581
|
+
value: function setAttribute(attributeName, value) {
|
|
13003
12582
|
this.attributes[attributeName] = value;
|
|
13004
12583
|
}
|
|
13005
12584
|
}, {
|
|
@@ -13233,9 +12812,6 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
|
|
|
13233
12812
|
|
|
13234
12813
|
// redraw at next frame
|
|
13235
12814
|
this.dirty();
|
|
13236
|
-
|
|
13237
|
-
// return;
|
|
13238
|
-
|
|
13239
12815
|
var newParsedValue = this.parsedStyle[name];
|
|
13240
12816
|
if (this.isConnected) {
|
|
13241
12817
|
attrModifiedEvent.relatedNode = this;
|
|
@@ -14802,7 +14378,7 @@ var Text = /*#__PURE__*/function (_DisplayObject) {
|
|
|
14802
14378
|
}
|
|
14803
14379
|
}]);
|
|
14804
14380
|
}(DisplayObject);
|
|
14805
|
-
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']));
|
|
14806
14382
|
|
|
14807
14383
|
/**
|
|
14808
14384
|
* canvas.customElements
|
|
@@ -15064,32 +14640,47 @@ var Document = /*#__PURE__*/function (_Node) {
|
|
|
15064
14640
|
}
|
|
15065
14641
|
|
|
15066
14642
|
/**
|
|
15067
|
-
* Picking 2D graphics
|
|
14643
|
+
* Picking 2D graphics by traversing elements and checking bounding boxes.
|
|
15068
14644
|
*/
|
|
15069
14645
|
}, {
|
|
15070
14646
|
key: "elementsFromBBox",
|
|
15071
14647
|
value: function elementsFromBBox(minX, minY, maxX, maxY) {
|
|
15072
|
-
var rBush = this.defaultView.context.rBushRoot;
|
|
15073
|
-
var rBushNodes = rBush.search({
|
|
15074
|
-
minX: minX,
|
|
15075
|
-
minY: minY,
|
|
15076
|
-
maxX: maxX,
|
|
15077
|
-
maxY: maxY
|
|
15078
|
-
});
|
|
15079
14648
|
var hitTestList = [];
|
|
15080
|
-
rBushNodes.forEach(function (_ref2) {
|
|
15081
|
-
var displayObject = _ref2.displayObject;
|
|
15082
|
-
var _displayObject$parsed = displayObject.parsedStyle.pointerEvents,
|
|
15083
|
-
pointerEvents = _displayObject$parsed === void 0 ? 'auto' : _displayObject$parsed;
|
|
15084
14649
|
|
|
15085
|
-
|
|
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`
|
|
15086
14659
|
// @see https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events
|
|
15087
14660
|
var isVisibilityAffected = ['auto', 'visiblepainted', 'visiblefill', 'visiblestroke', 'visible'].includes(pointerEvents);
|
|
15088
|
-
if (
|
|
15089
|
-
|
|
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
|
+
}
|
|
15090
14668
|
}
|
|
15091
|
-
|
|
15092
|
-
|
|
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)
|
|
15093
14684
|
hitTestList.sort(function (a, b) {
|
|
15094
14685
|
return b.sortable.renderOrder - a.sortable.renderOrder;
|
|
15095
14686
|
});
|
|
@@ -15821,32 +15412,34 @@ var FrustumCullingStrategy = /*#__PURE__*/function () {
|
|
|
15821
15412
|
}]);
|
|
15822
15413
|
}();
|
|
15823
15414
|
|
|
15415
|
+
/**
|
|
15416
|
+
* PrepareRendererPlugin handles rendering preparation tasks
|
|
15417
|
+
* Simplified implementation focused on core rendering needs
|
|
15418
|
+
*/
|
|
15824
15419
|
var PrepareRendererPlugin = /*#__PURE__*/function () {
|
|
15825
15420
|
function PrepareRendererPlugin() {
|
|
15826
15421
|
_classCallCheck(this, PrepareRendererPlugin);
|
|
15827
|
-
this.
|
|
15422
|
+
this.mutationRecords = [];
|
|
15828
15423
|
this.isFirstTimeRendering = true;
|
|
15829
|
-
this.syncing = false;
|
|
15830
15424
|
this.isFirstTimeRenderingFinished = false;
|
|
15831
15425
|
}
|
|
15832
15426
|
return _createClass(PrepareRendererPlugin, [{
|
|
15833
15427
|
key: "apply",
|
|
15834
15428
|
value: function apply(context) {
|
|
15835
15429
|
var _this = this,
|
|
15836
|
-
_runtime$globalThis$r
|
|
15837
|
-
|
|
15838
|
-
|
|
15839
|
-
renderingService = context.renderingService,
|
|
15840
|
-
renderingContext = context.renderingContext,
|
|
15841
|
-
rBushRoot = context.rBushRoot;
|
|
15430
|
+
_runtime$globalThis$r;
|
|
15431
|
+
var renderingService = context.renderingService,
|
|
15432
|
+
renderingContext = context.renderingContext;
|
|
15842
15433
|
var canvas = renderingContext.root.ownerDocument.defaultView;
|
|
15843
|
-
this.rBush = rBushRoot;
|
|
15844
15434
|
var handleAttributeChanged = function handleAttributeChanged(e) {
|
|
15845
|
-
renderingService.
|
|
15435
|
+
renderingService.dirty();
|
|
15846
15436
|
};
|
|
15847
15437
|
var handleBoundsChanged = function handleBoundsChanged(e) {
|
|
15848
|
-
_this
|
|
15849
|
-
|
|
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();
|
|
15850
15443
|
};
|
|
15851
15444
|
var handleMounted = function handleMounted(e) {
|
|
15852
15445
|
var object = e.target;
|
|
@@ -15856,13 +15449,10 @@ var PrepareRendererPlugin = /*#__PURE__*/function () {
|
|
|
15856
15449
|
};
|
|
15857
15450
|
var handleUnmounted = function handleUnmounted(e) {
|
|
15858
15451
|
var object = e.target;
|
|
15859
|
-
|
|
15860
|
-
|
|
15861
|
-
_this.rBush.remove(rBushNode.aabb);
|
|
15862
|
-
}
|
|
15863
|
-
_this.syncTasks["delete"](object);
|
|
15452
|
+
|
|
15453
|
+
// No spatial index cleanup needed
|
|
15864
15454
|
runtime.sceneGraphService.dirtyToRoot(object);
|
|
15865
|
-
renderingService.
|
|
15455
|
+
renderingService.dirty();
|
|
15866
15456
|
};
|
|
15867
15457
|
renderingService.hooks.init.tap(PrepareRendererPlugin.tag, function () {
|
|
15868
15458
|
canvas.addEventListener(ElementEvent.MOUNTED, handleMounted);
|
|
@@ -15875,109 +15465,20 @@ var PrepareRendererPlugin = /*#__PURE__*/function () {
|
|
|
15875
15465
|
canvas.removeEventListener(ElementEvent.UNMOUNTED, handleUnmounted);
|
|
15876
15466
|
canvas.removeEventListener(ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
15877
15467
|
canvas.removeEventListener(ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
|
|
15878
|
-
_this.
|
|
15468
|
+
_this.mutationRecords = [];
|
|
15879
15469
|
});
|
|
15880
15470
|
var ric = (_runtime$globalThis$r = runtime.globalThis.requestIdleCallback) !== null && _runtime$globalThis$r !== void 0 ? _runtime$globalThis$r : raf.bind(runtime.globalThis);
|
|
15881
|
-
var enableRICSyncRTree = ((_config$future = config.future) === null || _config$future === void 0 ? void 0 : _config$future.experimentalRICSyncRTree) === true;
|
|
15882
15471
|
renderingService.hooks.endFrame.tap(PrepareRendererPlugin.tag, function () {
|
|
15883
15472
|
if (_this.isFirstTimeRendering) {
|
|
15884
15473
|
_this.isFirstTimeRendering = false;
|
|
15885
|
-
_this.syncing = true;
|
|
15886
15474
|
ric(function () {
|
|
15887
|
-
_this.syncRTree(true);
|
|
15888
15475
|
_this.isFirstTimeRenderingFinished = true;
|
|
15889
15476
|
});
|
|
15890
|
-
} else if (enableRICSyncRTree && runtime.globalThis.requestIdleCallback && runtime.globalThis.cancelIdleCallback) {
|
|
15891
|
-
runtime.globalThis.cancelIdleCallback(_this.ricSyncRTreeId);
|
|
15892
|
-
_this.ricSyncRTreeId = runtime.globalThis.requestIdleCallback(function () {
|
|
15893
|
-
return _this.syncRTree();
|
|
15894
|
-
});
|
|
15895
|
-
} else {
|
|
15896
|
-
_this.syncRTree();
|
|
15897
|
-
}
|
|
15898
|
-
});
|
|
15899
|
-
}
|
|
15900
|
-
}, {
|
|
15901
|
-
key: "syncNode",
|
|
15902
|
-
value: function syncNode(node) {
|
|
15903
|
-
var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
15904
|
-
if (!node.isConnected) return;
|
|
15905
|
-
var rBushNode = node.rBushNode;
|
|
15906
|
-
|
|
15907
|
-
// clear dirty node
|
|
15908
|
-
if (rBushNode.aabb) this.rBush.remove(rBushNode.aabb);
|
|
15909
|
-
var renderBounds = node.getRenderBounds();
|
|
15910
|
-
if (renderBounds) {
|
|
15911
|
-
var renderable = node.renderable;
|
|
15912
|
-
if (force) {
|
|
15913
|
-
if (!renderable.dirtyRenderBounds) {
|
|
15914
|
-
renderable.dirtyRenderBounds = new AABB();
|
|
15915
|
-
}
|
|
15916
|
-
// save last dirty aabb
|
|
15917
|
-
renderable.dirtyRenderBounds.update(renderBounds.center, renderBounds.halfExtents);
|
|
15918
|
-
}
|
|
15919
|
-
var _renderBounds$getMin = renderBounds.getMin(),
|
|
15920
|
-
_renderBounds$getMin2 = _slicedToArray(_renderBounds$getMin, 2),
|
|
15921
|
-
minX = _renderBounds$getMin2[0],
|
|
15922
|
-
minY = _renderBounds$getMin2[1];
|
|
15923
|
-
var _renderBounds$getMax = renderBounds.getMax(),
|
|
15924
|
-
_renderBounds$getMax2 = _slicedToArray(_renderBounds$getMax, 2),
|
|
15925
|
-
maxX = _renderBounds$getMax2[0],
|
|
15926
|
-
maxY = _renderBounds$getMax2[1];
|
|
15927
|
-
if (!rBushNode.aabb) {
|
|
15928
|
-
rBushNode.aabb = {};
|
|
15929
|
-
}
|
|
15930
|
-
rBushNode.aabb.displayObject = node;
|
|
15931
|
-
rBushNode.aabb.minX = minX;
|
|
15932
|
-
rBushNode.aabb.minY = minY;
|
|
15933
|
-
rBushNode.aabb.maxX = maxX;
|
|
15934
|
-
rBushNode.aabb.maxY = maxY;
|
|
15935
|
-
}
|
|
15936
|
-
if (rBushNode.aabb) {
|
|
15937
|
-
// TODO: NaN occurs when width/height of Rect is 0
|
|
15938
|
-
if (!isNaN(rBushNode.aabb.maxX) && !isNaN(rBushNode.aabb.maxX) && !isNaN(rBushNode.aabb.minX) && !isNaN(rBushNode.aabb.minY)) {
|
|
15939
|
-
return rBushNode.aabb;
|
|
15940
|
-
}
|
|
15941
|
-
}
|
|
15942
|
-
}
|
|
15943
|
-
}, {
|
|
15944
|
-
key: "syncRTree",
|
|
15945
|
-
value: function syncRTree() {
|
|
15946
|
-
var _this2 = this;
|
|
15947
|
-
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
15948
|
-
if (!force && (this.syncing || this.syncTasks.size === 0)) {
|
|
15949
|
-
return;
|
|
15950
|
-
}
|
|
15951
|
-
this.syncing = true;
|
|
15952
|
-
|
|
15953
|
-
// bounds changed, need re-inserting its children
|
|
15954
|
-
var bulk = [];
|
|
15955
|
-
var synced = new Set();
|
|
15956
|
-
var sync = function sync(node) {
|
|
15957
|
-
if (!synced.has(node) && node.renderable) {
|
|
15958
|
-
var aabb = _this2.syncNode(node, force);
|
|
15959
|
-
if (aabb) {
|
|
15960
|
-
bulk.push(aabb);
|
|
15961
|
-
synced.add(node);
|
|
15962
|
-
}
|
|
15963
|
-
}
|
|
15964
|
-
};
|
|
15965
|
-
this.syncTasks.forEach(function (affectChildren, node) {
|
|
15966
|
-
if (affectChildren) {
|
|
15967
|
-
node.forEach(sync);
|
|
15968
15477
|
}
|
|
15969
|
-
var parent = node;
|
|
15970
|
-
while (parent) {
|
|
15971
|
-
sync(parent);
|
|
15972
|
-
parent = parent.parentElement;
|
|
15973
|
-
}
|
|
15974
|
-
});
|
|
15975
15478
|
|
|
15976
|
-
|
|
15977
|
-
|
|
15978
|
-
|
|
15979
|
-
bulk.length = 0;
|
|
15980
|
-
this.syncing = false;
|
|
15479
|
+
// Clear mutation records after each frame
|
|
15480
|
+
_this.mutationRecords = [];
|
|
15481
|
+
});
|
|
15981
15482
|
}
|
|
15982
15483
|
}]);
|
|
15983
15484
|
}();
|
|
@@ -16276,10 +15777,7 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16276
15777
|
this.getContextService().destroy();
|
|
16277
15778
|
|
|
16278
15779
|
// clear root after render service destroyed
|
|
16279
|
-
|
|
16280
|
-
// clear rbush
|
|
16281
|
-
this.context.rBushRoot.clear();
|
|
16282
|
-
}
|
|
15780
|
+
|
|
16283
15781
|
if (!skipTriggerEvent) {
|
|
16284
15782
|
this.dispatchEvent(new CustomEvent(CanvasEvent.AFTER_DESTROY), enableCancelEventPropagation, enableCancelEventPropagation);
|
|
16285
15783
|
}
|
|
@@ -16298,6 +15796,7 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16298
15796
|
clearEventRetain(insertedEvent);
|
|
16299
15797
|
clearEventRetain(removedEvent);
|
|
16300
15798
|
clearEventRetain(destroyEvent);
|
|
15799
|
+
runtime.textService.clearCache();
|
|
16301
15800
|
}
|
|
16302
15801
|
|
|
16303
15802
|
/**
|
|
@@ -16378,7 +15877,6 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16378
15877
|
value: function render(frame) {
|
|
16379
15878
|
var _this$getConfig$futur2,
|
|
16380
15879
|
_this4 = this;
|
|
16381
|
-
// console.log('render ----------------------');
|
|
16382
15880
|
if (frame) {
|
|
16383
15881
|
beforeRenderEvent.detail = frame;
|
|
16384
15882
|
afterRenderEvent.detail = frame;
|
|
@@ -16386,7 +15884,7 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16386
15884
|
var enableCancelEventPropagation = ((_this$getConfig$futur2 = this.getConfig().future) === null || _this$getConfig$futur2 === void 0 ? void 0 : _this$getConfig$futur2.experimentalCancelEventPropagation) === true;
|
|
16387
15885
|
this.dispatchEvent(beforeRenderEvent, enableCancelEventPropagation, enableCancelEventPropagation);
|
|
16388
15886
|
var renderingService = this.getRenderingService();
|
|
16389
|
-
renderingService.render(this
|
|
15887
|
+
renderingService.render(this, frame, function () {
|
|
16390
15888
|
// trigger actual rerender event
|
|
16391
15889
|
// @see https://github.com/antvis/G/issues/1268
|
|
16392
15890
|
_this4.dispatchEvent(rerenderEvent, enableCancelEventPropagation, enableCancelEventPropagation);
|
|
@@ -16416,9 +15914,6 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16416
15914
|
this.inited = false;
|
|
16417
15915
|
this.readyPromise = undefined;
|
|
16418
15916
|
|
|
16419
|
-
// FIXME: should re-create here?
|
|
16420
|
-
this.context.rBushRoot = new RBush();
|
|
16421
|
-
|
|
16422
15917
|
// reset rendering plugins
|
|
16423
15918
|
this.context.renderingPlugins = [];
|
|
16424
15919
|
this.context.renderingPlugins.push(new EventPlugin(), new PrepareRendererPlugin(),
|
|
@@ -16646,5 +16141,5 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
|
|
|
16646
16141
|
}]);
|
|
16647
16142
|
}(EventTarget);
|
|
16648
16143
|
|
|
16649
|
-
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 };
|
|
16650
16145
|
//# sourceMappingURL=index.esm.js.map
|