@solidjs/signals 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev.js +12 -9
- package/dist/node.cjs +149 -146
- package/dist/prod.js +149 -146
- package/dist/types/core/effect.d.ts +3 -1
- package/package.json +1 -1
package/dist/node.cjs
CHANGED
|
@@ -39,20 +39,20 @@ function schedule() {
|
|
|
39
39
|
if (scheduled)
|
|
40
40
|
return;
|
|
41
41
|
scheduled = true;
|
|
42
|
-
if (!globalQueue.
|
|
42
|
+
if (!globalQueue.K)
|
|
43
43
|
queueMicrotask(flush);
|
|
44
44
|
}
|
|
45
45
|
var pureQueue = [];
|
|
46
46
|
var Queue = class {
|
|
47
47
|
o = null;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
K = false;
|
|
49
|
+
L = [[], []];
|
|
50
|
+
F = [];
|
|
51
51
|
created = clock;
|
|
52
52
|
enqueue(type, fn) {
|
|
53
53
|
pureQueue.push(fn);
|
|
54
54
|
if (type)
|
|
55
|
-
this.
|
|
55
|
+
this.L[type - 1].push(fn);
|
|
56
56
|
schedule();
|
|
57
57
|
}
|
|
58
58
|
run(type) {
|
|
@@ -60,19 +60,19 @@ var Queue = class {
|
|
|
60
60
|
pureQueue.length && runQueue(pureQueue, type);
|
|
61
61
|
pureQueue = [];
|
|
62
62
|
return;
|
|
63
|
-
} else if (this.
|
|
64
|
-
const effects = this.
|
|
65
|
-
this.
|
|
63
|
+
} else if (this.L[type - 1].length) {
|
|
64
|
+
const effects = this.L[type - 1];
|
|
65
|
+
this.L[type - 1] = [];
|
|
66
66
|
runQueue(effects, type);
|
|
67
67
|
}
|
|
68
|
-
for (let i = 0; i < this.
|
|
69
|
-
this.
|
|
68
|
+
for (let i = 0; i < this.F.length; i++) {
|
|
69
|
+
this.F[i].run(type);
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
flush() {
|
|
73
|
-
if (this.
|
|
73
|
+
if (this.K)
|
|
74
74
|
return;
|
|
75
|
-
this.
|
|
75
|
+
this.K = true;
|
|
76
76
|
try {
|
|
77
77
|
this.run(EFFECT_PURE);
|
|
78
78
|
incrementClock();
|
|
@@ -80,17 +80,17 @@ var Queue = class {
|
|
|
80
80
|
this.run(EFFECT_RENDER);
|
|
81
81
|
this.run(EFFECT_USER);
|
|
82
82
|
} finally {
|
|
83
|
-
this.
|
|
83
|
+
this.K = false;
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
addChild(child) {
|
|
87
|
-
this.
|
|
87
|
+
this.F.push(child);
|
|
88
88
|
child.o = this;
|
|
89
89
|
}
|
|
90
90
|
removeChild(child) {
|
|
91
|
-
const index = this.
|
|
91
|
+
const index = this.F.indexOf(child);
|
|
92
92
|
if (index >= 0)
|
|
93
|
-
this.
|
|
93
|
+
this.F.splice(index, 1);
|
|
94
94
|
}
|
|
95
95
|
notify(...args) {
|
|
96
96
|
if (this.o)
|
|
@@ -160,20 +160,20 @@ var Owner = class {
|
|
|
160
160
|
let head = self ? this.t || this.o : this, current = this.m, next = null;
|
|
161
161
|
while (current && current.o === this) {
|
|
162
162
|
current.dispose(true);
|
|
163
|
-
current.
|
|
163
|
+
current.z();
|
|
164
164
|
next = current.m;
|
|
165
165
|
current.m = null;
|
|
166
166
|
current = next;
|
|
167
167
|
}
|
|
168
168
|
this.W = 0;
|
|
169
169
|
if (self)
|
|
170
|
-
this.
|
|
170
|
+
this.z();
|
|
171
171
|
if (current)
|
|
172
172
|
current.t = !self ? this : this.t;
|
|
173
173
|
if (head)
|
|
174
174
|
head.m = current;
|
|
175
175
|
}
|
|
176
|
-
|
|
176
|
+
z() {
|
|
177
177
|
if (this.t)
|
|
178
178
|
this.t.m = null;
|
|
179
179
|
this.o = null;
|
|
@@ -274,45 +274,45 @@ var Computation = class extends Owner {
|
|
|
274
274
|
c = null;
|
|
275
275
|
d = null;
|
|
276
276
|
g;
|
|
277
|
-
|
|
278
|
-
|
|
277
|
+
G;
|
|
278
|
+
A;
|
|
279
279
|
// Used in __DEV__ mode, hopefully removed in production
|
|
280
280
|
ca;
|
|
281
281
|
// Using false is an optimization as an alternative to _equals: () => false
|
|
282
282
|
// which could enable more efficient DIRTY notification
|
|
283
|
-
|
|
283
|
+
S = isEqual;
|
|
284
284
|
X;
|
|
285
285
|
_ = false;
|
|
286
286
|
/** Whether the computation is an error or has ancestors that are unresolved */
|
|
287
287
|
f = 0;
|
|
288
288
|
/** Which flags raised by sources are handled, vs. being passed through. */
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
289
|
+
T = DEFAULT_FLAGS;
|
|
290
|
+
B = -1;
|
|
291
|
+
x = false;
|
|
292
292
|
constructor(initialValue, compute2, options) {
|
|
293
293
|
super(options == null ? void 0 : options.id, compute2 === null);
|
|
294
|
-
this.
|
|
294
|
+
this.A = compute2;
|
|
295
295
|
this.a = compute2 ? STATE_DIRTY : STATE_CLEAN;
|
|
296
296
|
this.f = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
|
|
297
297
|
this.g = initialValue;
|
|
298
298
|
if ((options == null ? void 0 : options.equals) !== void 0)
|
|
299
|
-
this.
|
|
299
|
+
this.S = options.equals;
|
|
300
300
|
if (options == null ? void 0 : options.pureWrite)
|
|
301
301
|
this._ = true;
|
|
302
302
|
if (options == null ? void 0 : options.unobserved)
|
|
303
303
|
this.X = options == null ? void 0 : options.unobserved;
|
|
304
304
|
}
|
|
305
305
|
Y() {
|
|
306
|
-
if (this.
|
|
307
|
-
if (this.f & ERROR_BIT && this.
|
|
306
|
+
if (this.A) {
|
|
307
|
+
if (this.f & ERROR_BIT && this.B <= getClock())
|
|
308
308
|
update(this);
|
|
309
309
|
else
|
|
310
|
-
this.
|
|
310
|
+
this.y();
|
|
311
311
|
}
|
|
312
312
|
track(this);
|
|
313
313
|
newFlags |= this.f & ~currentMask;
|
|
314
314
|
if (this.f & ERROR_BIT) {
|
|
315
|
-
throw this.
|
|
315
|
+
throw this.G;
|
|
316
316
|
} else {
|
|
317
317
|
return this.g;
|
|
318
318
|
}
|
|
@@ -332,10 +332,10 @@ var Computation = class extends Owner {
|
|
|
332
332
|
* before continuing
|
|
333
333
|
*/
|
|
334
334
|
wait() {
|
|
335
|
-
if (this.
|
|
335
|
+
if (this.A && this.f & ERROR_BIT && this.B <= getClock()) {
|
|
336
336
|
update(this);
|
|
337
337
|
} else {
|
|
338
|
-
this.
|
|
338
|
+
this.y();
|
|
339
339
|
}
|
|
340
340
|
track(this);
|
|
341
341
|
if ((notStale || this.f & UNINITIALIZED_BIT) && this.f & LOADING_BIT) {
|
|
@@ -350,14 +350,14 @@ var Computation = class extends Owner {
|
|
|
350
350
|
write(value, flags = 0, raw = false) {
|
|
351
351
|
const newValue = !raw && typeof value === "function" ? value(this.g) : value;
|
|
352
352
|
const valueChanged = newValue !== UNCHANGED && (!!(this.f & UNINITIALIZED_BIT) || // this._stateFlags & LOADING_BIT & ~flags ||
|
|
353
|
-
this.
|
|
353
|
+
this.S === false || !this.S(this.g, newValue));
|
|
354
354
|
if (valueChanged) {
|
|
355
355
|
this.g = newValue;
|
|
356
|
-
this.
|
|
356
|
+
this.G = void 0;
|
|
357
357
|
}
|
|
358
358
|
const changedFlagsMask = this.f ^ flags, changedFlags = changedFlagsMask & flags;
|
|
359
359
|
this.f = flags;
|
|
360
|
-
this.
|
|
360
|
+
this.B = getClock() + 1;
|
|
361
361
|
if (this.d) {
|
|
362
362
|
for (let i = 0; i < this.d.length; i++) {
|
|
363
363
|
if (valueChanged) {
|
|
@@ -373,9 +373,9 @@ var Computation = class extends Owner {
|
|
|
373
373
|
* Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
|
|
374
374
|
*/
|
|
375
375
|
r(state, skipQueue) {
|
|
376
|
-
if (this.a >= state && !this.
|
|
376
|
+
if (this.a >= state && !this.x)
|
|
377
377
|
return;
|
|
378
|
-
this.
|
|
378
|
+
this.x = !!skipQueue;
|
|
379
379
|
this.a = state;
|
|
380
380
|
if (this.d) {
|
|
381
381
|
for (let i = 0; i < this.d.length; i++) {
|
|
@@ -392,7 +392,7 @@ var Computation = class extends Owner {
|
|
|
392
392
|
Z(mask, newFlags2) {
|
|
393
393
|
if (this.a >= STATE_DIRTY)
|
|
394
394
|
return;
|
|
395
|
-
if (mask & this.
|
|
395
|
+
if (mask & this.T) {
|
|
396
396
|
this.r(STATE_DIRTY);
|
|
397
397
|
return;
|
|
398
398
|
}
|
|
@@ -411,8 +411,8 @@ var Computation = class extends Owner {
|
|
|
411
411
|
}
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
|
-
|
|
415
|
-
this.
|
|
414
|
+
M(error) {
|
|
415
|
+
this.G = error;
|
|
416
416
|
this.write(UNCHANGED, this.f & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
|
|
417
417
|
}
|
|
418
418
|
/**
|
|
@@ -422,8 +422,8 @@ var Computation = class extends Owner {
|
|
|
422
422
|
*
|
|
423
423
|
* This function will ensure that the value and states we read from the computation are up to date
|
|
424
424
|
*/
|
|
425
|
-
|
|
426
|
-
if (!this.
|
|
425
|
+
y() {
|
|
426
|
+
if (!this.A) {
|
|
427
427
|
return;
|
|
428
428
|
}
|
|
429
429
|
if (this.a === STATE_DISPOSED) {
|
|
@@ -435,7 +435,7 @@ var Computation = class extends Owner {
|
|
|
435
435
|
let observerFlags = 0;
|
|
436
436
|
if (this.a === STATE_CHECK) {
|
|
437
437
|
for (let i = 0; i < this.c.length; i++) {
|
|
438
|
-
this.c[i].
|
|
438
|
+
this.c[i].y();
|
|
439
439
|
observerFlags |= this.c[i].f;
|
|
440
440
|
if (this.a === STATE_DIRTY) {
|
|
441
441
|
break;
|
|
@@ -452,12 +452,12 @@ var Computation = class extends Owner {
|
|
|
452
452
|
/**
|
|
453
453
|
* Remove ourselves from the owner graph and the computation graph
|
|
454
454
|
*/
|
|
455
|
-
|
|
455
|
+
z() {
|
|
456
456
|
if (this.a === STATE_DISPOSED)
|
|
457
457
|
return;
|
|
458
458
|
if (this.c)
|
|
459
459
|
removeSourceObservers(this, 0);
|
|
460
|
-
super.
|
|
460
|
+
super.z();
|
|
461
461
|
}
|
|
462
462
|
};
|
|
463
463
|
function track(computation) {
|
|
@@ -470,7 +470,7 @@ function track(computation) {
|
|
|
470
470
|
newSources.push(computation);
|
|
471
471
|
}
|
|
472
472
|
if (updateCheck) {
|
|
473
|
-
updateCheck.g = computation.
|
|
473
|
+
updateCheck.g = computation.B > currentObserver.B;
|
|
474
474
|
}
|
|
475
475
|
}
|
|
476
476
|
}
|
|
@@ -482,13 +482,13 @@ function update(node) {
|
|
|
482
482
|
try {
|
|
483
483
|
node.dispose(false);
|
|
484
484
|
node.emptyDisposal();
|
|
485
|
-
const result = compute(node, node.
|
|
485
|
+
const result = compute(node, node.A, node);
|
|
486
486
|
node.write(result, newFlags, true);
|
|
487
487
|
} catch (error) {
|
|
488
488
|
if (error instanceof NotReadyError) {
|
|
489
489
|
node.write(UNCHANGED, newFlags | LOADING_BIT | node.f & UNINITIALIZED_BIT);
|
|
490
490
|
} else {
|
|
491
|
-
node.
|
|
491
|
+
node.M(error);
|
|
492
492
|
}
|
|
493
493
|
} finally {
|
|
494
494
|
if (newSources) {
|
|
@@ -518,7 +518,7 @@ function update(node) {
|
|
|
518
518
|
newSources = prevSources;
|
|
519
519
|
newSourcesIndex = prevSourcesIndex;
|
|
520
520
|
newFlags = prevFlags;
|
|
521
|
-
node.
|
|
521
|
+
node.B = getClock() + 1;
|
|
522
522
|
node.a = STATE_CLEAN;
|
|
523
523
|
}
|
|
524
524
|
}
|
|
@@ -583,7 +583,7 @@ function isPending(fn, loadingValue) {
|
|
|
583
583
|
if (!currentObserver)
|
|
584
584
|
return pendingCheck(fn, loadingValue);
|
|
585
585
|
const c = new Computation(void 0, () => pendingCheck(fn, loadingValue));
|
|
586
|
-
c.
|
|
586
|
+
c.T |= LOADING_BIT;
|
|
587
587
|
return c.read();
|
|
588
588
|
}
|
|
589
589
|
function latest(fn, fallback) {
|
|
@@ -616,7 +616,7 @@ function runWithObserver(observer, run) {
|
|
|
616
616
|
newFlags | LOADING_BIT | observer.f & UNINITIALIZED_BIT
|
|
617
617
|
);
|
|
618
618
|
} else {
|
|
619
|
-
observer.
|
|
619
|
+
observer.M(error);
|
|
620
620
|
}
|
|
621
621
|
} finally {
|
|
622
622
|
if (newSources) {
|
|
@@ -645,7 +645,7 @@ function runWithObserver(observer, run) {
|
|
|
645
645
|
function compute(owner, fn, observer) {
|
|
646
646
|
const prevOwner = setOwner(owner), prevObserver = currentObserver, prevMask = currentMask, prevNotStale = notStale;
|
|
647
647
|
currentObserver = observer;
|
|
648
|
-
currentMask = (observer == null ? void 0 : observer.
|
|
648
|
+
currentMask = (observer == null ? void 0 : observer.T) ?? DEFAULT_FLAGS;
|
|
649
649
|
notStale = true;
|
|
650
650
|
try {
|
|
651
651
|
return fn(observer ? observer.g : void 0);
|
|
@@ -659,23 +659,23 @@ function compute(owner, fn, observer) {
|
|
|
659
659
|
|
|
660
660
|
// src/core/effect.ts
|
|
661
661
|
var Effect = class extends Computation {
|
|
662
|
-
|
|
663
|
-
M;
|
|
664
|
-
B;
|
|
665
|
-
U = false;
|
|
662
|
+
U;
|
|
666
663
|
N;
|
|
664
|
+
C;
|
|
665
|
+
V = false;
|
|
666
|
+
O;
|
|
667
667
|
s;
|
|
668
668
|
constructor(initialValue, compute2, effect, error, options) {
|
|
669
669
|
super(initialValue, compute2, options);
|
|
670
|
-
this.
|
|
671
|
-
this.
|
|
672
|
-
this.
|
|
670
|
+
this.U = effect;
|
|
671
|
+
this.N = error;
|
|
672
|
+
this.O = initialValue;
|
|
673
673
|
this.s = (options == null ? void 0 : options.render) ? EFFECT_RENDER : EFFECT_USER;
|
|
674
674
|
if (this.s === EFFECT_RENDER) {
|
|
675
|
-
this.
|
|
675
|
+
this.A = (p) => getClock() > this.h.created && !(this.f & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
|
|
676
676
|
}
|
|
677
|
-
this.
|
|
678
|
-
!(options == null ? void 0 : options.defer) && (this.s === EFFECT_USER ? this.h.enqueue(this.s, this.
|
|
677
|
+
this.y();
|
|
678
|
+
!(options == null ? void 0 : options.defer) && (this.s === EFFECT_USER ? this.h.enqueue(this.s, this.u.bind(this)) : this.u(this.s));
|
|
679
679
|
}
|
|
680
680
|
write(value, flags = 0) {
|
|
681
681
|
if (this.a == STATE_DIRTY) {
|
|
@@ -688,26 +688,26 @@ var Effect = class extends Computation {
|
|
|
688
688
|
if (value === UNCHANGED)
|
|
689
689
|
return this.g;
|
|
690
690
|
this.g = value;
|
|
691
|
-
this.
|
|
691
|
+
this.V = true;
|
|
692
692
|
return value;
|
|
693
693
|
}
|
|
694
694
|
r(state, skipQueue) {
|
|
695
695
|
if (this.a >= state || skipQueue)
|
|
696
696
|
return;
|
|
697
697
|
if (this.a === STATE_CLEAN)
|
|
698
|
-
this.h.enqueue(this.s, this.
|
|
698
|
+
this.h.enqueue(this.s, this.u.bind(this));
|
|
699
699
|
this.a = state;
|
|
700
700
|
}
|
|
701
|
-
|
|
702
|
-
this.
|
|
701
|
+
M(error) {
|
|
702
|
+
this.G = error;
|
|
703
703
|
this.h.notify(this, LOADING_BIT, 0);
|
|
704
704
|
this.f = ERROR_BIT;
|
|
705
705
|
if (this.s === EFFECT_USER) {
|
|
706
706
|
try {
|
|
707
|
-
return this.
|
|
707
|
+
return this.N ? this.N(error, () => {
|
|
708
708
|
var _a;
|
|
709
|
-
(_a = this.
|
|
710
|
-
this.
|
|
709
|
+
(_a = this.C) == null ? void 0 : _a.call(this);
|
|
710
|
+
this.C = void 0;
|
|
711
711
|
}) : console.error(error);
|
|
712
712
|
} catch (e) {
|
|
713
713
|
error = e;
|
|
@@ -716,51 +716,51 @@ var Effect = class extends Computation {
|
|
|
716
716
|
if (!this.h.notify(this, ERROR_BIT, ERROR_BIT))
|
|
717
717
|
throw error;
|
|
718
718
|
}
|
|
719
|
-
|
|
719
|
+
z() {
|
|
720
720
|
var _a;
|
|
721
721
|
if (this.a === STATE_DISPOSED)
|
|
722
722
|
return;
|
|
723
|
-
this.
|
|
723
|
+
this.U = void 0;
|
|
724
|
+
this.O = void 0;
|
|
724
725
|
this.N = void 0;
|
|
725
|
-
this.
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
super.y();
|
|
726
|
+
(_a = this.C) == null ? void 0 : _a.call(this);
|
|
727
|
+
this.C = void 0;
|
|
728
|
+
super.z();
|
|
729
729
|
}
|
|
730
|
-
|
|
730
|
+
u(type) {
|
|
731
731
|
var _a;
|
|
732
732
|
if (type) {
|
|
733
|
-
if (this.
|
|
734
|
-
(_a = this.
|
|
733
|
+
if (this.V && this.a !== STATE_DISPOSED) {
|
|
734
|
+
(_a = this.C) == null ? void 0 : _a.call(this);
|
|
735
735
|
try {
|
|
736
|
-
this.
|
|
736
|
+
this.C = this.U(this.g, this.O);
|
|
737
737
|
} catch (e) {
|
|
738
738
|
if (!this.h.notify(this, ERROR_BIT, ERROR_BIT))
|
|
739
739
|
throw e;
|
|
740
740
|
} finally {
|
|
741
|
-
this.
|
|
742
|
-
this.
|
|
741
|
+
this.O = this.g;
|
|
742
|
+
this.V = false;
|
|
743
743
|
}
|
|
744
744
|
}
|
|
745
745
|
} else
|
|
746
746
|
this.a !== STATE_CLEAN && runTop(this);
|
|
747
747
|
}
|
|
748
748
|
};
|
|
749
|
-
function runComputation() {
|
|
750
|
-
this.a !== STATE_CLEAN && runTop(this);
|
|
751
|
-
}
|
|
752
749
|
var EagerComputation = class extends Computation {
|
|
753
750
|
constructor(initialValue, compute2, options) {
|
|
754
751
|
super(initialValue, compute2, options);
|
|
755
|
-
!(options == null ? void 0 : options.defer) && this.
|
|
752
|
+
!(options == null ? void 0 : options.defer) && this.y();
|
|
756
753
|
}
|
|
757
754
|
r(state, skipQueue) {
|
|
758
|
-
if (this.a >= state && !this.
|
|
755
|
+
if (this.a >= state && !this.x)
|
|
759
756
|
return;
|
|
760
|
-
if (!skipQueue && (this.a === STATE_CLEAN || this.a === STATE_CHECK && this.
|
|
761
|
-
this.h.enqueue(EFFECT_PURE,
|
|
757
|
+
if (!skipQueue && (this.a === STATE_CLEAN || this.a === STATE_CHECK && this.x))
|
|
758
|
+
this.h.enqueue(EFFECT_PURE, this.u.bind(this));
|
|
762
759
|
super.r(state, skipQueue);
|
|
763
760
|
}
|
|
761
|
+
u() {
|
|
762
|
+
this.a !== STATE_CLEAN && runTop(this);
|
|
763
|
+
}
|
|
764
764
|
};
|
|
765
765
|
var FirewallComputation = class extends Computation {
|
|
766
766
|
firewall = true;
|
|
@@ -768,12 +768,15 @@ var FirewallComputation = class extends Computation {
|
|
|
768
768
|
super(void 0, compute2);
|
|
769
769
|
}
|
|
770
770
|
r(state, skipQueue) {
|
|
771
|
-
if (this.a >= state && !this.
|
|
771
|
+
if (this.a >= state && !this.x)
|
|
772
772
|
return;
|
|
773
|
-
if (!skipQueue && (this.a === STATE_CLEAN || this.a === STATE_CHECK && this.
|
|
774
|
-
this.h.enqueue(EFFECT_PURE,
|
|
773
|
+
if (!skipQueue && (this.a === STATE_CLEAN || this.a === STATE_CHECK && this.x))
|
|
774
|
+
this.h.enqueue(EFFECT_PURE, this.u.bind(this));
|
|
775
775
|
super.r(state, true);
|
|
776
|
-
this.
|
|
776
|
+
this.x = !!skipQueue;
|
|
777
|
+
}
|
|
778
|
+
u() {
|
|
779
|
+
this.a !== STATE_CLEAN && runTop(this);
|
|
777
780
|
}
|
|
778
781
|
};
|
|
779
782
|
function runTop(node) {
|
|
@@ -785,7 +788,7 @@ function runTop(node) {
|
|
|
785
788
|
}
|
|
786
789
|
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
787
790
|
if (ancestors[i].a !== STATE_DISPOSED)
|
|
788
|
-
ancestors[i].
|
|
791
|
+
ancestors[i].y();
|
|
789
792
|
}
|
|
790
793
|
}
|
|
791
794
|
|
|
@@ -858,7 +861,7 @@ function createAsync(compute2, value, options) {
|
|
|
858
861
|
(error) => {
|
|
859
862
|
if (abort)
|
|
860
863
|
return;
|
|
861
|
-
node.
|
|
864
|
+
node.M(error);
|
|
862
865
|
}
|
|
863
866
|
);
|
|
864
867
|
} else {
|
|
@@ -884,7 +887,7 @@ function createAsync(compute2, value, options) {
|
|
|
884
887
|
read.refresh = () => {
|
|
885
888
|
node.a = STATE_DIRTY;
|
|
886
889
|
refreshing = true;
|
|
887
|
-
node.
|
|
890
|
+
node.y();
|
|
888
891
|
};
|
|
889
892
|
return read;
|
|
890
893
|
}
|
|
@@ -1593,53 +1596,53 @@ function omit(props, ...keys) {
|
|
|
1593
1596
|
function mapArray(list, map, options) {
|
|
1594
1597
|
const keyFn = typeof (options == null ? void 0 : options.keyed) === "function" ? options.keyed : void 0;
|
|
1595
1598
|
return updateKeyedMap.bind({
|
|
1596
|
-
|
|
1599
|
+
H: new Owner(),
|
|
1597
1600
|
i: 0,
|
|
1598
1601
|
$: list,
|
|
1599
|
-
|
|
1600
|
-
|
|
1602
|
+
w: [],
|
|
1603
|
+
D: map,
|
|
1601
1604
|
e: [],
|
|
1602
1605
|
b: [],
|
|
1603
|
-
|
|
1606
|
+
E: keyFn,
|
|
1604
1607
|
j: keyFn || (options == null ? void 0 : options.keyed) === false ? [] : void 0,
|
|
1605
1608
|
k: map.length > 1 ? [] : void 0,
|
|
1606
|
-
|
|
1609
|
+
I: options == null ? void 0 : options.fallback
|
|
1607
1610
|
});
|
|
1608
1611
|
}
|
|
1609
1612
|
var pureOptions = { pureWrite: true };
|
|
1610
1613
|
function updateKeyedMap() {
|
|
1611
1614
|
const newItems = this.$() || [], newLen = newItems.length;
|
|
1612
1615
|
newItems[$TRACK];
|
|
1613
|
-
runWithOwner(this.
|
|
1616
|
+
runWithOwner(this.H, () => {
|
|
1614
1617
|
let i, j, mapper = this.j ? () => {
|
|
1615
1618
|
this.j[j] = new Computation(newItems[j], null, pureOptions);
|
|
1616
1619
|
this.k && (this.k[j] = new Computation(j, null, pureOptions));
|
|
1617
|
-
return this.
|
|
1620
|
+
return this.D(
|
|
1618
1621
|
Computation.prototype.read.bind(this.j[j]),
|
|
1619
1622
|
this.k ? Computation.prototype.read.bind(this.k[j]) : void 0
|
|
1620
1623
|
);
|
|
1621
1624
|
} : this.k ? () => {
|
|
1622
1625
|
const item = newItems[j];
|
|
1623
1626
|
this.k[j] = new Computation(j, null, pureOptions);
|
|
1624
|
-
return this.
|
|
1627
|
+
return this.D(() => item, Computation.prototype.read.bind(this.k[j]));
|
|
1625
1628
|
} : () => {
|
|
1626
1629
|
const item = newItems[j];
|
|
1627
|
-
return this.
|
|
1630
|
+
return this.D(() => item);
|
|
1628
1631
|
};
|
|
1629
1632
|
if (newLen === 0) {
|
|
1630
1633
|
if (this.i !== 0) {
|
|
1631
|
-
this.
|
|
1634
|
+
this.H.dispose(false);
|
|
1632
1635
|
this.b = [];
|
|
1633
|
-
this.
|
|
1636
|
+
this.w = [];
|
|
1634
1637
|
this.e = [];
|
|
1635
1638
|
this.i = 0;
|
|
1636
1639
|
this.j && (this.j = []);
|
|
1637
1640
|
this.k && (this.k = []);
|
|
1638
1641
|
}
|
|
1639
|
-
if (this.
|
|
1642
|
+
if (this.I && !this.e[0]) {
|
|
1640
1643
|
this.e[0] = compute(
|
|
1641
1644
|
this.b[0] = new Owner(),
|
|
1642
|
-
this.
|
|
1645
|
+
this.I,
|
|
1643
1646
|
null
|
|
1644
1647
|
);
|
|
1645
1648
|
}
|
|
@@ -1648,17 +1651,17 @@ function updateKeyedMap() {
|
|
|
1648
1651
|
this.b[0].dispose();
|
|
1649
1652
|
this.e = new Array(newLen);
|
|
1650
1653
|
for (j = 0; j < newLen; j++) {
|
|
1651
|
-
this.
|
|
1654
|
+
this.w[j] = newItems[j];
|
|
1652
1655
|
this.e[j] = compute(this.b[j] = new Owner(), mapper, null);
|
|
1653
1656
|
}
|
|
1654
1657
|
this.i = newLen;
|
|
1655
1658
|
} else {
|
|
1656
1659
|
let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.j ? new Array(newLen) : void 0, tempIndexes = this.k ? new Array(newLen) : void 0;
|
|
1657
|
-
for (start = 0, end = Math.min(this.i, newLen); start < end && (this.
|
|
1660
|
+
for (start = 0, end = Math.min(this.i, newLen); start < end && (this.w[start] === newItems[start] || this.j && compare(this.E, this.w[start], newItems[start])); start++) {
|
|
1658
1661
|
if (this.j)
|
|
1659
1662
|
this.j[start].write(newItems[start]);
|
|
1660
1663
|
}
|
|
1661
|
-
for (end = this.i - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.
|
|
1664
|
+
for (end = this.i - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.w[end] === newItems[newEnd] || this.j && compare(this.E, this.w[end], newItems[newEnd])); end--, newEnd--) {
|
|
1662
1665
|
temp[newEnd] = this.e[end];
|
|
1663
1666
|
tempNodes[newEnd] = this.b[end];
|
|
1664
1667
|
tempRows && (tempRows[newEnd] = this.j[end]);
|
|
@@ -1668,14 +1671,14 @@ function updateKeyedMap() {
|
|
|
1668
1671
|
newIndicesNext = new Array(newEnd + 1);
|
|
1669
1672
|
for (j = newEnd; j >= start; j--) {
|
|
1670
1673
|
item = newItems[j];
|
|
1671
|
-
key = this.
|
|
1674
|
+
key = this.E ? this.E(item) : item;
|
|
1672
1675
|
i = newIndices.get(key);
|
|
1673
1676
|
newIndicesNext[j] = i === void 0 ? -1 : i;
|
|
1674
1677
|
newIndices.set(key, j);
|
|
1675
1678
|
}
|
|
1676
1679
|
for (i = start; i <= end; i++) {
|
|
1677
|
-
item = this.
|
|
1678
|
-
key = this.
|
|
1680
|
+
item = this.w[i];
|
|
1681
|
+
key = this.E ? this.E(item) : item;
|
|
1679
1682
|
j = newIndices.get(key);
|
|
1680
1683
|
if (j !== void 0 && j !== -1) {
|
|
1681
1684
|
temp[j] = this.e[i];
|
|
@@ -1704,40 +1707,40 @@ function updateKeyedMap() {
|
|
|
1704
1707
|
}
|
|
1705
1708
|
}
|
|
1706
1709
|
this.e = this.e.slice(0, this.i = newLen);
|
|
1707
|
-
this.
|
|
1710
|
+
this.w = newItems.slice(0);
|
|
1708
1711
|
}
|
|
1709
1712
|
});
|
|
1710
1713
|
return this.e;
|
|
1711
1714
|
}
|
|
1712
1715
|
function repeat(count, map, options) {
|
|
1713
1716
|
return updateRepeat.bind({
|
|
1714
|
-
|
|
1717
|
+
H: new Owner(),
|
|
1715
1718
|
i: 0,
|
|
1716
1719
|
q: 0,
|
|
1717
1720
|
aa: count,
|
|
1718
|
-
|
|
1721
|
+
D: map,
|
|
1719
1722
|
b: [],
|
|
1720
1723
|
e: [],
|
|
1721
1724
|
ba: options == null ? void 0 : options.from,
|
|
1722
|
-
|
|
1725
|
+
I: options == null ? void 0 : options.fallback
|
|
1723
1726
|
});
|
|
1724
1727
|
}
|
|
1725
1728
|
function updateRepeat() {
|
|
1726
1729
|
var _a;
|
|
1727
1730
|
const newLen = this.aa();
|
|
1728
1731
|
const from = ((_a = this.ba) == null ? void 0 : _a.call(this)) || 0;
|
|
1729
|
-
runWithOwner(this.
|
|
1732
|
+
runWithOwner(this.H, () => {
|
|
1730
1733
|
if (newLen === 0) {
|
|
1731
1734
|
if (this.i !== 0) {
|
|
1732
|
-
this.
|
|
1735
|
+
this.H.dispose(false);
|
|
1733
1736
|
this.b = [];
|
|
1734
1737
|
this.e = [];
|
|
1735
1738
|
this.i = 0;
|
|
1736
1739
|
}
|
|
1737
|
-
if (this.
|
|
1740
|
+
if (this.I && !this.e[0]) {
|
|
1738
1741
|
this.e[0] = compute(
|
|
1739
1742
|
this.b[0] = new Owner(),
|
|
1740
|
-
this.
|
|
1743
|
+
this.I,
|
|
1741
1744
|
null
|
|
1742
1745
|
);
|
|
1743
1746
|
}
|
|
@@ -1767,7 +1770,7 @@ function updateRepeat() {
|
|
|
1767
1770
|
for (let i2 = 0; i2 < difference; i2++) {
|
|
1768
1771
|
this.e[i2] = compute(
|
|
1769
1772
|
this.b[i2] = new Owner(),
|
|
1770
|
-
() => this.
|
|
1773
|
+
() => this.D(i2 + from),
|
|
1771
1774
|
null
|
|
1772
1775
|
);
|
|
1773
1776
|
}
|
|
@@ -1775,7 +1778,7 @@ function updateRepeat() {
|
|
|
1775
1778
|
for (let i = prevTo; i < to; i++) {
|
|
1776
1779
|
this.e[i - from] = compute(
|
|
1777
1780
|
this.b[i - from] = new Owner(),
|
|
1778
|
-
() => this.
|
|
1781
|
+
() => this.D(i),
|
|
1779
1782
|
null
|
|
1780
1783
|
);
|
|
1781
1784
|
}
|
|
@@ -1791,17 +1794,17 @@ function compare(key, a, b) {
|
|
|
1791
1794
|
|
|
1792
1795
|
// src/boundaries.ts
|
|
1793
1796
|
var BoundaryComputation = class extends EagerComputation {
|
|
1794
|
-
|
|
1797
|
+
J;
|
|
1795
1798
|
constructor(compute2, propagationMask) {
|
|
1796
1799
|
super(void 0, compute2, { defer: true });
|
|
1797
|
-
this.
|
|
1800
|
+
this.J = propagationMask;
|
|
1798
1801
|
}
|
|
1799
1802
|
write(value, flags) {
|
|
1800
|
-
super.write(value, flags & ~this.
|
|
1801
|
-
if (this.
|
|
1803
|
+
super.write(value, flags & ~this.J);
|
|
1804
|
+
if (this.J & LOADING_BIT && !(this.f & UNINITIALIZED_BIT)) {
|
|
1802
1805
|
flags &= ~LOADING_BIT;
|
|
1803
1806
|
}
|
|
1804
|
-
this.h.notify(this, this.
|
|
1807
|
+
this.h.notify(this, this.J, flags);
|
|
1805
1808
|
return this.g;
|
|
1806
1809
|
}
|
|
1807
1810
|
};
|
|
@@ -1820,8 +1823,8 @@ function createBoundChildren(owner, fn, queue, mask) {
|
|
|
1820
1823
|
}
|
|
1821
1824
|
var ConditionalQueue = class extends Queue {
|
|
1822
1825
|
n;
|
|
1823
|
-
O = /* @__PURE__ */ new Set();
|
|
1824
1826
|
P = /* @__PURE__ */ new Set();
|
|
1827
|
+
Q = /* @__PURE__ */ new Set();
|
|
1825
1828
|
constructor(disabled) {
|
|
1826
1829
|
super();
|
|
1827
1830
|
this.n = disabled;
|
|
@@ -1835,16 +1838,16 @@ var ConditionalQueue = class extends Queue {
|
|
|
1835
1838
|
if (this.n.read()) {
|
|
1836
1839
|
if (type & LOADING_BIT) {
|
|
1837
1840
|
if (flags & LOADING_BIT) {
|
|
1838
|
-
this.
|
|
1841
|
+
this.Q.add(node);
|
|
1839
1842
|
type &= ~LOADING_BIT;
|
|
1840
|
-
} else if (this.
|
|
1843
|
+
} else if (this.Q.delete(node))
|
|
1841
1844
|
type &= ~LOADING_BIT;
|
|
1842
1845
|
}
|
|
1843
1846
|
if (type & ERROR_BIT) {
|
|
1844
1847
|
if (flags & ERROR_BIT) {
|
|
1845
|
-
this.
|
|
1848
|
+
this.P.add(node);
|
|
1846
1849
|
type &= ~ERROR_BIT;
|
|
1847
|
-
} else if (this.
|
|
1850
|
+
} else if (this.P.delete(node))
|
|
1848
1851
|
type &= ~ERROR_BIT;
|
|
1849
1852
|
}
|
|
1850
1853
|
}
|
|
@@ -1852,12 +1855,12 @@ var ConditionalQueue = class extends Queue {
|
|
|
1852
1855
|
}
|
|
1853
1856
|
};
|
|
1854
1857
|
var CollectionQueue = class extends Queue {
|
|
1855
|
-
|
|
1858
|
+
R;
|
|
1856
1859
|
b = /* @__PURE__ */ new Set();
|
|
1857
1860
|
n = new Computation(false, null, { pureWrite: true });
|
|
1858
1861
|
constructor(type) {
|
|
1859
1862
|
super();
|
|
1860
|
-
this.
|
|
1863
|
+
this.R = type;
|
|
1861
1864
|
}
|
|
1862
1865
|
run(type) {
|
|
1863
1866
|
if (!type || this.n.read())
|
|
@@ -1865,9 +1868,9 @@ var CollectionQueue = class extends Queue {
|
|
|
1865
1868
|
return super.run(type);
|
|
1866
1869
|
}
|
|
1867
1870
|
notify(node, type, flags) {
|
|
1868
|
-
if (!(type & this.
|
|
1871
|
+
if (!(type & this.R))
|
|
1869
1872
|
return super.notify(node, type, flags);
|
|
1870
|
-
if (flags & this.
|
|
1873
|
+
if (flags & this.R) {
|
|
1871
1874
|
this.b.add(node);
|
|
1872
1875
|
if (this.b.size === 1)
|
|
1873
1876
|
this.n.write(true);
|
|
@@ -1876,7 +1879,7 @@ var CollectionQueue = class extends Queue {
|
|
|
1876
1879
|
if (this.b.size === 0)
|
|
1877
1880
|
this.n.write(false);
|
|
1878
1881
|
}
|
|
1879
|
-
type &= ~this.
|
|
1882
|
+
type &= ~this.R;
|
|
1880
1883
|
return type ? super.notify(node, type, flags) : true;
|
|
1881
1884
|
}
|
|
1882
1885
|
};
|
|
@@ -1888,12 +1891,12 @@ function createBoundary(fn, condition) {
|
|
|
1888
1891
|
const tree = createBoundChildren(owner, fn, queue, 0);
|
|
1889
1892
|
new EagerComputation(void 0, () => {
|
|
1890
1893
|
const disabled = queue.n.read();
|
|
1891
|
-
tree.
|
|
1894
|
+
tree.J = disabled ? ERROR_BIT | LOADING_BIT : 0;
|
|
1892
1895
|
if (!disabled) {
|
|
1893
|
-
queue.
|
|
1894
|
-
queue.
|
|
1896
|
+
queue.Q.forEach((node) => queue.notify(node, LOADING_BIT, LOADING_BIT));
|
|
1897
|
+
queue.P.forEach((node) => queue.notify(node, ERROR_BIT, ERROR_BIT));
|
|
1898
|
+
queue.Q.clear();
|
|
1895
1899
|
queue.P.clear();
|
|
1896
|
-
queue.O.clear();
|
|
1897
1900
|
}
|
|
1898
1901
|
});
|
|
1899
1902
|
return () => queue.n.read() ? void 0 : tree.read();
|
|
@@ -1919,12 +1922,12 @@ function createErrorBoundary(fn, fallback) {
|
|
|
1919
1922
|
return createCollectionBoundary(
|
|
1920
1923
|
ERROR_BIT,
|
|
1921
1924
|
fn,
|
|
1922
|
-
(queue) => fallback(queue.b.values().next().value.
|
|
1925
|
+
(queue) => fallback(queue.b.values().next().value.G, () => {
|
|
1923
1926
|
var _a;
|
|
1924
1927
|
incrementClock();
|
|
1925
1928
|
for (let node of queue.b) {
|
|
1926
1929
|
node.a = STATE_DIRTY;
|
|
1927
|
-
(_a = node.h) == null ? void 0 : _a.enqueue(node.s, node);
|
|
1930
|
+
(_a = node.h) == null ? void 0 : _a.enqueue(node.s, node.u.bind(node));
|
|
1928
1931
|
}
|
|
1929
1932
|
})
|
|
1930
1933
|
);
|