@solidjs/signals 0.9.5 → 0.9.6
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 +715 -380
- package/dist/node.cjs +1259 -984
- package/dist/prod.js +1114 -799
- package/dist/types/core/constants.d.ts +2 -0
- package/dist/types/core/core.d.ts +12 -14
- package/dist/types/core/effect.d.ts +11 -0
- package/dist/types/core/index.d.ts +3 -3
- package/dist/types/core/scheduler.d.ts +14 -4
- package/dist/types/signals.d.ts +50 -3
- package/dist/types/store/optimistic.d.ts +7 -7
- package/dist/types/store/projection.d.ts +1 -0
- package/dist/types/store/store.d.ts +4 -2
- package/package.json +1 -1
package/dist/prod.js
CHANGED
|
@@ -23,12 +23,14 @@ const REACTIVE_IN_HEAP = 1 << 3;
|
|
|
23
23
|
const REACTIVE_IN_HEAP_HEIGHT = 1 << 4;
|
|
24
24
|
const REACTIVE_ZOMBIE = 1 << 5;
|
|
25
25
|
const REACTIVE_DISPOSED = 1 << 6;
|
|
26
|
+
const REACTIVE_OPTIMISTIC_DIRTY = 1 << 7;
|
|
26
27
|
const STATUS_NONE = 0;
|
|
27
28
|
const STATUS_PENDING = 1 << 0;
|
|
28
29
|
const STATUS_ERROR = 1 << 1;
|
|
29
30
|
const STATUS_UNINITIALIZED = 1 << 2;
|
|
30
31
|
const EFFECT_RENDER = 1;
|
|
31
32
|
const EFFECT_USER = 2;
|
|
33
|
+
const EFFECT_TRACKED = 3;
|
|
32
34
|
const NOT_PENDING = {};
|
|
33
35
|
const SUPPORTS_PROXY = typeof Proxy === "function";
|
|
34
36
|
const defaultContext = {};
|
|
@@ -45,7 +47,7 @@ function actualInsertIntoHeap(e, t) {
|
|
|
45
47
|
e.T = t;
|
|
46
48
|
r.T = e;
|
|
47
49
|
}
|
|
48
|
-
if (i > t.
|
|
50
|
+
if (i > t.O) t.O = i;
|
|
49
51
|
}
|
|
50
52
|
function insertIntoHeap(e, t) {
|
|
51
53
|
let n = e.S;
|
|
@@ -70,10 +72,10 @@ function deleteFromHeap(e, t) {
|
|
|
70
72
|
else {
|
|
71
73
|
const n = e.R;
|
|
72
74
|
const r = t.l[i];
|
|
73
|
-
const
|
|
75
|
+
const o = n ?? r;
|
|
74
76
|
if (e === r) t.l[i] = n;
|
|
75
77
|
else e.T.R = n;
|
|
76
|
-
|
|
78
|
+
o.T = e.T;
|
|
77
79
|
}
|
|
78
80
|
e.T = e;
|
|
79
81
|
e.R = undefined;
|
|
@@ -81,7 +83,7 @@ function deleteFromHeap(e, t) {
|
|
|
81
83
|
function markHeap(e) {
|
|
82
84
|
if (e._) return;
|
|
83
85
|
e._ = true;
|
|
84
|
-
for (let t = 0; t <= e.
|
|
86
|
+
for (let t = 0; t <= e.O; t++) {
|
|
85
87
|
for (let n = e.l[t]; n !== undefined; n = n.R) {
|
|
86
88
|
if (n.S & REACTIVE_IN_HEAP) markNode(n);
|
|
87
89
|
}
|
|
@@ -91,69 +93,77 @@ function markNode(e, t = REACTIVE_DIRTY) {
|
|
|
91
93
|
const n = e.S;
|
|
92
94
|
if ((n & (REACTIVE_CHECK | REACTIVE_DIRTY)) >= t) return;
|
|
93
95
|
e.S = (n & -4) | t;
|
|
94
|
-
for (let t = e.
|
|
95
|
-
markNode(t.
|
|
96
|
+
for (let t = e.p; t !== null; t = t.I) {
|
|
97
|
+
markNode(t.h, REACTIVE_CHECK);
|
|
96
98
|
}
|
|
97
|
-
if (e.
|
|
98
|
-
for (let t = e.
|
|
99
|
-
for (let e = t.
|
|
100
|
-
markNode(e.
|
|
99
|
+
if (e.A !== null) {
|
|
100
|
+
for (let t = e.A; t !== null; t = t.P) {
|
|
101
|
+
for (let e = t.p; e !== null; e = e.I) {
|
|
102
|
+
markNode(e.h, REACTIVE_CHECK);
|
|
101
103
|
}
|
|
102
104
|
}
|
|
103
105
|
}
|
|
104
106
|
}
|
|
105
107
|
function runHeap(e, t) {
|
|
106
108
|
e._ = false;
|
|
107
|
-
for (e.
|
|
108
|
-
let n = e.l[e.
|
|
109
|
+
for (e.N = 0; e.N <= e.O; e.N++) {
|
|
110
|
+
let n = e.l[e.N];
|
|
109
111
|
while (n !== undefined) {
|
|
110
112
|
if (n.S & REACTIVE_IN_HEAP) t(n);
|
|
111
113
|
else adjustHeight(n, e);
|
|
112
|
-
n = e.l[e.
|
|
114
|
+
n = e.l[e.N];
|
|
113
115
|
}
|
|
114
116
|
}
|
|
115
|
-
e.
|
|
117
|
+
e.O = 0;
|
|
116
118
|
}
|
|
117
119
|
function adjustHeight(e, t) {
|
|
118
120
|
deleteFromHeap(e, t);
|
|
119
121
|
let n = e.o;
|
|
120
|
-
for (let t = e.
|
|
122
|
+
for (let t = e.C; t; t = t.D) {
|
|
121
123
|
const e = t.V;
|
|
122
124
|
const i = e.m || e;
|
|
123
125
|
if (i.U && i.o >= n) n = i.o + 1;
|
|
124
126
|
}
|
|
125
127
|
if (e.o !== n) {
|
|
126
128
|
e.o = n;
|
|
127
|
-
for (let n = e.
|
|
128
|
-
insertIntoHeapHeight(n.
|
|
129
|
+
for (let n = e.p; n !== null; n = n.I) {
|
|
130
|
+
insertIntoHeapHeight(n.h, t);
|
|
129
131
|
}
|
|
130
132
|
}
|
|
131
133
|
}
|
|
132
134
|
const transitions = new Set();
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
const zombieQueue = { l: new Array(2e3).fill(undefined), _: false, C: 0, h: 0 };
|
|
135
|
+
const dirtyQueue = { l: new Array(2e3).fill(undefined), _: false, N: 0, O: 0 };
|
|
136
|
+
const zombieQueue = { l: new Array(2e3).fill(undefined), _: false, N: 0, O: 0 };
|
|
136
137
|
let clock = 0;
|
|
137
138
|
let activeTransition = null;
|
|
138
139
|
let scheduled = false;
|
|
140
|
+
let optimisticReadActive = false;
|
|
141
|
+
let projectionWriteActive = false;
|
|
142
|
+
function setOptimisticReadActive(e) {
|
|
143
|
+
optimisticReadActive = e;
|
|
144
|
+
}
|
|
145
|
+
function setProjectionWriteActive(e) {
|
|
146
|
+
projectionWriteActive = e;
|
|
147
|
+
}
|
|
139
148
|
function schedule() {
|
|
140
149
|
if (scheduled) return;
|
|
141
150
|
scheduled = true;
|
|
142
|
-
if (!globalQueue.k)
|
|
151
|
+
if (!globalQueue.k) queueMicrotask(flush);
|
|
143
152
|
}
|
|
144
153
|
class Queue {
|
|
145
154
|
i = null;
|
|
155
|
+
W = [[], []];
|
|
146
156
|
G = [[], []];
|
|
147
|
-
|
|
157
|
+
M = [];
|
|
148
158
|
created = clock;
|
|
149
159
|
addChild(e) {
|
|
150
|
-
this.
|
|
160
|
+
this.M.push(e);
|
|
151
161
|
e.i = this;
|
|
152
162
|
}
|
|
153
163
|
removeChild(e) {
|
|
154
|
-
const t = this.
|
|
164
|
+
const t = this.M.indexOf(e);
|
|
155
165
|
if (t >= 0) {
|
|
156
|
-
this.
|
|
166
|
+
this.M.splice(t, 1);
|
|
157
167
|
e.i = null;
|
|
158
168
|
}
|
|
159
169
|
}
|
|
@@ -161,40 +171,49 @@ class Queue {
|
|
|
161
171
|
if (this.i) return this.i.notify(e, t, n);
|
|
162
172
|
return false;
|
|
163
173
|
}
|
|
164
|
-
|
|
165
|
-
if (
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
runQueue(
|
|
174
|
+
$(e, t, n) {
|
|
175
|
+
if (t[e - 1].length) {
|
|
176
|
+
const n = t[e - 1];
|
|
177
|
+
t[e - 1] = [];
|
|
178
|
+
runQueue(n, e);
|
|
169
179
|
}
|
|
170
|
-
for (let t = 0; t < this.
|
|
171
|
-
this.
|
|
180
|
+
for (let t = 0; t < this.M.length; t++) {
|
|
181
|
+
this.M[t][n]?.(e);
|
|
172
182
|
}
|
|
173
183
|
}
|
|
184
|
+
run(e) {
|
|
185
|
+
this.$(e, this.W, "run");
|
|
186
|
+
}
|
|
187
|
+
runOptimistic(e) {
|
|
188
|
+
this.$(e, this.G, "runOptimistic");
|
|
189
|
+
}
|
|
174
190
|
enqueue(e, t) {
|
|
175
|
-
if (e)
|
|
191
|
+
if (e) {
|
|
192
|
+
const n = optimisticReadActive ? this.G : this.W;
|
|
193
|
+
n[e - 1].push(t);
|
|
194
|
+
}
|
|
176
195
|
schedule();
|
|
177
196
|
}
|
|
178
197
|
stashQueues(e) {
|
|
179
|
-
e.
|
|
180
|
-
e.
|
|
181
|
-
this.
|
|
182
|
-
for (let t = 0; t < this.
|
|
183
|
-
let n = this.
|
|
184
|
-
let i = e.
|
|
198
|
+
e.W[0].push(...this.W[0]);
|
|
199
|
+
e.W[1].push(...this.W[1]);
|
|
200
|
+
this.W = [[], []];
|
|
201
|
+
for (let t = 0; t < this.M.length; t++) {
|
|
202
|
+
let n = this.M[t];
|
|
203
|
+
let i = e.M[t];
|
|
185
204
|
if (!i) {
|
|
186
|
-
i = {
|
|
187
|
-
e.
|
|
205
|
+
i = { W: [[], []], M: [] };
|
|
206
|
+
e.M[t] = i;
|
|
188
207
|
}
|
|
189
208
|
n.stashQueues(i);
|
|
190
209
|
}
|
|
191
210
|
}
|
|
192
211
|
restoreQueues(e) {
|
|
193
|
-
this.
|
|
194
|
-
this.
|
|
195
|
-
for (let t = 0; t < e.
|
|
196
|
-
const n = e.
|
|
197
|
-
let i = this.
|
|
212
|
+
this.W[0].push(...e.W[0]);
|
|
213
|
+
this.W[1].push(...e.W[1]);
|
|
214
|
+
for (let t = 0; t < e.M.length; t++) {
|
|
215
|
+
const n = e.M[t];
|
|
216
|
+
let i = this.M[t];
|
|
198
217
|
if (i) i.restoreQueues(n);
|
|
199
218
|
}
|
|
200
219
|
}
|
|
@@ -202,39 +221,50 @@ class Queue {
|
|
|
202
221
|
class GlobalQueue extends Queue {
|
|
203
222
|
k = false;
|
|
204
223
|
L = [];
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
static
|
|
224
|
+
H = [];
|
|
225
|
+
F = new Set();
|
|
226
|
+
static j;
|
|
227
|
+
static K;
|
|
228
|
+
static Y = null;
|
|
208
229
|
flush() {
|
|
209
230
|
if (this.k) return;
|
|
210
231
|
this.k = true;
|
|
211
232
|
try {
|
|
212
|
-
runHeap(dirtyQueue, GlobalQueue.
|
|
233
|
+
runHeap(dirtyQueue, GlobalQueue.j);
|
|
213
234
|
if (activeTransition) {
|
|
214
|
-
|
|
235
|
+
const e = transitionComplete(activeTransition);
|
|
236
|
+
if (!e) {
|
|
215
237
|
let e = activeTransition;
|
|
216
|
-
runHeap(zombieQueue, GlobalQueue.
|
|
238
|
+
runHeap(zombieQueue, GlobalQueue.j);
|
|
217
239
|
this.L = [];
|
|
240
|
+
this.H = [];
|
|
241
|
+
this.F = new Set();
|
|
242
|
+
this.runOptimistic(EFFECT_RENDER);
|
|
243
|
+
this.runOptimistic(EFFECT_USER);
|
|
218
244
|
this.stashQueues(activeTransition.queueStash);
|
|
219
245
|
clock++;
|
|
220
246
|
scheduled = false;
|
|
221
|
-
runTransitionPending(activeTransition.pendingNodes
|
|
247
|
+
runTransitionPending(activeTransition.pendingNodes);
|
|
222
248
|
activeTransition = null;
|
|
223
|
-
|
|
249
|
+
finalizePureQueue(null, true);
|
|
224
250
|
return;
|
|
225
251
|
}
|
|
226
252
|
this.L !== activeTransition.pendingNodes && this.L.push(...activeTransition.pendingNodes);
|
|
227
|
-
this.$ !== activeTransition.optimisticNodes &&
|
|
228
|
-
this.$.push(...activeTransition.optimisticNodes);
|
|
229
253
|
this.restoreQueues(activeTransition.queueStash);
|
|
230
254
|
transitions.delete(activeTransition);
|
|
255
|
+
const t = activeTransition;
|
|
231
256
|
activeTransition = null;
|
|
232
|
-
runTransitionPending(this.L
|
|
233
|
-
|
|
234
|
-
|
|
257
|
+
runTransitionPending(this.L);
|
|
258
|
+
finalizePureQueue(t);
|
|
259
|
+
} else {
|
|
260
|
+
if (transitions.size) runHeap(zombieQueue, GlobalQueue.j);
|
|
261
|
+
finalizePureQueue();
|
|
262
|
+
}
|
|
235
263
|
clock++;
|
|
236
|
-
scheduled =
|
|
264
|
+
scheduled = dirtyQueue.O >= dirtyQueue.N;
|
|
265
|
+
this.runOptimistic(EFFECT_RENDER);
|
|
237
266
|
this.run(EFFECT_RENDER);
|
|
267
|
+
this.runOptimistic(EFFECT_USER);
|
|
238
268
|
this.run(EFFECT_USER);
|
|
239
269
|
} finally {
|
|
240
270
|
this.k = false;
|
|
@@ -243,8 +273,8 @@ class GlobalQueue extends Queue {
|
|
|
243
273
|
notify(e, t, n) {
|
|
244
274
|
if (t & STATUS_PENDING) {
|
|
245
275
|
if (n & STATUS_PENDING) {
|
|
246
|
-
if (activeTransition && !activeTransition.asyncNodes.includes(e.
|
|
247
|
-
activeTransition.asyncNodes.push(e.
|
|
276
|
+
if (activeTransition && e.B && !activeTransition.asyncNodes.includes(e.B.cause)) {
|
|
277
|
+
activeTransition.asyncNodes.push(e.B.cause);
|
|
248
278
|
schedule();
|
|
249
279
|
}
|
|
250
280
|
}
|
|
@@ -262,8 +292,9 @@ class GlobalQueue extends Queue {
|
|
|
262
292
|
pendingNodes: [],
|
|
263
293
|
asyncNodes: [],
|
|
264
294
|
optimisticNodes: [],
|
|
295
|
+
optimisticStores: new Set(),
|
|
265
296
|
actions: [],
|
|
266
|
-
queueStash: {
|
|
297
|
+
queueStash: { W: [[], []], M: [] },
|
|
267
298
|
done: false
|
|
268
299
|
};
|
|
269
300
|
} else if (e) {
|
|
@@ -276,67 +307,85 @@ class GlobalQueue extends Queue {
|
|
|
276
307
|
activeTransition.time = clock;
|
|
277
308
|
for (let e = 0; e < this.L.length; e++) {
|
|
278
309
|
const t = this.L[e];
|
|
279
|
-
t.
|
|
310
|
+
t.X = activeTransition;
|
|
280
311
|
activeTransition.pendingNodes.push(t);
|
|
281
312
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
t
|
|
313
|
+
this.L = activeTransition.pendingNodes;
|
|
314
|
+
for (let e = 0; e < this.H.length; e++) {
|
|
315
|
+
const t = this.H[e];
|
|
316
|
+
t.X = activeTransition;
|
|
285
317
|
activeTransition.optimisticNodes.push(t);
|
|
286
318
|
}
|
|
287
|
-
this.
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
for (let t = e.O; t !== null; t = t.p) {
|
|
293
|
-
const e = t.A.S & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue;
|
|
294
|
-
if (e.C > t.A.o) e.C = t.A.o;
|
|
295
|
-
insertIntoHeap(t.A, e);
|
|
319
|
+
this.H = activeTransition.optimisticNodes;
|
|
320
|
+
for (const e of this.F) {
|
|
321
|
+
activeTransition.optimisticStores.add(e);
|
|
322
|
+
}
|
|
323
|
+
this.F = activeTransition.optimisticStores;
|
|
296
324
|
}
|
|
297
325
|
}
|
|
298
|
-
function
|
|
299
|
-
let
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
326
|
+
function insertSubs(e, t = false) {
|
|
327
|
+
for (let n = e.p; n !== null; n = n.I) {
|
|
328
|
+
if (t) n.h.S |= REACTIVE_OPTIMISTIC_DIRTY;
|
|
329
|
+
const e = n.h;
|
|
330
|
+
if (e.q === EFFECT_TRACKED) {
|
|
331
|
+
if (!e.Z) {
|
|
332
|
+
e.Z = true;
|
|
333
|
+
e.J.enqueue(EFFECT_USER, e.ee);
|
|
334
|
+
}
|
|
335
|
+
continue;
|
|
307
336
|
}
|
|
308
|
-
i
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
globalQueue.$ = [];
|
|
312
|
-
if (dirtyQueue.h >= dirtyQueue.C) {
|
|
313
|
-
t = true;
|
|
314
|
-
runHeap(dirtyQueue, GlobalQueue.F);
|
|
337
|
+
const i = n.h.S & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue;
|
|
338
|
+
if (i.N > n.h.o) i.N = n.h.o;
|
|
339
|
+
insertIntoHeap(n.h, i);
|
|
315
340
|
}
|
|
316
|
-
optimisticRun = false;
|
|
317
|
-
t && runPending(globalQueue.L);
|
|
318
341
|
}
|
|
319
|
-
function
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
342
|
+
function finalizePureQueue(e = null, t = false) {
|
|
343
|
+
let n = !t;
|
|
344
|
+
if (dirtyQueue.O >= dirtyQueue.N) {
|
|
345
|
+
n = true;
|
|
346
|
+
runHeap(dirtyQueue, GlobalQueue.j);
|
|
347
|
+
}
|
|
348
|
+
if (n) {
|
|
349
|
+
const t = globalQueue.L;
|
|
350
|
+
for (let e = 0; e < t.length; e++) {
|
|
351
|
+
const n = t[e];
|
|
352
|
+
if (n.te !== NOT_PENDING) {
|
|
353
|
+
n.ne = n.te;
|
|
354
|
+
n.te = NOT_PENDING;
|
|
355
|
+
if (n.q && n.q !== EFFECT_TRACKED) n.Z = true;
|
|
356
|
+
}
|
|
357
|
+
if (n.U) GlobalQueue.K(n, false, true);
|
|
358
|
+
}
|
|
359
|
+
t.length = 0;
|
|
360
|
+
const n = e ? e.optimisticNodes : globalQueue.H;
|
|
361
|
+
for (let e = 0; e < n.length; e++) {
|
|
362
|
+
const t = n[e];
|
|
363
|
+
const i = t.te;
|
|
364
|
+
if (i !== NOT_PENDING && t.ne !== i) {
|
|
365
|
+
t.ne = i;
|
|
366
|
+
insertSubs(t, true);
|
|
367
|
+
}
|
|
368
|
+
t.te = NOT_PENDING;
|
|
369
|
+
t.X = null;
|
|
370
|
+
}
|
|
371
|
+
n.length = 0;
|
|
372
|
+
const i = e ? e.optimisticStores : globalQueue.F;
|
|
373
|
+
if (GlobalQueue.Y && i.size) {
|
|
374
|
+
for (const e of i) {
|
|
375
|
+
GlobalQueue.Y(e);
|
|
376
|
+
}
|
|
377
|
+
i.clear();
|
|
378
|
+
schedule();
|
|
326
379
|
}
|
|
327
|
-
if (n.U) GlobalQueue.W(n, false, true);
|
|
328
380
|
}
|
|
329
|
-
e.length = 0;
|
|
330
381
|
}
|
|
331
|
-
function
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
i.q.Z(t);
|
|
339
|
-
}
|
|
382
|
+
function trackOptimisticStore(e) {
|
|
383
|
+
globalQueue.F.add(e);
|
|
384
|
+
schedule();
|
|
385
|
+
}
|
|
386
|
+
function runTransitionPending(e) {
|
|
387
|
+
for (let t = 0; t < e.length; t++) {
|
|
388
|
+
e[t].X = activeTransition;
|
|
340
389
|
}
|
|
341
390
|
}
|
|
342
391
|
const globalQueue = new GlobalQueue();
|
|
@@ -353,7 +402,7 @@ function transitionComplete(e) {
|
|
|
353
402
|
if (e.actions.length) return false;
|
|
354
403
|
let t = true;
|
|
355
404
|
for (let n = 0; n < e.asyncNodes.length; n++) {
|
|
356
|
-
if (e.asyncNodes[n].
|
|
405
|
+
if (e.asyncNodes[n].ie & STATUS_PENDING) {
|
|
357
406
|
t = false;
|
|
358
407
|
break;
|
|
359
408
|
}
|
|
@@ -367,7 +416,6 @@ function currentTransition(e) {
|
|
|
367
416
|
}
|
|
368
417
|
function runInTransition(e, t) {
|
|
369
418
|
const n = activeTransition;
|
|
370
|
-
activeTransition = null;
|
|
371
419
|
try {
|
|
372
420
|
activeTransition = currentTransition(e);
|
|
373
421
|
return t();
|
|
@@ -375,161 +423,258 @@ function runInTransition(e, t) {
|
|
|
375
423
|
activeTransition = n;
|
|
376
424
|
}
|
|
377
425
|
}
|
|
426
|
+
function restoreTransition(e, t) {
|
|
427
|
+
globalQueue.initTransition(e);
|
|
428
|
+
const n = t();
|
|
429
|
+
flush();
|
|
430
|
+
return n;
|
|
431
|
+
}
|
|
378
432
|
function action(e) {
|
|
379
|
-
return (...t) =>
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
if (e.done) {
|
|
391
|
-
i = currentTransition(i);
|
|
392
|
-
i.actions.splice(i.actions.indexOf(n), 1);
|
|
393
|
-
activeTransition = i;
|
|
433
|
+
return (...t) =>
|
|
434
|
+
new Promise((n, i) => {
|
|
435
|
+
const r = e(...t);
|
|
436
|
+
globalQueue.initTransition();
|
|
437
|
+
let o = activeTransition;
|
|
438
|
+
o.actions.push(r);
|
|
439
|
+
const done = (e, t) => {
|
|
440
|
+
o = currentTransition(o);
|
|
441
|
+
const s = o.actions.indexOf(r);
|
|
442
|
+
if (s >= 0) o.actions.splice(s, 1);
|
|
443
|
+
activeTransition = o;
|
|
394
444
|
schedule();
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
445
|
+
t ? i(t) : n(e);
|
|
446
|
+
};
|
|
447
|
+
const step = (e, t) => {
|
|
448
|
+
let n;
|
|
449
|
+
try {
|
|
450
|
+
n = t ? r.throw(e) : r.next(e);
|
|
451
|
+
} catch (e) {
|
|
452
|
+
return done(undefined, e);
|
|
453
|
+
}
|
|
454
|
+
if (n instanceof Promise)
|
|
455
|
+
return void n.then(run, e => restoreTransition(o, () => step(e, true)));
|
|
456
|
+
run(n);
|
|
457
|
+
};
|
|
458
|
+
const run = e => {
|
|
459
|
+
if (e.done) return done(e.value);
|
|
460
|
+
if (e.value instanceof Promise)
|
|
461
|
+
return void e.value.then(
|
|
462
|
+
e => restoreTransition(o, () => step(e)),
|
|
463
|
+
e => restoreTransition(o, () => step(e, true))
|
|
464
|
+
);
|
|
465
|
+
restoreTransition(o, () => step(e.value));
|
|
466
|
+
};
|
|
467
|
+
step();
|
|
468
|
+
});
|
|
404
469
|
}
|
|
405
|
-
GlobalQueue.
|
|
406
|
-
GlobalQueue.
|
|
470
|
+
GlobalQueue.j = recompute;
|
|
471
|
+
GlobalQueue.K = disposeChildren;
|
|
407
472
|
let tracking = false;
|
|
408
473
|
let stale = false;
|
|
409
|
-
let pendingValueCheck = false;
|
|
410
|
-
let pendingCheck = null;
|
|
411
474
|
let refreshing = false;
|
|
475
|
+
let pendingCheckActive = false;
|
|
476
|
+
let foundPending = false;
|
|
477
|
+
let pendingReadActive = false;
|
|
412
478
|
let context = null;
|
|
413
479
|
function recompute(e, t = false) {
|
|
414
|
-
const n = e.
|
|
480
|
+
const n = e.q;
|
|
415
481
|
if (!t) {
|
|
416
|
-
if (e.
|
|
482
|
+
if (e.X && (!n || activeTransition) && activeTransition !== e.X)
|
|
483
|
+
globalQueue.initTransition(e.X);
|
|
417
484
|
deleteFromHeap(e, e.S & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
418
|
-
if (e.
|
|
485
|
+
if (e.X) disposeChildren(e);
|
|
419
486
|
else {
|
|
420
487
|
markDisposal(e);
|
|
421
|
-
e.
|
|
422
|
-
e.
|
|
423
|
-
e.
|
|
424
|
-
e.
|
|
488
|
+
e.re = e.oe;
|
|
489
|
+
e.se = e.ue;
|
|
490
|
+
e.oe = null;
|
|
491
|
+
e.ue = null;
|
|
425
492
|
}
|
|
426
493
|
}
|
|
427
|
-
const i =
|
|
494
|
+
const i = !!(e.S & REACTIVE_OPTIMISTIC_DIRTY);
|
|
495
|
+
const r = e.le && e.te !== NOT_PENDING;
|
|
496
|
+
const o = context;
|
|
428
497
|
context = e;
|
|
429
|
-
e.
|
|
498
|
+
e.ce = null;
|
|
430
499
|
e.S = REACTIVE_RECOMPUTING_DEPS;
|
|
431
|
-
e.
|
|
432
|
-
let
|
|
433
|
-
let
|
|
434
|
-
let o = e.J;
|
|
435
|
-
let u = e.j;
|
|
500
|
+
e.ae = clock;
|
|
501
|
+
let s = e.te === NOT_PENDING ? e.ne : e.te;
|
|
502
|
+
let u = e.o;
|
|
436
503
|
let l = tracking;
|
|
437
|
-
|
|
504
|
+
let c = optimisticReadActive;
|
|
438
505
|
tracking = true;
|
|
506
|
+
if (i) setOptimisticReadActive(true);
|
|
439
507
|
try {
|
|
440
|
-
|
|
441
|
-
e
|
|
508
|
+
s = handleAsync(e, e.U(s));
|
|
509
|
+
clearStatus(e);
|
|
442
510
|
} catch (t) {
|
|
443
511
|
if (t instanceof NotReadyError) {
|
|
444
512
|
if (t.cause !== e) link(t.cause, e);
|
|
445
|
-
|
|
446
|
-
} else
|
|
513
|
+
notifyStatus(e, STATUS_PENDING, t);
|
|
514
|
+
} else notifyStatus(e, STATUS_ERROR, t);
|
|
447
515
|
} finally {
|
|
448
516
|
tracking = l;
|
|
517
|
+
e.S = REACTIVE_NONE;
|
|
518
|
+
context = o;
|
|
449
519
|
}
|
|
450
|
-
e.
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
let n = t !== null ? t.P : e.D;
|
|
455
|
-
if (n !== null) {
|
|
520
|
+
if (!e.B) {
|
|
521
|
+
const o = e.ce;
|
|
522
|
+
let l = o !== null ? o.D : e.C;
|
|
523
|
+
if (l !== null) {
|
|
456
524
|
do {
|
|
457
|
-
|
|
458
|
-
} while (
|
|
459
|
-
if (
|
|
460
|
-
else e.
|
|
525
|
+
l = unlinkSubs(l);
|
|
526
|
+
} while (l !== null);
|
|
527
|
+
if (o !== null) o.D = null;
|
|
528
|
+
else e.C = null;
|
|
461
529
|
}
|
|
462
|
-
|
|
463
|
-
const c = !e.ue || !e.ue(e.M === NOT_PENDING || (e.oe && e.K) || n ? e.Y : e.M, r);
|
|
464
|
-
const a = e.J !== o || e.j !== u;
|
|
465
|
-
if (e.N && e.J & STATUS_PENDING && activeTransition) activeTransition.asyncNodes.push(e);
|
|
466
|
-
e.le?.(a, o);
|
|
467
|
-
if (c || a) {
|
|
530
|
+
const c = !e.fe || !e.fe(e.te === NOT_PENDING ? e.ne : e.te, s);
|
|
468
531
|
if (c) {
|
|
469
|
-
if (t || e.
|
|
470
|
-
else e.
|
|
471
|
-
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
insertIntoHeapHeight(t.A, t.A.S & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
532
|
+
if (t || (n && activeTransition !== e.X) || i) e.ne = s;
|
|
533
|
+
else e.te = s;
|
|
534
|
+
insertSubs(e, i || r);
|
|
535
|
+
} else if (e.o != u) {
|
|
536
|
+
for (let t = e.p; t !== null; t = t.I) {
|
|
537
|
+
insertIntoHeapHeight(t.h, t.h.S & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
538
|
+
}
|
|
477
539
|
}
|
|
478
540
|
}
|
|
479
|
-
|
|
480
|
-
(!t || e.
|
|
481
|
-
e.
|
|
541
|
+
setOptimisticReadActive(c);
|
|
542
|
+
(!t || e.ie & STATUS_PENDING) && !e.X && globalQueue.L.push(e);
|
|
543
|
+
e.X && n && activeTransition !== e.X && runInTransition(e.X, () => recompute(e));
|
|
482
544
|
}
|
|
483
545
|
function handleAsync(e, t, n) {
|
|
484
546
|
const i = typeof t === "object" && t !== null;
|
|
485
|
-
const r = i &&
|
|
486
|
-
const
|
|
487
|
-
if (!
|
|
488
|
-
e.
|
|
547
|
+
const r = i && untrack(() => t[Symbol.asyncIterator]);
|
|
548
|
+
const o = !r && i && untrack(() => typeof t.then === "function");
|
|
549
|
+
if (!o && !r) {
|
|
550
|
+
e.Ee = null;
|
|
489
551
|
return t;
|
|
490
552
|
}
|
|
491
|
-
e.
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
553
|
+
e.Ee = t;
|
|
554
|
+
let s;
|
|
555
|
+
const handleError = n => {
|
|
556
|
+
if (e.Ee !== t) return;
|
|
557
|
+
globalQueue.initTransition(e.X);
|
|
558
|
+
if (n instanceof NotReadyError) {
|
|
559
|
+
if (n.cause !== e) link(n.cause, e);
|
|
560
|
+
notifyStatus(e, STATUS_PENDING, n);
|
|
561
|
+
} else notifyStatus(e, STATUS_ERROR, n);
|
|
562
|
+
e.ae = clock;
|
|
563
|
+
};
|
|
564
|
+
const asyncWrite = (i, r) => {
|
|
565
|
+
if (e.Ee !== t) return;
|
|
566
|
+
globalQueue.initTransition(e.X);
|
|
567
|
+
clearStatus(e);
|
|
568
|
+
if (n) n(i);
|
|
569
|
+
else if (e.le) {
|
|
570
|
+
const t = e.te !== NOT_PENDING;
|
|
571
|
+
if (e.U) e.te = i;
|
|
572
|
+
if (!t) {
|
|
573
|
+
e.ne = i;
|
|
574
|
+
insertSubs(e);
|
|
575
|
+
}
|
|
576
|
+
e.ae = clock;
|
|
504
577
|
schedule();
|
|
505
|
-
|
|
506
|
-
|
|
578
|
+
} else setSignal(e, () => i);
|
|
579
|
+
flush();
|
|
580
|
+
r?.();
|
|
581
|
+
};
|
|
582
|
+
if (o) {
|
|
583
|
+
let n = false,
|
|
584
|
+
i = true;
|
|
585
|
+
t.then(
|
|
586
|
+
e => {
|
|
587
|
+
if (i) {
|
|
588
|
+
s = e;
|
|
589
|
+
n = true;
|
|
590
|
+
} else asyncWrite(e);
|
|
591
|
+
},
|
|
592
|
+
e => {
|
|
593
|
+
if (!i) handleError(e);
|
|
594
|
+
}
|
|
595
|
+
);
|
|
596
|
+
i = false;
|
|
597
|
+
if (!n) {
|
|
598
|
+
globalQueue.initTransition(e.X);
|
|
599
|
+
throw new NotReadyError(context);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
if (r) {
|
|
603
|
+
const n = t[Symbol.asyncIterator]();
|
|
604
|
+
let i = false;
|
|
605
|
+
const iterate = () => {
|
|
606
|
+
let e,
|
|
607
|
+
t = false,
|
|
608
|
+
r = true;
|
|
609
|
+
n.next().then(
|
|
610
|
+
n => {
|
|
611
|
+
if (r) {
|
|
612
|
+
e = n;
|
|
613
|
+
t = true;
|
|
614
|
+
} else if (!n.done) asyncWrite(n.value, iterate);
|
|
615
|
+
},
|
|
616
|
+
e => {
|
|
617
|
+
if (!r) handleError(e);
|
|
618
|
+
}
|
|
619
|
+
);
|
|
620
|
+
r = false;
|
|
621
|
+
if (t && !e.done) {
|
|
622
|
+
s = e.value;
|
|
623
|
+
i = true;
|
|
624
|
+
return iterate();
|
|
625
|
+
}
|
|
626
|
+
return t && e.done;
|
|
627
|
+
};
|
|
628
|
+
const r = iterate();
|
|
629
|
+
if (!i && !r) {
|
|
630
|
+
globalQueue.initTransition(e.X);
|
|
631
|
+
throw new NotReadyError(context);
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
return s;
|
|
635
|
+
}
|
|
636
|
+
function clearStatus(e) {
|
|
637
|
+
e.ie = STATUS_NONE;
|
|
638
|
+
e.B = null;
|
|
639
|
+
updatePendingSignal(e);
|
|
640
|
+
if (e.Te) {
|
|
641
|
+
e.Te();
|
|
507
642
|
} else {
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
globalQueue.initTransition(e.K);
|
|
513
|
-
n ? n(i) : setSignal(e, () => i);
|
|
514
|
-
flush();
|
|
643
|
+
if (!e.X) {
|
|
644
|
+
for (let t = e.p; t !== null; t = t.I) {
|
|
645
|
+
if (t.h.ie & STATUS_PENDING) {
|
|
646
|
+
insertIntoHeap(t.h, t.h.S & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
515
647
|
}
|
|
516
|
-
} catch (n) {
|
|
517
|
-
if (e.ae !== t) return;
|
|
518
|
-
globalQueue.initTransition(e.K);
|
|
519
|
-
setStatusFlags(e, STATUS_ERROR, n);
|
|
520
|
-
e.se = clock;
|
|
521
|
-
notifySubs(e);
|
|
522
|
-
schedule();
|
|
523
|
-
flush();
|
|
524
648
|
}
|
|
525
|
-
}
|
|
649
|
+
}
|
|
650
|
+
schedule();
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
function notifyStatus(e, t, n) {
|
|
654
|
+
e.ie = t | (e.ie & STATUS_UNINITIALIZED);
|
|
655
|
+
e.B = n;
|
|
656
|
+
updatePendingSignal(e);
|
|
657
|
+
if (e.Te) return e.Te();
|
|
658
|
+
for (let i = e.p; i !== null; i = i.I) {
|
|
659
|
+
i.h.ae = clock;
|
|
660
|
+
if (i.h.B !== n) {
|
|
661
|
+
!i.h.X && globalQueue.L.push(i.h);
|
|
662
|
+
notifyStatus(i.h, t, n);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
for (let i = e.A; i !== null; i = i.P) {
|
|
666
|
+
for (let e = i.p; e !== null; e = e.I) {
|
|
667
|
+
e.h.ae = clock;
|
|
668
|
+
if (e.h.B !== n) {
|
|
669
|
+
!e.h.X && globalQueue.L.push(e.h);
|
|
670
|
+
notifyStatus(e.h, t, n);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
526
673
|
}
|
|
527
|
-
globalQueue.initTransition(e.K);
|
|
528
|
-
throw new NotReadyError(context);
|
|
529
674
|
}
|
|
530
675
|
function updateIfNecessary(e) {
|
|
531
676
|
if (e.S & REACTIVE_CHECK) {
|
|
532
|
-
for (let t = e.
|
|
677
|
+
for (let t = e.C; t; t = t.D) {
|
|
533
678
|
const n = t.V;
|
|
534
679
|
const i = n.m || n;
|
|
535
680
|
if (i.U) {
|
|
@@ -547,68 +692,64 @@ function updateIfNecessary(e) {
|
|
|
547
692
|
}
|
|
548
693
|
function unlinkSubs(e) {
|
|
549
694
|
const t = e.V;
|
|
550
|
-
const n = e.
|
|
551
|
-
const i = e.
|
|
552
|
-
const r = e.
|
|
553
|
-
if (i !== null) i.
|
|
554
|
-
else t.
|
|
555
|
-
if (r !== null) r.
|
|
695
|
+
const n = e.D;
|
|
696
|
+
const i = e.I;
|
|
697
|
+
const r = e.Re;
|
|
698
|
+
if (i !== null) i.Re = r;
|
|
699
|
+
else t.de = r;
|
|
700
|
+
if (r !== null) r.I = i;
|
|
556
701
|
else {
|
|
557
|
-
t.
|
|
702
|
+
t.p = i;
|
|
558
703
|
if (i === null) {
|
|
559
|
-
t.
|
|
560
|
-
t.U && !t.
|
|
704
|
+
t.Oe?.();
|
|
705
|
+
t.U && !t.Se && unobserved(t);
|
|
561
706
|
}
|
|
562
707
|
}
|
|
563
708
|
return n;
|
|
564
709
|
}
|
|
565
710
|
function unobserved(e) {
|
|
566
711
|
deleteFromHeap(e, e.S & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
567
|
-
let t = e.
|
|
712
|
+
let t = e.C;
|
|
568
713
|
while (t !== null) {
|
|
569
714
|
t = unlinkSubs(t);
|
|
570
715
|
}
|
|
571
|
-
e.
|
|
716
|
+
e.C = null;
|
|
572
717
|
disposeChildren(e, true);
|
|
573
718
|
}
|
|
574
719
|
function link(e, t) {
|
|
575
|
-
const n = t.
|
|
720
|
+
const n = t.ce;
|
|
576
721
|
if (n !== null && n.V === e) return;
|
|
577
722
|
let i = null;
|
|
578
723
|
const r = t.S & REACTIVE_RECOMPUTING_DEPS;
|
|
579
724
|
if (r) {
|
|
580
|
-
i = n !== null ? n.
|
|
725
|
+
i = n !== null ? n.D : t.C;
|
|
581
726
|
if (i !== null && i.V === e) {
|
|
582
|
-
t.
|
|
727
|
+
t.ce = i;
|
|
583
728
|
return;
|
|
584
729
|
}
|
|
585
730
|
}
|
|
586
|
-
const
|
|
587
|
-
if (
|
|
588
|
-
const
|
|
589
|
-
if (n !== null) n.
|
|
590
|
-
else t.
|
|
591
|
-
if (
|
|
592
|
-
else e.
|
|
731
|
+
const o = e.de;
|
|
732
|
+
if (o !== null && o.h === t && (!r || isValidLink(o, t))) return;
|
|
733
|
+
const s = (t.ce = e.de = { V: e, h: t, D: i, Re: o, I: null });
|
|
734
|
+
if (n !== null) n.D = s;
|
|
735
|
+
else t.C = s;
|
|
736
|
+
if (o !== null) o.I = s;
|
|
737
|
+
else e.p = s;
|
|
593
738
|
}
|
|
594
739
|
function isValidLink(e, t) {
|
|
595
|
-
const n = t.
|
|
740
|
+
const n = t.ce;
|
|
596
741
|
if (n !== null) {
|
|
597
|
-
let i = t.
|
|
742
|
+
let i = t.C;
|
|
598
743
|
do {
|
|
599
744
|
if (i === e) return true;
|
|
600
745
|
if (i === n) break;
|
|
601
|
-
i = i.
|
|
746
|
+
i = i.D;
|
|
602
747
|
} while (i !== null);
|
|
603
748
|
}
|
|
604
749
|
return false;
|
|
605
750
|
}
|
|
606
|
-
function setStatusFlags(e, t, n = null) {
|
|
607
|
-
e.J = t;
|
|
608
|
-
e.j = n;
|
|
609
|
-
}
|
|
610
751
|
function markDisposal(e) {
|
|
611
|
-
let t = e.
|
|
752
|
+
let t = e.ue;
|
|
612
753
|
while (t) {
|
|
613
754
|
t.S |= REACTIVE_ZOMBIE;
|
|
614
755
|
if (t.S & REACTIVE_IN_HEAP) {
|
|
@@ -616,47 +757,47 @@ function markDisposal(e) {
|
|
|
616
757
|
insertIntoHeap(t, zombieQueue);
|
|
617
758
|
}
|
|
618
759
|
markDisposal(t);
|
|
619
|
-
t = t.
|
|
760
|
+
t = t._e;
|
|
620
761
|
}
|
|
621
762
|
}
|
|
622
763
|
function dispose(e) {
|
|
623
|
-
let t = e.
|
|
764
|
+
let t = e.C || null;
|
|
624
765
|
do {
|
|
625
766
|
t = unlinkSubs(t);
|
|
626
767
|
} while (t !== null);
|
|
627
|
-
e.
|
|
628
|
-
e.
|
|
768
|
+
e.C = null;
|
|
769
|
+
e.ce = null;
|
|
629
770
|
disposeChildren(e, true);
|
|
630
771
|
}
|
|
631
772
|
function disposeChildren(e, t = false, n) {
|
|
632
773
|
if (e.S & REACTIVE_DISPOSED) return;
|
|
633
774
|
if (t) e.S = REACTIVE_DISPOSED;
|
|
634
|
-
let i = n ? e.
|
|
775
|
+
let i = n ? e.se : e.ue;
|
|
635
776
|
while (i) {
|
|
636
|
-
const e = i.
|
|
637
|
-
if (i.
|
|
777
|
+
const e = i._e;
|
|
778
|
+
if (i.C) {
|
|
638
779
|
const e = i;
|
|
639
780
|
deleteFromHeap(e, e.S & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
640
|
-
let t = e.
|
|
781
|
+
let t = e.C;
|
|
641
782
|
do {
|
|
642
783
|
t = unlinkSubs(t);
|
|
643
784
|
} while (t !== null);
|
|
644
|
-
e.
|
|
645
|
-
e.
|
|
785
|
+
e.C = null;
|
|
786
|
+
e.ce = null;
|
|
646
787
|
}
|
|
647
788
|
disposeChildren(i, true);
|
|
648
789
|
i = e;
|
|
649
790
|
}
|
|
650
791
|
if (n) {
|
|
651
|
-
e.
|
|
792
|
+
e.se = null;
|
|
652
793
|
} else {
|
|
653
|
-
e.
|
|
654
|
-
e.
|
|
794
|
+
e.ue = null;
|
|
795
|
+
e._e = null;
|
|
655
796
|
}
|
|
656
797
|
runDisposal(e, n);
|
|
657
798
|
}
|
|
658
799
|
function runDisposal(e, t) {
|
|
659
|
-
let n = t ? e.
|
|
800
|
+
let n = t ? e.re : e.oe;
|
|
660
801
|
if (!n) return;
|
|
661
802
|
if (Array.isArray(n)) {
|
|
662
803
|
for (let e = 0; e < n.length; e++) {
|
|
@@ -666,10 +807,10 @@ function runDisposal(e, t) {
|
|
|
666
807
|
} else {
|
|
667
808
|
n.call(n);
|
|
668
809
|
}
|
|
669
|
-
t ? (e.
|
|
810
|
+
t ? (e.re = null) : (e.oe = null);
|
|
670
811
|
}
|
|
671
812
|
function getNextChildId(e) {
|
|
672
|
-
if (e.id != null) return formatId(e.id, e.
|
|
813
|
+
if (e.id != null) return formatId(e.id, e.pe++);
|
|
673
814
|
throw new Error("Cannot get child id from owner without an id");
|
|
674
815
|
}
|
|
675
816
|
function formatId(e, t) {
|
|
@@ -680,45 +821,44 @@ function formatId(e, t) {
|
|
|
680
821
|
function computed(e, t, n) {
|
|
681
822
|
const i = {
|
|
682
823
|
id: n?.id ?? (context?.id != null ? getNextChildId(context) : undefined),
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
824
|
+
fe: n?.equals != null ? n.equals : isEqual,
|
|
825
|
+
Ie: !!n?.pureWrite,
|
|
826
|
+
Oe: n?.unobserved,
|
|
827
|
+
oe: null,
|
|
828
|
+
J: context?.J ?? globalQueue,
|
|
829
|
+
he: context?.he ?? defaultContext,
|
|
830
|
+
pe: 0,
|
|
690
831
|
U: e,
|
|
691
|
-
|
|
832
|
+
ne: t,
|
|
692
833
|
o: 0,
|
|
693
|
-
|
|
834
|
+
A: null,
|
|
694
835
|
R: undefined,
|
|
695
836
|
T: null,
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
837
|
+
C: null,
|
|
838
|
+
ce: null,
|
|
839
|
+
p: null,
|
|
840
|
+
de: null,
|
|
700
841
|
i: context,
|
|
701
|
-
|
|
702
|
-
|
|
842
|
+
_e: null,
|
|
843
|
+
ue: null,
|
|
703
844
|
S: REACTIVE_NONE,
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
845
|
+
ie: STATUS_UNINITIALIZED,
|
|
846
|
+
ae: clock,
|
|
847
|
+
te: NOT_PENDING,
|
|
848
|
+
re: null,
|
|
849
|
+
se: null,
|
|
850
|
+
Ee: null,
|
|
851
|
+
X: null
|
|
711
852
|
};
|
|
712
|
-
if (n?.pe) Object.assign(i, n.pe);
|
|
713
853
|
i.T = i;
|
|
714
854
|
const r = context?.t ? context.u : context;
|
|
715
855
|
if (context) {
|
|
716
|
-
const e = context.
|
|
856
|
+
const e = context.ue;
|
|
717
857
|
if (e === null) {
|
|
718
|
-
context.
|
|
858
|
+
context.ue = i;
|
|
719
859
|
} else {
|
|
720
|
-
i.
|
|
721
|
-
context.
|
|
860
|
+
i._e = e;
|
|
861
|
+
context.ue = i;
|
|
722
862
|
}
|
|
723
863
|
}
|
|
724
864
|
if (r) i.o = r.o + 1;
|
|
@@ -727,22 +867,54 @@ function computed(e, t, n) {
|
|
|
727
867
|
}
|
|
728
868
|
function signal(e, t, n = null) {
|
|
729
869
|
const i = {
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
J: STATUS_NONE,
|
|
738
|
-
se: clock,
|
|
870
|
+
fe: t?.equals != null ? t.equals : isEqual,
|
|
871
|
+
Ie: !!t?.pureWrite,
|
|
872
|
+
Oe: t?.unobserved,
|
|
873
|
+
ne: e,
|
|
874
|
+
p: null,
|
|
875
|
+
de: null,
|
|
876
|
+
ae: clock,
|
|
739
877
|
m: n,
|
|
740
|
-
|
|
741
|
-
|
|
878
|
+
P: n?.A || null,
|
|
879
|
+
te: NOT_PENDING
|
|
742
880
|
};
|
|
743
|
-
n && (n.
|
|
881
|
+
n && (n.A = i);
|
|
744
882
|
return i;
|
|
745
883
|
}
|
|
884
|
+
function optimisticSignal(e, t) {
|
|
885
|
+
const n = signal(e, t);
|
|
886
|
+
n.le = true;
|
|
887
|
+
return n;
|
|
888
|
+
}
|
|
889
|
+
function optimisticComputed(e, t, n) {
|
|
890
|
+
const i = computed(e, t, n);
|
|
891
|
+
i.le = true;
|
|
892
|
+
return i;
|
|
893
|
+
}
|
|
894
|
+
function getPendingSignal(e) {
|
|
895
|
+
if (!e.Ae) {
|
|
896
|
+
e.Ae = optimisticSignal(false, { pureWrite: true });
|
|
897
|
+
if (computePendingState(e)) setSignal(e.Ae, true);
|
|
898
|
+
}
|
|
899
|
+
return e.Ae;
|
|
900
|
+
}
|
|
901
|
+
function computePendingState(e) {
|
|
902
|
+
if (e.te !== NOT_PENDING) return true;
|
|
903
|
+
const t = e;
|
|
904
|
+
return !!(t.ie & STATUS_PENDING && !(t.ie & STATUS_UNINITIALIZED));
|
|
905
|
+
}
|
|
906
|
+
function getPendingValueComputed(e) {
|
|
907
|
+
if (!e.ge) {
|
|
908
|
+
const t = pendingReadActive;
|
|
909
|
+
pendingReadActive = false;
|
|
910
|
+
e.ge = optimisticComputed(() => read(e));
|
|
911
|
+
pendingReadActive = t;
|
|
912
|
+
}
|
|
913
|
+
return e.ge;
|
|
914
|
+
}
|
|
915
|
+
function updatePendingSignal(e) {
|
|
916
|
+
if (e.Ae) setSignal(e.Ae, computePendingState(e));
|
|
917
|
+
}
|
|
746
918
|
function isEqual(e, t) {
|
|
747
919
|
return e === t;
|
|
748
920
|
}
|
|
@@ -756,16 +928,36 @@ function untrack(e) {
|
|
|
756
928
|
}
|
|
757
929
|
}
|
|
758
930
|
function read(e) {
|
|
931
|
+
if (pendingCheckActive) {
|
|
932
|
+
const t = e.m || e;
|
|
933
|
+
const n = getPendingSignal(t);
|
|
934
|
+
const i = pendingCheckActive;
|
|
935
|
+
pendingCheckActive = false;
|
|
936
|
+
if (read(n)) {
|
|
937
|
+
foundPending = true;
|
|
938
|
+
}
|
|
939
|
+
pendingCheckActive = i;
|
|
940
|
+
return e.ne;
|
|
941
|
+
}
|
|
942
|
+
if (pendingReadActive) {
|
|
943
|
+
const t = getPendingValueComputed(e);
|
|
944
|
+
const n = pendingReadActive;
|
|
945
|
+
pendingReadActive = false;
|
|
946
|
+
const i = read(t);
|
|
947
|
+
pendingReadActive = n;
|
|
948
|
+
if (t.ie & STATUS_PENDING) return e.ne;
|
|
949
|
+
return i;
|
|
950
|
+
}
|
|
759
951
|
let t = context;
|
|
760
952
|
if (t?.t) t = t.u;
|
|
761
953
|
if (refreshing && e.U) recompute(e);
|
|
762
|
-
if (t && tracking
|
|
954
|
+
if (t && tracking) {
|
|
763
955
|
if (e.U && e.S & REACTIVE_DISPOSED) recompute(e);
|
|
764
956
|
link(e, t);
|
|
765
957
|
const n = e.m || e;
|
|
766
958
|
if (n.U) {
|
|
767
959
|
const i = e.S & REACTIVE_ZOMBIE;
|
|
768
|
-
if (n.o >= (i ? zombieQueue.
|
|
960
|
+
if (n.o >= (i ? zombieQueue.N : dirtyQueue.N)) {
|
|
769
961
|
markNode(t);
|
|
770
962
|
markHeap(i ? zombieQueue : dirtyQueue);
|
|
771
963
|
updateIfNecessary(n);
|
|
@@ -776,73 +968,60 @@ function read(e) {
|
|
|
776
968
|
}
|
|
777
969
|
}
|
|
778
970
|
}
|
|
779
|
-
if (pendingValueCheck) {
|
|
780
|
-
if (!e.ce) {
|
|
781
|
-
e.ce = signal(e.Y);
|
|
782
|
-
e.ce.oe = true;
|
|
783
|
-
}
|
|
784
|
-
pendingValueCheck = false;
|
|
785
|
-
try {
|
|
786
|
-
return read(e.ce);
|
|
787
|
-
} finally {
|
|
788
|
-
pendingValueCheck = true;
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
971
|
const n = e.m || e;
|
|
792
|
-
if (
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
e.
|
|
801
|
-
pendingCheck = e;
|
|
802
|
-
}
|
|
803
|
-
if (!pendingCheck && n.J & STATUS_PENDING) {
|
|
804
|
-
if ((t && !stale) || n.J & STATUS_UNINITIALIZED || e.m) throw n.j;
|
|
805
|
-
else if (t && stale) {
|
|
806
|
-
setStatusFlags(t, t.J | STATUS_PENDING, n.j);
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
if (e.J & STATUS_ERROR) {
|
|
810
|
-
if (e.se < clock) {
|
|
972
|
+
if (
|
|
973
|
+
t &&
|
|
974
|
+
!optimisticReadActive &&
|
|
975
|
+
n.ie & STATUS_PENDING &&
|
|
976
|
+
!(stale && n.X && activeTransition !== n.X)
|
|
977
|
+
)
|
|
978
|
+
throw n.B;
|
|
979
|
+
if (e.U && e.ie & STATUS_ERROR) {
|
|
980
|
+
if (e.ae < clock) {
|
|
811
981
|
recompute(e, true);
|
|
812
982
|
return read(e);
|
|
813
|
-
} else
|
|
814
|
-
throw e.j;
|
|
815
|
-
}
|
|
983
|
+
} else throw e.B;
|
|
816
984
|
}
|
|
817
985
|
return !t ||
|
|
818
|
-
|
|
819
|
-
e.
|
|
820
|
-
(stale &&
|
|
821
|
-
? e.
|
|
822
|
-
: e.
|
|
986
|
+
optimisticReadActive ||
|
|
987
|
+
e.te === NOT_PENDING ||
|
|
988
|
+
(stale && e.X && activeTransition !== e.X)
|
|
989
|
+
? e.ne
|
|
990
|
+
: e.te;
|
|
823
991
|
}
|
|
824
992
|
function setSignal(e, t) {
|
|
825
|
-
if (e.
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
const
|
|
830
|
-
if (!
|
|
993
|
+
if (e.X && activeTransition !== e.X) globalQueue.initTransition(e.X);
|
|
994
|
+
const n = e.le && !projectionWriteActive;
|
|
995
|
+
const i = n ? e.ne : e.te === NOT_PENDING ? e.ne : e.te;
|
|
996
|
+
if (typeof t === "function") t = t(i);
|
|
997
|
+
const r = !e.fe || !e.fe(i, t);
|
|
998
|
+
if (!r) return t;
|
|
831
999
|
if (n) {
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
1000
|
+
const n = e.te === NOT_PENDING;
|
|
1001
|
+
if (e.X && !n) {
|
|
1002
|
+
globalQueue.initTransition(e.X);
|
|
1003
|
+
}
|
|
1004
|
+
if (n) {
|
|
1005
|
+
e.te = e.ne;
|
|
1006
|
+
globalQueue.H.push(e);
|
|
836
1007
|
}
|
|
837
|
-
|
|
1008
|
+
e.ne = t;
|
|
1009
|
+
} else {
|
|
1010
|
+
if (e.te === NOT_PENDING) globalQueue.L.push(e);
|
|
1011
|
+
e.te = t;
|
|
1012
|
+
}
|
|
1013
|
+
updatePendingSignal(e);
|
|
1014
|
+
if (e.ge) {
|
|
1015
|
+
setSignal(e.ge, t);
|
|
838
1016
|
}
|
|
839
|
-
|
|
840
|
-
e
|
|
841
|
-
e.oe && !optimisticRun ? globalQueue.$.push(e) : notifySubs(e);
|
|
1017
|
+
e.ae = clock;
|
|
1018
|
+
insertSubs(e, n);
|
|
842
1019
|
schedule();
|
|
843
1020
|
return t;
|
|
844
1021
|
}
|
|
1022
|
+
const PENDING_OWNER = {};
|
|
845
1023
|
function getObserver() {
|
|
1024
|
+
if (pendingCheckActive || pendingReadActive) return PENDING_OWNER;
|
|
846
1025
|
return tracking ? context : null;
|
|
847
1026
|
}
|
|
848
1027
|
function getOwner() {
|
|
@@ -850,42 +1029,37 @@ function getOwner() {
|
|
|
850
1029
|
}
|
|
851
1030
|
function onCleanup(e) {
|
|
852
1031
|
if (!context) return e;
|
|
853
|
-
|
|
854
|
-
if (
|
|
855
|
-
|
|
856
|
-
} else if (Array.isArray(t.te)) {
|
|
857
|
-
t.te.push(e);
|
|
858
|
-
} else {
|
|
859
|
-
t.te = [t.te, e];
|
|
860
|
-
}
|
|
1032
|
+
if (!context.oe) context.oe = e;
|
|
1033
|
+
else if (Array.isArray(context.oe)) context.oe.push(e);
|
|
1034
|
+
else context.oe = [context.oe, e];
|
|
861
1035
|
return e;
|
|
862
1036
|
}
|
|
863
1037
|
function createOwner(e) {
|
|
864
1038
|
const t = context;
|
|
865
1039
|
const n = {
|
|
1040
|
+
id: e?.id ?? (t?.id != null ? getNextChildId(t) : undefined),
|
|
866
1041
|
t: true,
|
|
867
1042
|
u: t?.t ? t.u : t,
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
ne: null,
|
|
1043
|
+
ue: null,
|
|
1044
|
+
_e: null,
|
|
1045
|
+
oe: null,
|
|
1046
|
+
J: t?.J ?? globalQueue,
|
|
1047
|
+
he: t?.he || defaultContext,
|
|
1048
|
+
pe: 0,
|
|
1049
|
+
re: null,
|
|
1050
|
+
se: null,
|
|
877
1051
|
i: t,
|
|
878
1052
|
dispose(e = true) {
|
|
879
1053
|
disposeChildren(n, e);
|
|
880
1054
|
}
|
|
881
1055
|
};
|
|
882
1056
|
if (t) {
|
|
883
|
-
const e = t.
|
|
1057
|
+
const e = t.ue;
|
|
884
1058
|
if (e === null) {
|
|
885
|
-
t.
|
|
1059
|
+
t.ue = n;
|
|
886
1060
|
} else {
|
|
887
|
-
n.
|
|
888
|
-
t.
|
|
1061
|
+
n._e = e;
|
|
1062
|
+
t.ue = n;
|
|
889
1063
|
}
|
|
890
1064
|
}
|
|
891
1065
|
return n;
|
|
@@ -916,25 +1090,25 @@ function staleValues(e, t = true) {
|
|
|
916
1090
|
}
|
|
917
1091
|
}
|
|
918
1092
|
function pending(e) {
|
|
919
|
-
const t =
|
|
920
|
-
|
|
1093
|
+
const t = pendingReadActive;
|
|
1094
|
+
pendingReadActive = true;
|
|
921
1095
|
try {
|
|
922
|
-
return
|
|
1096
|
+
return e();
|
|
923
1097
|
} finally {
|
|
924
|
-
|
|
1098
|
+
pendingReadActive = t;
|
|
925
1099
|
}
|
|
926
1100
|
}
|
|
927
1101
|
function isPending(e) {
|
|
928
|
-
const t =
|
|
929
|
-
|
|
1102
|
+
const t = pendingCheckActive;
|
|
1103
|
+
const n = foundPending;
|
|
1104
|
+
pendingCheckActive = true;
|
|
1105
|
+
foundPending = false;
|
|
930
1106
|
try {
|
|
931
|
-
|
|
932
|
-
return
|
|
933
|
-
} catch (e) {
|
|
934
|
-
if (!(e instanceof NotReadyError)) return false;
|
|
935
|
-
throw e;
|
|
1107
|
+
e();
|
|
1108
|
+
return foundPending;
|
|
936
1109
|
} finally {
|
|
937
|
-
|
|
1110
|
+
pendingCheckActive = t;
|
|
1111
|
+
foundPending = n;
|
|
938
1112
|
}
|
|
939
1113
|
}
|
|
940
1114
|
function refresh(e) {
|
|
@@ -950,7 +1124,6 @@ function refresh(e) {
|
|
|
950
1124
|
refreshing = t;
|
|
951
1125
|
if (!t) {
|
|
952
1126
|
schedule();
|
|
953
|
-
flush();
|
|
954
1127
|
}
|
|
955
1128
|
}
|
|
956
1129
|
}
|
|
@@ -964,7 +1137,7 @@ function getContext(e, t = getOwner()) {
|
|
|
964
1137
|
if (!t) {
|
|
965
1138
|
throw new NoOwnerError();
|
|
966
1139
|
}
|
|
967
|
-
const n = hasContext(e, t) ? t.
|
|
1140
|
+
const n = hasContext(e, t) ? t.he[e.id] : e.defaultValue;
|
|
968
1141
|
if (isUndefined(n)) {
|
|
969
1142
|
throw new ContextNotFoundError();
|
|
970
1143
|
}
|
|
@@ -974,73 +1147,92 @@ function setContext(e, t, n = getOwner()) {
|
|
|
974
1147
|
if (!n) {
|
|
975
1148
|
throw new NoOwnerError();
|
|
976
1149
|
}
|
|
977
|
-
n.
|
|
1150
|
+
n.he = { ...n.he, [e.id]: isUndefined(t) ? e.defaultValue : t };
|
|
978
1151
|
}
|
|
979
1152
|
function hasContext(e, t) {
|
|
980
|
-
return !isUndefined(t?.
|
|
1153
|
+
return !isUndefined(t?.he[e.id]);
|
|
981
1154
|
}
|
|
982
1155
|
function isUndefined(e) {
|
|
983
1156
|
return typeof e === "undefined";
|
|
984
1157
|
}
|
|
985
1158
|
function effect(e, t, n, i, r) {
|
|
986
|
-
let
|
|
987
|
-
const
|
|
1159
|
+
let o = false;
|
|
1160
|
+
const s = computed(r?.render ? t => staleValues(() => e(t)) : e, i, {
|
|
988
1161
|
...r,
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
}
|
|
1016
|
-
}
|
|
1017
|
-
if (!this._e.notify(this, STATUS_ERROR, STATUS_ERROR)) throw e;
|
|
1018
|
-
} else if (this.B === EFFECT_RENDER) {
|
|
1019
|
-
this._e.notify(this, STATUS_PENDING | STATUS_ERROR, this.J);
|
|
1162
|
+
equals: () => {
|
|
1163
|
+
s.Z = !s.B;
|
|
1164
|
+
if (o) s.J.enqueue(s.q, runEffect.bind(s));
|
|
1165
|
+
return false;
|
|
1166
|
+
},
|
|
1167
|
+
lazy: true
|
|
1168
|
+
});
|
|
1169
|
+
s.Pe = i;
|
|
1170
|
+
s.Ne = t;
|
|
1171
|
+
s.Ce = n;
|
|
1172
|
+
s.ye = undefined;
|
|
1173
|
+
s.q = r?.render ? EFFECT_RENDER : EFFECT_USER;
|
|
1174
|
+
s.Te = () => {
|
|
1175
|
+
if (s.ie & STATUS_ERROR) {
|
|
1176
|
+
let e = s.B;
|
|
1177
|
+
s.J.notify(s, STATUS_PENDING, 0);
|
|
1178
|
+
if (s.q === EFFECT_USER) {
|
|
1179
|
+
try {
|
|
1180
|
+
return s.Ce
|
|
1181
|
+
? s.Ce(e, () => {
|
|
1182
|
+
s.ye?.();
|
|
1183
|
+
s.ye = undefined;
|
|
1184
|
+
})
|
|
1185
|
+
: console.error(e);
|
|
1186
|
+
} catch (t) {
|
|
1187
|
+
e = t;
|
|
1020
1188
|
}
|
|
1021
1189
|
}
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
!r?.defer &&
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
onCleanup(() => o.Ie?.());
|
|
1190
|
+
if (!s.J.notify(s, STATUS_ERROR, STATUS_ERROR)) throw e;
|
|
1191
|
+
} else if (s.q === EFFECT_RENDER) s.J.notify(s, STATUS_PENDING | STATUS_ERROR, s.ie);
|
|
1192
|
+
};
|
|
1193
|
+
recompute(s, true);
|
|
1194
|
+
!r?.defer && (s.q === EFFECT_USER ? s.J.enqueue(s.q, runEffect.bind(s)) : runEffect.call(s));
|
|
1195
|
+
o = true;
|
|
1196
|
+
onCleanup(() => s.ye?.());
|
|
1030
1197
|
}
|
|
1031
1198
|
function runEffect() {
|
|
1032
|
-
if (!this.
|
|
1033
|
-
this.
|
|
1034
|
-
this.
|
|
1199
|
+
if (!this.Z || this.S & REACTIVE_DISPOSED) return;
|
|
1200
|
+
this.ye?.();
|
|
1201
|
+
this.ye = undefined;
|
|
1035
1202
|
try {
|
|
1036
|
-
this.
|
|
1203
|
+
this.ye = this.Ne(this.ne, this.Pe);
|
|
1037
1204
|
} catch (e) {
|
|
1038
|
-
if (!this.
|
|
1205
|
+
if (!this.J.notify(this, STATUS_ERROR, STATUS_ERROR)) throw e;
|
|
1039
1206
|
} finally {
|
|
1040
|
-
this.
|
|
1041
|
-
this.
|
|
1207
|
+
this.Pe = this.ne;
|
|
1208
|
+
this.Z = false;
|
|
1042
1209
|
}
|
|
1043
1210
|
}
|
|
1211
|
+
function trackedEffect(e, t) {
|
|
1212
|
+
const run = () => {
|
|
1213
|
+
if (!n.Z || n.S & REACTIVE_DISPOSED) return;
|
|
1214
|
+
n.Z = false;
|
|
1215
|
+
recompute(n);
|
|
1216
|
+
};
|
|
1217
|
+
const n = computed(
|
|
1218
|
+
() => {
|
|
1219
|
+
try {
|
|
1220
|
+
n.ye?.();
|
|
1221
|
+
n.ye = undefined;
|
|
1222
|
+
n.ye = staleValues(e) || undefined;
|
|
1223
|
+
} finally {
|
|
1224
|
+
}
|
|
1225
|
+
},
|
|
1226
|
+
undefined,
|
|
1227
|
+
{ ...t, lazy: true, pureWrite: true }
|
|
1228
|
+
);
|
|
1229
|
+
n.ye = undefined;
|
|
1230
|
+
n.Z = true;
|
|
1231
|
+
n.q = EFFECT_TRACKED;
|
|
1232
|
+
n.ee = run;
|
|
1233
|
+
n.J.enqueue(EFFECT_USER, run);
|
|
1234
|
+
onCleanup(() => n.ye?.());
|
|
1235
|
+
}
|
|
1044
1236
|
function createSignal(e, t, n) {
|
|
1045
1237
|
if (typeof e === "function") {
|
|
1046
1238
|
const i = computed(e, t, n);
|
|
@@ -1054,12 +1246,14 @@ function createMemo(e, t, n) {
|
|
|
1054
1246
|
return read.bind(null, i);
|
|
1055
1247
|
}
|
|
1056
1248
|
function createEffect(e, t, n, i) {
|
|
1057
|
-
|
|
1249
|
+
effect(e, t.effect || t, t.error, n, i);
|
|
1058
1250
|
}
|
|
1059
1251
|
function createRenderEffect(e, t, n, i) {
|
|
1060
|
-
|
|
1252
|
+
effect(e, t, undefined, n, { render: true, ...i });
|
|
1253
|
+
}
|
|
1254
|
+
function createTrackedEffect(e, t) {
|
|
1255
|
+
trackedEffect(e, t);
|
|
1061
1256
|
}
|
|
1062
|
-
function createTrackedEffect(e, t) {}
|
|
1063
1257
|
function createReaction(e, t) {
|
|
1064
1258
|
let n = undefined;
|
|
1065
1259
|
onCleanup(() => n?.());
|
|
@@ -1096,39 +1290,16 @@ function resolve(e) {
|
|
|
1096
1290
|
});
|
|
1097
1291
|
}
|
|
1098
1292
|
function createOptimistic(e, t, n) {
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
t => {
|
|
1102
|
-
const n = getOwner();
|
|
1103
|
-
const i = e(t);
|
|
1104
|
-
if (n.J & STATUS_UNINITIALIZED) return i;
|
|
1105
|
-
n.M = i;
|
|
1106
|
-
return t;
|
|
1107
|
-
},
|
|
1108
|
-
t,
|
|
1109
|
-
n
|
|
1110
|
-
);
|
|
1111
|
-
i.oe = true;
|
|
1112
|
-
return [read.bind(null, i), setSignal.bind(null, i)];
|
|
1113
|
-
}
|
|
1114
|
-
const i = signal(e, t);
|
|
1115
|
-
i.oe = true;
|
|
1116
|
-
return [
|
|
1117
|
-
read.bind(null, i),
|
|
1118
|
-
t => {
|
|
1119
|
-
i.M = e;
|
|
1120
|
-
return setSignal(i, t);
|
|
1121
|
-
}
|
|
1122
|
-
];
|
|
1293
|
+
const i = typeof e === "function" ? optimisticComputed(e, t, n) : optimisticSignal(e, t);
|
|
1294
|
+
return [read.bind(null, i), setSignal.bind(null, i)];
|
|
1123
1295
|
}
|
|
1124
1296
|
function onSettled(e) {
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
});
|
|
1297
|
+
getOwner()
|
|
1298
|
+
? createTrackedEffect(() => untrack(e))
|
|
1299
|
+
: globalQueue.enqueue(EFFECT_USER, () => {
|
|
1300
|
+
const t = e();
|
|
1301
|
+
t?.();
|
|
1302
|
+
});
|
|
1132
1303
|
}
|
|
1133
1304
|
function unwrap(e) {
|
|
1134
1305
|
return e?.[$TARGET]?.[STORE_NODE] ?? e;
|
|
@@ -1144,67 +1315,67 @@ function getAllKeys(e, t, n) {
|
|
|
1144
1315
|
function applyState(e, t, n, i) {
|
|
1145
1316
|
const r = t?.[$TARGET];
|
|
1146
1317
|
if (!r) return;
|
|
1147
|
-
const
|
|
1148
|
-
const
|
|
1318
|
+
const o = r[STORE_VALUE];
|
|
1319
|
+
const s = r[STORE_OVERRIDE];
|
|
1149
1320
|
let u = r[STORE_NODE];
|
|
1150
|
-
if (e ===
|
|
1321
|
+
if (e === o && !s) return;
|
|
1151
1322
|
(r[STORE_LOOKUP] || storeLookup).set(e, r[$PROXY]);
|
|
1152
1323
|
r[STORE_VALUE] = e;
|
|
1153
1324
|
r[STORE_OVERRIDE] = undefined;
|
|
1154
|
-
if (Array.isArray(
|
|
1325
|
+
if (Array.isArray(o)) {
|
|
1155
1326
|
let t = false;
|
|
1156
|
-
const l = getOverrideValue(
|
|
1327
|
+
const l = getOverrideValue(o, s, u, "length");
|
|
1157
1328
|
if (e.length && l && e[0] && n(e[0]) != null) {
|
|
1158
|
-
let c, a, f, E,
|
|
1329
|
+
let c, a, f, E, T, R, d, O;
|
|
1159
1330
|
for (
|
|
1160
1331
|
f = 0, E = Math.min(l, e.length);
|
|
1161
|
-
f < E && ((
|
|
1332
|
+
f < E && ((R = getOverrideValue(o, s, u, f)) === e[f] || (R && e[f] && n(R) === n(e[f])));
|
|
1162
1333
|
f++
|
|
1163
1334
|
) {
|
|
1164
|
-
applyState(e[f], wrap(
|
|
1335
|
+
applyState(e[f], wrap(R, r), n, i);
|
|
1165
1336
|
}
|
|
1166
1337
|
const S = new Array(e.length),
|
|
1167
1338
|
_ = new Map();
|
|
1168
1339
|
for (
|
|
1169
|
-
E = l - 1,
|
|
1340
|
+
E = l - 1, T = e.length - 1;
|
|
1170
1341
|
E >= f &&
|
|
1171
|
-
|
|
1172
|
-
((
|
|
1173
|
-
E--,
|
|
1342
|
+
T >= f &&
|
|
1343
|
+
((R = getOverrideValue(o, s, u, E)) === e[T] || (R && e[T] && n(R) === n(e[T])));
|
|
1344
|
+
E--, T--
|
|
1174
1345
|
) {
|
|
1175
|
-
S[
|
|
1346
|
+
S[T] = R;
|
|
1176
1347
|
}
|
|
1177
|
-
if (f >
|
|
1178
|
-
for (a = f; a <=
|
|
1348
|
+
if (f > T || f > E) {
|
|
1349
|
+
for (a = f; a <= T; a++) {
|
|
1179
1350
|
t = true;
|
|
1180
1351
|
r[STORE_NODE][a] && setSignal(r[STORE_NODE][a], wrap(e[a], r));
|
|
1181
1352
|
}
|
|
1182
1353
|
for (; a < e.length; a++) {
|
|
1183
1354
|
t = true;
|
|
1184
|
-
const
|
|
1185
|
-
r[STORE_NODE][a] && setSignal(r[STORE_NODE][a],
|
|
1186
|
-
applyState(e[a],
|
|
1355
|
+
const o = wrap(S[a], r);
|
|
1356
|
+
r[STORE_NODE][a] && setSignal(r[STORE_NODE][a], o);
|
|
1357
|
+
applyState(e[a], o, n, i);
|
|
1187
1358
|
}
|
|
1188
1359
|
t && r[STORE_NODE][$TRACK] && setSignal(r[STORE_NODE][$TRACK], void 0);
|
|
1189
1360
|
l !== e.length && r[STORE_NODE].length && setSignal(r[STORE_NODE].length, e.length);
|
|
1190
1361
|
return;
|
|
1191
1362
|
}
|
|
1192
|
-
|
|
1193
|
-
for (a =
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
c = _.get(
|
|
1197
|
-
|
|
1198
|
-
_.set(
|
|
1363
|
+
d = new Array(T + 1);
|
|
1364
|
+
for (a = T; a >= f; a--) {
|
|
1365
|
+
R = e[a];
|
|
1366
|
+
O = R ? n(R) : R;
|
|
1367
|
+
c = _.get(O);
|
|
1368
|
+
d[a] = c === undefined ? -1 : c;
|
|
1369
|
+
_.set(O, a);
|
|
1199
1370
|
}
|
|
1200
1371
|
for (c = f; c <= E; c++) {
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
a = _.get(
|
|
1372
|
+
R = getOverrideValue(o, s, u, c);
|
|
1373
|
+
O = R ? n(R) : R;
|
|
1374
|
+
a = _.get(O);
|
|
1204
1375
|
if (a !== undefined && a !== -1) {
|
|
1205
|
-
S[a] =
|
|
1206
|
-
a =
|
|
1207
|
-
_.set(
|
|
1376
|
+
S[a] = R;
|
|
1377
|
+
a = d[a];
|
|
1378
|
+
_.set(O, a);
|
|
1208
1379
|
}
|
|
1209
1380
|
}
|
|
1210
1381
|
for (a = f; a < e.length; a++) {
|
|
@@ -1217,7 +1388,7 @@ function applyState(e, t, n, i) {
|
|
|
1217
1388
|
if (f < e.length) t = true;
|
|
1218
1389
|
} else if (e.length) {
|
|
1219
1390
|
for (let t = 0, l = e.length; t < l; t++) {
|
|
1220
|
-
const l = getOverrideValue(
|
|
1391
|
+
const l = getOverrideValue(o, s, u, t);
|
|
1221
1392
|
isWrappable(l)
|
|
1222
1393
|
? applyState(e[t], wrap(l, r), n, i)
|
|
1223
1394
|
: r[STORE_NODE][t] && setSignal(r[STORE_NODE][t], e[t]);
|
|
@@ -1232,17 +1403,17 @@ function applyState(e, t, n, i) {
|
|
|
1232
1403
|
}
|
|
1233
1404
|
if (u) {
|
|
1234
1405
|
const t = u[$TRACK];
|
|
1235
|
-
const l = t || i ? getAllKeys(
|
|
1406
|
+
const l = t || i ? getAllKeys(o, s, e) : Object.keys(u);
|
|
1236
1407
|
for (let c = 0, a = l.length; c < a; c++) {
|
|
1237
1408
|
const a = l[c];
|
|
1238
1409
|
const f = u[a];
|
|
1239
|
-
const E = unwrap(getOverrideValue(
|
|
1240
|
-
let
|
|
1241
|
-
if (E ===
|
|
1242
|
-
if (!E || !isWrappable(E) || (n(E) != null && n(E) !== n(
|
|
1410
|
+
const E = unwrap(getOverrideValue(o, s, u, a));
|
|
1411
|
+
let T = unwrap(e[a]);
|
|
1412
|
+
if (E === T) continue;
|
|
1413
|
+
if (!E || !isWrappable(E) || (n(E) != null && n(E) !== n(T))) {
|
|
1243
1414
|
t && setSignal(t, void 0);
|
|
1244
|
-
f && setSignal(f, isWrappable(
|
|
1245
|
-
} else applyState(
|
|
1415
|
+
f && setSignal(f, isWrappable(T) ? wrap(T, r) : T);
|
|
1416
|
+
} else applyState(T, wrap(E, r), n, i);
|
|
1246
1417
|
}
|
|
1247
1418
|
}
|
|
1248
1419
|
if ((u = r[STORE_HAS])) {
|
|
@@ -1257,8 +1428,8 @@ function reconcile(e, t, n = false) {
|
|
|
1257
1428
|
return i => {
|
|
1258
1429
|
if (i == null) throw new Error("Cannot reconcile null or undefined state");
|
|
1259
1430
|
const r = typeof t === "string" ? e => e[t] : t;
|
|
1260
|
-
const
|
|
1261
|
-
if (
|
|
1431
|
+
const o = r(i);
|
|
1432
|
+
if (o !== undefined && r(e) !== r(i))
|
|
1262
1433
|
throw new Error("Cannot reconcile states with different identity");
|
|
1263
1434
|
applyState(e, i, r, n);
|
|
1264
1435
|
};
|
|
@@ -1283,19 +1454,19 @@ function createProjectionInternal(e, t = {}, n) {
|
|
|
1283
1454
|
r.set(e, t);
|
|
1284
1455
|
return t;
|
|
1285
1456
|
};
|
|
1286
|
-
const
|
|
1457
|
+
const o = wrapProjection(t);
|
|
1287
1458
|
i = computed(() => {
|
|
1288
1459
|
const t = getOwner();
|
|
1289
|
-
storeSetter(new Proxy(
|
|
1460
|
+
storeSetter(new Proxy(o, writeTraps), i => {
|
|
1290
1461
|
const r = handleAsync(t, e(i), e => {
|
|
1291
|
-
e !==
|
|
1462
|
+
e !== i && e !== undefined && storeSetter(o, reconcile(e, n?.key || "id", n?.all));
|
|
1292
1463
|
setSignal(t, undefined);
|
|
1293
1464
|
});
|
|
1294
|
-
r !==
|
|
1465
|
+
r !== i && r !== undefined && reconcile(r, n?.key || "id", n?.all)(o);
|
|
1295
1466
|
});
|
|
1296
1467
|
});
|
|
1297
|
-
i.
|
|
1298
|
-
return { store:
|
|
1468
|
+
i.Se = true;
|
|
1469
|
+
return { store: o, node: i };
|
|
1299
1470
|
}
|
|
1300
1471
|
function createProjection(e, t = {}, n) {
|
|
1301
1472
|
return createProjectionInternal(e, t, n).store;
|
|
@@ -1304,28 +1475,34 @@ const writeTraps = {
|
|
|
1304
1475
|
get(e, t) {
|
|
1305
1476
|
let n;
|
|
1306
1477
|
setWriteOverride(true);
|
|
1478
|
+
setProjectionWriteActive(true);
|
|
1307
1479
|
try {
|
|
1308
1480
|
n = e[t];
|
|
1309
1481
|
} finally {
|
|
1310
1482
|
setWriteOverride(false);
|
|
1483
|
+
setProjectionWriteActive(false);
|
|
1311
1484
|
}
|
|
1312
1485
|
return typeof n === "object" && n !== null ? new Proxy(n, writeTraps) : n;
|
|
1313
1486
|
},
|
|
1314
1487
|
set(e, t, n) {
|
|
1315
1488
|
setWriteOverride(true);
|
|
1489
|
+
setProjectionWriteActive(true);
|
|
1316
1490
|
try {
|
|
1317
1491
|
e[t] = n;
|
|
1318
1492
|
} finally {
|
|
1319
1493
|
setWriteOverride(false);
|
|
1494
|
+
setProjectionWriteActive(false);
|
|
1320
1495
|
}
|
|
1321
1496
|
return true;
|
|
1322
1497
|
},
|
|
1323
1498
|
deleteProperty(e, t) {
|
|
1324
1499
|
setWriteOverride(true);
|
|
1500
|
+
setProjectionWriteActive(true);
|
|
1325
1501
|
try {
|
|
1326
1502
|
delete e[t];
|
|
1327
1503
|
} finally {
|
|
1328
1504
|
setWriteOverride(false);
|
|
1505
|
+
setProjectionWriteActive(false);
|
|
1329
1506
|
}
|
|
1330
1507
|
return true;
|
|
1331
1508
|
}
|
|
@@ -1338,11 +1515,13 @@ const $TRACK = Symbol(0),
|
|
|
1338
1515
|
const PARENTS = new WeakMap();
|
|
1339
1516
|
const STORE_VALUE = "v",
|
|
1340
1517
|
STORE_OVERRIDE = "o",
|
|
1518
|
+
STORE_OPTIMISTIC_OVERRIDE = "x",
|
|
1341
1519
|
STORE_NODE = "n",
|
|
1342
1520
|
STORE_HAS = "h",
|
|
1343
1521
|
STORE_WRAP = "w",
|
|
1344
1522
|
STORE_LOOKUP = "l",
|
|
1345
|
-
STORE_FIREWALL = "f"
|
|
1523
|
+
STORE_FIREWALL = "f",
|
|
1524
|
+
STORE_OPTIMISTIC = "p";
|
|
1346
1525
|
function createStoreProxy(e, t = storeTraps, n) {
|
|
1347
1526
|
let i;
|
|
1348
1527
|
if (Array.isArray(e)) {
|
|
@@ -1374,9 +1553,9 @@ function getNodes(e, t) {
|
|
|
1374
1553
|
if (!n) e[t] = n = Object.create(null);
|
|
1375
1554
|
return n;
|
|
1376
1555
|
}
|
|
1377
|
-
function getNode(e, t, n, i, r = isEqual) {
|
|
1556
|
+
function getNode(e, t, n, i, r = isEqual, o) {
|
|
1378
1557
|
if (e[t]) return e[t];
|
|
1379
|
-
|
|
1558
|
+
const s = signal(
|
|
1380
1559
|
n,
|
|
1381
1560
|
{
|
|
1382
1561
|
equals: r,
|
|
@@ -1385,17 +1564,22 @@ function getNode(e, t, n, i, r = isEqual) {
|
|
|
1385
1564
|
}
|
|
1386
1565
|
},
|
|
1387
1566
|
i
|
|
1388
|
-
)
|
|
1567
|
+
);
|
|
1568
|
+
if (o) s.le = true;
|
|
1569
|
+
return (e[t] = s);
|
|
1389
1570
|
}
|
|
1390
1571
|
function trackSelf(e, t = $TRACK) {
|
|
1391
|
-
getObserver() &&
|
|
1572
|
+
getObserver() &&
|
|
1573
|
+
read(
|
|
1574
|
+
getNode(getNodes(e, STORE_NODE), t, undefined, e[STORE_FIREWALL], false, e[STORE_OPTIMISTIC])
|
|
1575
|
+
);
|
|
1392
1576
|
}
|
|
1393
1577
|
function getKeys(e, t, n = true) {
|
|
1394
1578
|
const i = untrack(() => (n ? Object.keys(e) : Reflect.ownKeys(e)));
|
|
1395
1579
|
if (!t) return i;
|
|
1396
1580
|
const r = new Set(i);
|
|
1397
|
-
const
|
|
1398
|
-
for (const e of
|
|
1581
|
+
const o = Reflect.ownKeys(t);
|
|
1582
|
+
for (const e of o) {
|
|
1399
1583
|
if (t[e] !== $DELETED) r.add(e);
|
|
1400
1584
|
else r.delete(e);
|
|
1401
1585
|
}
|
|
@@ -1421,104 +1605,170 @@ const storeTraps = {
|
|
|
1421
1605
|
}
|
|
1422
1606
|
const i = getNodes(e, STORE_NODE);
|
|
1423
1607
|
const r = i[t];
|
|
1424
|
-
const
|
|
1425
|
-
const
|
|
1426
|
-
const u =
|
|
1608
|
+
const o = e[STORE_OPTIMISTIC_OVERRIDE] && t in e[STORE_OPTIMISTIC_OVERRIDE];
|
|
1609
|
+
const s = o || (e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE]);
|
|
1610
|
+
const u = !!e[STORE_VALUE][$TARGET];
|
|
1611
|
+
const l = o
|
|
1612
|
+
? e[STORE_OPTIMISTIC_OVERRIDE]
|
|
1613
|
+
: e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE]
|
|
1614
|
+
? e[STORE_OVERRIDE]
|
|
1615
|
+
: e[STORE_VALUE];
|
|
1427
1616
|
if (!r) {
|
|
1428
|
-
const e = Object.getOwnPropertyDescriptor(
|
|
1617
|
+
const e = Object.getOwnPropertyDescriptor(l, t);
|
|
1429
1618
|
if (e && e.get) return e.get.call(n);
|
|
1430
1619
|
}
|
|
1431
1620
|
if (writeOnly(n)) {
|
|
1432
|
-
let n = r && (s || !
|
|
1621
|
+
let n = r && (s || !u) ? (r.te !== NOT_PENDING ? (r.le ? r.ne : r.te) : r.ne) : l[t];
|
|
1433
1622
|
n === $DELETED && (n = undefined);
|
|
1434
1623
|
if (!isWrappable(n)) return n;
|
|
1435
1624
|
const i = wrap(n, e);
|
|
1436
1625
|
Writing?.add(i);
|
|
1437
1626
|
return i;
|
|
1438
1627
|
}
|
|
1439
|
-
let
|
|
1440
|
-
|
|
1628
|
+
let c = r ? (s || !u ? read(i[t]) : (read(i[t]), l[t])) : l[t];
|
|
1629
|
+
c === $DELETED && (c = undefined);
|
|
1441
1630
|
if (!r) {
|
|
1442
|
-
if (!s && typeof
|
|
1631
|
+
if (!s && typeof c === "function" && !l.hasOwnProperty(t)) {
|
|
1443
1632
|
let t;
|
|
1444
1633
|
return !Array.isArray(e[STORE_VALUE]) &&
|
|
1445
1634
|
(t = Object.getPrototypeOf(e[STORE_VALUE])) &&
|
|
1446
1635
|
t !== Object.prototype
|
|
1447
|
-
?
|
|
1448
|
-
:
|
|
1636
|
+
? c.bind(l)
|
|
1637
|
+
: c;
|
|
1449
1638
|
} else if (getObserver()) {
|
|
1450
|
-
return read(
|
|
1639
|
+
return read(
|
|
1640
|
+
getNode(
|
|
1641
|
+
i,
|
|
1642
|
+
t,
|
|
1643
|
+
isWrappable(c) ? wrap(c, e) : c,
|
|
1644
|
+
e[STORE_FIREWALL],
|
|
1645
|
+
isEqual,
|
|
1646
|
+
e[STORE_OPTIMISTIC]
|
|
1647
|
+
)
|
|
1648
|
+
);
|
|
1451
1649
|
}
|
|
1452
1650
|
}
|
|
1453
|
-
return isWrappable(
|
|
1651
|
+
return isWrappable(c) ? wrap(c, e) : c;
|
|
1454
1652
|
},
|
|
1455
1653
|
has(e, t) {
|
|
1456
1654
|
if (t === $PROXY || t === $TRACK || t === "__proto__") return true;
|
|
1457
1655
|
const n =
|
|
1458
|
-
e[
|
|
1459
|
-
? e[
|
|
1460
|
-
: t in e[
|
|
1461
|
-
|
|
1656
|
+
e[STORE_OPTIMISTIC_OVERRIDE] && t in e[STORE_OPTIMISTIC_OVERRIDE]
|
|
1657
|
+
? e[STORE_OPTIMISTIC_OVERRIDE][t] !== $DELETED
|
|
1658
|
+
: e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE]
|
|
1659
|
+
? e[STORE_OVERRIDE][t] !== $DELETED
|
|
1660
|
+
: t in e[STORE_VALUE];
|
|
1661
|
+
getObserver() &&
|
|
1662
|
+
read(getNode(getNodes(e, STORE_HAS), t, n, e[STORE_FIREWALL], isEqual, e[STORE_OPTIMISTIC]));
|
|
1462
1663
|
return n;
|
|
1463
1664
|
},
|
|
1464
1665
|
set(e, t, n) {
|
|
1465
1666
|
const i = e[$PROXY];
|
|
1466
1667
|
if (writeOnly(i)) {
|
|
1668
|
+
if (e[STORE_OPTIMISTIC]) {
|
|
1669
|
+
const t = e[STORE_FIREWALL];
|
|
1670
|
+
if (t?.X) {
|
|
1671
|
+
globalQueue.initTransition(t.X);
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1467
1674
|
untrack(() => {
|
|
1468
1675
|
const r = e[STORE_VALUE];
|
|
1469
|
-
const
|
|
1470
|
-
const
|
|
1471
|
-
const u =
|
|
1472
|
-
if (
|
|
1473
|
-
const l =
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1676
|
+
const o = r[t];
|
|
1677
|
+
const s = e[STORE_OPTIMISTIC] && !projectionWriteActive;
|
|
1678
|
+
const u = s ? STORE_OPTIMISTIC_OVERRIDE : STORE_OVERRIDE;
|
|
1679
|
+
if (s) trackOptimisticStore(i);
|
|
1680
|
+
const l =
|
|
1681
|
+
e[STORE_OPTIMISTIC_OVERRIDE] && t in e[STORE_OPTIMISTIC_OVERRIDE]
|
|
1682
|
+
? e[STORE_OPTIMISTIC_OVERRIDE][t]
|
|
1683
|
+
: e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE]
|
|
1684
|
+
? e[STORE_OVERRIDE][t]
|
|
1685
|
+
: o;
|
|
1686
|
+
const c = n?.[$TARGET]?.[STORE_VALUE] ?? n;
|
|
1687
|
+
if (l === c) return true;
|
|
1688
|
+
const a = e[STORE_OPTIMISTIC_OVERRIDE]?.length || e[STORE_OVERRIDE]?.length || r.length;
|
|
1689
|
+
if (c !== undefined && c === o) delete e[u][t];
|
|
1690
|
+
else (e[u] || (e[u] = Object.create(null)))[t] = c;
|
|
1691
|
+
const f = isWrappable(c);
|
|
1692
|
+
if (isWrappable(l)) {
|
|
1693
|
+
const e = PARENTS.get(l);
|
|
1694
|
+
e && (e instanceof Set ? e.delete(i) : PARENTS.delete(l));
|
|
1480
1695
|
}
|
|
1481
|
-
if (recursivelyNotify(i, storeLookup) &&
|
|
1696
|
+
if (recursivelyNotify(i, storeLookup) && f) recursivelyAddParent(c, i);
|
|
1482
1697
|
e[STORE_HAS]?.[t] && setSignal(e[STORE_HAS][t], true);
|
|
1483
|
-
const
|
|
1484
|
-
|
|
1698
|
+
const E = getNodes(e, STORE_NODE);
|
|
1699
|
+
E[t] && setSignal(E[t], () => (f ? wrap(c, e) : c));
|
|
1485
1700
|
if (Array.isArray(r)) {
|
|
1486
|
-
|
|
1487
|
-
|
|
1701
|
+
if (t === "length") {
|
|
1702
|
+
E.length && setSignal(E.length, c);
|
|
1703
|
+
} else {
|
|
1704
|
+
const e = parseInt(t) + 1;
|
|
1705
|
+
if (e > a) E.length && setSignal(E.length, e);
|
|
1706
|
+
}
|
|
1488
1707
|
}
|
|
1489
|
-
|
|
1708
|
+
E[$TRACK] && setSignal(E[$TRACK], undefined);
|
|
1490
1709
|
});
|
|
1491
1710
|
}
|
|
1492
1711
|
return true;
|
|
1493
1712
|
},
|
|
1494
1713
|
deleteProperty(e, t) {
|
|
1495
|
-
|
|
1714
|
+
const n = e[STORE_OPTIMISTIC_OVERRIDE]?.[t] === $DELETED;
|
|
1715
|
+
const i = e[STORE_OVERRIDE]?.[t] === $DELETED;
|
|
1716
|
+
if (writeOnly(e[$PROXY]) && !n && !i) {
|
|
1496
1717
|
untrack(() => {
|
|
1497
|
-
const n =
|
|
1498
|
-
|
|
1499
|
-
if (
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1718
|
+
const n = e[STORE_OPTIMISTIC] && !projectionWriteActive;
|
|
1719
|
+
const i = n ? STORE_OPTIMISTIC_OVERRIDE : STORE_OVERRIDE;
|
|
1720
|
+
if (n) trackOptimisticStore(e[$PROXY]);
|
|
1721
|
+
const r =
|
|
1722
|
+
e[STORE_OPTIMISTIC_OVERRIDE] && t in e[STORE_OPTIMISTIC_OVERRIDE]
|
|
1723
|
+
? e[STORE_OPTIMISTIC_OVERRIDE][t]
|
|
1724
|
+
: e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE]
|
|
1725
|
+
? e[STORE_OVERRIDE][t]
|
|
1726
|
+
: e[STORE_VALUE][t];
|
|
1727
|
+
if (t in e[STORE_VALUE] || (e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE])) {
|
|
1728
|
+
(e[i] || (e[i] = Object.create(null)))[t] = $DELETED;
|
|
1729
|
+
} else if (e[i] && t in e[i]) {
|
|
1730
|
+
delete e[i][t];
|
|
1503
1731
|
} else return true;
|
|
1504
|
-
if (isWrappable(
|
|
1505
|
-
const t = PARENTS.get(
|
|
1506
|
-
t && (t instanceof Set ? t.delete(e) : PARENTS.delete(
|
|
1732
|
+
if (isWrappable(r)) {
|
|
1733
|
+
const t = PARENTS.get(r);
|
|
1734
|
+
t && (t instanceof Set ? t.delete(e) : PARENTS.delete(r));
|
|
1507
1735
|
}
|
|
1508
1736
|
if (e[STORE_HAS]?.[t]) setSignal(e[STORE_HAS][t], false);
|
|
1509
|
-
const
|
|
1510
|
-
|
|
1511
|
-
|
|
1737
|
+
const o = getNodes(e, STORE_NODE);
|
|
1738
|
+
o[t] && setSignal(o[t], undefined);
|
|
1739
|
+
o[$TRACK] && setSignal(o[$TRACK], undefined);
|
|
1512
1740
|
});
|
|
1513
1741
|
}
|
|
1514
1742
|
return true;
|
|
1515
1743
|
},
|
|
1516
1744
|
ownKeys(e) {
|
|
1517
1745
|
trackSelf(e);
|
|
1518
|
-
|
|
1746
|
+
let t = getKeys(e[STORE_VALUE], e[STORE_OVERRIDE], false);
|
|
1747
|
+
if (e[STORE_OPTIMISTIC_OVERRIDE]) {
|
|
1748
|
+
const n = new Set(t);
|
|
1749
|
+
for (const t of Reflect.ownKeys(e[STORE_OPTIMISTIC_OVERRIDE])) {
|
|
1750
|
+
if (e[STORE_OPTIMISTIC_OVERRIDE][t] !== $DELETED) n.add(t);
|
|
1751
|
+
else n.delete(t);
|
|
1752
|
+
}
|
|
1753
|
+
t = Array.from(n);
|
|
1754
|
+
}
|
|
1755
|
+
return t;
|
|
1519
1756
|
},
|
|
1520
1757
|
getOwnPropertyDescriptor(e, t) {
|
|
1521
1758
|
if (t === $PROXY) return { value: e[$PROXY], writable: true, configurable: true };
|
|
1759
|
+
if (e[STORE_OPTIMISTIC_OVERRIDE] && t in e[STORE_OPTIMISTIC_OVERRIDE]) {
|
|
1760
|
+
if (e[STORE_OPTIMISTIC_OVERRIDE][t] === $DELETED) return undefined;
|
|
1761
|
+
const n = getPropertyDescriptor(e[STORE_VALUE], e[STORE_OVERRIDE], t);
|
|
1762
|
+
if (n) {
|
|
1763
|
+
return { ...n, value: e[STORE_OPTIMISTIC_OVERRIDE][t] };
|
|
1764
|
+
}
|
|
1765
|
+
return {
|
|
1766
|
+
value: e[STORE_OPTIMISTIC_OVERRIDE][t],
|
|
1767
|
+
writable: true,
|
|
1768
|
+
enumerable: true,
|
|
1769
|
+
configurable: true
|
|
1770
|
+
};
|
|
1771
|
+
}
|
|
1522
1772
|
return getPropertyDescriptor(e[STORE_VALUE], e[STORE_OVERRIDE], t);
|
|
1523
1773
|
},
|
|
1524
1774
|
getPrototypeOf(e) {
|
|
@@ -1597,8 +1847,8 @@ function recursivelyAddParent(e, t) {
|
|
|
1597
1847
|
const t = getKeys(e, n);
|
|
1598
1848
|
for (let i = 0; i < t.length; i++) {
|
|
1599
1849
|
const r = t[i];
|
|
1600
|
-
const
|
|
1601
|
-
isWrappable(
|
|
1850
|
+
const o = n && r in n ? n[r] : e[r];
|
|
1851
|
+
isWrappable(o) && recursivelyAddParent(o, e);
|
|
1602
1852
|
}
|
|
1603
1853
|
}
|
|
1604
1854
|
}
|
|
@@ -1607,19 +1857,88 @@ function deep(e) {
|
|
|
1607
1857
|
return e[$DEEP];
|
|
1608
1858
|
}
|
|
1609
1859
|
function createOptimisticStore(e, t, n) {
|
|
1610
|
-
|
|
1860
|
+
GlobalQueue.Y ||= clearOptimisticStore;
|
|
1861
|
+
const i = typeof e === "function";
|
|
1862
|
+
const r = (i ? t : e) ?? {};
|
|
1863
|
+
const o = i ? e : undefined;
|
|
1864
|
+
const { store: s } = createOptimisticProjectionInternal(o, r, n);
|
|
1865
|
+
return [s, e => storeSetter(s, e)];
|
|
1866
|
+
}
|
|
1867
|
+
function clearOptimisticStore(e) {
|
|
1868
|
+
const t = e[$TARGET];
|
|
1869
|
+
if (!t || !t[STORE_OPTIMISTIC_OVERRIDE]) return;
|
|
1870
|
+
const n = t[STORE_OPTIMISTIC_OVERRIDE];
|
|
1871
|
+
const i = t[STORE_NODE];
|
|
1872
|
+
if (i) {
|
|
1873
|
+
for (const e of Reflect.ownKeys(n)) {
|
|
1874
|
+
if (i[e]) {
|
|
1875
|
+
const n =
|
|
1876
|
+
t[STORE_OVERRIDE] && e in t[STORE_OVERRIDE] ? t[STORE_OVERRIDE][e] : t[STORE_VALUE][e];
|
|
1877
|
+
const r = n === $DELETED ? undefined : n;
|
|
1878
|
+
setSignal(i[e], isWrappable(r) ? wrap(r, t) : r);
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1881
|
+
i[$TRACK] && setSignal(i[$TRACK], undefined);
|
|
1882
|
+
}
|
|
1883
|
+
delete t[STORE_OPTIMISTIC_OVERRIDE];
|
|
1884
|
+
}
|
|
1885
|
+
function createOptimisticProjectionInternal(e, t = {}, n) {
|
|
1886
|
+
let i;
|
|
1887
|
+
const r = new WeakMap();
|
|
1888
|
+
const wrapper = e => {
|
|
1889
|
+
e[STORE_WRAP] = wrapProjection;
|
|
1890
|
+
e[STORE_LOOKUP] = r;
|
|
1891
|
+
e[STORE_OPTIMISTIC] = true;
|
|
1892
|
+
Object.defineProperty(e, STORE_FIREWALL, {
|
|
1893
|
+
get() {
|
|
1894
|
+
return i;
|
|
1895
|
+
},
|
|
1896
|
+
configurable: true
|
|
1897
|
+
});
|
|
1898
|
+
};
|
|
1899
|
+
const wrapProjection = e => {
|
|
1900
|
+
if (r.has(e)) return r.get(e);
|
|
1901
|
+
if (e[$TARGET]?.[STORE_WRAP] === wrapProjection) return e;
|
|
1902
|
+
const t = createStoreProxy(e, storeTraps, wrapper);
|
|
1903
|
+
r.set(e, t);
|
|
1904
|
+
return t;
|
|
1905
|
+
};
|
|
1906
|
+
const o = wrapProjection(t);
|
|
1907
|
+
if (e) {
|
|
1908
|
+
i = computed(() => {
|
|
1909
|
+
const t = getOwner();
|
|
1910
|
+
setProjectionWriteActive(true);
|
|
1911
|
+
try {
|
|
1912
|
+
storeSetter(new Proxy(o, writeTraps), i => {
|
|
1913
|
+
const r = handleAsync(t, e(i), e => {
|
|
1914
|
+
setProjectionWriteActive(true);
|
|
1915
|
+
try {
|
|
1916
|
+
e !== i && e !== undefined && storeSetter(o, reconcile(e, n?.key || "id", n?.all));
|
|
1917
|
+
} finally {
|
|
1918
|
+
setProjectionWriteActive(false);
|
|
1919
|
+
}
|
|
1920
|
+
});
|
|
1921
|
+
r !== i && r !== undefined && reconcile(r, n?.key || "id", n?.all)(o);
|
|
1922
|
+
});
|
|
1923
|
+
} finally {
|
|
1924
|
+
setProjectionWriteActive(false);
|
|
1925
|
+
}
|
|
1926
|
+
});
|
|
1927
|
+
i.Se = true;
|
|
1928
|
+
}
|
|
1929
|
+
return { store: o, node: i };
|
|
1611
1930
|
}
|
|
1612
1931
|
function snapshot(e, t, n) {
|
|
1613
|
-
let i, r,
|
|
1932
|
+
let i, r, o, s, u, l;
|
|
1614
1933
|
if (!isWrappable(e)) return e;
|
|
1615
1934
|
if (t && t.has(e)) return t.get(e);
|
|
1616
1935
|
if (!t) t = new Map();
|
|
1617
1936
|
if ((i = e[$TARGET] || n?.get(e)?.[$TARGET])) {
|
|
1618
|
-
|
|
1937
|
+
o = i[STORE_OVERRIDE];
|
|
1619
1938
|
r = Array.isArray(i[STORE_VALUE]);
|
|
1620
1939
|
t.set(
|
|
1621
1940
|
e,
|
|
1622
|
-
|
|
1941
|
+
o ? (s = r ? [] : Object.create(Object.getPrototypeOf(i[STORE_VALUE]))) : i[STORE_VALUE]
|
|
1623
1942
|
);
|
|
1624
1943
|
e = i[STORE_VALUE];
|
|
1625
1944
|
n = storeLookup;
|
|
@@ -1628,32 +1947,32 @@ function snapshot(e, t, n) {
|
|
|
1628
1947
|
t.set(e, e);
|
|
1629
1948
|
}
|
|
1630
1949
|
if (r) {
|
|
1631
|
-
const i =
|
|
1950
|
+
const i = o?.length || e.length;
|
|
1632
1951
|
for (let r = 0; r < i; r++) {
|
|
1633
|
-
l =
|
|
1952
|
+
l = o && r in o ? o[r] : e[r];
|
|
1634
1953
|
if (l === $DELETED) continue;
|
|
1635
|
-
if ((u = snapshot(l, t, n)) !== l ||
|
|
1636
|
-
if (!
|
|
1637
|
-
|
|
1954
|
+
if ((u = snapshot(l, t, n)) !== l || s) {
|
|
1955
|
+
if (!s) t.set(e, (s = [...e]));
|
|
1956
|
+
s[r] = u;
|
|
1638
1957
|
}
|
|
1639
1958
|
}
|
|
1640
1959
|
} else {
|
|
1641
|
-
const i = getKeys(e,
|
|
1960
|
+
const i = getKeys(e, o);
|
|
1642
1961
|
for (let r = 0, c = i.length; r < c; r++) {
|
|
1643
1962
|
let c = i[r];
|
|
1644
|
-
const a = getPropertyDescriptor(e,
|
|
1963
|
+
const a = getPropertyDescriptor(e, o, c);
|
|
1645
1964
|
if (a.get) continue;
|
|
1646
|
-
l =
|
|
1647
|
-
if ((u = snapshot(l, t, n)) !== e[c] ||
|
|
1648
|
-
if (!
|
|
1649
|
-
|
|
1650
|
-
Object.assign(
|
|
1965
|
+
l = o && c in o ? o[c] : e[c];
|
|
1966
|
+
if ((u = snapshot(l, t, n)) !== e[c] || s) {
|
|
1967
|
+
if (!s) {
|
|
1968
|
+
s = Object.create(Object.getPrototypeOf(e));
|
|
1969
|
+
Object.assign(s, e);
|
|
1651
1970
|
}
|
|
1652
|
-
|
|
1971
|
+
s[c] = u;
|
|
1653
1972
|
}
|
|
1654
1973
|
}
|
|
1655
1974
|
}
|
|
1656
|
-
return
|
|
1975
|
+
return s || e;
|
|
1657
1976
|
}
|
|
1658
1977
|
function trueFn() {
|
|
1659
1978
|
return true;
|
|
@@ -1695,8 +2014,8 @@ function merge(...e) {
|
|
|
1695
2014
|
for (let i = 0; i < e.length; i++) {
|
|
1696
2015
|
const r = e[i];
|
|
1697
2016
|
t = t || (!!r && $PROXY in r);
|
|
1698
|
-
const
|
|
1699
|
-
if (
|
|
2017
|
+
const o = !!r && r[$SOURCES];
|
|
2018
|
+
if (o) n.push(...o);
|
|
1700
2019
|
else n.push(typeof r === "function" ? ((t = true), createMemo(r)) : r);
|
|
1701
2020
|
}
|
|
1702
2021
|
if (SUPPORTS_PROXY && t) {
|
|
@@ -1726,35 +2045,35 @@ function merge(...e) {
|
|
|
1726
2045
|
}
|
|
1727
2046
|
const i = Object.create(null);
|
|
1728
2047
|
let r = false;
|
|
1729
|
-
let
|
|
1730
|
-
for (let e =
|
|
2048
|
+
let o = n.length - 1;
|
|
2049
|
+
for (let e = o; e >= 0; e--) {
|
|
1731
2050
|
const t = n[e];
|
|
1732
2051
|
if (!t) {
|
|
1733
|
-
e ===
|
|
2052
|
+
e === o && o--;
|
|
1734
2053
|
continue;
|
|
1735
2054
|
}
|
|
1736
|
-
const
|
|
1737
|
-
for (let n =
|
|
1738
|
-
const u =
|
|
2055
|
+
const s = Object.getOwnPropertyNames(t);
|
|
2056
|
+
for (let n = s.length - 1; n >= 0; n--) {
|
|
2057
|
+
const u = s[n];
|
|
1739
2058
|
if (u === "__proto__" || u === "constructor") continue;
|
|
1740
2059
|
if (!i[u]) {
|
|
1741
|
-
r = r || e !==
|
|
2060
|
+
r = r || e !== o;
|
|
1742
2061
|
const n = Object.getOwnPropertyDescriptor(t, u);
|
|
1743
2062
|
i[u] = n.get ? { enumerable: true, configurable: true, get: n.get.bind(t) } : n;
|
|
1744
2063
|
}
|
|
1745
2064
|
}
|
|
1746
2065
|
}
|
|
1747
|
-
if (!r) return n[
|
|
1748
|
-
const
|
|
2066
|
+
if (!r) return n[o];
|
|
2067
|
+
const s = {};
|
|
1749
2068
|
const u = Object.keys(i);
|
|
1750
2069
|
for (let e = u.length - 1; e >= 0; e--) {
|
|
1751
2070
|
const t = u[e],
|
|
1752
2071
|
n = i[t];
|
|
1753
|
-
if (n.get) Object.defineProperty(
|
|
1754
|
-
else
|
|
2072
|
+
if (n.get) Object.defineProperty(s, t, n);
|
|
2073
|
+
else s[t] = n.value;
|
|
1755
2074
|
}
|
|
1756
|
-
|
|
1757
|
-
return
|
|
2075
|
+
s[$SOURCES] = n;
|
|
2076
|
+
return s;
|
|
1758
2077
|
}
|
|
1759
2078
|
function omit(e, ...t) {
|
|
1760
2079
|
const n = new Set(t);
|
|
@@ -1789,247 +2108,241 @@ function mapArray(e, t, n) {
|
|
|
1789
2108
|
const i = typeof n?.keyed === "function" ? n.keyed : undefined;
|
|
1790
2109
|
return createMemo(
|
|
1791
2110
|
updateKeyedMap.bind({
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
2111
|
+
De: createOwner(),
|
|
2112
|
+
we: 0,
|
|
2113
|
+
be: e,
|
|
2114
|
+
ve: [],
|
|
2115
|
+
Ve: t,
|
|
2116
|
+
me: [],
|
|
2117
|
+
Ue: [],
|
|
2118
|
+
ke: i,
|
|
2119
|
+
We: i || n?.keyed === false ? [] : undefined,
|
|
2120
|
+
Qe: t.length > 1 ? [] : undefined,
|
|
2121
|
+
xe: n?.fallback
|
|
1803
2122
|
})
|
|
1804
2123
|
);
|
|
1805
2124
|
}
|
|
1806
2125
|
const pureOptions = { pureWrite: true };
|
|
1807
2126
|
function updateKeyedMap() {
|
|
1808
|
-
const e = this.
|
|
2127
|
+
const e = this.be() || [],
|
|
1809
2128
|
t = e.length;
|
|
1810
2129
|
e[$TRACK];
|
|
1811
|
-
runWithOwner(this.
|
|
2130
|
+
runWithOwner(this.De, () => {
|
|
1812
2131
|
let n,
|
|
1813
2132
|
i,
|
|
1814
|
-
r = this.
|
|
2133
|
+
r = this.We
|
|
1815
2134
|
? () => {
|
|
1816
|
-
this.
|
|
1817
|
-
this.
|
|
1818
|
-
return this.
|
|
1819
|
-
read.bind(null, this.
|
|
1820
|
-
this.
|
|
2135
|
+
this.We[i] = signal(e[i], pureOptions);
|
|
2136
|
+
this.Qe && (this.Qe[i] = signal(i, pureOptions));
|
|
2137
|
+
return this.Ve(
|
|
2138
|
+
read.bind(null, this.We[i]),
|
|
2139
|
+
this.Qe ? read.bind(null, this.Qe[i]) : undefined
|
|
1821
2140
|
);
|
|
1822
2141
|
}
|
|
1823
|
-
: this.
|
|
2142
|
+
: this.Qe
|
|
1824
2143
|
? () => {
|
|
1825
2144
|
const t = e[i];
|
|
1826
|
-
this.
|
|
1827
|
-
return this.
|
|
2145
|
+
this.Qe[i] = signal(i, pureOptions);
|
|
2146
|
+
return this.Ve(() => t, read.bind(null, this.Qe[i]));
|
|
1828
2147
|
}
|
|
1829
2148
|
: () => {
|
|
1830
2149
|
const t = e[i];
|
|
1831
|
-
return this.
|
|
2150
|
+
return this.Ve(() => t);
|
|
1832
2151
|
};
|
|
1833
2152
|
if (t === 0) {
|
|
1834
|
-
if (this.
|
|
1835
|
-
this.
|
|
1836
|
-
this.
|
|
1837
|
-
this.
|
|
1838
|
-
this.
|
|
1839
|
-
this.
|
|
1840
|
-
this.
|
|
1841
|
-
this.
|
|
2153
|
+
if (this.we !== 0) {
|
|
2154
|
+
this.De.dispose(false);
|
|
2155
|
+
this.Ue = [];
|
|
2156
|
+
this.ve = [];
|
|
2157
|
+
this.me = [];
|
|
2158
|
+
this.we = 0;
|
|
2159
|
+
this.We && (this.We = []);
|
|
2160
|
+
this.Qe && (this.Qe = []);
|
|
1842
2161
|
}
|
|
1843
|
-
if (this.
|
|
1844
|
-
this.
|
|
2162
|
+
if (this.xe && !this.me[0]) {
|
|
2163
|
+
this.me[0] = runWithOwner((this.Ue[0] = createOwner()), this.xe);
|
|
1845
2164
|
}
|
|
1846
|
-
} else if (this.
|
|
1847
|
-
if (this.
|
|
1848
|
-
this.
|
|
2165
|
+
} else if (this.we === 0) {
|
|
2166
|
+
if (this.Ue[0]) this.Ue[0].dispose();
|
|
2167
|
+
this.me = new Array(t);
|
|
1849
2168
|
for (i = 0; i < t; i++) {
|
|
1850
|
-
this.
|
|
1851
|
-
this.
|
|
2169
|
+
this.ve[i] = e[i];
|
|
2170
|
+
this.me[i] = runWithOwner((this.Ue[i] = createOwner()), r);
|
|
1852
2171
|
}
|
|
1853
|
-
this.
|
|
2172
|
+
this.we = t;
|
|
1854
2173
|
} else {
|
|
1855
|
-
let
|
|
1856
|
-
|
|
2174
|
+
let o,
|
|
2175
|
+
s,
|
|
1857
2176
|
u,
|
|
1858
2177
|
l,
|
|
1859
2178
|
c,
|
|
1860
2179
|
a,
|
|
1861
2180
|
f,
|
|
1862
2181
|
E = new Array(t),
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
2182
|
+
T = new Array(t),
|
|
2183
|
+
R = this.We ? new Array(t) : undefined,
|
|
2184
|
+
d = this.Qe ? new Array(t) : undefined;
|
|
1866
2185
|
for (
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
2186
|
+
o = 0, s = Math.min(this.we, t);
|
|
2187
|
+
o < s && (this.ve[o] === e[o] || (this.We && compare(this.ke, this.ve[o], e[o])));
|
|
2188
|
+
o++
|
|
1870
2189
|
) {
|
|
1871
|
-
if (this.
|
|
2190
|
+
if (this.We) setSignal(this.We[o], e[o]);
|
|
1872
2191
|
}
|
|
1873
2192
|
for (
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
u >=
|
|
1877
|
-
(this.
|
|
1878
|
-
|
|
2193
|
+
s = this.we - 1, u = t - 1;
|
|
2194
|
+
s >= o &&
|
|
2195
|
+
u >= o &&
|
|
2196
|
+
(this.ve[s] === e[u] || (this.We && compare(this.ke, this.ve[s], e[u])));
|
|
2197
|
+
s--, u--
|
|
1879
2198
|
) {
|
|
1880
|
-
E[u] = this.
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
2199
|
+
E[u] = this.me[s];
|
|
2200
|
+
T[u] = this.Ue[s];
|
|
2201
|
+
R && (R[u] = this.We[s]);
|
|
2202
|
+
d && (d[u] = this.Qe[s]);
|
|
1884
2203
|
}
|
|
1885
2204
|
a = new Map();
|
|
1886
2205
|
f = new Array(u + 1);
|
|
1887
|
-
for (i = u; i >=
|
|
2206
|
+
for (i = u; i >= o; i--) {
|
|
1888
2207
|
l = e[i];
|
|
1889
|
-
c = this.
|
|
2208
|
+
c = this.ke ? this.ke(l) : l;
|
|
1890
2209
|
n = a.get(c);
|
|
1891
2210
|
f[i] = n === undefined ? -1 : n;
|
|
1892
2211
|
a.set(c, i);
|
|
1893
2212
|
}
|
|
1894
|
-
for (n =
|
|
1895
|
-
l = this.
|
|
1896
|
-
c = this.
|
|
2213
|
+
for (n = o; n <= s; n++) {
|
|
2214
|
+
l = this.ve[n];
|
|
2215
|
+
c = this.ke ? this.ke(l) : l;
|
|
1897
2216
|
i = a.get(c);
|
|
1898
2217
|
if (i !== undefined && i !== -1) {
|
|
1899
|
-
E[i] = this.
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
2218
|
+
E[i] = this.me[n];
|
|
2219
|
+
T[i] = this.Ue[n];
|
|
2220
|
+
R && (R[i] = this.We[n]);
|
|
2221
|
+
d && (d[i] = this.Qe[n]);
|
|
1903
2222
|
i = f[i];
|
|
1904
2223
|
a.set(c, i);
|
|
1905
|
-
} else this.
|
|
2224
|
+
} else this.Ue[n].dispose();
|
|
1906
2225
|
}
|
|
1907
|
-
for (i =
|
|
2226
|
+
for (i = o; i < t; i++) {
|
|
1908
2227
|
if (i in E) {
|
|
1909
|
-
this.
|
|
1910
|
-
this.
|
|
1911
|
-
if (T) {
|
|
1912
|
-
this.Ue[i] = T[i];
|
|
1913
|
-
setSignal(this.Ue[i], e[i]);
|
|
1914
|
-
}
|
|
2228
|
+
this.me[i] = E[i];
|
|
2229
|
+
this.Ue[i] = T[i];
|
|
1915
2230
|
if (R) {
|
|
1916
|
-
this.
|
|
1917
|
-
setSignal(this.
|
|
2231
|
+
this.We[i] = R[i];
|
|
2232
|
+
setSignal(this.We[i], e[i]);
|
|
2233
|
+
}
|
|
2234
|
+
if (d) {
|
|
2235
|
+
this.Qe[i] = d[i];
|
|
2236
|
+
setSignal(this.Qe[i], i);
|
|
1918
2237
|
}
|
|
1919
2238
|
} else {
|
|
1920
|
-
this.
|
|
2239
|
+
this.me[i] = runWithOwner((this.Ue[i] = createOwner()), r);
|
|
1921
2240
|
}
|
|
1922
2241
|
}
|
|
1923
|
-
this.
|
|
1924
|
-
this.
|
|
2242
|
+
this.me = this.me.slice(0, (this.we = t));
|
|
2243
|
+
this.ve = e.slice(0);
|
|
1925
2244
|
}
|
|
1926
2245
|
});
|
|
1927
|
-
return this.
|
|
2246
|
+
return this.me;
|
|
1928
2247
|
}
|
|
1929
2248
|
function repeat(e, t, n) {
|
|
1930
2249
|
return updateRepeat.bind({
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
2250
|
+
De: createOwner(),
|
|
2251
|
+
we: 0,
|
|
2252
|
+
Ge: 0,
|
|
2253
|
+
Me: e,
|
|
2254
|
+
Ve: t,
|
|
2255
|
+
Ue: [],
|
|
2256
|
+
me: [],
|
|
2257
|
+
$e: n?.from,
|
|
2258
|
+
xe: n?.fallback
|
|
1940
2259
|
});
|
|
1941
2260
|
}
|
|
1942
2261
|
function updateRepeat() {
|
|
1943
|
-
const e = this.
|
|
1944
|
-
const t = this
|
|
1945
|
-
runWithOwner(this.
|
|
2262
|
+
const e = this.Me();
|
|
2263
|
+
const t = this.$e?.() || 0;
|
|
2264
|
+
runWithOwner(this.De, () => {
|
|
1946
2265
|
if (e === 0) {
|
|
1947
|
-
if (this.
|
|
1948
|
-
this.
|
|
1949
|
-
this.
|
|
1950
|
-
this.
|
|
1951
|
-
this.
|
|
2266
|
+
if (this.we !== 0) {
|
|
2267
|
+
this.De.dispose(false);
|
|
2268
|
+
this.Ue = [];
|
|
2269
|
+
this.me = [];
|
|
2270
|
+
this.we = 0;
|
|
1952
2271
|
}
|
|
1953
|
-
if (this.
|
|
1954
|
-
this.
|
|
2272
|
+
if (this.xe && !this.me[0]) {
|
|
2273
|
+
this.me[0] = runWithOwner((this.Ue[0] = createOwner()), this.xe);
|
|
1955
2274
|
}
|
|
1956
2275
|
return;
|
|
1957
2276
|
}
|
|
1958
2277
|
const n = t + e;
|
|
1959
|
-
const i = this.
|
|
1960
|
-
if (this.
|
|
1961
|
-
for (let e = n; e < i; e++) this.
|
|
1962
|
-
if (this.
|
|
1963
|
-
let e = this.
|
|
1964
|
-
while (e < t && e < this.
|
|
1965
|
-
this.
|
|
1966
|
-
this.
|
|
1967
|
-
} else if (this.
|
|
1968
|
-
let n = i - this.
|
|
1969
|
-
let r = this.
|
|
1970
|
-
this.
|
|
2278
|
+
const i = this.Ge + this.we;
|
|
2279
|
+
if (this.we === 0 && this.Ue[0]) this.Ue[0].dispose();
|
|
2280
|
+
for (let e = n; e < i; e++) this.Ue[e - this.Ge].dispose();
|
|
2281
|
+
if (this.Ge < t) {
|
|
2282
|
+
let e = this.Ge;
|
|
2283
|
+
while (e < t && e < this.we) this.Ue[e++].dispose();
|
|
2284
|
+
this.Ue.splice(0, t - this.Ge);
|
|
2285
|
+
this.me.splice(0, t - this.Ge);
|
|
2286
|
+
} else if (this.Ge > t) {
|
|
2287
|
+
let n = i - this.Ge - 1;
|
|
2288
|
+
let r = this.Ge - t;
|
|
2289
|
+
this.Ue.length = this.me.length = e;
|
|
1971
2290
|
while (n >= r) {
|
|
1972
|
-
this.
|
|
1973
|
-
this.
|
|
2291
|
+
this.Ue[n] = this.Ue[n - r];
|
|
2292
|
+
this.me[n] = this.me[n - r];
|
|
1974
2293
|
n--;
|
|
1975
2294
|
}
|
|
1976
2295
|
for (let e = 0; e < r; e++) {
|
|
1977
|
-
this.
|
|
2296
|
+
this.me[e] = runWithOwner((this.Ue[e] = createOwner()), () => this.Ve(e + t));
|
|
1978
2297
|
}
|
|
1979
2298
|
}
|
|
1980
2299
|
for (let e = i; e < n; e++) {
|
|
1981
|
-
this.
|
|
2300
|
+
this.me[e - t] = runWithOwner((this.Ue[e - t] = createOwner()), () => this.Ve(e));
|
|
1982
2301
|
}
|
|
1983
|
-
this.
|
|
1984
|
-
this.
|
|
1985
|
-
this.
|
|
2302
|
+
this.me = this.me.slice(0, e);
|
|
2303
|
+
this.Ge = t;
|
|
2304
|
+
this.we = e;
|
|
1986
2305
|
});
|
|
1987
|
-
return this.
|
|
2306
|
+
return this.me;
|
|
1988
2307
|
}
|
|
1989
2308
|
function compare(e, t, n) {
|
|
1990
2309
|
return e ? e(t) === e(n) : true;
|
|
1991
2310
|
}
|
|
1992
2311
|
function boundaryComputed(e, t) {
|
|
1993
|
-
const n = computed(e, undefined, {
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
},
|
|
2003
|
-
Qe: t
|
|
2004
|
-
}
|
|
2005
|
-
});
|
|
2006
|
-
n.Qe = t;
|
|
2007
|
-
n.Te = true;
|
|
2312
|
+
const n = computed(e, undefined, { lazy: true });
|
|
2313
|
+
n.Te = () => {
|
|
2314
|
+
const e = n.ie;
|
|
2315
|
+
n.ie &= ~n.Le;
|
|
2316
|
+
n.J.notify(n, n.Le, e);
|
|
2317
|
+
};
|
|
2318
|
+
n.Le = t;
|
|
2319
|
+
n.Se = true;
|
|
2320
|
+
recompute(n, true);
|
|
2008
2321
|
return n;
|
|
2009
2322
|
}
|
|
2010
2323
|
function createBoundChildren(e, t, n, i) {
|
|
2011
|
-
const r = e.
|
|
2012
|
-
r.addChild((e.
|
|
2013
|
-
onCleanup(() => r.removeChild(e.
|
|
2324
|
+
const r = e.J;
|
|
2325
|
+
r.addChild((e.J = n));
|
|
2326
|
+
onCleanup(() => r.removeChild(e.J));
|
|
2014
2327
|
return runWithOwner(e, () => {
|
|
2015
2328
|
const e = computed(t);
|
|
2016
2329
|
return boundaryComputed(() => staleValues(() => flatten(read(e))), i);
|
|
2017
2330
|
});
|
|
2018
2331
|
}
|
|
2019
2332
|
class ConditionalQueue extends Queue {
|
|
2020
|
-
|
|
2021
|
-
|
|
2333
|
+
He;
|
|
2334
|
+
Fe = new Set();
|
|
2022
2335
|
L = new Set();
|
|
2023
2336
|
constructor(e) {
|
|
2024
2337
|
super();
|
|
2025
|
-
this.
|
|
2338
|
+
this.He = e;
|
|
2026
2339
|
}
|
|
2027
2340
|
run(e) {
|
|
2028
|
-
if (!e || read(this.
|
|
2341
|
+
if (!e || read(this.He)) return;
|
|
2029
2342
|
return super.run(e);
|
|
2030
2343
|
}
|
|
2031
2344
|
notify(e, t, n) {
|
|
2032
|
-
if (read(this.
|
|
2345
|
+
if (read(this.He)) {
|
|
2033
2346
|
if (t & STATUS_PENDING) {
|
|
2034
2347
|
if (n & STATUS_PENDING) {
|
|
2035
2348
|
this.L.add(e);
|
|
@@ -2038,37 +2351,37 @@ class ConditionalQueue extends Queue {
|
|
|
2038
2351
|
}
|
|
2039
2352
|
if (t & STATUS_ERROR) {
|
|
2040
2353
|
if (n & STATUS_ERROR) {
|
|
2041
|
-
this
|
|
2354
|
+
this.Fe.add(e);
|
|
2042
2355
|
t &= ~STATUS_ERROR;
|
|
2043
|
-
} else if (this
|
|
2356
|
+
} else if (this.Fe.delete(e)) t &= ~STATUS_ERROR;
|
|
2044
2357
|
}
|
|
2045
2358
|
}
|
|
2046
2359
|
return t ? super.notify(e, t, n) : true;
|
|
2047
2360
|
}
|
|
2048
2361
|
}
|
|
2049
2362
|
class CollectionQueue extends Queue {
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2363
|
+
je;
|
|
2364
|
+
Ue = new Set();
|
|
2365
|
+
He = signal(false, { pureWrite: true });
|
|
2366
|
+
Ke = false;
|
|
2054
2367
|
constructor(e) {
|
|
2055
2368
|
super();
|
|
2056
|
-
this.
|
|
2369
|
+
this.je = e;
|
|
2057
2370
|
}
|
|
2058
2371
|
run(e) {
|
|
2059
|
-
if (!e || read(this.
|
|
2372
|
+
if (!e || read(this.He)) return;
|
|
2060
2373
|
return super.run(e);
|
|
2061
2374
|
}
|
|
2062
2375
|
notify(e, t, n) {
|
|
2063
|
-
if (!(t & this.
|
|
2064
|
-
if (n & this.
|
|
2065
|
-
this.
|
|
2066
|
-
if (this.
|
|
2067
|
-
} else if (this.
|
|
2068
|
-
this.
|
|
2069
|
-
if (this.
|
|
2070
|
-
}
|
|
2071
|
-
t &= ~this.
|
|
2376
|
+
if (!(t & this.je) || (this.je & STATUS_PENDING && this.Ke)) return super.notify(e, t, n);
|
|
2377
|
+
if (n & this.je) {
|
|
2378
|
+
this.Ue.add(e);
|
|
2379
|
+
if (this.Ue.size === 1) setSignal(this.He, true);
|
|
2380
|
+
} else if (this.Ue.size > 0) {
|
|
2381
|
+
this.Ue.delete(e);
|
|
2382
|
+
if (this.Ue.size === 0) setSignal(this.He, false);
|
|
2383
|
+
}
|
|
2384
|
+
t &= ~this.je;
|
|
2072
2385
|
return t ? super.notify(e, t, n) : true;
|
|
2073
2386
|
}
|
|
2074
2387
|
}
|
|
@@ -2082,53 +2395,55 @@ function createBoundary(e, t) {
|
|
|
2082
2395
|
const i = new ConditionalQueue(computed(() => t() === BoundaryMode.HIDDEN));
|
|
2083
2396
|
const r = createBoundChildren(n, e, i, 0);
|
|
2084
2397
|
computed(() => {
|
|
2085
|
-
const e = read(i.
|
|
2086
|
-
r.
|
|
2398
|
+
const e = read(i.He);
|
|
2399
|
+
r.Le = e ? STATUS_ERROR | STATUS_PENDING : 0;
|
|
2087
2400
|
if (!e) {
|
|
2088
2401
|
i.L.forEach(e => i.notify(e, STATUS_PENDING, STATUS_PENDING));
|
|
2089
|
-
i
|
|
2402
|
+
i.Fe.forEach(e => i.notify(e, STATUS_ERROR, STATUS_ERROR));
|
|
2090
2403
|
i.L.clear();
|
|
2091
|
-
i
|
|
2404
|
+
i.Fe.clear();
|
|
2092
2405
|
}
|
|
2093
2406
|
});
|
|
2094
|
-
return () => (read(i.
|
|
2407
|
+
return () => (read(i.He) ? undefined : read(r));
|
|
2095
2408
|
}
|
|
2096
2409
|
function createCollectionBoundary(e, t, n) {
|
|
2097
2410
|
const i = createOwner();
|
|
2098
2411
|
const r = new CollectionQueue(e);
|
|
2099
|
-
const
|
|
2100
|
-
const
|
|
2101
|
-
if (!read(r.
|
|
2102
|
-
const e = read(
|
|
2103
|
-
if (!untrack(() => read(r.
|
|
2104
|
-
|
|
2412
|
+
const o = createBoundChildren(i, t, r, e);
|
|
2413
|
+
const s = computed(() => {
|
|
2414
|
+
if (!read(r.He)) {
|
|
2415
|
+
const e = read(o);
|
|
2416
|
+
if (!untrack(() => read(r.He))) {
|
|
2417
|
+
r.Ke = true;
|
|
2418
|
+
return e;
|
|
2419
|
+
}
|
|
2105
2420
|
}
|
|
2106
2421
|
return n(r);
|
|
2107
2422
|
});
|
|
2108
|
-
return read.bind(null,
|
|
2423
|
+
return read.bind(null, s);
|
|
2109
2424
|
}
|
|
2110
2425
|
function createLoadBoundary(e, t) {
|
|
2111
2426
|
return createCollectionBoundary(STATUS_PENDING, e, () => t());
|
|
2112
2427
|
}
|
|
2113
2428
|
function collectErrorSources(e, t) {
|
|
2114
2429
|
let n = true;
|
|
2115
|
-
let i = e.
|
|
2430
|
+
let i = e.C;
|
|
2116
2431
|
while (i !== null) {
|
|
2117
2432
|
const e = i.V;
|
|
2118
|
-
if (e.
|
|
2433
|
+
if (e.C && e.ie & STATUS_ERROR) {
|
|
2119
2434
|
n = false;
|
|
2120
2435
|
collectErrorSources(e, t);
|
|
2121
2436
|
}
|
|
2122
|
-
i = i.
|
|
2437
|
+
i = i.D;
|
|
2123
2438
|
}
|
|
2124
2439
|
n && t.push(e);
|
|
2125
2440
|
}
|
|
2126
2441
|
function createErrorBoundary(e, t) {
|
|
2127
2442
|
return createCollectionBoundary(STATUS_ERROR, e, e => {
|
|
2128
|
-
let n = e.
|
|
2129
|
-
return t(n.
|
|
2443
|
+
let n = e.Ue.values().next().value;
|
|
2444
|
+
return t(n.B, () => {
|
|
2130
2445
|
const t = [];
|
|
2131
|
-
for (const n of e.
|
|
2446
|
+
for (const n of e.Ue) collectErrorSources(n, t);
|
|
2132
2447
|
for (const e of t) recompute(e);
|
|
2133
2448
|
schedule();
|
|
2134
2449
|
});
|
|
@@ -2158,9 +2473,9 @@ function flatten(e, t) {
|
|
|
2158
2473
|
function flattenArray(e, t = [], n) {
|
|
2159
2474
|
let i = null;
|
|
2160
2475
|
let r = false;
|
|
2161
|
-
for (let
|
|
2476
|
+
for (let o = 0; o < e.length; o++) {
|
|
2162
2477
|
try {
|
|
2163
|
-
let i = e[
|
|
2478
|
+
let i = e[o];
|
|
2164
2479
|
if (typeof i === "function" && !i.length) {
|
|
2165
2480
|
if (n?.doNotUnwrap) {
|
|
2166
2481
|
t.push(i);
|