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