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