@solidjs/signals 0.8.2 → 0.8.3
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 +88 -42
- package/dist/node.cjs +339 -289
- package/dist/prod.js +334 -288
- package/dist/types/core/core.d.ts +2 -1
- package/dist/types/core/effect.d.ts +0 -1
- package/dist/types/core/index.d.ts +1 -1
- package/dist/types/core/scheduler.d.ts +0 -1
- package/dist/types/signals.d.ts +1 -1
- package/dist/types/store/store.d.ts +3 -2
- package/package.json +1 -1
package/dist/prod.js
CHANGED
|
@@ -24,13 +24,13 @@ var SUPPORTS_PROXY = typeof Proxy === "function";
|
|
|
24
24
|
|
|
25
25
|
// src/core/heap.ts
|
|
26
26
|
function actualInsertIntoHeap(n, heap) {
|
|
27
|
-
const parentHeight = (n.w
|
|
27
|
+
const parentHeight = (n.w?.$ ? n.w.aa?.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.s[height];
|
|
32
32
|
if (heapAtHeight === void 0) {
|
|
33
|
-
heap.
|
|
33
|
+
heap.s[height] = n;
|
|
34
34
|
} else {
|
|
35
35
|
const tail = heapAtHeight.z;
|
|
36
36
|
tail.Q = n;
|
|
@@ -67,13 +67,13 @@ function deleteFromHeap(n, heap) {
|
|
|
67
67
|
n.b = flags & ~(8 /* InHeap */ | 16 /* InHeapHeight */);
|
|
68
68
|
const height = n.c;
|
|
69
69
|
if (n.z === n) {
|
|
70
|
-
heap.
|
|
70
|
+
heap.s[height] = void 0;
|
|
71
71
|
} else {
|
|
72
72
|
const next = n.Q;
|
|
73
|
-
const dhh = heap.
|
|
73
|
+
const dhh = heap.s[height];
|
|
74
74
|
const end = next ?? dhh;
|
|
75
75
|
if (n === dhh) {
|
|
76
|
-
heap.
|
|
76
|
+
heap.s[height] = next;
|
|
77
77
|
} else {
|
|
78
78
|
n.z.Q = next;
|
|
79
79
|
}
|
|
@@ -83,11 +83,11 @@ function deleteFromHeap(n, heap) {
|
|
|
83
83
|
n.Q = void 0;
|
|
84
84
|
}
|
|
85
85
|
function markHeap(heap) {
|
|
86
|
-
if (heap.
|
|
86
|
+
if (heap.ba)
|
|
87
87
|
return;
|
|
88
|
-
heap.
|
|
88
|
+
heap.ba = true;
|
|
89
89
|
for (let i = 0; i <= heap.L; i++) {
|
|
90
|
-
for (let el = heap.
|
|
90
|
+
for (let el = heap.s[i]; el !== void 0; el = el.Q) {
|
|
91
91
|
if (el.b & 8 /* InHeap */)
|
|
92
92
|
markNode(el);
|
|
93
93
|
}
|
|
@@ -98,28 +98,28 @@ 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.x; link2 !== null; link2 = link2.A) {
|
|
102
102
|
markNode(link2.j, 1 /* Check */);
|
|
103
103
|
}
|
|
104
|
-
if (el.
|
|
105
|
-
for (let child = el.
|
|
106
|
-
for (let link2 = child.
|
|
104
|
+
if (el.ca !== null) {
|
|
105
|
+
for (let child = el.ca; child !== null; child = child.sa) {
|
|
106
|
+
for (let link2 = child.x; link2 !== null; link2 = link2.A) {
|
|
107
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.ba = false;
|
|
114
|
+
for (heap.q = 0; heap.q <= heap.L; heap.q++) {
|
|
115
|
+
let el = heap.s[heap.q];
|
|
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.s[heap.q];
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
heap.L = 0;
|
|
@@ -127,10 +127,10 @@ function runHeap(heap, recompute2) {
|
|
|
127
127
|
function adjustHeight(el, heap) {
|
|
128
128
|
deleteFromHeap(el, heap);
|
|
129
129
|
let newHeight = el.c;
|
|
130
|
-
for (let d = el.
|
|
130
|
+
for (let d = el.l; d; d = d.E) {
|
|
131
131
|
const dep1 = d.R;
|
|
132
|
-
const dep =
|
|
133
|
-
if (
|
|
132
|
+
const dep = dep1.ia || dep1;
|
|
133
|
+
if (dep.H) {
|
|
134
134
|
if (dep.c >= newHeight) {
|
|
135
135
|
newHeight = dep.c + 1;
|
|
136
136
|
}
|
|
@@ -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.x; s !== null; s = s.A) {
|
|
142
142
|
insertIntoHeapHeight(s.j, heap);
|
|
143
143
|
}
|
|
144
144
|
}
|
|
@@ -147,41 +147,40 @@ function adjustHeight(el, heap) {
|
|
|
147
147
|
// src/core/scheduler.ts
|
|
148
148
|
var clock = 0;
|
|
149
149
|
var activeTransition = null;
|
|
150
|
-
var unobserved = [];
|
|
151
150
|
var transitions = /* @__PURE__ */ new Set();
|
|
152
151
|
var scheduled = false;
|
|
153
152
|
function schedule() {
|
|
154
153
|
if (scheduled)
|
|
155
154
|
return;
|
|
156
155
|
scheduled = true;
|
|
157
|
-
if (!globalQueue.
|
|
156
|
+
if (!globalQueue.da)
|
|
158
157
|
queueMicrotask(flush);
|
|
159
158
|
}
|
|
160
159
|
var dirtyQueue = {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
160
|
+
s: new Array(2e3).fill(void 0),
|
|
161
|
+
ba: false,
|
|
162
|
+
q: 0,
|
|
164
163
|
L: 0
|
|
165
164
|
};
|
|
166
165
|
var zombieQueue = {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
166
|
+
s: new Array(2e3).fill(void 0),
|
|
167
|
+
ba: false,
|
|
168
|
+
q: 0,
|
|
170
169
|
L: 0
|
|
171
170
|
};
|
|
172
171
|
var Queue = class {
|
|
173
172
|
w = null;
|
|
174
173
|
k = [[], []];
|
|
175
|
-
|
|
174
|
+
m = [];
|
|
176
175
|
created = clock;
|
|
177
176
|
addChild(child) {
|
|
178
|
-
this.
|
|
177
|
+
this.m.push(child);
|
|
179
178
|
child.w = this;
|
|
180
179
|
}
|
|
181
180
|
removeChild(child) {
|
|
182
|
-
const index = this.
|
|
181
|
+
const index = this.m.indexOf(child);
|
|
183
182
|
if (index >= 0) {
|
|
184
|
-
this.
|
|
183
|
+
this.m.splice(index, 1);
|
|
185
184
|
child.w = null;
|
|
186
185
|
}
|
|
187
186
|
}
|
|
@@ -196,8 +195,8 @@ var Queue = class {
|
|
|
196
195
|
this.k[type - 1] = [];
|
|
197
196
|
runQueue(effects, type);
|
|
198
197
|
}
|
|
199
|
-
for (let i = 0; i < this.
|
|
200
|
-
this.
|
|
198
|
+
for (let i = 0; i < this.m.length; i++) {
|
|
199
|
+
this.m[i].run(type);
|
|
201
200
|
}
|
|
202
201
|
}
|
|
203
202
|
enqueue(type, fn) {
|
|
@@ -209,12 +208,12 @@ var Queue = class {
|
|
|
209
208
|
stub.k[0].push(...this.k[0]);
|
|
210
209
|
stub.k[1].push(...this.k[1]);
|
|
211
210
|
this.k = [[], []];
|
|
212
|
-
for (let i = 0; i < this.
|
|
213
|
-
let child = this.
|
|
214
|
-
let childStub = stub.
|
|
211
|
+
for (let i = 0; i < this.m.length; i++) {
|
|
212
|
+
let child = this.m[i];
|
|
213
|
+
let childStub = stub.m[i];
|
|
215
214
|
if (!childStub) {
|
|
216
|
-
childStub = { k: [[], []],
|
|
217
|
-
stub.
|
|
215
|
+
childStub = { k: [[], []], m: [] };
|
|
216
|
+
stub.m[i] = childStub;
|
|
218
217
|
}
|
|
219
218
|
child.stashQueues(childStub);
|
|
220
219
|
}
|
|
@@ -222,23 +221,23 @@ var Queue = class {
|
|
|
222
221
|
restoreQueues(stub) {
|
|
223
222
|
this.k[0].push(...stub.k[0]);
|
|
224
223
|
this.k[1].push(...stub.k[1]);
|
|
225
|
-
for (let i = 0; i < stub.
|
|
226
|
-
const childStub = stub.
|
|
227
|
-
let child = this.
|
|
224
|
+
for (let i = 0; i < stub.m.length; i++) {
|
|
225
|
+
const childStub = stub.m[i];
|
|
226
|
+
let child = this.m[i];
|
|
228
227
|
if (child)
|
|
229
228
|
child.restoreQueues(childStub);
|
|
230
229
|
}
|
|
231
230
|
}
|
|
232
231
|
};
|
|
233
232
|
var GlobalQueue = class _GlobalQueue extends Queue {
|
|
234
|
-
|
|
233
|
+
da = false;
|
|
235
234
|
h = [];
|
|
236
235
|
static S;
|
|
237
|
-
static
|
|
236
|
+
static la;
|
|
238
237
|
flush() {
|
|
239
|
-
if (this.
|
|
238
|
+
if (this.da)
|
|
240
239
|
return;
|
|
241
|
-
this.
|
|
240
|
+
this.da = true;
|
|
242
241
|
try {
|
|
243
242
|
runHeap(dirtyQueue, _GlobalQueue.S);
|
|
244
243
|
if (activeTransition) {
|
|
@@ -266,8 +265,8 @@ var GlobalQueue = class _GlobalQueue extends Queue {
|
|
|
266
265
|
n.g = n.e;
|
|
267
266
|
n.e = NOT_PENDING;
|
|
268
267
|
}
|
|
269
|
-
if (n.
|
|
270
|
-
_GlobalQueue.
|
|
268
|
+
if (n.H)
|
|
269
|
+
_GlobalQueue.la(n, false, true);
|
|
271
270
|
}
|
|
272
271
|
globalQueue.h.length = 0;
|
|
273
272
|
clock++;
|
|
@@ -275,15 +274,14 @@ var GlobalQueue = class _GlobalQueue extends Queue {
|
|
|
275
274
|
this.run(1 /* Render */);
|
|
276
275
|
this.run(2 /* User */);
|
|
277
276
|
} finally {
|
|
278
|
-
this.
|
|
279
|
-
unobserved.length && notifyUnobserved();
|
|
277
|
+
this.da = false;
|
|
280
278
|
}
|
|
281
279
|
}
|
|
282
280
|
notify(node, mask, flags) {
|
|
283
281
|
if (mask & 1 /* Pending */) {
|
|
284
282
|
if (flags & 1 /* Pending */) {
|
|
285
|
-
if (activeTransition && !activeTransition.asyncNodes.includes(node.
|
|
286
|
-
activeTransition.asyncNodes.push(node.
|
|
283
|
+
if (activeTransition && !activeTransition.asyncNodes.includes(node.B.cause))
|
|
284
|
+
activeTransition.asyncNodes.push(node.B.cause);
|
|
287
285
|
}
|
|
288
286
|
return true;
|
|
289
287
|
}
|
|
@@ -297,7 +295,7 @@ var GlobalQueue = class _GlobalQueue extends Queue {
|
|
|
297
295
|
time: clock,
|
|
298
296
|
pendingNodes: [],
|
|
299
297
|
asyncNodes: [],
|
|
300
|
-
queueStash: { k: [[], []],
|
|
298
|
+
queueStash: { k: [[], []], m: [] }
|
|
301
299
|
};
|
|
302
300
|
}
|
|
303
301
|
transitions.add(activeTransition);
|
|
@@ -316,8 +314,8 @@ function runPending(pendingNodes, value) {
|
|
|
316
314
|
for (let i = 0; i < p.length; i++) {
|
|
317
315
|
const n = p[i];
|
|
318
316
|
n.T = activeTransition;
|
|
319
|
-
if (n.
|
|
320
|
-
n.
|
|
317
|
+
if (n.I) {
|
|
318
|
+
n.I.ea(value);
|
|
321
319
|
needsReset = true;
|
|
322
320
|
}
|
|
323
321
|
}
|
|
@@ -343,18 +341,10 @@ function transitionComplete(transition) {
|
|
|
343
341
|
}
|
|
344
342
|
return done;
|
|
345
343
|
}
|
|
346
|
-
function notifyUnobserved() {
|
|
347
|
-
for (let i = 0; i < unobserved.length; i++) {
|
|
348
|
-
const source = unobserved[i];
|
|
349
|
-
if (!source.s)
|
|
350
|
-
unobserved[i].sa?.();
|
|
351
|
-
}
|
|
352
|
-
unobserved = [];
|
|
353
|
-
}
|
|
354
344
|
|
|
355
345
|
// src/core/core.ts
|
|
356
346
|
GlobalQueue.S = recompute;
|
|
357
|
-
GlobalQueue.
|
|
347
|
+
GlobalQueue.la = disposeChildren;
|
|
358
348
|
var tracking = false;
|
|
359
349
|
var stale = false;
|
|
360
350
|
var pendingValueCheck = false;
|
|
@@ -362,10 +352,10 @@ var pendingCheck = null;
|
|
|
362
352
|
var context = null;
|
|
363
353
|
var defaultContext = {};
|
|
364
354
|
function notifySubs(node) {
|
|
365
|
-
for (let s = node.
|
|
355
|
+
for (let s = node.x; s !== null; s = s.A) {
|
|
366
356
|
const queue = s.j.b & 32 /* Zombie */ ? zombieQueue : dirtyQueue;
|
|
367
|
-
if (queue.
|
|
368
|
-
queue.
|
|
357
|
+
if (queue.q > s.j.c)
|
|
358
|
+
queue.q = s.j.c;
|
|
369
359
|
insertIntoHeap(s.j, queue);
|
|
370
360
|
}
|
|
371
361
|
}
|
|
@@ -377,24 +367,24 @@ function recompute(el, create = false) {
|
|
|
377
367
|
markDisposal(el);
|
|
378
368
|
globalQueue.h.push(el);
|
|
379
369
|
el.V = el.t;
|
|
380
|
-
el.U = el.
|
|
370
|
+
el.U = el.r;
|
|
381
371
|
el.t = null;
|
|
382
|
-
el.
|
|
372
|
+
el.r = null;
|
|
383
373
|
}
|
|
384
374
|
const oldcontext = context;
|
|
385
375
|
context = el;
|
|
386
|
-
el.
|
|
376
|
+
el.F = null;
|
|
387
377
|
el.b = 4 /* RecomputingDeps */;
|
|
388
378
|
el.J = clock;
|
|
389
379
|
let value = el.e === NOT_PENDING ? el.g : el.e;
|
|
390
380
|
let oldHeight = el.c;
|
|
391
381
|
let prevStatusFlags = el.f;
|
|
392
|
-
let prevError = el.
|
|
382
|
+
let prevError = el.B;
|
|
393
383
|
let prevTracking = tracking;
|
|
394
384
|
clearStatusFlags(el);
|
|
395
385
|
tracking = true;
|
|
396
386
|
try {
|
|
397
|
-
value = el.
|
|
387
|
+
value = el.H(value);
|
|
398
388
|
} catch (e) {
|
|
399
389
|
if (e instanceof NotReadyError) {
|
|
400
390
|
if (e.cause !== el)
|
|
@@ -408,51 +398,51 @@ function recompute(el, create = false) {
|
|
|
408
398
|
}
|
|
409
399
|
el.b = 0 /* None */;
|
|
410
400
|
context = oldcontext;
|
|
411
|
-
const depsTail = el.
|
|
412
|
-
let toRemove = depsTail !== null ? depsTail.
|
|
401
|
+
const depsTail = el.F;
|
|
402
|
+
let toRemove = depsTail !== null ? depsTail.E : el.l;
|
|
413
403
|
if (toRemove !== null) {
|
|
414
404
|
do {
|
|
415
405
|
toRemove = unlinkSubs(toRemove);
|
|
416
406
|
} while (toRemove !== null);
|
|
417
407
|
if (depsTail !== null) {
|
|
418
|
-
depsTail.
|
|
408
|
+
depsTail.E = null;
|
|
419
409
|
} else {
|
|
420
|
-
el.
|
|
410
|
+
el.l = null;
|
|
421
411
|
}
|
|
422
412
|
}
|
|
423
|
-
const valueChanged = !el.
|
|
424
|
-
const statusFlagsChanged = el.f !== prevStatusFlags || el.
|
|
425
|
-
el.
|
|
413
|
+
const valueChanged = !el.fa || !el.fa(el.e === NOT_PENDING ? el.g : el.e, value);
|
|
414
|
+
const statusFlagsChanged = el.f !== prevStatusFlags || el.B !== prevError;
|
|
415
|
+
el.ma?.(statusFlagsChanged, prevStatusFlags);
|
|
426
416
|
if (valueChanged || statusFlagsChanged) {
|
|
427
417
|
if (valueChanged) {
|
|
428
|
-
if (create || el.
|
|
418
|
+
if (create || el.ja || el.K)
|
|
429
419
|
el.g = value;
|
|
430
420
|
else {
|
|
431
421
|
if (el.e === NOT_PENDING)
|
|
432
422
|
globalQueue.h.push(el);
|
|
433
423
|
el.e = value;
|
|
434
424
|
}
|
|
435
|
-
if (el.
|
|
436
|
-
el.
|
|
425
|
+
if (el.C)
|
|
426
|
+
el.C.ea(value);
|
|
437
427
|
}
|
|
438
|
-
for (let s = el.
|
|
428
|
+
for (let s = el.x; s !== null; s = s.A) {
|
|
439
429
|
const queue = s.j.b & 32 /* Zombie */ ? zombieQueue : dirtyQueue;
|
|
440
|
-
if (s.j.c < el.c && queue.
|
|
441
|
-
queue.
|
|
430
|
+
if (s.j.c < el.c && queue.q > s.j.c)
|
|
431
|
+
queue.q = s.j.c;
|
|
442
432
|
insertIntoHeap(s.j, queue);
|
|
443
433
|
}
|
|
444
434
|
} else if (el.c != oldHeight) {
|
|
445
|
-
for (let s = el.
|
|
435
|
+
for (let s = el.x; s !== null; s = s.A) {
|
|
446
436
|
insertIntoHeapHeight(s.j, s.j.b & 32 /* Zombie */ ? zombieQueue : dirtyQueue);
|
|
447
437
|
}
|
|
448
438
|
}
|
|
449
439
|
}
|
|
450
440
|
function updateIfNecessary(el) {
|
|
451
441
|
if (el.b & 1 /* Check */) {
|
|
452
|
-
for (let d = el.
|
|
442
|
+
for (let d = el.l; d; d = d.E) {
|
|
453
443
|
const dep1 = d.R;
|
|
454
|
-
const dep =
|
|
455
|
-
if (
|
|
444
|
+
const dep = dep1.ia || dep1;
|
|
445
|
+
if (dep.H) {
|
|
456
446
|
updateIfNecessary(dep);
|
|
457
447
|
}
|
|
458
448
|
if (el.b & 2 /* Dirty */) {
|
|
@@ -467,32 +457,45 @@ function updateIfNecessary(el) {
|
|
|
467
457
|
}
|
|
468
458
|
function unlinkSubs(link2) {
|
|
469
459
|
const dep = link2.R;
|
|
470
|
-
const nextDep = link2.
|
|
460
|
+
const nextDep = link2.E;
|
|
471
461
|
const nextSub = link2.A;
|
|
472
|
-
const prevSub = link2.
|
|
462
|
+
const prevSub = link2.na;
|
|
473
463
|
if (nextSub !== null) {
|
|
474
|
-
nextSub.
|
|
464
|
+
nextSub.na = prevSub;
|
|
475
465
|
} else {
|
|
476
466
|
dep.W = prevSub;
|
|
477
467
|
}
|
|
478
468
|
if (prevSub !== null) {
|
|
479
469
|
prevSub.A = nextSub;
|
|
480
470
|
} else {
|
|
481
|
-
dep.
|
|
471
|
+
dep.x = nextSub;
|
|
472
|
+
if (nextSub === null) {
|
|
473
|
+
dep.ta?.();
|
|
474
|
+
dep.H && unobserved(dep);
|
|
475
|
+
}
|
|
482
476
|
}
|
|
483
477
|
return nextDep;
|
|
484
478
|
}
|
|
479
|
+
function unobserved(el) {
|
|
480
|
+
deleteFromHeap(el, el.b & 32 /* Zombie */ ? zombieQueue : dirtyQueue);
|
|
481
|
+
let dep = el.l;
|
|
482
|
+
while (dep !== null) {
|
|
483
|
+
dep = unlinkSubs(dep);
|
|
484
|
+
}
|
|
485
|
+
el.l = null;
|
|
486
|
+
runDisposal(el);
|
|
487
|
+
}
|
|
485
488
|
function link(dep, sub) {
|
|
486
|
-
const prevDep = sub.
|
|
489
|
+
const prevDep = sub.F;
|
|
487
490
|
if (prevDep !== null && prevDep.R === dep) {
|
|
488
491
|
return;
|
|
489
492
|
}
|
|
490
493
|
let nextDep = null;
|
|
491
494
|
const isRecomputing = sub.b & 4 /* RecomputingDeps */;
|
|
492
495
|
if (isRecomputing) {
|
|
493
|
-
nextDep = prevDep !== null ? prevDep.
|
|
496
|
+
nextDep = prevDep !== null ? prevDep.E : sub.l;
|
|
494
497
|
if (nextDep !== null && nextDep.R === dep) {
|
|
495
|
-
sub.
|
|
498
|
+
sub.F = nextDep;
|
|
496
499
|
return;
|
|
497
500
|
}
|
|
498
501
|
}
|
|
@@ -500,28 +503,28 @@ function link(dep, sub) {
|
|
|
500
503
|
if (prevSub !== null && prevSub.j === sub && (!isRecomputing || isValidLink(prevSub, sub))) {
|
|
501
504
|
return;
|
|
502
505
|
}
|
|
503
|
-
const newLink = sub.
|
|
506
|
+
const newLink = sub.F = dep.W = {
|
|
504
507
|
R: dep,
|
|
505
508
|
j: sub,
|
|
506
|
-
|
|
507
|
-
|
|
509
|
+
E: nextDep,
|
|
510
|
+
na: prevSub,
|
|
508
511
|
A: null
|
|
509
512
|
};
|
|
510
513
|
if (prevDep !== null) {
|
|
511
|
-
prevDep.
|
|
514
|
+
prevDep.E = newLink;
|
|
512
515
|
} else {
|
|
513
|
-
sub.
|
|
516
|
+
sub.l = newLink;
|
|
514
517
|
}
|
|
515
518
|
if (prevSub !== null) {
|
|
516
519
|
prevSub.A = newLink;
|
|
517
520
|
} else {
|
|
518
|
-
dep.
|
|
521
|
+
dep.x = newLink;
|
|
519
522
|
}
|
|
520
523
|
}
|
|
521
524
|
function isValidLink(checkLink, sub) {
|
|
522
|
-
const depsTail = sub.
|
|
525
|
+
const depsTail = sub.F;
|
|
523
526
|
if (depsTail !== null) {
|
|
524
|
-
let link2 = sub.
|
|
527
|
+
let link2 = sub.l;
|
|
525
528
|
do {
|
|
526
529
|
if (link2 === checkLink) {
|
|
527
530
|
return true;
|
|
@@ -529,14 +532,14 @@ function isValidLink(checkLink, sub) {
|
|
|
529
532
|
if (link2 === depsTail) {
|
|
530
533
|
break;
|
|
531
534
|
}
|
|
532
|
-
link2 = link2.
|
|
535
|
+
link2 = link2.E;
|
|
533
536
|
} while (link2 !== null);
|
|
534
537
|
}
|
|
535
538
|
return false;
|
|
536
539
|
}
|
|
537
540
|
function setStatusFlags(signal2, flags, error = null) {
|
|
538
541
|
signal2.f = flags;
|
|
539
|
-
signal2.
|
|
542
|
+
signal2.B = error;
|
|
540
543
|
}
|
|
541
544
|
function setError(signal2, error) {
|
|
542
545
|
setStatusFlags(signal2, 2 /* Error */, error);
|
|
@@ -545,7 +548,7 @@ function clearStatusFlags(signal2) {
|
|
|
545
548
|
setStatusFlags(signal2, 0 /* None */);
|
|
546
549
|
}
|
|
547
550
|
function markDisposal(el) {
|
|
548
|
-
let child = el.
|
|
551
|
+
let child = el.r;
|
|
549
552
|
while (child) {
|
|
550
553
|
child.b |= 32 /* Zombie */;
|
|
551
554
|
const inHeap = child.b & 8 /* InHeap */;
|
|
@@ -557,23 +560,32 @@ function markDisposal(el) {
|
|
|
557
560
|
child = child.M;
|
|
558
561
|
}
|
|
559
562
|
}
|
|
563
|
+
function dispose(node) {
|
|
564
|
+
let toRemove = node.l || null;
|
|
565
|
+
do {
|
|
566
|
+
toRemove = unlinkSubs(toRemove);
|
|
567
|
+
} while (toRemove !== null);
|
|
568
|
+
node.l = null;
|
|
569
|
+
node.F = null;
|
|
570
|
+
disposeChildren(node, true);
|
|
571
|
+
}
|
|
560
572
|
function disposeChildren(node, self = false, zombie) {
|
|
561
573
|
if (node.b & 64 /* Disposed */)
|
|
562
574
|
return;
|
|
563
575
|
if (self)
|
|
564
576
|
node.b = 64 /* Disposed */;
|
|
565
|
-
let child = zombie ? node.U : node.
|
|
577
|
+
let child = zombie ? node.U : node.r;
|
|
566
578
|
while (child) {
|
|
567
579
|
const nextChild = child.M;
|
|
568
|
-
if (child.
|
|
580
|
+
if (child.l) {
|
|
569
581
|
const n = child;
|
|
570
582
|
deleteFromHeap(n, n.b & 32 /* Zombie */ ? zombieQueue : dirtyQueue);
|
|
571
|
-
let toRemove = n.
|
|
583
|
+
let toRemove = n.l;
|
|
572
584
|
do {
|
|
573
585
|
toRemove = unlinkSubs(toRemove);
|
|
574
586
|
} while (toRemove !== null);
|
|
575
|
-
n.
|
|
576
|
-
n.
|
|
587
|
+
n.l = null;
|
|
588
|
+
n.F = null;
|
|
577
589
|
}
|
|
578
590
|
disposeChildren(child, true);
|
|
579
591
|
child = nextChild;
|
|
@@ -581,7 +593,7 @@ function disposeChildren(node, self = false, zombie) {
|
|
|
581
593
|
if (zombie) {
|
|
582
594
|
node.U = null;
|
|
583
595
|
} else {
|
|
584
|
-
node.
|
|
596
|
+
node.r = null;
|
|
585
597
|
node.M = null;
|
|
586
598
|
}
|
|
587
599
|
runDisposal(node, zombie);
|
|
@@ -602,16 +614,16 @@ function runDisposal(node, zombie) {
|
|
|
602
614
|
}
|
|
603
615
|
function withOptions(obj, options) {
|
|
604
616
|
obj.id = options?.id ?? (context?.id != null ? getNextChildId(context) : void 0);
|
|
605
|
-
obj.
|
|
606
|
-
obj.
|
|
607
|
-
obj.
|
|
608
|
-
if (options?.
|
|
609
|
-
Object.assign(obj, options.
|
|
617
|
+
obj.fa = options?.equals != null ? options.equals : isEqual;
|
|
618
|
+
obj.za = !!options?.pureWrite;
|
|
619
|
+
obj.ta = options?.unobserved;
|
|
620
|
+
if (options?.ka)
|
|
621
|
+
Object.assign(obj, options.ka);
|
|
610
622
|
return obj;
|
|
611
623
|
}
|
|
612
624
|
function getNextChildId(owner) {
|
|
613
625
|
if (owner.id != null)
|
|
614
|
-
return formatId(owner.id, owner.
|
|
626
|
+
return formatId(owner.id, owner.oa++);
|
|
615
627
|
throw new Error("Cannot get child id from owner without an id");
|
|
616
628
|
}
|
|
617
629
|
function formatId(prefix, id) {
|
|
@@ -623,21 +635,21 @@ function computed(fn, initialValue, options) {
|
|
|
623
635
|
{
|
|
624
636
|
t: null,
|
|
625
637
|
i: globalQueue,
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
638
|
+
D: defaultContext,
|
|
639
|
+
oa: 0,
|
|
640
|
+
H: fn,
|
|
629
641
|
g: initialValue,
|
|
630
642
|
c: 0,
|
|
631
|
-
|
|
643
|
+
ca: null,
|
|
632
644
|
Q: void 0,
|
|
633
645
|
z: null,
|
|
646
|
+
l: null,
|
|
647
|
+
F: null,
|
|
634
648
|
x: null,
|
|
635
|
-
I: null,
|
|
636
|
-
s: null,
|
|
637
649
|
W: null,
|
|
638
650
|
w: context,
|
|
639
651
|
M: null,
|
|
640
|
-
|
|
652
|
+
r: null,
|
|
641
653
|
b: 0 /* None */,
|
|
642
654
|
f: 4 /* Uninitialized */,
|
|
643
655
|
J: clock,
|
|
@@ -648,16 +660,16 @@ function computed(fn, initialValue, options) {
|
|
|
648
660
|
options
|
|
649
661
|
);
|
|
650
662
|
self.z = self;
|
|
651
|
-
const parent = context
|
|
663
|
+
const parent = context?.$ ? context.aa : context;
|
|
652
664
|
if (context) {
|
|
653
665
|
context.i && (self.i = context.i);
|
|
654
|
-
context.
|
|
655
|
-
const lastChild = context.
|
|
666
|
+
context.D && (self.D = context.D);
|
|
667
|
+
const lastChild = context.r;
|
|
656
668
|
if (lastChild === null) {
|
|
657
|
-
context.
|
|
669
|
+
context.r = self;
|
|
658
670
|
} else {
|
|
659
671
|
self.M = lastChild;
|
|
660
|
-
context.
|
|
672
|
+
context.r = self;
|
|
661
673
|
}
|
|
662
674
|
}
|
|
663
675
|
if (parent)
|
|
@@ -720,7 +732,7 @@ function asyncComputed(asyncFn, initialValue, options) {
|
|
|
720
732
|
throw new NotReadyError(context);
|
|
721
733
|
};
|
|
722
734
|
const self = computed(fn, initialValue, options);
|
|
723
|
-
self.
|
|
735
|
+
self.ua = () => {
|
|
724
736
|
refreshing = true;
|
|
725
737
|
recompute(self);
|
|
726
738
|
flush();
|
|
@@ -729,13 +741,13 @@ function asyncComputed(asyncFn, initialValue, options) {
|
|
|
729
741
|
}
|
|
730
742
|
function signal(v, options, firewall = null) {
|
|
731
743
|
if (firewall !== null) {
|
|
732
|
-
return firewall.
|
|
744
|
+
return firewall.ca = withOptions(
|
|
733
745
|
{
|
|
734
746
|
g: v,
|
|
735
|
-
|
|
747
|
+
x: null,
|
|
736
748
|
W: null,
|
|
737
|
-
|
|
738
|
-
|
|
749
|
+
ia: firewall,
|
|
750
|
+
sa: firewall.ca,
|
|
739
751
|
f: 0 /* None */,
|
|
740
752
|
J: clock,
|
|
741
753
|
e: NOT_PENDING
|
|
@@ -746,7 +758,7 @@ function signal(v, options, firewall = null) {
|
|
|
746
758
|
return withOptions(
|
|
747
759
|
{
|
|
748
760
|
g: v,
|
|
749
|
-
|
|
761
|
+
x: null,
|
|
750
762
|
W: null,
|
|
751
763
|
f: 0 /* None */,
|
|
752
764
|
J: clock,
|
|
@@ -771,14 +783,14 @@ function untrack(fn) {
|
|
|
771
783
|
}
|
|
772
784
|
function read(el) {
|
|
773
785
|
let c = context;
|
|
774
|
-
if (c
|
|
775
|
-
c = c
|
|
786
|
+
if (c?.$)
|
|
787
|
+
c = c.aa;
|
|
776
788
|
if (c && tracking) {
|
|
777
789
|
link(el, c);
|
|
778
|
-
const owner =
|
|
779
|
-
if (
|
|
790
|
+
const owner = el.ia || el;
|
|
791
|
+
if (owner.H) {
|
|
780
792
|
const isZombie = el.b & 32 /* Zombie */;
|
|
781
|
-
if (owner.c >= (isZombie ? zombieQueue.
|
|
793
|
+
if (owner.c >= (isZombie ? zombieQueue.q : dirtyQueue.q)) {
|
|
782
794
|
markNode(c);
|
|
783
795
|
markHeap(isZombie ? zombieQueue : dirtyQueue);
|
|
784
796
|
updateIfNecessary(owner);
|
|
@@ -791,40 +803,40 @@ function read(el) {
|
|
|
791
803
|
}
|
|
792
804
|
if (pendingCheck) {
|
|
793
805
|
const pendingResult = (el.f & 1 /* Pending */) !== 0 || !!el.T || false;
|
|
794
|
-
if (!el.
|
|
795
|
-
el.
|
|
796
|
-
el.
|
|
797
|
-
el.
|
|
806
|
+
if (!el.I) {
|
|
807
|
+
el.I = signal(pendingResult);
|
|
808
|
+
el.I.ja = true;
|
|
809
|
+
el.I.ea = (v) => setSignal(el.I, v);
|
|
798
810
|
}
|
|
799
811
|
const prev = pendingCheck;
|
|
800
812
|
pendingCheck = null;
|
|
801
|
-
read(el.
|
|
813
|
+
read(el.I);
|
|
802
814
|
pendingCheck = prev;
|
|
803
815
|
prev.g = pendingResult || prev.g;
|
|
804
816
|
}
|
|
805
817
|
if (pendingValueCheck) {
|
|
806
|
-
if (!el.
|
|
807
|
-
el.
|
|
818
|
+
if (!el.C) {
|
|
819
|
+
el.C = signal(
|
|
808
820
|
el.e === NOT_PENDING ? el.g : el.e
|
|
809
821
|
);
|
|
810
|
-
el.
|
|
811
|
-
el.
|
|
822
|
+
el.C.ja = true;
|
|
823
|
+
el.C.ea = (v) => queueMicrotask(() => queueMicrotask(() => setSignal(el.C, v)));
|
|
812
824
|
}
|
|
813
825
|
pendingValueCheck = false;
|
|
814
826
|
try {
|
|
815
|
-
return read(el.
|
|
827
|
+
return read(el.C);
|
|
816
828
|
} finally {
|
|
817
829
|
pendingValueCheck = true;
|
|
818
830
|
}
|
|
819
831
|
}
|
|
820
832
|
if (el.f & 1 /* Pending */) {
|
|
821
833
|
if (c && !stale || el.f & 4 /* Uninitialized */)
|
|
822
|
-
throw el.
|
|
834
|
+
throw el.B;
|
|
823
835
|
else if (c && stale && !pendingCheck) {
|
|
824
836
|
setStatusFlags(
|
|
825
837
|
c,
|
|
826
838
|
c.f | 1,
|
|
827
|
-
el.
|
|
839
|
+
el.B
|
|
828
840
|
);
|
|
829
841
|
}
|
|
830
842
|
}
|
|
@@ -833,7 +845,7 @@ function read(el) {
|
|
|
833
845
|
recompute(el, true);
|
|
834
846
|
return read(el);
|
|
835
847
|
} else {
|
|
836
|
-
throw el.
|
|
848
|
+
throw el.B;
|
|
837
849
|
}
|
|
838
850
|
}
|
|
839
851
|
return !c || el.e === NOT_PENDING || stale && !pendingCheck && el.T && activeTransition !== el.T ? el.g : el.e;
|
|
@@ -844,19 +856,19 @@ function setSignal(el, v) {
|
|
|
844
856
|
el.e === NOT_PENDING ? el.g : el.e
|
|
845
857
|
);
|
|
846
858
|
}
|
|
847
|
-
const valueChanged = !el.
|
|
859
|
+
const valueChanged = !el.fa || !el.fa(el.e === NOT_PENDING ? el.g : el.e, v);
|
|
848
860
|
if (!valueChanged && !el.f)
|
|
849
861
|
return v;
|
|
850
862
|
if (valueChanged) {
|
|
851
|
-
if (el.
|
|
863
|
+
if (el.ja)
|
|
852
864
|
el.g = v;
|
|
853
865
|
else {
|
|
854
866
|
if (el.e === NOT_PENDING)
|
|
855
867
|
globalQueue.h.push(el);
|
|
856
868
|
el.e = v;
|
|
857
869
|
}
|
|
858
|
-
if (el.
|
|
859
|
-
el.
|
|
870
|
+
if (el.C)
|
|
871
|
+
el.C.ea(v);
|
|
860
872
|
}
|
|
861
873
|
clearStatusFlags(el);
|
|
862
874
|
el.J = clock;
|
|
@@ -886,15 +898,15 @@ function onCleanup(fn) {
|
|
|
886
898
|
function createOwner(options) {
|
|
887
899
|
const parent = context;
|
|
888
900
|
const owner = {
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
901
|
+
$: true,
|
|
902
|
+
aa: parent?.$ ? parent.aa : parent,
|
|
903
|
+
r: null,
|
|
892
904
|
M: null,
|
|
893
905
|
t: null,
|
|
894
906
|
id: options?.id ?? (parent?.id != null ? getNextChildId(parent) : void 0),
|
|
895
907
|
i: parent?.i ?? globalQueue,
|
|
896
|
-
|
|
897
|
-
|
|
908
|
+
D: parent?.D || defaultContext,
|
|
909
|
+
oa: 0,
|
|
898
910
|
V: null,
|
|
899
911
|
U: null,
|
|
900
912
|
w: parent,
|
|
@@ -903,12 +915,12 @@ function createOwner(options) {
|
|
|
903
915
|
}
|
|
904
916
|
};
|
|
905
917
|
if (parent) {
|
|
906
|
-
const lastChild = parent.
|
|
918
|
+
const lastChild = parent.r;
|
|
907
919
|
if (lastChild === null) {
|
|
908
|
-
parent.
|
|
920
|
+
parent.r = owner;
|
|
909
921
|
} else {
|
|
910
922
|
owner.M = lastChild;
|
|
911
|
-
parent.
|
|
923
|
+
parent.r = owner;
|
|
912
924
|
}
|
|
913
925
|
}
|
|
914
926
|
return owner;
|
|
@@ -969,7 +981,7 @@ function getContext(context2, owner = getOwner()) {
|
|
|
969
981
|
if (!owner) {
|
|
970
982
|
throw new NoOwnerError();
|
|
971
983
|
}
|
|
972
|
-
const value = hasContext(context2, owner) ? owner.
|
|
984
|
+
const value = hasContext(context2, owner) ? owner.D[context2.id] : context2.defaultValue;
|
|
973
985
|
if (isUndefined(value)) {
|
|
974
986
|
throw new ContextNotFoundError();
|
|
975
987
|
}
|
|
@@ -979,13 +991,13 @@ function setContext(context2, value, owner = getOwner()) {
|
|
|
979
991
|
if (!owner) {
|
|
980
992
|
throw new NoOwnerError();
|
|
981
993
|
}
|
|
982
|
-
owner.
|
|
983
|
-
...owner.
|
|
994
|
+
owner.D = {
|
|
995
|
+
...owner.D,
|
|
984
996
|
[context2.id]: isUndefined(value) ? context2.defaultValue : value
|
|
985
997
|
};
|
|
986
998
|
}
|
|
987
999
|
function hasContext(context2, owner) {
|
|
988
|
-
return !isUndefined(owner?.
|
|
1000
|
+
return !isUndefined(owner?.D[context2.id]);
|
|
989
1001
|
}
|
|
990
1002
|
function isUndefined(value) {
|
|
991
1003
|
return typeof value === "undefined";
|
|
@@ -996,27 +1008,27 @@ function effect(compute, effect2, error, initialValue, options) {
|
|
|
996
1008
|
let initialized = false;
|
|
997
1009
|
const node = computed(compute, initialValue, {
|
|
998
1010
|
...options,
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1011
|
+
ka: {
|
|
1012
|
+
ga: true,
|
|
1013
|
+
pa: initialValue,
|
|
1014
|
+
va: effect2,
|
|
1015
|
+
qa: error,
|
|
1004
1016
|
N: void 0,
|
|
1005
1017
|
i: getOwner()?.i ?? globalQueue,
|
|
1006
1018
|
K: options?.render ? 1 /* Render */ : 2 /* User */,
|
|
1007
|
-
|
|
1019
|
+
ma(statusFlagsChanged, prevStatusFlags) {
|
|
1008
1020
|
if (initialized) {
|
|
1009
1021
|
const errorChanged = this.f && this.f === prevStatusFlags && statusFlagsChanged;
|
|
1010
|
-
this.
|
|
1011
|
-
if (this.
|
|
1022
|
+
this.ga = !(this.f & 2 /* Error */) && !(this.f & 1 /* Pending */ & ~prevStatusFlags) && !errorChanged;
|
|
1023
|
+
if (this.ga)
|
|
1012
1024
|
this.i.enqueue(this.K, runEffect.bind(this));
|
|
1013
1025
|
}
|
|
1014
1026
|
if (this.f & 2 /* Error */) {
|
|
1015
|
-
let error2 = this.
|
|
1027
|
+
let error2 = this.B;
|
|
1016
1028
|
this.i.notify(this, 1 /* Pending */, 0);
|
|
1017
1029
|
if (this.K === 2 /* User */) {
|
|
1018
1030
|
try {
|
|
1019
|
-
return this.
|
|
1031
|
+
return this.qa ? this.qa(error2, () => {
|
|
1020
1032
|
this.N?.();
|
|
1021
1033
|
this.N = void 0;
|
|
1022
1034
|
}) : console.error(error2);
|
|
@@ -1038,23 +1050,23 @@ function effect(compute, effect2, error, initialValue, options) {
|
|
|
1038
1050
|
});
|
|
1039
1051
|
initialized = true;
|
|
1040
1052
|
if (node.K === 1 /* Render */)
|
|
1041
|
-
node.
|
|
1053
|
+
node.H = (p) => staleValues(() => compute(p));
|
|
1042
1054
|
!options?.defer && !(node.f & (2 /* Error */ | 1 /* Pending */)) && (node.K === 2 /* User */ ? node.i.enqueue(node.K, runEffect.bind(node)) : runEffect.call(node));
|
|
1043
1055
|
onCleanup(() => node.N?.());
|
|
1044
1056
|
}
|
|
1045
1057
|
function runEffect() {
|
|
1046
|
-
if (!this.
|
|
1058
|
+
if (!this.ga || this.b & 64 /* Disposed */)
|
|
1047
1059
|
return;
|
|
1048
1060
|
this.N?.();
|
|
1049
1061
|
this.N = void 0;
|
|
1050
1062
|
try {
|
|
1051
|
-
this.N = this.
|
|
1063
|
+
this.N = this.va(this.g, this.pa);
|
|
1052
1064
|
} catch (error) {
|
|
1053
1065
|
if (!this.i.notify(this, 2 /* Error */, 2 /* Error */))
|
|
1054
1066
|
throw error;
|
|
1055
1067
|
} finally {
|
|
1056
|
-
this.
|
|
1057
|
-
this.
|
|
1068
|
+
this.pa = this.g;
|
|
1069
|
+
this.ga = false;
|
|
1058
1070
|
}
|
|
1059
1071
|
}
|
|
1060
1072
|
|
|
@@ -1085,7 +1097,7 @@ function createMemo(compute, value, options) {
|
|
|
1085
1097
|
function createAsync(compute, value, options) {
|
|
1086
1098
|
const node = asyncComputed(compute, value, options);
|
|
1087
1099
|
const ret = read.bind(null, node);
|
|
1088
|
-
ret.refresh = node.
|
|
1100
|
+
ret.refresh = node.ua;
|
|
1089
1101
|
return ret;
|
|
1090
1102
|
}
|
|
1091
1103
|
function createEffect(compute, effectFn, value, options) {
|
|
@@ -1105,11 +1117,29 @@ function createRenderEffect(compute, effectFn, value, options) {
|
|
|
1105
1117
|
}
|
|
1106
1118
|
function createTrackedEffect(compute, options) {
|
|
1107
1119
|
}
|
|
1108
|
-
function createReaction(
|
|
1120
|
+
function createReaction(effectFn, options) {
|
|
1121
|
+
let cleanup = void 0;
|
|
1122
|
+
onCleanup(() => cleanup?.());
|
|
1123
|
+
return (tracking2) => {
|
|
1124
|
+
effect(
|
|
1125
|
+
() => (tracking2(), getOwner()),
|
|
1126
|
+
(node) => {
|
|
1127
|
+
cleanup?.();
|
|
1128
|
+
cleanup = (effectFn.effect || effectFn)?.();
|
|
1129
|
+
dispose(node);
|
|
1130
|
+
},
|
|
1131
|
+
effectFn.error,
|
|
1132
|
+
void 0,
|
|
1133
|
+
{
|
|
1134
|
+
defer: true,
|
|
1135
|
+
...options
|
|
1136
|
+
}
|
|
1137
|
+
);
|
|
1138
|
+
};
|
|
1109
1139
|
}
|
|
1110
1140
|
function resolve(fn) {
|
|
1111
1141
|
return new Promise((res, rej) => {
|
|
1112
|
-
createRoot((
|
|
1142
|
+
createRoot((dispose2) => {
|
|
1113
1143
|
computed(() => {
|
|
1114
1144
|
try {
|
|
1115
1145
|
res(fn());
|
|
@@ -1118,7 +1148,7 @@ function resolve(fn) {
|
|
|
1118
1148
|
throw err;
|
|
1119
1149
|
rej(err);
|
|
1120
1150
|
}
|
|
1121
|
-
|
|
1151
|
+
dispose2();
|
|
1122
1152
|
});
|
|
1123
1153
|
});
|
|
1124
1154
|
});
|
|
@@ -1127,6 +1157,14 @@ function createOptimistic(first, second, third) {
|
|
|
1127
1157
|
return {};
|
|
1128
1158
|
}
|
|
1129
1159
|
function onSettled(callback) {
|
|
1160
|
+
let cleanup;
|
|
1161
|
+
const o = getOwner();
|
|
1162
|
+
if (o)
|
|
1163
|
+
onCleanup(() => cleanup?.());
|
|
1164
|
+
globalQueue.enqueue(2 /* User */, () => {
|
|
1165
|
+
cleanup = callback();
|
|
1166
|
+
!o && cleanup?.();
|
|
1167
|
+
});
|
|
1130
1168
|
}
|
|
1131
1169
|
|
|
1132
1170
|
// src/store/reconcile.ts
|
|
@@ -1262,23 +1300,17 @@ function reconcile(value, key, all = false) {
|
|
|
1262
1300
|
function createProjectionInternal(fn, initialValue = {}, options) {
|
|
1263
1301
|
let node;
|
|
1264
1302
|
const wrappedMap = /* @__PURE__ */ new WeakMap();
|
|
1265
|
-
const traps = {
|
|
1266
|
-
...storeTraps,
|
|
1267
|
-
get(target, property, receiver) {
|
|
1268
|
-
const o = getOwner();
|
|
1269
|
-
const n = node;
|
|
1270
|
-
(!o || o !== n) && n && read(n);
|
|
1271
|
-
return storeTraps.get(target, property, receiver);
|
|
1272
|
-
}
|
|
1273
|
-
};
|
|
1274
1303
|
const wrapProjection = (source) => {
|
|
1275
1304
|
if (wrappedMap.has(source))
|
|
1276
1305
|
return wrappedMap.get(source);
|
|
1277
1306
|
if (source[$TARGET]?.[STORE_WRAP] === wrapProjection)
|
|
1278
1307
|
return source;
|
|
1279
|
-
const wrapped = createStoreProxy(source,
|
|
1308
|
+
const wrapped = createStoreProxy(source, storeTraps, {
|
|
1280
1309
|
[STORE_WRAP]: wrapProjection,
|
|
1281
|
-
[STORE_LOOKUP]: wrappedMap
|
|
1310
|
+
[STORE_LOOKUP]: wrappedMap,
|
|
1311
|
+
[STORE_FIREWALL]() {
|
|
1312
|
+
return node;
|
|
1313
|
+
}
|
|
1282
1314
|
});
|
|
1283
1315
|
wrappedMap.set(source, wrapped);
|
|
1284
1316
|
return wrapped;
|
|
@@ -1311,6 +1343,7 @@ var STORE_NODE = "n";
|
|
|
1311
1343
|
var STORE_HAS = "h";
|
|
1312
1344
|
var STORE_WRAP = "w";
|
|
1313
1345
|
var STORE_LOOKUP = "l";
|
|
1346
|
+
var STORE_FIREWALL = "f";
|
|
1314
1347
|
function createStoreProxy(value, traps = storeTraps, extend) {
|
|
1315
1348
|
let newTarget;
|
|
1316
1349
|
if (Array.isArray(value)) {
|
|
@@ -1339,18 +1372,24 @@ function getNodes(target, type) {
|
|
|
1339
1372
|
target[type] = nodes = /* @__PURE__ */ Object.create(null);
|
|
1340
1373
|
return nodes;
|
|
1341
1374
|
}
|
|
1342
|
-
function getNode(nodes, property, value, equals = isEqual) {
|
|
1375
|
+
function getNode(nodes, property, value, firewall, equals = isEqual) {
|
|
1343
1376
|
if (nodes[property])
|
|
1344
1377
|
return nodes[property];
|
|
1345
|
-
return nodes[property] = signal(
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1378
|
+
return nodes[property] = signal(
|
|
1379
|
+
value,
|
|
1380
|
+
{
|
|
1381
|
+
equals,
|
|
1382
|
+
unobserved() {
|
|
1383
|
+
delete nodes[property];
|
|
1384
|
+
}
|
|
1385
|
+
},
|
|
1386
|
+
firewall
|
|
1387
|
+
);
|
|
1351
1388
|
}
|
|
1352
1389
|
function trackSelf(target, symbol = $TRACK) {
|
|
1353
|
-
getObserver() && read(
|
|
1390
|
+
getObserver() && read(
|
|
1391
|
+
getNode(getNodes(target, STORE_NODE), symbol, void 0, target[STORE_FIREWALL]?.(), false)
|
|
1392
|
+
);
|
|
1354
1393
|
}
|
|
1355
1394
|
function getKeys(source, override, enumerable = true) {
|
|
1356
1395
|
const baseKeys = untrack(() => enumerable ? Object.keys(source) : Reflect.ownKeys(source));
|
|
@@ -1413,7 +1452,14 @@ var storeTraps = {
|
|
|
1413
1452
|
let proto;
|
|
1414
1453
|
return !Array.isArray(target[STORE_VALUE]) && (proto = Object.getPrototypeOf(target[STORE_VALUE])) && proto !== Object.prototype ? value.bind(storeValue) : value;
|
|
1415
1454
|
} else if (getObserver()) {
|
|
1416
|
-
return read(
|
|
1455
|
+
return read(
|
|
1456
|
+
getNode(
|
|
1457
|
+
nodes,
|
|
1458
|
+
property,
|
|
1459
|
+
isWrappable(value) ? wrap(value, target) : value,
|
|
1460
|
+
target[STORE_FIREWALL]?.()
|
|
1461
|
+
)
|
|
1462
|
+
);
|
|
1417
1463
|
}
|
|
1418
1464
|
}
|
|
1419
1465
|
return isWrappable(value) ? wrap(value, target) : value;
|
|
@@ -1422,7 +1468,7 @@ var storeTraps = {
|
|
|
1422
1468
|
if (property === $PROXY || property === $TRACK || property === "__proto__")
|
|
1423
1469
|
return true;
|
|
1424
1470
|
const has = target[STORE_OVERRIDE] && property in target[STORE_OVERRIDE] ? target[STORE_OVERRIDE][property] !== $DELETED : property in target[STORE_VALUE];
|
|
1425
|
-
getObserver() && read(getNode(getNodes(target, STORE_HAS), property, has));
|
|
1471
|
+
getObserver() && read(getNode(getNodes(target, STORE_HAS), property, has, target[STORE_FIREWALL]?.()));
|
|
1426
1472
|
return has;
|
|
1427
1473
|
},
|
|
1428
1474
|
set(target, property, rawValue) {
|
|
@@ -1797,60 +1843,60 @@ function mapArray(list, map, options) {
|
|
|
1797
1843
|
const keyFn = typeof options?.keyed === "function" ? options.keyed : void 0;
|
|
1798
1844
|
return createMemo(
|
|
1799
1845
|
updateKeyedMap.bind({
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1846
|
+
X: createOwner(),
|
|
1847
|
+
n: 0,
|
|
1848
|
+
wa: list,
|
|
1803
1849
|
G: [],
|
|
1804
1850
|
O: map,
|
|
1805
1851
|
d: [],
|
|
1806
1852
|
a: [],
|
|
1807
1853
|
P: keyFn,
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1854
|
+
o: keyFn || options?.keyed === false ? [] : void 0,
|
|
1855
|
+
p: map.length > 1 ? [] : void 0,
|
|
1856
|
+
Y: options?.fallback
|
|
1811
1857
|
})
|
|
1812
1858
|
);
|
|
1813
1859
|
}
|
|
1814
1860
|
var pureOptions = { pureWrite: true };
|
|
1815
1861
|
function updateKeyedMap() {
|
|
1816
|
-
const newItems = this.
|
|
1862
|
+
const newItems = this.wa() || [], newLen = newItems.length;
|
|
1817
1863
|
newItems[$TRACK];
|
|
1818
|
-
runWithOwner(this.
|
|
1819
|
-
let i, j, mapper = this.
|
|
1820
|
-
this.
|
|
1821
|
-
this.
|
|
1864
|
+
runWithOwner(this.X, () => {
|
|
1865
|
+
let i, j, mapper = this.o ? () => {
|
|
1866
|
+
this.o[j] = signal(newItems[j], pureOptions);
|
|
1867
|
+
this.p && (this.p[j] = signal(j, pureOptions));
|
|
1822
1868
|
return this.O(
|
|
1823
|
-
read.bind(null, this.
|
|
1824
|
-
this.
|
|
1869
|
+
read.bind(null, this.o[j]),
|
|
1870
|
+
this.p ? read.bind(null, this.p[j]) : void 0
|
|
1825
1871
|
);
|
|
1826
|
-
} : this.
|
|
1872
|
+
} : this.p ? () => {
|
|
1827
1873
|
const item = newItems[j];
|
|
1828
|
-
this.
|
|
1874
|
+
this.p[j] = signal(j, pureOptions);
|
|
1829
1875
|
return this.O(
|
|
1830
1876
|
() => item,
|
|
1831
|
-
read.bind(null, this.
|
|
1877
|
+
read.bind(null, this.p[j])
|
|
1832
1878
|
);
|
|
1833
1879
|
} : () => {
|
|
1834
1880
|
const item = newItems[j];
|
|
1835
1881
|
return this.O(() => item);
|
|
1836
1882
|
};
|
|
1837
1883
|
if (newLen === 0) {
|
|
1838
|
-
if (this.
|
|
1839
|
-
this.
|
|
1884
|
+
if (this.n !== 0) {
|
|
1885
|
+
this.X.dispose(false);
|
|
1840
1886
|
this.a = [];
|
|
1841
1887
|
this.G = [];
|
|
1842
1888
|
this.d = [];
|
|
1843
|
-
this.
|
|
1844
|
-
this.n && (this.n = []);
|
|
1889
|
+
this.n = 0;
|
|
1845
1890
|
this.o && (this.o = []);
|
|
1891
|
+
this.p && (this.p = []);
|
|
1846
1892
|
}
|
|
1847
|
-
if (this.
|
|
1893
|
+
if (this.Y && !this.d[0]) {
|
|
1848
1894
|
this.d[0] = runWithOwner(
|
|
1849
1895
|
this.a[0] = createOwner(),
|
|
1850
|
-
this.
|
|
1896
|
+
this.Y
|
|
1851
1897
|
);
|
|
1852
1898
|
}
|
|
1853
|
-
} else if (this.
|
|
1899
|
+
} else if (this.n === 0) {
|
|
1854
1900
|
if (this.a[0])
|
|
1855
1901
|
this.a[0].dispose();
|
|
1856
1902
|
this.d = new Array(newLen);
|
|
@@ -1858,18 +1904,18 @@ function updateKeyedMap() {
|
|
|
1858
1904
|
this.G[j] = newItems[j];
|
|
1859
1905
|
this.d[j] = runWithOwner(this.a[j] = createOwner(), mapper);
|
|
1860
1906
|
}
|
|
1861
|
-
this.
|
|
1907
|
+
this.n = newLen;
|
|
1862
1908
|
} else {
|
|
1863
|
-
let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.
|
|
1864
|
-
for (start = 0, end = Math.min(this.
|
|
1865
|
-
if (this.
|
|
1866
|
-
setSignal(this.
|
|
1909
|
+
let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.o ? new Array(newLen) : void 0, tempIndexes = this.p ? new Array(newLen) : void 0;
|
|
1910
|
+
for (start = 0, end = Math.min(this.n, newLen); start < end && (this.G[start] === newItems[start] || this.o && compare(this.P, this.G[start], newItems[start])); start++) {
|
|
1911
|
+
if (this.o)
|
|
1912
|
+
setSignal(this.o[start], newItems[start]);
|
|
1867
1913
|
}
|
|
1868
|
-
for (end = this.
|
|
1914
|
+
for (end = this.n - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.G[end] === newItems[newEnd] || this.o && compare(this.P, this.G[end], newItems[newEnd])); end--, newEnd--) {
|
|
1869
1915
|
temp[newEnd] = this.d[end];
|
|
1870
1916
|
tempNodes[newEnd] = this.a[end];
|
|
1871
|
-
tempRows && (tempRows[newEnd] = this.
|
|
1872
|
-
tempIndexes && (tempIndexes[newEnd] = this.
|
|
1917
|
+
tempRows && (tempRows[newEnd] = this.o[end]);
|
|
1918
|
+
tempIndexes && (tempIndexes[newEnd] = this.p[end]);
|
|
1873
1919
|
}
|
|
1874
1920
|
newIndices = /* @__PURE__ */ new Map();
|
|
1875
1921
|
newIndicesNext = new Array(newEnd + 1);
|
|
@@ -1887,8 +1933,8 @@ function updateKeyedMap() {
|
|
|
1887
1933
|
if (j !== void 0 && j !== -1) {
|
|
1888
1934
|
temp[j] = this.d[i];
|
|
1889
1935
|
tempNodes[j] = this.a[i];
|
|
1890
|
-
tempRows && (tempRows[j] = this.
|
|
1891
|
-
tempIndexes && (tempIndexes[j] = this.
|
|
1936
|
+
tempRows && (tempRows[j] = this.o[i]);
|
|
1937
|
+
tempIndexes && (tempIndexes[j] = this.p[i]);
|
|
1892
1938
|
j = newIndicesNext[j];
|
|
1893
1939
|
newIndices.set(key, j);
|
|
1894
1940
|
} else
|
|
@@ -1899,18 +1945,18 @@ function updateKeyedMap() {
|
|
|
1899
1945
|
this.d[j] = temp[j];
|
|
1900
1946
|
this.a[j] = tempNodes[j];
|
|
1901
1947
|
if (tempRows) {
|
|
1902
|
-
this.
|
|
1903
|
-
setSignal(this.
|
|
1948
|
+
this.o[j] = tempRows[j];
|
|
1949
|
+
setSignal(this.o[j], newItems[j]);
|
|
1904
1950
|
}
|
|
1905
1951
|
if (tempIndexes) {
|
|
1906
|
-
this.
|
|
1907
|
-
setSignal(this.
|
|
1952
|
+
this.p[j] = tempIndexes[j];
|
|
1953
|
+
setSignal(this.p[j], j);
|
|
1908
1954
|
}
|
|
1909
1955
|
} else {
|
|
1910
1956
|
this.d[j] = runWithOwner(this.a[j] = createOwner(), mapper);
|
|
1911
1957
|
}
|
|
1912
1958
|
}
|
|
1913
|
-
this.d = this.d.slice(0, this.
|
|
1959
|
+
this.d = this.d.slice(0, this.n = newLen);
|
|
1914
1960
|
this.G = newItems.slice(0);
|
|
1915
1961
|
}
|
|
1916
1962
|
});
|
|
@@ -1918,45 +1964,45 @@ function updateKeyedMap() {
|
|
|
1918
1964
|
}
|
|
1919
1965
|
function repeat(count, map, options) {
|
|
1920
1966
|
return updateRepeat.bind({
|
|
1921
|
-
|
|
1922
|
-
|
|
1967
|
+
X: createOwner(),
|
|
1968
|
+
n: 0,
|
|
1923
1969
|
y: 0,
|
|
1924
|
-
|
|
1970
|
+
xa: count,
|
|
1925
1971
|
O: map,
|
|
1926
1972
|
a: [],
|
|
1927
1973
|
d: [],
|
|
1928
|
-
|
|
1929
|
-
|
|
1974
|
+
ya: options?.from,
|
|
1975
|
+
Y: options?.fallback
|
|
1930
1976
|
});
|
|
1931
1977
|
}
|
|
1932
1978
|
function updateRepeat() {
|
|
1933
|
-
const newLen = this.
|
|
1934
|
-
const from = this.
|
|
1935
|
-
runWithOwner(this.
|
|
1979
|
+
const newLen = this.xa();
|
|
1980
|
+
const from = this.ya?.() || 0;
|
|
1981
|
+
runWithOwner(this.X, () => {
|
|
1936
1982
|
if (newLen === 0) {
|
|
1937
|
-
if (this.
|
|
1938
|
-
this.
|
|
1983
|
+
if (this.n !== 0) {
|
|
1984
|
+
this.X.dispose(false);
|
|
1939
1985
|
this.a = [];
|
|
1940
1986
|
this.d = [];
|
|
1941
|
-
this.
|
|
1987
|
+
this.n = 0;
|
|
1942
1988
|
}
|
|
1943
|
-
if (this.
|
|
1989
|
+
if (this.Y && !this.d[0]) {
|
|
1944
1990
|
this.d[0] = runWithOwner(
|
|
1945
1991
|
this.a[0] = createOwner(),
|
|
1946
|
-
this.
|
|
1992
|
+
this.Y
|
|
1947
1993
|
);
|
|
1948
1994
|
}
|
|
1949
1995
|
return;
|
|
1950
1996
|
}
|
|
1951
1997
|
const to = from + newLen;
|
|
1952
|
-
const prevTo = this.y + this.
|
|
1953
|
-
if (this.
|
|
1998
|
+
const prevTo = this.y + this.n;
|
|
1999
|
+
if (this.n === 0 && this.a[0])
|
|
1954
2000
|
this.a[0].dispose();
|
|
1955
2001
|
for (let i = to; i < prevTo; i++)
|
|
1956
2002
|
this.a[i - this.y].dispose();
|
|
1957
2003
|
if (this.y < from) {
|
|
1958
2004
|
let i = this.y;
|
|
1959
|
-
while (i < from && i < this.
|
|
2005
|
+
while (i < from && i < this.n)
|
|
1960
2006
|
this.a[i++].dispose();
|
|
1961
2007
|
this.a.splice(0, from - this.y);
|
|
1962
2008
|
this.d.splice(0, from - this.y);
|
|
@@ -1984,7 +2030,7 @@ function updateRepeat() {
|
|
|
1984
2030
|
}
|
|
1985
2031
|
this.d = this.d.slice(0, newLen);
|
|
1986
2032
|
this.y = from;
|
|
1987
|
-
this.
|
|
2033
|
+
this.n = newLen;
|
|
1988
2034
|
});
|
|
1989
2035
|
return this.d;
|
|
1990
2036
|
}
|
|
@@ -1995,19 +2041,19 @@ function compare(key, a, b) {
|
|
|
1995
2041
|
// src/boundaries.ts
|
|
1996
2042
|
function boundaryComputed(fn, propagationMask) {
|
|
1997
2043
|
const node = computed(fn, void 0, {
|
|
1998
|
-
|
|
1999
|
-
|
|
2044
|
+
ka: {
|
|
2045
|
+
ma() {
|
|
2000
2046
|
let flags = this.f;
|
|
2001
|
-
this.f &= ~this.
|
|
2002
|
-
if (this.
|
|
2047
|
+
this.f &= ~this.Z;
|
|
2048
|
+
if (this.Z & 1 /* Pending */ && !(this.f & 4 /* Uninitialized */)) {
|
|
2003
2049
|
flags &= ~1 /* Pending */;
|
|
2004
2050
|
}
|
|
2005
|
-
this.i.notify(this, this.
|
|
2051
|
+
this.i.notify(this, this.Z, flags);
|
|
2006
2052
|
},
|
|
2007
|
-
|
|
2053
|
+
Z: propagationMask
|
|
2008
2054
|
}
|
|
2009
2055
|
});
|
|
2010
|
-
node.
|
|
2056
|
+
node.Z = propagationMask;
|
|
2011
2057
|
return node;
|
|
2012
2058
|
}
|
|
2013
2059
|
function createBoundChildren(owner, fn, queue, mask) {
|
|
@@ -2021,7 +2067,7 @@ function createBoundChildren(owner, fn, queue, mask) {
|
|
|
2021
2067
|
}
|
|
2022
2068
|
var ConditionalQueue = class extends Queue {
|
|
2023
2069
|
u;
|
|
2024
|
-
|
|
2070
|
+
ha = /* @__PURE__ */ new Set();
|
|
2025
2071
|
h = /* @__PURE__ */ new Set();
|
|
2026
2072
|
constructor(disabled) {
|
|
2027
2073
|
super();
|
|
@@ -2043,9 +2089,9 @@ var ConditionalQueue = class extends Queue {
|
|
|
2043
2089
|
}
|
|
2044
2090
|
if (type & 2 /* Error */) {
|
|
2045
2091
|
if (flags & 2 /* Error */) {
|
|
2046
|
-
this.
|
|
2092
|
+
this.ha.add(node);
|
|
2047
2093
|
type &= ~2 /* Error */;
|
|
2048
|
-
} else if (this.
|
|
2094
|
+
} else if (this.ha.delete(node))
|
|
2049
2095
|
type &= ~2 /* Error */;
|
|
2050
2096
|
}
|
|
2051
2097
|
}
|
|
@@ -2053,13 +2099,13 @@ var ConditionalQueue = class extends Queue {
|
|
|
2053
2099
|
}
|
|
2054
2100
|
};
|
|
2055
2101
|
var CollectionQueue = class extends Queue {
|
|
2056
|
-
|
|
2102
|
+
_;
|
|
2057
2103
|
a = /* @__PURE__ */ new Set();
|
|
2058
2104
|
u = signal(false, { pureWrite: true });
|
|
2059
|
-
|
|
2105
|
+
ra = false;
|
|
2060
2106
|
constructor(type) {
|
|
2061
2107
|
super();
|
|
2062
|
-
this.
|
|
2108
|
+
this._ = type;
|
|
2063
2109
|
}
|
|
2064
2110
|
run(type) {
|
|
2065
2111
|
if (!type || read(this.u))
|
|
@@ -2067,9 +2113,9 @@ var CollectionQueue = class extends Queue {
|
|
|
2067
2113
|
return super.run(type);
|
|
2068
2114
|
}
|
|
2069
2115
|
notify(node, type, flags) {
|
|
2070
|
-
if (!(type & this.
|
|
2116
|
+
if (!(type & this._) || this._ & 1 /* Pending */ && this.ra)
|
|
2071
2117
|
return super.notify(node, type, flags);
|
|
2072
|
-
if (flags & this.
|
|
2118
|
+
if (flags & this._) {
|
|
2073
2119
|
this.a.add(node);
|
|
2074
2120
|
if (this.a.size === 1)
|
|
2075
2121
|
setSignal(this.u, true);
|
|
@@ -2078,7 +2124,7 @@ var CollectionQueue = class extends Queue {
|
|
|
2078
2124
|
if (this.a.size === 0)
|
|
2079
2125
|
setSignal(this.u, false);
|
|
2080
2126
|
}
|
|
2081
|
-
type &= ~this.
|
|
2127
|
+
type &= ~this._;
|
|
2082
2128
|
return type ? super.notify(node, type, flags) : true;
|
|
2083
2129
|
}
|
|
2084
2130
|
};
|
|
@@ -2088,14 +2134,14 @@ function createBoundary(fn, condition) {
|
|
|
2088
2134
|
const tree = createBoundChildren(owner, fn, queue, 0);
|
|
2089
2135
|
computed(() => {
|
|
2090
2136
|
const disabled = read(queue.u);
|
|
2091
|
-
tree.
|
|
2137
|
+
tree.Z = disabled ? 2 /* Error */ | 1 /* Pending */ : 0;
|
|
2092
2138
|
if (!disabled) {
|
|
2093
2139
|
queue.h.forEach(
|
|
2094
2140
|
(node) => queue.notify(node, 1 /* Pending */, 1 /* Pending */)
|
|
2095
2141
|
);
|
|
2096
|
-
queue.
|
|
2142
|
+
queue.ha.forEach((node) => queue.notify(node, 2 /* Error */, 2 /* Error */));
|
|
2097
2143
|
queue.h.clear();
|
|
2098
|
-
queue.
|
|
2144
|
+
queue.ha.clear();
|
|
2099
2145
|
}
|
|
2100
2146
|
});
|
|
2101
2147
|
return () => read(queue.u) ? void 0 : read(tree);
|
|
@@ -2108,7 +2154,7 @@ function createCollectionBoundary(type, fn, fallback) {
|
|
|
2108
2154
|
if (!read(queue.u)) {
|
|
2109
2155
|
const resolved = read(tree);
|
|
2110
2156
|
if (!untrack(() => read(queue.u)))
|
|
2111
|
-
queue.
|
|
2157
|
+
queue.ra = true;
|
|
2112
2158
|
return resolved;
|
|
2113
2159
|
}
|
|
2114
2160
|
return fallback(queue);
|
|
@@ -2121,7 +2167,7 @@ function createLoadBoundary(fn, fallback) {
|
|
|
2121
2167
|
function createErrorBoundary(fn, fallback) {
|
|
2122
2168
|
return createCollectionBoundary(2 /* Error */, fn, (queue) => {
|
|
2123
2169
|
let node = queue.a.values().next().value;
|
|
2124
|
-
return fallback(node.
|
|
2170
|
+
return fallback(node.B, () => {
|
|
2125
2171
|
for (let node2 of queue.a) {
|
|
2126
2172
|
recompute(node2, true);
|
|
2127
2173
|
}
|