@solidjs/signals 0.13.7 → 0.13.9
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/dev.js +55 -28
- package/dist/node.cjs +113 -85
- package/dist/prod.js +105 -72
- package/dist/types/store/utils.d.ts +1 -2
- package/package.json +1 -1
package/dist/dev.js
CHANGED
|
@@ -1361,7 +1361,7 @@ function updateIfNecessary(el) {
|
|
|
1361
1361
|
) {
|
|
1362
1362
|
recompute(el);
|
|
1363
1363
|
}
|
|
1364
|
-
el._flags =
|
|
1364
|
+
el._flags = el._flags & (REACTIVE_SNAPSHOT_STALE | REACTIVE_IN_HEAP | REACTIVE_IN_HEAP_HEIGHT);
|
|
1365
1365
|
}
|
|
1366
1366
|
function computed(fn, initialValue, options) {
|
|
1367
1367
|
const transparent = options?.transparent ?? false;
|
|
@@ -1606,7 +1606,7 @@ function read(el) {
|
|
|
1606
1606
|
}
|
|
1607
1607
|
if (el._fn && el._statusFlags & STATUS_ERROR) {
|
|
1608
1608
|
if (el._time < clock) {
|
|
1609
|
-
recompute(el
|
|
1609
|
+
recompute(el);
|
|
1610
1610
|
return read(el);
|
|
1611
1611
|
} else throw el._error;
|
|
1612
1612
|
}
|
|
@@ -2335,6 +2335,18 @@ function createWriteTraps(isActive) {
|
|
|
2335
2335
|
}
|
|
2336
2336
|
return typeof value === "object" && value !== null ? new Proxy(value, traps) : value;
|
|
2337
2337
|
},
|
|
2338
|
+
has(_, prop) {
|
|
2339
|
+
let value;
|
|
2340
|
+
setWriteOverride(true);
|
|
2341
|
+
setProjectionWriteActive(true);
|
|
2342
|
+
try {
|
|
2343
|
+
value = prop in _;
|
|
2344
|
+
} finally {
|
|
2345
|
+
setWriteOverride(false);
|
|
2346
|
+
setProjectionWriteActive(false);
|
|
2347
|
+
}
|
|
2348
|
+
return value;
|
|
2349
|
+
},
|
|
2338
2350
|
set(_, prop, value) {
|
|
2339
2351
|
if (isActive && !isActive()) return true;
|
|
2340
2352
|
setWriteOverride(true);
|
|
@@ -2392,7 +2404,12 @@ function wrap(value, target) {
|
|
|
2392
2404
|
return p;
|
|
2393
2405
|
}
|
|
2394
2406
|
function isWrappable(obj) {
|
|
2395
|
-
return
|
|
2407
|
+
return (
|
|
2408
|
+
obj != null &&
|
|
2409
|
+
typeof obj === "object" &&
|
|
2410
|
+
!Object.isFrozen(obj) &&
|
|
2411
|
+
!(typeof Node !== "undefined" && obj instanceof Node)
|
|
2412
|
+
);
|
|
2396
2413
|
}
|
|
2397
2414
|
let writeOverride = false;
|
|
2398
2415
|
function setWriteOverride(value) {
|
|
@@ -2544,17 +2561,19 @@ const storeTraps = {
|
|
|
2544
2561
|
: target[STORE_OVERRIDE] && property in target[STORE_OVERRIDE]
|
|
2545
2562
|
? target[STORE_OVERRIDE][property] !== $DELETED
|
|
2546
2563
|
: property in target[STORE_VALUE];
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2564
|
+
if (!writeOnly(target[$PROXY])) {
|
|
2565
|
+
getObserver() &&
|
|
2566
|
+
read(
|
|
2567
|
+
getNode(
|
|
2568
|
+
getNodes(target, STORE_HAS),
|
|
2569
|
+
property,
|
|
2570
|
+
has,
|
|
2571
|
+
target[STORE_FIREWALL],
|
|
2572
|
+
isEqual,
|
|
2573
|
+
target[STORE_OPTIMISTIC]
|
|
2574
|
+
)
|
|
2575
|
+
);
|
|
2576
|
+
}
|
|
2558
2577
|
return has;
|
|
2559
2578
|
},
|
|
2560
2579
|
set(target, property, rawValue) {
|
|
@@ -2592,25 +2611,32 @@ const storeTraps = {
|
|
|
2592
2611
|
? target[STORE_OVERRIDE][property]
|
|
2593
2612
|
: base;
|
|
2594
2613
|
const value = rawValue?.[$TARGET]?.[STORE_VALUE] ?? rawValue;
|
|
2595
|
-
|
|
2614
|
+
const isArrayIndexWrite = Array.isArray(state) && property !== "length";
|
|
2615
|
+
const nextIndex = isArrayIndexWrite ? parseInt(property) + 1 : 0;
|
|
2596
2616
|
const len =
|
|
2597
|
-
|
|
2598
|
-
target[
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2617
|
+
isArrayIndexWrite &&
|
|
2618
|
+
(target[STORE_OPTIMISTIC_OVERRIDE] && "length" in target[STORE_OPTIMISTIC_OVERRIDE]
|
|
2619
|
+
? target[STORE_OPTIMISTIC_OVERRIDE].length
|
|
2620
|
+
: target[STORE_OVERRIDE] && "length" in target[STORE_OVERRIDE]
|
|
2621
|
+
? target[STORE_OVERRIDE].length
|
|
2622
|
+
: state.length);
|
|
2623
|
+
const nextLength = isArrayIndexWrite && nextIndex > len ? nextIndex : undefined;
|
|
2624
|
+
if (prev === value && nextLength === undefined) return true;
|
|
2625
|
+
if (value !== undefined && value === base && nextLength === undefined)
|
|
2626
|
+
delete target[overrideKey]?.[property];
|
|
2627
|
+
else {
|
|
2628
|
+
const override = target[overrideKey] || (target[overrideKey] = Object.create(null));
|
|
2629
|
+
override[property] = value;
|
|
2630
|
+
if (nextLength !== undefined) override.length = nextLength;
|
|
2631
|
+
}
|
|
2602
2632
|
const wrappable = isWrappable(value);
|
|
2603
2633
|
target[STORE_HAS]?.[property] && setSignal(target[STORE_HAS][property], true);
|
|
2604
2634
|
const nodes = getNodes(target, STORE_NODE);
|
|
2605
2635
|
nodes[property] &&
|
|
2606
2636
|
setSignal(nodes[property], () => (wrappable ? wrap(value, target) : value));
|
|
2607
2637
|
if (Array.isArray(state)) {
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
} else {
|
|
2611
|
-
const index = parseInt(property) + 1;
|
|
2612
|
-
if (index > len) nodes.length && setSignal(nodes.length, index);
|
|
2613
|
-
}
|
|
2638
|
+
const lengthValue = property === "length" ? value : nextLength;
|
|
2639
|
+
lengthValue !== undefined && nodes.length && setSignal(nodes.length, lengthValue);
|
|
2614
2640
|
}
|
|
2615
2641
|
nodes[$TRACK] && setSignal(nodes[$TRACK], undefined);
|
|
2616
2642
|
});
|
|
@@ -3364,8 +3390,9 @@ class CollectionQueue extends Queue {
|
|
|
3364
3390
|
checkSources() {
|
|
3365
3391
|
for (const source of this._sources) {
|
|
3366
3392
|
if (
|
|
3367
|
-
|
|
3368
|
-
!(
|
|
3393
|
+
source._flags & REACTIVE_DISPOSED ||
|
|
3394
|
+
(!(source._statusFlags & this._collectionType) &&
|
|
3395
|
+
!(this._collectionType & STATUS_ERROR && source._statusFlags & STATUS_PENDING))
|
|
3369
3396
|
)
|
|
3370
3397
|
this._sources.delete(source);
|
|
3371
3398
|
}
|
package/dist/node.cjs
CHANGED
|
@@ -44,8 +44,8 @@ const S = {};
|
|
|
44
44
|
const w = {};
|
|
45
45
|
const m = "sp";
|
|
46
46
|
const b = typeof Proxy === "function";
|
|
47
|
-
const
|
|
48
|
-
const
|
|
47
|
+
const O = {};
|
|
48
|
+
const _ = Symbol("refresh");
|
|
49
49
|
function actualInsertIntoHeap(e, t) {
|
|
50
50
|
const n = (e.i?.t ? e.i.u?.o : e.i?.o) ?? -1;
|
|
51
51
|
if (n >= e.o) e.o = n + 1;
|
|
@@ -92,8 +92,8 @@ function deleteFromHeap(e, t) {
|
|
|
92
92
|
e.h = undefined;
|
|
93
93
|
}
|
|
94
94
|
function markHeap(e) {
|
|
95
|
-
if (e.
|
|
96
|
-
e.
|
|
95
|
+
if (e.O) return;
|
|
96
|
+
e.O = true;
|
|
97
97
|
for (let t = 0; t <= e.S; t++) {
|
|
98
98
|
for (let n = e.l[t]; n !== undefined; n = n.h) {
|
|
99
99
|
if (n.m & i) markNode(n);
|
|
@@ -104,19 +104,19 @@ function markNode(e, r = n) {
|
|
|
104
104
|
const i = e.m;
|
|
105
105
|
if ((i & (t | n)) >= r) return;
|
|
106
106
|
e.m = (i & -4) | r;
|
|
107
|
-
for (let n = e.
|
|
107
|
+
for (let n = e._; n !== null; n = n.P) {
|
|
108
108
|
markNode(n.k, t);
|
|
109
109
|
}
|
|
110
|
-
if (e.
|
|
111
|
-
for (let n = e.
|
|
112
|
-
for (let e = n.
|
|
110
|
+
if (e.W !== null) {
|
|
111
|
+
for (let n = e.W; n !== null; n = n.C) {
|
|
112
|
+
for (let e = n._; e !== null; e = e.P) {
|
|
113
113
|
markNode(e.k, t);
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
function runHeap(e, t) {
|
|
119
|
-
e.
|
|
119
|
+
e.O = false;
|
|
120
120
|
for (e.j = 0; e.j <= e.S; e.j++) {
|
|
121
121
|
let n = e.l[e.j];
|
|
122
122
|
while (n !== undefined) {
|
|
@@ -137,18 +137,18 @@ function adjustHeight(e, t) {
|
|
|
137
137
|
}
|
|
138
138
|
if (e.o !== n) {
|
|
139
139
|
e.o = n;
|
|
140
|
-
for (let n = e.
|
|
140
|
+
for (let n = e._; n !== null; n = n.P) {
|
|
141
141
|
insertIntoHeapHeight(n.k, t);
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
const x = new Set();
|
|
146
|
-
const P = { l: new Array(2e3).fill(undefined),
|
|
147
|
-
const v = { l: new Array(2e3).fill(undefined),
|
|
146
|
+
const P = { l: new Array(2e3).fill(undefined), O: false, j: 0, S: 0 };
|
|
147
|
+
const v = { l: new Array(2e3).fill(undefined), O: false, j: 0, S: 0 };
|
|
148
148
|
let E = 0;
|
|
149
149
|
let k = null;
|
|
150
|
-
let C = false;
|
|
151
150
|
let W = false;
|
|
151
|
+
let C = false;
|
|
152
152
|
let j = null;
|
|
153
153
|
function enforceLoadingBoundary(e) {}
|
|
154
154
|
function shouldReadStashedOptimisticValue(e) {
|
|
@@ -165,7 +165,7 @@ function runLaneEffects(e) {
|
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
function queueStashedOptimisticEffects(e) {
|
|
168
|
-
for (let t = e.
|
|
168
|
+
for (let t = e._; t !== null; t = t.P) {
|
|
169
169
|
const e = t.k;
|
|
170
170
|
if (!e.D) continue;
|
|
171
171
|
if (e.D === y) {
|
|
@@ -181,7 +181,7 @@ function queueStashedOptimisticEffects(e) {
|
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
function setProjectionWriteActive(e) {
|
|
184
|
-
|
|
184
|
+
C = e;
|
|
185
185
|
}
|
|
186
186
|
function mergeTransitionState(e, t) {
|
|
187
187
|
t.B = e;
|
|
@@ -227,9 +227,9 @@ function cleanupCompletedLanes(e) {
|
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
229
|
function schedule() {
|
|
230
|
-
if (
|
|
231
|
-
|
|
232
|
-
if (!A.ne && !
|
|
230
|
+
if (W) return;
|
|
231
|
+
W = true;
|
|
232
|
+
if (!A.ne && !C) queueMicrotask(flush);
|
|
233
233
|
}
|
|
234
234
|
class Queue {
|
|
235
235
|
i = null;
|
|
@@ -319,7 +319,7 @@ class GlobalQueue extends Queue {
|
|
|
319
319
|
runLaneEffects(g);
|
|
320
320
|
this.stashQueues(e.ce);
|
|
321
321
|
E++;
|
|
322
|
-
|
|
322
|
+
W = P.S >= P.j;
|
|
323
323
|
reassignPendingTransition(e.se);
|
|
324
324
|
k = null;
|
|
325
325
|
if (!e.G.length && e.U.length) {
|
|
@@ -350,7 +350,7 @@ class GlobalQueue extends Queue {
|
|
|
350
350
|
finalizePureQueue();
|
|
351
351
|
}
|
|
352
352
|
E++;
|
|
353
|
-
|
|
353
|
+
W = P.S >= P.j;
|
|
354
354
|
runLaneEffects(h);
|
|
355
355
|
this.run(h);
|
|
356
356
|
runLaneEffects(g);
|
|
@@ -426,7 +426,7 @@ class GlobalQueue extends Queue {
|
|
|
426
426
|
function insertSubs(e, t = false) {
|
|
427
427
|
const n = e.Y || M;
|
|
428
428
|
const r = e.pe !== undefined;
|
|
429
|
-
for (let i = e.
|
|
429
|
+
for (let i = e._; i !== null; i = i.P) {
|
|
430
430
|
if (r && i.k.he) {
|
|
431
431
|
i.k.m |= c;
|
|
432
432
|
continue;
|
|
@@ -504,7 +504,7 @@ function flush() {
|
|
|
504
504
|
if (A.ne) {
|
|
505
505
|
return;
|
|
506
506
|
}
|
|
507
|
-
while (
|
|
507
|
+
while (W || k) {
|
|
508
508
|
A.flush();
|
|
509
509
|
}
|
|
510
510
|
}
|
|
@@ -629,10 +629,10 @@ function unlinkSubs(e) {
|
|
|
629
629
|
else t.be = i;
|
|
630
630
|
if (i !== null) i.P = r;
|
|
631
631
|
else {
|
|
632
|
-
t.
|
|
632
|
+
t._ = r;
|
|
633
633
|
if (r === null) {
|
|
634
|
-
t.
|
|
635
|
-
t.R && !t.
|
|
634
|
+
t.Oe?.();
|
|
635
|
+
t.R && !t._e && !(t.m & o) && unobserved(t);
|
|
636
636
|
}
|
|
637
637
|
}
|
|
638
638
|
return n;
|
|
@@ -664,7 +664,7 @@ function link(e, t) {
|
|
|
664
664
|
if (n !== null) n.N = u;
|
|
665
665
|
else t.A = u;
|
|
666
666
|
if (o !== null) o.P = u;
|
|
667
|
-
else e.
|
|
667
|
+
else e._ = u;
|
|
668
668
|
}
|
|
669
669
|
function isValidLink(e, t) {
|
|
670
670
|
const n = t.xe;
|
|
@@ -724,12 +724,12 @@ function disposeChildren(e, t = false, n) {
|
|
|
724
724
|
e.ke = null;
|
|
725
725
|
} else {
|
|
726
726
|
e.Pe = null;
|
|
727
|
-
e.
|
|
727
|
+
e.We = 0;
|
|
728
728
|
}
|
|
729
729
|
runDisposal(e, n);
|
|
730
730
|
}
|
|
731
731
|
function runDisposal(e, t) {
|
|
732
|
-
let n = t ? e.
|
|
732
|
+
let n = t ? e.Ce : e.je;
|
|
733
733
|
if (!n) return;
|
|
734
734
|
if (Array.isArray(n)) {
|
|
735
735
|
for (let e = 0; e < n.length; e++) {
|
|
@@ -739,12 +739,12 @@ function runDisposal(e, t) {
|
|
|
739
739
|
} else {
|
|
740
740
|
n.call(n);
|
|
741
741
|
}
|
|
742
|
-
t ? (e.
|
|
742
|
+
t ? (e.Ce = null) : (e.je = null);
|
|
743
743
|
}
|
|
744
744
|
function childId(e, t) {
|
|
745
745
|
let n = e;
|
|
746
746
|
while (n.Ae && n.i) n = n.i;
|
|
747
|
-
if (n.id != null) return formatId(n.id, t ? n.
|
|
747
|
+
if (n.id != null) return formatId(n.id, t ? n.We++ : n.We);
|
|
748
748
|
throw new Error("Cannot get child id from owner without an id");
|
|
749
749
|
}
|
|
750
750
|
function getNextChildId(e) {
|
|
@@ -787,9 +787,9 @@ function createOwner(e) {
|
|
|
787
787
|
ve: null,
|
|
788
788
|
je: null,
|
|
789
789
|
V: t?.V ?? A,
|
|
790
|
-
Ne: t?.Ne ||
|
|
791
|
-
|
|
792
|
-
|
|
790
|
+
Ne: t?.Ne || O,
|
|
791
|
+
We: 0,
|
|
792
|
+
Ce: null,
|
|
793
793
|
ke: null,
|
|
794
794
|
i: t,
|
|
795
795
|
dispose(e = true) {
|
|
@@ -860,9 +860,9 @@ function setPendingError(e, t, n) {
|
|
|
860
860
|
}
|
|
861
861
|
}
|
|
862
862
|
function forEachDependent(e, t) {
|
|
863
|
-
for (let n = e.
|
|
864
|
-
for (let n = e.
|
|
865
|
-
for (let e = n.
|
|
863
|
+
for (let n = e._; n !== null; n = n.P) t(n.k);
|
|
864
|
+
for (let n = e.W; n !== null; n = n.C) {
|
|
865
|
+
for (let e = n._; e !== null; e = e.P) t(e.k);
|
|
866
866
|
}
|
|
867
867
|
}
|
|
868
868
|
function settlePendingSource(e) {
|
|
@@ -1175,11 +1175,11 @@ function recompute(t, n = false) {
|
|
|
1175
1175
|
if (t.K || i === y) disposeChildren(t);
|
|
1176
1176
|
else {
|
|
1177
1177
|
markDisposal(t);
|
|
1178
|
-
t.
|
|
1178
|
+
t.Ce = t.je;
|
|
1179
1179
|
t.ke = t.Pe;
|
|
1180
1180
|
t.je = null;
|
|
1181
1181
|
t.Pe = null;
|
|
1182
|
-
t.
|
|
1182
|
+
t.We = 0;
|
|
1183
1183
|
}
|
|
1184
1184
|
}
|
|
1185
1185
|
const s = !!(t.m & f);
|
|
@@ -1255,7 +1255,7 @@ function recompute(t, n = false) {
|
|
|
1255
1255
|
} else if (u) {
|
|
1256
1256
|
t.Z = h;
|
|
1257
1257
|
} else if (t.o != g) {
|
|
1258
|
-
for (let e = t.
|
|
1258
|
+
for (let e = t._; e !== null; e = e.P) {
|
|
1259
1259
|
insertIntoHeapHeight(e.k, e.k.m & o ? v : P);
|
|
1260
1260
|
}
|
|
1261
1261
|
}
|
|
@@ -1264,23 +1264,23 @@ function recompute(t, n = false) {
|
|
|
1264
1264
|
(!n || t.ge & a) && !t.K && !(k && u) && A.se.push(t);
|
|
1265
1265
|
t.K && i && k !== t.K && runInTransition(t.K, () => recompute(t));
|
|
1266
1266
|
}
|
|
1267
|
-
function updateIfNecessary(
|
|
1268
|
-
if (
|
|
1269
|
-
for (let
|
|
1270
|
-
const
|
|
1271
|
-
const i =
|
|
1267
|
+
function updateIfNecessary(e) {
|
|
1268
|
+
if (e.m & t) {
|
|
1269
|
+
for (let t = e.A; t; t = t.N) {
|
|
1270
|
+
const r = t.L;
|
|
1271
|
+
const i = r.I || r;
|
|
1272
1272
|
if (i.R) {
|
|
1273
1273
|
updateIfNecessary(i);
|
|
1274
1274
|
}
|
|
1275
|
-
if (
|
|
1275
|
+
if (e.m & n) {
|
|
1276
1276
|
break;
|
|
1277
1277
|
}
|
|
1278
1278
|
}
|
|
1279
1279
|
}
|
|
1280
|
-
if (
|
|
1281
|
-
recompute(
|
|
1280
|
+
if (e.m & (n | f) || (e.ae && e.de < E && !e.Ee)) {
|
|
1281
|
+
recompute(e);
|
|
1282
1282
|
}
|
|
1283
|
-
|
|
1283
|
+
e.m = e.m & (c | i | s);
|
|
1284
1284
|
}
|
|
1285
1285
|
function computed(t, n, r) {
|
|
1286
1286
|
const i = r?.transparent ?? false;
|
|
@@ -1289,20 +1289,20 @@ function computed(t, n, r) {
|
|
|
1289
1289
|
Ae: i || undefined,
|
|
1290
1290
|
Te: r?.equals != null ? r.equals : isEqual,
|
|
1291
1291
|
le: !!r?.pureWrite,
|
|
1292
|
-
|
|
1292
|
+
Oe: r?.unobserved,
|
|
1293
1293
|
je: null,
|
|
1294
1294
|
V: V?.V ?? A,
|
|
1295
|
-
Ne: V?.Ne ??
|
|
1296
|
-
|
|
1295
|
+
Ne: V?.Ne ?? O,
|
|
1296
|
+
We: 0,
|
|
1297
1297
|
R: t,
|
|
1298
1298
|
$: n,
|
|
1299
1299
|
o: 0,
|
|
1300
|
-
|
|
1300
|
+
W: null,
|
|
1301
1301
|
h: undefined,
|
|
1302
1302
|
p: null,
|
|
1303
1303
|
A: null,
|
|
1304
1304
|
xe: null,
|
|
1305
|
-
|
|
1305
|
+
_: null,
|
|
1306
1306
|
be: null,
|
|
1307
1307
|
i: V,
|
|
1308
1308
|
ve: null,
|
|
@@ -1311,7 +1311,7 @@ function computed(t, n, r) {
|
|
|
1311
1311
|
ge: p,
|
|
1312
1312
|
de: E,
|
|
1313
1313
|
Z: S,
|
|
1314
|
-
|
|
1314
|
+
Ce: null,
|
|
1315
1315
|
ke: null,
|
|
1316
1316
|
Ee: null,
|
|
1317
1317
|
K: null
|
|
@@ -1354,16 +1354,16 @@ function signal(e, t, n = null) {
|
|
|
1354
1354
|
Te: t?.equals != null ? t.equals : isEqual,
|
|
1355
1355
|
le: !!t?.pureWrite,
|
|
1356
1356
|
De: !!t?.De,
|
|
1357
|
-
|
|
1357
|
+
Oe: t?.unobserved,
|
|
1358
1358
|
$: e,
|
|
1359
|
-
|
|
1359
|
+
_: null,
|
|
1360
1360
|
be: null,
|
|
1361
1361
|
de: E,
|
|
1362
1362
|
I: n,
|
|
1363
|
-
|
|
1363
|
+
C: n?.W || null,
|
|
1364
1364
|
Z: S
|
|
1365
1365
|
};
|
|
1366
|
-
n && (n.
|
|
1366
|
+
n && (n.W = r);
|
|
1367
1367
|
if (B && !r.De && !((n?.ge ?? 0) & a)) {
|
|
1368
1368
|
r.pe = e === undefined ? w : e;
|
|
1369
1369
|
G.add(r);
|
|
@@ -1485,7 +1485,7 @@ function read(e) {
|
|
|
1485
1485
|
}
|
|
1486
1486
|
if (e.R && e.ge & d) {
|
|
1487
1487
|
if (e.de < E) {
|
|
1488
|
-
recompute(e
|
|
1488
|
+
recompute(e);
|
|
1489
1489
|
return read(e);
|
|
1490
1490
|
} else throw e.ae;
|
|
1491
1491
|
}
|
|
@@ -1511,7 +1511,7 @@ function read(e) {
|
|
|
1511
1511
|
}
|
|
1512
1512
|
function setSignal(e, t) {
|
|
1513
1513
|
if (e.K && k !== e.K) A.initTransition(e.K);
|
|
1514
|
-
const n = e.ee !== undefined && !
|
|
1514
|
+
const n = e.ee !== undefined && !C;
|
|
1515
1515
|
const r = e.ee !== undefined && e.ee !== S;
|
|
1516
1516
|
const i = n ? (r ? e.ee : e.$) : e.Z === S ? e.$ : e.Z;
|
|
1517
1517
|
if (typeof t === "function") t = t(i);
|
|
@@ -1661,7 +1661,7 @@ function refresh(e) {
|
|
|
1661
1661
|
Q = true;
|
|
1662
1662
|
try {
|
|
1663
1663
|
if (typeof e !== "function") {
|
|
1664
|
-
recompute(e[
|
|
1664
|
+
recompute(e[_]);
|
|
1665
1665
|
return e;
|
|
1666
1666
|
}
|
|
1667
1667
|
return untrack(e);
|
|
@@ -2091,7 +2091,7 @@ function createProjectionInternal(e, t = {}, n) {
|
|
|
2091
2091
|
u !== o && u !== undefined && reconcile(u, n?.key || "id")(s);
|
|
2092
2092
|
});
|
|
2093
2093
|
});
|
|
2094
|
-
r.
|
|
2094
|
+
r._e = true;
|
|
2095
2095
|
return { store: s, node: r };
|
|
2096
2096
|
}
|
|
2097
2097
|
function createProjection(e, t = {}, n) {
|
|
@@ -2111,6 +2111,18 @@ function createWriteTraps(e) {
|
|
|
2111
2111
|
}
|
|
2112
2112
|
return typeof r === "object" && r !== null ? new Proxy(r, t) : r;
|
|
2113
2113
|
},
|
|
2114
|
+
has(e, t) {
|
|
2115
|
+
let n;
|
|
2116
|
+
setWriteOverride(true);
|
|
2117
|
+
setProjectionWriteActive(true);
|
|
2118
|
+
try {
|
|
2119
|
+
n = t in e;
|
|
2120
|
+
} finally {
|
|
2121
|
+
setWriteOverride(false);
|
|
2122
|
+
setProjectionWriteActive(false);
|
|
2123
|
+
}
|
|
2124
|
+
return n;
|
|
2125
|
+
},
|
|
2114
2126
|
set(t, n, r) {
|
|
2115
2127
|
if (e && !e()) return true;
|
|
2116
2128
|
setWriteOverride(true);
|
|
@@ -2168,7 +2180,12 @@ function wrap(e, t) {
|
|
|
2168
2180
|
return n;
|
|
2169
2181
|
}
|
|
2170
2182
|
function isWrappable(e) {
|
|
2171
|
-
return
|
|
2183
|
+
return (
|
|
2184
|
+
e != null &&
|
|
2185
|
+
typeof e === "object" &&
|
|
2186
|
+
!Object.isFrozen(e) &&
|
|
2187
|
+
!(typeof Node !== "undefined" && e instanceof Node)
|
|
2188
|
+
);
|
|
2172
2189
|
}
|
|
2173
2190
|
let oe = false;
|
|
2174
2191
|
function setWriteOverride(e) {
|
|
@@ -2231,7 +2248,7 @@ const fe = {
|
|
|
2231
2248
|
get(e, t, n) {
|
|
2232
2249
|
if (t === z) return e;
|
|
2233
2250
|
if (t === U) return n;
|
|
2234
|
-
if (t ===
|
|
2251
|
+
if (t === _) return e[re];
|
|
2235
2252
|
if (t === K) {
|
|
2236
2253
|
trackSelf(e);
|
|
2237
2254
|
return n;
|
|
@@ -2272,7 +2289,9 @@ const fe = {
|
|
|
2272
2289
|
has(e, t) {
|
|
2273
2290
|
if (t === U || t === K || t === "__proto__") return true;
|
|
2274
2291
|
const n = e[Z] && t in e[Z] ? e[Z][t] !== J : e[Y] && t in e[Y] ? e[Y][t] !== J : t in e[X];
|
|
2275
|
-
|
|
2292
|
+
if (!writeOnly(e[U])) {
|
|
2293
|
+
getObserver() && read(getNode(getNodes(e, ee), t, n, e[re], isEqual, e[ie]));
|
|
2294
|
+
}
|
|
2276
2295
|
return n;
|
|
2277
2296
|
},
|
|
2278
2297
|
set(e, t, n) {
|
|
@@ -2296,28 +2315,37 @@ const fe = {
|
|
|
2296
2315
|
e[m][t] = s;
|
|
2297
2316
|
}
|
|
2298
2317
|
}
|
|
2299
|
-
const o = e[ie] && !
|
|
2318
|
+
const o = e[ie] && !C;
|
|
2300
2319
|
const u = o ? Z : Y;
|
|
2301
2320
|
if (o) trackOptimisticStore(r);
|
|
2302
2321
|
const f = e[Z] && t in e[Z] ? e[Z][t] : e[Y] && t in e[Y] ? e[Y][t] : s;
|
|
2303
2322
|
const c = n?.[z]?.[X] ?? n;
|
|
2304
|
-
|
|
2305
|
-
const
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2323
|
+
const l = Array.isArray(i) && t !== "length";
|
|
2324
|
+
const d = l ? parseInt(t) + 1 : 0;
|
|
2325
|
+
const p =
|
|
2326
|
+
l &&
|
|
2327
|
+
(e[Z] && "length" in e[Z]
|
|
2328
|
+
? e[Z].length
|
|
2329
|
+
: e[Y] && "length" in e[Y]
|
|
2330
|
+
? e[Y].length
|
|
2331
|
+
: i.length);
|
|
2332
|
+
const h = l && d > p ? d : undefined;
|
|
2333
|
+
if (f === c && h === undefined) return true;
|
|
2334
|
+
if (c !== undefined && c === s && h === undefined) delete e[u]?.[t];
|
|
2335
|
+
else {
|
|
2336
|
+
const n = e[u] || (e[u] = Object.create(null));
|
|
2337
|
+
n[t] = c;
|
|
2338
|
+
if (h !== undefined) n.length = h;
|
|
2339
|
+
}
|
|
2340
|
+
const g = isWrappable(c);
|
|
2309
2341
|
e[ee]?.[t] && setSignal(e[ee][t], true);
|
|
2310
|
-
const
|
|
2311
|
-
|
|
2342
|
+
const y = getNodes(e, $);
|
|
2343
|
+
y[t] && setSignal(y[t], () => (g ? wrap(c, e) : c));
|
|
2312
2344
|
if (Array.isArray(i)) {
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
} else {
|
|
2316
|
-
const e = parseInt(t) + 1;
|
|
2317
|
-
if (e > l) p.length && setSignal(p.length, e);
|
|
2318
|
-
}
|
|
2345
|
+
const e = t === "length" ? c : h;
|
|
2346
|
+
e !== undefined && y.length && setSignal(y.length, e);
|
|
2319
2347
|
}
|
|
2320
|
-
|
|
2348
|
+
y[K] && setSignal(y[K], undefined);
|
|
2321
2349
|
});
|
|
2322
2350
|
}
|
|
2323
2351
|
return true;
|
|
@@ -2327,7 +2355,7 @@ const fe = {
|
|
|
2327
2355
|
const r = e[Y]?.[t] === J;
|
|
2328
2356
|
if (writeOnly(e[U]) && !n && !r) {
|
|
2329
2357
|
untrack(() => {
|
|
2330
|
-
const n = e[ie] && !
|
|
2358
|
+
const n = e[ie] && !C;
|
|
2331
2359
|
const r = n ? Z : Y;
|
|
2332
2360
|
if (n) trackOptimisticStore(e[U]);
|
|
2333
2361
|
const i = e[Z] && t in e[Z] ? e[Z][t] : e[Y] && t in e[Y] ? e[Y][t] : e[X][t];
|
|
@@ -2485,7 +2513,7 @@ function createOptimisticProjectionInternal(e, t = {}, n) {
|
|
|
2485
2513
|
setProjectionWriteActive(false);
|
|
2486
2514
|
}
|
|
2487
2515
|
});
|
|
2488
|
-
r.
|
|
2516
|
+
r._e = true;
|
|
2489
2517
|
}
|
|
2490
2518
|
return { store: s, node: r };
|
|
2491
2519
|
}
|
|
@@ -2946,7 +2974,7 @@ function boundaryComputed(e, t) {
|
|
|
2946
2974
|
n.V.notify(n, n.ut, r, i);
|
|
2947
2975
|
};
|
|
2948
2976
|
n.ut = t;
|
|
2949
|
-
n.
|
|
2977
|
+
n._e = true;
|
|
2950
2978
|
recompute(n, true);
|
|
2951
2979
|
return n;
|
|
2952
2980
|
}
|
|
@@ -3008,7 +3036,7 @@ class CollectionQueue extends Queue {
|
|
|
3008
3036
|
}
|
|
3009
3037
|
checkSources() {
|
|
3010
3038
|
for (const e of this.ct) {
|
|
3011
|
-
if (!(e.ge & this.ft) && !(this.ft & d && e.ge & a)) this.ct.delete(e);
|
|
3039
|
+
if (e.m & u || (!(e.ge & this.ft) && !(this.ft & d && e.ge & a))) this.ct.delete(e);
|
|
3012
3040
|
}
|
|
3013
3041
|
if (!this.ct.size) {
|
|
3014
3042
|
setSignal(this.lt, false);
|
|
@@ -3100,7 +3128,7 @@ function flattenArray(e, t = [], n) {
|
|
|
3100
3128
|
return i;
|
|
3101
3129
|
}
|
|
3102
3130
|
exports.$PROXY = U;
|
|
3103
|
-
exports.$REFRESH =
|
|
3131
|
+
exports.$REFRESH = _;
|
|
3104
3132
|
exports.$TARGET = z;
|
|
3105
3133
|
exports.$TRACK = K;
|
|
3106
3134
|
exports.ContextNotFoundError = ContextNotFoundError;
|
package/dist/prod.js
CHANGED
|
@@ -679,7 +679,7 @@ function isValidLink(e, t) {
|
|
|
679
679
|
}
|
|
680
680
|
const PENDING_OWNER = {};
|
|
681
681
|
function markDisposal(e) {
|
|
682
|
-
let t = e.
|
|
682
|
+
let t = e.Pe;
|
|
683
683
|
while (t) {
|
|
684
684
|
t.O |= REACTIVE_ZOMBIE;
|
|
685
685
|
if (t.O & REACTIVE_IN_HEAP) {
|
|
@@ -687,7 +687,7 @@ function markDisposal(e) {
|
|
|
687
687
|
insertIntoHeap(t, zombieQueue);
|
|
688
688
|
}
|
|
689
689
|
markDisposal(t);
|
|
690
|
-
t = t.
|
|
690
|
+
t = t.ge;
|
|
691
691
|
}
|
|
692
692
|
}
|
|
693
693
|
function dispose(e) {
|
|
@@ -703,9 +703,9 @@ function disposeChildren(e, t = false, n) {
|
|
|
703
703
|
if (e.O & REACTIVE_DISPOSED) return;
|
|
704
704
|
if (t) e.O = REACTIVE_DISPOSED;
|
|
705
705
|
if (t && e.L) e.Ce = null;
|
|
706
|
-
let i = n ? e.De : e.
|
|
706
|
+
let i = n ? e.De : e.Pe;
|
|
707
707
|
while (i) {
|
|
708
|
-
const e = i.
|
|
708
|
+
const e = i.ge;
|
|
709
709
|
if (i.C) {
|
|
710
710
|
const e = i;
|
|
711
711
|
deleteFromHeap(e, e.O & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
@@ -722,13 +722,13 @@ function disposeChildren(e, t = false, n) {
|
|
|
722
722
|
if (n) {
|
|
723
723
|
e.De = null;
|
|
724
724
|
} else {
|
|
725
|
-
e.
|
|
725
|
+
e.Pe = null;
|
|
726
726
|
e.ye = 0;
|
|
727
727
|
}
|
|
728
728
|
runDisposal(e, n);
|
|
729
729
|
}
|
|
730
730
|
function runDisposal(e, t) {
|
|
731
|
-
let n = t ? e.
|
|
731
|
+
let n = t ? e.ve : e.me;
|
|
732
732
|
if (!n) return;
|
|
733
733
|
if (Array.isArray(n)) {
|
|
734
734
|
for (let e = 0; e < n.length; e++) {
|
|
@@ -738,11 +738,11 @@ function runDisposal(e, t) {
|
|
|
738
738
|
} else {
|
|
739
739
|
n.call(n);
|
|
740
740
|
}
|
|
741
|
-
t ? (e.
|
|
741
|
+
t ? (e.ve = null) : (e.me = null);
|
|
742
742
|
}
|
|
743
743
|
function childId(e, t) {
|
|
744
744
|
let n = e;
|
|
745
|
-
while (n.
|
|
745
|
+
while (n.Ve && n.i) n = n.i;
|
|
746
746
|
if (n.id != null) return formatId(n.id, t ? n.ye++ : n.ye);
|
|
747
747
|
throw new Error("Cannot get child id from owner without an id");
|
|
748
748
|
}
|
|
@@ -766,9 +766,9 @@ function getOwner() {
|
|
|
766
766
|
}
|
|
767
767
|
function cleanup(e) {
|
|
768
768
|
if (!context) return e;
|
|
769
|
-
if (!context.
|
|
770
|
-
else if (Array.isArray(context.
|
|
771
|
-
else context.
|
|
769
|
+
if (!context.me) context.me = e;
|
|
770
|
+
else if (Array.isArray(context.me)) context.me.push(e);
|
|
771
|
+
else context.me = [context.me, e];
|
|
772
772
|
return e;
|
|
773
773
|
}
|
|
774
774
|
function isDisposed(e) {
|
|
@@ -779,16 +779,16 @@ function createOwner(e) {
|
|
|
779
779
|
const n = e?.transparent ?? false;
|
|
780
780
|
const i = {
|
|
781
781
|
id: e?.id ?? (n ? t?.id : t?.id != null ? getNextChildId(t) : undefined),
|
|
782
|
-
|
|
782
|
+
Ve: n || undefined,
|
|
783
783
|
t: true,
|
|
784
784
|
u: t?.t ? t.u : t,
|
|
785
|
-
ge: null,
|
|
786
785
|
Pe: null,
|
|
787
|
-
|
|
786
|
+
ge: null,
|
|
787
|
+
me: null,
|
|
788
788
|
F: t?.F ?? globalQueue,
|
|
789
|
-
|
|
789
|
+
we: t?.we || defaultContext,
|
|
790
790
|
ye: 0,
|
|
791
|
-
|
|
791
|
+
ve: null,
|
|
792
792
|
De: null,
|
|
793
793
|
i: t,
|
|
794
794
|
dispose(e = true) {
|
|
@@ -796,12 +796,12 @@ function createOwner(e) {
|
|
|
796
796
|
}
|
|
797
797
|
};
|
|
798
798
|
if (t) {
|
|
799
|
-
const e = t.
|
|
799
|
+
const e = t.Pe;
|
|
800
800
|
if (e === null) {
|
|
801
|
-
t.
|
|
801
|
+
t.Pe = i;
|
|
802
802
|
} else {
|
|
803
|
-
i.
|
|
804
|
-
t.
|
|
803
|
+
i.ge = e;
|
|
804
|
+
t.Pe = i;
|
|
805
805
|
}
|
|
806
806
|
}
|
|
807
807
|
return i;
|
|
@@ -811,28 +811,28 @@ function createRoot(e, t) {
|
|
|
811
811
|
return runWithOwner(n, () => e(n.dispose));
|
|
812
812
|
}
|
|
813
813
|
function addPendingSource(e, t) {
|
|
814
|
-
if (e.
|
|
815
|
-
if (!e.
|
|
816
|
-
e.
|
|
814
|
+
if (e.be === t || e.Le?.has(t)) return false;
|
|
815
|
+
if (!e.be) {
|
|
816
|
+
e.be = t;
|
|
817
817
|
return true;
|
|
818
818
|
}
|
|
819
819
|
if (!e.Le) {
|
|
820
|
-
e.Le = new Set([e.
|
|
820
|
+
e.Le = new Set([e.be, t]);
|
|
821
821
|
} else {
|
|
822
822
|
e.Le.add(t);
|
|
823
823
|
}
|
|
824
|
-
e.
|
|
824
|
+
e.be = undefined;
|
|
825
825
|
return true;
|
|
826
826
|
}
|
|
827
827
|
function removePendingSource(e, t) {
|
|
828
|
-
if (e.
|
|
829
|
-
if (e.
|
|
830
|
-
e.
|
|
828
|
+
if (e.be) {
|
|
829
|
+
if (e.be !== t) return false;
|
|
830
|
+
e.be = undefined;
|
|
831
831
|
return true;
|
|
832
832
|
}
|
|
833
833
|
if (!e.Le?.delete(t)) return false;
|
|
834
834
|
if (e.Le.size === 1) {
|
|
835
|
-
e.
|
|
835
|
+
e.be = e.Le.values().next().value;
|
|
836
836
|
e.Le = undefined;
|
|
837
837
|
} else if (e.Le.size === 0) {
|
|
838
838
|
e.Le = undefined;
|
|
@@ -840,7 +840,7 @@ function removePendingSource(e, t) {
|
|
|
840
840
|
return true;
|
|
841
841
|
}
|
|
842
842
|
function clearPendingSources(e) {
|
|
843
|
-
e.
|
|
843
|
+
e.be = undefined;
|
|
844
844
|
e.Le?.clear();
|
|
845
845
|
e.Le = undefined;
|
|
846
846
|
}
|
|
@@ -871,7 +871,7 @@ function settlePendingSource(e) {
|
|
|
871
871
|
if (n.has(i) || !removePendingSource(i, e)) return;
|
|
872
872
|
n.add(i);
|
|
873
873
|
i.Ee = clock;
|
|
874
|
-
const r = i.
|
|
874
|
+
const r = i.be ?? i.Le?.values().next().value;
|
|
875
875
|
if (r) {
|
|
876
876
|
setPendingError(i, r);
|
|
877
877
|
updatePendingSignal(i);
|
|
@@ -1072,8 +1072,8 @@ function notifyStatus(e, t, n, i, r) {
|
|
|
1072
1072
|
forEachDependent(e, e => {
|
|
1073
1073
|
e.Ee = clock;
|
|
1074
1074
|
if (
|
|
1075
|
-
(t === STATUS_PENDING && s && e.
|
|
1076
|
-
(t !== STATUS_PENDING && (e.le !== n || e.
|
|
1075
|
+
(t === STATUS_PENDING && s && e.be !== s && !e.Le?.has(s)) ||
|
|
1076
|
+
(t !== STATUS_PENDING && (e.le !== n || e.be || e.Le))
|
|
1077
1077
|
) {
|
|
1078
1078
|
if (!a && !e.K) globalQueue.se.push(e);
|
|
1079
1079
|
notifyStatus(e, t, n, a, f);
|
|
@@ -1135,10 +1135,10 @@ function releaseSnapshotScope(e) {
|
|
|
1135
1135
|
schedule();
|
|
1136
1136
|
}
|
|
1137
1137
|
function releaseSubtree(e) {
|
|
1138
|
-
let t = e.
|
|
1138
|
+
let t = e.Pe;
|
|
1139
1139
|
while (t) {
|
|
1140
1140
|
if (t.We) {
|
|
1141
|
-
t = t.
|
|
1141
|
+
t = t.ge;
|
|
1142
1142
|
continue;
|
|
1143
1143
|
}
|
|
1144
1144
|
if (t.L) {
|
|
@@ -1152,7 +1152,7 @@ function releaseSubtree(e) {
|
|
|
1152
1152
|
}
|
|
1153
1153
|
}
|
|
1154
1154
|
releaseSubtree(t);
|
|
1155
|
-
t = t.
|
|
1155
|
+
t = t.ge;
|
|
1156
1156
|
}
|
|
1157
1157
|
}
|
|
1158
1158
|
function clearSnapshots() {
|
|
@@ -1175,10 +1175,10 @@ function recompute(e, t = false) {
|
|
|
1175
1175
|
if (e.K || n === EFFECT_TRACKED) disposeChildren(e);
|
|
1176
1176
|
else {
|
|
1177
1177
|
markDisposal(e);
|
|
1178
|
-
e.
|
|
1179
|
-
e.De = e.
|
|
1180
|
-
e.
|
|
1181
|
-
e.
|
|
1178
|
+
e.ve = e.me;
|
|
1179
|
+
e.De = e.Pe;
|
|
1180
|
+
e.me = null;
|
|
1181
|
+
e.Pe = null;
|
|
1182
1182
|
e.ye = 0;
|
|
1183
1183
|
}
|
|
1184
1184
|
}
|
|
@@ -1280,19 +1280,19 @@ function updateIfNecessary(e) {
|
|
|
1280
1280
|
if (e.O & (REACTIVE_DIRTY | REACTIVE_OPTIMISTIC_DIRTY) || (e.le && e.Ee < clock && !e.Ce)) {
|
|
1281
1281
|
recompute(e);
|
|
1282
1282
|
}
|
|
1283
|
-
e.O =
|
|
1283
|
+
e.O = e.O & (REACTIVE_SNAPSHOT_STALE | REACTIVE_IN_HEAP | REACTIVE_IN_HEAP_HEIGHT);
|
|
1284
1284
|
}
|
|
1285
1285
|
function computed(e, t, n) {
|
|
1286
1286
|
const i = n?.transparent ?? false;
|
|
1287
1287
|
const r = {
|
|
1288
1288
|
id: n?.id ?? (i ? context?.id : context?.id != null ? getNextChildId(context) : undefined),
|
|
1289
|
-
|
|
1289
|
+
Ve: i || undefined,
|
|
1290
1290
|
ke: n?.equals != null ? n.equals : isEqual,
|
|
1291
1291
|
fe: !!n?.pureWrite,
|
|
1292
1292
|
he: n?.unobserved,
|
|
1293
|
-
|
|
1293
|
+
me: null,
|
|
1294
1294
|
F: context?.F ?? globalQueue,
|
|
1295
|
-
|
|
1295
|
+
we: context?.we ?? defaultContext,
|
|
1296
1296
|
ye: 0,
|
|
1297
1297
|
L: e,
|
|
1298
1298
|
J: t,
|
|
@@ -1305,13 +1305,13 @@ function computed(e, t, n) {
|
|
|
1305
1305
|
I: null,
|
|
1306
1306
|
pe: null,
|
|
1307
1307
|
i: context,
|
|
1308
|
-
Pe: null,
|
|
1309
1308
|
ge: null,
|
|
1309
|
+
Pe: null,
|
|
1310
1310
|
O: n?.lazy ? REACTIVE_LAZY : REACTIVE_NONE,
|
|
1311
1311
|
Se: STATUS_UNINITIALIZED,
|
|
1312
1312
|
Ee: clock,
|
|
1313
1313
|
X: NOT_PENDING,
|
|
1314
|
-
|
|
1314
|
+
ve: null,
|
|
1315
1315
|
De: null,
|
|
1316
1316
|
Ce: null,
|
|
1317
1317
|
K: null
|
|
@@ -1319,12 +1319,12 @@ function computed(e, t, n) {
|
|
|
1319
1319
|
r.T = r;
|
|
1320
1320
|
const s = context?.t ? context.u : context;
|
|
1321
1321
|
if (context) {
|
|
1322
|
-
const e = context.
|
|
1322
|
+
const e = context.Pe;
|
|
1323
1323
|
if (e === null) {
|
|
1324
|
-
context.
|
|
1324
|
+
context.Pe = r;
|
|
1325
1325
|
} else {
|
|
1326
|
-
r.
|
|
1327
|
-
context.
|
|
1326
|
+
r.ge = e;
|
|
1327
|
+
context.Pe = r;
|
|
1328
1328
|
}
|
|
1329
1329
|
}
|
|
1330
1330
|
if (s) r.o = s.o + 1;
|
|
@@ -1485,7 +1485,7 @@ function read(e) {
|
|
|
1485
1485
|
}
|
|
1486
1486
|
if (e.L && e.Se & STATUS_ERROR) {
|
|
1487
1487
|
if (e.Ee < clock) {
|
|
1488
|
-
recompute(e
|
|
1488
|
+
recompute(e);
|
|
1489
1489
|
return read(e);
|
|
1490
1490
|
} else throw e.le;
|
|
1491
1491
|
}
|
|
@@ -1683,7 +1683,7 @@ function getContext(e, t = getOwner()) {
|
|
|
1683
1683
|
if (!t) {
|
|
1684
1684
|
throw new NoOwnerError();
|
|
1685
1685
|
}
|
|
1686
|
-
const n = hasContext(e, t) ? t.
|
|
1686
|
+
const n = hasContext(e, t) ? t.we[e.id] : e.defaultValue;
|
|
1687
1687
|
if (isUndefined(n)) {
|
|
1688
1688
|
throw new ContextNotFoundError();
|
|
1689
1689
|
}
|
|
@@ -1693,10 +1693,10 @@ function setContext(e, t, n = getOwner()) {
|
|
|
1693
1693
|
if (!n) {
|
|
1694
1694
|
throw new NoOwnerError();
|
|
1695
1695
|
}
|
|
1696
|
-
n.
|
|
1696
|
+
n.we = { ...n.we, [e.id]: isUndefined(t) ? e.defaultValue : t };
|
|
1697
1697
|
}
|
|
1698
1698
|
function hasContext(e, t) {
|
|
1699
|
-
return !isUndefined(t?.
|
|
1699
|
+
return !isUndefined(t?.we[e.id]);
|
|
1700
1700
|
}
|
|
1701
1701
|
function isUndefined(e) {
|
|
1702
1702
|
return typeof e === "undefined";
|
|
@@ -2114,6 +2114,18 @@ function createWriteTraps(e) {
|
|
|
2114
2114
|
}
|
|
2115
2115
|
return typeof i === "object" && i !== null ? new Proxy(i, t) : i;
|
|
2116
2116
|
},
|
|
2117
|
+
has(e, t) {
|
|
2118
|
+
let n;
|
|
2119
|
+
setWriteOverride(true);
|
|
2120
|
+
setProjectionWriteActive(true);
|
|
2121
|
+
try {
|
|
2122
|
+
n = t in e;
|
|
2123
|
+
} finally {
|
|
2124
|
+
setWriteOverride(false);
|
|
2125
|
+
setProjectionWriteActive(false);
|
|
2126
|
+
}
|
|
2127
|
+
return n;
|
|
2128
|
+
},
|
|
2117
2129
|
set(t, n, i) {
|
|
2118
2130
|
if (e && !e()) return true;
|
|
2119
2131
|
setWriteOverride(true);
|
|
@@ -2171,7 +2183,12 @@ function wrap(e, t) {
|
|
|
2171
2183
|
return n;
|
|
2172
2184
|
}
|
|
2173
2185
|
function isWrappable(e) {
|
|
2174
|
-
return
|
|
2186
|
+
return (
|
|
2187
|
+
e != null &&
|
|
2188
|
+
typeof e === "object" &&
|
|
2189
|
+
!Object.isFrozen(e) &&
|
|
2190
|
+
!(typeof Node !== "undefined" && e instanceof Node)
|
|
2191
|
+
);
|
|
2175
2192
|
}
|
|
2176
2193
|
let writeOverride = false;
|
|
2177
2194
|
function setWriteOverride(e) {
|
|
@@ -2305,8 +2322,12 @@ const storeTraps = {
|
|
|
2305
2322
|
: e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE]
|
|
2306
2323
|
? e[STORE_OVERRIDE][t] !== $DELETED
|
|
2307
2324
|
: t in e[STORE_VALUE];
|
|
2308
|
-
|
|
2309
|
-
|
|
2325
|
+
if (!writeOnly(e[$PROXY])) {
|
|
2326
|
+
getObserver() &&
|
|
2327
|
+
read(
|
|
2328
|
+
getNode(getNodes(e, STORE_HAS), t, n, e[STORE_FIREWALL], isEqual, e[STORE_OPTIMISTIC])
|
|
2329
|
+
);
|
|
2330
|
+
}
|
|
2310
2331
|
return n;
|
|
2311
2332
|
},
|
|
2312
2333
|
set(e, t, n) {
|
|
@@ -2344,23 +2365,32 @@ const storeTraps = {
|
|
|
2344
2365
|
? e[STORE_OVERRIDE][t]
|
|
2345
2366
|
: s;
|
|
2346
2367
|
const a = n?.[$TARGET]?.[STORE_VALUE] ?? n;
|
|
2347
|
-
|
|
2348
|
-
const
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2368
|
+
const f = Array.isArray(r) && t !== "length";
|
|
2369
|
+
const l = f ? parseInt(t) + 1 : 0;
|
|
2370
|
+
const E =
|
|
2371
|
+
f &&
|
|
2372
|
+
(e[STORE_OPTIMISTIC_OVERRIDE] && "length" in e[STORE_OPTIMISTIC_OVERRIDE]
|
|
2373
|
+
? e[STORE_OPTIMISTIC_OVERRIDE].length
|
|
2374
|
+
: e[STORE_OVERRIDE] && "length" in e[STORE_OVERRIDE]
|
|
2375
|
+
? e[STORE_OVERRIDE].length
|
|
2376
|
+
: r.length);
|
|
2377
|
+
const T = f && l > E ? l : undefined;
|
|
2378
|
+
if (c === a && T === undefined) return true;
|
|
2379
|
+
if (a !== undefined && a === s && T === undefined) delete e[u]?.[t];
|
|
2380
|
+
else {
|
|
2381
|
+
const n = e[u] || (e[u] = Object.create(null));
|
|
2382
|
+
n[t] = a;
|
|
2383
|
+
if (T !== undefined) n.length = T;
|
|
2384
|
+
}
|
|
2385
|
+
const d = isWrappable(a);
|
|
2352
2386
|
e[STORE_HAS]?.[t] && setSignal(e[STORE_HAS][t], true);
|
|
2353
|
-
const
|
|
2354
|
-
|
|
2387
|
+
const S = getNodes(e, STORE_NODE);
|
|
2388
|
+
S[t] && setSignal(S[t], () => (d ? wrap(a, e) : a));
|
|
2355
2389
|
if (Array.isArray(r)) {
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
} else {
|
|
2359
|
-
const e = parseInt(t) + 1;
|
|
2360
|
-
if (e > f) E.length && setSignal(E.length, e);
|
|
2361
|
-
}
|
|
2390
|
+
const e = t === "length" ? a : T;
|
|
2391
|
+
e !== undefined && S.length && setSignal(S.length, e);
|
|
2362
2392
|
}
|
|
2363
|
-
|
|
2393
|
+
S[$TRACK] && setSignal(S[$TRACK], undefined);
|
|
2364
2394
|
});
|
|
2365
2395
|
}
|
|
2366
2396
|
return true;
|
|
@@ -3065,7 +3095,10 @@ class CollectionQueue extends Queue {
|
|
|
3065
3095
|
}
|
|
3066
3096
|
checkSources() {
|
|
3067
3097
|
for (const e of this.ft) {
|
|
3068
|
-
if (
|
|
3098
|
+
if (
|
|
3099
|
+
e.O & REACTIVE_DISPOSED ||
|
|
3100
|
+
(!(e.Se & this.ct) && !(this.ct & STATUS_ERROR && e.Se & STATUS_PENDING))
|
|
3101
|
+
)
|
|
3069
3102
|
this.ft.delete(e);
|
|
3070
3103
|
}
|
|
3071
3104
|
if (!this.ft.size) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type Store } from "./store.js";
|
|
2
1
|
/**
|
|
3
2
|
* Returns a non reactive copy of the store object.
|
|
4
3
|
* It will attempt to preserver the original reference unless the value has been modified.
|
|
@@ -12,7 +11,7 @@ export declare function snapshot<T>(item: T, map?: Map<unknown, unknown>, lookup
|
|
|
12
11
|
* and returns plain (non-proxy) data. Works correctly with `reconcile()`.
|
|
13
12
|
* @param store store proxy object
|
|
14
13
|
*/
|
|
15
|
-
export declare function deep<T extends object>(store:
|
|
14
|
+
export declare function deep<T extends object>(store: T): T;
|
|
16
15
|
type DistributeOverride<T, F> = T extends undefined ? F : T;
|
|
17
16
|
type Override<T, U> = T extends any ? U extends any ? {
|
|
18
17
|
[K in keyof T]: K extends keyof U ? DistributeOverride<U[K], T[K]> : T[K];
|