@solidjs/signals 0.9.5 → 0.9.7
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 +718 -380
- package/dist/node.cjs +1262 -984
- package/dist/prod.js +1117 -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
|
-
|
|
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);
|
|
310
340
|
}
|
|
311
|
-
globalQueue.$ = [];
|
|
312
|
-
if (dirtyQueue.h >= dirtyQueue.C) {
|
|
313
|
-
t = true;
|
|
314
|
-
runHeap(dirtyQueue, GlobalQueue.F);
|
|
315
|
-
}
|
|
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 | (t !== STATUS_ERROR ? e.ie & STATUS_UNINITIALIZED : 0);
|
|
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,57 @@ 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
|
+
const n = context;
|
|
911
|
+
context = null;
|
|
912
|
+
e.ge = optimisticComputed(() => read(e));
|
|
913
|
+
context = n;
|
|
914
|
+
pendingReadActive = t;
|
|
915
|
+
}
|
|
916
|
+
return e.ge;
|
|
917
|
+
}
|
|
918
|
+
function updatePendingSignal(e) {
|
|
919
|
+
if (e.Ae) setSignal(e.Ae, computePendingState(e));
|
|
920
|
+
}
|
|
746
921
|
function isEqual(e, t) {
|
|
747
922
|
return e === t;
|
|
748
923
|
}
|
|
@@ -756,16 +931,36 @@ function untrack(e) {
|
|
|
756
931
|
}
|
|
757
932
|
}
|
|
758
933
|
function read(e) {
|
|
934
|
+
if (pendingCheckActive) {
|
|
935
|
+
const t = e.m || e;
|
|
936
|
+
const n = getPendingSignal(t);
|
|
937
|
+
const i = pendingCheckActive;
|
|
938
|
+
pendingCheckActive = false;
|
|
939
|
+
if (read(n)) {
|
|
940
|
+
foundPending = true;
|
|
941
|
+
}
|
|
942
|
+
pendingCheckActive = i;
|
|
943
|
+
return e.ne;
|
|
944
|
+
}
|
|
945
|
+
if (pendingReadActive) {
|
|
946
|
+
const t = getPendingValueComputed(e);
|
|
947
|
+
const n = pendingReadActive;
|
|
948
|
+
pendingReadActive = false;
|
|
949
|
+
const i = read(t);
|
|
950
|
+
pendingReadActive = n;
|
|
951
|
+
if (t.ie & STATUS_PENDING) return e.ne;
|
|
952
|
+
return i;
|
|
953
|
+
}
|
|
759
954
|
let t = context;
|
|
760
955
|
if (t?.t) t = t.u;
|
|
761
956
|
if (refreshing && e.U) recompute(e);
|
|
762
|
-
if (t && tracking
|
|
957
|
+
if (t && tracking) {
|
|
763
958
|
if (e.U && e.S & REACTIVE_DISPOSED) recompute(e);
|
|
764
959
|
link(e, t);
|
|
765
960
|
const n = e.m || e;
|
|
766
961
|
if (n.U) {
|
|
767
962
|
const i = e.S & REACTIVE_ZOMBIE;
|
|
768
|
-
if (n.o >= (i ? zombieQueue.
|
|
963
|
+
if (n.o >= (i ? zombieQueue.N : dirtyQueue.N)) {
|
|
769
964
|
markNode(t);
|
|
770
965
|
markHeap(i ? zombieQueue : dirtyQueue);
|
|
771
966
|
updateIfNecessary(n);
|
|
@@ -776,73 +971,60 @@ function read(e) {
|
|
|
776
971
|
}
|
|
777
972
|
}
|
|
778
973
|
}
|
|
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
974
|
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) {
|
|
975
|
+
if (
|
|
976
|
+
t &&
|
|
977
|
+
!optimisticReadActive &&
|
|
978
|
+
n.ie & STATUS_PENDING &&
|
|
979
|
+
!(stale && n.X && activeTransition !== n.X)
|
|
980
|
+
)
|
|
981
|
+
throw n.B;
|
|
982
|
+
if (e.U && e.ie & STATUS_ERROR) {
|
|
983
|
+
if (e.ae < clock) {
|
|
811
984
|
recompute(e, true);
|
|
812
985
|
return read(e);
|
|
813
|
-
} else
|
|
814
|
-
throw e.j;
|
|
815
|
-
}
|
|
986
|
+
} else throw e.B;
|
|
816
987
|
}
|
|
817
988
|
return !t ||
|
|
818
|
-
|
|
819
|
-
e.
|
|
820
|
-
(stale &&
|
|
821
|
-
? e.
|
|
822
|
-
: e.
|
|
989
|
+
optimisticReadActive ||
|
|
990
|
+
e.te === NOT_PENDING ||
|
|
991
|
+
(stale && e.X && activeTransition !== e.X)
|
|
992
|
+
? e.ne
|
|
993
|
+
: e.te;
|
|
823
994
|
}
|
|
824
995
|
function setSignal(e, t) {
|
|
825
|
-
if (e.
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
const
|
|
830
|
-
if (!
|
|
996
|
+
if (e.X && activeTransition !== e.X) globalQueue.initTransition(e.X);
|
|
997
|
+
const n = e.le && !projectionWriteActive;
|
|
998
|
+
const i = n ? e.ne : e.te === NOT_PENDING ? e.ne : e.te;
|
|
999
|
+
if (typeof t === "function") t = t(i);
|
|
1000
|
+
const r = !e.fe || !e.fe(i, t);
|
|
1001
|
+
if (!r) return t;
|
|
831
1002
|
if (n) {
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
1003
|
+
const n = e.te === NOT_PENDING;
|
|
1004
|
+
if (e.X && !n) {
|
|
1005
|
+
globalQueue.initTransition(e.X);
|
|
1006
|
+
}
|
|
1007
|
+
if (n) {
|
|
1008
|
+
e.te = e.ne;
|
|
1009
|
+
globalQueue.H.push(e);
|
|
836
1010
|
}
|
|
837
|
-
|
|
1011
|
+
e.ne = t;
|
|
1012
|
+
} else {
|
|
1013
|
+
if (e.te === NOT_PENDING) globalQueue.L.push(e);
|
|
1014
|
+
e.te = t;
|
|
838
1015
|
}
|
|
839
|
-
|
|
840
|
-
e.
|
|
841
|
-
|
|
1016
|
+
updatePendingSignal(e);
|
|
1017
|
+
if (e.ge) {
|
|
1018
|
+
setSignal(e.ge, t);
|
|
1019
|
+
}
|
|
1020
|
+
e.ae = clock;
|
|
1021
|
+
insertSubs(e, n);
|
|
842
1022
|
schedule();
|
|
843
1023
|
return t;
|
|
844
1024
|
}
|
|
1025
|
+
const PENDING_OWNER = {};
|
|
845
1026
|
function getObserver() {
|
|
1027
|
+
if (pendingCheckActive || pendingReadActive) return PENDING_OWNER;
|
|
846
1028
|
return tracking ? context : null;
|
|
847
1029
|
}
|
|
848
1030
|
function getOwner() {
|
|
@@ -850,42 +1032,37 @@ function getOwner() {
|
|
|
850
1032
|
}
|
|
851
1033
|
function onCleanup(e) {
|
|
852
1034
|
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
|
-
}
|
|
1035
|
+
if (!context.oe) context.oe = e;
|
|
1036
|
+
else if (Array.isArray(context.oe)) context.oe.push(e);
|
|
1037
|
+
else context.oe = [context.oe, e];
|
|
861
1038
|
return e;
|
|
862
1039
|
}
|
|
863
1040
|
function createOwner(e) {
|
|
864
1041
|
const t = context;
|
|
865
1042
|
const n = {
|
|
1043
|
+
id: e?.id ?? (t?.id != null ? getNextChildId(t) : undefined),
|
|
866
1044
|
t: true,
|
|
867
1045
|
u: t?.t ? t.u : t,
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
ne: null,
|
|
1046
|
+
ue: null,
|
|
1047
|
+
_e: null,
|
|
1048
|
+
oe: null,
|
|
1049
|
+
J: t?.J ?? globalQueue,
|
|
1050
|
+
he: t?.he || defaultContext,
|
|
1051
|
+
pe: 0,
|
|
1052
|
+
re: null,
|
|
1053
|
+
se: null,
|
|
877
1054
|
i: t,
|
|
878
1055
|
dispose(e = true) {
|
|
879
1056
|
disposeChildren(n, e);
|
|
880
1057
|
}
|
|
881
1058
|
};
|
|
882
1059
|
if (t) {
|
|
883
|
-
const e = t.
|
|
1060
|
+
const e = t.ue;
|
|
884
1061
|
if (e === null) {
|
|
885
|
-
t.
|
|
1062
|
+
t.ue = n;
|
|
886
1063
|
} else {
|
|
887
|
-
n.
|
|
888
|
-
t.
|
|
1064
|
+
n._e = e;
|
|
1065
|
+
t.ue = n;
|
|
889
1066
|
}
|
|
890
1067
|
}
|
|
891
1068
|
return n;
|
|
@@ -916,25 +1093,25 @@ function staleValues(e, t = true) {
|
|
|
916
1093
|
}
|
|
917
1094
|
}
|
|
918
1095
|
function pending(e) {
|
|
919
|
-
const t =
|
|
920
|
-
|
|
1096
|
+
const t = pendingReadActive;
|
|
1097
|
+
pendingReadActive = true;
|
|
921
1098
|
try {
|
|
922
|
-
return
|
|
1099
|
+
return e();
|
|
923
1100
|
} finally {
|
|
924
|
-
|
|
1101
|
+
pendingReadActive = t;
|
|
925
1102
|
}
|
|
926
1103
|
}
|
|
927
1104
|
function isPending(e) {
|
|
928
|
-
const t =
|
|
929
|
-
|
|
1105
|
+
const t = pendingCheckActive;
|
|
1106
|
+
const n = foundPending;
|
|
1107
|
+
pendingCheckActive = true;
|
|
1108
|
+
foundPending = false;
|
|
930
1109
|
try {
|
|
931
|
-
|
|
932
|
-
return
|
|
933
|
-
} catch (e) {
|
|
934
|
-
if (!(e instanceof NotReadyError)) return false;
|
|
935
|
-
throw e;
|
|
1110
|
+
e();
|
|
1111
|
+
return foundPending;
|
|
936
1112
|
} finally {
|
|
937
|
-
|
|
1113
|
+
pendingCheckActive = t;
|
|
1114
|
+
foundPending = n;
|
|
938
1115
|
}
|
|
939
1116
|
}
|
|
940
1117
|
function refresh(e) {
|
|
@@ -950,7 +1127,6 @@ function refresh(e) {
|
|
|
950
1127
|
refreshing = t;
|
|
951
1128
|
if (!t) {
|
|
952
1129
|
schedule();
|
|
953
|
-
flush();
|
|
954
1130
|
}
|
|
955
1131
|
}
|
|
956
1132
|
}
|
|
@@ -964,7 +1140,7 @@ function getContext(e, t = getOwner()) {
|
|
|
964
1140
|
if (!t) {
|
|
965
1141
|
throw new NoOwnerError();
|
|
966
1142
|
}
|
|
967
|
-
const n = hasContext(e, t) ? t.
|
|
1143
|
+
const n = hasContext(e, t) ? t.he[e.id] : e.defaultValue;
|
|
968
1144
|
if (isUndefined(n)) {
|
|
969
1145
|
throw new ContextNotFoundError();
|
|
970
1146
|
}
|
|
@@ -974,73 +1150,92 @@ function setContext(e, t, n = getOwner()) {
|
|
|
974
1150
|
if (!n) {
|
|
975
1151
|
throw new NoOwnerError();
|
|
976
1152
|
}
|
|
977
|
-
n.
|
|
1153
|
+
n.he = { ...n.he, [e.id]: isUndefined(t) ? e.defaultValue : t };
|
|
978
1154
|
}
|
|
979
1155
|
function hasContext(e, t) {
|
|
980
|
-
return !isUndefined(t?.
|
|
1156
|
+
return !isUndefined(t?.he[e.id]);
|
|
981
1157
|
}
|
|
982
1158
|
function isUndefined(e) {
|
|
983
1159
|
return typeof e === "undefined";
|
|
984
1160
|
}
|
|
985
1161
|
function effect(e, t, n, i, r) {
|
|
986
|
-
let
|
|
987
|
-
const
|
|
1162
|
+
let o = false;
|
|
1163
|
+
const s = computed(r?.render ? t => staleValues(() => e(t)) : e, i, {
|
|
988
1164
|
...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);
|
|
1165
|
+
equals: () => {
|
|
1166
|
+
s.Z = !s.B;
|
|
1167
|
+
if (o) s.J.enqueue(s.q, runEffect.bind(s));
|
|
1168
|
+
return false;
|
|
1169
|
+
},
|
|
1170
|
+
lazy: true
|
|
1171
|
+
});
|
|
1172
|
+
s.Pe = i;
|
|
1173
|
+
s.Ne = t;
|
|
1174
|
+
s.Ce = n;
|
|
1175
|
+
s.ye = undefined;
|
|
1176
|
+
s.q = r?.render ? EFFECT_RENDER : EFFECT_USER;
|
|
1177
|
+
s.Te = () => {
|
|
1178
|
+
if (s.ie & STATUS_ERROR) {
|
|
1179
|
+
let e = s.B;
|
|
1180
|
+
s.J.notify(s, STATUS_PENDING, 0);
|
|
1181
|
+
if (s.q === EFFECT_USER) {
|
|
1182
|
+
try {
|
|
1183
|
+
return s.Ce
|
|
1184
|
+
? s.Ce(e, () => {
|
|
1185
|
+
s.ye?.();
|
|
1186
|
+
s.ye = undefined;
|
|
1187
|
+
})
|
|
1188
|
+
: console.error(e);
|
|
1189
|
+
} catch (t) {
|
|
1190
|
+
e = t;
|
|
1020
1191
|
}
|
|
1021
1192
|
}
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
!r?.defer &&
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
onCleanup(() => o.Ie?.());
|
|
1193
|
+
if (!s.J.notify(s, STATUS_ERROR, STATUS_ERROR)) throw e;
|
|
1194
|
+
} else if (s.q === EFFECT_RENDER) s.J.notify(s, STATUS_PENDING | STATUS_ERROR, s.ie);
|
|
1195
|
+
};
|
|
1196
|
+
recompute(s, true);
|
|
1197
|
+
!r?.defer && (s.q === EFFECT_USER ? s.J.enqueue(s.q, runEffect.bind(s)) : runEffect.call(s));
|
|
1198
|
+
o = true;
|
|
1199
|
+
onCleanup(() => s.ye?.());
|
|
1030
1200
|
}
|
|
1031
1201
|
function runEffect() {
|
|
1032
|
-
if (!this.
|
|
1033
|
-
this.
|
|
1034
|
-
this.
|
|
1202
|
+
if (!this.Z || this.S & REACTIVE_DISPOSED) return;
|
|
1203
|
+
this.ye?.();
|
|
1204
|
+
this.ye = undefined;
|
|
1035
1205
|
try {
|
|
1036
|
-
this.
|
|
1206
|
+
this.ye = this.Ne(this.ne, this.Pe);
|
|
1037
1207
|
} catch (e) {
|
|
1038
|
-
if (!this.
|
|
1208
|
+
if (!this.J.notify(this, STATUS_ERROR, STATUS_ERROR)) throw e;
|
|
1039
1209
|
} finally {
|
|
1040
|
-
this.
|
|
1041
|
-
this.
|
|
1210
|
+
this.Pe = this.ne;
|
|
1211
|
+
this.Z = false;
|
|
1042
1212
|
}
|
|
1043
1213
|
}
|
|
1214
|
+
function trackedEffect(e, t) {
|
|
1215
|
+
const run = () => {
|
|
1216
|
+
if (!n.Z || n.S & REACTIVE_DISPOSED) return;
|
|
1217
|
+
n.Z = false;
|
|
1218
|
+
recompute(n);
|
|
1219
|
+
};
|
|
1220
|
+
const n = computed(
|
|
1221
|
+
() => {
|
|
1222
|
+
try {
|
|
1223
|
+
n.ye?.();
|
|
1224
|
+
n.ye = undefined;
|
|
1225
|
+
n.ye = staleValues(e) || undefined;
|
|
1226
|
+
} finally {
|
|
1227
|
+
}
|
|
1228
|
+
},
|
|
1229
|
+
undefined,
|
|
1230
|
+
{ ...t, lazy: true, pureWrite: true }
|
|
1231
|
+
);
|
|
1232
|
+
n.ye = undefined;
|
|
1233
|
+
n.Z = true;
|
|
1234
|
+
n.q = EFFECT_TRACKED;
|
|
1235
|
+
n.ee = run;
|
|
1236
|
+
n.J.enqueue(EFFECT_USER, run);
|
|
1237
|
+
onCleanup(() => n.ye?.());
|
|
1238
|
+
}
|
|
1044
1239
|
function createSignal(e, t, n) {
|
|
1045
1240
|
if (typeof e === "function") {
|
|
1046
1241
|
const i = computed(e, t, n);
|
|
@@ -1054,12 +1249,14 @@ function createMemo(e, t, n) {
|
|
|
1054
1249
|
return read.bind(null, i);
|
|
1055
1250
|
}
|
|
1056
1251
|
function createEffect(e, t, n, i) {
|
|
1057
|
-
|
|
1252
|
+
effect(e, t.effect || t, t.error, n, i);
|
|
1058
1253
|
}
|
|
1059
1254
|
function createRenderEffect(e, t, n, i) {
|
|
1060
|
-
|
|
1255
|
+
effect(e, t, undefined, n, { render: true, ...i });
|
|
1256
|
+
}
|
|
1257
|
+
function createTrackedEffect(e, t) {
|
|
1258
|
+
trackedEffect(e, t);
|
|
1061
1259
|
}
|
|
1062
|
-
function createTrackedEffect(e, t) {}
|
|
1063
1260
|
function createReaction(e, t) {
|
|
1064
1261
|
let n = undefined;
|
|
1065
1262
|
onCleanup(() => n?.());
|
|
@@ -1096,39 +1293,16 @@ function resolve(e) {
|
|
|
1096
1293
|
});
|
|
1097
1294
|
}
|
|
1098
1295
|
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
|
-
];
|
|
1296
|
+
const i = typeof e === "function" ? optimisticComputed(e, t, n) : optimisticSignal(e, t);
|
|
1297
|
+
return [read.bind(null, i), setSignal.bind(null, i)];
|
|
1123
1298
|
}
|
|
1124
1299
|
function onSettled(e) {
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
});
|
|
1300
|
+
getOwner()
|
|
1301
|
+
? createTrackedEffect(() => untrack(e))
|
|
1302
|
+
: globalQueue.enqueue(EFFECT_USER, () => {
|
|
1303
|
+
const t = e();
|
|
1304
|
+
t?.();
|
|
1305
|
+
});
|
|
1132
1306
|
}
|
|
1133
1307
|
function unwrap(e) {
|
|
1134
1308
|
return e?.[$TARGET]?.[STORE_NODE] ?? e;
|
|
@@ -1144,67 +1318,67 @@ function getAllKeys(e, t, n) {
|
|
|
1144
1318
|
function applyState(e, t, n, i) {
|
|
1145
1319
|
const r = t?.[$TARGET];
|
|
1146
1320
|
if (!r) return;
|
|
1147
|
-
const
|
|
1148
|
-
const
|
|
1321
|
+
const o = r[STORE_VALUE];
|
|
1322
|
+
const s = r[STORE_OVERRIDE];
|
|
1149
1323
|
let u = r[STORE_NODE];
|
|
1150
|
-
if (e ===
|
|
1324
|
+
if (e === o && !s) return;
|
|
1151
1325
|
(r[STORE_LOOKUP] || storeLookup).set(e, r[$PROXY]);
|
|
1152
1326
|
r[STORE_VALUE] = e;
|
|
1153
1327
|
r[STORE_OVERRIDE] = undefined;
|
|
1154
|
-
if (Array.isArray(
|
|
1328
|
+
if (Array.isArray(o)) {
|
|
1155
1329
|
let t = false;
|
|
1156
|
-
const l = getOverrideValue(
|
|
1330
|
+
const l = getOverrideValue(o, s, u, "length");
|
|
1157
1331
|
if (e.length && l && e[0] && n(e[0]) != null) {
|
|
1158
|
-
let c, a, f, E,
|
|
1332
|
+
let c, a, f, E, T, R, d, O;
|
|
1159
1333
|
for (
|
|
1160
1334
|
f = 0, E = Math.min(l, e.length);
|
|
1161
|
-
f < E && ((
|
|
1335
|
+
f < E && ((R = getOverrideValue(o, s, u, f)) === e[f] || (R && e[f] && n(R) === n(e[f])));
|
|
1162
1336
|
f++
|
|
1163
1337
|
) {
|
|
1164
|
-
applyState(e[f], wrap(
|
|
1338
|
+
applyState(e[f], wrap(R, r), n, i);
|
|
1165
1339
|
}
|
|
1166
1340
|
const S = new Array(e.length),
|
|
1167
1341
|
_ = new Map();
|
|
1168
1342
|
for (
|
|
1169
|
-
E = l - 1,
|
|
1343
|
+
E = l - 1, T = e.length - 1;
|
|
1170
1344
|
E >= f &&
|
|
1171
|
-
|
|
1172
|
-
((
|
|
1173
|
-
E--,
|
|
1345
|
+
T >= f &&
|
|
1346
|
+
((R = getOverrideValue(o, s, u, E)) === e[T] || (R && e[T] && n(R) === n(e[T])));
|
|
1347
|
+
E--, T--
|
|
1174
1348
|
) {
|
|
1175
|
-
S[
|
|
1349
|
+
S[T] = R;
|
|
1176
1350
|
}
|
|
1177
|
-
if (f >
|
|
1178
|
-
for (a = f; a <=
|
|
1351
|
+
if (f > T || f > E) {
|
|
1352
|
+
for (a = f; a <= T; a++) {
|
|
1179
1353
|
t = true;
|
|
1180
1354
|
r[STORE_NODE][a] && setSignal(r[STORE_NODE][a], wrap(e[a], r));
|
|
1181
1355
|
}
|
|
1182
1356
|
for (; a < e.length; a++) {
|
|
1183
1357
|
t = true;
|
|
1184
|
-
const
|
|
1185
|
-
r[STORE_NODE][a] && setSignal(r[STORE_NODE][a],
|
|
1186
|
-
applyState(e[a],
|
|
1358
|
+
const o = wrap(S[a], r);
|
|
1359
|
+
r[STORE_NODE][a] && setSignal(r[STORE_NODE][a], o);
|
|
1360
|
+
applyState(e[a], o, n, i);
|
|
1187
1361
|
}
|
|
1188
1362
|
t && r[STORE_NODE][$TRACK] && setSignal(r[STORE_NODE][$TRACK], void 0);
|
|
1189
1363
|
l !== e.length && r[STORE_NODE].length && setSignal(r[STORE_NODE].length, e.length);
|
|
1190
1364
|
return;
|
|
1191
1365
|
}
|
|
1192
|
-
|
|
1193
|
-
for (a =
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
c = _.get(
|
|
1197
|
-
|
|
1198
|
-
_.set(
|
|
1366
|
+
d = new Array(T + 1);
|
|
1367
|
+
for (a = T; a >= f; a--) {
|
|
1368
|
+
R = e[a];
|
|
1369
|
+
O = R ? n(R) : R;
|
|
1370
|
+
c = _.get(O);
|
|
1371
|
+
d[a] = c === undefined ? -1 : c;
|
|
1372
|
+
_.set(O, a);
|
|
1199
1373
|
}
|
|
1200
1374
|
for (c = f; c <= E; c++) {
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
a = _.get(
|
|
1375
|
+
R = getOverrideValue(o, s, u, c);
|
|
1376
|
+
O = R ? n(R) : R;
|
|
1377
|
+
a = _.get(O);
|
|
1204
1378
|
if (a !== undefined && a !== -1) {
|
|
1205
|
-
S[a] =
|
|
1206
|
-
a =
|
|
1207
|
-
_.set(
|
|
1379
|
+
S[a] = R;
|
|
1380
|
+
a = d[a];
|
|
1381
|
+
_.set(O, a);
|
|
1208
1382
|
}
|
|
1209
1383
|
}
|
|
1210
1384
|
for (a = f; a < e.length; a++) {
|
|
@@ -1217,7 +1391,7 @@ function applyState(e, t, n, i) {
|
|
|
1217
1391
|
if (f < e.length) t = true;
|
|
1218
1392
|
} else if (e.length) {
|
|
1219
1393
|
for (let t = 0, l = e.length; t < l; t++) {
|
|
1220
|
-
const l = getOverrideValue(
|
|
1394
|
+
const l = getOverrideValue(o, s, u, t);
|
|
1221
1395
|
isWrappable(l)
|
|
1222
1396
|
? applyState(e[t], wrap(l, r), n, i)
|
|
1223
1397
|
: r[STORE_NODE][t] && setSignal(r[STORE_NODE][t], e[t]);
|
|
@@ -1232,17 +1406,17 @@ function applyState(e, t, n, i) {
|
|
|
1232
1406
|
}
|
|
1233
1407
|
if (u) {
|
|
1234
1408
|
const t = u[$TRACK];
|
|
1235
|
-
const l = t || i ? getAllKeys(
|
|
1409
|
+
const l = t || i ? getAllKeys(o, s, e) : Object.keys(u);
|
|
1236
1410
|
for (let c = 0, a = l.length; c < a; c++) {
|
|
1237
1411
|
const a = l[c];
|
|
1238
1412
|
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(
|
|
1413
|
+
const E = unwrap(getOverrideValue(o, s, u, a));
|
|
1414
|
+
let T = unwrap(e[a]);
|
|
1415
|
+
if (E === T) continue;
|
|
1416
|
+
if (!E || !isWrappable(E) || (n(E) != null && n(E) !== n(T))) {
|
|
1243
1417
|
t && setSignal(t, void 0);
|
|
1244
|
-
f && setSignal(f, isWrappable(
|
|
1245
|
-
} else applyState(
|
|
1418
|
+
f && setSignal(f, isWrappable(T) ? wrap(T, r) : T);
|
|
1419
|
+
} else applyState(T, wrap(E, r), n, i);
|
|
1246
1420
|
}
|
|
1247
1421
|
}
|
|
1248
1422
|
if ((u = r[STORE_HAS])) {
|
|
@@ -1257,8 +1431,8 @@ function reconcile(e, t, n = false) {
|
|
|
1257
1431
|
return i => {
|
|
1258
1432
|
if (i == null) throw new Error("Cannot reconcile null or undefined state");
|
|
1259
1433
|
const r = typeof t === "string" ? e => e[t] : t;
|
|
1260
|
-
const
|
|
1261
|
-
if (
|
|
1434
|
+
const o = r(i);
|
|
1435
|
+
if (o !== undefined && r(e) !== r(i))
|
|
1262
1436
|
throw new Error("Cannot reconcile states with different identity");
|
|
1263
1437
|
applyState(e, i, r, n);
|
|
1264
1438
|
};
|
|
@@ -1283,19 +1457,19 @@ function createProjectionInternal(e, t = {}, n) {
|
|
|
1283
1457
|
r.set(e, t);
|
|
1284
1458
|
return t;
|
|
1285
1459
|
};
|
|
1286
|
-
const
|
|
1460
|
+
const o = wrapProjection(t);
|
|
1287
1461
|
i = computed(() => {
|
|
1288
1462
|
const t = getOwner();
|
|
1289
|
-
storeSetter(new Proxy(
|
|
1463
|
+
storeSetter(new Proxy(o, writeTraps), i => {
|
|
1290
1464
|
const r = handleAsync(t, e(i), e => {
|
|
1291
|
-
e !==
|
|
1465
|
+
e !== i && e !== undefined && storeSetter(o, reconcile(e, n?.key || "id", n?.all));
|
|
1292
1466
|
setSignal(t, undefined);
|
|
1293
1467
|
});
|
|
1294
|
-
r !==
|
|
1468
|
+
r !== i && r !== undefined && reconcile(r, n?.key || "id", n?.all)(o);
|
|
1295
1469
|
});
|
|
1296
1470
|
});
|
|
1297
|
-
i.
|
|
1298
|
-
return { store:
|
|
1471
|
+
i.Se = true;
|
|
1472
|
+
return { store: o, node: i };
|
|
1299
1473
|
}
|
|
1300
1474
|
function createProjection(e, t = {}, n) {
|
|
1301
1475
|
return createProjectionInternal(e, t, n).store;
|
|
@@ -1304,28 +1478,34 @@ const writeTraps = {
|
|
|
1304
1478
|
get(e, t) {
|
|
1305
1479
|
let n;
|
|
1306
1480
|
setWriteOverride(true);
|
|
1481
|
+
setProjectionWriteActive(true);
|
|
1307
1482
|
try {
|
|
1308
1483
|
n = e[t];
|
|
1309
1484
|
} finally {
|
|
1310
1485
|
setWriteOverride(false);
|
|
1486
|
+
setProjectionWriteActive(false);
|
|
1311
1487
|
}
|
|
1312
1488
|
return typeof n === "object" && n !== null ? new Proxy(n, writeTraps) : n;
|
|
1313
1489
|
},
|
|
1314
1490
|
set(e, t, n) {
|
|
1315
1491
|
setWriteOverride(true);
|
|
1492
|
+
setProjectionWriteActive(true);
|
|
1316
1493
|
try {
|
|
1317
1494
|
e[t] = n;
|
|
1318
1495
|
} finally {
|
|
1319
1496
|
setWriteOverride(false);
|
|
1497
|
+
setProjectionWriteActive(false);
|
|
1320
1498
|
}
|
|
1321
1499
|
return true;
|
|
1322
1500
|
},
|
|
1323
1501
|
deleteProperty(e, t) {
|
|
1324
1502
|
setWriteOverride(true);
|
|
1503
|
+
setProjectionWriteActive(true);
|
|
1325
1504
|
try {
|
|
1326
1505
|
delete e[t];
|
|
1327
1506
|
} finally {
|
|
1328
1507
|
setWriteOverride(false);
|
|
1508
|
+
setProjectionWriteActive(false);
|
|
1329
1509
|
}
|
|
1330
1510
|
return true;
|
|
1331
1511
|
}
|
|
@@ -1338,11 +1518,13 @@ const $TRACK = Symbol(0),
|
|
|
1338
1518
|
const PARENTS = new WeakMap();
|
|
1339
1519
|
const STORE_VALUE = "v",
|
|
1340
1520
|
STORE_OVERRIDE = "o",
|
|
1521
|
+
STORE_OPTIMISTIC_OVERRIDE = "x",
|
|
1341
1522
|
STORE_NODE = "n",
|
|
1342
1523
|
STORE_HAS = "h",
|
|
1343
1524
|
STORE_WRAP = "w",
|
|
1344
1525
|
STORE_LOOKUP = "l",
|
|
1345
|
-
STORE_FIREWALL = "f"
|
|
1526
|
+
STORE_FIREWALL = "f",
|
|
1527
|
+
STORE_OPTIMISTIC = "p";
|
|
1346
1528
|
function createStoreProxy(e, t = storeTraps, n) {
|
|
1347
1529
|
let i;
|
|
1348
1530
|
if (Array.isArray(e)) {
|
|
@@ -1374,9 +1556,9 @@ function getNodes(e, t) {
|
|
|
1374
1556
|
if (!n) e[t] = n = Object.create(null);
|
|
1375
1557
|
return n;
|
|
1376
1558
|
}
|
|
1377
|
-
function getNode(e, t, n, i, r = isEqual) {
|
|
1559
|
+
function getNode(e, t, n, i, r = isEqual, o) {
|
|
1378
1560
|
if (e[t]) return e[t];
|
|
1379
|
-
|
|
1561
|
+
const s = signal(
|
|
1380
1562
|
n,
|
|
1381
1563
|
{
|
|
1382
1564
|
equals: r,
|
|
@@ -1385,17 +1567,22 @@ function getNode(e, t, n, i, r = isEqual) {
|
|
|
1385
1567
|
}
|
|
1386
1568
|
},
|
|
1387
1569
|
i
|
|
1388
|
-
)
|
|
1570
|
+
);
|
|
1571
|
+
if (o) s.le = true;
|
|
1572
|
+
return (e[t] = s);
|
|
1389
1573
|
}
|
|
1390
1574
|
function trackSelf(e, t = $TRACK) {
|
|
1391
|
-
getObserver() &&
|
|
1575
|
+
getObserver() &&
|
|
1576
|
+
read(
|
|
1577
|
+
getNode(getNodes(e, STORE_NODE), t, undefined, e[STORE_FIREWALL], false, e[STORE_OPTIMISTIC])
|
|
1578
|
+
);
|
|
1392
1579
|
}
|
|
1393
1580
|
function getKeys(e, t, n = true) {
|
|
1394
1581
|
const i = untrack(() => (n ? Object.keys(e) : Reflect.ownKeys(e)));
|
|
1395
1582
|
if (!t) return i;
|
|
1396
1583
|
const r = new Set(i);
|
|
1397
|
-
const
|
|
1398
|
-
for (const e of
|
|
1584
|
+
const o = Reflect.ownKeys(t);
|
|
1585
|
+
for (const e of o) {
|
|
1399
1586
|
if (t[e] !== $DELETED) r.add(e);
|
|
1400
1587
|
else r.delete(e);
|
|
1401
1588
|
}
|
|
@@ -1421,104 +1608,170 @@ const storeTraps = {
|
|
|
1421
1608
|
}
|
|
1422
1609
|
const i = getNodes(e, STORE_NODE);
|
|
1423
1610
|
const r = i[t];
|
|
1424
|
-
const
|
|
1425
|
-
const
|
|
1426
|
-
const u =
|
|
1611
|
+
const o = e[STORE_OPTIMISTIC_OVERRIDE] && t in e[STORE_OPTIMISTIC_OVERRIDE];
|
|
1612
|
+
const s = o || (e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE]);
|
|
1613
|
+
const u = !!e[STORE_VALUE][$TARGET];
|
|
1614
|
+
const l = o
|
|
1615
|
+
? e[STORE_OPTIMISTIC_OVERRIDE]
|
|
1616
|
+
: e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE]
|
|
1617
|
+
? e[STORE_OVERRIDE]
|
|
1618
|
+
: e[STORE_VALUE];
|
|
1427
1619
|
if (!r) {
|
|
1428
|
-
const e = Object.getOwnPropertyDescriptor(
|
|
1620
|
+
const e = Object.getOwnPropertyDescriptor(l, t);
|
|
1429
1621
|
if (e && e.get) return e.get.call(n);
|
|
1430
1622
|
}
|
|
1431
1623
|
if (writeOnly(n)) {
|
|
1432
|
-
let n = r && (s || !
|
|
1624
|
+
let n = r && (s || !u) ? (r.te !== NOT_PENDING ? (r.le ? r.ne : r.te) : r.ne) : l[t];
|
|
1433
1625
|
n === $DELETED && (n = undefined);
|
|
1434
1626
|
if (!isWrappable(n)) return n;
|
|
1435
1627
|
const i = wrap(n, e);
|
|
1436
1628
|
Writing?.add(i);
|
|
1437
1629
|
return i;
|
|
1438
1630
|
}
|
|
1439
|
-
let
|
|
1440
|
-
|
|
1631
|
+
let c = r ? (s || !u ? read(i[t]) : (read(i[t]), l[t])) : l[t];
|
|
1632
|
+
c === $DELETED && (c = undefined);
|
|
1441
1633
|
if (!r) {
|
|
1442
|
-
if (!s && typeof
|
|
1634
|
+
if (!s && typeof c === "function" && !l.hasOwnProperty(t)) {
|
|
1443
1635
|
let t;
|
|
1444
1636
|
return !Array.isArray(e[STORE_VALUE]) &&
|
|
1445
1637
|
(t = Object.getPrototypeOf(e[STORE_VALUE])) &&
|
|
1446
1638
|
t !== Object.prototype
|
|
1447
|
-
?
|
|
1448
|
-
:
|
|
1639
|
+
? c.bind(l)
|
|
1640
|
+
: c;
|
|
1449
1641
|
} else if (getObserver()) {
|
|
1450
|
-
return read(
|
|
1642
|
+
return read(
|
|
1643
|
+
getNode(
|
|
1644
|
+
i,
|
|
1645
|
+
t,
|
|
1646
|
+
isWrappable(c) ? wrap(c, e) : c,
|
|
1647
|
+
e[STORE_FIREWALL],
|
|
1648
|
+
isEqual,
|
|
1649
|
+
e[STORE_OPTIMISTIC]
|
|
1650
|
+
)
|
|
1651
|
+
);
|
|
1451
1652
|
}
|
|
1452
1653
|
}
|
|
1453
|
-
return isWrappable(
|
|
1654
|
+
return isWrappable(c) ? wrap(c, e) : c;
|
|
1454
1655
|
},
|
|
1455
1656
|
has(e, t) {
|
|
1456
1657
|
if (t === $PROXY || t === $TRACK || t === "__proto__") return true;
|
|
1457
1658
|
const n =
|
|
1458
|
-
e[
|
|
1459
|
-
? e[
|
|
1460
|
-
: t in e[
|
|
1461
|
-
|
|
1659
|
+
e[STORE_OPTIMISTIC_OVERRIDE] && t in e[STORE_OPTIMISTIC_OVERRIDE]
|
|
1660
|
+
? e[STORE_OPTIMISTIC_OVERRIDE][t] !== $DELETED
|
|
1661
|
+
: e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE]
|
|
1662
|
+
? e[STORE_OVERRIDE][t] !== $DELETED
|
|
1663
|
+
: t in e[STORE_VALUE];
|
|
1664
|
+
getObserver() &&
|
|
1665
|
+
read(getNode(getNodes(e, STORE_HAS), t, n, e[STORE_FIREWALL], isEqual, e[STORE_OPTIMISTIC]));
|
|
1462
1666
|
return n;
|
|
1463
1667
|
},
|
|
1464
1668
|
set(e, t, n) {
|
|
1465
1669
|
const i = e[$PROXY];
|
|
1466
1670
|
if (writeOnly(i)) {
|
|
1671
|
+
if (e[STORE_OPTIMISTIC]) {
|
|
1672
|
+
const t = e[STORE_FIREWALL];
|
|
1673
|
+
if (t?.X) {
|
|
1674
|
+
globalQueue.initTransition(t.X);
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1467
1677
|
untrack(() => {
|
|
1468
1678
|
const r = e[STORE_VALUE];
|
|
1469
|
-
const
|
|
1470
|
-
const
|
|
1471
|
-
const u =
|
|
1472
|
-
if (
|
|
1473
|
-
const l =
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1679
|
+
const o = r[t];
|
|
1680
|
+
const s = e[STORE_OPTIMISTIC] && !projectionWriteActive;
|
|
1681
|
+
const u = s ? STORE_OPTIMISTIC_OVERRIDE : STORE_OVERRIDE;
|
|
1682
|
+
if (s) trackOptimisticStore(i);
|
|
1683
|
+
const l =
|
|
1684
|
+
e[STORE_OPTIMISTIC_OVERRIDE] && t in e[STORE_OPTIMISTIC_OVERRIDE]
|
|
1685
|
+
? e[STORE_OPTIMISTIC_OVERRIDE][t]
|
|
1686
|
+
: e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE]
|
|
1687
|
+
? e[STORE_OVERRIDE][t]
|
|
1688
|
+
: o;
|
|
1689
|
+
const c = n?.[$TARGET]?.[STORE_VALUE] ?? n;
|
|
1690
|
+
if (l === c) return true;
|
|
1691
|
+
const a = e[STORE_OPTIMISTIC_OVERRIDE]?.length || e[STORE_OVERRIDE]?.length || r.length;
|
|
1692
|
+
if (c !== undefined && c === o) delete e[u][t];
|
|
1693
|
+
else (e[u] || (e[u] = Object.create(null)))[t] = c;
|
|
1694
|
+
const f = isWrappable(c);
|
|
1695
|
+
if (isWrappable(l)) {
|
|
1696
|
+
const e = PARENTS.get(l);
|
|
1697
|
+
e && (e instanceof Set ? e.delete(i) : PARENTS.delete(l));
|
|
1480
1698
|
}
|
|
1481
|
-
if (recursivelyNotify(i, storeLookup) &&
|
|
1699
|
+
if (recursivelyNotify(i, storeLookup) && f) recursivelyAddParent(c, i);
|
|
1482
1700
|
e[STORE_HAS]?.[t] && setSignal(e[STORE_HAS][t], true);
|
|
1483
|
-
const
|
|
1484
|
-
|
|
1701
|
+
const E = getNodes(e, STORE_NODE);
|
|
1702
|
+
E[t] && setSignal(E[t], () => (f ? wrap(c, e) : c));
|
|
1485
1703
|
if (Array.isArray(r)) {
|
|
1486
|
-
|
|
1487
|
-
|
|
1704
|
+
if (t === "length") {
|
|
1705
|
+
E.length && setSignal(E.length, c);
|
|
1706
|
+
} else {
|
|
1707
|
+
const e = parseInt(t) + 1;
|
|
1708
|
+
if (e > a) E.length && setSignal(E.length, e);
|
|
1709
|
+
}
|
|
1488
1710
|
}
|
|
1489
|
-
|
|
1711
|
+
E[$TRACK] && setSignal(E[$TRACK], undefined);
|
|
1490
1712
|
});
|
|
1491
1713
|
}
|
|
1492
1714
|
return true;
|
|
1493
1715
|
},
|
|
1494
1716
|
deleteProperty(e, t) {
|
|
1495
|
-
|
|
1717
|
+
const n = e[STORE_OPTIMISTIC_OVERRIDE]?.[t] === $DELETED;
|
|
1718
|
+
const i = e[STORE_OVERRIDE]?.[t] === $DELETED;
|
|
1719
|
+
if (writeOnly(e[$PROXY]) && !n && !i) {
|
|
1496
1720
|
untrack(() => {
|
|
1497
|
-
const n =
|
|
1498
|
-
|
|
1499
|
-
if (
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1721
|
+
const n = e[STORE_OPTIMISTIC] && !projectionWriteActive;
|
|
1722
|
+
const i = n ? STORE_OPTIMISTIC_OVERRIDE : STORE_OVERRIDE;
|
|
1723
|
+
if (n) trackOptimisticStore(e[$PROXY]);
|
|
1724
|
+
const r =
|
|
1725
|
+
e[STORE_OPTIMISTIC_OVERRIDE] && t in e[STORE_OPTIMISTIC_OVERRIDE]
|
|
1726
|
+
? e[STORE_OPTIMISTIC_OVERRIDE][t]
|
|
1727
|
+
: e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE]
|
|
1728
|
+
? e[STORE_OVERRIDE][t]
|
|
1729
|
+
: e[STORE_VALUE][t];
|
|
1730
|
+
if (t in e[STORE_VALUE] || (e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE])) {
|
|
1731
|
+
(e[i] || (e[i] = Object.create(null)))[t] = $DELETED;
|
|
1732
|
+
} else if (e[i] && t in e[i]) {
|
|
1733
|
+
delete e[i][t];
|
|
1503
1734
|
} else return true;
|
|
1504
|
-
if (isWrappable(
|
|
1505
|
-
const t = PARENTS.get(
|
|
1506
|
-
t && (t instanceof Set ? t.delete(e) : PARENTS.delete(
|
|
1735
|
+
if (isWrappable(r)) {
|
|
1736
|
+
const t = PARENTS.get(r);
|
|
1737
|
+
t && (t instanceof Set ? t.delete(e) : PARENTS.delete(r));
|
|
1507
1738
|
}
|
|
1508
1739
|
if (e[STORE_HAS]?.[t]) setSignal(e[STORE_HAS][t], false);
|
|
1509
|
-
const
|
|
1510
|
-
|
|
1511
|
-
|
|
1740
|
+
const o = getNodes(e, STORE_NODE);
|
|
1741
|
+
o[t] && setSignal(o[t], undefined);
|
|
1742
|
+
o[$TRACK] && setSignal(o[$TRACK], undefined);
|
|
1512
1743
|
});
|
|
1513
1744
|
}
|
|
1514
1745
|
return true;
|
|
1515
1746
|
},
|
|
1516
1747
|
ownKeys(e) {
|
|
1517
1748
|
trackSelf(e);
|
|
1518
|
-
|
|
1749
|
+
let t = getKeys(e[STORE_VALUE], e[STORE_OVERRIDE], false);
|
|
1750
|
+
if (e[STORE_OPTIMISTIC_OVERRIDE]) {
|
|
1751
|
+
const n = new Set(t);
|
|
1752
|
+
for (const t of Reflect.ownKeys(e[STORE_OPTIMISTIC_OVERRIDE])) {
|
|
1753
|
+
if (e[STORE_OPTIMISTIC_OVERRIDE][t] !== $DELETED) n.add(t);
|
|
1754
|
+
else n.delete(t);
|
|
1755
|
+
}
|
|
1756
|
+
t = Array.from(n);
|
|
1757
|
+
}
|
|
1758
|
+
return t;
|
|
1519
1759
|
},
|
|
1520
1760
|
getOwnPropertyDescriptor(e, t) {
|
|
1521
1761
|
if (t === $PROXY) return { value: e[$PROXY], writable: true, configurable: true };
|
|
1762
|
+
if (e[STORE_OPTIMISTIC_OVERRIDE] && t in e[STORE_OPTIMISTIC_OVERRIDE]) {
|
|
1763
|
+
if (e[STORE_OPTIMISTIC_OVERRIDE][t] === $DELETED) return undefined;
|
|
1764
|
+
const n = getPropertyDescriptor(e[STORE_VALUE], e[STORE_OVERRIDE], t);
|
|
1765
|
+
if (n) {
|
|
1766
|
+
return { ...n, value: e[STORE_OPTIMISTIC_OVERRIDE][t] };
|
|
1767
|
+
}
|
|
1768
|
+
return {
|
|
1769
|
+
value: e[STORE_OPTIMISTIC_OVERRIDE][t],
|
|
1770
|
+
writable: true,
|
|
1771
|
+
enumerable: true,
|
|
1772
|
+
configurable: true
|
|
1773
|
+
};
|
|
1774
|
+
}
|
|
1522
1775
|
return getPropertyDescriptor(e[STORE_VALUE], e[STORE_OVERRIDE], t);
|
|
1523
1776
|
},
|
|
1524
1777
|
getPrototypeOf(e) {
|
|
@@ -1597,8 +1850,8 @@ function recursivelyAddParent(e, t) {
|
|
|
1597
1850
|
const t = getKeys(e, n);
|
|
1598
1851
|
for (let i = 0; i < t.length; i++) {
|
|
1599
1852
|
const r = t[i];
|
|
1600
|
-
const
|
|
1601
|
-
isWrappable(
|
|
1853
|
+
const o = n && r in n ? n[r] : e[r];
|
|
1854
|
+
isWrappable(o) && recursivelyAddParent(o, e);
|
|
1602
1855
|
}
|
|
1603
1856
|
}
|
|
1604
1857
|
}
|
|
@@ -1607,19 +1860,88 @@ function deep(e) {
|
|
|
1607
1860
|
return e[$DEEP];
|
|
1608
1861
|
}
|
|
1609
1862
|
function createOptimisticStore(e, t, n) {
|
|
1610
|
-
|
|
1863
|
+
GlobalQueue.Y ||= clearOptimisticStore;
|
|
1864
|
+
const i = typeof e === "function";
|
|
1865
|
+
const r = (i ? t : e) ?? {};
|
|
1866
|
+
const o = i ? e : undefined;
|
|
1867
|
+
const { store: s } = createOptimisticProjectionInternal(o, r, n);
|
|
1868
|
+
return [s, e => storeSetter(s, e)];
|
|
1869
|
+
}
|
|
1870
|
+
function clearOptimisticStore(e) {
|
|
1871
|
+
const t = e[$TARGET];
|
|
1872
|
+
if (!t || !t[STORE_OPTIMISTIC_OVERRIDE]) return;
|
|
1873
|
+
const n = t[STORE_OPTIMISTIC_OVERRIDE];
|
|
1874
|
+
const i = t[STORE_NODE];
|
|
1875
|
+
if (i) {
|
|
1876
|
+
for (const e of Reflect.ownKeys(n)) {
|
|
1877
|
+
if (i[e]) {
|
|
1878
|
+
const n =
|
|
1879
|
+
t[STORE_OVERRIDE] && e in t[STORE_OVERRIDE] ? t[STORE_OVERRIDE][e] : t[STORE_VALUE][e];
|
|
1880
|
+
const r = n === $DELETED ? undefined : n;
|
|
1881
|
+
setSignal(i[e], isWrappable(r) ? wrap(r, t) : r);
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
i[$TRACK] && setSignal(i[$TRACK], undefined);
|
|
1885
|
+
}
|
|
1886
|
+
delete t[STORE_OPTIMISTIC_OVERRIDE];
|
|
1887
|
+
}
|
|
1888
|
+
function createOptimisticProjectionInternal(e, t = {}, n) {
|
|
1889
|
+
let i;
|
|
1890
|
+
const r = new WeakMap();
|
|
1891
|
+
const wrapper = e => {
|
|
1892
|
+
e[STORE_WRAP] = wrapProjection;
|
|
1893
|
+
e[STORE_LOOKUP] = r;
|
|
1894
|
+
e[STORE_OPTIMISTIC] = true;
|
|
1895
|
+
Object.defineProperty(e, STORE_FIREWALL, {
|
|
1896
|
+
get() {
|
|
1897
|
+
return i;
|
|
1898
|
+
},
|
|
1899
|
+
configurable: true
|
|
1900
|
+
});
|
|
1901
|
+
};
|
|
1902
|
+
const wrapProjection = e => {
|
|
1903
|
+
if (r.has(e)) return r.get(e);
|
|
1904
|
+
if (e[$TARGET]?.[STORE_WRAP] === wrapProjection) return e;
|
|
1905
|
+
const t = createStoreProxy(e, storeTraps, wrapper);
|
|
1906
|
+
r.set(e, t);
|
|
1907
|
+
return t;
|
|
1908
|
+
};
|
|
1909
|
+
const o = wrapProjection(t);
|
|
1910
|
+
if (e) {
|
|
1911
|
+
i = computed(() => {
|
|
1912
|
+
const t = getOwner();
|
|
1913
|
+
setProjectionWriteActive(true);
|
|
1914
|
+
try {
|
|
1915
|
+
storeSetter(new Proxy(o, writeTraps), i => {
|
|
1916
|
+
const r = handleAsync(t, e(i), e => {
|
|
1917
|
+
setProjectionWriteActive(true);
|
|
1918
|
+
try {
|
|
1919
|
+
e !== i && e !== undefined && storeSetter(o, reconcile(e, n?.key || "id", n?.all));
|
|
1920
|
+
} finally {
|
|
1921
|
+
setProjectionWriteActive(false);
|
|
1922
|
+
}
|
|
1923
|
+
});
|
|
1924
|
+
r !== i && r !== undefined && reconcile(r, n?.key || "id", n?.all)(o);
|
|
1925
|
+
});
|
|
1926
|
+
} finally {
|
|
1927
|
+
setProjectionWriteActive(false);
|
|
1928
|
+
}
|
|
1929
|
+
});
|
|
1930
|
+
i.Se = true;
|
|
1931
|
+
}
|
|
1932
|
+
return { store: o, node: i };
|
|
1611
1933
|
}
|
|
1612
1934
|
function snapshot(e, t, n) {
|
|
1613
|
-
let i, r,
|
|
1935
|
+
let i, r, o, s, u, l;
|
|
1614
1936
|
if (!isWrappable(e)) return e;
|
|
1615
1937
|
if (t && t.has(e)) return t.get(e);
|
|
1616
1938
|
if (!t) t = new Map();
|
|
1617
1939
|
if ((i = e[$TARGET] || n?.get(e)?.[$TARGET])) {
|
|
1618
|
-
|
|
1940
|
+
o = i[STORE_OVERRIDE];
|
|
1619
1941
|
r = Array.isArray(i[STORE_VALUE]);
|
|
1620
1942
|
t.set(
|
|
1621
1943
|
e,
|
|
1622
|
-
|
|
1944
|
+
o ? (s = r ? [] : Object.create(Object.getPrototypeOf(i[STORE_VALUE]))) : i[STORE_VALUE]
|
|
1623
1945
|
);
|
|
1624
1946
|
e = i[STORE_VALUE];
|
|
1625
1947
|
n = storeLookup;
|
|
@@ -1628,32 +1950,32 @@ function snapshot(e, t, n) {
|
|
|
1628
1950
|
t.set(e, e);
|
|
1629
1951
|
}
|
|
1630
1952
|
if (r) {
|
|
1631
|
-
const i =
|
|
1953
|
+
const i = o?.length || e.length;
|
|
1632
1954
|
for (let r = 0; r < i; r++) {
|
|
1633
|
-
l =
|
|
1955
|
+
l = o && r in o ? o[r] : e[r];
|
|
1634
1956
|
if (l === $DELETED) continue;
|
|
1635
|
-
if ((u = snapshot(l, t, n)) !== l ||
|
|
1636
|
-
if (!
|
|
1637
|
-
|
|
1957
|
+
if ((u = snapshot(l, t, n)) !== l || s) {
|
|
1958
|
+
if (!s) t.set(e, (s = [...e]));
|
|
1959
|
+
s[r] = u;
|
|
1638
1960
|
}
|
|
1639
1961
|
}
|
|
1640
1962
|
} else {
|
|
1641
|
-
const i = getKeys(e,
|
|
1963
|
+
const i = getKeys(e, o);
|
|
1642
1964
|
for (let r = 0, c = i.length; r < c; r++) {
|
|
1643
1965
|
let c = i[r];
|
|
1644
|
-
const a = getPropertyDescriptor(e,
|
|
1966
|
+
const a = getPropertyDescriptor(e, o, c);
|
|
1645
1967
|
if (a.get) continue;
|
|
1646
|
-
l =
|
|
1647
|
-
if ((u = snapshot(l, t, n)) !== e[c] ||
|
|
1648
|
-
if (!
|
|
1649
|
-
|
|
1650
|
-
Object.assign(
|
|
1968
|
+
l = o && c in o ? o[c] : e[c];
|
|
1969
|
+
if ((u = snapshot(l, t, n)) !== e[c] || s) {
|
|
1970
|
+
if (!s) {
|
|
1971
|
+
s = Object.create(Object.getPrototypeOf(e));
|
|
1972
|
+
Object.assign(s, e);
|
|
1651
1973
|
}
|
|
1652
|
-
|
|
1974
|
+
s[c] = u;
|
|
1653
1975
|
}
|
|
1654
1976
|
}
|
|
1655
1977
|
}
|
|
1656
|
-
return
|
|
1978
|
+
return s || e;
|
|
1657
1979
|
}
|
|
1658
1980
|
function trueFn() {
|
|
1659
1981
|
return true;
|
|
@@ -1695,8 +2017,8 @@ function merge(...e) {
|
|
|
1695
2017
|
for (let i = 0; i < e.length; i++) {
|
|
1696
2018
|
const r = e[i];
|
|
1697
2019
|
t = t || (!!r && $PROXY in r);
|
|
1698
|
-
const
|
|
1699
|
-
if (
|
|
2020
|
+
const o = !!r && r[$SOURCES];
|
|
2021
|
+
if (o) n.push(...o);
|
|
1700
2022
|
else n.push(typeof r === "function" ? ((t = true), createMemo(r)) : r);
|
|
1701
2023
|
}
|
|
1702
2024
|
if (SUPPORTS_PROXY && t) {
|
|
@@ -1726,35 +2048,35 @@ function merge(...e) {
|
|
|
1726
2048
|
}
|
|
1727
2049
|
const i = Object.create(null);
|
|
1728
2050
|
let r = false;
|
|
1729
|
-
let
|
|
1730
|
-
for (let e =
|
|
2051
|
+
let o = n.length - 1;
|
|
2052
|
+
for (let e = o; e >= 0; e--) {
|
|
1731
2053
|
const t = n[e];
|
|
1732
2054
|
if (!t) {
|
|
1733
|
-
e ===
|
|
2055
|
+
e === o && o--;
|
|
1734
2056
|
continue;
|
|
1735
2057
|
}
|
|
1736
|
-
const
|
|
1737
|
-
for (let n =
|
|
1738
|
-
const u =
|
|
2058
|
+
const s = Object.getOwnPropertyNames(t);
|
|
2059
|
+
for (let n = s.length - 1; n >= 0; n--) {
|
|
2060
|
+
const u = s[n];
|
|
1739
2061
|
if (u === "__proto__" || u === "constructor") continue;
|
|
1740
2062
|
if (!i[u]) {
|
|
1741
|
-
r = r || e !==
|
|
2063
|
+
r = r || e !== o;
|
|
1742
2064
|
const n = Object.getOwnPropertyDescriptor(t, u);
|
|
1743
2065
|
i[u] = n.get ? { enumerable: true, configurable: true, get: n.get.bind(t) } : n;
|
|
1744
2066
|
}
|
|
1745
2067
|
}
|
|
1746
2068
|
}
|
|
1747
|
-
if (!r) return n[
|
|
1748
|
-
const
|
|
2069
|
+
if (!r) return n[o];
|
|
2070
|
+
const s = {};
|
|
1749
2071
|
const u = Object.keys(i);
|
|
1750
2072
|
for (let e = u.length - 1; e >= 0; e--) {
|
|
1751
2073
|
const t = u[e],
|
|
1752
2074
|
n = i[t];
|
|
1753
|
-
if (n.get) Object.defineProperty(
|
|
1754
|
-
else
|
|
2075
|
+
if (n.get) Object.defineProperty(s, t, n);
|
|
2076
|
+
else s[t] = n.value;
|
|
1755
2077
|
}
|
|
1756
|
-
|
|
1757
|
-
return
|
|
2078
|
+
s[$SOURCES] = n;
|
|
2079
|
+
return s;
|
|
1758
2080
|
}
|
|
1759
2081
|
function omit(e, ...t) {
|
|
1760
2082
|
const n = new Set(t);
|
|
@@ -1789,247 +2111,241 @@ function mapArray(e, t, n) {
|
|
|
1789
2111
|
const i = typeof n?.keyed === "function" ? n.keyed : undefined;
|
|
1790
2112
|
return createMemo(
|
|
1791
2113
|
updateKeyedMap.bind({
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
2114
|
+
De: createOwner(),
|
|
2115
|
+
we: 0,
|
|
2116
|
+
be: e,
|
|
2117
|
+
ve: [],
|
|
2118
|
+
Ve: t,
|
|
2119
|
+
me: [],
|
|
2120
|
+
Ue: [],
|
|
2121
|
+
ke: i,
|
|
2122
|
+
We: i || n?.keyed === false ? [] : undefined,
|
|
2123
|
+
xe: t.length > 1 ? [] : undefined,
|
|
2124
|
+
Qe: n?.fallback
|
|
1803
2125
|
})
|
|
1804
2126
|
);
|
|
1805
2127
|
}
|
|
1806
2128
|
const pureOptions = { pureWrite: true };
|
|
1807
2129
|
function updateKeyedMap() {
|
|
1808
|
-
const e = this.
|
|
2130
|
+
const e = this.be() || [],
|
|
1809
2131
|
t = e.length;
|
|
1810
2132
|
e[$TRACK];
|
|
1811
|
-
runWithOwner(this.
|
|
2133
|
+
runWithOwner(this.De, () => {
|
|
1812
2134
|
let n,
|
|
1813
2135
|
i,
|
|
1814
|
-
r = this.
|
|
2136
|
+
r = this.We
|
|
1815
2137
|
? () => {
|
|
1816
|
-
this.
|
|
1817
|
-
this.
|
|
1818
|
-
return this.
|
|
1819
|
-
read.bind(null, this.
|
|
1820
|
-
this.
|
|
2138
|
+
this.We[i] = signal(e[i], pureOptions);
|
|
2139
|
+
this.xe && (this.xe[i] = signal(i, pureOptions));
|
|
2140
|
+
return this.Ve(
|
|
2141
|
+
read.bind(null, this.We[i]),
|
|
2142
|
+
this.xe ? read.bind(null, this.xe[i]) : undefined
|
|
1821
2143
|
);
|
|
1822
2144
|
}
|
|
1823
|
-
: this.
|
|
2145
|
+
: this.xe
|
|
1824
2146
|
? () => {
|
|
1825
2147
|
const t = e[i];
|
|
1826
|
-
this.
|
|
1827
|
-
return this.
|
|
2148
|
+
this.xe[i] = signal(i, pureOptions);
|
|
2149
|
+
return this.Ve(() => t, read.bind(null, this.xe[i]));
|
|
1828
2150
|
}
|
|
1829
2151
|
: () => {
|
|
1830
2152
|
const t = e[i];
|
|
1831
|
-
return this.
|
|
2153
|
+
return this.Ve(() => t);
|
|
1832
2154
|
};
|
|
1833
2155
|
if (t === 0) {
|
|
1834
|
-
if (this.
|
|
1835
|
-
this.
|
|
1836
|
-
this.
|
|
1837
|
-
this.
|
|
1838
|
-
this.
|
|
1839
|
-
this.
|
|
1840
|
-
this.
|
|
1841
|
-
this.
|
|
2156
|
+
if (this.we !== 0) {
|
|
2157
|
+
this.De.dispose(false);
|
|
2158
|
+
this.Ue = [];
|
|
2159
|
+
this.ve = [];
|
|
2160
|
+
this.me = [];
|
|
2161
|
+
this.we = 0;
|
|
2162
|
+
this.We && (this.We = []);
|
|
2163
|
+
this.xe && (this.xe = []);
|
|
1842
2164
|
}
|
|
1843
|
-
if (this.
|
|
1844
|
-
this.
|
|
2165
|
+
if (this.Qe && !this.me[0]) {
|
|
2166
|
+
this.me[0] = runWithOwner((this.Ue[0] = createOwner()), this.Qe);
|
|
1845
2167
|
}
|
|
1846
|
-
} else if (this.
|
|
1847
|
-
if (this.
|
|
1848
|
-
this.
|
|
2168
|
+
} else if (this.we === 0) {
|
|
2169
|
+
if (this.Ue[0]) this.Ue[0].dispose();
|
|
2170
|
+
this.me = new Array(t);
|
|
1849
2171
|
for (i = 0; i < t; i++) {
|
|
1850
|
-
this.
|
|
1851
|
-
this.
|
|
2172
|
+
this.ve[i] = e[i];
|
|
2173
|
+
this.me[i] = runWithOwner((this.Ue[i] = createOwner()), r);
|
|
1852
2174
|
}
|
|
1853
|
-
this.
|
|
2175
|
+
this.we = t;
|
|
1854
2176
|
} else {
|
|
1855
|
-
let
|
|
1856
|
-
|
|
2177
|
+
let o,
|
|
2178
|
+
s,
|
|
1857
2179
|
u,
|
|
1858
2180
|
l,
|
|
1859
2181
|
c,
|
|
1860
2182
|
a,
|
|
1861
2183
|
f,
|
|
1862
2184
|
E = new Array(t),
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
2185
|
+
T = new Array(t),
|
|
2186
|
+
R = this.We ? new Array(t) : undefined,
|
|
2187
|
+
d = this.xe ? new Array(t) : undefined;
|
|
1866
2188
|
for (
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
2189
|
+
o = 0, s = Math.min(this.we, t);
|
|
2190
|
+
o < s && (this.ve[o] === e[o] || (this.We && compare(this.ke, this.ve[o], e[o])));
|
|
2191
|
+
o++
|
|
1870
2192
|
) {
|
|
1871
|
-
if (this.
|
|
2193
|
+
if (this.We) setSignal(this.We[o], e[o]);
|
|
1872
2194
|
}
|
|
1873
2195
|
for (
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
u >=
|
|
1877
|
-
(this.
|
|
1878
|
-
|
|
2196
|
+
s = this.we - 1, u = t - 1;
|
|
2197
|
+
s >= o &&
|
|
2198
|
+
u >= o &&
|
|
2199
|
+
(this.ve[s] === e[u] || (this.We && compare(this.ke, this.ve[s], e[u])));
|
|
2200
|
+
s--, u--
|
|
1879
2201
|
) {
|
|
1880
|
-
E[u] = this.
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
2202
|
+
E[u] = this.me[s];
|
|
2203
|
+
T[u] = this.Ue[s];
|
|
2204
|
+
R && (R[u] = this.We[s]);
|
|
2205
|
+
d && (d[u] = this.xe[s]);
|
|
1884
2206
|
}
|
|
1885
2207
|
a = new Map();
|
|
1886
2208
|
f = new Array(u + 1);
|
|
1887
|
-
for (i = u; i >=
|
|
2209
|
+
for (i = u; i >= o; i--) {
|
|
1888
2210
|
l = e[i];
|
|
1889
|
-
c = this.
|
|
2211
|
+
c = this.ke ? this.ke(l) : l;
|
|
1890
2212
|
n = a.get(c);
|
|
1891
2213
|
f[i] = n === undefined ? -1 : n;
|
|
1892
2214
|
a.set(c, i);
|
|
1893
2215
|
}
|
|
1894
|
-
for (n =
|
|
1895
|
-
l = this.
|
|
1896
|
-
c = this.
|
|
2216
|
+
for (n = o; n <= s; n++) {
|
|
2217
|
+
l = this.ve[n];
|
|
2218
|
+
c = this.ke ? this.ke(l) : l;
|
|
1897
2219
|
i = a.get(c);
|
|
1898
2220
|
if (i !== undefined && i !== -1) {
|
|
1899
|
-
E[i] = this.
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
2221
|
+
E[i] = this.me[n];
|
|
2222
|
+
T[i] = this.Ue[n];
|
|
2223
|
+
R && (R[i] = this.We[n]);
|
|
2224
|
+
d && (d[i] = this.xe[n]);
|
|
1903
2225
|
i = f[i];
|
|
1904
2226
|
a.set(c, i);
|
|
1905
|
-
} else this.
|
|
2227
|
+
} else this.Ue[n].dispose();
|
|
1906
2228
|
}
|
|
1907
|
-
for (i =
|
|
2229
|
+
for (i = o; i < t; i++) {
|
|
1908
2230
|
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
|
-
}
|
|
2231
|
+
this.me[i] = E[i];
|
|
2232
|
+
this.Ue[i] = T[i];
|
|
1915
2233
|
if (R) {
|
|
1916
|
-
this.
|
|
1917
|
-
setSignal(this.
|
|
2234
|
+
this.We[i] = R[i];
|
|
2235
|
+
setSignal(this.We[i], e[i]);
|
|
2236
|
+
}
|
|
2237
|
+
if (d) {
|
|
2238
|
+
this.xe[i] = d[i];
|
|
2239
|
+
setSignal(this.xe[i], i);
|
|
1918
2240
|
}
|
|
1919
2241
|
} else {
|
|
1920
|
-
this.
|
|
2242
|
+
this.me[i] = runWithOwner((this.Ue[i] = createOwner()), r);
|
|
1921
2243
|
}
|
|
1922
2244
|
}
|
|
1923
|
-
this.
|
|
1924
|
-
this.
|
|
2245
|
+
this.me = this.me.slice(0, (this.we = t));
|
|
2246
|
+
this.ve = e.slice(0);
|
|
1925
2247
|
}
|
|
1926
2248
|
});
|
|
1927
|
-
return this.
|
|
2249
|
+
return this.me;
|
|
1928
2250
|
}
|
|
1929
2251
|
function repeat(e, t, n) {
|
|
1930
2252
|
return updateRepeat.bind({
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
2253
|
+
De: createOwner(),
|
|
2254
|
+
we: 0,
|
|
2255
|
+
Ge: 0,
|
|
2256
|
+
Me: e,
|
|
2257
|
+
Ve: t,
|
|
2258
|
+
Ue: [],
|
|
2259
|
+
me: [],
|
|
2260
|
+
$e: n?.from,
|
|
2261
|
+
Qe: n?.fallback
|
|
1940
2262
|
});
|
|
1941
2263
|
}
|
|
1942
2264
|
function updateRepeat() {
|
|
1943
|
-
const e = this.
|
|
1944
|
-
const t = this
|
|
1945
|
-
runWithOwner(this.
|
|
2265
|
+
const e = this.Me();
|
|
2266
|
+
const t = this.$e?.() || 0;
|
|
2267
|
+
runWithOwner(this.De, () => {
|
|
1946
2268
|
if (e === 0) {
|
|
1947
|
-
if (this.
|
|
1948
|
-
this.
|
|
1949
|
-
this.
|
|
1950
|
-
this.
|
|
1951
|
-
this.
|
|
2269
|
+
if (this.we !== 0) {
|
|
2270
|
+
this.De.dispose(false);
|
|
2271
|
+
this.Ue = [];
|
|
2272
|
+
this.me = [];
|
|
2273
|
+
this.we = 0;
|
|
1952
2274
|
}
|
|
1953
|
-
if (this.
|
|
1954
|
-
this.
|
|
2275
|
+
if (this.Qe && !this.me[0]) {
|
|
2276
|
+
this.me[0] = runWithOwner((this.Ue[0] = createOwner()), this.Qe);
|
|
1955
2277
|
}
|
|
1956
2278
|
return;
|
|
1957
2279
|
}
|
|
1958
2280
|
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.
|
|
2281
|
+
const i = this.Ge + this.we;
|
|
2282
|
+
if (this.we === 0 && this.Ue[0]) this.Ue[0].dispose();
|
|
2283
|
+
for (let e = n; e < i; e++) this.Ue[e - this.Ge].dispose();
|
|
2284
|
+
if (this.Ge < t) {
|
|
2285
|
+
let e = this.Ge;
|
|
2286
|
+
while (e < t && e < this.we) this.Ue[e++].dispose();
|
|
2287
|
+
this.Ue.splice(0, t - this.Ge);
|
|
2288
|
+
this.me.splice(0, t - this.Ge);
|
|
2289
|
+
} else if (this.Ge > t) {
|
|
2290
|
+
let n = i - this.Ge - 1;
|
|
2291
|
+
let r = this.Ge - t;
|
|
2292
|
+
this.Ue.length = this.me.length = e;
|
|
1971
2293
|
while (n >= r) {
|
|
1972
|
-
this.
|
|
1973
|
-
this.
|
|
2294
|
+
this.Ue[n] = this.Ue[n - r];
|
|
2295
|
+
this.me[n] = this.me[n - r];
|
|
1974
2296
|
n--;
|
|
1975
2297
|
}
|
|
1976
2298
|
for (let e = 0; e < r; e++) {
|
|
1977
|
-
this.
|
|
2299
|
+
this.me[e] = runWithOwner((this.Ue[e] = createOwner()), () => this.Ve(e + t));
|
|
1978
2300
|
}
|
|
1979
2301
|
}
|
|
1980
2302
|
for (let e = i; e < n; e++) {
|
|
1981
|
-
this.
|
|
2303
|
+
this.me[e - t] = runWithOwner((this.Ue[e - t] = createOwner()), () => this.Ve(e));
|
|
1982
2304
|
}
|
|
1983
|
-
this.
|
|
1984
|
-
this.
|
|
1985
|
-
this.
|
|
2305
|
+
this.me = this.me.slice(0, e);
|
|
2306
|
+
this.Ge = t;
|
|
2307
|
+
this.we = e;
|
|
1986
2308
|
});
|
|
1987
|
-
return this.
|
|
2309
|
+
return this.me;
|
|
1988
2310
|
}
|
|
1989
2311
|
function compare(e, t, n) {
|
|
1990
2312
|
return e ? e(t) === e(n) : true;
|
|
1991
2313
|
}
|
|
1992
2314
|
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;
|
|
2315
|
+
const n = computed(e, undefined, { lazy: true });
|
|
2316
|
+
n.Te = () => {
|
|
2317
|
+
const e = n.ie;
|
|
2318
|
+
n.ie &= ~n.Le;
|
|
2319
|
+
n.J.notify(n, n.Le, e);
|
|
2320
|
+
};
|
|
2321
|
+
n.Le = t;
|
|
2322
|
+
n.Se = true;
|
|
2323
|
+
recompute(n, true);
|
|
2008
2324
|
return n;
|
|
2009
2325
|
}
|
|
2010
2326
|
function createBoundChildren(e, t, n, i) {
|
|
2011
|
-
const r = e.
|
|
2012
|
-
r.addChild((e.
|
|
2013
|
-
onCleanup(() => r.removeChild(e.
|
|
2327
|
+
const r = e.J;
|
|
2328
|
+
r.addChild((e.J = n));
|
|
2329
|
+
onCleanup(() => r.removeChild(e.J));
|
|
2014
2330
|
return runWithOwner(e, () => {
|
|
2015
2331
|
const e = computed(t);
|
|
2016
2332
|
return boundaryComputed(() => staleValues(() => flatten(read(e))), i);
|
|
2017
2333
|
});
|
|
2018
2334
|
}
|
|
2019
2335
|
class ConditionalQueue extends Queue {
|
|
2020
|
-
|
|
2021
|
-
|
|
2336
|
+
He;
|
|
2337
|
+
Fe = new Set();
|
|
2022
2338
|
L = new Set();
|
|
2023
2339
|
constructor(e) {
|
|
2024
2340
|
super();
|
|
2025
|
-
this.
|
|
2341
|
+
this.He = e;
|
|
2026
2342
|
}
|
|
2027
2343
|
run(e) {
|
|
2028
|
-
if (!e || read(this.
|
|
2344
|
+
if (!e || read(this.He)) return;
|
|
2029
2345
|
return super.run(e);
|
|
2030
2346
|
}
|
|
2031
2347
|
notify(e, t, n) {
|
|
2032
|
-
if (read(this.
|
|
2348
|
+
if (read(this.He)) {
|
|
2033
2349
|
if (t & STATUS_PENDING) {
|
|
2034
2350
|
if (n & STATUS_PENDING) {
|
|
2035
2351
|
this.L.add(e);
|
|
@@ -2038,37 +2354,37 @@ class ConditionalQueue extends Queue {
|
|
|
2038
2354
|
}
|
|
2039
2355
|
if (t & STATUS_ERROR) {
|
|
2040
2356
|
if (n & STATUS_ERROR) {
|
|
2041
|
-
this
|
|
2357
|
+
this.Fe.add(e);
|
|
2042
2358
|
t &= ~STATUS_ERROR;
|
|
2043
|
-
} else if (this
|
|
2359
|
+
} else if (this.Fe.delete(e)) t &= ~STATUS_ERROR;
|
|
2044
2360
|
}
|
|
2045
2361
|
}
|
|
2046
2362
|
return t ? super.notify(e, t, n) : true;
|
|
2047
2363
|
}
|
|
2048
2364
|
}
|
|
2049
2365
|
class CollectionQueue extends Queue {
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2366
|
+
je;
|
|
2367
|
+
Ue = new Set();
|
|
2368
|
+
He = signal(false, { pureWrite: true });
|
|
2369
|
+
Ke = false;
|
|
2054
2370
|
constructor(e) {
|
|
2055
2371
|
super();
|
|
2056
|
-
this.
|
|
2372
|
+
this.je = e;
|
|
2057
2373
|
}
|
|
2058
2374
|
run(e) {
|
|
2059
|
-
if (!e || read(this.
|
|
2375
|
+
if (!e || read(this.He)) return;
|
|
2060
2376
|
return super.run(e);
|
|
2061
2377
|
}
|
|
2062
2378
|
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.
|
|
2379
|
+
if (!(t & this.je) || (this.je & STATUS_PENDING && this.Ke)) return super.notify(e, t, n);
|
|
2380
|
+
if (n & this.je) {
|
|
2381
|
+
this.Ue.add(e);
|
|
2382
|
+
if (this.Ue.size === 1) setSignal(this.He, true);
|
|
2383
|
+
} else if (this.Ue.size > 0) {
|
|
2384
|
+
this.Ue.delete(e);
|
|
2385
|
+
if (this.Ue.size === 0) setSignal(this.He, false);
|
|
2386
|
+
}
|
|
2387
|
+
t &= ~this.je;
|
|
2072
2388
|
return t ? super.notify(e, t, n) : true;
|
|
2073
2389
|
}
|
|
2074
2390
|
}
|
|
@@ -2082,53 +2398,55 @@ function createBoundary(e, t) {
|
|
|
2082
2398
|
const i = new ConditionalQueue(computed(() => t() === BoundaryMode.HIDDEN));
|
|
2083
2399
|
const r = createBoundChildren(n, e, i, 0);
|
|
2084
2400
|
computed(() => {
|
|
2085
|
-
const e = read(i.
|
|
2086
|
-
r.
|
|
2401
|
+
const e = read(i.He);
|
|
2402
|
+
r.Le = e ? STATUS_ERROR | STATUS_PENDING : 0;
|
|
2087
2403
|
if (!e) {
|
|
2088
2404
|
i.L.forEach(e => i.notify(e, STATUS_PENDING, STATUS_PENDING));
|
|
2089
|
-
i
|
|
2405
|
+
i.Fe.forEach(e => i.notify(e, STATUS_ERROR, STATUS_ERROR));
|
|
2090
2406
|
i.L.clear();
|
|
2091
|
-
i
|
|
2407
|
+
i.Fe.clear();
|
|
2092
2408
|
}
|
|
2093
2409
|
});
|
|
2094
|
-
return () => (read(i.
|
|
2410
|
+
return () => (read(i.He) ? undefined : read(r));
|
|
2095
2411
|
}
|
|
2096
2412
|
function createCollectionBoundary(e, t, n) {
|
|
2097
2413
|
const i = createOwner();
|
|
2098
2414
|
const r = new CollectionQueue(e);
|
|
2099
|
-
const
|
|
2100
|
-
const
|
|
2101
|
-
if (!read(r.
|
|
2102
|
-
const e = read(
|
|
2103
|
-
if (!untrack(() => read(r.
|
|
2104
|
-
|
|
2415
|
+
const o = createBoundChildren(i, t, r, e);
|
|
2416
|
+
const s = computed(() => {
|
|
2417
|
+
if (!read(r.He)) {
|
|
2418
|
+
const e = read(o);
|
|
2419
|
+
if (!untrack(() => read(r.He))) {
|
|
2420
|
+
r.Ke = true;
|
|
2421
|
+
return e;
|
|
2422
|
+
}
|
|
2105
2423
|
}
|
|
2106
2424
|
return n(r);
|
|
2107
2425
|
});
|
|
2108
|
-
return read.bind(null,
|
|
2426
|
+
return read.bind(null, s);
|
|
2109
2427
|
}
|
|
2110
2428
|
function createLoadBoundary(e, t) {
|
|
2111
2429
|
return createCollectionBoundary(STATUS_PENDING, e, () => t());
|
|
2112
2430
|
}
|
|
2113
2431
|
function collectErrorSources(e, t) {
|
|
2114
2432
|
let n = true;
|
|
2115
|
-
let i = e.
|
|
2433
|
+
let i = e.C;
|
|
2116
2434
|
while (i !== null) {
|
|
2117
2435
|
const e = i.V;
|
|
2118
|
-
if (e.
|
|
2436
|
+
if (e.C && e.ie & STATUS_ERROR) {
|
|
2119
2437
|
n = false;
|
|
2120
2438
|
collectErrorSources(e, t);
|
|
2121
2439
|
}
|
|
2122
|
-
i = i.
|
|
2440
|
+
i = i.D;
|
|
2123
2441
|
}
|
|
2124
2442
|
n && t.push(e);
|
|
2125
2443
|
}
|
|
2126
2444
|
function createErrorBoundary(e, t) {
|
|
2127
2445
|
return createCollectionBoundary(STATUS_ERROR, e, e => {
|
|
2128
|
-
let n = e.
|
|
2129
|
-
return t(n.
|
|
2446
|
+
let n = e.Ue.values().next().value;
|
|
2447
|
+
return t(n.B, () => {
|
|
2130
2448
|
const t = [];
|
|
2131
|
-
for (const n of e.
|
|
2449
|
+
for (const n of e.Ue) collectErrorSources(n, t);
|
|
2132
2450
|
for (const e of t) recompute(e);
|
|
2133
2451
|
schedule();
|
|
2134
2452
|
});
|
|
@@ -2158,9 +2476,9 @@ function flatten(e, t) {
|
|
|
2158
2476
|
function flattenArray(e, t = [], n) {
|
|
2159
2477
|
let i = null;
|
|
2160
2478
|
let r = false;
|
|
2161
|
-
for (let
|
|
2479
|
+
for (let o = 0; o < e.length; o++) {
|
|
2162
2480
|
try {
|
|
2163
|
-
let i = e[
|
|
2481
|
+
let i = e[o];
|
|
2164
2482
|
if (typeof i === "function" && !i.length) {
|
|
2165
2483
|
if (n?.doNotUnwrap) {
|
|
2166
2484
|
t.push(i);
|