@solidjs/signals 0.0.6 → 0.0.7
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 +8 -3
- package/dist/node.cjs +48 -43
- package/dist/prod.js +48 -43
- package/dist/types/core/scheduler.d.ts +2 -2
- package/dist/types/core/suspense.d.ts +1 -1
- package/package.json +1 -1
package/dist/dev.js
CHANGED
|
@@ -622,16 +622,21 @@ var Queue = class {
|
|
|
622
622
|
runEffectQueue(effects);
|
|
623
623
|
}
|
|
624
624
|
}
|
|
625
|
+
let rerun = false;
|
|
625
626
|
for (let i = 0; i < this._children.length; i++) {
|
|
626
|
-
this._children[i].run(type);
|
|
627
|
+
rerun = this._children[i].run(type) || rerun;
|
|
627
628
|
}
|
|
629
|
+
if (type === EFFECT_PURE && this._queues[type].length)
|
|
630
|
+
return true;
|
|
628
631
|
}
|
|
629
632
|
flush() {
|
|
630
633
|
if (this._running)
|
|
631
634
|
return;
|
|
632
635
|
this._running = true;
|
|
633
636
|
try {
|
|
634
|
-
this.run(EFFECT_PURE)
|
|
637
|
+
while (this.run(EFFECT_PURE)) {
|
|
638
|
+
}
|
|
639
|
+
;
|
|
635
640
|
incrementClock();
|
|
636
641
|
scheduled = false;
|
|
637
642
|
this.run(EFFECT_RENDER);
|
|
@@ -775,7 +780,7 @@ var SuspenseQueue = class extends Queue {
|
|
|
775
780
|
run(type) {
|
|
776
781
|
if (type && this._fallback)
|
|
777
782
|
return;
|
|
778
|
-
super.run(type);
|
|
783
|
+
return super.run(type);
|
|
779
784
|
}
|
|
780
785
|
_update(node) {
|
|
781
786
|
if (node._stateFlags & LOADING_BIT) {
|
package/dist/node.cjs
CHANGED
|
@@ -279,7 +279,7 @@ var Computation = class extends Owner {
|
|
|
279
279
|
P() {
|
|
280
280
|
var _a;
|
|
281
281
|
if (this.C)
|
|
282
|
-
this.
|
|
282
|
+
this.t();
|
|
283
283
|
if (!this.C || ((_a = this.c) == null ? void 0 : _a.length))
|
|
284
284
|
track(this);
|
|
285
285
|
newFlags |= this.f & ~currentMask;
|
|
@@ -344,7 +344,7 @@ var Computation = class extends Owner {
|
|
|
344
344
|
if (this.b) {
|
|
345
345
|
for (let i = 0; i < this.b.length; i++) {
|
|
346
346
|
if (valueChanged) {
|
|
347
|
-
this.b[i].
|
|
347
|
+
this.b[i].u(STATE_DIRTY);
|
|
348
348
|
} else if (changedFlagsMask) {
|
|
349
349
|
this.b[i].Q(changedFlagsMask, changedFlags);
|
|
350
350
|
}
|
|
@@ -355,13 +355,13 @@ var Computation = class extends Owner {
|
|
|
355
355
|
/**
|
|
356
356
|
* Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
|
|
357
357
|
*/
|
|
358
|
-
|
|
358
|
+
u(state) {
|
|
359
359
|
if (this.a >= state)
|
|
360
360
|
return;
|
|
361
361
|
this.a = state;
|
|
362
362
|
if (this.b) {
|
|
363
363
|
for (let i = 0; i < this.b.length; i++) {
|
|
364
|
-
this.b[i].
|
|
364
|
+
this.b[i].u(STATE_CHECK);
|
|
365
365
|
}
|
|
366
366
|
}
|
|
367
367
|
}
|
|
@@ -375,7 +375,7 @@ var Computation = class extends Owner {
|
|
|
375
375
|
if (this.a >= STATE_DIRTY)
|
|
376
376
|
return;
|
|
377
377
|
if (mask & this.D) {
|
|
378
|
-
this.
|
|
378
|
+
this.u(STATE_DIRTY);
|
|
379
379
|
return;
|
|
380
380
|
}
|
|
381
381
|
if (this.a >= STATE_CHECK)
|
|
@@ -383,7 +383,7 @@ var Computation = class extends Owner {
|
|
|
383
383
|
const prevFlags = this.f & mask;
|
|
384
384
|
const deltaFlags = prevFlags ^ newFlags2;
|
|
385
385
|
if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
|
|
386
|
-
this.
|
|
386
|
+
this.u(STATE_CHECK);
|
|
387
387
|
} else {
|
|
388
388
|
this.f ^= deltaFlags;
|
|
389
389
|
if (this.b) {
|
|
@@ -403,7 +403,7 @@ var Computation = class extends Owner {
|
|
|
403
403
|
*
|
|
404
404
|
* This function will ensure that the value and states we read from the computation are up to date
|
|
405
405
|
*/
|
|
406
|
-
|
|
406
|
+
t() {
|
|
407
407
|
if (this.a === STATE_DISPOSED) {
|
|
408
408
|
throw new Error("Tried to read a disposed computation");
|
|
409
409
|
}
|
|
@@ -413,7 +413,7 @@ var Computation = class extends Owner {
|
|
|
413
413
|
let observerFlags = 0;
|
|
414
414
|
if (this.a === STATE_CHECK) {
|
|
415
415
|
for (let i = 0; i < this.c.length; i++) {
|
|
416
|
-
this.c[i].
|
|
416
|
+
this.c[i].t();
|
|
417
417
|
observerFlags |= this.c[i].f;
|
|
418
418
|
if (this.a === STATE_DIRTY) {
|
|
419
419
|
break;
|
|
@@ -445,7 +445,7 @@ function loadingState(node) {
|
|
|
445
445
|
void 0,
|
|
446
446
|
() => {
|
|
447
447
|
track(node);
|
|
448
|
-
node.
|
|
448
|
+
node.t();
|
|
449
449
|
return !!(node.f & LOADING_BIT);
|
|
450
450
|
},
|
|
451
451
|
options
|
|
@@ -461,7 +461,7 @@ function errorState(node) {
|
|
|
461
461
|
void 0,
|
|
462
462
|
() => {
|
|
463
463
|
track(node);
|
|
464
|
-
node.
|
|
464
|
+
node.t();
|
|
465
465
|
return !!(node.f & ERROR_BIT);
|
|
466
466
|
},
|
|
467
467
|
options
|
|
@@ -606,35 +606,40 @@ function schedule() {
|
|
|
606
606
|
}
|
|
607
607
|
var Queue = class {
|
|
608
608
|
E = false;
|
|
609
|
-
|
|
609
|
+
q = [[], [], []];
|
|
610
610
|
A = [];
|
|
611
611
|
enqueue(type, node) {
|
|
612
|
-
this.
|
|
612
|
+
this.q[0].push(node);
|
|
613
613
|
if (type)
|
|
614
|
-
this.
|
|
614
|
+
this.q[type].push(node);
|
|
615
615
|
schedule();
|
|
616
616
|
}
|
|
617
617
|
run(type) {
|
|
618
|
-
if (this.
|
|
618
|
+
if (this.q[type].length) {
|
|
619
619
|
if (type === EFFECT_PURE) {
|
|
620
|
-
runPureQueue(this.
|
|
621
|
-
this.
|
|
620
|
+
runPureQueue(this.q[type]);
|
|
621
|
+
this.q[type] = [];
|
|
622
622
|
} else {
|
|
623
|
-
const effects = this.
|
|
624
|
-
this.
|
|
623
|
+
const effects = this.q[type];
|
|
624
|
+
this.q[type] = [];
|
|
625
625
|
runEffectQueue(effects);
|
|
626
626
|
}
|
|
627
627
|
}
|
|
628
|
+
let rerun = false;
|
|
628
629
|
for (let i = 0; i < this.A.length; i++) {
|
|
629
|
-
this.A[i].run(type);
|
|
630
|
+
rerun = this.A[i].run(type) || rerun;
|
|
630
631
|
}
|
|
632
|
+
if (type === EFFECT_PURE && this.q[type].length)
|
|
633
|
+
return true;
|
|
631
634
|
}
|
|
632
635
|
flush() {
|
|
633
636
|
if (this.E)
|
|
634
637
|
return;
|
|
635
638
|
this.E = true;
|
|
636
639
|
try {
|
|
637
|
-
this.run(EFFECT_PURE)
|
|
640
|
+
while (this.run(EFFECT_PURE)) {
|
|
641
|
+
}
|
|
642
|
+
;
|
|
638
643
|
incrementClock();
|
|
639
644
|
scheduled = false;
|
|
640
645
|
this.run(EFFECT_RENDER);
|
|
@@ -682,7 +687,7 @@ function runTop(node) {
|
|
|
682
687
|
}
|
|
683
688
|
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
684
689
|
if (ancestors[i].a !== STATE_DISPOSED)
|
|
685
|
-
ancestors[i].
|
|
690
|
+
ancestors[i].t();
|
|
686
691
|
}
|
|
687
692
|
}
|
|
688
693
|
function runPureQueue(queue) {
|
|
@@ -710,7 +715,7 @@ var Effect = class extends Computation {
|
|
|
710
715
|
this.F = initialValue;
|
|
711
716
|
this.B = (options == null ? void 0 : options.render) ? EFFECT_RENDER : EFFECT_USER;
|
|
712
717
|
this.e = ((_a = getOwner()) == null ? void 0 : _a.e) || globalQueue;
|
|
713
|
-
this.
|
|
718
|
+
this.t();
|
|
714
719
|
this.B === EFFECT_USER ? this.e.enqueue(this.B, this) : this.R();
|
|
715
720
|
}
|
|
716
721
|
write(value, flags = 0) {
|
|
@@ -726,7 +731,7 @@ var Effect = class extends Computation {
|
|
|
726
731
|
this.L = true;
|
|
727
732
|
return value;
|
|
728
733
|
}
|
|
729
|
-
|
|
734
|
+
u(state) {
|
|
730
735
|
if (this.a >= state)
|
|
731
736
|
return;
|
|
732
737
|
if (this.a === STATE_CLEAN)
|
|
@@ -755,38 +760,38 @@ var EagerComputation = class extends Computation {
|
|
|
755
760
|
var _a;
|
|
756
761
|
super(initialValue, compute2, options);
|
|
757
762
|
this.e = ((_a = getOwner()) == null ? void 0 : _a.e) || globalQueue;
|
|
758
|
-
this.
|
|
763
|
+
this.t();
|
|
759
764
|
}
|
|
760
|
-
|
|
765
|
+
u(state) {
|
|
761
766
|
if (this.a >= state)
|
|
762
767
|
return;
|
|
763
768
|
if (this.a === STATE_CLEAN)
|
|
764
769
|
this.e.enqueue(EFFECT_PURE, this);
|
|
765
|
-
super.
|
|
770
|
+
super.u(state);
|
|
766
771
|
}
|
|
767
772
|
};
|
|
768
773
|
|
|
769
774
|
// src/core/suspense.ts
|
|
770
775
|
var SuspenseQueue = class extends Queue {
|
|
771
776
|
g = /* @__PURE__ */ new Set();
|
|
772
|
-
|
|
777
|
+
r = false;
|
|
773
778
|
M = new Computation(false, null);
|
|
774
779
|
run(type) {
|
|
775
|
-
if (type && this.
|
|
780
|
+
if (type && this.r)
|
|
776
781
|
return;
|
|
777
|
-
super.run(type);
|
|
782
|
+
return super.run(type);
|
|
778
783
|
}
|
|
779
784
|
S(node) {
|
|
780
785
|
if (node.f & LOADING_BIT) {
|
|
781
786
|
this.g.add(node);
|
|
782
|
-
if (!this.
|
|
783
|
-
this.
|
|
787
|
+
if (!this.r) {
|
|
788
|
+
this.r = true;
|
|
784
789
|
queueTask(() => this.M.write(true));
|
|
785
790
|
}
|
|
786
791
|
} else {
|
|
787
792
|
this.g.delete(node);
|
|
788
793
|
if (this.g.size === 0) {
|
|
789
|
-
this.
|
|
794
|
+
this.r = false;
|
|
790
795
|
queueTask(() => this.M.write(false));
|
|
791
796
|
}
|
|
792
797
|
}
|
|
@@ -809,7 +814,7 @@ function createSuspense(fn, fallback) {
|
|
|
809
814
|
const child = new Computation(null, fn);
|
|
810
815
|
return new LiveComputation(null, () => flatten(child.wait()));
|
|
811
816
|
}, queue);
|
|
812
|
-
const equality = new Computation(null, () => queue.M.read() || queue.
|
|
817
|
+
const equality = new Computation(null, () => queue.M.read() || queue.r);
|
|
813
818
|
const comp = new Computation(null, () => equality.read() ? fallback() : tree.read());
|
|
814
819
|
return comp.read.bind(comp);
|
|
815
820
|
}
|
|
@@ -1423,14 +1428,14 @@ function mapArray(list, map, options) {
|
|
|
1423
1428
|
T: new Owner(),
|
|
1424
1429
|
w: 0,
|
|
1425
1430
|
U: list,
|
|
1426
|
-
|
|
1431
|
+
s: [],
|
|
1427
1432
|
N: map,
|
|
1428
1433
|
l: [],
|
|
1429
1434
|
g: [],
|
|
1430
1435
|
y: keyFn,
|
|
1431
1436
|
h: keyFn || (options == null ? void 0 : options.keyed) === false ? [] : void 0,
|
|
1432
1437
|
i: map.length > 1 ? [] : void 0,
|
|
1433
|
-
|
|
1438
|
+
r: options == null ? void 0 : options.fallback
|
|
1434
1439
|
});
|
|
1435
1440
|
}
|
|
1436
1441
|
function updateKeyedMap() {
|
|
@@ -1456,16 +1461,16 @@ function updateKeyedMap() {
|
|
|
1456
1461
|
if (this.w !== 0) {
|
|
1457
1462
|
this.T.dispose(false);
|
|
1458
1463
|
this.g = [];
|
|
1459
|
-
this.
|
|
1464
|
+
this.s = [];
|
|
1460
1465
|
this.l = [];
|
|
1461
1466
|
this.w = 0;
|
|
1462
1467
|
this.h && (this.h = []);
|
|
1463
1468
|
this.i && (this.i = []);
|
|
1464
1469
|
}
|
|
1465
|
-
if (this.
|
|
1470
|
+
if (this.r && !this.l[0]) {
|
|
1466
1471
|
this.l[0] = compute(
|
|
1467
1472
|
this.g[0] = new Owner(),
|
|
1468
|
-
this.
|
|
1473
|
+
this.r,
|
|
1469
1474
|
null
|
|
1470
1475
|
);
|
|
1471
1476
|
}
|
|
@@ -1474,17 +1479,17 @@ function updateKeyedMap() {
|
|
|
1474
1479
|
this.g[0].dispose();
|
|
1475
1480
|
this.l = new Array(newLen);
|
|
1476
1481
|
for (j = 0; j < newLen; j++) {
|
|
1477
|
-
this.
|
|
1482
|
+
this.s[j] = newItems[j];
|
|
1478
1483
|
this.l[j] = compute(this.g[j] = new Owner(), mapper, null);
|
|
1479
1484
|
}
|
|
1480
1485
|
this.w = newLen;
|
|
1481
1486
|
} else {
|
|
1482
1487
|
let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.h ? new Array(newLen) : void 0, tempIndexes = this.i ? new Array(newLen) : void 0;
|
|
1483
|
-
for (start = 0, end = Math.min(this.w, newLen); start < end && (this.
|
|
1488
|
+
for (start = 0, end = Math.min(this.w, newLen); start < end && (this.s[start] === newItems[start] || this.h && compare(this.y, this.s[start], newItems[start])); start++) {
|
|
1484
1489
|
if (this.h)
|
|
1485
1490
|
this.h[start].write(newItems[start]);
|
|
1486
1491
|
}
|
|
1487
|
-
for (end = this.w - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.
|
|
1492
|
+
for (end = this.w - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.s[end] === newItems[newEnd] || this.h && compare(this.y, this.s[end], newItems[newEnd])); end--, newEnd--) {
|
|
1488
1493
|
temp[newEnd] = this.l[end];
|
|
1489
1494
|
tempNodes[newEnd] = this.g[end];
|
|
1490
1495
|
tempRows && (tempRows[newEnd] = this.h[end]);
|
|
@@ -1500,7 +1505,7 @@ function updateKeyedMap() {
|
|
|
1500
1505
|
newIndices.set(key, j);
|
|
1501
1506
|
}
|
|
1502
1507
|
for (i = start; i <= end; i++) {
|
|
1503
|
-
item = this.
|
|
1508
|
+
item = this.s[i];
|
|
1504
1509
|
key = this.y ? this.y(item) : item;
|
|
1505
1510
|
j = newIndices.get(key);
|
|
1506
1511
|
if (j !== void 0 && j !== -1) {
|
|
@@ -1530,7 +1535,7 @@ function updateKeyedMap() {
|
|
|
1530
1535
|
}
|
|
1531
1536
|
}
|
|
1532
1537
|
this.l = this.l.slice(0, this.w = newLen);
|
|
1533
|
-
this.
|
|
1538
|
+
this.s = newItems.slice(0);
|
|
1534
1539
|
}
|
|
1535
1540
|
});
|
|
1536
1541
|
return this.l;
|
package/dist/prod.js
CHANGED
|
@@ -276,7 +276,7 @@ var Computation = class extends Owner {
|
|
|
276
276
|
}
|
|
277
277
|
P() {
|
|
278
278
|
if (this.C)
|
|
279
|
-
this.
|
|
279
|
+
this.t();
|
|
280
280
|
if (!this.C || this.c?.length)
|
|
281
281
|
track(this);
|
|
282
282
|
newFlags |= this.f & ~currentMask;
|
|
@@ -341,7 +341,7 @@ var Computation = class extends Owner {
|
|
|
341
341
|
if (this.b) {
|
|
342
342
|
for (let i = 0; i < this.b.length; i++) {
|
|
343
343
|
if (valueChanged) {
|
|
344
|
-
this.b[i].
|
|
344
|
+
this.b[i].u(STATE_DIRTY);
|
|
345
345
|
} else if (changedFlagsMask) {
|
|
346
346
|
this.b[i].Q(changedFlagsMask, changedFlags);
|
|
347
347
|
}
|
|
@@ -352,13 +352,13 @@ var Computation = class extends Owner {
|
|
|
352
352
|
/**
|
|
353
353
|
* Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
|
|
354
354
|
*/
|
|
355
|
-
|
|
355
|
+
u(state) {
|
|
356
356
|
if (this.a >= state)
|
|
357
357
|
return;
|
|
358
358
|
this.a = state;
|
|
359
359
|
if (this.b) {
|
|
360
360
|
for (let i = 0; i < this.b.length; i++) {
|
|
361
|
-
this.b[i].
|
|
361
|
+
this.b[i].u(STATE_CHECK);
|
|
362
362
|
}
|
|
363
363
|
}
|
|
364
364
|
}
|
|
@@ -372,7 +372,7 @@ var Computation = class extends Owner {
|
|
|
372
372
|
if (this.a >= STATE_DIRTY)
|
|
373
373
|
return;
|
|
374
374
|
if (mask & this.D) {
|
|
375
|
-
this.
|
|
375
|
+
this.u(STATE_DIRTY);
|
|
376
376
|
return;
|
|
377
377
|
}
|
|
378
378
|
if (this.a >= STATE_CHECK)
|
|
@@ -380,7 +380,7 @@ var Computation = class extends Owner {
|
|
|
380
380
|
const prevFlags = this.f & mask;
|
|
381
381
|
const deltaFlags = prevFlags ^ newFlags2;
|
|
382
382
|
if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
|
|
383
|
-
this.
|
|
383
|
+
this.u(STATE_CHECK);
|
|
384
384
|
} else {
|
|
385
385
|
this.f ^= deltaFlags;
|
|
386
386
|
if (this.b) {
|
|
@@ -400,7 +400,7 @@ var Computation = class extends Owner {
|
|
|
400
400
|
*
|
|
401
401
|
* This function will ensure that the value and states we read from the computation are up to date
|
|
402
402
|
*/
|
|
403
|
-
|
|
403
|
+
t() {
|
|
404
404
|
if (this.a === STATE_DISPOSED) {
|
|
405
405
|
throw new Error("Tried to read a disposed computation");
|
|
406
406
|
}
|
|
@@ -410,7 +410,7 @@ var Computation = class extends Owner {
|
|
|
410
410
|
let observerFlags = 0;
|
|
411
411
|
if (this.a === STATE_CHECK) {
|
|
412
412
|
for (let i = 0; i < this.c.length; i++) {
|
|
413
|
-
this.c[i].
|
|
413
|
+
this.c[i].t();
|
|
414
414
|
observerFlags |= this.c[i].f;
|
|
415
415
|
if (this.a === STATE_DIRTY) {
|
|
416
416
|
break;
|
|
@@ -442,7 +442,7 @@ function loadingState(node) {
|
|
|
442
442
|
void 0,
|
|
443
443
|
() => {
|
|
444
444
|
track(node);
|
|
445
|
-
node.
|
|
445
|
+
node.t();
|
|
446
446
|
return !!(node.f & LOADING_BIT);
|
|
447
447
|
},
|
|
448
448
|
options
|
|
@@ -458,7 +458,7 @@ function errorState(node) {
|
|
|
458
458
|
void 0,
|
|
459
459
|
() => {
|
|
460
460
|
track(node);
|
|
461
|
-
node.
|
|
461
|
+
node.t();
|
|
462
462
|
return !!(node.f & ERROR_BIT);
|
|
463
463
|
},
|
|
464
464
|
options
|
|
@@ -602,35 +602,40 @@ function schedule() {
|
|
|
602
602
|
}
|
|
603
603
|
var Queue = class {
|
|
604
604
|
E = false;
|
|
605
|
-
|
|
605
|
+
q = [[], [], []];
|
|
606
606
|
A = [];
|
|
607
607
|
enqueue(type, node) {
|
|
608
|
-
this.
|
|
608
|
+
this.q[0].push(node);
|
|
609
609
|
if (type)
|
|
610
|
-
this.
|
|
610
|
+
this.q[type].push(node);
|
|
611
611
|
schedule();
|
|
612
612
|
}
|
|
613
613
|
run(type) {
|
|
614
|
-
if (this.
|
|
614
|
+
if (this.q[type].length) {
|
|
615
615
|
if (type === EFFECT_PURE) {
|
|
616
|
-
runPureQueue(this.
|
|
617
|
-
this.
|
|
616
|
+
runPureQueue(this.q[type]);
|
|
617
|
+
this.q[type] = [];
|
|
618
618
|
} else {
|
|
619
|
-
const effects = this.
|
|
620
|
-
this.
|
|
619
|
+
const effects = this.q[type];
|
|
620
|
+
this.q[type] = [];
|
|
621
621
|
runEffectQueue(effects);
|
|
622
622
|
}
|
|
623
623
|
}
|
|
624
|
+
let rerun = false;
|
|
624
625
|
for (let i = 0; i < this.A.length; i++) {
|
|
625
|
-
this.A[i].run(type);
|
|
626
|
+
rerun = this.A[i].run(type) || rerun;
|
|
626
627
|
}
|
|
628
|
+
if (type === EFFECT_PURE && this.q[type].length)
|
|
629
|
+
return true;
|
|
627
630
|
}
|
|
628
631
|
flush() {
|
|
629
632
|
if (this.E)
|
|
630
633
|
return;
|
|
631
634
|
this.E = true;
|
|
632
635
|
try {
|
|
633
|
-
this.run(EFFECT_PURE)
|
|
636
|
+
while (this.run(EFFECT_PURE)) {
|
|
637
|
+
}
|
|
638
|
+
;
|
|
634
639
|
incrementClock();
|
|
635
640
|
scheduled = false;
|
|
636
641
|
this.run(EFFECT_RENDER);
|
|
@@ -678,7 +683,7 @@ function runTop(node) {
|
|
|
678
683
|
}
|
|
679
684
|
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
680
685
|
if (ancestors[i].a !== STATE_DISPOSED)
|
|
681
|
-
ancestors[i].
|
|
686
|
+
ancestors[i].t();
|
|
682
687
|
}
|
|
683
688
|
}
|
|
684
689
|
function runPureQueue(queue) {
|
|
@@ -705,7 +710,7 @@ var Effect = class extends Computation {
|
|
|
705
710
|
this.F = initialValue;
|
|
706
711
|
this.B = options?.render ? EFFECT_RENDER : EFFECT_USER;
|
|
707
712
|
this.e = getOwner()?.e || globalQueue;
|
|
708
|
-
this.
|
|
713
|
+
this.t();
|
|
709
714
|
this.B === EFFECT_USER ? this.e.enqueue(this.B, this) : this.R();
|
|
710
715
|
}
|
|
711
716
|
write(value, flags = 0) {
|
|
@@ -720,7 +725,7 @@ var Effect = class extends Computation {
|
|
|
720
725
|
this.L = true;
|
|
721
726
|
return value;
|
|
722
727
|
}
|
|
723
|
-
|
|
728
|
+
u(state) {
|
|
724
729
|
if (this.a >= state)
|
|
725
730
|
return;
|
|
726
731
|
if (this.a === STATE_CLEAN)
|
|
@@ -748,38 +753,38 @@ var EagerComputation = class extends Computation {
|
|
|
748
753
|
constructor(initialValue, compute2, options) {
|
|
749
754
|
super(initialValue, compute2, options);
|
|
750
755
|
this.e = getOwner()?.e || globalQueue;
|
|
751
|
-
this.
|
|
756
|
+
this.t();
|
|
752
757
|
}
|
|
753
|
-
|
|
758
|
+
u(state) {
|
|
754
759
|
if (this.a >= state)
|
|
755
760
|
return;
|
|
756
761
|
if (this.a === STATE_CLEAN)
|
|
757
762
|
this.e.enqueue(EFFECT_PURE, this);
|
|
758
|
-
super.
|
|
763
|
+
super.u(state);
|
|
759
764
|
}
|
|
760
765
|
};
|
|
761
766
|
|
|
762
767
|
// src/core/suspense.ts
|
|
763
768
|
var SuspenseQueue = class extends Queue {
|
|
764
769
|
g = /* @__PURE__ */ new Set();
|
|
765
|
-
|
|
770
|
+
r = false;
|
|
766
771
|
M = new Computation(false, null);
|
|
767
772
|
run(type) {
|
|
768
|
-
if (type && this.
|
|
773
|
+
if (type && this.r)
|
|
769
774
|
return;
|
|
770
|
-
super.run(type);
|
|
775
|
+
return super.run(type);
|
|
771
776
|
}
|
|
772
777
|
S(node) {
|
|
773
778
|
if (node.f & LOADING_BIT) {
|
|
774
779
|
this.g.add(node);
|
|
775
|
-
if (!this.
|
|
776
|
-
this.
|
|
780
|
+
if (!this.r) {
|
|
781
|
+
this.r = true;
|
|
777
782
|
queueTask(() => this.M.write(true));
|
|
778
783
|
}
|
|
779
784
|
} else {
|
|
780
785
|
this.g.delete(node);
|
|
781
786
|
if (this.g.size === 0) {
|
|
782
|
-
this.
|
|
787
|
+
this.r = false;
|
|
783
788
|
queueTask(() => this.M.write(false));
|
|
784
789
|
}
|
|
785
790
|
}
|
|
@@ -801,7 +806,7 @@ function createSuspense(fn, fallback) {
|
|
|
801
806
|
const child = new Computation(null, fn);
|
|
802
807
|
return new LiveComputation(null, () => flatten(child.wait()));
|
|
803
808
|
}, queue);
|
|
804
|
-
const equality = new Computation(null, () => queue.M.read() || queue.
|
|
809
|
+
const equality = new Computation(null, () => queue.M.read() || queue.r);
|
|
805
810
|
const comp = new Computation(null, () => equality.read() ? fallback() : tree.read());
|
|
806
811
|
return comp.read.bind(comp);
|
|
807
812
|
}
|
|
@@ -1412,14 +1417,14 @@ function mapArray(list, map, options) {
|
|
|
1412
1417
|
T: new Owner(),
|
|
1413
1418
|
w: 0,
|
|
1414
1419
|
U: list,
|
|
1415
|
-
|
|
1420
|
+
s: [],
|
|
1416
1421
|
N: map,
|
|
1417
1422
|
l: [],
|
|
1418
1423
|
g: [],
|
|
1419
1424
|
y: keyFn,
|
|
1420
1425
|
h: keyFn || options?.keyed === false ? [] : void 0,
|
|
1421
1426
|
i: map.length > 1 ? [] : void 0,
|
|
1422
|
-
|
|
1427
|
+
r: options?.fallback
|
|
1423
1428
|
});
|
|
1424
1429
|
}
|
|
1425
1430
|
function updateKeyedMap() {
|
|
@@ -1445,16 +1450,16 @@ function updateKeyedMap() {
|
|
|
1445
1450
|
if (this.w !== 0) {
|
|
1446
1451
|
this.T.dispose(false);
|
|
1447
1452
|
this.g = [];
|
|
1448
|
-
this.
|
|
1453
|
+
this.s = [];
|
|
1449
1454
|
this.l = [];
|
|
1450
1455
|
this.w = 0;
|
|
1451
1456
|
this.h && (this.h = []);
|
|
1452
1457
|
this.i && (this.i = []);
|
|
1453
1458
|
}
|
|
1454
|
-
if (this.
|
|
1459
|
+
if (this.r && !this.l[0]) {
|
|
1455
1460
|
this.l[0] = compute(
|
|
1456
1461
|
this.g[0] = new Owner(),
|
|
1457
|
-
this.
|
|
1462
|
+
this.r,
|
|
1458
1463
|
null
|
|
1459
1464
|
);
|
|
1460
1465
|
}
|
|
@@ -1463,17 +1468,17 @@ function updateKeyedMap() {
|
|
|
1463
1468
|
this.g[0].dispose();
|
|
1464
1469
|
this.l = new Array(newLen);
|
|
1465
1470
|
for (j = 0; j < newLen; j++) {
|
|
1466
|
-
this.
|
|
1471
|
+
this.s[j] = newItems[j];
|
|
1467
1472
|
this.l[j] = compute(this.g[j] = new Owner(), mapper, null);
|
|
1468
1473
|
}
|
|
1469
1474
|
this.w = newLen;
|
|
1470
1475
|
} else {
|
|
1471
1476
|
let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.h ? new Array(newLen) : void 0, tempIndexes = this.i ? new Array(newLen) : void 0;
|
|
1472
|
-
for (start = 0, end = Math.min(this.w, newLen); start < end && (this.
|
|
1477
|
+
for (start = 0, end = Math.min(this.w, newLen); start < end && (this.s[start] === newItems[start] || this.h && compare(this.y, this.s[start], newItems[start])); start++) {
|
|
1473
1478
|
if (this.h)
|
|
1474
1479
|
this.h[start].write(newItems[start]);
|
|
1475
1480
|
}
|
|
1476
|
-
for (end = this.w - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.
|
|
1481
|
+
for (end = this.w - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.s[end] === newItems[newEnd] || this.h && compare(this.y, this.s[end], newItems[newEnd])); end--, newEnd--) {
|
|
1477
1482
|
temp[newEnd] = this.l[end];
|
|
1478
1483
|
tempNodes[newEnd] = this.g[end];
|
|
1479
1484
|
tempRows && (tempRows[newEnd] = this.h[end]);
|
|
@@ -1489,7 +1494,7 @@ function updateKeyedMap() {
|
|
|
1489
1494
|
newIndices.set(key, j);
|
|
1490
1495
|
}
|
|
1491
1496
|
for (i = start; i <= end; i++) {
|
|
1492
|
-
item = this.
|
|
1497
|
+
item = this.s[i];
|
|
1493
1498
|
key = this.y ? this.y(item) : item;
|
|
1494
1499
|
j = newIndices.get(key);
|
|
1495
1500
|
if (j !== void 0 && j !== -1) {
|
|
@@ -1519,7 +1524,7 @@ function updateKeyedMap() {
|
|
|
1519
1524
|
}
|
|
1520
1525
|
}
|
|
1521
1526
|
this.l = this.l.slice(0, this.w = newLen);
|
|
1522
|
-
this.
|
|
1527
|
+
this.s = newItems.slice(0);
|
|
1523
1528
|
}
|
|
1524
1529
|
});
|
|
1525
1530
|
return this.l;
|
|
@@ -2,7 +2,7 @@ import { Computation } from "./core.js";
|
|
|
2
2
|
import type { Effect } from "./effect.js";
|
|
3
3
|
export interface IQueue {
|
|
4
4
|
enqueue<T extends Computation | Effect>(type: number, node: T): void;
|
|
5
|
-
run(type: number): void;
|
|
5
|
+
run(type: number): boolean | void;
|
|
6
6
|
flush(): void;
|
|
7
7
|
addChild(child: IQueue): void;
|
|
8
8
|
removeChild(child: IQueue): void;
|
|
@@ -12,7 +12,7 @@ export declare class Queue implements IQueue {
|
|
|
12
12
|
_queues: [Computation[], Effect[], Effect[]];
|
|
13
13
|
_children: IQueue[];
|
|
14
14
|
enqueue<T extends Computation | Effect>(type: number, node: T): void;
|
|
15
|
-
run(type: number):
|
|
15
|
+
run(type: number): true | undefined;
|
|
16
16
|
flush(): void;
|
|
17
17
|
addChild(child: IQueue): void;
|
|
18
18
|
removeChild(child: IQueue): void;
|
|
@@ -5,7 +5,7 @@ export declare class SuspenseQueue extends Queue {
|
|
|
5
5
|
_nodes: Set<Effect>;
|
|
6
6
|
_fallback: boolean;
|
|
7
7
|
_signal: Computation<boolean>;
|
|
8
|
-
run(type: number):
|
|
8
|
+
run(type: number): true | undefined;
|
|
9
9
|
_update(node: Effect): void;
|
|
10
10
|
}
|
|
11
11
|
export declare function createSuspense(fn: () => any, fallback: () => any): () => any;
|