@solidjs/signals 0.0.10 → 0.0.11
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 +3 -2
- package/dist/node.cjs +48 -47
- package/dist/prod.js +48 -47
- package/dist/types/core/scheduler.d.ts +2 -0
- package/package.json +1 -1
package/dist/dev.js
CHANGED
|
@@ -53,6 +53,7 @@ var Queue = class {
|
|
|
53
53
|
_running = false;
|
|
54
54
|
_queues = [[], [], []];
|
|
55
55
|
_children = [];
|
|
56
|
+
created = clock;
|
|
56
57
|
enqueue(type, node) {
|
|
57
58
|
this._queues[0].push(node);
|
|
58
59
|
if (type)
|
|
@@ -421,7 +422,7 @@ var Computation = class extends Owner {
|
|
|
421
422
|
if ((notStale || this._stateFlags & UNINITIALIZED_BIT) && this.loading()) {
|
|
422
423
|
throw new NotReadyError();
|
|
423
424
|
}
|
|
424
|
-
if (staleCheck && this.
|
|
425
|
+
if (staleCheck && this.loading())
|
|
425
426
|
staleCheck._value = true;
|
|
426
427
|
return this._read();
|
|
427
428
|
}
|
|
@@ -726,7 +727,7 @@ var Effect = class extends Computation {
|
|
|
726
727
|
this._prevValue = initialValue;
|
|
727
728
|
this._type = options?.render ? EFFECT_RENDER : EFFECT_USER;
|
|
728
729
|
if (this._type === EFFECT_RENDER) {
|
|
729
|
-
this._compute = (p) => latest(() => compute2(p));
|
|
730
|
+
this._compute = (p) => getClock() > this._queue.created ? latest(() => compute2(p)) : compute2(p);
|
|
730
731
|
}
|
|
731
732
|
if (!options?.defer) {
|
|
732
733
|
this._updateIfNecessary();
|
package/dist/node.cjs
CHANGED
|
@@ -52,6 +52,7 @@ var Queue = class {
|
|
|
52
52
|
H = false;
|
|
53
53
|
r = [[], [], []];
|
|
54
54
|
D = [];
|
|
55
|
+
created = clock;
|
|
55
56
|
enqueue(type, node) {
|
|
56
57
|
this.r[0].push(node);
|
|
57
58
|
if (type)
|
|
@@ -352,7 +353,7 @@ var UNCHANGED = Symbol(0);
|
|
|
352
353
|
var Computation = class extends Owner {
|
|
353
354
|
f = null;
|
|
354
355
|
d = null;
|
|
355
|
-
|
|
356
|
+
b;
|
|
356
357
|
E;
|
|
357
358
|
u;
|
|
358
359
|
// Used in __DEV__ mode, hopefully removed in production
|
|
@@ -362,7 +363,7 @@ var Computation = class extends Owner {
|
|
|
362
363
|
N = isEqual;
|
|
363
364
|
U;
|
|
364
365
|
/** Whether the computation is an error or has ancestors that are unresolved */
|
|
365
|
-
|
|
366
|
+
c = 0;
|
|
366
367
|
/** Which flags raised by sources are handled, vs. being passed through. */
|
|
367
368
|
O = DEFAULT_FLAGS;
|
|
368
369
|
P = null;
|
|
@@ -372,8 +373,8 @@ var Computation = class extends Owner {
|
|
|
372
373
|
super(compute2 === null);
|
|
373
374
|
this.u = compute2;
|
|
374
375
|
this.a = compute2 ? STATE_DIRTY : STATE_CLEAN;
|
|
375
|
-
this.
|
|
376
|
-
this.
|
|
376
|
+
this.c = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
|
|
377
|
+
this.b = initialValue;
|
|
377
378
|
if ((options == null ? void 0 : options.equals) !== void 0)
|
|
378
379
|
this.N = options.equals;
|
|
379
380
|
if (options == null ? void 0 : options.unobserved)
|
|
@@ -382,18 +383,18 @@ var Computation = class extends Owner {
|
|
|
382
383
|
V() {
|
|
383
384
|
var _a;
|
|
384
385
|
if (this.u) {
|
|
385
|
-
if (this.
|
|
386
|
+
if (this.c & ERROR_BIT && this.z <= getClock())
|
|
386
387
|
update(this);
|
|
387
388
|
else
|
|
388
389
|
this.y();
|
|
389
390
|
}
|
|
390
391
|
if (!this.u || ((_a = this.f) == null ? void 0 : _a.length))
|
|
391
392
|
track(this);
|
|
392
|
-
newFlags |= this.
|
|
393
|
-
if (this.
|
|
393
|
+
newFlags |= this.c & ~currentMask;
|
|
394
|
+
if (this.c & ERROR_BIT) {
|
|
394
395
|
throw this.E;
|
|
395
396
|
} else {
|
|
396
|
-
return this.
|
|
397
|
+
return this.b;
|
|
397
398
|
}
|
|
398
399
|
}
|
|
399
400
|
/**
|
|
@@ -411,14 +412,14 @@ var Computation = class extends Owner {
|
|
|
411
412
|
* before continuing
|
|
412
413
|
*/
|
|
413
414
|
wait() {
|
|
414
|
-
if (this.u && this.
|
|
415
|
+
if (this.u && this.c & ERROR_BIT && this.z <= getClock()) {
|
|
415
416
|
update(this);
|
|
416
417
|
}
|
|
417
|
-
if ((notStale || this.
|
|
418
|
+
if ((notStale || this.c & UNINITIALIZED_BIT) && this.loading()) {
|
|
418
419
|
throw new NotReadyError();
|
|
419
420
|
}
|
|
420
|
-
if (staleCheck && this.
|
|
421
|
-
staleCheck.
|
|
421
|
+
if (staleCheck && this.loading())
|
|
422
|
+
staleCheck.b = true;
|
|
422
423
|
return this.V();
|
|
423
424
|
}
|
|
424
425
|
/**
|
|
@@ -436,14 +437,14 @@ var Computation = class extends Owner {
|
|
|
436
437
|
}
|
|
437
438
|
/** Update the computation with a new value. */
|
|
438
439
|
write(value, flags = 0, raw = false) {
|
|
439
|
-
const newValue = !raw && typeof value === "function" ? value(this.
|
|
440
|
-
const valueChanged = newValue !== UNCHANGED && (!!(this.
|
|
440
|
+
const newValue = !raw && typeof value === "function" ? value(this.b) : value;
|
|
441
|
+
const valueChanged = newValue !== UNCHANGED && (!!(this.c & UNINITIALIZED_BIT) || this.N === false || !this.N(this.b, newValue));
|
|
441
442
|
if (valueChanged) {
|
|
442
|
-
this.
|
|
443
|
+
this.b = newValue;
|
|
443
444
|
this.E = void 0;
|
|
444
445
|
}
|
|
445
|
-
const changedFlagsMask = this.
|
|
446
|
-
this.
|
|
446
|
+
const changedFlagsMask = this.c ^ flags, changedFlags = changedFlagsMask & flags;
|
|
447
|
+
this.c = flags;
|
|
447
448
|
this.z = getClock() + 1;
|
|
448
449
|
if (this.d) {
|
|
449
450
|
for (let i = 0; i < this.d.length; i++) {
|
|
@@ -454,7 +455,7 @@ var Computation = class extends Owner {
|
|
|
454
455
|
}
|
|
455
456
|
}
|
|
456
457
|
}
|
|
457
|
-
return this.
|
|
458
|
+
return this.b;
|
|
458
459
|
}
|
|
459
460
|
/**
|
|
460
461
|
* Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
|
|
@@ -485,12 +486,12 @@ var Computation = class extends Owner {
|
|
|
485
486
|
}
|
|
486
487
|
if (this.a >= STATE_CHECK)
|
|
487
488
|
return;
|
|
488
|
-
const prevFlags = this.
|
|
489
|
+
const prevFlags = this.c & mask;
|
|
489
490
|
const deltaFlags = prevFlags ^ newFlags2;
|
|
490
491
|
if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
|
|
491
492
|
this.q(STATE_CHECK);
|
|
492
493
|
} else {
|
|
493
|
-
this.
|
|
494
|
+
this.c ^= deltaFlags;
|
|
494
495
|
if (this.d) {
|
|
495
496
|
for (let i = 0; i < this.d.length; i++) {
|
|
496
497
|
this.d[i].W(mask, newFlags2);
|
|
@@ -500,7 +501,7 @@ var Computation = class extends Owner {
|
|
|
500
501
|
}
|
|
501
502
|
J(error) {
|
|
502
503
|
this.E = error;
|
|
503
|
-
this.write(UNCHANGED, this.
|
|
504
|
+
this.write(UNCHANGED, this.c & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
|
|
504
505
|
}
|
|
505
506
|
/**
|
|
506
507
|
* This is the core part of the reactivity system, which makes sure that the values are updated
|
|
@@ -520,7 +521,7 @@ var Computation = class extends Owner {
|
|
|
520
521
|
if (this.a === STATE_CHECK) {
|
|
521
522
|
for (let i = 0; i < this.f.length; i++) {
|
|
522
523
|
this.f[i].y();
|
|
523
|
-
observerFlags |= this.f[i].
|
|
524
|
+
observerFlags |= this.f[i].c;
|
|
524
525
|
if (this.a === STATE_DIRTY) {
|
|
525
526
|
break;
|
|
526
527
|
}
|
|
@@ -552,7 +553,7 @@ function loadingState(node) {
|
|
|
552
553
|
() => {
|
|
553
554
|
track(node);
|
|
554
555
|
node.y();
|
|
555
|
-
return !!(node.
|
|
556
|
+
return !!(node.c & LOADING_BIT);
|
|
556
557
|
},
|
|
557
558
|
options
|
|
558
559
|
);
|
|
@@ -570,7 +571,7 @@ function track(computation) {
|
|
|
570
571
|
newSources.push(computation);
|
|
571
572
|
}
|
|
572
573
|
if (updateCheck) {
|
|
573
|
-
updateCheck.
|
|
574
|
+
updateCheck.b = computation.z > currentObserver.z;
|
|
574
575
|
}
|
|
575
576
|
}
|
|
576
577
|
}
|
|
@@ -586,7 +587,7 @@ function update(node) {
|
|
|
586
587
|
node.write(result, newFlags, true);
|
|
587
588
|
} catch (error) {
|
|
588
589
|
if (error instanceof NotReadyError) {
|
|
589
|
-
node.write(UNCHANGED, newFlags | LOADING_BIT | node.
|
|
590
|
+
node.write(UNCHANGED, newFlags | LOADING_BIT | node.c & UNINITIALIZED_BIT);
|
|
590
591
|
} else {
|
|
591
592
|
node.J(error);
|
|
592
593
|
}
|
|
@@ -646,20 +647,20 @@ function untrack(fn) {
|
|
|
646
647
|
}
|
|
647
648
|
function hasUpdated(fn) {
|
|
648
649
|
const current = updateCheck;
|
|
649
|
-
updateCheck = {
|
|
650
|
+
updateCheck = { b: false };
|
|
650
651
|
try {
|
|
651
652
|
fn();
|
|
652
|
-
return updateCheck.
|
|
653
|
+
return updateCheck.b;
|
|
653
654
|
} finally {
|
|
654
655
|
updateCheck = current;
|
|
655
656
|
}
|
|
656
657
|
}
|
|
657
658
|
function isStale(fn) {
|
|
658
659
|
const current = staleCheck;
|
|
659
|
-
staleCheck = {
|
|
660
|
+
staleCheck = { b: false };
|
|
660
661
|
try {
|
|
661
662
|
latest(fn);
|
|
662
|
-
return staleCheck.
|
|
663
|
+
return staleCheck.b;
|
|
663
664
|
} catch {
|
|
664
665
|
} finally {
|
|
665
666
|
staleCheck = current;
|
|
@@ -692,7 +693,7 @@ function compute(owner, fn, observer) {
|
|
|
692
693
|
currentMask = (observer == null ? void 0 : observer.O) ?? DEFAULT_FLAGS;
|
|
693
694
|
notStale = true;
|
|
694
695
|
try {
|
|
695
|
-
return fn(observer ? observer.
|
|
696
|
+
return fn(observer ? observer.b : void 0);
|
|
696
697
|
} finally {
|
|
697
698
|
setOwner(prevOwner);
|
|
698
699
|
currentObserver = prevObserver;
|
|
@@ -723,7 +724,7 @@ var Effect = class extends Computation {
|
|
|
723
724
|
this.M = initialValue;
|
|
724
725
|
this.w = (options == null ? void 0 : options.render) ? EFFECT_RENDER : EFFECT_USER;
|
|
725
726
|
if (this.w === EFFECT_RENDER) {
|
|
726
|
-
this.u = (p) => latest(() => compute2(p));
|
|
727
|
+
this.u = (p) => getClock() > this.h.created ? latest(() => compute2(p)) : compute2(p);
|
|
727
728
|
}
|
|
728
729
|
if (!(options == null ? void 0 : options.defer)) {
|
|
729
730
|
this.y();
|
|
@@ -733,15 +734,15 @@ var Effect = class extends Computation {
|
|
|
733
734
|
write(value, flags = 0) {
|
|
734
735
|
var _a, _b;
|
|
735
736
|
if (this.a == STATE_DIRTY) {
|
|
736
|
-
const currentFlags = this.
|
|
737
|
-
this.
|
|
737
|
+
const currentFlags = this.c;
|
|
738
|
+
this.c = flags;
|
|
738
739
|
if (this.w === EFFECT_RENDER && (flags & LOADING_BIT) !== (currentFlags & LOADING_BIT)) {
|
|
739
740
|
(_b = (_a = this.h).R) == null ? void 0 : _b.call(_a, this);
|
|
740
741
|
}
|
|
741
742
|
}
|
|
742
743
|
if (value === UNCHANGED)
|
|
743
|
-
return this.
|
|
744
|
-
this.
|
|
744
|
+
return this.b;
|
|
745
|
+
this.b = value;
|
|
745
746
|
this.Q = true;
|
|
746
747
|
return value;
|
|
747
748
|
}
|
|
@@ -755,8 +756,8 @@ var Effect = class extends Computation {
|
|
|
755
756
|
J(error) {
|
|
756
757
|
var _a, _b, _c;
|
|
757
758
|
(_a = this.B) == null ? void 0 : _a.call(this);
|
|
758
|
-
if (this.
|
|
759
|
-
this.
|
|
759
|
+
if (this.c & LOADING_BIT) {
|
|
760
|
+
this.c = 0;
|
|
760
761
|
(_c = (_b = this.h).R) == null ? void 0 : _c.call(_b, this);
|
|
761
762
|
}
|
|
762
763
|
if (this.w === EFFECT_USER) {
|
|
@@ -784,11 +785,11 @@ var Effect = class extends Computation {
|
|
|
784
785
|
if (this.Q && this.a !== STATE_DISPOSED) {
|
|
785
786
|
(_a = this.B) == null ? void 0 : _a.call(this);
|
|
786
787
|
try {
|
|
787
|
-
this.B = this.K(this.
|
|
788
|
+
this.B = this.K(this.b, this.M);
|
|
788
789
|
} catch (e) {
|
|
789
790
|
this.handleError(e);
|
|
790
791
|
} finally {
|
|
791
|
-
this.M = this.
|
|
792
|
+
this.M = this.b;
|
|
792
793
|
this.Q = false;
|
|
793
794
|
}
|
|
794
795
|
}
|
|
@@ -831,7 +832,7 @@ var SuspenseQueue = class extends Queue {
|
|
|
831
832
|
return super.run(type);
|
|
832
833
|
}
|
|
833
834
|
R(node) {
|
|
834
|
-
if (node.
|
|
835
|
+
if (node.c & LOADING_BIT) {
|
|
835
836
|
this.e.add(node);
|
|
836
837
|
if (!this.o) {
|
|
837
838
|
this.o = true;
|
|
@@ -849,13 +850,13 @@ var SuspenseQueue = class extends Queue {
|
|
|
849
850
|
var LiveComputation = class extends EagerComputation {
|
|
850
851
|
write(value, flags = 0) {
|
|
851
852
|
var _a, _b;
|
|
852
|
-
const currentFlags = this.
|
|
853
|
+
const currentFlags = this.c;
|
|
853
854
|
const dirty = this.a === STATE_DIRTY;
|
|
854
855
|
super.write(value, flags);
|
|
855
856
|
if (dirty && (flags & LOADING_BIT) !== (currentFlags & LOADING_BIT)) {
|
|
856
857
|
(_b = (_a = this.h).R) == null ? void 0 : _b.call(_a, this);
|
|
857
858
|
}
|
|
858
|
-
return this.
|
|
859
|
+
return this.b;
|
|
859
860
|
}
|
|
860
861
|
};
|
|
861
862
|
function createSuspense(fn, fallback) {
|
|
@@ -911,10 +912,10 @@ function createAsync(compute2, value, options) {
|
|
|
911
912
|
let uninitialized = value === void 0;
|
|
912
913
|
const lhs = new EagerComputation(
|
|
913
914
|
{
|
|
914
|
-
|
|
915
|
+
b: value
|
|
915
916
|
},
|
|
916
917
|
(p) => {
|
|
917
|
-
const value2 = p == null ? void 0 : p.
|
|
918
|
+
const value2 = p == null ? void 0 : p.b;
|
|
918
919
|
const source = compute2(value2);
|
|
919
920
|
const isPromise = source instanceof Promise;
|
|
920
921
|
const iterator = source[Symbol.asyncIterator];
|
|
@@ -923,13 +924,13 @@ function createAsync(compute2, value, options) {
|
|
|
923
924
|
wait() {
|
|
924
925
|
return source;
|
|
925
926
|
},
|
|
926
|
-
|
|
927
|
+
b: source
|
|
927
928
|
};
|
|
928
929
|
}
|
|
929
930
|
const signal = new Computation(value2, null, options);
|
|
930
931
|
const w = signal.wait;
|
|
931
932
|
signal.wait = function() {
|
|
932
|
-
if (signal.
|
|
933
|
+
if (signal.c & ERROR_BIT && signal.z <= getClock()) {
|
|
933
934
|
lhs.q(STATE_DIRTY);
|
|
934
935
|
throw new NotReadyError();
|
|
935
936
|
}
|
|
@@ -1219,7 +1220,7 @@ var proxyTraps = {
|
|
|
1219
1220
|
return desc.get.call(receiver);
|
|
1220
1221
|
}
|
|
1221
1222
|
if (Writing.has(storeValue)) {
|
|
1222
|
-
const value2 = tracked ? tracked.
|
|
1223
|
+
const value2 = tracked ? tracked.b : storeValue[property];
|
|
1223
1224
|
return isWrappable(value2) ? (Writing.add(value2[$RAW] || value2), wrap2(value2)) : value2;
|
|
1224
1225
|
}
|
|
1225
1226
|
let value = tracked ? nodes[property].read() : storeValue[property];
|
package/dist/prod.js
CHANGED
|
@@ -50,6 +50,7 @@ var Queue = class {
|
|
|
50
50
|
H = false;
|
|
51
51
|
r = [[], [], []];
|
|
52
52
|
D = [];
|
|
53
|
+
created = clock;
|
|
53
54
|
enqueue(type, node) {
|
|
54
55
|
this.r[0].push(node);
|
|
55
56
|
if (type)
|
|
@@ -350,7 +351,7 @@ var UNCHANGED = Symbol(0);
|
|
|
350
351
|
var Computation = class extends Owner {
|
|
351
352
|
f = null;
|
|
352
353
|
d = null;
|
|
353
|
-
|
|
354
|
+
b;
|
|
354
355
|
E;
|
|
355
356
|
u;
|
|
356
357
|
// Used in __DEV__ mode, hopefully removed in production
|
|
@@ -360,7 +361,7 @@ var Computation = class extends Owner {
|
|
|
360
361
|
N = isEqual;
|
|
361
362
|
U;
|
|
362
363
|
/** Whether the computation is an error or has ancestors that are unresolved */
|
|
363
|
-
|
|
364
|
+
c = 0;
|
|
364
365
|
/** Which flags raised by sources are handled, vs. being passed through. */
|
|
365
366
|
O = DEFAULT_FLAGS;
|
|
366
367
|
P = null;
|
|
@@ -370,8 +371,8 @@ var Computation = class extends Owner {
|
|
|
370
371
|
super(compute2 === null);
|
|
371
372
|
this.u = compute2;
|
|
372
373
|
this.a = compute2 ? STATE_DIRTY : STATE_CLEAN;
|
|
373
|
-
this.
|
|
374
|
-
this.
|
|
374
|
+
this.c = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
|
|
375
|
+
this.b = initialValue;
|
|
375
376
|
if (options?.equals !== void 0)
|
|
376
377
|
this.N = options.equals;
|
|
377
378
|
if (options?.unobserved)
|
|
@@ -379,18 +380,18 @@ var Computation = class extends Owner {
|
|
|
379
380
|
}
|
|
380
381
|
V() {
|
|
381
382
|
if (this.u) {
|
|
382
|
-
if (this.
|
|
383
|
+
if (this.c & ERROR_BIT && this.z <= getClock())
|
|
383
384
|
update(this);
|
|
384
385
|
else
|
|
385
386
|
this.y();
|
|
386
387
|
}
|
|
387
388
|
if (!this.u || this.f?.length)
|
|
388
389
|
track(this);
|
|
389
|
-
newFlags |= this.
|
|
390
|
-
if (this.
|
|
390
|
+
newFlags |= this.c & ~currentMask;
|
|
391
|
+
if (this.c & ERROR_BIT) {
|
|
391
392
|
throw this.E;
|
|
392
393
|
} else {
|
|
393
|
-
return this.
|
|
394
|
+
return this.b;
|
|
394
395
|
}
|
|
395
396
|
}
|
|
396
397
|
/**
|
|
@@ -408,14 +409,14 @@ var Computation = class extends Owner {
|
|
|
408
409
|
* before continuing
|
|
409
410
|
*/
|
|
410
411
|
wait() {
|
|
411
|
-
if (this.u && this.
|
|
412
|
+
if (this.u && this.c & ERROR_BIT && this.z <= getClock()) {
|
|
412
413
|
update(this);
|
|
413
414
|
}
|
|
414
|
-
if ((notStale || this.
|
|
415
|
+
if ((notStale || this.c & UNINITIALIZED_BIT) && this.loading()) {
|
|
415
416
|
throw new NotReadyError();
|
|
416
417
|
}
|
|
417
|
-
if (staleCheck && this.
|
|
418
|
-
staleCheck.
|
|
418
|
+
if (staleCheck && this.loading())
|
|
419
|
+
staleCheck.b = true;
|
|
419
420
|
return this.V();
|
|
420
421
|
}
|
|
421
422
|
/**
|
|
@@ -433,14 +434,14 @@ var Computation = class extends Owner {
|
|
|
433
434
|
}
|
|
434
435
|
/** Update the computation with a new value. */
|
|
435
436
|
write(value, flags = 0, raw = false) {
|
|
436
|
-
const newValue = !raw && typeof value === "function" ? value(this.
|
|
437
|
-
const valueChanged = newValue !== UNCHANGED && (!!(this.
|
|
437
|
+
const newValue = !raw && typeof value === "function" ? value(this.b) : value;
|
|
438
|
+
const valueChanged = newValue !== UNCHANGED && (!!(this.c & UNINITIALIZED_BIT) || this.N === false || !this.N(this.b, newValue));
|
|
438
439
|
if (valueChanged) {
|
|
439
|
-
this.
|
|
440
|
+
this.b = newValue;
|
|
440
441
|
this.E = void 0;
|
|
441
442
|
}
|
|
442
|
-
const changedFlagsMask = this.
|
|
443
|
-
this.
|
|
443
|
+
const changedFlagsMask = this.c ^ flags, changedFlags = changedFlagsMask & flags;
|
|
444
|
+
this.c = flags;
|
|
444
445
|
this.z = getClock() + 1;
|
|
445
446
|
if (this.d) {
|
|
446
447
|
for (let i = 0; i < this.d.length; i++) {
|
|
@@ -451,7 +452,7 @@ var Computation = class extends Owner {
|
|
|
451
452
|
}
|
|
452
453
|
}
|
|
453
454
|
}
|
|
454
|
-
return this.
|
|
455
|
+
return this.b;
|
|
455
456
|
}
|
|
456
457
|
/**
|
|
457
458
|
* Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
|
|
@@ -482,12 +483,12 @@ var Computation = class extends Owner {
|
|
|
482
483
|
}
|
|
483
484
|
if (this.a >= STATE_CHECK)
|
|
484
485
|
return;
|
|
485
|
-
const prevFlags = this.
|
|
486
|
+
const prevFlags = this.c & mask;
|
|
486
487
|
const deltaFlags = prevFlags ^ newFlags2;
|
|
487
488
|
if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
|
|
488
489
|
this.q(STATE_CHECK);
|
|
489
490
|
} else {
|
|
490
|
-
this.
|
|
491
|
+
this.c ^= deltaFlags;
|
|
491
492
|
if (this.d) {
|
|
492
493
|
for (let i = 0; i < this.d.length; i++) {
|
|
493
494
|
this.d[i].W(mask, newFlags2);
|
|
@@ -497,7 +498,7 @@ var Computation = class extends Owner {
|
|
|
497
498
|
}
|
|
498
499
|
J(error) {
|
|
499
500
|
this.E = error;
|
|
500
|
-
this.write(UNCHANGED, this.
|
|
501
|
+
this.write(UNCHANGED, this.c & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
|
|
501
502
|
}
|
|
502
503
|
/**
|
|
503
504
|
* This is the core part of the reactivity system, which makes sure that the values are updated
|
|
@@ -517,7 +518,7 @@ var Computation = class extends Owner {
|
|
|
517
518
|
if (this.a === STATE_CHECK) {
|
|
518
519
|
for (let i = 0; i < this.f.length; i++) {
|
|
519
520
|
this.f[i].y();
|
|
520
|
-
observerFlags |= this.f[i].
|
|
521
|
+
observerFlags |= this.f[i].c;
|
|
521
522
|
if (this.a === STATE_DIRTY) {
|
|
522
523
|
break;
|
|
523
524
|
}
|
|
@@ -549,7 +550,7 @@ function loadingState(node) {
|
|
|
549
550
|
() => {
|
|
550
551
|
track(node);
|
|
551
552
|
node.y();
|
|
552
|
-
return !!(node.
|
|
553
|
+
return !!(node.c & LOADING_BIT);
|
|
553
554
|
},
|
|
554
555
|
options
|
|
555
556
|
);
|
|
@@ -567,7 +568,7 @@ function track(computation) {
|
|
|
567
568
|
newSources.push(computation);
|
|
568
569
|
}
|
|
569
570
|
if (updateCheck) {
|
|
570
|
-
updateCheck.
|
|
571
|
+
updateCheck.b = computation.z > currentObserver.z;
|
|
571
572
|
}
|
|
572
573
|
}
|
|
573
574
|
}
|
|
@@ -583,7 +584,7 @@ function update(node) {
|
|
|
583
584
|
node.write(result, newFlags, true);
|
|
584
585
|
} catch (error) {
|
|
585
586
|
if (error instanceof NotReadyError) {
|
|
586
|
-
node.write(UNCHANGED, newFlags | LOADING_BIT | node.
|
|
587
|
+
node.write(UNCHANGED, newFlags | LOADING_BIT | node.c & UNINITIALIZED_BIT);
|
|
587
588
|
} else {
|
|
588
589
|
node.J(error);
|
|
589
590
|
}
|
|
@@ -642,20 +643,20 @@ function untrack(fn) {
|
|
|
642
643
|
}
|
|
643
644
|
function hasUpdated(fn) {
|
|
644
645
|
const current = updateCheck;
|
|
645
|
-
updateCheck = {
|
|
646
|
+
updateCheck = { b: false };
|
|
646
647
|
try {
|
|
647
648
|
fn();
|
|
648
|
-
return updateCheck.
|
|
649
|
+
return updateCheck.b;
|
|
649
650
|
} finally {
|
|
650
651
|
updateCheck = current;
|
|
651
652
|
}
|
|
652
653
|
}
|
|
653
654
|
function isStale(fn) {
|
|
654
655
|
const current = staleCheck;
|
|
655
|
-
staleCheck = {
|
|
656
|
+
staleCheck = { b: false };
|
|
656
657
|
try {
|
|
657
658
|
latest(fn);
|
|
658
|
-
return staleCheck.
|
|
659
|
+
return staleCheck.b;
|
|
659
660
|
} catch {
|
|
660
661
|
} finally {
|
|
661
662
|
staleCheck = current;
|
|
@@ -688,7 +689,7 @@ function compute(owner, fn, observer) {
|
|
|
688
689
|
currentMask = observer?.O ?? DEFAULT_FLAGS;
|
|
689
690
|
notStale = true;
|
|
690
691
|
try {
|
|
691
|
-
return fn(observer ? observer.
|
|
692
|
+
return fn(observer ? observer.b : void 0);
|
|
692
693
|
} finally {
|
|
693
694
|
setOwner(prevOwner);
|
|
694
695
|
currentObserver = prevObserver;
|
|
@@ -719,7 +720,7 @@ var Effect = class extends Computation {
|
|
|
719
720
|
this.M = initialValue;
|
|
720
721
|
this.w = options?.render ? EFFECT_RENDER : EFFECT_USER;
|
|
721
722
|
if (this.w === EFFECT_RENDER) {
|
|
722
|
-
this.u = (p) => latest(() => compute2(p));
|
|
723
|
+
this.u = (p) => getClock() > this.h.created ? latest(() => compute2(p)) : compute2(p);
|
|
723
724
|
}
|
|
724
725
|
if (!options?.defer) {
|
|
725
726
|
this.y();
|
|
@@ -728,15 +729,15 @@ var Effect = class extends Computation {
|
|
|
728
729
|
}
|
|
729
730
|
write(value, flags = 0) {
|
|
730
731
|
if (this.a == STATE_DIRTY) {
|
|
731
|
-
const currentFlags = this.
|
|
732
|
-
this.
|
|
732
|
+
const currentFlags = this.c;
|
|
733
|
+
this.c = flags;
|
|
733
734
|
if (this.w === EFFECT_RENDER && (flags & LOADING_BIT) !== (currentFlags & LOADING_BIT)) {
|
|
734
735
|
this.h.R?.(this);
|
|
735
736
|
}
|
|
736
737
|
}
|
|
737
738
|
if (value === UNCHANGED)
|
|
738
|
-
return this.
|
|
739
|
-
this.
|
|
739
|
+
return this.b;
|
|
740
|
+
this.b = value;
|
|
740
741
|
this.Q = true;
|
|
741
742
|
return value;
|
|
742
743
|
}
|
|
@@ -749,8 +750,8 @@ var Effect = class extends Computation {
|
|
|
749
750
|
}
|
|
750
751
|
J(error) {
|
|
751
752
|
this.B?.();
|
|
752
|
-
if (this.
|
|
753
|
-
this.
|
|
753
|
+
if (this.c & LOADING_BIT) {
|
|
754
|
+
this.c = 0;
|
|
754
755
|
this.h.R?.(this);
|
|
755
756
|
}
|
|
756
757
|
if (this.w === EFFECT_USER) {
|
|
@@ -776,11 +777,11 @@ var Effect = class extends Computation {
|
|
|
776
777
|
if (this.Q && this.a !== STATE_DISPOSED) {
|
|
777
778
|
this.B?.();
|
|
778
779
|
try {
|
|
779
|
-
this.B = this.K(this.
|
|
780
|
+
this.B = this.K(this.b, this.M);
|
|
780
781
|
} catch (e) {
|
|
781
782
|
this.handleError(e);
|
|
782
783
|
} finally {
|
|
783
|
-
this.M = this.
|
|
784
|
+
this.M = this.b;
|
|
784
785
|
this.Q = false;
|
|
785
786
|
}
|
|
786
787
|
}
|
|
@@ -823,7 +824,7 @@ var SuspenseQueue = class extends Queue {
|
|
|
823
824
|
return super.run(type);
|
|
824
825
|
}
|
|
825
826
|
R(node) {
|
|
826
|
-
if (node.
|
|
827
|
+
if (node.c & LOADING_BIT) {
|
|
827
828
|
this.e.add(node);
|
|
828
829
|
if (!this.o) {
|
|
829
830
|
this.o = true;
|
|
@@ -840,13 +841,13 @@ var SuspenseQueue = class extends Queue {
|
|
|
840
841
|
};
|
|
841
842
|
var LiveComputation = class extends EagerComputation {
|
|
842
843
|
write(value, flags = 0) {
|
|
843
|
-
const currentFlags = this.
|
|
844
|
+
const currentFlags = this.c;
|
|
844
845
|
const dirty = this.a === STATE_DIRTY;
|
|
845
846
|
super.write(value, flags);
|
|
846
847
|
if (dirty && (flags & LOADING_BIT) !== (currentFlags & LOADING_BIT)) {
|
|
847
848
|
this.h.R?.(this);
|
|
848
849
|
}
|
|
849
|
-
return this.
|
|
850
|
+
return this.b;
|
|
850
851
|
}
|
|
851
852
|
};
|
|
852
853
|
function createSuspense(fn, fallback) {
|
|
@@ -901,10 +902,10 @@ function createAsync(compute2, value, options) {
|
|
|
901
902
|
let uninitialized = value === void 0;
|
|
902
903
|
const lhs = new EagerComputation(
|
|
903
904
|
{
|
|
904
|
-
|
|
905
|
+
b: value
|
|
905
906
|
},
|
|
906
907
|
(p) => {
|
|
907
|
-
const value2 = p?.
|
|
908
|
+
const value2 = p?.b;
|
|
908
909
|
const source = compute2(value2);
|
|
909
910
|
const isPromise = source instanceof Promise;
|
|
910
911
|
const iterator = source[Symbol.asyncIterator];
|
|
@@ -913,13 +914,13 @@ function createAsync(compute2, value, options) {
|
|
|
913
914
|
wait() {
|
|
914
915
|
return source;
|
|
915
916
|
},
|
|
916
|
-
|
|
917
|
+
b: source
|
|
917
918
|
};
|
|
918
919
|
}
|
|
919
920
|
const signal = new Computation(value2, null, options);
|
|
920
921
|
const w = signal.wait;
|
|
921
922
|
signal.wait = function() {
|
|
922
|
-
if (signal.
|
|
923
|
+
if (signal.c & ERROR_BIT && signal.z <= getClock()) {
|
|
923
924
|
lhs.q(STATE_DIRTY);
|
|
924
925
|
throw new NotReadyError();
|
|
925
926
|
}
|
|
@@ -1208,7 +1209,7 @@ var proxyTraps = {
|
|
|
1208
1209
|
return desc.get.call(receiver);
|
|
1209
1210
|
}
|
|
1210
1211
|
if (Writing.has(storeValue)) {
|
|
1211
|
-
const value2 = tracked ? tracked.
|
|
1212
|
+
const value2 = tracked ? tracked.b : storeValue[property];
|
|
1212
1213
|
return isWrappable(value2) ? (Writing.add(value2[$RAW] || value2), wrap2(value2)) : value2;
|
|
1213
1214
|
}
|
|
1214
1215
|
let value = tracked ? nodes[property].read() : storeValue[property];
|
|
@@ -8,11 +8,13 @@ export interface IQueue {
|
|
|
8
8
|
flush(): void;
|
|
9
9
|
addChild(child: IQueue): void;
|
|
10
10
|
removeChild(child: IQueue): void;
|
|
11
|
+
created: number;
|
|
11
12
|
}
|
|
12
13
|
export declare class Queue implements IQueue {
|
|
13
14
|
_running: boolean;
|
|
14
15
|
_queues: [Computation[], Effect[], Effect[]];
|
|
15
16
|
_children: IQueue[];
|
|
17
|
+
created: number;
|
|
16
18
|
enqueue<T extends Computation | Effect>(type: number, node: T): void;
|
|
17
19
|
run(type: number): true | undefined;
|
|
18
20
|
flush(): void;
|