@solidjs/signals 0.9.1 → 0.9.3
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 +227 -85
- package/dist/node.cjs +703 -571
- package/dist/prod.js +505 -376
- package/dist/types/core/constants.d.ts +1 -0
- package/dist/types/core/core.d.ts +5 -2
- package/dist/types/core/index.d.ts +1 -1
- package/dist/types/core/scheduler.d.ts +10 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/store/projection.d.ts +8 -3
- package/dist/types/store/store.d.ts +10 -6
- package/package.json +3 -3
package/dist/prod.js
CHANGED
|
@@ -32,6 +32,7 @@ const EFFECT_USER = 2;
|
|
|
32
32
|
const NOT_PENDING = {};
|
|
33
33
|
const SUPPORTS_PROXY = typeof Proxy === "function";
|
|
34
34
|
const defaultContext = {};
|
|
35
|
+
const $REFRESH = Symbol("refresh");
|
|
35
36
|
function actualInsertIntoHeap(e, t) {
|
|
36
37
|
const n = (e.i?.t ? e.i.u?.o : e.i?.o) ?? -1;
|
|
37
38
|
if (n >= e.o) e.o = n + 1;
|
|
@@ -40,56 +41,56 @@ function actualInsertIntoHeap(e, t) {
|
|
|
40
41
|
if (r === undefined) t.l[i] = e;
|
|
41
42
|
else {
|
|
42
43
|
const t = r.T;
|
|
43
|
-
t.
|
|
44
|
+
t.R = e;
|
|
44
45
|
e.T = t;
|
|
45
46
|
r.T = e;
|
|
46
47
|
}
|
|
47
|
-
if (i > t.
|
|
48
|
+
if (i > t.h) t.h = i;
|
|
48
49
|
}
|
|
49
50
|
function insertIntoHeap(e, t) {
|
|
50
|
-
let n = e.
|
|
51
|
+
let n = e.S;
|
|
51
52
|
if (n & (REACTIVE_IN_HEAP | REACTIVE_RECOMPUTING_DEPS)) return;
|
|
52
53
|
if (n & REACTIVE_CHECK) {
|
|
53
|
-
e.
|
|
54
|
-
} else e.
|
|
54
|
+
e.S = (n & -4) | REACTIVE_DIRTY | REACTIVE_IN_HEAP;
|
|
55
|
+
} else e.S = n | REACTIVE_IN_HEAP;
|
|
55
56
|
if (!(n & REACTIVE_IN_HEAP_HEIGHT)) actualInsertIntoHeap(e, t);
|
|
56
57
|
}
|
|
57
58
|
function insertIntoHeapHeight(e, t) {
|
|
58
|
-
let n = e.
|
|
59
|
+
let n = e.S;
|
|
59
60
|
if (n & (REACTIVE_IN_HEAP | REACTIVE_RECOMPUTING_DEPS | REACTIVE_IN_HEAP_HEIGHT)) return;
|
|
60
|
-
e.
|
|
61
|
+
e.S = n | REACTIVE_IN_HEAP_HEIGHT;
|
|
61
62
|
actualInsertIntoHeap(e, t);
|
|
62
63
|
}
|
|
63
64
|
function deleteFromHeap(e, t) {
|
|
64
|
-
const n = e.
|
|
65
|
+
const n = e.S;
|
|
65
66
|
if (!(n & (REACTIVE_IN_HEAP | REACTIVE_IN_HEAP_HEIGHT))) return;
|
|
66
|
-
e.
|
|
67
|
+
e.S = n & -25;
|
|
67
68
|
const i = e.o;
|
|
68
69
|
if (e.T === e) t.l[i] = undefined;
|
|
69
70
|
else {
|
|
70
|
-
const n = e.
|
|
71
|
+
const n = e.R;
|
|
71
72
|
const r = t.l[i];
|
|
72
73
|
const s = n ?? r;
|
|
73
74
|
if (e === r) t.l[i] = n;
|
|
74
|
-
else e.T.
|
|
75
|
+
else e.T.R = n;
|
|
75
76
|
s.T = e.T;
|
|
76
77
|
}
|
|
77
78
|
e.T = e;
|
|
78
|
-
e.
|
|
79
|
+
e.R = undefined;
|
|
79
80
|
}
|
|
80
81
|
function markHeap(e) {
|
|
81
|
-
if (e.
|
|
82
|
-
e.
|
|
83
|
-
for (let t = 0; t <= e.
|
|
84
|
-
for (let n = e.l[t]; n !== undefined; n = n.
|
|
85
|
-
if (n.
|
|
82
|
+
if (e._) return;
|
|
83
|
+
e._ = true;
|
|
84
|
+
for (let t = 0; t <= e.h; t++) {
|
|
85
|
+
for (let n = e.l[t]; n !== undefined; n = n.R) {
|
|
86
|
+
if (n.S & REACTIVE_IN_HEAP) markNode(n);
|
|
86
87
|
}
|
|
87
88
|
}
|
|
88
89
|
}
|
|
89
90
|
function markNode(e, t = REACTIVE_DIRTY) {
|
|
90
|
-
const n = e.
|
|
91
|
+
const n = e.S;
|
|
91
92
|
if ((n & (REACTIVE_CHECK | REACTIVE_DIRTY)) >= t) return;
|
|
92
|
-
e.
|
|
93
|
+
e.S = (n & -4) | t;
|
|
93
94
|
for (let t = e.O; t !== null; t = t.p) {
|
|
94
95
|
markNode(t.A, REACTIVE_CHECK);
|
|
95
96
|
}
|
|
@@ -102,24 +103,24 @@ function markNode(e, t = REACTIVE_DIRTY) {
|
|
|
102
103
|
}
|
|
103
104
|
}
|
|
104
105
|
function runHeap(e, t) {
|
|
105
|
-
e.
|
|
106
|
-
for (e.C = 0; e.C <= e.
|
|
106
|
+
e._ = false;
|
|
107
|
+
for (e.C = 0; e.C <= e.h; e.C++) {
|
|
107
108
|
let n = e.l[e.C];
|
|
108
109
|
while (n !== undefined) {
|
|
109
|
-
if (n.
|
|
110
|
+
if (n.S & REACTIVE_IN_HEAP) t(n);
|
|
110
111
|
else adjustHeight(n, e);
|
|
111
112
|
n = e.l[e.C];
|
|
112
113
|
}
|
|
113
114
|
}
|
|
114
|
-
e.
|
|
115
|
+
e.h = 0;
|
|
115
116
|
}
|
|
116
117
|
function adjustHeight(e, t) {
|
|
117
118
|
deleteFromHeap(e, t);
|
|
118
119
|
let n = e.o;
|
|
119
120
|
for (let t = e.D; t; t = t.P) {
|
|
120
121
|
const e = t.V;
|
|
121
|
-
const i = e.
|
|
122
|
-
if (i.
|
|
122
|
+
const i = e.m || e;
|
|
123
|
+
if (i.U && i.o >= n) n = i.o + 1;
|
|
123
124
|
}
|
|
124
125
|
if (e.o !== n) {
|
|
125
126
|
e.o = n;
|
|
@@ -129,15 +130,16 @@ function adjustHeight(e, t) {
|
|
|
129
130
|
}
|
|
130
131
|
}
|
|
131
132
|
const transitions = new Set();
|
|
132
|
-
|
|
133
|
-
const
|
|
133
|
+
let optimisticRun = false;
|
|
134
|
+
const dirtyQueue = { l: new Array(2e3).fill(undefined), _: false, C: 0, h: 0 };
|
|
135
|
+
const zombieQueue = { l: new Array(2e3).fill(undefined), _: false, C: 0, h: 0 };
|
|
134
136
|
let clock = 0;
|
|
135
137
|
let activeTransition = null;
|
|
136
138
|
let scheduled = false;
|
|
137
139
|
function schedule() {
|
|
138
140
|
if (scheduled) return;
|
|
139
141
|
scheduled = true;
|
|
140
|
-
if (!globalQueue.k) queueMicrotask(flush);
|
|
142
|
+
if (!globalQueue.k) Promise.resolve().then(() => queueMicrotask(flush));
|
|
141
143
|
}
|
|
142
144
|
class Queue {
|
|
143
145
|
i = null;
|
|
@@ -200,36 +202,36 @@ class Queue {
|
|
|
200
202
|
class GlobalQueue extends Queue {
|
|
201
203
|
k = false;
|
|
202
204
|
$ = [];
|
|
203
|
-
|
|
205
|
+
L = [];
|
|
204
206
|
static F;
|
|
207
|
+
static W;
|
|
205
208
|
flush() {
|
|
206
209
|
if (this.k) return;
|
|
207
210
|
this.k = true;
|
|
208
211
|
try {
|
|
209
|
-
runHeap(dirtyQueue, GlobalQueue.
|
|
212
|
+
runHeap(dirtyQueue, GlobalQueue.F);
|
|
210
213
|
if (activeTransition) {
|
|
211
214
|
if (!transitionComplete(activeTransition)) {
|
|
212
|
-
|
|
215
|
+
let e = activeTransition;
|
|
216
|
+
runHeap(zombieQueue, GlobalQueue.F);
|
|
213
217
|
this.$ = [];
|
|
214
218
|
this.stashQueues(activeTransition.queueStash);
|
|
215
219
|
clock++;
|
|
216
220
|
scheduled = false;
|
|
217
221
|
runTransitionPending(activeTransition.pendingNodes, true);
|
|
218
222
|
activeTransition = null;
|
|
223
|
+
runOptimistic(e);
|
|
219
224
|
return;
|
|
220
225
|
}
|
|
221
226
|
this.$.push(...activeTransition.pendingNodes);
|
|
227
|
+
this.L !== activeTransition.optimisticNodes &&
|
|
228
|
+
this.L.push(...activeTransition.optimisticNodes);
|
|
222
229
|
this.restoreQueues(activeTransition.queueStash);
|
|
223
230
|
transitions.delete(activeTransition);
|
|
224
231
|
activeTransition = null;
|
|
225
232
|
runTransitionPending(this.$, false);
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
runPending(this.$);
|
|
229
|
-
while (dirtyQueue.R >= dirtyQueue.C) {
|
|
230
|
-
runHeap(dirtyQueue, GlobalQueue.L);
|
|
231
|
-
runPending(this.$);
|
|
232
|
-
}
|
|
233
|
+
} else if (transitions.size) runHeap(zombieQueue, GlobalQueue.F);
|
|
234
|
+
runOptimistic();
|
|
233
235
|
clock++;
|
|
234
236
|
scheduled = false;
|
|
235
237
|
this.run(EFFECT_RENDER);
|
|
@@ -241,8 +243,8 @@ class GlobalQueue extends Queue {
|
|
|
241
243
|
notify(e, t, n) {
|
|
242
244
|
if (t & STATUS_PENDING) {
|
|
243
245
|
if (n & STATUS_PENDING) {
|
|
244
|
-
if (activeTransition && !activeTransition.asyncNodes.includes(e.
|
|
245
|
-
activeTransition.asyncNodes.push(e.
|
|
246
|
+
if (activeTransition && !activeTransition.asyncNodes.includes(e.j.cause)) {
|
|
247
|
+
activeTransition.asyncNodes.push(e.j.cause);
|
|
246
248
|
schedule();
|
|
247
249
|
}
|
|
248
250
|
}
|
|
@@ -253,33 +255,69 @@ class GlobalQueue extends Queue {
|
|
|
253
255
|
initTransition(e) {
|
|
254
256
|
if (activeTransition && activeTransition.time === clock) return;
|
|
255
257
|
if (!activeTransition) {
|
|
256
|
-
activeTransition = e
|
|
258
|
+
activeTransition = e?.K ?? {
|
|
257
259
|
time: clock,
|
|
258
260
|
pendingNodes: [],
|
|
259
261
|
asyncNodes: [],
|
|
260
|
-
|
|
262
|
+
optimisticNodes: [],
|
|
263
|
+
actions: [],
|
|
264
|
+
queueStash: { G: [[], []], H: [] },
|
|
265
|
+
done: false
|
|
261
266
|
};
|
|
262
267
|
}
|
|
263
268
|
transitions.add(activeTransition);
|
|
264
269
|
activeTransition.time = clock;
|
|
265
270
|
for (let e = 0; e < this.$.length; e++) {
|
|
266
271
|
const t = this.$[e];
|
|
267
|
-
t.
|
|
272
|
+
t.K = activeTransition;
|
|
268
273
|
activeTransition.pendingNodes.push(t);
|
|
269
274
|
}
|
|
275
|
+
for (let e = 0; e < this.L.length; e++) {
|
|
276
|
+
const t = this.L[e];
|
|
277
|
+
t.K = activeTransition;
|
|
278
|
+
activeTransition.optimisticNodes.push(t);
|
|
279
|
+
}
|
|
270
280
|
this.$ = activeTransition.pendingNodes;
|
|
281
|
+
this.L = activeTransition.optimisticNodes;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
function notifySubs(e) {
|
|
285
|
+
for (let t = e.O; t !== null; t = t.p) {
|
|
286
|
+
const e = t.A.S & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue;
|
|
287
|
+
if (e.C > t.A.o) e.C = t.A.o;
|
|
288
|
+
insertIntoHeap(t.A, e);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
function runOptimistic(e = null) {
|
|
292
|
+
let t = !e;
|
|
293
|
+
const n = globalQueue.L;
|
|
294
|
+
optimisticRun = true;
|
|
295
|
+
for (let t = 0; t < n.length; t++) {
|
|
296
|
+
const i = n[t];
|
|
297
|
+
if (!e && (!i.K || i.K.done) && i.M !== NOT_PENDING) {
|
|
298
|
+
i.Y = i.M;
|
|
299
|
+
i.M = NOT_PENDING;
|
|
300
|
+
}
|
|
301
|
+
i.K = e;
|
|
302
|
+
notifySubs(i);
|
|
303
|
+
}
|
|
304
|
+
globalQueue.L = [];
|
|
305
|
+
if (dirtyQueue.h >= dirtyQueue.C) {
|
|
306
|
+
t = true;
|
|
307
|
+
runHeap(dirtyQueue, GlobalQueue.F);
|
|
271
308
|
}
|
|
309
|
+
optimisticRun = false;
|
|
310
|
+
t && runPending(globalQueue.$);
|
|
272
311
|
}
|
|
273
312
|
function runPending(e) {
|
|
274
313
|
for (let t = 0; t < e.length; t++) {
|
|
275
314
|
const n = e[t];
|
|
276
|
-
if (n.
|
|
277
|
-
n.
|
|
278
|
-
n.
|
|
279
|
-
if (n.
|
|
315
|
+
if (n.M !== NOT_PENDING) {
|
|
316
|
+
n.Y = n.M;
|
|
317
|
+
n.M = NOT_PENDING;
|
|
318
|
+
if (n.B) n.X = true;
|
|
280
319
|
}
|
|
281
|
-
if (n.
|
|
282
|
-
if (n.m) GlobalQueue.F(n, false, true);
|
|
320
|
+
if (n.U) GlobalQueue.W(n, false, true);
|
|
283
321
|
}
|
|
284
322
|
e.length = 0;
|
|
285
323
|
}
|
|
@@ -287,12 +325,8 @@ function runTransitionPending(e, t) {
|
|
|
287
325
|
const n = e.slice();
|
|
288
326
|
for (let e = 0; e < n.length; e++) {
|
|
289
327
|
const i = n[e];
|
|
290
|
-
i.
|
|
291
|
-
if (i.
|
|
292
|
-
if (i.X && i.X.K !== NOT_PENDING) {
|
|
293
|
-
i.X.q(i.X.K);
|
|
294
|
-
i.X.K = NOT_PENDING;
|
|
295
|
-
}
|
|
328
|
+
i.K = activeTransition;
|
|
329
|
+
if (i.q) i.q.Z(t);
|
|
296
330
|
}
|
|
297
331
|
}
|
|
298
332
|
const globalQueue = new GlobalQueue();
|
|
@@ -305,6 +339,8 @@ function runQueue(e, t) {
|
|
|
305
339
|
for (let n = 0; n < e.length; n++) e[n](t);
|
|
306
340
|
}
|
|
307
341
|
function transitionComplete(e) {
|
|
342
|
+
if (e.done) return true;
|
|
343
|
+
if (e.actions.length) return false;
|
|
308
344
|
let t = true;
|
|
309
345
|
for (let n = 0; n < e.asyncNodes.length; n++) {
|
|
310
346
|
if (e.asyncNodes[n].J & STATUS_PENDING) {
|
|
@@ -312,35 +348,58 @@ function transitionComplete(e) {
|
|
|
312
348
|
break;
|
|
313
349
|
}
|
|
314
350
|
}
|
|
351
|
+
t && (e.done = true);
|
|
315
352
|
return t;
|
|
316
353
|
}
|
|
317
354
|
function runInTransition(e, t) {
|
|
318
355
|
const n = activeTransition;
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
356
|
+
try {
|
|
357
|
+
activeTransition = e;
|
|
358
|
+
return t();
|
|
359
|
+
} finally {
|
|
360
|
+
activeTransition = n;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
function action(e) {
|
|
364
|
+
return (...t) => {
|
|
365
|
+
const n = e(...t);
|
|
366
|
+
globalQueue.initTransition();
|
|
367
|
+
let i = activeTransition;
|
|
368
|
+
i.actions.push(n);
|
|
369
|
+
const step = e => {
|
|
370
|
+
let t = n.next(e);
|
|
371
|
+
if (t instanceof Promise) return t.then(process);
|
|
372
|
+
process(t);
|
|
373
|
+
};
|
|
374
|
+
const process = e => {
|
|
375
|
+
if (e.done) {
|
|
376
|
+
i.actions.splice(i.actions.indexOf(n), 1);
|
|
377
|
+
activeTransition = i;
|
|
378
|
+
schedule();
|
|
379
|
+
flush();
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
const t = e.value;
|
|
383
|
+
if (t instanceof Promise) return t.then(step);
|
|
384
|
+
runInTransition(i, () => step(t));
|
|
385
|
+
};
|
|
386
|
+
runInTransition(i, () => step());
|
|
387
|
+
};
|
|
322
388
|
}
|
|
323
|
-
GlobalQueue.
|
|
324
|
-
GlobalQueue.
|
|
389
|
+
GlobalQueue.F = recompute;
|
|
390
|
+
GlobalQueue.W = disposeChildren;
|
|
325
391
|
let tracking = false;
|
|
326
392
|
let stale = false;
|
|
327
393
|
let pendingValueCheck = false;
|
|
328
394
|
let pendingCheck = null;
|
|
329
395
|
let refreshing = false;
|
|
330
396
|
let context = null;
|
|
331
|
-
function notifySubs(e) {
|
|
332
|
-
for (let t = e.O; t !== null; t = t.p) {
|
|
333
|
-
const e = t.A._ & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue;
|
|
334
|
-
if (e.C > t.A.o) e.C = t.A.o;
|
|
335
|
-
insertIntoHeap(t.A, e);
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
397
|
function recompute(e, t = false) {
|
|
339
|
-
const n = e.
|
|
398
|
+
const n = e.B && e.K != activeTransition;
|
|
340
399
|
if (!t) {
|
|
341
|
-
if (e.
|
|
342
|
-
deleteFromHeap(e, e.
|
|
343
|
-
if (e.
|
|
400
|
+
if (e.K && activeTransition !== e.K && !n) globalQueue.initTransition(e);
|
|
401
|
+
deleteFromHeap(e, e.S & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
402
|
+
if (e.K) disposeChildren(e);
|
|
344
403
|
else {
|
|
345
404
|
markDisposal(e);
|
|
346
405
|
e.ee = e.te;
|
|
@@ -352,17 +411,17 @@ function recompute(e, t = false) {
|
|
|
352
411
|
const i = context;
|
|
353
412
|
context = e;
|
|
354
413
|
e.re = null;
|
|
355
|
-
e.
|
|
414
|
+
e.S = REACTIVE_RECOMPUTING_DEPS;
|
|
356
415
|
e.se = clock;
|
|
357
|
-
let r = e.
|
|
416
|
+
let r = e.M === NOT_PENDING || (e.oe && e.K) ? e.Y : e.M;
|
|
358
417
|
let s = e.o;
|
|
359
418
|
let o = e.J;
|
|
360
|
-
let u = e.
|
|
419
|
+
let u = e.j;
|
|
361
420
|
let l = tracking;
|
|
362
421
|
setStatusFlags(e, STATUS_NONE | (o & STATUS_UNINITIALIZED));
|
|
363
422
|
tracking = true;
|
|
364
423
|
try {
|
|
365
|
-
r = handleAsync(e, e.
|
|
424
|
+
r = handleAsync(e, e.U(r));
|
|
366
425
|
e.J &= ~STATUS_UNINITIALIZED;
|
|
367
426
|
} catch (t) {
|
|
368
427
|
if (t instanceof NotReadyError) {
|
|
@@ -372,7 +431,7 @@ function recompute(e, t = false) {
|
|
|
372
431
|
} finally {
|
|
373
432
|
tracking = l;
|
|
374
433
|
}
|
|
375
|
-
e.
|
|
434
|
+
e.S = REACTIVE_NONE;
|
|
376
435
|
context = i;
|
|
377
436
|
if (!(e.J & STATUS_PENDING)) {
|
|
378
437
|
const t = e.re;
|
|
@@ -385,45 +444,42 @@ function recompute(e, t = false) {
|
|
|
385
444
|
else e.D = null;
|
|
386
445
|
}
|
|
387
446
|
}
|
|
388
|
-
const c = !e.
|
|
389
|
-
const a = e.J !== o || e.
|
|
447
|
+
const c = !e.ue || !e.ue(e.M === NOT_PENDING || (e.oe && e.K) || n ? e.Y : e.M, r);
|
|
448
|
+
const a = e.J !== o || e.j !== u;
|
|
390
449
|
e.le?.(a, o);
|
|
391
450
|
if (c || a) {
|
|
392
451
|
if (c) {
|
|
393
|
-
if (t || e.
|
|
394
|
-
else e.
|
|
395
|
-
if (e.
|
|
396
|
-
}
|
|
397
|
-
for (let t = e.O; t !== null; t = t.p) {
|
|
398
|
-
const n = t.A._ & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue;
|
|
399
|
-
if (t.A.o < e.o && n.C > t.A.o) n.C = t.A.o;
|
|
400
|
-
insertIntoHeap(t.A, n);
|
|
452
|
+
if (t || e.oe || n) e.Y = r;
|
|
453
|
+
else e.M = r;
|
|
454
|
+
if (e.ce) setSignal(e.ce, r);
|
|
401
455
|
}
|
|
456
|
+
(!e.oe || optimisticRun) && notifySubs(e);
|
|
402
457
|
} else if (e.o != s) {
|
|
403
458
|
for (let t = e.O; t !== null; t = t.p) {
|
|
404
|
-
insertIntoHeapHeight(t.A, t.A.
|
|
459
|
+
insertIntoHeapHeight(t.A, t.A.S & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
405
460
|
}
|
|
406
461
|
}
|
|
407
|
-
|
|
408
|
-
|
|
462
|
+
e.oe && !optimisticRun && globalQueue.L.push(e);
|
|
463
|
+
(!t || e.J & STATUS_PENDING) && !e.K && globalQueue.$.push(e);
|
|
464
|
+
e.K && n && runInTransition(e.K, () => recompute(e));
|
|
409
465
|
}
|
|
410
466
|
function handleAsync(e, t, n) {
|
|
411
467
|
const i = typeof t === "object" && t !== null;
|
|
412
468
|
const r = i && t instanceof Promise;
|
|
413
469
|
const s = i && untrack(() => t[Symbol.asyncIterator]);
|
|
414
470
|
if (!r && !s) {
|
|
415
|
-
e.
|
|
471
|
+
e.ae = null;
|
|
416
472
|
return t;
|
|
417
473
|
}
|
|
418
|
-
e.
|
|
474
|
+
e.ae = t;
|
|
419
475
|
if (r) {
|
|
420
476
|
t.then(i => {
|
|
421
|
-
if (e.
|
|
477
|
+
if (e.ae !== t) return;
|
|
422
478
|
globalQueue.initTransition(e);
|
|
423
479
|
n?.(i) ?? setSignal(e, () => i);
|
|
424
480
|
flush();
|
|
425
481
|
}).catch(n => {
|
|
426
|
-
if (e.
|
|
482
|
+
if (e.ae !== t) return;
|
|
427
483
|
globalQueue.initTransition(e);
|
|
428
484
|
setStatusFlags(e, STATUS_ERROR, n);
|
|
429
485
|
e.se = clock;
|
|
@@ -435,13 +491,13 @@ function handleAsync(e, t, n) {
|
|
|
435
491
|
(async () => {
|
|
436
492
|
try {
|
|
437
493
|
for await (let i of t) {
|
|
438
|
-
if (e.
|
|
494
|
+
if (e.ae !== t) return;
|
|
439
495
|
globalQueue.initTransition(e);
|
|
440
496
|
n?.(i) ?? setSignal(e, () => i);
|
|
441
497
|
flush();
|
|
442
498
|
}
|
|
443
499
|
} catch (n) {
|
|
444
|
-
if (e.
|
|
500
|
+
if (e.ae !== t) return;
|
|
445
501
|
globalQueue.initTransition(e);
|
|
446
502
|
setStatusFlags(e, STATUS_ERROR, n);
|
|
447
503
|
e.se = clock;
|
|
@@ -455,42 +511,42 @@ function handleAsync(e, t, n) {
|
|
|
455
511
|
throw new NotReadyError(context);
|
|
456
512
|
}
|
|
457
513
|
function updateIfNecessary(e) {
|
|
458
|
-
if (e.
|
|
514
|
+
if (e.S & REACTIVE_CHECK) {
|
|
459
515
|
for (let t = e.D; t; t = t.P) {
|
|
460
516
|
const n = t.V;
|
|
461
|
-
const i = n.
|
|
462
|
-
if (i.
|
|
517
|
+
const i = n.m || n;
|
|
518
|
+
if (i.U) {
|
|
463
519
|
updateIfNecessary(i);
|
|
464
520
|
}
|
|
465
|
-
if (e.
|
|
521
|
+
if (e.S & REACTIVE_DIRTY) {
|
|
466
522
|
break;
|
|
467
523
|
}
|
|
468
524
|
}
|
|
469
525
|
}
|
|
470
|
-
if (e.
|
|
526
|
+
if (e.S & REACTIVE_DIRTY) {
|
|
471
527
|
recompute(e);
|
|
472
528
|
}
|
|
473
|
-
e.
|
|
529
|
+
e.S = REACTIVE_NONE;
|
|
474
530
|
}
|
|
475
531
|
function unlinkSubs(e) {
|
|
476
532
|
const t = e.V;
|
|
477
533
|
const n = e.P;
|
|
478
534
|
const i = e.p;
|
|
479
|
-
const r = e.
|
|
480
|
-
if (i !== null) i.
|
|
481
|
-
else t.
|
|
535
|
+
const r = e.fe;
|
|
536
|
+
if (i !== null) i.fe = r;
|
|
537
|
+
else t.Ee = r;
|
|
482
538
|
if (r !== null) r.p = i;
|
|
483
539
|
else {
|
|
484
540
|
t.O = i;
|
|
485
541
|
if (i === null) {
|
|
486
|
-
t.
|
|
487
|
-
t.
|
|
542
|
+
t.de?.();
|
|
543
|
+
t.U && !t.Te && unobserved(t);
|
|
488
544
|
}
|
|
489
545
|
}
|
|
490
546
|
return n;
|
|
491
547
|
}
|
|
492
548
|
function unobserved(e) {
|
|
493
|
-
deleteFromHeap(e, e.
|
|
549
|
+
deleteFromHeap(e, e.S & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
494
550
|
let t = e.D;
|
|
495
551
|
while (t !== null) {
|
|
496
552
|
t = unlinkSubs(t);
|
|
@@ -502,7 +558,7 @@ function link(e, t) {
|
|
|
502
558
|
const n = t.re;
|
|
503
559
|
if (n !== null && n.V === e) return;
|
|
504
560
|
let i = null;
|
|
505
|
-
const r = t.
|
|
561
|
+
const r = t.S & REACTIVE_RECOMPUTING_DEPS;
|
|
506
562
|
if (r) {
|
|
507
563
|
i = n !== null ? n.P : t.D;
|
|
508
564
|
if (i !== null && i.V === e) {
|
|
@@ -510,9 +566,9 @@ function link(e, t) {
|
|
|
510
566
|
return;
|
|
511
567
|
}
|
|
512
568
|
}
|
|
513
|
-
const s = e.
|
|
569
|
+
const s = e.Ee;
|
|
514
570
|
if (s !== null && s.A === t && (!r || isValidLink(s, t))) return;
|
|
515
|
-
const o = (t.re = e.
|
|
571
|
+
const o = (t.re = e.Ee = { V: e, A: t, P: i, fe: s, p: null });
|
|
516
572
|
if (n !== null) n.P = o;
|
|
517
573
|
else t.D = o;
|
|
518
574
|
if (s !== null) s.p = o;
|
|
@@ -532,18 +588,18 @@ function isValidLink(e, t) {
|
|
|
532
588
|
}
|
|
533
589
|
function setStatusFlags(e, t, n = null) {
|
|
534
590
|
e.J = t;
|
|
535
|
-
e.
|
|
591
|
+
e.j = n;
|
|
536
592
|
}
|
|
537
593
|
function markDisposal(e) {
|
|
538
594
|
let t = e.ie;
|
|
539
595
|
while (t) {
|
|
540
|
-
t.
|
|
541
|
-
if (t.
|
|
596
|
+
t.S |= REACTIVE_ZOMBIE;
|
|
597
|
+
if (t.S & REACTIVE_IN_HEAP) {
|
|
542
598
|
deleteFromHeap(t, dirtyQueue);
|
|
543
599
|
insertIntoHeap(t, zombieQueue);
|
|
544
600
|
}
|
|
545
601
|
markDisposal(t);
|
|
546
|
-
t = t.
|
|
602
|
+
t = t.Re;
|
|
547
603
|
}
|
|
548
604
|
}
|
|
549
605
|
function dispose(e) {
|
|
@@ -556,14 +612,14 @@ function dispose(e) {
|
|
|
556
612
|
disposeChildren(e, true);
|
|
557
613
|
}
|
|
558
614
|
function disposeChildren(e, t = false, n) {
|
|
559
|
-
if (e.
|
|
560
|
-
if (t) e.
|
|
615
|
+
if (e.S & REACTIVE_DISPOSED) return;
|
|
616
|
+
if (t) e.S = REACTIVE_DISPOSED;
|
|
561
617
|
let i = n ? e.ne : e.ie;
|
|
562
618
|
while (i) {
|
|
563
|
-
const e = i.
|
|
619
|
+
const e = i.Re;
|
|
564
620
|
if (i.D) {
|
|
565
621
|
const e = i;
|
|
566
|
-
deleteFromHeap(e, e.
|
|
622
|
+
deleteFromHeap(e, e.S & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
567
623
|
let t = e.D;
|
|
568
624
|
do {
|
|
569
625
|
t = unlinkSubs(t);
|
|
@@ -578,7 +634,7 @@ function disposeChildren(e, t = false, n) {
|
|
|
578
634
|
e.ne = null;
|
|
579
635
|
} else {
|
|
580
636
|
e.ie = null;
|
|
581
|
-
e.
|
|
637
|
+
e.Re = null;
|
|
582
638
|
}
|
|
583
639
|
runDisposal(e, n);
|
|
584
640
|
}
|
|
@@ -607,36 +663,36 @@ function formatId(e, t) {
|
|
|
607
663
|
function computed(e, t, n) {
|
|
608
664
|
const i = {
|
|
609
665
|
id: n?.id ?? (context?.id != null ? getNextChildId(context) : undefined),
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
666
|
+
ue: n?.equals != null ? n.equals : isEqual,
|
|
667
|
+
Se: !!n?.pureWrite,
|
|
668
|
+
de: n?.unobserved,
|
|
613
669
|
te: null,
|
|
614
670
|
_e: context?._e ?? globalQueue,
|
|
615
|
-
|
|
671
|
+
Oe: context?.Oe ?? defaultContext,
|
|
616
672
|
he: 0,
|
|
617
|
-
|
|
618
|
-
|
|
673
|
+
U: e,
|
|
674
|
+
Y: t,
|
|
619
675
|
o: 0,
|
|
620
676
|
N: null,
|
|
621
|
-
|
|
677
|
+
R: undefined,
|
|
622
678
|
T: null,
|
|
623
679
|
D: null,
|
|
624
680
|
re: null,
|
|
625
681
|
O: null,
|
|
626
|
-
|
|
682
|
+
Ee: null,
|
|
627
683
|
i: context,
|
|
628
|
-
|
|
684
|
+
Re: null,
|
|
629
685
|
ie: null,
|
|
630
|
-
|
|
686
|
+
S: REACTIVE_NONE,
|
|
631
687
|
J: STATUS_UNINITIALIZED,
|
|
632
688
|
se: clock,
|
|
633
|
-
|
|
689
|
+
M: NOT_PENDING,
|
|
634
690
|
ee: null,
|
|
635
691
|
ne: null,
|
|
636
|
-
|
|
637
|
-
|
|
692
|
+
ae: null,
|
|
693
|
+
K: null
|
|
638
694
|
};
|
|
639
|
-
if (n?.
|
|
695
|
+
if (n?.pe) Object.assign(i, n.pe);
|
|
640
696
|
i.T = i;
|
|
641
697
|
const r = context?.t ? context.u : context;
|
|
642
698
|
if (context) {
|
|
@@ -644,28 +700,28 @@ function computed(e, t, n) {
|
|
|
644
700
|
if (e === null) {
|
|
645
701
|
context.ie = i;
|
|
646
702
|
} else {
|
|
647
|
-
i.
|
|
703
|
+
i.Re = e;
|
|
648
704
|
context.ie = i;
|
|
649
705
|
}
|
|
650
706
|
}
|
|
651
707
|
if (r) i.o = r.o + 1;
|
|
652
|
-
recompute(i, true);
|
|
708
|
+
!n?.lazy && recompute(i, true);
|
|
653
709
|
return i;
|
|
654
710
|
}
|
|
655
711
|
function signal(e, t, n = null) {
|
|
656
712
|
const i = {
|
|
657
713
|
id: t?.id ?? (context?.id != null ? getNextChildId(context) : undefined),
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
714
|
+
ue: t?.equals != null ? t.equals : isEqual,
|
|
715
|
+
Se: !!t?.pureWrite,
|
|
716
|
+
de: t?.unobserved,
|
|
717
|
+
Y: e,
|
|
662
718
|
O: null,
|
|
663
|
-
|
|
719
|
+
Ee: null,
|
|
664
720
|
J: STATUS_NONE,
|
|
665
721
|
se: clock,
|
|
666
|
-
|
|
722
|
+
m: n,
|
|
667
723
|
I: n?.N || null,
|
|
668
|
-
|
|
724
|
+
M: NOT_PENDING
|
|
669
725
|
};
|
|
670
726
|
n && (n.N = i);
|
|
671
727
|
return i;
|
|
@@ -685,13 +741,13 @@ function untrack(e) {
|
|
|
685
741
|
function read(e) {
|
|
686
742
|
let t = context;
|
|
687
743
|
if (t?.t) t = t.u;
|
|
688
|
-
if (refreshing && e.
|
|
744
|
+
if (refreshing && e.U) recompute(e);
|
|
689
745
|
if (t && tracking && !pendingCheck && !pendingValueCheck) {
|
|
690
|
-
if (e.
|
|
746
|
+
if (e.U && e.S & REACTIVE_DISPOSED) recompute(e);
|
|
691
747
|
link(e, t);
|
|
692
|
-
const n = e.
|
|
693
|
-
if (n.
|
|
694
|
-
const i = e.
|
|
748
|
+
const n = e.m || e;
|
|
749
|
+
if (n.U) {
|
|
750
|
+
const i = e.S & REACTIVE_ZOMBIE;
|
|
695
751
|
if (n.o >= (i ? zombieQueue.C : dirtyQueue.C)) {
|
|
696
752
|
markNode(t);
|
|
697
753
|
markHeap(i ? zombieQueue : dirtyQueue);
|
|
@@ -703,34 +759,34 @@ function read(e) {
|
|
|
703
759
|
}
|
|
704
760
|
}
|
|
705
761
|
}
|
|
706
|
-
if (pendingCheck) {
|
|
707
|
-
if (!e.Z) {
|
|
708
|
-
e.Z = signal(false);
|
|
709
|
-
e.Z.ue = true;
|
|
710
|
-
e.Z.q = t => setSignal(e.Z, t);
|
|
711
|
-
}
|
|
712
|
-
const t = pendingCheck;
|
|
713
|
-
pendingCheck = null;
|
|
714
|
-
t.M = read(e.Z) || t.M;
|
|
715
|
-
pendingCheck = t;
|
|
716
|
-
}
|
|
717
762
|
if (pendingValueCheck) {
|
|
718
|
-
if (!e.
|
|
719
|
-
e.
|
|
720
|
-
e.
|
|
721
|
-
e.X.q = t => setSignal(e.X, t);
|
|
763
|
+
if (!e.ce) {
|
|
764
|
+
e.ce = signal(e.Y);
|
|
765
|
+
e.ce.oe = true;
|
|
722
766
|
}
|
|
723
767
|
pendingValueCheck = false;
|
|
724
768
|
try {
|
|
725
|
-
return read(e.
|
|
769
|
+
return read(e.ce);
|
|
726
770
|
} finally {
|
|
727
771
|
pendingValueCheck = true;
|
|
728
772
|
}
|
|
729
773
|
}
|
|
730
|
-
|
|
731
|
-
|
|
774
|
+
const n = e.m || e;
|
|
775
|
+
if (pendingCheck) {
|
|
776
|
+
if (!n.q) {
|
|
777
|
+
n.q = signal(false);
|
|
778
|
+
n.q.oe = true;
|
|
779
|
+
n.q.Z = e => setSignal(n.q, e);
|
|
780
|
+
}
|
|
781
|
+
const e = pendingCheck;
|
|
782
|
+
pendingCheck = null;
|
|
783
|
+
e.Y = read(n.q) || e.Y;
|
|
784
|
+
pendingCheck = e;
|
|
785
|
+
}
|
|
786
|
+
if (!pendingCheck && n.J & STATUS_PENDING) {
|
|
787
|
+
if ((t && !stale) || n.J & STATUS_UNINITIALIZED || e.m) throw n.j;
|
|
732
788
|
else if (t && stale) {
|
|
733
|
-
setStatusFlags(t, t.J |
|
|
789
|
+
setStatusFlags(t, t.J | STATUS_PENDING, n.j);
|
|
734
790
|
}
|
|
735
791
|
}
|
|
736
792
|
if (e.J & STATUS_ERROR) {
|
|
@@ -738,33 +794,33 @@ function read(e) {
|
|
|
738
794
|
recompute(e, true);
|
|
739
795
|
return read(e);
|
|
740
796
|
} else {
|
|
741
|
-
throw e.
|
|
797
|
+
throw e.j;
|
|
742
798
|
}
|
|
743
799
|
}
|
|
744
800
|
return !t ||
|
|
745
|
-
e.
|
|
746
|
-
e.
|
|
747
|
-
(stale && !pendingCheck && e.
|
|
748
|
-
? e.
|
|
749
|
-
: e.
|
|
801
|
+
e.oe ||
|
|
802
|
+
e.M === NOT_PENDING ||
|
|
803
|
+
(stale && !pendingCheck && (t.oe || (e.K && activeTransition !== e.K)))
|
|
804
|
+
? e.Y
|
|
805
|
+
: e.M;
|
|
750
806
|
}
|
|
751
807
|
function setSignal(e, t) {
|
|
752
808
|
if (typeof t === "function") {
|
|
753
|
-
t = t(e.
|
|
809
|
+
t = t(e.M === NOT_PENDING || (e.oe && e.K) ? e.Y : e.M);
|
|
754
810
|
}
|
|
755
|
-
const n = !e.
|
|
811
|
+
const n = !e.ue || !e.ue(e.M === NOT_PENDING || (e.oe && e.K) ? e.Y : e.M, t);
|
|
756
812
|
if (!n && !e.J) return t;
|
|
757
813
|
if (n) {
|
|
758
|
-
if (e.
|
|
814
|
+
if (e.oe) e.Y = t;
|
|
759
815
|
else {
|
|
760
|
-
if (e.
|
|
761
|
-
e.
|
|
816
|
+
if (e.M === NOT_PENDING) globalQueue.$.push(e);
|
|
817
|
+
e.M = t;
|
|
762
818
|
}
|
|
763
|
-
if (e.
|
|
819
|
+
if (e.ce) setSignal(e.ce, t);
|
|
764
820
|
}
|
|
765
821
|
setStatusFlags(e, STATUS_NONE);
|
|
766
822
|
e.se = clock;
|
|
767
|
-
notifySubs(e);
|
|
823
|
+
e.oe && !optimisticRun ? globalQueue.L.push(e) : notifySubs(e);
|
|
768
824
|
schedule();
|
|
769
825
|
return t;
|
|
770
826
|
}
|
|
@@ -792,11 +848,11 @@ function createOwner(e) {
|
|
|
792
848
|
t: true,
|
|
793
849
|
u: t?.t ? t.u : t,
|
|
794
850
|
ie: null,
|
|
795
|
-
|
|
851
|
+
Re: null,
|
|
796
852
|
te: null,
|
|
797
853
|
id: e?.id ?? (t?.id != null ? getNextChildId(t) : undefined),
|
|
798
854
|
_e: t?._e ?? globalQueue,
|
|
799
|
-
|
|
855
|
+
Oe: t?.Oe || defaultContext,
|
|
800
856
|
he: 0,
|
|
801
857
|
ee: null,
|
|
802
858
|
ne: null,
|
|
@@ -810,7 +866,7 @@ function createOwner(e) {
|
|
|
810
866
|
if (e === null) {
|
|
811
867
|
t.ie = n;
|
|
812
868
|
} else {
|
|
813
|
-
n.
|
|
869
|
+
n.Re = e;
|
|
814
870
|
t.ie = n;
|
|
815
871
|
}
|
|
816
872
|
}
|
|
@@ -849,10 +905,10 @@ function pending(e) {
|
|
|
849
905
|
}
|
|
850
906
|
function isPending(e) {
|
|
851
907
|
const t = pendingCheck;
|
|
852
|
-
pendingCheck = {
|
|
908
|
+
pendingCheck = { Y: false };
|
|
853
909
|
try {
|
|
854
910
|
staleValues(e);
|
|
855
|
-
return pendingCheck.
|
|
911
|
+
return pendingCheck.Y;
|
|
856
912
|
} catch (e) {
|
|
857
913
|
if (!(e instanceof NotReadyError)) return false;
|
|
858
914
|
throw e;
|
|
@@ -864,6 +920,10 @@ function refresh(e) {
|
|
|
864
920
|
let t = refreshing;
|
|
865
921
|
refreshing = true;
|
|
866
922
|
try {
|
|
923
|
+
if (typeof e !== "function") {
|
|
924
|
+
recompute(e[$REFRESH]);
|
|
925
|
+
return e;
|
|
926
|
+
}
|
|
867
927
|
return untrack(e);
|
|
868
928
|
} finally {
|
|
869
929
|
refreshing = t;
|
|
@@ -883,7 +943,7 @@ function getContext(e, t = getOwner()) {
|
|
|
883
943
|
if (!t) {
|
|
884
944
|
throw new NoOwnerError();
|
|
885
945
|
}
|
|
886
|
-
const n = hasContext(e, t) ? t.
|
|
946
|
+
const n = hasContext(e, t) ? t.Oe[e.id] : e.defaultValue;
|
|
887
947
|
if (isUndefined(n)) {
|
|
888
948
|
throw new ContextNotFoundError();
|
|
889
949
|
}
|
|
@@ -893,10 +953,10 @@ function setContext(e, t, n = getOwner()) {
|
|
|
893
953
|
if (!n) {
|
|
894
954
|
throw new NoOwnerError();
|
|
895
955
|
}
|
|
896
|
-
n.
|
|
956
|
+
n.Oe = { ...n.Oe, [e.id]: isUndefined(t) ? e.defaultValue : t };
|
|
897
957
|
}
|
|
898
958
|
function hasContext(e, t) {
|
|
899
|
-
return !isUndefined(t?.
|
|
959
|
+
return !isUndefined(t?.Oe[e.id]);
|
|
900
960
|
}
|
|
901
961
|
function isUndefined(e) {
|
|
902
962
|
return typeof e === "undefined";
|
|
@@ -905,23 +965,23 @@ function effect(e, t, n, i, r) {
|
|
|
905
965
|
let s = false;
|
|
906
966
|
const o = computed(e, i, {
|
|
907
967
|
...r,
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
968
|
+
pe: {
|
|
969
|
+
X: true,
|
|
970
|
+
Ae: i,
|
|
971
|
+
ge: t,
|
|
912
972
|
Ne: n,
|
|
913
973
|
Ie: undefined,
|
|
914
|
-
|
|
974
|
+
B: r?.render ? EFFECT_RENDER : EFFECT_USER,
|
|
915
975
|
le(e, t) {
|
|
916
976
|
if (s) {
|
|
917
977
|
const n = this.J && this.J === t && e;
|
|
918
|
-
this.
|
|
919
|
-
if (this.
|
|
978
|
+
this.X = !(this.J & STATUS_ERROR) && !(this.J & STATUS_PENDING & ~t) && !n;
|
|
979
|
+
if (this.X) this._e.enqueue(this.B, runEffect.bind(this));
|
|
920
980
|
}
|
|
921
981
|
if (this.J & STATUS_ERROR) {
|
|
922
|
-
let e = this.
|
|
982
|
+
let e = this.j;
|
|
923
983
|
this._e.notify(this, STATUS_PENDING, 0);
|
|
924
|
-
if (this.
|
|
984
|
+
if (this.B === EFFECT_USER) {
|
|
925
985
|
try {
|
|
926
986
|
return this.Ne
|
|
927
987
|
? this.Ne(e, () => {
|
|
@@ -934,30 +994,30 @@ function effect(e, t, n, i, r) {
|
|
|
934
994
|
}
|
|
935
995
|
}
|
|
936
996
|
if (!this._e.notify(this, STATUS_ERROR, STATUS_ERROR)) throw e;
|
|
937
|
-
} else if (this.
|
|
997
|
+
} else if (this.B === EFFECT_RENDER) {
|
|
938
998
|
this._e.notify(this, STATUS_PENDING | STATUS_ERROR, this.J);
|
|
939
999
|
}
|
|
940
1000
|
}
|
|
941
1001
|
}
|
|
942
1002
|
});
|
|
943
1003
|
s = true;
|
|
944
|
-
if (o.
|
|
1004
|
+
if (o.B === EFFECT_RENDER) o.U = t => staleValues(() => e(t));
|
|
945
1005
|
!r?.defer &&
|
|
946
1006
|
!(o.J & (STATUS_ERROR | STATUS_PENDING)) &&
|
|
947
|
-
(o.
|
|
1007
|
+
(o.B === EFFECT_USER ? o._e.enqueue(o.B, runEffect.bind(o)) : runEffect.call(o));
|
|
948
1008
|
onCleanup(() => o.Ie?.());
|
|
949
1009
|
}
|
|
950
1010
|
function runEffect() {
|
|
951
|
-
if (!this.
|
|
1011
|
+
if (!this.X || this.S & REACTIVE_DISPOSED) return;
|
|
952
1012
|
this.Ie?.();
|
|
953
1013
|
this.Ie = undefined;
|
|
954
1014
|
try {
|
|
955
|
-
this.Ie = this.
|
|
1015
|
+
this.Ie = this.ge(this.Y, this.Ae);
|
|
956
1016
|
} catch (e) {
|
|
957
1017
|
if (!this._e.notify(this, STATUS_ERROR, STATUS_ERROR)) throw e;
|
|
958
1018
|
} finally {
|
|
959
|
-
this.
|
|
960
|
-
this.
|
|
1019
|
+
this.Ae = this.Y;
|
|
1020
|
+
this.X = false;
|
|
961
1021
|
}
|
|
962
1022
|
}
|
|
963
1023
|
function createSignal(e, t, n) {
|
|
@@ -1017,7 +1077,30 @@ function resolve(e) {
|
|
|
1017
1077
|
});
|
|
1018
1078
|
}
|
|
1019
1079
|
function createOptimistic(e, t, n) {
|
|
1020
|
-
|
|
1080
|
+
if (typeof e === "function") {
|
|
1081
|
+
const i = computed(
|
|
1082
|
+
t => {
|
|
1083
|
+
let n = i || getOwner();
|
|
1084
|
+
n.M = e(t);
|
|
1085
|
+
return t;
|
|
1086
|
+
},
|
|
1087
|
+
t,
|
|
1088
|
+
n
|
|
1089
|
+
);
|
|
1090
|
+
i.oe = true;
|
|
1091
|
+
return [read.bind(null, i), setSignal.bind(null, i)];
|
|
1092
|
+
}
|
|
1093
|
+
const i = getOwner();
|
|
1094
|
+
const r = i?.id != null;
|
|
1095
|
+
const s = signal(e, r ? { id: getNextChildId(i), ...t } : t);
|
|
1096
|
+
s.oe = true;
|
|
1097
|
+
return [
|
|
1098
|
+
read.bind(null, s),
|
|
1099
|
+
t => {
|
|
1100
|
+
s.M = e;
|
|
1101
|
+
return setSignal(s, t);
|
|
1102
|
+
}
|
|
1103
|
+
];
|
|
1021
1104
|
}
|
|
1022
1105
|
function onSettled(e) {
|
|
1023
1106
|
let t;
|
|
@@ -1032,7 +1115,7 @@ function unwrap(e) {
|
|
|
1032
1115
|
return e?.[$TARGET]?.[STORE_NODE] ?? e;
|
|
1033
1116
|
}
|
|
1034
1117
|
function getOverrideValue(e, t, n, i) {
|
|
1035
|
-
return
|
|
1118
|
+
return t && i in t ? t[i] : e[i];
|
|
1036
1119
|
}
|
|
1037
1120
|
function getAllKeys(e, t, n) {
|
|
1038
1121
|
const i = getKeys(e, t);
|
|
@@ -1053,7 +1136,7 @@ function applyState(e, t, n, i) {
|
|
|
1053
1136
|
let t = false;
|
|
1054
1137
|
const l = getOverrideValue(s, o, u, "length");
|
|
1055
1138
|
if (e.length && l && e[0] && n(e[0]) != null) {
|
|
1056
|
-
let c, a, f, E, d, T,
|
|
1139
|
+
let c, a, f, E, d, T, R, h;
|
|
1057
1140
|
for (
|
|
1058
1141
|
f = 0, E = Math.min(l, e.length);
|
|
1059
1142
|
f < E && ((T = getOverrideValue(s, o, u, f)) === e[f] || (T && e[f] && n(T) === n(e[f])));
|
|
@@ -1061,8 +1144,8 @@ function applyState(e, t, n, i) {
|
|
|
1061
1144
|
) {
|
|
1062
1145
|
applyState(e[f], wrap(T, r), n, i);
|
|
1063
1146
|
}
|
|
1064
|
-
const
|
|
1065
|
-
|
|
1147
|
+
const S = new Array(e.length),
|
|
1148
|
+
_ = new Map();
|
|
1066
1149
|
for (
|
|
1067
1150
|
E = l - 1, d = e.length - 1;
|
|
1068
1151
|
E >= f &&
|
|
@@ -1070,7 +1153,7 @@ function applyState(e, t, n, i) {
|
|
|
1070
1153
|
((T = getOverrideValue(s, o, u, E)) === e[d] || (T && e[d] && n(T) === n(e[d])));
|
|
1071
1154
|
E--, d--
|
|
1072
1155
|
) {
|
|
1073
|
-
|
|
1156
|
+
S[d] = T;
|
|
1074
1157
|
}
|
|
1075
1158
|
if (f > d || f > E) {
|
|
1076
1159
|
for (a = f; a <= d; a++) {
|
|
@@ -1079,7 +1162,7 @@ function applyState(e, t, n, i) {
|
|
|
1079
1162
|
}
|
|
1080
1163
|
for (; a < e.length; a++) {
|
|
1081
1164
|
t = true;
|
|
1082
|
-
const s = wrap(
|
|
1165
|
+
const s = wrap(S[a], r);
|
|
1083
1166
|
r[STORE_NODE][a] && setSignal(r[STORE_NODE][a], s);
|
|
1084
1167
|
applyState(e[a], s, n, i);
|
|
1085
1168
|
}
|
|
@@ -1087,36 +1170,38 @@ function applyState(e, t, n, i) {
|
|
|
1087
1170
|
l !== e.length && r[STORE_NODE].length && setSignal(r[STORE_NODE].length, e.length);
|
|
1088
1171
|
return;
|
|
1089
1172
|
}
|
|
1090
|
-
|
|
1173
|
+
R = new Array(d + 1);
|
|
1091
1174
|
for (a = d; a >= f; a--) {
|
|
1092
1175
|
T = e[a];
|
|
1093
|
-
|
|
1094
|
-
c =
|
|
1095
|
-
|
|
1096
|
-
|
|
1176
|
+
h = T ? n(T) : T;
|
|
1177
|
+
c = _.get(h);
|
|
1178
|
+
R[a] = c === undefined ? -1 : c;
|
|
1179
|
+
_.set(h, a);
|
|
1097
1180
|
}
|
|
1098
1181
|
for (c = f; c <= E; c++) {
|
|
1099
1182
|
T = getOverrideValue(s, o, u, c);
|
|
1100
|
-
|
|
1101
|
-
a =
|
|
1183
|
+
h = T ? n(T) : T;
|
|
1184
|
+
a = _.get(h);
|
|
1102
1185
|
if (a !== undefined && a !== -1) {
|
|
1103
|
-
|
|
1104
|
-
a =
|
|
1105
|
-
|
|
1186
|
+
S[a] = T;
|
|
1187
|
+
a = R[a];
|
|
1188
|
+
_.set(h, a);
|
|
1106
1189
|
}
|
|
1107
1190
|
}
|
|
1108
1191
|
for (a = f; a < e.length; a++) {
|
|
1109
|
-
if (a in
|
|
1110
|
-
const t = wrap(
|
|
1192
|
+
if (a in S) {
|
|
1193
|
+
const t = wrap(S[a], r);
|
|
1111
1194
|
r[STORE_NODE][a] && setSignal(r[STORE_NODE][a], t);
|
|
1112
1195
|
applyState(e[a], t, n, i);
|
|
1113
1196
|
} else r[STORE_NODE][a] && setSignal(r[STORE_NODE][a], wrap(e[a], r));
|
|
1114
1197
|
}
|
|
1115
1198
|
if (f < e.length) t = true;
|
|
1116
|
-
} else if (
|
|
1199
|
+
} else if (e.length) {
|
|
1117
1200
|
for (let t = 0, l = e.length; t < l; t++) {
|
|
1118
1201
|
const l = getOverrideValue(s, o, u, t);
|
|
1119
|
-
isWrappable(l)
|
|
1202
|
+
isWrappable(l)
|
|
1203
|
+
? applyState(e[t], wrap(l, r), n, i)
|
|
1204
|
+
: r[STORE_NODE][t] && setSignal(r[STORE_NODE][t], e[t]);
|
|
1120
1205
|
}
|
|
1121
1206
|
}
|
|
1122
1207
|
if (l !== e.length) {
|
|
@@ -1162,34 +1247,70 @@ function reconcile(e, t, n = false) {
|
|
|
1162
1247
|
function createProjectionInternal(e, t = {}, n) {
|
|
1163
1248
|
let i;
|
|
1164
1249
|
const r = new WeakMap();
|
|
1250
|
+
const wrapper = e => {
|
|
1251
|
+
e[STORE_WRAP] = wrapProjection;
|
|
1252
|
+
e[STORE_LOOKUP] = r;
|
|
1253
|
+
Object.defineProperty(e, STORE_FIREWALL, {
|
|
1254
|
+
get() {
|
|
1255
|
+
return i;
|
|
1256
|
+
},
|
|
1257
|
+
configurable: true
|
|
1258
|
+
});
|
|
1259
|
+
};
|
|
1165
1260
|
const wrapProjection = e => {
|
|
1166
1261
|
if (r.has(e)) return r.get(e);
|
|
1167
1262
|
if (e[$TARGET]?.[STORE_WRAP] === wrapProjection) return e;
|
|
1168
|
-
const t = createStoreProxy(e, storeTraps,
|
|
1169
|
-
[STORE_WRAP]: wrapProjection,
|
|
1170
|
-
[STORE_LOOKUP]: r,
|
|
1171
|
-
[STORE_FIREWALL]() {
|
|
1172
|
-
return i;
|
|
1173
|
-
}
|
|
1174
|
-
});
|
|
1263
|
+
const t = createStoreProxy(e, storeTraps, wrapper);
|
|
1175
1264
|
r.set(e, t);
|
|
1176
1265
|
return t;
|
|
1177
1266
|
};
|
|
1178
1267
|
const s = wrapProjection(t);
|
|
1179
1268
|
i = computed(() => {
|
|
1180
1269
|
const t = i || getOwner();
|
|
1181
|
-
storeSetter(s,
|
|
1182
|
-
const
|
|
1183
|
-
e !==
|
|
1270
|
+
storeSetter(new Proxy(s, writeTraps), r => {
|
|
1271
|
+
const o = handleAsync(t, e(r), e => {
|
|
1272
|
+
e !== s && e !== undefined && storeSetter(s, reconcile(e, n?.key || "id", n?.all));
|
|
1273
|
+
setSignal(i, undefined);
|
|
1184
1274
|
});
|
|
1185
|
-
|
|
1275
|
+
o !== s && o !== undefined && reconcile(o, n?.key || "id", n?.all)(s);
|
|
1186
1276
|
});
|
|
1187
1277
|
});
|
|
1278
|
+
i.Te = true;
|
|
1188
1279
|
return { store: s, node: i };
|
|
1189
1280
|
}
|
|
1190
1281
|
function createProjection(e, t = {}, n) {
|
|
1191
1282
|
return createProjectionInternal(e, t, n).store;
|
|
1192
1283
|
}
|
|
1284
|
+
const writeTraps = {
|
|
1285
|
+
get(e, t) {
|
|
1286
|
+
let n;
|
|
1287
|
+
setWriteOverride(true);
|
|
1288
|
+
try {
|
|
1289
|
+
n = e[t];
|
|
1290
|
+
} finally {
|
|
1291
|
+
setWriteOverride(false);
|
|
1292
|
+
}
|
|
1293
|
+
return typeof n === "object" && n !== null ? new Proxy(n, writeTraps) : n;
|
|
1294
|
+
},
|
|
1295
|
+
set(e, t, n) {
|
|
1296
|
+
setWriteOverride(true);
|
|
1297
|
+
try {
|
|
1298
|
+
e[t] = n;
|
|
1299
|
+
} finally {
|
|
1300
|
+
setWriteOverride(false);
|
|
1301
|
+
}
|
|
1302
|
+
return true;
|
|
1303
|
+
},
|
|
1304
|
+
deleteProperty(e, t) {
|
|
1305
|
+
setWriteOverride(true);
|
|
1306
|
+
try {
|
|
1307
|
+
delete e[t];
|
|
1308
|
+
} finally {
|
|
1309
|
+
setWriteOverride(false);
|
|
1310
|
+
}
|
|
1311
|
+
return true;
|
|
1312
|
+
}
|
|
1313
|
+
};
|
|
1193
1314
|
const $TRACK = Symbol(0),
|
|
1194
1315
|
$DEEP = Symbol(0),
|
|
1195
1316
|
$TARGET = Symbol(0),
|
|
@@ -1209,7 +1330,7 @@ function createStoreProxy(e, t = storeTraps, n) {
|
|
|
1209
1330
|
i = [];
|
|
1210
1331
|
i.v = e;
|
|
1211
1332
|
} else i = { v: e };
|
|
1212
|
-
n &&
|
|
1333
|
+
n && n(i);
|
|
1213
1334
|
return (i[$PROXY] = new Proxy(i, t));
|
|
1214
1335
|
}
|
|
1215
1336
|
const storeLookup = new WeakMap();
|
|
@@ -1222,6 +1343,13 @@ function wrap(e, t) {
|
|
|
1222
1343
|
function isWrappable(e) {
|
|
1223
1344
|
return e != null && typeof e === "object" && !Object.isFrozen(e);
|
|
1224
1345
|
}
|
|
1346
|
+
let writeOverride = false;
|
|
1347
|
+
function setWriteOverride(e) {
|
|
1348
|
+
writeOverride = e;
|
|
1349
|
+
}
|
|
1350
|
+
function writeOnly(e) {
|
|
1351
|
+
return writeOverride || !!Writing?.has(e);
|
|
1352
|
+
}
|
|
1225
1353
|
function getNodes(e, t) {
|
|
1226
1354
|
let n = e[t];
|
|
1227
1355
|
if (!n) e[t] = n = Object.create(null);
|
|
@@ -1241,8 +1369,7 @@ function getNode(e, t, n, i, r = isEqual) {
|
|
|
1241
1369
|
));
|
|
1242
1370
|
}
|
|
1243
1371
|
function trackSelf(e, t = $TRACK) {
|
|
1244
|
-
getObserver() &&
|
|
1245
|
-
read(getNode(getNodes(e, STORE_NODE), t, undefined, e[STORE_FIREWALL]?.(), false));
|
|
1372
|
+
getObserver() && read(getNode(getNodes(e, STORE_NODE), t, undefined, e[STORE_FIREWALL], false));
|
|
1246
1373
|
}
|
|
1247
1374
|
function getKeys(e, t, n = true) {
|
|
1248
1375
|
const i = untrack(() => (n ? Object.keys(e) : Reflect.ownKeys(e)));
|
|
@@ -1268,6 +1395,7 @@ const storeTraps = {
|
|
|
1268
1395
|
get(e, t, n) {
|
|
1269
1396
|
if (t === $TARGET) return e;
|
|
1270
1397
|
if (t === $PROXY) return n;
|
|
1398
|
+
if (t === $REFRESH) return e[STORE_FIREWALL];
|
|
1271
1399
|
if (t === $TRACK || t === $DEEP) {
|
|
1272
1400
|
trackSelf(e, t);
|
|
1273
1401
|
return n;
|
|
@@ -1281,12 +1409,12 @@ const storeTraps = {
|
|
|
1281
1409
|
const e = Object.getOwnPropertyDescriptor(u, t);
|
|
1282
1410
|
if (e && e.get) return e.get.call(n);
|
|
1283
1411
|
}
|
|
1284
|
-
if (
|
|
1285
|
-
let n = r && (s || !o) ? (r.
|
|
1412
|
+
if (writeOnly(n)) {
|
|
1413
|
+
let n = r && (s || !o) ? (r.M !== NOT_PENDING ? r.M : r.Y) : u[t];
|
|
1286
1414
|
n === $DELETED && (n = undefined);
|
|
1287
1415
|
if (!isWrappable(n)) return n;
|
|
1288
1416
|
const i = wrap(n, e);
|
|
1289
|
-
Writing
|
|
1417
|
+
Writing?.add(i);
|
|
1290
1418
|
return i;
|
|
1291
1419
|
}
|
|
1292
1420
|
let l = r ? (s || !o ? read(i[t]) : (read(i[t]), u[t])) : u[t];
|
|
@@ -1300,7 +1428,7 @@ const storeTraps = {
|
|
|
1300
1428
|
? l.bind(u)
|
|
1301
1429
|
: l;
|
|
1302
1430
|
} else if (getObserver()) {
|
|
1303
|
-
return read(getNode(i, t, isWrappable(l) ? wrap(l, e) : l, e[STORE_FIREWALL]
|
|
1431
|
+
return read(getNode(i, t, isWrappable(l) ? wrap(l, e) : l, e[STORE_FIREWALL]));
|
|
1304
1432
|
}
|
|
1305
1433
|
}
|
|
1306
1434
|
return isWrappable(l) ? wrap(l, e) : l;
|
|
@@ -1311,12 +1439,12 @@ const storeTraps = {
|
|
|
1311
1439
|
e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE]
|
|
1312
1440
|
? e[STORE_OVERRIDE][t] !== $DELETED
|
|
1313
1441
|
: t in e[STORE_VALUE];
|
|
1314
|
-
getObserver() && read(getNode(getNodes(e, STORE_HAS), t, n, e[STORE_FIREWALL]
|
|
1442
|
+
getObserver() && read(getNode(getNodes(e, STORE_HAS), t, n, e[STORE_FIREWALL]));
|
|
1315
1443
|
return n;
|
|
1316
1444
|
},
|
|
1317
1445
|
set(e, t, n) {
|
|
1318
1446
|
const i = e[$PROXY];
|
|
1319
|
-
if (
|
|
1447
|
+
if (writeOnly(i)) {
|
|
1320
1448
|
untrack(() => {
|
|
1321
1449
|
const r = e[STORE_VALUE];
|
|
1322
1450
|
const s = r[t];
|
|
@@ -1345,7 +1473,7 @@ const storeTraps = {
|
|
|
1345
1473
|
return true;
|
|
1346
1474
|
},
|
|
1347
1475
|
deleteProperty(e, t) {
|
|
1348
|
-
if (
|
|
1476
|
+
if (writeOnly(e[$PROXY]) && e[STORE_OVERRIDE]?.[t] !== $DELETED) {
|
|
1349
1477
|
untrack(() => {
|
|
1350
1478
|
const n =
|
|
1351
1479
|
e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE] ? e[STORE_OVERRIDE][t] : e[STORE_VALUE][t];
|
|
@@ -1642,68 +1770,68 @@ function mapArray(e, t, n) {
|
|
|
1642
1770
|
const i = typeof n?.keyed === "function" ? n.keyed : undefined;
|
|
1643
1771
|
return createMemo(
|
|
1644
1772
|
updateKeyedMap.bind({
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
we: [],
|
|
1773
|
+
ye: createOwner(),
|
|
1774
|
+
Ce: 0,
|
|
1775
|
+
De: e,
|
|
1776
|
+
Pe: [],
|
|
1777
|
+
we: t,
|
|
1651
1778
|
be: [],
|
|
1652
|
-
Ve:
|
|
1779
|
+
Ve: [],
|
|
1780
|
+
me: i,
|
|
1653
1781
|
Ue: i || n?.keyed === false ? [] : undefined,
|
|
1654
|
-
|
|
1655
|
-
|
|
1782
|
+
ke: t.length > 1 ? [] : undefined,
|
|
1783
|
+
ve: n?.fallback
|
|
1656
1784
|
})
|
|
1657
1785
|
);
|
|
1658
1786
|
}
|
|
1659
1787
|
const pureOptions = { pureWrite: true };
|
|
1660
1788
|
function updateKeyedMap() {
|
|
1661
|
-
const e = this.
|
|
1789
|
+
const e = this.De() || [],
|
|
1662
1790
|
t = e.length;
|
|
1663
1791
|
e[$TRACK];
|
|
1664
|
-
runWithOwner(this.
|
|
1792
|
+
runWithOwner(this.ye, () => {
|
|
1665
1793
|
let n,
|
|
1666
1794
|
i,
|
|
1667
1795
|
r = this.Ue
|
|
1668
1796
|
? () => {
|
|
1669
1797
|
this.Ue[i] = signal(e[i], pureOptions);
|
|
1670
|
-
this.
|
|
1671
|
-
return this.
|
|
1798
|
+
this.ke && (this.ke[i] = signal(i, pureOptions));
|
|
1799
|
+
return this.we(
|
|
1672
1800
|
read.bind(null, this.Ue[i]),
|
|
1673
|
-
this.
|
|
1801
|
+
this.ke ? read.bind(null, this.ke[i]) : undefined
|
|
1674
1802
|
);
|
|
1675
1803
|
}
|
|
1676
|
-
: this.
|
|
1804
|
+
: this.ke
|
|
1677
1805
|
? () => {
|
|
1678
1806
|
const t = e[i];
|
|
1679
|
-
this.
|
|
1680
|
-
return this.
|
|
1807
|
+
this.ke[i] = signal(i, pureOptions);
|
|
1808
|
+
return this.we(() => t, read.bind(null, this.ke[i]));
|
|
1681
1809
|
}
|
|
1682
1810
|
: () => {
|
|
1683
1811
|
const t = e[i];
|
|
1684
|
-
return this.
|
|
1812
|
+
return this.we(() => t);
|
|
1685
1813
|
};
|
|
1686
1814
|
if (t === 0) {
|
|
1687
|
-
if (this.
|
|
1688
|
-
this.
|
|
1815
|
+
if (this.Ce !== 0) {
|
|
1816
|
+
this.ye.dispose(false);
|
|
1817
|
+
this.Ve = [];
|
|
1818
|
+
this.Pe = [];
|
|
1689
1819
|
this.be = [];
|
|
1690
|
-
this.
|
|
1691
|
-
this.we = [];
|
|
1692
|
-
this.ye = 0;
|
|
1820
|
+
this.Ce = 0;
|
|
1693
1821
|
this.Ue && (this.Ue = []);
|
|
1694
|
-
this.
|
|
1822
|
+
this.ke && (this.ke = []);
|
|
1695
1823
|
}
|
|
1696
|
-
if (this.
|
|
1697
|
-
this.
|
|
1824
|
+
if (this.ve && !this.be[0]) {
|
|
1825
|
+
this.be[0] = runWithOwner((this.Ve[0] = createOwner()), this.ve);
|
|
1698
1826
|
}
|
|
1699
|
-
} else if (this.
|
|
1700
|
-
if (this.
|
|
1701
|
-
this.
|
|
1827
|
+
} else if (this.Ce === 0) {
|
|
1828
|
+
if (this.Ve[0]) this.Ve[0].dispose();
|
|
1829
|
+
this.be = new Array(t);
|
|
1702
1830
|
for (i = 0; i < t; i++) {
|
|
1703
|
-
this.
|
|
1704
|
-
this.
|
|
1831
|
+
this.Pe[i] = e[i];
|
|
1832
|
+
this.be[i] = runWithOwner((this.Ve[i] = createOwner()), r);
|
|
1705
1833
|
}
|
|
1706
|
-
this.
|
|
1834
|
+
this.Ce = t;
|
|
1707
1835
|
} else {
|
|
1708
1836
|
let s,
|
|
1709
1837
|
o,
|
|
@@ -1715,149 +1843,149 @@ function updateKeyedMap() {
|
|
|
1715
1843
|
E = new Array(t),
|
|
1716
1844
|
d = new Array(t),
|
|
1717
1845
|
T = this.Ue ? new Array(t) : undefined,
|
|
1718
|
-
|
|
1846
|
+
R = this.ke ? new Array(t) : undefined;
|
|
1719
1847
|
for (
|
|
1720
|
-
s = 0, o = Math.min(this.
|
|
1721
|
-
s < o && (this.
|
|
1848
|
+
s = 0, o = Math.min(this.Ce, t);
|
|
1849
|
+
s < o && (this.Pe[s] === e[s] || (this.Ue && compare(this.me, this.Pe[s], e[s])));
|
|
1722
1850
|
s++
|
|
1723
1851
|
) {
|
|
1724
1852
|
if (this.Ue) setSignal(this.Ue[s], e[s]);
|
|
1725
1853
|
}
|
|
1726
1854
|
for (
|
|
1727
|
-
o = this.
|
|
1855
|
+
o = this.Ce - 1, u = t - 1;
|
|
1728
1856
|
o >= s &&
|
|
1729
1857
|
u >= s &&
|
|
1730
|
-
(this.
|
|
1858
|
+
(this.Pe[o] === e[u] || (this.Ue && compare(this.me, this.Pe[o], e[u])));
|
|
1731
1859
|
o--, u--
|
|
1732
1860
|
) {
|
|
1733
|
-
E[u] = this.
|
|
1734
|
-
d[u] = this.
|
|
1861
|
+
E[u] = this.be[o];
|
|
1862
|
+
d[u] = this.Ve[o];
|
|
1735
1863
|
T && (T[u] = this.Ue[o]);
|
|
1736
|
-
|
|
1864
|
+
R && (R[u] = this.ke[o]);
|
|
1737
1865
|
}
|
|
1738
1866
|
a = new Map();
|
|
1739
1867
|
f = new Array(u + 1);
|
|
1740
1868
|
for (i = u; i >= s; i--) {
|
|
1741
1869
|
l = e[i];
|
|
1742
|
-
c = this.
|
|
1870
|
+
c = this.me ? this.me(l) : l;
|
|
1743
1871
|
n = a.get(c);
|
|
1744
1872
|
f[i] = n === undefined ? -1 : n;
|
|
1745
1873
|
a.set(c, i);
|
|
1746
1874
|
}
|
|
1747
1875
|
for (n = s; n <= o; n++) {
|
|
1748
|
-
l = this.
|
|
1749
|
-
c = this.
|
|
1876
|
+
l = this.Pe[n];
|
|
1877
|
+
c = this.me ? this.me(l) : l;
|
|
1750
1878
|
i = a.get(c);
|
|
1751
1879
|
if (i !== undefined && i !== -1) {
|
|
1752
|
-
E[i] = this.
|
|
1753
|
-
d[i] = this.
|
|
1880
|
+
E[i] = this.be[n];
|
|
1881
|
+
d[i] = this.Ve[n];
|
|
1754
1882
|
T && (T[i] = this.Ue[n]);
|
|
1755
|
-
|
|
1883
|
+
R && (R[i] = this.ke[n]);
|
|
1756
1884
|
i = f[i];
|
|
1757
1885
|
a.set(c, i);
|
|
1758
|
-
} else this.
|
|
1886
|
+
} else this.Ve[n].dispose();
|
|
1759
1887
|
}
|
|
1760
1888
|
for (i = s; i < t; i++) {
|
|
1761
1889
|
if (i in E) {
|
|
1762
|
-
this.
|
|
1763
|
-
this.
|
|
1890
|
+
this.be[i] = E[i];
|
|
1891
|
+
this.Ve[i] = d[i];
|
|
1764
1892
|
if (T) {
|
|
1765
1893
|
this.Ue[i] = T[i];
|
|
1766
1894
|
setSignal(this.Ue[i], e[i]);
|
|
1767
1895
|
}
|
|
1768
|
-
if (
|
|
1769
|
-
this.
|
|
1770
|
-
setSignal(this.
|
|
1896
|
+
if (R) {
|
|
1897
|
+
this.ke[i] = R[i];
|
|
1898
|
+
setSignal(this.ke[i], i);
|
|
1771
1899
|
}
|
|
1772
1900
|
} else {
|
|
1773
|
-
this.
|
|
1901
|
+
this.be[i] = runWithOwner((this.Ve[i] = createOwner()), r);
|
|
1774
1902
|
}
|
|
1775
1903
|
}
|
|
1776
|
-
this.
|
|
1777
|
-
this.
|
|
1904
|
+
this.be = this.be.slice(0, (this.Ce = t));
|
|
1905
|
+
this.Pe = e.slice(0);
|
|
1778
1906
|
}
|
|
1779
1907
|
});
|
|
1780
|
-
return this.
|
|
1908
|
+
return this.be;
|
|
1781
1909
|
}
|
|
1782
1910
|
function repeat(e, t, n) {
|
|
1783
1911
|
return updateRepeat.bind({
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1912
|
+
ye: createOwner(),
|
|
1913
|
+
Ce: 0,
|
|
1914
|
+
xe: 0,
|
|
1915
|
+
Ge: e,
|
|
1916
|
+
we: t,
|
|
1917
|
+
Ve: [],
|
|
1789
1918
|
be: [],
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
ke: n?.fallback
|
|
1919
|
+
He: n?.from,
|
|
1920
|
+
ve: n?.fallback
|
|
1793
1921
|
});
|
|
1794
1922
|
}
|
|
1795
1923
|
function updateRepeat() {
|
|
1796
|
-
const e = this.
|
|
1797
|
-
const t = this.
|
|
1798
|
-
runWithOwner(this.
|
|
1924
|
+
const e = this.Ge();
|
|
1925
|
+
const t = this.He?.() || 0;
|
|
1926
|
+
runWithOwner(this.ye, () => {
|
|
1799
1927
|
if (e === 0) {
|
|
1800
|
-
if (this.
|
|
1801
|
-
this.
|
|
1928
|
+
if (this.Ce !== 0) {
|
|
1929
|
+
this.ye.dispose(false);
|
|
1930
|
+
this.Ve = [];
|
|
1802
1931
|
this.be = [];
|
|
1803
|
-
this.
|
|
1804
|
-
this.ye = 0;
|
|
1932
|
+
this.Ce = 0;
|
|
1805
1933
|
}
|
|
1806
|
-
if (this.
|
|
1807
|
-
this.
|
|
1934
|
+
if (this.ve && !this.be[0]) {
|
|
1935
|
+
this.be[0] = runWithOwner((this.Ve[0] = createOwner()), this.ve);
|
|
1808
1936
|
}
|
|
1809
1937
|
return;
|
|
1810
1938
|
}
|
|
1811
1939
|
const n = t + e;
|
|
1812
|
-
const i = this.
|
|
1813
|
-
if (this.
|
|
1814
|
-
for (let e = n; e < i; e++) this.
|
|
1815
|
-
if (this.
|
|
1816
|
-
let e = this.
|
|
1817
|
-
while (e < t && e < this.
|
|
1818
|
-
this.
|
|
1819
|
-
this.
|
|
1820
|
-
} else if (this.
|
|
1821
|
-
let n = i - this.
|
|
1822
|
-
let r = this.
|
|
1823
|
-
this.
|
|
1940
|
+
const i = this.xe + this.Ce;
|
|
1941
|
+
if (this.Ce === 0 && this.Ve[0]) this.Ve[0].dispose();
|
|
1942
|
+
for (let e = n; e < i; e++) this.Ve[e - this.xe].dispose();
|
|
1943
|
+
if (this.xe < t) {
|
|
1944
|
+
let e = this.xe;
|
|
1945
|
+
while (e < t && e < this.Ce) this.Ve[e++].dispose();
|
|
1946
|
+
this.Ve.splice(0, t - this.xe);
|
|
1947
|
+
this.be.splice(0, t - this.xe);
|
|
1948
|
+
} else if (this.xe > t) {
|
|
1949
|
+
let n = i - this.xe - 1;
|
|
1950
|
+
let r = this.xe - t;
|
|
1951
|
+
this.Ve.length = this.be.length = e;
|
|
1824
1952
|
while (n >= r) {
|
|
1953
|
+
this.Ve[n] = this.Ve[n - r];
|
|
1825
1954
|
this.be[n] = this.be[n - r];
|
|
1826
|
-
this.we[n] = this.we[n - r];
|
|
1827
1955
|
n--;
|
|
1828
1956
|
}
|
|
1829
1957
|
for (let e = 0; e < r; e++) {
|
|
1830
|
-
this.
|
|
1958
|
+
this.be[e] = runWithOwner((this.Ve[e] = createOwner()), () => this.we(e + t));
|
|
1831
1959
|
}
|
|
1832
1960
|
}
|
|
1833
1961
|
for (let e = i; e < n; e++) {
|
|
1834
|
-
this.
|
|
1962
|
+
this.be[e - t] = runWithOwner((this.Ve[e - t] = createOwner()), () => this.we(e));
|
|
1835
1963
|
}
|
|
1836
|
-
this.
|
|
1837
|
-
this.
|
|
1838
|
-
this.
|
|
1964
|
+
this.be = this.be.slice(0, e);
|
|
1965
|
+
this.xe = t;
|
|
1966
|
+
this.Ce = e;
|
|
1839
1967
|
});
|
|
1840
|
-
return this.
|
|
1968
|
+
return this.be;
|
|
1841
1969
|
}
|
|
1842
1970
|
function compare(e, t, n) {
|
|
1843
1971
|
return e ? e(t) === e(n) : true;
|
|
1844
1972
|
}
|
|
1845
1973
|
function boundaryComputed(e, t) {
|
|
1846
1974
|
const n = computed(e, undefined, {
|
|
1847
|
-
|
|
1975
|
+
pe: {
|
|
1848
1976
|
le() {
|
|
1849
1977
|
let e = this.J;
|
|
1850
|
-
this.J &= ~this.
|
|
1851
|
-
if (this.
|
|
1978
|
+
this.J &= ~this.Qe;
|
|
1979
|
+
if (this.Qe & STATUS_PENDING && !(this.J & STATUS_UNINITIALIZED)) {
|
|
1852
1980
|
e &= ~STATUS_PENDING;
|
|
1853
1981
|
}
|
|
1854
|
-
this._e.notify(this, this.
|
|
1982
|
+
this._e.notify(this, this.Qe, e);
|
|
1855
1983
|
},
|
|
1856
|
-
|
|
1984
|
+
Qe: t
|
|
1857
1985
|
}
|
|
1858
1986
|
});
|
|
1859
|
-
n.
|
|
1860
|
-
n.
|
|
1987
|
+
n.Qe = t;
|
|
1988
|
+
n.Te = true;
|
|
1861
1989
|
return n;
|
|
1862
1990
|
}
|
|
1863
1991
|
function createBoundChildren(e, t, n, i) {
|
|
@@ -1870,19 +1998,19 @@ function createBoundChildren(e, t, n, i) {
|
|
|
1870
1998
|
});
|
|
1871
1999
|
}
|
|
1872
2000
|
class ConditionalQueue extends Queue {
|
|
1873
|
-
|
|
1874
|
-
|
|
2001
|
+
$e;
|
|
2002
|
+
Le = new Set();
|
|
1875
2003
|
$ = new Set();
|
|
1876
2004
|
constructor(e) {
|
|
1877
2005
|
super();
|
|
1878
|
-
this
|
|
2006
|
+
this.$e = e;
|
|
1879
2007
|
}
|
|
1880
2008
|
run(e) {
|
|
1881
|
-
if (!e || read(this
|
|
2009
|
+
if (!e || read(this.$e)) return;
|
|
1882
2010
|
return super.run(e);
|
|
1883
2011
|
}
|
|
1884
2012
|
notify(e, t, n) {
|
|
1885
|
-
if (read(this
|
|
2013
|
+
if (read(this.$e)) {
|
|
1886
2014
|
if (t & STATUS_PENDING) {
|
|
1887
2015
|
if (n & STATUS_PENDING) {
|
|
1888
2016
|
this.$.add(e);
|
|
@@ -1891,37 +2019,37 @@ class ConditionalQueue extends Queue {
|
|
|
1891
2019
|
}
|
|
1892
2020
|
if (t & STATUS_ERROR) {
|
|
1893
2021
|
if (n & STATUS_ERROR) {
|
|
1894
|
-
this
|
|
2022
|
+
this.Le.add(e);
|
|
1895
2023
|
t &= ~STATUS_ERROR;
|
|
1896
|
-
} else if (this
|
|
2024
|
+
} else if (this.Le.delete(e)) t &= ~STATUS_ERROR;
|
|
1897
2025
|
}
|
|
1898
2026
|
}
|
|
1899
2027
|
return t ? super.notify(e, t, n) : true;
|
|
1900
2028
|
}
|
|
1901
2029
|
}
|
|
1902
2030
|
class CollectionQueue extends Queue {
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
2031
|
+
Fe;
|
|
2032
|
+
Ve = new Set();
|
|
2033
|
+
$e = signal(false, { pureWrite: true });
|
|
2034
|
+
We = false;
|
|
1907
2035
|
constructor(e) {
|
|
1908
2036
|
super();
|
|
1909
|
-
this.
|
|
2037
|
+
this.Fe = e;
|
|
1910
2038
|
}
|
|
1911
2039
|
run(e) {
|
|
1912
|
-
if (!e || read(this
|
|
2040
|
+
if (!e || read(this.$e)) return;
|
|
1913
2041
|
return super.run(e);
|
|
1914
2042
|
}
|
|
1915
2043
|
notify(e, t, n) {
|
|
1916
|
-
if (!(t & this.
|
|
1917
|
-
if (n & this.
|
|
1918
|
-
this.
|
|
1919
|
-
if (this.
|
|
1920
|
-
} else if (this.
|
|
1921
|
-
this.
|
|
1922
|
-
if (this.
|
|
1923
|
-
}
|
|
1924
|
-
t &= ~this.
|
|
2044
|
+
if (!(t & this.Fe) || (this.Fe & STATUS_PENDING && this.We)) return super.notify(e, t, n);
|
|
2045
|
+
if (n & this.Fe) {
|
|
2046
|
+
this.Ve.add(e);
|
|
2047
|
+
if (this.Ve.size === 1) setSignal(this.$e, true);
|
|
2048
|
+
} else if (this.Ve.size > 0) {
|
|
2049
|
+
this.Ve.delete(e);
|
|
2050
|
+
if (this.Ve.size === 0) setSignal(this.$e, false);
|
|
2051
|
+
}
|
|
2052
|
+
t &= ~this.Fe;
|
|
1925
2053
|
return t ? super.notify(e, t, n) : true;
|
|
1926
2054
|
}
|
|
1927
2055
|
}
|
|
@@ -1935,25 +2063,25 @@ function createBoundary(e, t) {
|
|
|
1935
2063
|
const i = new ConditionalQueue(computed(() => t() === BoundaryMode.HIDDEN));
|
|
1936
2064
|
const r = createBoundChildren(n, e, i, 0);
|
|
1937
2065
|
computed(() => {
|
|
1938
|
-
const e = read(i
|
|
1939
|
-
r.
|
|
2066
|
+
const e = read(i.$e);
|
|
2067
|
+
r.Qe = e ? STATUS_ERROR | STATUS_PENDING : 0;
|
|
1940
2068
|
if (!e) {
|
|
1941
2069
|
i.$.forEach(e => i.notify(e, STATUS_PENDING, STATUS_PENDING));
|
|
1942
|
-
i
|
|
2070
|
+
i.Le.forEach(e => i.notify(e, STATUS_ERROR, STATUS_ERROR));
|
|
1943
2071
|
i.$.clear();
|
|
1944
|
-
i
|
|
2072
|
+
i.Le.clear();
|
|
1945
2073
|
}
|
|
1946
2074
|
});
|
|
1947
|
-
return () => (read(i
|
|
2075
|
+
return () => (read(i.$e) ? undefined : read(r));
|
|
1948
2076
|
}
|
|
1949
2077
|
function createCollectionBoundary(e, t, n) {
|
|
1950
2078
|
const i = createOwner();
|
|
1951
2079
|
const r = new CollectionQueue(e);
|
|
1952
2080
|
const s = createBoundChildren(i, t, r, e);
|
|
1953
2081
|
const o = computed(() => {
|
|
1954
|
-
if (!read(r
|
|
2082
|
+
if (!read(r.$e)) {
|
|
1955
2083
|
const e = read(s);
|
|
1956
|
-
if (!untrack(() => read(r
|
|
2084
|
+
if (!untrack(() => read(r.$e))) r.We = true;
|
|
1957
2085
|
return e;
|
|
1958
2086
|
}
|
|
1959
2087
|
return n(r);
|
|
@@ -1978,10 +2106,10 @@ function collectErrorSources(e, t) {
|
|
|
1978
2106
|
}
|
|
1979
2107
|
function createErrorBoundary(e, t) {
|
|
1980
2108
|
return createCollectionBoundary(STATUS_ERROR, e, e => {
|
|
1981
|
-
let n = e.
|
|
1982
|
-
return t(n.
|
|
2109
|
+
let n = e.Ve.values().next().value;
|
|
2110
|
+
return t(n.j, () => {
|
|
1983
2111
|
const t = [];
|
|
1984
|
-
for (const n of e.
|
|
2112
|
+
for (const n of e.Ve) collectErrorSources(n, t);
|
|
1985
2113
|
for (const e of t) recompute(e);
|
|
1986
2114
|
schedule();
|
|
1987
2115
|
});
|
|
@@ -2044,6 +2172,7 @@ export {
|
|
|
2044
2172
|
NoOwnerError,
|
|
2045
2173
|
NotReadyError,
|
|
2046
2174
|
SUPPORTS_PROXY,
|
|
2175
|
+
action,
|
|
2047
2176
|
createBoundary,
|
|
2048
2177
|
createContext,
|
|
2049
2178
|
createEffect,
|