@solidjs/signals 0.12.0 → 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 +2 -2
- package/dist/dev.js +219 -183
- package/dist/node.cjs +934 -913
- package/dist/prod.js +778 -752
- package/dist/types/boundaries.d.ts +6 -2
- package/dist/types/core/external.d.ts +26 -0
- package/dist/types/core/index.d.ts +3 -2
- package/dist/types/core/lanes.d.ts +3 -5
- package/dist/types/core/scheduler.d.ts +3 -1
- package/dist/types/core/types.d.ts +1 -1
- package/dist/types/index.d.ts +5 -4
- package/dist/types/signals.d.ts +1 -0
- package/dist/types/store/index.d.ts +2 -2
- package/dist/types/store/reconcile.d.ts +1 -1
- package/dist/types/store/store.d.ts +2 -4
- package/dist/types/store/utils.d.ts +8 -0
- package/package.json +1 -1
package/dist/prod.js
CHANGED
|
@@ -82,10 +82,10 @@ function deleteFromHeap(e, t) {
|
|
|
82
82
|
else {
|
|
83
83
|
const n = e.S;
|
|
84
84
|
const r = t.l[i];
|
|
85
|
-
const
|
|
85
|
+
const o = n ?? r;
|
|
86
86
|
if (e === r) t.l[i] = n;
|
|
87
87
|
else e.T.S = n;
|
|
88
|
-
|
|
88
|
+
o.T = e.T;
|
|
89
89
|
}
|
|
90
90
|
e.T = e;
|
|
91
91
|
e.S = undefined;
|
|
@@ -107,7 +107,7 @@ function markNode(e, t = REACTIVE_DIRTY) {
|
|
|
107
107
|
markNode(t.h, REACTIVE_CHECK);
|
|
108
108
|
}
|
|
109
109
|
if (e.A !== null) {
|
|
110
|
-
for (let t = e.A; t !== null; t = t.
|
|
110
|
+
for (let t = e.A; t !== null; t = t.N) {
|
|
111
111
|
for (let e = t.I; e !== null; e = e.p) {
|
|
112
112
|
markNode(e.h, REACTIVE_CHECK);
|
|
113
113
|
}
|
|
@@ -116,12 +116,12 @@ function markNode(e, t = REACTIVE_DIRTY) {
|
|
|
116
116
|
}
|
|
117
117
|
function runHeap(e, t) {
|
|
118
118
|
e._ = false;
|
|
119
|
-
for (e.
|
|
120
|
-
let n = e.l[e.
|
|
119
|
+
for (e.P = 0; e.P <= e.R; e.P++) {
|
|
120
|
+
let n = e.l[e.P];
|
|
121
121
|
while (n !== undefined) {
|
|
122
122
|
if (n.O & REACTIVE_IN_HEAP) t(n);
|
|
123
123
|
else adjustHeight(n, e);
|
|
124
|
-
n = e.l[e.
|
|
124
|
+
n = e.l[e.P];
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
e.R = 0;
|
|
@@ -130,8 +130,8 @@ function adjustHeight(e, t) {
|
|
|
130
130
|
deleteFromHeap(e, t);
|
|
131
131
|
let n = e.o;
|
|
132
132
|
for (let t = e.C; t; t = t.D) {
|
|
133
|
-
const e = t.
|
|
134
|
-
const i = e.
|
|
133
|
+
const e = t.m;
|
|
134
|
+
const i = e.V || e;
|
|
135
135
|
if (i.L && i.o >= n) n = i.o + 1;
|
|
136
136
|
}
|
|
137
137
|
if (e.o !== n) {
|
|
@@ -142,13 +142,13 @@ function adjustHeight(e, t) {
|
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
const transitions = new Set();
|
|
145
|
-
const dirtyQueue = { l: new Array(2e3).fill(undefined), _: false,
|
|
146
|
-
const zombieQueue = { l: new Array(2e3).fill(undefined), _: false,
|
|
145
|
+
const dirtyQueue = { l: new Array(2e3).fill(undefined), _: false, P: 0, R: 0 };
|
|
146
|
+
const zombieQueue = { l: new Array(2e3).fill(undefined), _: false, P: 0, R: 0 };
|
|
147
147
|
let clock = 0;
|
|
148
148
|
let activeTransition = null;
|
|
149
149
|
let scheduled = false;
|
|
150
150
|
let projectionWriteActive = false;
|
|
151
|
-
function
|
|
151
|
+
function enforceLoadingBoundary(e) {}
|
|
152
152
|
function runLaneEffects(e) {
|
|
153
153
|
for (const t of activeLanes) {
|
|
154
154
|
if (t.k || t.U.size > 0) continue;
|
|
@@ -170,16 +170,16 @@ function schedule() {
|
|
|
170
170
|
class Queue {
|
|
171
171
|
i = null;
|
|
172
172
|
G = [[], []];
|
|
173
|
-
|
|
173
|
+
F = [];
|
|
174
174
|
created = clock;
|
|
175
175
|
addChild(e) {
|
|
176
|
-
this.
|
|
176
|
+
this.F.push(e);
|
|
177
177
|
e.i = this;
|
|
178
178
|
}
|
|
179
179
|
removeChild(e) {
|
|
180
|
-
const t = this.
|
|
180
|
+
const t = this.F.indexOf(e);
|
|
181
181
|
if (t >= 0) {
|
|
182
|
-
this.
|
|
182
|
+
this.F.splice(t, 1);
|
|
183
183
|
e.i = null;
|
|
184
184
|
}
|
|
185
185
|
}
|
|
@@ -193,7 +193,7 @@ class Queue {
|
|
|
193
193
|
this.G[e - 1] = [];
|
|
194
194
|
runQueue(t, e);
|
|
195
195
|
}
|
|
196
|
-
for (let t = 0; t < this.
|
|
196
|
+
for (let t = 0; t < this.F.length; t++) this.F[t].run?.(e);
|
|
197
197
|
}
|
|
198
198
|
enqueue(e, t) {
|
|
199
199
|
if (e) {
|
|
@@ -210,12 +210,12 @@ class Queue {
|
|
|
210
210
|
e.G[0].push(...this.G[0]);
|
|
211
211
|
e.G[1].push(...this.G[1]);
|
|
212
212
|
this.G = [[], []];
|
|
213
|
-
for (let t = 0; t < this.
|
|
214
|
-
let n = this.
|
|
215
|
-
let i = e.
|
|
213
|
+
for (let t = 0; t < this.F.length; t++) {
|
|
214
|
+
let n = this.F[t];
|
|
215
|
+
let i = e.F[t];
|
|
216
216
|
if (!i) {
|
|
217
|
-
i = { G: [[], []],
|
|
218
|
-
e.
|
|
217
|
+
i = { G: [[], []], F: [] };
|
|
218
|
+
e.F[t] = i;
|
|
219
219
|
}
|
|
220
220
|
n.stashQueues(i);
|
|
221
221
|
}
|
|
@@ -223,21 +223,21 @@ class Queue {
|
|
|
223
223
|
restoreQueues(e) {
|
|
224
224
|
this.G[0].push(...e.G[0]);
|
|
225
225
|
this.G[1].push(...e.G[1]);
|
|
226
|
-
for (let t = 0; t < e.
|
|
227
|
-
const n = e.
|
|
228
|
-
let i = this.
|
|
226
|
+
for (let t = 0; t < e.F.length; t++) {
|
|
227
|
+
const n = e.F[t];
|
|
228
|
+
let i = this.F[t];
|
|
229
229
|
if (i) i.restoreQueues(n);
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
233
|
class GlobalQueue extends Queue {
|
|
234
234
|
H = false;
|
|
235
|
-
|
|
235
|
+
M = [];
|
|
236
236
|
$ = [];
|
|
237
237
|
j = new Set();
|
|
238
238
|
static K;
|
|
239
239
|
static Y;
|
|
240
|
-
static
|
|
240
|
+
static B = null;
|
|
241
241
|
flush() {
|
|
242
242
|
if (this.H) return;
|
|
243
243
|
this.H = true;
|
|
@@ -248,32 +248,32 @@ class GlobalQueue extends Queue {
|
|
|
248
248
|
if (!e) {
|
|
249
249
|
let e = activeTransition;
|
|
250
250
|
runHeap(zombieQueue, GlobalQueue.K);
|
|
251
|
-
this.
|
|
251
|
+
this.M = [];
|
|
252
252
|
this.$ = [];
|
|
253
253
|
this.j = new Set();
|
|
254
254
|
runLaneEffects(EFFECT_RENDER);
|
|
255
255
|
runLaneEffects(EFFECT_USER);
|
|
256
|
-
this.stashQueues(activeTransition.
|
|
256
|
+
this.stashQueues(activeTransition.Z);
|
|
257
257
|
clock++;
|
|
258
|
-
scheduled = dirtyQueue.R >= dirtyQueue.
|
|
259
|
-
reassignPendingTransition(activeTransition.
|
|
258
|
+
scheduled = dirtyQueue.R >= dirtyQueue.P;
|
|
259
|
+
reassignPendingTransition(activeTransition.M);
|
|
260
260
|
activeTransition = null;
|
|
261
261
|
finalizePureQueue(null, true);
|
|
262
262
|
return;
|
|
263
263
|
}
|
|
264
|
-
this.
|
|
265
|
-
this.restoreQueues(activeTransition.
|
|
264
|
+
this.M !== activeTransition.M && this.M.push(...activeTransition.M);
|
|
265
|
+
this.restoreQueues(activeTransition.Z);
|
|
266
266
|
transitions.delete(activeTransition);
|
|
267
267
|
const t = activeTransition;
|
|
268
268
|
activeTransition = null;
|
|
269
|
-
reassignPendingTransition(this.
|
|
269
|
+
reassignPendingTransition(this.M);
|
|
270
270
|
finalizePureQueue(t);
|
|
271
271
|
} else {
|
|
272
272
|
if (transitions.size) runHeap(zombieQueue, GlobalQueue.K);
|
|
273
273
|
finalizePureQueue();
|
|
274
274
|
}
|
|
275
275
|
clock++;
|
|
276
|
-
scheduled = dirtyQueue.R >= dirtyQueue.
|
|
276
|
+
scheduled = dirtyQueue.R >= dirtyQueue.P;
|
|
277
277
|
runLaneEffects(EFFECT_RENDER);
|
|
278
278
|
this.run(EFFECT_RENDER);
|
|
279
279
|
runLaneEffects(EFFECT_USER);
|
|
@@ -285,9 +285,9 @@ class GlobalQueue extends Queue {
|
|
|
285
285
|
notify(e, t, n, i) {
|
|
286
286
|
if (t & STATUS_PENDING) {
|
|
287
287
|
if (n & STATUS_PENDING) {
|
|
288
|
-
const t = i !== undefined ? i : e.
|
|
289
|
-
if (activeTransition && t && !activeTransition.
|
|
290
|
-
activeTransition.
|
|
288
|
+
const t = i !== undefined ? i : e.q;
|
|
289
|
+
if (activeTransition && t && !activeTransition.X.includes(t.source)) {
|
|
290
|
+
activeTransition.X.push(t.source);
|
|
291
291
|
schedule();
|
|
292
292
|
}
|
|
293
293
|
}
|
|
@@ -302,12 +302,12 @@ class GlobalQueue extends Queue {
|
|
|
302
302
|
if (!activeTransition) {
|
|
303
303
|
activeTransition = e ?? {
|
|
304
304
|
J: clock,
|
|
305
|
-
|
|
306
|
-
|
|
305
|
+
M: [],
|
|
306
|
+
X: [],
|
|
307
307
|
$: [],
|
|
308
308
|
j: new Set(),
|
|
309
309
|
ee: [],
|
|
310
|
-
|
|
310
|
+
Z: { G: [[], []], F: [] },
|
|
311
311
|
te: false
|
|
312
312
|
};
|
|
313
313
|
} else if (e) {
|
|
@@ -326,12 +326,12 @@ class GlobalQueue extends Queue {
|
|
|
326
326
|
}
|
|
327
327
|
transitions.add(activeTransition);
|
|
328
328
|
activeTransition.J = clock;
|
|
329
|
-
for (let e = 0; e < this.
|
|
330
|
-
const t = this.
|
|
329
|
+
for (let e = 0; e < this.M.length; e++) {
|
|
330
|
+
const t = this.M[e];
|
|
331
331
|
t.ne = activeTransition;
|
|
332
|
-
activeTransition.
|
|
332
|
+
activeTransition.M.push(t);
|
|
333
333
|
}
|
|
334
|
-
this.
|
|
334
|
+
this.M = activeTransition.M;
|
|
335
335
|
for (let e = 0; e < this.$.length; e++) {
|
|
336
336
|
const t = this.$[e];
|
|
337
337
|
t.ne = activeTransition;
|
|
@@ -349,7 +349,7 @@ function insertSubs(e, t = false) {
|
|
|
349
349
|
const n = e.ie || currentOptimisticLane;
|
|
350
350
|
const i = e.re !== undefined;
|
|
351
351
|
for (let r = e.I; r !== null; r = r.p) {
|
|
352
|
-
if (i && r.h.
|
|
352
|
+
if (i && r.h.oe) {
|
|
353
353
|
r.h.O |= REACTIVE_SNAPSHOT_STALE;
|
|
354
354
|
continue;
|
|
355
355
|
}
|
|
@@ -361,54 +361,59 @@ function insertSubs(e, t = false) {
|
|
|
361
361
|
r.h.ie = undefined;
|
|
362
362
|
}
|
|
363
363
|
const e = r.h;
|
|
364
|
-
if (e.
|
|
364
|
+
if (e.se === EFFECT_TRACKED) {
|
|
365
365
|
if (!e.ue) {
|
|
366
366
|
e.ue = true;
|
|
367
|
-
e.ce.enqueue(EFFECT_USER, e.
|
|
367
|
+
e.ce.enqueue(EFFECT_USER, e.ae);
|
|
368
368
|
}
|
|
369
369
|
continue;
|
|
370
370
|
}
|
|
371
|
-
const
|
|
372
|
-
if (
|
|
373
|
-
insertIntoHeap(r.h,
|
|
371
|
+
const o = r.h.O & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue;
|
|
372
|
+
if (o.P > r.h.o) o.P = r.h.o;
|
|
373
|
+
insertIntoHeap(r.h, o);
|
|
374
374
|
}
|
|
375
375
|
}
|
|
376
|
+
function commitPendingNodes() {
|
|
377
|
+
const e = globalQueue.M;
|
|
378
|
+
for (let t = 0; t < e.length; t++) {
|
|
379
|
+
const n = e[t];
|
|
380
|
+
if (n.le !== NOT_PENDING) {
|
|
381
|
+
n.fe = n.le;
|
|
382
|
+
n.le = NOT_PENDING;
|
|
383
|
+
if (n.se && n.se !== EFFECT_TRACKED) n.ue = true;
|
|
384
|
+
}
|
|
385
|
+
if (!(n.Ee & STATUS_PENDING)) n.Ee &= ~STATUS_UNINITIALIZED;
|
|
386
|
+
if (n.L) GlobalQueue.Y(n, false, true);
|
|
387
|
+
}
|
|
388
|
+
e.length = 0;
|
|
389
|
+
}
|
|
376
390
|
function finalizePureQueue(e = null, t = false) {
|
|
377
391
|
let n = !t;
|
|
392
|
+
if (n) commitPendingNodes();
|
|
378
393
|
if (!t) checkBoundaryChildren(globalQueue);
|
|
379
|
-
if (dirtyQueue.R >= dirtyQueue.
|
|
394
|
+
if (dirtyQueue.R >= dirtyQueue.P) runHeap(dirtyQueue, GlobalQueue.K);
|
|
380
395
|
if (n) {
|
|
381
|
-
|
|
396
|
+
commitPendingNodes();
|
|
397
|
+
const t = e ? e.$ : globalQueue.$;
|
|
382
398
|
for (let e = 0; e < t.length; e++) {
|
|
383
399
|
const n = t[e];
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
n.
|
|
387
|
-
|
|
400
|
+
n.ie = undefined;
|
|
401
|
+
if (n.le !== NOT_PENDING) {
|
|
402
|
+
n.fe = n.le;
|
|
403
|
+
n.le = NOT_PENDING;
|
|
388
404
|
}
|
|
389
|
-
|
|
390
|
-
|
|
405
|
+
const i = n.Te;
|
|
406
|
+
n.Te = NOT_PENDING;
|
|
407
|
+
if (i !== NOT_PENDING && n.fe !== i) insertSubs(n, true);
|
|
408
|
+
n.ne = null;
|
|
391
409
|
}
|
|
392
410
|
t.length = 0;
|
|
393
|
-
const n = e ? e
|
|
394
|
-
|
|
395
|
-
const
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
t.fe = i;
|
|
400
|
-
insertSubs(t, true);
|
|
401
|
-
}
|
|
402
|
-
t.ae = NOT_PENDING;
|
|
403
|
-
t.ne = null;
|
|
404
|
-
}
|
|
405
|
-
n.length = 0;
|
|
406
|
-
const i = e ? e.j : globalQueue.j;
|
|
407
|
-
if (GlobalQueue.Z && i.size) {
|
|
408
|
-
for (const e of i) {
|
|
409
|
-
GlobalQueue.Z(e);
|
|
410
|
-
}
|
|
411
|
-
i.clear();
|
|
411
|
+
const n = e ? e.j : globalQueue.j;
|
|
412
|
+
if (GlobalQueue.B && n.size) {
|
|
413
|
+
for (const e of n) {
|
|
414
|
+
GlobalQueue.B(e);
|
|
415
|
+
}
|
|
416
|
+
n.clear();
|
|
412
417
|
schedule();
|
|
413
418
|
}
|
|
414
419
|
for (const t of activeLanes) {
|
|
@@ -418,17 +423,17 @@ function finalizePureQueue(e = null, t = false) {
|
|
|
418
423
|
if (t.W[0].length) runQueue(t.W[0], EFFECT_RENDER);
|
|
419
424
|
if (t.W[1].length) runQueue(t.W[1], EFFECT_USER);
|
|
420
425
|
}
|
|
421
|
-
if (t.
|
|
426
|
+
if (t.de.ie === t) t.de.ie = undefined;
|
|
422
427
|
t.U.clear();
|
|
423
428
|
t.W[0].length = 0;
|
|
424
429
|
t.W[1].length = 0;
|
|
425
430
|
activeLanes.delete(t);
|
|
426
|
-
signalLanes.delete(t.
|
|
431
|
+
signalLanes.delete(t.de);
|
|
427
432
|
}
|
|
428
433
|
}
|
|
429
434
|
}
|
|
430
435
|
function checkBoundaryChildren(e) {
|
|
431
|
-
for (const t of e.
|
|
436
|
+
for (const t of e.F) {
|
|
432
437
|
t.checkSources?.();
|
|
433
438
|
checkBoundaryChildren(t);
|
|
434
439
|
}
|
|
@@ -455,9 +460,9 @@ function transitionComplete(e) {
|
|
|
455
460
|
if (e.te) return true;
|
|
456
461
|
if (e.ee.length) return false;
|
|
457
462
|
let t = true;
|
|
458
|
-
for (let n = 0; n < e.
|
|
459
|
-
const i = e.
|
|
460
|
-
if (i.Ee & STATUS_PENDING && i.
|
|
463
|
+
for (let n = 0; n < e.X.length; n++) {
|
|
464
|
+
const i = e.X[n];
|
|
465
|
+
if (i.Ee & STATUS_PENDING && i.q?.source === i) {
|
|
461
466
|
t = false;
|
|
462
467
|
break;
|
|
463
468
|
}
|
|
@@ -488,12 +493,12 @@ function getOrCreateLane(e) {
|
|
|
488
493
|
if (t) {
|
|
489
494
|
return findLane(t);
|
|
490
495
|
}
|
|
491
|
-
const n = e.
|
|
496
|
+
const n = e.Se;
|
|
492
497
|
const i = n?.ie ? findLane(n.ie) : null;
|
|
493
|
-
t = {
|
|
498
|
+
t = { de: e, U: new Set(), W: [[], []], k: null, ne: activeTransition, Re: i };
|
|
494
499
|
signalLanes.set(e, t);
|
|
495
500
|
activeLanes.add(t);
|
|
496
|
-
e.
|
|
501
|
+
e.Oe = false;
|
|
497
502
|
return t;
|
|
498
503
|
}
|
|
499
504
|
function findLane(e) {
|
|
@@ -519,7 +524,7 @@ function resolveLane(e) {
|
|
|
519
524
|
return undefined;
|
|
520
525
|
}
|
|
521
526
|
function hasActiveOverride(e) {
|
|
522
|
-
return !!(e.
|
|
527
|
+
return !!(e.Te !== undefined && e.Te !== NOT_PENDING);
|
|
523
528
|
}
|
|
524
529
|
function assignOrMergeLane(e, t) {
|
|
525
530
|
const n = findLane(t);
|
|
@@ -532,9 +537,9 @@ function assignOrMergeLane(e, t) {
|
|
|
532
537
|
const r = findLane(i);
|
|
533
538
|
if (activeLanes.has(r)) {
|
|
534
539
|
if (r !== n && !hasActiveOverride(e)) {
|
|
535
|
-
if (n.
|
|
540
|
+
if (n.Re && findLane(n.Re) === r) {
|
|
536
541
|
e.ie = t;
|
|
537
|
-
} else if (r.
|
|
542
|
+
} else if (r.Re && findLane(r.Re) === n);
|
|
538
543
|
else mergeLanes(n, r);
|
|
539
544
|
}
|
|
540
545
|
return;
|
|
@@ -545,43 +550,42 @@ function assignOrMergeLane(e, t) {
|
|
|
545
550
|
function handleAsync(e, t, n) {
|
|
546
551
|
const i = typeof t === "object" && t !== null;
|
|
547
552
|
const r = i && untrack(() => t[Symbol.asyncIterator]);
|
|
548
|
-
const
|
|
549
|
-
if (!
|
|
550
|
-
e.
|
|
553
|
+
const o = !r && i && untrack(() => typeof t.then === "function");
|
|
554
|
+
if (!o && !r) {
|
|
555
|
+
e._e = null;
|
|
551
556
|
return t;
|
|
552
557
|
}
|
|
553
|
-
e.
|
|
554
|
-
let
|
|
558
|
+
e._e = t;
|
|
559
|
+
let s;
|
|
555
560
|
const handleError = n => {
|
|
556
|
-
if (e.
|
|
561
|
+
if (e._e !== t) return;
|
|
557
562
|
globalQueue.initTransition(e.ne);
|
|
558
563
|
notifyStatus(e, n instanceof NotReadyError ? STATUS_PENDING : STATUS_ERROR, n);
|
|
559
564
|
e.J = clock;
|
|
560
565
|
};
|
|
561
566
|
const asyncWrite = (i, r) => {
|
|
562
|
-
if (e.
|
|
567
|
+
if (e._e !== t) return;
|
|
563
568
|
if (e.O & (REACTIVE_DIRTY | REACTIVE_OPTIMISTIC_DIRTY)) return;
|
|
564
569
|
globalQueue.initTransition(e.ne);
|
|
565
570
|
clearStatus(e);
|
|
566
|
-
const
|
|
567
|
-
if (
|
|
571
|
+
const o = resolveLane(e);
|
|
572
|
+
if (o) o.U.delete(e);
|
|
568
573
|
if (n) n(i);
|
|
569
|
-
else if (e.
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
if (!t) {
|
|
574
|
+
else if (e.Te !== undefined) {
|
|
575
|
+
if (e.Te !== undefined && e.Te !== NOT_PENDING) e.le = i;
|
|
576
|
+
else {
|
|
573
577
|
e.fe = i;
|
|
574
578
|
insertSubs(e);
|
|
575
579
|
}
|
|
576
580
|
e.J = clock;
|
|
577
|
-
} else if (
|
|
581
|
+
} else if (o) {
|
|
578
582
|
const t = e.fe;
|
|
579
|
-
const n = e.
|
|
583
|
+
const n = e.Ie;
|
|
580
584
|
if (!n || !n(i, t)) {
|
|
581
585
|
e.fe = i;
|
|
582
586
|
e.J = clock;
|
|
583
|
-
if (e.
|
|
584
|
-
setSignal(e.
|
|
587
|
+
if (e.pe) {
|
|
588
|
+
setSignal(e.pe, i);
|
|
585
589
|
}
|
|
586
590
|
insertSubs(e, true);
|
|
587
591
|
}
|
|
@@ -592,13 +596,13 @@ function handleAsync(e, t, n) {
|
|
|
592
596
|
flush();
|
|
593
597
|
r?.();
|
|
594
598
|
};
|
|
595
|
-
if (
|
|
599
|
+
if (o) {
|
|
596
600
|
let n = false,
|
|
597
601
|
i = true;
|
|
598
602
|
t.then(
|
|
599
603
|
e => {
|
|
600
604
|
if (i) {
|
|
601
|
-
|
|
605
|
+
s = e;
|
|
602
606
|
n = true;
|
|
603
607
|
} else asyncWrite(e);
|
|
604
608
|
},
|
|
@@ -636,7 +640,7 @@ function handleAsync(e, t, n) {
|
|
|
636
640
|
);
|
|
637
641
|
r = false;
|
|
638
642
|
if (t && !e.done) {
|
|
639
|
-
|
|
643
|
+
s = e.value;
|
|
640
644
|
i = true;
|
|
641
645
|
return iterate();
|
|
642
646
|
}
|
|
@@ -648,23 +652,23 @@ function handleAsync(e, t, n) {
|
|
|
648
652
|
throw new NotReadyError(context);
|
|
649
653
|
}
|
|
650
654
|
}
|
|
651
|
-
return
|
|
655
|
+
return s;
|
|
652
656
|
}
|
|
653
657
|
function clearStatus(e) {
|
|
654
658
|
e.Ee = e.Ee & STATUS_UNINITIALIZED;
|
|
655
|
-
e.
|
|
659
|
+
e.q = null;
|
|
656
660
|
updatePendingSignal(e);
|
|
657
|
-
e.
|
|
661
|
+
e.he?.();
|
|
658
662
|
}
|
|
659
663
|
function notifyStatus(e, t, n, i, r) {
|
|
660
664
|
if (t === STATUS_ERROR && !(n instanceof StatusError) && !(n instanceof NotReadyError))
|
|
661
665
|
n = new StatusError(e, n);
|
|
662
|
-
const
|
|
663
|
-
const
|
|
664
|
-
const u =
|
|
666
|
+
const o = n instanceof NotReadyError && n.source === e;
|
|
667
|
+
const s = t === STATUS_PENDING && e.Te !== undefined && !o;
|
|
668
|
+
const u = s && hasActiveOverride(e);
|
|
665
669
|
if (!i) {
|
|
666
670
|
e.Ee = t | (t !== STATUS_ERROR ? e.Ee & STATUS_UNINITIALIZED : 0);
|
|
667
|
-
e.
|
|
671
|
+
e.q = n;
|
|
668
672
|
updatePendingSignal(e);
|
|
669
673
|
}
|
|
670
674
|
if (r && !i) {
|
|
@@ -672,50 +676,50 @@ function notifyStatus(e, t, n, i, r) {
|
|
|
672
676
|
}
|
|
673
677
|
if (u && activeTransition && n instanceof NotReadyError) {
|
|
674
678
|
const e = n.source;
|
|
675
|
-
if (!activeTransition.
|
|
676
|
-
activeTransition.
|
|
679
|
+
if (!activeTransition.X.includes(e)) {
|
|
680
|
+
activeTransition.X.push(e);
|
|
677
681
|
}
|
|
678
682
|
}
|
|
679
683
|
const c = i || u;
|
|
680
|
-
const
|
|
681
|
-
if (e.
|
|
684
|
+
const a = i || s ? undefined : r;
|
|
685
|
+
if (e.he) {
|
|
682
686
|
if (c) {
|
|
683
|
-
e.
|
|
687
|
+
e.he(t, n);
|
|
684
688
|
} else {
|
|
685
|
-
e.
|
|
689
|
+
e.he();
|
|
686
690
|
}
|
|
687
691
|
return;
|
|
688
692
|
}
|
|
689
693
|
for (let i = e.I; i !== null; i = i.p) {
|
|
690
694
|
i.h.J = clock;
|
|
691
|
-
if (i.h.
|
|
692
|
-
!i.h.ne && globalQueue.
|
|
693
|
-
notifyStatus(i.h, t, n, c,
|
|
695
|
+
if (i.h.q !== n) {
|
|
696
|
+
!i.h.ne && globalQueue.M.push(i.h);
|
|
697
|
+
notifyStatus(i.h, t, n, c, a);
|
|
694
698
|
}
|
|
695
699
|
}
|
|
696
|
-
for (let i = e.A; i !== null; i = i.
|
|
700
|
+
for (let i = e.A; i !== null; i = i.N) {
|
|
697
701
|
for (let e = i.I; e !== null; e = e.p) {
|
|
698
702
|
e.h.J = clock;
|
|
699
|
-
if (e.h.
|
|
700
|
-
!e.h.ne && globalQueue.
|
|
701
|
-
notifyStatus(e.h, t, n, c,
|
|
703
|
+
if (e.h.q !== n) {
|
|
704
|
+
!e.h.ne && globalQueue.M.push(e.h);
|
|
705
|
+
notifyStatus(e.h, t, n, c, a);
|
|
702
706
|
}
|
|
703
707
|
}
|
|
704
708
|
}
|
|
705
709
|
}
|
|
706
710
|
function unlinkSubs(e) {
|
|
707
|
-
const t = e.
|
|
711
|
+
const t = e.m;
|
|
708
712
|
const n = e.D;
|
|
709
713
|
const i = e.p;
|
|
710
|
-
const r = e.
|
|
711
|
-
if (i !== null) i.
|
|
714
|
+
const r = e.Ae;
|
|
715
|
+
if (i !== null) i.Ae = r;
|
|
712
716
|
else t.Ne = r;
|
|
713
717
|
if (r !== null) r.p = i;
|
|
714
718
|
else {
|
|
715
719
|
t.I = i;
|
|
716
720
|
if (i === null) {
|
|
717
721
|
t.ge?.();
|
|
718
|
-
t.L && !t.
|
|
722
|
+
t.L && !t.Pe && !(t.O & REACTIVE_ZOMBIE) && unobserved(t);
|
|
719
723
|
}
|
|
720
724
|
}
|
|
721
725
|
return n;
|
|
@@ -730,27 +734,27 @@ function unobserved(e) {
|
|
|
730
734
|
disposeChildren(e, true);
|
|
731
735
|
}
|
|
732
736
|
function link(e, t) {
|
|
733
|
-
const n = t.
|
|
734
|
-
if (n !== null && n.
|
|
737
|
+
const n = t.Ce;
|
|
738
|
+
if (n !== null && n.m === e) return;
|
|
735
739
|
let i = null;
|
|
736
740
|
const r = t.O & REACTIVE_RECOMPUTING_DEPS;
|
|
737
741
|
if (r) {
|
|
738
742
|
i = n !== null ? n.D : t.C;
|
|
739
|
-
if (i !== null && i.
|
|
740
|
-
t.
|
|
743
|
+
if (i !== null && i.m === e) {
|
|
744
|
+
t.Ce = i;
|
|
741
745
|
return;
|
|
742
746
|
}
|
|
743
747
|
}
|
|
744
|
-
const
|
|
745
|
-
if (
|
|
746
|
-
const
|
|
747
|
-
if (n !== null) n.D =
|
|
748
|
-
else t.C =
|
|
749
|
-
if (
|
|
750
|
-
else e.I =
|
|
748
|
+
const o = e.Ne;
|
|
749
|
+
if (o !== null && o.h === t && (!r || isValidLink(o, t))) return;
|
|
750
|
+
const s = (t.Ce = e.Ne = { m: e, h: t, D: i, Ae: o, p: null });
|
|
751
|
+
if (n !== null) n.D = s;
|
|
752
|
+
else t.C = s;
|
|
753
|
+
if (o !== null) o.p = s;
|
|
754
|
+
else e.I = s;
|
|
751
755
|
}
|
|
752
756
|
function isValidLink(e, t) {
|
|
753
|
-
const n = t.
|
|
757
|
+
const n = t.Ce;
|
|
754
758
|
if (n !== null) {
|
|
755
759
|
let i = t.C;
|
|
756
760
|
do {
|
|
@@ -771,7 +775,7 @@ function markDisposal(e) {
|
|
|
771
775
|
insertIntoHeap(t, zombieQueue);
|
|
772
776
|
}
|
|
773
777
|
markDisposal(t);
|
|
774
|
-
t = t.
|
|
778
|
+
t = t.ye;
|
|
775
779
|
}
|
|
776
780
|
}
|
|
777
781
|
function dispose(e) {
|
|
@@ -780,15 +784,15 @@ function dispose(e) {
|
|
|
780
784
|
t = unlinkSubs(t);
|
|
781
785
|
} while (t !== null);
|
|
782
786
|
e.C = null;
|
|
783
|
-
e.
|
|
787
|
+
e.Ce = null;
|
|
784
788
|
disposeChildren(e, true);
|
|
785
789
|
}
|
|
786
790
|
function disposeChildren(e, t = false, n) {
|
|
787
791
|
if (e.O & REACTIVE_DISPOSED) return;
|
|
788
792
|
if (t) e.O = REACTIVE_DISPOSED;
|
|
789
|
-
let i = n ? e.
|
|
793
|
+
let i = n ? e.ve : e.De;
|
|
790
794
|
while (i) {
|
|
791
|
-
const e = i.
|
|
795
|
+
const e = i.ye;
|
|
792
796
|
if (i.C) {
|
|
793
797
|
const e = i;
|
|
794
798
|
deleteFromHeap(e, e.O & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
@@ -797,22 +801,21 @@ function disposeChildren(e, t = false, n) {
|
|
|
797
801
|
t = unlinkSubs(t);
|
|
798
802
|
} while (t !== null);
|
|
799
803
|
e.C = null;
|
|
800
|
-
e.
|
|
804
|
+
e.Ce = null;
|
|
801
805
|
}
|
|
802
806
|
disposeChildren(i, true);
|
|
803
807
|
i = e;
|
|
804
808
|
}
|
|
805
809
|
if (n) {
|
|
806
|
-
e.
|
|
810
|
+
e.ve = null;
|
|
807
811
|
} else {
|
|
808
812
|
e.De = null;
|
|
809
|
-
e.ve = null;
|
|
810
813
|
e.we = 0;
|
|
811
814
|
}
|
|
812
815
|
runDisposal(e, n);
|
|
813
816
|
}
|
|
814
817
|
function runDisposal(e, t) {
|
|
815
|
-
let n = t ? e.
|
|
818
|
+
let n = t ? e.be : e.me;
|
|
816
819
|
if (!n) return;
|
|
817
820
|
if (Array.isArray(n)) {
|
|
818
821
|
for (let e = 0; e < n.length; e++) {
|
|
@@ -822,11 +825,11 @@ function runDisposal(e, t) {
|
|
|
822
825
|
} else {
|
|
823
826
|
n.call(n);
|
|
824
827
|
}
|
|
825
|
-
t ? (e.
|
|
828
|
+
t ? (e.be = null) : (e.me = null);
|
|
826
829
|
}
|
|
827
830
|
function childId(e, t) {
|
|
828
831
|
let n = e;
|
|
829
|
-
while (n.
|
|
832
|
+
while (n.Ve && n.i) n = n.i;
|
|
830
833
|
if (n.id != null) return formatId(n.id, t ? n.we++ : n.we);
|
|
831
834
|
throw new Error("Cannot get child id from owner without an id");
|
|
832
835
|
}
|
|
@@ -863,17 +866,17 @@ function createOwner(e) {
|
|
|
863
866
|
const n = e?.transparent ?? false;
|
|
864
867
|
const i = {
|
|
865
868
|
id: e?.id ?? (n ? t?.id : t?.id != null ? getNextChildId(t) : undefined),
|
|
866
|
-
|
|
869
|
+
Ve: n || undefined,
|
|
867
870
|
t: true,
|
|
868
871
|
u: t?.t ? t.u : t,
|
|
869
872
|
De: null,
|
|
870
|
-
|
|
873
|
+
ye: null,
|
|
871
874
|
me: null,
|
|
872
875
|
ce: t?.ce ?? globalQueue,
|
|
873
|
-
|
|
876
|
+
Le: t?.Le || defaultContext,
|
|
874
877
|
we: 0,
|
|
875
|
-
Ve: null,
|
|
876
878
|
be: null,
|
|
879
|
+
ve: null,
|
|
877
880
|
i: t,
|
|
878
881
|
dispose(e = true) {
|
|
879
882
|
disposeChildren(i, e);
|
|
@@ -884,7 +887,7 @@ function createOwner(e) {
|
|
|
884
887
|
if (e === null) {
|
|
885
888
|
t.De = i;
|
|
886
889
|
} else {
|
|
887
|
-
i.
|
|
890
|
+
i.ye = e;
|
|
888
891
|
t.De = i;
|
|
889
892
|
}
|
|
890
893
|
}
|
|
@@ -895,57 +898,59 @@ function createRoot(e, t) {
|
|
|
895
898
|
return runWithOwner(n, () => e(n.dispose));
|
|
896
899
|
}
|
|
897
900
|
function effect(e, t, n, i, r) {
|
|
898
|
-
let
|
|
899
|
-
const
|
|
901
|
+
let o = false;
|
|
902
|
+
const s = computed(r?.render ? t => staleValues(() => e(t)) : e, i, {
|
|
900
903
|
...r,
|
|
901
904
|
equals: () => {
|
|
902
|
-
|
|
903
|
-
if (
|
|
905
|
+
s.ue = !s.q;
|
|
906
|
+
if (o) s.ce.enqueue(s.se, runEffect.bind(s));
|
|
904
907
|
return false;
|
|
905
908
|
},
|
|
906
909
|
lazy: true
|
|
907
910
|
});
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
const n = e !== undefined ? e :
|
|
915
|
-
const i = t !== undefined ? t :
|
|
911
|
+
s.ke = i;
|
|
912
|
+
s.Ue = t;
|
|
913
|
+
s.xe = n;
|
|
914
|
+
s.We = undefined;
|
|
915
|
+
s.se = r?.render ? EFFECT_RENDER : EFFECT_USER;
|
|
916
|
+
s.he = (e, t) => {
|
|
917
|
+
const n = e !== undefined ? e : s.Ee;
|
|
918
|
+
const i = t !== undefined ? t : s.q;
|
|
916
919
|
if (n & STATUS_ERROR) {
|
|
917
920
|
let e = i;
|
|
918
|
-
|
|
919
|
-
if (
|
|
921
|
+
s.ce.notify(s, STATUS_PENDING, 0);
|
|
922
|
+
if (s.se === EFFECT_USER) {
|
|
920
923
|
try {
|
|
921
|
-
return
|
|
922
|
-
?
|
|
923
|
-
|
|
924
|
-
|
|
924
|
+
return s.xe
|
|
925
|
+
? s.xe(e, () => {
|
|
926
|
+
s.We?.();
|
|
927
|
+
s.We = undefined;
|
|
925
928
|
})
|
|
926
929
|
: console.error(e);
|
|
927
930
|
} catch (t) {
|
|
928
931
|
e = t;
|
|
929
932
|
}
|
|
930
933
|
}
|
|
931
|
-
if (!
|
|
932
|
-
} else if (
|
|
934
|
+
if (!s.ce.notify(s, STATUS_ERROR, STATUS_ERROR)) throw e;
|
|
935
|
+
} else if (s.se === EFFECT_RENDER) {
|
|
936
|
+
s.ce.notify(s, STATUS_PENDING | STATUS_ERROR, n, i);
|
|
937
|
+
}
|
|
933
938
|
};
|
|
934
|
-
recompute(
|
|
935
|
-
!r?.defer && (
|
|
936
|
-
|
|
937
|
-
onCleanup(() =>
|
|
939
|
+
recompute(s, true);
|
|
940
|
+
!r?.defer && (s.se === EFFECT_USER ? s.ce.enqueue(s.se, runEffect.bind(s)) : runEffect.call(s));
|
|
941
|
+
o = true;
|
|
942
|
+
onCleanup(() => s.We?.());
|
|
938
943
|
}
|
|
939
944
|
function runEffect() {
|
|
940
945
|
if (!this.ue || this.O & REACTIVE_DISPOSED) return;
|
|
941
|
-
this.
|
|
942
|
-
this.
|
|
946
|
+
this.We?.();
|
|
947
|
+
this.We = undefined;
|
|
943
948
|
try {
|
|
944
|
-
this.
|
|
949
|
+
this.We = this.Ue(this.fe, this.ke);
|
|
945
950
|
} catch (e) {
|
|
946
951
|
if (!this.ce.notify(this, STATUS_ERROR, STATUS_ERROR)) throw e;
|
|
947
952
|
} finally {
|
|
948
|
-
this.
|
|
953
|
+
this.ke = this.fe;
|
|
949
954
|
this.ue = false;
|
|
950
955
|
}
|
|
951
956
|
}
|
|
@@ -958,21 +963,44 @@ function trackedEffect(e, t) {
|
|
|
958
963
|
const n = computed(
|
|
959
964
|
() => {
|
|
960
965
|
try {
|
|
961
|
-
n.
|
|
962
|
-
n.
|
|
963
|
-
n.
|
|
966
|
+
n.We?.();
|
|
967
|
+
n.We = undefined;
|
|
968
|
+
n.We = staleValues(e) || undefined;
|
|
964
969
|
} finally {
|
|
965
970
|
}
|
|
966
971
|
},
|
|
967
972
|
undefined,
|
|
968
973
|
{ ...t, lazy: true }
|
|
969
974
|
);
|
|
970
|
-
n.
|
|
975
|
+
n.We = undefined;
|
|
971
976
|
n.ue = true;
|
|
972
|
-
n.
|
|
973
|
-
n.
|
|
977
|
+
n.se = EFFECT_TRACKED;
|
|
978
|
+
n.ae = run;
|
|
974
979
|
n.ce.enqueue(EFFECT_USER, run);
|
|
975
|
-
onCleanup(() => n.
|
|
980
|
+
onCleanup(() => n.We?.());
|
|
981
|
+
}
|
|
982
|
+
let externalSourceConfig = null;
|
|
983
|
+
function enableExternalSource(e) {
|
|
984
|
+
const { factory: t, untrack: n = e => e() } = e;
|
|
985
|
+
if (externalSourceConfig) {
|
|
986
|
+
const { factory: e, untrack: i } = externalSourceConfig;
|
|
987
|
+
externalSourceConfig = {
|
|
988
|
+
factory: (n, i) => {
|
|
989
|
+
const r = e(n, i);
|
|
990
|
+
const o = t(e => r.track(e), i);
|
|
991
|
+
return {
|
|
992
|
+
track: e => o.track(e),
|
|
993
|
+
dispose() {
|
|
994
|
+
o.dispose();
|
|
995
|
+
r.dispose();
|
|
996
|
+
}
|
|
997
|
+
};
|
|
998
|
+
},
|
|
999
|
+
untrack: e => i(() => n(e))
|
|
1000
|
+
};
|
|
1001
|
+
} else {
|
|
1002
|
+
externalSourceConfig = { factory: t, untrack: n };
|
|
1003
|
+
}
|
|
976
1004
|
}
|
|
977
1005
|
GlobalQueue.K = recompute;
|
|
978
1006
|
GlobalQueue.Y = disposeChildren;
|
|
@@ -988,7 +1016,7 @@ let snapshotCaptureActive = false;
|
|
|
988
1016
|
let snapshotSources = null;
|
|
989
1017
|
function ownerInSnapshotScope(e) {
|
|
990
1018
|
while (e) {
|
|
991
|
-
if (e.
|
|
1019
|
+
if (e.He) return true;
|
|
992
1020
|
e = e.i;
|
|
993
1021
|
}
|
|
994
1022
|
return false;
|
|
@@ -998,32 +1026,32 @@ function setSnapshotCapture(e) {
|
|
|
998
1026
|
if (e && !snapshotSources) snapshotSources = new Set();
|
|
999
1027
|
}
|
|
1000
1028
|
function markSnapshotScope(e) {
|
|
1001
|
-
e.
|
|
1029
|
+
e.He = true;
|
|
1002
1030
|
}
|
|
1003
1031
|
function releaseSnapshotScope(e) {
|
|
1004
|
-
e.
|
|
1032
|
+
e.He = false;
|
|
1005
1033
|
releaseSubtree(e);
|
|
1006
1034
|
schedule();
|
|
1007
1035
|
}
|
|
1008
1036
|
function releaseSubtree(e) {
|
|
1009
1037
|
let t = e.De;
|
|
1010
1038
|
while (t) {
|
|
1011
|
-
if (t.
|
|
1012
|
-
t = t.
|
|
1039
|
+
if (t.He) {
|
|
1040
|
+
t = t.ye;
|
|
1013
1041
|
continue;
|
|
1014
1042
|
}
|
|
1015
1043
|
if (t.L) {
|
|
1016
1044
|
const e = t;
|
|
1017
|
-
e.
|
|
1045
|
+
e.oe = false;
|
|
1018
1046
|
if (e.O & REACTIVE_SNAPSHOT_STALE) {
|
|
1019
1047
|
e.O &= ~REACTIVE_SNAPSHOT_STALE;
|
|
1020
1048
|
e.O |= REACTIVE_DIRTY;
|
|
1021
|
-
if (dirtyQueue.
|
|
1049
|
+
if (dirtyQueue.P > e.o) dirtyQueue.P = e.o;
|
|
1022
1050
|
insertIntoHeap(e, dirtyQueue);
|
|
1023
1051
|
}
|
|
1024
1052
|
}
|
|
1025
1053
|
releaseSubtree(t);
|
|
1026
|
-
t = t.
|
|
1054
|
+
t = t.ye;
|
|
1027
1055
|
}
|
|
1028
1056
|
}
|
|
1029
1057
|
function clearSnapshots() {
|
|
@@ -1037,7 +1065,7 @@ function clearSnapshots() {
|
|
|
1037
1065
|
snapshotCaptureActive = false;
|
|
1038
1066
|
}
|
|
1039
1067
|
function recompute(e, t = false) {
|
|
1040
|
-
const n = e.
|
|
1068
|
+
const n = e.se;
|
|
1041
1069
|
if (!t) {
|
|
1042
1070
|
if (e.ne && (!n || activeTransition) && activeTransition !== e.ne)
|
|
1043
1071
|
globalQueue.initTransition(e.ne);
|
|
@@ -1045,25 +1073,25 @@ function recompute(e, t = false) {
|
|
|
1045
1073
|
if (e.ne || n === EFFECT_TRACKED) disposeChildren(e);
|
|
1046
1074
|
else {
|
|
1047
1075
|
markDisposal(e);
|
|
1048
|
-
e.
|
|
1049
|
-
e.
|
|
1076
|
+
e.be = e.me;
|
|
1077
|
+
e.ve = e.De;
|
|
1050
1078
|
e.me = null;
|
|
1051
1079
|
e.De = null;
|
|
1052
1080
|
e.we = 0;
|
|
1053
1081
|
}
|
|
1054
1082
|
}
|
|
1055
1083
|
const i = !!(e.O & REACTIVE_OPTIMISTIC_DIRTY);
|
|
1056
|
-
const r =
|
|
1057
|
-
const
|
|
1058
|
-
const
|
|
1084
|
+
const r = e.Te !== undefined && e.Te !== NOT_PENDING;
|
|
1085
|
+
const o = !!(e.Ee & STATUS_PENDING);
|
|
1086
|
+
const s = context;
|
|
1059
1087
|
context = e;
|
|
1060
|
-
e.
|
|
1088
|
+
e.Ce = null;
|
|
1061
1089
|
e.O = REACTIVE_RECOMPUTING_DEPS;
|
|
1062
1090
|
e.J = clock;
|
|
1063
|
-
let u = e.
|
|
1091
|
+
let u = e.le === NOT_PENDING ? e.fe : e.le;
|
|
1064
1092
|
let c = e.o;
|
|
1065
|
-
let
|
|
1066
|
-
let
|
|
1093
|
+
let a = tracking;
|
|
1094
|
+
let l = currentOptimisticLane;
|
|
1067
1095
|
tracking = true;
|
|
1068
1096
|
if (i) {
|
|
1069
1097
|
const t = resolveLane(e);
|
|
@@ -1075,15 +1103,15 @@ function recompute(e, t = false) {
|
|
|
1075
1103
|
const t = resolveLane(e);
|
|
1076
1104
|
if (t) {
|
|
1077
1105
|
t.U.delete(e);
|
|
1078
|
-
updatePendingSignal(t.
|
|
1106
|
+
updatePendingSignal(t.de);
|
|
1079
1107
|
}
|
|
1080
1108
|
} catch (t) {
|
|
1081
1109
|
if (t instanceof NotReadyError && currentOptimisticLane) {
|
|
1082
1110
|
const t = findLane(currentOptimisticLane);
|
|
1083
|
-
if (t.
|
|
1111
|
+
if (t.de !== e) {
|
|
1084
1112
|
t.U.add(e);
|
|
1085
1113
|
e.ie = t;
|
|
1086
|
-
updatePendingSignal(t.
|
|
1114
|
+
updatePendingSignal(t.de);
|
|
1087
1115
|
}
|
|
1088
1116
|
}
|
|
1089
1117
|
notifyStatus(
|
|
@@ -1094,51 +1122,50 @@ function recompute(e, t = false) {
|
|
|
1094
1122
|
t instanceof NotReadyError ? e.ie : undefined
|
|
1095
1123
|
);
|
|
1096
1124
|
} finally {
|
|
1097
|
-
tracking =
|
|
1125
|
+
tracking = a;
|
|
1098
1126
|
e.O = REACTIVE_NONE | (t ? e.O & REACTIVE_SNAPSHOT_STALE : 0);
|
|
1099
|
-
context =
|
|
1127
|
+
context = s;
|
|
1100
1128
|
}
|
|
1101
|
-
if (!e.
|
|
1102
|
-
const
|
|
1103
|
-
let
|
|
1104
|
-
if (
|
|
1129
|
+
if (!e.q) {
|
|
1130
|
+
const s = e.Ce;
|
|
1131
|
+
let a = s !== null ? s.D : e.C;
|
|
1132
|
+
if (a !== null) {
|
|
1105
1133
|
do {
|
|
1106
|
-
|
|
1107
|
-
} while (
|
|
1108
|
-
if (
|
|
1134
|
+
a = unlinkSubs(a);
|
|
1135
|
+
} while (a !== null);
|
|
1136
|
+
if (s !== null) s.D = null;
|
|
1109
1137
|
else e.C = null;
|
|
1110
1138
|
}
|
|
1111
|
-
const
|
|
1112
|
-
const f = !e.
|
|
1139
|
+
const l = r ? e.Te : e.le === NOT_PENDING ? e.fe : e.le;
|
|
1140
|
+
const f = !e.Ie || !e.Ie(l, u);
|
|
1113
1141
|
if (f) {
|
|
1114
|
-
const
|
|
1115
|
-
if (t || (n && activeTransition !== e.ne) || i)
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
}
|
|
1122
|
-
if (
|
|
1123
|
-
|
|
1124
|
-
}
|
|
1142
|
+
const s = r ? e.Te : undefined;
|
|
1143
|
+
if (t || (n && activeTransition !== e.ne) || i) {
|
|
1144
|
+
e.fe = u;
|
|
1145
|
+
if (r && i) {
|
|
1146
|
+
e.Te = u;
|
|
1147
|
+
e.le = u;
|
|
1148
|
+
}
|
|
1149
|
+
} else e.le = u;
|
|
1150
|
+
if (r && !i && o && !e.Oe) e.Te = u;
|
|
1151
|
+
if (!r || i || e.Te !== s) insertSubs(e, i || r);
|
|
1125
1152
|
} else if (r) {
|
|
1126
|
-
e.
|
|
1153
|
+
e.le = u;
|
|
1127
1154
|
} else if (e.o != c) {
|
|
1128
1155
|
for (let t = e.I; t !== null; t = t.p) {
|
|
1129
1156
|
insertIntoHeapHeight(t.h, t.h.O & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
1130
1157
|
}
|
|
1131
1158
|
}
|
|
1132
1159
|
}
|
|
1133
|
-
currentOptimisticLane =
|
|
1134
|
-
(!t || e.Ee & STATUS_PENDING) && !e.ne && !(activeTransition &&
|
|
1160
|
+
currentOptimisticLane = l;
|
|
1161
|
+
(!t || e.Ee & STATUS_PENDING) && !e.ne && !(activeTransition && r) && globalQueue.M.push(e);
|
|
1135
1162
|
e.ne && n && activeTransition !== e.ne && runInTransition(e.ne, () => recompute(e));
|
|
1136
1163
|
}
|
|
1137
1164
|
function updateIfNecessary(e) {
|
|
1138
1165
|
if (e.O & REACTIVE_CHECK) {
|
|
1139
1166
|
for (let t = e.C; t; t = t.D) {
|
|
1140
|
-
const n = t.
|
|
1141
|
-
const i = n.
|
|
1167
|
+
const n = t.m;
|
|
1168
|
+
const i = n.V || n;
|
|
1142
1169
|
if (i.L) {
|
|
1143
1170
|
updateIfNecessary(i);
|
|
1144
1171
|
}
|
|
@@ -1147,7 +1174,7 @@ function updateIfNecessary(e) {
|
|
|
1147
1174
|
}
|
|
1148
1175
|
}
|
|
1149
1176
|
}
|
|
1150
|
-
if (e.O & (REACTIVE_DIRTY | REACTIVE_OPTIMISTIC_DIRTY) || (e.
|
|
1177
|
+
if (e.O & (REACTIVE_DIRTY | REACTIVE_OPTIMISTIC_DIRTY) || (e.q && e.J < clock && !e._e)) {
|
|
1151
1178
|
recompute(e);
|
|
1152
1179
|
}
|
|
1153
1180
|
e.O = REACTIVE_NONE | (e.O & REACTIVE_SNAPSHOT_STALE);
|
|
@@ -1156,13 +1183,13 @@ function computed(e, t, n) {
|
|
|
1156
1183
|
const i = n?.transparent ?? false;
|
|
1157
1184
|
const r = {
|
|
1158
1185
|
id: n?.id ?? (i ? context?.id : context?.id != null ? getNextChildId(context) : undefined),
|
|
1159
|
-
|
|
1160
|
-
|
|
1186
|
+
Ve: i || undefined,
|
|
1187
|
+
Ie: n?.equals != null ? n.equals : isEqual,
|
|
1161
1188
|
Ge: !!n?.pureWrite,
|
|
1162
1189
|
ge: n?.unobserved,
|
|
1163
1190
|
me: null,
|
|
1164
1191
|
ce: context?.ce ?? globalQueue,
|
|
1165
|
-
|
|
1192
|
+
Le: context?.Le ?? defaultContext,
|
|
1166
1193
|
we: 0,
|
|
1167
1194
|
L: e,
|
|
1168
1195
|
fe: t,
|
|
@@ -1171,34 +1198,45 @@ function computed(e, t, n) {
|
|
|
1171
1198
|
S: undefined,
|
|
1172
1199
|
T: null,
|
|
1173
1200
|
C: null,
|
|
1174
|
-
|
|
1201
|
+
Ce: null,
|
|
1175
1202
|
I: null,
|
|
1176
1203
|
Ne: null,
|
|
1177
1204
|
i: context,
|
|
1178
|
-
|
|
1205
|
+
ye: null,
|
|
1179
1206
|
De: null,
|
|
1180
1207
|
O: n?.lazy ? REACTIVE_LAZY : REACTIVE_NONE,
|
|
1181
1208
|
Ee: STATUS_UNINITIALIZED,
|
|
1182
1209
|
J: clock,
|
|
1183
|
-
|
|
1184
|
-
Ve: null,
|
|
1210
|
+
le: NOT_PENDING,
|
|
1185
1211
|
be: null,
|
|
1186
|
-
|
|
1212
|
+
ve: null,
|
|
1213
|
+
_e: null,
|
|
1187
1214
|
ne: null
|
|
1188
1215
|
};
|
|
1189
1216
|
r.T = r;
|
|
1190
|
-
const
|
|
1217
|
+
const o = context?.t ? context.u : context;
|
|
1191
1218
|
if (context) {
|
|
1192
1219
|
const e = context.De;
|
|
1193
1220
|
if (e === null) {
|
|
1194
1221
|
context.De = r;
|
|
1195
1222
|
} else {
|
|
1196
|
-
r.
|
|
1223
|
+
r.ye = e;
|
|
1197
1224
|
context.De = r;
|
|
1198
1225
|
}
|
|
1199
1226
|
}
|
|
1200
|
-
if (
|
|
1201
|
-
if (snapshotCaptureActive && ownerInSnapshotScope(context)) r.
|
|
1227
|
+
if (o) r.o = o.o + 1;
|
|
1228
|
+
if (snapshotCaptureActive && ownerInSnapshotScope(context)) r.oe = true;
|
|
1229
|
+
if (externalSourceConfig) {
|
|
1230
|
+
const e = signal(undefined, { equals: false, pureWrite: true });
|
|
1231
|
+
const t = externalSourceConfig.factory(r.L, () => {
|
|
1232
|
+
setSignal(e, undefined);
|
|
1233
|
+
});
|
|
1234
|
+
onCleanup(() => t.dispose());
|
|
1235
|
+
r.L = n => {
|
|
1236
|
+
read(e);
|
|
1237
|
+
return t.track(n);
|
|
1238
|
+
};
|
|
1239
|
+
}
|
|
1202
1240
|
!n?.lazy && recompute(r, true);
|
|
1203
1241
|
if (snapshotCaptureActive && !n?.lazy) {
|
|
1204
1242
|
if (!(r.Ee & STATUS_PENDING)) {
|
|
@@ -1210,19 +1248,19 @@ function computed(e, t, n) {
|
|
|
1210
1248
|
}
|
|
1211
1249
|
function signal(e, t, n = null) {
|
|
1212
1250
|
const i = {
|
|
1213
|
-
|
|
1251
|
+
Ie: t?.equals != null ? t.equals : isEqual,
|
|
1214
1252
|
Ge: !!t?.pureWrite,
|
|
1215
1253
|
ge: t?.unobserved,
|
|
1216
1254
|
fe: e,
|
|
1217
1255
|
I: null,
|
|
1218
1256
|
Ne: null,
|
|
1219
1257
|
J: clock,
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1258
|
+
V: n,
|
|
1259
|
+
N: n?.A || null,
|
|
1260
|
+
le: NOT_PENDING
|
|
1223
1261
|
};
|
|
1224
1262
|
n && (n.A = i);
|
|
1225
|
-
if (snapshotCaptureActive && !i.Ge) {
|
|
1263
|
+
if (snapshotCaptureActive && !i.Ge && !((n?.Ee ?? 0) & STATUS_PENDING)) {
|
|
1226
1264
|
i.re = e === undefined ? NO_SNAPSHOT : e;
|
|
1227
1265
|
snapshotSources.add(i);
|
|
1228
1266
|
}
|
|
@@ -1230,22 +1268,23 @@ function signal(e, t, n = null) {
|
|
|
1230
1268
|
}
|
|
1231
1269
|
function optimisticSignal(e, t) {
|
|
1232
1270
|
const n = signal(e, t);
|
|
1233
|
-
n.
|
|
1271
|
+
n.Te = NOT_PENDING;
|
|
1234
1272
|
return n;
|
|
1235
1273
|
}
|
|
1236
1274
|
function optimisticComputed(e, t, n) {
|
|
1237
1275
|
const i = computed(e, t, n);
|
|
1238
|
-
i.
|
|
1276
|
+
i.Te = NOT_PENDING;
|
|
1239
1277
|
return i;
|
|
1240
1278
|
}
|
|
1241
1279
|
function isEqual(e, t) {
|
|
1242
1280
|
return e === t;
|
|
1243
1281
|
}
|
|
1244
1282
|
function untrack(e, t) {
|
|
1245
|
-
if (!tracking && true) return e();
|
|
1283
|
+
if (!externalSourceConfig && !tracking && true) return e();
|
|
1246
1284
|
const n = tracking;
|
|
1247
1285
|
tracking = false;
|
|
1248
1286
|
try {
|
|
1287
|
+
if (externalSourceConfig) return externalSourceConfig.untrack(e);
|
|
1249
1288
|
return e();
|
|
1250
1289
|
} finally {
|
|
1251
1290
|
tracking = n;
|
|
@@ -1256,27 +1295,28 @@ function read(e) {
|
|
|
1256
1295
|
const t = getLatestValueComputed(e);
|
|
1257
1296
|
const n = latestReadActive;
|
|
1258
1297
|
latestReadActive = false;
|
|
1259
|
-
|
|
1298
|
+
const i = e.Te !== undefined && e.Te !== NOT_PENDING ? e.Te : e.fe;
|
|
1299
|
+
let r;
|
|
1260
1300
|
try {
|
|
1261
|
-
|
|
1262
|
-
} catch (
|
|
1263
|
-
if (!context &&
|
|
1264
|
-
throw
|
|
1301
|
+
r = read(t);
|
|
1302
|
+
} catch (e) {
|
|
1303
|
+
if (!context && e instanceof NotReadyError) return i;
|
|
1304
|
+
throw e;
|
|
1265
1305
|
} finally {
|
|
1266
1306
|
latestReadActive = n;
|
|
1267
1307
|
}
|
|
1268
|
-
if (t.Ee & STATUS_PENDING) return
|
|
1308
|
+
if (t.Ee & STATUS_PENDING) return i;
|
|
1269
1309
|
if (stale && currentOptimisticLane && t.ie) {
|
|
1270
|
-
const
|
|
1271
|
-
const
|
|
1272
|
-
if (
|
|
1273
|
-
return
|
|
1310
|
+
const e = findLane(t.ie);
|
|
1311
|
+
const n = findLane(currentOptimisticLane);
|
|
1312
|
+
if (e !== n && e.U.size > 0) {
|
|
1313
|
+
return i;
|
|
1274
1314
|
}
|
|
1275
1315
|
}
|
|
1276
|
-
return
|
|
1316
|
+
return r;
|
|
1277
1317
|
}
|
|
1278
1318
|
if (pendingCheckActive) {
|
|
1279
|
-
const t = e.
|
|
1319
|
+
const t = e.V || e;
|
|
1280
1320
|
const n = getPendingSignal(t);
|
|
1281
1321
|
const i = pendingCheckActive;
|
|
1282
1322
|
pendingCheckActive = false;
|
|
@@ -1293,13 +1333,13 @@ function read(e) {
|
|
|
1293
1333
|
e.O &= ~REACTIVE_LAZY;
|
|
1294
1334
|
recompute(e, true);
|
|
1295
1335
|
}
|
|
1296
|
-
const n = e.
|
|
1336
|
+
const n = e.V || e;
|
|
1297
1337
|
if (t && tracking) {
|
|
1298
1338
|
if (e.L && e.O & REACTIVE_DISPOSED) recompute(e);
|
|
1299
1339
|
link(e, t);
|
|
1300
1340
|
if (n.L) {
|
|
1301
1341
|
const i = e.O & REACTIVE_ZOMBIE;
|
|
1302
|
-
if (n.o >= (i ? zombieQueue.
|
|
1342
|
+
if (n.o >= (i ? zombieQueue.P : dirtyQueue.P)) {
|
|
1303
1343
|
markNode(t);
|
|
1304
1344
|
markHeap(i ? zombieQueue : dirtyQueue);
|
|
1305
1345
|
updateIfNecessary(n);
|
|
@@ -1316,74 +1356,73 @@ function read(e) {
|
|
|
1316
1356
|
const i = n.ie;
|
|
1317
1357
|
const r = findLane(currentOptimisticLane);
|
|
1318
1358
|
if (i && findLane(i) === r && !hasActiveOverride(n)) {
|
|
1319
|
-
if (!tracking) link(e, t);
|
|
1320
|
-
throw n.
|
|
1359
|
+
if (!tracking && e !== t) link(e, t);
|
|
1360
|
+
throw n.q;
|
|
1321
1361
|
}
|
|
1322
1362
|
} else {
|
|
1323
|
-
if (!tracking) link(e, t);
|
|
1324
|
-
throw n.
|
|
1363
|
+
if (!tracking && e !== t) link(e, t);
|
|
1364
|
+
throw n.q;
|
|
1325
1365
|
}
|
|
1326
1366
|
} else if (!t && n.Ee & STATUS_UNINITIALIZED) {
|
|
1327
|
-
throw n.
|
|
1367
|
+
throw n.q;
|
|
1328
1368
|
}
|
|
1329
1369
|
}
|
|
1330
1370
|
if (e.L && e.Ee & STATUS_ERROR) {
|
|
1331
1371
|
if (e.J < clock) {
|
|
1332
1372
|
recompute(e, true);
|
|
1333
1373
|
return read(e);
|
|
1334
|
-
} else throw e.
|
|
1374
|
+
} else throw e.q;
|
|
1335
1375
|
}
|
|
1336
|
-
if (snapshotCaptureActive && t && t.
|
|
1376
|
+
if (snapshotCaptureActive && t && t.oe) {
|
|
1337
1377
|
const n = e.re;
|
|
1338
1378
|
if (n !== undefined) {
|
|
1339
1379
|
const i = n === NO_SNAPSHOT ? undefined : n;
|
|
1340
|
-
const r = e.
|
|
1380
|
+
const r = e.le !== NOT_PENDING ? e.le : e.fe;
|
|
1341
1381
|
if (r !== i) t.O |= REACTIVE_SNAPSHOT_STALE;
|
|
1342
1382
|
return i;
|
|
1343
1383
|
}
|
|
1344
1384
|
}
|
|
1385
|
+
if (e.Te !== undefined && e.Te !== NOT_PENDING) return e.Te;
|
|
1345
1386
|
return !t ||
|
|
1346
|
-
(currentOptimisticLane !== null &&
|
|
1347
|
-
|
|
1387
|
+
(currentOptimisticLane !== null &&
|
|
1388
|
+
(e.Te !== undefined || e.ie || n === e || !!(n.Ee & STATUS_PENDING))) ||
|
|
1389
|
+
e.le === NOT_PENDING ||
|
|
1348
1390
|
(stale && e.ne && activeTransition !== e.ne)
|
|
1349
1391
|
? e.fe
|
|
1350
|
-
: e.
|
|
1392
|
+
: e.le;
|
|
1351
1393
|
}
|
|
1352
1394
|
function setSignal(e, t) {
|
|
1353
1395
|
if (e.ne && activeTransition !== e.ne) globalQueue.initTransition(e.ne);
|
|
1354
|
-
const n = e.
|
|
1355
|
-
const i =
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1396
|
+
const n = e.Te !== undefined && !projectionWriteActive;
|
|
1397
|
+
const i = e.Te !== undefined && e.Te !== NOT_PENDING;
|
|
1398
|
+
const r = n ? (i ? e.Te : e.fe) : e.le === NOT_PENDING ? e.fe : e.le;
|
|
1399
|
+
if (typeof t === "function") t = t(r);
|
|
1400
|
+
const o = !e.Ie || !e.Ie(r, t) || !!(e.Ee & STATUS_UNINITIALIZED);
|
|
1401
|
+
if (!o) {
|
|
1402
|
+
if (n && i && e.L) {
|
|
1360
1403
|
insertSubs(e, true);
|
|
1361
1404
|
schedule();
|
|
1362
1405
|
}
|
|
1363
1406
|
return t;
|
|
1364
1407
|
}
|
|
1365
1408
|
if (n) {
|
|
1366
|
-
const n =
|
|
1367
|
-
if (e.ne
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
if (e.ae === NOT_PENDING) {
|
|
1371
|
-
e.ae = e.fe;
|
|
1372
|
-
}
|
|
1373
|
-
if (!n) {
|
|
1409
|
+
const n = e.Te === NOT_PENDING;
|
|
1410
|
+
if (!n && e.ne) globalQueue.initTransition(e.ne);
|
|
1411
|
+
if (n) {
|
|
1412
|
+
e.le = e.fe;
|
|
1374
1413
|
globalQueue.$.push(e);
|
|
1375
1414
|
}
|
|
1376
|
-
e.Oe =
|
|
1415
|
+
e.Oe = true;
|
|
1377
1416
|
const i = getOrCreateLane(e);
|
|
1378
1417
|
e.ie = i;
|
|
1379
|
-
e.
|
|
1418
|
+
e.Te = t;
|
|
1380
1419
|
} else {
|
|
1381
|
-
if (e.
|
|
1382
|
-
e.
|
|
1420
|
+
if (e.le === NOT_PENDING) globalQueue.M.push(e);
|
|
1421
|
+
e.le = t;
|
|
1383
1422
|
}
|
|
1384
1423
|
updatePendingSignal(e);
|
|
1385
|
-
if (e.
|
|
1386
|
-
setSignal(e.
|
|
1424
|
+
if (e.pe) {
|
|
1425
|
+
setSignal(e.pe, t);
|
|
1387
1426
|
}
|
|
1388
1427
|
e.J = clock;
|
|
1389
1428
|
insertSubs(e, n);
|
|
@@ -1403,32 +1442,32 @@ function runWithOwner(e, t) {
|
|
|
1403
1442
|
}
|
|
1404
1443
|
}
|
|
1405
1444
|
function getPendingSignal(e) {
|
|
1406
|
-
if (!e.
|
|
1407
|
-
e.
|
|
1408
|
-
if (e.
|
|
1409
|
-
e.
|
|
1445
|
+
if (!e.Qe) {
|
|
1446
|
+
e.Qe = optimisticSignal(false, { pureWrite: true });
|
|
1447
|
+
if (e.Se) {
|
|
1448
|
+
e.Qe.Se = e;
|
|
1410
1449
|
}
|
|
1411
|
-
if (computePendingState(e)) setSignal(e.
|
|
1450
|
+
if (computePendingState(e)) setSignal(e.Qe, true);
|
|
1412
1451
|
}
|
|
1413
|
-
return e.
|
|
1452
|
+
return e.Qe;
|
|
1414
1453
|
}
|
|
1415
1454
|
function computePendingState(e) {
|
|
1416
1455
|
const t = e;
|
|
1417
|
-
if (e.
|
|
1456
|
+
if (e.Te !== undefined && e.Te !== NOT_PENDING) {
|
|
1418
1457
|
if (t.Ee & STATUS_PENDING && !(t.Ee & STATUS_UNINITIALIZED)) return true;
|
|
1419
|
-
if (e.
|
|
1458
|
+
if (e.Se) {
|
|
1420
1459
|
const t = e.ie ? findLane(e.ie) : null;
|
|
1421
1460
|
return !!(t && t.U.size > 0);
|
|
1422
1461
|
}
|
|
1423
1462
|
return true;
|
|
1424
1463
|
}
|
|
1425
|
-
if (e.
|
|
1464
|
+
if (e.le !== NOT_PENDING && !(t.Ee & STATUS_UNINITIALIZED)) return true;
|
|
1426
1465
|
return !!(t.Ee & STATUS_PENDING && !(t.Ee & STATUS_UNINITIALIZED));
|
|
1427
1466
|
}
|
|
1428
1467
|
function updatePendingSignal(e) {
|
|
1429
|
-
if (e.
|
|
1468
|
+
if (e.Qe) {
|
|
1430
1469
|
const t = computePendingState(e);
|
|
1431
|
-
const n = e.
|
|
1470
|
+
const n = e.Qe;
|
|
1432
1471
|
setSignal(n, t);
|
|
1433
1472
|
if (!t && n.ie) {
|
|
1434
1473
|
const t = resolveLane(e);
|
|
@@ -1444,20 +1483,20 @@ function updatePendingSignal(e) {
|
|
|
1444
1483
|
}
|
|
1445
1484
|
}
|
|
1446
1485
|
function getLatestValueComputed(e) {
|
|
1447
|
-
if (!e.
|
|
1486
|
+
if (!e.pe) {
|
|
1448
1487
|
const t = latestReadActive;
|
|
1449
1488
|
latestReadActive = false;
|
|
1450
1489
|
const n = pendingCheckActive;
|
|
1451
1490
|
pendingCheckActive = false;
|
|
1452
1491
|
const i = context;
|
|
1453
1492
|
context = null;
|
|
1454
|
-
e.
|
|
1455
|
-
e.
|
|
1493
|
+
e.pe = optimisticComputed(() => read(e));
|
|
1494
|
+
e.pe.Se = e;
|
|
1456
1495
|
context = i;
|
|
1457
1496
|
pendingCheckActive = n;
|
|
1458
1497
|
latestReadActive = t;
|
|
1459
1498
|
}
|
|
1460
|
-
return e.
|
|
1499
|
+
return e.pe;
|
|
1461
1500
|
}
|
|
1462
1501
|
function staleValues(e, t = true) {
|
|
1463
1502
|
const n = stale;
|
|
@@ -1518,7 +1557,7 @@ function getContext(e, t = getOwner()) {
|
|
|
1518
1557
|
if (!t) {
|
|
1519
1558
|
throw new NoOwnerError();
|
|
1520
1559
|
}
|
|
1521
|
-
const n = hasContext(e, t) ? t.
|
|
1560
|
+
const n = hasContext(e, t) ? t.Le[e.id] : e.defaultValue;
|
|
1522
1561
|
if (isUndefined(n)) {
|
|
1523
1562
|
throw new ContextNotFoundError();
|
|
1524
1563
|
}
|
|
@@ -1528,10 +1567,10 @@ function setContext(e, t, n = getOwner()) {
|
|
|
1528
1567
|
if (!n) {
|
|
1529
1568
|
throw new NoOwnerError();
|
|
1530
1569
|
}
|
|
1531
|
-
n.
|
|
1570
|
+
n.Le = { ...n.Le, [e.id]: isUndefined(t) ? e.defaultValue : t };
|
|
1532
1571
|
}
|
|
1533
1572
|
function hasContext(e, t) {
|
|
1534
|
-
return !isUndefined(t?.
|
|
1573
|
+
return !isUndefined(t?.Le[e.id]);
|
|
1535
1574
|
}
|
|
1536
1575
|
function isUndefined(e) {
|
|
1537
1576
|
return typeof e === "undefined";
|
|
@@ -1547,13 +1586,13 @@ function action(e) {
|
|
|
1547
1586
|
new Promise((n, i) => {
|
|
1548
1587
|
const r = e(...t);
|
|
1549
1588
|
globalQueue.initTransition();
|
|
1550
|
-
let
|
|
1551
|
-
|
|
1589
|
+
let o = activeTransition;
|
|
1590
|
+
o.ee.push(r);
|
|
1552
1591
|
const done = (e, t) => {
|
|
1553
|
-
|
|
1554
|
-
const
|
|
1555
|
-
if (
|
|
1556
|
-
setActiveTransition(
|
|
1592
|
+
o = currentTransition(o);
|
|
1593
|
+
const s = o.ee.indexOf(r);
|
|
1594
|
+
if (s >= 0) o.ee.splice(s, 1);
|
|
1595
|
+
setActiveTransition(o);
|
|
1557
1596
|
schedule();
|
|
1558
1597
|
t ? i(t) : n(e);
|
|
1559
1598
|
};
|
|
@@ -1565,32 +1604,37 @@ function action(e) {
|
|
|
1565
1604
|
return done(undefined, e);
|
|
1566
1605
|
}
|
|
1567
1606
|
if (n instanceof Promise)
|
|
1568
|
-
return void n.then(run, e => restoreTransition(
|
|
1607
|
+
return void n.then(run, e => restoreTransition(o, () => step(e, true)));
|
|
1569
1608
|
run(n);
|
|
1570
1609
|
};
|
|
1571
1610
|
const run = e => {
|
|
1572
1611
|
if (e.done) return done(e.value);
|
|
1573
1612
|
if (e.value instanceof Promise)
|
|
1574
1613
|
return void e.value.then(
|
|
1575
|
-
e => restoreTransition(
|
|
1576
|
-
e => restoreTransition(
|
|
1614
|
+
e => restoreTransition(o, () => step(e)),
|
|
1615
|
+
e => restoreTransition(o, () => step(e, true))
|
|
1577
1616
|
);
|
|
1578
|
-
restoreTransition(
|
|
1617
|
+
restoreTransition(o, () => step(e.value));
|
|
1579
1618
|
};
|
|
1580
1619
|
step();
|
|
1581
1620
|
});
|
|
1582
1621
|
}
|
|
1622
|
+
function accessor(e) {
|
|
1623
|
+
const t = read.bind(null, e);
|
|
1624
|
+
t.$r = true;
|
|
1625
|
+
return t;
|
|
1626
|
+
}
|
|
1583
1627
|
function createSignal(e, t, n) {
|
|
1584
1628
|
if (typeof e === "function") {
|
|
1585
1629
|
const i = computed(e, t, n);
|
|
1586
|
-
return [
|
|
1630
|
+
return [accessor(i), setSignal.bind(null, i)];
|
|
1587
1631
|
}
|
|
1588
1632
|
const i = signal(e, t);
|
|
1589
|
-
return [
|
|
1633
|
+
return [accessor(i), setSignal.bind(null, i)];
|
|
1590
1634
|
}
|
|
1591
1635
|
function createMemo(e, t, n) {
|
|
1592
1636
|
let i = computed(e, t, n);
|
|
1593
|
-
return
|
|
1637
|
+
return accessor(i);
|
|
1594
1638
|
}
|
|
1595
1639
|
function createEffect(e, t, n, i) {
|
|
1596
1640
|
effect(e, t.effect || t, t.error, n, i);
|
|
@@ -1638,7 +1682,7 @@ function resolve(e) {
|
|
|
1638
1682
|
}
|
|
1639
1683
|
function createOptimistic(e, t, n) {
|
|
1640
1684
|
const i = typeof e === "function" ? optimisticComputed(e, t, n) : optimisticSignal(e, t);
|
|
1641
|
-
return [
|
|
1685
|
+
return [accessor(i), setSignal.bind(null, i)];
|
|
1642
1686
|
}
|
|
1643
1687
|
function onSettled(e) {
|
|
1644
1688
|
getOwner()
|
|
@@ -1660,128 +1704,128 @@ function getAllKeys(e, t, n) {
|
|
|
1660
1704
|
const r = Object.keys(n);
|
|
1661
1705
|
return Array.from(new Set([...i, ...r]));
|
|
1662
1706
|
}
|
|
1663
|
-
function applyState(e, t, n
|
|
1664
|
-
const
|
|
1665
|
-
if (!
|
|
1666
|
-
const
|
|
1667
|
-
const o =
|
|
1668
|
-
const
|
|
1669
|
-
let
|
|
1670
|
-
if (e ===
|
|
1671
|
-
(
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
if (Array.isArray(
|
|
1707
|
+
function applyState(e, t, n) {
|
|
1708
|
+
const i = t?.[$TARGET];
|
|
1709
|
+
if (!i) return;
|
|
1710
|
+
const r = i[STORE_VALUE];
|
|
1711
|
+
const o = i[STORE_OVERRIDE];
|
|
1712
|
+
const s = i[STORE_OPTIMISTIC_OVERRIDE];
|
|
1713
|
+
let u = i[STORE_NODE];
|
|
1714
|
+
if (e === r && !o && !s) return;
|
|
1715
|
+
(i[STORE_LOOKUP] || storeLookup).set(e, i[$PROXY]);
|
|
1716
|
+
i[STORE_VALUE] = e;
|
|
1717
|
+
i[STORE_OVERRIDE] = undefined;
|
|
1718
|
+
if (Array.isArray(r)) {
|
|
1675
1719
|
let t = false;
|
|
1676
|
-
const
|
|
1677
|
-
if (e.length &&
|
|
1678
|
-
let a, f, E, T, d, S, R
|
|
1720
|
+
const c = getOverrideValue(r, o, u, "length", s);
|
|
1721
|
+
if (e.length && c && e[0] && n(e[0]) != null) {
|
|
1722
|
+
let a, l, f, E, T, d, S, R;
|
|
1679
1723
|
for (
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
((
|
|
1683
|
-
|
|
1724
|
+
f = 0, E = Math.min(c, e.length);
|
|
1725
|
+
f < E &&
|
|
1726
|
+
((d = getOverrideValue(r, o, u, f, s)) === e[f] || (d && e[f] && n(d) === n(e[f])));
|
|
1727
|
+
f++
|
|
1684
1728
|
) {
|
|
1685
|
-
applyState(e[
|
|
1729
|
+
applyState(e[f], wrap(d, i), n);
|
|
1686
1730
|
}
|
|
1687
|
-
const
|
|
1688
|
-
|
|
1731
|
+
const O = new Array(e.length),
|
|
1732
|
+
_ = new Map();
|
|
1689
1733
|
for (
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
((
|
|
1694
|
-
|
|
1734
|
+
E = c - 1, T = e.length - 1;
|
|
1735
|
+
E >= f &&
|
|
1736
|
+
T >= f &&
|
|
1737
|
+
((d = getOverrideValue(r, o, u, E, s)) === e[T] || (d && e[T] && n(d) === n(e[T])));
|
|
1738
|
+
E--, T--
|
|
1695
1739
|
) {
|
|
1696
|
-
|
|
1740
|
+
O[T] = d;
|
|
1697
1741
|
}
|
|
1698
|
-
if (
|
|
1699
|
-
for (
|
|
1742
|
+
if (f > T || f > E) {
|
|
1743
|
+
for (l = f; l <= T; l++) {
|
|
1700
1744
|
t = true;
|
|
1701
|
-
|
|
1745
|
+
i[STORE_NODE][l] && setSignal(i[STORE_NODE][l], wrap(e[l], i));
|
|
1702
1746
|
}
|
|
1703
|
-
for (;
|
|
1747
|
+
for (; l < e.length; l++) {
|
|
1704
1748
|
t = true;
|
|
1705
|
-
const
|
|
1706
|
-
|
|
1707
|
-
applyState(e[
|
|
1749
|
+
const r = wrap(O[l], i);
|
|
1750
|
+
i[STORE_NODE][l] && setSignal(i[STORE_NODE][l], r);
|
|
1751
|
+
applyState(e[l], r, n);
|
|
1708
1752
|
}
|
|
1709
|
-
t &&
|
|
1710
|
-
|
|
1753
|
+
t && i[STORE_NODE][$TRACK] && setSignal(i[STORE_NODE][$TRACK], void 0);
|
|
1754
|
+
c !== e.length && i[STORE_NODE].length && setSignal(i[STORE_NODE].length, e.length);
|
|
1711
1755
|
return;
|
|
1712
1756
|
}
|
|
1713
|
-
|
|
1714
|
-
for (
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
a =
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
}
|
|
1721
|
-
for (a =
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
if (
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1757
|
+
S = new Array(T + 1);
|
|
1758
|
+
for (l = T; l >= f; l--) {
|
|
1759
|
+
d = e[l];
|
|
1760
|
+
R = d ? n(d) : d;
|
|
1761
|
+
a = _.get(R);
|
|
1762
|
+
S[l] = a === undefined ? -1 : a;
|
|
1763
|
+
_.set(R, l);
|
|
1764
|
+
}
|
|
1765
|
+
for (a = f; a <= E; a++) {
|
|
1766
|
+
d = getOverrideValue(r, o, u, a, s);
|
|
1767
|
+
R = d ? n(d) : d;
|
|
1768
|
+
l = _.get(R);
|
|
1769
|
+
if (l !== undefined && l !== -1) {
|
|
1770
|
+
O[l] = d;
|
|
1771
|
+
l = S[l];
|
|
1772
|
+
_.set(R, l);
|
|
1729
1773
|
}
|
|
1730
1774
|
}
|
|
1731
|
-
for (
|
|
1732
|
-
if (
|
|
1733
|
-
const t = wrap(
|
|
1734
|
-
|
|
1735
|
-
applyState(e[
|
|
1736
|
-
} else
|
|
1775
|
+
for (l = f; l < e.length; l++) {
|
|
1776
|
+
if (l in O) {
|
|
1777
|
+
const t = wrap(O[l], i);
|
|
1778
|
+
i[STORE_NODE][l] && setSignal(i[STORE_NODE][l], t);
|
|
1779
|
+
applyState(e[l], t, n);
|
|
1780
|
+
} else i[STORE_NODE][l] && setSignal(i[STORE_NODE][l], wrap(e[l], i));
|
|
1737
1781
|
}
|
|
1738
|
-
if (
|
|
1782
|
+
if (f < e.length) t = true;
|
|
1739
1783
|
} else if (e.length) {
|
|
1740
|
-
for (let t = 0,
|
|
1741
|
-
const
|
|
1742
|
-
isWrappable(
|
|
1743
|
-
? applyState(e[t], wrap(
|
|
1744
|
-
:
|
|
1784
|
+
for (let t = 0, c = e.length; t < c; t++) {
|
|
1785
|
+
const c = getOverrideValue(r, o, u, t, s);
|
|
1786
|
+
isWrappable(c)
|
|
1787
|
+
? applyState(e[t], wrap(c, i), n)
|
|
1788
|
+
: i[STORE_NODE][t] && setSignal(i[STORE_NODE][t], e[t]);
|
|
1745
1789
|
}
|
|
1746
1790
|
}
|
|
1747
|
-
if (
|
|
1791
|
+
if (c !== e.length) {
|
|
1748
1792
|
t = true;
|
|
1749
|
-
|
|
1793
|
+
i[STORE_NODE].length && setSignal(i[STORE_NODE].length, e.length);
|
|
1750
1794
|
}
|
|
1751
|
-
t &&
|
|
1795
|
+
t && i[STORE_NODE][$TRACK] && setSignal(i[STORE_NODE][$TRACK], void 0);
|
|
1752
1796
|
return;
|
|
1753
1797
|
}
|
|
1754
|
-
if (
|
|
1755
|
-
const t =
|
|
1756
|
-
const
|
|
1757
|
-
for (let a = 0,
|
|
1758
|
-
const
|
|
1759
|
-
const
|
|
1760
|
-
const
|
|
1761
|
-
let
|
|
1762
|
-
if (
|
|
1763
|
-
if (!
|
|
1798
|
+
if (u) {
|
|
1799
|
+
const t = u[$TRACK];
|
|
1800
|
+
const c = t ? getAllKeys(r, o, e) : Object.keys(u);
|
|
1801
|
+
for (let a = 0, l = c.length; a < l; a++) {
|
|
1802
|
+
const l = c[a];
|
|
1803
|
+
const f = u[l];
|
|
1804
|
+
const E = unwrap(getOverrideValue(r, o, u, l, s));
|
|
1805
|
+
let T = unwrap(e[l]);
|
|
1806
|
+
if (E === T) continue;
|
|
1807
|
+
if (!E || !isWrappable(E) || !isWrappable(T) || (n(E) != null && n(E) !== n(T))) {
|
|
1764
1808
|
t && setSignal(t, void 0);
|
|
1765
|
-
|
|
1766
|
-
} else applyState(
|
|
1809
|
+
f && setSignal(f, isWrappable(T) ? wrap(T, i) : T);
|
|
1810
|
+
} else applyState(T, wrap(E, i), n);
|
|
1767
1811
|
}
|
|
1768
1812
|
}
|
|
1769
|
-
if ((
|
|
1770
|
-
const t = Object.keys(
|
|
1813
|
+
if ((u = i[STORE_HAS])) {
|
|
1814
|
+
const t = Object.keys(u);
|
|
1771
1815
|
for (let n = 0, i = t.length; n < i; n++) {
|
|
1772
1816
|
const i = t[n];
|
|
1773
|
-
setSignal(
|
|
1817
|
+
setSignal(u[i], i in e);
|
|
1774
1818
|
}
|
|
1775
1819
|
}
|
|
1776
1820
|
}
|
|
1777
|
-
function reconcile(e, t
|
|
1778
|
-
return
|
|
1779
|
-
if (
|
|
1780
|
-
const
|
|
1781
|
-
const
|
|
1782
|
-
if (
|
|
1821
|
+
function reconcile(e, t) {
|
|
1822
|
+
return n => {
|
|
1823
|
+
if (n == null) throw new Error("Cannot reconcile null or undefined state");
|
|
1824
|
+
const i = typeof t === "string" ? e => e[t] : t;
|
|
1825
|
+
const r = i(n);
|
|
1826
|
+
if (r !== undefined && i(e) !== i(n))
|
|
1783
1827
|
throw new Error("Cannot reconcile states with different identity");
|
|
1784
|
-
applyState(e,
|
|
1828
|
+
applyState(e, n, i);
|
|
1785
1829
|
};
|
|
1786
1830
|
}
|
|
1787
1831
|
function createProjectionInternal(e, t = {}, n) {
|
|
@@ -1804,18 +1848,18 @@ function createProjectionInternal(e, t = {}, n) {
|
|
|
1804
1848
|
r.set(e, t);
|
|
1805
1849
|
return t;
|
|
1806
1850
|
};
|
|
1807
|
-
const
|
|
1851
|
+
const o = wrapProjection(t);
|
|
1808
1852
|
i = computed(() => {
|
|
1809
1853
|
const t = getOwner();
|
|
1810
|
-
storeSetter(new Proxy(
|
|
1854
|
+
storeSetter(new Proxy(o, writeTraps), i => {
|
|
1811
1855
|
const r = handleAsync(t, e(i), e => {
|
|
1812
|
-
e !== i && e !== undefined && storeSetter(
|
|
1856
|
+
e !== i && e !== undefined && storeSetter(o, reconcile(e, n?.key || "id"));
|
|
1813
1857
|
});
|
|
1814
|
-
r !== i && r !== undefined && reconcile(r, n?.key || "id"
|
|
1858
|
+
r !== i && r !== undefined && reconcile(r, n?.key || "id")(o);
|
|
1815
1859
|
});
|
|
1816
1860
|
});
|
|
1817
|
-
i.
|
|
1818
|
-
return { store:
|
|
1861
|
+
i.Pe = true;
|
|
1862
|
+
return { store: o, node: i };
|
|
1819
1863
|
}
|
|
1820
1864
|
function createProjection(e, t = {}, n) {
|
|
1821
1865
|
return createProjectionInternal(e, t, n).store;
|
|
@@ -1857,11 +1901,9 @@ const writeTraps = {
|
|
|
1857
1901
|
}
|
|
1858
1902
|
};
|
|
1859
1903
|
const $TRACK = Symbol(0),
|
|
1860
|
-
$DEEP = Symbol(0),
|
|
1861
1904
|
$TARGET = Symbol(0),
|
|
1862
1905
|
$PROXY = Symbol(0),
|
|
1863
1906
|
$DELETED = Symbol(0);
|
|
1864
|
-
const PARENTS = new WeakMap();
|
|
1865
1907
|
const STORE_VALUE = "v",
|
|
1866
1908
|
STORE_OVERRIDE = "o",
|
|
1867
1909
|
STORE_OPTIMISTIC_OVERRIDE = "x",
|
|
@@ -1902,7 +1944,7 @@ function getNodes(e, t) {
|
|
|
1902
1944
|
if (!n) e[t] = n = Object.create(null);
|
|
1903
1945
|
return n;
|
|
1904
1946
|
}
|
|
1905
|
-
function getNode(e, t, n, i, r = isEqual,
|
|
1947
|
+
function getNode(e, t, n, i, r = isEqual, o, s) {
|
|
1906
1948
|
if (e[t]) return e[t];
|
|
1907
1949
|
const u = signal(
|
|
1908
1950
|
n,
|
|
@@ -1914,9 +1956,11 @@ function getNode(e, t, n, i, r = isEqual, s, o) {
|
|
|
1914
1956
|
},
|
|
1915
1957
|
i
|
|
1916
1958
|
);
|
|
1917
|
-
if (
|
|
1918
|
-
|
|
1919
|
-
|
|
1959
|
+
if (o) {
|
|
1960
|
+
u.Te = NOT_PENDING;
|
|
1961
|
+
}
|
|
1962
|
+
if (s && t in s) {
|
|
1963
|
+
const e = s[t];
|
|
1920
1964
|
u.re = e === undefined ? NO_SNAPSHOT : e;
|
|
1921
1965
|
snapshotSources?.add(u);
|
|
1922
1966
|
}
|
|
@@ -1932,8 +1976,8 @@ function getKeys(e, t, n = true) {
|
|
|
1932
1976
|
const i = untrack(() => (n ? Object.keys(e) : Reflect.ownKeys(e)));
|
|
1933
1977
|
if (!t) return i;
|
|
1934
1978
|
const r = new Set(i);
|
|
1935
|
-
const
|
|
1936
|
-
for (const e of
|
|
1979
|
+
const o = Reflect.ownKeys(t);
|
|
1980
|
+
for (const e of o) {
|
|
1937
1981
|
if (t[e] !== $DELETED) r.add(e);
|
|
1938
1982
|
else r.delete(e);
|
|
1939
1983
|
}
|
|
@@ -1953,16 +1997,16 @@ const storeTraps = {
|
|
|
1953
1997
|
if (t === $TARGET) return e;
|
|
1954
1998
|
if (t === $PROXY) return n;
|
|
1955
1999
|
if (t === $REFRESH) return e[STORE_FIREWALL];
|
|
1956
|
-
if (t === $TRACK
|
|
1957
|
-
trackSelf(e
|
|
2000
|
+
if (t === $TRACK) {
|
|
2001
|
+
trackSelf(e);
|
|
1958
2002
|
return n;
|
|
1959
2003
|
}
|
|
1960
2004
|
const i = getNodes(e, STORE_NODE);
|
|
1961
2005
|
const r = i[t];
|
|
1962
|
-
const
|
|
1963
|
-
const
|
|
2006
|
+
const o = e[STORE_OPTIMISTIC_OVERRIDE] && t in e[STORE_OPTIMISTIC_OVERRIDE];
|
|
2007
|
+
const s = o || (e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE]);
|
|
1964
2008
|
const u = !!e[STORE_VALUE][$TARGET];
|
|
1965
|
-
const c =
|
|
2009
|
+
const c = o
|
|
1966
2010
|
? e[STORE_OPTIMISTIC_OVERRIDE]
|
|
1967
2011
|
: e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE]
|
|
1968
2012
|
? e[STORE_OVERRIDE]
|
|
@@ -1972,29 +2016,36 @@ const storeTraps = {
|
|
|
1972
2016
|
if (e && e.get) return e.get.call(n);
|
|
1973
2017
|
}
|
|
1974
2018
|
if (writeOnly(n)) {
|
|
1975
|
-
let n =
|
|
2019
|
+
let n =
|
|
2020
|
+
r && (s || !u)
|
|
2021
|
+
? r.Te !== undefined && r.Te !== NOT_PENDING
|
|
2022
|
+
? r.Te
|
|
2023
|
+
: r.le !== NOT_PENDING
|
|
2024
|
+
? r.le
|
|
2025
|
+
: r.fe
|
|
2026
|
+
: c[t];
|
|
1976
2027
|
n === $DELETED && (n = undefined);
|
|
1977
2028
|
if (!isWrappable(n)) return n;
|
|
1978
2029
|
const i = wrap(n, e);
|
|
1979
2030
|
Writing?.add(i);
|
|
1980
2031
|
return i;
|
|
1981
2032
|
}
|
|
1982
|
-
let
|
|
1983
|
-
|
|
2033
|
+
let a = r ? (s || !u ? read(i[t]) : (read(i[t]), c[t])) : c[t];
|
|
2034
|
+
a === $DELETED && (a = undefined);
|
|
1984
2035
|
if (!r) {
|
|
1985
|
-
if (!
|
|
2036
|
+
if (!s && typeof a === "function" && !c.hasOwnProperty(t)) {
|
|
1986
2037
|
let t;
|
|
1987
2038
|
return !Array.isArray(e[STORE_VALUE]) &&
|
|
1988
2039
|
(t = Object.getPrototypeOf(e[STORE_VALUE])) &&
|
|
1989
2040
|
t !== Object.prototype
|
|
1990
|
-
?
|
|
1991
|
-
:
|
|
2041
|
+
? a.bind(c)
|
|
2042
|
+
: a;
|
|
1992
2043
|
} else if (getObserver()) {
|
|
1993
2044
|
return read(
|
|
1994
2045
|
getNode(
|
|
1995
2046
|
i,
|
|
1996
2047
|
t,
|
|
1997
|
-
isWrappable(
|
|
2048
|
+
isWrappable(a) ? wrap(a, e) : a,
|
|
1998
2049
|
e[STORE_FIREWALL],
|
|
1999
2050
|
isEqual,
|
|
2000
2051
|
e[STORE_OPTIMISTIC],
|
|
@@ -2003,7 +2054,7 @@ const storeTraps = {
|
|
|
2003
2054
|
);
|
|
2004
2055
|
}
|
|
2005
2056
|
}
|
|
2006
|
-
return isWrappable(
|
|
2057
|
+
return isWrappable(a) ? wrap(a, e) : a;
|
|
2007
2058
|
},
|
|
2008
2059
|
has(e, t) {
|
|
2009
2060
|
if (t === $PROXY || t === $TRACK || t === "__proto__") return true;
|
|
@@ -2028,45 +2079,44 @@ const storeTraps = {
|
|
|
2028
2079
|
}
|
|
2029
2080
|
untrack(() => {
|
|
2030
2081
|
const r = e[STORE_VALUE];
|
|
2031
|
-
const
|
|
2032
|
-
if (
|
|
2082
|
+
const o = r[t];
|
|
2083
|
+
if (
|
|
2084
|
+
snapshotCaptureActive &&
|
|
2085
|
+
typeof t !== "symbol" &&
|
|
2086
|
+
!((e[STORE_FIREWALL]?.Ee ?? 0) & STATUS_PENDING)
|
|
2087
|
+
) {
|
|
2033
2088
|
if (!e[STORE_SNAPSHOT_PROPS]) {
|
|
2034
2089
|
e[STORE_SNAPSHOT_PROPS] = Object.create(null);
|
|
2035
2090
|
snapshotSources?.add(e);
|
|
2036
2091
|
}
|
|
2037
2092
|
if (!(t in e[STORE_SNAPSHOT_PROPS])) {
|
|
2038
|
-
e[STORE_SNAPSHOT_PROPS][t] =
|
|
2093
|
+
e[STORE_SNAPSHOT_PROPS][t] = o;
|
|
2039
2094
|
}
|
|
2040
2095
|
}
|
|
2041
|
-
const
|
|
2042
|
-
const u =
|
|
2043
|
-
if (
|
|
2096
|
+
const s = e[STORE_OPTIMISTIC] && !projectionWriteActive;
|
|
2097
|
+
const u = s ? STORE_OPTIMISTIC_OVERRIDE : STORE_OVERRIDE;
|
|
2098
|
+
if (s) trackOptimisticStore(i);
|
|
2044
2099
|
const c =
|
|
2045
2100
|
e[STORE_OPTIMISTIC_OVERRIDE] && t in e[STORE_OPTIMISTIC_OVERRIDE]
|
|
2046
2101
|
? e[STORE_OPTIMISTIC_OVERRIDE][t]
|
|
2047
2102
|
: e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE]
|
|
2048
2103
|
? e[STORE_OVERRIDE][t]
|
|
2049
|
-
:
|
|
2050
|
-
const
|
|
2051
|
-
if (c ===
|
|
2052
|
-
const
|
|
2053
|
-
if (
|
|
2054
|
-
else (e[u] || (e[u] = Object.create(null)))[t] =
|
|
2055
|
-
const f = isWrappable(
|
|
2056
|
-
if (isWrappable(c)) {
|
|
2057
|
-
const e = PARENTS.get(c);
|
|
2058
|
-
e && (e instanceof Set ? e.delete(i) : PARENTS.delete(c));
|
|
2059
|
-
}
|
|
2060
|
-
if (recursivelyNotify(i, storeLookup) && f) recursivelyAddParent(l, i);
|
|
2104
|
+
: o;
|
|
2105
|
+
const a = n?.[$TARGET]?.[STORE_VALUE] ?? n;
|
|
2106
|
+
if (c === a) return true;
|
|
2107
|
+
const l = e[STORE_OPTIMISTIC_OVERRIDE]?.length || e[STORE_OVERRIDE]?.length || r.length;
|
|
2108
|
+
if (a !== undefined && a === o) delete e[u][t];
|
|
2109
|
+
else (e[u] || (e[u] = Object.create(null)))[t] = a;
|
|
2110
|
+
const f = isWrappable(a);
|
|
2061
2111
|
e[STORE_HAS]?.[t] && setSignal(e[STORE_HAS][t], true);
|
|
2062
2112
|
const E = getNodes(e, STORE_NODE);
|
|
2063
|
-
E[t] && setSignal(E[t], () => (f ? wrap(
|
|
2113
|
+
E[t] && setSignal(E[t], () => (f ? wrap(a, e) : a));
|
|
2064
2114
|
if (Array.isArray(r)) {
|
|
2065
2115
|
if (t === "length") {
|
|
2066
|
-
E.length && setSignal(E.length,
|
|
2116
|
+
E.length && setSignal(E.length, a);
|
|
2067
2117
|
} else {
|
|
2068
2118
|
const e = parseInt(t) + 1;
|
|
2069
|
-
if (e >
|
|
2119
|
+
if (e > l) E.length && setSignal(E.length, e);
|
|
2070
2120
|
}
|
|
2071
2121
|
}
|
|
2072
2122
|
E[$TRACK] && setSignal(E[$TRACK], undefined);
|
|
@@ -2093,14 +2143,10 @@ const storeTraps = {
|
|
|
2093
2143
|
} else if (e[i] && t in e[i]) {
|
|
2094
2144
|
delete e[i][t];
|
|
2095
2145
|
} else return true;
|
|
2096
|
-
if (isWrappable(r)) {
|
|
2097
|
-
const t = PARENTS.get(r);
|
|
2098
|
-
t && (t instanceof Set ? t.delete(e) : PARENTS.delete(r));
|
|
2099
|
-
}
|
|
2100
2146
|
if (e[STORE_HAS]?.[t]) setSignal(e[STORE_HAS][t], false);
|
|
2101
|
-
const
|
|
2102
|
-
|
|
2103
|
-
|
|
2147
|
+
const o = getNodes(e, STORE_NODE);
|
|
2148
|
+
o[t] && setSignal(o[t], undefined);
|
|
2149
|
+
o[$TRACK] && setSignal(o[$TRACK], undefined);
|
|
2104
2150
|
});
|
|
2105
2151
|
}
|
|
2106
2152
|
return true;
|
|
@@ -2167,66 +2213,13 @@ function createStore(e, t, n) {
|
|
|
2167
2213
|
r = i ? createProjectionInternal(e, t, n).store : wrap(e);
|
|
2168
2214
|
return [r, e => storeSetter(r, e)];
|
|
2169
2215
|
}
|
|
2170
|
-
function recursivelyNotify(e, t) {
|
|
2171
|
-
let n = e[$TARGET] || t?.get(e)?.[$TARGET];
|
|
2172
|
-
let i = false;
|
|
2173
|
-
if (n) {
|
|
2174
|
-
const e = getNodes(n, STORE_NODE)[$DEEP];
|
|
2175
|
-
if (e) {
|
|
2176
|
-
setSignal(e, undefined);
|
|
2177
|
-
i = true;
|
|
2178
|
-
}
|
|
2179
|
-
t = n[STORE_LOOKUP] || t;
|
|
2180
|
-
}
|
|
2181
|
-
const r = PARENTS.get(n?.[STORE_VALUE] || e);
|
|
2182
|
-
if (!r) return i;
|
|
2183
|
-
if (r instanceof Set) {
|
|
2184
|
-
for (let e of r) i = recursivelyNotify(e, t) || i;
|
|
2185
|
-
} else i = recursivelyNotify(r, t) || i;
|
|
2186
|
-
return i;
|
|
2187
|
-
}
|
|
2188
|
-
function recursivelyAddParent(e, t) {
|
|
2189
|
-
let n;
|
|
2190
|
-
const i = e[$TARGET];
|
|
2191
|
-
if (i) {
|
|
2192
|
-
n = i[STORE_OVERRIDE];
|
|
2193
|
-
e = i[STORE_VALUE];
|
|
2194
|
-
}
|
|
2195
|
-
if (t) {
|
|
2196
|
-
let n = PARENTS.get(e);
|
|
2197
|
-
if (!n) PARENTS.set(e, t);
|
|
2198
|
-
else if (n !== t) {
|
|
2199
|
-
if (!(n instanceof Set)) PARENTS.set(e, (n = new Set([n])));
|
|
2200
|
-
else if (n.has(t)) return;
|
|
2201
|
-
n.add(t);
|
|
2202
|
-
} else return;
|
|
2203
|
-
}
|
|
2204
|
-
if (Array.isArray(e)) {
|
|
2205
|
-
const t = n?.length || e.length;
|
|
2206
|
-
for (let i = 0; i < t; i++) {
|
|
2207
|
-
const t = n && i in n ? n[i] : e[i];
|
|
2208
|
-
isWrappable(t) && recursivelyAddParent(t, e);
|
|
2209
|
-
}
|
|
2210
|
-
} else {
|
|
2211
|
-
const t = getKeys(e, n);
|
|
2212
|
-
for (let i = 0; i < t.length; i++) {
|
|
2213
|
-
const r = t[i];
|
|
2214
|
-
const s = n && r in n ? n[r] : e[r];
|
|
2215
|
-
isWrappable(s) && recursivelyAddParent(s, e);
|
|
2216
|
-
}
|
|
2217
|
-
}
|
|
2218
|
-
}
|
|
2219
|
-
function deep(e) {
|
|
2220
|
-
recursivelyAddParent(e);
|
|
2221
|
-
return e[$DEEP];
|
|
2222
|
-
}
|
|
2223
2216
|
function createOptimisticStore(e, t, n) {
|
|
2224
|
-
GlobalQueue.
|
|
2217
|
+
GlobalQueue.B ||= clearOptimisticStore;
|
|
2225
2218
|
const i = typeof e === "function";
|
|
2226
2219
|
const r = (i ? t : e) ?? {};
|
|
2227
|
-
const
|
|
2228
|
-
const { store:
|
|
2229
|
-
return [
|
|
2220
|
+
const o = i ? e : undefined;
|
|
2221
|
+
const { store: s } = createOptimisticProjectionInternal(o, r, n);
|
|
2222
|
+
return [s, e => storeSetter(s, e)];
|
|
2230
2223
|
}
|
|
2231
2224
|
function clearOptimisticStore(e) {
|
|
2232
2225
|
const t = e[$TARGET];
|
|
@@ -2276,30 +2269,30 @@ function createOptimisticProjectionInternal(e, t = {}, n) {
|
|
|
2276
2269
|
r.set(e, t);
|
|
2277
2270
|
return t;
|
|
2278
2271
|
};
|
|
2279
|
-
const
|
|
2272
|
+
const o = wrapProjection(t);
|
|
2280
2273
|
if (e) {
|
|
2281
2274
|
i = computed(() => {
|
|
2282
2275
|
const t = getOwner();
|
|
2283
2276
|
setProjectionWriteActive(true);
|
|
2284
2277
|
try {
|
|
2285
|
-
storeSetter(new Proxy(
|
|
2278
|
+
storeSetter(new Proxy(o, writeTraps), i => {
|
|
2286
2279
|
const r = handleAsync(t, e(i), e => {
|
|
2287
2280
|
setProjectionWriteActive(true);
|
|
2288
2281
|
try {
|
|
2289
|
-
e !== i && e !== undefined && storeSetter(
|
|
2282
|
+
e !== i && e !== undefined && storeSetter(o, reconcile(e, n?.key || "id"));
|
|
2290
2283
|
} finally {
|
|
2291
2284
|
setProjectionWriteActive(false);
|
|
2292
2285
|
}
|
|
2293
2286
|
});
|
|
2294
|
-
r !== i && r !== undefined && reconcile(r, n?.key || "id"
|
|
2287
|
+
r !== i && r !== undefined && reconcile(r, n?.key || "id")(o);
|
|
2295
2288
|
});
|
|
2296
2289
|
} finally {
|
|
2297
2290
|
setProjectionWriteActive(false);
|
|
2298
2291
|
}
|
|
2299
2292
|
});
|
|
2300
|
-
i.
|
|
2293
|
+
i.Pe = true;
|
|
2301
2294
|
}
|
|
2302
|
-
return { store:
|
|
2295
|
+
return { store: o, node: i };
|
|
2303
2296
|
}
|
|
2304
2297
|
const DELETE = Symbol(0);
|
|
2305
2298
|
function updatePath(e, t, n = 0) {
|
|
@@ -2307,8 +2300,8 @@ function updatePath(e, t, n = 0) {
|
|
|
2307
2300
|
r = e;
|
|
2308
2301
|
if (n < t.length - 1) {
|
|
2309
2302
|
i = t[n];
|
|
2310
|
-
const
|
|
2311
|
-
const
|
|
2303
|
+
const o = typeof i;
|
|
2304
|
+
const s = Array.isArray(e);
|
|
2312
2305
|
if (Array.isArray(i)) {
|
|
2313
2306
|
for (let r = 0; r < i.length; r++) {
|
|
2314
2307
|
t[n] = i[r];
|
|
@@ -2316,7 +2309,7 @@ function updatePath(e, t, n = 0) {
|
|
|
2316
2309
|
}
|
|
2317
2310
|
t[n] = i;
|
|
2318
2311
|
return;
|
|
2319
|
-
} else if (
|
|
2312
|
+
} else if (s && o === "function") {
|
|
2320
2313
|
for (let r = 0; r < e.length; r++) {
|
|
2321
2314
|
if (i(e[r], r)) {
|
|
2322
2315
|
t[n] = r;
|
|
@@ -2325,9 +2318,9 @@ function updatePath(e, t, n = 0) {
|
|
|
2325
2318
|
}
|
|
2326
2319
|
t[n] = i;
|
|
2327
2320
|
return;
|
|
2328
|
-
} else if (
|
|
2329
|
-
const { from: r = 0, to:
|
|
2330
|
-
for (let i = r; i <=
|
|
2321
|
+
} else if (s && o === "object") {
|
|
2322
|
+
const { from: r = 0, to: o = e.length - 1, by: s = 1 } = i;
|
|
2323
|
+
for (let i = r; i <= o; i += s) {
|
|
2331
2324
|
t[n] = i;
|
|
2332
2325
|
updatePath(e, t, n);
|
|
2333
2326
|
}
|
|
@@ -2339,20 +2332,20 @@ function updatePath(e, t, n = 0) {
|
|
|
2339
2332
|
}
|
|
2340
2333
|
r = e[i];
|
|
2341
2334
|
}
|
|
2342
|
-
let
|
|
2343
|
-
if (typeof
|
|
2344
|
-
|
|
2345
|
-
if (
|
|
2335
|
+
let o = t[t.length - 1];
|
|
2336
|
+
if (typeof o === "function") {
|
|
2337
|
+
o = o(r);
|
|
2338
|
+
if (o === r) return;
|
|
2346
2339
|
}
|
|
2347
|
-
if (i === undefined &&
|
|
2348
|
-
if (
|
|
2340
|
+
if (i === undefined && o == undefined) return;
|
|
2341
|
+
if (o === DELETE) {
|
|
2349
2342
|
delete e[i];
|
|
2350
|
-
} else if (i === undefined || (isWrappable(r) && isWrappable(
|
|
2343
|
+
} else if (i === undefined || (isWrappable(r) && isWrappable(o) && !Array.isArray(o))) {
|
|
2351
2344
|
const t = i !== undefined ? e[i] : e;
|
|
2352
|
-
const n = Object.keys(
|
|
2353
|
-
for (let e = 0; e < n.length; e++) t[n[e]] =
|
|
2345
|
+
const n = Object.keys(o);
|
|
2346
|
+
for (let e = 0; e < n.length; e++) t[n[e]] = o[n[e]];
|
|
2354
2347
|
} else {
|
|
2355
|
-
e[i] =
|
|
2348
|
+
e[i] = o;
|
|
2356
2349
|
}
|
|
2357
2350
|
}
|
|
2358
2351
|
const storePath = Object.assign(
|
|
@@ -2363,51 +2356,60 @@ const storePath = Object.assign(
|
|
|
2363
2356
|
},
|
|
2364
2357
|
{ DELETE: DELETE }
|
|
2365
2358
|
);
|
|
2366
|
-
function
|
|
2367
|
-
let
|
|
2359
|
+
function snapshotImpl(e, t, n, i) {
|
|
2360
|
+
let r, o, s, u, c, a;
|
|
2368
2361
|
if (!isWrappable(e)) return e;
|
|
2369
|
-
if (
|
|
2370
|
-
if (!
|
|
2371
|
-
if ((
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2362
|
+
if (n && n.has(e)) return n.get(e);
|
|
2363
|
+
if (!n) n = new Map();
|
|
2364
|
+
if ((r = e[$TARGET] || i?.get(e)?.[$TARGET])) {
|
|
2365
|
+
if (t) trackSelf(r, $TRACK);
|
|
2366
|
+
s = r[STORE_OVERRIDE];
|
|
2367
|
+
o = Array.isArray(r[STORE_VALUE]);
|
|
2368
|
+
n.set(
|
|
2375
2369
|
e,
|
|
2376
|
-
s ? (
|
|
2370
|
+
s ? (u = o ? [] : Object.create(Object.getPrototypeOf(r[STORE_VALUE]))) : r[STORE_VALUE]
|
|
2377
2371
|
);
|
|
2378
|
-
e =
|
|
2379
|
-
|
|
2372
|
+
e = r[STORE_VALUE];
|
|
2373
|
+
i = storeLookup;
|
|
2380
2374
|
} else {
|
|
2381
|
-
|
|
2382
|
-
|
|
2375
|
+
o = Array.isArray(e);
|
|
2376
|
+
n.set(e, e);
|
|
2383
2377
|
}
|
|
2384
|
-
if (
|
|
2385
|
-
const
|
|
2386
|
-
for (let
|
|
2387
|
-
|
|
2388
|
-
if (
|
|
2389
|
-
if (
|
|
2390
|
-
|
|
2391
|
-
|
|
2378
|
+
if (o) {
|
|
2379
|
+
const o = s?.length || e.length;
|
|
2380
|
+
for (let l = 0; l < o; l++) {
|
|
2381
|
+
a = s && l in s ? s[l] : e[l];
|
|
2382
|
+
if (a === $DELETED) continue;
|
|
2383
|
+
if (t && isWrappable(a)) wrap(a, r);
|
|
2384
|
+
if ((c = snapshotImpl(a, t, n, i)) !== a || u) {
|
|
2385
|
+
if (!u) n.set(e, (u = [...e]));
|
|
2386
|
+
u[l] = c;
|
|
2392
2387
|
}
|
|
2393
2388
|
}
|
|
2394
2389
|
} else {
|
|
2395
|
-
const
|
|
2396
|
-
for (let
|
|
2397
|
-
let
|
|
2398
|
-
const
|
|
2399
|
-
if (
|
|
2400
|
-
|
|
2401
|
-
if (
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
Object.
|
|
2390
|
+
const o = getKeys(e, s);
|
|
2391
|
+
for (let l = 0, f = o.length; l < f; l++) {
|
|
2392
|
+
let f = o[l];
|
|
2393
|
+
const E = getPropertyDescriptor(e, s, f);
|
|
2394
|
+
if (E.get) continue;
|
|
2395
|
+
a = s && f in s ? s[f] : e[f];
|
|
2396
|
+
if (t && isWrappable(a)) wrap(a, r);
|
|
2397
|
+
if ((c = snapshotImpl(a, t, n, i)) !== e[f] || u) {
|
|
2398
|
+
if (!u) {
|
|
2399
|
+
u = Object.create(Object.getPrototypeOf(e));
|
|
2400
|
+
Object.assign(u, e);
|
|
2405
2401
|
}
|
|
2406
|
-
|
|
2402
|
+
u[f] = c;
|
|
2407
2403
|
}
|
|
2408
2404
|
}
|
|
2409
2405
|
}
|
|
2410
|
-
return
|
|
2406
|
+
return u || e;
|
|
2407
|
+
}
|
|
2408
|
+
function snapshot(e, t, n) {
|
|
2409
|
+
return snapshotImpl(e, false, t, n);
|
|
2410
|
+
}
|
|
2411
|
+
function deep(e) {
|
|
2412
|
+
return snapshotImpl(e, true);
|
|
2411
2413
|
}
|
|
2412
2414
|
function trueFn() {
|
|
2413
2415
|
return true;
|
|
@@ -2449,8 +2451,8 @@ function merge(...e) {
|
|
|
2449
2451
|
for (let i = 0; i < e.length; i++) {
|
|
2450
2452
|
const r = e[i];
|
|
2451
2453
|
t = t || (!!r && $PROXY in r);
|
|
2452
|
-
const
|
|
2453
|
-
if (
|
|
2454
|
+
const o = !!r && r[$SOURCES];
|
|
2455
|
+
if (o) n.push(...o);
|
|
2454
2456
|
else n.push(typeof r === "function" ? ((t = true), createMemo(r)) : r);
|
|
2455
2457
|
}
|
|
2456
2458
|
if (SUPPORTS_PROXY && t) {
|
|
@@ -2480,35 +2482,35 @@ function merge(...e) {
|
|
|
2480
2482
|
}
|
|
2481
2483
|
const i = Object.create(null);
|
|
2482
2484
|
let r = false;
|
|
2483
|
-
let
|
|
2484
|
-
for (let e =
|
|
2485
|
+
let o = n.length - 1;
|
|
2486
|
+
for (let e = o; e >= 0; e--) {
|
|
2485
2487
|
const t = n[e];
|
|
2486
2488
|
if (!t) {
|
|
2487
|
-
e ===
|
|
2489
|
+
e === o && o--;
|
|
2488
2490
|
continue;
|
|
2489
2491
|
}
|
|
2490
|
-
const
|
|
2491
|
-
for (let n =
|
|
2492
|
-
const u =
|
|
2492
|
+
const s = Object.getOwnPropertyNames(t);
|
|
2493
|
+
for (let n = s.length - 1; n >= 0; n--) {
|
|
2494
|
+
const u = s[n];
|
|
2493
2495
|
if (u === "__proto__" || u === "constructor") continue;
|
|
2494
2496
|
if (!i[u]) {
|
|
2495
|
-
r = r || e !==
|
|
2497
|
+
r = r || e !== o;
|
|
2496
2498
|
const n = Object.getOwnPropertyDescriptor(t, u);
|
|
2497
2499
|
i[u] = n.get ? { enumerable: true, configurable: true, get: n.get.bind(t) } : n;
|
|
2498
2500
|
}
|
|
2499
2501
|
}
|
|
2500
2502
|
}
|
|
2501
|
-
if (!r) return n[
|
|
2502
|
-
const
|
|
2503
|
+
if (!r) return n[o];
|
|
2504
|
+
const s = {};
|
|
2503
2505
|
const u = Object.keys(i);
|
|
2504
2506
|
for (let e = u.length - 1; e >= 0; e--) {
|
|
2505
2507
|
const t = u[e],
|
|
2506
2508
|
n = i[t];
|
|
2507
|
-
if (n.get) Object.defineProperty(
|
|
2508
|
-
else
|
|
2509
|
+
if (n.get) Object.defineProperty(s, t, n);
|
|
2510
|
+
else s[t] = n.value;
|
|
2509
2511
|
}
|
|
2510
|
-
|
|
2511
|
-
return
|
|
2512
|
+
s[$SOURCES] = n;
|
|
2513
|
+
return s;
|
|
2512
2514
|
}
|
|
2513
2515
|
function omit(e, ...t) {
|
|
2514
2516
|
const n = new Set(t);
|
|
@@ -2542,26 +2544,26 @@ function omit(e, ...t) {
|
|
|
2542
2544
|
function mapArray(e, t, n) {
|
|
2543
2545
|
const i = typeof n?.keyed === "function" ? n.keyed : undefined;
|
|
2544
2546
|
const r = t.length > 1;
|
|
2545
|
-
const
|
|
2547
|
+
const o = t;
|
|
2546
2548
|
return createMemo(
|
|
2547
2549
|
updateKeyedMap.bind({
|
|
2548
2550
|
Fe: createOwner(),
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2551
|
+
Me: 0,
|
|
2552
|
+
$e: e,
|
|
2553
|
+
je: [],
|
|
2554
|
+
Ke: o,
|
|
2555
|
+
Ye: [],
|
|
2554
2556
|
Be: [],
|
|
2555
|
-
|
|
2557
|
+
Ze: i,
|
|
2556
2558
|
qe: i || n?.keyed === false ? [] : undefined,
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
+
Xe: r ? [] : undefined,
|
|
2560
|
+
ze: n?.fallback
|
|
2559
2561
|
})
|
|
2560
2562
|
);
|
|
2561
2563
|
}
|
|
2562
2564
|
const pureOptions = { pureWrite: true };
|
|
2563
2565
|
function updateKeyedMap() {
|
|
2564
|
-
const e = this
|
|
2566
|
+
const e = this.$e() || [],
|
|
2565
2567
|
t = e.length;
|
|
2566
2568
|
e[$TRACK];
|
|
2567
2569
|
runWithOwner(this.Fe, () => {
|
|
@@ -2570,192 +2572,189 @@ function updateKeyedMap() {
|
|
|
2570
2572
|
r = this.qe
|
|
2571
2573
|
? () => {
|
|
2572
2574
|
this.qe[i] = signal(e[i], pureOptions);
|
|
2573
|
-
this.
|
|
2574
|
-
return this.
|
|
2575
|
-
read.bind(null, this.qe[i]),
|
|
2576
|
-
this.ze ? read.bind(null, this.ze[i]) : undefined
|
|
2577
|
-
);
|
|
2575
|
+
this.Xe && (this.Xe[i] = signal(i, pureOptions));
|
|
2576
|
+
return this.Ke(accessor(this.qe[i]), this.Xe ? accessor(this.Xe[i]) : undefined);
|
|
2578
2577
|
}
|
|
2579
|
-
: this.
|
|
2578
|
+
: this.Xe
|
|
2580
2579
|
? () => {
|
|
2581
2580
|
const t = e[i];
|
|
2582
|
-
this.
|
|
2583
|
-
return this.
|
|
2581
|
+
this.Xe[i] = signal(i, pureOptions);
|
|
2582
|
+
return this.Ke(() => t, accessor(this.Xe[i]));
|
|
2584
2583
|
}
|
|
2585
2584
|
: () => {
|
|
2586
2585
|
const t = e[i];
|
|
2587
|
-
return this.
|
|
2586
|
+
return this.Ke(() => t);
|
|
2588
2587
|
};
|
|
2589
2588
|
if (t === 0) {
|
|
2590
|
-
if (this
|
|
2589
|
+
if (this.Me !== 0) {
|
|
2591
2590
|
this.Fe.dispose(false);
|
|
2592
2591
|
this.Be = [];
|
|
2593
|
-
this.
|
|
2594
|
-
this.
|
|
2595
|
-
this
|
|
2592
|
+
this.je = [];
|
|
2593
|
+
this.Ye = [];
|
|
2594
|
+
this.Me = 0;
|
|
2596
2595
|
this.qe && (this.qe = []);
|
|
2597
|
-
this.
|
|
2596
|
+
this.Xe && (this.Xe = []);
|
|
2598
2597
|
}
|
|
2599
|
-
if (this.
|
|
2600
|
-
this.
|
|
2598
|
+
if (this.ze && !this.Ye[0]) {
|
|
2599
|
+
this.Ye[0] = runWithOwner((this.Be[0] = createOwner()), this.ze);
|
|
2601
2600
|
}
|
|
2602
|
-
} else if (this
|
|
2601
|
+
} else if (this.Me === 0) {
|
|
2603
2602
|
if (this.Be[0]) this.Be[0].dispose();
|
|
2604
|
-
this.
|
|
2603
|
+
this.Ye = new Array(t);
|
|
2605
2604
|
for (i = 0; i < t; i++) {
|
|
2606
|
-
this.
|
|
2607
|
-
this.
|
|
2605
|
+
this.je[i] = e[i];
|
|
2606
|
+
this.Ye[i] = runWithOwner((this.Be[i] = createOwner()), r);
|
|
2608
2607
|
}
|
|
2609
|
-
this
|
|
2608
|
+
this.Me = t;
|
|
2610
2609
|
} else {
|
|
2611
|
-
let
|
|
2612
|
-
|
|
2610
|
+
let o,
|
|
2611
|
+
s,
|
|
2613
2612
|
u,
|
|
2614
2613
|
c,
|
|
2615
|
-
l,
|
|
2616
2614
|
a,
|
|
2615
|
+
l,
|
|
2617
2616
|
f,
|
|
2618
2617
|
E = new Array(t),
|
|
2619
2618
|
T = new Array(t),
|
|
2620
2619
|
d = this.qe ? new Array(t) : undefined,
|
|
2621
|
-
S = this.
|
|
2620
|
+
S = this.Xe ? new Array(t) : undefined;
|
|
2622
2621
|
for (
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2622
|
+
o = 0, s = Math.min(this.Me, t);
|
|
2623
|
+
o < s && (this.je[o] === e[o] || (this.qe && compare(this.Ze, this.je[o], e[o])));
|
|
2624
|
+
o++
|
|
2626
2625
|
) {
|
|
2627
|
-
if (this.qe) setSignal(this.qe[
|
|
2626
|
+
if (this.qe) setSignal(this.qe[o], e[o]);
|
|
2628
2627
|
}
|
|
2629
2628
|
for (
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
u >=
|
|
2633
|
-
(this.
|
|
2634
|
-
|
|
2629
|
+
s = this.Me - 1, u = t - 1;
|
|
2630
|
+
s >= o &&
|
|
2631
|
+
u >= o &&
|
|
2632
|
+
(this.je[s] === e[u] || (this.qe && compare(this.Ze, this.je[s], e[u])));
|
|
2633
|
+
s--, u--
|
|
2635
2634
|
) {
|
|
2636
|
-
E[u] = this.
|
|
2637
|
-
T[u] = this.Be[
|
|
2638
|
-
d && (d[u] = this.qe[
|
|
2639
|
-
S && (S[u] = this.
|
|
2635
|
+
E[u] = this.Ye[s];
|
|
2636
|
+
T[u] = this.Be[s];
|
|
2637
|
+
d && (d[u] = this.qe[s]);
|
|
2638
|
+
S && (S[u] = this.Xe[s]);
|
|
2640
2639
|
}
|
|
2641
|
-
|
|
2640
|
+
l = new Map();
|
|
2642
2641
|
f = new Array(u + 1);
|
|
2643
|
-
for (i = u; i >=
|
|
2642
|
+
for (i = u; i >= o; i--) {
|
|
2644
2643
|
c = e[i];
|
|
2645
|
-
|
|
2646
|
-
n =
|
|
2644
|
+
a = this.Ze ? this.Ze(c) : c;
|
|
2645
|
+
n = l.get(a);
|
|
2647
2646
|
f[i] = n === undefined ? -1 : n;
|
|
2648
|
-
|
|
2647
|
+
l.set(a, i);
|
|
2649
2648
|
}
|
|
2650
|
-
for (n =
|
|
2651
|
-
c = this.
|
|
2652
|
-
|
|
2653
|
-
i =
|
|
2649
|
+
for (n = o; n <= s; n++) {
|
|
2650
|
+
c = this.je[n];
|
|
2651
|
+
a = this.Ze ? this.Ze(c) : c;
|
|
2652
|
+
i = l.get(a);
|
|
2654
2653
|
if (i !== undefined && i !== -1) {
|
|
2655
|
-
E[i] = this.
|
|
2654
|
+
E[i] = this.Ye[n];
|
|
2656
2655
|
T[i] = this.Be[n];
|
|
2657
2656
|
d && (d[i] = this.qe[n]);
|
|
2658
|
-
S && (S[i] = this.
|
|
2657
|
+
S && (S[i] = this.Xe[n]);
|
|
2659
2658
|
i = f[i];
|
|
2660
|
-
|
|
2659
|
+
l.set(a, i);
|
|
2661
2660
|
} else this.Be[n].dispose();
|
|
2662
2661
|
}
|
|
2663
|
-
for (i =
|
|
2662
|
+
for (i = o; i < t; i++) {
|
|
2664
2663
|
if (i in E) {
|
|
2665
|
-
this.
|
|
2664
|
+
this.Ye[i] = E[i];
|
|
2666
2665
|
this.Be[i] = T[i];
|
|
2667
2666
|
if (d) {
|
|
2668
2667
|
this.qe[i] = d[i];
|
|
2669
2668
|
setSignal(this.qe[i], e[i]);
|
|
2670
2669
|
}
|
|
2671
2670
|
if (S) {
|
|
2672
|
-
this.
|
|
2673
|
-
setSignal(this.
|
|
2671
|
+
this.Xe[i] = S[i];
|
|
2672
|
+
setSignal(this.Xe[i], i);
|
|
2674
2673
|
}
|
|
2675
2674
|
} else {
|
|
2676
|
-
this.
|
|
2675
|
+
this.Ye[i] = runWithOwner((this.Be[i] = createOwner()), r);
|
|
2677
2676
|
}
|
|
2678
2677
|
}
|
|
2679
|
-
this.
|
|
2680
|
-
this.
|
|
2678
|
+
this.Ye = this.Ye.slice(0, (this.Me = t));
|
|
2679
|
+
this.je = e.slice(0);
|
|
2681
2680
|
}
|
|
2682
2681
|
});
|
|
2683
|
-
return this.
|
|
2682
|
+
return this.Ye;
|
|
2684
2683
|
}
|
|
2685
2684
|
function repeat(e, t, n) {
|
|
2686
2685
|
const i = t;
|
|
2687
2686
|
return updateRepeat.bind({
|
|
2688
2687
|
Fe: createOwner(),
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2688
|
+
Me: 0,
|
|
2689
|
+
Je: 0,
|
|
2690
|
+
et: e,
|
|
2691
|
+
Ke: i,
|
|
2693
2692
|
Be: [],
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2693
|
+
Ye: [],
|
|
2694
|
+
tt: n?.from,
|
|
2695
|
+
ze: n?.fallback
|
|
2697
2696
|
});
|
|
2698
2697
|
}
|
|
2699
2698
|
function updateRepeat() {
|
|
2700
|
-
const e = this.
|
|
2701
|
-
const t = this.
|
|
2699
|
+
const e = this.et();
|
|
2700
|
+
const t = this.tt?.() || 0;
|
|
2702
2701
|
runWithOwner(this.Fe, () => {
|
|
2703
2702
|
if (e === 0) {
|
|
2704
|
-
if (this
|
|
2703
|
+
if (this.Me !== 0) {
|
|
2705
2704
|
this.Fe.dispose(false);
|
|
2706
2705
|
this.Be = [];
|
|
2707
|
-
this.
|
|
2708
|
-
this
|
|
2706
|
+
this.Ye = [];
|
|
2707
|
+
this.Me = 0;
|
|
2709
2708
|
}
|
|
2710
|
-
if (this.
|
|
2711
|
-
this.
|
|
2709
|
+
if (this.ze && !this.Ye[0]) {
|
|
2710
|
+
this.Ye[0] = runWithOwner((this.Be[0] = createOwner()), this.ze);
|
|
2712
2711
|
}
|
|
2713
2712
|
return;
|
|
2714
2713
|
}
|
|
2715
2714
|
const n = t + e;
|
|
2716
|
-
const i = this.
|
|
2717
|
-
if (this
|
|
2718
|
-
for (let e = n; e < i; e++) this.Be[e - this.
|
|
2719
|
-
if (this.
|
|
2720
|
-
let e = this.
|
|
2721
|
-
while (e < t && e < this
|
|
2722
|
-
this.Be.splice(0, t - this.
|
|
2723
|
-
this.
|
|
2724
|
-
} else if (this.
|
|
2725
|
-
let n = i - this.
|
|
2726
|
-
let r = this.
|
|
2727
|
-
this.Be.length = this.
|
|
2715
|
+
const i = this.Je + this.Me;
|
|
2716
|
+
if (this.Me === 0 && this.Be[0]) this.Be[0].dispose();
|
|
2717
|
+
for (let e = n; e < i; e++) this.Be[e - this.Je].dispose();
|
|
2718
|
+
if (this.Je < t) {
|
|
2719
|
+
let e = this.Je;
|
|
2720
|
+
while (e < t && e < this.Me) this.Be[e++].dispose();
|
|
2721
|
+
this.Be.splice(0, t - this.Je);
|
|
2722
|
+
this.Ye.splice(0, t - this.Je);
|
|
2723
|
+
} else if (this.Je > t) {
|
|
2724
|
+
let n = i - this.Je - 1;
|
|
2725
|
+
let r = this.Je - t;
|
|
2726
|
+
this.Be.length = this.Ye.length = e;
|
|
2728
2727
|
while (n >= r) {
|
|
2729
2728
|
this.Be[n] = this.Be[n - r];
|
|
2730
|
-
this.
|
|
2729
|
+
this.Ye[n] = this.Ye[n - r];
|
|
2731
2730
|
n--;
|
|
2732
2731
|
}
|
|
2733
2732
|
for (let e = 0; e < r; e++) {
|
|
2734
|
-
this.
|
|
2733
|
+
this.Ye[e] = runWithOwner((this.Be[e] = createOwner()), () => this.Ke(e + t));
|
|
2735
2734
|
}
|
|
2736
2735
|
}
|
|
2737
2736
|
for (let e = i; e < n; e++) {
|
|
2738
|
-
this.
|
|
2737
|
+
this.Ye[e - t] = runWithOwner((this.Be[e - t] = createOwner()), () => this.Ke(e));
|
|
2739
2738
|
}
|
|
2740
|
-
this.
|
|
2741
|
-
this.
|
|
2742
|
-
this
|
|
2739
|
+
this.Ye = this.Ye.slice(0, e);
|
|
2740
|
+
this.Je = t;
|
|
2741
|
+
this.Me = e;
|
|
2743
2742
|
});
|
|
2744
|
-
return this.
|
|
2743
|
+
return this.Ye;
|
|
2745
2744
|
}
|
|
2746
2745
|
function compare(e, t, n) {
|
|
2747
2746
|
return e ? e(t) === e(n) : true;
|
|
2748
2747
|
}
|
|
2749
2748
|
function boundaryComputed(e, t) {
|
|
2750
2749
|
const n = computed(e, undefined, { lazy: true });
|
|
2751
|
-
n.
|
|
2750
|
+
n.he = (e, t) => {
|
|
2752
2751
|
const i = e !== undefined ? e : n.Ee;
|
|
2753
|
-
const r = t !== undefined ? t : n.
|
|
2754
|
-
n.Ee &= ~n.
|
|
2755
|
-
n.ce.notify(n, n.
|
|
2752
|
+
const r = t !== undefined ? t : n.q;
|
|
2753
|
+
n.Ee &= ~n.nt;
|
|
2754
|
+
n.ce.notify(n, n.nt, i, r);
|
|
2756
2755
|
};
|
|
2757
|
-
n.
|
|
2758
|
-
n.
|
|
2756
|
+
n.nt = t;
|
|
2757
|
+
n.Pe = true;
|
|
2759
2758
|
recompute(n, true);
|
|
2760
2759
|
return n;
|
|
2761
2760
|
}
|
|
@@ -2768,64 +2767,90 @@ function createBoundChildren(e, t, n, i) {
|
|
|
2768
2767
|
return boundaryComputed(() => staleValues(() => flatten(read(e))), i);
|
|
2769
2768
|
});
|
|
2770
2769
|
}
|
|
2770
|
+
const ON_INIT = Symbol();
|
|
2771
2771
|
class CollectionQueue extends Queue {
|
|
2772
|
-
|
|
2773
|
-
|
|
2772
|
+
it;
|
|
2773
|
+
rt = new Set();
|
|
2774
2774
|
ot = signal(false, { pureWrite: true });
|
|
2775
|
-
|
|
2775
|
+
st = false;
|
|
2776
|
+
ut;
|
|
2777
|
+
ct = ON_INIT;
|
|
2776
2778
|
constructor(e) {
|
|
2777
2779
|
super();
|
|
2778
|
-
this.
|
|
2780
|
+
this.it = e;
|
|
2779
2781
|
}
|
|
2780
2782
|
run(e) {
|
|
2781
2783
|
if (!e || read(this.ot)) return;
|
|
2782
2784
|
return super.run(e);
|
|
2783
2785
|
}
|
|
2784
2786
|
notify(e, t, n, i) {
|
|
2785
|
-
if (!(t & this.
|
|
2786
|
-
if (
|
|
2787
|
-
const
|
|
2787
|
+
if (!(t & this.it)) return super.notify(e, t, n, i);
|
|
2788
|
+
if (this.st && this.ut) {
|
|
2789
|
+
const e = untrack(() => {
|
|
2790
|
+
try {
|
|
2791
|
+
return this.ut();
|
|
2792
|
+
} catch {
|
|
2793
|
+
return ON_INIT;
|
|
2794
|
+
}
|
|
2795
|
+
});
|
|
2796
|
+
if (e !== this.ct) {
|
|
2797
|
+
this.ct = e;
|
|
2798
|
+
this.st = false;
|
|
2799
|
+
this.rt.clear();
|
|
2800
|
+
}
|
|
2801
|
+
}
|
|
2802
|
+
if (this.it & STATUS_PENDING && this.st) return super.notify(e, t, n, i);
|
|
2803
|
+
if (n & this.it) {
|
|
2804
|
+
const t = i?.source || e.q?.source;
|
|
2788
2805
|
if (t) {
|
|
2789
|
-
const e = this.
|
|
2790
|
-
this.
|
|
2806
|
+
const e = this.rt.size === 0;
|
|
2807
|
+
this.rt.add(t);
|
|
2791
2808
|
if (e) setSignal(this.ot, true);
|
|
2792
2809
|
}
|
|
2793
2810
|
}
|
|
2794
|
-
t &= ~this.
|
|
2811
|
+
t &= ~this.it;
|
|
2795
2812
|
return t ? super.notify(e, t, n, i) : true;
|
|
2796
2813
|
}
|
|
2797
2814
|
checkSources() {
|
|
2798
|
-
for (const e of this.
|
|
2799
|
-
if (!(e.Ee & this.
|
|
2815
|
+
for (const e of this.rt) {
|
|
2816
|
+
if (!(e.Ee & this.it)) this.rt.delete(e);
|
|
2817
|
+
}
|
|
2818
|
+
if (!this.rt.size) {
|
|
2819
|
+
setSignal(this.ot, false);
|
|
2820
|
+
if (this.ut) {
|
|
2821
|
+
try {
|
|
2822
|
+
this.ct = untrack(() => this.ut());
|
|
2823
|
+
} catch {}
|
|
2824
|
+
}
|
|
2800
2825
|
}
|
|
2801
|
-
if (!this.st.size) setSignal(this.ot, false);
|
|
2802
2826
|
}
|
|
2803
2827
|
}
|
|
2804
|
-
function createCollectionBoundary(e, t, n) {
|
|
2805
|
-
const
|
|
2806
|
-
const
|
|
2807
|
-
|
|
2808
|
-
const
|
|
2809
|
-
|
|
2828
|
+
function createCollectionBoundary(e, t, n, i) {
|
|
2829
|
+
const r = createOwner();
|
|
2830
|
+
const o = new CollectionQueue(e);
|
|
2831
|
+
if (i) o.ut = i;
|
|
2832
|
+
const s = createBoundChildren(r, t, o, e);
|
|
2833
|
+
const u = computed(() => {
|
|
2834
|
+
if (!read(o.ot)) {
|
|
2810
2835
|
const e = read(s);
|
|
2811
|
-
if (!untrack(() => read(
|
|
2812
|
-
|
|
2836
|
+
if (!untrack(() => read(o.ot))) {
|
|
2837
|
+
o.st = true;
|
|
2813
2838
|
return e;
|
|
2814
2839
|
}
|
|
2815
2840
|
}
|
|
2816
|
-
return n(
|
|
2841
|
+
return n(o);
|
|
2817
2842
|
});
|
|
2818
|
-
return
|
|
2843
|
+
return accessor(u);
|
|
2819
2844
|
}
|
|
2820
|
-
function
|
|
2821
|
-
return createCollectionBoundary(STATUS_PENDING, e, () => t());
|
|
2845
|
+
function createLoadingBoundary(e, t, n) {
|
|
2846
|
+
return createCollectionBoundary(STATUS_PENDING, e, () => t(), n?.on);
|
|
2822
2847
|
}
|
|
2823
2848
|
function createErrorBoundary(e, t) {
|
|
2824
2849
|
return createCollectionBoundary(STATUS_ERROR, e, e => {
|
|
2825
|
-
let n = e.
|
|
2826
|
-
const i = n.
|
|
2850
|
+
let n = e.rt.values().next().value;
|
|
2851
|
+
const i = n.q?.cause ?? n.q;
|
|
2827
2852
|
return t(i, () => {
|
|
2828
|
-
for (const t of e.
|
|
2853
|
+
for (const t of e.rt) recompute(t);
|
|
2829
2854
|
schedule();
|
|
2830
2855
|
});
|
|
2831
2856
|
});
|
|
@@ -2854,9 +2879,9 @@ function flatten(e, t) {
|
|
|
2854
2879
|
function flattenArray(e, t = [], n) {
|
|
2855
2880
|
let i = null;
|
|
2856
2881
|
let r = false;
|
|
2857
|
-
for (let
|
|
2882
|
+
for (let o = 0; o < e.length; o++) {
|
|
2858
2883
|
try {
|
|
2859
|
-
let i = e[
|
|
2884
|
+
let i = e[o];
|
|
2860
2885
|
if (typeof i === "function" && !i.length) {
|
|
2861
2886
|
if (n?.doNotUnwrap) {
|
|
2862
2887
|
t.push(i);
|
|
@@ -2893,7 +2918,7 @@ export {
|
|
|
2893
2918
|
createContext,
|
|
2894
2919
|
createEffect,
|
|
2895
2920
|
createErrorBoundary,
|
|
2896
|
-
|
|
2921
|
+
createLoadingBoundary,
|
|
2897
2922
|
createMemo,
|
|
2898
2923
|
createOptimistic,
|
|
2899
2924
|
createOptimisticStore,
|
|
@@ -2906,6 +2931,8 @@ export {
|
|
|
2906
2931
|
createStore,
|
|
2907
2932
|
createTrackedEffect,
|
|
2908
2933
|
deep,
|
|
2934
|
+
enableExternalSource,
|
|
2935
|
+
enforceLoadingBoundary,
|
|
2909
2936
|
flatten,
|
|
2910
2937
|
flush,
|
|
2911
2938
|
getContext,
|
|
@@ -2932,7 +2959,6 @@ export {
|
|
|
2932
2959
|
resolve,
|
|
2933
2960
|
runWithOwner,
|
|
2934
2961
|
setContext,
|
|
2935
|
-
setOnUnhandledAsync,
|
|
2936
2962
|
setSnapshotCapture,
|
|
2937
2963
|
snapshot,
|
|
2938
2964
|
storePath,
|