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/essential.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Voodoo.js v0.
|
|
6
|
+
* Voodoo.js v0.13.0
|
|
7
7
|
* JavaScript feels like magic.
|
|
8
8
|
* (c) 2026 Voodoo.js contributors. MIT License.
|
|
9
9
|
*/
|
|
@@ -22,10 +22,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
22
22
|
// src/reactivity/index.ts
|
|
23
23
|
var reactivity_exports = {};
|
|
24
24
|
__export(reactivity_exports, {
|
|
25
|
+
ArrayOp: () => ArrayOp,
|
|
25
26
|
EffectScope: () => EffectScope,
|
|
26
27
|
ITERATE_KEY: () => ITERATE_KEY,
|
|
27
28
|
ReactiveEffect: () => ReactiveEffect,
|
|
28
29
|
TriggerType: () => TriggerType,
|
|
30
|
+
arrayVersion: () => arrayVersion,
|
|
29
31
|
computed: () => computed,
|
|
30
32
|
effect: () => effect,
|
|
31
33
|
effectScope: () => effectScope,
|
|
@@ -38,6 +40,7 @@ __export(reactivity_exports, {
|
|
|
38
40
|
isReactive: () => isReactive,
|
|
39
41
|
isRef: () => isRef,
|
|
40
42
|
markRaw: () => markRaw,
|
|
43
|
+
mutationsSince: () => mutationsSince,
|
|
41
44
|
nextTick: () => nextTick,
|
|
42
45
|
pauseTracking: () => pauseTracking,
|
|
43
46
|
queueJob: () => queueJob,
|
|
@@ -200,7 +203,9 @@ function trigger(target, type, key, _newValue) {
|
|
|
200
203
|
if (!isArr) add(depsMap.get(ITERATE_KEY));
|
|
201
204
|
else if (isIntegerKey(key)) add(depsMap.get("length"));
|
|
202
205
|
} else if (type === "delete" /* DELETE */) {
|
|
203
|
-
|
|
206
|
+
add(depsMap.get(ITERATE_KEY));
|
|
207
|
+
} else if (isArr && isIntegerKey(key)) {
|
|
208
|
+
add(depsMap.get(ITERATE_KEY));
|
|
204
209
|
} else if (isArr && key === "length") {
|
|
205
210
|
const newLen = Number(_newValue);
|
|
206
211
|
depsMap.forEach((dep, k) => {
|
|
@@ -213,12 +218,61 @@ function trigger(target, type, key, _newValue) {
|
|
|
213
218
|
else queueJob(e);
|
|
214
219
|
}
|
|
215
220
|
}
|
|
221
|
+
function triggerArrayRange(target, from) {
|
|
222
|
+
const depsMap = targetMap.get(target);
|
|
223
|
+
if (!depsMap) return;
|
|
224
|
+
const effects = /* @__PURE__ */ new Set();
|
|
225
|
+
const add = (dep) => {
|
|
226
|
+
if (!dep) return;
|
|
227
|
+
for (const e of dep) if (e !== activeEffect) effects.add(e);
|
|
228
|
+
};
|
|
229
|
+
add(depsMap.get("length"));
|
|
230
|
+
add(depsMap.get(ITERATE_KEY));
|
|
231
|
+
if (from >= 0) {
|
|
232
|
+
depsMap.forEach((dep, k) => {
|
|
233
|
+
if (typeof k === "string" && isIntegerKey(k) && Number(k) >= from) add(dep);
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
for (const e of effects) {
|
|
237
|
+
if (e.scheduler) e.scheduler();
|
|
238
|
+
else queueJob(e);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
function record(target, type, index, removed, added) {
|
|
242
|
+
let log = mutationLogs.get(target);
|
|
243
|
+
if (!log) mutationLogs.set(target, log = { version: 0, ops: [] });
|
|
244
|
+
log.version++;
|
|
245
|
+
if (type === 3 /* RESET */) {
|
|
246
|
+
log.ops.length = 0;
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
log.ops.push({ type, index, removed, added });
|
|
250
|
+
if (log.ops.length > LOG_LIMIT) log.ops.shift();
|
|
251
|
+
}
|
|
252
|
+
function arrayVersion(target) {
|
|
253
|
+
const log = mutationLogs.get(target);
|
|
254
|
+
return log ? log.version : 0;
|
|
255
|
+
}
|
|
256
|
+
function mutationsSince(target, since) {
|
|
257
|
+
const log = mutationLogs.get(target);
|
|
258
|
+
if (!log) return since === 0 ? NO_MUTATIONS : null;
|
|
259
|
+
if (since > log.version) return null;
|
|
260
|
+
const missing = log.version - since;
|
|
261
|
+
if (missing === 0) return NO_MUTATIONS;
|
|
262
|
+
if (missing > log.ops.length) return null;
|
|
263
|
+
return log.ops.slice(log.ops.length - missing);
|
|
264
|
+
}
|
|
216
265
|
function isIntegerKey(key) {
|
|
217
266
|
return typeof key === "string" && key !== "NaN" && key[0] !== "-" && String(parseInt(key, 10)) === key;
|
|
218
267
|
}
|
|
219
268
|
function isObject(val) {
|
|
220
269
|
return val !== null && typeof val === "object";
|
|
221
270
|
}
|
|
271
|
+
function spliceStart(raw, length) {
|
|
272
|
+
const n = Math.trunc(Number(raw)) || 0;
|
|
273
|
+
if (n < 0) return Math.max(length + n, 0);
|
|
274
|
+
return Math.min(n, length);
|
|
275
|
+
}
|
|
222
276
|
function canObserve(value) {
|
|
223
277
|
if (!isObject(value)) return false;
|
|
224
278
|
if (value[SKIP]) return false;
|
|
@@ -228,6 +282,23 @@ function canObserve(value) {
|
|
|
228
282
|
if (NON_REACTIVE.has(tag)) return false;
|
|
229
283
|
return tag === "Object" || tag === "Array" || tag === "Map" || tag === "Set";
|
|
230
284
|
}
|
|
285
|
+
function recordDirectWrite(target, key, lengthBefore, hadKey, oldValue, value) {
|
|
286
|
+
if (key === "length") {
|
|
287
|
+
const next = target.length;
|
|
288
|
+
if (next < lengthBefore) record(target, 1 /* SPLICE */, next, lengthBefore - next, 0);
|
|
289
|
+
else if (next > lengthBefore) record(target, 3 /* RESET */, 0, 0, 0);
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
if (!isIntegerKey(key)) return;
|
|
293
|
+
const index = Number(key);
|
|
294
|
+
if (hadKey) {
|
|
295
|
+
if (hasChanged(value, oldValue)) record(target, 2 /* SET */, index, 1, 1);
|
|
296
|
+
} else if (index === lengthBefore) {
|
|
297
|
+
record(target, 1 /* SPLICE */, index, 0, 1);
|
|
298
|
+
} else {
|
|
299
|
+
record(target, 3 /* RESET */, 0, 0, 0);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
231
302
|
function markRaw(value) {
|
|
232
303
|
Object.defineProperty(value, SKIP, { value: true, enumerable: false, configurable: true });
|
|
233
304
|
return value;
|
|
@@ -350,7 +421,7 @@ function traverse(value, seen = /* @__PURE__ */ new Set()) {
|
|
|
350
421
|
else for (const key of Object.keys(value)) traverse(value[key], seen);
|
|
351
422
|
return value;
|
|
352
423
|
}
|
|
353
|
-
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;
|
|
424
|
+
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;
|
|
354
425
|
var init_reactivity = __esm({
|
|
355
426
|
"src/reactivity/index.ts"() {
|
|
356
427
|
resolvedPromise = /* @__PURE__ */ Promise.resolve();
|
|
@@ -477,6 +548,15 @@ var init_reactivity = __esm({
|
|
|
477
548
|
TriggerType2["CLEAR"] = "clear";
|
|
478
549
|
return TriggerType2;
|
|
479
550
|
})(TriggerType || {});
|
|
551
|
+
ArrayOp = /* @__PURE__ */ ((ArrayOp2) => {
|
|
552
|
+
ArrayOp2[ArrayOp2["SPLICE"] = 1] = "SPLICE";
|
|
553
|
+
ArrayOp2[ArrayOp2["SET"] = 2] = "SET";
|
|
554
|
+
ArrayOp2[ArrayOp2["RESET"] = 3] = "RESET";
|
|
555
|
+
return ArrayOp2;
|
|
556
|
+
})(ArrayOp || {});
|
|
557
|
+
LOG_LIMIT = 32;
|
|
558
|
+
mutationLogs = /* @__PURE__ */ new WeakMap();
|
|
559
|
+
NO_MUTATIONS = [];
|
|
480
560
|
RAW = /* @__PURE__ */ Symbol("voodoo:raw");
|
|
481
561
|
IS_REACTIVE = /* @__PURE__ */ Symbol("voodoo:isReactive");
|
|
482
562
|
SKIP = /* @__PURE__ */ Symbol("voodoo:skip");
|
|
@@ -494,14 +574,61 @@ var init_reactivity = __esm({
|
|
|
494
574
|
return res;
|
|
495
575
|
};
|
|
496
576
|
}
|
|
497
|
-
for (const key of ["push", "pop", "shift", "unshift", "splice"]) {
|
|
577
|
+
for (const key of ["push", "pop", "shift", "unshift", "splice", "reverse", "sort"]) {
|
|
498
578
|
inst[key] = function(...args) {
|
|
579
|
+
const raw = toRaw(this);
|
|
580
|
+
const before = raw.length;
|
|
581
|
+
for (let i = 0; i < args.length; i++) args[i] = toRaw(args[i]);
|
|
499
582
|
pauseTracking();
|
|
583
|
+
let result;
|
|
500
584
|
try {
|
|
501
|
-
|
|
585
|
+
result = raw[key].apply(raw, args);
|
|
502
586
|
} finally {
|
|
503
587
|
resetTracking();
|
|
504
588
|
}
|
|
589
|
+
const after = raw.length;
|
|
590
|
+
let from = -1;
|
|
591
|
+
if (key === "push") {
|
|
592
|
+
if (args.length) {
|
|
593
|
+
record(raw, 1 /* SPLICE */, before, 0, args.length);
|
|
594
|
+
from = before;
|
|
595
|
+
}
|
|
596
|
+
} else if (key === "unshift") {
|
|
597
|
+
if (args.length) {
|
|
598
|
+
record(raw, 1 /* SPLICE */, 0, 0, args.length);
|
|
599
|
+
from = 0;
|
|
600
|
+
}
|
|
601
|
+
} else if (key === "pop") {
|
|
602
|
+
if (before > 0) {
|
|
603
|
+
record(raw, 1 /* SPLICE */, after, 1, 0);
|
|
604
|
+
from = after;
|
|
605
|
+
}
|
|
606
|
+
} else if (key === "shift") {
|
|
607
|
+
if (before > 0) {
|
|
608
|
+
record(raw, 1 /* SPLICE */, 0, 1, 0);
|
|
609
|
+
from = 0;
|
|
610
|
+
}
|
|
611
|
+
} else if (key === "splice") {
|
|
612
|
+
const removed = result.length;
|
|
613
|
+
const added = args.length > 2 ? args.length - 2 : 0;
|
|
614
|
+
if (removed || added) {
|
|
615
|
+
record(raw, 1 /* SPLICE */, spliceStart(args[0], before), removed, added);
|
|
616
|
+
from = spliceStart(args[0], before);
|
|
617
|
+
}
|
|
618
|
+
} else {
|
|
619
|
+
if (before > 1) {
|
|
620
|
+
record(raw, 3 /* RESET */, 0, before, after);
|
|
621
|
+
from = 0;
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
if (from >= 0) triggerArrayRange(raw, from);
|
|
625
|
+
if (key === "pop" || key === "shift") return isObject(result) ? reactive(result) : result;
|
|
626
|
+
if (key === "splice") {
|
|
627
|
+
const out = result;
|
|
628
|
+
for (let i = 0; i < out.length; i++) if (isObject(out[i])) out[i] = reactive(out[i]);
|
|
629
|
+
return out;
|
|
630
|
+
}
|
|
631
|
+
return key === "reverse" || key === "sort" ? this : result;
|
|
505
632
|
};
|
|
506
633
|
}
|
|
507
634
|
return inst;
|
|
@@ -543,8 +670,11 @@ var init_reactivity = __esm({
|
|
|
543
670
|
return true;
|
|
544
671
|
}
|
|
545
672
|
const hadKey = Array.isArray(target) && isIntegerKey(key) ? Number(key) < target.length : Object.prototype.hasOwnProperty.call(target, key);
|
|
673
|
+
const isArr = Array.isArray(target);
|
|
674
|
+
const arrayLength = isArr ? target.length : 0;
|
|
546
675
|
const result = Reflect.set(target, key, value, receiver);
|
|
547
676
|
if (target === toRaw(receiver)) {
|
|
677
|
+
if (isArr) recordDirectWrite(target, key, arrayLength, hadKey, oldValue, value);
|
|
548
678
|
if (!hadKey) trigger(target, "add" /* ADD */, key, value);
|
|
549
679
|
else if (hasChanged(value, oldValue)) trigger(target, "set" /* SET */, key, value);
|
|
550
680
|
}
|
|
@@ -553,7 +683,10 @@ var init_reactivity = __esm({
|
|
|
553
683
|
deleteProperty(target, key) {
|
|
554
684
|
const hadKey = Object.prototype.hasOwnProperty.call(target, key);
|
|
555
685
|
const result = Reflect.deleteProperty(target, key);
|
|
556
|
-
if (result && hadKey)
|
|
686
|
+
if (result && hadKey) {
|
|
687
|
+
if (Array.isArray(target)) record(target, 3 /* RESET */, 0, 0, 0);
|
|
688
|
+
trigger(target, "delete" /* DELETE */, key);
|
|
689
|
+
}
|
|
557
690
|
return result;
|
|
558
691
|
},
|
|
559
692
|
has(target, key) {
|
|
@@ -2484,8 +2617,15 @@ function trackEffectScope(node, scope) {
|
|
|
2484
2617
|
list.push(scope);
|
|
2485
2618
|
}
|
|
2486
2619
|
var ignoredRemovals = /* @__PURE__ */ new WeakSet();
|
|
2620
|
+
var detachedTemplates = /* @__PURE__ */ new WeakMap();
|
|
2487
2621
|
function removeQuietly(node) {
|
|
2488
2622
|
ignoredRemovals.add(node);
|
|
2623
|
+
const parent = node.parentNode;
|
|
2624
|
+
if (parent) {
|
|
2625
|
+
let kept = detachedTemplates.get(parent);
|
|
2626
|
+
if (!kept) detachedTemplates.set(parent, kept = /* @__PURE__ */ new Set());
|
|
2627
|
+
kept.add(node);
|
|
2628
|
+
}
|
|
2489
2629
|
node.remove();
|
|
2490
2630
|
}
|
|
2491
2631
|
function addCleanup(node, fn) {
|
|
@@ -2501,6 +2641,11 @@ function destroy(node) {
|
|
|
2501
2641
|
}
|
|
2502
2642
|
for (let i = children.length - 1; i >= 0; i--) destroy(children[i]);
|
|
2503
2643
|
}
|
|
2644
|
+
const detached = detachedTemplates.get(node);
|
|
2645
|
+
if (detached) {
|
|
2646
|
+
detachedTemplates.delete(node);
|
|
2647
|
+
for (const template of detached) destroy(template);
|
|
2648
|
+
}
|
|
2504
2649
|
const list = nodeCleanups.get(node);
|
|
2505
2650
|
if (list) {
|
|
2506
2651
|
nodeCleanups.delete(node);
|
|
@@ -5623,6 +5768,8 @@ function viewTransition(update) {
|
|
|
5623
5768
|
// src/directives/core.ts
|
|
5624
5769
|
init_reactivity();
|
|
5625
5770
|
init_registry();
|
|
5771
|
+
|
|
5772
|
+
// src/directives/core.ts
|
|
5626
5773
|
function setValue(expression, scope, value) {
|
|
5627
5774
|
try {
|
|
5628
5775
|
const target = parse(expression);
|
|
@@ -5767,7 +5914,7 @@ defineDirective(
|
|
|
5767
5914
|
},
|
|
5768
5915
|
{ priority: PRIORITY.IF, terminal: true }
|
|
5769
5916
|
);
|
|
5770
|
-
function renderTemplate(source, anchor, scope
|
|
5917
|
+
function renderTemplate(source, anchor, scope) {
|
|
5771
5918
|
const parent = anchor.parentNode;
|
|
5772
5919
|
if (!parent) return [];
|
|
5773
5920
|
const nodes = [];
|
|
@@ -5786,19 +5933,61 @@ function renderTemplate(source, anchor, scope, batch) {
|
|
|
5786
5933
|
const clone2 = source.cloneNode(true);
|
|
5787
5934
|
nodes.push(clone2);
|
|
5788
5935
|
markNodeScope(clone2, scope);
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
batch.pending.push([clone2, scope]);
|
|
5792
|
-
} else {
|
|
5793
|
-
parent.insertBefore(clone2, anchor);
|
|
5794
|
-
walk(clone2, scope);
|
|
5795
|
-
}
|
|
5936
|
+
parent.insertBefore(clone2, anchor);
|
|
5937
|
+
walk(clone2, scope);
|
|
5796
5938
|
}
|
|
5797
5939
|
return nodes;
|
|
5798
5940
|
}
|
|
5799
5941
|
defineDirective("else-if", () => void 0, { priority: PRIORITY.IF, terminal: true });
|
|
5800
5942
|
defineDirective("else", () => void 0, { priority: PRIORITY.IF, terminal: true });
|
|
5801
5943
|
var FOR_PATTERN = /^\s*\(?\s*([^)]*?)\s*\)?\s+(?:in|of)\s+(.+?)\s*$/;
|
|
5944
|
+
var KEY_PATH = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/;
|
|
5945
|
+
var NO_BLOCKS = [];
|
|
5946
|
+
function sameStored(stored, incoming) {
|
|
5947
|
+
if (stored === incoming) return true;
|
|
5948
|
+
return incoming !== null && typeof incoming === "object" && stored === toRaw(incoming);
|
|
5949
|
+
}
|
|
5950
|
+
function sameKey(a, b) {
|
|
5951
|
+
return a === b || a !== a && b !== b;
|
|
5952
|
+
}
|
|
5953
|
+
function longestIncreasing(arr) {
|
|
5954
|
+
const length = arr.length;
|
|
5955
|
+
const previous = new Int32Array(length);
|
|
5956
|
+
const tails = [];
|
|
5957
|
+
for (let i = 0; i < length; i++) {
|
|
5958
|
+
const value = arr[i];
|
|
5959
|
+
if (value === 0) continue;
|
|
5960
|
+
if (tails.length === 0) {
|
|
5961
|
+
tails.push(i);
|
|
5962
|
+
continue;
|
|
5963
|
+
}
|
|
5964
|
+
const last = tails[tails.length - 1];
|
|
5965
|
+
if (arr[last] < value) {
|
|
5966
|
+
previous[i] = last;
|
|
5967
|
+
tails.push(i);
|
|
5968
|
+
continue;
|
|
5969
|
+
}
|
|
5970
|
+
let low = 0;
|
|
5971
|
+
let high = tails.length - 1;
|
|
5972
|
+
while (low < high) {
|
|
5973
|
+
const mid = low + high >> 1;
|
|
5974
|
+
if (arr[tails[mid]] < value) low = mid + 1;
|
|
5975
|
+
else high = mid;
|
|
5976
|
+
}
|
|
5977
|
+
if (value < arr[tails[low]]) {
|
|
5978
|
+
if (low > 0) previous[i] = tails[low - 1];
|
|
5979
|
+
tails[low] = i;
|
|
5980
|
+
}
|
|
5981
|
+
}
|
|
5982
|
+
let cursor = tails.length;
|
|
5983
|
+
const out = new Int32Array(cursor);
|
|
5984
|
+
let node = tails[cursor - 1];
|
|
5985
|
+
while (cursor-- > 0) {
|
|
5986
|
+
out[cursor] = node;
|
|
5987
|
+
node = previous[node];
|
|
5988
|
+
}
|
|
5989
|
+
return out;
|
|
5990
|
+
}
|
|
5802
5991
|
defineDirective(
|
|
5803
5992
|
"for",
|
|
5804
5993
|
({ el, scope, expression, effect: effect2 }) => {
|
|
@@ -5823,77 +6012,322 @@ defineDirective(
|
|
|
5823
6012
|
template.removeAttribute(`${p2}bind:key`);
|
|
5824
6013
|
template.removeAttribute(`${p2}key`);
|
|
5825
6014
|
removeQuietly(el);
|
|
6015
|
+
const isTemplateRow = template.tagName === "TEMPLATE";
|
|
6016
|
+
let keyIsItem = false;
|
|
6017
|
+
let keyIsIndex = false;
|
|
6018
|
+
let keyProp = null;
|
|
6019
|
+
let keyPath = null;
|
|
6020
|
+
if (keyExpression && KEY_PATH.test(keyExpression)) {
|
|
6021
|
+
const parts = keyExpression.split(".");
|
|
6022
|
+
if (parts[0] === itemAlias) {
|
|
6023
|
+
if (parts.length === 1) keyIsItem = true;
|
|
6024
|
+
else if (parts.length === 2) keyProp = parts[1];
|
|
6025
|
+
else keyPath = parts.slice(1);
|
|
6026
|
+
} else if (indexAlias && parts.length === 1 && parts[0] === indexAlias) {
|
|
6027
|
+
keyIsIndex = true;
|
|
6028
|
+
}
|
|
6029
|
+
}
|
|
5826
6030
|
let blocks = [];
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
|
|
5830
|
-
|
|
5831
|
-
|
|
6031
|
+
let rows = [];
|
|
6032
|
+
let entries = null;
|
|
6033
|
+
let count = 0;
|
|
6034
|
+
let keyScope = null;
|
|
6035
|
+
let lastSource = null;
|
|
6036
|
+
let lastVersion = 0;
|
|
6037
|
+
const pending = [];
|
|
6038
|
+
const pendingRuns = [];
|
|
6039
|
+
const varsAt = (i) => {
|
|
6040
|
+
if (entries) return entries[i];
|
|
6041
|
+
const vars = { [itemAlias]: rows[i] };
|
|
6042
|
+
if (indexAlias) vars[indexAlias] = i;
|
|
6043
|
+
return vars;
|
|
6044
|
+
};
|
|
6045
|
+
const keyAt = (i) => {
|
|
6046
|
+
if (keyIsIndex) return i;
|
|
6047
|
+
if (!keyExpression) {
|
|
6048
|
+
return i;
|
|
6049
|
+
}
|
|
6050
|
+
const item = entries ? entries[i][itemAlias] : rows[i];
|
|
6051
|
+
if (keyIsItem) return item;
|
|
6052
|
+
if (keyProp !== null) return item == null ? void 0 : item[keyProp];
|
|
6053
|
+
if (keyPath !== null) {
|
|
6054
|
+
let value = item;
|
|
6055
|
+
for (let d = 0; d < keyPath.length; d++) {
|
|
6056
|
+
if (value == null) return void 0;
|
|
6057
|
+
value = value[keyPath[d]];
|
|
5832
6058
|
}
|
|
6059
|
+
return value;
|
|
5833
6060
|
}
|
|
5834
|
-
|
|
6061
|
+
if (!keyScope) keyScope = scope.child({});
|
|
6062
|
+
keyScope.data = varsAt(i);
|
|
6063
|
+
return evaluateIn(keyExpression, keyScope, ":key");
|
|
5835
6064
|
};
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
const batch = {
|
|
5845
|
-
fragment: document.createDocumentFragment(),
|
|
5846
|
-
pending: []
|
|
5847
|
-
};
|
|
5848
|
-
entries.forEach((vars, index) => {
|
|
5849
|
-
const key = keyExpression ? evaluateIn(keyExpression, scope.child(vars), ":key") : `__index_${index}`;
|
|
5850
|
-
if (keyExpression && used.has(key)) warnDuplicateKey(el, key, expression);
|
|
5851
|
-
const existing = previous.get(key);
|
|
5852
|
-
if (existing && !used.has(key)) {
|
|
5853
|
-
used.add(key);
|
|
5854
|
-
for (const [name, value] of Object.entries(vars)) existing.data[name] = value;
|
|
5855
|
-
next.push(existing);
|
|
5856
|
-
return;
|
|
6065
|
+
const syncData = (block2, i) => {
|
|
6066
|
+
const raw = toRaw(block2.data);
|
|
6067
|
+
if (entries) {
|
|
6068
|
+
const vars = entries[i];
|
|
6069
|
+
for (const name in vars) {
|
|
6070
|
+
if (!sameStored(raw[name], vars[name])) {
|
|
6071
|
+
block2.data[name] = vars[name];
|
|
6072
|
+
}
|
|
5857
6073
|
}
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
|
|
5862
|
-
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
|
|
5869
|
-
|
|
5870
|
-
|
|
6074
|
+
return;
|
|
6075
|
+
}
|
|
6076
|
+
const item = rows[i];
|
|
6077
|
+
if (!sameStored(raw[itemAlias], item)) {
|
|
6078
|
+
block2.data[itemAlias] = item;
|
|
6079
|
+
}
|
|
6080
|
+
if (indexAlias !== void 0 && raw[indexAlias] !== i) {
|
|
6081
|
+
block2.data[indexAlias] = i;
|
|
6082
|
+
}
|
|
6083
|
+
};
|
|
6084
|
+
const buildRange = (from, to, before, out) => {
|
|
6085
|
+
if (from >= to) return;
|
|
6086
|
+
const parent = anchor.parentNode;
|
|
6087
|
+
if (!parent) return;
|
|
6088
|
+
pendingRuns.push(pending.length);
|
|
6089
|
+
if (isTemplateRow) {
|
|
6090
|
+
for (let i = from; i < to; i++) {
|
|
6091
|
+
const childScope = scope.reactiveChild(varsAt(i));
|
|
6092
|
+
const nodes = renderTemplate(template, before, childScope);
|
|
6093
|
+
out.push({ key: keyAt(i), scope: childScope, nodes, data: childScope.data });
|
|
6094
|
+
}
|
|
6095
|
+
return;
|
|
6096
|
+
}
|
|
6097
|
+
const fragment = document.createDocumentFragment();
|
|
6098
|
+
for (let i = from; i < to; i++) {
|
|
6099
|
+
const childScope = scope.reactiveChild(varsAt(i));
|
|
6100
|
+
const clone2 = template.cloneNode(true);
|
|
6101
|
+
markNodeScope(clone2, childScope);
|
|
6102
|
+
fragment.appendChild(clone2);
|
|
6103
|
+
pending.push([clone2, childScope]);
|
|
6104
|
+
out.push({ key: keyAt(i), scope: childScope, nodes: [clone2], data: childScope.data });
|
|
6105
|
+
}
|
|
6106
|
+
parent.insertBefore(fragment, before);
|
|
6107
|
+
};
|
|
6108
|
+
const destroyBlock = (block2) => {
|
|
6109
|
+
const nodes = block2.nodes;
|
|
6110
|
+
for (let j = 0; j < nodes.length; j++) {
|
|
6111
|
+
destroy(nodes[j]);
|
|
6112
|
+
nodes[j].remove();
|
|
6113
|
+
}
|
|
6114
|
+
};
|
|
6115
|
+
const moveBlock = (block2, before) => {
|
|
6116
|
+
const parent = anchor.parentNode;
|
|
6117
|
+
if (!parent) return;
|
|
6118
|
+
const nodes = block2.nodes;
|
|
6119
|
+
if (nodes[nodes.length - 1].nextSibling === before) return;
|
|
6120
|
+
for (let j = 0; j < nodes.length; j++) {
|
|
6121
|
+
parent.insertBefore(nodes[j], before);
|
|
6122
|
+
}
|
|
6123
|
+
};
|
|
6124
|
+
const nodeAfter = (oldIndex) => oldIndex < blocks.length ? blocks[oldIndex].nodes[0] : anchor;
|
|
6125
|
+
const spliceBlocks = (index, remove, added) => {
|
|
6126
|
+
const addCount = added.length;
|
|
6127
|
+
if (remove === 0 && addCount === 0) return;
|
|
6128
|
+
if (blocks.length === 0) {
|
|
6129
|
+
blocks = added;
|
|
6130
|
+
return;
|
|
6131
|
+
}
|
|
6132
|
+
if (addCount === 0) {
|
|
6133
|
+
blocks.splice(index, remove);
|
|
6134
|
+
return;
|
|
6135
|
+
}
|
|
6136
|
+
if (addCount <= 1024) {
|
|
6137
|
+
blocks.splice(index, remove, ...added);
|
|
6138
|
+
return;
|
|
6139
|
+
}
|
|
6140
|
+
const out = new Array(blocks.length - remove + addCount);
|
|
6141
|
+
let w = 0;
|
|
6142
|
+
for (let k = 0; k < index; k++) out[w++] = blocks[k];
|
|
6143
|
+
for (let k = 0; k < addCount; k++) out[w++] = added[k];
|
|
6144
|
+
for (let k = index + remove; k < blocks.length; k++) out[w++] = blocks[k];
|
|
6145
|
+
blocks = out;
|
|
6146
|
+
};
|
|
6147
|
+
const flushPending = () => {
|
|
6148
|
+
for (let r = pendingRuns.length - 1; r >= 0; r--) {
|
|
6149
|
+
const start2 = pendingRuns[r];
|
|
6150
|
+
const end = r + 1 < pendingRuns.length ? pendingRuns[r + 1] : pending.length;
|
|
6151
|
+
for (let k = start2; k < end; k++) walk(pending[k][0], pending[k][1]);
|
|
6152
|
+
}
|
|
6153
|
+
pending.length = 0;
|
|
6154
|
+
pendingRuns.length = 0;
|
|
6155
|
+
};
|
|
6156
|
+
let lo = 0;
|
|
6157
|
+
let oldHi = 0;
|
|
6158
|
+
let newHi = 0;
|
|
6159
|
+
const regionFromMutations = (source) => {
|
|
6160
|
+
const ops = mutationsSince(source, lastVersion);
|
|
6161
|
+
if (!ops) return false;
|
|
6162
|
+
const oldLen = blocks.length;
|
|
6163
|
+
lo = 0;
|
|
6164
|
+
oldHi = 0;
|
|
6165
|
+
newHi = 0;
|
|
6166
|
+
let current2 = oldLen;
|
|
6167
|
+
for (let k = 0; k < ops.length; k++) {
|
|
6168
|
+
const op = ops[k];
|
|
6169
|
+
const index = op.index;
|
|
6170
|
+
const removed = op.type === 2 /* SET */ ? 1 : op.removed;
|
|
6171
|
+
const added = op.type === 2 /* SET */ ? 1 : op.added;
|
|
6172
|
+
const end = index + removed;
|
|
6173
|
+
if (k === 0) {
|
|
6174
|
+
lo = index;
|
|
6175
|
+
oldHi = end;
|
|
6176
|
+
newHi = index + added;
|
|
6177
|
+
} else if (end <= newHi) {
|
|
6178
|
+
if (index < lo) lo = index;
|
|
6179
|
+
newHi += added - removed;
|
|
6180
|
+
} else {
|
|
6181
|
+
if (index < lo) lo = index;
|
|
6182
|
+
oldHi = end - newHi + oldHi;
|
|
6183
|
+
newHi = index + added;
|
|
5871
6184
|
}
|
|
6185
|
+
if (oldHi < lo) oldHi = lo;
|
|
6186
|
+
if (newHi < lo) newHi = lo;
|
|
6187
|
+
current2 += added - removed;
|
|
5872
6188
|
}
|
|
5873
|
-
|
|
5874
|
-
|
|
5875
|
-
|
|
5876
|
-
|
|
5877
|
-
|
|
5878
|
-
|
|
6189
|
+
if (current2 !== count) return false;
|
|
6190
|
+
if (lo > oldHi || lo > newHi) return false;
|
|
6191
|
+
if (oldHi > oldLen || newHi > count) return false;
|
|
6192
|
+
if (indexAlias !== void 0 && oldHi - newHi !== 0) {
|
|
6193
|
+
for (let i = newHi; i < count; i++) syncData(blocks[i - newHi + oldHi], i);
|
|
6194
|
+
}
|
|
6195
|
+
return true;
|
|
6196
|
+
};
|
|
6197
|
+
const regionFromScan = () => {
|
|
6198
|
+
const oldLen = blocks.length;
|
|
6199
|
+
const newLen = count;
|
|
6200
|
+
let i = 0;
|
|
6201
|
+
const shared = oldLen < newLen ? oldLen : newLen;
|
|
6202
|
+
while (i < shared) {
|
|
6203
|
+
const block2 = blocks[i];
|
|
6204
|
+
if (!sameKey(block2.key, keyAt(i))) break;
|
|
6205
|
+
syncData(block2, i);
|
|
6206
|
+
i++;
|
|
6207
|
+
}
|
|
6208
|
+
let oe = oldLen - 1;
|
|
6209
|
+
let ne = newLen - 1;
|
|
6210
|
+
while (oe >= i && ne >= i) {
|
|
6211
|
+
const block2 = blocks[oe];
|
|
6212
|
+
if (!sameKey(block2.key, keyAt(ne))) break;
|
|
6213
|
+
syncData(block2, ne);
|
|
6214
|
+
oe--;
|
|
6215
|
+
ne--;
|
|
6216
|
+
}
|
|
6217
|
+
lo = i;
|
|
6218
|
+
oldHi = oe + 1;
|
|
6219
|
+
newHi = ne + 1;
|
|
6220
|
+
};
|
|
6221
|
+
const reconcileRegion = () => {
|
|
6222
|
+
const toPatch = newHi - lo;
|
|
6223
|
+
if (lo >= oldHi) {
|
|
6224
|
+
if (toPatch > 0) {
|
|
6225
|
+
const created = [];
|
|
6226
|
+
buildRange(lo, newHi, nodeAfter(lo), created);
|
|
6227
|
+
spliceBlocks(lo, 0, created);
|
|
6228
|
+
}
|
|
6229
|
+
return;
|
|
6230
|
+
}
|
|
6231
|
+
if (toPatch === 0) {
|
|
6232
|
+
for (let j = lo; j < oldHi; j++) destroyBlock(blocks[j]);
|
|
6233
|
+
spliceBlocks(lo, oldHi - lo, NO_BLOCKS);
|
|
6234
|
+
return;
|
|
6235
|
+
}
|
|
6236
|
+
const keyToNew = /* @__PURE__ */ new Map();
|
|
6237
|
+
for (let n = lo; n < newHi; n++) {
|
|
6238
|
+
const key = keyAt(n);
|
|
6239
|
+
if (keyExpression && keyToNew.has(key)) warnDuplicateKey(el, key, expression);
|
|
6240
|
+
keyToNew.set(key, n);
|
|
6241
|
+
}
|
|
6242
|
+
const oldOfNew = new Int32Array(toPatch);
|
|
6243
|
+
const reused = new Array(toPatch);
|
|
6244
|
+
let matched = 0;
|
|
6245
|
+
let moved = false;
|
|
6246
|
+
let highestSoFar = 0;
|
|
6247
|
+
for (let o = lo; o < oldHi; o++) {
|
|
6248
|
+
const block2 = blocks[o];
|
|
6249
|
+
const target = matched >= toPatch ? void 0 : keyToNew.get(block2.key);
|
|
6250
|
+
if (target === void 0 || reused[target - lo] !== void 0) {
|
|
6251
|
+
destroyBlock(block2);
|
|
6252
|
+
continue;
|
|
6253
|
+
}
|
|
6254
|
+
oldOfNew[target - lo] = o + 1;
|
|
6255
|
+
reused[target - lo] = block2;
|
|
6256
|
+
if (target >= highestSoFar) highestSoFar = target;
|
|
6257
|
+
else moved = true;
|
|
6258
|
+
syncData(block2, target);
|
|
6259
|
+
matched++;
|
|
6260
|
+
}
|
|
6261
|
+
const stay = moved ? longestIncreasing(oldOfNew) : null;
|
|
6262
|
+
let s = stay ? stay.length - 1 : -1;
|
|
6263
|
+
const region = new Array(toPatch);
|
|
6264
|
+
let before = nodeAfter(oldHi);
|
|
6265
|
+
let runEnd = -1;
|
|
6266
|
+
for (let n = toPatch - 1; n >= 0; n--) {
|
|
6267
|
+
const newIndex = lo + n;
|
|
6268
|
+
const block2 = reused[n];
|
|
6269
|
+
if (block2 === void 0) {
|
|
6270
|
+
if (runEnd < 0) runEnd = newIndex + 1;
|
|
6271
|
+
continue;
|
|
6272
|
+
}
|
|
6273
|
+
if (runEnd >= 0) {
|
|
6274
|
+
const created = [];
|
|
6275
|
+
buildRange(newIndex + 1, runEnd, before, created);
|
|
6276
|
+
for (let c = 0; c < created.length; c++) region[n + 1 + c] = created[c];
|
|
6277
|
+
if (created.length) before = created[0].nodes[0];
|
|
6278
|
+
runEnd = -1;
|
|
5879
6279
|
}
|
|
5880
|
-
|
|
6280
|
+
region[n] = block2;
|
|
6281
|
+
if (moved && (s < 0 || n !== stay[s])) moveBlock(block2, before);
|
|
6282
|
+
else if (moved) s--;
|
|
6283
|
+
before = block2.nodes[0];
|
|
5881
6284
|
}
|
|
5882
|
-
|
|
6285
|
+
if (runEnd >= 0) {
|
|
6286
|
+
const created = [];
|
|
6287
|
+
buildRange(lo, runEnd, before, created);
|
|
6288
|
+
for (let c = 0; c < created.length; c++) region[c] = created[c];
|
|
6289
|
+
}
|
|
6290
|
+
spliceBlocks(lo, oldHi - lo, region);
|
|
6291
|
+
};
|
|
6292
|
+
const clearAll = () => {
|
|
6293
|
+
for (const block2 of blocks) destroyBlock(block2);
|
|
6294
|
+
blocks = [];
|
|
6295
|
+
lastSource = null;
|
|
6296
|
+
lastVersion = 0;
|
|
6297
|
+
};
|
|
6298
|
+
addCleanup(anchor, clearAll);
|
|
6299
|
+
effect2(() => {
|
|
6300
|
+
const source = evaluateIn(sourceExpression, scope, "v-for");
|
|
6301
|
+
const raw = toRaw(source);
|
|
6302
|
+
let fromMutations = false;
|
|
6303
|
+
if (Array.isArray(raw)) {
|
|
6304
|
+
track(raw, "length");
|
|
6305
|
+
track(raw, ITERATE_KEY);
|
|
6306
|
+
rows = raw;
|
|
6307
|
+
entries = null;
|
|
6308
|
+
count = raw.length;
|
|
6309
|
+
const version3 = arrayVersion(raw);
|
|
6310
|
+
if (raw === lastSource && keyExpression && !keyIsIndex) {
|
|
6311
|
+
fromMutations = regionFromMutations(raw);
|
|
6312
|
+
}
|
|
6313
|
+
lastSource = raw;
|
|
6314
|
+
lastVersion = version3;
|
|
6315
|
+
} else {
|
|
6316
|
+
entries = normalizeSource(source, itemAlias, indexAlias, thirdAlias);
|
|
6317
|
+
rows = entries;
|
|
6318
|
+
count = entries.length;
|
|
6319
|
+
lastSource = null;
|
|
6320
|
+
lastVersion = 0;
|
|
6321
|
+
}
|
|
6322
|
+
if (!fromMutations) regionFromScan();
|
|
6323
|
+
reconcileRegion();
|
|
6324
|
+
flushPending();
|
|
5883
6325
|
});
|
|
5884
6326
|
},
|
|
5885
6327
|
{ priority: PRIORITY.FOR, terminal: true }
|
|
5886
6328
|
);
|
|
5887
6329
|
function normalizeSource(source, itemAlias, indexAlias, thirdAlias) {
|
|
5888
6330
|
const out = [];
|
|
5889
|
-
if (Array.isArray(source)) {
|
|
5890
|
-
source.forEach((item, index) => {
|
|
5891
|
-
const vars = { [itemAlias]: item };
|
|
5892
|
-
if (indexAlias) vars[indexAlias] = index;
|
|
5893
|
-
out.push(vars);
|
|
5894
|
-
});
|
|
5895
|
-
return out;
|
|
5896
|
-
}
|
|
5897
6331
|
if (typeof source === "number") {
|
|
5898
6332
|
for (let i = 1; i <= source; i++) {
|
|
5899
6333
|
const vars = { [itemAlias]: i };
|
|
@@ -7016,7 +7450,7 @@ function data(values) {
|
|
|
7016
7450
|
Object.defineProperties(rootScope.data, Object.getOwnPropertyDescriptors(values));
|
|
7017
7451
|
return rootScope.data;
|
|
7018
7452
|
}
|
|
7019
|
-
var version2 = "0.
|
|
7453
|
+
var version2 = "0.13.0";
|
|
7020
7454
|
var core = {
|
|
7021
7455
|
// Utilities first: Voodoo's own names can override.
|
|
7022
7456
|
...utils_exports,
|
|
@@ -12406,7 +12840,7 @@ defineDirective(
|
|
|
12406
12840
|
restoring = false;
|
|
12407
12841
|
});
|
|
12408
12842
|
}
|
|
12409
|
-
const
|
|
12843
|
+
const record2 = debounce(() => {
|
|
12410
12844
|
if (restoring) return;
|
|
12411
12845
|
const current2 = JSON.stringify(serializable(scope.data));
|
|
12412
12846
|
if (current2 === JSON.stringify(snapshots[position])) return;
|
|
@@ -12416,12 +12850,12 @@ defineDirective(
|
|
|
12416
12850
|
position = snapshots.length - 1;
|
|
12417
12851
|
sync();
|
|
12418
12852
|
}, parseDuration(el.getAttribute("v-history-debounce") ?? void 0, 300));
|
|
12419
|
-
const stopWatching = watch(scope.data, () =>
|
|
12853
|
+
const stopWatching = watch(scope.data, () => record2(), { deep: true });
|
|
12420
12854
|
controllers.set(el, controller);
|
|
12421
12855
|
scope.set("$history", controller);
|
|
12422
12856
|
cleanup(() => {
|
|
12423
12857
|
stopWatching();
|
|
12424
|
-
|
|
12858
|
+
record2.cancel();
|
|
12425
12859
|
controllers.delete(el);
|
|
12426
12860
|
});
|
|
12427
12861
|
},
|