voodoojs 0.12.4 → 0.13.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/README.md +1 -1
- package/dist/{chunk-XGZ7SXD3.js → chunk-2LGAXVD7.js} +4 -4
- package/dist/{chunk-XIMSOXWF.js → chunk-4IJE5BWY.js} +5 -5
- package/dist/{chunk-FAWOJTRM.js → chunk-FMDHZ5GI.js} +139 -9
- package/dist/{chunk-OHISQWSW.js → chunk-GE4JWATC.js} +5 -5
- package/dist/{chunk-2GSZT3CX.js → chunk-H2NGDLMD.js} +363 -76
- package/dist/{chunk-AR6WDY7K.js → chunk-IBIZ6OUI.js} +4 -4
- package/dist/{chunk-7XRFOONN.js → chunk-IJQ2PFXU.js} +3 -3
- package/dist/{chunk-ELIX2DRQ.js → chunk-JBUNTP7F.js} +19 -7
- package/dist/{chunk-NKQGUWVF.js → chunk-MV73OSCS.js} +4 -4
- package/dist/{chunk-3MPIJH5X.js → chunk-OIH4BR2H.js} +6 -6
- package/dist/{chunk-FNTYILLW.js → chunk-TEVCUTTC.js} +3 -3
- package/dist/essential.cjs +508 -74
- package/dist/essential.d.cts +1 -1
- package/dist/essential.d.ts +1 -1
- package/dist/essential.js +10 -10
- package/dist/gpu.cjs +7 -1
- package/dist/gpu.js +10 -10
- package/dist/http.cjs +1 -1
- package/dist/http.js +5 -5
- package/dist/index.cjs +556 -122
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +20 -20
- package/dist/reactivity.cjs +138 -5
- package/dist/reactivity.d.cts +32 -1
- package/dist/reactivity.d.ts +32 -1
- package/dist/reactivity.js +2 -2
- package/dist/socket.cjs +115 -5
- package/dist/socket.d.cts +1 -1
- package/dist/socket.d.ts +1 -1
- package/dist/socket.js +9 -9
- package/dist/style-E22XVZ33.js +5 -0
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +2 -2
- package/dist/voodoo.core.js +572 -72
- package/dist/voodoo.core.min.js +17 -17
- package/dist/voodoo.full.js +621 -121
- package/dist/voodoo.full.min.js +62 -62
- package/dist/voodoo.js +575 -75
- package/dist/voodoo.min.js +26 -26
- package/package.json +1 -1
- package/dist/style-DA6RFLKO.js +0 -5
- package/dist/{query-XooOh4vB.d.cts → query-D_BGQw8m.d.cts} +28 -28
- package/dist/{query-DzHfm8Kg.d.ts → query-Dl6Urlwd.d.ts} +28 -28
package/dist/voodoo.full.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Voodoo.js v0.
|
|
2
|
+
* Voodoo.js v0.13.0
|
|
3
3
|
* JavaScript feels like magic.
|
|
4
4
|
* (c) 2026 Voodoo.js contributors. MIT License.
|
|
5
5
|
*/
|
|
@@ -31,10 +31,12 @@ var Voodoo = (() => {
|
|
|
31
31
|
// src/reactivity/index.ts
|
|
32
32
|
var reactivity_exports = {};
|
|
33
33
|
__export(reactivity_exports, {
|
|
34
|
+
ArrayOp: () => ArrayOp,
|
|
34
35
|
EffectScope: () => EffectScope,
|
|
35
36
|
ITERATE_KEY: () => ITERATE_KEY,
|
|
36
37
|
ReactiveEffect: () => ReactiveEffect,
|
|
37
38
|
TriggerType: () => TriggerType,
|
|
39
|
+
arrayVersion: () => arrayVersion,
|
|
38
40
|
computed: () => computed,
|
|
39
41
|
effect: () => effect,
|
|
40
42
|
effectScope: () => effectScope,
|
|
@@ -47,6 +49,7 @@ var Voodoo = (() => {
|
|
|
47
49
|
isReactive: () => isReactive,
|
|
48
50
|
isRef: () => isRef,
|
|
49
51
|
markRaw: () => markRaw,
|
|
52
|
+
mutationsSince: () => mutationsSince,
|
|
50
53
|
nextTick: () => nextTick,
|
|
51
54
|
pauseTracking: () => pauseTracking,
|
|
52
55
|
queueJob: () => queueJob,
|
|
@@ -210,7 +213,9 @@ var Voodoo = (() => {
|
|
|
210
213
|
if (!isArr) add(depsMap.get(ITERATE_KEY));
|
|
211
214
|
else if (isIntegerKey(key)) add(depsMap.get("length"));
|
|
212
215
|
} else if (type === "delete" /* DELETE */) {
|
|
213
|
-
|
|
216
|
+
add(depsMap.get(ITERATE_KEY));
|
|
217
|
+
} else if (isArr && isIntegerKey(key)) {
|
|
218
|
+
add(depsMap.get(ITERATE_KEY));
|
|
214
219
|
} else if (isArr && key === "length") {
|
|
215
220
|
const newLen = Number(_newValue);
|
|
216
221
|
depsMap.forEach((dep, k) => {
|
|
@@ -223,12 +228,61 @@ var Voodoo = (() => {
|
|
|
223
228
|
else queueJob(e);
|
|
224
229
|
}
|
|
225
230
|
}
|
|
231
|
+
function triggerArrayRange(target, from) {
|
|
232
|
+
const depsMap = targetMap.get(target);
|
|
233
|
+
if (!depsMap) return;
|
|
234
|
+
const effects = /* @__PURE__ */ new Set();
|
|
235
|
+
const add = (dep) => {
|
|
236
|
+
if (!dep) return;
|
|
237
|
+
for (const e of dep) if (e !== activeEffect) effects.add(e);
|
|
238
|
+
};
|
|
239
|
+
add(depsMap.get("length"));
|
|
240
|
+
add(depsMap.get(ITERATE_KEY));
|
|
241
|
+
if (from >= 0) {
|
|
242
|
+
depsMap.forEach((dep, k) => {
|
|
243
|
+
if (typeof k === "string" && isIntegerKey(k) && Number(k) >= from) add(dep);
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
for (const e of effects) {
|
|
247
|
+
if (e.scheduler) e.scheduler();
|
|
248
|
+
else queueJob(e);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
function record(target, type, index, removed, added) {
|
|
252
|
+
let log = mutationLogs.get(target);
|
|
253
|
+
if (!log) mutationLogs.set(target, log = { version: 0, ops: [] });
|
|
254
|
+
log.version++;
|
|
255
|
+
if (type === 3 /* RESET */) {
|
|
256
|
+
log.ops.length = 0;
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
log.ops.push({ type, index, removed, added });
|
|
260
|
+
if (log.ops.length > LOG_LIMIT) log.ops.shift();
|
|
261
|
+
}
|
|
262
|
+
function arrayVersion(target) {
|
|
263
|
+
const log = mutationLogs.get(target);
|
|
264
|
+
return log ? log.version : 0;
|
|
265
|
+
}
|
|
266
|
+
function mutationsSince(target, since) {
|
|
267
|
+
const log = mutationLogs.get(target);
|
|
268
|
+
if (!log) return since === 0 ? NO_MUTATIONS : null;
|
|
269
|
+
if (since > log.version) return null;
|
|
270
|
+
const missing = log.version - since;
|
|
271
|
+
if (missing === 0) return NO_MUTATIONS;
|
|
272
|
+
if (missing > log.ops.length) return null;
|
|
273
|
+
return log.ops.slice(log.ops.length - missing);
|
|
274
|
+
}
|
|
226
275
|
function isIntegerKey(key) {
|
|
227
276
|
return typeof key === "string" && key !== "NaN" && key[0] !== "-" && String(parseInt(key, 10)) === key;
|
|
228
277
|
}
|
|
229
278
|
function isObject(val) {
|
|
230
279
|
return val !== null && typeof val === "object";
|
|
231
280
|
}
|
|
281
|
+
function spliceStart(raw, length) {
|
|
282
|
+
const n2 = Math.trunc(Number(raw)) || 0;
|
|
283
|
+
if (n2 < 0) return Math.max(length + n2, 0);
|
|
284
|
+
return Math.min(n2, length);
|
|
285
|
+
}
|
|
232
286
|
function canObserve(value) {
|
|
233
287
|
if (!isObject(value)) return false;
|
|
234
288
|
if (value[SKIP]) return false;
|
|
@@ -238,6 +292,23 @@ var Voodoo = (() => {
|
|
|
238
292
|
if (NON_REACTIVE.has(tag)) return false;
|
|
239
293
|
return tag === "Object" || tag === "Array" || tag === "Map" || tag === "Set";
|
|
240
294
|
}
|
|
295
|
+
function recordDirectWrite(target, key, lengthBefore, hadKey, oldValue, value) {
|
|
296
|
+
if (key === "length") {
|
|
297
|
+
const next = target.length;
|
|
298
|
+
if (next < lengthBefore) record(target, 1 /* SPLICE */, next, lengthBefore - next, 0);
|
|
299
|
+
else if (next > lengthBefore) record(target, 3 /* RESET */, 0, 0, 0);
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
if (!isIntegerKey(key)) return;
|
|
303
|
+
const index = Number(key);
|
|
304
|
+
if (hadKey) {
|
|
305
|
+
if (hasChanged(value, oldValue)) record(target, 2 /* SET */, index, 1, 1);
|
|
306
|
+
} else if (index === lengthBefore) {
|
|
307
|
+
record(target, 1 /* SPLICE */, index, 0, 1);
|
|
308
|
+
} else {
|
|
309
|
+
record(target, 3 /* RESET */, 0, 0, 0);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
241
312
|
function markRaw(value) {
|
|
242
313
|
Object.defineProperty(value, SKIP, { value: true, enumerable: false, configurable: true });
|
|
243
314
|
return value;
|
|
@@ -360,7 +431,7 @@ var Voodoo = (() => {
|
|
|
360
431
|
else for (const key of Object.keys(value)) traverse(value[key], seen);
|
|
361
432
|
return value;
|
|
362
433
|
}
|
|
363
|
-
var resolvedPromise, queue, postQueue, isFlushing, isFlushPending, flushPromise, RECURSION_LIMIT, errorHandler, activeEffect, shouldTrack, trackStack, effectId, ReactiveEffect, activeScope, EffectScope, ITERATE_KEY, targetMap, TriggerType, RAW, IS_REACTIVE, SKIP, reactiveMap, arrayInstrumentations, NON_REACTIVE, baseHandlers, collectionHandlers, RefImpl, ComputedRefImpl;
|
|
434
|
+
var resolvedPromise, queue, postQueue, isFlushing, isFlushPending, flushPromise, RECURSION_LIMIT, errorHandler, activeEffect, shouldTrack, trackStack, effectId, ReactiveEffect, activeScope, EffectScope, ITERATE_KEY, targetMap, TriggerType, ArrayOp, LOG_LIMIT, mutationLogs, NO_MUTATIONS, RAW, IS_REACTIVE, SKIP, reactiveMap, arrayInstrumentations, NON_REACTIVE, baseHandlers, collectionHandlers, RefImpl, ComputedRefImpl;
|
|
364
435
|
var init_reactivity = __esm({
|
|
365
436
|
"src/reactivity/index.ts"() {
|
|
366
437
|
"use strict";
|
|
@@ -490,6 +561,15 @@ var Voodoo = (() => {
|
|
|
490
561
|
TriggerType2["CLEAR"] = "clear";
|
|
491
562
|
return TriggerType2;
|
|
492
563
|
})(TriggerType || {});
|
|
564
|
+
ArrayOp = /* @__PURE__ */ ((ArrayOp2) => {
|
|
565
|
+
ArrayOp2[ArrayOp2["SPLICE"] = 1] = "SPLICE";
|
|
566
|
+
ArrayOp2[ArrayOp2["SET"] = 2] = "SET";
|
|
567
|
+
ArrayOp2[ArrayOp2["RESET"] = 3] = "RESET";
|
|
568
|
+
return ArrayOp2;
|
|
569
|
+
})(ArrayOp || {});
|
|
570
|
+
LOG_LIMIT = 32;
|
|
571
|
+
mutationLogs = /* @__PURE__ */ new WeakMap();
|
|
572
|
+
NO_MUTATIONS = [];
|
|
493
573
|
RAW = /* @__PURE__ */ Symbol("voodoo:raw");
|
|
494
574
|
IS_REACTIVE = /* @__PURE__ */ Symbol("voodoo:isReactive");
|
|
495
575
|
SKIP = /* @__PURE__ */ Symbol("voodoo:skip");
|
|
@@ -507,14 +587,61 @@ var Voodoo = (() => {
|
|
|
507
587
|
return res;
|
|
508
588
|
};
|
|
509
589
|
}
|
|
510
|
-
for (const key of ["push", "pop", "shift", "unshift", "splice"]) {
|
|
590
|
+
for (const key of ["push", "pop", "shift", "unshift", "splice", "reverse", "sort"]) {
|
|
511
591
|
inst[key] = function(...args) {
|
|
592
|
+
const raw = toRaw(this);
|
|
593
|
+
const before = raw.length;
|
|
594
|
+
for (let i = 0; i < args.length; i++) args[i] = toRaw(args[i]);
|
|
512
595
|
pauseTracking();
|
|
596
|
+
let result;
|
|
513
597
|
try {
|
|
514
|
-
|
|
598
|
+
result = raw[key].apply(raw, args);
|
|
515
599
|
} finally {
|
|
516
600
|
resetTracking();
|
|
517
601
|
}
|
|
602
|
+
const after = raw.length;
|
|
603
|
+
let from = -1;
|
|
604
|
+
if (key === "push") {
|
|
605
|
+
if (args.length) {
|
|
606
|
+
record(raw, 1 /* SPLICE */, before, 0, args.length);
|
|
607
|
+
from = before;
|
|
608
|
+
}
|
|
609
|
+
} else if (key === "unshift") {
|
|
610
|
+
if (args.length) {
|
|
611
|
+
record(raw, 1 /* SPLICE */, 0, 0, args.length);
|
|
612
|
+
from = 0;
|
|
613
|
+
}
|
|
614
|
+
} else if (key === "pop") {
|
|
615
|
+
if (before > 0) {
|
|
616
|
+
record(raw, 1 /* SPLICE */, after, 1, 0);
|
|
617
|
+
from = after;
|
|
618
|
+
}
|
|
619
|
+
} else if (key === "shift") {
|
|
620
|
+
if (before > 0) {
|
|
621
|
+
record(raw, 1 /* SPLICE */, 0, 1, 0);
|
|
622
|
+
from = 0;
|
|
623
|
+
}
|
|
624
|
+
} else if (key === "splice") {
|
|
625
|
+
const removed = result.length;
|
|
626
|
+
const added = args.length > 2 ? args.length - 2 : 0;
|
|
627
|
+
if (removed || added) {
|
|
628
|
+
record(raw, 1 /* SPLICE */, spliceStart(args[0], before), removed, added);
|
|
629
|
+
from = spliceStart(args[0], before);
|
|
630
|
+
}
|
|
631
|
+
} else {
|
|
632
|
+
if (before > 1) {
|
|
633
|
+
record(raw, 3 /* RESET */, 0, before, after);
|
|
634
|
+
from = 0;
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
if (from >= 0) triggerArrayRange(raw, from);
|
|
638
|
+
if (key === "pop" || key === "shift") return isObject(result) ? reactive(result) : result;
|
|
639
|
+
if (key === "splice") {
|
|
640
|
+
const out = result;
|
|
641
|
+
for (let i = 0; i < out.length; i++) if (isObject(out[i])) out[i] = reactive(out[i]);
|
|
642
|
+
return out;
|
|
643
|
+
}
|
|
644
|
+
return key === "reverse" || key === "sort" ? this : result;
|
|
518
645
|
};
|
|
519
646
|
}
|
|
520
647
|
return inst;
|
|
@@ -556,8 +683,11 @@ var Voodoo = (() => {
|
|
|
556
683
|
return true;
|
|
557
684
|
}
|
|
558
685
|
const hadKey = Array.isArray(target) && isIntegerKey(key) ? Number(key) < target.length : Object.prototype.hasOwnProperty.call(target, key);
|
|
686
|
+
const isArr = Array.isArray(target);
|
|
687
|
+
const arrayLength = isArr ? target.length : 0;
|
|
559
688
|
const result = Reflect.set(target, key, value, receiver);
|
|
560
689
|
if (target === toRaw(receiver)) {
|
|
690
|
+
if (isArr) recordDirectWrite(target, key, arrayLength, hadKey, oldValue, value);
|
|
561
691
|
if (!hadKey) trigger(target, "add" /* ADD */, key, value);
|
|
562
692
|
else if (hasChanged(value, oldValue)) trigger(target, "set" /* SET */, key, value);
|
|
563
693
|
}
|
|
@@ -566,7 +696,10 @@ var Voodoo = (() => {
|
|
|
566
696
|
deleteProperty(target, key) {
|
|
567
697
|
const hadKey = Object.prototype.hasOwnProperty.call(target, key);
|
|
568
698
|
const result = Reflect.deleteProperty(target, key);
|
|
569
|
-
if (result && hadKey)
|
|
699
|
+
if (result && hadKey) {
|
|
700
|
+
if (Array.isArray(target)) record(target, 3 /* RESET */, 0, 0, 0);
|
|
701
|
+
trigger(target, "delete" /* DELETE */, key);
|
|
702
|
+
}
|
|
570
703
|
return result;
|
|
571
704
|
},
|
|
572
705
|
has(target, key) {
|
|
@@ -2514,8 +2647,15 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
|
|
|
2514
2647
|
return (_a2 = nodeEffectScopes.get(node)) != null ? _a2 : [];
|
|
2515
2648
|
}
|
|
2516
2649
|
var ignoredRemovals = /* @__PURE__ */ new WeakSet();
|
|
2650
|
+
var detachedTemplates = /* @__PURE__ */ new WeakMap();
|
|
2517
2651
|
function removeQuietly(node) {
|
|
2518
2652
|
ignoredRemovals.add(node);
|
|
2653
|
+
const parent = node.parentNode;
|
|
2654
|
+
if (parent) {
|
|
2655
|
+
let kept = detachedTemplates.get(parent);
|
|
2656
|
+
if (!kept) detachedTemplates.set(parent, kept = /* @__PURE__ */ new Set());
|
|
2657
|
+
kept.add(node);
|
|
2658
|
+
}
|
|
2519
2659
|
node.remove();
|
|
2520
2660
|
}
|
|
2521
2661
|
function addCleanup(node, fn) {
|
|
@@ -2531,6 +2671,11 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
|
|
|
2531
2671
|
}
|
|
2532
2672
|
for (let i = children.length - 1; i >= 0; i--) destroy(children[i]);
|
|
2533
2673
|
}
|
|
2674
|
+
const detached = detachedTemplates.get(node);
|
|
2675
|
+
if (detached) {
|
|
2676
|
+
detachedTemplates.delete(node);
|
|
2677
|
+
for (const template of detached) destroy(template);
|
|
2678
|
+
}
|
|
2534
2679
|
const list = nodeCleanups.get(node);
|
|
2535
2680
|
if (list) {
|
|
2536
2681
|
nodeCleanups.delete(node);
|
|
@@ -5717,6 +5862,35 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
|
|
|
5717
5862
|
// src/directives/core.ts
|
|
5718
5863
|
init_reactivity();
|
|
5719
5864
|
init_registry();
|
|
5865
|
+
|
|
5866
|
+
// src/runtime/metrics.ts
|
|
5867
|
+
function blank() {
|
|
5868
|
+
return {
|
|
5869
|
+
on: false,
|
|
5870
|
+
itemsVisited: 0,
|
|
5871
|
+
keyEvaluations: 0,
|
|
5872
|
+
prefixScanned: 0,
|
|
5873
|
+
suffixScanned: 0,
|
|
5874
|
+
middleReconciled: 0,
|
|
5875
|
+
scopeAllocations: 0,
|
|
5876
|
+
proxyWrites: 0,
|
|
5877
|
+
arrayAllocations: 0,
|
|
5878
|
+
keyMapLookups: 0,
|
|
5879
|
+
domCreates: 0,
|
|
5880
|
+
domRemoves: 0,
|
|
5881
|
+
domMoves: 0,
|
|
5882
|
+
domInserts: 0,
|
|
5883
|
+
lisRuns: 0,
|
|
5884
|
+
lisElements: 0,
|
|
5885
|
+
paths: {}
|
|
5886
|
+
};
|
|
5887
|
+
}
|
|
5888
|
+
var metrics = /* @__PURE__ */ blank();
|
|
5889
|
+
function countPath(name) {
|
|
5890
|
+
metrics.paths[name] = (metrics.paths[name] || 0) + 1;
|
|
5891
|
+
}
|
|
5892
|
+
|
|
5893
|
+
// src/directives/core.ts
|
|
5720
5894
|
function setValue(expression, scope, value) {
|
|
5721
5895
|
try {
|
|
5722
5896
|
const target = parse(expression);
|
|
@@ -5862,7 +6036,7 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
|
|
|
5862
6036
|
},
|
|
5863
6037
|
{ priority: PRIORITY.IF, terminal: true }
|
|
5864
6038
|
);
|
|
5865
|
-
function renderTemplate(source, anchor, scope
|
|
6039
|
+
function renderTemplate(source, anchor, scope) {
|
|
5866
6040
|
const parent = anchor.parentNode;
|
|
5867
6041
|
if (!parent) return [];
|
|
5868
6042
|
const nodes = [];
|
|
@@ -5879,21 +6053,64 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
|
|
|
5879
6053
|
}
|
|
5880
6054
|
} else {
|
|
5881
6055
|
const clone2 = source.cloneNode(true);
|
|
6056
|
+
if (metrics.on) metrics.domCreates++;
|
|
5882
6057
|
nodes.push(clone2);
|
|
5883
6058
|
markNodeScope(clone2, scope);
|
|
5884
|
-
|
|
5885
|
-
|
|
5886
|
-
batch.pending.push([clone2, scope]);
|
|
5887
|
-
} else {
|
|
5888
|
-
parent.insertBefore(clone2, anchor);
|
|
5889
|
-
walk(clone2, scope);
|
|
5890
|
-
}
|
|
6059
|
+
parent.insertBefore(clone2, anchor);
|
|
6060
|
+
walk(clone2, scope);
|
|
5891
6061
|
}
|
|
5892
6062
|
return nodes;
|
|
5893
6063
|
}
|
|
5894
6064
|
defineDirective("else-if", () => void 0, { priority: PRIORITY.IF, terminal: true });
|
|
5895
6065
|
defineDirective("else", () => void 0, { priority: PRIORITY.IF, terminal: true });
|
|
5896
6066
|
var FOR_PATTERN = /^\s*\(?\s*([^)]*?)\s*\)?\s+(?:in|of)\s+(.+?)\s*$/;
|
|
6067
|
+
var KEY_PATH = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/;
|
|
6068
|
+
var NO_BLOCKS = [];
|
|
6069
|
+
function sameStored(stored, incoming) {
|
|
6070
|
+
if (stored === incoming) return true;
|
|
6071
|
+
return incoming !== null && typeof incoming === "object" && stored === toRaw(incoming);
|
|
6072
|
+
}
|
|
6073
|
+
function sameKey(a, b) {
|
|
6074
|
+
return a === b || a !== a && b !== b;
|
|
6075
|
+
}
|
|
6076
|
+
function longestIncreasing(arr) {
|
|
6077
|
+
const length = arr.length;
|
|
6078
|
+
const previous = new Int32Array(length);
|
|
6079
|
+
const tails = [];
|
|
6080
|
+
for (let i = 0; i < length; i++) {
|
|
6081
|
+
const value = arr[i];
|
|
6082
|
+
if (value === 0) continue;
|
|
6083
|
+
if (tails.length === 0) {
|
|
6084
|
+
tails.push(i);
|
|
6085
|
+
continue;
|
|
6086
|
+
}
|
|
6087
|
+
const last = tails[tails.length - 1];
|
|
6088
|
+
if (arr[last] < value) {
|
|
6089
|
+
previous[i] = last;
|
|
6090
|
+
tails.push(i);
|
|
6091
|
+
continue;
|
|
6092
|
+
}
|
|
6093
|
+
let low = 0;
|
|
6094
|
+
let high = tails.length - 1;
|
|
6095
|
+
while (low < high) {
|
|
6096
|
+
const mid = low + high >> 1;
|
|
6097
|
+
if (arr[tails[mid]] < value) low = mid + 1;
|
|
6098
|
+
else high = mid;
|
|
6099
|
+
}
|
|
6100
|
+
if (value < arr[tails[low]]) {
|
|
6101
|
+
if (low > 0) previous[i] = tails[low - 1];
|
|
6102
|
+
tails[low] = i;
|
|
6103
|
+
}
|
|
6104
|
+
}
|
|
6105
|
+
let cursor = tails.length;
|
|
6106
|
+
const out = new Int32Array(cursor);
|
|
6107
|
+
let node = tails[cursor - 1];
|
|
6108
|
+
while (cursor-- > 0) {
|
|
6109
|
+
out[cursor] = node;
|
|
6110
|
+
node = previous[node];
|
|
6111
|
+
}
|
|
6112
|
+
return out;
|
|
6113
|
+
}
|
|
5897
6114
|
defineDirective(
|
|
5898
6115
|
"for",
|
|
5899
6116
|
({ el, scope, expression, effect: effect2 }) => {
|
|
@@ -5919,78 +6136,361 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
|
|
|
5919
6136
|
template.removeAttribute(`${p2}bind:key`);
|
|
5920
6137
|
template.removeAttribute(`${p2}key`);
|
|
5921
6138
|
removeQuietly(el);
|
|
6139
|
+
const isTemplateRow = template.tagName === "TEMPLATE";
|
|
6140
|
+
let keyIsItem = false;
|
|
6141
|
+
let keyIsIndex = false;
|
|
6142
|
+
let keyProp = null;
|
|
6143
|
+
let keyPath = null;
|
|
6144
|
+
if (keyExpression && KEY_PATH.test(keyExpression)) {
|
|
6145
|
+
const parts = keyExpression.split(".");
|
|
6146
|
+
if (parts[0] === itemAlias) {
|
|
6147
|
+
if (parts.length === 1) keyIsItem = true;
|
|
6148
|
+
else if (parts.length === 2) keyProp = parts[1];
|
|
6149
|
+
else keyPath = parts.slice(1);
|
|
6150
|
+
} else if (indexAlias && parts.length === 1 && parts[0] === indexAlias) {
|
|
6151
|
+
keyIsIndex = true;
|
|
6152
|
+
}
|
|
6153
|
+
}
|
|
5922
6154
|
let blocks = [];
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
|
|
6155
|
+
let rows = [];
|
|
6156
|
+
let entries = null;
|
|
6157
|
+
let count = 0;
|
|
6158
|
+
let keyScope = null;
|
|
6159
|
+
let lastSource = null;
|
|
6160
|
+
let lastVersion = 0;
|
|
6161
|
+
const pending2 = [];
|
|
6162
|
+
const pendingRuns = [];
|
|
6163
|
+
const varsAt = (i) => {
|
|
6164
|
+
if (entries) return entries[i];
|
|
6165
|
+
const vars = { [itemAlias]: rows[i] };
|
|
6166
|
+
if (indexAlias) vars[indexAlias] = i;
|
|
6167
|
+
return vars;
|
|
6168
|
+
};
|
|
6169
|
+
const keyAt = (i) => {
|
|
6170
|
+
if (metrics.on) metrics.keyEvaluations++;
|
|
6171
|
+
if (keyIsIndex) return i;
|
|
6172
|
+
if (!keyExpression) {
|
|
6173
|
+
return i;
|
|
6174
|
+
}
|
|
6175
|
+
const item = entries ? entries[i][itemAlias] : rows[i];
|
|
6176
|
+
if (keyIsItem) return item;
|
|
6177
|
+
if (keyProp !== null) return item == null ? void 0 : item[keyProp];
|
|
6178
|
+
if (keyPath !== null) {
|
|
6179
|
+
let value = item;
|
|
6180
|
+
for (let d2 = 0; d2 < keyPath.length; d2++) {
|
|
6181
|
+
if (value == null) return void 0;
|
|
6182
|
+
value = value[keyPath[d2]];
|
|
6183
|
+
}
|
|
6184
|
+
return value;
|
|
6185
|
+
}
|
|
6186
|
+
if (!keyScope) keyScope = scope.child({});
|
|
6187
|
+
keyScope.data = varsAt(i);
|
|
6188
|
+
return evaluateIn(keyExpression, keyScope, ":key");
|
|
6189
|
+
};
|
|
6190
|
+
const syncData = (block2, i) => {
|
|
6191
|
+
const raw = toRaw(block2.data);
|
|
6192
|
+
if (entries) {
|
|
6193
|
+
const vars = entries[i];
|
|
6194
|
+
for (const name in vars) {
|
|
6195
|
+
if (!sameStored(raw[name], vars[name])) {
|
|
6196
|
+
if (metrics.on) metrics.proxyWrites++;
|
|
6197
|
+
block2.data[name] = vars[name];
|
|
6198
|
+
}
|
|
6199
|
+
}
|
|
6200
|
+
return;
|
|
6201
|
+
}
|
|
6202
|
+
const item = rows[i];
|
|
6203
|
+
if (!sameStored(raw[itemAlias], item)) {
|
|
6204
|
+
if (metrics.on) metrics.proxyWrites++;
|
|
6205
|
+
block2.data[itemAlias] = item;
|
|
6206
|
+
}
|
|
6207
|
+
if (indexAlias !== void 0 && raw[indexAlias] !== i) {
|
|
6208
|
+
if (metrics.on) metrics.proxyWrites++;
|
|
6209
|
+
block2.data[indexAlias] = i;
|
|
6210
|
+
}
|
|
6211
|
+
};
|
|
6212
|
+
const buildRange = (from, to, before, out) => {
|
|
6213
|
+
if (from >= to) return;
|
|
6214
|
+
const parent = anchor.parentNode;
|
|
6215
|
+
if (!parent) return;
|
|
6216
|
+
pendingRuns.push(pending2.length);
|
|
6217
|
+
if (isTemplateRow) {
|
|
6218
|
+
for (let i = from; i < to; i++) {
|
|
6219
|
+
const childScope = scope.reactiveChild(varsAt(i));
|
|
6220
|
+
if (metrics.on) {
|
|
6221
|
+
metrics.scopeAllocations++;
|
|
6222
|
+
metrics.itemsVisited++;
|
|
6223
|
+
}
|
|
6224
|
+
const nodes = renderTemplate(template, before, childScope);
|
|
6225
|
+
out.push({ key: keyAt(i), scope: childScope, nodes, data: childScope.data });
|
|
6226
|
+
}
|
|
6227
|
+
return;
|
|
6228
|
+
}
|
|
6229
|
+
const fragment = document.createDocumentFragment();
|
|
6230
|
+
for (let i = from; i < to; i++) {
|
|
6231
|
+
const childScope = scope.reactiveChild(varsAt(i));
|
|
6232
|
+
const clone2 = template.cloneNode(true);
|
|
6233
|
+
markNodeScope(clone2, childScope);
|
|
6234
|
+
fragment.appendChild(clone2);
|
|
6235
|
+
pending2.push([clone2, childScope]);
|
|
6236
|
+
out.push({ key: keyAt(i), scope: childScope, nodes: [clone2], data: childScope.data });
|
|
6237
|
+
if (metrics.on) {
|
|
6238
|
+
metrics.scopeAllocations++;
|
|
6239
|
+
metrics.domCreates++;
|
|
6240
|
+
metrics.itemsVisited++;
|
|
6241
|
+
}
|
|
6242
|
+
}
|
|
6243
|
+
if (metrics.on) metrics.domInserts++;
|
|
6244
|
+
parent.insertBefore(fragment, before);
|
|
6245
|
+
};
|
|
6246
|
+
const destroyBlock = (block2) => {
|
|
6247
|
+
const nodes = block2.nodes;
|
|
6248
|
+
for (let j = 0; j < nodes.length; j++) {
|
|
6249
|
+
if (metrics.on) metrics.domRemoves++;
|
|
6250
|
+
destroy(nodes[j]);
|
|
6251
|
+
nodes[j].remove();
|
|
6252
|
+
}
|
|
6253
|
+
};
|
|
6254
|
+
const moveBlock = (block2, before) => {
|
|
6255
|
+
const parent = anchor.parentNode;
|
|
6256
|
+
if (!parent) return;
|
|
6257
|
+
const nodes = block2.nodes;
|
|
6258
|
+
if (nodes[nodes.length - 1].nextSibling === before) return;
|
|
6259
|
+
for (let j = 0; j < nodes.length; j++) {
|
|
6260
|
+
if (metrics.on) metrics.domMoves++;
|
|
6261
|
+
parent.insertBefore(nodes[j], before);
|
|
6262
|
+
}
|
|
6263
|
+
};
|
|
6264
|
+
const nodeAfter = (oldIndex) => oldIndex < blocks.length ? blocks[oldIndex].nodes[0] : anchor;
|
|
6265
|
+
const spliceBlocks = (index, remove, added) => {
|
|
6266
|
+
const addCount = added.length;
|
|
6267
|
+
if (remove === 0 && addCount === 0) return;
|
|
6268
|
+
if (blocks.length === 0) {
|
|
6269
|
+
blocks = added;
|
|
6270
|
+
return;
|
|
6271
|
+
}
|
|
6272
|
+
if (addCount === 0) {
|
|
6273
|
+
blocks.splice(index, remove);
|
|
6274
|
+
return;
|
|
6275
|
+
}
|
|
6276
|
+
if (addCount <= 1024) {
|
|
6277
|
+
blocks.splice(index, remove, ...added);
|
|
6278
|
+
return;
|
|
6279
|
+
}
|
|
6280
|
+
const out = new Array(blocks.length - remove + addCount);
|
|
6281
|
+
let w = 0;
|
|
6282
|
+
for (let k = 0; k < index; k++) out[w++] = blocks[k];
|
|
6283
|
+
for (let k = 0; k < addCount; k++) out[w++] = added[k];
|
|
6284
|
+
for (let k = index + remove; k < blocks.length; k++) out[w++] = blocks[k];
|
|
6285
|
+
blocks = out;
|
|
6286
|
+
};
|
|
6287
|
+
const flushPending = () => {
|
|
6288
|
+
for (let r2 = pendingRuns.length - 1; r2 >= 0; r2--) {
|
|
6289
|
+
const start2 = pendingRuns[r2];
|
|
6290
|
+
const end = r2 + 1 < pendingRuns.length ? pendingRuns[r2 + 1] : pending2.length;
|
|
6291
|
+
for (let k = start2; k < end; k++) walk(pending2[k][0], pending2[k][1]);
|
|
6292
|
+
}
|
|
6293
|
+
pending2.length = 0;
|
|
6294
|
+
pendingRuns.length = 0;
|
|
6295
|
+
};
|
|
6296
|
+
let lo = 0;
|
|
6297
|
+
let oldHi = 0;
|
|
6298
|
+
let newHi = 0;
|
|
6299
|
+
const regionFromMutations = (source) => {
|
|
6300
|
+
const ops = mutationsSince(source, lastVersion);
|
|
6301
|
+
if (!ops) return false;
|
|
6302
|
+
const oldLen = blocks.length;
|
|
6303
|
+
lo = 0;
|
|
6304
|
+
oldHi = 0;
|
|
6305
|
+
newHi = 0;
|
|
6306
|
+
let current2 = oldLen;
|
|
6307
|
+
for (let k = 0; k < ops.length; k++) {
|
|
6308
|
+
const op = ops[k];
|
|
6309
|
+
const index = op.index;
|
|
6310
|
+
const removed = op.type === 2 /* SET */ ? 1 : op.removed;
|
|
6311
|
+
const added = op.type === 2 /* SET */ ? 1 : op.added;
|
|
6312
|
+
const end = index + removed;
|
|
6313
|
+
if (k === 0) {
|
|
6314
|
+
lo = index;
|
|
6315
|
+
oldHi = end;
|
|
6316
|
+
newHi = index + added;
|
|
6317
|
+
} else if (end <= newHi) {
|
|
6318
|
+
if (index < lo) lo = index;
|
|
6319
|
+
newHi += added - removed;
|
|
6320
|
+
} else {
|
|
6321
|
+
if (index < lo) lo = index;
|
|
6322
|
+
oldHi = end - newHi + oldHi;
|
|
6323
|
+
newHi = index + added;
|
|
6324
|
+
}
|
|
6325
|
+
if (oldHi < lo) oldHi = lo;
|
|
6326
|
+
if (newHi < lo) newHi = lo;
|
|
6327
|
+
current2 += added - removed;
|
|
6328
|
+
}
|
|
6329
|
+
if (current2 !== count) return false;
|
|
6330
|
+
if (lo > oldHi || lo > newHi) return false;
|
|
6331
|
+
if (oldHi > oldLen || newHi > count) return false;
|
|
6332
|
+
if (metrics.on) countPath(ops.length === 0 ? "unchanged" : "mutation");
|
|
6333
|
+
if (indexAlias !== void 0 && oldHi - newHi !== 0) {
|
|
6334
|
+
for (let i = newHi; i < count; i++) syncData(blocks[i - newHi + oldHi], i);
|
|
6335
|
+
}
|
|
6336
|
+
return true;
|
|
6337
|
+
};
|
|
6338
|
+
const regionFromScan = () => {
|
|
6339
|
+
const oldLen = blocks.length;
|
|
6340
|
+
const newLen = count;
|
|
6341
|
+
let i = 0;
|
|
6342
|
+
const shared = oldLen < newLen ? oldLen : newLen;
|
|
6343
|
+
while (i < shared) {
|
|
6344
|
+
const block2 = blocks[i];
|
|
6345
|
+
if (!sameKey(block2.key, keyAt(i))) break;
|
|
6346
|
+
syncData(block2, i);
|
|
6347
|
+
i++;
|
|
6348
|
+
}
|
|
6349
|
+
if (metrics.on) {
|
|
6350
|
+
metrics.prefixScanned += i;
|
|
6351
|
+
metrics.itemsVisited += i;
|
|
6352
|
+
}
|
|
6353
|
+
let oe = oldLen - 1;
|
|
6354
|
+
let ne = newLen - 1;
|
|
6355
|
+
while (oe >= i && ne >= i) {
|
|
6356
|
+
const block2 = blocks[oe];
|
|
6357
|
+
if (!sameKey(block2.key, keyAt(ne))) break;
|
|
6358
|
+
syncData(block2, ne);
|
|
6359
|
+
oe--;
|
|
6360
|
+
ne--;
|
|
6361
|
+
}
|
|
6362
|
+
if (metrics.on) {
|
|
6363
|
+
const scanned = oldLen - 1 - oe;
|
|
6364
|
+
metrics.suffixScanned += scanned;
|
|
6365
|
+
metrics.itemsVisited += scanned;
|
|
6366
|
+
countPath("scan");
|
|
6367
|
+
}
|
|
6368
|
+
lo = i;
|
|
6369
|
+
oldHi = oe + 1;
|
|
6370
|
+
newHi = ne + 1;
|
|
6371
|
+
};
|
|
6372
|
+
const reconcileRegion = () => {
|
|
6373
|
+
const toPatch = newHi - lo;
|
|
6374
|
+
if (lo >= oldHi) {
|
|
6375
|
+
if (toPatch > 0) {
|
|
6376
|
+
const created = [];
|
|
6377
|
+
buildRange(lo, newHi, nodeAfter(lo), created);
|
|
6378
|
+
spliceBlocks(lo, 0, created);
|
|
6379
|
+
}
|
|
6380
|
+
return;
|
|
6381
|
+
}
|
|
6382
|
+
if (toPatch === 0) {
|
|
6383
|
+
if (metrics.on) metrics.itemsVisited += oldHi - lo;
|
|
6384
|
+
for (let j = lo; j < oldHi; j++) destroyBlock(blocks[j]);
|
|
6385
|
+
spliceBlocks(lo, oldHi - lo, NO_BLOCKS);
|
|
6386
|
+
return;
|
|
6387
|
+
}
|
|
6388
|
+
if (metrics.on) {
|
|
6389
|
+
metrics.arrayAllocations += 3;
|
|
6390
|
+
metrics.middleReconciled += toPatch;
|
|
6391
|
+
metrics.itemsVisited += toPatch + (oldHi - lo);
|
|
6392
|
+
}
|
|
6393
|
+
const keyToNew = /* @__PURE__ */ new Map();
|
|
6394
|
+
for (let n2 = lo; n2 < newHi; n2++) {
|
|
6395
|
+
const key = keyAt(n2);
|
|
6396
|
+
if (keyExpression && keyToNew.has(key)) warnDuplicateKey(el, key, expression);
|
|
6397
|
+
keyToNew.set(key, n2);
|
|
6398
|
+
}
|
|
6399
|
+
const oldOfNew = new Int32Array(toPatch);
|
|
6400
|
+
const reused = new Array(toPatch);
|
|
6401
|
+
let matched = 0;
|
|
6402
|
+
let moved = false;
|
|
6403
|
+
let highestSoFar = 0;
|
|
6404
|
+
for (let o = lo; o < oldHi; o++) {
|
|
6405
|
+
const block2 = blocks[o];
|
|
6406
|
+
if (metrics.on) metrics.keyMapLookups++;
|
|
6407
|
+
const target = matched >= toPatch ? void 0 : keyToNew.get(block2.key);
|
|
6408
|
+
if (target === void 0 || reused[target - lo] !== void 0) {
|
|
6409
|
+
destroyBlock(block2);
|
|
6410
|
+
continue;
|
|
6411
|
+
}
|
|
6412
|
+
oldOfNew[target - lo] = o + 1;
|
|
6413
|
+
reused[target - lo] = block2;
|
|
6414
|
+
if (target >= highestSoFar) highestSoFar = target;
|
|
6415
|
+
else moved = true;
|
|
6416
|
+
syncData(block2, target);
|
|
6417
|
+
matched++;
|
|
6418
|
+
}
|
|
6419
|
+
const stay = moved ? longestIncreasing(oldOfNew) : null;
|
|
6420
|
+
if (metrics.on && moved) {
|
|
6421
|
+
metrics.lisRuns++;
|
|
6422
|
+
metrics.lisElements += toPatch;
|
|
6423
|
+
}
|
|
6424
|
+
let s = stay ? stay.length - 1 : -1;
|
|
6425
|
+
const region = new Array(toPatch);
|
|
6426
|
+
let before = nodeAfter(oldHi);
|
|
6427
|
+
let runEnd = -1;
|
|
6428
|
+
for (let n2 = toPatch - 1; n2 >= 0; n2--) {
|
|
6429
|
+
const newIndex = lo + n2;
|
|
6430
|
+
const block2 = reused[n2];
|
|
6431
|
+
if (block2 === void 0) {
|
|
6432
|
+
if (runEnd < 0) runEnd = newIndex + 1;
|
|
6433
|
+
continue;
|
|
6434
|
+
}
|
|
6435
|
+
if (runEnd >= 0) {
|
|
6436
|
+
const created = [];
|
|
6437
|
+
buildRange(newIndex + 1, runEnd, before, created);
|
|
6438
|
+
for (let c2 = 0; c2 < created.length; c2++) region[n2 + 1 + c2] = created[c2];
|
|
6439
|
+
if (created.length) before = created[0].nodes[0];
|
|
6440
|
+
runEnd = -1;
|
|
5928
6441
|
}
|
|
6442
|
+
region[n2] = block2;
|
|
6443
|
+
if (moved && (s < 0 || n2 !== stay[s])) moveBlock(block2, before);
|
|
6444
|
+
else if (moved) s--;
|
|
6445
|
+
before = block2.nodes[0];
|
|
5929
6446
|
}
|
|
6447
|
+
if (runEnd >= 0) {
|
|
6448
|
+
const created = [];
|
|
6449
|
+
buildRange(lo, runEnd, before, created);
|
|
6450
|
+
for (let c2 = 0; c2 < created.length; c2++) region[c2] = created[c2];
|
|
6451
|
+
}
|
|
6452
|
+
spliceBlocks(lo, oldHi - lo, region);
|
|
6453
|
+
};
|
|
6454
|
+
const clearAll = () => {
|
|
6455
|
+
for (const block2 of blocks) destroyBlock(block2);
|
|
5930
6456
|
blocks = [];
|
|
6457
|
+
lastSource = null;
|
|
6458
|
+
lastVersion = 0;
|
|
5931
6459
|
};
|
|
5932
6460
|
addCleanup(anchor, clearAll);
|
|
5933
6461
|
effect2(() => {
|
|
5934
|
-
var _a3, _b, _c;
|
|
5935
6462
|
const source = evaluateIn(sourceExpression, scope, "v-for");
|
|
5936
|
-
const
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
|
|
5941
|
-
|
|
5942
|
-
|
|
5943
|
-
|
|
5944
|
-
|
|
5945
|
-
|
|
5946
|
-
|
|
5947
|
-
if (keyExpression && used.has(key)) warnDuplicateKey(el, key, expression);
|
|
5948
|
-
const existing = previous.get(key);
|
|
5949
|
-
if (existing && !used.has(key)) {
|
|
5950
|
-
used.add(key);
|
|
5951
|
-
for (const [name, value] of Object.entries(vars)) existing.data[name] = value;
|
|
5952
|
-
next.push(existing);
|
|
5953
|
-
return;
|
|
5954
|
-
}
|
|
5955
|
-
const childScope = scope.reactiveChild(vars);
|
|
5956
|
-
const nodes = renderTemplate(template, anchor, childScope, batch);
|
|
5957
|
-
used.add(key);
|
|
5958
|
-
next.push({ key, scope: childScope, nodes, data: childScope.data });
|
|
5959
|
-
});
|
|
5960
|
-
if (batch.fragment.firstChild) (_a3 = anchor.parentNode) == null ? void 0 : _a3.insertBefore(batch.fragment, anchor);
|
|
5961
|
-
for (const [node, rowScope] of batch.pending) walk(node, rowScope);
|
|
5962
|
-
const reused = new Set(next);
|
|
5963
|
-
for (const block2 of blocks) {
|
|
5964
|
-
if (used.has(block2.key) && reused.has(block2)) continue;
|
|
5965
|
-
for (const node of block2.nodes) {
|
|
5966
|
-
destroy(node);
|
|
5967
|
-
node.remove();
|
|
6463
|
+
const raw = toRaw(source);
|
|
6464
|
+
let fromMutations = false;
|
|
6465
|
+
if (Array.isArray(raw)) {
|
|
6466
|
+
track(raw, "length");
|
|
6467
|
+
track(raw, ITERATE_KEY);
|
|
6468
|
+
rows = raw;
|
|
6469
|
+
entries = null;
|
|
6470
|
+
count = raw.length;
|
|
6471
|
+
const version3 = arrayVersion(raw);
|
|
6472
|
+
if (raw === lastSource && keyExpression && !keyIsIndex) {
|
|
6473
|
+
fromMutations = regionFromMutations(raw);
|
|
5968
6474
|
}
|
|
6475
|
+
lastSource = raw;
|
|
6476
|
+
lastVersion = version3;
|
|
6477
|
+
} else {
|
|
6478
|
+
entries = normalizeSource(source, itemAlias, indexAlias, thirdAlias);
|
|
6479
|
+
rows = entries;
|
|
6480
|
+
count = entries.length;
|
|
6481
|
+
lastSource = null;
|
|
6482
|
+
lastVersion = 0;
|
|
6483
|
+
if (metrics.on) metrics.arrayAllocations += count + 1;
|
|
5969
6484
|
}
|
|
5970
|
-
|
|
5971
|
-
|
|
5972
|
-
|
|
5973
|
-
const last = block2.nodes[block2.nodes.length - 1];
|
|
5974
|
-
if (last && last.nextSibling !== cursor) {
|
|
5975
|
-
for (const node of block2.nodes) (_b = anchor.parentNode) == null ? void 0 : _b.insertBefore(node, cursor);
|
|
5976
|
-
}
|
|
5977
|
-
cursor = (_c = block2.nodes[0]) != null ? _c : cursor;
|
|
5978
|
-
}
|
|
5979
|
-
blocks = next;
|
|
6485
|
+
if (!fromMutations) regionFromScan();
|
|
6486
|
+
reconcileRegion();
|
|
6487
|
+
flushPending();
|
|
5980
6488
|
});
|
|
5981
6489
|
},
|
|
5982
6490
|
{ priority: PRIORITY.FOR, terminal: true }
|
|
5983
6491
|
);
|
|
5984
6492
|
function normalizeSource(source, itemAlias, indexAlias, thirdAlias) {
|
|
5985
6493
|
const out = [];
|
|
5986
|
-
if (Array.isArray(source)) {
|
|
5987
|
-
source.forEach((item, index) => {
|
|
5988
|
-
const vars = { [itemAlias]: item };
|
|
5989
|
-
if (indexAlias) vars[indexAlias] = index;
|
|
5990
|
-
out.push(vars);
|
|
5991
|
-
});
|
|
5992
|
-
return out;
|
|
5993
|
-
}
|
|
5994
6494
|
if (typeof source === "number") {
|
|
5995
6495
|
for (let i = 1; i <= source; i++) {
|
|
5996
6496
|
const vars = { [itemAlias]: i };
|
|
@@ -7136,7 +7636,7 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
|
|
|
7136
7636
|
Object.defineProperties(rootScope.data, Object.getOwnPropertyDescriptors(values));
|
|
7137
7637
|
return rootScope.data;
|
|
7138
7638
|
}
|
|
7139
|
-
var version2 = "0.
|
|
7639
|
+
var version2 = "0.13.0";
|
|
7140
7640
|
var core = {
|
|
7141
7641
|
// Utilities first: Voodoo's own names can override.
|
|
7142
7642
|
...utils_exports,
|
|
@@ -8397,7 +8897,7 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
|
|
|
8397
8897
|
}, 0);
|
|
8398
8898
|
}
|
|
8399
8899
|
}
|
|
8400
|
-
function compileRoute(pattern,
|
|
8900
|
+
function compileRoute(pattern, record2) {
|
|
8401
8901
|
const clean = pattern === "*" ? "*" : normalizePath(pattern);
|
|
8402
8902
|
const raw = clean === "*" ? ["*"] : clean.split("/").filter(Boolean);
|
|
8403
8903
|
const segments = [];
|
|
@@ -8418,7 +8918,7 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
|
|
|
8418
8918
|
segments.push({ type: "static", value: piece, optional: false });
|
|
8419
8919
|
score += 4;
|
|
8420
8920
|
}
|
|
8421
|
-
return { pattern: clean, segments, score, record };
|
|
8921
|
+
return { pattern: clean, segments, score, record: record2 };
|
|
8422
8922
|
}
|
|
8423
8923
|
function matchSegments(segments, parts) {
|
|
8424
8924
|
const params = {};
|
|
@@ -8504,16 +9004,16 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
|
|
|
8504
9004
|
route.name = location2.name;
|
|
8505
9005
|
route.meta = location2.meta;
|
|
8506
9006
|
route.matched = location2.matched;
|
|
8507
|
-
const
|
|
8508
|
-
if ((
|
|
8509
|
-
document.title = settings2.titleTemplate.includes("%s") ? settings2.titleTemplate.replace("%s",
|
|
9007
|
+
const record2 = findRecord(location2.matched);
|
|
9008
|
+
if ((record2 == null ? void 0 : record2.title) && typeof document !== "undefined") {
|
|
9009
|
+
document.title = settings2.titleTemplate.includes("%s") ? settings2.titleTemplate.replace("%s", record2.title) : record2.title;
|
|
8510
9010
|
}
|
|
8511
9011
|
}
|
|
8512
9012
|
async function runGuards(to, from) {
|
|
8513
|
-
const
|
|
8514
|
-
if (
|
|
8515
|
-
if (
|
|
8516
|
-
const verdict = await
|
|
9013
|
+
const record2 = findRecord(to.matched);
|
|
9014
|
+
if (record2 == null ? void 0 : record2.redirect) return record2.redirect;
|
|
9015
|
+
if (record2 == null ? void 0 : record2.beforeEnter) {
|
|
9016
|
+
const verdict = await record2.beforeEnter(to, from);
|
|
8517
9017
|
if (verdict === false) return false;
|
|
8518
9018
|
if (typeof verdict === "string") return verdict;
|
|
8519
9019
|
}
|
|
@@ -8679,8 +9179,8 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
|
|
|
8679
9179
|
if (destination.hash) scheduleScroll(destination, from, null);
|
|
8680
9180
|
(_a2 = settings2.afterEach) == null ? void 0 : _a2.call(settings2, snapshot(), from);
|
|
8681
9181
|
}
|
|
8682
|
-
function addRoute(pattern,
|
|
8683
|
-
const compiledRoute = compileRoute(pattern,
|
|
9182
|
+
function addRoute(pattern, record2) {
|
|
9183
|
+
const compiledRoute = compileRoute(pattern, record2);
|
|
8684
9184
|
const index = compiled.findIndex((item) => item.pattern === compiledRoute.pattern);
|
|
8685
9185
|
if (index > -1) compiled.splice(index, 1, compiledRoute);
|
|
8686
9186
|
else compiled.push(compiledRoute);
|
|
@@ -8709,8 +9209,8 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
|
|
|
8709
9209
|
settings2.titleTemplate = (_h = options.titleTemplate) != null ? _h : "%s";
|
|
8710
9210
|
settings2.scrollBehavior = (_i = options.scrollBehavior) != null ? _i : null;
|
|
8711
9211
|
compiled.length = 0;
|
|
8712
|
-
for (const [pattern,
|
|
8713
|
-
compiled.push(compileRoute(pattern,
|
|
9212
|
+
for (const [pattern, record2] of Object.entries((_j = options.routes) != null ? _j : {})) {
|
|
9213
|
+
compiled.push(compileRoute(pattern, record2));
|
|
8714
9214
|
}
|
|
8715
9215
|
configured = true;
|
|
8716
9216
|
startListening();
|
|
@@ -8772,11 +9272,11 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
|
|
|
8772
9272
|
for (const child of Array.from(el.childNodes)) destroy(child);
|
|
8773
9273
|
el.textContent = "";
|
|
8774
9274
|
};
|
|
8775
|
-
const mount = (
|
|
9275
|
+
const mount = (record2, html) => {
|
|
8776
9276
|
unmount();
|
|
8777
|
-
if (
|
|
9277
|
+
if (record2 == null ? void 0 : record2.component) {
|
|
8778
9278
|
const host = document.createElement("div");
|
|
8779
|
-
host.setAttribute(`${config.prefix}component`,
|
|
9279
|
+
host.setAttribute(`${config.prefix}component`, record2.component);
|
|
8780
9280
|
host.className = "v-router-page";
|
|
8781
9281
|
el.appendChild(host);
|
|
8782
9282
|
walk(host, scope);
|
|
@@ -8785,28 +9285,28 @@ Suggestion: attribute expressions accept a single value. If the logic spans more
|
|
|
8785
9285
|
el.innerHTML = html != null ? html : fallbackHtml;
|
|
8786
9286
|
for (const child of Array.from(el.childNodes)) walk(child, scope);
|
|
8787
9287
|
};
|
|
8788
|
-
const render3 = async (
|
|
9288
|
+
const render3 = async (record2, current2) => {
|
|
8789
9289
|
let html = null;
|
|
8790
|
-
if (
|
|
9290
|
+
if (record2 == null ? void 0 : record2.view) {
|
|
8791
9291
|
el.classList.add("v-router-loading");
|
|
8792
9292
|
try {
|
|
8793
|
-
html = await loadView(
|
|
9293
|
+
html = await loadView(record2.view);
|
|
8794
9294
|
} catch (err) {
|
|
8795
|
-
handleError(err, `v-router-view loading "${
|
|
9295
|
+
handleError(err, `v-router-view loading "${record2.view}"`);
|
|
8796
9296
|
html = "";
|
|
8797
9297
|
} finally {
|
|
8798
9298
|
el.classList.remove("v-router-loading");
|
|
8799
9299
|
}
|
|
8800
9300
|
if (current2 !== token) return;
|
|
8801
9301
|
}
|
|
8802
|
-
if (useTransition) viewTransition(() => mount(
|
|
8803
|
-
else mount(
|
|
9302
|
+
if (useTransition) viewTransition(() => mount(record2, html));
|
|
9303
|
+
else mount(record2, html);
|
|
8804
9304
|
};
|
|
8805
9305
|
effect2(() => {
|
|
8806
9306
|
const matched = route.matched;
|
|
8807
9307
|
void paramsSignature(route.params);
|
|
8808
|
-
const
|
|
8809
|
-
void render3(
|
|
9308
|
+
const record2 = findRecord(matched);
|
|
9309
|
+
void render3(record2, ++token);
|
|
8810
9310
|
});
|
|
8811
9311
|
cleanup(() => {
|
|
8812
9312
|
token++;
|
|
@@ -13555,7 +14055,7 @@ form.v-loading [type="submit"],form.v-loading button[disabled]{opacity:.6}
|
|
|
13555
14055
|
restoring = false;
|
|
13556
14056
|
});
|
|
13557
14057
|
}
|
|
13558
|
-
const
|
|
14058
|
+
const record2 = debounce(() => {
|
|
13559
14059
|
if (restoring) return;
|
|
13560
14060
|
const current2 = JSON.stringify(serializable(scope.data));
|
|
13561
14061
|
if (current2 === JSON.stringify(snapshots[position])) return;
|
|
@@ -13565,12 +14065,12 @@ form.v-loading [type="submit"],form.v-loading button[disabled]{opacity:.6}
|
|
|
13565
14065
|
position = snapshots.length - 1;
|
|
13566
14066
|
sync();
|
|
13567
14067
|
}, parseDuration((_a2 = el.getAttribute("v-history-debounce")) != null ? _a2 : void 0, 300));
|
|
13568
|
-
const stopWatching = watch(scope.data, () =>
|
|
14068
|
+
const stopWatching = watch(scope.data, () => record2(), { deep: true });
|
|
13569
14069
|
controllers.set(el, controller);
|
|
13570
14070
|
scope.set("$history", controller);
|
|
13571
14071
|
cleanup(() => {
|
|
13572
14072
|
stopWatching();
|
|
13573
|
-
|
|
14073
|
+
record2.cancel();
|
|
13574
14074
|
controllers.delete(el);
|
|
13575
14075
|
});
|
|
13576
14076
|
},
|
|
@@ -20035,7 +20535,7 @@ textarea.v-dialog-input{min-height:96px;resize:vertical}
|
|
|
20035
20535
|
var flashTimers = /* @__PURE__ */ new Map();
|
|
20036
20536
|
var outlined = [];
|
|
20037
20537
|
var requestStarts = /* @__PURE__ */ new WeakMap();
|
|
20038
|
-
var
|
|
20538
|
+
var metrics2 = {
|
|
20039
20539
|
effects: 0,
|
|
20040
20540
|
mutations: 0,
|
|
20041
20541
|
effectsPerSecond: 0,
|
|
@@ -20454,7 +20954,7 @@ textarea.v-dialog-input{min-height:96px;resize:vertical}
|
|
|
20454
20954
|
const original = item.fn;
|
|
20455
20955
|
patchedEffects.set(item, original);
|
|
20456
20956
|
item.fn = () => {
|
|
20457
|
-
|
|
20957
|
+
metrics2.effects++;
|
|
20458
20958
|
flash(owner);
|
|
20459
20959
|
return original();
|
|
20460
20960
|
};
|
|
@@ -20904,20 +21404,20 @@ textarea.v-dialog-input{min-height:96px;resize:vertical}
|
|
|
20904
21404
|
function renderPerformanceTab() {
|
|
20905
21405
|
const frag = document.createDocumentFragment();
|
|
20906
21406
|
const updates = h("div", "v-xray-metric");
|
|
20907
|
-
updates.appendChild(h("span", "v-xray-metric-value", String(
|
|
21407
|
+
updates.appendChild(h("span", "v-xray-metric-value", String(metrics2.updatesPerSecond)));
|
|
20908
21408
|
updates.appendChild(h("span", void 0, "DOM updates per second"));
|
|
20909
21409
|
frag.appendChild(updates);
|
|
20910
21410
|
const effects = h("div", "v-xray-metric");
|
|
20911
|
-
effects.appendChild(h("span", "v-xray-metric-value", String(
|
|
21411
|
+
effects.appendChild(h("span", "v-xray-metric-value", String(metrics2.effectsPerSecond)));
|
|
20912
21412
|
effects.appendChild(h("span", void 0, "reactive effects triggered per second"));
|
|
20913
21413
|
frag.appendChild(effects);
|
|
20914
21414
|
const total = h("div", "v-xray-metric");
|
|
20915
|
-
total.appendChild(h("span", "v-xray-metric-value", String(
|
|
21415
|
+
total.appendChild(h("span", "v-xray-metric-value", String(metrics2.effects)));
|
|
20916
21416
|
total.appendChild(h("span", void 0, "effects triggered since x-ray was enabled"));
|
|
20917
21417
|
frag.appendChild(total);
|
|
20918
21418
|
const chart = h("div", "v-xray-chart");
|
|
20919
|
-
const peak = Math.max(1, ...
|
|
20920
|
-
for (const item of
|
|
21419
|
+
const peak = Math.max(1, ...metrics2.history.map((item) => Math.max(item.effects, item.updates)));
|
|
21420
|
+
for (const item of metrics2.history) {
|
|
20921
21421
|
const bar = h("div", "v-xray-bar");
|
|
20922
21422
|
const value = Math.max(item.effects, item.updates);
|
|
20923
21423
|
bar.style.height = `${Math.max(2, Math.round(value / peak * 46))}px`;
|
|
@@ -21160,14 +21660,14 @@ textarea.v-dialog-input{min-height:96px;resize:vertical}
|
|
|
21160
21660
|
function observeMutations() {
|
|
21161
21661
|
observer3 = new MutationObserver((records) => {
|
|
21162
21662
|
let structural = false;
|
|
21163
|
-
for (const
|
|
21164
|
-
const target =
|
|
21663
|
+
for (const record2 of records) {
|
|
21664
|
+
const target = record2.target;
|
|
21165
21665
|
if (isXrayNode(target)) continue;
|
|
21166
|
-
if (
|
|
21666
|
+
if (record2.type === "attributes" && record2.attributeName === "class" && target.nodeType === 1 && flashing.has(target)) {
|
|
21167
21667
|
continue;
|
|
21168
21668
|
}
|
|
21169
|
-
|
|
21170
|
-
if (
|
|
21669
|
+
metrics2.mutations++;
|
|
21670
|
+
if (record2.type === "childList" && record2.addedNodes.length) structural = true;
|
|
21171
21671
|
}
|
|
21172
21672
|
if (structural && !scanTimer) {
|
|
21173
21673
|
scanTimer = window.setTimeout(() => {
|
|
@@ -21185,15 +21685,15 @@ textarea.v-dialog-input{min-height:96px;resize:vertical}
|
|
|
21185
21685
|
}
|
|
21186
21686
|
function startTimers() {
|
|
21187
21687
|
metricsTimer = window.setInterval(() => {
|
|
21188
|
-
|
|
21189
|
-
|
|
21190
|
-
lastEffectCount =
|
|
21191
|
-
lastMutationCount =
|
|
21192
|
-
|
|
21193
|
-
effects:
|
|
21194
|
-
updates:
|
|
21688
|
+
metrics2.effectsPerSecond = metrics2.effects - lastEffectCount;
|
|
21689
|
+
metrics2.updatesPerSecond = metrics2.mutations - lastMutationCount;
|
|
21690
|
+
lastEffectCount = metrics2.effects;
|
|
21691
|
+
lastMutationCount = metrics2.mutations;
|
|
21692
|
+
metrics2.history.push({
|
|
21693
|
+
effects: metrics2.effectsPerSecond,
|
|
21694
|
+
updates: metrics2.updatesPerSecond
|
|
21195
21695
|
});
|
|
21196
|
-
if (
|
|
21696
|
+
if (metrics2.history.length > 40) metrics2.history.shift();
|
|
21197
21697
|
if (activeTab === "desempenho") renderActiveTab();
|
|
21198
21698
|
}, 1e3);
|
|
21199
21699
|
refreshTimer = window.setInterval(() => {
|
|
@@ -21212,11 +21712,11 @@ textarea.v-dialog-input{min-height:96px;resize:vertical}
|
|
|
21212
21712
|
injectStyle("xray", XRAY_CSS);
|
|
21213
21713
|
refs = buildPanel();
|
|
21214
21714
|
activeTab = activeTab || "estado";
|
|
21215
|
-
|
|
21216
|
-
|
|
21715
|
+
metrics2.effects = 0;
|
|
21716
|
+
metrics2.mutations = 0;
|
|
21217
21717
|
lastEffectCount = 0;
|
|
21218
21718
|
lastMutationCount = 0;
|
|
21219
|
-
|
|
21719
|
+
metrics2.history.length = 0;
|
|
21220
21720
|
scanDocument();
|
|
21221
21721
|
listenEvents();
|
|
21222
21722
|
listenNetwork();
|