@solidjs/signals 0.8.1 → 0.8.2
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 +45 -22
- package/dist/node.cjs +352 -330
- package/dist/prod.js +352 -329
- package/dist/types/boundaries.d.ts +1 -2
- package/dist/types/core/scheduler.d.ts +11 -2
- package/package.json +1 -1
package/dist/node.cjs
CHANGED
|
@@ -27,21 +27,21 @@ var SUPPORTS_PROXY = typeof Proxy === "function";
|
|
|
27
27
|
// src/core/heap.ts
|
|
28
28
|
function actualInsertIntoHeap(n, heap) {
|
|
29
29
|
var _a, _b, _c;
|
|
30
|
-
const parentHeight = (((_a = n.
|
|
30
|
+
const parentHeight = (((_a = n.w) == null ? void 0 : _a._) ? (_b = n.w.$) == null ? void 0 : _b.c : (_c = n.w) == null ? void 0 : _c.c) ?? -1;
|
|
31
31
|
if (parentHeight >= n.c)
|
|
32
32
|
n.c = parentHeight + 1;
|
|
33
33
|
const height = n.c;
|
|
34
|
-
const heapAtHeight = heap.
|
|
34
|
+
const heapAtHeight = heap.r[height];
|
|
35
35
|
if (heapAtHeight === void 0) {
|
|
36
|
-
heap.
|
|
36
|
+
heap.r[height] = n;
|
|
37
37
|
} else {
|
|
38
|
-
const tail = heapAtHeight.
|
|
39
|
-
tail.
|
|
40
|
-
n.
|
|
41
|
-
heapAtHeight.
|
|
38
|
+
const tail = heapAtHeight.z;
|
|
39
|
+
tail.Q = n;
|
|
40
|
+
n.z = tail;
|
|
41
|
+
heapAtHeight.z = n;
|
|
42
42
|
}
|
|
43
|
-
if (height > heap.
|
|
44
|
-
heap.
|
|
43
|
+
if (height > heap.L) {
|
|
44
|
+
heap.L = height;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
function insertIntoHeap(n, heap) {
|
|
@@ -69,28 +69,28 @@ function deleteFromHeap(n, heap) {
|
|
|
69
69
|
return;
|
|
70
70
|
n.b = flags & ~(8 /* InHeap */ | 16 /* InHeapHeight */);
|
|
71
71
|
const height = n.c;
|
|
72
|
-
if (n.
|
|
73
|
-
heap.
|
|
72
|
+
if (n.z === n) {
|
|
73
|
+
heap.r[height] = void 0;
|
|
74
74
|
} else {
|
|
75
|
-
const next = n.
|
|
76
|
-
const dhh = heap.
|
|
75
|
+
const next = n.Q;
|
|
76
|
+
const dhh = heap.r[height];
|
|
77
77
|
const end = next ?? dhh;
|
|
78
78
|
if (n === dhh) {
|
|
79
|
-
heap.
|
|
79
|
+
heap.r[height] = next;
|
|
80
80
|
} else {
|
|
81
|
-
n.
|
|
81
|
+
n.z.Q = next;
|
|
82
82
|
}
|
|
83
|
-
end.
|
|
83
|
+
end.z = n.z;
|
|
84
84
|
}
|
|
85
|
-
n.
|
|
86
|
-
n.
|
|
85
|
+
n.z = n;
|
|
86
|
+
n.Q = void 0;
|
|
87
87
|
}
|
|
88
88
|
function markHeap(heap) {
|
|
89
89
|
if (heap.aa)
|
|
90
90
|
return;
|
|
91
91
|
heap.aa = true;
|
|
92
|
-
for (let i = 0; i <= heap.
|
|
93
|
-
for (let el = heap.
|
|
92
|
+
for (let i = 0; i <= heap.L; i++) {
|
|
93
|
+
for (let el = heap.r[i]; el !== void 0; el = el.Q) {
|
|
94
94
|
if (el.b & 8 /* InHeap */)
|
|
95
95
|
markNode(el);
|
|
96
96
|
}
|
|
@@ -101,12 +101,12 @@ function markNode(el, newState = 2 /* Dirty */) {
|
|
|
101
101
|
if ((flags & (1 /* Check */ | 2 /* Dirty */)) >= newState)
|
|
102
102
|
return;
|
|
103
103
|
el.b = flags & ~(1 /* Check */ | 2 /* Dirty */) | newState;
|
|
104
|
-
for (let link2 = el.
|
|
104
|
+
for (let link2 = el.s; link2 !== null; link2 = link2.A) {
|
|
105
105
|
markNode(link2.j, 1 /* Check */);
|
|
106
106
|
}
|
|
107
107
|
if (el.ba !== null) {
|
|
108
108
|
for (let child = el.ba; child !== null; child = child.ra) {
|
|
109
|
-
for (let link2 = child.
|
|
109
|
+
for (let link2 = child.s; link2 !== null; link2 = link2.A) {
|
|
110
110
|
markNode(link2.j, 1 /* Check */);
|
|
111
111
|
}
|
|
112
112
|
}
|
|
@@ -114,25 +114,25 @@ function markNode(el, newState = 2 /* Dirty */) {
|
|
|
114
114
|
}
|
|
115
115
|
function runHeap(heap, recompute2) {
|
|
116
116
|
heap.aa = false;
|
|
117
|
-
for (heap.
|
|
118
|
-
let el = heap.
|
|
117
|
+
for (heap.p = 0; heap.p <= heap.L; heap.p++) {
|
|
118
|
+
let el = heap.r[heap.p];
|
|
119
119
|
while (el !== void 0) {
|
|
120
120
|
if (el.b & 8 /* InHeap */)
|
|
121
121
|
recompute2(el);
|
|
122
122
|
else {
|
|
123
123
|
adjustHeight(el, heap);
|
|
124
124
|
}
|
|
125
|
-
el = heap.
|
|
125
|
+
el = heap.r[heap.p];
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
-
heap.
|
|
128
|
+
heap.L = 0;
|
|
129
129
|
}
|
|
130
130
|
function adjustHeight(el, heap) {
|
|
131
131
|
deleteFromHeap(el, heap);
|
|
132
132
|
let newHeight = el.c;
|
|
133
|
-
for (let d = el.
|
|
134
|
-
const dep1 = d.
|
|
135
|
-
const dep = "_owner" in dep1 ? dep1.
|
|
133
|
+
for (let d = el.x; d; d = d.F) {
|
|
134
|
+
const dep1 = d.R;
|
|
135
|
+
const dep = "_owner" in dep1 ? dep1.B : dep1;
|
|
136
136
|
if ("_fn" in dep) {
|
|
137
137
|
if (dep.c >= newHeight) {
|
|
138
138
|
newHeight = dep.c + 1;
|
|
@@ -141,7 +141,7 @@ function adjustHeight(el, heap) {
|
|
|
141
141
|
}
|
|
142
142
|
if (el.c !== newHeight) {
|
|
143
143
|
el.c = newHeight;
|
|
144
|
-
for (let s = el.
|
|
144
|
+
for (let s = el.s; s !== null; s = s.A) {
|
|
145
145
|
insertIntoHeapHeight(s.j, heap);
|
|
146
146
|
}
|
|
147
147
|
}
|
|
@@ -161,59 +161,83 @@ function schedule() {
|
|
|
161
161
|
queueMicrotask(flush);
|
|
162
162
|
}
|
|
163
163
|
var dirtyQueue = {
|
|
164
|
-
|
|
164
|
+
r: new Array(2e3).fill(void 0),
|
|
165
165
|
aa: false,
|
|
166
|
-
|
|
167
|
-
|
|
166
|
+
p: 0,
|
|
167
|
+
L: 0
|
|
168
168
|
};
|
|
169
169
|
var zombieQueue = {
|
|
170
|
-
|
|
170
|
+
r: new Array(2e3).fill(void 0),
|
|
171
171
|
aa: false,
|
|
172
|
-
|
|
173
|
-
|
|
172
|
+
p: 0,
|
|
173
|
+
L: 0
|
|
174
174
|
};
|
|
175
175
|
var Queue = class {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
176
|
+
w = null;
|
|
177
|
+
k = [[], []];
|
|
178
|
+
l = [];
|
|
179
179
|
created = clock;
|
|
180
180
|
addChild(child) {
|
|
181
|
-
this.
|
|
182
|
-
child.
|
|
181
|
+
this.l.push(child);
|
|
182
|
+
child.w = this;
|
|
183
183
|
}
|
|
184
184
|
removeChild(child) {
|
|
185
|
-
const index = this.
|
|
185
|
+
const index = this.l.indexOf(child);
|
|
186
186
|
if (index >= 0) {
|
|
187
|
-
this.
|
|
188
|
-
child.
|
|
187
|
+
this.l.splice(index, 1);
|
|
188
|
+
child.w = null;
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
notify(node, mask, flags) {
|
|
192
|
-
if (this.
|
|
193
|
-
return this.
|
|
192
|
+
if (this.w)
|
|
193
|
+
return this.w.notify(node, mask, flags);
|
|
194
194
|
return false;
|
|
195
195
|
}
|
|
196
196
|
run(type) {
|
|
197
|
-
if (this.
|
|
198
|
-
const effects = this.
|
|
199
|
-
this.
|
|
197
|
+
if (this.k[type - 1].length) {
|
|
198
|
+
const effects = this.k[type - 1];
|
|
199
|
+
this.k[type - 1] = [];
|
|
200
200
|
runQueue(effects, type);
|
|
201
201
|
}
|
|
202
|
-
for (let i = 0; i < this.
|
|
203
|
-
this.
|
|
202
|
+
for (let i = 0; i < this.l.length; i++) {
|
|
203
|
+
this.l[i].run(type);
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
enqueue(type, fn) {
|
|
207
207
|
if (type)
|
|
208
|
-
this.
|
|
208
|
+
this.k[type - 1].push(fn);
|
|
209
209
|
schedule();
|
|
210
210
|
}
|
|
211
|
+
stashQueues(stub) {
|
|
212
|
+
stub.k[0].push(...this.k[0]);
|
|
213
|
+
stub.k[1].push(...this.k[1]);
|
|
214
|
+
this.k = [[], []];
|
|
215
|
+
for (let i = 0; i < this.l.length; i++) {
|
|
216
|
+
let child = this.l[i];
|
|
217
|
+
let childStub = stub.l[i];
|
|
218
|
+
if (!childStub) {
|
|
219
|
+
childStub = { k: [[], []], l: [] };
|
|
220
|
+
stub.l[i] = childStub;
|
|
221
|
+
}
|
|
222
|
+
child.stashQueues(childStub);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
restoreQueues(stub) {
|
|
226
|
+
this.k[0].push(...stub.k[0]);
|
|
227
|
+
this.k[1].push(...stub.k[1]);
|
|
228
|
+
for (let i = 0; i < stub.l.length; i++) {
|
|
229
|
+
const childStub = stub.l[i];
|
|
230
|
+
let child = this.l[i];
|
|
231
|
+
if (child)
|
|
232
|
+
child.restoreQueues(childStub);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
211
235
|
};
|
|
212
236
|
var GlobalQueue = class _GlobalQueue extends Queue {
|
|
213
237
|
ca = false;
|
|
214
238
|
h = [];
|
|
215
239
|
static S;
|
|
216
|
-
static
|
|
240
|
+
static ka;
|
|
217
241
|
flush() {
|
|
218
242
|
if (this.ca)
|
|
219
243
|
return;
|
|
@@ -224,9 +248,7 @@ var GlobalQueue = class _GlobalQueue extends Queue {
|
|
|
224
248
|
if (!transitionComplete(activeTransition)) {
|
|
225
249
|
runHeap(zombieQueue, _GlobalQueue.S);
|
|
226
250
|
globalQueue.h = [];
|
|
227
|
-
|
|
228
|
-
activeTransition.queues[1].push(...globalQueue.A[1]);
|
|
229
|
-
globalQueue.A = [[], []];
|
|
251
|
+
globalQueue.stashQueues(activeTransition.queueStash);
|
|
230
252
|
clock++;
|
|
231
253
|
scheduled = false;
|
|
232
254
|
runPending(activeTransition.pendingNodes, true);
|
|
@@ -234,8 +256,7 @@ var GlobalQueue = class _GlobalQueue extends Queue {
|
|
|
234
256
|
return;
|
|
235
257
|
}
|
|
236
258
|
globalQueue.h.push(...activeTransition.pendingNodes);
|
|
237
|
-
globalQueue.
|
|
238
|
-
globalQueue.A[1].push(...activeTransition.queues[1]);
|
|
259
|
+
globalQueue.restoreQueues(activeTransition.queueStash);
|
|
239
260
|
transitions.delete(activeTransition);
|
|
240
261
|
activeTransition = null;
|
|
241
262
|
if (runPending(globalQueue.h, false))
|
|
@@ -249,7 +270,7 @@ var GlobalQueue = class _GlobalQueue extends Queue {
|
|
|
249
270
|
n.e = NOT_PENDING;
|
|
250
271
|
}
|
|
251
272
|
if (n.ha)
|
|
252
|
-
_GlobalQueue.
|
|
273
|
+
_GlobalQueue.ka(n, false, true);
|
|
253
274
|
}
|
|
254
275
|
globalQueue.h.length = 0;
|
|
255
276
|
clock++;
|
|
@@ -264,8 +285,8 @@ var GlobalQueue = class _GlobalQueue extends Queue {
|
|
|
264
285
|
notify(node, mask, flags) {
|
|
265
286
|
if (mask & 1 /* Pending */) {
|
|
266
287
|
if (flags & 1 /* Pending */) {
|
|
267
|
-
if (activeTransition && !activeTransition.asyncNodes.includes(node.
|
|
268
|
-
activeTransition.asyncNodes.push(node.
|
|
288
|
+
if (activeTransition && !activeTransition.asyncNodes.includes(node.C.cause))
|
|
289
|
+
activeTransition.asyncNodes.push(node.C.cause);
|
|
269
290
|
}
|
|
270
291
|
return true;
|
|
271
292
|
}
|
|
@@ -279,7 +300,7 @@ var GlobalQueue = class _GlobalQueue extends Queue {
|
|
|
279
300
|
time: clock,
|
|
280
301
|
pendingNodes: [],
|
|
281
302
|
asyncNodes: [],
|
|
282
|
-
|
|
303
|
+
queueStash: { k: [[], []], l: [] }
|
|
283
304
|
};
|
|
284
305
|
}
|
|
285
306
|
transitions.add(activeTransition);
|
|
@@ -298,8 +319,8 @@ function runPending(pendingNodes, value) {
|
|
|
298
319
|
for (let i = 0; i < p.length; i++) {
|
|
299
320
|
const n = p[i];
|
|
300
321
|
n.T = activeTransition;
|
|
301
|
-
if (n.
|
|
302
|
-
n.
|
|
322
|
+
if (n.H) {
|
|
323
|
+
n.H.da(value);
|
|
303
324
|
needsReset = true;
|
|
304
325
|
}
|
|
305
326
|
}
|
|
@@ -329,7 +350,7 @@ function notifyUnobserved() {
|
|
|
329
350
|
var _a, _b;
|
|
330
351
|
for (let i = 0; i < unobserved.length; i++) {
|
|
331
352
|
const source = unobserved[i];
|
|
332
|
-
if (!source.
|
|
353
|
+
if (!source.s)
|
|
333
354
|
(_b = (_a = unobserved[i]).sa) == null ? void 0 : _b.call(_a);
|
|
334
355
|
}
|
|
335
356
|
unobserved = [];
|
|
@@ -337,13 +358,21 @@ function notifyUnobserved() {
|
|
|
337
358
|
|
|
338
359
|
// src/core/core.ts
|
|
339
360
|
GlobalQueue.S = recompute;
|
|
340
|
-
GlobalQueue.
|
|
361
|
+
GlobalQueue.ka = disposeChildren;
|
|
341
362
|
var tracking = false;
|
|
342
363
|
var stale = false;
|
|
343
364
|
var pendingValueCheck = false;
|
|
344
365
|
var pendingCheck = null;
|
|
345
366
|
var context = null;
|
|
346
367
|
var defaultContext = {};
|
|
368
|
+
function notifySubs(node) {
|
|
369
|
+
for (let s = node.s; s !== null; s = s.A) {
|
|
370
|
+
const queue = s.j.b & 32 /* Zombie */ ? zombieQueue : dirtyQueue;
|
|
371
|
+
if (queue.p > s.j.c)
|
|
372
|
+
queue.p = s.j.c;
|
|
373
|
+
insertIntoHeap(s.j, queue);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
347
376
|
function recompute(el, create = false) {
|
|
348
377
|
var _a;
|
|
349
378
|
deleteFromHeap(el, el.b & 32 /* Zombie */ ? zombieQueue : dirtyQueue);
|
|
@@ -352,20 +381,20 @@ function recompute(el, create = false) {
|
|
|
352
381
|
else {
|
|
353
382
|
markDisposal(el);
|
|
354
383
|
globalQueue.h.push(el);
|
|
355
|
-
el.V = el.
|
|
356
|
-
el.U = el.
|
|
357
|
-
el.
|
|
358
|
-
el.
|
|
384
|
+
el.V = el.t;
|
|
385
|
+
el.U = el.q;
|
|
386
|
+
el.t = null;
|
|
387
|
+
el.q = null;
|
|
359
388
|
}
|
|
360
389
|
const oldcontext = context;
|
|
361
390
|
context = el;
|
|
362
|
-
el.
|
|
391
|
+
el.I = null;
|
|
363
392
|
el.b = 4 /* RecomputingDeps */;
|
|
364
|
-
el.
|
|
393
|
+
el.J = clock;
|
|
365
394
|
let value = el.e === NOT_PENDING ? el.g : el.e;
|
|
366
395
|
let oldHeight = el.c;
|
|
367
396
|
let prevStatusFlags = el.f;
|
|
368
|
-
let prevError = el.
|
|
397
|
+
let prevError = el.C;
|
|
369
398
|
let prevTracking = tracking;
|
|
370
399
|
clearStatusFlags(el);
|
|
371
400
|
tracking = true;
|
|
@@ -384,50 +413,50 @@ function recompute(el, create = false) {
|
|
|
384
413
|
}
|
|
385
414
|
el.b = 0 /* None */;
|
|
386
415
|
context = oldcontext;
|
|
387
|
-
const depsTail = el.
|
|
388
|
-
let toRemove = depsTail !== null ? depsTail.
|
|
416
|
+
const depsTail = el.I;
|
|
417
|
+
let toRemove = depsTail !== null ? depsTail.F : el.x;
|
|
389
418
|
if (toRemove !== null) {
|
|
390
419
|
do {
|
|
391
420
|
toRemove = unlinkSubs(toRemove);
|
|
392
421
|
} while (toRemove !== null);
|
|
393
422
|
if (depsTail !== null) {
|
|
394
|
-
depsTail.
|
|
423
|
+
depsTail.F = null;
|
|
395
424
|
} else {
|
|
396
|
-
el.
|
|
425
|
+
el.x = null;
|
|
397
426
|
}
|
|
398
427
|
}
|
|
399
428
|
const valueChanged = !el.ea || !el.ea(el.e === NOT_PENDING ? el.g : el.e, value);
|
|
400
|
-
const statusFlagsChanged = el.f !== prevStatusFlags || el.
|
|
401
|
-
(_a = el.
|
|
429
|
+
const statusFlagsChanged = el.f !== prevStatusFlags || el.C !== prevError;
|
|
430
|
+
(_a = el.la) == null ? void 0 : _a.call(el, statusFlagsChanged, prevStatusFlags);
|
|
402
431
|
if (valueChanged || statusFlagsChanged) {
|
|
403
432
|
if (valueChanged) {
|
|
404
|
-
if (create || el.ia || el.
|
|
433
|
+
if (create || el.ia || el.K)
|
|
405
434
|
el.g = value;
|
|
406
435
|
else {
|
|
407
436
|
if (el.e === NOT_PENDING)
|
|
408
437
|
globalQueue.h.push(el);
|
|
409
438
|
el.e = value;
|
|
410
439
|
}
|
|
411
|
-
if (el.
|
|
412
|
-
el.
|
|
440
|
+
if (el.D)
|
|
441
|
+
el.D.da(value);
|
|
413
442
|
}
|
|
414
|
-
for (let s = el.
|
|
443
|
+
for (let s = el.s; s !== null; s = s.A) {
|
|
415
444
|
const queue = s.j.b & 32 /* Zombie */ ? zombieQueue : dirtyQueue;
|
|
416
|
-
if (s.j.c < el.c && queue.
|
|
417
|
-
queue.
|
|
445
|
+
if (s.j.c < el.c && queue.p > s.j.c)
|
|
446
|
+
queue.p = s.j.c;
|
|
418
447
|
insertIntoHeap(s.j, queue);
|
|
419
448
|
}
|
|
420
449
|
} else if (el.c != oldHeight) {
|
|
421
|
-
for (let s = el.
|
|
450
|
+
for (let s = el.s; s !== null; s = s.A) {
|
|
422
451
|
insertIntoHeapHeight(s.j, s.j.b & 32 /* Zombie */ ? zombieQueue : dirtyQueue);
|
|
423
452
|
}
|
|
424
453
|
}
|
|
425
454
|
}
|
|
426
455
|
function updateIfNecessary(el) {
|
|
427
456
|
if (el.b & 1 /* Check */) {
|
|
428
|
-
for (let d = el.
|
|
429
|
-
const dep1 = d.
|
|
430
|
-
const dep = "_owner" in dep1 ? dep1.
|
|
457
|
+
for (let d = el.x; d; d = d.F) {
|
|
458
|
+
const dep1 = d.R;
|
|
459
|
+
const dep = "_owner" in dep1 ? dep1.B : dep1;
|
|
431
460
|
if ("_fn" in dep) {
|
|
432
461
|
updateIfNecessary(dep);
|
|
433
462
|
}
|
|
@@ -442,62 +471,62 @@ function updateIfNecessary(el) {
|
|
|
442
471
|
el.b = 0 /* None */;
|
|
443
472
|
}
|
|
444
473
|
function unlinkSubs(link2) {
|
|
445
|
-
const dep = link2.
|
|
446
|
-
const nextDep = link2.
|
|
447
|
-
const nextSub = link2.
|
|
448
|
-
const prevSub = link2.
|
|
474
|
+
const dep = link2.R;
|
|
475
|
+
const nextDep = link2.F;
|
|
476
|
+
const nextSub = link2.A;
|
|
477
|
+
const prevSub = link2.ma;
|
|
449
478
|
if (nextSub !== null) {
|
|
450
|
-
nextSub.
|
|
479
|
+
nextSub.ma = prevSub;
|
|
451
480
|
} else {
|
|
452
|
-
dep.
|
|
481
|
+
dep.W = prevSub;
|
|
453
482
|
}
|
|
454
483
|
if (prevSub !== null) {
|
|
455
|
-
prevSub.
|
|
484
|
+
prevSub.A = nextSub;
|
|
456
485
|
} else {
|
|
457
|
-
dep.
|
|
486
|
+
dep.s = nextSub;
|
|
458
487
|
}
|
|
459
488
|
return nextDep;
|
|
460
489
|
}
|
|
461
490
|
function link(dep, sub) {
|
|
462
|
-
const prevDep = sub.
|
|
463
|
-
if (prevDep !== null && prevDep.
|
|
491
|
+
const prevDep = sub.I;
|
|
492
|
+
if (prevDep !== null && prevDep.R === dep) {
|
|
464
493
|
return;
|
|
465
494
|
}
|
|
466
495
|
let nextDep = null;
|
|
467
496
|
const isRecomputing = sub.b & 4 /* RecomputingDeps */;
|
|
468
497
|
if (isRecomputing) {
|
|
469
|
-
nextDep = prevDep !== null ? prevDep.
|
|
470
|
-
if (nextDep !== null && nextDep.
|
|
471
|
-
sub.
|
|
498
|
+
nextDep = prevDep !== null ? prevDep.F : sub.x;
|
|
499
|
+
if (nextDep !== null && nextDep.R === dep) {
|
|
500
|
+
sub.I = nextDep;
|
|
472
501
|
return;
|
|
473
502
|
}
|
|
474
503
|
}
|
|
475
|
-
const prevSub = dep.
|
|
504
|
+
const prevSub = dep.W;
|
|
476
505
|
if (prevSub !== null && prevSub.j === sub && (!isRecomputing || isValidLink(prevSub, sub))) {
|
|
477
506
|
return;
|
|
478
507
|
}
|
|
479
|
-
const newLink = sub.
|
|
480
|
-
|
|
508
|
+
const newLink = sub.I = dep.W = {
|
|
509
|
+
R: dep,
|
|
481
510
|
j: sub,
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
511
|
+
F: nextDep,
|
|
512
|
+
ma: prevSub,
|
|
513
|
+
A: null
|
|
485
514
|
};
|
|
486
515
|
if (prevDep !== null) {
|
|
487
|
-
prevDep.
|
|
516
|
+
prevDep.F = newLink;
|
|
488
517
|
} else {
|
|
489
|
-
sub.
|
|
518
|
+
sub.x = newLink;
|
|
490
519
|
}
|
|
491
520
|
if (prevSub !== null) {
|
|
492
|
-
prevSub.
|
|
521
|
+
prevSub.A = newLink;
|
|
493
522
|
} else {
|
|
494
|
-
dep.
|
|
523
|
+
dep.s = newLink;
|
|
495
524
|
}
|
|
496
525
|
}
|
|
497
526
|
function isValidLink(checkLink, sub) {
|
|
498
|
-
const depsTail = sub.
|
|
527
|
+
const depsTail = sub.I;
|
|
499
528
|
if (depsTail !== null) {
|
|
500
|
-
let link2 = sub.
|
|
529
|
+
let link2 = sub.x;
|
|
501
530
|
do {
|
|
502
531
|
if (link2 === checkLink) {
|
|
503
532
|
return true;
|
|
@@ -505,23 +534,23 @@ function isValidLink(checkLink, sub) {
|
|
|
505
534
|
if (link2 === depsTail) {
|
|
506
535
|
break;
|
|
507
536
|
}
|
|
508
|
-
link2 = link2.
|
|
537
|
+
link2 = link2.F;
|
|
509
538
|
} while (link2 !== null);
|
|
510
539
|
}
|
|
511
540
|
return false;
|
|
512
541
|
}
|
|
513
542
|
function setStatusFlags(signal2, flags, error = null) {
|
|
514
543
|
signal2.f = flags;
|
|
515
|
-
signal2.
|
|
544
|
+
signal2.C = error;
|
|
516
545
|
}
|
|
517
546
|
function setError(signal2, error) {
|
|
518
|
-
setStatusFlags(signal2, 2 /* Error
|
|
547
|
+
setStatusFlags(signal2, 2 /* Error */, error);
|
|
519
548
|
}
|
|
520
549
|
function clearStatusFlags(signal2) {
|
|
521
550
|
setStatusFlags(signal2, 0 /* None */);
|
|
522
551
|
}
|
|
523
552
|
function markDisposal(el) {
|
|
524
|
-
let child = el.
|
|
553
|
+
let child = el.q;
|
|
525
554
|
while (child) {
|
|
526
555
|
child.b |= 32 /* Zombie */;
|
|
527
556
|
const inHeap = child.b & 8 /* InHeap */;
|
|
@@ -530,7 +559,7 @@ function markDisposal(el) {
|
|
|
530
559
|
insertIntoHeap(child, zombieQueue);
|
|
531
560
|
}
|
|
532
561
|
markDisposal(child);
|
|
533
|
-
child = child.
|
|
562
|
+
child = child.M;
|
|
534
563
|
}
|
|
535
564
|
}
|
|
536
565
|
function disposeChildren(node, self = false, zombie) {
|
|
@@ -538,18 +567,18 @@ function disposeChildren(node, self = false, zombie) {
|
|
|
538
567
|
return;
|
|
539
568
|
if (self)
|
|
540
569
|
node.b = 64 /* Disposed */;
|
|
541
|
-
let child = zombie ? node.U : node.
|
|
570
|
+
let child = zombie ? node.U : node.q;
|
|
542
571
|
while (child) {
|
|
543
|
-
const nextChild = child.
|
|
544
|
-
if (child.
|
|
572
|
+
const nextChild = child.M;
|
|
573
|
+
if (child.x) {
|
|
545
574
|
const n = child;
|
|
546
575
|
deleteFromHeap(n, n.b & 32 /* Zombie */ ? zombieQueue : dirtyQueue);
|
|
547
|
-
let toRemove = n.
|
|
576
|
+
let toRemove = n.x;
|
|
548
577
|
do {
|
|
549
578
|
toRemove = unlinkSubs(toRemove);
|
|
550
579
|
} while (toRemove !== null);
|
|
551
|
-
n.
|
|
552
|
-
n.
|
|
580
|
+
n.x = null;
|
|
581
|
+
n.I = null;
|
|
553
582
|
}
|
|
554
583
|
disposeChildren(child, true);
|
|
555
584
|
child = nextChild;
|
|
@@ -557,13 +586,13 @@ function disposeChildren(node, self = false, zombie) {
|
|
|
557
586
|
if (zombie) {
|
|
558
587
|
node.U = null;
|
|
559
588
|
} else {
|
|
560
|
-
node.
|
|
561
|
-
node.
|
|
589
|
+
node.q = null;
|
|
590
|
+
node.M = null;
|
|
562
591
|
}
|
|
563
592
|
runDisposal(node, zombie);
|
|
564
593
|
}
|
|
565
594
|
function runDisposal(node, zombie) {
|
|
566
|
-
let disposal = zombie ? node.V : node.
|
|
595
|
+
let disposal = zombie ? node.V : node.t;
|
|
567
596
|
if (!disposal)
|
|
568
597
|
return;
|
|
569
598
|
if (Array.isArray(disposal)) {
|
|
@@ -574,7 +603,7 @@ function runDisposal(node, zombie) {
|
|
|
574
603
|
} else {
|
|
575
604
|
disposal.call(disposal);
|
|
576
605
|
}
|
|
577
|
-
zombie ? node.V = null : node.
|
|
606
|
+
zombie ? node.V = null : node.t = null;
|
|
578
607
|
}
|
|
579
608
|
function withOptions(obj, options) {
|
|
580
609
|
obj.id = (options == null ? void 0 : options.id) ?? ((context == null ? void 0 : context.id) != null ? getNextChildId(context) : void 0);
|
|
@@ -587,7 +616,7 @@ function withOptions(obj, options) {
|
|
|
587
616
|
}
|
|
588
617
|
function getNextChildId(owner) {
|
|
589
618
|
if (owner.id != null)
|
|
590
|
-
return formatId(owner.id, owner.
|
|
619
|
+
return formatId(owner.id, owner.na++);
|
|
591
620
|
throw new Error("Cannot get child id from owner without an id");
|
|
592
621
|
}
|
|
593
622
|
function formatId(prefix, id) {
|
|
@@ -597,43 +626,43 @@ function formatId(prefix, id) {
|
|
|
597
626
|
function computed(fn, initialValue, options) {
|
|
598
627
|
const self = withOptions(
|
|
599
628
|
{
|
|
600
|
-
|
|
629
|
+
t: null,
|
|
601
630
|
i: globalQueue,
|
|
602
|
-
|
|
603
|
-
|
|
631
|
+
E: defaultContext,
|
|
632
|
+
na: 0,
|
|
604
633
|
ha: fn,
|
|
605
634
|
g: initialValue,
|
|
606
635
|
c: 0,
|
|
607
636
|
ba: null,
|
|
608
|
-
|
|
637
|
+
Q: void 0,
|
|
638
|
+
z: null,
|
|
609
639
|
x: null,
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
o: null,
|
|
640
|
+
I: null,
|
|
641
|
+
s: null,
|
|
642
|
+
W: null,
|
|
643
|
+
w: context,
|
|
644
|
+
M: null,
|
|
645
|
+
q: null,
|
|
617
646
|
b: 0 /* None */,
|
|
618
647
|
f: 4 /* Uninitialized */,
|
|
619
|
-
|
|
648
|
+
J: clock,
|
|
620
649
|
e: NOT_PENDING,
|
|
621
650
|
V: null,
|
|
622
651
|
U: null
|
|
623
652
|
},
|
|
624
653
|
options
|
|
625
654
|
);
|
|
626
|
-
self.
|
|
655
|
+
self.z = self;
|
|
627
656
|
const parent = (context == null ? void 0 : context._) ? context.$ : context;
|
|
628
657
|
if (context) {
|
|
629
658
|
context.i && (self.i = context.i);
|
|
630
|
-
context.
|
|
631
|
-
const lastChild = context.
|
|
659
|
+
context.E && (self.E = context.E);
|
|
660
|
+
const lastChild = context.q;
|
|
632
661
|
if (lastChild === null) {
|
|
633
|
-
context.
|
|
662
|
+
context.q = self;
|
|
634
663
|
} else {
|
|
635
|
-
self.
|
|
636
|
-
context.
|
|
664
|
+
self.M = lastChild;
|
|
665
|
+
context.q = self;
|
|
637
666
|
}
|
|
638
667
|
}
|
|
639
668
|
if (parent)
|
|
@@ -665,6 +694,9 @@ function asyncComputed(asyncFn, initialValue, options) {
|
|
|
665
694
|
return;
|
|
666
695
|
globalQueue.initTransition(self);
|
|
667
696
|
setError(self, e);
|
|
697
|
+
self.J = clock;
|
|
698
|
+
notifySubs(self);
|
|
699
|
+
schedule();
|
|
668
700
|
flush();
|
|
669
701
|
});
|
|
670
702
|
} else {
|
|
@@ -682,6 +714,9 @@ function asyncComputed(asyncFn, initialValue, options) {
|
|
|
682
714
|
return;
|
|
683
715
|
globalQueue.initTransition(self);
|
|
684
716
|
setError(self, error);
|
|
717
|
+
self.J = clock;
|
|
718
|
+
notifySubs(self);
|
|
719
|
+
schedule();
|
|
685
720
|
flush();
|
|
686
721
|
}
|
|
687
722
|
})();
|
|
@@ -702,12 +737,12 @@ function signal(v, options, firewall = null) {
|
|
|
702
737
|
return firewall.ba = withOptions(
|
|
703
738
|
{
|
|
704
739
|
g: v,
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
740
|
+
s: null,
|
|
741
|
+
W: null,
|
|
742
|
+
B: firewall,
|
|
708
743
|
ra: firewall.ba,
|
|
709
744
|
f: 0 /* None */,
|
|
710
|
-
|
|
745
|
+
J: clock,
|
|
711
746
|
e: NOT_PENDING
|
|
712
747
|
},
|
|
713
748
|
options
|
|
@@ -716,10 +751,10 @@ function signal(v, options, firewall = null) {
|
|
|
716
751
|
return withOptions(
|
|
717
752
|
{
|
|
718
753
|
g: v,
|
|
719
|
-
|
|
720
|
-
|
|
754
|
+
s: null,
|
|
755
|
+
W: null,
|
|
721
756
|
f: 0 /* None */,
|
|
722
|
-
|
|
757
|
+
J: clock,
|
|
723
758
|
e: NOT_PENDING
|
|
724
759
|
},
|
|
725
760
|
options
|
|
@@ -745,65 +780,65 @@ function read(el) {
|
|
|
745
780
|
c = c.$;
|
|
746
781
|
if (c && tracking) {
|
|
747
782
|
link(el, c);
|
|
748
|
-
const owner = "_owner" in el ? el.
|
|
783
|
+
const owner = "_owner" in el ? el.B : el;
|
|
749
784
|
if ("_fn" in owner) {
|
|
750
785
|
const isZombie = el.b & 32 /* Zombie */;
|
|
751
|
-
if (owner.c >= (isZombie ? zombieQueue.
|
|
786
|
+
if (owner.c >= (isZombie ? zombieQueue.p : dirtyQueue.p)) {
|
|
752
787
|
markNode(c);
|
|
753
788
|
markHeap(isZombie ? zombieQueue : dirtyQueue);
|
|
754
789
|
updateIfNecessary(owner);
|
|
755
790
|
}
|
|
756
791
|
const height = owner.c;
|
|
757
|
-
if (height >= c.c && el.
|
|
792
|
+
if (height >= c.c && el.w !== c) {
|
|
758
793
|
c.c = height + 1;
|
|
759
794
|
}
|
|
760
795
|
}
|
|
761
796
|
}
|
|
762
797
|
if (pendingCheck) {
|
|
763
798
|
const pendingResult = (el.f & 1 /* Pending */) !== 0 || !!el.T || false;
|
|
764
|
-
if (!el.
|
|
765
|
-
el.
|
|
766
|
-
el.
|
|
767
|
-
el.
|
|
799
|
+
if (!el.H) {
|
|
800
|
+
el.H = signal(pendingResult);
|
|
801
|
+
el.H.ia = true;
|
|
802
|
+
el.H.da = (v) => setSignal(el.H, v);
|
|
768
803
|
}
|
|
769
804
|
const prev = pendingCheck;
|
|
770
805
|
pendingCheck = null;
|
|
771
|
-
read(el.
|
|
806
|
+
read(el.H);
|
|
772
807
|
pendingCheck = prev;
|
|
773
808
|
prev.g = pendingResult || prev.g;
|
|
774
809
|
}
|
|
775
810
|
if (pendingValueCheck) {
|
|
776
|
-
if (!el.
|
|
777
|
-
el.
|
|
811
|
+
if (!el.D) {
|
|
812
|
+
el.D = signal(
|
|
778
813
|
el.e === NOT_PENDING ? el.g : el.e
|
|
779
814
|
);
|
|
780
|
-
el.
|
|
781
|
-
el.
|
|
815
|
+
el.D.ia = true;
|
|
816
|
+
el.D.da = (v) => queueMicrotask(() => queueMicrotask(() => setSignal(el.D, v)));
|
|
782
817
|
}
|
|
783
818
|
pendingValueCheck = false;
|
|
784
819
|
try {
|
|
785
|
-
return read(el.
|
|
820
|
+
return read(el.D);
|
|
786
821
|
} finally {
|
|
787
822
|
pendingValueCheck = true;
|
|
788
823
|
}
|
|
789
824
|
}
|
|
790
825
|
if (el.f & 1 /* Pending */) {
|
|
791
826
|
if (c && !stale || el.f & 4 /* Uninitialized */)
|
|
792
|
-
throw el.
|
|
827
|
+
throw el.C;
|
|
793
828
|
else if (c && stale && !pendingCheck) {
|
|
794
829
|
setStatusFlags(
|
|
795
830
|
c,
|
|
796
831
|
c.f | 1,
|
|
797
|
-
el.
|
|
832
|
+
el.C
|
|
798
833
|
);
|
|
799
834
|
}
|
|
800
835
|
}
|
|
801
836
|
if (el.f & 2 /* Error */) {
|
|
802
|
-
if (el.
|
|
837
|
+
if (el.J < clock) {
|
|
803
838
|
recompute(el, true);
|
|
804
839
|
return read(el);
|
|
805
840
|
} else {
|
|
806
|
-
throw el.
|
|
841
|
+
throw el.C;
|
|
807
842
|
}
|
|
808
843
|
}
|
|
809
844
|
return !c || el.e === NOT_PENDING || stale && !pendingCheck && el.T && activeTransition !== el.T ? el.g : el.e;
|
|
@@ -825,17 +860,12 @@ function setSignal(el, v) {
|
|
|
825
860
|
globalQueue.h.push(el);
|
|
826
861
|
el.e = v;
|
|
827
862
|
}
|
|
828
|
-
if (el.
|
|
829
|
-
el.
|
|
863
|
+
if (el.D)
|
|
864
|
+
el.D.da(v);
|
|
830
865
|
}
|
|
831
866
|
clearStatusFlags(el);
|
|
832
|
-
el.
|
|
833
|
-
|
|
834
|
-
const queue = s.j.b & 32 /* Zombie */ ? zombieQueue : dirtyQueue;
|
|
835
|
-
if (queue.n > s.j.c)
|
|
836
|
-
queue.n = s.j.c;
|
|
837
|
-
insertIntoHeap(s.j, queue);
|
|
838
|
-
}
|
|
867
|
+
el.J = clock;
|
|
868
|
+
notifySubs(el);
|
|
839
869
|
schedule();
|
|
840
870
|
return v;
|
|
841
871
|
}
|
|
@@ -849,12 +879,12 @@ function onCleanup(fn) {
|
|
|
849
879
|
if (!context)
|
|
850
880
|
return fn;
|
|
851
881
|
const node = context;
|
|
852
|
-
if (!node.
|
|
853
|
-
node.
|
|
854
|
-
} else if (Array.isArray(node.
|
|
855
|
-
node.
|
|
882
|
+
if (!node.t) {
|
|
883
|
+
node.t = fn;
|
|
884
|
+
} else if (Array.isArray(node.t)) {
|
|
885
|
+
node.t.push(fn);
|
|
856
886
|
} else {
|
|
857
|
-
node.
|
|
887
|
+
node.t = [node.t, fn];
|
|
858
888
|
}
|
|
859
889
|
return fn;
|
|
860
890
|
}
|
|
@@ -863,27 +893,27 @@ function createOwner(options) {
|
|
|
863
893
|
const owner = {
|
|
864
894
|
_: true,
|
|
865
895
|
$: (parent == null ? void 0 : parent._) ? parent.$ : parent,
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
896
|
+
q: null,
|
|
897
|
+
M: null,
|
|
898
|
+
t: null,
|
|
869
899
|
id: (options == null ? void 0 : options.id) ?? ((parent == null ? void 0 : parent.id) != null ? getNextChildId(parent) : void 0),
|
|
870
900
|
i: (parent == null ? void 0 : parent.i) ?? globalQueue,
|
|
871
|
-
|
|
872
|
-
|
|
901
|
+
E: (parent == null ? void 0 : parent.E) || defaultContext,
|
|
902
|
+
na: 0,
|
|
873
903
|
V: null,
|
|
874
904
|
U: null,
|
|
875
|
-
|
|
905
|
+
w: parent,
|
|
876
906
|
dispose(self = true) {
|
|
877
907
|
disposeChildren(owner, self);
|
|
878
908
|
}
|
|
879
909
|
};
|
|
880
910
|
if (parent) {
|
|
881
|
-
const lastChild = parent.
|
|
911
|
+
const lastChild = parent.q;
|
|
882
912
|
if (lastChild === null) {
|
|
883
|
-
parent.
|
|
913
|
+
parent.q = owner;
|
|
884
914
|
} else {
|
|
885
|
-
owner.
|
|
886
|
-
parent.
|
|
915
|
+
owner.M = lastChild;
|
|
916
|
+
parent.q = owner;
|
|
887
917
|
}
|
|
888
918
|
}
|
|
889
919
|
return owner;
|
|
@@ -944,7 +974,7 @@ function getContext(context2, owner = getOwner()) {
|
|
|
944
974
|
if (!owner) {
|
|
945
975
|
throw new NoOwnerError();
|
|
946
976
|
}
|
|
947
|
-
const value = hasContext(context2, owner) ? owner.
|
|
977
|
+
const value = hasContext(context2, owner) ? owner.E[context2.id] : context2.defaultValue;
|
|
948
978
|
if (isUndefined(value)) {
|
|
949
979
|
throw new ContextNotFoundError();
|
|
950
980
|
}
|
|
@@ -954,13 +984,13 @@ function setContext(context2, value, owner = getOwner()) {
|
|
|
954
984
|
if (!owner) {
|
|
955
985
|
throw new NoOwnerError();
|
|
956
986
|
}
|
|
957
|
-
owner.
|
|
958
|
-
...owner.
|
|
987
|
+
owner.E = {
|
|
988
|
+
...owner.E,
|
|
959
989
|
[context2.id]: isUndefined(value) ? context2.defaultValue : value
|
|
960
990
|
};
|
|
961
991
|
}
|
|
962
992
|
function hasContext(context2, owner) {
|
|
963
|
-
return !isUndefined(owner == null ? void 0 : owner.
|
|
993
|
+
return !isUndefined(owner == null ? void 0 : owner.E[context2.id]);
|
|
964
994
|
}
|
|
965
995
|
function isUndefined(value) {
|
|
966
996
|
return typeof value === "undefined";
|
|
@@ -974,28 +1004,28 @@ function effect(compute, effect2, error, initialValue, options) {
|
|
|
974
1004
|
...options,
|
|
975
1005
|
ja: {
|
|
976
1006
|
fa: true,
|
|
977
|
-
|
|
1007
|
+
oa: initialValue,
|
|
978
1008
|
ua: effect2,
|
|
979
|
-
|
|
980
|
-
|
|
1009
|
+
pa: error,
|
|
1010
|
+
N: void 0,
|
|
981
1011
|
i: ((_a = getOwner()) == null ? void 0 : _a.i) ?? globalQueue,
|
|
982
|
-
|
|
983
|
-
|
|
1012
|
+
K: (options == null ? void 0 : options.render) ? 1 /* Render */ : 2 /* User */,
|
|
1013
|
+
la(statusFlagsChanged, prevStatusFlags) {
|
|
984
1014
|
if (initialized) {
|
|
985
1015
|
const errorChanged = this.f && this.f === prevStatusFlags && statusFlagsChanged;
|
|
986
1016
|
this.fa = !(this.f & 2 /* Error */) && !(this.f & 1 /* Pending */ & ~prevStatusFlags) && !errorChanged;
|
|
987
1017
|
if (this.fa)
|
|
988
|
-
this.i.enqueue(this.
|
|
1018
|
+
this.i.enqueue(this.K, runEffect.bind(this));
|
|
989
1019
|
}
|
|
990
1020
|
if (this.f & 2 /* Error */) {
|
|
991
|
-
let error2 = this.
|
|
1021
|
+
let error2 = this.C;
|
|
992
1022
|
this.i.notify(this, 1 /* Pending */, 0);
|
|
993
|
-
if (this.
|
|
1023
|
+
if (this.K === 2 /* User */) {
|
|
994
1024
|
try {
|
|
995
|
-
return this.
|
|
1025
|
+
return this.pa ? this.pa(error2, () => {
|
|
996
1026
|
var _a2;
|
|
997
|
-
(_a2 = this.
|
|
998
|
-
this.
|
|
1027
|
+
(_a2 = this.N) == null ? void 0 : _a2.call(this);
|
|
1028
|
+
this.N = void 0;
|
|
999
1029
|
}) : console.error(error2);
|
|
1000
1030
|
} catch (e) {
|
|
1001
1031
|
error2 = e;
|
|
@@ -1003,7 +1033,7 @@ function effect(compute, effect2, error, initialValue, options) {
|
|
|
1003
1033
|
}
|
|
1004
1034
|
if (!this.i.notify(this, 2 /* Error */, 2 /* Error */))
|
|
1005
1035
|
throw error2;
|
|
1006
|
-
} else if (this.
|
|
1036
|
+
} else if (this.K === 1 /* Render */) {
|
|
1007
1037
|
this.i.notify(
|
|
1008
1038
|
this,
|
|
1009
1039
|
1 /* Pending */ | 2 /* Error */,
|
|
@@ -1014,28 +1044,27 @@ function effect(compute, effect2, error, initialValue, options) {
|
|
|
1014
1044
|
}
|
|
1015
1045
|
});
|
|
1016
1046
|
initialized = true;
|
|
1017
|
-
if (node.
|
|
1018
|
-
node.ha = (p) =>
|
|
1019
|
-
|
|
1020
|
-
!(options == null ? void 0 : options.defer) && !(node.f & (2 /* Error */ | 1 /* Pending */)) && (node.I === 2 /* User */ ? node.i.enqueue(node.I, runEffect.bind(node)) : runEffect.call(node));
|
|
1047
|
+
if (node.K === 1 /* Render */)
|
|
1048
|
+
node.ha = (p) => staleValues(() => compute(p));
|
|
1049
|
+
!(options == null ? void 0 : options.defer) && !(node.f & (2 /* Error */ | 1 /* Pending */)) && (node.K === 2 /* User */ ? node.i.enqueue(node.K, runEffect.bind(node)) : runEffect.call(node));
|
|
1021
1050
|
onCleanup(() => {
|
|
1022
1051
|
var _a2;
|
|
1023
|
-
return (_a2 = node.
|
|
1052
|
+
return (_a2 = node.N) == null ? void 0 : _a2.call(node);
|
|
1024
1053
|
});
|
|
1025
1054
|
}
|
|
1026
1055
|
function runEffect() {
|
|
1027
1056
|
var _a;
|
|
1028
1057
|
if (!this.fa || this.b & 64 /* Disposed */)
|
|
1029
1058
|
return;
|
|
1030
|
-
(_a = this.
|
|
1031
|
-
this.
|
|
1059
|
+
(_a = this.N) == null ? void 0 : _a.call(this);
|
|
1060
|
+
this.N = void 0;
|
|
1032
1061
|
try {
|
|
1033
|
-
this.
|
|
1062
|
+
this.N = this.ua(this.g, this.oa);
|
|
1034
1063
|
} catch (error) {
|
|
1035
1064
|
if (!this.i.notify(this, 2 /* Error */, 2 /* Error */))
|
|
1036
1065
|
throw error;
|
|
1037
1066
|
} finally {
|
|
1038
|
-
this.
|
|
1067
|
+
this.oa = this.g;
|
|
1039
1068
|
this.fa = false;
|
|
1040
1069
|
}
|
|
1041
1070
|
}
|
|
@@ -1786,17 +1815,17 @@ function mapArray(list, map, options) {
|
|
|
1786
1815
|
const keyFn = typeof (options == null ? void 0 : options.keyed) === "function" ? options.keyed : void 0;
|
|
1787
1816
|
return createMemo(
|
|
1788
1817
|
updateKeyedMap.bind({
|
|
1789
|
-
|
|
1790
|
-
|
|
1818
|
+
B: createOwner(),
|
|
1819
|
+
m: 0,
|
|
1791
1820
|
va: list,
|
|
1792
|
-
|
|
1793
|
-
|
|
1821
|
+
G: [],
|
|
1822
|
+
O: map,
|
|
1794
1823
|
d: [],
|
|
1795
1824
|
a: [],
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1825
|
+
P: keyFn,
|
|
1826
|
+
n: keyFn || (options == null ? void 0 : options.keyed) === false ? [] : void 0,
|
|
1827
|
+
o: map.length > 1 ? [] : void 0,
|
|
1828
|
+
X: options == null ? void 0 : options.fallback
|
|
1800
1829
|
})
|
|
1801
1830
|
);
|
|
1802
1831
|
}
|
|
@@ -1804,80 +1833,80 @@ var pureOptions = { pureWrite: true };
|
|
|
1804
1833
|
function updateKeyedMap() {
|
|
1805
1834
|
const newItems = this.va() || [], newLen = newItems.length;
|
|
1806
1835
|
newItems[$TRACK];
|
|
1807
|
-
runWithOwner(this.
|
|
1808
|
-
let i, j, mapper = this.
|
|
1809
|
-
this.
|
|
1810
|
-
this.
|
|
1811
|
-
return this.
|
|
1812
|
-
read.bind(null, this.
|
|
1813
|
-
this.
|
|
1836
|
+
runWithOwner(this.B, () => {
|
|
1837
|
+
let i, j, mapper = this.n ? () => {
|
|
1838
|
+
this.n[j] = signal(newItems[j], pureOptions);
|
|
1839
|
+
this.o && (this.o[j] = signal(j, pureOptions));
|
|
1840
|
+
return this.O(
|
|
1841
|
+
read.bind(null, this.n[j]),
|
|
1842
|
+
this.o ? read.bind(null, this.o[j]) : void 0
|
|
1814
1843
|
);
|
|
1815
|
-
} : this.
|
|
1844
|
+
} : this.o ? () => {
|
|
1816
1845
|
const item = newItems[j];
|
|
1817
|
-
this.
|
|
1818
|
-
return this.
|
|
1846
|
+
this.o[j] = signal(j, pureOptions);
|
|
1847
|
+
return this.O(
|
|
1819
1848
|
() => item,
|
|
1820
|
-
read.bind(null, this.
|
|
1849
|
+
read.bind(null, this.o[j])
|
|
1821
1850
|
);
|
|
1822
1851
|
} : () => {
|
|
1823
1852
|
const item = newItems[j];
|
|
1824
|
-
return this.
|
|
1853
|
+
return this.O(() => item);
|
|
1825
1854
|
};
|
|
1826
1855
|
if (newLen === 0) {
|
|
1827
|
-
if (this.
|
|
1828
|
-
this.
|
|
1856
|
+
if (this.m !== 0) {
|
|
1857
|
+
this.B.dispose(false);
|
|
1829
1858
|
this.a = [];
|
|
1830
|
-
this.
|
|
1859
|
+
this.G = [];
|
|
1831
1860
|
this.d = [];
|
|
1832
|
-
this.
|
|
1833
|
-
this.
|
|
1834
|
-
this.
|
|
1861
|
+
this.m = 0;
|
|
1862
|
+
this.n && (this.n = []);
|
|
1863
|
+
this.o && (this.o = []);
|
|
1835
1864
|
}
|
|
1836
|
-
if (this.
|
|
1865
|
+
if (this.X && !this.d[0]) {
|
|
1837
1866
|
this.d[0] = runWithOwner(
|
|
1838
1867
|
this.a[0] = createOwner(),
|
|
1839
|
-
this.
|
|
1868
|
+
this.X
|
|
1840
1869
|
);
|
|
1841
1870
|
}
|
|
1842
|
-
} else if (this.
|
|
1871
|
+
} else if (this.m === 0) {
|
|
1843
1872
|
if (this.a[0])
|
|
1844
1873
|
this.a[0].dispose();
|
|
1845
1874
|
this.d = new Array(newLen);
|
|
1846
1875
|
for (j = 0; j < newLen; j++) {
|
|
1847
|
-
this.
|
|
1876
|
+
this.G[j] = newItems[j];
|
|
1848
1877
|
this.d[j] = runWithOwner(this.a[j] = createOwner(), mapper);
|
|
1849
1878
|
}
|
|
1850
|
-
this.
|
|
1879
|
+
this.m = newLen;
|
|
1851
1880
|
} else {
|
|
1852
|
-
let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.
|
|
1853
|
-
for (start = 0, end = Math.min(this.
|
|
1854
|
-
if (this.
|
|
1855
|
-
setSignal(this.
|
|
1881
|
+
let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.n ? new Array(newLen) : void 0, tempIndexes = this.o ? new Array(newLen) : void 0;
|
|
1882
|
+
for (start = 0, end = Math.min(this.m, newLen); start < end && (this.G[start] === newItems[start] || this.n && compare(this.P, this.G[start], newItems[start])); start++) {
|
|
1883
|
+
if (this.n)
|
|
1884
|
+
setSignal(this.n[start], newItems[start]);
|
|
1856
1885
|
}
|
|
1857
|
-
for (end = this.
|
|
1886
|
+
for (end = this.m - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.G[end] === newItems[newEnd] || this.n && compare(this.P, this.G[end], newItems[newEnd])); end--, newEnd--) {
|
|
1858
1887
|
temp[newEnd] = this.d[end];
|
|
1859
1888
|
tempNodes[newEnd] = this.a[end];
|
|
1860
|
-
tempRows && (tempRows[newEnd] = this.
|
|
1861
|
-
tempIndexes && (tempIndexes[newEnd] = this.
|
|
1889
|
+
tempRows && (tempRows[newEnd] = this.n[end]);
|
|
1890
|
+
tempIndexes && (tempIndexes[newEnd] = this.o[end]);
|
|
1862
1891
|
}
|
|
1863
1892
|
newIndices = /* @__PURE__ */ new Map();
|
|
1864
1893
|
newIndicesNext = new Array(newEnd + 1);
|
|
1865
1894
|
for (j = newEnd; j >= start; j--) {
|
|
1866
1895
|
item = newItems[j];
|
|
1867
|
-
key = this.
|
|
1896
|
+
key = this.P ? this.P(item) : item;
|
|
1868
1897
|
i = newIndices.get(key);
|
|
1869
1898
|
newIndicesNext[j] = i === void 0 ? -1 : i;
|
|
1870
1899
|
newIndices.set(key, j);
|
|
1871
1900
|
}
|
|
1872
1901
|
for (i = start; i <= end; i++) {
|
|
1873
|
-
item = this.
|
|
1874
|
-
key = this.
|
|
1902
|
+
item = this.G[i];
|
|
1903
|
+
key = this.P ? this.P(item) : item;
|
|
1875
1904
|
j = newIndices.get(key);
|
|
1876
1905
|
if (j !== void 0 && j !== -1) {
|
|
1877
1906
|
temp[j] = this.d[i];
|
|
1878
1907
|
tempNodes[j] = this.a[i];
|
|
1879
|
-
tempRows && (tempRows[j] = this.
|
|
1880
|
-
tempIndexes && (tempIndexes[j] = this.
|
|
1908
|
+
tempRows && (tempRows[j] = this.n[i]);
|
|
1909
|
+
tempIndexes && (tempIndexes[j] = this.o[i]);
|
|
1881
1910
|
j = newIndicesNext[j];
|
|
1882
1911
|
newIndices.set(key, j);
|
|
1883
1912
|
} else
|
|
@@ -1888,71 +1917,71 @@ function updateKeyedMap() {
|
|
|
1888
1917
|
this.d[j] = temp[j];
|
|
1889
1918
|
this.a[j] = tempNodes[j];
|
|
1890
1919
|
if (tempRows) {
|
|
1891
|
-
this.
|
|
1892
|
-
setSignal(this.
|
|
1920
|
+
this.n[j] = tempRows[j];
|
|
1921
|
+
setSignal(this.n[j], newItems[j]);
|
|
1893
1922
|
}
|
|
1894
1923
|
if (tempIndexes) {
|
|
1895
|
-
this.
|
|
1896
|
-
setSignal(this.
|
|
1924
|
+
this.o[j] = tempIndexes[j];
|
|
1925
|
+
setSignal(this.o[j], j);
|
|
1897
1926
|
}
|
|
1898
1927
|
} else {
|
|
1899
1928
|
this.d[j] = runWithOwner(this.a[j] = createOwner(), mapper);
|
|
1900
1929
|
}
|
|
1901
1930
|
}
|
|
1902
|
-
this.d = this.d.slice(0, this.
|
|
1903
|
-
this.
|
|
1931
|
+
this.d = this.d.slice(0, this.m = newLen);
|
|
1932
|
+
this.G = newItems.slice(0);
|
|
1904
1933
|
}
|
|
1905
1934
|
});
|
|
1906
1935
|
return this.d;
|
|
1907
1936
|
}
|
|
1908
1937
|
function repeat(count, map, options) {
|
|
1909
1938
|
return updateRepeat.bind({
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1939
|
+
B: createOwner(),
|
|
1940
|
+
m: 0,
|
|
1941
|
+
y: 0,
|
|
1913
1942
|
wa: count,
|
|
1914
|
-
|
|
1943
|
+
O: map,
|
|
1915
1944
|
a: [],
|
|
1916
1945
|
d: [],
|
|
1917
1946
|
xa: options == null ? void 0 : options.from,
|
|
1918
|
-
|
|
1947
|
+
X: options == null ? void 0 : options.fallback
|
|
1919
1948
|
});
|
|
1920
1949
|
}
|
|
1921
1950
|
function updateRepeat() {
|
|
1922
1951
|
var _a;
|
|
1923
1952
|
const newLen = this.wa();
|
|
1924
1953
|
const from = ((_a = this.xa) == null ? void 0 : _a.call(this)) || 0;
|
|
1925
|
-
runWithOwner(this.
|
|
1954
|
+
runWithOwner(this.B, () => {
|
|
1926
1955
|
if (newLen === 0) {
|
|
1927
|
-
if (this.
|
|
1928
|
-
this.
|
|
1956
|
+
if (this.m !== 0) {
|
|
1957
|
+
this.B.dispose(false);
|
|
1929
1958
|
this.a = [];
|
|
1930
1959
|
this.d = [];
|
|
1931
|
-
this.
|
|
1960
|
+
this.m = 0;
|
|
1932
1961
|
}
|
|
1933
|
-
if (this.
|
|
1962
|
+
if (this.X && !this.d[0]) {
|
|
1934
1963
|
this.d[0] = runWithOwner(
|
|
1935
1964
|
this.a[0] = createOwner(),
|
|
1936
|
-
this.
|
|
1965
|
+
this.X
|
|
1937
1966
|
);
|
|
1938
1967
|
}
|
|
1939
1968
|
return;
|
|
1940
1969
|
}
|
|
1941
1970
|
const to = from + newLen;
|
|
1942
|
-
const prevTo = this.
|
|
1943
|
-
if (this.
|
|
1971
|
+
const prevTo = this.y + this.m;
|
|
1972
|
+
if (this.m === 0 && this.a[0])
|
|
1944
1973
|
this.a[0].dispose();
|
|
1945
1974
|
for (let i = to; i < prevTo; i++)
|
|
1946
|
-
this.a[i - this.
|
|
1947
|
-
if (this.
|
|
1948
|
-
let i = this.
|
|
1949
|
-
while (i < from && i < this.
|
|
1975
|
+
this.a[i - this.y].dispose();
|
|
1976
|
+
if (this.y < from) {
|
|
1977
|
+
let i = this.y;
|
|
1978
|
+
while (i < from && i < this.m)
|
|
1950
1979
|
this.a[i++].dispose();
|
|
1951
|
-
this.a.splice(0, from - this.
|
|
1952
|
-
this.d.splice(0, from - this.
|
|
1953
|
-
} else if (this.
|
|
1954
|
-
let i = prevTo - this.
|
|
1955
|
-
let difference = this.
|
|
1980
|
+
this.a.splice(0, from - this.y);
|
|
1981
|
+
this.d.splice(0, from - this.y);
|
|
1982
|
+
} else if (this.y > from) {
|
|
1983
|
+
let i = prevTo - this.y - 1;
|
|
1984
|
+
let difference = this.y - from;
|
|
1956
1985
|
this.a.length = this.d.length = newLen;
|
|
1957
1986
|
while (i >= difference) {
|
|
1958
1987
|
this.a[i] = this.a[i - difference];
|
|
@@ -1962,19 +1991,19 @@ function updateRepeat() {
|
|
|
1962
1991
|
for (let i2 = 0; i2 < difference; i2++) {
|
|
1963
1992
|
this.d[i2] = runWithOwner(
|
|
1964
1993
|
this.a[i2] = createOwner(),
|
|
1965
|
-
() => this.
|
|
1994
|
+
() => this.O(i2 + from)
|
|
1966
1995
|
);
|
|
1967
1996
|
}
|
|
1968
1997
|
}
|
|
1969
1998
|
for (let i = prevTo; i < to; i++) {
|
|
1970
1999
|
this.d[i - from] = runWithOwner(
|
|
1971
2000
|
this.a[i - from] = createOwner(),
|
|
1972
|
-
() => this.
|
|
2001
|
+
() => this.O(i)
|
|
1973
2002
|
);
|
|
1974
2003
|
}
|
|
1975
2004
|
this.d = this.d.slice(0, newLen);
|
|
1976
|
-
this.
|
|
1977
|
-
this.
|
|
2005
|
+
this.y = from;
|
|
2006
|
+
this.m = newLen;
|
|
1978
2007
|
});
|
|
1979
2008
|
return this.d;
|
|
1980
2009
|
}
|
|
@@ -1986,18 +2015,18 @@ function compare(key, a, b) {
|
|
|
1986
2015
|
function boundaryComputed(fn, propagationMask) {
|
|
1987
2016
|
const node = computed(fn, void 0, {
|
|
1988
2017
|
ja: {
|
|
1989
|
-
|
|
2018
|
+
la() {
|
|
1990
2019
|
let flags = this.f;
|
|
1991
|
-
this.f &= ~this.
|
|
1992
|
-
if (this.
|
|
2020
|
+
this.f &= ~this.Y;
|
|
2021
|
+
if (this.Y & 1 /* Pending */ && !(this.f & 4 /* Uninitialized */)) {
|
|
1993
2022
|
flags &= ~1 /* Pending */;
|
|
1994
2023
|
}
|
|
1995
|
-
this.i.notify(this, this.
|
|
2024
|
+
this.i.notify(this, this.Y, flags);
|
|
1996
2025
|
},
|
|
1997
|
-
|
|
2026
|
+
Y: propagationMask
|
|
1998
2027
|
}
|
|
1999
2028
|
});
|
|
2000
|
-
node.
|
|
2029
|
+
node.Y = propagationMask;
|
|
2001
2030
|
return node;
|
|
2002
2031
|
}
|
|
2003
2032
|
function createBoundChildren(owner, fn, queue, mask) {
|
|
@@ -2010,20 +2039,20 @@ function createBoundChildren(owner, fn, queue, mask) {
|
|
|
2010
2039
|
});
|
|
2011
2040
|
}
|
|
2012
2041
|
var ConditionalQueue = class extends Queue {
|
|
2013
|
-
|
|
2042
|
+
u;
|
|
2014
2043
|
ga = /* @__PURE__ */ new Set();
|
|
2015
2044
|
h = /* @__PURE__ */ new Set();
|
|
2016
2045
|
constructor(disabled) {
|
|
2017
2046
|
super();
|
|
2018
|
-
this.
|
|
2047
|
+
this.u = disabled;
|
|
2019
2048
|
}
|
|
2020
2049
|
run(type) {
|
|
2021
|
-
if (!type || read(this.
|
|
2050
|
+
if (!type || read(this.u))
|
|
2022
2051
|
return;
|
|
2023
2052
|
return super.run(type);
|
|
2024
2053
|
}
|
|
2025
2054
|
notify(node, type, flags) {
|
|
2026
|
-
if (read(this.
|
|
2055
|
+
if (read(this.u)) {
|
|
2027
2056
|
if (type & 1 /* Pending */) {
|
|
2028
2057
|
if (flags & 1 /* Pending */) {
|
|
2029
2058
|
this.h.add(node);
|
|
@@ -2043,39 +2072,32 @@ var ConditionalQueue = class extends Queue {
|
|
|
2043
2072
|
}
|
|
2044
2073
|
};
|
|
2045
2074
|
var CollectionQueue = class extends Queue {
|
|
2046
|
-
|
|
2075
|
+
Z;
|
|
2047
2076
|
a = /* @__PURE__ */ new Set();
|
|
2048
|
-
|
|
2049
|
-
|
|
2077
|
+
u = signal(false, { pureWrite: true });
|
|
2078
|
+
qa = false;
|
|
2050
2079
|
constructor(type) {
|
|
2051
2080
|
super();
|
|
2052
|
-
this.
|
|
2081
|
+
this.Z = type;
|
|
2053
2082
|
}
|
|
2054
2083
|
run(type) {
|
|
2055
|
-
if (!type || read(this.
|
|
2084
|
+
if (!type || read(this.u))
|
|
2056
2085
|
return;
|
|
2057
2086
|
return super.run(type);
|
|
2058
2087
|
}
|
|
2059
|
-
enqueue(type, fn) {
|
|
2060
|
-
var _a;
|
|
2061
|
-
if (this.O & 1 /* Pending */ && this.ka) {
|
|
2062
|
-
return (_a = this.q) == null ? void 0 : _a.enqueue(type, fn);
|
|
2063
|
-
}
|
|
2064
|
-
return super.enqueue(type, fn);
|
|
2065
|
-
}
|
|
2066
2088
|
notify(node, type, flags) {
|
|
2067
|
-
if (!(type & this.
|
|
2089
|
+
if (!(type & this.Z) || this.Z & 1 /* Pending */ && this.qa)
|
|
2068
2090
|
return super.notify(node, type, flags);
|
|
2069
|
-
if (flags & this.
|
|
2091
|
+
if (flags & this.Z) {
|
|
2070
2092
|
this.a.add(node);
|
|
2071
2093
|
if (this.a.size === 1)
|
|
2072
|
-
setSignal(this.
|
|
2094
|
+
setSignal(this.u, true);
|
|
2073
2095
|
} else if (this.a.size > 0) {
|
|
2074
2096
|
this.a.delete(node);
|
|
2075
2097
|
if (this.a.size === 0)
|
|
2076
|
-
setSignal(this.
|
|
2098
|
+
setSignal(this.u, false);
|
|
2077
2099
|
}
|
|
2078
|
-
type &= ~this.
|
|
2100
|
+
type &= ~this.Z;
|
|
2079
2101
|
return type ? super.notify(node, type, flags) : true;
|
|
2080
2102
|
}
|
|
2081
2103
|
};
|
|
@@ -2084,8 +2106,8 @@ function createBoundary(fn, condition) {
|
|
|
2084
2106
|
const queue = new ConditionalQueue(computed(() => condition() === "hidden" /* HIDDEN */));
|
|
2085
2107
|
const tree = createBoundChildren(owner, fn, queue, 0);
|
|
2086
2108
|
computed(() => {
|
|
2087
|
-
const disabled = read(queue.
|
|
2088
|
-
tree.
|
|
2109
|
+
const disabled = read(queue.u);
|
|
2110
|
+
tree.Y = disabled ? 2 /* Error */ | 1 /* Pending */ : 0;
|
|
2089
2111
|
if (!disabled) {
|
|
2090
2112
|
queue.h.forEach(
|
|
2091
2113
|
(node) => queue.notify(node, 1 /* Pending */, 1 /* Pending */)
|
|
@@ -2095,17 +2117,17 @@ function createBoundary(fn, condition) {
|
|
|
2095
2117
|
queue.ga.clear();
|
|
2096
2118
|
}
|
|
2097
2119
|
});
|
|
2098
|
-
return () => read(queue.
|
|
2120
|
+
return () => read(queue.u) ? void 0 : read(tree);
|
|
2099
2121
|
}
|
|
2100
2122
|
function createCollectionBoundary(type, fn, fallback) {
|
|
2101
2123
|
const owner = createOwner();
|
|
2102
2124
|
const queue = new CollectionQueue(type);
|
|
2103
2125
|
const tree = createBoundChildren(owner, fn, queue, type);
|
|
2104
2126
|
const decision = computed(() => {
|
|
2105
|
-
if (!read(queue.
|
|
2127
|
+
if (!read(queue.u)) {
|
|
2106
2128
|
const resolved = read(tree);
|
|
2107
|
-
if (!untrack(() => read(queue.
|
|
2108
|
-
queue.
|
|
2129
|
+
if (!untrack(() => read(queue.u)))
|
|
2130
|
+
queue.qa = true;
|
|
2109
2131
|
return resolved;
|
|
2110
2132
|
}
|
|
2111
2133
|
return fallback(queue);
|
|
@@ -2118,7 +2140,7 @@ function createLoadBoundary(fn, fallback) {
|
|
|
2118
2140
|
function createErrorBoundary(fn, fallback) {
|
|
2119
2141
|
return createCollectionBoundary(2 /* Error */, fn, (queue) => {
|
|
2120
2142
|
let node = queue.a.values().next().value;
|
|
2121
|
-
return fallback(node.
|
|
2143
|
+
return fallback(node.C, () => {
|
|
2122
2144
|
for (let node2 of queue.a) {
|
|
2123
2145
|
recompute(node2, true);
|
|
2124
2146
|
}
|