@solidjs/signals 0.12.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/dev.js +228 -184
- package/dist/node.cjs +902 -873
- package/dist/prod.js +787 -753
- 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,65 @@ 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) {
|
|
386
|
+
const e = n.q?.source;
|
|
387
|
+
if (e && !(e.Ee & STATUS_PENDING)) {
|
|
388
|
+
n.Ee &= -6;
|
|
389
|
+
n.q = null;
|
|
390
|
+
}
|
|
391
|
+
} else n.Ee &= ~STATUS_UNINITIALIZED;
|
|
392
|
+
if (n.L) GlobalQueue.Y(n, false, true);
|
|
393
|
+
}
|
|
394
|
+
e.length = 0;
|
|
395
|
+
}
|
|
376
396
|
function finalizePureQueue(e = null, t = false) {
|
|
377
397
|
let n = !t;
|
|
398
|
+
if (n) commitPendingNodes();
|
|
378
399
|
if (!t) checkBoundaryChildren(globalQueue);
|
|
379
|
-
if (dirtyQueue.R >= dirtyQueue.
|
|
400
|
+
if (dirtyQueue.R >= dirtyQueue.P) runHeap(dirtyQueue, GlobalQueue.K);
|
|
380
401
|
if (n) {
|
|
381
|
-
|
|
402
|
+
commitPendingNodes();
|
|
403
|
+
const t = e ? e.$ : globalQueue.$;
|
|
382
404
|
for (let e = 0; e < t.length; e++) {
|
|
383
405
|
const n = t[e];
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
n.
|
|
387
|
-
|
|
406
|
+
n.ie = undefined;
|
|
407
|
+
if (n.le !== NOT_PENDING) {
|
|
408
|
+
n.fe = n.le;
|
|
409
|
+
n.le = NOT_PENDING;
|
|
388
410
|
}
|
|
389
|
-
|
|
390
|
-
|
|
411
|
+
const i = n.Te;
|
|
412
|
+
n.Te = NOT_PENDING;
|
|
413
|
+
if (i !== NOT_PENDING && n.fe !== i) insertSubs(n, true);
|
|
414
|
+
n.ne = null;
|
|
391
415
|
}
|
|
392
416
|
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();
|
|
417
|
+
const n = e ? e.j : globalQueue.j;
|
|
418
|
+
if (GlobalQueue.B && n.size) {
|
|
419
|
+
for (const e of n) {
|
|
420
|
+
GlobalQueue.B(e);
|
|
421
|
+
}
|
|
422
|
+
n.clear();
|
|
412
423
|
schedule();
|
|
413
424
|
}
|
|
414
425
|
for (const t of activeLanes) {
|
|
@@ -418,17 +429,17 @@ function finalizePureQueue(e = null, t = false) {
|
|
|
418
429
|
if (t.W[0].length) runQueue(t.W[0], EFFECT_RENDER);
|
|
419
430
|
if (t.W[1].length) runQueue(t.W[1], EFFECT_USER);
|
|
420
431
|
}
|
|
421
|
-
if (t.
|
|
432
|
+
if (t.de.ie === t) t.de.ie = undefined;
|
|
422
433
|
t.U.clear();
|
|
423
434
|
t.W[0].length = 0;
|
|
424
435
|
t.W[1].length = 0;
|
|
425
436
|
activeLanes.delete(t);
|
|
426
|
-
signalLanes.delete(t.
|
|
437
|
+
signalLanes.delete(t.de);
|
|
427
438
|
}
|
|
428
439
|
}
|
|
429
440
|
}
|
|
430
441
|
function checkBoundaryChildren(e) {
|
|
431
|
-
for (const t of e.
|
|
442
|
+
for (const t of e.F) {
|
|
432
443
|
t.checkSources?.();
|
|
433
444
|
checkBoundaryChildren(t);
|
|
434
445
|
}
|
|
@@ -455,9 +466,9 @@ function transitionComplete(e) {
|
|
|
455
466
|
if (e.te) return true;
|
|
456
467
|
if (e.ee.length) return false;
|
|
457
468
|
let t = true;
|
|
458
|
-
for (let n = 0; n < e.
|
|
459
|
-
const i = e.
|
|
460
|
-
if (i.Ee & STATUS_PENDING && i.
|
|
469
|
+
for (let n = 0; n < e.X.length; n++) {
|
|
470
|
+
const i = e.X[n];
|
|
471
|
+
if (i.Ee & STATUS_PENDING && i.q?.source === i) {
|
|
461
472
|
t = false;
|
|
462
473
|
break;
|
|
463
474
|
}
|
|
@@ -488,12 +499,12 @@ function getOrCreateLane(e) {
|
|
|
488
499
|
if (t) {
|
|
489
500
|
return findLane(t);
|
|
490
501
|
}
|
|
491
|
-
const n = e.
|
|
502
|
+
const n = e.Se;
|
|
492
503
|
const i = n?.ie ? findLane(n.ie) : null;
|
|
493
|
-
t = {
|
|
504
|
+
t = { de: e, U: new Set(), W: [[], []], k: null, ne: activeTransition, Re: i };
|
|
494
505
|
signalLanes.set(e, t);
|
|
495
506
|
activeLanes.add(t);
|
|
496
|
-
e.
|
|
507
|
+
e.Oe = false;
|
|
497
508
|
return t;
|
|
498
509
|
}
|
|
499
510
|
function findLane(e) {
|
|
@@ -519,7 +530,7 @@ function resolveLane(e) {
|
|
|
519
530
|
return undefined;
|
|
520
531
|
}
|
|
521
532
|
function hasActiveOverride(e) {
|
|
522
|
-
return !!(e.
|
|
533
|
+
return !!(e.Te !== undefined && e.Te !== NOT_PENDING);
|
|
523
534
|
}
|
|
524
535
|
function assignOrMergeLane(e, t) {
|
|
525
536
|
const n = findLane(t);
|
|
@@ -532,9 +543,9 @@ function assignOrMergeLane(e, t) {
|
|
|
532
543
|
const r = findLane(i);
|
|
533
544
|
if (activeLanes.has(r)) {
|
|
534
545
|
if (r !== n && !hasActiveOverride(e)) {
|
|
535
|
-
if (n.
|
|
546
|
+
if (n.Re && findLane(n.Re) === r) {
|
|
536
547
|
e.ie = t;
|
|
537
|
-
} else if (r.
|
|
548
|
+
} else if (r.Re && findLane(r.Re) === n);
|
|
538
549
|
else mergeLanes(n, r);
|
|
539
550
|
}
|
|
540
551
|
return;
|
|
@@ -545,43 +556,42 @@ function assignOrMergeLane(e, t) {
|
|
|
545
556
|
function handleAsync(e, t, n) {
|
|
546
557
|
const i = typeof t === "object" && t !== null;
|
|
547
558
|
const r = i && untrack(() => t[Symbol.asyncIterator]);
|
|
548
|
-
const
|
|
549
|
-
if (!
|
|
550
|
-
e.
|
|
559
|
+
const o = !r && i && untrack(() => typeof t.then === "function");
|
|
560
|
+
if (!o && !r) {
|
|
561
|
+
e._e = null;
|
|
551
562
|
return t;
|
|
552
563
|
}
|
|
553
|
-
e.
|
|
554
|
-
let
|
|
564
|
+
e._e = t;
|
|
565
|
+
let s;
|
|
555
566
|
const handleError = n => {
|
|
556
|
-
if (e.
|
|
567
|
+
if (e._e !== t) return;
|
|
557
568
|
globalQueue.initTransition(e.ne);
|
|
558
569
|
notifyStatus(e, n instanceof NotReadyError ? STATUS_PENDING : STATUS_ERROR, n);
|
|
559
570
|
e.J = clock;
|
|
560
571
|
};
|
|
561
572
|
const asyncWrite = (i, r) => {
|
|
562
|
-
if (e.
|
|
573
|
+
if (e._e !== t) return;
|
|
563
574
|
if (e.O & (REACTIVE_DIRTY | REACTIVE_OPTIMISTIC_DIRTY)) return;
|
|
564
575
|
globalQueue.initTransition(e.ne);
|
|
565
576
|
clearStatus(e);
|
|
566
|
-
const
|
|
567
|
-
if (
|
|
577
|
+
const o = resolveLane(e);
|
|
578
|
+
if (o) o.U.delete(e);
|
|
568
579
|
if (n) n(i);
|
|
569
|
-
else if (e.
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
if (!t) {
|
|
580
|
+
else if (e.Te !== undefined) {
|
|
581
|
+
if (e.Te !== undefined && e.Te !== NOT_PENDING) e.le = i;
|
|
582
|
+
else {
|
|
573
583
|
e.fe = i;
|
|
574
584
|
insertSubs(e);
|
|
575
585
|
}
|
|
576
586
|
e.J = clock;
|
|
577
|
-
} else if (
|
|
587
|
+
} else if (o) {
|
|
578
588
|
const t = e.fe;
|
|
579
|
-
const n = e.
|
|
589
|
+
const n = e.Ie;
|
|
580
590
|
if (!n || !n(i, t)) {
|
|
581
591
|
e.fe = i;
|
|
582
592
|
e.J = clock;
|
|
583
|
-
if (e.
|
|
584
|
-
setSignal(e.
|
|
593
|
+
if (e.pe) {
|
|
594
|
+
setSignal(e.pe, i);
|
|
585
595
|
}
|
|
586
596
|
insertSubs(e, true);
|
|
587
597
|
}
|
|
@@ -592,13 +602,13 @@ function handleAsync(e, t, n) {
|
|
|
592
602
|
flush();
|
|
593
603
|
r?.();
|
|
594
604
|
};
|
|
595
|
-
if (
|
|
605
|
+
if (o) {
|
|
596
606
|
let n = false,
|
|
597
607
|
i = true;
|
|
598
608
|
t.then(
|
|
599
609
|
e => {
|
|
600
610
|
if (i) {
|
|
601
|
-
|
|
611
|
+
s = e;
|
|
602
612
|
n = true;
|
|
603
613
|
} else asyncWrite(e);
|
|
604
614
|
},
|
|
@@ -636,7 +646,7 @@ function handleAsync(e, t, n) {
|
|
|
636
646
|
);
|
|
637
647
|
r = false;
|
|
638
648
|
if (t && !e.done) {
|
|
639
|
-
|
|
649
|
+
s = e.value;
|
|
640
650
|
i = true;
|
|
641
651
|
return iterate();
|
|
642
652
|
}
|
|
@@ -648,23 +658,23 @@ function handleAsync(e, t, n) {
|
|
|
648
658
|
throw new NotReadyError(context);
|
|
649
659
|
}
|
|
650
660
|
}
|
|
651
|
-
return
|
|
661
|
+
return s;
|
|
652
662
|
}
|
|
653
663
|
function clearStatus(e) {
|
|
654
664
|
e.Ee = e.Ee & STATUS_UNINITIALIZED;
|
|
655
|
-
e.
|
|
665
|
+
e.q = null;
|
|
656
666
|
updatePendingSignal(e);
|
|
657
|
-
e.
|
|
667
|
+
e.he?.();
|
|
658
668
|
}
|
|
659
669
|
function notifyStatus(e, t, n, i, r) {
|
|
660
670
|
if (t === STATUS_ERROR && !(n instanceof StatusError) && !(n instanceof NotReadyError))
|
|
661
671
|
n = new StatusError(e, n);
|
|
662
|
-
const
|
|
663
|
-
const
|
|
664
|
-
const u =
|
|
672
|
+
const o = n instanceof NotReadyError && n.source === e;
|
|
673
|
+
const s = t === STATUS_PENDING && e.Te !== undefined && !o;
|
|
674
|
+
const u = s && hasActiveOverride(e);
|
|
665
675
|
if (!i) {
|
|
666
676
|
e.Ee = t | (t !== STATUS_ERROR ? e.Ee & STATUS_UNINITIALIZED : 0);
|
|
667
|
-
e.
|
|
677
|
+
e.q = n;
|
|
668
678
|
updatePendingSignal(e);
|
|
669
679
|
}
|
|
670
680
|
if (r && !i) {
|
|
@@ -672,50 +682,50 @@ function notifyStatus(e, t, n, i, r) {
|
|
|
672
682
|
}
|
|
673
683
|
if (u && activeTransition && n instanceof NotReadyError) {
|
|
674
684
|
const e = n.source;
|
|
675
|
-
if (!activeTransition.
|
|
676
|
-
activeTransition.
|
|
685
|
+
if (!activeTransition.X.includes(e)) {
|
|
686
|
+
activeTransition.X.push(e);
|
|
677
687
|
}
|
|
678
688
|
}
|
|
679
689
|
const c = i || u;
|
|
680
|
-
const
|
|
681
|
-
if (e.
|
|
690
|
+
const a = i || s ? undefined : r;
|
|
691
|
+
if (e.he) {
|
|
682
692
|
if (c) {
|
|
683
|
-
e.
|
|
693
|
+
e.he(t, n);
|
|
684
694
|
} else {
|
|
685
|
-
e.
|
|
695
|
+
e.he();
|
|
686
696
|
}
|
|
687
697
|
return;
|
|
688
698
|
}
|
|
689
699
|
for (let i = e.I; i !== null; i = i.p) {
|
|
690
700
|
i.h.J = clock;
|
|
691
|
-
if (i.h.
|
|
692
|
-
!i.h.ne && globalQueue.
|
|
693
|
-
notifyStatus(i.h, t, n, c,
|
|
701
|
+
if (i.h.q !== n) {
|
|
702
|
+
!i.h.ne && globalQueue.M.push(i.h);
|
|
703
|
+
notifyStatus(i.h, t, n, c, a);
|
|
694
704
|
}
|
|
695
705
|
}
|
|
696
|
-
for (let i = e.A; i !== null; i = i.
|
|
706
|
+
for (let i = e.A; i !== null; i = i.N) {
|
|
697
707
|
for (let e = i.I; e !== null; e = e.p) {
|
|
698
708
|
e.h.J = clock;
|
|
699
|
-
if (e.h.
|
|
700
|
-
!e.h.ne && globalQueue.
|
|
701
|
-
notifyStatus(e.h, t, n, c,
|
|
709
|
+
if (e.h.q !== n) {
|
|
710
|
+
!e.h.ne && globalQueue.M.push(e.h);
|
|
711
|
+
notifyStatus(e.h, t, n, c, a);
|
|
702
712
|
}
|
|
703
713
|
}
|
|
704
714
|
}
|
|
705
715
|
}
|
|
706
716
|
function unlinkSubs(e) {
|
|
707
|
-
const t = e.
|
|
717
|
+
const t = e.m;
|
|
708
718
|
const n = e.D;
|
|
709
719
|
const i = e.p;
|
|
710
|
-
const r = e.
|
|
711
|
-
if (i !== null) i.
|
|
720
|
+
const r = e.Ae;
|
|
721
|
+
if (i !== null) i.Ae = r;
|
|
712
722
|
else t.Ne = r;
|
|
713
723
|
if (r !== null) r.p = i;
|
|
714
724
|
else {
|
|
715
725
|
t.I = i;
|
|
716
726
|
if (i === null) {
|
|
717
727
|
t.ge?.();
|
|
718
|
-
t.L && !t.
|
|
728
|
+
t.L && !t.Pe && !(t.O & REACTIVE_ZOMBIE) && unobserved(t);
|
|
719
729
|
}
|
|
720
730
|
}
|
|
721
731
|
return n;
|
|
@@ -730,27 +740,27 @@ function unobserved(e) {
|
|
|
730
740
|
disposeChildren(e, true);
|
|
731
741
|
}
|
|
732
742
|
function link(e, t) {
|
|
733
|
-
const n = t.
|
|
734
|
-
if (n !== null && n.
|
|
743
|
+
const n = t.Ce;
|
|
744
|
+
if (n !== null && n.m === e) return;
|
|
735
745
|
let i = null;
|
|
736
746
|
const r = t.O & REACTIVE_RECOMPUTING_DEPS;
|
|
737
747
|
if (r) {
|
|
738
748
|
i = n !== null ? n.D : t.C;
|
|
739
|
-
if (i !== null && i.
|
|
740
|
-
t.
|
|
749
|
+
if (i !== null && i.m === e) {
|
|
750
|
+
t.Ce = i;
|
|
741
751
|
return;
|
|
742
752
|
}
|
|
743
753
|
}
|
|
744
|
-
const
|
|
745
|
-
if (
|
|
746
|
-
const
|
|
747
|
-
if (n !== null) n.D =
|
|
748
|
-
else t.C =
|
|
749
|
-
if (
|
|
750
|
-
else e.I =
|
|
754
|
+
const o = e.Ne;
|
|
755
|
+
if (o !== null && o.h === t && (!r || isValidLink(o, t))) return;
|
|
756
|
+
const s = (t.Ce = e.Ne = { m: e, h: t, D: i, Ae: o, p: null });
|
|
757
|
+
if (n !== null) n.D = s;
|
|
758
|
+
else t.C = s;
|
|
759
|
+
if (o !== null) o.p = s;
|
|
760
|
+
else e.I = s;
|
|
751
761
|
}
|
|
752
762
|
function isValidLink(e, t) {
|
|
753
|
-
const n = t.
|
|
763
|
+
const n = t.Ce;
|
|
754
764
|
if (n !== null) {
|
|
755
765
|
let i = t.C;
|
|
756
766
|
do {
|
|
@@ -771,7 +781,7 @@ function markDisposal(e) {
|
|
|
771
781
|
insertIntoHeap(t, zombieQueue);
|
|
772
782
|
}
|
|
773
783
|
markDisposal(t);
|
|
774
|
-
t = t.
|
|
784
|
+
t = t.ye;
|
|
775
785
|
}
|
|
776
786
|
}
|
|
777
787
|
function dispose(e) {
|
|
@@ -780,15 +790,15 @@ function dispose(e) {
|
|
|
780
790
|
t = unlinkSubs(t);
|
|
781
791
|
} while (t !== null);
|
|
782
792
|
e.C = null;
|
|
783
|
-
e.
|
|
793
|
+
e.Ce = null;
|
|
784
794
|
disposeChildren(e, true);
|
|
785
795
|
}
|
|
786
796
|
function disposeChildren(e, t = false, n) {
|
|
787
797
|
if (e.O & REACTIVE_DISPOSED) return;
|
|
788
798
|
if (t) e.O = REACTIVE_DISPOSED;
|
|
789
|
-
let i = n ? e.
|
|
799
|
+
let i = n ? e.ve : e.De;
|
|
790
800
|
while (i) {
|
|
791
|
-
const e = i.
|
|
801
|
+
const e = i.ye;
|
|
792
802
|
if (i.C) {
|
|
793
803
|
const e = i;
|
|
794
804
|
deleteFromHeap(e, e.O & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
@@ -797,22 +807,21 @@ function disposeChildren(e, t = false, n) {
|
|
|
797
807
|
t = unlinkSubs(t);
|
|
798
808
|
} while (t !== null);
|
|
799
809
|
e.C = null;
|
|
800
|
-
e.
|
|
810
|
+
e.Ce = null;
|
|
801
811
|
}
|
|
802
812
|
disposeChildren(i, true);
|
|
803
813
|
i = e;
|
|
804
814
|
}
|
|
805
815
|
if (n) {
|
|
806
|
-
e.
|
|
816
|
+
e.ve = null;
|
|
807
817
|
} else {
|
|
808
818
|
e.De = null;
|
|
809
|
-
e.ve = null;
|
|
810
819
|
e.we = 0;
|
|
811
820
|
}
|
|
812
821
|
runDisposal(e, n);
|
|
813
822
|
}
|
|
814
823
|
function runDisposal(e, t) {
|
|
815
|
-
let n = t ? e.
|
|
824
|
+
let n = t ? e.be : e.me;
|
|
816
825
|
if (!n) return;
|
|
817
826
|
if (Array.isArray(n)) {
|
|
818
827
|
for (let e = 0; e < n.length; e++) {
|
|
@@ -822,11 +831,11 @@ function runDisposal(e, t) {
|
|
|
822
831
|
} else {
|
|
823
832
|
n.call(n);
|
|
824
833
|
}
|
|
825
|
-
t ? (e.
|
|
834
|
+
t ? (e.be = null) : (e.me = null);
|
|
826
835
|
}
|
|
827
836
|
function childId(e, t) {
|
|
828
837
|
let n = e;
|
|
829
|
-
while (n.
|
|
838
|
+
while (n.Ve && n.i) n = n.i;
|
|
830
839
|
if (n.id != null) return formatId(n.id, t ? n.we++ : n.we);
|
|
831
840
|
throw new Error("Cannot get child id from owner without an id");
|
|
832
841
|
}
|
|
@@ -863,17 +872,17 @@ function createOwner(e) {
|
|
|
863
872
|
const n = e?.transparent ?? false;
|
|
864
873
|
const i = {
|
|
865
874
|
id: e?.id ?? (n ? t?.id : t?.id != null ? getNextChildId(t) : undefined),
|
|
866
|
-
|
|
875
|
+
Ve: n || undefined,
|
|
867
876
|
t: true,
|
|
868
877
|
u: t?.t ? t.u : t,
|
|
869
878
|
De: null,
|
|
870
|
-
|
|
879
|
+
ye: null,
|
|
871
880
|
me: null,
|
|
872
881
|
ce: t?.ce ?? globalQueue,
|
|
873
|
-
|
|
882
|
+
Le: t?.Le || defaultContext,
|
|
874
883
|
we: 0,
|
|
875
|
-
Ve: null,
|
|
876
884
|
be: null,
|
|
885
|
+
ve: null,
|
|
877
886
|
i: t,
|
|
878
887
|
dispose(e = true) {
|
|
879
888
|
disposeChildren(i, e);
|
|
@@ -884,7 +893,7 @@ function createOwner(e) {
|
|
|
884
893
|
if (e === null) {
|
|
885
894
|
t.De = i;
|
|
886
895
|
} else {
|
|
887
|
-
i.
|
|
896
|
+
i.ye = e;
|
|
888
897
|
t.De = i;
|
|
889
898
|
}
|
|
890
899
|
}
|
|
@@ -895,57 +904,59 @@ function createRoot(e, t) {
|
|
|
895
904
|
return runWithOwner(n, () => e(n.dispose));
|
|
896
905
|
}
|
|
897
906
|
function effect(e, t, n, i, r) {
|
|
898
|
-
let
|
|
899
|
-
const
|
|
907
|
+
let o = false;
|
|
908
|
+
const s = computed(r?.render ? t => staleValues(() => e(t)) : e, i, {
|
|
900
909
|
...r,
|
|
901
910
|
equals: () => {
|
|
902
|
-
|
|
903
|
-
if (
|
|
911
|
+
s.ue = !s.q;
|
|
912
|
+
if (o) s.ce.enqueue(s.se, runEffect.bind(s));
|
|
904
913
|
return false;
|
|
905
914
|
},
|
|
906
915
|
lazy: true
|
|
907
916
|
});
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
const n = e !== undefined ? e :
|
|
915
|
-
const i = t !== undefined ? t :
|
|
917
|
+
s.ke = i;
|
|
918
|
+
s.Ue = t;
|
|
919
|
+
s.xe = n;
|
|
920
|
+
s.We = undefined;
|
|
921
|
+
s.se = r?.render ? EFFECT_RENDER : EFFECT_USER;
|
|
922
|
+
s.he = (e, t) => {
|
|
923
|
+
const n = e !== undefined ? e : s.Ee;
|
|
924
|
+
const i = t !== undefined ? t : s.q;
|
|
916
925
|
if (n & STATUS_ERROR) {
|
|
917
926
|
let e = i;
|
|
918
|
-
|
|
919
|
-
if (
|
|
927
|
+
s.ce.notify(s, STATUS_PENDING, 0);
|
|
928
|
+
if (s.se === EFFECT_USER) {
|
|
920
929
|
try {
|
|
921
|
-
return
|
|
922
|
-
?
|
|
923
|
-
|
|
924
|
-
|
|
930
|
+
return s.xe
|
|
931
|
+
? s.xe(e, () => {
|
|
932
|
+
s.We?.();
|
|
933
|
+
s.We = undefined;
|
|
925
934
|
})
|
|
926
935
|
: console.error(e);
|
|
927
936
|
} catch (t) {
|
|
928
937
|
e = t;
|
|
929
938
|
}
|
|
930
939
|
}
|
|
931
|
-
if (!
|
|
932
|
-
} else if (
|
|
940
|
+
if (!s.ce.notify(s, STATUS_ERROR, STATUS_ERROR)) throw e;
|
|
941
|
+
} else if (s.se === EFFECT_RENDER) {
|
|
942
|
+
s.ce.notify(s, STATUS_PENDING | STATUS_ERROR, n, i);
|
|
943
|
+
}
|
|
933
944
|
};
|
|
934
|
-
recompute(
|
|
935
|
-
!r?.defer && (
|
|
936
|
-
|
|
937
|
-
onCleanup(() =>
|
|
945
|
+
recompute(s, true);
|
|
946
|
+
!r?.defer && (s.se === EFFECT_USER ? s.ce.enqueue(s.se, runEffect.bind(s)) : runEffect.call(s));
|
|
947
|
+
o = true;
|
|
948
|
+
onCleanup(() => s.We?.());
|
|
938
949
|
}
|
|
939
950
|
function runEffect() {
|
|
940
951
|
if (!this.ue || this.O & REACTIVE_DISPOSED) return;
|
|
941
|
-
this.
|
|
942
|
-
this.
|
|
952
|
+
this.We?.();
|
|
953
|
+
this.We = undefined;
|
|
943
954
|
try {
|
|
944
|
-
this.
|
|
955
|
+
this.We = this.Ue(this.fe, this.ke);
|
|
945
956
|
} catch (e) {
|
|
946
957
|
if (!this.ce.notify(this, STATUS_ERROR, STATUS_ERROR)) throw e;
|
|
947
958
|
} finally {
|
|
948
|
-
this.
|
|
959
|
+
this.ke = this.fe;
|
|
949
960
|
this.ue = false;
|
|
950
961
|
}
|
|
951
962
|
}
|
|
@@ -958,21 +969,44 @@ function trackedEffect(e, t) {
|
|
|
958
969
|
const n = computed(
|
|
959
970
|
() => {
|
|
960
971
|
try {
|
|
961
|
-
n.
|
|
962
|
-
n.
|
|
963
|
-
n.
|
|
972
|
+
n.We?.();
|
|
973
|
+
n.We = undefined;
|
|
974
|
+
n.We = staleValues(e) || undefined;
|
|
964
975
|
} finally {
|
|
965
976
|
}
|
|
966
977
|
},
|
|
967
978
|
undefined,
|
|
968
979
|
{ ...t, lazy: true }
|
|
969
980
|
);
|
|
970
|
-
n.
|
|
981
|
+
n.We = undefined;
|
|
971
982
|
n.ue = true;
|
|
972
|
-
n.
|
|
973
|
-
n.
|
|
983
|
+
n.se = EFFECT_TRACKED;
|
|
984
|
+
n.ae = run;
|
|
974
985
|
n.ce.enqueue(EFFECT_USER, run);
|
|
975
|
-
onCleanup(() => n.
|
|
986
|
+
onCleanup(() => n.We?.());
|
|
987
|
+
}
|
|
988
|
+
let externalSourceConfig = null;
|
|
989
|
+
function enableExternalSource(e) {
|
|
990
|
+
const { factory: t, untrack: n = e => e() } = e;
|
|
991
|
+
if (externalSourceConfig) {
|
|
992
|
+
const { factory: e, untrack: i } = externalSourceConfig;
|
|
993
|
+
externalSourceConfig = {
|
|
994
|
+
factory: (n, i) => {
|
|
995
|
+
const r = e(n, i);
|
|
996
|
+
const o = t(e => r.track(e), i);
|
|
997
|
+
return {
|
|
998
|
+
track: e => o.track(e),
|
|
999
|
+
dispose() {
|
|
1000
|
+
o.dispose();
|
|
1001
|
+
r.dispose();
|
|
1002
|
+
}
|
|
1003
|
+
};
|
|
1004
|
+
},
|
|
1005
|
+
untrack: e => i(() => n(e))
|
|
1006
|
+
};
|
|
1007
|
+
} else {
|
|
1008
|
+
externalSourceConfig = { factory: t, untrack: n };
|
|
1009
|
+
}
|
|
976
1010
|
}
|
|
977
1011
|
GlobalQueue.K = recompute;
|
|
978
1012
|
GlobalQueue.Y = disposeChildren;
|
|
@@ -988,7 +1022,7 @@ let snapshotCaptureActive = false;
|
|
|
988
1022
|
let snapshotSources = null;
|
|
989
1023
|
function ownerInSnapshotScope(e) {
|
|
990
1024
|
while (e) {
|
|
991
|
-
if (e.
|
|
1025
|
+
if (e.He) return true;
|
|
992
1026
|
e = e.i;
|
|
993
1027
|
}
|
|
994
1028
|
return false;
|
|
@@ -998,32 +1032,32 @@ function setSnapshotCapture(e) {
|
|
|
998
1032
|
if (e && !snapshotSources) snapshotSources = new Set();
|
|
999
1033
|
}
|
|
1000
1034
|
function markSnapshotScope(e) {
|
|
1001
|
-
e.
|
|
1035
|
+
e.He = true;
|
|
1002
1036
|
}
|
|
1003
1037
|
function releaseSnapshotScope(e) {
|
|
1004
|
-
e.
|
|
1038
|
+
e.He = false;
|
|
1005
1039
|
releaseSubtree(e);
|
|
1006
1040
|
schedule();
|
|
1007
1041
|
}
|
|
1008
1042
|
function releaseSubtree(e) {
|
|
1009
1043
|
let t = e.De;
|
|
1010
1044
|
while (t) {
|
|
1011
|
-
if (t.
|
|
1012
|
-
t = t.
|
|
1045
|
+
if (t.He) {
|
|
1046
|
+
t = t.ye;
|
|
1013
1047
|
continue;
|
|
1014
1048
|
}
|
|
1015
1049
|
if (t.L) {
|
|
1016
1050
|
const e = t;
|
|
1017
|
-
e.
|
|
1051
|
+
e.oe = false;
|
|
1018
1052
|
if (e.O & REACTIVE_SNAPSHOT_STALE) {
|
|
1019
1053
|
e.O &= ~REACTIVE_SNAPSHOT_STALE;
|
|
1020
1054
|
e.O |= REACTIVE_DIRTY;
|
|
1021
|
-
if (dirtyQueue.
|
|
1055
|
+
if (dirtyQueue.P > e.o) dirtyQueue.P = e.o;
|
|
1022
1056
|
insertIntoHeap(e, dirtyQueue);
|
|
1023
1057
|
}
|
|
1024
1058
|
}
|
|
1025
1059
|
releaseSubtree(t);
|
|
1026
|
-
t = t.
|
|
1060
|
+
t = t.ye;
|
|
1027
1061
|
}
|
|
1028
1062
|
}
|
|
1029
1063
|
function clearSnapshots() {
|
|
@@ -1037,7 +1071,7 @@ function clearSnapshots() {
|
|
|
1037
1071
|
snapshotCaptureActive = false;
|
|
1038
1072
|
}
|
|
1039
1073
|
function recompute(e, t = false) {
|
|
1040
|
-
const n = e.
|
|
1074
|
+
const n = e.se;
|
|
1041
1075
|
if (!t) {
|
|
1042
1076
|
if (e.ne && (!n || activeTransition) && activeTransition !== e.ne)
|
|
1043
1077
|
globalQueue.initTransition(e.ne);
|
|
@@ -1045,25 +1079,25 @@ function recompute(e, t = false) {
|
|
|
1045
1079
|
if (e.ne || n === EFFECT_TRACKED) disposeChildren(e);
|
|
1046
1080
|
else {
|
|
1047
1081
|
markDisposal(e);
|
|
1048
|
-
e.
|
|
1049
|
-
e.
|
|
1082
|
+
e.be = e.me;
|
|
1083
|
+
e.ve = e.De;
|
|
1050
1084
|
e.me = null;
|
|
1051
1085
|
e.De = null;
|
|
1052
1086
|
e.we = 0;
|
|
1053
1087
|
}
|
|
1054
1088
|
}
|
|
1055
1089
|
const i = !!(e.O & REACTIVE_OPTIMISTIC_DIRTY);
|
|
1056
|
-
const r =
|
|
1057
|
-
const
|
|
1058
|
-
const
|
|
1090
|
+
const r = e.Te !== undefined && e.Te !== NOT_PENDING;
|
|
1091
|
+
const o = !!(e.Ee & STATUS_PENDING);
|
|
1092
|
+
const s = context;
|
|
1059
1093
|
context = e;
|
|
1060
|
-
e.
|
|
1094
|
+
e.Ce = null;
|
|
1061
1095
|
e.O = REACTIVE_RECOMPUTING_DEPS;
|
|
1062
1096
|
e.J = clock;
|
|
1063
|
-
let u = e.
|
|
1097
|
+
let u = e.le === NOT_PENDING ? e.fe : e.le;
|
|
1064
1098
|
let c = e.o;
|
|
1065
|
-
let
|
|
1066
|
-
let
|
|
1099
|
+
let a = tracking;
|
|
1100
|
+
let l = currentOptimisticLane;
|
|
1067
1101
|
tracking = true;
|
|
1068
1102
|
if (i) {
|
|
1069
1103
|
const t = resolveLane(e);
|
|
@@ -1075,15 +1109,15 @@ function recompute(e, t = false) {
|
|
|
1075
1109
|
const t = resolveLane(e);
|
|
1076
1110
|
if (t) {
|
|
1077
1111
|
t.U.delete(e);
|
|
1078
|
-
updatePendingSignal(t.
|
|
1112
|
+
updatePendingSignal(t.de);
|
|
1079
1113
|
}
|
|
1080
1114
|
} catch (t) {
|
|
1081
1115
|
if (t instanceof NotReadyError && currentOptimisticLane) {
|
|
1082
1116
|
const t = findLane(currentOptimisticLane);
|
|
1083
|
-
if (t.
|
|
1117
|
+
if (t.de !== e) {
|
|
1084
1118
|
t.U.add(e);
|
|
1085
1119
|
e.ie = t;
|
|
1086
|
-
updatePendingSignal(t.
|
|
1120
|
+
updatePendingSignal(t.de);
|
|
1087
1121
|
}
|
|
1088
1122
|
}
|
|
1089
1123
|
notifyStatus(
|
|
@@ -1094,51 +1128,50 @@ function recompute(e, t = false) {
|
|
|
1094
1128
|
t instanceof NotReadyError ? e.ie : undefined
|
|
1095
1129
|
);
|
|
1096
1130
|
} finally {
|
|
1097
|
-
tracking =
|
|
1131
|
+
tracking = a;
|
|
1098
1132
|
e.O = REACTIVE_NONE | (t ? e.O & REACTIVE_SNAPSHOT_STALE : 0);
|
|
1099
|
-
context =
|
|
1133
|
+
context = s;
|
|
1100
1134
|
}
|
|
1101
|
-
if (!e.
|
|
1102
|
-
const
|
|
1103
|
-
let
|
|
1104
|
-
if (
|
|
1135
|
+
if (!e.q) {
|
|
1136
|
+
const s = e.Ce;
|
|
1137
|
+
let a = s !== null ? s.D : e.C;
|
|
1138
|
+
if (a !== null) {
|
|
1105
1139
|
do {
|
|
1106
|
-
|
|
1107
|
-
} while (
|
|
1108
|
-
if (
|
|
1140
|
+
a = unlinkSubs(a);
|
|
1141
|
+
} while (a !== null);
|
|
1142
|
+
if (s !== null) s.D = null;
|
|
1109
1143
|
else e.C = null;
|
|
1110
1144
|
}
|
|
1111
|
-
const
|
|
1112
|
-
const f = !e.
|
|
1145
|
+
const l = r ? e.Te : e.le === NOT_PENDING ? e.fe : e.le;
|
|
1146
|
+
const f = !e.Ie || !e.Ie(l, u);
|
|
1113
1147
|
if (f) {
|
|
1114
|
-
const
|
|
1115
|
-
if (t || (n && activeTransition !== e.ne) || i)
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
}
|
|
1122
|
-
if (
|
|
1123
|
-
|
|
1124
|
-
}
|
|
1148
|
+
const s = r ? e.Te : undefined;
|
|
1149
|
+
if (t || (n && activeTransition !== e.ne) || i) {
|
|
1150
|
+
e.fe = u;
|
|
1151
|
+
if (r && i) {
|
|
1152
|
+
e.Te = u;
|
|
1153
|
+
e.le = u;
|
|
1154
|
+
}
|
|
1155
|
+
} else e.le = u;
|
|
1156
|
+
if (r && !i && o && !e.Oe) e.Te = u;
|
|
1157
|
+
if (!r || i || e.Te !== s) insertSubs(e, i || r);
|
|
1125
1158
|
} else if (r) {
|
|
1126
|
-
e.
|
|
1159
|
+
e.le = u;
|
|
1127
1160
|
} else if (e.o != c) {
|
|
1128
1161
|
for (let t = e.I; t !== null; t = t.p) {
|
|
1129
1162
|
insertIntoHeapHeight(t.h, t.h.O & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
1130
1163
|
}
|
|
1131
1164
|
}
|
|
1132
1165
|
}
|
|
1133
|
-
currentOptimisticLane =
|
|
1134
|
-
(!t || e.Ee & STATUS_PENDING) && !e.ne && !(activeTransition &&
|
|
1166
|
+
currentOptimisticLane = l;
|
|
1167
|
+
(!t || e.Ee & STATUS_PENDING) && !e.ne && !(activeTransition && r) && globalQueue.M.push(e);
|
|
1135
1168
|
e.ne && n && activeTransition !== e.ne && runInTransition(e.ne, () => recompute(e));
|
|
1136
1169
|
}
|
|
1137
1170
|
function updateIfNecessary(e) {
|
|
1138
1171
|
if (e.O & REACTIVE_CHECK) {
|
|
1139
1172
|
for (let t = e.C; t; t = t.D) {
|
|
1140
|
-
const n = t.
|
|
1141
|
-
const i = n.
|
|
1173
|
+
const n = t.m;
|
|
1174
|
+
const i = n.V || n;
|
|
1142
1175
|
if (i.L) {
|
|
1143
1176
|
updateIfNecessary(i);
|
|
1144
1177
|
}
|
|
@@ -1147,7 +1180,7 @@ function updateIfNecessary(e) {
|
|
|
1147
1180
|
}
|
|
1148
1181
|
}
|
|
1149
1182
|
}
|
|
1150
|
-
if (e.O & (REACTIVE_DIRTY | REACTIVE_OPTIMISTIC_DIRTY) || (e.
|
|
1183
|
+
if (e.O & (REACTIVE_DIRTY | REACTIVE_OPTIMISTIC_DIRTY) || (e.q && e.J < clock && !e._e)) {
|
|
1151
1184
|
recompute(e);
|
|
1152
1185
|
}
|
|
1153
1186
|
e.O = REACTIVE_NONE | (e.O & REACTIVE_SNAPSHOT_STALE);
|
|
@@ -1156,13 +1189,13 @@ function computed(e, t, n) {
|
|
|
1156
1189
|
const i = n?.transparent ?? false;
|
|
1157
1190
|
const r = {
|
|
1158
1191
|
id: n?.id ?? (i ? context?.id : context?.id != null ? getNextChildId(context) : undefined),
|
|
1159
|
-
|
|
1160
|
-
|
|
1192
|
+
Ve: i || undefined,
|
|
1193
|
+
Ie: n?.equals != null ? n.equals : isEqual,
|
|
1161
1194
|
Ge: !!n?.pureWrite,
|
|
1162
1195
|
ge: n?.unobserved,
|
|
1163
1196
|
me: null,
|
|
1164
1197
|
ce: context?.ce ?? globalQueue,
|
|
1165
|
-
|
|
1198
|
+
Le: context?.Le ?? defaultContext,
|
|
1166
1199
|
we: 0,
|
|
1167
1200
|
L: e,
|
|
1168
1201
|
fe: t,
|
|
@@ -1171,34 +1204,45 @@ function computed(e, t, n) {
|
|
|
1171
1204
|
S: undefined,
|
|
1172
1205
|
T: null,
|
|
1173
1206
|
C: null,
|
|
1174
|
-
|
|
1207
|
+
Ce: null,
|
|
1175
1208
|
I: null,
|
|
1176
1209
|
Ne: null,
|
|
1177
1210
|
i: context,
|
|
1178
|
-
|
|
1211
|
+
ye: null,
|
|
1179
1212
|
De: null,
|
|
1180
1213
|
O: n?.lazy ? REACTIVE_LAZY : REACTIVE_NONE,
|
|
1181
1214
|
Ee: STATUS_UNINITIALIZED,
|
|
1182
1215
|
J: clock,
|
|
1183
|
-
|
|
1184
|
-
Ve: null,
|
|
1216
|
+
le: NOT_PENDING,
|
|
1185
1217
|
be: null,
|
|
1186
|
-
|
|
1218
|
+
ve: null,
|
|
1219
|
+
_e: null,
|
|
1187
1220
|
ne: null
|
|
1188
1221
|
};
|
|
1189
1222
|
r.T = r;
|
|
1190
|
-
const
|
|
1223
|
+
const o = context?.t ? context.u : context;
|
|
1191
1224
|
if (context) {
|
|
1192
1225
|
const e = context.De;
|
|
1193
1226
|
if (e === null) {
|
|
1194
1227
|
context.De = r;
|
|
1195
1228
|
} else {
|
|
1196
|
-
r.
|
|
1229
|
+
r.ye = e;
|
|
1197
1230
|
context.De = r;
|
|
1198
1231
|
}
|
|
1199
1232
|
}
|
|
1200
|
-
if (
|
|
1201
|
-
if (snapshotCaptureActive && ownerInSnapshotScope(context)) r.
|
|
1233
|
+
if (o) r.o = o.o + 1;
|
|
1234
|
+
if (snapshotCaptureActive && ownerInSnapshotScope(context)) r.oe = true;
|
|
1235
|
+
if (externalSourceConfig) {
|
|
1236
|
+
const e = signal(undefined, { equals: false, pureWrite: true });
|
|
1237
|
+
const t = externalSourceConfig.factory(r.L, () => {
|
|
1238
|
+
setSignal(e, undefined);
|
|
1239
|
+
});
|
|
1240
|
+
onCleanup(() => t.dispose());
|
|
1241
|
+
r.L = n => {
|
|
1242
|
+
read(e);
|
|
1243
|
+
return t.track(n);
|
|
1244
|
+
};
|
|
1245
|
+
}
|
|
1202
1246
|
!n?.lazy && recompute(r, true);
|
|
1203
1247
|
if (snapshotCaptureActive && !n?.lazy) {
|
|
1204
1248
|
if (!(r.Ee & STATUS_PENDING)) {
|
|
@@ -1210,19 +1254,19 @@ function computed(e, t, n) {
|
|
|
1210
1254
|
}
|
|
1211
1255
|
function signal(e, t, n = null) {
|
|
1212
1256
|
const i = {
|
|
1213
|
-
|
|
1257
|
+
Ie: t?.equals != null ? t.equals : isEqual,
|
|
1214
1258
|
Ge: !!t?.pureWrite,
|
|
1215
1259
|
ge: t?.unobserved,
|
|
1216
1260
|
fe: e,
|
|
1217
1261
|
I: null,
|
|
1218
1262
|
Ne: null,
|
|
1219
1263
|
J: clock,
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1264
|
+
V: n,
|
|
1265
|
+
N: n?.A || null,
|
|
1266
|
+
le: NOT_PENDING
|
|
1223
1267
|
};
|
|
1224
1268
|
n && (n.A = i);
|
|
1225
|
-
if (snapshotCaptureActive && !i.Ge) {
|
|
1269
|
+
if (snapshotCaptureActive && !i.Ge && !((n?.Ee ?? 0) & STATUS_PENDING)) {
|
|
1226
1270
|
i.re = e === undefined ? NO_SNAPSHOT : e;
|
|
1227
1271
|
snapshotSources.add(i);
|
|
1228
1272
|
}
|
|
@@ -1230,22 +1274,23 @@ function signal(e, t, n = null) {
|
|
|
1230
1274
|
}
|
|
1231
1275
|
function optimisticSignal(e, t) {
|
|
1232
1276
|
const n = signal(e, t);
|
|
1233
|
-
n.
|
|
1277
|
+
n.Te = NOT_PENDING;
|
|
1234
1278
|
return n;
|
|
1235
1279
|
}
|
|
1236
1280
|
function optimisticComputed(e, t, n) {
|
|
1237
1281
|
const i = computed(e, t, n);
|
|
1238
|
-
i.
|
|
1282
|
+
i.Te = NOT_PENDING;
|
|
1239
1283
|
return i;
|
|
1240
1284
|
}
|
|
1241
1285
|
function isEqual(e, t) {
|
|
1242
1286
|
return e === t;
|
|
1243
1287
|
}
|
|
1244
1288
|
function untrack(e, t) {
|
|
1245
|
-
if (!tracking && true) return e();
|
|
1289
|
+
if (!externalSourceConfig && !tracking && true) return e();
|
|
1246
1290
|
const n = tracking;
|
|
1247
1291
|
tracking = false;
|
|
1248
1292
|
try {
|
|
1293
|
+
if (externalSourceConfig) return externalSourceConfig.untrack(e);
|
|
1249
1294
|
return e();
|
|
1250
1295
|
} finally {
|
|
1251
1296
|
tracking = n;
|
|
@@ -1256,27 +1301,28 @@ function read(e) {
|
|
|
1256
1301
|
const t = getLatestValueComputed(e);
|
|
1257
1302
|
const n = latestReadActive;
|
|
1258
1303
|
latestReadActive = false;
|
|
1259
|
-
|
|
1304
|
+
const i = e.Te !== undefined && e.Te !== NOT_PENDING ? e.Te : e.fe;
|
|
1305
|
+
let r;
|
|
1260
1306
|
try {
|
|
1261
|
-
|
|
1262
|
-
} catch (
|
|
1263
|
-
if (!context &&
|
|
1264
|
-
throw
|
|
1307
|
+
r = read(t);
|
|
1308
|
+
} catch (e) {
|
|
1309
|
+
if (!context && e instanceof NotReadyError) return i;
|
|
1310
|
+
throw e;
|
|
1265
1311
|
} finally {
|
|
1266
1312
|
latestReadActive = n;
|
|
1267
1313
|
}
|
|
1268
|
-
if (t.Ee & STATUS_PENDING) return
|
|
1314
|
+
if (t.Ee & STATUS_PENDING) return i;
|
|
1269
1315
|
if (stale && currentOptimisticLane && t.ie) {
|
|
1270
|
-
const
|
|
1271
|
-
const
|
|
1272
|
-
if (
|
|
1273
|
-
return
|
|
1316
|
+
const e = findLane(t.ie);
|
|
1317
|
+
const n = findLane(currentOptimisticLane);
|
|
1318
|
+
if (e !== n && e.U.size > 0) {
|
|
1319
|
+
return i;
|
|
1274
1320
|
}
|
|
1275
1321
|
}
|
|
1276
|
-
return
|
|
1322
|
+
return r;
|
|
1277
1323
|
}
|
|
1278
1324
|
if (pendingCheckActive) {
|
|
1279
|
-
const t = e.
|
|
1325
|
+
const t = e.V || e;
|
|
1280
1326
|
const n = getPendingSignal(t);
|
|
1281
1327
|
const i = pendingCheckActive;
|
|
1282
1328
|
pendingCheckActive = false;
|
|
@@ -1293,13 +1339,13 @@ function read(e) {
|
|
|
1293
1339
|
e.O &= ~REACTIVE_LAZY;
|
|
1294
1340
|
recompute(e, true);
|
|
1295
1341
|
}
|
|
1296
|
-
const n = e.
|
|
1342
|
+
const n = e.V || e;
|
|
1297
1343
|
if (t && tracking) {
|
|
1298
1344
|
if (e.L && e.O & REACTIVE_DISPOSED) recompute(e);
|
|
1299
1345
|
link(e, t);
|
|
1300
1346
|
if (n.L) {
|
|
1301
1347
|
const i = e.O & REACTIVE_ZOMBIE;
|
|
1302
|
-
if (n.o >= (i ? zombieQueue.
|
|
1348
|
+
if (n.o >= (i ? zombieQueue.P : dirtyQueue.P)) {
|
|
1303
1349
|
markNode(t);
|
|
1304
1350
|
markHeap(i ? zombieQueue : dirtyQueue);
|
|
1305
1351
|
updateIfNecessary(n);
|
|
@@ -1311,79 +1357,80 @@ function read(e) {
|
|
|
1311
1357
|
}
|
|
1312
1358
|
}
|
|
1313
1359
|
if (n.Ee & STATUS_PENDING) {
|
|
1314
|
-
|
|
1360
|
+
const i = n.q?.source;
|
|
1361
|
+
if (i && !(i.Ee & STATUS_PENDING)) clearStatus(n);
|
|
1362
|
+
else if (t && !(stale && n.ne && activeTransition !== n.ne)) {
|
|
1315
1363
|
if (currentOptimisticLane) {
|
|
1316
1364
|
const i = n.ie;
|
|
1317
1365
|
const r = findLane(currentOptimisticLane);
|
|
1318
1366
|
if (i && findLane(i) === r && !hasActiveOverride(n)) {
|
|
1319
|
-
if (!tracking) link(e, t);
|
|
1320
|
-
throw n.
|
|
1367
|
+
if (!tracking && e !== t) link(e, t);
|
|
1368
|
+
throw n.q;
|
|
1321
1369
|
}
|
|
1322
1370
|
} else {
|
|
1323
|
-
if (!tracking) link(e, t);
|
|
1324
|
-
throw n.
|
|
1371
|
+
if (!tracking && e !== t) link(e, t);
|
|
1372
|
+
throw n.q;
|
|
1325
1373
|
}
|
|
1326
1374
|
} else if (!t && n.Ee & STATUS_UNINITIALIZED) {
|
|
1327
|
-
throw n.
|
|
1375
|
+
throw n.q;
|
|
1328
1376
|
}
|
|
1329
1377
|
}
|
|
1330
1378
|
if (e.L && e.Ee & STATUS_ERROR) {
|
|
1331
1379
|
if (e.J < clock) {
|
|
1332
1380
|
recompute(e, true);
|
|
1333
1381
|
return read(e);
|
|
1334
|
-
} else throw e.
|
|
1382
|
+
} else throw e.q;
|
|
1335
1383
|
}
|
|
1336
|
-
if (snapshotCaptureActive && t && t.
|
|
1384
|
+
if (snapshotCaptureActive && t && t.oe) {
|
|
1337
1385
|
const n = e.re;
|
|
1338
1386
|
if (n !== undefined) {
|
|
1339
1387
|
const i = n === NO_SNAPSHOT ? undefined : n;
|
|
1340
|
-
const r = e.
|
|
1388
|
+
const r = e.le !== NOT_PENDING ? e.le : e.fe;
|
|
1341
1389
|
if (r !== i) t.O |= REACTIVE_SNAPSHOT_STALE;
|
|
1342
1390
|
return i;
|
|
1343
1391
|
}
|
|
1344
1392
|
}
|
|
1393
|
+
if (e.Te !== undefined && e.Te !== NOT_PENDING) return e.Te;
|
|
1345
1394
|
return !t ||
|
|
1346
|
-
(currentOptimisticLane !== null &&
|
|
1347
|
-
|
|
1395
|
+
(currentOptimisticLane !== null &&
|
|
1396
|
+
(e.Te !== undefined || e.ie || n === e || !!(n.Ee & STATUS_PENDING))) ||
|
|
1397
|
+
e.le === NOT_PENDING ||
|
|
1348
1398
|
(stale && e.ne && activeTransition !== e.ne)
|
|
1349
1399
|
? e.fe
|
|
1350
|
-
: e.
|
|
1400
|
+
: e.le;
|
|
1351
1401
|
}
|
|
1352
1402
|
function setSignal(e, t) {
|
|
1353
1403
|
if (e.ne && activeTransition !== e.ne) globalQueue.initTransition(e.ne);
|
|
1354
|
-
const n = e.
|
|
1355
|
-
const i =
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1404
|
+
const n = e.Te !== undefined && !projectionWriteActive;
|
|
1405
|
+
const i = e.Te !== undefined && e.Te !== NOT_PENDING;
|
|
1406
|
+
const r = n ? (i ? e.Te : e.fe) : e.le === NOT_PENDING ? e.fe : e.le;
|
|
1407
|
+
if (typeof t === "function") t = t(r);
|
|
1408
|
+
const o = !e.Ie || !e.Ie(r, t) || !!(e.Ee & STATUS_UNINITIALIZED);
|
|
1409
|
+
if (!o) {
|
|
1410
|
+
if (n && i && e.L) {
|
|
1360
1411
|
insertSubs(e, true);
|
|
1361
1412
|
schedule();
|
|
1362
1413
|
}
|
|
1363
1414
|
return t;
|
|
1364
1415
|
}
|
|
1365
1416
|
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) {
|
|
1417
|
+
const n = e.Te === NOT_PENDING;
|
|
1418
|
+
if (!n && e.ne) globalQueue.initTransition(e.ne);
|
|
1419
|
+
if (n) {
|
|
1420
|
+
e.le = e.fe;
|
|
1374
1421
|
globalQueue.$.push(e);
|
|
1375
1422
|
}
|
|
1376
|
-
e.Oe =
|
|
1423
|
+
e.Oe = true;
|
|
1377
1424
|
const i = getOrCreateLane(e);
|
|
1378
1425
|
e.ie = i;
|
|
1379
|
-
e.
|
|
1426
|
+
e.Te = t;
|
|
1380
1427
|
} else {
|
|
1381
|
-
if (e.
|
|
1382
|
-
e.
|
|
1428
|
+
if (e.le === NOT_PENDING) globalQueue.M.push(e);
|
|
1429
|
+
e.le = t;
|
|
1383
1430
|
}
|
|
1384
1431
|
updatePendingSignal(e);
|
|
1385
|
-
if (e.
|
|
1386
|
-
setSignal(e.
|
|
1432
|
+
if (e.pe) {
|
|
1433
|
+
setSignal(e.pe, t);
|
|
1387
1434
|
}
|
|
1388
1435
|
e.J = clock;
|
|
1389
1436
|
insertSubs(e, n);
|
|
@@ -1403,32 +1450,32 @@ function runWithOwner(e, t) {
|
|
|
1403
1450
|
}
|
|
1404
1451
|
}
|
|
1405
1452
|
function getPendingSignal(e) {
|
|
1406
|
-
if (!e.
|
|
1407
|
-
e.
|
|
1408
|
-
if (e.
|
|
1409
|
-
e.
|
|
1453
|
+
if (!e.Qe) {
|
|
1454
|
+
e.Qe = optimisticSignal(false, { pureWrite: true });
|
|
1455
|
+
if (e.Se) {
|
|
1456
|
+
e.Qe.Se = e;
|
|
1410
1457
|
}
|
|
1411
|
-
if (computePendingState(e)) setSignal(e.
|
|
1458
|
+
if (computePendingState(e)) setSignal(e.Qe, true);
|
|
1412
1459
|
}
|
|
1413
|
-
return e.
|
|
1460
|
+
return e.Qe;
|
|
1414
1461
|
}
|
|
1415
1462
|
function computePendingState(e) {
|
|
1416
1463
|
const t = e;
|
|
1417
|
-
if (e.
|
|
1464
|
+
if (e.Te !== undefined && e.Te !== NOT_PENDING) {
|
|
1418
1465
|
if (t.Ee & STATUS_PENDING && !(t.Ee & STATUS_UNINITIALIZED)) return true;
|
|
1419
|
-
if (e.
|
|
1466
|
+
if (e.Se) {
|
|
1420
1467
|
const t = e.ie ? findLane(e.ie) : null;
|
|
1421
1468
|
return !!(t && t.U.size > 0);
|
|
1422
1469
|
}
|
|
1423
1470
|
return true;
|
|
1424
1471
|
}
|
|
1425
|
-
if (e.
|
|
1472
|
+
if (e.le !== NOT_PENDING && !(t.Ee & STATUS_UNINITIALIZED)) return true;
|
|
1426
1473
|
return !!(t.Ee & STATUS_PENDING && !(t.Ee & STATUS_UNINITIALIZED));
|
|
1427
1474
|
}
|
|
1428
1475
|
function updatePendingSignal(e) {
|
|
1429
|
-
if (e.
|
|
1476
|
+
if (e.Qe) {
|
|
1430
1477
|
const t = computePendingState(e);
|
|
1431
|
-
const n = e.
|
|
1478
|
+
const n = e.Qe;
|
|
1432
1479
|
setSignal(n, t);
|
|
1433
1480
|
if (!t && n.ie) {
|
|
1434
1481
|
const t = resolveLane(e);
|
|
@@ -1444,20 +1491,20 @@ function updatePendingSignal(e) {
|
|
|
1444
1491
|
}
|
|
1445
1492
|
}
|
|
1446
1493
|
function getLatestValueComputed(e) {
|
|
1447
|
-
if (!e.
|
|
1494
|
+
if (!e.pe) {
|
|
1448
1495
|
const t = latestReadActive;
|
|
1449
1496
|
latestReadActive = false;
|
|
1450
1497
|
const n = pendingCheckActive;
|
|
1451
1498
|
pendingCheckActive = false;
|
|
1452
1499
|
const i = context;
|
|
1453
1500
|
context = null;
|
|
1454
|
-
e.
|
|
1455
|
-
e.
|
|
1501
|
+
e.pe = optimisticComputed(() => read(e));
|
|
1502
|
+
e.pe.Se = e;
|
|
1456
1503
|
context = i;
|
|
1457
1504
|
pendingCheckActive = n;
|
|
1458
1505
|
latestReadActive = t;
|
|
1459
1506
|
}
|
|
1460
|
-
return e.
|
|
1507
|
+
return e.pe;
|
|
1461
1508
|
}
|
|
1462
1509
|
function staleValues(e, t = true) {
|
|
1463
1510
|
const n = stale;
|
|
@@ -1518,7 +1565,7 @@ function getContext(e, t = getOwner()) {
|
|
|
1518
1565
|
if (!t) {
|
|
1519
1566
|
throw new NoOwnerError();
|
|
1520
1567
|
}
|
|
1521
|
-
const n = hasContext(e, t) ? t.
|
|
1568
|
+
const n = hasContext(e, t) ? t.Le[e.id] : e.defaultValue;
|
|
1522
1569
|
if (isUndefined(n)) {
|
|
1523
1570
|
throw new ContextNotFoundError();
|
|
1524
1571
|
}
|
|
@@ -1528,10 +1575,10 @@ function setContext(e, t, n = getOwner()) {
|
|
|
1528
1575
|
if (!n) {
|
|
1529
1576
|
throw new NoOwnerError();
|
|
1530
1577
|
}
|
|
1531
|
-
n.
|
|
1578
|
+
n.Le = { ...n.Le, [e.id]: isUndefined(t) ? e.defaultValue : t };
|
|
1532
1579
|
}
|
|
1533
1580
|
function hasContext(e, t) {
|
|
1534
|
-
return !isUndefined(t?.
|
|
1581
|
+
return !isUndefined(t?.Le[e.id]);
|
|
1535
1582
|
}
|
|
1536
1583
|
function isUndefined(e) {
|
|
1537
1584
|
return typeof e === "undefined";
|
|
@@ -1547,13 +1594,13 @@ function action(e) {
|
|
|
1547
1594
|
new Promise((n, i) => {
|
|
1548
1595
|
const r = e(...t);
|
|
1549
1596
|
globalQueue.initTransition();
|
|
1550
|
-
let
|
|
1551
|
-
|
|
1597
|
+
let o = activeTransition;
|
|
1598
|
+
o.ee.push(r);
|
|
1552
1599
|
const done = (e, t) => {
|
|
1553
|
-
|
|
1554
|
-
const
|
|
1555
|
-
if (
|
|
1556
|
-
setActiveTransition(
|
|
1600
|
+
o = currentTransition(o);
|
|
1601
|
+
const s = o.ee.indexOf(r);
|
|
1602
|
+
if (s >= 0) o.ee.splice(s, 1);
|
|
1603
|
+
setActiveTransition(o);
|
|
1557
1604
|
schedule();
|
|
1558
1605
|
t ? i(t) : n(e);
|
|
1559
1606
|
};
|
|
@@ -1565,32 +1612,37 @@ function action(e) {
|
|
|
1565
1612
|
return done(undefined, e);
|
|
1566
1613
|
}
|
|
1567
1614
|
if (n instanceof Promise)
|
|
1568
|
-
return void n.then(run, e => restoreTransition(
|
|
1615
|
+
return void n.then(run, e => restoreTransition(o, () => step(e, true)));
|
|
1569
1616
|
run(n);
|
|
1570
1617
|
};
|
|
1571
1618
|
const run = e => {
|
|
1572
1619
|
if (e.done) return done(e.value);
|
|
1573
1620
|
if (e.value instanceof Promise)
|
|
1574
1621
|
return void e.value.then(
|
|
1575
|
-
e => restoreTransition(
|
|
1576
|
-
e => restoreTransition(
|
|
1622
|
+
e => restoreTransition(o, () => step(e)),
|
|
1623
|
+
e => restoreTransition(o, () => step(e, true))
|
|
1577
1624
|
);
|
|
1578
|
-
restoreTransition(
|
|
1625
|
+
restoreTransition(o, () => step(e.value));
|
|
1579
1626
|
};
|
|
1580
1627
|
step();
|
|
1581
1628
|
});
|
|
1582
1629
|
}
|
|
1630
|
+
function accessor(e) {
|
|
1631
|
+
const t = read.bind(null, e);
|
|
1632
|
+
t.$r = true;
|
|
1633
|
+
return t;
|
|
1634
|
+
}
|
|
1583
1635
|
function createSignal(e, t, n) {
|
|
1584
1636
|
if (typeof e === "function") {
|
|
1585
1637
|
const i = computed(e, t, n);
|
|
1586
|
-
return [
|
|
1638
|
+
return [accessor(i), setSignal.bind(null, i)];
|
|
1587
1639
|
}
|
|
1588
1640
|
const i = signal(e, t);
|
|
1589
|
-
return [
|
|
1641
|
+
return [accessor(i), setSignal.bind(null, i)];
|
|
1590
1642
|
}
|
|
1591
1643
|
function createMemo(e, t, n) {
|
|
1592
1644
|
let i = computed(e, t, n);
|
|
1593
|
-
return
|
|
1645
|
+
return accessor(i);
|
|
1594
1646
|
}
|
|
1595
1647
|
function createEffect(e, t, n, i) {
|
|
1596
1648
|
effect(e, t.effect || t, t.error, n, i);
|
|
@@ -1638,7 +1690,7 @@ function resolve(e) {
|
|
|
1638
1690
|
}
|
|
1639
1691
|
function createOptimistic(e, t, n) {
|
|
1640
1692
|
const i = typeof e === "function" ? optimisticComputed(e, t, n) : optimisticSignal(e, t);
|
|
1641
|
-
return [
|
|
1693
|
+
return [accessor(i), setSignal.bind(null, i)];
|
|
1642
1694
|
}
|
|
1643
1695
|
function onSettled(e) {
|
|
1644
1696
|
getOwner()
|
|
@@ -1660,128 +1712,128 @@ function getAllKeys(e, t, n) {
|
|
|
1660
1712
|
const r = Object.keys(n);
|
|
1661
1713
|
return Array.from(new Set([...i, ...r]));
|
|
1662
1714
|
}
|
|
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(
|
|
1715
|
+
function applyState(e, t, n) {
|
|
1716
|
+
const i = t?.[$TARGET];
|
|
1717
|
+
if (!i) return;
|
|
1718
|
+
const r = i[STORE_VALUE];
|
|
1719
|
+
const o = i[STORE_OVERRIDE];
|
|
1720
|
+
const s = i[STORE_OPTIMISTIC_OVERRIDE];
|
|
1721
|
+
let u = i[STORE_NODE];
|
|
1722
|
+
if (e === r && !o && !s) return;
|
|
1723
|
+
(i[STORE_LOOKUP] || storeLookup).set(e, i[$PROXY]);
|
|
1724
|
+
i[STORE_VALUE] = e;
|
|
1725
|
+
i[STORE_OVERRIDE] = undefined;
|
|
1726
|
+
if (Array.isArray(r)) {
|
|
1675
1727
|
let t = false;
|
|
1676
|
-
const
|
|
1677
|
-
if (e.length &&
|
|
1678
|
-
let a, f, E, T, d, S, R
|
|
1728
|
+
const c = getOverrideValue(r, o, u, "length", s);
|
|
1729
|
+
if (e.length && c && e[0] && n(e[0]) != null) {
|
|
1730
|
+
let a, l, f, E, T, d, S, R;
|
|
1679
1731
|
for (
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
((
|
|
1683
|
-
|
|
1732
|
+
f = 0, E = Math.min(c, e.length);
|
|
1733
|
+
f < E &&
|
|
1734
|
+
((d = getOverrideValue(r, o, u, f, s)) === e[f] || (d && e[f] && n(d) === n(e[f])));
|
|
1735
|
+
f++
|
|
1684
1736
|
) {
|
|
1685
|
-
applyState(e[
|
|
1737
|
+
applyState(e[f], wrap(d, i), n);
|
|
1686
1738
|
}
|
|
1687
|
-
const
|
|
1688
|
-
|
|
1739
|
+
const O = new Array(e.length),
|
|
1740
|
+
_ = new Map();
|
|
1689
1741
|
for (
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
((
|
|
1694
|
-
|
|
1742
|
+
E = c - 1, T = e.length - 1;
|
|
1743
|
+
E >= f &&
|
|
1744
|
+
T >= f &&
|
|
1745
|
+
((d = getOverrideValue(r, o, u, E, s)) === e[T] || (d && e[T] && n(d) === n(e[T])));
|
|
1746
|
+
E--, T--
|
|
1695
1747
|
) {
|
|
1696
|
-
|
|
1748
|
+
O[T] = d;
|
|
1697
1749
|
}
|
|
1698
|
-
if (
|
|
1699
|
-
for (
|
|
1750
|
+
if (f > T || f > E) {
|
|
1751
|
+
for (l = f; l <= T; l++) {
|
|
1700
1752
|
t = true;
|
|
1701
|
-
|
|
1753
|
+
i[STORE_NODE][l] && setSignal(i[STORE_NODE][l], wrap(e[l], i));
|
|
1702
1754
|
}
|
|
1703
|
-
for (;
|
|
1755
|
+
for (; l < e.length; l++) {
|
|
1704
1756
|
t = true;
|
|
1705
|
-
const
|
|
1706
|
-
|
|
1707
|
-
applyState(e[
|
|
1757
|
+
const r = wrap(O[l], i);
|
|
1758
|
+
i[STORE_NODE][l] && setSignal(i[STORE_NODE][l], r);
|
|
1759
|
+
applyState(e[l], r, n);
|
|
1708
1760
|
}
|
|
1709
|
-
t &&
|
|
1710
|
-
|
|
1761
|
+
t && i[STORE_NODE][$TRACK] && setSignal(i[STORE_NODE][$TRACK], void 0);
|
|
1762
|
+
c !== e.length && i[STORE_NODE].length && setSignal(i[STORE_NODE].length, e.length);
|
|
1711
1763
|
return;
|
|
1712
1764
|
}
|
|
1713
|
-
|
|
1714
|
-
for (
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
a =
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
}
|
|
1721
|
-
for (a =
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
if (
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1765
|
+
S = new Array(T + 1);
|
|
1766
|
+
for (l = T; l >= f; l--) {
|
|
1767
|
+
d = e[l];
|
|
1768
|
+
R = d ? n(d) : d;
|
|
1769
|
+
a = _.get(R);
|
|
1770
|
+
S[l] = a === undefined ? -1 : a;
|
|
1771
|
+
_.set(R, l);
|
|
1772
|
+
}
|
|
1773
|
+
for (a = f; a <= E; a++) {
|
|
1774
|
+
d = getOverrideValue(r, o, u, a, s);
|
|
1775
|
+
R = d ? n(d) : d;
|
|
1776
|
+
l = _.get(R);
|
|
1777
|
+
if (l !== undefined && l !== -1) {
|
|
1778
|
+
O[l] = d;
|
|
1779
|
+
l = S[l];
|
|
1780
|
+
_.set(R, l);
|
|
1729
1781
|
}
|
|
1730
1782
|
}
|
|
1731
|
-
for (
|
|
1732
|
-
if (
|
|
1733
|
-
const t = wrap(
|
|
1734
|
-
|
|
1735
|
-
applyState(e[
|
|
1736
|
-
} else
|
|
1783
|
+
for (l = f; l < e.length; l++) {
|
|
1784
|
+
if (l in O) {
|
|
1785
|
+
const t = wrap(O[l], i);
|
|
1786
|
+
i[STORE_NODE][l] && setSignal(i[STORE_NODE][l], t);
|
|
1787
|
+
applyState(e[l], t, n);
|
|
1788
|
+
} else i[STORE_NODE][l] && setSignal(i[STORE_NODE][l], wrap(e[l], i));
|
|
1737
1789
|
}
|
|
1738
|
-
if (
|
|
1790
|
+
if (f < e.length) t = true;
|
|
1739
1791
|
} else if (e.length) {
|
|
1740
|
-
for (let t = 0,
|
|
1741
|
-
const
|
|
1742
|
-
isWrappable(
|
|
1743
|
-
? applyState(e[t], wrap(
|
|
1744
|
-
:
|
|
1792
|
+
for (let t = 0, c = e.length; t < c; t++) {
|
|
1793
|
+
const c = getOverrideValue(r, o, u, t, s);
|
|
1794
|
+
isWrappable(c)
|
|
1795
|
+
? applyState(e[t], wrap(c, i), n)
|
|
1796
|
+
: i[STORE_NODE][t] && setSignal(i[STORE_NODE][t], e[t]);
|
|
1745
1797
|
}
|
|
1746
1798
|
}
|
|
1747
|
-
if (
|
|
1799
|
+
if (c !== e.length) {
|
|
1748
1800
|
t = true;
|
|
1749
|
-
|
|
1801
|
+
i[STORE_NODE].length && setSignal(i[STORE_NODE].length, e.length);
|
|
1750
1802
|
}
|
|
1751
|
-
t &&
|
|
1803
|
+
t && i[STORE_NODE][$TRACK] && setSignal(i[STORE_NODE][$TRACK], void 0);
|
|
1752
1804
|
return;
|
|
1753
1805
|
}
|
|
1754
|
-
if (
|
|
1755
|
-
const t =
|
|
1756
|
-
const
|
|
1757
|
-
for (let a = 0,
|
|
1758
|
-
const
|
|
1759
|
-
const
|
|
1760
|
-
const
|
|
1761
|
-
let
|
|
1762
|
-
if (
|
|
1763
|
-
if (!
|
|
1806
|
+
if (u) {
|
|
1807
|
+
const t = u[$TRACK];
|
|
1808
|
+
const c = t ? getAllKeys(r, o, e) : Object.keys(u);
|
|
1809
|
+
for (let a = 0, l = c.length; a < l; a++) {
|
|
1810
|
+
const l = c[a];
|
|
1811
|
+
const f = u[l];
|
|
1812
|
+
const E = unwrap(getOverrideValue(r, o, u, l, s));
|
|
1813
|
+
let T = unwrap(e[l]);
|
|
1814
|
+
if (E === T) continue;
|
|
1815
|
+
if (!E || !isWrappable(E) || !isWrappable(T) || (n(E) != null && n(E) !== n(T))) {
|
|
1764
1816
|
t && setSignal(t, void 0);
|
|
1765
|
-
|
|
1766
|
-
} else applyState(
|
|
1817
|
+
f && setSignal(f, isWrappable(T) ? wrap(T, i) : T);
|
|
1818
|
+
} else applyState(T, wrap(E, i), n);
|
|
1767
1819
|
}
|
|
1768
1820
|
}
|
|
1769
|
-
if ((
|
|
1770
|
-
const t = Object.keys(
|
|
1821
|
+
if ((u = i[STORE_HAS])) {
|
|
1822
|
+
const t = Object.keys(u);
|
|
1771
1823
|
for (let n = 0, i = t.length; n < i; n++) {
|
|
1772
1824
|
const i = t[n];
|
|
1773
|
-
setSignal(
|
|
1825
|
+
setSignal(u[i], i in e);
|
|
1774
1826
|
}
|
|
1775
1827
|
}
|
|
1776
1828
|
}
|
|
1777
|
-
function reconcile(e, t
|
|
1778
|
-
return
|
|
1779
|
-
if (
|
|
1780
|
-
const
|
|
1781
|
-
const
|
|
1782
|
-
if (
|
|
1829
|
+
function reconcile(e, t) {
|
|
1830
|
+
return n => {
|
|
1831
|
+
if (n == null) throw new Error("Cannot reconcile null or undefined state");
|
|
1832
|
+
const i = typeof t === "string" ? e => e[t] : t;
|
|
1833
|
+
const r = i(n);
|
|
1834
|
+
if (r !== undefined && i(e) !== i(n))
|
|
1783
1835
|
throw new Error("Cannot reconcile states with different identity");
|
|
1784
|
-
applyState(e,
|
|
1836
|
+
applyState(e, n, i);
|
|
1785
1837
|
};
|
|
1786
1838
|
}
|
|
1787
1839
|
function createProjectionInternal(e, t = {}, n) {
|
|
@@ -1804,18 +1856,18 @@ function createProjectionInternal(e, t = {}, n) {
|
|
|
1804
1856
|
r.set(e, t);
|
|
1805
1857
|
return t;
|
|
1806
1858
|
};
|
|
1807
|
-
const
|
|
1859
|
+
const o = wrapProjection(t);
|
|
1808
1860
|
i = computed(() => {
|
|
1809
1861
|
const t = getOwner();
|
|
1810
|
-
storeSetter(new Proxy(
|
|
1862
|
+
storeSetter(new Proxy(o, writeTraps), i => {
|
|
1811
1863
|
const r = handleAsync(t, e(i), e => {
|
|
1812
|
-
e !== i && e !== undefined && storeSetter(
|
|
1864
|
+
e !== i && e !== undefined && storeSetter(o, reconcile(e, n?.key || "id"));
|
|
1813
1865
|
});
|
|
1814
|
-
r !== i && r !== undefined && reconcile(r, n?.key || "id"
|
|
1866
|
+
r !== i && r !== undefined && reconcile(r, n?.key || "id")(o);
|
|
1815
1867
|
});
|
|
1816
1868
|
});
|
|
1817
|
-
i.
|
|
1818
|
-
return { store:
|
|
1869
|
+
i.Pe = true;
|
|
1870
|
+
return { store: o, node: i };
|
|
1819
1871
|
}
|
|
1820
1872
|
function createProjection(e, t = {}, n) {
|
|
1821
1873
|
return createProjectionInternal(e, t, n).store;
|
|
@@ -1857,11 +1909,9 @@ const writeTraps = {
|
|
|
1857
1909
|
}
|
|
1858
1910
|
};
|
|
1859
1911
|
const $TRACK = Symbol(0),
|
|
1860
|
-
$DEEP = Symbol(0),
|
|
1861
1912
|
$TARGET = Symbol(0),
|
|
1862
1913
|
$PROXY = Symbol(0),
|
|
1863
1914
|
$DELETED = Symbol(0);
|
|
1864
|
-
const PARENTS = new WeakMap();
|
|
1865
1915
|
const STORE_VALUE = "v",
|
|
1866
1916
|
STORE_OVERRIDE = "o",
|
|
1867
1917
|
STORE_OPTIMISTIC_OVERRIDE = "x",
|
|
@@ -1902,7 +1952,7 @@ function getNodes(e, t) {
|
|
|
1902
1952
|
if (!n) e[t] = n = Object.create(null);
|
|
1903
1953
|
return n;
|
|
1904
1954
|
}
|
|
1905
|
-
function getNode(e, t, n, i, r = isEqual,
|
|
1955
|
+
function getNode(e, t, n, i, r = isEqual, o, s) {
|
|
1906
1956
|
if (e[t]) return e[t];
|
|
1907
1957
|
const u = signal(
|
|
1908
1958
|
n,
|
|
@@ -1914,9 +1964,11 @@ function getNode(e, t, n, i, r = isEqual, s, o) {
|
|
|
1914
1964
|
},
|
|
1915
1965
|
i
|
|
1916
1966
|
);
|
|
1917
|
-
if (
|
|
1918
|
-
|
|
1919
|
-
|
|
1967
|
+
if (o) {
|
|
1968
|
+
u.Te = NOT_PENDING;
|
|
1969
|
+
}
|
|
1970
|
+
if (s && t in s) {
|
|
1971
|
+
const e = s[t];
|
|
1920
1972
|
u.re = e === undefined ? NO_SNAPSHOT : e;
|
|
1921
1973
|
snapshotSources?.add(u);
|
|
1922
1974
|
}
|
|
@@ -1932,8 +1984,8 @@ function getKeys(e, t, n = true) {
|
|
|
1932
1984
|
const i = untrack(() => (n ? Object.keys(e) : Reflect.ownKeys(e)));
|
|
1933
1985
|
if (!t) return i;
|
|
1934
1986
|
const r = new Set(i);
|
|
1935
|
-
const
|
|
1936
|
-
for (const e of
|
|
1987
|
+
const o = Reflect.ownKeys(t);
|
|
1988
|
+
for (const e of o) {
|
|
1937
1989
|
if (t[e] !== $DELETED) r.add(e);
|
|
1938
1990
|
else r.delete(e);
|
|
1939
1991
|
}
|
|
@@ -1953,16 +2005,16 @@ const storeTraps = {
|
|
|
1953
2005
|
if (t === $TARGET) return e;
|
|
1954
2006
|
if (t === $PROXY) return n;
|
|
1955
2007
|
if (t === $REFRESH) return e[STORE_FIREWALL];
|
|
1956
|
-
if (t === $TRACK
|
|
1957
|
-
trackSelf(e
|
|
2008
|
+
if (t === $TRACK) {
|
|
2009
|
+
trackSelf(e);
|
|
1958
2010
|
return n;
|
|
1959
2011
|
}
|
|
1960
2012
|
const i = getNodes(e, STORE_NODE);
|
|
1961
2013
|
const r = i[t];
|
|
1962
|
-
const
|
|
1963
|
-
const
|
|
2014
|
+
const o = e[STORE_OPTIMISTIC_OVERRIDE] && t in e[STORE_OPTIMISTIC_OVERRIDE];
|
|
2015
|
+
const s = o || (e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE]);
|
|
1964
2016
|
const u = !!e[STORE_VALUE][$TARGET];
|
|
1965
|
-
const c =
|
|
2017
|
+
const c = o
|
|
1966
2018
|
? e[STORE_OPTIMISTIC_OVERRIDE]
|
|
1967
2019
|
: e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE]
|
|
1968
2020
|
? e[STORE_OVERRIDE]
|
|
@@ -1972,29 +2024,36 @@ const storeTraps = {
|
|
|
1972
2024
|
if (e && e.get) return e.get.call(n);
|
|
1973
2025
|
}
|
|
1974
2026
|
if (writeOnly(n)) {
|
|
1975
|
-
let n =
|
|
2027
|
+
let n =
|
|
2028
|
+
r && (s || !u)
|
|
2029
|
+
? r.Te !== undefined && r.Te !== NOT_PENDING
|
|
2030
|
+
? r.Te
|
|
2031
|
+
: r.le !== NOT_PENDING
|
|
2032
|
+
? r.le
|
|
2033
|
+
: r.fe
|
|
2034
|
+
: c[t];
|
|
1976
2035
|
n === $DELETED && (n = undefined);
|
|
1977
2036
|
if (!isWrappable(n)) return n;
|
|
1978
2037
|
const i = wrap(n, e);
|
|
1979
2038
|
Writing?.add(i);
|
|
1980
2039
|
return i;
|
|
1981
2040
|
}
|
|
1982
|
-
let
|
|
1983
|
-
|
|
2041
|
+
let a = r ? (s || !u ? read(i[t]) : (read(i[t]), c[t])) : c[t];
|
|
2042
|
+
a === $DELETED && (a = undefined);
|
|
1984
2043
|
if (!r) {
|
|
1985
|
-
if (!
|
|
2044
|
+
if (!s && typeof a === "function" && !c.hasOwnProperty(t)) {
|
|
1986
2045
|
let t;
|
|
1987
2046
|
return !Array.isArray(e[STORE_VALUE]) &&
|
|
1988
2047
|
(t = Object.getPrototypeOf(e[STORE_VALUE])) &&
|
|
1989
2048
|
t !== Object.prototype
|
|
1990
|
-
?
|
|
1991
|
-
:
|
|
2049
|
+
? a.bind(c)
|
|
2050
|
+
: a;
|
|
1992
2051
|
} else if (getObserver()) {
|
|
1993
2052
|
return read(
|
|
1994
2053
|
getNode(
|
|
1995
2054
|
i,
|
|
1996
2055
|
t,
|
|
1997
|
-
isWrappable(
|
|
2056
|
+
isWrappable(a) ? wrap(a, e) : a,
|
|
1998
2057
|
e[STORE_FIREWALL],
|
|
1999
2058
|
isEqual,
|
|
2000
2059
|
e[STORE_OPTIMISTIC],
|
|
@@ -2003,7 +2062,7 @@ const storeTraps = {
|
|
|
2003
2062
|
);
|
|
2004
2063
|
}
|
|
2005
2064
|
}
|
|
2006
|
-
return isWrappable(
|
|
2065
|
+
return isWrappable(a) ? wrap(a, e) : a;
|
|
2007
2066
|
},
|
|
2008
2067
|
has(e, t) {
|
|
2009
2068
|
if (t === $PROXY || t === $TRACK || t === "__proto__") return true;
|
|
@@ -2028,45 +2087,44 @@ const storeTraps = {
|
|
|
2028
2087
|
}
|
|
2029
2088
|
untrack(() => {
|
|
2030
2089
|
const r = e[STORE_VALUE];
|
|
2031
|
-
const
|
|
2032
|
-
if (
|
|
2090
|
+
const o = r[t];
|
|
2091
|
+
if (
|
|
2092
|
+
snapshotCaptureActive &&
|
|
2093
|
+
typeof t !== "symbol" &&
|
|
2094
|
+
!((e[STORE_FIREWALL]?.Ee ?? 0) & STATUS_PENDING)
|
|
2095
|
+
) {
|
|
2033
2096
|
if (!e[STORE_SNAPSHOT_PROPS]) {
|
|
2034
2097
|
e[STORE_SNAPSHOT_PROPS] = Object.create(null);
|
|
2035
2098
|
snapshotSources?.add(e);
|
|
2036
2099
|
}
|
|
2037
2100
|
if (!(t in e[STORE_SNAPSHOT_PROPS])) {
|
|
2038
|
-
e[STORE_SNAPSHOT_PROPS][t] =
|
|
2101
|
+
e[STORE_SNAPSHOT_PROPS][t] = o;
|
|
2039
2102
|
}
|
|
2040
2103
|
}
|
|
2041
|
-
const
|
|
2042
|
-
const u =
|
|
2043
|
-
if (
|
|
2104
|
+
const s = e[STORE_OPTIMISTIC] && !projectionWriteActive;
|
|
2105
|
+
const u = s ? STORE_OPTIMISTIC_OVERRIDE : STORE_OVERRIDE;
|
|
2106
|
+
if (s) trackOptimisticStore(i);
|
|
2044
2107
|
const c =
|
|
2045
2108
|
e[STORE_OPTIMISTIC_OVERRIDE] && t in e[STORE_OPTIMISTIC_OVERRIDE]
|
|
2046
2109
|
? e[STORE_OPTIMISTIC_OVERRIDE][t]
|
|
2047
2110
|
: e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE]
|
|
2048
2111
|
? 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);
|
|
2112
|
+
: o;
|
|
2113
|
+
const a = n?.[$TARGET]?.[STORE_VALUE] ?? n;
|
|
2114
|
+
if (c === a) return true;
|
|
2115
|
+
const l = e[STORE_OPTIMISTIC_OVERRIDE]?.length || e[STORE_OVERRIDE]?.length || r.length;
|
|
2116
|
+
if (a !== undefined && a === o) delete e[u][t];
|
|
2117
|
+
else (e[u] || (e[u] = Object.create(null)))[t] = a;
|
|
2118
|
+
const f = isWrappable(a);
|
|
2061
2119
|
e[STORE_HAS]?.[t] && setSignal(e[STORE_HAS][t], true);
|
|
2062
2120
|
const E = getNodes(e, STORE_NODE);
|
|
2063
|
-
E[t] && setSignal(E[t], () => (f ? wrap(
|
|
2121
|
+
E[t] && setSignal(E[t], () => (f ? wrap(a, e) : a));
|
|
2064
2122
|
if (Array.isArray(r)) {
|
|
2065
2123
|
if (t === "length") {
|
|
2066
|
-
E.length && setSignal(E.length,
|
|
2124
|
+
E.length && setSignal(E.length, a);
|
|
2067
2125
|
} else {
|
|
2068
2126
|
const e = parseInt(t) + 1;
|
|
2069
|
-
if (e >
|
|
2127
|
+
if (e > l) E.length && setSignal(E.length, e);
|
|
2070
2128
|
}
|
|
2071
2129
|
}
|
|
2072
2130
|
E[$TRACK] && setSignal(E[$TRACK], undefined);
|
|
@@ -2093,14 +2151,10 @@ const storeTraps = {
|
|
|
2093
2151
|
} else if (e[i] && t in e[i]) {
|
|
2094
2152
|
delete e[i][t];
|
|
2095
2153
|
} 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
2154
|
if (e[STORE_HAS]?.[t]) setSignal(e[STORE_HAS][t], false);
|
|
2101
|
-
const
|
|
2102
|
-
|
|
2103
|
-
|
|
2155
|
+
const o = getNodes(e, STORE_NODE);
|
|
2156
|
+
o[t] && setSignal(o[t], undefined);
|
|
2157
|
+
o[$TRACK] && setSignal(o[$TRACK], undefined);
|
|
2104
2158
|
});
|
|
2105
2159
|
}
|
|
2106
2160
|
return true;
|
|
@@ -2167,66 +2221,13 @@ function createStore(e, t, n) {
|
|
|
2167
2221
|
r = i ? createProjectionInternal(e, t, n).store : wrap(e);
|
|
2168
2222
|
return [r, e => storeSetter(r, e)];
|
|
2169
2223
|
}
|
|
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
2224
|
function createOptimisticStore(e, t, n) {
|
|
2224
|
-
GlobalQueue.
|
|
2225
|
+
GlobalQueue.B ||= clearOptimisticStore;
|
|
2225
2226
|
const i = typeof e === "function";
|
|
2226
2227
|
const r = (i ? t : e) ?? {};
|
|
2227
|
-
const
|
|
2228
|
-
const { store:
|
|
2229
|
-
return [
|
|
2228
|
+
const o = i ? e : undefined;
|
|
2229
|
+
const { store: s } = createOptimisticProjectionInternal(o, r, n);
|
|
2230
|
+
return [s, e => storeSetter(s, e)];
|
|
2230
2231
|
}
|
|
2231
2232
|
function clearOptimisticStore(e) {
|
|
2232
2233
|
const t = e[$TARGET];
|
|
@@ -2276,30 +2277,30 @@ function createOptimisticProjectionInternal(e, t = {}, n) {
|
|
|
2276
2277
|
r.set(e, t);
|
|
2277
2278
|
return t;
|
|
2278
2279
|
};
|
|
2279
|
-
const
|
|
2280
|
+
const o = wrapProjection(t);
|
|
2280
2281
|
if (e) {
|
|
2281
2282
|
i = computed(() => {
|
|
2282
2283
|
const t = getOwner();
|
|
2283
2284
|
setProjectionWriteActive(true);
|
|
2284
2285
|
try {
|
|
2285
|
-
storeSetter(new Proxy(
|
|
2286
|
+
storeSetter(new Proxy(o, writeTraps), i => {
|
|
2286
2287
|
const r = handleAsync(t, e(i), e => {
|
|
2287
2288
|
setProjectionWriteActive(true);
|
|
2288
2289
|
try {
|
|
2289
|
-
e !== i && e !== undefined && storeSetter(
|
|
2290
|
+
e !== i && e !== undefined && storeSetter(o, reconcile(e, n?.key || "id"));
|
|
2290
2291
|
} finally {
|
|
2291
2292
|
setProjectionWriteActive(false);
|
|
2292
2293
|
}
|
|
2293
2294
|
});
|
|
2294
|
-
r !== i && r !== undefined && reconcile(r, n?.key || "id"
|
|
2295
|
+
r !== i && r !== undefined && reconcile(r, n?.key || "id")(o);
|
|
2295
2296
|
});
|
|
2296
2297
|
} finally {
|
|
2297
2298
|
setProjectionWriteActive(false);
|
|
2298
2299
|
}
|
|
2299
2300
|
});
|
|
2300
|
-
i.
|
|
2301
|
+
i.Pe = true;
|
|
2301
2302
|
}
|
|
2302
|
-
return { store:
|
|
2303
|
+
return { store: o, node: i };
|
|
2303
2304
|
}
|
|
2304
2305
|
const DELETE = Symbol(0);
|
|
2305
2306
|
function updatePath(e, t, n = 0) {
|
|
@@ -2307,8 +2308,8 @@ function updatePath(e, t, n = 0) {
|
|
|
2307
2308
|
r = e;
|
|
2308
2309
|
if (n < t.length - 1) {
|
|
2309
2310
|
i = t[n];
|
|
2310
|
-
const
|
|
2311
|
-
const
|
|
2311
|
+
const o = typeof i;
|
|
2312
|
+
const s = Array.isArray(e);
|
|
2312
2313
|
if (Array.isArray(i)) {
|
|
2313
2314
|
for (let r = 0; r < i.length; r++) {
|
|
2314
2315
|
t[n] = i[r];
|
|
@@ -2316,7 +2317,7 @@ function updatePath(e, t, n = 0) {
|
|
|
2316
2317
|
}
|
|
2317
2318
|
t[n] = i;
|
|
2318
2319
|
return;
|
|
2319
|
-
} else if (
|
|
2320
|
+
} else if (s && o === "function") {
|
|
2320
2321
|
for (let r = 0; r < e.length; r++) {
|
|
2321
2322
|
if (i(e[r], r)) {
|
|
2322
2323
|
t[n] = r;
|
|
@@ -2325,9 +2326,9 @@ function updatePath(e, t, n = 0) {
|
|
|
2325
2326
|
}
|
|
2326
2327
|
t[n] = i;
|
|
2327
2328
|
return;
|
|
2328
|
-
} else if (
|
|
2329
|
-
const { from: r = 0, to:
|
|
2330
|
-
for (let i = r; i <=
|
|
2329
|
+
} else if (s && o === "object") {
|
|
2330
|
+
const { from: r = 0, to: o = e.length - 1, by: s = 1 } = i;
|
|
2331
|
+
for (let i = r; i <= o; i += s) {
|
|
2331
2332
|
t[n] = i;
|
|
2332
2333
|
updatePath(e, t, n);
|
|
2333
2334
|
}
|
|
@@ -2339,20 +2340,20 @@ function updatePath(e, t, n = 0) {
|
|
|
2339
2340
|
}
|
|
2340
2341
|
r = e[i];
|
|
2341
2342
|
}
|
|
2342
|
-
let
|
|
2343
|
-
if (typeof
|
|
2344
|
-
|
|
2345
|
-
if (
|
|
2343
|
+
let o = t[t.length - 1];
|
|
2344
|
+
if (typeof o === "function") {
|
|
2345
|
+
o = o(r);
|
|
2346
|
+
if (o === r) return;
|
|
2346
2347
|
}
|
|
2347
|
-
if (i === undefined &&
|
|
2348
|
-
if (
|
|
2348
|
+
if (i === undefined && o == undefined) return;
|
|
2349
|
+
if (o === DELETE) {
|
|
2349
2350
|
delete e[i];
|
|
2350
|
-
} else if (i === undefined || (isWrappable(r) && isWrappable(
|
|
2351
|
+
} else if (i === undefined || (isWrappable(r) && isWrappable(o) && !Array.isArray(o))) {
|
|
2351
2352
|
const t = i !== undefined ? e[i] : e;
|
|
2352
|
-
const n = Object.keys(
|
|
2353
|
-
for (let e = 0; e < n.length; e++) t[n[e]] =
|
|
2353
|
+
const n = Object.keys(o);
|
|
2354
|
+
for (let e = 0; e < n.length; e++) t[n[e]] = o[n[e]];
|
|
2354
2355
|
} else {
|
|
2355
|
-
e[i] =
|
|
2356
|
+
e[i] = o;
|
|
2356
2357
|
}
|
|
2357
2358
|
}
|
|
2358
2359
|
const storePath = Object.assign(
|
|
@@ -2363,51 +2364,60 @@ const storePath = Object.assign(
|
|
|
2363
2364
|
},
|
|
2364
2365
|
{ DELETE: DELETE }
|
|
2365
2366
|
);
|
|
2366
|
-
function
|
|
2367
|
-
let
|
|
2367
|
+
function snapshotImpl(e, t, n, i) {
|
|
2368
|
+
let r, o, s, u, c, a;
|
|
2368
2369
|
if (!isWrappable(e)) return e;
|
|
2369
|
-
if (
|
|
2370
|
-
if (!
|
|
2371
|
-
if ((
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2370
|
+
if (n && n.has(e)) return n.get(e);
|
|
2371
|
+
if (!n) n = new Map();
|
|
2372
|
+
if ((r = e[$TARGET] || i?.get(e)?.[$TARGET])) {
|
|
2373
|
+
if (t) trackSelf(r, $TRACK);
|
|
2374
|
+
s = r[STORE_OVERRIDE];
|
|
2375
|
+
o = Array.isArray(r[STORE_VALUE]);
|
|
2376
|
+
n.set(
|
|
2375
2377
|
e,
|
|
2376
|
-
s ? (
|
|
2378
|
+
s ? (u = o ? [] : Object.create(Object.getPrototypeOf(r[STORE_VALUE]))) : r[STORE_VALUE]
|
|
2377
2379
|
);
|
|
2378
|
-
e =
|
|
2379
|
-
|
|
2380
|
+
e = r[STORE_VALUE];
|
|
2381
|
+
i = storeLookup;
|
|
2380
2382
|
} else {
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
+
o = Array.isArray(e);
|
|
2384
|
+
n.set(e, e);
|
|
2383
2385
|
}
|
|
2384
|
-
if (
|
|
2385
|
-
const
|
|
2386
|
-
for (let
|
|
2387
|
-
|
|
2388
|
-
if (
|
|
2389
|
-
if (
|
|
2390
|
-
|
|
2391
|
-
|
|
2386
|
+
if (o) {
|
|
2387
|
+
const o = s?.length || e.length;
|
|
2388
|
+
for (let l = 0; l < o; l++) {
|
|
2389
|
+
a = s && l in s ? s[l] : e[l];
|
|
2390
|
+
if (a === $DELETED) continue;
|
|
2391
|
+
if (t && isWrappable(a)) wrap(a, r);
|
|
2392
|
+
if ((c = snapshotImpl(a, t, n, i)) !== a || u) {
|
|
2393
|
+
if (!u) n.set(e, (u = [...e]));
|
|
2394
|
+
u[l] = c;
|
|
2392
2395
|
}
|
|
2393
2396
|
}
|
|
2394
2397
|
} else {
|
|
2395
|
-
const
|
|
2396
|
-
for (let
|
|
2397
|
-
let
|
|
2398
|
-
const
|
|
2399
|
-
if (
|
|
2400
|
-
|
|
2401
|
-
if (
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
Object.
|
|
2398
|
+
const o = getKeys(e, s);
|
|
2399
|
+
for (let l = 0, f = o.length; l < f; l++) {
|
|
2400
|
+
let f = o[l];
|
|
2401
|
+
const E = getPropertyDescriptor(e, s, f);
|
|
2402
|
+
if (E.get) continue;
|
|
2403
|
+
a = s && f in s ? s[f] : e[f];
|
|
2404
|
+
if (t && isWrappable(a)) wrap(a, r);
|
|
2405
|
+
if ((c = snapshotImpl(a, t, n, i)) !== e[f] || u) {
|
|
2406
|
+
if (!u) {
|
|
2407
|
+
u = Object.create(Object.getPrototypeOf(e));
|
|
2408
|
+
Object.assign(u, e);
|
|
2405
2409
|
}
|
|
2406
|
-
|
|
2410
|
+
u[f] = c;
|
|
2407
2411
|
}
|
|
2408
2412
|
}
|
|
2409
2413
|
}
|
|
2410
|
-
return
|
|
2414
|
+
return u || e;
|
|
2415
|
+
}
|
|
2416
|
+
function snapshot(e, t, n) {
|
|
2417
|
+
return snapshotImpl(e, false, t, n);
|
|
2418
|
+
}
|
|
2419
|
+
function deep(e) {
|
|
2420
|
+
return snapshotImpl(e, true);
|
|
2411
2421
|
}
|
|
2412
2422
|
function trueFn() {
|
|
2413
2423
|
return true;
|
|
@@ -2449,8 +2459,8 @@ function merge(...e) {
|
|
|
2449
2459
|
for (let i = 0; i < e.length; i++) {
|
|
2450
2460
|
const r = e[i];
|
|
2451
2461
|
t = t || (!!r && $PROXY in r);
|
|
2452
|
-
const
|
|
2453
|
-
if (
|
|
2462
|
+
const o = !!r && r[$SOURCES];
|
|
2463
|
+
if (o) n.push(...o);
|
|
2454
2464
|
else n.push(typeof r === "function" ? ((t = true), createMemo(r)) : r);
|
|
2455
2465
|
}
|
|
2456
2466
|
if (SUPPORTS_PROXY && t) {
|
|
@@ -2480,35 +2490,35 @@ function merge(...e) {
|
|
|
2480
2490
|
}
|
|
2481
2491
|
const i = Object.create(null);
|
|
2482
2492
|
let r = false;
|
|
2483
|
-
let
|
|
2484
|
-
for (let e =
|
|
2493
|
+
let o = n.length - 1;
|
|
2494
|
+
for (let e = o; e >= 0; e--) {
|
|
2485
2495
|
const t = n[e];
|
|
2486
2496
|
if (!t) {
|
|
2487
|
-
e ===
|
|
2497
|
+
e === o && o--;
|
|
2488
2498
|
continue;
|
|
2489
2499
|
}
|
|
2490
|
-
const
|
|
2491
|
-
for (let n =
|
|
2492
|
-
const u =
|
|
2500
|
+
const s = Object.getOwnPropertyNames(t);
|
|
2501
|
+
for (let n = s.length - 1; n >= 0; n--) {
|
|
2502
|
+
const u = s[n];
|
|
2493
2503
|
if (u === "__proto__" || u === "constructor") continue;
|
|
2494
2504
|
if (!i[u]) {
|
|
2495
|
-
r = r || e !==
|
|
2505
|
+
r = r || e !== o;
|
|
2496
2506
|
const n = Object.getOwnPropertyDescriptor(t, u);
|
|
2497
2507
|
i[u] = n.get ? { enumerable: true, configurable: true, get: n.get.bind(t) } : n;
|
|
2498
2508
|
}
|
|
2499
2509
|
}
|
|
2500
2510
|
}
|
|
2501
|
-
if (!r) return n[
|
|
2502
|
-
const
|
|
2511
|
+
if (!r) return n[o];
|
|
2512
|
+
const s = {};
|
|
2503
2513
|
const u = Object.keys(i);
|
|
2504
2514
|
for (let e = u.length - 1; e >= 0; e--) {
|
|
2505
2515
|
const t = u[e],
|
|
2506
2516
|
n = i[t];
|
|
2507
|
-
if (n.get) Object.defineProperty(
|
|
2508
|
-
else
|
|
2517
|
+
if (n.get) Object.defineProperty(s, t, n);
|
|
2518
|
+
else s[t] = n.value;
|
|
2509
2519
|
}
|
|
2510
|
-
|
|
2511
|
-
return
|
|
2520
|
+
s[$SOURCES] = n;
|
|
2521
|
+
return s;
|
|
2512
2522
|
}
|
|
2513
2523
|
function omit(e, ...t) {
|
|
2514
2524
|
const n = new Set(t);
|
|
@@ -2542,26 +2552,26 @@ function omit(e, ...t) {
|
|
|
2542
2552
|
function mapArray(e, t, n) {
|
|
2543
2553
|
const i = typeof n?.keyed === "function" ? n.keyed : undefined;
|
|
2544
2554
|
const r = t.length > 1;
|
|
2545
|
-
const
|
|
2555
|
+
const o = t;
|
|
2546
2556
|
return createMemo(
|
|
2547
2557
|
updateKeyedMap.bind({
|
|
2548
2558
|
Fe: createOwner(),
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2559
|
+
Me: 0,
|
|
2560
|
+
$e: e,
|
|
2561
|
+
je: [],
|
|
2562
|
+
Ke: o,
|
|
2563
|
+
Ye: [],
|
|
2554
2564
|
Be: [],
|
|
2555
|
-
|
|
2565
|
+
Ze: i,
|
|
2556
2566
|
qe: i || n?.keyed === false ? [] : undefined,
|
|
2557
|
-
|
|
2558
|
-
|
|
2567
|
+
Xe: r ? [] : undefined,
|
|
2568
|
+
ze: n?.fallback
|
|
2559
2569
|
})
|
|
2560
2570
|
);
|
|
2561
2571
|
}
|
|
2562
2572
|
const pureOptions = { pureWrite: true };
|
|
2563
2573
|
function updateKeyedMap() {
|
|
2564
|
-
const e = this
|
|
2574
|
+
const e = this.$e() || [],
|
|
2565
2575
|
t = e.length;
|
|
2566
2576
|
e[$TRACK];
|
|
2567
2577
|
runWithOwner(this.Fe, () => {
|
|
@@ -2570,192 +2580,189 @@ function updateKeyedMap() {
|
|
|
2570
2580
|
r = this.qe
|
|
2571
2581
|
? () => {
|
|
2572
2582
|
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
|
-
);
|
|
2583
|
+
this.Xe && (this.Xe[i] = signal(i, pureOptions));
|
|
2584
|
+
return this.Ke(accessor(this.qe[i]), this.Xe ? accessor(this.Xe[i]) : undefined);
|
|
2578
2585
|
}
|
|
2579
|
-
: this.
|
|
2586
|
+
: this.Xe
|
|
2580
2587
|
? () => {
|
|
2581
2588
|
const t = e[i];
|
|
2582
|
-
this.
|
|
2583
|
-
return this.
|
|
2589
|
+
this.Xe[i] = signal(i, pureOptions);
|
|
2590
|
+
return this.Ke(() => t, accessor(this.Xe[i]));
|
|
2584
2591
|
}
|
|
2585
2592
|
: () => {
|
|
2586
2593
|
const t = e[i];
|
|
2587
|
-
return this.
|
|
2594
|
+
return this.Ke(() => t);
|
|
2588
2595
|
};
|
|
2589
2596
|
if (t === 0) {
|
|
2590
|
-
if (this
|
|
2597
|
+
if (this.Me !== 0) {
|
|
2591
2598
|
this.Fe.dispose(false);
|
|
2592
2599
|
this.Be = [];
|
|
2593
|
-
this.
|
|
2594
|
-
this.
|
|
2595
|
-
this
|
|
2600
|
+
this.je = [];
|
|
2601
|
+
this.Ye = [];
|
|
2602
|
+
this.Me = 0;
|
|
2596
2603
|
this.qe && (this.qe = []);
|
|
2597
|
-
this.
|
|
2604
|
+
this.Xe && (this.Xe = []);
|
|
2598
2605
|
}
|
|
2599
|
-
if (this.
|
|
2600
|
-
this.
|
|
2606
|
+
if (this.ze && !this.Ye[0]) {
|
|
2607
|
+
this.Ye[0] = runWithOwner((this.Be[0] = createOwner()), this.ze);
|
|
2601
2608
|
}
|
|
2602
|
-
} else if (this
|
|
2609
|
+
} else if (this.Me === 0) {
|
|
2603
2610
|
if (this.Be[0]) this.Be[0].dispose();
|
|
2604
|
-
this.
|
|
2611
|
+
this.Ye = new Array(t);
|
|
2605
2612
|
for (i = 0; i < t; i++) {
|
|
2606
|
-
this.
|
|
2607
|
-
this.
|
|
2613
|
+
this.je[i] = e[i];
|
|
2614
|
+
this.Ye[i] = runWithOwner((this.Be[i] = createOwner()), r);
|
|
2608
2615
|
}
|
|
2609
|
-
this
|
|
2616
|
+
this.Me = t;
|
|
2610
2617
|
} else {
|
|
2611
|
-
let
|
|
2612
|
-
|
|
2618
|
+
let o,
|
|
2619
|
+
s,
|
|
2613
2620
|
u,
|
|
2614
2621
|
c,
|
|
2615
|
-
l,
|
|
2616
2622
|
a,
|
|
2623
|
+
l,
|
|
2617
2624
|
f,
|
|
2618
2625
|
E = new Array(t),
|
|
2619
2626
|
T = new Array(t),
|
|
2620
2627
|
d = this.qe ? new Array(t) : undefined,
|
|
2621
|
-
S = this.
|
|
2628
|
+
S = this.Xe ? new Array(t) : undefined;
|
|
2622
2629
|
for (
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2630
|
+
o = 0, s = Math.min(this.Me, t);
|
|
2631
|
+
o < s && (this.je[o] === e[o] || (this.qe && compare(this.Ze, this.je[o], e[o])));
|
|
2632
|
+
o++
|
|
2626
2633
|
) {
|
|
2627
|
-
if (this.qe) setSignal(this.qe[
|
|
2634
|
+
if (this.qe) setSignal(this.qe[o], e[o]);
|
|
2628
2635
|
}
|
|
2629
2636
|
for (
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
u >=
|
|
2633
|
-
(this.
|
|
2634
|
-
|
|
2637
|
+
s = this.Me - 1, u = t - 1;
|
|
2638
|
+
s >= o &&
|
|
2639
|
+
u >= o &&
|
|
2640
|
+
(this.je[s] === e[u] || (this.qe && compare(this.Ze, this.je[s], e[u])));
|
|
2641
|
+
s--, u--
|
|
2635
2642
|
) {
|
|
2636
|
-
E[u] = this.
|
|
2637
|
-
T[u] = this.Be[
|
|
2638
|
-
d && (d[u] = this.qe[
|
|
2639
|
-
S && (S[u] = this.
|
|
2643
|
+
E[u] = this.Ye[s];
|
|
2644
|
+
T[u] = this.Be[s];
|
|
2645
|
+
d && (d[u] = this.qe[s]);
|
|
2646
|
+
S && (S[u] = this.Xe[s]);
|
|
2640
2647
|
}
|
|
2641
|
-
|
|
2648
|
+
l = new Map();
|
|
2642
2649
|
f = new Array(u + 1);
|
|
2643
|
-
for (i = u; i >=
|
|
2650
|
+
for (i = u; i >= o; i--) {
|
|
2644
2651
|
c = e[i];
|
|
2645
|
-
|
|
2646
|
-
n =
|
|
2652
|
+
a = this.Ze ? this.Ze(c) : c;
|
|
2653
|
+
n = l.get(a);
|
|
2647
2654
|
f[i] = n === undefined ? -1 : n;
|
|
2648
|
-
|
|
2655
|
+
l.set(a, i);
|
|
2649
2656
|
}
|
|
2650
|
-
for (n =
|
|
2651
|
-
c = this.
|
|
2652
|
-
|
|
2653
|
-
i =
|
|
2657
|
+
for (n = o; n <= s; n++) {
|
|
2658
|
+
c = this.je[n];
|
|
2659
|
+
a = this.Ze ? this.Ze(c) : c;
|
|
2660
|
+
i = l.get(a);
|
|
2654
2661
|
if (i !== undefined && i !== -1) {
|
|
2655
|
-
E[i] = this.
|
|
2662
|
+
E[i] = this.Ye[n];
|
|
2656
2663
|
T[i] = this.Be[n];
|
|
2657
2664
|
d && (d[i] = this.qe[n]);
|
|
2658
|
-
S && (S[i] = this.
|
|
2665
|
+
S && (S[i] = this.Xe[n]);
|
|
2659
2666
|
i = f[i];
|
|
2660
|
-
|
|
2667
|
+
l.set(a, i);
|
|
2661
2668
|
} else this.Be[n].dispose();
|
|
2662
2669
|
}
|
|
2663
|
-
for (i =
|
|
2670
|
+
for (i = o; i < t; i++) {
|
|
2664
2671
|
if (i in E) {
|
|
2665
|
-
this.
|
|
2672
|
+
this.Ye[i] = E[i];
|
|
2666
2673
|
this.Be[i] = T[i];
|
|
2667
2674
|
if (d) {
|
|
2668
2675
|
this.qe[i] = d[i];
|
|
2669
2676
|
setSignal(this.qe[i], e[i]);
|
|
2670
2677
|
}
|
|
2671
2678
|
if (S) {
|
|
2672
|
-
this.
|
|
2673
|
-
setSignal(this.
|
|
2679
|
+
this.Xe[i] = S[i];
|
|
2680
|
+
setSignal(this.Xe[i], i);
|
|
2674
2681
|
}
|
|
2675
2682
|
} else {
|
|
2676
|
-
this.
|
|
2683
|
+
this.Ye[i] = runWithOwner((this.Be[i] = createOwner()), r);
|
|
2677
2684
|
}
|
|
2678
2685
|
}
|
|
2679
|
-
this.
|
|
2680
|
-
this.
|
|
2686
|
+
this.Ye = this.Ye.slice(0, (this.Me = t));
|
|
2687
|
+
this.je = e.slice(0);
|
|
2681
2688
|
}
|
|
2682
2689
|
});
|
|
2683
|
-
return this.
|
|
2690
|
+
return this.Ye;
|
|
2684
2691
|
}
|
|
2685
2692
|
function repeat(e, t, n) {
|
|
2686
2693
|
const i = t;
|
|
2687
2694
|
return updateRepeat.bind({
|
|
2688
2695
|
Fe: createOwner(),
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2696
|
+
Me: 0,
|
|
2697
|
+
Je: 0,
|
|
2698
|
+
et: e,
|
|
2699
|
+
Ke: i,
|
|
2693
2700
|
Be: [],
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2701
|
+
Ye: [],
|
|
2702
|
+
tt: n?.from,
|
|
2703
|
+
ze: n?.fallback
|
|
2697
2704
|
});
|
|
2698
2705
|
}
|
|
2699
2706
|
function updateRepeat() {
|
|
2700
|
-
const e = this.
|
|
2701
|
-
const t = this.
|
|
2707
|
+
const e = this.et();
|
|
2708
|
+
const t = this.tt?.() || 0;
|
|
2702
2709
|
runWithOwner(this.Fe, () => {
|
|
2703
2710
|
if (e === 0) {
|
|
2704
|
-
if (this
|
|
2711
|
+
if (this.Me !== 0) {
|
|
2705
2712
|
this.Fe.dispose(false);
|
|
2706
2713
|
this.Be = [];
|
|
2707
|
-
this.
|
|
2708
|
-
this
|
|
2714
|
+
this.Ye = [];
|
|
2715
|
+
this.Me = 0;
|
|
2709
2716
|
}
|
|
2710
|
-
if (this.
|
|
2711
|
-
this.
|
|
2717
|
+
if (this.ze && !this.Ye[0]) {
|
|
2718
|
+
this.Ye[0] = runWithOwner((this.Be[0] = createOwner()), this.ze);
|
|
2712
2719
|
}
|
|
2713
2720
|
return;
|
|
2714
2721
|
}
|
|
2715
2722
|
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.
|
|
2723
|
+
const i = this.Je + this.Me;
|
|
2724
|
+
if (this.Me === 0 && this.Be[0]) this.Be[0].dispose();
|
|
2725
|
+
for (let e = n; e < i; e++) this.Be[e - this.Je].dispose();
|
|
2726
|
+
if (this.Je < t) {
|
|
2727
|
+
let e = this.Je;
|
|
2728
|
+
while (e < t && e < this.Me) this.Be[e++].dispose();
|
|
2729
|
+
this.Be.splice(0, t - this.Je);
|
|
2730
|
+
this.Ye.splice(0, t - this.Je);
|
|
2731
|
+
} else if (this.Je > t) {
|
|
2732
|
+
let n = i - this.Je - 1;
|
|
2733
|
+
let r = this.Je - t;
|
|
2734
|
+
this.Be.length = this.Ye.length = e;
|
|
2728
2735
|
while (n >= r) {
|
|
2729
2736
|
this.Be[n] = this.Be[n - r];
|
|
2730
|
-
this.
|
|
2737
|
+
this.Ye[n] = this.Ye[n - r];
|
|
2731
2738
|
n--;
|
|
2732
2739
|
}
|
|
2733
2740
|
for (let e = 0; e < r; e++) {
|
|
2734
|
-
this.
|
|
2741
|
+
this.Ye[e] = runWithOwner((this.Be[e] = createOwner()), () => this.Ke(e + t));
|
|
2735
2742
|
}
|
|
2736
2743
|
}
|
|
2737
2744
|
for (let e = i; e < n; e++) {
|
|
2738
|
-
this.
|
|
2745
|
+
this.Ye[e - t] = runWithOwner((this.Be[e - t] = createOwner()), () => this.Ke(e));
|
|
2739
2746
|
}
|
|
2740
|
-
this.
|
|
2741
|
-
this.
|
|
2742
|
-
this
|
|
2747
|
+
this.Ye = this.Ye.slice(0, e);
|
|
2748
|
+
this.Je = t;
|
|
2749
|
+
this.Me = e;
|
|
2743
2750
|
});
|
|
2744
|
-
return this.
|
|
2751
|
+
return this.Ye;
|
|
2745
2752
|
}
|
|
2746
2753
|
function compare(e, t, n) {
|
|
2747
2754
|
return e ? e(t) === e(n) : true;
|
|
2748
2755
|
}
|
|
2749
2756
|
function boundaryComputed(e, t) {
|
|
2750
2757
|
const n = computed(e, undefined, { lazy: true });
|
|
2751
|
-
n.
|
|
2758
|
+
n.he = (e, t) => {
|
|
2752
2759
|
const i = e !== undefined ? e : n.Ee;
|
|
2753
|
-
const r = t !== undefined ? t : n.
|
|
2754
|
-
n.Ee &= ~n.
|
|
2755
|
-
n.ce.notify(n, n.
|
|
2760
|
+
const r = t !== undefined ? t : n.q;
|
|
2761
|
+
n.Ee &= ~n.nt;
|
|
2762
|
+
n.ce.notify(n, n.nt, i, r);
|
|
2756
2763
|
};
|
|
2757
|
-
n.
|
|
2758
|
-
n.
|
|
2764
|
+
n.nt = t;
|
|
2765
|
+
n.Pe = true;
|
|
2759
2766
|
recompute(n, true);
|
|
2760
2767
|
return n;
|
|
2761
2768
|
}
|
|
@@ -2768,64 +2775,90 @@ function createBoundChildren(e, t, n, i) {
|
|
|
2768
2775
|
return boundaryComputed(() => staleValues(() => flatten(read(e))), i);
|
|
2769
2776
|
});
|
|
2770
2777
|
}
|
|
2778
|
+
const ON_INIT = Symbol();
|
|
2771
2779
|
class CollectionQueue extends Queue {
|
|
2772
|
-
|
|
2773
|
-
|
|
2780
|
+
it;
|
|
2781
|
+
rt = new Set();
|
|
2774
2782
|
ot = signal(false, { pureWrite: true });
|
|
2775
|
-
|
|
2783
|
+
st = false;
|
|
2784
|
+
ut;
|
|
2785
|
+
ct = ON_INIT;
|
|
2776
2786
|
constructor(e) {
|
|
2777
2787
|
super();
|
|
2778
|
-
this.
|
|
2788
|
+
this.it = e;
|
|
2779
2789
|
}
|
|
2780
2790
|
run(e) {
|
|
2781
2791
|
if (!e || read(this.ot)) return;
|
|
2782
2792
|
return super.run(e);
|
|
2783
2793
|
}
|
|
2784
2794
|
notify(e, t, n, i) {
|
|
2785
|
-
if (!(t & this.
|
|
2786
|
-
if (
|
|
2787
|
-
const
|
|
2795
|
+
if (!(t & this.it)) return super.notify(e, t, n, i);
|
|
2796
|
+
if (this.st && this.ut) {
|
|
2797
|
+
const e = untrack(() => {
|
|
2798
|
+
try {
|
|
2799
|
+
return this.ut();
|
|
2800
|
+
} catch {
|
|
2801
|
+
return ON_INIT;
|
|
2802
|
+
}
|
|
2803
|
+
});
|
|
2804
|
+
if (e !== this.ct) {
|
|
2805
|
+
this.ct = e;
|
|
2806
|
+
this.st = false;
|
|
2807
|
+
this.rt.clear();
|
|
2808
|
+
}
|
|
2809
|
+
}
|
|
2810
|
+
if (this.it & STATUS_PENDING && this.st) return super.notify(e, t, n, i);
|
|
2811
|
+
if (n & this.it) {
|
|
2812
|
+
const t = i?.source || e.q?.source;
|
|
2788
2813
|
if (t) {
|
|
2789
|
-
const e = this.
|
|
2790
|
-
this.
|
|
2814
|
+
const e = this.rt.size === 0;
|
|
2815
|
+
this.rt.add(t);
|
|
2791
2816
|
if (e) setSignal(this.ot, true);
|
|
2792
2817
|
}
|
|
2793
2818
|
}
|
|
2794
|
-
t &= ~this.
|
|
2819
|
+
t &= ~this.it;
|
|
2795
2820
|
return t ? super.notify(e, t, n, i) : true;
|
|
2796
2821
|
}
|
|
2797
2822
|
checkSources() {
|
|
2798
|
-
for (const e of this.
|
|
2799
|
-
if (!(e.Ee & this.
|
|
2823
|
+
for (const e of this.rt) {
|
|
2824
|
+
if (!(e.Ee & this.it)) this.rt.delete(e);
|
|
2825
|
+
}
|
|
2826
|
+
if (!this.rt.size) {
|
|
2827
|
+
setSignal(this.ot, false);
|
|
2828
|
+
if (this.ut) {
|
|
2829
|
+
try {
|
|
2830
|
+
this.ct = untrack(() => this.ut());
|
|
2831
|
+
} catch {}
|
|
2832
|
+
}
|
|
2800
2833
|
}
|
|
2801
|
-
if (!this.st.size) setSignal(this.ot, false);
|
|
2802
2834
|
}
|
|
2803
2835
|
}
|
|
2804
|
-
function createCollectionBoundary(e, t, n) {
|
|
2805
|
-
const
|
|
2806
|
-
const
|
|
2807
|
-
|
|
2808
|
-
const
|
|
2809
|
-
|
|
2836
|
+
function createCollectionBoundary(e, t, n, i) {
|
|
2837
|
+
const r = createOwner();
|
|
2838
|
+
const o = new CollectionQueue(e);
|
|
2839
|
+
if (i) o.ut = i;
|
|
2840
|
+
const s = createBoundChildren(r, t, o, e);
|
|
2841
|
+
const u = computed(() => {
|
|
2842
|
+
if (!read(o.ot)) {
|
|
2810
2843
|
const e = read(s);
|
|
2811
|
-
if (!untrack(() => read(
|
|
2812
|
-
|
|
2844
|
+
if (!untrack(() => read(o.ot))) {
|
|
2845
|
+
o.st = true;
|
|
2813
2846
|
return e;
|
|
2814
2847
|
}
|
|
2815
2848
|
}
|
|
2816
|
-
return n(
|
|
2849
|
+
return n(o);
|
|
2817
2850
|
});
|
|
2818
|
-
return
|
|
2851
|
+
return accessor(u);
|
|
2819
2852
|
}
|
|
2820
|
-
function
|
|
2821
|
-
return createCollectionBoundary(STATUS_PENDING, e, () => t());
|
|
2853
|
+
function createLoadingBoundary(e, t, n) {
|
|
2854
|
+
return createCollectionBoundary(STATUS_PENDING, e, () => t(), n?.on);
|
|
2822
2855
|
}
|
|
2823
2856
|
function createErrorBoundary(e, t) {
|
|
2824
2857
|
return createCollectionBoundary(STATUS_ERROR, e, e => {
|
|
2825
|
-
let n = e.
|
|
2826
|
-
const i = n.
|
|
2858
|
+
let n = e.rt.values().next().value;
|
|
2859
|
+
const i = n.q?.cause ?? n.q;
|
|
2827
2860
|
return t(i, () => {
|
|
2828
|
-
for (const t of e.
|
|
2861
|
+
for (const t of e.rt) recompute(t);
|
|
2829
2862
|
schedule();
|
|
2830
2863
|
});
|
|
2831
2864
|
});
|
|
@@ -2854,9 +2887,9 @@ function flatten(e, t) {
|
|
|
2854
2887
|
function flattenArray(e, t = [], n) {
|
|
2855
2888
|
let i = null;
|
|
2856
2889
|
let r = false;
|
|
2857
|
-
for (let
|
|
2890
|
+
for (let o = 0; o < e.length; o++) {
|
|
2858
2891
|
try {
|
|
2859
|
-
let i = e[
|
|
2892
|
+
let i = e[o];
|
|
2860
2893
|
if (typeof i === "function" && !i.length) {
|
|
2861
2894
|
if (n?.doNotUnwrap) {
|
|
2862
2895
|
t.push(i);
|
|
@@ -2893,7 +2926,7 @@ export {
|
|
|
2893
2926
|
createContext,
|
|
2894
2927
|
createEffect,
|
|
2895
2928
|
createErrorBoundary,
|
|
2896
|
-
|
|
2929
|
+
createLoadingBoundary,
|
|
2897
2930
|
createMemo,
|
|
2898
2931
|
createOptimistic,
|
|
2899
2932
|
createOptimisticStore,
|
|
@@ -2906,6 +2939,8 @@ export {
|
|
|
2906
2939
|
createStore,
|
|
2907
2940
|
createTrackedEffect,
|
|
2908
2941
|
deep,
|
|
2942
|
+
enableExternalSource,
|
|
2943
|
+
enforceLoadingBoundary,
|
|
2909
2944
|
flatten,
|
|
2910
2945
|
flush,
|
|
2911
2946
|
getContext,
|
|
@@ -2932,7 +2967,6 @@ export {
|
|
|
2932
2967
|
resolve,
|
|
2933
2968
|
runWithOwner,
|
|
2934
2969
|
setContext,
|
|
2935
|
-
setOnUnhandledAsync,
|
|
2936
2970
|
setSnapshotCapture,
|
|
2937
2971
|
snapshot,
|
|
2938
2972
|
storePath,
|