@solidjs/signals 2.0.0-rc.0 → 2.0.0-rc.1
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/dev.js +2622 -2438
- package/dist/node.cjs +3770 -3571
- package/dist/prod/core/async.js +186 -132
- package/dist/prod/core/core.js +118 -107
- package/dist/prod/core/effect.js +13 -13
- package/dist/prod/core/external.js +1 -1
- package/dist/prod/core/graph.js +8 -8
- package/dist/prod/core/heap.js +24 -24
- package/dist/prod/core/lanes.js +3 -3
- package/dist/prod/core/optimistic.js +38 -21
- package/dist/prod/core/owner.js +21 -21
- package/dist/prod/core/scheduler.js +55 -47
- package/dist/prod/core/verdict.js +40 -40
- package/dist/prod/index.js +7 -7
- package/dist/prod/map.js +81 -79
- package/dist/prod/signals.js +20 -1
- package/dist/prod/store/index.js +36 -0
- package/dist/prod/store/next/optimistic.js +377 -0
- package/dist/prod/store/next/projection.js +172 -0
- package/dist/prod/store/next/reconcile.js +327 -0
- package/dist/prod/store/next/store.js +1232 -0
- package/dist/prod/store/next/target.js +20 -0
- package/dist/prod/store/store.js +123 -879
- package/dist/prod/store/utils.js +59 -186
- package/dist/types/core/core.d.ts +8 -0
- package/dist/types/core/dev.d.ts +1 -1
- package/dist/types/core/scheduler.d.ts +4 -2
- package/dist/types/signals.d.ts +19 -0
- package/dist/types/store/index.d.ts +15 -5
- package/dist/types/store/next/optimistic.d.ts +20 -0
- package/dist/types/store/next/projection.d.ts +24 -0
- package/dist/types/store/next/reconcile.d.ts +3 -0
- package/dist/types/store/next/store.d.ts +71 -0
- package/dist/types/store/next/target.d.ts +99 -0
- package/dist/types/store/store.d.ts +26 -101
- package/dist/types/store/utils.d.ts +0 -40
- package/dist/types-cjs/core/core.d.cts +8 -0
- package/dist/types-cjs/core/dev.d.cts +1 -1
- package/dist/types-cjs/core/scheduler.d.cts +4 -2
- package/dist/types-cjs/signals.d.cts +19 -0
- package/dist/types-cjs/store/index.d.cts +15 -5
- package/dist/types-cjs/store/next/optimistic.d.cts +20 -0
- package/dist/types-cjs/store/next/projection.d.cts +24 -0
- package/dist/types-cjs/store/next/reconcile.d.cts +3 -0
- package/dist/types-cjs/store/next/store.d.cts +71 -0
- package/dist/types-cjs/store/next/target.d.cts +99 -0
- package/dist/types-cjs/store/store.d.cts +26 -101
- package/dist/types-cjs/store/utils.d.cts +0 -40
- package/package.json +2 -1
- package/dist/prod/store/optimistic.js +0 -217
- package/dist/prod/store/projection.js +0 -231
- package/dist/prod/store/reconcile.js +0 -707
|
@@ -59,13 +59,9 @@ let projectionWriteActive = false;
|
|
|
59
59
|
// releasing the slot in the parent store's node map.
|
|
60
60
|
const transientStoreNodes = new Set;
|
|
61
61
|
|
|
62
|
-
function registerTransientStoreNode(e) {
|
|
63
|
-
transientStoreNodes.add(e);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
62
|
function canUseSimpleSyncFlush(e) {
|
|
67
63
|
const t = e.m;
|
|
68
|
-
return transitions.size === 0 && activeLanes.size === 0 && e.vt.length === 0 && t.Me.length === 0 && t.A.length === 0 && t.
|
|
64
|
+
return transitions.size === 0 && activeLanes.size === 0 && e.vt.length === 0 && t.Me.length === 0 && t.A.length === 0 && t.dn.size === 0 && transientStoreNodes.size === 0;
|
|
69
65
|
}
|
|
70
66
|
|
|
71
67
|
function sweepTransientStoreNodes() {
|
|
@@ -75,8 +71,8 @@ function sweepTransientStoreNodes() {
|
|
|
75
71
|
transientStoreNodes.delete(e);
|
|
76
72
|
continue;
|
|
77
73
|
}
|
|
78
|
-
if (e.
|
|
79
|
-
if (e.
|
|
74
|
+
if (e._e !== NOT_PENDING) continue;
|
|
75
|
+
if (e.De !== undefined && e.De !== NOT_PENDING) continue;
|
|
80
76
|
// A live affects() mark keeps the node addressable: sweeping it would
|
|
81
77
|
// detach the refcount from the slot (a fresh probe would upsert a new,
|
|
82
78
|
// unmarked node for the same property).
|
|
@@ -114,7 +110,7 @@ function setProjectionWriteActive(e) {
|
|
|
114
110
|
Ie: new Map,
|
|
115
111
|
Me: [],
|
|
116
112
|
A: [],
|
|
117
|
-
|
|
113
|
+
dn: new Set,
|
|
118
114
|
ie: [],
|
|
119
115
|
yt: {
|
|
120
116
|
bt: [ [], [] ],
|
|
@@ -143,7 +139,7 @@ function mergeTransitionState(e, t) {
|
|
|
143
139
|
e.A.push(...t.A);
|
|
144
140
|
t.A.length = 0;
|
|
145
141
|
}
|
|
146
|
-
for (const i of t.
|
|
142
|
+
for (const i of t.dn) e.dn.add(i);
|
|
147
143
|
for (const [i, n] of t.Ie) {
|
|
148
144
|
let t = e.Ie.get(i);
|
|
149
145
|
if (!t) e.Ie.set(i, t = new Set);
|
|
@@ -159,7 +155,7 @@ function schedule() {
|
|
|
159
155
|
}
|
|
160
156
|
if (scheduled) return;
|
|
161
157
|
scheduled = true;
|
|
162
|
-
if (!syncDepth && !globalQueue.
|
|
158
|
+
if (!syncDepth && !globalQueue.cn && !projectionWriteActive) queueMicrotask(flush);
|
|
163
159
|
}
|
|
164
160
|
|
|
165
161
|
/**
|
|
@@ -193,24 +189,24 @@ function notifyHalted() {
|
|
|
193
189
|
let queueRunToken = 0;
|
|
194
190
|
|
|
195
191
|
class Queue {
|
|
196
|
-
|
|
192
|
+
Fe=null;
|
|
197
193
|
bt=[ [], [] ];
|
|
198
194
|
vt=[];
|
|
199
195
|
kt=0;
|
|
200
196
|
created=clock;
|
|
201
197
|
addChild(e) {
|
|
202
198
|
this.vt.push(e);
|
|
203
|
-
e.
|
|
199
|
+
e.Fe = this;
|
|
204
200
|
}
|
|
205
201
|
removeChild(e) {
|
|
206
202
|
const t = this.vt.indexOf(e);
|
|
207
203
|
if (t >= 0) {
|
|
208
204
|
this.vt.splice(t, 1);
|
|
209
|
-
e.
|
|
205
|
+
e.Fe = null;
|
|
210
206
|
}
|
|
211
207
|
}
|
|
212
208
|
notify(e, t, i, n) {
|
|
213
|
-
if (this.
|
|
209
|
+
if (this.Fe) return this.Fe.notify(e, t, i, n);
|
|
214
210
|
return false;
|
|
215
211
|
}
|
|
216
212
|
run(e) {
|
|
@@ -282,14 +278,14 @@ class Queue {
|
|
|
282
278
|
}
|
|
283
279
|
|
|
284
280
|
class GlobalQueue extends Queue {
|
|
285
|
-
|
|
281
|
+
cn=false;
|
|
286
282
|
// The current transaction-shaped batch: a plain ambient batch while no
|
|
287
283
|
// transition is active, the active transition itself after initTransition.
|
|
288
284
|
m=createBatch();
|
|
289
285
|
static Ce;
|
|
290
286
|
static me;
|
|
291
287
|
static et;
|
|
292
|
-
static
|
|
288
|
+
static gt=null;
|
|
293
289
|
// Store-side hook: drops a keyless affects() mark's identity scope when the
|
|
294
290
|
// carrier node's last registration releases (wired by store.ts, mirroring
|
|
295
291
|
// _clearOptimisticStore).
|
|
@@ -303,7 +299,7 @@ class GlobalQueue extends Queue {
|
|
|
303
299
|
static h=null;
|
|
304
300
|
// External-source bridge (wired by enableExternalSource(); null while no
|
|
305
301
|
// config is active — including after _resetExternalSourceConfig()).
|
|
306
|
-
static
|
|
302
|
+
static dt=null;
|
|
307
303
|
static St=null;
|
|
308
304
|
// Verdict-layer hooks (wired by verdict.ts when isPending()/latest() are
|
|
309
305
|
// imported; null in apps that never use them). Call sites either guard for
|
|
@@ -313,12 +309,12 @@ class GlobalQueue extends Queue {
|
|
|
313
309
|
// isPending()/latest()).
|
|
314
310
|
static Pe=null;
|
|
315
311
|
static Se=null;
|
|
316
|
-
static
|
|
312
|
+
static Ge=null;
|
|
317
313
|
static un=null;
|
|
318
314
|
static At=null;
|
|
319
315
|
static Ct=null;
|
|
320
|
-
static
|
|
321
|
-
static
|
|
316
|
+
static Pt=null;
|
|
317
|
+
static $e=null;
|
|
322
318
|
static k=null;
|
|
323
319
|
static Lt=null;
|
|
324
320
|
// Optimistic-engine hooks (wired by core/optimistic.ts via
|
|
@@ -331,18 +327,18 @@ class GlobalQueue extends Queue {
|
|
|
331
327
|
static Gt=null;
|
|
332
328
|
static En=null;
|
|
333
329
|
static Tn=null;
|
|
334
|
-
static dn=null;
|
|
335
330
|
static In=null;
|
|
331
|
+
static Nn=null;
|
|
336
332
|
static Rt=null;
|
|
337
333
|
static Ot=null;
|
|
338
|
-
static
|
|
334
|
+
static Dt=null;
|
|
339
335
|
static je=null;
|
|
340
|
-
static $e=null;
|
|
341
336
|
static ze=null;
|
|
342
|
-
static
|
|
337
|
+
static Be=null;
|
|
338
|
+
static Qn=null;
|
|
343
339
|
flush() {
|
|
344
|
-
if (this.
|
|
345
|
-
this.
|
|
340
|
+
if (this.cn) return;
|
|
341
|
+
this.cn = true;
|
|
346
342
|
try {
|
|
347
343
|
if (false) ;
|
|
348
344
|
runHeap(dirtyQueue, GlobalQueue.Ce);
|
|
@@ -368,8 +364,8 @@ class GlobalQueue extends Queue {
|
|
|
368
364
|
if (this.m === e) currentBatch = this.m = createBatch();
|
|
369
365
|
// Run lane effects immediately (before stashing) - lanes with no pending async
|
|
370
366
|
if (activeLanes.size) {
|
|
371
|
-
GlobalQueue.
|
|
372
|
-
GlobalQueue.
|
|
367
|
+
GlobalQueue.Nn(EFFECT_RENDER);
|
|
368
|
+
GlobalQueue.Nn(EFFECT_USER);
|
|
373
369
|
}
|
|
374
370
|
this.stashQueues(e.yt);
|
|
375
371
|
clock++;
|
|
@@ -398,7 +394,7 @@ class GlobalQueue extends Queue {
|
|
|
398
394
|
e.Qt = i.Qt;
|
|
399
395
|
e.Me = i.Me;
|
|
400
396
|
e.A = i.A;
|
|
401
|
-
e.
|
|
397
|
+
e.dn = i.dn;
|
|
402
398
|
currentBatch = this.m = e;
|
|
403
399
|
}
|
|
404
400
|
} else {
|
|
@@ -417,15 +413,15 @@ class GlobalQueue extends Queue {
|
|
|
417
413
|
// Check if finalization added items to the heap (from optimistic reversion)
|
|
418
414
|
scheduled = dirtyQueue.EE >= dirtyQueue.Ve;
|
|
419
415
|
// Run lane effects first (for ready lanes), then regular effects
|
|
420
|
-
activeLanes.size && GlobalQueue.
|
|
416
|
+
activeLanes.size && GlobalQueue.Nn(EFFECT_RENDER);
|
|
421
417
|
this.run(EFFECT_RENDER);
|
|
422
|
-
activeLanes.size && GlobalQueue.
|
|
418
|
+
activeLanes.size && GlobalQueue.Nn(EFFECT_USER);
|
|
423
419
|
this.run(EFFECT_USER);
|
|
424
420
|
if (false) ;
|
|
425
421
|
if (false && !scheduled && !activeTransition && transitions.size === 0 && activeLanes.size === 0) ;
|
|
426
422
|
if (false) ;
|
|
427
423
|
} finally {
|
|
428
|
-
this.
|
|
424
|
+
this.cn = false;
|
|
429
425
|
}
|
|
430
426
|
}
|
|
431
427
|
notify(e, t, i, n) {
|
|
@@ -485,7 +481,7 @@ class GlobalQueue extends Queue {
|
|
|
485
481
|
activeTransition.Me.push(i);
|
|
486
482
|
}
|
|
487
483
|
if (t.A.length) activeTransition.A.push(...t.A);
|
|
488
|
-
for (const e of t.
|
|
484
|
+
for (const e of t.dn) activeTransition.dn.add(e);
|
|
489
485
|
// Gated readers recorded against the ambient batch move with it: their
|
|
490
486
|
// replay-at-commit now happens at the transaction's completion.
|
|
491
487
|
if (t.ln.size) {
|
|
@@ -517,9 +513,9 @@ function insertSubs(e, t = false) {
|
|
|
517
513
|
// Get source lane: prefer node's own lane over current context
|
|
518
514
|
// This is important for isPending signals which need their own lane to flush immediately
|
|
519
515
|
const i = e.Ke || currentOptimisticLane;
|
|
520
|
-
const n = e.
|
|
516
|
+
const n = e.xe !== undefined;
|
|
521
517
|
const s = reaskArmed;
|
|
522
|
-
for (let r = e.o; r !== null; r = r.
|
|
518
|
+
for (let r = e.o; r !== null; r = r.ue) {
|
|
523
519
|
// A value-change notification is a new question for the subscriber: any
|
|
524
520
|
// pending re-ask mark (refresh) it carried is superseded.
|
|
525
521
|
if (s) r.fe.se &= ~REACTIVE_REASK;
|
|
@@ -542,16 +538,16 @@ function insertSubs(e, t = false) {
|
|
|
542
538
|
function commitPendingNode(e) {
|
|
543
539
|
const t = e;
|
|
544
540
|
if (!t.ce) {
|
|
545
|
-
if (e.
|
|
546
|
-
e.
|
|
547
|
-
e.
|
|
541
|
+
if (e._e !== NOT_PENDING) {
|
|
542
|
+
e.be = e._e;
|
|
543
|
+
e._e = NOT_PENDING;
|
|
548
544
|
}
|
|
549
|
-
if (e.
|
|
545
|
+
if (e.Oe || e.ge) GlobalQueue.un(e);
|
|
550
546
|
return;
|
|
551
547
|
}
|
|
552
|
-
if (e.
|
|
553
|
-
e.
|
|
554
|
-
e.
|
|
548
|
+
if (e._e !== NOT_PENDING) {
|
|
549
|
+
e.be = e._e;
|
|
550
|
+
e._e = NOT_PENDING;
|
|
555
551
|
// Set _modified for effects, but not for tracked effects (they handle their own scheduling)
|
|
556
552
|
if (e.Re && e.Re !== EFFECT_TRACKED) e.Je = true;
|
|
557
553
|
}
|
|
@@ -562,7 +558,18 @@ function commitPendingNode(e) {
|
|
|
562
558
|
t.se &= ~REACTIVE_MANUAL_WRITE;
|
|
563
559
|
if (!(t.S & STATUS_PENDING)) t.S &= ~STATUS_UNINITIALIZED;
|
|
564
560
|
if (t.We !== null || t.Qe !== null) GlobalQueue.me(t, false, true);
|
|
565
|
-
if (e.
|
|
561
|
+
if (e.Oe || e.ge) GlobalQueue.un(e);
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
// Store commit hook (INTERNALS-STORE-STATE.md §3): installed by the store
|
|
565
|
+
// module at init (same treeshakeable pattern as _resolveOptimistic /
|
|
566
|
+
// _clearOptimisticStores). Folds committed store-node values into their
|
|
567
|
+
// backing objects at the same moment pending values commit — the single
|
|
568
|
+
// mutation point of the owned-raw model.
|
|
569
|
+
let storeCommitHook = null;
|
|
570
|
+
|
|
571
|
+
function setStoreCommitHook(e) {
|
|
572
|
+
storeCommitHook = e;
|
|
566
573
|
}
|
|
567
574
|
|
|
568
575
|
function commitPendingNodes() {
|
|
@@ -571,6 +578,7 @@ function commitPendingNodes() {
|
|
|
571
578
|
commitPendingNode(e[t]);
|
|
572
579
|
}
|
|
573
580
|
e.length = 0;
|
|
581
|
+
storeCommitHook?.();
|
|
574
582
|
}
|
|
575
583
|
|
|
576
584
|
function finalizePureQueue(e = null, t = false) {
|
|
@@ -617,10 +625,10 @@ function finalizePureQueue(e = null, t = false) {
|
|
|
617
625
|
// hook; the hook iterates, clears, and schedules (keeping the loop out of
|
|
618
626
|
// core lets esbuild shake it — rollup already folds the null guard). The
|
|
619
627
|
// completing transition scopes the clear to its own layer keys (#2899).
|
|
620
|
-
if (t.
|
|
628
|
+
if (t.dn.size) GlobalQueue.gt(t.dn, e);
|
|
621
629
|
sweepTransientStoreNodes();
|
|
622
630
|
// Lanes only enter activeLanes through the engine's getOrCreateLane.
|
|
623
|
-
if (activeLanes.size) GlobalQueue.
|
|
631
|
+
if (activeLanes.size) GlobalQueue.In(e);
|
|
624
632
|
}
|
|
625
633
|
}
|
|
626
634
|
|
|
@@ -677,7 +685,7 @@ function flush(e) {
|
|
|
677
685
|
}
|
|
678
686
|
}
|
|
679
687
|
}
|
|
680
|
-
if (globalQueue.
|
|
688
|
+
if (globalQueue.cn) {
|
|
681
689
|
return;
|
|
682
690
|
}
|
|
683
691
|
if (halted) return;
|
|
@@ -746,4 +754,4 @@ function runInTransition(e, t) {
|
|
|
746
754
|
}
|
|
747
755
|
}
|
|
748
756
|
|
|
749
|
-
export { GlobalQueue, Queue, activeAffectsMarks, activeLanes, activeTransition, armReaskClear, assignOrMergeLane, clock, currentTransition, dirtyQueue, enforceLoadingBoundary, finalizePureQueue, findLane, flush, globalQueue, haltReactivity, insertSubs, projectionWriteActive, queuePendingNode,
|
|
757
|
+
export { GlobalQueue, Queue, activeAffectsMarks, activeLanes, activeTransition, armReaskClear, assignOrMergeLane, clock, currentTransition, dirtyQueue, enforceLoadingBoundary, finalizePureQueue, findLane, flush, globalQueue, haltReactivity, insertSubs, projectionWriteActive, queuePendingNode, resetErrorHalt, runInTransition, schedule, setProjectionWriteActive, setStoreCommitHook, shiftAffectsMarks, storeCommitHook, zombieQueue };
|
|
@@ -32,15 +32,15 @@ let pendingProbe = null;
|
|
|
32
32
|
* Get or create the pending signal for a node (lazy).
|
|
33
33
|
* Used by isPending() to track pending state reactively.
|
|
34
34
|
*/ function getPendingSignal(e) {
|
|
35
|
-
if (!e.
|
|
35
|
+
if (!e.Oe) {
|
|
36
36
|
// Start false, write true if pending - ensures reversion returns to false
|
|
37
|
-
e.
|
|
37
|
+
e.Oe = optimisticSignal(false, {
|
|
38
38
|
ownedWrite: true
|
|
39
39
|
});
|
|
40
|
-
e.
|
|
41
|
-
if (computePendingState(e)) setSignal(e.
|
|
40
|
+
e.Oe.nn = e;
|
|
41
|
+
if (computePendingState(e)) setSignal(e.Oe, true);
|
|
42
42
|
}
|
|
43
|
-
return e.
|
|
43
|
+
return e.Oe;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
function collectPendingSources(e) {
|
|
@@ -89,7 +89,7 @@ function collectPendingSources(e) {
|
|
|
89
89
|
const r = i.se & REACTIVE_RECOMPUTING_DEPS ? i.Ye : undefined;
|
|
90
90
|
if (r !== null) {
|
|
91
91
|
for (let e = i.tt ?? null; e !== null; e = e.nt) {
|
|
92
|
-
if (!e.
|
|
92
|
+
if (!e.ye && markWalk(e.it, t)) return true;
|
|
93
93
|
if (e === r) break;
|
|
94
94
|
}
|
|
95
95
|
}
|
|
@@ -102,10 +102,10 @@ function collectPendingSources(e) {
|
|
|
102
102
|
|
|
103
103
|
function quietPending(e) {
|
|
104
104
|
if (e.oe) {
|
|
105
|
-
for (const t of e.oe) if (!t.
|
|
105
|
+
for (const t of e.oe) if (!t.pe) return false;
|
|
106
106
|
return true;
|
|
107
107
|
}
|
|
108
|
-
return e.
|
|
108
|
+
return e.pe;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
// NOTE: a loadingValue node's open loading window (_loading) is verdict-quiet
|
|
@@ -132,35 +132,35 @@ function computePendingState(e) {
|
|
|
132
132
|
const n = t.lt || t;
|
|
133
133
|
return newQuestionInFlight(n);
|
|
134
134
|
}
|
|
135
|
-
if (n && e.
|
|
135
|
+
if (n && e._e !== NOT_PENDING && !hasActiveOverride(e)) {
|
|
136
136
|
return !!(n.se & REACTIVE_MANUAL_WRITE) || !n.Te && !(n.S & STATUS_PENDING) || !!(n.S & STATUS_PENDING) && quietPending(n);
|
|
137
137
|
}
|
|
138
138
|
// `!comp._loading`: a hold created while the loading window is still open is
|
|
139
139
|
// the window's own landing in flight to its commit — verdict-quiet like the
|
|
140
140
|
// rest of the window (the UNINITIALIZED check suppresses exactly this frame
|
|
141
141
|
// for windowless first loads; born-committed nodes need their own gate, #2990).
|
|
142
|
-
if (e.
|
|
143
|
-
if (hasActiveOverride(e)) return !e.
|
|
142
|
+
if (e._e !== NOT_PENDING && !(t.S & STATUS_UNINITIALIZED) && !t.Ee) {
|
|
143
|
+
if (hasActiveOverride(e)) return !e.Ue || !e.Ue(e._e, unwrapOverride(e.De));
|
|
144
144
|
return true;
|
|
145
145
|
}
|
|
146
146
|
return newQuestionInFlight(t);
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
function syncCompanions(e, t) {
|
|
150
|
-
if (e.
|
|
151
|
-
if (e.
|
|
150
|
+
if (e.Oe) updatePendingSignal(e);
|
|
151
|
+
if (e.ge) setSignal(e.ge, t);
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
function updatePendingSignal(e) {
|
|
155
|
-
if (e.
|
|
156
|
-
setSignal(e.
|
|
155
|
+
if (e.Oe) {
|
|
156
|
+
setSignal(e.Oe, computePendingState(e));
|
|
157
157
|
}
|
|
158
|
-
if (e.
|
|
158
|
+
if (e.ge) updatePendingSignal(e.ge);
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
function updateChildCompanions(e) {
|
|
162
162
|
for (let t = e.u; t !== null; t = t.ae) {
|
|
163
|
-
if (t.
|
|
163
|
+
if (t.Oe || t.ge) updatePendingSignal(t);
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
|
|
@@ -178,8 +178,8 @@ function updateChildCompanions(e) {
|
|
|
178
178
|
const visit = e => {
|
|
179
179
|
if (i.has(e)) return;
|
|
180
180
|
i.add(e);
|
|
181
|
-
if (e.
|
|
182
|
-
for (let t = e.o; t !== null; t = t.
|
|
181
|
+
if (e.Oe || e.ge) n(e);
|
|
182
|
+
for (let t = e.o; t !== null; t = t.ue) visit(t.fe);
|
|
183
183
|
for (let t = e.u ?? null; t !== null; t = t.ae) {
|
|
184
184
|
visit(t);
|
|
185
185
|
}
|
|
@@ -188,20 +188,20 @@ function updateChildCompanions(e) {
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
function snapCompanionsToState(e) {
|
|
191
|
-
const t = e.
|
|
192
|
-
if (t && (t.
|
|
191
|
+
const t = e.Oe;
|
|
192
|
+
if (t && (t.De === undefined || t.De === NOT_PENDING)) {
|
|
193
193
|
const n = computePendingState(e);
|
|
194
|
-
if (t.
|
|
195
|
-
t.
|
|
196
|
-
t.
|
|
194
|
+
if (t.be !== n || t._e !== NOT_PENDING) {
|
|
195
|
+
t.be = n;
|
|
196
|
+
t._e = NOT_PENDING;
|
|
197
197
|
t.de = clock;
|
|
198
198
|
insertSubs(t);
|
|
199
199
|
schedule();
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
|
-
const n = e.
|
|
202
|
+
const n = e.ge;
|
|
203
203
|
if (n && !(n.se & REACTIVE_DISPOSED)) {
|
|
204
|
-
if ((n.
|
|
204
|
+
if ((n.De === undefined || n.De === NOT_PENDING) && n._e === NOT_PENDING && !Object.is(n.be, e.be) && !(n.se & (REACTIVE_DIRTY | REACTIVE_CHECK))) {
|
|
205
205
|
n.se |= REACTIVE_DIRTY;
|
|
206
206
|
insertIntoHeap(n, queueFor(n));
|
|
207
207
|
insertSubs(n);
|
|
@@ -212,7 +212,7 @@ function snapCompanionsToState(e) {
|
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
function getLatestValueComputed(e) {
|
|
215
|
-
if (!e.
|
|
215
|
+
if (!e.ge) {
|
|
216
216
|
const t = latestReadActive;
|
|
217
217
|
setLatestReadActive(false);
|
|
218
218
|
const n = pendingCheckActive;
|
|
@@ -220,21 +220,21 @@ function getLatestValueComputed(e) {
|
|
|
220
220
|
const i = context;
|
|
221
221
|
setContextInternal(null);
|
|
222
222
|
// Detach from owner so it isn't disposed with effects
|
|
223
|
-
e.
|
|
224
|
-
e.
|
|
223
|
+
e.ge = optimisticComputed(() => read(e));
|
|
224
|
+
e.ge.nn = e;
|
|
225
225
|
// Parent-child lane relationship
|
|
226
226
|
setContextInternal(i);
|
|
227
227
|
setPendingCheckActive(n);
|
|
228
228
|
setLatestReadActive(t);
|
|
229
229
|
}
|
|
230
|
-
return e.
|
|
230
|
+
return e.ge;
|
|
231
231
|
}
|
|
232
232
|
|
|
233
233
|
/** The latest()-mode read path, installed as GlobalQueue._latestRead. */ function latestRead(e) {
|
|
234
234
|
const t = getLatestValueComputed(e);
|
|
235
235
|
const n = latestReadActive;
|
|
236
236
|
setLatestReadActive(false);
|
|
237
|
-
const i = e.
|
|
237
|
+
const i = e.De !== undefined && e.De !== NOT_PENDING ? unwrapOverride(e.De) : e.be;
|
|
238
238
|
let r;
|
|
239
239
|
try {
|
|
240
240
|
// An untracked latest() read has no reading context, so read() never
|
|
@@ -243,7 +243,7 @@ function getLatestValueComputed(e) {
|
|
|
243
243
|
// until the flush (#2922). Mirror the tracked-read pull here: mark the
|
|
244
244
|
// queued staleness through the graph, then bring the shadow up to date.
|
|
245
245
|
const e = queueFor(t);
|
|
246
|
-
if (t.
|
|
246
|
+
if (t.Le >= e.Ve && !(t.se & (REACTIVE_DISPOSED | REACTIVE_ZOMBIE))) {
|
|
247
247
|
markHeap(e);
|
|
248
248
|
prepareComputed(t, true);
|
|
249
249
|
}
|
|
@@ -266,7 +266,7 @@ function getLatestValueComputed(e) {
|
|
|
266
266
|
// speculative value in _pendingValue; a contextless read() only surfaces
|
|
267
267
|
// _value. Overrides stay authoritative (A17), and stale readers keep the
|
|
268
268
|
// other transition's committed view, matching read()'s own selection.
|
|
269
|
-
if (t.
|
|
269
|
+
if (t._e !== NOT_PENDING && !hasActiveOverride(t) && !(stale && t.Ne && activeTransition !== t.Ne)) return t._e;
|
|
270
270
|
return r;
|
|
271
271
|
}
|
|
272
272
|
|
|
@@ -285,14 +285,14 @@ function getLatestValueComputed(e) {
|
|
|
285
285
|
}
|
|
286
286
|
|
|
287
287
|
function recordFreshRead(e, t) {
|
|
288
|
-
if (pendingProbe !== null && e.
|
|
288
|
+
if (pendingProbe !== null && e._e !== NOT_PENDING && t === e._e) pendingProbe.freshReads.add(e);
|
|
289
289
|
}
|
|
290
290
|
|
|
291
291
|
function applyReask(e, t) {
|
|
292
292
|
const n = !!(e.S & STATUS_PENDING);
|
|
293
|
-
const i = t && !(n && !e.
|
|
294
|
-
const r = n && e.
|
|
295
|
-
e.
|
|
293
|
+
const i = t && !(n && !e.pe);
|
|
294
|
+
const r = n && e.pe !== i;
|
|
295
|
+
e.pe = i;
|
|
296
296
|
return r;
|
|
297
297
|
}
|
|
298
298
|
|
|
@@ -350,7 +350,7 @@ GlobalQueue.Pe = syncCompanions;
|
|
|
350
350
|
|
|
351
351
|
GlobalQueue.Se = updatePendingSignal;
|
|
352
352
|
|
|
353
|
-
GlobalQueue.
|
|
353
|
+
GlobalQueue.Ge = updateChildCompanions;
|
|
354
354
|
|
|
355
355
|
GlobalQueue.un = snapCompanionsToState;
|
|
356
356
|
|
|
@@ -358,9 +358,9 @@ GlobalQueue.At = latestRead;
|
|
|
358
358
|
|
|
359
359
|
GlobalQueue.Ct = pendingCheckRead;
|
|
360
360
|
|
|
361
|
-
GlobalQueue.
|
|
361
|
+
GlobalQueue.Pt = recordFreshRead;
|
|
362
362
|
|
|
363
|
-
GlobalQueue
|
|
363
|
+
GlobalQueue.$e = applyReask;
|
|
364
364
|
|
|
365
365
|
GlobalQueue.k = repollDownstreamVerdicts;
|
|
366
366
|
|
package/dist/prod/index.js
CHANGED
|
@@ -26,19 +26,19 @@ export { affects } from "./affects.js";
|
|
|
26
26
|
|
|
27
27
|
export { mapArray, repeat } from "./map.js";
|
|
28
28
|
|
|
29
|
-
export {
|
|
29
|
+
export { createStore, deep, reconcile, snapshot } from "./store/index.js";
|
|
30
30
|
|
|
31
|
-
export {
|
|
31
|
+
export { createErrorBoundary, createLoadingBoundary, createRevealOrder, flatten } from "./boundaries.js";
|
|
32
32
|
|
|
33
|
-
export {
|
|
33
|
+
export { $PROXY, $TARGET, $TRACK, isWrappable } from "./store/store.js";
|
|
34
34
|
|
|
35
|
-
export {
|
|
35
|
+
export { createOptimisticStoreNext as createOptimisticStore } from "./store/next/optimistic.js";
|
|
36
36
|
|
|
37
|
-
export {
|
|
37
|
+
export { createProjectionNext as createProjection } from "./store/next/projection.js";
|
|
38
38
|
|
|
39
|
-
export {
|
|
39
|
+
export { merge, omit } from "./store/utils.js";
|
|
40
40
|
|
|
41
|
-
export {
|
|
41
|
+
export { storePath } from "./store/storePath.js";
|
|
42
42
|
|
|
43
43
|
const DEV = undefined;
|
|
44
44
|
|