@solidjs/signals 0.4.6 → 0.4.8
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 +10 -6
- package/dist/node.cjs +158 -154
- package/dist/prod.js +158 -154
- package/package.json +1 -1
package/dist/prod.js
CHANGED
|
@@ -120,7 +120,7 @@ var Queue = class {
|
|
|
120
120
|
this.f[0].push.apply(this.f[0], queue.f[0]);
|
|
121
121
|
this.f[1].push.apply(this.f[1], queue.f[1]);
|
|
122
122
|
for (let i = 0; i < queue.e.length; i++) {
|
|
123
|
-
const og = this.e.find((c) => c.
|
|
123
|
+
const og = this.e.find((c) => c.h === queue.e[i].h);
|
|
124
124
|
if (og)
|
|
125
125
|
og.merge(queue.e[i]);
|
|
126
126
|
else
|
|
@@ -143,7 +143,7 @@ var Transition = class _Transition {
|
|
|
143
143
|
s = /* @__PURE__ */ new Set();
|
|
144
144
|
R = /* @__PURE__ */ new Set();
|
|
145
145
|
W = /* @__PURE__ */ new Set();
|
|
146
|
-
|
|
146
|
+
J = false;
|
|
147
147
|
f = [[], []];
|
|
148
148
|
u = /* @__PURE__ */ new Map();
|
|
149
149
|
E = [];
|
|
@@ -219,7 +219,7 @@ var Transition = class _Transition {
|
|
|
219
219
|
this.f[1].push.apply(this.f[1], queue.f[1]);
|
|
220
220
|
this.E.push.apply(this.E, queue.E);
|
|
221
221
|
for (let i = 0; i < queue.e.length; i++) {
|
|
222
|
-
const og = this.e.find((c) => c.
|
|
222
|
+
const og = this.e.find((c) => c.h === queue.e[i].h);
|
|
223
223
|
if (og)
|
|
224
224
|
og.merge(queue.e[i]);
|
|
225
225
|
else
|
|
@@ -234,9 +234,9 @@ var Transition = class _Transition {
|
|
|
234
234
|
queueMicrotask(() => this.flush());
|
|
235
235
|
}
|
|
236
236
|
runTransition(fn, force = false) {
|
|
237
|
-
if (this.
|
|
238
|
-
if (this.
|
|
239
|
-
return this.
|
|
237
|
+
if (this.J) {
|
|
238
|
+
if (this.J instanceof _Transition)
|
|
239
|
+
return this.J.runTransition(fn, force);
|
|
240
240
|
if (!force)
|
|
241
241
|
throw new Error("Transition already completed");
|
|
242
242
|
fn();
|
|
@@ -260,12 +260,12 @@ var Transition = class _Transition {
|
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
262
|
addOptimistic(fn) {
|
|
263
|
-
if (fn.
|
|
264
|
-
mergeTransitions(fn.
|
|
265
|
-
ActiveTransition = fn.
|
|
263
|
+
if (fn.j && fn.j !== this) {
|
|
264
|
+
mergeTransitions(fn.j, this);
|
|
265
|
+
ActiveTransition = fn.j;
|
|
266
266
|
return;
|
|
267
267
|
}
|
|
268
|
-
fn.
|
|
268
|
+
fn.j = this;
|
|
269
269
|
this.W.add(fn);
|
|
270
270
|
}
|
|
271
271
|
};
|
|
@@ -274,12 +274,12 @@ function transition(fn) {
|
|
|
274
274
|
queueMicrotask(() => t.runTransition(() => fn((fn2) => t.runTransition(fn2))));
|
|
275
275
|
}
|
|
276
276
|
function cloneGraph(node) {
|
|
277
|
-
if (node.
|
|
278
|
-
if (node.
|
|
279
|
-
mergeTransitions(node.
|
|
280
|
-
ActiveTransition = node.
|
|
277
|
+
if (node.j) {
|
|
278
|
+
if (node.j !== ActiveTransition) {
|
|
279
|
+
mergeTransitions(node.j, ActiveTransition);
|
|
280
|
+
ActiveTransition = node.j;
|
|
281
281
|
}
|
|
282
|
-
return node.
|
|
282
|
+
return node.j.a.get(node);
|
|
283
283
|
}
|
|
284
284
|
const clone = Object.create(Object.getPrototypeOf(node));
|
|
285
285
|
Object.assign(clone, node, {
|
|
@@ -287,10 +287,12 @@ function cloneGraph(node) {
|
|
|
287
287
|
r: null,
|
|
288
288
|
b: null,
|
|
289
289
|
a: node.a ? [...node.a] : null,
|
|
290
|
-
|
|
290
|
+
h: node
|
|
291
291
|
});
|
|
292
|
+
if (clone.F)
|
|
293
|
+
clone.g |= UNINITIALIZED_BIT;
|
|
292
294
|
ActiveTransition.a.set(node, clone);
|
|
293
|
-
node.
|
|
295
|
+
node.j = ActiveTransition;
|
|
294
296
|
if (node.a) {
|
|
295
297
|
for (let i = 0; i < node.a.length; i++)
|
|
296
298
|
node.a[i].b.push(clone);
|
|
@@ -298,7 +300,7 @@ function cloneGraph(node) {
|
|
|
298
300
|
if (node.b) {
|
|
299
301
|
clone.b = [];
|
|
300
302
|
for (let i = 0, length = node.b.length; i < length; i++) {
|
|
301
|
-
!node.b[i].
|
|
303
|
+
!node.b[i].h && clone.b.push(cloneGraph(node.b[i]));
|
|
302
304
|
}
|
|
303
305
|
}
|
|
304
306
|
return clone;
|
|
@@ -311,7 +313,7 @@ function replaceSourceObservers(node, transition2) {
|
|
|
311
313
|
transitionSource = transition2.a.get(node.a[i]);
|
|
312
314
|
source = transitionSource || node.a[i];
|
|
313
315
|
if (source.b && (swap = source.b.indexOf(node)) !== -1) {
|
|
314
|
-
source.b[swap] = transitionSource ? node.
|
|
316
|
+
source.b[swap] = transitionSource ? node.h : source.b[source.b.length - 1];
|
|
315
317
|
!transitionSource && source.b.pop();
|
|
316
318
|
}
|
|
317
319
|
}
|
|
@@ -319,15 +321,15 @@ function replaceSourceObservers(node, transition2) {
|
|
|
319
321
|
function cloneQueue(queue, parent, clonedQueues) {
|
|
320
322
|
const clone = Object.create(Object.getPrototypeOf(queue));
|
|
321
323
|
Object.assign(clone, queue, {
|
|
322
|
-
|
|
324
|
+
h: queue,
|
|
323
325
|
m: parent,
|
|
324
326
|
e: [],
|
|
325
327
|
enqueue(type, fn) {
|
|
326
328
|
ActiveTransition?.enqueue(type, fn);
|
|
327
329
|
},
|
|
328
330
|
notify(node, type, flags) {
|
|
329
|
-
node = node.
|
|
330
|
-
if (!clone.
|
|
331
|
+
node = node.h || node;
|
|
332
|
+
if (!clone.G || type & LOADING_BIT) {
|
|
331
333
|
type &= ~LOADING_BIT;
|
|
332
334
|
ActiveTransition?.notify(node, LOADING_BIT, flags);
|
|
333
335
|
if (!type)
|
|
@@ -344,7 +346,7 @@ function cloneQueue(queue, parent, clonedQueues) {
|
|
|
344
346
|
}
|
|
345
347
|
function resolveQueues(children) {
|
|
346
348
|
for (const child of children) {
|
|
347
|
-
const og = child.
|
|
349
|
+
const og = child.h;
|
|
348
350
|
if (og) {
|
|
349
351
|
const clonedChildren = child.e;
|
|
350
352
|
delete child.enqueue;
|
|
@@ -352,47 +354,49 @@ function resolveQueues(children) {
|
|
|
352
354
|
delete child.m;
|
|
353
355
|
delete child.e;
|
|
354
356
|
Object.assign(og, child);
|
|
355
|
-
delete og.
|
|
357
|
+
delete og.h;
|
|
356
358
|
resolveQueues(clonedChildren);
|
|
357
|
-
} else if (child.m.
|
|
358
|
-
child.m.
|
|
359
|
+
} else if (child.m.h) {
|
|
360
|
+
child.m.h.addChild(child);
|
|
359
361
|
}
|
|
360
362
|
}
|
|
361
363
|
}
|
|
362
364
|
function mergeTransitions(t1, t2) {
|
|
363
365
|
t2.a.forEach((value, key) => {
|
|
364
|
-
key.
|
|
366
|
+
key.j = t1;
|
|
365
367
|
t1.a.set(key, value);
|
|
366
368
|
});
|
|
367
369
|
t2.W.forEach((c) => {
|
|
368
|
-
c.
|
|
370
|
+
c.j = t1;
|
|
369
371
|
t1.W.add(c);
|
|
370
372
|
});
|
|
371
373
|
t2.R.forEach((p) => t1.R.add(p));
|
|
372
374
|
t2.s.forEach((n) => t1.s.add(n));
|
|
373
375
|
t1.merge(t2);
|
|
374
|
-
t2.
|
|
376
|
+
t2.J = t1;
|
|
375
377
|
}
|
|
376
378
|
function finishTransition(transition2) {
|
|
377
|
-
if (transition2.
|
|
379
|
+
if (transition2.J || transition2.X || transition2.R.size || transition2.s.size)
|
|
378
380
|
return;
|
|
379
381
|
for (const [source, clone] of transition2.a) {
|
|
380
|
-
if (source === clone || source.
|
|
382
|
+
if (source === clone || source.j !== transition2)
|
|
381
383
|
continue;
|
|
382
384
|
if (clone.a)
|
|
383
385
|
replaceSourceObservers(clone, transition2);
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
386
|
+
if (!(clone.g === UNINITIALIZED_BIT)) {
|
|
387
|
+
source.dispose(false);
|
|
388
|
+
source.emptyDisposal();
|
|
389
|
+
Object.assign(source, clone);
|
|
390
|
+
delete source.h;
|
|
391
|
+
}
|
|
392
|
+
delete source.j;
|
|
389
393
|
}
|
|
390
394
|
globalQueue.f[0].push.apply(globalQueue.f[0], transition2.f[0]);
|
|
391
395
|
globalQueue.f[1].push.apply(globalQueue.f[1], transition2.f[1]);
|
|
392
396
|
resolveQueues(transition2.e);
|
|
393
|
-
transition2.
|
|
397
|
+
transition2.J = true;
|
|
394
398
|
for (const reset of transition2.W) {
|
|
395
|
-
delete reset.
|
|
399
|
+
delete reset.j;
|
|
396
400
|
reset();
|
|
397
401
|
}
|
|
398
402
|
globalQueue.flush();
|
|
@@ -419,7 +423,7 @@ var Owner = class {
|
|
|
419
423
|
c = STATE_CLEAN;
|
|
420
424
|
n = null;
|
|
421
425
|
w = defaultContext;
|
|
422
|
-
|
|
426
|
+
l = globalQueue;
|
|
423
427
|
ea = 0;
|
|
424
428
|
id = null;
|
|
425
429
|
constructor(id = null, skipAppend = false) {
|
|
@@ -440,8 +444,8 @@ var Owner = class {
|
|
|
440
444
|
if (child.w !== this.w) {
|
|
441
445
|
child.w = { ...this.w, ...child.w };
|
|
442
446
|
}
|
|
443
|
-
if (this.
|
|
444
|
-
child.
|
|
447
|
+
if (this.l)
|
|
448
|
+
child.l = this.l;
|
|
445
449
|
}
|
|
446
450
|
dispose(self = true) {
|
|
447
451
|
if (this.c === STATE_DISPOSED)
|
|
@@ -449,20 +453,20 @@ var Owner = class {
|
|
|
449
453
|
let head = self ? this.B || this.m : this, current = this.r, next = null;
|
|
450
454
|
while (current && current.m === this) {
|
|
451
455
|
current.dispose(true);
|
|
452
|
-
current.
|
|
456
|
+
current.K();
|
|
453
457
|
next = current.r;
|
|
454
458
|
current.r = null;
|
|
455
459
|
current = next;
|
|
456
460
|
}
|
|
457
461
|
this.ea = 0;
|
|
458
462
|
if (self)
|
|
459
|
-
this.
|
|
463
|
+
this.K();
|
|
460
464
|
if (current)
|
|
461
465
|
current.B = !self ? this : this.B;
|
|
462
466
|
if (head)
|
|
463
467
|
head.r = current;
|
|
464
468
|
}
|
|
465
|
-
|
|
469
|
+
K() {
|
|
466
470
|
if (this.B)
|
|
467
471
|
this.B.r = null;
|
|
468
472
|
this.m = null;
|
|
@@ -552,9 +556,9 @@ var UNCHANGED = Symbol(0);
|
|
|
552
556
|
var Computation = class extends Owner {
|
|
553
557
|
a = null;
|
|
554
558
|
b = null;
|
|
555
|
-
|
|
556
|
-
K;
|
|
559
|
+
k;
|
|
557
560
|
L;
|
|
561
|
+
F;
|
|
558
562
|
// Used in __DEV__ mode, hopefully removed in production
|
|
559
563
|
ka;
|
|
560
564
|
// Using false is an optimization as an alternative to _equals: () => false
|
|
@@ -563,19 +567,19 @@ var Computation = class extends Owner {
|
|
|
563
567
|
da;
|
|
564
568
|
ga = false;
|
|
565
569
|
/** Whether the computation is an error or has ancestors that are unresolved */
|
|
566
|
-
|
|
570
|
+
g = 0;
|
|
567
571
|
/** Which flags raised by sources are handled, vs. being passed through. */
|
|
568
572
|
aa = DEFAULT_FLAGS;
|
|
569
573
|
M = -1;
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
574
|
+
H = false;
|
|
575
|
+
j;
|
|
576
|
+
h;
|
|
573
577
|
constructor(initialValue, compute2, options) {
|
|
574
578
|
super(options?.id, compute2 === null);
|
|
575
|
-
this.
|
|
579
|
+
this.F = compute2;
|
|
576
580
|
this.c = compute2 ? STATE_DIRTY : STATE_CLEAN;
|
|
577
|
-
this.
|
|
578
|
-
this.
|
|
581
|
+
this.g = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
|
|
582
|
+
this.k = initialValue;
|
|
579
583
|
if (options?.equals !== void 0)
|
|
580
584
|
this.$ = options.equals;
|
|
581
585
|
if (options?.pureWrite)
|
|
@@ -583,17 +587,17 @@ var Computation = class extends Owner {
|
|
|
583
587
|
if (options?.unobserved)
|
|
584
588
|
this.da = options?.unobserved;
|
|
585
589
|
if (ActiveTransition) {
|
|
586
|
-
this.
|
|
590
|
+
this.j = ActiveTransition;
|
|
587
591
|
ActiveTransition.a.set(this, this);
|
|
588
592
|
}
|
|
589
593
|
}
|
|
590
594
|
fa() {
|
|
591
595
|
track(this);
|
|
592
|
-
newFlags |= this.
|
|
593
|
-
if (this.
|
|
594
|
-
throw this.
|
|
596
|
+
newFlags |= this.g & ~currentMask;
|
|
597
|
+
if (this.g & ERROR_BIT) {
|
|
598
|
+
throw this.L;
|
|
595
599
|
} else {
|
|
596
|
-
return this.
|
|
600
|
+
return this.k;
|
|
597
601
|
}
|
|
598
602
|
}
|
|
599
603
|
/**
|
|
@@ -601,16 +605,16 @@ var Computation = class extends Owner {
|
|
|
601
605
|
* Automatically re-executes the surrounding computation when the value changes
|
|
602
606
|
*/
|
|
603
607
|
read() {
|
|
604
|
-
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.
|
|
608
|
+
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.h && this.g & UNINITIALIZED_BIT)) {
|
|
605
609
|
const clone = ActiveTransition.a.get(this) || cloneGraph(this);
|
|
606
610
|
if (clone !== this)
|
|
607
611
|
return clone.read();
|
|
608
612
|
}
|
|
609
|
-
if (this.
|
|
610
|
-
if (this.
|
|
613
|
+
if (this.F) {
|
|
614
|
+
if (this.g & ERROR_BIT && this.M <= clock)
|
|
611
615
|
update(this);
|
|
612
616
|
else
|
|
613
|
-
this.
|
|
617
|
+
this.I();
|
|
614
618
|
}
|
|
615
619
|
return this.fa();
|
|
616
620
|
}
|
|
@@ -622,42 +626,42 @@ var Computation = class extends Owner {
|
|
|
622
626
|
* before continuing
|
|
623
627
|
*/
|
|
624
628
|
wait() {
|
|
625
|
-
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.
|
|
629
|
+
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.h && this.g & UNINITIALIZED_BIT)) {
|
|
626
630
|
const clone = ActiveTransition.a.get(this) || cloneGraph(this);
|
|
627
631
|
if (clone !== this)
|
|
628
632
|
return clone.wait();
|
|
629
633
|
}
|
|
630
|
-
if (this.
|
|
631
|
-
if (this.
|
|
634
|
+
if (this.F) {
|
|
635
|
+
if (this.g & ERROR_BIT && this.M <= clock)
|
|
632
636
|
update(this);
|
|
633
637
|
else
|
|
634
|
-
this.
|
|
638
|
+
this.I();
|
|
635
639
|
}
|
|
636
|
-
if ((notStale || this.
|
|
640
|
+
if ((notStale || this.g & UNINITIALIZED_BIT) && this.g & LOADING_BIT) {
|
|
637
641
|
track(this);
|
|
638
642
|
throw new NotReadyError();
|
|
639
643
|
}
|
|
640
|
-
if (staleCheck && this.
|
|
641
|
-
staleCheck.
|
|
644
|
+
if (staleCheck && this.g & LOADING_BIT) {
|
|
645
|
+
staleCheck.k = true;
|
|
642
646
|
}
|
|
643
647
|
return this.fa();
|
|
644
648
|
}
|
|
645
649
|
/** Update the computation with a new value. */
|
|
646
650
|
write(value, flags = 0, raw = false) {
|
|
647
|
-
if (ActiveTransition && !this.
|
|
651
|
+
if (ActiveTransition && !this.h) {
|
|
648
652
|
const clone = cloneGraph(this);
|
|
649
653
|
if (clone !== this)
|
|
650
654
|
return clone.write(value, flags, raw);
|
|
651
655
|
}
|
|
652
|
-
const newValue = !raw && typeof value === "function" ? value(this.
|
|
653
|
-
const valueChanged = newValue !== UNCHANGED && (!!(this.
|
|
654
|
-
this.$ === false || !this.$(this.
|
|
656
|
+
const newValue = !raw && typeof value === "function" ? value(this.k) : value;
|
|
657
|
+
const valueChanged = newValue !== UNCHANGED && (!!(this.g & UNINITIALIZED_BIT) || // this._stateFlags & LOADING_BIT & ~flags ||
|
|
658
|
+
this.$ === false || !this.$(this.k, newValue));
|
|
655
659
|
if (valueChanged) {
|
|
656
|
-
this.
|
|
657
|
-
this.
|
|
660
|
+
this.k = newValue;
|
|
661
|
+
this.L = void 0;
|
|
658
662
|
}
|
|
659
|
-
const changedFlagsMask = this.
|
|
660
|
-
this.
|
|
663
|
+
const changedFlagsMask = this.g ^ flags, changedFlags = changedFlagsMask & flags;
|
|
664
|
+
this.g = flags;
|
|
661
665
|
this.M = clock + 1;
|
|
662
666
|
if (this.b) {
|
|
663
667
|
for (let i = 0; i < this.b.length; i++) {
|
|
@@ -668,15 +672,15 @@ var Computation = class extends Owner {
|
|
|
668
672
|
}
|
|
669
673
|
}
|
|
670
674
|
}
|
|
671
|
-
return this.
|
|
675
|
+
return this.k;
|
|
672
676
|
}
|
|
673
677
|
/**
|
|
674
678
|
* Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
|
|
675
679
|
*/
|
|
676
680
|
x(state, skipQueue) {
|
|
677
|
-
if (this.c >= state && !this.
|
|
681
|
+
if (this.c >= state && !this.H)
|
|
678
682
|
return;
|
|
679
|
-
this.
|
|
683
|
+
this.H = !!skipQueue;
|
|
680
684
|
this.c = state;
|
|
681
685
|
if (this.b) {
|
|
682
686
|
for (let i = 0; i < this.b.length; i++) {
|
|
@@ -699,12 +703,12 @@ var Computation = class extends Owner {
|
|
|
699
703
|
}
|
|
700
704
|
if (this.c >= STATE_CHECK)
|
|
701
705
|
return;
|
|
702
|
-
const prevFlags = this.
|
|
706
|
+
const prevFlags = this.g & mask;
|
|
703
707
|
const deltaFlags = prevFlags ^ newFlags2;
|
|
704
708
|
if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
|
|
705
709
|
this.x(STATE_CHECK);
|
|
706
710
|
} else {
|
|
707
|
-
this.
|
|
711
|
+
this.g ^= deltaFlags;
|
|
708
712
|
if (this.b) {
|
|
709
713
|
for (let i = 0; i < this.b.length; i++) {
|
|
710
714
|
this.b[i].Y(mask, newFlags2);
|
|
@@ -713,13 +717,13 @@ var Computation = class extends Owner {
|
|
|
713
717
|
}
|
|
714
718
|
}
|
|
715
719
|
N(error) {
|
|
716
|
-
if (ActiveTransition && !this.
|
|
720
|
+
if (ActiveTransition && !this.h) {
|
|
717
721
|
const clone = cloneGraph(this);
|
|
718
722
|
if (clone !== this)
|
|
719
723
|
return clone.N(error);
|
|
720
724
|
}
|
|
721
|
-
this.
|
|
722
|
-
this.write(UNCHANGED, this.
|
|
725
|
+
this.L = error;
|
|
726
|
+
this.write(UNCHANGED, this.g & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
|
|
723
727
|
}
|
|
724
728
|
/**
|
|
725
729
|
* This is the core part of the reactivity system, which makes sure that the values are updated
|
|
@@ -728,8 +732,8 @@ var Computation = class extends Owner {
|
|
|
728
732
|
*
|
|
729
733
|
* This function will ensure that the value and states we read from the computation are up to date
|
|
730
734
|
*/
|
|
731
|
-
|
|
732
|
-
if (!this.
|
|
735
|
+
I() {
|
|
736
|
+
if (!this.F) {
|
|
733
737
|
return;
|
|
734
738
|
}
|
|
735
739
|
if (this.c === STATE_DISPOSED) {
|
|
@@ -742,8 +746,8 @@ var Computation = class extends Owner {
|
|
|
742
746
|
if (this.c === STATE_CHECK) {
|
|
743
747
|
for (let i = 0; i < this.a.length; i++) {
|
|
744
748
|
const source = ActiveTransition && ActiveTransition.a.get(this.a[i]) || this.a[i];
|
|
745
|
-
source.
|
|
746
|
-
observerFlags |= source.
|
|
749
|
+
source.I();
|
|
750
|
+
observerFlags |= source.g & ~UNINITIALIZED_BIT;
|
|
747
751
|
if (this.c === STATE_DIRTY) {
|
|
748
752
|
break;
|
|
749
753
|
}
|
|
@@ -759,17 +763,17 @@ var Computation = class extends Owner {
|
|
|
759
763
|
/**
|
|
760
764
|
* Remove ourselves from the owner graph and the computation graph
|
|
761
765
|
*/
|
|
762
|
-
|
|
766
|
+
K() {
|
|
763
767
|
if (this.c === STATE_DISPOSED)
|
|
764
768
|
return;
|
|
765
769
|
if (this.a)
|
|
766
770
|
removeSourceObservers(this, 0);
|
|
767
|
-
super.
|
|
771
|
+
super.K();
|
|
768
772
|
}
|
|
769
773
|
};
|
|
770
774
|
function track(computation) {
|
|
771
|
-
if (ActiveTransition && computation.
|
|
772
|
-
computation = computation.
|
|
775
|
+
if (ActiveTransition && computation.h)
|
|
776
|
+
computation = computation.h;
|
|
773
777
|
if (currentObserver) {
|
|
774
778
|
if (!newSources && currentObserver.a && currentObserver.a[newSourcesIndex] === computation) {
|
|
775
779
|
newSourcesIndex++;
|
|
@@ -779,7 +783,7 @@ function track(computation) {
|
|
|
779
783
|
newSources.push(computation);
|
|
780
784
|
}
|
|
781
785
|
if (updateCheck) {
|
|
782
|
-
updateCheck.
|
|
786
|
+
updateCheck.k = computation.M > currentObserver.M;
|
|
783
787
|
}
|
|
784
788
|
}
|
|
785
789
|
}
|
|
@@ -791,11 +795,11 @@ function update(node) {
|
|
|
791
795
|
try {
|
|
792
796
|
node.dispose(false);
|
|
793
797
|
node.emptyDisposal();
|
|
794
|
-
const result = compute(node, node.
|
|
798
|
+
const result = compute(node, node.F, node);
|
|
795
799
|
node.write(result, newFlags, true);
|
|
796
800
|
} catch (error) {
|
|
797
801
|
if (error instanceof NotReadyError) {
|
|
798
|
-
node.write(UNCHANGED, newFlags | LOADING_BIT | node.
|
|
802
|
+
node.write(UNCHANGED, newFlags | LOADING_BIT | node.g & UNINITIALIZED_BIT);
|
|
799
803
|
} else {
|
|
800
804
|
node.N(error);
|
|
801
805
|
}
|
|
@@ -855,20 +859,20 @@ function untrack(fn) {
|
|
|
855
859
|
}
|
|
856
860
|
function hasUpdated(fn) {
|
|
857
861
|
const current = updateCheck;
|
|
858
|
-
updateCheck = {
|
|
862
|
+
updateCheck = { k: false };
|
|
859
863
|
try {
|
|
860
864
|
fn();
|
|
861
|
-
return updateCheck.
|
|
865
|
+
return updateCheck.k;
|
|
862
866
|
} finally {
|
|
863
867
|
updateCheck = current;
|
|
864
868
|
}
|
|
865
869
|
}
|
|
866
870
|
function pendingCheck(fn, loadingValue) {
|
|
867
871
|
const current = staleCheck;
|
|
868
|
-
staleCheck = {
|
|
872
|
+
staleCheck = { k: false };
|
|
869
873
|
try {
|
|
870
874
|
latest(fn);
|
|
871
|
-
return staleCheck.
|
|
875
|
+
return staleCheck.k;
|
|
872
876
|
} catch (err) {
|
|
873
877
|
if (!(err instanceof NotReadyError))
|
|
874
878
|
return false;
|
|
@@ -913,7 +917,7 @@ function runWithObserver(observer, run) {
|
|
|
913
917
|
if (error instanceof NotReadyError) {
|
|
914
918
|
observer.write(
|
|
915
919
|
UNCHANGED,
|
|
916
|
-
newFlags | LOADING_BIT | observer.
|
|
920
|
+
newFlags | LOADING_BIT | observer.g & UNINITIALIZED_BIT
|
|
917
921
|
);
|
|
918
922
|
} else {
|
|
919
923
|
observer.N(error);
|
|
@@ -948,7 +952,7 @@ function compute(owner, fn, observer) {
|
|
|
948
952
|
currentMask = observer?.aa ?? DEFAULT_FLAGS;
|
|
949
953
|
notStale = true;
|
|
950
954
|
try {
|
|
951
|
-
return fn.call(observer, observer ? observer.
|
|
955
|
+
return fn.call(observer, observer ? observer.k : void 0);
|
|
952
956
|
} finally {
|
|
953
957
|
setOwner(prevOwner);
|
|
954
958
|
currentObserver = prevObserver;
|
|
@@ -972,36 +976,36 @@ var Effect = class extends Computation {
|
|
|
972
976
|
this._ = initialValue;
|
|
973
977
|
this.A = options?.render ? EFFECT_RENDER : EFFECT_USER;
|
|
974
978
|
if (this.A === EFFECT_RENDER) {
|
|
975
|
-
this.
|
|
976
|
-
return !this.
|
|
979
|
+
this.F = function(p) {
|
|
980
|
+
return !this.h && clock > this.l.created && !(this.g & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
|
|
977
981
|
};
|
|
978
982
|
}
|
|
979
|
-
this.
|
|
980
|
-
!options?.defer && (this.A === EFFECT_USER ? this.
|
|
983
|
+
this.I();
|
|
984
|
+
!options?.defer && (this.A === EFFECT_USER ? this.l.enqueue(this.A, this.C.bind(this)) : this.C(this.A));
|
|
981
985
|
}
|
|
982
986
|
write(value, flags = 0) {
|
|
983
987
|
if (this.c == STATE_DIRTY) {
|
|
984
|
-
this.
|
|
988
|
+
this.g = flags;
|
|
985
989
|
if (this.A === EFFECT_RENDER) {
|
|
986
|
-
this.
|
|
990
|
+
this.l.notify(this, LOADING_BIT | ERROR_BIT, this.g);
|
|
987
991
|
}
|
|
988
992
|
}
|
|
989
993
|
if (value === UNCHANGED)
|
|
990
|
-
return this.
|
|
991
|
-
this.
|
|
994
|
+
return this.k;
|
|
995
|
+
this.k = value;
|
|
992
996
|
this.ca = true;
|
|
993
|
-
this.
|
|
997
|
+
this.L = void 0;
|
|
994
998
|
return value;
|
|
995
999
|
}
|
|
996
1000
|
x(state, skipQueue) {
|
|
997
1001
|
if (this.c >= state || skipQueue)
|
|
998
1002
|
return;
|
|
999
1003
|
if (this.c === STATE_CLEAN)
|
|
1000
|
-
this.
|
|
1004
|
+
this.l.enqueue(this.A, this.C.bind(this));
|
|
1001
1005
|
this.c = state;
|
|
1002
1006
|
}
|
|
1003
1007
|
Y(mask, newFlags2) {
|
|
1004
|
-
if (this.
|
|
1008
|
+
if (this.h) {
|
|
1005
1009
|
if (this.c >= STATE_DIRTY)
|
|
1006
1010
|
return;
|
|
1007
1011
|
if (mask & 3) {
|
|
@@ -1012,9 +1016,9 @@ var Effect = class extends Computation {
|
|
|
1012
1016
|
super.Y(mask, newFlags2);
|
|
1013
1017
|
}
|
|
1014
1018
|
N(error) {
|
|
1015
|
-
this.
|
|
1016
|
-
this.
|
|
1017
|
-
this.
|
|
1019
|
+
this.L = error;
|
|
1020
|
+
this.l.notify(this, LOADING_BIT, 0);
|
|
1021
|
+
this.g = ERROR_BIT;
|
|
1018
1022
|
if (this.A === EFFECT_USER) {
|
|
1019
1023
|
try {
|
|
1020
1024
|
return this.Z ? this.Z(error, () => {
|
|
@@ -1025,10 +1029,10 @@ var Effect = class extends Computation {
|
|
|
1025
1029
|
error = e;
|
|
1026
1030
|
}
|
|
1027
1031
|
}
|
|
1028
|
-
if (!this.
|
|
1032
|
+
if (!this.l.notify(this, ERROR_BIT, ERROR_BIT))
|
|
1029
1033
|
throw error;
|
|
1030
1034
|
}
|
|
1031
|
-
|
|
1035
|
+
K() {
|
|
1032
1036
|
if (this.c === STATE_DISPOSED)
|
|
1033
1037
|
return;
|
|
1034
1038
|
this.ba = void 0;
|
|
@@ -1036,21 +1040,21 @@ var Effect = class extends Computation {
|
|
|
1036
1040
|
this.Z = void 0;
|
|
1037
1041
|
this.O?.();
|
|
1038
1042
|
this.O = void 0;
|
|
1039
|
-
this.
|
|
1040
|
-
super.
|
|
1043
|
+
this.l.notify(this, ERROR_BIT | LOADING_BIT, 0);
|
|
1044
|
+
super.K();
|
|
1041
1045
|
}
|
|
1042
1046
|
C(type) {
|
|
1043
1047
|
if (type) {
|
|
1044
|
-
const effect = this.
|
|
1048
|
+
const effect = this.h || this;
|
|
1045
1049
|
if (effect.ca && effect.c !== STATE_DISPOSED) {
|
|
1046
1050
|
effect.O?.();
|
|
1047
1051
|
try {
|
|
1048
|
-
effect.O = effect.ba(effect.
|
|
1052
|
+
effect.O = effect.ba(effect.k, effect._);
|
|
1049
1053
|
} catch (e) {
|
|
1050
|
-
if (!effect.
|
|
1054
|
+
if (!effect.l.notify(effect, ERROR_BIT, ERROR_BIT))
|
|
1051
1055
|
throw e;
|
|
1052
1056
|
} finally {
|
|
1053
|
-
effect._ = effect.
|
|
1057
|
+
effect._ = effect.k;
|
|
1054
1058
|
effect.ca = false;
|
|
1055
1059
|
}
|
|
1056
1060
|
}
|
|
@@ -1061,13 +1065,13 @@ var Effect = class extends Computation {
|
|
|
1061
1065
|
var EagerComputation = class extends Computation {
|
|
1062
1066
|
constructor(initialValue, compute2, options) {
|
|
1063
1067
|
super(initialValue, compute2, options);
|
|
1064
|
-
!options?.defer && this.
|
|
1068
|
+
!options?.defer && this.I();
|
|
1065
1069
|
}
|
|
1066
1070
|
x(state, skipQueue) {
|
|
1067
|
-
if (this.c >= state && !this.
|
|
1071
|
+
if (this.c >= state && !this.H)
|
|
1068
1072
|
return;
|
|
1069
|
-
if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.
|
|
1070
|
-
this.
|
|
1073
|
+
if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.H))
|
|
1074
|
+
this.l.enqueue(EFFECT_PURE, this.C.bind(this));
|
|
1071
1075
|
super.x(state, skipQueue);
|
|
1072
1076
|
}
|
|
1073
1077
|
C() {
|
|
@@ -1080,12 +1084,12 @@ var FirewallComputation = class extends Computation {
|
|
|
1080
1084
|
super(void 0, compute2);
|
|
1081
1085
|
}
|
|
1082
1086
|
x(state, skipQueue) {
|
|
1083
|
-
if (this.c >= state && !this.
|
|
1087
|
+
if (this.c >= state && !this.H)
|
|
1084
1088
|
return;
|
|
1085
|
-
if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.
|
|
1086
|
-
this.
|
|
1089
|
+
if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.H))
|
|
1090
|
+
this.l.enqueue(EFFECT_PURE, this.C.bind(this));
|
|
1087
1091
|
super.x(state, true);
|
|
1088
|
-
this.
|
|
1092
|
+
this.H = !!skipQueue;
|
|
1089
1093
|
}
|
|
1090
1094
|
C() {
|
|
1091
1095
|
this.c !== STATE_CLEAN && runTop(this);
|
|
@@ -1100,7 +1104,7 @@ function runTop(node) {
|
|
|
1100
1104
|
}
|
|
1101
1105
|
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
1102
1106
|
if (ancestors[i].c !== STATE_DISPOSED)
|
|
1103
|
-
ancestors[i].
|
|
1107
|
+
ancestors[i].I();
|
|
1104
1108
|
}
|
|
1105
1109
|
}
|
|
1106
1110
|
|
|
@@ -1234,7 +1238,7 @@ var storeTraps = {
|
|
|
1234
1238
|
return desc.get.call(receiver);
|
|
1235
1239
|
}
|
|
1236
1240
|
if (Writing?.has(receiver)) {
|
|
1237
|
-
let value2 = tracked && (overridden || !proxySource) ? tracked.
|
|
1241
|
+
let value2 = tracked && (overridden || !proxySource) ? tracked.k : storeValue[property];
|
|
1238
1242
|
value2 === $DELETED && (value2 = void 0);
|
|
1239
1243
|
if (!isWrappable(value2))
|
|
1240
1244
|
return value2;
|
|
@@ -1771,7 +1775,7 @@ function createMemo(compute2, value, options) {
|
|
|
1771
1775
|
return resolvedValue;
|
|
1772
1776
|
}
|
|
1773
1777
|
resolvedValue = node.wait();
|
|
1774
|
-
if (!node.a?.length && node.r?.m !== node && !(node.
|
|
1778
|
+
if (!node.a?.length && node.r?.m !== node && !(node.g & UNINITIALIZED_BIT)) {
|
|
1775
1779
|
node.dispose();
|
|
1776
1780
|
node = void 0;
|
|
1777
1781
|
}
|
|
@@ -1833,12 +1837,12 @@ function createAsync(compute2, value, options) {
|
|
|
1833
1837
|
const read = node.wait.bind(node);
|
|
1834
1838
|
read.refresh = () => {
|
|
1835
1839
|
let n = node;
|
|
1836
|
-
if (ActiveTransition && !node.
|
|
1840
|
+
if (ActiveTransition && !node.h) {
|
|
1837
1841
|
n = cloneGraph(node);
|
|
1838
1842
|
}
|
|
1839
1843
|
n.c = STATE_DIRTY;
|
|
1840
1844
|
refreshing = true;
|
|
1841
|
-
n.
|
|
1845
|
+
n.I();
|
|
1842
1846
|
};
|
|
1843
1847
|
return read;
|
|
1844
1848
|
}
|
|
@@ -1906,7 +1910,7 @@ function createOptimistic(initial, compute2, key) {
|
|
|
1906
1910
|
if (!ActiveTransition)
|
|
1907
1911
|
throw new Error("createOptimistic can only be updated inside a transition");
|
|
1908
1912
|
ActiveTransition.addOptimistic(reset2);
|
|
1909
|
-
queueMicrotask(() => node.write(v));
|
|
1913
|
+
queueMicrotask(() => reset2.j && node.write(v));
|
|
1910
1914
|
};
|
|
1911
1915
|
var write = write2;
|
|
1912
1916
|
const node = new Computation(initial, null);
|
|
@@ -1937,7 +1941,7 @@ function createOptimistic(initial, compute2, key) {
|
|
|
1937
1941
|
throw new Error("createOptimistic can only be updated inside a transition");
|
|
1938
1942
|
ActiveTransition.addOptimistic(reset);
|
|
1939
1943
|
queueMicrotask(
|
|
1940
|
-
() => setStore((s) => {
|
|
1944
|
+
() => reset.j && setStore((s) => {
|
|
1941
1945
|
lastChange = typeof v === "function" ? v(lastChange) : v;
|
|
1942
1946
|
compute2(s.value, lastChange);
|
|
1943
1947
|
})
|
|
@@ -2154,17 +2158,17 @@ var BoundaryComputation = class extends EagerComputation {
|
|
|
2154
2158
|
}
|
|
2155
2159
|
write(value, flags) {
|
|
2156
2160
|
super.write(value, flags & ~this.U);
|
|
2157
|
-
if (this.U & LOADING_BIT && !(this.
|
|
2161
|
+
if (this.U & LOADING_BIT && !(this.g & UNINITIALIZED_BIT)) {
|
|
2158
2162
|
flags &= ~LOADING_BIT;
|
|
2159
2163
|
}
|
|
2160
|
-
this.
|
|
2161
|
-
return this.
|
|
2164
|
+
this.l.notify(this, this.U, flags);
|
|
2165
|
+
return this.k;
|
|
2162
2166
|
}
|
|
2163
2167
|
};
|
|
2164
2168
|
function createBoundChildren(owner, fn, queue, mask) {
|
|
2165
|
-
const parentQueue = owner.
|
|
2166
|
-
parentQueue.addChild(owner.
|
|
2167
|
-
onCleanup(() => parentQueue.removeChild(owner.
|
|
2169
|
+
const parentQueue = owner.l;
|
|
2170
|
+
parentQueue.addChild(owner.l = queue);
|
|
2171
|
+
onCleanup(() => parentQueue.removeChild(owner.l));
|
|
2168
2172
|
return compute(
|
|
2169
2173
|
owner,
|
|
2170
2174
|
() => {
|
|
@@ -2215,12 +2219,12 @@ var ConditionalQueue = class extends Queue {
|
|
|
2215
2219
|
}
|
|
2216
2220
|
};
|
|
2217
2221
|
var CollectionQueue = class extends Queue {
|
|
2218
|
-
|
|
2222
|
+
G;
|
|
2219
2223
|
d = /* @__PURE__ */ new Set();
|
|
2220
2224
|
t = new Computation(false, null, { pureWrite: true });
|
|
2221
2225
|
constructor(type) {
|
|
2222
2226
|
super();
|
|
2223
|
-
this.
|
|
2227
|
+
this.G = type;
|
|
2224
2228
|
}
|
|
2225
2229
|
run(type) {
|
|
2226
2230
|
if (!type || this.t.read())
|
|
@@ -2230,9 +2234,9 @@ var CollectionQueue = class extends Queue {
|
|
|
2230
2234
|
notify(node, type, flags) {
|
|
2231
2235
|
if (ActiveTransition && ActiveTransition.u.has(this))
|
|
2232
2236
|
return ActiveTransition.u.get(this).notify(node, type, flags);
|
|
2233
|
-
if (!(type & this.
|
|
2237
|
+
if (!(type & this.G))
|
|
2234
2238
|
return super.notify(node, type, flags);
|
|
2235
|
-
if (flags & this.
|
|
2239
|
+
if (flags & this.G) {
|
|
2236
2240
|
this.d.add(node);
|
|
2237
2241
|
if (this.d.size === 1)
|
|
2238
2242
|
this.t.write(true);
|
|
@@ -2241,11 +2245,11 @@ var CollectionQueue = class extends Queue {
|
|
|
2241
2245
|
if (this.d.size === 0)
|
|
2242
2246
|
this.t.write(false);
|
|
2243
2247
|
}
|
|
2244
|
-
type &= ~this.
|
|
2248
|
+
type &= ~this.G;
|
|
2245
2249
|
return type ? super.notify(node, type, flags) : true;
|
|
2246
2250
|
}
|
|
2247
2251
|
merge(queue) {
|
|
2248
|
-
queue.d.forEach((n) => this.notify(n, this.
|
|
2252
|
+
queue.d.forEach((n) => this.notify(n, this.G, this.G));
|
|
2249
2253
|
super.merge(queue);
|
|
2250
2254
|
}
|
|
2251
2255
|
};
|
|
@@ -2288,13 +2292,13 @@ function createErrorBoundary(fn, fallback) {
|
|
|
2288
2292
|
return createCollectionBoundary(ERROR_BIT, fn, (queue) => {
|
|
2289
2293
|
let node = queue.d.values().next().value;
|
|
2290
2294
|
ActiveTransition && ActiveTransition.a.has(node) && (node = ActiveTransition.a.get(node));
|
|
2291
|
-
return fallback(node.
|
|
2295
|
+
return fallback(node.L, () => {
|
|
2292
2296
|
incrementClock();
|
|
2293
2297
|
for (let node2 of queue.d) {
|
|
2294
|
-
if (ActiveTransition && !node2.
|
|
2298
|
+
if (ActiveTransition && !node2.h)
|
|
2295
2299
|
node2 = cloneGraph(node2);
|
|
2296
2300
|
node2.c = STATE_DIRTY;
|
|
2297
|
-
node2.
|
|
2301
|
+
node2.l?.enqueue(node2.A, node2.C.bind(node2));
|
|
2298
2302
|
}
|
|
2299
2303
|
});
|
|
2300
2304
|
});
|