@solidjs/signals 0.9.4 → 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 +739 -380
- package/dist/node.cjs +1273 -977
- package/dist/prod.js +1132 -796
- 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 +15 -5
- 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
|
-
this.L.push(...activeTransition.pendingNodes);
|
|
227
|
-
this.$ !== activeTransition.optimisticNodes &&
|
|
228
|
-
this.$.push(...activeTransition.optimisticNodes);
|
|
252
|
+
this.L !== activeTransition.pendingNodes && this.L.push(...activeTransition.pendingNodes);
|
|
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
|
}
|
|
@@ -253,80 +283,109 @@ class GlobalQueue extends Queue {
|
|
|
253
283
|
return false;
|
|
254
284
|
}
|
|
255
285
|
initTransition(e) {
|
|
256
|
-
if (
|
|
286
|
+
if (e) e = currentTransition(e);
|
|
287
|
+
if (e && e === activeTransition) return;
|
|
288
|
+
if (!e && activeTransition && activeTransition.time === clock) return;
|
|
257
289
|
if (!activeTransition) {
|
|
258
|
-
activeTransition = e
|
|
290
|
+
activeTransition = e ?? {
|
|
259
291
|
time: clock,
|
|
260
292
|
pendingNodes: [],
|
|
261
293
|
asyncNodes: [],
|
|
262
294
|
optimisticNodes: [],
|
|
295
|
+
optimisticStores: new Set(),
|
|
263
296
|
actions: [],
|
|
264
|
-
queueStash: {
|
|
297
|
+
queueStash: { W: [[], []], M: [] },
|
|
265
298
|
done: false
|
|
266
299
|
};
|
|
300
|
+
} else if (e) {
|
|
301
|
+
activeTransition.done = e;
|
|
302
|
+
e.actions.push(...activeTransition.actions);
|
|
303
|
+
transitions.delete(activeTransition);
|
|
304
|
+
activeTransition = e;
|
|
267
305
|
}
|
|
268
306
|
transitions.add(activeTransition);
|
|
269
307
|
activeTransition.time = clock;
|
|
270
308
|
for (let e = 0; e < this.L.length; e++) {
|
|
271
309
|
const t = this.L[e];
|
|
272
|
-
t.
|
|
310
|
+
t.X = activeTransition;
|
|
273
311
|
activeTransition.pendingNodes.push(t);
|
|
274
312
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
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;
|
|
278
317
|
activeTransition.optimisticNodes.push(t);
|
|
279
318
|
}
|
|
280
|
-
this.
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
for (let t = e.O; t !== null; t = t.p) {
|
|
286
|
-
const e = t.A.S & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue;
|
|
287
|
-
if (e.C > t.A.o) e.C = t.A.o;
|
|
288
|
-
insertIntoHeap(t.A, e);
|
|
319
|
+
this.H = activeTransition.optimisticNodes;
|
|
320
|
+
for (const e of this.F) {
|
|
321
|
+
activeTransition.optimisticStores.add(e);
|
|
322
|
+
}
|
|
323
|
+
this.F = activeTransition.optimisticStores;
|
|
289
324
|
}
|
|
290
325
|
}
|
|
291
|
-
function
|
|
292
|
-
let
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
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;
|
|
300
336
|
}
|
|
301
|
-
i
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
globalQueue.$ = [];
|
|
305
|
-
if (dirtyQueue.h >= dirtyQueue.C) {
|
|
306
|
-
t = true;
|
|
307
|
-
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);
|
|
308
340
|
}
|
|
309
|
-
optimisticRun = false;
|
|
310
|
-
t && runPending(globalQueue.L);
|
|
311
341
|
}
|
|
312
|
-
function
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
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();
|
|
319
379
|
}
|
|
320
|
-
if (n.U) GlobalQueue.W(n, false, true);
|
|
321
380
|
}
|
|
322
|
-
e.length = 0;
|
|
323
381
|
}
|
|
324
|
-
function
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
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;
|
|
330
389
|
}
|
|
331
390
|
}
|
|
332
391
|
const globalQueue = new GlobalQueue();
|
|
@@ -343,7 +402,7 @@ function transitionComplete(e) {
|
|
|
343
402
|
if (e.actions.length) return false;
|
|
344
403
|
let t = true;
|
|
345
404
|
for (let n = 0; n < e.asyncNodes.length; n++) {
|
|
346
|
-
if (e.asyncNodes[n].
|
|
405
|
+
if (e.asyncNodes[n].ie & STATUS_PENDING) {
|
|
347
406
|
t = false;
|
|
348
407
|
break;
|
|
349
408
|
}
|
|
@@ -351,168 +410,271 @@ function transitionComplete(e) {
|
|
|
351
410
|
t && (e.done = true);
|
|
352
411
|
return t;
|
|
353
412
|
}
|
|
413
|
+
function currentTransition(e) {
|
|
414
|
+
while (e.done && typeof e.done === "object") e = e.done;
|
|
415
|
+
return e;
|
|
416
|
+
}
|
|
354
417
|
function runInTransition(e, t) {
|
|
355
418
|
const n = activeTransition;
|
|
356
419
|
try {
|
|
357
|
-
activeTransition = e;
|
|
420
|
+
activeTransition = currentTransition(e);
|
|
358
421
|
return t();
|
|
359
422
|
} finally {
|
|
360
423
|
activeTransition = n;
|
|
361
424
|
}
|
|
362
425
|
}
|
|
426
|
+
function restoreTransition(e, t) {
|
|
427
|
+
globalQueue.initTransition(e);
|
|
428
|
+
const n = t();
|
|
429
|
+
flush();
|
|
430
|
+
return n;
|
|
431
|
+
}
|
|
363
432
|
function action(e) {
|
|
364
|
-
return (...t) =>
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
if (e.done) {
|
|
376
|
-
i.actions.splice(i.actions.indexOf(n), 1);
|
|
377
|
-
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;
|
|
378
444
|
schedule();
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
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
|
+
});
|
|
388
469
|
}
|
|
389
|
-
GlobalQueue.
|
|
390
|
-
GlobalQueue.
|
|
470
|
+
GlobalQueue.j = recompute;
|
|
471
|
+
GlobalQueue.K = disposeChildren;
|
|
391
472
|
let tracking = false;
|
|
392
473
|
let stale = false;
|
|
393
|
-
let pendingValueCheck = false;
|
|
394
|
-
let pendingCheck = null;
|
|
395
474
|
let refreshing = false;
|
|
475
|
+
let pendingCheckActive = false;
|
|
476
|
+
let foundPending = false;
|
|
477
|
+
let pendingReadActive = false;
|
|
396
478
|
let context = null;
|
|
397
479
|
function recompute(e, t = false) {
|
|
398
|
-
const n = e.
|
|
480
|
+
const n = e.q;
|
|
399
481
|
if (!t) {
|
|
400
|
-
if (e.
|
|
482
|
+
if (e.X && (!n || activeTransition) && activeTransition !== e.X)
|
|
483
|
+
globalQueue.initTransition(e.X);
|
|
401
484
|
deleteFromHeap(e, e.S & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
402
|
-
if (e.
|
|
485
|
+
if (e.X) disposeChildren(e);
|
|
403
486
|
else {
|
|
404
487
|
markDisposal(e);
|
|
405
|
-
e.
|
|
406
|
-
e.
|
|
407
|
-
e.
|
|
408
|
-
e.
|
|
488
|
+
e.re = e.oe;
|
|
489
|
+
e.se = e.ue;
|
|
490
|
+
e.oe = null;
|
|
491
|
+
e.ue = null;
|
|
409
492
|
}
|
|
410
493
|
}
|
|
411
|
-
const i =
|
|
494
|
+
const i = !!(e.S & REACTIVE_OPTIMISTIC_DIRTY);
|
|
495
|
+
const r = e.le && e.te !== NOT_PENDING;
|
|
496
|
+
const o = context;
|
|
412
497
|
context = e;
|
|
413
|
-
e.
|
|
498
|
+
e.ce = null;
|
|
414
499
|
e.S = REACTIVE_RECOMPUTING_DEPS;
|
|
415
|
-
e.
|
|
416
|
-
let
|
|
417
|
-
let
|
|
418
|
-
let o = e.J;
|
|
419
|
-
let u = e.j;
|
|
500
|
+
e.ae = clock;
|
|
501
|
+
let s = e.te === NOT_PENDING ? e.ne : e.te;
|
|
502
|
+
let u = e.o;
|
|
420
503
|
let l = tracking;
|
|
421
|
-
|
|
504
|
+
let c = optimisticReadActive;
|
|
422
505
|
tracking = true;
|
|
506
|
+
if (i) setOptimisticReadActive(true);
|
|
423
507
|
try {
|
|
424
|
-
|
|
425
|
-
e
|
|
508
|
+
s = handleAsync(e, e.U(s));
|
|
509
|
+
clearStatus(e);
|
|
426
510
|
} catch (t) {
|
|
427
511
|
if (t instanceof NotReadyError) {
|
|
428
512
|
if (t.cause !== e) link(t.cause, e);
|
|
429
|
-
|
|
430
|
-
} else
|
|
513
|
+
notifyStatus(e, STATUS_PENDING, t);
|
|
514
|
+
} else notifyStatus(e, STATUS_ERROR, t);
|
|
431
515
|
} finally {
|
|
432
516
|
tracking = l;
|
|
517
|
+
e.S = REACTIVE_NONE;
|
|
518
|
+
context = o;
|
|
433
519
|
}
|
|
434
|
-
e.
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
let n = t !== null ? t.P : e.D;
|
|
439
|
-
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) {
|
|
440
524
|
do {
|
|
441
|
-
|
|
442
|
-
} while (
|
|
443
|
-
if (
|
|
444
|
-
else e.
|
|
525
|
+
l = unlinkSubs(l);
|
|
526
|
+
} while (l !== null);
|
|
527
|
+
if (o !== null) o.D = null;
|
|
528
|
+
else e.C = null;
|
|
445
529
|
}
|
|
446
|
-
|
|
447
|
-
const c = !e.ue || !e.ue(e.M === NOT_PENDING || (e.oe && e.K) || n ? e.Y : e.M, r);
|
|
448
|
-
const a = e.J !== o || e.j !== u;
|
|
449
|
-
e.le?.(a, o);
|
|
450
|
-
if (c || a) {
|
|
530
|
+
const c = !e.fe || !e.fe(e.te === NOT_PENDING ? e.ne : e.te, s);
|
|
451
531
|
if (c) {
|
|
452
|
-
if (t || e.
|
|
453
|
-
else e.
|
|
454
|
-
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
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
|
+
}
|
|
460
539
|
}
|
|
461
540
|
}
|
|
462
|
-
|
|
463
|
-
(!t || e.
|
|
464
|
-
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));
|
|
465
544
|
}
|
|
466
545
|
function handleAsync(e, t, n) {
|
|
467
546
|
const i = typeof t === "object" && t !== null;
|
|
468
|
-
const r = i &&
|
|
469
|
-
const
|
|
470
|
-
if (!
|
|
471
|
-
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;
|
|
472
551
|
return t;
|
|
473
552
|
}
|
|
474
|
-
e.
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
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;
|
|
487
577
|
schedule();
|
|
488
|
-
|
|
489
|
-
|
|
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();
|
|
490
642
|
} else {
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
globalQueue.initTransition(e);
|
|
496
|
-
n?.(i) ?? setSignal(e, () => i);
|
|
497
|
-
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);
|
|
498
647
|
}
|
|
499
|
-
} catch (n) {
|
|
500
|
-
if (e.ae !== t) return;
|
|
501
|
-
globalQueue.initTransition(e);
|
|
502
|
-
setStatusFlags(e, STATUS_ERROR, n);
|
|
503
|
-
e.se = clock;
|
|
504
|
-
notifySubs(e);
|
|
505
|
-
schedule();
|
|
506
|
-
flush();
|
|
507
648
|
}
|
|
508
|
-
}
|
|
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
|
+
}
|
|
509
673
|
}
|
|
510
|
-
globalQueue.initTransition(e);
|
|
511
|
-
throw new NotReadyError(context);
|
|
512
674
|
}
|
|
513
675
|
function updateIfNecessary(e) {
|
|
514
676
|
if (e.S & REACTIVE_CHECK) {
|
|
515
|
-
for (let t = e.
|
|
677
|
+
for (let t = e.C; t; t = t.D) {
|
|
516
678
|
const n = t.V;
|
|
517
679
|
const i = n.m || n;
|
|
518
680
|
if (i.U) {
|
|
@@ -530,68 +692,64 @@ function updateIfNecessary(e) {
|
|
|
530
692
|
}
|
|
531
693
|
function unlinkSubs(e) {
|
|
532
694
|
const t = e.V;
|
|
533
|
-
const n = e.
|
|
534
|
-
const i = e.
|
|
535
|
-
const r = e.
|
|
536
|
-
if (i !== null) i.
|
|
537
|
-
else t.
|
|
538
|
-
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;
|
|
539
701
|
else {
|
|
540
|
-
t.
|
|
702
|
+
t.p = i;
|
|
541
703
|
if (i === null) {
|
|
542
|
-
t.
|
|
543
|
-
t.U && !t.
|
|
704
|
+
t.Oe?.();
|
|
705
|
+
t.U && !t.Se && unobserved(t);
|
|
544
706
|
}
|
|
545
707
|
}
|
|
546
708
|
return n;
|
|
547
709
|
}
|
|
548
710
|
function unobserved(e) {
|
|
549
711
|
deleteFromHeap(e, e.S & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
550
|
-
let t = e.
|
|
712
|
+
let t = e.C;
|
|
551
713
|
while (t !== null) {
|
|
552
714
|
t = unlinkSubs(t);
|
|
553
715
|
}
|
|
554
|
-
e.
|
|
716
|
+
e.C = null;
|
|
555
717
|
disposeChildren(e, true);
|
|
556
718
|
}
|
|
557
719
|
function link(e, t) {
|
|
558
|
-
const n = t.
|
|
720
|
+
const n = t.ce;
|
|
559
721
|
if (n !== null && n.V === e) return;
|
|
560
722
|
let i = null;
|
|
561
723
|
const r = t.S & REACTIVE_RECOMPUTING_DEPS;
|
|
562
724
|
if (r) {
|
|
563
|
-
i = n !== null ? n.
|
|
725
|
+
i = n !== null ? n.D : t.C;
|
|
564
726
|
if (i !== null && i.V === e) {
|
|
565
|
-
t.
|
|
727
|
+
t.ce = i;
|
|
566
728
|
return;
|
|
567
729
|
}
|
|
568
730
|
}
|
|
569
|
-
const
|
|
570
|
-
if (
|
|
571
|
-
const
|
|
572
|
-
if (n !== null) n.
|
|
573
|
-
else t.
|
|
574
|
-
if (
|
|
575
|
-
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;
|
|
576
738
|
}
|
|
577
739
|
function isValidLink(e, t) {
|
|
578
|
-
const n = t.
|
|
740
|
+
const n = t.ce;
|
|
579
741
|
if (n !== null) {
|
|
580
|
-
let i = t.
|
|
742
|
+
let i = t.C;
|
|
581
743
|
do {
|
|
582
744
|
if (i === e) return true;
|
|
583
745
|
if (i === n) break;
|
|
584
|
-
i = i.
|
|
746
|
+
i = i.D;
|
|
585
747
|
} while (i !== null);
|
|
586
748
|
}
|
|
587
749
|
return false;
|
|
588
750
|
}
|
|
589
|
-
function setStatusFlags(e, t, n = null) {
|
|
590
|
-
e.J = t;
|
|
591
|
-
e.j = n;
|
|
592
|
-
}
|
|
593
751
|
function markDisposal(e) {
|
|
594
|
-
let t = e.
|
|
752
|
+
let t = e.ue;
|
|
595
753
|
while (t) {
|
|
596
754
|
t.S |= REACTIVE_ZOMBIE;
|
|
597
755
|
if (t.S & REACTIVE_IN_HEAP) {
|
|
@@ -599,47 +757,47 @@ function markDisposal(e) {
|
|
|
599
757
|
insertIntoHeap(t, zombieQueue);
|
|
600
758
|
}
|
|
601
759
|
markDisposal(t);
|
|
602
|
-
t = t.
|
|
760
|
+
t = t._e;
|
|
603
761
|
}
|
|
604
762
|
}
|
|
605
763
|
function dispose(e) {
|
|
606
|
-
let t = e.
|
|
764
|
+
let t = e.C || null;
|
|
607
765
|
do {
|
|
608
766
|
t = unlinkSubs(t);
|
|
609
767
|
} while (t !== null);
|
|
610
|
-
e.
|
|
611
|
-
e.
|
|
768
|
+
e.C = null;
|
|
769
|
+
e.ce = null;
|
|
612
770
|
disposeChildren(e, true);
|
|
613
771
|
}
|
|
614
772
|
function disposeChildren(e, t = false, n) {
|
|
615
773
|
if (e.S & REACTIVE_DISPOSED) return;
|
|
616
774
|
if (t) e.S = REACTIVE_DISPOSED;
|
|
617
|
-
let i = n ? e.
|
|
775
|
+
let i = n ? e.se : e.ue;
|
|
618
776
|
while (i) {
|
|
619
|
-
const e = i.
|
|
620
|
-
if (i.
|
|
777
|
+
const e = i._e;
|
|
778
|
+
if (i.C) {
|
|
621
779
|
const e = i;
|
|
622
780
|
deleteFromHeap(e, e.S & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
623
|
-
let t = e.
|
|
781
|
+
let t = e.C;
|
|
624
782
|
do {
|
|
625
783
|
t = unlinkSubs(t);
|
|
626
784
|
} while (t !== null);
|
|
627
|
-
e.
|
|
628
|
-
e.
|
|
785
|
+
e.C = null;
|
|
786
|
+
e.ce = null;
|
|
629
787
|
}
|
|
630
788
|
disposeChildren(i, true);
|
|
631
789
|
i = e;
|
|
632
790
|
}
|
|
633
791
|
if (n) {
|
|
634
|
-
e.
|
|
792
|
+
e.se = null;
|
|
635
793
|
} else {
|
|
636
|
-
e.
|
|
637
|
-
e.
|
|
794
|
+
e.ue = null;
|
|
795
|
+
e._e = null;
|
|
638
796
|
}
|
|
639
797
|
runDisposal(e, n);
|
|
640
798
|
}
|
|
641
799
|
function runDisposal(e, t) {
|
|
642
|
-
let n = t ? e.
|
|
800
|
+
let n = t ? e.re : e.oe;
|
|
643
801
|
if (!n) return;
|
|
644
802
|
if (Array.isArray(n)) {
|
|
645
803
|
for (let e = 0; e < n.length; e++) {
|
|
@@ -649,10 +807,10 @@ function runDisposal(e, t) {
|
|
|
649
807
|
} else {
|
|
650
808
|
n.call(n);
|
|
651
809
|
}
|
|
652
|
-
t ? (e.
|
|
810
|
+
t ? (e.re = null) : (e.oe = null);
|
|
653
811
|
}
|
|
654
812
|
function getNextChildId(e) {
|
|
655
|
-
if (e.id != null) return formatId(e.id, e.
|
|
813
|
+
if (e.id != null) return formatId(e.id, e.pe++);
|
|
656
814
|
throw new Error("Cannot get child id from owner without an id");
|
|
657
815
|
}
|
|
658
816
|
function formatId(e, t) {
|
|
@@ -663,45 +821,44 @@ function formatId(e, t) {
|
|
|
663
821
|
function computed(e, t, n) {
|
|
664
822
|
const i = {
|
|
665
823
|
id: n?.id ?? (context?.id != null ? getNextChildId(context) : undefined),
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
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,
|
|
673
831
|
U: e,
|
|
674
|
-
|
|
832
|
+
ne: t,
|
|
675
833
|
o: 0,
|
|
676
|
-
|
|
834
|
+
A: null,
|
|
677
835
|
R: undefined,
|
|
678
836
|
T: null,
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
837
|
+
C: null,
|
|
838
|
+
ce: null,
|
|
839
|
+
p: null,
|
|
840
|
+
de: null,
|
|
683
841
|
i: context,
|
|
684
|
-
|
|
685
|
-
|
|
842
|
+
_e: null,
|
|
843
|
+
ue: null,
|
|
686
844
|
S: REACTIVE_NONE,
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
845
|
+
ie: STATUS_UNINITIALIZED,
|
|
846
|
+
ae: clock,
|
|
847
|
+
te: NOT_PENDING,
|
|
848
|
+
re: null,
|
|
849
|
+
se: null,
|
|
850
|
+
Ee: null,
|
|
851
|
+
X: null
|
|
694
852
|
};
|
|
695
|
-
if (n?.pe) Object.assign(i, n.pe);
|
|
696
853
|
i.T = i;
|
|
697
854
|
const r = context?.t ? context.u : context;
|
|
698
855
|
if (context) {
|
|
699
|
-
const e = context.
|
|
856
|
+
const e = context.ue;
|
|
700
857
|
if (e === null) {
|
|
701
|
-
context.
|
|
858
|
+
context.ue = i;
|
|
702
859
|
} else {
|
|
703
|
-
i.
|
|
704
|
-
context.
|
|
860
|
+
i._e = e;
|
|
861
|
+
context.ue = i;
|
|
705
862
|
}
|
|
706
863
|
}
|
|
707
864
|
if (r) i.o = r.o + 1;
|
|
@@ -710,22 +867,54 @@ function computed(e, t, n) {
|
|
|
710
867
|
}
|
|
711
868
|
function signal(e, t, n = null) {
|
|
712
869
|
const i = {
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
J: STATUS_NONE,
|
|
721
|
-
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,
|
|
722
877
|
m: n,
|
|
723
|
-
|
|
724
|
-
|
|
878
|
+
P: n?.A || null,
|
|
879
|
+
te: NOT_PENDING
|
|
725
880
|
};
|
|
726
|
-
n && (n.
|
|
881
|
+
n && (n.A = i);
|
|
727
882
|
return i;
|
|
728
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
|
+
}
|
|
729
918
|
function isEqual(e, t) {
|
|
730
919
|
return e === t;
|
|
731
920
|
}
|
|
@@ -739,16 +928,36 @@ function untrack(e) {
|
|
|
739
928
|
}
|
|
740
929
|
}
|
|
741
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
|
+
}
|
|
742
951
|
let t = context;
|
|
743
952
|
if (t?.t) t = t.u;
|
|
744
953
|
if (refreshing && e.U) recompute(e);
|
|
745
|
-
if (t && tracking
|
|
954
|
+
if (t && tracking) {
|
|
746
955
|
if (e.U && e.S & REACTIVE_DISPOSED) recompute(e);
|
|
747
956
|
link(e, t);
|
|
748
957
|
const n = e.m || e;
|
|
749
958
|
if (n.U) {
|
|
750
959
|
const i = e.S & REACTIVE_ZOMBIE;
|
|
751
|
-
if (n.o >= (i ? zombieQueue.
|
|
960
|
+
if (n.o >= (i ? zombieQueue.N : dirtyQueue.N)) {
|
|
752
961
|
markNode(t);
|
|
753
962
|
markHeap(i ? zombieQueue : dirtyQueue);
|
|
754
963
|
updateIfNecessary(n);
|
|
@@ -759,72 +968,60 @@ function read(e) {
|
|
|
759
968
|
}
|
|
760
969
|
}
|
|
761
970
|
}
|
|
762
|
-
if (pendingValueCheck) {
|
|
763
|
-
if (!e.ce) {
|
|
764
|
-
e.ce = signal(e.Y);
|
|
765
|
-
e.ce.oe = true;
|
|
766
|
-
}
|
|
767
|
-
pendingValueCheck = false;
|
|
768
|
-
try {
|
|
769
|
-
return read(e.ce);
|
|
770
|
-
} finally {
|
|
771
|
-
pendingValueCheck = true;
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
971
|
const n = e.m || e;
|
|
775
|
-
if (
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
e.
|
|
784
|
-
pendingCheck = e;
|
|
785
|
-
}
|
|
786
|
-
if (!pendingCheck && n.J & STATUS_PENDING) {
|
|
787
|
-
if ((t && !stale) || n.J & STATUS_UNINITIALIZED || e.m) throw n.j;
|
|
788
|
-
else if (t && stale) {
|
|
789
|
-
setStatusFlags(t, t.J | STATUS_PENDING, n.j);
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
if (e.J & STATUS_ERROR) {
|
|
793
|
-
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) {
|
|
794
981
|
recompute(e, true);
|
|
795
982
|
return read(e);
|
|
796
|
-
} else
|
|
797
|
-
throw e.j;
|
|
798
|
-
}
|
|
983
|
+
} else throw e.B;
|
|
799
984
|
}
|
|
800
985
|
return !t ||
|
|
801
|
-
|
|
802
|
-
e.
|
|
803
|
-
(stale &&
|
|
804
|
-
? e.
|
|
805
|
-
: e.
|
|
986
|
+
optimisticReadActive ||
|
|
987
|
+
e.te === NOT_PENDING ||
|
|
988
|
+
(stale && e.X && activeTransition !== e.X)
|
|
989
|
+
? e.ne
|
|
990
|
+
: e.te;
|
|
806
991
|
}
|
|
807
992
|
function setSignal(e, t) {
|
|
808
|
-
if (
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
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;
|
|
813
999
|
if (n) {
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
e.M = t;
|
|
1000
|
+
const n = e.te === NOT_PENDING;
|
|
1001
|
+
if (e.X && !n) {
|
|
1002
|
+
globalQueue.initTransition(e.X);
|
|
818
1003
|
}
|
|
819
|
-
if (
|
|
1004
|
+
if (n) {
|
|
1005
|
+
e.te = e.ne;
|
|
1006
|
+
globalQueue.H.push(e);
|
|
1007
|
+
}
|
|
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);
|
|
820
1016
|
}
|
|
821
|
-
|
|
822
|
-
e
|
|
823
|
-
e.oe && !optimisticRun ? globalQueue.$.push(e) : notifySubs(e);
|
|
1017
|
+
e.ae = clock;
|
|
1018
|
+
insertSubs(e, n);
|
|
824
1019
|
schedule();
|
|
825
1020
|
return t;
|
|
826
1021
|
}
|
|
1022
|
+
const PENDING_OWNER = {};
|
|
827
1023
|
function getObserver() {
|
|
1024
|
+
if (pendingCheckActive || pendingReadActive) return PENDING_OWNER;
|
|
828
1025
|
return tracking ? context : null;
|
|
829
1026
|
}
|
|
830
1027
|
function getOwner() {
|
|
@@ -832,42 +1029,37 @@ function getOwner() {
|
|
|
832
1029
|
}
|
|
833
1030
|
function onCleanup(e) {
|
|
834
1031
|
if (!context) return e;
|
|
835
|
-
|
|
836
|
-
if (
|
|
837
|
-
|
|
838
|
-
} else if (Array.isArray(t.te)) {
|
|
839
|
-
t.te.push(e);
|
|
840
|
-
} else {
|
|
841
|
-
t.te = [t.te, e];
|
|
842
|
-
}
|
|
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];
|
|
843
1035
|
return e;
|
|
844
1036
|
}
|
|
845
1037
|
function createOwner(e) {
|
|
846
1038
|
const t = context;
|
|
847
1039
|
const n = {
|
|
1040
|
+
id: e?.id ?? (t?.id != null ? getNextChildId(t) : undefined),
|
|
848
1041
|
t: true,
|
|
849
1042
|
u: t?.t ? t.u : t,
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
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,
|
|
859
1051
|
i: t,
|
|
860
1052
|
dispose(e = true) {
|
|
861
1053
|
disposeChildren(n, e);
|
|
862
1054
|
}
|
|
863
1055
|
};
|
|
864
1056
|
if (t) {
|
|
865
|
-
const e = t.
|
|
1057
|
+
const e = t.ue;
|
|
866
1058
|
if (e === null) {
|
|
867
|
-
t.
|
|
1059
|
+
t.ue = n;
|
|
868
1060
|
} else {
|
|
869
|
-
n.
|
|
870
|
-
t.
|
|
1061
|
+
n._e = e;
|
|
1062
|
+
t.ue = n;
|
|
871
1063
|
}
|
|
872
1064
|
}
|
|
873
1065
|
return n;
|
|
@@ -878,11 +1070,14 @@ function createRoot(e, t) {
|
|
|
878
1070
|
}
|
|
879
1071
|
function runWithOwner(e, t) {
|
|
880
1072
|
const n = context;
|
|
1073
|
+
const i = tracking;
|
|
881
1074
|
context = e;
|
|
1075
|
+
tracking = false;
|
|
882
1076
|
try {
|
|
883
1077
|
return t();
|
|
884
1078
|
} finally {
|
|
885
1079
|
context = n;
|
|
1080
|
+
tracking = i;
|
|
886
1081
|
}
|
|
887
1082
|
}
|
|
888
1083
|
function staleValues(e, t = true) {
|
|
@@ -895,25 +1090,25 @@ function staleValues(e, t = true) {
|
|
|
895
1090
|
}
|
|
896
1091
|
}
|
|
897
1092
|
function pending(e) {
|
|
898
|
-
const t =
|
|
899
|
-
|
|
1093
|
+
const t = pendingReadActive;
|
|
1094
|
+
pendingReadActive = true;
|
|
900
1095
|
try {
|
|
901
|
-
return
|
|
1096
|
+
return e();
|
|
902
1097
|
} finally {
|
|
903
|
-
|
|
1098
|
+
pendingReadActive = t;
|
|
904
1099
|
}
|
|
905
1100
|
}
|
|
906
1101
|
function isPending(e) {
|
|
907
|
-
const t =
|
|
908
|
-
|
|
1102
|
+
const t = pendingCheckActive;
|
|
1103
|
+
const n = foundPending;
|
|
1104
|
+
pendingCheckActive = true;
|
|
1105
|
+
foundPending = false;
|
|
909
1106
|
try {
|
|
910
|
-
|
|
911
|
-
return
|
|
912
|
-
} catch (e) {
|
|
913
|
-
if (!(e instanceof NotReadyError)) return false;
|
|
914
|
-
throw e;
|
|
1107
|
+
e();
|
|
1108
|
+
return foundPending;
|
|
915
1109
|
} finally {
|
|
916
|
-
|
|
1110
|
+
pendingCheckActive = t;
|
|
1111
|
+
foundPending = n;
|
|
917
1112
|
}
|
|
918
1113
|
}
|
|
919
1114
|
function refresh(e) {
|
|
@@ -929,7 +1124,6 @@ function refresh(e) {
|
|
|
929
1124
|
refreshing = t;
|
|
930
1125
|
if (!t) {
|
|
931
1126
|
schedule();
|
|
932
|
-
flush();
|
|
933
1127
|
}
|
|
934
1128
|
}
|
|
935
1129
|
}
|
|
@@ -943,7 +1137,7 @@ function getContext(e, t = getOwner()) {
|
|
|
943
1137
|
if (!t) {
|
|
944
1138
|
throw new NoOwnerError();
|
|
945
1139
|
}
|
|
946
|
-
const n = hasContext(e, t) ? t.
|
|
1140
|
+
const n = hasContext(e, t) ? t.he[e.id] : e.defaultValue;
|
|
947
1141
|
if (isUndefined(n)) {
|
|
948
1142
|
throw new ContextNotFoundError();
|
|
949
1143
|
}
|
|
@@ -953,73 +1147,92 @@ function setContext(e, t, n = getOwner()) {
|
|
|
953
1147
|
if (!n) {
|
|
954
1148
|
throw new NoOwnerError();
|
|
955
1149
|
}
|
|
956
|
-
n.
|
|
1150
|
+
n.he = { ...n.he, [e.id]: isUndefined(t) ? e.defaultValue : t };
|
|
957
1151
|
}
|
|
958
1152
|
function hasContext(e, t) {
|
|
959
|
-
return !isUndefined(t?.
|
|
1153
|
+
return !isUndefined(t?.he[e.id]);
|
|
960
1154
|
}
|
|
961
1155
|
function isUndefined(e) {
|
|
962
1156
|
return typeof e === "undefined";
|
|
963
1157
|
}
|
|
964
1158
|
function effect(e, t, n, i, r) {
|
|
965
|
-
let
|
|
966
|
-
const
|
|
1159
|
+
let o = false;
|
|
1160
|
+
const s = computed(r?.render ? t => staleValues(() => e(t)) : e, i, {
|
|
967
1161
|
...r,
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
}
|
|
995
|
-
}
|
|
996
|
-
if (!this._e.notify(this, STATUS_ERROR, STATUS_ERROR)) throw e;
|
|
997
|
-
} else if (this.B === EFFECT_RENDER) {
|
|
998
|
-
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;
|
|
999
1188
|
}
|
|
1000
1189
|
}
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
!r?.defer &&
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
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?.());
|
|
1009
1197
|
}
|
|
1010
1198
|
function runEffect() {
|
|
1011
|
-
if (!this.
|
|
1012
|
-
this.
|
|
1013
|
-
this.
|
|
1199
|
+
if (!this.Z || this.S & REACTIVE_DISPOSED) return;
|
|
1200
|
+
this.ye?.();
|
|
1201
|
+
this.ye = undefined;
|
|
1014
1202
|
try {
|
|
1015
|
-
this.
|
|
1203
|
+
this.ye = this.Ne(this.ne, this.Pe);
|
|
1016
1204
|
} catch (e) {
|
|
1017
|
-
if (!this.
|
|
1205
|
+
if (!this.J.notify(this, STATUS_ERROR, STATUS_ERROR)) throw e;
|
|
1018
1206
|
} finally {
|
|
1019
|
-
this.
|
|
1020
|
-
this.
|
|
1207
|
+
this.Pe = this.ne;
|
|
1208
|
+
this.Z = false;
|
|
1021
1209
|
}
|
|
1022
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
|
+
}
|
|
1023
1236
|
function createSignal(e, t, n) {
|
|
1024
1237
|
if (typeof e === "function") {
|
|
1025
1238
|
const i = computed(e, t, n);
|
|
@@ -1033,12 +1246,14 @@ function createMemo(e, t, n) {
|
|
|
1033
1246
|
return read.bind(null, i);
|
|
1034
1247
|
}
|
|
1035
1248
|
function createEffect(e, t, n, i) {
|
|
1036
|
-
|
|
1249
|
+
effect(e, t.effect || t, t.error, n, i);
|
|
1037
1250
|
}
|
|
1038
1251
|
function createRenderEffect(e, t, n, i) {
|
|
1039
|
-
|
|
1252
|
+
effect(e, t, undefined, n, { render: true, ...i });
|
|
1253
|
+
}
|
|
1254
|
+
function createTrackedEffect(e, t) {
|
|
1255
|
+
trackedEffect(e, t);
|
|
1040
1256
|
}
|
|
1041
|
-
function createTrackedEffect(e, t) {}
|
|
1042
1257
|
function createReaction(e, t) {
|
|
1043
1258
|
let n = undefined;
|
|
1044
1259
|
onCleanup(() => n?.());
|
|
@@ -1075,39 +1290,16 @@ function resolve(e) {
|
|
|
1075
1290
|
});
|
|
1076
1291
|
}
|
|
1077
1292
|
function createOptimistic(e, t, n) {
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
t => {
|
|
1081
|
-
const n = getOwner();
|
|
1082
|
-
const i = e(t);
|
|
1083
|
-
if (n.J & STATUS_UNINITIALIZED) return i;
|
|
1084
|
-
n.M = i;
|
|
1085
|
-
return t;
|
|
1086
|
-
},
|
|
1087
|
-
t,
|
|
1088
|
-
n
|
|
1089
|
-
);
|
|
1090
|
-
i.oe = true;
|
|
1091
|
-
return [read.bind(null, i), setSignal.bind(null, i)];
|
|
1092
|
-
}
|
|
1093
|
-
const i = signal(e, t);
|
|
1094
|
-
i.oe = true;
|
|
1095
|
-
return [
|
|
1096
|
-
read.bind(null, i),
|
|
1097
|
-
t => {
|
|
1098
|
-
i.M = e;
|
|
1099
|
-
return setSignal(i, t);
|
|
1100
|
-
}
|
|
1101
|
-
];
|
|
1293
|
+
const i = typeof e === "function" ? optimisticComputed(e, t, n) : optimisticSignal(e, t);
|
|
1294
|
+
return [read.bind(null, i), setSignal.bind(null, i)];
|
|
1102
1295
|
}
|
|
1103
1296
|
function onSettled(e) {
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
});
|
|
1297
|
+
getOwner()
|
|
1298
|
+
? createTrackedEffect(() => untrack(e))
|
|
1299
|
+
: globalQueue.enqueue(EFFECT_USER, () => {
|
|
1300
|
+
const t = e();
|
|
1301
|
+
t?.();
|
|
1302
|
+
});
|
|
1111
1303
|
}
|
|
1112
1304
|
function unwrap(e) {
|
|
1113
1305
|
return e?.[$TARGET]?.[STORE_NODE] ?? e;
|
|
@@ -1123,67 +1315,67 @@ function getAllKeys(e, t, n) {
|
|
|
1123
1315
|
function applyState(e, t, n, i) {
|
|
1124
1316
|
const r = t?.[$TARGET];
|
|
1125
1317
|
if (!r) return;
|
|
1126
|
-
const
|
|
1127
|
-
const
|
|
1318
|
+
const o = r[STORE_VALUE];
|
|
1319
|
+
const s = r[STORE_OVERRIDE];
|
|
1128
1320
|
let u = r[STORE_NODE];
|
|
1129
|
-
if (e ===
|
|
1321
|
+
if (e === o && !s) return;
|
|
1130
1322
|
(r[STORE_LOOKUP] || storeLookup).set(e, r[$PROXY]);
|
|
1131
1323
|
r[STORE_VALUE] = e;
|
|
1132
1324
|
r[STORE_OVERRIDE] = undefined;
|
|
1133
|
-
if (Array.isArray(
|
|
1325
|
+
if (Array.isArray(o)) {
|
|
1134
1326
|
let t = false;
|
|
1135
|
-
const l = getOverrideValue(
|
|
1327
|
+
const l = getOverrideValue(o, s, u, "length");
|
|
1136
1328
|
if (e.length && l && e[0] && n(e[0]) != null) {
|
|
1137
|
-
let c, a, f, E,
|
|
1329
|
+
let c, a, f, E, T, R, d, O;
|
|
1138
1330
|
for (
|
|
1139
1331
|
f = 0, E = Math.min(l, e.length);
|
|
1140
|
-
f < E && ((
|
|
1332
|
+
f < E && ((R = getOverrideValue(o, s, u, f)) === e[f] || (R && e[f] && n(R) === n(e[f])));
|
|
1141
1333
|
f++
|
|
1142
1334
|
) {
|
|
1143
|
-
applyState(e[f], wrap(
|
|
1335
|
+
applyState(e[f], wrap(R, r), n, i);
|
|
1144
1336
|
}
|
|
1145
1337
|
const S = new Array(e.length),
|
|
1146
1338
|
_ = new Map();
|
|
1147
1339
|
for (
|
|
1148
|
-
E = l - 1,
|
|
1340
|
+
E = l - 1, T = e.length - 1;
|
|
1149
1341
|
E >= f &&
|
|
1150
|
-
|
|
1151
|
-
((
|
|
1152
|
-
E--,
|
|
1342
|
+
T >= f &&
|
|
1343
|
+
((R = getOverrideValue(o, s, u, E)) === e[T] || (R && e[T] && n(R) === n(e[T])));
|
|
1344
|
+
E--, T--
|
|
1153
1345
|
) {
|
|
1154
|
-
S[
|
|
1346
|
+
S[T] = R;
|
|
1155
1347
|
}
|
|
1156
|
-
if (f >
|
|
1157
|
-
for (a = f; a <=
|
|
1348
|
+
if (f > T || f > E) {
|
|
1349
|
+
for (a = f; a <= T; a++) {
|
|
1158
1350
|
t = true;
|
|
1159
1351
|
r[STORE_NODE][a] && setSignal(r[STORE_NODE][a], wrap(e[a], r));
|
|
1160
1352
|
}
|
|
1161
1353
|
for (; a < e.length; a++) {
|
|
1162
1354
|
t = true;
|
|
1163
|
-
const
|
|
1164
|
-
r[STORE_NODE][a] && setSignal(r[STORE_NODE][a],
|
|
1165
|
-
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);
|
|
1166
1358
|
}
|
|
1167
1359
|
t && r[STORE_NODE][$TRACK] && setSignal(r[STORE_NODE][$TRACK], void 0);
|
|
1168
1360
|
l !== e.length && r[STORE_NODE].length && setSignal(r[STORE_NODE].length, e.length);
|
|
1169
1361
|
return;
|
|
1170
1362
|
}
|
|
1171
|
-
|
|
1172
|
-
for (a =
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
c = _.get(
|
|
1176
|
-
|
|
1177
|
-
_.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);
|
|
1178
1370
|
}
|
|
1179
1371
|
for (c = f; c <= E; c++) {
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
a = _.get(
|
|
1372
|
+
R = getOverrideValue(o, s, u, c);
|
|
1373
|
+
O = R ? n(R) : R;
|
|
1374
|
+
a = _.get(O);
|
|
1183
1375
|
if (a !== undefined && a !== -1) {
|
|
1184
|
-
S[a] =
|
|
1185
|
-
a =
|
|
1186
|
-
_.set(
|
|
1376
|
+
S[a] = R;
|
|
1377
|
+
a = d[a];
|
|
1378
|
+
_.set(O, a);
|
|
1187
1379
|
}
|
|
1188
1380
|
}
|
|
1189
1381
|
for (a = f; a < e.length; a++) {
|
|
@@ -1196,7 +1388,7 @@ function applyState(e, t, n, i) {
|
|
|
1196
1388
|
if (f < e.length) t = true;
|
|
1197
1389
|
} else if (e.length) {
|
|
1198
1390
|
for (let t = 0, l = e.length; t < l; t++) {
|
|
1199
|
-
const l = getOverrideValue(
|
|
1391
|
+
const l = getOverrideValue(o, s, u, t);
|
|
1200
1392
|
isWrappable(l)
|
|
1201
1393
|
? applyState(e[t], wrap(l, r), n, i)
|
|
1202
1394
|
: r[STORE_NODE][t] && setSignal(r[STORE_NODE][t], e[t]);
|
|
@@ -1211,17 +1403,17 @@ function applyState(e, t, n, i) {
|
|
|
1211
1403
|
}
|
|
1212
1404
|
if (u) {
|
|
1213
1405
|
const t = u[$TRACK];
|
|
1214
|
-
const l = t || i ? getAllKeys(
|
|
1406
|
+
const l = t || i ? getAllKeys(o, s, e) : Object.keys(u);
|
|
1215
1407
|
for (let c = 0, a = l.length; c < a; c++) {
|
|
1216
1408
|
const a = l[c];
|
|
1217
1409
|
const f = u[a];
|
|
1218
|
-
const E = unwrap(getOverrideValue(
|
|
1219
|
-
let
|
|
1220
|
-
if (E ===
|
|
1221
|
-
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))) {
|
|
1222
1414
|
t && setSignal(t, void 0);
|
|
1223
|
-
f && setSignal(f, isWrappable(
|
|
1224
|
-
} else applyState(
|
|
1415
|
+
f && setSignal(f, isWrappable(T) ? wrap(T, r) : T);
|
|
1416
|
+
} else applyState(T, wrap(E, r), n, i);
|
|
1225
1417
|
}
|
|
1226
1418
|
}
|
|
1227
1419
|
if ((u = r[STORE_HAS])) {
|
|
@@ -1236,8 +1428,8 @@ function reconcile(e, t, n = false) {
|
|
|
1236
1428
|
return i => {
|
|
1237
1429
|
if (i == null) throw new Error("Cannot reconcile null or undefined state");
|
|
1238
1430
|
const r = typeof t === "string" ? e => e[t] : t;
|
|
1239
|
-
const
|
|
1240
|
-
if (
|
|
1431
|
+
const o = r(i);
|
|
1432
|
+
if (o !== undefined && r(e) !== r(i))
|
|
1241
1433
|
throw new Error("Cannot reconcile states with different identity");
|
|
1242
1434
|
applyState(e, i, r, n);
|
|
1243
1435
|
};
|
|
@@ -1262,19 +1454,19 @@ function createProjectionInternal(e, t = {}, n) {
|
|
|
1262
1454
|
r.set(e, t);
|
|
1263
1455
|
return t;
|
|
1264
1456
|
};
|
|
1265
|
-
const
|
|
1457
|
+
const o = wrapProjection(t);
|
|
1266
1458
|
i = computed(() => {
|
|
1267
1459
|
const t = getOwner();
|
|
1268
|
-
storeSetter(new Proxy(
|
|
1460
|
+
storeSetter(new Proxy(o, writeTraps), i => {
|
|
1269
1461
|
const r = handleAsync(t, e(i), e => {
|
|
1270
|
-
e !==
|
|
1462
|
+
e !== i && e !== undefined && storeSetter(o, reconcile(e, n?.key || "id", n?.all));
|
|
1271
1463
|
setSignal(t, undefined);
|
|
1272
1464
|
});
|
|
1273
|
-
r !==
|
|
1465
|
+
r !== i && r !== undefined && reconcile(r, n?.key || "id", n?.all)(o);
|
|
1274
1466
|
});
|
|
1275
1467
|
});
|
|
1276
|
-
i.
|
|
1277
|
-
return { store:
|
|
1468
|
+
i.Se = true;
|
|
1469
|
+
return { store: o, node: i };
|
|
1278
1470
|
}
|
|
1279
1471
|
function createProjection(e, t = {}, n) {
|
|
1280
1472
|
return createProjectionInternal(e, t, n).store;
|
|
@@ -1283,28 +1475,34 @@ const writeTraps = {
|
|
|
1283
1475
|
get(e, t) {
|
|
1284
1476
|
let n;
|
|
1285
1477
|
setWriteOverride(true);
|
|
1478
|
+
setProjectionWriteActive(true);
|
|
1286
1479
|
try {
|
|
1287
1480
|
n = e[t];
|
|
1288
1481
|
} finally {
|
|
1289
1482
|
setWriteOverride(false);
|
|
1483
|
+
setProjectionWriteActive(false);
|
|
1290
1484
|
}
|
|
1291
1485
|
return typeof n === "object" && n !== null ? new Proxy(n, writeTraps) : n;
|
|
1292
1486
|
},
|
|
1293
1487
|
set(e, t, n) {
|
|
1294
1488
|
setWriteOverride(true);
|
|
1489
|
+
setProjectionWriteActive(true);
|
|
1295
1490
|
try {
|
|
1296
1491
|
e[t] = n;
|
|
1297
1492
|
} finally {
|
|
1298
1493
|
setWriteOverride(false);
|
|
1494
|
+
setProjectionWriteActive(false);
|
|
1299
1495
|
}
|
|
1300
1496
|
return true;
|
|
1301
1497
|
},
|
|
1302
1498
|
deleteProperty(e, t) {
|
|
1303
1499
|
setWriteOverride(true);
|
|
1500
|
+
setProjectionWriteActive(true);
|
|
1304
1501
|
try {
|
|
1305
1502
|
delete e[t];
|
|
1306
1503
|
} finally {
|
|
1307
1504
|
setWriteOverride(false);
|
|
1505
|
+
setProjectionWriteActive(false);
|
|
1308
1506
|
}
|
|
1309
1507
|
return true;
|
|
1310
1508
|
}
|
|
@@ -1317,11 +1515,13 @@ const $TRACK = Symbol(0),
|
|
|
1317
1515
|
const PARENTS = new WeakMap();
|
|
1318
1516
|
const STORE_VALUE = "v",
|
|
1319
1517
|
STORE_OVERRIDE = "o",
|
|
1518
|
+
STORE_OPTIMISTIC_OVERRIDE = "x",
|
|
1320
1519
|
STORE_NODE = "n",
|
|
1321
1520
|
STORE_HAS = "h",
|
|
1322
1521
|
STORE_WRAP = "w",
|
|
1323
1522
|
STORE_LOOKUP = "l",
|
|
1324
|
-
STORE_FIREWALL = "f"
|
|
1523
|
+
STORE_FIREWALL = "f",
|
|
1524
|
+
STORE_OPTIMISTIC = "p";
|
|
1325
1525
|
function createStoreProxy(e, t = storeTraps, n) {
|
|
1326
1526
|
let i;
|
|
1327
1527
|
if (Array.isArray(e)) {
|
|
@@ -1353,9 +1553,9 @@ function getNodes(e, t) {
|
|
|
1353
1553
|
if (!n) e[t] = n = Object.create(null);
|
|
1354
1554
|
return n;
|
|
1355
1555
|
}
|
|
1356
|
-
function getNode(e, t, n, i, r = isEqual) {
|
|
1556
|
+
function getNode(e, t, n, i, r = isEqual, o) {
|
|
1357
1557
|
if (e[t]) return e[t];
|
|
1358
|
-
|
|
1558
|
+
const s = signal(
|
|
1359
1559
|
n,
|
|
1360
1560
|
{
|
|
1361
1561
|
equals: r,
|
|
@@ -1364,17 +1564,22 @@ function getNode(e, t, n, i, r = isEqual) {
|
|
|
1364
1564
|
}
|
|
1365
1565
|
},
|
|
1366
1566
|
i
|
|
1367
|
-
)
|
|
1567
|
+
);
|
|
1568
|
+
if (o) s.le = true;
|
|
1569
|
+
return (e[t] = s);
|
|
1368
1570
|
}
|
|
1369
1571
|
function trackSelf(e, t = $TRACK) {
|
|
1370
|
-
getObserver() &&
|
|
1572
|
+
getObserver() &&
|
|
1573
|
+
read(
|
|
1574
|
+
getNode(getNodes(e, STORE_NODE), t, undefined, e[STORE_FIREWALL], false, e[STORE_OPTIMISTIC])
|
|
1575
|
+
);
|
|
1371
1576
|
}
|
|
1372
1577
|
function getKeys(e, t, n = true) {
|
|
1373
1578
|
const i = untrack(() => (n ? Object.keys(e) : Reflect.ownKeys(e)));
|
|
1374
1579
|
if (!t) return i;
|
|
1375
1580
|
const r = new Set(i);
|
|
1376
|
-
const
|
|
1377
|
-
for (const e of
|
|
1581
|
+
const o = Reflect.ownKeys(t);
|
|
1582
|
+
for (const e of o) {
|
|
1378
1583
|
if (t[e] !== $DELETED) r.add(e);
|
|
1379
1584
|
else r.delete(e);
|
|
1380
1585
|
}
|
|
@@ -1400,104 +1605,170 @@ const storeTraps = {
|
|
|
1400
1605
|
}
|
|
1401
1606
|
const i = getNodes(e, STORE_NODE);
|
|
1402
1607
|
const r = i[t];
|
|
1403
|
-
const
|
|
1404
|
-
const
|
|
1405
|
-
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];
|
|
1406
1616
|
if (!r) {
|
|
1407
|
-
const e = Object.getOwnPropertyDescriptor(
|
|
1617
|
+
const e = Object.getOwnPropertyDescriptor(l, t);
|
|
1408
1618
|
if (e && e.get) return e.get.call(n);
|
|
1409
1619
|
}
|
|
1410
1620
|
if (writeOnly(n)) {
|
|
1411
|
-
let n = r && (s || !
|
|
1621
|
+
let n = r && (s || !u) ? (r.te !== NOT_PENDING ? (r.le ? r.ne : r.te) : r.ne) : l[t];
|
|
1412
1622
|
n === $DELETED && (n = undefined);
|
|
1413
1623
|
if (!isWrappable(n)) return n;
|
|
1414
1624
|
const i = wrap(n, e);
|
|
1415
1625
|
Writing?.add(i);
|
|
1416
1626
|
return i;
|
|
1417
1627
|
}
|
|
1418
|
-
let
|
|
1419
|
-
|
|
1628
|
+
let c = r ? (s || !u ? read(i[t]) : (read(i[t]), l[t])) : l[t];
|
|
1629
|
+
c === $DELETED && (c = undefined);
|
|
1420
1630
|
if (!r) {
|
|
1421
|
-
if (!s && typeof
|
|
1631
|
+
if (!s && typeof c === "function" && !l.hasOwnProperty(t)) {
|
|
1422
1632
|
let t;
|
|
1423
1633
|
return !Array.isArray(e[STORE_VALUE]) &&
|
|
1424
1634
|
(t = Object.getPrototypeOf(e[STORE_VALUE])) &&
|
|
1425
1635
|
t !== Object.prototype
|
|
1426
|
-
?
|
|
1427
|
-
:
|
|
1636
|
+
? c.bind(l)
|
|
1637
|
+
: c;
|
|
1428
1638
|
} else if (getObserver()) {
|
|
1429
|
-
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
|
+
);
|
|
1430
1649
|
}
|
|
1431
1650
|
}
|
|
1432
|
-
return isWrappable(
|
|
1651
|
+
return isWrappable(c) ? wrap(c, e) : c;
|
|
1433
1652
|
},
|
|
1434
1653
|
has(e, t) {
|
|
1435
1654
|
if (t === $PROXY || t === $TRACK || t === "__proto__") return true;
|
|
1436
1655
|
const n =
|
|
1437
|
-
e[
|
|
1438
|
-
? e[
|
|
1439
|
-
: t in e[
|
|
1440
|
-
|
|
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]));
|
|
1441
1663
|
return n;
|
|
1442
1664
|
},
|
|
1443
1665
|
set(e, t, n) {
|
|
1444
1666
|
const i = e[$PROXY];
|
|
1445
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
|
+
}
|
|
1446
1674
|
untrack(() => {
|
|
1447
1675
|
const r = e[STORE_VALUE];
|
|
1448
|
-
const
|
|
1449
|
-
const
|
|
1450
|
-
const u =
|
|
1451
|
-
if (
|
|
1452
|
-
const l =
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
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));
|
|
1459
1695
|
}
|
|
1460
|
-
if (recursivelyNotify(i, storeLookup) &&
|
|
1696
|
+
if (recursivelyNotify(i, storeLookup) && f) recursivelyAddParent(c, i);
|
|
1461
1697
|
e[STORE_HAS]?.[t] && setSignal(e[STORE_HAS][t], true);
|
|
1462
|
-
const
|
|
1463
|
-
|
|
1698
|
+
const E = getNodes(e, STORE_NODE);
|
|
1699
|
+
E[t] && setSignal(E[t], () => (f ? wrap(c, e) : c));
|
|
1464
1700
|
if (Array.isArray(r)) {
|
|
1465
|
-
|
|
1466
|
-
|
|
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
|
+
}
|
|
1467
1707
|
}
|
|
1468
|
-
|
|
1708
|
+
E[$TRACK] && setSignal(E[$TRACK], undefined);
|
|
1469
1709
|
});
|
|
1470
1710
|
}
|
|
1471
1711
|
return true;
|
|
1472
1712
|
},
|
|
1473
1713
|
deleteProperty(e, t) {
|
|
1474
|
-
|
|
1714
|
+
const n = e[STORE_OPTIMISTIC_OVERRIDE]?.[t] === $DELETED;
|
|
1715
|
+
const i = e[STORE_OVERRIDE]?.[t] === $DELETED;
|
|
1716
|
+
if (writeOnly(e[$PROXY]) && !n && !i) {
|
|
1475
1717
|
untrack(() => {
|
|
1476
|
-
const n =
|
|
1477
|
-
|
|
1478
|
-
if (
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
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];
|
|
1482
1731
|
} else return true;
|
|
1483
|
-
if (isWrappable(
|
|
1484
|
-
const t = PARENTS.get(
|
|
1485
|
-
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));
|
|
1486
1735
|
}
|
|
1487
1736
|
if (e[STORE_HAS]?.[t]) setSignal(e[STORE_HAS][t], false);
|
|
1488
|
-
const
|
|
1489
|
-
|
|
1490
|
-
|
|
1737
|
+
const o = getNodes(e, STORE_NODE);
|
|
1738
|
+
o[t] && setSignal(o[t], undefined);
|
|
1739
|
+
o[$TRACK] && setSignal(o[$TRACK], undefined);
|
|
1491
1740
|
});
|
|
1492
1741
|
}
|
|
1493
1742
|
return true;
|
|
1494
1743
|
},
|
|
1495
1744
|
ownKeys(e) {
|
|
1496
1745
|
trackSelf(e);
|
|
1497
|
-
|
|
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;
|
|
1498
1756
|
},
|
|
1499
1757
|
getOwnPropertyDescriptor(e, t) {
|
|
1500
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
|
+
}
|
|
1501
1772
|
return getPropertyDescriptor(e[STORE_VALUE], e[STORE_OVERRIDE], t);
|
|
1502
1773
|
},
|
|
1503
1774
|
getPrototypeOf(e) {
|
|
@@ -1576,8 +1847,8 @@ function recursivelyAddParent(e, t) {
|
|
|
1576
1847
|
const t = getKeys(e, n);
|
|
1577
1848
|
for (let i = 0; i < t.length; i++) {
|
|
1578
1849
|
const r = t[i];
|
|
1579
|
-
const
|
|
1580
|
-
isWrappable(
|
|
1850
|
+
const o = n && r in n ? n[r] : e[r];
|
|
1851
|
+
isWrappable(o) && recursivelyAddParent(o, e);
|
|
1581
1852
|
}
|
|
1582
1853
|
}
|
|
1583
1854
|
}
|
|
@@ -1586,19 +1857,88 @@ function deep(e) {
|
|
|
1586
1857
|
return e[$DEEP];
|
|
1587
1858
|
}
|
|
1588
1859
|
function createOptimisticStore(e, t, n) {
|
|
1589
|
-
|
|
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 };
|
|
1590
1930
|
}
|
|
1591
1931
|
function snapshot(e, t, n) {
|
|
1592
|
-
let i, r,
|
|
1932
|
+
let i, r, o, s, u, l;
|
|
1593
1933
|
if (!isWrappable(e)) return e;
|
|
1594
1934
|
if (t && t.has(e)) return t.get(e);
|
|
1595
1935
|
if (!t) t = new Map();
|
|
1596
1936
|
if ((i = e[$TARGET] || n?.get(e)?.[$TARGET])) {
|
|
1597
|
-
|
|
1937
|
+
o = i[STORE_OVERRIDE];
|
|
1598
1938
|
r = Array.isArray(i[STORE_VALUE]);
|
|
1599
1939
|
t.set(
|
|
1600
1940
|
e,
|
|
1601
|
-
|
|
1941
|
+
o ? (s = r ? [] : Object.create(Object.getPrototypeOf(i[STORE_VALUE]))) : i[STORE_VALUE]
|
|
1602
1942
|
);
|
|
1603
1943
|
e = i[STORE_VALUE];
|
|
1604
1944
|
n = storeLookup;
|
|
@@ -1607,32 +1947,32 @@ function snapshot(e, t, n) {
|
|
|
1607
1947
|
t.set(e, e);
|
|
1608
1948
|
}
|
|
1609
1949
|
if (r) {
|
|
1610
|
-
const i =
|
|
1950
|
+
const i = o?.length || e.length;
|
|
1611
1951
|
for (let r = 0; r < i; r++) {
|
|
1612
|
-
l =
|
|
1952
|
+
l = o && r in o ? o[r] : e[r];
|
|
1613
1953
|
if (l === $DELETED) continue;
|
|
1614
|
-
if ((u = snapshot(l, t, n)) !== l ||
|
|
1615
|
-
if (!
|
|
1616
|
-
|
|
1954
|
+
if ((u = snapshot(l, t, n)) !== l || s) {
|
|
1955
|
+
if (!s) t.set(e, (s = [...e]));
|
|
1956
|
+
s[r] = u;
|
|
1617
1957
|
}
|
|
1618
1958
|
}
|
|
1619
1959
|
} else {
|
|
1620
|
-
const i = getKeys(e,
|
|
1960
|
+
const i = getKeys(e, o);
|
|
1621
1961
|
for (let r = 0, c = i.length; r < c; r++) {
|
|
1622
1962
|
let c = i[r];
|
|
1623
|
-
const a = getPropertyDescriptor(e,
|
|
1963
|
+
const a = getPropertyDescriptor(e, o, c);
|
|
1624
1964
|
if (a.get) continue;
|
|
1625
|
-
l =
|
|
1626
|
-
if ((u = snapshot(l, t, n)) !== e[c] ||
|
|
1627
|
-
if (!
|
|
1628
|
-
|
|
1629
|
-
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);
|
|
1630
1970
|
}
|
|
1631
|
-
|
|
1971
|
+
s[c] = u;
|
|
1632
1972
|
}
|
|
1633
1973
|
}
|
|
1634
1974
|
}
|
|
1635
|
-
return
|
|
1975
|
+
return s || e;
|
|
1636
1976
|
}
|
|
1637
1977
|
function trueFn() {
|
|
1638
1978
|
return true;
|
|
@@ -1674,8 +2014,8 @@ function merge(...e) {
|
|
|
1674
2014
|
for (let i = 0; i < e.length; i++) {
|
|
1675
2015
|
const r = e[i];
|
|
1676
2016
|
t = t || (!!r && $PROXY in r);
|
|
1677
|
-
const
|
|
1678
|
-
if (
|
|
2017
|
+
const o = !!r && r[$SOURCES];
|
|
2018
|
+
if (o) n.push(...o);
|
|
1679
2019
|
else n.push(typeof r === "function" ? ((t = true), createMemo(r)) : r);
|
|
1680
2020
|
}
|
|
1681
2021
|
if (SUPPORTS_PROXY && t) {
|
|
@@ -1705,35 +2045,35 @@ function merge(...e) {
|
|
|
1705
2045
|
}
|
|
1706
2046
|
const i = Object.create(null);
|
|
1707
2047
|
let r = false;
|
|
1708
|
-
let
|
|
1709
|
-
for (let e =
|
|
2048
|
+
let o = n.length - 1;
|
|
2049
|
+
for (let e = o; e >= 0; e--) {
|
|
1710
2050
|
const t = n[e];
|
|
1711
2051
|
if (!t) {
|
|
1712
|
-
e ===
|
|
2052
|
+
e === o && o--;
|
|
1713
2053
|
continue;
|
|
1714
2054
|
}
|
|
1715
|
-
const
|
|
1716
|
-
for (let n =
|
|
1717
|
-
const u =
|
|
2055
|
+
const s = Object.getOwnPropertyNames(t);
|
|
2056
|
+
for (let n = s.length - 1; n >= 0; n--) {
|
|
2057
|
+
const u = s[n];
|
|
1718
2058
|
if (u === "__proto__" || u === "constructor") continue;
|
|
1719
2059
|
if (!i[u]) {
|
|
1720
|
-
r = r || e !==
|
|
2060
|
+
r = r || e !== o;
|
|
1721
2061
|
const n = Object.getOwnPropertyDescriptor(t, u);
|
|
1722
2062
|
i[u] = n.get ? { enumerable: true, configurable: true, get: n.get.bind(t) } : n;
|
|
1723
2063
|
}
|
|
1724
2064
|
}
|
|
1725
2065
|
}
|
|
1726
|
-
if (!r) return n[
|
|
1727
|
-
const
|
|
2066
|
+
if (!r) return n[o];
|
|
2067
|
+
const s = {};
|
|
1728
2068
|
const u = Object.keys(i);
|
|
1729
2069
|
for (let e = u.length - 1; e >= 0; e--) {
|
|
1730
2070
|
const t = u[e],
|
|
1731
2071
|
n = i[t];
|
|
1732
|
-
if (n.get) Object.defineProperty(
|
|
1733
|
-
else
|
|
2072
|
+
if (n.get) Object.defineProperty(s, t, n);
|
|
2073
|
+
else s[t] = n.value;
|
|
1734
2074
|
}
|
|
1735
|
-
|
|
1736
|
-
return
|
|
2075
|
+
s[$SOURCES] = n;
|
|
2076
|
+
return s;
|
|
1737
2077
|
}
|
|
1738
2078
|
function omit(e, ...t) {
|
|
1739
2079
|
const n = new Set(t);
|
|
@@ -1768,247 +2108,241 @@ function mapArray(e, t, n) {
|
|
|
1768
2108
|
const i = typeof n?.keyed === "function" ? n.keyed : undefined;
|
|
1769
2109
|
return createMemo(
|
|
1770
2110
|
updateKeyedMap.bind({
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
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
|
|
1782
2122
|
})
|
|
1783
2123
|
);
|
|
1784
2124
|
}
|
|
1785
2125
|
const pureOptions = { pureWrite: true };
|
|
1786
2126
|
function updateKeyedMap() {
|
|
1787
|
-
const e = this.
|
|
2127
|
+
const e = this.be() || [],
|
|
1788
2128
|
t = e.length;
|
|
1789
2129
|
e[$TRACK];
|
|
1790
|
-
runWithOwner(this.
|
|
2130
|
+
runWithOwner(this.De, () => {
|
|
1791
2131
|
let n,
|
|
1792
2132
|
i,
|
|
1793
|
-
r = this.
|
|
2133
|
+
r = this.We
|
|
1794
2134
|
? () => {
|
|
1795
|
-
this.
|
|
1796
|
-
this.
|
|
1797
|
-
return this.
|
|
1798
|
-
read.bind(null, this.
|
|
1799
|
-
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
|
|
1800
2140
|
);
|
|
1801
2141
|
}
|
|
1802
|
-
: this.
|
|
2142
|
+
: this.Qe
|
|
1803
2143
|
? () => {
|
|
1804
2144
|
const t = e[i];
|
|
1805
|
-
this.
|
|
1806
|
-
return this.
|
|
2145
|
+
this.Qe[i] = signal(i, pureOptions);
|
|
2146
|
+
return this.Ve(() => t, read.bind(null, this.Qe[i]));
|
|
1807
2147
|
}
|
|
1808
2148
|
: () => {
|
|
1809
2149
|
const t = e[i];
|
|
1810
|
-
return this.
|
|
2150
|
+
return this.Ve(() => t);
|
|
1811
2151
|
};
|
|
1812
2152
|
if (t === 0) {
|
|
1813
|
-
if (this.
|
|
1814
|
-
this.
|
|
1815
|
-
this.
|
|
1816
|
-
this.
|
|
1817
|
-
this.
|
|
1818
|
-
this.
|
|
1819
|
-
this.
|
|
1820
|
-
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 = []);
|
|
1821
2161
|
}
|
|
1822
|
-
if (this.
|
|
1823
|
-
this.
|
|
2162
|
+
if (this.xe && !this.me[0]) {
|
|
2163
|
+
this.me[0] = runWithOwner((this.Ue[0] = createOwner()), this.xe);
|
|
1824
2164
|
}
|
|
1825
|
-
} else if (this.
|
|
1826
|
-
if (this.
|
|
1827
|
-
this.
|
|
2165
|
+
} else if (this.we === 0) {
|
|
2166
|
+
if (this.Ue[0]) this.Ue[0].dispose();
|
|
2167
|
+
this.me = new Array(t);
|
|
1828
2168
|
for (i = 0; i < t; i++) {
|
|
1829
|
-
this.
|
|
1830
|
-
this.
|
|
2169
|
+
this.ve[i] = e[i];
|
|
2170
|
+
this.me[i] = runWithOwner((this.Ue[i] = createOwner()), r);
|
|
1831
2171
|
}
|
|
1832
|
-
this.
|
|
2172
|
+
this.we = t;
|
|
1833
2173
|
} else {
|
|
1834
|
-
let
|
|
1835
|
-
|
|
2174
|
+
let o,
|
|
2175
|
+
s,
|
|
1836
2176
|
u,
|
|
1837
2177
|
l,
|
|
1838
2178
|
c,
|
|
1839
2179
|
a,
|
|
1840
2180
|
f,
|
|
1841
2181
|
E = new Array(t),
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
2182
|
+
T = new Array(t),
|
|
2183
|
+
R = this.We ? new Array(t) : undefined,
|
|
2184
|
+
d = this.Qe ? new Array(t) : undefined;
|
|
1845
2185
|
for (
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
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++
|
|
1849
2189
|
) {
|
|
1850
|
-
if (this.
|
|
2190
|
+
if (this.We) setSignal(this.We[o], e[o]);
|
|
1851
2191
|
}
|
|
1852
2192
|
for (
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
u >=
|
|
1856
|
-
(this.
|
|
1857
|
-
|
|
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--
|
|
1858
2198
|
) {
|
|
1859
|
-
E[u] = this.
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
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]);
|
|
1863
2203
|
}
|
|
1864
2204
|
a = new Map();
|
|
1865
2205
|
f = new Array(u + 1);
|
|
1866
|
-
for (i = u; i >=
|
|
2206
|
+
for (i = u; i >= o; i--) {
|
|
1867
2207
|
l = e[i];
|
|
1868
|
-
c = this.
|
|
2208
|
+
c = this.ke ? this.ke(l) : l;
|
|
1869
2209
|
n = a.get(c);
|
|
1870
2210
|
f[i] = n === undefined ? -1 : n;
|
|
1871
2211
|
a.set(c, i);
|
|
1872
2212
|
}
|
|
1873
|
-
for (n =
|
|
1874
|
-
l = this.
|
|
1875
|
-
c = this.
|
|
2213
|
+
for (n = o; n <= s; n++) {
|
|
2214
|
+
l = this.ve[n];
|
|
2215
|
+
c = this.ke ? this.ke(l) : l;
|
|
1876
2216
|
i = a.get(c);
|
|
1877
2217
|
if (i !== undefined && i !== -1) {
|
|
1878
|
-
E[i] = this.
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
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]);
|
|
1882
2222
|
i = f[i];
|
|
1883
2223
|
a.set(c, i);
|
|
1884
|
-
} else this.
|
|
2224
|
+
} else this.Ue[n].dispose();
|
|
1885
2225
|
}
|
|
1886
|
-
for (i =
|
|
2226
|
+
for (i = o; i < t; i++) {
|
|
1887
2227
|
if (i in E) {
|
|
1888
|
-
this.
|
|
1889
|
-
this.
|
|
1890
|
-
if (T) {
|
|
1891
|
-
this.Ue[i] = T[i];
|
|
1892
|
-
setSignal(this.Ue[i], e[i]);
|
|
1893
|
-
}
|
|
2228
|
+
this.me[i] = E[i];
|
|
2229
|
+
this.Ue[i] = T[i];
|
|
1894
2230
|
if (R) {
|
|
1895
|
-
this.
|
|
1896
|
-
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);
|
|
1897
2237
|
}
|
|
1898
2238
|
} else {
|
|
1899
|
-
this.
|
|
2239
|
+
this.me[i] = runWithOwner((this.Ue[i] = createOwner()), r);
|
|
1900
2240
|
}
|
|
1901
2241
|
}
|
|
1902
|
-
this.
|
|
1903
|
-
this.
|
|
2242
|
+
this.me = this.me.slice(0, (this.we = t));
|
|
2243
|
+
this.ve = e.slice(0);
|
|
1904
2244
|
}
|
|
1905
2245
|
});
|
|
1906
|
-
return this.
|
|
2246
|
+
return this.me;
|
|
1907
2247
|
}
|
|
1908
2248
|
function repeat(e, t, n) {
|
|
1909
2249
|
return updateRepeat.bind({
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
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
|
|
1919
2259
|
});
|
|
1920
2260
|
}
|
|
1921
2261
|
function updateRepeat() {
|
|
1922
|
-
const e = this.
|
|
1923
|
-
const t = this
|
|
1924
|
-
runWithOwner(this.
|
|
2262
|
+
const e = this.Me();
|
|
2263
|
+
const t = this.$e?.() || 0;
|
|
2264
|
+
runWithOwner(this.De, () => {
|
|
1925
2265
|
if (e === 0) {
|
|
1926
|
-
if (this.
|
|
1927
|
-
this.
|
|
1928
|
-
this.
|
|
1929
|
-
this.
|
|
1930
|
-
this.
|
|
2266
|
+
if (this.we !== 0) {
|
|
2267
|
+
this.De.dispose(false);
|
|
2268
|
+
this.Ue = [];
|
|
2269
|
+
this.me = [];
|
|
2270
|
+
this.we = 0;
|
|
1931
2271
|
}
|
|
1932
|
-
if (this.
|
|
1933
|
-
this.
|
|
2272
|
+
if (this.xe && !this.me[0]) {
|
|
2273
|
+
this.me[0] = runWithOwner((this.Ue[0] = createOwner()), this.xe);
|
|
1934
2274
|
}
|
|
1935
2275
|
return;
|
|
1936
2276
|
}
|
|
1937
2277
|
const n = t + e;
|
|
1938
|
-
const i = this.
|
|
1939
|
-
if (this.
|
|
1940
|
-
for (let e = n; e < i; e++) this.
|
|
1941
|
-
if (this.
|
|
1942
|
-
let e = this.
|
|
1943
|
-
while (e < t && e < this.
|
|
1944
|
-
this.
|
|
1945
|
-
this.
|
|
1946
|
-
} else if (this.
|
|
1947
|
-
let n = i - this.
|
|
1948
|
-
let r = this.
|
|
1949
|
-
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;
|
|
1950
2290
|
while (n >= r) {
|
|
1951
|
-
this.
|
|
1952
|
-
this.
|
|
2291
|
+
this.Ue[n] = this.Ue[n - r];
|
|
2292
|
+
this.me[n] = this.me[n - r];
|
|
1953
2293
|
n--;
|
|
1954
2294
|
}
|
|
1955
2295
|
for (let e = 0; e < r; e++) {
|
|
1956
|
-
this.
|
|
2296
|
+
this.me[e] = runWithOwner((this.Ue[e] = createOwner()), () => this.Ve(e + t));
|
|
1957
2297
|
}
|
|
1958
2298
|
}
|
|
1959
2299
|
for (let e = i; e < n; e++) {
|
|
1960
|
-
this.
|
|
2300
|
+
this.me[e - t] = runWithOwner((this.Ue[e - t] = createOwner()), () => this.Ve(e));
|
|
1961
2301
|
}
|
|
1962
|
-
this.
|
|
1963
|
-
this.
|
|
1964
|
-
this.
|
|
2302
|
+
this.me = this.me.slice(0, e);
|
|
2303
|
+
this.Ge = t;
|
|
2304
|
+
this.we = e;
|
|
1965
2305
|
});
|
|
1966
|
-
return this.
|
|
2306
|
+
return this.me;
|
|
1967
2307
|
}
|
|
1968
2308
|
function compare(e, t, n) {
|
|
1969
2309
|
return e ? e(t) === e(n) : true;
|
|
1970
2310
|
}
|
|
1971
2311
|
function boundaryComputed(e, t) {
|
|
1972
|
-
const n = computed(e, undefined, {
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
},
|
|
1982
|
-
Qe: t
|
|
1983
|
-
}
|
|
1984
|
-
});
|
|
1985
|
-
n.Qe = t;
|
|
1986
|
-
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);
|
|
1987
2321
|
return n;
|
|
1988
2322
|
}
|
|
1989
2323
|
function createBoundChildren(e, t, n, i) {
|
|
1990
|
-
const r = e.
|
|
1991
|
-
r.addChild((e.
|
|
1992
|
-
onCleanup(() => r.removeChild(e.
|
|
2324
|
+
const r = e.J;
|
|
2325
|
+
r.addChild((e.J = n));
|
|
2326
|
+
onCleanup(() => r.removeChild(e.J));
|
|
1993
2327
|
return runWithOwner(e, () => {
|
|
1994
2328
|
const e = computed(t);
|
|
1995
2329
|
return boundaryComputed(() => staleValues(() => flatten(read(e))), i);
|
|
1996
2330
|
});
|
|
1997
2331
|
}
|
|
1998
2332
|
class ConditionalQueue extends Queue {
|
|
1999
|
-
|
|
2000
|
-
|
|
2333
|
+
He;
|
|
2334
|
+
Fe = new Set();
|
|
2001
2335
|
L = new Set();
|
|
2002
2336
|
constructor(e) {
|
|
2003
2337
|
super();
|
|
2004
|
-
this.
|
|
2338
|
+
this.He = e;
|
|
2005
2339
|
}
|
|
2006
2340
|
run(e) {
|
|
2007
|
-
if (!e || read(this.
|
|
2341
|
+
if (!e || read(this.He)) return;
|
|
2008
2342
|
return super.run(e);
|
|
2009
2343
|
}
|
|
2010
2344
|
notify(e, t, n) {
|
|
2011
|
-
if (read(this.
|
|
2345
|
+
if (read(this.He)) {
|
|
2012
2346
|
if (t & STATUS_PENDING) {
|
|
2013
2347
|
if (n & STATUS_PENDING) {
|
|
2014
2348
|
this.L.add(e);
|
|
@@ -2017,37 +2351,37 @@ class ConditionalQueue extends Queue {
|
|
|
2017
2351
|
}
|
|
2018
2352
|
if (t & STATUS_ERROR) {
|
|
2019
2353
|
if (n & STATUS_ERROR) {
|
|
2020
|
-
this
|
|
2354
|
+
this.Fe.add(e);
|
|
2021
2355
|
t &= ~STATUS_ERROR;
|
|
2022
|
-
} else if (this
|
|
2356
|
+
} else if (this.Fe.delete(e)) t &= ~STATUS_ERROR;
|
|
2023
2357
|
}
|
|
2024
2358
|
}
|
|
2025
2359
|
return t ? super.notify(e, t, n) : true;
|
|
2026
2360
|
}
|
|
2027
2361
|
}
|
|
2028
2362
|
class CollectionQueue extends Queue {
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2363
|
+
je;
|
|
2364
|
+
Ue = new Set();
|
|
2365
|
+
He = signal(false, { pureWrite: true });
|
|
2366
|
+
Ke = false;
|
|
2033
2367
|
constructor(e) {
|
|
2034
2368
|
super();
|
|
2035
|
-
this.
|
|
2369
|
+
this.je = e;
|
|
2036
2370
|
}
|
|
2037
2371
|
run(e) {
|
|
2038
|
-
if (!e || read(this.
|
|
2372
|
+
if (!e || read(this.He)) return;
|
|
2039
2373
|
return super.run(e);
|
|
2040
2374
|
}
|
|
2041
2375
|
notify(e, t, n) {
|
|
2042
|
-
if (!(t & this.
|
|
2043
|
-
if (n & this.
|
|
2044
|
-
this.
|
|
2045
|
-
if (this.
|
|
2046
|
-
} else if (this.
|
|
2047
|
-
this.
|
|
2048
|
-
if (this.
|
|
2049
|
-
}
|
|
2050
|
-
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;
|
|
2051
2385
|
return t ? super.notify(e, t, n) : true;
|
|
2052
2386
|
}
|
|
2053
2387
|
}
|
|
@@ -2061,53 +2395,55 @@ function createBoundary(e, t) {
|
|
|
2061
2395
|
const i = new ConditionalQueue(computed(() => t() === BoundaryMode.HIDDEN));
|
|
2062
2396
|
const r = createBoundChildren(n, e, i, 0);
|
|
2063
2397
|
computed(() => {
|
|
2064
|
-
const e = read(i.
|
|
2065
|
-
r.
|
|
2398
|
+
const e = read(i.He);
|
|
2399
|
+
r.Le = e ? STATUS_ERROR | STATUS_PENDING : 0;
|
|
2066
2400
|
if (!e) {
|
|
2067
2401
|
i.L.forEach(e => i.notify(e, STATUS_PENDING, STATUS_PENDING));
|
|
2068
|
-
i
|
|
2402
|
+
i.Fe.forEach(e => i.notify(e, STATUS_ERROR, STATUS_ERROR));
|
|
2069
2403
|
i.L.clear();
|
|
2070
|
-
i
|
|
2404
|
+
i.Fe.clear();
|
|
2071
2405
|
}
|
|
2072
2406
|
});
|
|
2073
|
-
return () => (read(i.
|
|
2407
|
+
return () => (read(i.He) ? undefined : read(r));
|
|
2074
2408
|
}
|
|
2075
2409
|
function createCollectionBoundary(e, t, n) {
|
|
2076
2410
|
const i = createOwner();
|
|
2077
2411
|
const r = new CollectionQueue(e);
|
|
2078
|
-
const
|
|
2079
|
-
const
|
|
2080
|
-
if (!read(r.
|
|
2081
|
-
const e = read(
|
|
2082
|
-
if (!untrack(() => read(r.
|
|
2083
|
-
|
|
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
|
+
}
|
|
2084
2420
|
}
|
|
2085
2421
|
return n(r);
|
|
2086
2422
|
});
|
|
2087
|
-
return read.bind(null,
|
|
2423
|
+
return read.bind(null, s);
|
|
2088
2424
|
}
|
|
2089
2425
|
function createLoadBoundary(e, t) {
|
|
2090
2426
|
return createCollectionBoundary(STATUS_PENDING, e, () => t());
|
|
2091
2427
|
}
|
|
2092
2428
|
function collectErrorSources(e, t) {
|
|
2093
2429
|
let n = true;
|
|
2094
|
-
let i = e.
|
|
2430
|
+
let i = e.C;
|
|
2095
2431
|
while (i !== null) {
|
|
2096
2432
|
const e = i.V;
|
|
2097
|
-
if (e.
|
|
2433
|
+
if (e.C && e.ie & STATUS_ERROR) {
|
|
2098
2434
|
n = false;
|
|
2099
2435
|
collectErrorSources(e, t);
|
|
2100
2436
|
}
|
|
2101
|
-
i = i.
|
|
2437
|
+
i = i.D;
|
|
2102
2438
|
}
|
|
2103
2439
|
n && t.push(e);
|
|
2104
2440
|
}
|
|
2105
2441
|
function createErrorBoundary(e, t) {
|
|
2106
2442
|
return createCollectionBoundary(STATUS_ERROR, e, e => {
|
|
2107
|
-
let n = e.
|
|
2108
|
-
return t(n.
|
|
2443
|
+
let n = e.Ue.values().next().value;
|
|
2444
|
+
return t(n.B, () => {
|
|
2109
2445
|
const t = [];
|
|
2110
|
-
for (const n of e.
|
|
2446
|
+
for (const n of e.Ue) collectErrorSources(n, t);
|
|
2111
2447
|
for (const e of t) recompute(e);
|
|
2112
2448
|
schedule();
|
|
2113
2449
|
});
|
|
@@ -2137,9 +2473,9 @@ function flatten(e, t) {
|
|
|
2137
2473
|
function flattenArray(e, t = [], n) {
|
|
2138
2474
|
let i = null;
|
|
2139
2475
|
let r = false;
|
|
2140
|
-
for (let
|
|
2476
|
+
for (let o = 0; o < e.length; o++) {
|
|
2141
2477
|
try {
|
|
2142
|
-
let i = e[
|
|
2478
|
+
let i = e[o];
|
|
2143
2479
|
if (typeof i === "function" && !i.length) {
|
|
2144
2480
|
if (n?.doNotUnwrap) {
|
|
2145
2481
|
t.push(i);
|