@solidjs/signals 0.8.0 → 0.8.1
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 +15 -4
- package/dist/node.cjs +310 -298
- package/dist/prod.js +309 -298
- package/dist/types/boundaries.d.ts +3 -1
- package/dist/types/core/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/prod.js
CHANGED
|
@@ -24,16 +24,16 @@ var SUPPORTS_PROXY = typeof Proxy === "function";
|
|
|
24
24
|
|
|
25
25
|
// src/core/heap.ts
|
|
26
26
|
function actualInsertIntoHeap(n, heap) {
|
|
27
|
-
const parentHeight = (n.
|
|
28
|
-
if (parentHeight >= n.
|
|
29
|
-
n.
|
|
30
|
-
const height = n.
|
|
31
|
-
const heapAtHeight = heap.
|
|
27
|
+
const parentHeight = (n.q?._ ? n.q.$?.c : n.q?.c) ?? -1;
|
|
28
|
+
if (parentHeight >= n.c)
|
|
29
|
+
n.c = parentHeight + 1;
|
|
30
|
+
const height = n.c;
|
|
31
|
+
const heapAtHeight = heap.p[height];
|
|
32
32
|
if (heapAtHeight === void 0) {
|
|
33
|
-
heap.
|
|
33
|
+
heap.p[height] = n;
|
|
34
34
|
} else {
|
|
35
35
|
const tail = heapAtHeight.x;
|
|
36
|
-
tail.
|
|
36
|
+
tail.P = n;
|
|
37
37
|
n.x = tail;
|
|
38
38
|
heapAtHeight.x = n;
|
|
39
39
|
}
|
|
@@ -65,29 +65,29 @@ function deleteFromHeap(n, heap) {
|
|
|
65
65
|
if (!(flags & (8 /* InHeap */ | 16 /* InHeapHeight */)))
|
|
66
66
|
return;
|
|
67
67
|
n.b = flags & ~(8 /* InHeap */ | 16 /* InHeapHeight */);
|
|
68
|
-
const height = n.
|
|
68
|
+
const height = n.c;
|
|
69
69
|
if (n.x === n) {
|
|
70
|
-
heap.
|
|
70
|
+
heap.p[height] = void 0;
|
|
71
71
|
} else {
|
|
72
|
-
const next = n.
|
|
73
|
-
const dhh = heap.
|
|
72
|
+
const next = n.P;
|
|
73
|
+
const dhh = heap.p[height];
|
|
74
74
|
const end = next ?? dhh;
|
|
75
75
|
if (n === dhh) {
|
|
76
|
-
heap.
|
|
76
|
+
heap.p[height] = next;
|
|
77
77
|
} else {
|
|
78
|
-
n.x.
|
|
78
|
+
n.x.P = next;
|
|
79
79
|
}
|
|
80
80
|
end.x = n.x;
|
|
81
81
|
}
|
|
82
82
|
n.x = n;
|
|
83
|
-
n.
|
|
83
|
+
n.P = void 0;
|
|
84
84
|
}
|
|
85
85
|
function markHeap(heap) {
|
|
86
|
-
if (heap
|
|
86
|
+
if (heap.aa)
|
|
87
87
|
return;
|
|
88
|
-
heap
|
|
88
|
+
heap.aa = true;
|
|
89
89
|
for (let i = 0; i <= heap.J; i++) {
|
|
90
|
-
for (let el = heap.
|
|
90
|
+
for (let el = heap.p[i]; el !== void 0; el = el.P) {
|
|
91
91
|
if (el.b & 8 /* InHeap */)
|
|
92
92
|
markNode(el);
|
|
93
93
|
}
|
|
@@ -98,48 +98,48 @@ 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.
|
|
102
|
-
markNode(link2.
|
|
101
|
+
for (let link2 = el.r; link2 !== null; link2 = link2.y) {
|
|
102
|
+
markNode(link2.j, 1 /* Check */);
|
|
103
103
|
}
|
|
104
|
-
if (el.
|
|
105
|
-
for (let child = el.
|
|
106
|
-
for (let link2 = child.
|
|
107
|
-
markNode(link2.
|
|
104
|
+
if (el.ba !== null) {
|
|
105
|
+
for (let child = el.ba; child !== null; child = child.ra) {
|
|
106
|
+
for (let link2 = child.r; link2 !== null; link2 = link2.y) {
|
|
107
|
+
markNode(link2.j, 1 /* Check */);
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
function runHeap(heap, recompute2) {
|
|
113
|
-
heap
|
|
114
|
-
for (heap.
|
|
115
|
-
let el = heap.
|
|
113
|
+
heap.aa = false;
|
|
114
|
+
for (heap.n = 0; heap.n <= heap.J; heap.n++) {
|
|
115
|
+
let el = heap.p[heap.n];
|
|
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.p[heap.n];
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
heap.J = 0;
|
|
126
126
|
}
|
|
127
127
|
function adjustHeight(el, heap) {
|
|
128
128
|
deleteFromHeap(el, heap);
|
|
129
|
-
let newHeight = el.
|
|
129
|
+
let newHeight = el.c;
|
|
130
130
|
for (let d = el.u; d; d = d.E) {
|
|
131
|
-
const dep1 = d.
|
|
131
|
+
const dep1 = d.Q;
|
|
132
132
|
const dep = "_owner" in dep1 ? dep1.z : dep1;
|
|
133
133
|
if ("_fn" in dep) {
|
|
134
|
-
if (dep.
|
|
135
|
-
newHeight = dep.
|
|
134
|
+
if (dep.c >= newHeight) {
|
|
135
|
+
newHeight = dep.c + 1;
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
-
if (el.
|
|
140
|
-
el.
|
|
141
|
-
for (let s = el.
|
|
142
|
-
insertIntoHeapHeight(s.
|
|
139
|
+
if (el.c !== newHeight) {
|
|
140
|
+
el.c = newHeight;
|
|
141
|
+
for (let s = el.r; s !== null; s = s.y) {
|
|
142
|
+
insertIntoHeapHeight(s.j, heap);
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
}
|
|
@@ -154,40 +154,40 @@ function schedule() {
|
|
|
154
154
|
if (scheduled)
|
|
155
155
|
return;
|
|
156
156
|
scheduled = true;
|
|
157
|
-
if (!globalQueue.
|
|
157
|
+
if (!globalQueue.ca)
|
|
158
158
|
queueMicrotask(flush);
|
|
159
159
|
}
|
|
160
160
|
var dirtyQueue = {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
161
|
+
p: new Array(2e3).fill(void 0),
|
|
162
|
+
aa: false,
|
|
163
|
+
n: 0,
|
|
164
164
|
J: 0
|
|
165
165
|
};
|
|
166
166
|
var zombieQueue = {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
167
|
+
p: new Array(2e3).fill(void 0),
|
|
168
|
+
aa: false,
|
|
169
|
+
n: 0,
|
|
170
170
|
J: 0
|
|
171
171
|
};
|
|
172
172
|
var Queue = class {
|
|
173
|
-
|
|
173
|
+
q = null;
|
|
174
174
|
A = [[], []];
|
|
175
|
-
|
|
175
|
+
R = [];
|
|
176
176
|
created = clock;
|
|
177
177
|
addChild(child) {
|
|
178
|
-
this.
|
|
179
|
-
child.
|
|
178
|
+
this.R.push(child);
|
|
179
|
+
child.q = this;
|
|
180
180
|
}
|
|
181
181
|
removeChild(child) {
|
|
182
|
-
const index = this.
|
|
182
|
+
const index = this.R.indexOf(child);
|
|
183
183
|
if (index >= 0) {
|
|
184
|
-
this.
|
|
185
|
-
child.
|
|
184
|
+
this.R.splice(index, 1);
|
|
185
|
+
child.q = null;
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
notify(node, mask, flags) {
|
|
189
|
-
if (this.
|
|
190
|
-
return this.
|
|
189
|
+
if (this.q)
|
|
190
|
+
return this.q.notify(node, mask, flags);
|
|
191
191
|
return false;
|
|
192
192
|
}
|
|
193
193
|
run(type) {
|
|
@@ -196,8 +196,8 @@ var Queue = class {
|
|
|
196
196
|
this.A[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.R.length; i++) {
|
|
200
|
+
this.R[i].run(type);
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
enqueue(type, fn) {
|
|
@@ -207,19 +207,19 @@ var Queue = class {
|
|
|
207
207
|
}
|
|
208
208
|
};
|
|
209
209
|
var GlobalQueue = class _GlobalQueue extends Queue {
|
|
210
|
-
|
|
210
|
+
ca = false;
|
|
211
211
|
h = [];
|
|
212
|
-
static
|
|
213
|
-
static
|
|
212
|
+
static S;
|
|
213
|
+
static la;
|
|
214
214
|
flush() {
|
|
215
|
-
if (this.
|
|
215
|
+
if (this.ca)
|
|
216
216
|
return;
|
|
217
|
-
this.
|
|
217
|
+
this.ca = true;
|
|
218
218
|
try {
|
|
219
|
-
runHeap(dirtyQueue, _GlobalQueue.
|
|
219
|
+
runHeap(dirtyQueue, _GlobalQueue.S);
|
|
220
220
|
if (activeTransition) {
|
|
221
221
|
if (!transitionComplete(activeTransition)) {
|
|
222
|
-
runHeap(zombieQueue, _GlobalQueue.
|
|
222
|
+
runHeap(zombieQueue, _GlobalQueue.S);
|
|
223
223
|
globalQueue.h = [];
|
|
224
224
|
activeTransition.queues[0].push(...globalQueue.A[0]);
|
|
225
225
|
activeTransition.queues[1].push(...globalQueue.A[1]);
|
|
@@ -236,17 +236,17 @@ var GlobalQueue = class _GlobalQueue extends Queue {
|
|
|
236
236
|
transitions.delete(activeTransition);
|
|
237
237
|
activeTransition = null;
|
|
238
238
|
if (runPending(globalQueue.h, false))
|
|
239
|
-
runHeap(dirtyQueue, _GlobalQueue.
|
|
239
|
+
runHeap(dirtyQueue, _GlobalQueue.S);
|
|
240
240
|
} else if (transitions.size)
|
|
241
|
-
runHeap(zombieQueue, _GlobalQueue.
|
|
241
|
+
runHeap(zombieQueue, _GlobalQueue.S);
|
|
242
242
|
for (let i = 0; i < globalQueue.h.length; i++) {
|
|
243
243
|
const n = globalQueue.h[i];
|
|
244
|
-
if (n.
|
|
245
|
-
n.g = n.
|
|
246
|
-
n.
|
|
244
|
+
if (n.e !== NOT_PENDING) {
|
|
245
|
+
n.g = n.e;
|
|
246
|
+
n.e = NOT_PENDING;
|
|
247
247
|
}
|
|
248
248
|
if (n.ha)
|
|
249
|
-
_GlobalQueue.
|
|
249
|
+
_GlobalQueue.la(n, false, true);
|
|
250
250
|
}
|
|
251
251
|
globalQueue.h.length = 0;
|
|
252
252
|
clock++;
|
|
@@ -254,7 +254,7 @@ var GlobalQueue = class _GlobalQueue extends Queue {
|
|
|
254
254
|
this.run(1 /* Render */);
|
|
255
255
|
this.run(2 /* User */);
|
|
256
256
|
} finally {
|
|
257
|
-
this.
|
|
257
|
+
this.ca = false;
|
|
258
258
|
unobserved.length && notifyUnobserved();
|
|
259
259
|
}
|
|
260
260
|
}
|
|
@@ -272,7 +272,7 @@ var GlobalQueue = class _GlobalQueue extends Queue {
|
|
|
272
272
|
if (activeTransition && activeTransition.time === clock)
|
|
273
273
|
return;
|
|
274
274
|
if (!activeTransition) {
|
|
275
|
-
activeTransition = node.
|
|
275
|
+
activeTransition = node.T ?? {
|
|
276
276
|
time: clock,
|
|
277
277
|
pendingNodes: [],
|
|
278
278
|
asyncNodes: [],
|
|
@@ -283,7 +283,7 @@ var GlobalQueue = class _GlobalQueue extends Queue {
|
|
|
283
283
|
activeTransition.time = clock;
|
|
284
284
|
for (let i = 0; i < globalQueue.h.length; i++) {
|
|
285
285
|
const n = globalQueue.h[i];
|
|
286
|
-
n.
|
|
286
|
+
n.T = activeTransition;
|
|
287
287
|
activeTransition.pendingNodes.push(n);
|
|
288
288
|
}
|
|
289
289
|
globalQueue.h = activeTransition.pendingNodes;
|
|
@@ -294,9 +294,9 @@ function runPending(pendingNodes, value) {
|
|
|
294
294
|
const p = pendingNodes.slice();
|
|
295
295
|
for (let i = 0; i < p.length; i++) {
|
|
296
296
|
const n = p[i];
|
|
297
|
-
n.
|
|
297
|
+
n.T = activeTransition;
|
|
298
298
|
if (n.G) {
|
|
299
|
-
n.G.
|
|
299
|
+
n.G.da(value);
|
|
300
300
|
needsReset = true;
|
|
301
301
|
}
|
|
302
302
|
}
|
|
@@ -325,15 +325,15 @@ function transitionComplete(transition) {
|
|
|
325
325
|
function notifyUnobserved() {
|
|
326
326
|
for (let i = 0; i < unobserved.length; i++) {
|
|
327
327
|
const source = unobserved[i];
|
|
328
|
-
if (!source.
|
|
329
|
-
unobserved[i].
|
|
328
|
+
if (!source.r)
|
|
329
|
+
unobserved[i].sa?.();
|
|
330
330
|
}
|
|
331
331
|
unobserved = [];
|
|
332
332
|
}
|
|
333
333
|
|
|
334
334
|
// src/core/core.ts
|
|
335
|
-
GlobalQueue.
|
|
336
|
-
GlobalQueue.
|
|
335
|
+
GlobalQueue.S = recompute;
|
|
336
|
+
GlobalQueue.la = disposeChildren;
|
|
337
337
|
var tracking = false;
|
|
338
338
|
var stale = false;
|
|
339
339
|
var pendingValueCheck = false;
|
|
@@ -342,23 +342,23 @@ var context = null;
|
|
|
342
342
|
var defaultContext = {};
|
|
343
343
|
function recompute(el, create = false) {
|
|
344
344
|
deleteFromHeap(el, el.b & 32 /* Zombie */ ? zombieQueue : dirtyQueue);
|
|
345
|
-
if (el.
|
|
345
|
+
if (el.e !== NOT_PENDING || el.U || el.V)
|
|
346
346
|
disposeChildren(el);
|
|
347
347
|
else {
|
|
348
348
|
markDisposal(el);
|
|
349
349
|
globalQueue.h.push(el);
|
|
350
|
-
el.
|
|
351
|
-
el.
|
|
352
|
-
el.
|
|
353
|
-
el.
|
|
350
|
+
el.V = el.s;
|
|
351
|
+
el.U = el.o;
|
|
352
|
+
el.s = null;
|
|
353
|
+
el.o = null;
|
|
354
354
|
}
|
|
355
355
|
const oldcontext = context;
|
|
356
356
|
context = el;
|
|
357
357
|
el.H = null;
|
|
358
358
|
el.b = 4 /* RecomputingDeps */;
|
|
359
|
-
el.
|
|
360
|
-
let value = el.
|
|
361
|
-
let oldHeight = el.
|
|
359
|
+
el.W = clock;
|
|
360
|
+
let value = el.e === NOT_PENDING ? el.g : el.e;
|
|
361
|
+
let oldHeight = el.c;
|
|
362
362
|
let prevStatusFlags = el.f;
|
|
363
363
|
let prevError = el.B;
|
|
364
364
|
let prevTracking = tracking;
|
|
@@ -391,37 +391,37 @@ function recompute(el, create = false) {
|
|
|
391
391
|
el.u = null;
|
|
392
392
|
}
|
|
393
393
|
}
|
|
394
|
-
const valueChanged = !el.
|
|
394
|
+
const valueChanged = !el.ea || !el.ea(el.e === NOT_PENDING ? el.g : el.e, value);
|
|
395
395
|
const statusFlagsChanged = el.f !== prevStatusFlags || el.B !== prevError;
|
|
396
|
-
el.
|
|
396
|
+
el.ma?.(statusFlagsChanged, prevStatusFlags);
|
|
397
397
|
if (valueChanged || statusFlagsChanged) {
|
|
398
398
|
if (valueChanged) {
|
|
399
399
|
if (create || el.ia || el.I)
|
|
400
400
|
el.g = value;
|
|
401
401
|
else {
|
|
402
|
-
if (el.
|
|
402
|
+
if (el.e === NOT_PENDING)
|
|
403
403
|
globalQueue.h.push(el);
|
|
404
|
-
el.
|
|
404
|
+
el.e = value;
|
|
405
405
|
}
|
|
406
406
|
if (el.C)
|
|
407
|
-
el.C.
|
|
407
|
+
el.C.da(value);
|
|
408
408
|
}
|
|
409
|
-
for (let s = el.
|
|
410
|
-
const queue = s.
|
|
411
|
-
if (s.
|
|
412
|
-
queue.
|
|
413
|
-
insertIntoHeap(s.
|
|
409
|
+
for (let s = el.r; s !== null; s = s.y) {
|
|
410
|
+
const queue = s.j.b & 32 /* Zombie */ ? zombieQueue : dirtyQueue;
|
|
411
|
+
if (s.j.c < el.c && queue.n > s.j.c)
|
|
412
|
+
queue.n = s.j.c;
|
|
413
|
+
insertIntoHeap(s.j, queue);
|
|
414
414
|
}
|
|
415
|
-
} else if (el.
|
|
416
|
-
for (let s = el.
|
|
417
|
-
insertIntoHeapHeight(s.
|
|
415
|
+
} else if (el.c != oldHeight) {
|
|
416
|
+
for (let s = el.r; s !== null; s = s.y) {
|
|
417
|
+
insertIntoHeapHeight(s.j, s.j.b & 32 /* Zombie */ ? zombieQueue : dirtyQueue);
|
|
418
418
|
}
|
|
419
419
|
}
|
|
420
420
|
}
|
|
421
421
|
function updateIfNecessary(el) {
|
|
422
422
|
if (el.b & 1 /* Check */) {
|
|
423
423
|
for (let d = el.u; d; d = d.E) {
|
|
424
|
-
const dep1 = d.
|
|
424
|
+
const dep1 = d.Q;
|
|
425
425
|
const dep = "_owner" in dep1 ? dep1.z : dep1;
|
|
426
426
|
if ("_fn" in dep) {
|
|
427
427
|
updateIfNecessary(dep);
|
|
@@ -437,45 +437,45 @@ function updateIfNecessary(el) {
|
|
|
437
437
|
el.b = 0 /* None */;
|
|
438
438
|
}
|
|
439
439
|
function unlinkSubs(link2) {
|
|
440
|
-
const dep = link2.
|
|
440
|
+
const dep = link2.Q;
|
|
441
441
|
const nextDep = link2.E;
|
|
442
442
|
const nextSub = link2.y;
|
|
443
|
-
const prevSub = link2.
|
|
443
|
+
const prevSub = link2.na;
|
|
444
444
|
if (nextSub !== null) {
|
|
445
|
-
nextSub.
|
|
445
|
+
nextSub.na = prevSub;
|
|
446
446
|
} else {
|
|
447
|
-
dep.
|
|
447
|
+
dep.X = prevSub;
|
|
448
448
|
}
|
|
449
449
|
if (prevSub !== null) {
|
|
450
450
|
prevSub.y = nextSub;
|
|
451
451
|
} else {
|
|
452
|
-
dep.
|
|
452
|
+
dep.r = nextSub;
|
|
453
453
|
}
|
|
454
454
|
return nextDep;
|
|
455
455
|
}
|
|
456
456
|
function link(dep, sub) {
|
|
457
457
|
const prevDep = sub.H;
|
|
458
|
-
if (prevDep !== null && prevDep.
|
|
458
|
+
if (prevDep !== null && prevDep.Q === dep) {
|
|
459
459
|
return;
|
|
460
460
|
}
|
|
461
461
|
let nextDep = null;
|
|
462
462
|
const isRecomputing = sub.b & 4 /* RecomputingDeps */;
|
|
463
463
|
if (isRecomputing) {
|
|
464
464
|
nextDep = prevDep !== null ? prevDep.E : sub.u;
|
|
465
|
-
if (nextDep !== null && nextDep.
|
|
465
|
+
if (nextDep !== null && nextDep.Q === dep) {
|
|
466
466
|
sub.H = nextDep;
|
|
467
467
|
return;
|
|
468
468
|
}
|
|
469
469
|
}
|
|
470
|
-
const prevSub = dep.
|
|
471
|
-
if (prevSub !== null && prevSub.
|
|
470
|
+
const prevSub = dep.X;
|
|
471
|
+
if (prevSub !== null && prevSub.j === sub && (!isRecomputing || isValidLink(prevSub, sub))) {
|
|
472
472
|
return;
|
|
473
473
|
}
|
|
474
|
-
const newLink = sub.H = dep.
|
|
475
|
-
|
|
476
|
-
|
|
474
|
+
const newLink = sub.H = dep.X = {
|
|
475
|
+
Q: dep,
|
|
476
|
+
j: sub,
|
|
477
477
|
E: nextDep,
|
|
478
|
-
|
|
478
|
+
na: prevSub,
|
|
479
479
|
y: null
|
|
480
480
|
};
|
|
481
481
|
if (prevDep !== null) {
|
|
@@ -486,7 +486,7 @@ function link(dep, sub) {
|
|
|
486
486
|
if (prevSub !== null) {
|
|
487
487
|
prevSub.y = newLink;
|
|
488
488
|
} else {
|
|
489
|
-
dep.
|
|
489
|
+
dep.r = newLink;
|
|
490
490
|
}
|
|
491
491
|
}
|
|
492
492
|
function isValidLink(checkLink, sub) {
|
|
@@ -516,7 +516,7 @@ function clearStatusFlags(signal2) {
|
|
|
516
516
|
setStatusFlags(signal2, 0 /* None */);
|
|
517
517
|
}
|
|
518
518
|
function markDisposal(el) {
|
|
519
|
-
let child = el.
|
|
519
|
+
let child = el.o;
|
|
520
520
|
while (child) {
|
|
521
521
|
child.b |= 32 /* Zombie */;
|
|
522
522
|
const inHeap = child.b & 8 /* InHeap */;
|
|
@@ -533,7 +533,7 @@ function disposeChildren(node, self = false, zombie) {
|
|
|
533
533
|
return;
|
|
534
534
|
if (self)
|
|
535
535
|
node.b = 64 /* Disposed */;
|
|
536
|
-
let child = zombie ? node.
|
|
536
|
+
let child = zombie ? node.U : node.o;
|
|
537
537
|
while (child) {
|
|
538
538
|
const nextChild = child.K;
|
|
539
539
|
if (child.u) {
|
|
@@ -550,15 +550,15 @@ function disposeChildren(node, self = false, zombie) {
|
|
|
550
550
|
child = nextChild;
|
|
551
551
|
}
|
|
552
552
|
if (zombie) {
|
|
553
|
-
node.
|
|
553
|
+
node.U = null;
|
|
554
554
|
} else {
|
|
555
|
-
node.
|
|
555
|
+
node.o = null;
|
|
556
556
|
node.K = null;
|
|
557
557
|
}
|
|
558
558
|
runDisposal(node, zombie);
|
|
559
559
|
}
|
|
560
560
|
function runDisposal(node, zombie) {
|
|
561
|
-
let disposal = zombie ? node.
|
|
561
|
+
let disposal = zombie ? node.V : node.s;
|
|
562
562
|
if (!disposal)
|
|
563
563
|
return;
|
|
564
564
|
if (Array.isArray(disposal)) {
|
|
@@ -569,20 +569,20 @@ function runDisposal(node, zombie) {
|
|
|
569
569
|
} else {
|
|
570
570
|
disposal.call(disposal);
|
|
571
571
|
}
|
|
572
|
-
zombie ? node.
|
|
572
|
+
zombie ? node.V = null : node.s = null;
|
|
573
573
|
}
|
|
574
574
|
function withOptions(obj, options) {
|
|
575
575
|
obj.id = options?.id ?? (context?.id != null ? getNextChildId(context) : void 0);
|
|
576
|
-
obj.
|
|
577
|
-
obj.
|
|
578
|
-
obj.
|
|
576
|
+
obj.ea = options?.equals != null ? options.equals : isEqual;
|
|
577
|
+
obj.ya = !!options?.pureWrite;
|
|
578
|
+
obj.sa = options?.unobserved;
|
|
579
579
|
if (options?.ja)
|
|
580
580
|
Object.assign(obj, options.ja);
|
|
581
581
|
return obj;
|
|
582
582
|
}
|
|
583
583
|
function getNextChildId(owner) {
|
|
584
584
|
if (owner.id != null)
|
|
585
|
-
return formatId(owner.id, owner.
|
|
585
|
+
return formatId(owner.id, owner.oa++);
|
|
586
586
|
throw new Error("Cannot get child id from owner without an id");
|
|
587
587
|
}
|
|
588
588
|
function formatId(prefix, id) {
|
|
@@ -592,47 +592,47 @@ function formatId(prefix, id) {
|
|
|
592
592
|
function computed(fn, initialValue, options) {
|
|
593
593
|
const self = withOptions(
|
|
594
594
|
{
|
|
595
|
-
|
|
595
|
+
s: null,
|
|
596
596
|
i: globalQueue,
|
|
597
597
|
D: defaultContext,
|
|
598
|
-
|
|
598
|
+
oa: 0,
|
|
599
599
|
ha: fn,
|
|
600
600
|
g: initialValue,
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
601
|
+
c: 0,
|
|
602
|
+
ba: null,
|
|
603
|
+
P: void 0,
|
|
604
604
|
x: null,
|
|
605
605
|
u: null,
|
|
606
606
|
H: null,
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
607
|
+
r: null,
|
|
608
|
+
X: null,
|
|
609
|
+
q: context,
|
|
610
610
|
K: null,
|
|
611
|
-
|
|
611
|
+
o: null,
|
|
612
612
|
b: 0 /* None */,
|
|
613
613
|
f: 4 /* Uninitialized */,
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
614
|
+
W: clock,
|
|
615
|
+
e: NOT_PENDING,
|
|
616
|
+
V: null,
|
|
617
|
+
U: null
|
|
618
618
|
},
|
|
619
619
|
options
|
|
620
620
|
);
|
|
621
621
|
self.x = self;
|
|
622
|
-
const parent = context?.
|
|
622
|
+
const parent = context?._ ? context.$ : context;
|
|
623
623
|
if (context) {
|
|
624
624
|
context.i && (self.i = context.i);
|
|
625
625
|
context.D && (self.D = context.D);
|
|
626
|
-
const lastChild = context.
|
|
626
|
+
const lastChild = context.o;
|
|
627
627
|
if (lastChild === null) {
|
|
628
|
-
context.
|
|
628
|
+
context.o = self;
|
|
629
629
|
} else {
|
|
630
630
|
self.K = lastChild;
|
|
631
|
-
context.
|
|
631
|
+
context.o = self;
|
|
632
632
|
}
|
|
633
633
|
}
|
|
634
634
|
if (parent)
|
|
635
|
-
self.
|
|
635
|
+
self.c = parent.c + 1;
|
|
636
636
|
recompute(self, true);
|
|
637
637
|
return self;
|
|
638
638
|
}
|
|
@@ -685,7 +685,7 @@ function asyncComputed(asyncFn, initialValue, options) {
|
|
|
685
685
|
throw new NotReadyError(context);
|
|
686
686
|
};
|
|
687
687
|
const self = computed(fn, initialValue, options);
|
|
688
|
-
self.
|
|
688
|
+
self.ta = () => {
|
|
689
689
|
refreshing = true;
|
|
690
690
|
recompute(self);
|
|
691
691
|
flush();
|
|
@@ -694,16 +694,16 @@ function asyncComputed(asyncFn, initialValue, options) {
|
|
|
694
694
|
}
|
|
695
695
|
function signal(v, options, firewall = null) {
|
|
696
696
|
if (firewall !== null) {
|
|
697
|
-
return firewall.
|
|
697
|
+
return firewall.ba = withOptions(
|
|
698
698
|
{
|
|
699
699
|
g: v,
|
|
700
|
-
|
|
701
|
-
|
|
700
|
+
r: null,
|
|
701
|
+
X: null,
|
|
702
702
|
z: firewall,
|
|
703
|
-
|
|
703
|
+
ra: firewall.ba,
|
|
704
704
|
f: 0 /* None */,
|
|
705
|
-
|
|
706
|
-
|
|
705
|
+
W: clock,
|
|
706
|
+
e: NOT_PENDING
|
|
707
707
|
},
|
|
708
708
|
options
|
|
709
709
|
);
|
|
@@ -711,11 +711,11 @@ function signal(v, options, firewall = null) {
|
|
|
711
711
|
return withOptions(
|
|
712
712
|
{
|
|
713
713
|
g: v,
|
|
714
|
-
|
|
715
|
-
|
|
714
|
+
r: null,
|
|
715
|
+
X: null,
|
|
716
716
|
f: 0 /* None */,
|
|
717
|
-
|
|
718
|
-
|
|
717
|
+
W: clock,
|
|
718
|
+
e: NOT_PENDING
|
|
719
719
|
},
|
|
720
720
|
options
|
|
721
721
|
);
|
|
@@ -736,30 +736,30 @@ function untrack(fn) {
|
|
|
736
736
|
}
|
|
737
737
|
function read(el) {
|
|
738
738
|
let c = context;
|
|
739
|
-
if (c?.
|
|
740
|
-
c = c
|
|
739
|
+
if (c?._)
|
|
740
|
+
c = c.$;
|
|
741
741
|
if (c && tracking) {
|
|
742
742
|
link(el, c);
|
|
743
743
|
const owner = "_owner" in el ? el.z : el;
|
|
744
744
|
if ("_fn" in owner) {
|
|
745
745
|
const isZombie = el.b & 32 /* Zombie */;
|
|
746
|
-
if (owner.
|
|
746
|
+
if (owner.c >= (isZombie ? zombieQueue.n : dirtyQueue.n)) {
|
|
747
747
|
markNode(c);
|
|
748
748
|
markHeap(isZombie ? zombieQueue : dirtyQueue);
|
|
749
749
|
updateIfNecessary(owner);
|
|
750
750
|
}
|
|
751
|
-
const height = owner.
|
|
752
|
-
if (height >= c.
|
|
753
|
-
c.
|
|
751
|
+
const height = owner.c;
|
|
752
|
+
if (height >= c.c && el.q !== c) {
|
|
753
|
+
c.c = height + 1;
|
|
754
754
|
}
|
|
755
755
|
}
|
|
756
756
|
}
|
|
757
757
|
if (pendingCheck) {
|
|
758
|
-
const pendingResult = (el.f & 1 /* Pending */) !== 0 || !!el.
|
|
758
|
+
const pendingResult = (el.f & 1 /* Pending */) !== 0 || !!el.T || false;
|
|
759
759
|
if (!el.G) {
|
|
760
760
|
el.G = signal(pendingResult);
|
|
761
761
|
el.G.ia = true;
|
|
762
|
-
el.G.
|
|
762
|
+
el.G.da = (v) => setSignal(el.G, v);
|
|
763
763
|
}
|
|
764
764
|
const prev = pendingCheck;
|
|
765
765
|
pendingCheck = null;
|
|
@@ -770,10 +770,10 @@ function read(el) {
|
|
|
770
770
|
if (pendingValueCheck) {
|
|
771
771
|
if (!el.C) {
|
|
772
772
|
el.C = signal(
|
|
773
|
-
el.
|
|
773
|
+
el.e === NOT_PENDING ? el.g : el.e
|
|
774
774
|
);
|
|
775
775
|
el.C.ia = true;
|
|
776
|
-
el.C.
|
|
776
|
+
el.C.da = (v) => queueMicrotask(() => queueMicrotask(() => setSignal(el.C, v)));
|
|
777
777
|
}
|
|
778
778
|
pendingValueCheck = false;
|
|
779
779
|
try {
|
|
@@ -794,39 +794,42 @@ function read(el) {
|
|
|
794
794
|
}
|
|
795
795
|
}
|
|
796
796
|
if (el.f & 2 /* Error */) {
|
|
797
|
-
if (el.
|
|
797
|
+
if (el.W < clock) {
|
|
798
798
|
recompute(el, true);
|
|
799
799
|
return read(el);
|
|
800
800
|
} else {
|
|
801
801
|
throw el.B;
|
|
802
802
|
}
|
|
803
803
|
}
|
|
804
|
-
return !c || el.
|
|
804
|
+
return !c || el.e === NOT_PENDING || stale && !pendingCheck && el.T && activeTransition !== el.T ? el.g : el.e;
|
|
805
805
|
}
|
|
806
806
|
function setSignal(el, v) {
|
|
807
807
|
if (typeof v === "function") {
|
|
808
808
|
v = v(
|
|
809
|
-
el.
|
|
809
|
+
el.e === NOT_PENDING ? el.g : el.e
|
|
810
810
|
);
|
|
811
811
|
}
|
|
812
|
-
const valueChanged = !el.
|
|
812
|
+
const valueChanged = !el.ea || !el.ea(el.e === NOT_PENDING ? el.g : el.e, v);
|
|
813
813
|
if (!valueChanged && !el.f)
|
|
814
814
|
return v;
|
|
815
815
|
if (valueChanged) {
|
|
816
816
|
if (el.ia)
|
|
817
817
|
el.g = v;
|
|
818
818
|
else {
|
|
819
|
-
if (el.
|
|
819
|
+
if (el.e === NOT_PENDING)
|
|
820
820
|
globalQueue.h.push(el);
|
|
821
|
-
el.
|
|
821
|
+
el.e = v;
|
|
822
822
|
}
|
|
823
823
|
if (el.C)
|
|
824
|
-
el.C.
|
|
824
|
+
el.C.da(v);
|
|
825
825
|
}
|
|
826
826
|
clearStatusFlags(el);
|
|
827
|
-
el.
|
|
828
|
-
for (let
|
|
829
|
-
|
|
827
|
+
el.W = clock;
|
|
828
|
+
for (let s = el.r; s !== null; s = s.y) {
|
|
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);
|
|
830
833
|
}
|
|
831
834
|
schedule();
|
|
832
835
|
return v;
|
|
@@ -841,41 +844,41 @@ function onCleanup(fn) {
|
|
|
841
844
|
if (!context)
|
|
842
845
|
return fn;
|
|
843
846
|
const node = context;
|
|
844
|
-
if (!node.
|
|
845
|
-
node.
|
|
846
|
-
} else if (Array.isArray(node.
|
|
847
|
-
node.
|
|
847
|
+
if (!node.s) {
|
|
848
|
+
node.s = fn;
|
|
849
|
+
} else if (Array.isArray(node.s)) {
|
|
850
|
+
node.s.push(fn);
|
|
848
851
|
} else {
|
|
849
|
-
node.
|
|
852
|
+
node.s = [node.s, fn];
|
|
850
853
|
}
|
|
851
854
|
return fn;
|
|
852
855
|
}
|
|
853
856
|
function createOwner(options) {
|
|
854
857
|
const parent = context;
|
|
855
858
|
const owner = {
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
+
_: true,
|
|
860
|
+
$: parent?._ ? parent.$ : parent,
|
|
861
|
+
o: null,
|
|
859
862
|
K: null,
|
|
860
|
-
|
|
863
|
+
s: null,
|
|
861
864
|
id: options?.id ?? (parent?.id != null ? getNextChildId(parent) : void 0),
|
|
862
865
|
i: parent?.i ?? globalQueue,
|
|
863
866
|
D: parent?.D || defaultContext,
|
|
864
|
-
|
|
867
|
+
oa: 0,
|
|
868
|
+
V: null,
|
|
865
869
|
U: null,
|
|
866
|
-
|
|
867
|
-
s: parent,
|
|
870
|
+
q: parent,
|
|
868
871
|
dispose(self = true) {
|
|
869
872
|
disposeChildren(owner, self);
|
|
870
873
|
}
|
|
871
874
|
};
|
|
872
875
|
if (parent) {
|
|
873
|
-
const lastChild = parent.
|
|
876
|
+
const lastChild = parent.o;
|
|
874
877
|
if (lastChild === null) {
|
|
875
|
-
parent.
|
|
878
|
+
parent.o = owner;
|
|
876
879
|
} else {
|
|
877
880
|
owner.K = lastChild;
|
|
878
|
-
parent.
|
|
881
|
+
parent.o = owner;
|
|
879
882
|
}
|
|
880
883
|
}
|
|
881
884
|
return owner;
|
|
@@ -964,18 +967,18 @@ function effect(compute, effect2, error, initialValue, options) {
|
|
|
964
967
|
const node = computed(compute, initialValue, {
|
|
965
968
|
...options,
|
|
966
969
|
ja: {
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
970
|
+
fa: true,
|
|
971
|
+
pa: initialValue,
|
|
972
|
+
ua: effect2,
|
|
973
|
+
qa: error,
|
|
971
974
|
L: void 0,
|
|
972
975
|
i: getOwner()?.i ?? globalQueue,
|
|
973
976
|
I: options?.render ? 1 /* Render */ : 2 /* User */,
|
|
974
|
-
|
|
977
|
+
ma(statusFlagsChanged, prevStatusFlags) {
|
|
975
978
|
if (initialized) {
|
|
976
979
|
const errorChanged = this.f && this.f === prevStatusFlags && statusFlagsChanged;
|
|
977
|
-
this.
|
|
978
|
-
if (this.
|
|
980
|
+
this.fa = !(this.f & 2 /* Error */) && !(this.f & 1 /* Pending */ & ~prevStatusFlags) && !errorChanged;
|
|
981
|
+
if (this.fa)
|
|
979
982
|
this.i.enqueue(this.I, runEffect.bind(this));
|
|
980
983
|
}
|
|
981
984
|
if (this.f & 2 /* Error */) {
|
|
@@ -983,7 +986,7 @@ function effect(compute, effect2, error, initialValue, options) {
|
|
|
983
986
|
this.i.notify(this, 1 /* Pending */, 0);
|
|
984
987
|
if (this.I === 2 /* User */) {
|
|
985
988
|
try {
|
|
986
|
-
return this.
|
|
989
|
+
return this.qa ? this.qa(error2, () => {
|
|
987
990
|
this.L?.();
|
|
988
991
|
this.L = void 0;
|
|
989
992
|
}) : console.error(error2);
|
|
@@ -1011,18 +1014,18 @@ function effect(compute, effect2, error, initialValue, options) {
|
|
|
1011
1014
|
onCleanup(() => node.L?.());
|
|
1012
1015
|
}
|
|
1013
1016
|
function runEffect() {
|
|
1014
|
-
if (!this.
|
|
1017
|
+
if (!this.fa || this.b & 64 /* Disposed */)
|
|
1015
1018
|
return;
|
|
1016
1019
|
this.L?.();
|
|
1017
1020
|
this.L = void 0;
|
|
1018
1021
|
try {
|
|
1019
|
-
this.L = this.
|
|
1022
|
+
this.L = this.ua(this.g, this.pa);
|
|
1020
1023
|
} catch (error) {
|
|
1021
1024
|
if (!this.i.notify(this, 2 /* Error */, 2 /* Error */))
|
|
1022
1025
|
throw error;
|
|
1023
1026
|
} finally {
|
|
1024
|
-
this.
|
|
1025
|
-
this.
|
|
1027
|
+
this.pa = this.g;
|
|
1028
|
+
this.fa = false;
|
|
1026
1029
|
}
|
|
1027
1030
|
}
|
|
1028
1031
|
|
|
@@ -1053,7 +1056,7 @@ function createMemo(compute, value, options) {
|
|
|
1053
1056
|
function createAsync(compute, value, options) {
|
|
1054
1057
|
const node = asyncComputed(compute, value, options);
|
|
1055
1058
|
const ret = read.bind(null, node);
|
|
1056
|
-
ret.refresh = node.
|
|
1059
|
+
ret.refresh = node.ta;
|
|
1057
1060
|
return ret;
|
|
1058
1061
|
}
|
|
1059
1062
|
function createEffect(compute, effectFn, value, options) {
|
|
@@ -1366,7 +1369,7 @@ var storeTraps = {
|
|
|
1366
1369
|
return desc.get.call(receiver);
|
|
1367
1370
|
}
|
|
1368
1371
|
if (Writing?.has(receiver)) {
|
|
1369
|
-
let value2 = tracked && (overridden || !proxySource) ? tracked.
|
|
1372
|
+
let value2 = tracked && (overridden || !proxySource) ? tracked.e !== NOT_PENDING ? tracked.e : tracked.g : storeValue[property];
|
|
1370
1373
|
value2 === $DELETED && (value2 = void 0);
|
|
1371
1374
|
if (!isWrappable(value2))
|
|
1372
1375
|
return value2;
|
|
@@ -1766,78 +1769,78 @@ function mapArray(list, map, options) {
|
|
|
1766
1769
|
return createMemo(
|
|
1767
1770
|
updateKeyedMap.bind({
|
|
1768
1771
|
z: createOwner(),
|
|
1769
|
-
|
|
1770
|
-
|
|
1772
|
+
k: 0,
|
|
1773
|
+
va: list,
|
|
1771
1774
|
F: [],
|
|
1772
1775
|
M: map,
|
|
1773
|
-
|
|
1776
|
+
d: [],
|
|
1774
1777
|
a: [],
|
|
1775
1778
|
N: keyFn,
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
+
l: keyFn || options?.keyed === false ? [] : void 0,
|
|
1780
|
+
m: map.length > 1 ? [] : void 0,
|
|
1781
|
+
Y: options?.fallback
|
|
1779
1782
|
})
|
|
1780
1783
|
);
|
|
1781
1784
|
}
|
|
1782
1785
|
var pureOptions = { pureWrite: true };
|
|
1783
1786
|
function updateKeyedMap() {
|
|
1784
|
-
const newItems = this.
|
|
1787
|
+
const newItems = this.va() || [], newLen = newItems.length;
|
|
1785
1788
|
newItems[$TRACK];
|
|
1786
1789
|
runWithOwner(this.z, () => {
|
|
1787
|
-
let i, j, mapper = this.
|
|
1788
|
-
this.
|
|
1789
|
-
this.
|
|
1790
|
+
let i, j, mapper = this.l ? () => {
|
|
1791
|
+
this.l[j] = signal(newItems[j], pureOptions);
|
|
1792
|
+
this.m && (this.m[j] = signal(j, pureOptions));
|
|
1790
1793
|
return this.M(
|
|
1791
|
-
read.bind(null, this.
|
|
1792
|
-
this.
|
|
1794
|
+
read.bind(null, this.l[j]),
|
|
1795
|
+
this.m ? read.bind(null, this.m[j]) : void 0
|
|
1793
1796
|
);
|
|
1794
|
-
} : this.
|
|
1797
|
+
} : this.m ? () => {
|
|
1795
1798
|
const item = newItems[j];
|
|
1796
|
-
this.
|
|
1799
|
+
this.m[j] = signal(j, pureOptions);
|
|
1797
1800
|
return this.M(
|
|
1798
1801
|
() => item,
|
|
1799
|
-
read.bind(null, this.
|
|
1802
|
+
read.bind(null, this.m[j])
|
|
1800
1803
|
);
|
|
1801
1804
|
} : () => {
|
|
1802
1805
|
const item = newItems[j];
|
|
1803
1806
|
return this.M(() => item);
|
|
1804
1807
|
};
|
|
1805
1808
|
if (newLen === 0) {
|
|
1806
|
-
if (this.
|
|
1809
|
+
if (this.k !== 0) {
|
|
1807
1810
|
this.z.dispose(false);
|
|
1808
1811
|
this.a = [];
|
|
1809
1812
|
this.F = [];
|
|
1810
|
-
this.
|
|
1811
|
-
this.
|
|
1812
|
-
this.k && (this.k = []);
|
|
1813
|
+
this.d = [];
|
|
1814
|
+
this.k = 0;
|
|
1813
1815
|
this.l && (this.l = []);
|
|
1816
|
+
this.m && (this.m = []);
|
|
1814
1817
|
}
|
|
1815
|
-
if (this.
|
|
1816
|
-
this.
|
|
1818
|
+
if (this.Y && !this.d[0]) {
|
|
1819
|
+
this.d[0] = runWithOwner(
|
|
1817
1820
|
this.a[0] = createOwner(),
|
|
1818
|
-
this.
|
|
1821
|
+
this.Y
|
|
1819
1822
|
);
|
|
1820
1823
|
}
|
|
1821
|
-
} else if (this.
|
|
1824
|
+
} else if (this.k === 0) {
|
|
1822
1825
|
if (this.a[0])
|
|
1823
1826
|
this.a[0].dispose();
|
|
1824
|
-
this.
|
|
1827
|
+
this.d = new Array(newLen);
|
|
1825
1828
|
for (j = 0; j < newLen; j++) {
|
|
1826
1829
|
this.F[j] = newItems[j];
|
|
1827
|
-
this.
|
|
1830
|
+
this.d[j] = runWithOwner(this.a[j] = createOwner(), mapper);
|
|
1828
1831
|
}
|
|
1829
|
-
this.
|
|
1832
|
+
this.k = newLen;
|
|
1830
1833
|
} else {
|
|
1831
|
-
let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.
|
|
1832
|
-
for (start = 0, end = Math.min(this.
|
|
1833
|
-
if (this.
|
|
1834
|
-
setSignal(this.
|
|
1834
|
+
let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.l ? new Array(newLen) : void 0, tempIndexes = this.m ? new Array(newLen) : void 0;
|
|
1835
|
+
for (start = 0, end = Math.min(this.k, newLen); start < end && (this.F[start] === newItems[start] || this.l && compare(this.N, this.F[start], newItems[start])); start++) {
|
|
1836
|
+
if (this.l)
|
|
1837
|
+
setSignal(this.l[start], newItems[start]);
|
|
1835
1838
|
}
|
|
1836
|
-
for (end = this.
|
|
1837
|
-
temp[newEnd] = this.
|
|
1839
|
+
for (end = this.k - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.F[end] === newItems[newEnd] || this.l && compare(this.N, this.F[end], newItems[newEnd])); end--, newEnd--) {
|
|
1840
|
+
temp[newEnd] = this.d[end];
|
|
1838
1841
|
tempNodes[newEnd] = this.a[end];
|
|
1839
|
-
tempRows && (tempRows[newEnd] = this.
|
|
1840
|
-
tempIndexes && (tempIndexes[newEnd] = this.
|
|
1842
|
+
tempRows && (tempRows[newEnd] = this.l[end]);
|
|
1843
|
+
tempIndexes && (tempIndexes[newEnd] = this.m[end]);
|
|
1841
1844
|
}
|
|
1842
1845
|
newIndices = /* @__PURE__ */ new Map();
|
|
1843
1846
|
newIndicesNext = new Array(newEnd + 1);
|
|
@@ -1853,10 +1856,10 @@ function updateKeyedMap() {
|
|
|
1853
1856
|
key = this.N ? this.N(item) : item;
|
|
1854
1857
|
j = newIndices.get(key);
|
|
1855
1858
|
if (j !== void 0 && j !== -1) {
|
|
1856
|
-
temp[j] = this.
|
|
1859
|
+
temp[j] = this.d[i];
|
|
1857
1860
|
tempNodes[j] = this.a[i];
|
|
1858
|
-
tempRows && (tempRows[j] = this.
|
|
1859
|
-
tempIndexes && (tempIndexes[j] = this.
|
|
1861
|
+
tempRows && (tempRows[j] = this.l[i]);
|
|
1862
|
+
tempIndexes && (tempIndexes[j] = this.m[i]);
|
|
1860
1863
|
j = newIndicesNext[j];
|
|
1861
1864
|
newIndices.set(key, j);
|
|
1862
1865
|
} else
|
|
@@ -1864,97 +1867,97 @@ function updateKeyedMap() {
|
|
|
1864
1867
|
}
|
|
1865
1868
|
for (j = start; j < newLen; j++) {
|
|
1866
1869
|
if (j in temp) {
|
|
1867
|
-
this.
|
|
1870
|
+
this.d[j] = temp[j];
|
|
1868
1871
|
this.a[j] = tempNodes[j];
|
|
1869
1872
|
if (tempRows) {
|
|
1870
|
-
this.
|
|
1871
|
-
setSignal(this.
|
|
1873
|
+
this.l[j] = tempRows[j];
|
|
1874
|
+
setSignal(this.l[j], newItems[j]);
|
|
1872
1875
|
}
|
|
1873
1876
|
if (tempIndexes) {
|
|
1874
|
-
this.
|
|
1875
|
-
setSignal(this.
|
|
1877
|
+
this.m[j] = tempIndexes[j];
|
|
1878
|
+
setSignal(this.m[j], j);
|
|
1876
1879
|
}
|
|
1877
1880
|
} else {
|
|
1878
|
-
this.
|
|
1881
|
+
this.d[j] = runWithOwner(this.a[j] = createOwner(), mapper);
|
|
1879
1882
|
}
|
|
1880
1883
|
}
|
|
1881
|
-
this.
|
|
1884
|
+
this.d = this.d.slice(0, this.k = newLen);
|
|
1882
1885
|
this.F = newItems.slice(0);
|
|
1883
1886
|
}
|
|
1884
1887
|
});
|
|
1885
|
-
return this.
|
|
1888
|
+
return this.d;
|
|
1886
1889
|
}
|
|
1887
1890
|
function repeat(count, map, options) {
|
|
1888
1891
|
return updateRepeat.bind({
|
|
1889
1892
|
z: createOwner(),
|
|
1890
|
-
|
|
1893
|
+
k: 0,
|
|
1891
1894
|
w: 0,
|
|
1892
|
-
|
|
1895
|
+
wa: count,
|
|
1893
1896
|
M: map,
|
|
1894
1897
|
a: [],
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
+
d: [],
|
|
1899
|
+
xa: options?.from,
|
|
1900
|
+
Y: options?.fallback
|
|
1898
1901
|
});
|
|
1899
1902
|
}
|
|
1900
1903
|
function updateRepeat() {
|
|
1901
|
-
const newLen = this.
|
|
1902
|
-
const from = this.
|
|
1904
|
+
const newLen = this.wa();
|
|
1905
|
+
const from = this.xa?.() || 0;
|
|
1903
1906
|
runWithOwner(this.z, () => {
|
|
1904
1907
|
if (newLen === 0) {
|
|
1905
|
-
if (this.
|
|
1908
|
+
if (this.k !== 0) {
|
|
1906
1909
|
this.z.dispose(false);
|
|
1907
1910
|
this.a = [];
|
|
1908
|
-
this.
|
|
1909
|
-
this.
|
|
1911
|
+
this.d = [];
|
|
1912
|
+
this.k = 0;
|
|
1910
1913
|
}
|
|
1911
|
-
if (this.
|
|
1912
|
-
this.
|
|
1914
|
+
if (this.Y && !this.d[0]) {
|
|
1915
|
+
this.d[0] = runWithOwner(
|
|
1913
1916
|
this.a[0] = createOwner(),
|
|
1914
|
-
this.
|
|
1917
|
+
this.Y
|
|
1915
1918
|
);
|
|
1916
1919
|
}
|
|
1917
1920
|
return;
|
|
1918
1921
|
}
|
|
1919
1922
|
const to = from + newLen;
|
|
1920
|
-
const prevTo = this.w + this.
|
|
1921
|
-
if (this.
|
|
1923
|
+
const prevTo = this.w + this.k;
|
|
1924
|
+
if (this.k === 0 && this.a[0])
|
|
1922
1925
|
this.a[0].dispose();
|
|
1923
1926
|
for (let i = to; i < prevTo; i++)
|
|
1924
1927
|
this.a[i - this.w].dispose();
|
|
1925
1928
|
if (this.w < from) {
|
|
1926
1929
|
let i = this.w;
|
|
1927
|
-
while (i < from && i < this.
|
|
1930
|
+
while (i < from && i < this.k)
|
|
1928
1931
|
this.a[i++].dispose();
|
|
1929
1932
|
this.a.splice(0, from - this.w);
|
|
1930
|
-
this.
|
|
1933
|
+
this.d.splice(0, from - this.w);
|
|
1931
1934
|
} else if (this.w > from) {
|
|
1932
1935
|
let i = prevTo - this.w - 1;
|
|
1933
1936
|
let difference = this.w - from;
|
|
1934
|
-
this.a.length = this.
|
|
1937
|
+
this.a.length = this.d.length = newLen;
|
|
1935
1938
|
while (i >= difference) {
|
|
1936
1939
|
this.a[i] = this.a[i - difference];
|
|
1937
|
-
this.
|
|
1940
|
+
this.d[i] = this.d[i - difference];
|
|
1938
1941
|
i--;
|
|
1939
1942
|
}
|
|
1940
1943
|
for (let i2 = 0; i2 < difference; i2++) {
|
|
1941
|
-
this.
|
|
1944
|
+
this.d[i2] = runWithOwner(
|
|
1942
1945
|
this.a[i2] = createOwner(),
|
|
1943
1946
|
() => this.M(i2 + from)
|
|
1944
1947
|
);
|
|
1945
1948
|
}
|
|
1946
1949
|
}
|
|
1947
1950
|
for (let i = prevTo; i < to; i++) {
|
|
1948
|
-
this.
|
|
1951
|
+
this.d[i - from] = runWithOwner(
|
|
1949
1952
|
this.a[i - from] = createOwner(),
|
|
1950
1953
|
() => this.M(i)
|
|
1951
1954
|
);
|
|
1952
1955
|
}
|
|
1953
|
-
this.
|
|
1956
|
+
this.d = this.d.slice(0, newLen);
|
|
1954
1957
|
this.w = from;
|
|
1955
|
-
this.
|
|
1958
|
+
this.k = newLen;
|
|
1956
1959
|
});
|
|
1957
|
-
return this.
|
|
1960
|
+
return this.d;
|
|
1958
1961
|
}
|
|
1959
1962
|
function compare(key, a, b) {
|
|
1960
1963
|
return key ? key(a) === key(b) : true;
|
|
@@ -1964,18 +1967,18 @@ function compare(key, a, b) {
|
|
|
1964
1967
|
function boundaryComputed(fn, propagationMask) {
|
|
1965
1968
|
const node = computed(fn, void 0, {
|
|
1966
1969
|
ja: {
|
|
1967
|
-
|
|
1970
|
+
ma() {
|
|
1968
1971
|
let flags = this.f;
|
|
1969
|
-
this.f &= ~this.
|
|
1970
|
-
if (this.
|
|
1972
|
+
this.f &= ~this.Z;
|
|
1973
|
+
if (this.Z & 1 /* Pending */ && !(this.f & 4 /* Uninitialized */)) {
|
|
1971
1974
|
flags &= ~1 /* Pending */;
|
|
1972
1975
|
}
|
|
1973
|
-
this.i.notify(this, this.
|
|
1976
|
+
this.i.notify(this, this.Z, flags);
|
|
1974
1977
|
},
|
|
1975
|
-
|
|
1978
|
+
Z: propagationMask
|
|
1976
1979
|
}
|
|
1977
1980
|
});
|
|
1978
|
-
node.
|
|
1981
|
+
node.Z = propagationMask;
|
|
1979
1982
|
return node;
|
|
1980
1983
|
}
|
|
1981
1984
|
function createBoundChildren(owner, fn, queue, mask) {
|
|
@@ -1988,20 +1991,20 @@ function createBoundChildren(owner, fn, queue, mask) {
|
|
|
1988
1991
|
});
|
|
1989
1992
|
}
|
|
1990
1993
|
var ConditionalQueue = class extends Queue {
|
|
1991
|
-
|
|
1992
|
-
|
|
1994
|
+
t;
|
|
1995
|
+
ga = /* @__PURE__ */ new Set();
|
|
1993
1996
|
h = /* @__PURE__ */ new Set();
|
|
1994
1997
|
constructor(disabled) {
|
|
1995
1998
|
super();
|
|
1996
|
-
this.
|
|
1999
|
+
this.t = disabled;
|
|
1997
2000
|
}
|
|
1998
2001
|
run(type) {
|
|
1999
|
-
if (!type || read(this.
|
|
2002
|
+
if (!type || read(this.t))
|
|
2000
2003
|
return;
|
|
2001
2004
|
return super.run(type);
|
|
2002
2005
|
}
|
|
2003
2006
|
notify(node, type, flags) {
|
|
2004
|
-
if (read(this.
|
|
2007
|
+
if (read(this.t)) {
|
|
2005
2008
|
if (type & 1 /* Pending */) {
|
|
2006
2009
|
if (flags & 1 /* Pending */) {
|
|
2007
2010
|
this.h.add(node);
|
|
@@ -2011,9 +2014,9 @@ var ConditionalQueue = class extends Queue {
|
|
|
2011
2014
|
}
|
|
2012
2015
|
if (type & 2 /* Error */) {
|
|
2013
2016
|
if (flags & 2 /* Error */) {
|
|
2014
|
-
this.
|
|
2017
|
+
this.ga.add(node);
|
|
2015
2018
|
type &= ~2 /* Error */;
|
|
2016
|
-
} else if (this.
|
|
2019
|
+
} else if (this.ga.delete(node))
|
|
2017
2020
|
type &= ~2 /* Error */;
|
|
2018
2021
|
}
|
|
2019
2022
|
}
|
|
@@ -2021,31 +2024,38 @@ var ConditionalQueue = class extends Queue {
|
|
|
2021
2024
|
}
|
|
2022
2025
|
};
|
|
2023
2026
|
var CollectionQueue = class extends Queue {
|
|
2024
|
-
|
|
2027
|
+
O;
|
|
2025
2028
|
a = /* @__PURE__ */ new Set();
|
|
2026
|
-
|
|
2029
|
+
t = signal(false, { pureWrite: true });
|
|
2030
|
+
ka = false;
|
|
2027
2031
|
constructor(type) {
|
|
2028
2032
|
super();
|
|
2029
|
-
this.
|
|
2033
|
+
this.O = type;
|
|
2030
2034
|
}
|
|
2031
2035
|
run(type) {
|
|
2032
|
-
if (!type || read(this.
|
|
2036
|
+
if (!type || read(this.t))
|
|
2033
2037
|
return;
|
|
2034
2038
|
return super.run(type);
|
|
2035
2039
|
}
|
|
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
|
+
}
|
|
2036
2046
|
notify(node, type, flags) {
|
|
2037
|
-
if (!(type & this.
|
|
2047
|
+
if (!(type & this.O) || this.O & 1 /* Pending */ && this.ka)
|
|
2038
2048
|
return super.notify(node, type, flags);
|
|
2039
|
-
if (flags & this.
|
|
2049
|
+
if (flags & this.O) {
|
|
2040
2050
|
this.a.add(node);
|
|
2041
2051
|
if (this.a.size === 1)
|
|
2042
|
-
setSignal(this.
|
|
2052
|
+
setSignal(this.t, true);
|
|
2043
2053
|
} else if (this.a.size > 0) {
|
|
2044
2054
|
this.a.delete(node);
|
|
2045
2055
|
if (this.a.size === 0)
|
|
2046
|
-
setSignal(this.
|
|
2056
|
+
setSignal(this.t, false);
|
|
2047
2057
|
}
|
|
2048
|
-
type &= ~this.
|
|
2058
|
+
type &= ~this.O;
|
|
2049
2059
|
return type ? super.notify(node, type, flags) : true;
|
|
2050
2060
|
}
|
|
2051
2061
|
};
|
|
@@ -2054,28 +2064,29 @@ function createBoundary(fn, condition) {
|
|
|
2054
2064
|
const queue = new ConditionalQueue(computed(() => condition() === "hidden" /* HIDDEN */));
|
|
2055
2065
|
const tree = createBoundChildren(owner, fn, queue, 0);
|
|
2056
2066
|
computed(() => {
|
|
2057
|
-
const disabled = read(queue.
|
|
2058
|
-
tree.
|
|
2067
|
+
const disabled = read(queue.t);
|
|
2068
|
+
tree.Z = disabled ? 2 /* Error */ | 1 /* Pending */ : 0;
|
|
2059
2069
|
if (!disabled) {
|
|
2060
2070
|
queue.h.forEach(
|
|
2061
2071
|
(node) => queue.notify(node, 1 /* Pending */, 1 /* Pending */)
|
|
2062
2072
|
);
|
|
2063
|
-
queue.
|
|
2073
|
+
queue.ga.forEach((node) => queue.notify(node, 2 /* Error */, 2 /* Error */));
|
|
2064
2074
|
queue.h.clear();
|
|
2065
|
-
queue.
|
|
2075
|
+
queue.ga.clear();
|
|
2066
2076
|
}
|
|
2067
2077
|
});
|
|
2068
|
-
return () => read(queue.
|
|
2078
|
+
return () => read(queue.t) ? void 0 : read(tree);
|
|
2069
2079
|
}
|
|
2070
2080
|
function createCollectionBoundary(type, fn, fallback) {
|
|
2071
2081
|
const owner = createOwner();
|
|
2072
2082
|
const queue = new CollectionQueue(type);
|
|
2073
2083
|
const tree = createBoundChildren(owner, fn, queue, type);
|
|
2074
2084
|
const decision = computed(() => {
|
|
2075
|
-
if (!read(queue.
|
|
2085
|
+
if (!read(queue.t)) {
|
|
2076
2086
|
const resolved = read(tree);
|
|
2077
|
-
if (!untrack(() => read(queue.
|
|
2078
|
-
|
|
2087
|
+
if (!untrack(() => read(queue.t)))
|
|
2088
|
+
queue.ka = true;
|
|
2089
|
+
return resolved;
|
|
2079
2090
|
}
|
|
2080
2091
|
return fallback(queue);
|
|
2081
2092
|
});
|