@solidjs/signals 0.13.3 → 0.13.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev.js +588 -354
- package/dist/node.cjs +1211 -1016
- package/dist/prod.js +1054 -852
- package/dist/types/core/async.d.ts +2 -1
- package/dist/types/core/effect.d.ts +2 -2
- package/dist/types/core/index.d.ts +1 -1
- package/dist/types/core/lanes.d.ts +4 -0
- package/dist/types/core/owner.d.ts +1 -1
- package/dist/types/core/scheduler.d.ts +3 -0
- package/dist/types/core/types.d.ts +4 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/signals.d.ts +2 -0
- package/dist/types/store/projection.d.ts +1 -0
- package/package.json +1 -1
package/dist/prod.js
CHANGED
|
@@ -148,38 +148,115 @@ let clock = 0;
|
|
|
148
148
|
let activeTransition = null;
|
|
149
149
|
let scheduled = false;
|
|
150
150
|
let projectionWriteActive = false;
|
|
151
|
+
let stashedOptimisticReads = null;
|
|
151
152
|
function enforceLoadingBoundary(e) {}
|
|
153
|
+
function shouldReadStashedOptimisticValue(e) {
|
|
154
|
+
return !!stashedOptimisticReads?.has(e);
|
|
155
|
+
}
|
|
152
156
|
function runLaneEffects(e) {
|
|
153
157
|
for (const t of activeLanes) {
|
|
154
|
-
if (t.
|
|
155
|
-
const n = t.
|
|
158
|
+
if (t.U || t.k.size > 0) continue;
|
|
159
|
+
const n = t.G[e - 1];
|
|
156
160
|
if (n.length) {
|
|
157
|
-
t.
|
|
161
|
+
t.G[e - 1] = [];
|
|
158
162
|
runQueue(n, e);
|
|
159
163
|
}
|
|
160
164
|
}
|
|
161
165
|
}
|
|
166
|
+
function queueStashedOptimisticEffects(e) {
|
|
167
|
+
for (let t = e.I; t !== null; t = t.p) {
|
|
168
|
+
const e = t.h;
|
|
169
|
+
if (!e.W) continue;
|
|
170
|
+
if (e.W === EFFECT_TRACKED) {
|
|
171
|
+
if (!e.H) {
|
|
172
|
+
e.H = true;
|
|
173
|
+
e.F.enqueue(EFFECT_USER, e.M);
|
|
174
|
+
}
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
const n = e.O & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue;
|
|
178
|
+
if (n.P > e.o) n.P = e.o;
|
|
179
|
+
insertIntoHeap(e, n);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
162
182
|
function setProjectionWriteActive(e) {
|
|
163
183
|
projectionWriteActive = e;
|
|
164
184
|
}
|
|
185
|
+
function mergeTransitionState(e, t) {
|
|
186
|
+
t.$ = e;
|
|
187
|
+
e.j.push(...t.j);
|
|
188
|
+
for (const n of activeLanes) {
|
|
189
|
+
if (n.K === t) n.K = e;
|
|
190
|
+
}
|
|
191
|
+
e.Y.push(...t.Y);
|
|
192
|
+
for (const n of t.B) e.B.add(n);
|
|
193
|
+
for (const n of t.Z) {
|
|
194
|
+
if (!e.Z.includes(n)) e.Z.push(n);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
function resolveOptimisticNodes(e) {
|
|
198
|
+
for (let t = 0; t < e.length; t++) {
|
|
199
|
+
const n = e[t];
|
|
200
|
+
n.q = undefined;
|
|
201
|
+
if (n.X !== NOT_PENDING) {
|
|
202
|
+
n.J = n.X;
|
|
203
|
+
n.X = NOT_PENDING;
|
|
204
|
+
}
|
|
205
|
+
const i = n.ee;
|
|
206
|
+
n.ee = NOT_PENDING;
|
|
207
|
+
if (i !== NOT_PENDING && n.J !== i) insertSubs(n, true);
|
|
208
|
+
n.K = null;
|
|
209
|
+
}
|
|
210
|
+
e.length = 0;
|
|
211
|
+
}
|
|
212
|
+
function cleanupCompletedLanes(e) {
|
|
213
|
+
for (const t of activeLanes) {
|
|
214
|
+
const n = e ? t.K === e : !t.K;
|
|
215
|
+
if (!n) continue;
|
|
216
|
+
if (!t.U) {
|
|
217
|
+
if (t.G[0].length) runQueue(t.G[0], EFFECT_RENDER);
|
|
218
|
+
if (t.G[1].length) runQueue(t.G[1], EFFECT_USER);
|
|
219
|
+
}
|
|
220
|
+
if (t.te.q === t) t.te.q = undefined;
|
|
221
|
+
t.k.clear();
|
|
222
|
+
t.G[0].length = 0;
|
|
223
|
+
t.G[1].length = 0;
|
|
224
|
+
activeLanes.delete(t);
|
|
225
|
+
signalLanes.delete(t.te);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
165
228
|
function schedule() {
|
|
166
229
|
if (scheduled) return;
|
|
167
230
|
scheduled = true;
|
|
168
|
-
if (!globalQueue.
|
|
231
|
+
if (!globalQueue.ne && !projectionWriteActive) queueMicrotask(flush);
|
|
232
|
+
}
|
|
233
|
+
function addTransitionBlocker(e) {
|
|
234
|
+
if (activeTransition && !activeTransition.Z.includes(e)) {
|
|
235
|
+
activeTransition.Z.push(e);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
function removeTransitionBlocker(e) {
|
|
239
|
+
const remove = t => {
|
|
240
|
+
if (!t) return;
|
|
241
|
+
const n = t.indexOf(e);
|
|
242
|
+
if (n >= 0) t.splice(n, 1);
|
|
243
|
+
};
|
|
244
|
+
remove(e.K?.Z);
|
|
245
|
+
remove(activeTransition?.Z);
|
|
169
246
|
}
|
|
170
247
|
class Queue {
|
|
171
248
|
i = null;
|
|
172
|
-
|
|
173
|
-
|
|
249
|
+
ie = [[], []];
|
|
250
|
+
re = [];
|
|
174
251
|
created = clock;
|
|
175
252
|
addChild(e) {
|
|
176
|
-
this.
|
|
253
|
+
this.re.push(e);
|
|
177
254
|
e.i = this;
|
|
178
255
|
}
|
|
179
256
|
removeChild(e) {
|
|
180
|
-
const t = this.
|
|
257
|
+
const t = this.re.indexOf(e);
|
|
181
258
|
if (t >= 0) {
|
|
182
|
-
this.
|
|
259
|
+
this.re.splice(t, 1);
|
|
183
260
|
e.i = null;
|
|
184
261
|
}
|
|
185
262
|
}
|
|
@@ -188,88 +265,101 @@ class Queue {
|
|
|
188
265
|
return false;
|
|
189
266
|
}
|
|
190
267
|
run(e) {
|
|
191
|
-
if (this.
|
|
192
|
-
const t = this.
|
|
193
|
-
this.
|
|
268
|
+
if (this.ie[e - 1].length) {
|
|
269
|
+
const t = this.ie[e - 1];
|
|
270
|
+
this.ie[e - 1] = [];
|
|
194
271
|
runQueue(t, e);
|
|
195
272
|
}
|
|
196
|
-
for (let t = 0; t < this.
|
|
273
|
+
for (let t = 0; t < this.re.length; t++) this.re[t].run?.(e);
|
|
197
274
|
}
|
|
198
275
|
enqueue(e, t) {
|
|
199
276
|
if (e) {
|
|
200
277
|
if (currentOptimisticLane) {
|
|
201
278
|
const n = findLane(currentOptimisticLane);
|
|
202
|
-
n.
|
|
279
|
+
n.G[e - 1].push(t);
|
|
203
280
|
} else {
|
|
204
|
-
this.
|
|
281
|
+
this.ie[e - 1].push(t);
|
|
205
282
|
}
|
|
206
283
|
}
|
|
207
284
|
schedule();
|
|
208
285
|
}
|
|
209
286
|
stashQueues(e) {
|
|
210
|
-
e.
|
|
211
|
-
e.
|
|
212
|
-
this.
|
|
213
|
-
for (let t = 0; t < this.
|
|
214
|
-
let n = this.
|
|
215
|
-
let i = e.
|
|
287
|
+
e.ie[0].push(...this.ie[0]);
|
|
288
|
+
e.ie[1].push(...this.ie[1]);
|
|
289
|
+
this.ie = [[], []];
|
|
290
|
+
for (let t = 0; t < this.re.length; t++) {
|
|
291
|
+
let n = this.re[t];
|
|
292
|
+
let i = e.re[t];
|
|
216
293
|
if (!i) {
|
|
217
|
-
i = {
|
|
218
|
-
e.
|
|
294
|
+
i = { ie: [[], []], re: [] };
|
|
295
|
+
e.re[t] = i;
|
|
219
296
|
}
|
|
220
297
|
n.stashQueues(i);
|
|
221
298
|
}
|
|
222
299
|
}
|
|
223
300
|
restoreQueues(e) {
|
|
224
|
-
this.
|
|
225
|
-
this.
|
|
226
|
-
for (let t = 0; t < e.
|
|
227
|
-
const n = e.
|
|
228
|
-
let i = this.
|
|
301
|
+
this.ie[0].push(...e.ie[0]);
|
|
302
|
+
this.ie[1].push(...e.ie[1]);
|
|
303
|
+
for (let t = 0; t < e.re.length; t++) {
|
|
304
|
+
const n = e.re[t];
|
|
305
|
+
let i = this.re[t];
|
|
229
306
|
if (i) i.restoreQueues(n);
|
|
230
307
|
}
|
|
231
308
|
}
|
|
232
309
|
}
|
|
233
310
|
class GlobalQueue extends Queue {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
static
|
|
239
|
-
static
|
|
240
|
-
static
|
|
311
|
+
ne = false;
|
|
312
|
+
oe = [];
|
|
313
|
+
Y = [];
|
|
314
|
+
B = new Set();
|
|
315
|
+
static se;
|
|
316
|
+
static ue;
|
|
317
|
+
static ce = null;
|
|
241
318
|
flush() {
|
|
242
|
-
if (this.
|
|
243
|
-
this.
|
|
319
|
+
if (this.ne) return;
|
|
320
|
+
this.ne = true;
|
|
244
321
|
try {
|
|
245
|
-
runHeap(dirtyQueue, GlobalQueue.
|
|
322
|
+
runHeap(dirtyQueue, GlobalQueue.se);
|
|
246
323
|
if (activeTransition) {
|
|
247
324
|
const e = transitionComplete(activeTransition);
|
|
248
325
|
if (!e) {
|
|
249
|
-
|
|
250
|
-
runHeap(zombieQueue, GlobalQueue.
|
|
251
|
-
this.
|
|
252
|
-
this
|
|
253
|
-
this.
|
|
326
|
+
const e = activeTransition;
|
|
327
|
+
runHeap(zombieQueue, GlobalQueue.se);
|
|
328
|
+
this.oe = [];
|
|
329
|
+
this.Y = [];
|
|
330
|
+
this.B = new Set();
|
|
254
331
|
runLaneEffects(EFFECT_RENDER);
|
|
255
332
|
runLaneEffects(EFFECT_USER);
|
|
256
|
-
this.stashQueues(
|
|
333
|
+
this.stashQueues(e.ae);
|
|
257
334
|
clock++;
|
|
258
335
|
scheduled = dirtyQueue.R >= dirtyQueue.P;
|
|
259
|
-
reassignPendingTransition(
|
|
336
|
+
reassignPendingTransition(e.oe);
|
|
260
337
|
activeTransition = null;
|
|
261
|
-
|
|
338
|
+
if (!e.j.length && e.Y.length) {
|
|
339
|
+
stashedOptimisticReads = new Set();
|
|
340
|
+
for (let t = 0; t < e.Y.length; t++) {
|
|
341
|
+
const n = e.Y[t];
|
|
342
|
+
if (n.L || n.fe) continue;
|
|
343
|
+
stashedOptimisticReads.add(n);
|
|
344
|
+
queueStashedOptimisticEffects(n);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
try {
|
|
348
|
+
finalizePureQueue(null, true);
|
|
349
|
+
} finally {
|
|
350
|
+
stashedOptimisticReads = null;
|
|
351
|
+
}
|
|
262
352
|
return;
|
|
263
353
|
}
|
|
264
|
-
this.
|
|
265
|
-
this.restoreQueues(activeTransition.
|
|
354
|
+
this.oe !== activeTransition.oe && this.oe.push(...activeTransition.oe);
|
|
355
|
+
this.restoreQueues(activeTransition.ae);
|
|
266
356
|
transitions.delete(activeTransition);
|
|
267
357
|
const t = activeTransition;
|
|
268
358
|
activeTransition = null;
|
|
269
|
-
reassignPendingTransition(this.
|
|
359
|
+
reassignPendingTransition(this.oe);
|
|
270
360
|
finalizePureQueue(t);
|
|
271
361
|
} else {
|
|
272
|
-
if (transitions.size) runHeap(zombieQueue, GlobalQueue.
|
|
362
|
+
if (transitions.size) runHeap(zombieQueue, GlobalQueue.se);
|
|
273
363
|
finalizePureQueue();
|
|
274
364
|
}
|
|
275
365
|
clock++;
|
|
@@ -279,16 +369,19 @@ class GlobalQueue extends Queue {
|
|
|
279
369
|
runLaneEffects(EFFECT_USER);
|
|
280
370
|
this.run(EFFECT_USER);
|
|
281
371
|
} finally {
|
|
282
|
-
this.
|
|
372
|
+
this.ne = false;
|
|
283
373
|
}
|
|
284
374
|
}
|
|
285
375
|
notify(e, t, n, i) {
|
|
286
376
|
if (t & STATUS_PENDING) {
|
|
287
377
|
if (n & STATUS_PENDING) {
|
|
288
|
-
const t = i !== undefined ? i : e.
|
|
289
|
-
if (activeTransition && t
|
|
290
|
-
|
|
291
|
-
|
|
378
|
+
const t = i !== undefined ? i : e.le;
|
|
379
|
+
if (activeTransition && t) {
|
|
380
|
+
const e = t.source;
|
|
381
|
+
if (!activeTransition.Z.includes(e)) {
|
|
382
|
+
activeTransition.Z.push(e);
|
|
383
|
+
schedule();
|
|
384
|
+
}
|
|
292
385
|
}
|
|
293
386
|
}
|
|
294
387
|
return true;
|
|
@@ -298,58 +391,56 @@ class GlobalQueue extends Queue {
|
|
|
298
391
|
initTransition(e) {
|
|
299
392
|
if (e) e = currentTransition(e);
|
|
300
393
|
if (e && e === activeTransition) return;
|
|
301
|
-
if (!e && activeTransition && activeTransition.
|
|
394
|
+
if (!e && activeTransition && activeTransition.Ee === clock) return;
|
|
302
395
|
if (!activeTransition) {
|
|
303
396
|
activeTransition = e ?? {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
397
|
+
Ee: clock,
|
|
398
|
+
oe: [],
|
|
399
|
+
Z: [],
|
|
400
|
+
Y: [],
|
|
401
|
+
B: new Set(),
|
|
402
|
+
j: [],
|
|
403
|
+
ae: { ie: [[], []], re: [] },
|
|
404
|
+
$: false
|
|
312
405
|
};
|
|
313
406
|
} else if (e) {
|
|
314
407
|
const t = activeTransition;
|
|
315
|
-
t
|
|
316
|
-
e.ee.push(...t.ee);
|
|
317
|
-
for (const n of activeLanes) {
|
|
318
|
-
if (n.ne === t) n.ne = e;
|
|
319
|
-
}
|
|
320
|
-
e.$.push(...t.$);
|
|
321
|
-
for (const n of t.j) {
|
|
322
|
-
e.j.add(n);
|
|
323
|
-
}
|
|
408
|
+
mergeTransitionState(e, t);
|
|
324
409
|
transitions.delete(t);
|
|
325
410
|
activeTransition = e;
|
|
326
411
|
}
|
|
327
412
|
transitions.add(activeTransition);
|
|
328
|
-
activeTransition.
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
413
|
+
activeTransition.Ee = clock;
|
|
414
|
+
if (this.oe !== activeTransition.oe) {
|
|
415
|
+
for (let e = 0; e < this.oe.length; e++) {
|
|
416
|
+
const t = this.oe[e];
|
|
417
|
+
t.K = activeTransition;
|
|
418
|
+
activeTransition.oe.push(t);
|
|
419
|
+
}
|
|
420
|
+
this.oe = activeTransition.oe;
|
|
421
|
+
}
|
|
422
|
+
if (this.Y !== activeTransition.Y) {
|
|
423
|
+
for (let e = 0; e < this.Y.length; e++) {
|
|
424
|
+
const t = this.Y[e];
|
|
425
|
+
t.K = activeTransition;
|
|
426
|
+
activeTransition.Y.push(t);
|
|
427
|
+
}
|
|
428
|
+
this.Y = activeTransition.Y;
|
|
429
|
+
}
|
|
341
430
|
for (const e of activeLanes) {
|
|
342
|
-
if (!e.
|
|
431
|
+
if (!e.K) e.K = activeTransition;
|
|
432
|
+
}
|
|
433
|
+
if (this.B !== activeTransition.B) {
|
|
434
|
+
for (const e of this.B) activeTransition.B.add(e);
|
|
435
|
+
this.B = activeTransition.B;
|
|
343
436
|
}
|
|
344
|
-
for (const e of this.j) activeTransition.j.add(e);
|
|
345
|
-
this.j = activeTransition.j;
|
|
346
437
|
}
|
|
347
438
|
}
|
|
348
439
|
function insertSubs(e, t = false) {
|
|
349
|
-
const n = e.
|
|
350
|
-
const i = e.
|
|
440
|
+
const n = e.q || currentOptimisticLane;
|
|
441
|
+
const i = e.Te !== undefined;
|
|
351
442
|
for (let r = e.I; r !== null; r = r.p) {
|
|
352
|
-
if (i && r.h.
|
|
443
|
+
if (i && r.h.de) {
|
|
353
444
|
r.h.O |= REACTIVE_SNAPSHOT_STALE;
|
|
354
445
|
continue;
|
|
355
446
|
}
|
|
@@ -358,13 +449,13 @@ function insertSubs(e, t = false) {
|
|
|
358
449
|
assignOrMergeLane(r.h, n);
|
|
359
450
|
} else if (t) {
|
|
360
451
|
r.h.O |= REACTIVE_OPTIMISTIC_DIRTY;
|
|
361
|
-
r.h.
|
|
452
|
+
r.h.q = undefined;
|
|
362
453
|
}
|
|
363
454
|
const e = r.h;
|
|
364
|
-
if (e.
|
|
365
|
-
if (!e.
|
|
366
|
-
e.
|
|
367
|
-
e.
|
|
455
|
+
if (e.W === EFFECT_TRACKED) {
|
|
456
|
+
if (!e.H) {
|
|
457
|
+
e.H = true;
|
|
458
|
+
e.F.enqueue(EFFECT_USER, e.M);
|
|
368
459
|
}
|
|
369
460
|
continue;
|
|
370
461
|
}
|
|
@@ -374,88 +465,56 @@ function insertSubs(e, t = false) {
|
|
|
374
465
|
}
|
|
375
466
|
}
|
|
376
467
|
function commitPendingNodes() {
|
|
377
|
-
const e = globalQueue.
|
|
468
|
+
const e = globalQueue.oe;
|
|
378
469
|
for (let t = 0; t < e.length; t++) {
|
|
379
470
|
const n = e[t];
|
|
380
|
-
if (n.
|
|
381
|
-
n.
|
|
382
|
-
n.
|
|
383
|
-
if (n.
|
|
471
|
+
if (n.X !== NOT_PENDING) {
|
|
472
|
+
n.J = n.X;
|
|
473
|
+
n.X = NOT_PENDING;
|
|
474
|
+
if (n.W && n.W !== EFFECT_TRACKED) n.H = true;
|
|
384
475
|
}
|
|
385
|
-
if (n.
|
|
386
|
-
|
|
387
|
-
if (e && !(e.Ee & STATUS_PENDING)) {
|
|
388
|
-
n.Ee &= -6;
|
|
389
|
-
n.q = null;
|
|
390
|
-
}
|
|
391
|
-
} else n.Ee &= ~STATUS_UNINITIALIZED;
|
|
392
|
-
if (n.L) GlobalQueue.Y(n, false, true);
|
|
476
|
+
if (!(n.Se & STATUS_PENDING)) n.Se &= ~STATUS_UNINITIALIZED;
|
|
477
|
+
if (n.L) GlobalQueue.ue(n, false, true);
|
|
393
478
|
}
|
|
394
479
|
e.length = 0;
|
|
395
480
|
}
|
|
396
481
|
function finalizePureQueue(e = null, t = false) {
|
|
397
|
-
|
|
482
|
+
const n = !t;
|
|
398
483
|
if (n) commitPendingNodes();
|
|
399
484
|
if (!t) checkBoundaryChildren(globalQueue);
|
|
400
|
-
if (dirtyQueue.R >= dirtyQueue.P) runHeap(dirtyQueue, GlobalQueue.
|
|
485
|
+
if (dirtyQueue.R >= dirtyQueue.P) runHeap(dirtyQueue, GlobalQueue.se);
|
|
401
486
|
if (n) {
|
|
402
487
|
commitPendingNodes();
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
n.fe = n.le;
|
|
409
|
-
n.le = NOT_PENDING;
|
|
410
|
-
}
|
|
411
|
-
const i = n.Te;
|
|
412
|
-
n.Te = NOT_PENDING;
|
|
413
|
-
if (i !== NOT_PENDING && n.fe !== i) insertSubs(n, true);
|
|
414
|
-
n.ne = null;
|
|
415
|
-
}
|
|
416
|
-
t.length = 0;
|
|
417
|
-
const n = e ? e.j : globalQueue.j;
|
|
418
|
-
if (GlobalQueue.B && n.size) {
|
|
419
|
-
for (const e of n) {
|
|
420
|
-
GlobalQueue.B(e);
|
|
421
|
-
}
|
|
422
|
-
n.clear();
|
|
423
|
-
schedule();
|
|
424
|
-
}
|
|
425
|
-
for (const t of activeLanes) {
|
|
426
|
-
const n = e ? t.ne === e : !t.ne;
|
|
427
|
-
if (!n) continue;
|
|
428
|
-
if (!t.k) {
|
|
429
|
-
if (t.W[0].length) runQueue(t.W[0], EFFECT_RENDER);
|
|
430
|
-
if (t.W[1].length) runQueue(t.W[1], EFFECT_USER);
|
|
488
|
+
resolveOptimisticNodes(e ? e.Y : globalQueue.Y);
|
|
489
|
+
const t = e ? e.B : globalQueue.B;
|
|
490
|
+
if (GlobalQueue.ce && t.size) {
|
|
491
|
+
for (const e of t) {
|
|
492
|
+
GlobalQueue.ce(e);
|
|
431
493
|
}
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
t.W[0].length = 0;
|
|
435
|
-
t.W[1].length = 0;
|
|
436
|
-
activeLanes.delete(t);
|
|
437
|
-
signalLanes.delete(t.de);
|
|
494
|
+
t.clear();
|
|
495
|
+
schedule();
|
|
438
496
|
}
|
|
497
|
+
cleanupCompletedLanes(e);
|
|
439
498
|
}
|
|
440
499
|
}
|
|
441
500
|
function checkBoundaryChildren(e) {
|
|
442
|
-
for (const t of e.
|
|
501
|
+
for (const t of e.re) {
|
|
443
502
|
t.checkSources?.();
|
|
444
503
|
checkBoundaryChildren(t);
|
|
445
504
|
}
|
|
446
505
|
}
|
|
447
506
|
function trackOptimisticStore(e) {
|
|
448
|
-
globalQueue.
|
|
507
|
+
globalQueue.B.add(e);
|
|
449
508
|
schedule();
|
|
450
509
|
}
|
|
451
510
|
function reassignPendingTransition(e) {
|
|
452
511
|
for (let t = 0; t < e.length; t++) {
|
|
453
|
-
e[t].
|
|
512
|
+
e[t].K = activeTransition;
|
|
454
513
|
}
|
|
455
514
|
}
|
|
456
515
|
const globalQueue = new GlobalQueue();
|
|
457
516
|
function flush() {
|
|
458
|
-
while (scheduled) {
|
|
517
|
+
while (scheduled || activeTransition) {
|
|
459
518
|
globalQueue.flush();
|
|
460
519
|
}
|
|
461
520
|
}
|
|
@@ -463,21 +522,21 @@ function runQueue(e, t) {
|
|
|
463
522
|
for (let n = 0; n < e.length; n++) e[n](t);
|
|
464
523
|
}
|
|
465
524
|
function transitionComplete(e) {
|
|
466
|
-
if (e
|
|
467
|
-
if (e.
|
|
525
|
+
if (e.$) return true;
|
|
526
|
+
if (e.j.length) return false;
|
|
468
527
|
let t = true;
|
|
469
|
-
for (let n = 0; n < e.
|
|
470
|
-
const i = e.
|
|
471
|
-
if (i.
|
|
528
|
+
for (let n = 0; n < e.Z.length; n++) {
|
|
529
|
+
const i = e.Z[n];
|
|
530
|
+
if (i.Se & STATUS_PENDING && i.le?.source === i) {
|
|
472
531
|
t = false;
|
|
473
532
|
break;
|
|
474
533
|
}
|
|
475
534
|
}
|
|
476
|
-
t && (e
|
|
535
|
+
t && (e.$ = true);
|
|
477
536
|
return t;
|
|
478
537
|
}
|
|
479
538
|
function currentTransition(e) {
|
|
480
|
-
while (e
|
|
539
|
+
while (e.$ && typeof e.$ === "object") e = e.$;
|
|
481
540
|
return e;
|
|
482
541
|
}
|
|
483
542
|
function setActiveTransition(e) {
|
|
@@ -499,105 +558,199 @@ function getOrCreateLane(e) {
|
|
|
499
558
|
if (t) {
|
|
500
559
|
return findLane(t);
|
|
501
560
|
}
|
|
502
|
-
const n = e.
|
|
503
|
-
const i = n?.
|
|
504
|
-
t = {
|
|
561
|
+
const n = e.Re;
|
|
562
|
+
const i = n?.q ? findLane(n.q) : null;
|
|
563
|
+
t = { te: e, k: new Set(), G: [[], []], U: null, K: activeTransition, Oe: i };
|
|
505
564
|
signalLanes.set(e, t);
|
|
506
565
|
activeLanes.add(t);
|
|
507
|
-
e.
|
|
566
|
+
e._e = false;
|
|
508
567
|
return t;
|
|
509
568
|
}
|
|
510
569
|
function findLane(e) {
|
|
511
|
-
while (e.
|
|
570
|
+
while (e.U) e = e.U;
|
|
512
571
|
return e;
|
|
513
572
|
}
|
|
514
573
|
function mergeLanes(e, t) {
|
|
515
574
|
e = findLane(e);
|
|
516
575
|
t = findLane(t);
|
|
517
576
|
if (e === t) return e;
|
|
518
|
-
t.
|
|
519
|
-
for (const n of t.
|
|
520
|
-
e.
|
|
521
|
-
e.
|
|
577
|
+
t.U = e;
|
|
578
|
+
for (const n of t.k) e.k.add(n);
|
|
579
|
+
e.G[0].push(...t.G[0]);
|
|
580
|
+
e.G[1].push(...t.G[1]);
|
|
522
581
|
return e;
|
|
523
582
|
}
|
|
524
583
|
function resolveLane(e) {
|
|
525
|
-
const t = e.
|
|
584
|
+
const t = e.q;
|
|
526
585
|
if (!t) return undefined;
|
|
527
586
|
const n = findLane(t);
|
|
528
587
|
if (activeLanes.has(n)) return n;
|
|
529
|
-
e.
|
|
588
|
+
e.q = undefined;
|
|
530
589
|
return undefined;
|
|
531
590
|
}
|
|
591
|
+
function resolveTransition(e) {
|
|
592
|
+
return resolveLane(e)?.K ?? e.K;
|
|
593
|
+
}
|
|
532
594
|
function hasActiveOverride(e) {
|
|
533
|
-
return !!(e.
|
|
595
|
+
return !!(e.ee !== undefined && e.ee !== NOT_PENDING);
|
|
534
596
|
}
|
|
535
597
|
function assignOrMergeLane(e, t) {
|
|
536
598
|
const n = findLane(t);
|
|
537
|
-
const i = e.
|
|
599
|
+
const i = e.q;
|
|
538
600
|
if (i) {
|
|
539
|
-
if (i.
|
|
540
|
-
e.
|
|
601
|
+
if (i.U) {
|
|
602
|
+
e.q = t;
|
|
541
603
|
return;
|
|
542
604
|
}
|
|
543
605
|
const r = findLane(i);
|
|
544
606
|
if (activeLanes.has(r)) {
|
|
545
607
|
if (r !== n && !hasActiveOverride(e)) {
|
|
546
|
-
if (n.
|
|
547
|
-
e.
|
|
548
|
-
} else if (r.
|
|
608
|
+
if (n.Oe && findLane(n.Oe) === r) {
|
|
609
|
+
e.q = t;
|
|
610
|
+
} else if (r.Oe && findLane(r.Oe) === n);
|
|
549
611
|
else mergeLanes(n, r);
|
|
550
612
|
}
|
|
551
613
|
return;
|
|
552
614
|
}
|
|
553
615
|
}
|
|
554
|
-
e.
|
|
616
|
+
e.q = t;
|
|
617
|
+
}
|
|
618
|
+
function addPendingSource(e, t) {
|
|
619
|
+
if (e.Ie === t || e.pe?.has(t)) return false;
|
|
620
|
+
if (!e.Ie) {
|
|
621
|
+
e.Ie = t;
|
|
622
|
+
return true;
|
|
623
|
+
}
|
|
624
|
+
if (!e.pe) {
|
|
625
|
+
e.pe = new Set([e.Ie, t]);
|
|
626
|
+
} else {
|
|
627
|
+
e.pe.add(t);
|
|
628
|
+
}
|
|
629
|
+
e.Ie = undefined;
|
|
630
|
+
return true;
|
|
631
|
+
}
|
|
632
|
+
function removePendingSource(e, t) {
|
|
633
|
+
if (e.Ie) {
|
|
634
|
+
if (e.Ie !== t) return false;
|
|
635
|
+
e.Ie = undefined;
|
|
636
|
+
return true;
|
|
637
|
+
}
|
|
638
|
+
if (!e.pe?.delete(t)) return false;
|
|
639
|
+
if (e.pe.size === 1) {
|
|
640
|
+
e.Ie = e.pe.values().next().value;
|
|
641
|
+
e.pe = undefined;
|
|
642
|
+
} else if (e.pe.size === 0) {
|
|
643
|
+
e.pe = undefined;
|
|
644
|
+
}
|
|
645
|
+
return true;
|
|
646
|
+
}
|
|
647
|
+
function clearPendingSources(e) {
|
|
648
|
+
e.Ie = undefined;
|
|
649
|
+
e.pe?.clear();
|
|
650
|
+
e.pe = undefined;
|
|
651
|
+
}
|
|
652
|
+
function setPendingError(e, t, n) {
|
|
653
|
+
if (!t) {
|
|
654
|
+
e.le = null;
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
657
|
+
if (n instanceof NotReadyError && n.source === t) {
|
|
658
|
+
e.le = n;
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
const i = e.le;
|
|
662
|
+
if (!(i instanceof NotReadyError) || i.source !== t) {
|
|
663
|
+
e.le = new NotReadyError(t);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
function forEachDependent(e, t) {
|
|
667
|
+
for (let n = e.I; n !== null; n = n.p) t(n.h);
|
|
668
|
+
for (let n = e.A; n !== null; n = n.N) {
|
|
669
|
+
for (let e = n.I; e !== null; e = e.p) t(e.h);
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
function settlePendingSource(e) {
|
|
673
|
+
let t = false;
|
|
674
|
+
const n = new Set();
|
|
675
|
+
const settle = i => {
|
|
676
|
+
if (n.has(i) || !removePendingSource(i, e)) return;
|
|
677
|
+
n.add(i);
|
|
678
|
+
i.Ee = clock;
|
|
679
|
+
const r = i.Ie ?? i.pe?.values().next().value;
|
|
680
|
+
if (r) {
|
|
681
|
+
setPendingError(i, r);
|
|
682
|
+
updatePendingSignal(i);
|
|
683
|
+
} else {
|
|
684
|
+
i.Se &= ~STATUS_PENDING;
|
|
685
|
+
setPendingError(i);
|
|
686
|
+
updatePendingSignal(i);
|
|
687
|
+
if (i.he) {
|
|
688
|
+
if (i.W === EFFECT_TRACKED) {
|
|
689
|
+
const e = i;
|
|
690
|
+
if (!e.H) {
|
|
691
|
+
e.H = true;
|
|
692
|
+
e.F.enqueue(EFFECT_USER, e.M);
|
|
693
|
+
}
|
|
694
|
+
} else {
|
|
695
|
+
const e = i.O & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue;
|
|
696
|
+
if (e.P > i.o) e.P = i.o;
|
|
697
|
+
insertIntoHeap(i, e);
|
|
698
|
+
}
|
|
699
|
+
t = true;
|
|
700
|
+
}
|
|
701
|
+
i.he = false;
|
|
702
|
+
}
|
|
703
|
+
forEachDependent(i, settle);
|
|
704
|
+
};
|
|
705
|
+
forEachDependent(e, settle);
|
|
706
|
+
if (t) schedule();
|
|
555
707
|
}
|
|
556
708
|
function handleAsync(e, t, n) {
|
|
557
709
|
const i = typeof t === "object" && t !== null;
|
|
558
710
|
const r = i && untrack(() => t[Symbol.asyncIterator]);
|
|
559
711
|
const o = !r && i && untrack(() => typeof t.then === "function");
|
|
560
712
|
if (!o && !r) {
|
|
561
|
-
e.
|
|
713
|
+
e.Ae = null;
|
|
562
714
|
return t;
|
|
563
715
|
}
|
|
564
|
-
e.
|
|
716
|
+
e.Ae = t;
|
|
565
717
|
let s;
|
|
566
718
|
const handleError = n => {
|
|
567
|
-
if (e.
|
|
568
|
-
globalQueue.initTransition(e
|
|
719
|
+
if (e.Ae !== t) return;
|
|
720
|
+
globalQueue.initTransition(resolveTransition(e));
|
|
569
721
|
notifyStatus(e, n instanceof NotReadyError ? STATUS_PENDING : STATUS_ERROR, n);
|
|
570
|
-
e.
|
|
722
|
+
e.Ee = clock;
|
|
571
723
|
};
|
|
572
724
|
const asyncWrite = (i, r) => {
|
|
573
|
-
if (e.
|
|
725
|
+
if (e.Ae !== t) return;
|
|
574
726
|
if (e.O & (REACTIVE_DIRTY | REACTIVE_OPTIMISTIC_DIRTY)) return;
|
|
575
|
-
globalQueue.initTransition(e
|
|
727
|
+
globalQueue.initTransition(resolveTransition(e));
|
|
576
728
|
clearStatus(e);
|
|
577
729
|
const o = resolveLane(e);
|
|
578
|
-
if (o) o.
|
|
730
|
+
if (o) o.k.delete(e);
|
|
579
731
|
if (n) n(i);
|
|
580
|
-
else if (e.
|
|
581
|
-
if (e.
|
|
732
|
+
else if (e.ee !== undefined) {
|
|
733
|
+
if (e.ee !== undefined && e.ee !== NOT_PENDING) e.X = i;
|
|
582
734
|
else {
|
|
583
|
-
e.
|
|
735
|
+
e.J = i;
|
|
584
736
|
insertSubs(e);
|
|
585
737
|
}
|
|
586
|
-
e.
|
|
738
|
+
e.Ee = clock;
|
|
587
739
|
} else if (o) {
|
|
588
|
-
const t = e.
|
|
589
|
-
const n = e.
|
|
740
|
+
const t = e.J;
|
|
741
|
+
const n = e.Ne;
|
|
590
742
|
if (!n || !n(i, t)) {
|
|
591
|
-
e.
|
|
592
|
-
e.
|
|
593
|
-
if (e.
|
|
594
|
-
setSignal(e.
|
|
743
|
+
e.J = i;
|
|
744
|
+
e.Ee = clock;
|
|
745
|
+
if (e.Pe) {
|
|
746
|
+
setSignal(e.Pe, i);
|
|
595
747
|
}
|
|
596
748
|
insertSubs(e, true);
|
|
597
749
|
}
|
|
598
750
|
} else {
|
|
599
751
|
setSignal(e, () => i);
|
|
600
752
|
}
|
|
753
|
+
settlePendingSource(e);
|
|
601
754
|
schedule();
|
|
602
755
|
flush();
|
|
603
756
|
r?.();
|
|
@@ -618,7 +771,7 @@ function handleAsync(e, t, n) {
|
|
|
618
771
|
);
|
|
619
772
|
i = false;
|
|
620
773
|
if (!n) {
|
|
621
|
-
globalQueue.initTransition(e
|
|
774
|
+
globalQueue.initTransition(resolveTransition(e));
|
|
622
775
|
throw new NotReadyError(context);
|
|
623
776
|
}
|
|
624
777
|
}
|
|
@@ -654,126 +807,92 @@ function handleAsync(e, t, n) {
|
|
|
654
807
|
};
|
|
655
808
|
const r = iterate();
|
|
656
809
|
if (!i && !r) {
|
|
657
|
-
globalQueue.initTransition(e
|
|
810
|
+
globalQueue.initTransition(resolveTransition(e));
|
|
658
811
|
throw new NotReadyError(context);
|
|
659
812
|
}
|
|
660
813
|
}
|
|
661
814
|
return s;
|
|
662
815
|
}
|
|
663
|
-
function clearStatus(e) {
|
|
664
|
-
e
|
|
665
|
-
e
|
|
816
|
+
function clearStatus(e, t = false) {
|
|
817
|
+
clearPendingSources(e);
|
|
818
|
+
removeTransitionBlocker(e);
|
|
819
|
+
e.he = false;
|
|
820
|
+
e.Se = t ? 0 : e.Se & STATUS_UNINITIALIZED;
|
|
821
|
+
setPendingError(e);
|
|
666
822
|
updatePendingSignal(e);
|
|
667
|
-
e.
|
|
823
|
+
e.ge?.();
|
|
668
824
|
}
|
|
669
825
|
function notifyStatus(e, t, n, i, r) {
|
|
670
826
|
if (t === STATUS_ERROR && !(n instanceof StatusError) && !(n instanceof NotReadyError))
|
|
671
827
|
n = new StatusError(e, n);
|
|
672
|
-
const o = n instanceof NotReadyError
|
|
673
|
-
const s =
|
|
674
|
-
const u =
|
|
828
|
+
const o = t === STATUS_PENDING && n instanceof NotReadyError ? n.source : undefined;
|
|
829
|
+
const s = o === e;
|
|
830
|
+
const u = t === STATUS_PENDING && e.ee !== undefined && !s;
|
|
831
|
+
const c = u && hasActiveOverride(e);
|
|
675
832
|
if (!i) {
|
|
676
|
-
|
|
677
|
-
|
|
833
|
+
if (t === STATUS_PENDING && o) {
|
|
834
|
+
addPendingSource(e, o);
|
|
835
|
+
e.Se = STATUS_PENDING | (e.Se & STATUS_UNINITIALIZED);
|
|
836
|
+
setPendingError(e, e.Ie ?? e.pe?.values().next().value, n);
|
|
837
|
+
if (o === e) addTransitionBlocker(e);
|
|
838
|
+
} else {
|
|
839
|
+
clearPendingSources(e);
|
|
840
|
+
removeTransitionBlocker(e);
|
|
841
|
+
e.Se = t | (t !== STATUS_ERROR ? e.Se & STATUS_UNINITIALIZED : 0);
|
|
842
|
+
e.le = n;
|
|
843
|
+
}
|
|
678
844
|
updatePendingSignal(e);
|
|
679
845
|
}
|
|
680
846
|
if (r && !i) {
|
|
681
847
|
assignOrMergeLane(e, r);
|
|
682
848
|
}
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
}
|
|
689
|
-
const c = i || u;
|
|
690
|
-
const a = i || s ? undefined : r;
|
|
691
|
-
if (e.he) {
|
|
692
|
-
if (c) {
|
|
693
|
-
e.he(t, n);
|
|
849
|
+
const a = i || c;
|
|
850
|
+
const f = i || u ? undefined : r;
|
|
851
|
+
if (e.ge) {
|
|
852
|
+
if (a) {
|
|
853
|
+
e.ge(t, n);
|
|
694
854
|
} else {
|
|
695
|
-
e.
|
|
855
|
+
e.ge();
|
|
696
856
|
}
|
|
697
857
|
return;
|
|
698
858
|
}
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
if (
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
for (let e = i.I; e !== null; e = e.p) {
|
|
708
|
-
e.h.J = clock;
|
|
709
|
-
if (e.h.q !== n) {
|
|
710
|
-
!e.h.ne && globalQueue.M.push(e.h);
|
|
711
|
-
notifyStatus(e.h, t, n, c, a);
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
function unlinkSubs(e) {
|
|
717
|
-
const t = e.m;
|
|
718
|
-
const n = e.D;
|
|
719
|
-
const i = e.p;
|
|
720
|
-
const r = e.Ae;
|
|
721
|
-
if (i !== null) i.Ae = r;
|
|
722
|
-
else t.Ne = r;
|
|
723
|
-
if (r !== null) r.p = i;
|
|
724
|
-
else {
|
|
725
|
-
t.I = i;
|
|
726
|
-
if (i === null) {
|
|
727
|
-
t.ge?.();
|
|
728
|
-
t.L && !t.Pe && !(t.O & REACTIVE_ZOMBIE) && unobserved(t);
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
return n;
|
|
732
|
-
}
|
|
733
|
-
function unobserved(e) {
|
|
734
|
-
deleteFromHeap(e, e.O & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
735
|
-
let t = e.C;
|
|
736
|
-
while (t !== null) {
|
|
737
|
-
t = unlinkSubs(t);
|
|
738
|
-
}
|
|
739
|
-
e.C = null;
|
|
740
|
-
disposeChildren(e, true);
|
|
741
|
-
}
|
|
742
|
-
function link(e, t) {
|
|
743
|
-
const n = t.Ce;
|
|
744
|
-
if (n !== null && n.m === e) return;
|
|
745
|
-
let i = null;
|
|
746
|
-
const r = t.O & REACTIVE_RECOMPUTING_DEPS;
|
|
747
|
-
if (r) {
|
|
748
|
-
i = n !== null ? n.D : t.C;
|
|
749
|
-
if (i !== null && i.m === e) {
|
|
750
|
-
t.Ce = i;
|
|
751
|
-
return;
|
|
859
|
+
forEachDependent(e, e => {
|
|
860
|
+
e.Ee = clock;
|
|
861
|
+
if (
|
|
862
|
+
(t === STATUS_PENDING && o && e.Ie !== o && !e.pe?.has(o)) ||
|
|
863
|
+
(t !== STATUS_PENDING && (e.le !== n || e.Ie || e.pe))
|
|
864
|
+
) {
|
|
865
|
+
!e.K && globalQueue.oe.push(e);
|
|
866
|
+
notifyStatus(e, t, n, a, f);
|
|
752
867
|
}
|
|
753
|
-
}
|
|
754
|
-
const o = e.Ne;
|
|
755
|
-
if (o !== null && o.h === t && (!r || isValidLink(o, t))) return;
|
|
756
|
-
const s = (t.Ce = e.Ne = { m: e, h: t, D: i, Ae: o, p: null });
|
|
757
|
-
if (n !== null) n.D = s;
|
|
758
|
-
else t.C = s;
|
|
759
|
-
if (o !== null) o.p = s;
|
|
760
|
-
else e.I = s;
|
|
868
|
+
});
|
|
761
869
|
}
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
870
|
+
let externalSourceConfig = null;
|
|
871
|
+
function enableExternalSource(e) {
|
|
872
|
+
const { factory: t, untrack: n = e => e() } = e;
|
|
873
|
+
if (externalSourceConfig) {
|
|
874
|
+
const { factory: e, untrack: i } = externalSourceConfig;
|
|
875
|
+
externalSourceConfig = {
|
|
876
|
+
factory: (n, i) => {
|
|
877
|
+
const r = e(n, i);
|
|
878
|
+
const o = t(e => r.track(e), i);
|
|
879
|
+
return {
|
|
880
|
+
track: e => o.track(e),
|
|
881
|
+
dispose() {
|
|
882
|
+
o.dispose();
|
|
883
|
+
r.dispose();
|
|
884
|
+
}
|
|
885
|
+
};
|
|
886
|
+
},
|
|
887
|
+
untrack: e => i(() => n(e))
|
|
888
|
+
};
|
|
889
|
+
} else {
|
|
890
|
+
externalSourceConfig = { factory: t, untrack: n };
|
|
771
891
|
}
|
|
772
|
-
return false;
|
|
773
892
|
}
|
|
774
893
|
const PENDING_OWNER = {};
|
|
775
894
|
function markDisposal(e) {
|
|
776
|
-
let t = e.
|
|
895
|
+
let t = e.Ce;
|
|
777
896
|
while (t) {
|
|
778
897
|
t.O |= REACTIVE_ZOMBIE;
|
|
779
898
|
if (t.O & REACTIVE_IN_HEAP) {
|
|
@@ -781,7 +900,7 @@ function markDisposal(e) {
|
|
|
781
900
|
insertIntoHeap(t, zombieQueue);
|
|
782
901
|
}
|
|
783
902
|
markDisposal(t);
|
|
784
|
-
t = t.
|
|
903
|
+
t = t.De;
|
|
785
904
|
}
|
|
786
905
|
}
|
|
787
906
|
function dispose(e) {
|
|
@@ -790,15 +909,15 @@ function dispose(e) {
|
|
|
790
909
|
t = unlinkSubs(t);
|
|
791
910
|
} while (t !== null);
|
|
792
911
|
e.C = null;
|
|
793
|
-
e.
|
|
912
|
+
e.ye = null;
|
|
794
913
|
disposeChildren(e, true);
|
|
795
914
|
}
|
|
796
915
|
function disposeChildren(e, t = false, n) {
|
|
797
916
|
if (e.O & REACTIVE_DISPOSED) return;
|
|
798
917
|
if (t) e.O = REACTIVE_DISPOSED;
|
|
799
|
-
let i = n ? e.
|
|
918
|
+
let i = n ? e.me : e.Ce;
|
|
800
919
|
while (i) {
|
|
801
|
-
const e = i.
|
|
920
|
+
const e = i.De;
|
|
802
921
|
if (i.C) {
|
|
803
922
|
const e = i;
|
|
804
923
|
deleteFromHeap(e, e.O & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
@@ -807,21 +926,21 @@ function disposeChildren(e, t = false, n) {
|
|
|
807
926
|
t = unlinkSubs(t);
|
|
808
927
|
} while (t !== null);
|
|
809
928
|
e.C = null;
|
|
810
|
-
e.
|
|
929
|
+
e.ye = null;
|
|
811
930
|
}
|
|
812
931
|
disposeChildren(i, true);
|
|
813
932
|
i = e;
|
|
814
933
|
}
|
|
815
934
|
if (n) {
|
|
816
|
-
e.
|
|
935
|
+
e.me = null;
|
|
817
936
|
} else {
|
|
818
|
-
e.
|
|
819
|
-
e.
|
|
937
|
+
e.Ce = null;
|
|
938
|
+
e.ve = 0;
|
|
820
939
|
}
|
|
821
940
|
runDisposal(e, n);
|
|
822
941
|
}
|
|
823
942
|
function runDisposal(e, t) {
|
|
824
|
-
let n = t ? e.
|
|
943
|
+
let n = t ? e.we : e.be;
|
|
825
944
|
if (!n) return;
|
|
826
945
|
if (Array.isArray(n)) {
|
|
827
946
|
for (let e = 0; e < n.length; e++) {
|
|
@@ -831,12 +950,12 @@ function runDisposal(e, t) {
|
|
|
831
950
|
} else {
|
|
832
951
|
n.call(n);
|
|
833
952
|
}
|
|
834
|
-
t ? (e.
|
|
953
|
+
t ? (e.we = null) : (e.be = null);
|
|
835
954
|
}
|
|
836
955
|
function childId(e, t) {
|
|
837
956
|
let n = e;
|
|
838
957
|
while (n.Ve && n.i) n = n.i;
|
|
839
|
-
if (n.id != null) return formatId(n.id, t ? n.
|
|
958
|
+
if (n.id != null) return formatId(n.id, t ? n.ve++ : n.ve);
|
|
840
959
|
throw new Error("Cannot get child id from owner without an id");
|
|
841
960
|
}
|
|
842
961
|
function getNextChildId(e) {
|
|
@@ -857,11 +976,11 @@ function getObserver() {
|
|
|
857
976
|
function getOwner() {
|
|
858
977
|
return context;
|
|
859
978
|
}
|
|
860
|
-
function
|
|
979
|
+
function cleanup(e) {
|
|
861
980
|
if (!context) return e;
|
|
862
|
-
if (!context.
|
|
863
|
-
else if (Array.isArray(context.
|
|
864
|
-
else context.
|
|
981
|
+
if (!context.be) context.be = e;
|
|
982
|
+
else if (Array.isArray(context.be)) context.be.push(e);
|
|
983
|
+
else context.be = [context.be, e];
|
|
865
984
|
return e;
|
|
866
985
|
}
|
|
867
986
|
function isDisposed(e) {
|
|
@@ -875,26 +994,26 @@ function createOwner(e) {
|
|
|
875
994
|
Ve: n || undefined,
|
|
876
995
|
t: true,
|
|
877
996
|
u: t?.t ? t.u : t,
|
|
997
|
+
Ce: null,
|
|
878
998
|
De: null,
|
|
879
|
-
ye: null,
|
|
880
|
-
me: null,
|
|
881
|
-
ce: t?.ce ?? globalQueue,
|
|
882
|
-
Le: t?.Le || defaultContext,
|
|
883
|
-
we: 0,
|
|
884
999
|
be: null,
|
|
885
|
-
|
|
1000
|
+
F: t?.F ?? globalQueue,
|
|
1001
|
+
Le: t?.Le || defaultContext,
|
|
1002
|
+
ve: 0,
|
|
1003
|
+
we: null,
|
|
1004
|
+
me: null,
|
|
886
1005
|
i: t,
|
|
887
1006
|
dispose(e = true) {
|
|
888
1007
|
disposeChildren(i, e);
|
|
889
1008
|
}
|
|
890
1009
|
};
|
|
891
1010
|
if (t) {
|
|
892
|
-
const e = t.
|
|
1011
|
+
const e = t.Ce;
|
|
893
1012
|
if (e === null) {
|
|
894
|
-
t.
|
|
1013
|
+
t.Ce = i;
|
|
895
1014
|
} else {
|
|
896
|
-
i.
|
|
897
|
-
t.
|
|
1015
|
+
i.De = e;
|
|
1016
|
+
t.Ce = i;
|
|
898
1017
|
}
|
|
899
1018
|
}
|
|
900
1019
|
return i;
|
|
@@ -903,115 +1022,66 @@ function createRoot(e, t) {
|
|
|
903
1022
|
const n = createOwner(t);
|
|
904
1023
|
return runWithOwner(n, () => e(n.dispose));
|
|
905
1024
|
}
|
|
906
|
-
function
|
|
907
|
-
|
|
908
|
-
const
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
s.xe = n;
|
|
920
|
-
s.We = undefined;
|
|
921
|
-
s.se = r?.render ? EFFECT_RENDER : EFFECT_USER;
|
|
922
|
-
s.he = (e, t) => {
|
|
923
|
-
const n = e !== undefined ? e : s.Ee;
|
|
924
|
-
const i = t !== undefined ? t : s.q;
|
|
925
|
-
if (n & STATUS_ERROR) {
|
|
926
|
-
let e = i;
|
|
927
|
-
s.ce.notify(s, STATUS_PENDING, 0);
|
|
928
|
-
if (s.se === EFFECT_USER) {
|
|
929
|
-
try {
|
|
930
|
-
return s.xe
|
|
931
|
-
? s.xe(e, () => {
|
|
932
|
-
s.We?.();
|
|
933
|
-
s.We = undefined;
|
|
934
|
-
})
|
|
935
|
-
: console.error(e);
|
|
936
|
-
} catch (t) {
|
|
937
|
-
e = t;
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
if (!s.ce.notify(s, STATUS_ERROR, STATUS_ERROR)) throw e;
|
|
941
|
-
} else if (s.se === EFFECT_RENDER) {
|
|
942
|
-
s.ce.notify(s, STATUS_PENDING | STATUS_ERROR, n, i);
|
|
1025
|
+
function unlinkSubs(e) {
|
|
1026
|
+
const t = e.m;
|
|
1027
|
+
const n = e.D;
|
|
1028
|
+
const i = e.p;
|
|
1029
|
+
const r = e.Ue;
|
|
1030
|
+
if (i !== null) i.Ue = r;
|
|
1031
|
+
else t.ke = r;
|
|
1032
|
+
if (r !== null) r.p = i;
|
|
1033
|
+
else {
|
|
1034
|
+
t.I = i;
|
|
1035
|
+
if (i === null) {
|
|
1036
|
+
t.Ge?.();
|
|
1037
|
+
t.L && !t.xe && !(t.O & REACTIVE_ZOMBIE) && unobserved(t);
|
|
943
1038
|
}
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
!r?.defer && (s.se === EFFECT_USER ? s.ce.enqueue(s.se, runEffect.bind(s)) : runEffect.call(s));
|
|
947
|
-
o = true;
|
|
948
|
-
onCleanup(() => s.We?.());
|
|
1039
|
+
}
|
|
1040
|
+
return n;
|
|
949
1041
|
}
|
|
950
|
-
function
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
this.We = this.Ue(this.fe, this.ke);
|
|
956
|
-
} catch (e) {
|
|
957
|
-
this.q = new StatusError(this, e);
|
|
958
|
-
this.Ee |= STATUS_ERROR;
|
|
959
|
-
if (!this.ce.notify(this, STATUS_ERROR, STATUS_ERROR)) throw e;
|
|
960
|
-
} finally {
|
|
961
|
-
this.ke = this.fe;
|
|
962
|
-
this.ue = false;
|
|
1042
|
+
function unobserved(e) {
|
|
1043
|
+
deleteFromHeap(e, e.O & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
1044
|
+
let t = e.C;
|
|
1045
|
+
while (t !== null) {
|
|
1046
|
+
t = unlinkSubs(t);
|
|
963
1047
|
}
|
|
1048
|
+
e.C = null;
|
|
1049
|
+
disposeChildren(e, true);
|
|
964
1050
|
}
|
|
965
|
-
function
|
|
966
|
-
const
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
()
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
);
|
|
983
|
-
|
|
984
|
-
n.ue = true;
|
|
985
|
-
n.se = EFFECT_TRACKED;
|
|
986
|
-
n.ae = run;
|
|
987
|
-
n.ce.enqueue(EFFECT_USER, run);
|
|
988
|
-
onCleanup(() => n.We?.());
|
|
1051
|
+
function link(e, t) {
|
|
1052
|
+
const n = t.ye;
|
|
1053
|
+
if (n !== null && n.m === e) return;
|
|
1054
|
+
let i = null;
|
|
1055
|
+
const r = t.O & REACTIVE_RECOMPUTING_DEPS;
|
|
1056
|
+
if (r) {
|
|
1057
|
+
i = n !== null ? n.D : t.C;
|
|
1058
|
+
if (i !== null && i.m === e) {
|
|
1059
|
+
t.ye = i;
|
|
1060
|
+
return;
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
const o = e.ke;
|
|
1064
|
+
if (o !== null && o.h === t && (!r || isValidLink(o, t))) return;
|
|
1065
|
+
const s = (t.ye = e.ke = { m: e, h: t, D: i, Ue: o, p: null });
|
|
1066
|
+
if (n !== null) n.D = s;
|
|
1067
|
+
else t.C = s;
|
|
1068
|
+
if (o !== null) o.p = s;
|
|
1069
|
+
else e.I = s;
|
|
989
1070
|
}
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
return {
|
|
1000
|
-
track: e => o.track(e),
|
|
1001
|
-
dispose() {
|
|
1002
|
-
o.dispose();
|
|
1003
|
-
r.dispose();
|
|
1004
|
-
}
|
|
1005
|
-
};
|
|
1006
|
-
},
|
|
1007
|
-
untrack: e => i(() => n(e))
|
|
1008
|
-
};
|
|
1009
|
-
} else {
|
|
1010
|
-
externalSourceConfig = { factory: t, untrack: n };
|
|
1071
|
+
function isValidLink(e, t) {
|
|
1072
|
+
const n = t.ye;
|
|
1073
|
+
if (n !== null) {
|
|
1074
|
+
let i = t.C;
|
|
1075
|
+
do {
|
|
1076
|
+
if (i === e) return true;
|
|
1077
|
+
if (i === n) break;
|
|
1078
|
+
i = i.D;
|
|
1079
|
+
} while (i !== null);
|
|
1011
1080
|
}
|
|
1081
|
+
return false;
|
|
1012
1082
|
}
|
|
1013
|
-
GlobalQueue.
|
|
1014
|
-
GlobalQueue.
|
|
1083
|
+
GlobalQueue.se = recompute;
|
|
1084
|
+
GlobalQueue.ue = disposeChildren;
|
|
1015
1085
|
let tracking = false;
|
|
1016
1086
|
let stale = false;
|
|
1017
1087
|
let refreshing = false;
|
|
@@ -1024,7 +1094,7 @@ let snapshotCaptureActive = false;
|
|
|
1024
1094
|
let snapshotSources = null;
|
|
1025
1095
|
function ownerInSnapshotScope(e) {
|
|
1026
1096
|
while (e) {
|
|
1027
|
-
if (e.
|
|
1097
|
+
if (e.We) return true;
|
|
1028
1098
|
e = e.i;
|
|
1029
1099
|
}
|
|
1030
1100
|
return false;
|
|
@@ -1034,23 +1104,23 @@ function setSnapshotCapture(e) {
|
|
|
1034
1104
|
if (e && !snapshotSources) snapshotSources = new Set();
|
|
1035
1105
|
}
|
|
1036
1106
|
function markSnapshotScope(e) {
|
|
1037
|
-
e.
|
|
1107
|
+
e.We = true;
|
|
1038
1108
|
}
|
|
1039
1109
|
function releaseSnapshotScope(e) {
|
|
1040
|
-
e.
|
|
1110
|
+
e.We = false;
|
|
1041
1111
|
releaseSubtree(e);
|
|
1042
1112
|
schedule();
|
|
1043
1113
|
}
|
|
1044
1114
|
function releaseSubtree(e) {
|
|
1045
|
-
let t = e.
|
|
1115
|
+
let t = e.Ce;
|
|
1046
1116
|
while (t) {
|
|
1047
|
-
if (t.
|
|
1048
|
-
t = t.
|
|
1117
|
+
if (t.We) {
|
|
1118
|
+
t = t.De;
|
|
1049
1119
|
continue;
|
|
1050
1120
|
}
|
|
1051
1121
|
if (t.L) {
|
|
1052
1122
|
const e = t;
|
|
1053
|
-
e.
|
|
1123
|
+
e.de = false;
|
|
1054
1124
|
if (e.O & REACTIVE_SNAPSHOT_STALE) {
|
|
1055
1125
|
e.O &= ~REACTIVE_SNAPSHOT_STALE;
|
|
1056
1126
|
e.O |= REACTIVE_DIRTY;
|
|
@@ -1059,13 +1129,13 @@ function releaseSubtree(e) {
|
|
|
1059
1129
|
}
|
|
1060
1130
|
}
|
|
1061
1131
|
releaseSubtree(t);
|
|
1062
|
-
t = t.
|
|
1132
|
+
t = t.De;
|
|
1063
1133
|
}
|
|
1064
1134
|
}
|
|
1065
1135
|
function clearSnapshots() {
|
|
1066
1136
|
if (snapshotSources) {
|
|
1067
1137
|
for (const e of snapshotSources) {
|
|
1068
|
-
delete e.
|
|
1138
|
+
delete e.Te;
|
|
1069
1139
|
delete e[STORE_SNAPSHOT_PROPS];
|
|
1070
1140
|
}
|
|
1071
1141
|
snapshotSources = null;
|
|
@@ -1073,33 +1143,33 @@ function clearSnapshots() {
|
|
|
1073
1143
|
snapshotCaptureActive = false;
|
|
1074
1144
|
}
|
|
1075
1145
|
function recompute(e, t = false) {
|
|
1076
|
-
const n = e.
|
|
1146
|
+
const n = e.W;
|
|
1077
1147
|
if (!t) {
|
|
1078
|
-
if (e.
|
|
1079
|
-
globalQueue.initTransition(e.
|
|
1148
|
+
if (e.K && (!n || activeTransition) && activeTransition !== e.K)
|
|
1149
|
+
globalQueue.initTransition(e.K);
|
|
1080
1150
|
deleteFromHeap(e, e.O & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
1081
|
-
if (e.
|
|
1151
|
+
if (e.K || n === EFFECT_TRACKED) disposeChildren(e);
|
|
1082
1152
|
else {
|
|
1083
1153
|
markDisposal(e);
|
|
1084
|
-
e.
|
|
1085
|
-
e.
|
|
1086
|
-
e.
|
|
1087
|
-
e.
|
|
1088
|
-
e.
|
|
1154
|
+
e.we = e.be;
|
|
1155
|
+
e.me = e.Ce;
|
|
1156
|
+
e.be = null;
|
|
1157
|
+
e.Ce = null;
|
|
1158
|
+
e.ve = 0;
|
|
1089
1159
|
}
|
|
1090
1160
|
}
|
|
1091
1161
|
const i = !!(e.O & REACTIVE_OPTIMISTIC_DIRTY);
|
|
1092
|
-
const r = e.
|
|
1093
|
-
const o = !!(e.
|
|
1162
|
+
const r = e.ee !== undefined && e.ee !== NOT_PENDING;
|
|
1163
|
+
const o = !!(e.Se & STATUS_PENDING);
|
|
1094
1164
|
const s = context;
|
|
1095
1165
|
context = e;
|
|
1096
|
-
e.
|
|
1166
|
+
e.ye = null;
|
|
1097
1167
|
e.O = REACTIVE_RECOMPUTING_DEPS;
|
|
1098
|
-
e.
|
|
1099
|
-
let u = e.
|
|
1168
|
+
e.Ee = clock;
|
|
1169
|
+
let u = e.X === NOT_PENDING ? e.J : e.X;
|
|
1100
1170
|
let c = e.o;
|
|
1101
1171
|
let a = tracking;
|
|
1102
|
-
let
|
|
1172
|
+
let f = currentOptimisticLane;
|
|
1103
1173
|
tracking = true;
|
|
1104
1174
|
if (i) {
|
|
1105
1175
|
const t = resolveLane(e);
|
|
@@ -1107,35 +1177,36 @@ function recompute(e, t = false) {
|
|
|
1107
1177
|
}
|
|
1108
1178
|
try {
|
|
1109
1179
|
u = handleAsync(e, e.L(u));
|
|
1110
|
-
clearStatus(e);
|
|
1111
|
-
const
|
|
1112
|
-
if (
|
|
1113
|
-
|
|
1114
|
-
updatePendingSignal(
|
|
1180
|
+
clearStatus(e, t);
|
|
1181
|
+
const n = resolveLane(e);
|
|
1182
|
+
if (n) {
|
|
1183
|
+
n.k.delete(e);
|
|
1184
|
+
updatePendingSignal(n.te);
|
|
1115
1185
|
}
|
|
1116
1186
|
} catch (t) {
|
|
1117
1187
|
if (t instanceof NotReadyError && currentOptimisticLane) {
|
|
1118
1188
|
const t = findLane(currentOptimisticLane);
|
|
1119
|
-
if (t.
|
|
1120
|
-
t.
|
|
1121
|
-
e.
|
|
1122
|
-
updatePendingSignal(t.
|
|
1189
|
+
if (t.te !== e) {
|
|
1190
|
+
t.k.add(e);
|
|
1191
|
+
e.q = t;
|
|
1192
|
+
updatePendingSignal(t.te);
|
|
1123
1193
|
}
|
|
1124
1194
|
}
|
|
1195
|
+
if (t instanceof NotReadyError) e.he = true;
|
|
1125
1196
|
notifyStatus(
|
|
1126
1197
|
e,
|
|
1127
1198
|
t instanceof NotReadyError ? STATUS_PENDING : STATUS_ERROR,
|
|
1128
1199
|
t,
|
|
1129
1200
|
undefined,
|
|
1130
|
-
t instanceof NotReadyError ? e.
|
|
1201
|
+
t instanceof NotReadyError ? e.q : undefined
|
|
1131
1202
|
);
|
|
1132
1203
|
} finally {
|
|
1133
1204
|
tracking = a;
|
|
1134
1205
|
e.O = REACTIVE_NONE | (t ? e.O & REACTIVE_SNAPSHOT_STALE : 0);
|
|
1135
1206
|
context = s;
|
|
1136
1207
|
}
|
|
1137
|
-
if (!e.
|
|
1138
|
-
const s = e.
|
|
1208
|
+
if (!e.le) {
|
|
1209
|
+
const s = e.ye;
|
|
1139
1210
|
let a = s !== null ? s.D : e.C;
|
|
1140
1211
|
if (a !== null) {
|
|
1141
1212
|
do {
|
|
@@ -1144,30 +1215,30 @@ function recompute(e, t = false) {
|
|
|
1144
1215
|
if (s !== null) s.D = null;
|
|
1145
1216
|
else e.C = null;
|
|
1146
1217
|
}
|
|
1147
|
-
const
|
|
1148
|
-
const
|
|
1149
|
-
if (
|
|
1150
|
-
const s = r ? e.
|
|
1151
|
-
if (t || (n && activeTransition !== e.
|
|
1152
|
-
e.
|
|
1218
|
+
const f = r ? e.ee : e.X === NOT_PENDING ? e.J : e.X;
|
|
1219
|
+
const l = !e.Ne || !e.Ne(f, u);
|
|
1220
|
+
if (l) {
|
|
1221
|
+
const s = r ? e.ee : undefined;
|
|
1222
|
+
if (t || (n && activeTransition !== e.K) || i) {
|
|
1223
|
+
e.J = u;
|
|
1153
1224
|
if (r && i) {
|
|
1154
|
-
e.
|
|
1155
|
-
e.
|
|
1225
|
+
e.ee = u;
|
|
1226
|
+
e.X = u;
|
|
1156
1227
|
}
|
|
1157
|
-
} else e.
|
|
1158
|
-
if (r && !i && o && !e.
|
|
1159
|
-
if (!r || i || e.
|
|
1228
|
+
} else e.X = u;
|
|
1229
|
+
if (r && !i && o && !e._e) e.ee = u;
|
|
1230
|
+
if (!r || i || e.ee !== s) insertSubs(e, i || r);
|
|
1160
1231
|
} else if (r) {
|
|
1161
|
-
e.
|
|
1232
|
+
e.X = u;
|
|
1162
1233
|
} else if (e.o != c) {
|
|
1163
1234
|
for (let t = e.I; t !== null; t = t.p) {
|
|
1164
1235
|
insertIntoHeapHeight(t.h, t.h.O & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
1165
1236
|
}
|
|
1166
1237
|
}
|
|
1167
1238
|
}
|
|
1168
|
-
currentOptimisticLane =
|
|
1169
|
-
(!t || e.
|
|
1170
|
-
e.
|
|
1239
|
+
currentOptimisticLane = f;
|
|
1240
|
+
(!t || e.Se & STATUS_PENDING) && !e.K && !(activeTransition && r) && globalQueue.oe.push(e);
|
|
1241
|
+
e.K && n && activeTransition !== e.K && runInTransition(e.K, () => recompute(e));
|
|
1171
1242
|
}
|
|
1172
1243
|
function updateIfNecessary(e) {
|
|
1173
1244
|
if (e.O & REACTIVE_CHECK) {
|
|
@@ -1182,7 +1253,7 @@ function updateIfNecessary(e) {
|
|
|
1182
1253
|
}
|
|
1183
1254
|
}
|
|
1184
1255
|
}
|
|
1185
|
-
if (e.O & (REACTIVE_DIRTY | REACTIVE_OPTIMISTIC_DIRTY) || (e.
|
|
1256
|
+
if (e.O & (REACTIVE_DIRTY | REACTIVE_OPTIMISTIC_DIRTY) || (e.le && e.Ee < clock && !e.Ae)) {
|
|
1186
1257
|
recompute(e);
|
|
1187
1258
|
}
|
|
1188
1259
|
e.O = REACTIVE_NONE | (e.O & REACTIVE_SNAPSHOT_STALE);
|
|
@@ -1192,54 +1263,54 @@ function computed(e, t, n) {
|
|
|
1192
1263
|
const r = {
|
|
1193
1264
|
id: n?.id ?? (i ? context?.id : context?.id != null ? getNextChildId(context) : undefined),
|
|
1194
1265
|
Ve: i || undefined,
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1266
|
+
Ne: n?.equals != null ? n.equals : isEqual,
|
|
1267
|
+
fe: !!n?.pureWrite,
|
|
1268
|
+
Ge: n?.unobserved,
|
|
1269
|
+
be: null,
|
|
1270
|
+
F: context?.F ?? globalQueue,
|
|
1200
1271
|
Le: context?.Le ?? defaultContext,
|
|
1201
|
-
|
|
1272
|
+
ve: 0,
|
|
1202
1273
|
L: e,
|
|
1203
|
-
|
|
1274
|
+
J: t,
|
|
1204
1275
|
o: 0,
|
|
1205
1276
|
A: null,
|
|
1206
1277
|
S: undefined,
|
|
1207
1278
|
T: null,
|
|
1208
1279
|
C: null,
|
|
1209
|
-
|
|
1280
|
+
ye: null,
|
|
1210
1281
|
I: null,
|
|
1211
|
-
|
|
1282
|
+
ke: null,
|
|
1212
1283
|
i: context,
|
|
1213
|
-
ye: null,
|
|
1214
1284
|
De: null,
|
|
1285
|
+
Ce: null,
|
|
1215
1286
|
O: n?.lazy ? REACTIVE_LAZY : REACTIVE_NONE,
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1287
|
+
Se: STATUS_UNINITIALIZED,
|
|
1288
|
+
Ee: clock,
|
|
1289
|
+
X: NOT_PENDING,
|
|
1290
|
+
we: null,
|
|
1291
|
+
me: null,
|
|
1292
|
+
Ae: null,
|
|
1293
|
+
K: null
|
|
1223
1294
|
};
|
|
1224
1295
|
r.T = r;
|
|
1225
1296
|
const o = context?.t ? context.u : context;
|
|
1226
1297
|
if (context) {
|
|
1227
|
-
const e = context.
|
|
1298
|
+
const e = context.Ce;
|
|
1228
1299
|
if (e === null) {
|
|
1229
|
-
context.
|
|
1300
|
+
context.Ce = r;
|
|
1230
1301
|
} else {
|
|
1231
|
-
r.
|
|
1232
|
-
context.
|
|
1302
|
+
r.De = e;
|
|
1303
|
+
context.Ce = r;
|
|
1233
1304
|
}
|
|
1234
1305
|
}
|
|
1235
1306
|
if (o) r.o = o.o + 1;
|
|
1236
|
-
if (snapshotCaptureActive && ownerInSnapshotScope(context)) r.
|
|
1307
|
+
if (snapshotCaptureActive && ownerInSnapshotScope(context)) r.de = true;
|
|
1237
1308
|
if (externalSourceConfig) {
|
|
1238
1309
|
const e = signal(undefined, { equals: false, pureWrite: true });
|
|
1239
1310
|
const t = externalSourceConfig.factory(r.L, () => {
|
|
1240
1311
|
setSignal(e, undefined);
|
|
1241
1312
|
});
|
|
1242
|
-
|
|
1313
|
+
cleanup(() => t.dispose());
|
|
1243
1314
|
r.L = n => {
|
|
1244
1315
|
read(e);
|
|
1245
1316
|
return t.track(n);
|
|
@@ -1247,8 +1318,8 @@ function computed(e, t, n) {
|
|
|
1247
1318
|
}
|
|
1248
1319
|
!n?.lazy && recompute(r, true);
|
|
1249
1320
|
if (snapshotCaptureActive && !n?.lazy) {
|
|
1250
|
-
if (!(r.
|
|
1251
|
-
r.
|
|
1321
|
+
if (!(r.Se & STATUS_PENDING)) {
|
|
1322
|
+
r.Te = r.J === undefined ? NO_SNAPSHOT : r.J;
|
|
1252
1323
|
snapshotSources.add(r);
|
|
1253
1324
|
}
|
|
1254
1325
|
}
|
|
@@ -1256,33 +1327,33 @@ function computed(e, t, n) {
|
|
|
1256
1327
|
}
|
|
1257
1328
|
function signal(e, t, n = null) {
|
|
1258
1329
|
const i = {
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1330
|
+
Ne: t?.equals != null ? t.equals : isEqual,
|
|
1331
|
+
fe: !!t?.pureWrite,
|
|
1332
|
+
He: !!t?.He,
|
|
1333
|
+
Ge: t?.unobserved,
|
|
1334
|
+
J: e,
|
|
1264
1335
|
I: null,
|
|
1265
|
-
|
|
1266
|
-
|
|
1336
|
+
ke: null,
|
|
1337
|
+
Ee: clock,
|
|
1267
1338
|
V: n,
|
|
1268
1339
|
N: n?.A || null,
|
|
1269
|
-
|
|
1340
|
+
X: NOT_PENDING
|
|
1270
1341
|
};
|
|
1271
1342
|
n && (n.A = i);
|
|
1272
|
-
if (snapshotCaptureActive && !i.
|
|
1273
|
-
i.
|
|
1343
|
+
if (snapshotCaptureActive && !i.He && !((n?.Se ?? 0) & STATUS_PENDING)) {
|
|
1344
|
+
i.Te = e === undefined ? NO_SNAPSHOT : e;
|
|
1274
1345
|
snapshotSources.add(i);
|
|
1275
1346
|
}
|
|
1276
1347
|
return i;
|
|
1277
1348
|
}
|
|
1278
1349
|
function optimisticSignal(e, t) {
|
|
1279
1350
|
const n = signal(e, t);
|
|
1280
|
-
n.
|
|
1351
|
+
n.ee = NOT_PENDING;
|
|
1281
1352
|
return n;
|
|
1282
1353
|
}
|
|
1283
1354
|
function optimisticComputed(e, t, n) {
|
|
1284
1355
|
const i = computed(e, t, n);
|
|
1285
|
-
i.
|
|
1356
|
+
i.ee = NOT_PENDING;
|
|
1286
1357
|
return i;
|
|
1287
1358
|
}
|
|
1288
1359
|
function isEqual(e, t) {
|
|
@@ -1304,7 +1375,7 @@ function read(e) {
|
|
|
1304
1375
|
const t = getLatestValueComputed(e);
|
|
1305
1376
|
const n = latestReadActive;
|
|
1306
1377
|
latestReadActive = false;
|
|
1307
|
-
const i = e.
|
|
1378
|
+
const i = e.ee !== undefined && e.ee !== NOT_PENDING ? e.ee : e.J;
|
|
1308
1379
|
let r;
|
|
1309
1380
|
try {
|
|
1310
1381
|
r = read(t);
|
|
@@ -1314,26 +1385,30 @@ function read(e) {
|
|
|
1314
1385
|
} finally {
|
|
1315
1386
|
latestReadActive = n;
|
|
1316
1387
|
}
|
|
1317
|
-
if (t.
|
|
1318
|
-
if (stale && currentOptimisticLane && t.
|
|
1319
|
-
const e = findLane(t.
|
|
1388
|
+
if (t.Se & STATUS_PENDING) return i;
|
|
1389
|
+
if (stale && currentOptimisticLane && t.q) {
|
|
1390
|
+
const e = findLane(t.q);
|
|
1320
1391
|
const n = findLane(currentOptimisticLane);
|
|
1321
|
-
if (e !== n && e.
|
|
1392
|
+
if (e !== n && e.k.size > 0) {
|
|
1322
1393
|
return i;
|
|
1323
1394
|
}
|
|
1324
1395
|
}
|
|
1325
1396
|
return r;
|
|
1326
1397
|
}
|
|
1327
1398
|
if (pendingCheckActive) {
|
|
1328
|
-
const t = e.V
|
|
1329
|
-
const n =
|
|
1330
|
-
const i = pendingCheckActive;
|
|
1399
|
+
const t = e.V;
|
|
1400
|
+
const n = pendingCheckActive;
|
|
1331
1401
|
pendingCheckActive = false;
|
|
1332
|
-
if (
|
|
1333
|
-
|
|
1402
|
+
if (t && e.ee !== undefined) {
|
|
1403
|
+
if (e.ee !== NOT_PENDING && (t.Ae || !!(t.Se & STATUS_PENDING))) {
|
|
1404
|
+
foundPending = true;
|
|
1405
|
+
}
|
|
1406
|
+
} else {
|
|
1407
|
+
if (read(getPendingSignal(e))) foundPending = true;
|
|
1408
|
+
if (t && read(getPendingSignal(t))) foundPending = true;
|
|
1334
1409
|
}
|
|
1335
|
-
pendingCheckActive =
|
|
1336
|
-
return e.
|
|
1410
|
+
pendingCheckActive = n;
|
|
1411
|
+
return e.J;
|
|
1337
1412
|
}
|
|
1338
1413
|
let t = context;
|
|
1339
1414
|
if (t?.t) t = t.u;
|
|
@@ -1359,56 +1434,57 @@ function read(e) {
|
|
|
1359
1434
|
}
|
|
1360
1435
|
}
|
|
1361
1436
|
}
|
|
1362
|
-
if (n.
|
|
1363
|
-
|
|
1364
|
-
if (i && !(i.Ee & STATUS_PENDING)) clearStatus(n);
|
|
1365
|
-
else if (t && !(stale && n.ne && activeTransition !== n.ne)) {
|
|
1437
|
+
if (n.Se & STATUS_PENDING) {
|
|
1438
|
+
if (t && !(stale && n.K && activeTransition !== n.K)) {
|
|
1366
1439
|
if (currentOptimisticLane) {
|
|
1367
|
-
const i = n.
|
|
1440
|
+
const i = n.q;
|
|
1368
1441
|
const r = findLane(currentOptimisticLane);
|
|
1369
1442
|
if (i && findLane(i) === r && !hasActiveOverride(n)) {
|
|
1370
1443
|
if (!tracking && e !== t) link(e, t);
|
|
1371
|
-
throw n.
|
|
1444
|
+
throw n.le;
|
|
1372
1445
|
}
|
|
1373
1446
|
} else {
|
|
1374
1447
|
if (!tracking && e !== t) link(e, t);
|
|
1375
|
-
throw n.
|
|
1448
|
+
throw n.le;
|
|
1376
1449
|
}
|
|
1377
|
-
} else if (!t && n.
|
|
1378
|
-
throw n.
|
|
1450
|
+
} else if (!t && n.Se & STATUS_UNINITIALIZED) {
|
|
1451
|
+
throw n.le;
|
|
1379
1452
|
}
|
|
1380
1453
|
}
|
|
1381
|
-
if (e.L && e.
|
|
1382
|
-
if (e.
|
|
1454
|
+
if (e.L && e.Se & STATUS_ERROR) {
|
|
1455
|
+
if (e.Ee < clock) {
|
|
1383
1456
|
recompute(e, true);
|
|
1384
1457
|
return read(e);
|
|
1385
|
-
} else throw e.
|
|
1458
|
+
} else throw e.le;
|
|
1386
1459
|
}
|
|
1387
|
-
if (snapshotCaptureActive && t && t.
|
|
1388
|
-
const n = e.
|
|
1460
|
+
if (snapshotCaptureActive && t && t.de) {
|
|
1461
|
+
const n = e.Te;
|
|
1389
1462
|
if (n !== undefined) {
|
|
1390
1463
|
const i = n === NO_SNAPSHOT ? undefined : n;
|
|
1391
|
-
const r = e.
|
|
1464
|
+
const r = e.X !== NOT_PENDING ? e.X : e.J;
|
|
1392
1465
|
if (r !== i) t.O |= REACTIVE_SNAPSHOT_STALE;
|
|
1393
1466
|
return i;
|
|
1394
1467
|
}
|
|
1395
1468
|
}
|
|
1396
|
-
if (e.
|
|
1469
|
+
if (e.ee !== undefined && e.ee !== NOT_PENDING) {
|
|
1470
|
+
if (t && stale && shouldReadStashedOptimisticValue(e)) return e.J;
|
|
1471
|
+
return e.ee;
|
|
1472
|
+
}
|
|
1397
1473
|
return !t ||
|
|
1398
1474
|
(currentOptimisticLane !== null &&
|
|
1399
|
-
(e.
|
|
1400
|
-
e.
|
|
1401
|
-
(stale && e.
|
|
1402
|
-
? e.
|
|
1403
|
-
: e.
|
|
1475
|
+
(e.ee !== undefined || e.q || (n === e && stale) || !!(n.Se & STATUS_PENDING))) ||
|
|
1476
|
+
e.X === NOT_PENDING ||
|
|
1477
|
+
(stale && e.K && activeTransition !== e.K)
|
|
1478
|
+
? e.J
|
|
1479
|
+
: e.X;
|
|
1404
1480
|
}
|
|
1405
1481
|
function setSignal(e, t) {
|
|
1406
|
-
if (e.
|
|
1407
|
-
const n = e.
|
|
1408
|
-
const i = e.
|
|
1409
|
-
const r = n ? (i ? e.
|
|
1482
|
+
if (e.K && activeTransition !== e.K) globalQueue.initTransition(e.K);
|
|
1483
|
+
const n = e.ee !== undefined && !projectionWriteActive;
|
|
1484
|
+
const i = e.ee !== undefined && e.ee !== NOT_PENDING;
|
|
1485
|
+
const r = n ? (i ? e.ee : e.J) : e.X === NOT_PENDING ? e.J : e.X;
|
|
1410
1486
|
if (typeof t === "function") t = t(r);
|
|
1411
|
-
const o = !e.
|
|
1487
|
+
const o = !e.Ne || !e.Ne(r, t) || !!(e.Se & STATUS_UNINITIALIZED);
|
|
1412
1488
|
if (!o) {
|
|
1413
1489
|
if (n && i && e.L) {
|
|
1414
1490
|
insertSubs(e, true);
|
|
@@ -1417,25 +1493,25 @@ function setSignal(e, t) {
|
|
|
1417
1493
|
return t;
|
|
1418
1494
|
}
|
|
1419
1495
|
if (n) {
|
|
1420
|
-
const n = e.
|
|
1421
|
-
if (!n
|
|
1496
|
+
const n = e.ee === NOT_PENDING;
|
|
1497
|
+
if (!n) globalQueue.initTransition(resolveTransition(e));
|
|
1422
1498
|
if (n) {
|
|
1423
|
-
e.
|
|
1424
|
-
globalQueue
|
|
1499
|
+
e.X = e.J;
|
|
1500
|
+
globalQueue.Y.push(e);
|
|
1425
1501
|
}
|
|
1426
|
-
e.
|
|
1502
|
+
e._e = true;
|
|
1427
1503
|
const i = getOrCreateLane(e);
|
|
1428
|
-
e.
|
|
1429
|
-
e.
|
|
1504
|
+
e.q = i;
|
|
1505
|
+
e.ee = t;
|
|
1430
1506
|
} else {
|
|
1431
|
-
if (e.
|
|
1432
|
-
e.
|
|
1507
|
+
if (e.X === NOT_PENDING) globalQueue.oe.push(e);
|
|
1508
|
+
e.X = t;
|
|
1433
1509
|
}
|
|
1434
1510
|
updatePendingSignal(e);
|
|
1435
|
-
if (e.
|
|
1436
|
-
setSignal(e.
|
|
1511
|
+
if (e.Pe) {
|
|
1512
|
+
setSignal(e.Pe, t);
|
|
1437
1513
|
}
|
|
1438
|
-
e.
|
|
1514
|
+
e.Ee = clock;
|
|
1439
1515
|
insertSubs(e, n);
|
|
1440
1516
|
schedule();
|
|
1441
1517
|
return t;
|
|
@@ -1453,61 +1529,68 @@ function runWithOwner(e, t) {
|
|
|
1453
1529
|
}
|
|
1454
1530
|
}
|
|
1455
1531
|
function getPendingSignal(e) {
|
|
1456
|
-
if (!e.
|
|
1457
|
-
e.
|
|
1458
|
-
if (e.
|
|
1459
|
-
e.
|
|
1532
|
+
if (!e.Qe) {
|
|
1533
|
+
e.Qe = optimisticSignal(false, { pureWrite: true });
|
|
1534
|
+
if (e.Re) {
|
|
1535
|
+
e.Qe.Re = e;
|
|
1460
1536
|
}
|
|
1461
|
-
if (computePendingState(e)) setSignal(e.
|
|
1537
|
+
if (computePendingState(e)) setSignal(e.Qe, true);
|
|
1462
1538
|
}
|
|
1463
|
-
return e.
|
|
1539
|
+
return e.Qe;
|
|
1464
1540
|
}
|
|
1465
1541
|
function computePendingState(e) {
|
|
1466
1542
|
const t = e;
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1543
|
+
const n = e.V;
|
|
1544
|
+
if (n && e.X !== NOT_PENDING) {
|
|
1545
|
+
return !n.Ae && !(n.Se & STATUS_PENDING);
|
|
1546
|
+
}
|
|
1547
|
+
if (e.ee !== undefined && e.ee !== NOT_PENDING) {
|
|
1548
|
+
if (t.Se & STATUS_PENDING && !(t.Se & STATUS_UNINITIALIZED)) return true;
|
|
1549
|
+
if (e.Re) {
|
|
1550
|
+
const t = e.q ? findLane(e.q) : null;
|
|
1551
|
+
return !!(t && t.k.size > 0);
|
|
1472
1552
|
}
|
|
1473
1553
|
return true;
|
|
1474
1554
|
}
|
|
1475
|
-
if (e.
|
|
1476
|
-
|
|
1555
|
+
if (e.ee !== undefined && e.ee === NOT_PENDING && !e.Re) {
|
|
1556
|
+
return false;
|
|
1557
|
+
}
|
|
1558
|
+
if (e.X !== NOT_PENDING && !(t.Se & STATUS_UNINITIALIZED)) return true;
|
|
1559
|
+
return !!(t.Se & STATUS_PENDING && !(t.Se & STATUS_UNINITIALIZED));
|
|
1477
1560
|
}
|
|
1478
1561
|
function updatePendingSignal(e) {
|
|
1479
|
-
if (e.
|
|
1562
|
+
if (e.Qe) {
|
|
1480
1563
|
const t = computePendingState(e);
|
|
1481
|
-
const n = e.
|
|
1564
|
+
const n = e.Qe;
|
|
1482
1565
|
setSignal(n, t);
|
|
1483
|
-
if (!t && n.
|
|
1566
|
+
if (!t && n.q) {
|
|
1484
1567
|
const t = resolveLane(e);
|
|
1485
|
-
if (t && t.
|
|
1486
|
-
const e = findLane(n.
|
|
1568
|
+
if (t && t.k.size > 0) {
|
|
1569
|
+
const e = findLane(n.q);
|
|
1487
1570
|
if (e !== t) {
|
|
1488
1571
|
mergeLanes(t, e);
|
|
1489
1572
|
}
|
|
1490
1573
|
}
|
|
1491
1574
|
signalLanes.delete(n);
|
|
1492
|
-
n.
|
|
1575
|
+
n.q = undefined;
|
|
1493
1576
|
}
|
|
1494
1577
|
}
|
|
1495
1578
|
}
|
|
1496
1579
|
function getLatestValueComputed(e) {
|
|
1497
|
-
if (!e.
|
|
1580
|
+
if (!e.Pe) {
|
|
1498
1581
|
const t = latestReadActive;
|
|
1499
1582
|
latestReadActive = false;
|
|
1500
1583
|
const n = pendingCheckActive;
|
|
1501
1584
|
pendingCheckActive = false;
|
|
1502
1585
|
const i = context;
|
|
1503
1586
|
context = null;
|
|
1504
|
-
e.
|
|
1505
|
-
e.
|
|
1587
|
+
e.Pe = optimisticComputed(() => read(e));
|
|
1588
|
+
e.Pe.Re = e;
|
|
1506
1589
|
context = i;
|
|
1507
1590
|
pendingCheckActive = n;
|
|
1508
1591
|
latestReadActive = t;
|
|
1509
1592
|
}
|
|
1510
|
-
return e.
|
|
1593
|
+
return e.Pe;
|
|
1511
1594
|
}
|
|
1512
1595
|
function staleValues(e, t = true) {
|
|
1513
1596
|
const n = stale;
|
|
@@ -1586,6 +1669,96 @@ function hasContext(e, t) {
|
|
|
1586
1669
|
function isUndefined(e) {
|
|
1587
1670
|
return typeof e === "undefined";
|
|
1588
1671
|
}
|
|
1672
|
+
function effect(e, t, n, i, r) {
|
|
1673
|
+
let o = false;
|
|
1674
|
+
const s = computed(r?.render ? t => staleValues(() => e(t)) : e, i, {
|
|
1675
|
+
...r,
|
|
1676
|
+
equals: () => {
|
|
1677
|
+
s.H = !s.le;
|
|
1678
|
+
if (o) s.F.enqueue(s.W, runEffect.bind(s));
|
|
1679
|
+
return false;
|
|
1680
|
+
},
|
|
1681
|
+
lazy: true
|
|
1682
|
+
});
|
|
1683
|
+
s.Fe = i;
|
|
1684
|
+
s.Me = t;
|
|
1685
|
+
s.$e = n;
|
|
1686
|
+
s.je = undefined;
|
|
1687
|
+
s.W = r?.render ? EFFECT_RENDER : EFFECT_USER;
|
|
1688
|
+
s.ge = (e, t) => {
|
|
1689
|
+
const n = e !== undefined ? e : s.Se;
|
|
1690
|
+
const i = t !== undefined ? t : s.le;
|
|
1691
|
+
if (n & STATUS_ERROR) {
|
|
1692
|
+
let e = i;
|
|
1693
|
+
s.F.notify(s, STATUS_PENDING, 0);
|
|
1694
|
+
if (s.W === EFFECT_USER) {
|
|
1695
|
+
try {
|
|
1696
|
+
return s.$e
|
|
1697
|
+
? s.$e(e, () => {
|
|
1698
|
+
s.je?.();
|
|
1699
|
+
s.je = undefined;
|
|
1700
|
+
})
|
|
1701
|
+
: console.error(e);
|
|
1702
|
+
} catch (t) {
|
|
1703
|
+
e = t;
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
if (!s.F.notify(s, STATUS_ERROR, STATUS_ERROR)) throw e;
|
|
1707
|
+
} else if (s.W === EFFECT_RENDER) {
|
|
1708
|
+
s.F.notify(s, STATUS_PENDING | STATUS_ERROR, n, i);
|
|
1709
|
+
}
|
|
1710
|
+
};
|
|
1711
|
+
recompute(s, true);
|
|
1712
|
+
!r?.defer && (s.W === EFFECT_USER ? s.F.enqueue(s.W, runEffect.bind(s)) : runEffect.call(s));
|
|
1713
|
+
o = true;
|
|
1714
|
+
cleanup(() => s.je?.());
|
|
1715
|
+
}
|
|
1716
|
+
function runEffect() {
|
|
1717
|
+
if (!this.H || this.O & REACTIVE_DISPOSED) return;
|
|
1718
|
+
this.je?.();
|
|
1719
|
+
this.je = undefined;
|
|
1720
|
+
try {
|
|
1721
|
+
this.je = this.Me(this.J, this.Fe);
|
|
1722
|
+
} catch (e) {
|
|
1723
|
+
this.le = new StatusError(this, e);
|
|
1724
|
+
this.Se |= STATUS_ERROR;
|
|
1725
|
+
if (!this.F.notify(this, STATUS_ERROR, STATUS_ERROR)) throw e;
|
|
1726
|
+
} finally {
|
|
1727
|
+
this.Fe = this.J;
|
|
1728
|
+
this.H = false;
|
|
1729
|
+
}
|
|
1730
|
+
}
|
|
1731
|
+
function trackedEffect(e, t) {
|
|
1732
|
+
const run = () => {
|
|
1733
|
+
if (!n.H || n.O & REACTIVE_DISPOSED) return;
|
|
1734
|
+
n.H = false;
|
|
1735
|
+
recompute(n);
|
|
1736
|
+
};
|
|
1737
|
+
const n = computed(
|
|
1738
|
+
() => {
|
|
1739
|
+
n.je?.();
|
|
1740
|
+
n.je = undefined;
|
|
1741
|
+
n.je = staleValues(e) || undefined;
|
|
1742
|
+
},
|
|
1743
|
+
undefined,
|
|
1744
|
+
{ ...t, lazy: true }
|
|
1745
|
+
);
|
|
1746
|
+
n.je = undefined;
|
|
1747
|
+
n.Ke = true;
|
|
1748
|
+
n.H = true;
|
|
1749
|
+
n.W = EFFECT_TRACKED;
|
|
1750
|
+
n.ge = (e, t) => {
|
|
1751
|
+
const i = e !== undefined ? e : n.Se;
|
|
1752
|
+
if (i & STATUS_ERROR) {
|
|
1753
|
+
n.F.notify(n, STATUS_PENDING, 0);
|
|
1754
|
+
const e = t !== undefined ? t : n.le;
|
|
1755
|
+
if (!n.F.notify(n, STATUS_ERROR, STATUS_ERROR)) throw e;
|
|
1756
|
+
}
|
|
1757
|
+
};
|
|
1758
|
+
n.M = run;
|
|
1759
|
+
n.F.enqueue(EFFECT_USER, run);
|
|
1760
|
+
cleanup(() => n.je?.());
|
|
1761
|
+
}
|
|
1589
1762
|
function restoreTransition(e, t) {
|
|
1590
1763
|
globalQueue.initTransition(e);
|
|
1591
1764
|
const n = t();
|
|
@@ -1598,11 +1771,11 @@ function action(e) {
|
|
|
1598
1771
|
const r = e(...t);
|
|
1599
1772
|
globalQueue.initTransition();
|
|
1600
1773
|
let o = activeTransition;
|
|
1601
|
-
o.
|
|
1774
|
+
o.j.push(r);
|
|
1602
1775
|
const done = (e, t) => {
|
|
1603
1776
|
o = currentTransition(o);
|
|
1604
|
-
const s = o.
|
|
1605
|
-
if (s >= 0) o.
|
|
1777
|
+
const s = o.j.indexOf(r);
|
|
1778
|
+
if (s >= 0) o.j.splice(s, 1);
|
|
1606
1779
|
setActiveTransition(o);
|
|
1607
1780
|
schedule();
|
|
1608
1781
|
t ? i(t) : n(e);
|
|
@@ -1630,6 +1803,9 @@ function action(e) {
|
|
|
1630
1803
|
step();
|
|
1631
1804
|
});
|
|
1632
1805
|
}
|
|
1806
|
+
function onCleanup(e) {
|
|
1807
|
+
return cleanup(e);
|
|
1808
|
+
}
|
|
1633
1809
|
function accessor(e) {
|
|
1634
1810
|
const t = read.bind(null, e);
|
|
1635
1811
|
t.$r = true;
|
|
@@ -1658,7 +1834,7 @@ function createTrackedEffect(e, t) {
|
|
|
1658
1834
|
}
|
|
1659
1835
|
function createReaction(e, t) {
|
|
1660
1836
|
let n = undefined;
|
|
1661
|
-
|
|
1837
|
+
cleanup(() => n?.());
|
|
1662
1838
|
const i = getOwner();
|
|
1663
1839
|
return r => {
|
|
1664
1840
|
runWithOwner(i, () => {
|
|
@@ -1696,7 +1872,8 @@ function createOptimistic(e, t, n) {
|
|
|
1696
1872
|
return [accessor(i), setSignal.bind(null, i)];
|
|
1697
1873
|
}
|
|
1698
1874
|
function onSettled(e) {
|
|
1699
|
-
getOwner()
|
|
1875
|
+
const t = getOwner();
|
|
1876
|
+
t && !t.Ke
|
|
1700
1877
|
? createTrackedEffect(() => untrack(e))
|
|
1701
1878
|
: globalQueue.enqueue(EFFECT_USER, () => {
|
|
1702
1879
|
const t = e();
|
|
@@ -1730,67 +1907,67 @@ function applyState(e, t, n) {
|
|
|
1730
1907
|
let t = false;
|
|
1731
1908
|
const c = getOverrideValue(r, o, u, "length", s);
|
|
1732
1909
|
if (e.length && c && e[0] && n(e[0]) != null) {
|
|
1733
|
-
let a,
|
|
1910
|
+
let a, f, l, E, T, d, S, R;
|
|
1734
1911
|
for (
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
((d = getOverrideValue(r, o, u,
|
|
1738
|
-
|
|
1912
|
+
l = 0, E = Math.min(c, e.length);
|
|
1913
|
+
l < E &&
|
|
1914
|
+
((d = getOverrideValue(r, o, u, l, s)) === e[l] || (d && e[l] && n(d) === n(e[l])));
|
|
1915
|
+
l++
|
|
1739
1916
|
) {
|
|
1740
|
-
applyState(e[
|
|
1917
|
+
applyState(e[l], wrap(d, i), n);
|
|
1741
1918
|
}
|
|
1742
1919
|
const O = new Array(e.length),
|
|
1743
1920
|
_ = new Map();
|
|
1744
1921
|
for (
|
|
1745
1922
|
E = c - 1, T = e.length - 1;
|
|
1746
|
-
E >=
|
|
1747
|
-
T >=
|
|
1923
|
+
E >= l &&
|
|
1924
|
+
T >= l &&
|
|
1748
1925
|
((d = getOverrideValue(r, o, u, E, s)) === e[T] || (d && e[T] && n(d) === n(e[T])));
|
|
1749
1926
|
E--, T--
|
|
1750
1927
|
) {
|
|
1751
1928
|
O[T] = d;
|
|
1752
1929
|
}
|
|
1753
|
-
if (
|
|
1754
|
-
for (
|
|
1930
|
+
if (l > T || l > E) {
|
|
1931
|
+
for (f = l; f <= T; f++) {
|
|
1755
1932
|
t = true;
|
|
1756
|
-
i[STORE_NODE][
|
|
1933
|
+
i[STORE_NODE][f] && setSignal(i[STORE_NODE][f], wrap(e[f], i));
|
|
1757
1934
|
}
|
|
1758
|
-
for (;
|
|
1935
|
+
for (; f < e.length; f++) {
|
|
1759
1936
|
t = true;
|
|
1760
|
-
const r = wrap(O[
|
|
1761
|
-
i[STORE_NODE][
|
|
1762
|
-
applyState(e[
|
|
1937
|
+
const r = wrap(O[f], i);
|
|
1938
|
+
i[STORE_NODE][f] && setSignal(i[STORE_NODE][f], r);
|
|
1939
|
+
applyState(e[f], r, n);
|
|
1763
1940
|
}
|
|
1764
1941
|
t && i[STORE_NODE][$TRACK] && setSignal(i[STORE_NODE][$TRACK], void 0);
|
|
1765
1942
|
c !== e.length && i[STORE_NODE].length && setSignal(i[STORE_NODE].length, e.length);
|
|
1766
1943
|
return;
|
|
1767
1944
|
}
|
|
1768
1945
|
S = new Array(T + 1);
|
|
1769
|
-
for (
|
|
1770
|
-
d = e[
|
|
1946
|
+
for (f = T; f >= l; f--) {
|
|
1947
|
+
d = e[f];
|
|
1771
1948
|
R = d ? n(d) : d;
|
|
1772
1949
|
a = _.get(R);
|
|
1773
|
-
S[
|
|
1774
|
-
_.set(R,
|
|
1950
|
+
S[f] = a === undefined ? -1 : a;
|
|
1951
|
+
_.set(R, f);
|
|
1775
1952
|
}
|
|
1776
|
-
for (a =
|
|
1953
|
+
for (a = l; a <= E; a++) {
|
|
1777
1954
|
d = getOverrideValue(r, o, u, a, s);
|
|
1778
1955
|
R = d ? n(d) : d;
|
|
1779
|
-
|
|
1780
|
-
if (
|
|
1781
|
-
O[
|
|
1782
|
-
|
|
1783
|
-
_.set(R,
|
|
1956
|
+
f = _.get(R);
|
|
1957
|
+
if (f !== undefined && f !== -1) {
|
|
1958
|
+
O[f] = d;
|
|
1959
|
+
f = S[f];
|
|
1960
|
+
_.set(R, f);
|
|
1784
1961
|
}
|
|
1785
1962
|
}
|
|
1786
|
-
for (
|
|
1787
|
-
if (
|
|
1788
|
-
const t = wrap(O[
|
|
1789
|
-
i[STORE_NODE][
|
|
1790
|
-
applyState(e[
|
|
1791
|
-
} else i[STORE_NODE][
|
|
1963
|
+
for (f = l; f < e.length; f++) {
|
|
1964
|
+
if (f in O) {
|
|
1965
|
+
const t = wrap(O[f], i);
|
|
1966
|
+
i[STORE_NODE][f] && setSignal(i[STORE_NODE][f], t);
|
|
1967
|
+
applyState(e[f], t, n);
|
|
1968
|
+
} else i[STORE_NODE][f] && setSignal(i[STORE_NODE][f], wrap(e[f], i));
|
|
1792
1969
|
}
|
|
1793
|
-
if (
|
|
1970
|
+
if (l < e.length) t = true;
|
|
1794
1971
|
} else if (e.length) {
|
|
1795
1972
|
for (let t = 0, c = e.length; t < c; t++) {
|
|
1796
1973
|
const c = getOverrideValue(r, o, u, t, s);
|
|
@@ -1809,15 +1986,15 @@ function applyState(e, t, n) {
|
|
|
1809
1986
|
if (u) {
|
|
1810
1987
|
const t = u[$TRACK];
|
|
1811
1988
|
const c = t ? getAllKeys(r, o, e) : Object.keys(u);
|
|
1812
|
-
for (let a = 0,
|
|
1813
|
-
const
|
|
1814
|
-
const
|
|
1815
|
-
const E = unwrap(getOverrideValue(r, o, u,
|
|
1816
|
-
let T = unwrap(e[
|
|
1989
|
+
for (let a = 0, f = c.length; a < f; a++) {
|
|
1990
|
+
const f = c[a];
|
|
1991
|
+
const l = u[f];
|
|
1992
|
+
const E = unwrap(getOverrideValue(r, o, u, f, s));
|
|
1993
|
+
let T = unwrap(e[f]);
|
|
1817
1994
|
if (E === T) continue;
|
|
1818
1995
|
if (!E || !isWrappable(E) || !isWrappable(T) || (n(E) != null && n(E) !== n(T))) {
|
|
1819
1996
|
t && setSignal(t, void 0);
|
|
1820
|
-
|
|
1997
|
+
l && setSignal(l, isWrappable(T) ? wrap(T, i) : T);
|
|
1821
1998
|
} else applyState(T, wrap(E, i), n);
|
|
1822
1999
|
}
|
|
1823
2000
|
}
|
|
@@ -1862,55 +2039,68 @@ function createProjectionInternal(e, t = {}, n) {
|
|
|
1862
2039
|
const o = wrapProjection(t);
|
|
1863
2040
|
i = computed(() => {
|
|
1864
2041
|
const t = getOwner();
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
2042
|
+
let i = false;
|
|
2043
|
+
let r;
|
|
2044
|
+
const s = new Proxy(
|
|
2045
|
+
o,
|
|
2046
|
+
createWriteTraps(() => !i || t.Ae === r)
|
|
2047
|
+
);
|
|
2048
|
+
storeSetter(s, s => {
|
|
2049
|
+
r = e(s);
|
|
2050
|
+
i = true;
|
|
2051
|
+
const u = handleAsync(t, r, e => {
|
|
2052
|
+
e !== s && e !== undefined && storeSetter(o, reconcile(e, n?.key || "id"));
|
|
1868
2053
|
});
|
|
1869
|
-
|
|
2054
|
+
u !== s && u !== undefined && reconcile(u, n?.key || "id")(o);
|
|
1870
2055
|
});
|
|
1871
2056
|
});
|
|
1872
|
-
i.
|
|
2057
|
+
i.xe = true;
|
|
1873
2058
|
return { store: o, node: i };
|
|
1874
2059
|
}
|
|
1875
2060
|
function createProjection(e, t = {}, n) {
|
|
1876
2061
|
return createProjectionInternal(e, t, n).store;
|
|
1877
2062
|
}
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
2063
|
+
function createWriteTraps(e) {
|
|
2064
|
+
const t = {
|
|
2065
|
+
get(e, n) {
|
|
2066
|
+
let i;
|
|
2067
|
+
setWriteOverride(true);
|
|
2068
|
+
setProjectionWriteActive(true);
|
|
2069
|
+
try {
|
|
2070
|
+
i = e[n];
|
|
2071
|
+
} finally {
|
|
2072
|
+
setWriteOverride(false);
|
|
2073
|
+
setProjectionWriteActive(false);
|
|
2074
|
+
}
|
|
2075
|
+
return typeof i === "object" && i !== null ? new Proxy(i, t) : i;
|
|
2076
|
+
},
|
|
2077
|
+
set(t, n, i) {
|
|
2078
|
+
if (e && !e()) return true;
|
|
2079
|
+
setWriteOverride(true);
|
|
2080
|
+
setProjectionWriteActive(true);
|
|
2081
|
+
try {
|
|
2082
|
+
t[n] = i;
|
|
2083
|
+
} finally {
|
|
2084
|
+
setWriteOverride(false);
|
|
2085
|
+
setProjectionWriteActive(false);
|
|
2086
|
+
}
|
|
2087
|
+
return true;
|
|
2088
|
+
},
|
|
2089
|
+
deleteProperty(t, n) {
|
|
2090
|
+
if (e && !e()) return true;
|
|
2091
|
+
setWriteOverride(true);
|
|
2092
|
+
setProjectionWriteActive(true);
|
|
2093
|
+
try {
|
|
2094
|
+
delete t[n];
|
|
2095
|
+
} finally {
|
|
2096
|
+
setWriteOverride(false);
|
|
2097
|
+
setProjectionWriteActive(false);
|
|
2098
|
+
}
|
|
2099
|
+
return true;
|
|
1910
2100
|
}
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
}
|
|
2101
|
+
};
|
|
2102
|
+
return t;
|
|
2103
|
+
}
|
|
1914
2104
|
const $TRACK = Symbol(0),
|
|
1915
2105
|
$TARGET = Symbol(0),
|
|
1916
2106
|
$PROXY = Symbol(0),
|
|
@@ -1968,11 +2158,11 @@ function getNode(e, t, n, i, r = isEqual, o, s) {
|
|
|
1968
2158
|
i
|
|
1969
2159
|
);
|
|
1970
2160
|
if (o) {
|
|
1971
|
-
u.
|
|
2161
|
+
u.ee = NOT_PENDING;
|
|
1972
2162
|
}
|
|
1973
2163
|
if (s && t in s) {
|
|
1974
2164
|
const e = s[t];
|
|
1975
|
-
u.
|
|
2165
|
+
u.Te = e === undefined ? NO_SNAPSHOT : e;
|
|
1976
2166
|
snapshotSources?.add(u);
|
|
1977
2167
|
}
|
|
1978
2168
|
return (e[t] = u);
|
|
@@ -2029,11 +2219,11 @@ const storeTraps = {
|
|
|
2029
2219
|
if (writeOnly(n)) {
|
|
2030
2220
|
let n =
|
|
2031
2221
|
r && (s || !u)
|
|
2032
|
-
? r.
|
|
2033
|
-
? r.
|
|
2034
|
-
: r.
|
|
2035
|
-
? r.
|
|
2036
|
-
: r.
|
|
2222
|
+
? r.ee !== undefined && r.ee !== NOT_PENDING
|
|
2223
|
+
? r.ee
|
|
2224
|
+
: r.X !== NOT_PENDING
|
|
2225
|
+
? r.X
|
|
2226
|
+
: r.J
|
|
2037
2227
|
: c[t];
|
|
2038
2228
|
n === $DELETED && (n = undefined);
|
|
2039
2229
|
if (!isWrappable(n)) return n;
|
|
@@ -2084,8 +2274,8 @@ const storeTraps = {
|
|
|
2084
2274
|
if (writeOnly(i)) {
|
|
2085
2275
|
if (e[STORE_OPTIMISTIC]) {
|
|
2086
2276
|
const t = e[STORE_FIREWALL];
|
|
2087
|
-
if (t?.
|
|
2088
|
-
globalQueue.initTransition(t.
|
|
2277
|
+
if (t?.K) {
|
|
2278
|
+
globalQueue.initTransition(t.K);
|
|
2089
2279
|
}
|
|
2090
2280
|
}
|
|
2091
2281
|
untrack(() => {
|
|
@@ -2094,7 +2284,7 @@ const storeTraps = {
|
|
|
2094
2284
|
if (
|
|
2095
2285
|
snapshotCaptureActive &&
|
|
2096
2286
|
typeof t !== "symbol" &&
|
|
2097
|
-
!((e[STORE_FIREWALL]?.
|
|
2287
|
+
!((e[STORE_FIREWALL]?.Se ?? 0) & STATUS_PENDING)
|
|
2098
2288
|
) {
|
|
2099
2289
|
if (!e[STORE_SNAPSHOT_PROPS]) {
|
|
2100
2290
|
e[STORE_SNAPSHOT_PROPS] = Object.create(null);
|
|
@@ -2115,19 +2305,19 @@ const storeTraps = {
|
|
|
2115
2305
|
: o;
|
|
2116
2306
|
const a = n?.[$TARGET]?.[STORE_VALUE] ?? n;
|
|
2117
2307
|
if (c === a) return true;
|
|
2118
|
-
const
|
|
2308
|
+
const f = e[STORE_OPTIMISTIC_OVERRIDE]?.length || e[STORE_OVERRIDE]?.length || r.length;
|
|
2119
2309
|
if (a !== undefined && a === o) delete e[u][t];
|
|
2120
2310
|
else (e[u] || (e[u] = Object.create(null)))[t] = a;
|
|
2121
|
-
const
|
|
2311
|
+
const l = isWrappable(a);
|
|
2122
2312
|
e[STORE_HAS]?.[t] && setSignal(e[STORE_HAS][t], true);
|
|
2123
2313
|
const E = getNodes(e, STORE_NODE);
|
|
2124
|
-
E[t] && setSignal(E[t], () => (
|
|
2314
|
+
E[t] && setSignal(E[t], () => (l ? wrap(a, e) : a));
|
|
2125
2315
|
if (Array.isArray(r)) {
|
|
2126
2316
|
if (t === "length") {
|
|
2127
2317
|
E.length && setSignal(E.length, a);
|
|
2128
2318
|
} else {
|
|
2129
2319
|
const e = parseInt(t) + 1;
|
|
2130
|
-
if (e >
|
|
2320
|
+
if (e > f) E.length && setSignal(E.length, e);
|
|
2131
2321
|
}
|
|
2132
2322
|
}
|
|
2133
2323
|
E[$TRACK] && setSignal(E[$TRACK], undefined);
|
|
@@ -2225,7 +2415,7 @@ function createStore(e, t, n) {
|
|
|
2225
2415
|
return [r, e => storeSetter(r, e)];
|
|
2226
2416
|
}
|
|
2227
2417
|
function createOptimisticStore(e, t, n) {
|
|
2228
|
-
GlobalQueue.
|
|
2418
|
+
GlobalQueue.ce ||= clearOptimisticStore;
|
|
2229
2419
|
const i = typeof e === "function";
|
|
2230
2420
|
const r = (i ? t : e) ?? {};
|
|
2231
2421
|
const o = i ? e : undefined;
|
|
@@ -2242,7 +2432,7 @@ function clearOptimisticStore(e) {
|
|
|
2242
2432
|
if (i) {
|
|
2243
2433
|
for (const e of Reflect.ownKeys(n)) {
|
|
2244
2434
|
if (i[e]) {
|
|
2245
|
-
i[e].
|
|
2435
|
+
i[e].q = undefined;
|
|
2246
2436
|
const n =
|
|
2247
2437
|
t[STORE_OVERRIDE] && e in t[STORE_OVERRIDE] ? t[STORE_OVERRIDE][e] : t[STORE_VALUE][e];
|
|
2248
2438
|
const r = n === $DELETED ? undefined : n;
|
|
@@ -2250,7 +2440,7 @@ function clearOptimisticStore(e) {
|
|
|
2250
2440
|
}
|
|
2251
2441
|
}
|
|
2252
2442
|
if (i[$TRACK]) {
|
|
2253
|
-
i[$TRACK].
|
|
2443
|
+
i[$TRACK].q = undefined;
|
|
2254
2444
|
setSignal(i[$TRACK], undefined);
|
|
2255
2445
|
}
|
|
2256
2446
|
}
|
|
@@ -2284,24 +2474,32 @@ function createOptimisticProjectionInternal(e, t = {}, n) {
|
|
|
2284
2474
|
if (e) {
|
|
2285
2475
|
i = computed(() => {
|
|
2286
2476
|
const t = getOwner();
|
|
2477
|
+
let i = false;
|
|
2478
|
+
let r;
|
|
2479
|
+
const s = new Proxy(
|
|
2480
|
+
o,
|
|
2481
|
+
createWriteTraps(() => !i || t.Ae === r)
|
|
2482
|
+
);
|
|
2287
2483
|
setProjectionWriteActive(true);
|
|
2288
2484
|
try {
|
|
2289
|
-
storeSetter(
|
|
2290
|
-
|
|
2485
|
+
storeSetter(s, s => {
|
|
2486
|
+
r = e(s);
|
|
2487
|
+
i = true;
|
|
2488
|
+
const u = handleAsync(t, r, e => {
|
|
2291
2489
|
setProjectionWriteActive(true);
|
|
2292
2490
|
try {
|
|
2293
|
-
e !==
|
|
2491
|
+
e !== s && e !== undefined && storeSetter(o, reconcile(e, n?.key || "id"));
|
|
2294
2492
|
} finally {
|
|
2295
2493
|
setProjectionWriteActive(false);
|
|
2296
2494
|
}
|
|
2297
2495
|
});
|
|
2298
|
-
|
|
2496
|
+
u !== s && u !== undefined && reconcile(u, n?.key || "id")(o);
|
|
2299
2497
|
});
|
|
2300
2498
|
} finally {
|
|
2301
2499
|
setProjectionWriteActive(false);
|
|
2302
2500
|
}
|
|
2303
2501
|
});
|
|
2304
|
-
i.
|
|
2502
|
+
i.xe = true;
|
|
2305
2503
|
}
|
|
2306
2504
|
return { store: o, node: i };
|
|
2307
2505
|
}
|
|
@@ -2388,29 +2586,29 @@ function snapshotImpl(e, t, n, i) {
|
|
|
2388
2586
|
}
|
|
2389
2587
|
if (o) {
|
|
2390
2588
|
const o = s?.length || e.length;
|
|
2391
|
-
for (let
|
|
2392
|
-
a = s &&
|
|
2589
|
+
for (let f = 0; f < o; f++) {
|
|
2590
|
+
a = s && f in s ? s[f] : e[f];
|
|
2393
2591
|
if (a === $DELETED) continue;
|
|
2394
2592
|
if (t && isWrappable(a)) wrap(a, r);
|
|
2395
2593
|
if ((c = snapshotImpl(a, t, n, i)) !== a || u) {
|
|
2396
2594
|
if (!u) n.set(e, (u = [...e]));
|
|
2397
|
-
u[
|
|
2595
|
+
u[f] = c;
|
|
2398
2596
|
}
|
|
2399
2597
|
}
|
|
2400
2598
|
} else {
|
|
2401
2599
|
const o = getKeys(e, s);
|
|
2402
|
-
for (let
|
|
2403
|
-
let
|
|
2404
|
-
const E = getPropertyDescriptor(e, s,
|
|
2600
|
+
for (let f = 0, l = o.length; f < l; f++) {
|
|
2601
|
+
let l = o[f];
|
|
2602
|
+
const E = getPropertyDescriptor(e, s, l);
|
|
2405
2603
|
if (E.get) continue;
|
|
2406
|
-
a = s &&
|
|
2604
|
+
a = s && l in s ? s[l] : e[l];
|
|
2407
2605
|
if (t && isWrappable(a)) wrap(a, r);
|
|
2408
|
-
if ((c = snapshotImpl(a, t, n, i)) !== e[
|
|
2606
|
+
if ((c = snapshotImpl(a, t, n, i)) !== e[l] || u) {
|
|
2409
2607
|
if (!u) {
|
|
2410
2608
|
u = Object.create(Object.getPrototypeOf(e));
|
|
2411
2609
|
Object.assign(u, e);
|
|
2412
2610
|
}
|
|
2413
|
-
u[
|
|
2611
|
+
u[l] = c;
|
|
2414
2612
|
}
|
|
2415
2613
|
}
|
|
2416
2614
|
}
|
|
@@ -2558,221 +2756,221 @@ function mapArray(e, t, n) {
|
|
|
2558
2756
|
const o = t;
|
|
2559
2757
|
return createMemo(
|
|
2560
2758
|
updateKeyedMap.bind({
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2759
|
+
Ye: createOwner(),
|
|
2760
|
+
Be: 0,
|
|
2761
|
+
Ze: e,
|
|
2762
|
+
qe: [],
|
|
2763
|
+
ze: o,
|
|
2764
|
+
Xe: [],
|
|
2765
|
+
Je: [],
|
|
2766
|
+
et: i,
|
|
2767
|
+
tt: i || n?.keyed === false ? [] : undefined,
|
|
2768
|
+
nt: r ? [] : undefined,
|
|
2769
|
+
it: n?.fallback
|
|
2572
2770
|
})
|
|
2573
2771
|
);
|
|
2574
2772
|
}
|
|
2575
2773
|
const pureOptions = { pureWrite: true };
|
|
2576
2774
|
function updateKeyedMap() {
|
|
2577
|
-
const e = this.
|
|
2775
|
+
const e = this.Ze() || [],
|
|
2578
2776
|
t = e.length;
|
|
2579
2777
|
e[$TRACK];
|
|
2580
|
-
runWithOwner(this.
|
|
2778
|
+
runWithOwner(this.Ye, () => {
|
|
2581
2779
|
let n,
|
|
2582
2780
|
i,
|
|
2583
|
-
r = this.
|
|
2781
|
+
r = this.tt
|
|
2584
2782
|
? () => {
|
|
2585
|
-
this.
|
|
2586
|
-
this.
|
|
2587
|
-
return this.
|
|
2783
|
+
this.tt[i] = signal(e[i], pureOptions);
|
|
2784
|
+
this.nt && (this.nt[i] = signal(i, pureOptions));
|
|
2785
|
+
return this.ze(accessor(this.tt[i]), this.nt ? accessor(this.nt[i]) : undefined);
|
|
2588
2786
|
}
|
|
2589
|
-
: this.
|
|
2787
|
+
: this.nt
|
|
2590
2788
|
? () => {
|
|
2591
2789
|
const t = e[i];
|
|
2592
|
-
this.
|
|
2593
|
-
return this.
|
|
2790
|
+
this.nt[i] = signal(i, pureOptions);
|
|
2791
|
+
return this.ze(() => t, accessor(this.nt[i]));
|
|
2594
2792
|
}
|
|
2595
2793
|
: () => {
|
|
2596
2794
|
const t = e[i];
|
|
2597
|
-
return this.
|
|
2795
|
+
return this.ze(() => t);
|
|
2598
2796
|
};
|
|
2599
2797
|
if (t === 0) {
|
|
2600
|
-
if (this
|
|
2601
|
-
this.
|
|
2602
|
-
this.
|
|
2603
|
-
this.
|
|
2604
|
-
this.
|
|
2605
|
-
this
|
|
2606
|
-
this.
|
|
2607
|
-
this.
|
|
2608
|
-
}
|
|
2609
|
-
if (this.
|
|
2610
|
-
this.
|
|
2611
|
-
}
|
|
2612
|
-
} else if (this
|
|
2613
|
-
if (this.
|
|
2614
|
-
this.
|
|
2798
|
+
if (this.Be !== 0) {
|
|
2799
|
+
this.Ye.dispose(false);
|
|
2800
|
+
this.Je = [];
|
|
2801
|
+
this.qe = [];
|
|
2802
|
+
this.Xe = [];
|
|
2803
|
+
this.Be = 0;
|
|
2804
|
+
this.tt && (this.tt = []);
|
|
2805
|
+
this.nt && (this.nt = []);
|
|
2806
|
+
}
|
|
2807
|
+
if (this.it && !this.Xe[0]) {
|
|
2808
|
+
this.Xe[0] = runWithOwner((this.Je[0] = createOwner()), this.it);
|
|
2809
|
+
}
|
|
2810
|
+
} else if (this.Be === 0) {
|
|
2811
|
+
if (this.Je[0]) this.Je[0].dispose();
|
|
2812
|
+
this.Xe = new Array(t);
|
|
2615
2813
|
for (i = 0; i < t; i++) {
|
|
2616
|
-
this.
|
|
2617
|
-
this.
|
|
2814
|
+
this.qe[i] = e[i];
|
|
2815
|
+
this.Xe[i] = runWithOwner((this.Je[i] = createOwner()), r);
|
|
2618
2816
|
}
|
|
2619
|
-
this
|
|
2817
|
+
this.Be = t;
|
|
2620
2818
|
} else {
|
|
2621
2819
|
let o,
|
|
2622
2820
|
s,
|
|
2623
2821
|
u,
|
|
2624
2822
|
c,
|
|
2625
2823
|
a,
|
|
2626
|
-
l,
|
|
2627
2824
|
f,
|
|
2825
|
+
l,
|
|
2628
2826
|
E = new Array(t),
|
|
2629
2827
|
T = new Array(t),
|
|
2630
|
-
d = this.
|
|
2631
|
-
S = this.
|
|
2828
|
+
d = this.tt ? new Array(t) : undefined,
|
|
2829
|
+
S = this.nt ? new Array(t) : undefined;
|
|
2632
2830
|
for (
|
|
2633
|
-
o = 0, s = Math.min(this
|
|
2634
|
-
o < s && (this.
|
|
2831
|
+
o = 0, s = Math.min(this.Be, t);
|
|
2832
|
+
o < s && (this.qe[o] === e[o] || (this.tt && compare(this.et, this.qe[o], e[o])));
|
|
2635
2833
|
o++
|
|
2636
2834
|
) {
|
|
2637
|
-
if (this.
|
|
2835
|
+
if (this.tt) setSignal(this.tt[o], e[o]);
|
|
2638
2836
|
}
|
|
2639
2837
|
for (
|
|
2640
|
-
s = this
|
|
2838
|
+
s = this.Be - 1, u = t - 1;
|
|
2641
2839
|
s >= o &&
|
|
2642
2840
|
u >= o &&
|
|
2643
|
-
(this.
|
|
2841
|
+
(this.qe[s] === e[u] || (this.tt && compare(this.et, this.qe[s], e[u])));
|
|
2644
2842
|
s--, u--
|
|
2645
2843
|
) {
|
|
2646
|
-
E[u] = this.
|
|
2647
|
-
T[u] = this.
|
|
2648
|
-
d && (d[u] = this.
|
|
2649
|
-
S && (S[u] = this.
|
|
2844
|
+
E[u] = this.Xe[s];
|
|
2845
|
+
T[u] = this.Je[s];
|
|
2846
|
+
d && (d[u] = this.tt[s]);
|
|
2847
|
+
S && (S[u] = this.nt[s]);
|
|
2650
2848
|
}
|
|
2651
|
-
|
|
2652
|
-
|
|
2849
|
+
f = new Map();
|
|
2850
|
+
l = new Array(u + 1);
|
|
2653
2851
|
for (i = u; i >= o; i--) {
|
|
2654
2852
|
c = e[i];
|
|
2655
|
-
a = this.
|
|
2656
|
-
n =
|
|
2657
|
-
|
|
2658
|
-
|
|
2853
|
+
a = this.et ? this.et(c) : c;
|
|
2854
|
+
n = f.get(a);
|
|
2855
|
+
l[i] = n === undefined ? -1 : n;
|
|
2856
|
+
f.set(a, i);
|
|
2659
2857
|
}
|
|
2660
2858
|
for (n = o; n <= s; n++) {
|
|
2661
|
-
c = this.
|
|
2662
|
-
a = this.
|
|
2663
|
-
i =
|
|
2859
|
+
c = this.qe[n];
|
|
2860
|
+
a = this.et ? this.et(c) : c;
|
|
2861
|
+
i = f.get(a);
|
|
2664
2862
|
if (i !== undefined && i !== -1) {
|
|
2665
|
-
E[i] = this.
|
|
2666
|
-
T[i] = this.
|
|
2667
|
-
d && (d[i] = this.
|
|
2668
|
-
S && (S[i] = this.
|
|
2669
|
-
i =
|
|
2670
|
-
|
|
2671
|
-
} else this.
|
|
2863
|
+
E[i] = this.Xe[n];
|
|
2864
|
+
T[i] = this.Je[n];
|
|
2865
|
+
d && (d[i] = this.tt[n]);
|
|
2866
|
+
S && (S[i] = this.nt[n]);
|
|
2867
|
+
i = l[i];
|
|
2868
|
+
f.set(a, i);
|
|
2869
|
+
} else this.Je[n].dispose();
|
|
2672
2870
|
}
|
|
2673
2871
|
for (i = o; i < t; i++) {
|
|
2674
2872
|
if (i in E) {
|
|
2675
|
-
this.
|
|
2676
|
-
this.
|
|
2873
|
+
this.Xe[i] = E[i];
|
|
2874
|
+
this.Je[i] = T[i];
|
|
2677
2875
|
if (d) {
|
|
2678
|
-
this.
|
|
2679
|
-
setSignal(this.
|
|
2876
|
+
this.tt[i] = d[i];
|
|
2877
|
+
setSignal(this.tt[i], e[i]);
|
|
2680
2878
|
}
|
|
2681
2879
|
if (S) {
|
|
2682
|
-
this.
|
|
2683
|
-
setSignal(this.
|
|
2880
|
+
this.nt[i] = S[i];
|
|
2881
|
+
setSignal(this.nt[i], i);
|
|
2684
2882
|
}
|
|
2685
2883
|
} else {
|
|
2686
|
-
this.
|
|
2884
|
+
this.Xe[i] = runWithOwner((this.Je[i] = createOwner()), r);
|
|
2687
2885
|
}
|
|
2688
2886
|
}
|
|
2689
|
-
this.
|
|
2690
|
-
this.
|
|
2887
|
+
this.Xe = this.Xe.slice(0, (this.Be = t));
|
|
2888
|
+
this.qe = e.slice(0);
|
|
2691
2889
|
}
|
|
2692
2890
|
});
|
|
2693
|
-
return this.
|
|
2891
|
+
return this.Xe;
|
|
2694
2892
|
}
|
|
2695
2893
|
function repeat(e, t, n) {
|
|
2696
2894
|
const i = t;
|
|
2697
2895
|
return updateRepeat.bind({
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2896
|
+
Ye: createOwner(),
|
|
2897
|
+
Be: 0,
|
|
2898
|
+
rt: 0,
|
|
2899
|
+
ot: e,
|
|
2900
|
+
ze: i,
|
|
2901
|
+
Je: [],
|
|
2902
|
+
Xe: [],
|
|
2903
|
+
st: n?.from,
|
|
2904
|
+
it: n?.fallback
|
|
2707
2905
|
});
|
|
2708
2906
|
}
|
|
2709
2907
|
function updateRepeat() {
|
|
2710
|
-
const e = this.
|
|
2711
|
-
const t = this.
|
|
2712
|
-
runWithOwner(this.
|
|
2908
|
+
const e = this.ot();
|
|
2909
|
+
const t = this.st?.() || 0;
|
|
2910
|
+
runWithOwner(this.Ye, () => {
|
|
2713
2911
|
if (e === 0) {
|
|
2714
|
-
if (this
|
|
2715
|
-
this.
|
|
2716
|
-
this.
|
|
2717
|
-
this.
|
|
2718
|
-
this
|
|
2912
|
+
if (this.Be !== 0) {
|
|
2913
|
+
this.Ye.dispose(false);
|
|
2914
|
+
this.Je = [];
|
|
2915
|
+
this.Xe = [];
|
|
2916
|
+
this.Be = 0;
|
|
2719
2917
|
}
|
|
2720
|
-
if (this.
|
|
2721
|
-
this.
|
|
2918
|
+
if (this.it && !this.Xe[0]) {
|
|
2919
|
+
this.Xe[0] = runWithOwner((this.Je[0] = createOwner()), this.it);
|
|
2722
2920
|
}
|
|
2723
2921
|
return;
|
|
2724
2922
|
}
|
|
2725
2923
|
const n = t + e;
|
|
2726
|
-
const i = this.
|
|
2727
|
-
if (this
|
|
2728
|
-
for (let e = n; e < i; e++) this.
|
|
2729
|
-
if (this.
|
|
2730
|
-
let e = this.
|
|
2731
|
-
while (e < t && e < this
|
|
2732
|
-
this.
|
|
2733
|
-
this.
|
|
2734
|
-
} else if (this.
|
|
2735
|
-
let n = i - this.
|
|
2736
|
-
let r = this.
|
|
2737
|
-
this.
|
|
2924
|
+
const i = this.rt + this.Be;
|
|
2925
|
+
if (this.Be === 0 && this.Je[0]) this.Je[0].dispose();
|
|
2926
|
+
for (let e = n; e < i; e++) this.Je[e - this.rt].dispose();
|
|
2927
|
+
if (this.rt < t) {
|
|
2928
|
+
let e = this.rt;
|
|
2929
|
+
while (e < t && e < this.Be) this.Je[e++].dispose();
|
|
2930
|
+
this.Je.splice(0, t - this.rt);
|
|
2931
|
+
this.Xe.splice(0, t - this.rt);
|
|
2932
|
+
} else if (this.rt > t) {
|
|
2933
|
+
let n = i - this.rt - 1;
|
|
2934
|
+
let r = this.rt - t;
|
|
2935
|
+
this.Je.length = this.Xe.length = e;
|
|
2738
2936
|
while (n >= r) {
|
|
2739
|
-
this.
|
|
2740
|
-
this.
|
|
2937
|
+
this.Je[n] = this.Je[n - r];
|
|
2938
|
+
this.Xe[n] = this.Xe[n - r];
|
|
2741
2939
|
n--;
|
|
2742
2940
|
}
|
|
2743
2941
|
for (let e = 0; e < r; e++) {
|
|
2744
|
-
this.
|
|
2942
|
+
this.Xe[e] = runWithOwner((this.Je[e] = createOwner()), () => this.ze(e + t));
|
|
2745
2943
|
}
|
|
2746
2944
|
}
|
|
2747
2945
|
for (let e = i; e < n; e++) {
|
|
2748
|
-
this.
|
|
2946
|
+
this.Xe[e - t] = runWithOwner((this.Je[e - t] = createOwner()), () => this.ze(e));
|
|
2749
2947
|
}
|
|
2750
|
-
this.
|
|
2751
|
-
this.
|
|
2752
|
-
this
|
|
2948
|
+
this.Xe = this.Xe.slice(0, e);
|
|
2949
|
+
this.rt = t;
|
|
2950
|
+
this.Be = e;
|
|
2753
2951
|
});
|
|
2754
|
-
return this.
|
|
2952
|
+
return this.Xe;
|
|
2755
2953
|
}
|
|
2756
2954
|
function compare(e, t, n) {
|
|
2757
2955
|
return e ? e(t) === e(n) : true;
|
|
2758
2956
|
}
|
|
2759
2957
|
function boundaryComputed(e, t) {
|
|
2760
2958
|
const n = computed(e, undefined, { lazy: true });
|
|
2761
|
-
n.
|
|
2762
|
-
const i = e !== undefined ? e : n.
|
|
2763
|
-
const r = t !== undefined ? t : n.
|
|
2764
|
-
n.
|
|
2765
|
-
n.
|
|
2959
|
+
n.ge = (e, t) => {
|
|
2960
|
+
const i = e !== undefined ? e : n.Se;
|
|
2961
|
+
const r = t !== undefined ? t : n.le;
|
|
2962
|
+
n.Se &= ~n.ut;
|
|
2963
|
+
n.F.notify(n, n.ut, i, r);
|
|
2766
2964
|
};
|
|
2767
|
-
n.
|
|
2768
|
-
n.
|
|
2965
|
+
n.ut = t;
|
|
2966
|
+
n.xe = true;
|
|
2769
2967
|
recompute(n, true);
|
|
2770
2968
|
return n;
|
|
2771
2969
|
}
|
|
2772
2970
|
function createBoundChildren(e, t, n, i) {
|
|
2773
|
-
const r = e.
|
|
2774
|
-
r.addChild((e.
|
|
2775
|
-
|
|
2971
|
+
const r = e.F;
|
|
2972
|
+
r.addChild((e.F = n));
|
|
2973
|
+
cleanup(() => r.removeChild(e.F));
|
|
2776
2974
|
return runWithOwner(e, () => {
|
|
2777
2975
|
const e = computed(t);
|
|
2778
2976
|
return boundaryComputed(() => staleValues(() => flatten(read(e))), i);
|
|
@@ -2780,57 +2978,61 @@ function createBoundChildren(e, t, n, i) {
|
|
|
2780
2978
|
}
|
|
2781
2979
|
const ON_INIT = Symbol();
|
|
2782
2980
|
class CollectionQueue extends Queue {
|
|
2783
|
-
rt;
|
|
2784
|
-
ot = new Set();
|
|
2785
|
-
st = signal(false, { pureWrite: true, Qe: true });
|
|
2786
|
-
ut = false;
|
|
2787
2981
|
ct;
|
|
2788
|
-
|
|
2982
|
+
ft = new Set();
|
|
2983
|
+
lt = signal(false, { pureWrite: true, He: true });
|
|
2984
|
+
Et = false;
|
|
2985
|
+
Tt;
|
|
2986
|
+
dt = ON_INIT;
|
|
2789
2987
|
constructor(e) {
|
|
2790
2988
|
super();
|
|
2791
|
-
this.
|
|
2989
|
+
this.ct = e;
|
|
2792
2990
|
}
|
|
2793
2991
|
run(e) {
|
|
2794
|
-
if (!e || read(this.
|
|
2992
|
+
if (!e || read(this.lt)) return;
|
|
2795
2993
|
return super.run(e);
|
|
2796
2994
|
}
|
|
2797
2995
|
notify(e, t, n, i) {
|
|
2798
|
-
if (!(t & this.
|
|
2799
|
-
if (this.
|
|
2996
|
+
if (!(t & this.ct)) return super.notify(e, t, n, i);
|
|
2997
|
+
if (this.Et && this.Tt) {
|
|
2800
2998
|
const e = untrack(() => {
|
|
2801
2999
|
try {
|
|
2802
|
-
return this.
|
|
3000
|
+
return this.Tt();
|
|
2803
3001
|
} catch {
|
|
2804
3002
|
return ON_INIT;
|
|
2805
3003
|
}
|
|
2806
3004
|
});
|
|
2807
|
-
if (e !== this.
|
|
2808
|
-
this.
|
|
2809
|
-
this.
|
|
2810
|
-
this.
|
|
3005
|
+
if (e !== this.dt) {
|
|
3006
|
+
this.dt = e;
|
|
3007
|
+
this.Et = false;
|
|
3008
|
+
this.ft.clear();
|
|
2811
3009
|
}
|
|
2812
3010
|
}
|
|
2813
|
-
if (this.
|
|
2814
|
-
if (n &
|
|
2815
|
-
|
|
3011
|
+
if (this.ct & STATUS_PENDING && this.Et) return super.notify(e, t, n, i);
|
|
3012
|
+
if (this.ct & STATUS_PENDING && n & STATUS_ERROR) {
|
|
3013
|
+
return super.notify(e, STATUS_ERROR, n, i);
|
|
3014
|
+
}
|
|
3015
|
+
if (n & this.ct) {
|
|
3016
|
+
const t = i?.source || e.le?.source;
|
|
2816
3017
|
if (t) {
|
|
2817
|
-
const e = this.
|
|
2818
|
-
this.
|
|
2819
|
-
if (e) setSignal(this.
|
|
3018
|
+
const e = this.ft.size === 0;
|
|
3019
|
+
this.ft.add(t);
|
|
3020
|
+
if (e) setSignal(this.lt, true);
|
|
2820
3021
|
}
|
|
2821
3022
|
}
|
|
2822
|
-
t &= ~this.
|
|
3023
|
+
t &= ~this.ct;
|
|
2823
3024
|
return t ? super.notify(e, t, n, i) : true;
|
|
2824
3025
|
}
|
|
2825
3026
|
checkSources() {
|
|
2826
|
-
for (const e of this.
|
|
2827
|
-
if (!(e.
|
|
3027
|
+
for (const e of this.ft) {
|
|
3028
|
+
if (!(e.Se & this.ct) && !(this.ct & STATUS_ERROR && e.Se & STATUS_PENDING))
|
|
3029
|
+
this.ft.delete(e);
|
|
2828
3030
|
}
|
|
2829
|
-
if (!this.
|
|
2830
|
-
setSignal(this.
|
|
2831
|
-
if (this.
|
|
3031
|
+
if (!this.ft.size) {
|
|
3032
|
+
setSignal(this.lt, false);
|
|
3033
|
+
if (this.Tt) {
|
|
2832
3034
|
try {
|
|
2833
|
-
this.
|
|
3035
|
+
this.dt = untrack(() => this.Tt());
|
|
2834
3036
|
} catch {}
|
|
2835
3037
|
}
|
|
2836
3038
|
}
|
|
@@ -2839,13 +3041,13 @@ class CollectionQueue extends Queue {
|
|
|
2839
3041
|
function createCollectionBoundary(e, t, n, i) {
|
|
2840
3042
|
const r = createOwner();
|
|
2841
3043
|
const o = new CollectionQueue(e);
|
|
2842
|
-
if (i) o.
|
|
3044
|
+
if (i) o.Tt = i;
|
|
2843
3045
|
const s = createBoundChildren(r, t, o, e);
|
|
2844
3046
|
const u = computed(() => {
|
|
2845
|
-
if (!read(o.
|
|
3047
|
+
if (!read(o.lt)) {
|
|
2846
3048
|
const e = read(s);
|
|
2847
|
-
if (!untrack(() => read(o.
|
|
2848
|
-
o.
|
|
3049
|
+
if (!untrack(() => read(o.lt))) {
|
|
3050
|
+
o.Et = true;
|
|
2849
3051
|
return e;
|
|
2850
3052
|
}
|
|
2851
3053
|
}
|
|
@@ -2858,10 +3060,10 @@ function createLoadingBoundary(e, t, n) {
|
|
|
2858
3060
|
}
|
|
2859
3061
|
function createErrorBoundary(e, t) {
|
|
2860
3062
|
return createCollectionBoundary(STATUS_ERROR, e, e => {
|
|
2861
|
-
let n = e.
|
|
2862
|
-
const i = n.
|
|
3063
|
+
let n = e.ft.values().next().value;
|
|
3064
|
+
const i = n.le?.cause ?? n.le;
|
|
2863
3065
|
return t(i, () => {
|
|
2864
|
-
for (const t of e.
|
|
3066
|
+
for (const t of e.ft) recompute(t);
|
|
2865
3067
|
schedule();
|
|
2866
3068
|
});
|
|
2867
3069
|
});
|