@solidjs/signals 0.4.5 → 0.4.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 +11 -6
- package/dist/node.cjs +143 -138
- package/dist/prod.js +143 -138
- package/package.json +1 -1
package/dist/node.cjs
CHANGED
|
@@ -123,7 +123,7 @@ var Queue = class {
|
|
|
123
123
|
this.f[0].push.apply(this.f[0], queue.f[0]);
|
|
124
124
|
this.f[1].push.apply(this.f[1], queue.f[1]);
|
|
125
125
|
for (let i = 0; i < queue.e.length; i++) {
|
|
126
|
-
const og = this.e.find((c) => c.
|
|
126
|
+
const og = this.e.find((c) => c.h === queue.e[i].h);
|
|
127
127
|
if (og)
|
|
128
128
|
og.merge(queue.e[i]);
|
|
129
129
|
else
|
|
@@ -146,7 +146,7 @@ var Transition = class _Transition {
|
|
|
146
146
|
s = /* @__PURE__ */ new Set();
|
|
147
147
|
R = /* @__PURE__ */ new Set();
|
|
148
148
|
W = /* @__PURE__ */ new Set();
|
|
149
|
-
|
|
149
|
+
J = false;
|
|
150
150
|
f = [[], []];
|
|
151
151
|
u = /* @__PURE__ */ new Map();
|
|
152
152
|
E = [];
|
|
@@ -222,7 +222,7 @@ var Transition = class _Transition {
|
|
|
222
222
|
this.f[1].push.apply(this.f[1], queue.f[1]);
|
|
223
223
|
this.E.push.apply(this.E, queue.E);
|
|
224
224
|
for (let i = 0; i < queue.e.length; i++) {
|
|
225
|
-
const og = this.e.find((c) => c.
|
|
225
|
+
const og = this.e.find((c) => c.h === queue.e[i].h);
|
|
226
226
|
if (og)
|
|
227
227
|
og.merge(queue.e[i]);
|
|
228
228
|
else
|
|
@@ -237,9 +237,9 @@ var Transition = class _Transition {
|
|
|
237
237
|
queueMicrotask(() => this.flush());
|
|
238
238
|
}
|
|
239
239
|
runTransition(fn, force = false) {
|
|
240
|
-
if (this.
|
|
241
|
-
if (this.
|
|
242
|
-
return this.
|
|
240
|
+
if (this.J) {
|
|
241
|
+
if (this.J instanceof _Transition)
|
|
242
|
+
return this.J.runTransition(fn, force);
|
|
243
243
|
if (!force)
|
|
244
244
|
throw new Error("Transition already completed");
|
|
245
245
|
fn();
|
|
@@ -263,12 +263,12 @@ var Transition = class _Transition {
|
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
265
|
addOptimistic(fn) {
|
|
266
|
-
if (fn.
|
|
267
|
-
mergeTransitions(fn.
|
|
268
|
-
ActiveTransition = fn.
|
|
266
|
+
if (fn.j && fn.j !== this) {
|
|
267
|
+
mergeTransitions(fn.j, this);
|
|
268
|
+
ActiveTransition = fn.j;
|
|
269
269
|
return;
|
|
270
270
|
}
|
|
271
|
-
fn.
|
|
271
|
+
fn.j = this;
|
|
272
272
|
this.W.add(fn);
|
|
273
273
|
}
|
|
274
274
|
};
|
|
@@ -277,12 +277,12 @@ function transition(fn) {
|
|
|
277
277
|
queueMicrotask(() => t.runTransition(() => fn((fn2) => t.runTransition(fn2))));
|
|
278
278
|
}
|
|
279
279
|
function cloneGraph(node) {
|
|
280
|
-
if (node.
|
|
281
|
-
if (node.
|
|
282
|
-
mergeTransitions(node.
|
|
283
|
-
ActiveTransition = node.
|
|
280
|
+
if (node.j) {
|
|
281
|
+
if (node.j !== ActiveTransition) {
|
|
282
|
+
mergeTransitions(node.j, ActiveTransition);
|
|
283
|
+
ActiveTransition = node.j;
|
|
284
284
|
}
|
|
285
|
-
return node.
|
|
285
|
+
return node.j.a.get(node);
|
|
286
286
|
}
|
|
287
287
|
const clone = Object.create(Object.getPrototypeOf(node));
|
|
288
288
|
Object.assign(clone, node, {
|
|
@@ -290,10 +290,12 @@ function cloneGraph(node) {
|
|
|
290
290
|
r: null,
|
|
291
291
|
b: null,
|
|
292
292
|
a: node.a ? [...node.a] : null,
|
|
293
|
-
|
|
293
|
+
h: node
|
|
294
294
|
});
|
|
295
|
+
if (clone.F)
|
|
296
|
+
clone.g |= UNINITIALIZED_BIT;
|
|
295
297
|
ActiveTransition.a.set(node, clone);
|
|
296
|
-
node.
|
|
298
|
+
node.j = ActiveTransition;
|
|
297
299
|
if (node.a) {
|
|
298
300
|
for (let i = 0; i < node.a.length; i++)
|
|
299
301
|
node.a[i].b.push(clone);
|
|
@@ -301,7 +303,7 @@ function cloneGraph(node) {
|
|
|
301
303
|
if (node.b) {
|
|
302
304
|
clone.b = [];
|
|
303
305
|
for (let i = 0, length = node.b.length; i < length; i++) {
|
|
304
|
-
!node.b[i].
|
|
306
|
+
!node.b[i].h && clone.b.push(cloneGraph(node.b[i]));
|
|
305
307
|
}
|
|
306
308
|
}
|
|
307
309
|
return clone;
|
|
@@ -314,7 +316,7 @@ function replaceSourceObservers(node, transition2) {
|
|
|
314
316
|
transitionSource = transition2.a.get(node.a[i]);
|
|
315
317
|
source = transitionSource || node.a[i];
|
|
316
318
|
if (source.b && (swap = source.b.indexOf(node)) !== -1) {
|
|
317
|
-
source.b[swap] = transitionSource ? node.
|
|
319
|
+
source.b[swap] = transitionSource ? node.h : source.b[source.b.length - 1];
|
|
318
320
|
!transitionSource && source.b.pop();
|
|
319
321
|
}
|
|
320
322
|
}
|
|
@@ -322,15 +324,15 @@ function replaceSourceObservers(node, transition2) {
|
|
|
322
324
|
function cloneQueue(queue, parent, clonedQueues) {
|
|
323
325
|
const clone = Object.create(Object.getPrototypeOf(queue));
|
|
324
326
|
Object.assign(clone, queue, {
|
|
325
|
-
|
|
327
|
+
h: queue,
|
|
326
328
|
m: parent,
|
|
327
329
|
e: [],
|
|
328
330
|
enqueue(type, fn) {
|
|
329
331
|
ActiveTransition == null ? void 0 : ActiveTransition.enqueue(type, fn);
|
|
330
332
|
},
|
|
331
333
|
notify(node, type, flags) {
|
|
332
|
-
node = node.
|
|
333
|
-
if (!clone.
|
|
334
|
+
node = node.h || node;
|
|
335
|
+
if (!clone.G || type & LOADING_BIT) {
|
|
334
336
|
type &= ~LOADING_BIT;
|
|
335
337
|
ActiveTransition == null ? void 0 : ActiveTransition.notify(node, LOADING_BIT, flags);
|
|
336
338
|
if (!type)
|
|
@@ -347,7 +349,7 @@ function cloneQueue(queue, parent, clonedQueues) {
|
|
|
347
349
|
}
|
|
348
350
|
function resolveQueues(children) {
|
|
349
351
|
for (const child of children) {
|
|
350
|
-
const og = child.
|
|
352
|
+
const og = child.h;
|
|
351
353
|
if (og) {
|
|
352
354
|
const clonedChildren = child.e;
|
|
353
355
|
delete child.enqueue;
|
|
@@ -355,47 +357,49 @@ function resolveQueues(children) {
|
|
|
355
357
|
delete child.m;
|
|
356
358
|
delete child.e;
|
|
357
359
|
Object.assign(og, child);
|
|
358
|
-
delete og.
|
|
360
|
+
delete og.h;
|
|
359
361
|
resolveQueues(clonedChildren);
|
|
360
|
-
} else if (child.m.
|
|
361
|
-
child.m.
|
|
362
|
+
} else if (child.m.h) {
|
|
363
|
+
child.m.h.addChild(child);
|
|
362
364
|
}
|
|
363
365
|
}
|
|
364
366
|
}
|
|
365
367
|
function mergeTransitions(t1, t2) {
|
|
366
368
|
t2.a.forEach((value, key) => {
|
|
367
|
-
key.
|
|
369
|
+
key.j = t1;
|
|
368
370
|
t1.a.set(key, value);
|
|
369
371
|
});
|
|
370
372
|
t2.W.forEach((c) => {
|
|
371
|
-
c.
|
|
373
|
+
c.j = t1;
|
|
372
374
|
t1.W.add(c);
|
|
373
375
|
});
|
|
374
376
|
t2.R.forEach((p) => t1.R.add(p));
|
|
375
377
|
t2.s.forEach((n) => t1.s.add(n));
|
|
376
378
|
t1.merge(t2);
|
|
377
|
-
t2.
|
|
379
|
+
t2.J = t1;
|
|
378
380
|
}
|
|
379
381
|
function finishTransition(transition2) {
|
|
380
|
-
if (transition2.
|
|
382
|
+
if (transition2.J || transition2.X || transition2.R.size || transition2.s.size)
|
|
381
383
|
return;
|
|
382
384
|
for (const [source, clone] of transition2.a) {
|
|
383
|
-
if (source === clone || source.
|
|
385
|
+
if (source === clone || source.j !== transition2)
|
|
384
386
|
continue;
|
|
385
387
|
if (clone.a)
|
|
386
388
|
replaceSourceObservers(clone, transition2);
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
389
|
+
if (!(clone.g & UNINITIALIZED_BIT)) {
|
|
390
|
+
source.dispose(false);
|
|
391
|
+
source.emptyDisposal();
|
|
392
|
+
Object.assign(source, clone);
|
|
393
|
+
delete source.h;
|
|
394
|
+
}
|
|
395
|
+
delete source.j;
|
|
392
396
|
}
|
|
393
397
|
globalQueue.f[0].push.apply(globalQueue.f[0], transition2.f[0]);
|
|
394
398
|
globalQueue.f[1].push.apply(globalQueue.f[1], transition2.f[1]);
|
|
395
399
|
resolveQueues(transition2.e);
|
|
396
|
-
transition2.
|
|
400
|
+
transition2.J = true;
|
|
397
401
|
for (const reset of transition2.W) {
|
|
398
|
-
delete reset.
|
|
402
|
+
delete reset.j;
|
|
399
403
|
reset();
|
|
400
404
|
}
|
|
401
405
|
globalQueue.flush();
|
|
@@ -452,20 +456,20 @@ var Owner = class {
|
|
|
452
456
|
let head = self ? this.B || this.m : this, current = this.r, next = null;
|
|
453
457
|
while (current && current.m === this) {
|
|
454
458
|
current.dispose(true);
|
|
455
|
-
current.
|
|
459
|
+
current.K();
|
|
456
460
|
next = current.r;
|
|
457
461
|
current.r = null;
|
|
458
462
|
current = next;
|
|
459
463
|
}
|
|
460
464
|
this.ea = 0;
|
|
461
465
|
if (self)
|
|
462
|
-
this.
|
|
466
|
+
this.K();
|
|
463
467
|
if (current)
|
|
464
468
|
current.B = !self ? this : this.B;
|
|
465
469
|
if (head)
|
|
466
470
|
head.r = current;
|
|
467
471
|
}
|
|
468
|
-
|
|
472
|
+
K() {
|
|
469
473
|
if (this.B)
|
|
470
474
|
this.B.r = null;
|
|
471
475
|
this.m = null;
|
|
@@ -555,9 +559,9 @@ var UNCHANGED = Symbol(0);
|
|
|
555
559
|
var Computation = class extends Owner {
|
|
556
560
|
a = null;
|
|
557
561
|
b = null;
|
|
558
|
-
|
|
559
|
-
K;
|
|
562
|
+
k;
|
|
560
563
|
L;
|
|
564
|
+
F;
|
|
561
565
|
// Used in __DEV__ mode, hopefully removed in production
|
|
562
566
|
ka;
|
|
563
567
|
// Using false is an optimization as an alternative to _equals: () => false
|
|
@@ -566,19 +570,19 @@ var Computation = class extends Owner {
|
|
|
566
570
|
da;
|
|
567
571
|
ga = false;
|
|
568
572
|
/** Whether the computation is an error or has ancestors that are unresolved */
|
|
569
|
-
|
|
573
|
+
g = 0;
|
|
570
574
|
/** Which flags raised by sources are handled, vs. being passed through. */
|
|
571
575
|
aa = DEFAULT_FLAGS;
|
|
572
576
|
M = -1;
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
577
|
+
H = false;
|
|
578
|
+
j;
|
|
579
|
+
h;
|
|
576
580
|
constructor(initialValue, compute2, options) {
|
|
577
581
|
super(options == null ? void 0 : options.id, compute2 === null);
|
|
578
|
-
this.
|
|
582
|
+
this.F = compute2;
|
|
579
583
|
this.c = compute2 ? STATE_DIRTY : STATE_CLEAN;
|
|
580
|
-
this.
|
|
581
|
-
this.
|
|
584
|
+
this.g = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
|
|
585
|
+
this.k = initialValue;
|
|
582
586
|
if ((options == null ? void 0 : options.equals) !== void 0)
|
|
583
587
|
this.$ = options.equals;
|
|
584
588
|
if (options == null ? void 0 : options.pureWrite)
|
|
@@ -586,17 +590,17 @@ var Computation = class extends Owner {
|
|
|
586
590
|
if (options == null ? void 0 : options.unobserved)
|
|
587
591
|
this.da = options == null ? void 0 : options.unobserved;
|
|
588
592
|
if (ActiveTransition) {
|
|
589
|
-
this.
|
|
593
|
+
this.j = ActiveTransition;
|
|
590
594
|
ActiveTransition.a.set(this, this);
|
|
591
595
|
}
|
|
592
596
|
}
|
|
593
597
|
fa() {
|
|
594
598
|
track(this);
|
|
595
|
-
newFlags |= this.
|
|
596
|
-
if (this.
|
|
597
|
-
throw this.
|
|
599
|
+
newFlags |= this.g & ~currentMask;
|
|
600
|
+
if (this.g & ERROR_BIT) {
|
|
601
|
+
throw this.L;
|
|
598
602
|
} else {
|
|
599
|
-
return this.
|
|
603
|
+
return this.k;
|
|
600
604
|
}
|
|
601
605
|
}
|
|
602
606
|
/**
|
|
@@ -604,16 +608,16 @@ var Computation = class extends Owner {
|
|
|
604
608
|
* Automatically re-executes the surrounding computation when the value changes
|
|
605
609
|
*/
|
|
606
610
|
read() {
|
|
607
|
-
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.
|
|
611
|
+
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.h && this.g & UNINITIALIZED_BIT)) {
|
|
608
612
|
const clone = ActiveTransition.a.get(this) || cloneGraph(this);
|
|
609
613
|
if (clone !== this)
|
|
610
614
|
return clone.read();
|
|
611
615
|
}
|
|
612
|
-
if (this.
|
|
613
|
-
if (this.
|
|
616
|
+
if (this.F) {
|
|
617
|
+
if (this.g & ERROR_BIT && this.M <= clock)
|
|
614
618
|
update(this);
|
|
615
619
|
else
|
|
616
|
-
this.
|
|
620
|
+
this.I();
|
|
617
621
|
}
|
|
618
622
|
return this.fa();
|
|
619
623
|
}
|
|
@@ -625,42 +629,42 @@ var Computation = class extends Owner {
|
|
|
625
629
|
* before continuing
|
|
626
630
|
*/
|
|
627
631
|
wait() {
|
|
628
|
-
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.
|
|
632
|
+
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.h && this.g & UNINITIALIZED_BIT)) {
|
|
629
633
|
const clone = ActiveTransition.a.get(this) || cloneGraph(this);
|
|
630
634
|
if (clone !== this)
|
|
631
635
|
return clone.wait();
|
|
632
636
|
}
|
|
633
|
-
if (this.
|
|
634
|
-
if (this.
|
|
637
|
+
if (this.F) {
|
|
638
|
+
if (this.g & ERROR_BIT && this.M <= clock)
|
|
635
639
|
update(this);
|
|
636
640
|
else
|
|
637
|
-
this.
|
|
641
|
+
this.I();
|
|
638
642
|
}
|
|
639
|
-
if ((notStale || this.
|
|
643
|
+
if ((notStale || this.g & UNINITIALIZED_BIT) && this.g & LOADING_BIT) {
|
|
640
644
|
track(this);
|
|
641
645
|
throw new NotReadyError();
|
|
642
646
|
}
|
|
643
|
-
if (staleCheck && this.
|
|
644
|
-
staleCheck.
|
|
647
|
+
if (staleCheck && this.g & LOADING_BIT) {
|
|
648
|
+
staleCheck.k = true;
|
|
645
649
|
}
|
|
646
650
|
return this.fa();
|
|
647
651
|
}
|
|
648
652
|
/** Update the computation with a new value. */
|
|
649
653
|
write(value, flags = 0, raw = false) {
|
|
650
|
-
if (ActiveTransition && !this.
|
|
654
|
+
if (ActiveTransition && !this.h) {
|
|
651
655
|
const clone = cloneGraph(this);
|
|
652
656
|
if (clone !== this)
|
|
653
657
|
return clone.write(value, flags, raw);
|
|
654
658
|
}
|
|
655
|
-
const newValue = !raw && typeof value === "function" ? value(this.
|
|
656
|
-
const valueChanged = newValue !== UNCHANGED && (!!(this.
|
|
657
|
-
this.$ === false || !this.$(this.
|
|
659
|
+
const newValue = !raw && typeof value === "function" ? value(this.k) : value;
|
|
660
|
+
const valueChanged = newValue !== UNCHANGED && (!!(this.g & UNINITIALIZED_BIT) || // this._stateFlags & LOADING_BIT & ~flags ||
|
|
661
|
+
this.$ === false || !this.$(this.k, newValue));
|
|
658
662
|
if (valueChanged) {
|
|
659
|
-
this.
|
|
660
|
-
this.
|
|
663
|
+
this.k = newValue;
|
|
664
|
+
this.L = void 0;
|
|
661
665
|
}
|
|
662
|
-
const changedFlagsMask = this.
|
|
663
|
-
this.
|
|
666
|
+
const changedFlagsMask = this.g ^ flags, changedFlags = changedFlagsMask & flags;
|
|
667
|
+
this.g = flags;
|
|
664
668
|
this.M = clock + 1;
|
|
665
669
|
if (this.b) {
|
|
666
670
|
for (let i = 0; i < this.b.length; i++) {
|
|
@@ -671,15 +675,15 @@ var Computation = class extends Owner {
|
|
|
671
675
|
}
|
|
672
676
|
}
|
|
673
677
|
}
|
|
674
|
-
return this.
|
|
678
|
+
return this.k;
|
|
675
679
|
}
|
|
676
680
|
/**
|
|
677
681
|
* Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
|
|
678
682
|
*/
|
|
679
683
|
x(state, skipQueue) {
|
|
680
|
-
if (this.c >= state && !this.
|
|
684
|
+
if (this.c >= state && !this.H)
|
|
681
685
|
return;
|
|
682
|
-
this.
|
|
686
|
+
this.H = !!skipQueue;
|
|
683
687
|
this.c = state;
|
|
684
688
|
if (this.b) {
|
|
685
689
|
for (let i = 0; i < this.b.length; i++) {
|
|
@@ -702,12 +706,12 @@ var Computation = class extends Owner {
|
|
|
702
706
|
}
|
|
703
707
|
if (this.c >= STATE_CHECK)
|
|
704
708
|
return;
|
|
705
|
-
const prevFlags = this.
|
|
709
|
+
const prevFlags = this.g & mask;
|
|
706
710
|
const deltaFlags = prevFlags ^ newFlags2;
|
|
707
711
|
if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
|
|
708
712
|
this.x(STATE_CHECK);
|
|
709
713
|
} else {
|
|
710
|
-
this.
|
|
714
|
+
this.g ^= deltaFlags;
|
|
711
715
|
if (this.b) {
|
|
712
716
|
for (let i = 0; i < this.b.length; i++) {
|
|
713
717
|
this.b[i].Y(mask, newFlags2);
|
|
@@ -716,13 +720,13 @@ var Computation = class extends Owner {
|
|
|
716
720
|
}
|
|
717
721
|
}
|
|
718
722
|
N(error) {
|
|
719
|
-
if (ActiveTransition && !this.
|
|
723
|
+
if (ActiveTransition && !this.h) {
|
|
720
724
|
const clone = cloneGraph(this);
|
|
721
725
|
if (clone !== this)
|
|
722
726
|
return clone.N(error);
|
|
723
727
|
}
|
|
724
|
-
this.
|
|
725
|
-
this.write(UNCHANGED, this.
|
|
728
|
+
this.L = error;
|
|
729
|
+
this.write(UNCHANGED, this.g & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
|
|
726
730
|
}
|
|
727
731
|
/**
|
|
728
732
|
* This is the core part of the reactivity system, which makes sure that the values are updated
|
|
@@ -731,8 +735,8 @@ var Computation = class extends Owner {
|
|
|
731
735
|
*
|
|
732
736
|
* This function will ensure that the value and states we read from the computation are up to date
|
|
733
737
|
*/
|
|
734
|
-
|
|
735
|
-
if (!this.
|
|
738
|
+
I() {
|
|
739
|
+
if (!this.F) {
|
|
736
740
|
return;
|
|
737
741
|
}
|
|
738
742
|
if (this.c === STATE_DISPOSED) {
|
|
@@ -745,8 +749,8 @@ var Computation = class extends Owner {
|
|
|
745
749
|
if (this.c === STATE_CHECK) {
|
|
746
750
|
for (let i = 0; i < this.a.length; i++) {
|
|
747
751
|
const source = ActiveTransition && ActiveTransition.a.get(this.a[i]) || this.a[i];
|
|
748
|
-
source.
|
|
749
|
-
observerFlags |= source.
|
|
752
|
+
source.I();
|
|
753
|
+
observerFlags |= source.g & ~UNINITIALIZED_BIT;
|
|
750
754
|
if (this.c === STATE_DIRTY) {
|
|
751
755
|
break;
|
|
752
756
|
}
|
|
@@ -762,17 +766,17 @@ var Computation = class extends Owner {
|
|
|
762
766
|
/**
|
|
763
767
|
* Remove ourselves from the owner graph and the computation graph
|
|
764
768
|
*/
|
|
765
|
-
|
|
769
|
+
K() {
|
|
766
770
|
if (this.c === STATE_DISPOSED)
|
|
767
771
|
return;
|
|
768
772
|
if (this.a)
|
|
769
773
|
removeSourceObservers(this, 0);
|
|
770
|
-
super.
|
|
774
|
+
super.K();
|
|
771
775
|
}
|
|
772
776
|
};
|
|
773
777
|
function track(computation) {
|
|
774
|
-
if (ActiveTransition && computation.
|
|
775
|
-
computation = computation.
|
|
778
|
+
if (ActiveTransition && computation.h)
|
|
779
|
+
computation = computation.h;
|
|
776
780
|
if (currentObserver) {
|
|
777
781
|
if (!newSources && currentObserver.a && currentObserver.a[newSourcesIndex] === computation) {
|
|
778
782
|
newSourcesIndex++;
|
|
@@ -782,7 +786,7 @@ function track(computation) {
|
|
|
782
786
|
newSources.push(computation);
|
|
783
787
|
}
|
|
784
788
|
if (updateCheck) {
|
|
785
|
-
updateCheck.
|
|
789
|
+
updateCheck.k = computation.M > currentObserver.M;
|
|
786
790
|
}
|
|
787
791
|
}
|
|
788
792
|
}
|
|
@@ -794,11 +798,11 @@ function update(node) {
|
|
|
794
798
|
try {
|
|
795
799
|
node.dispose(false);
|
|
796
800
|
node.emptyDisposal();
|
|
797
|
-
const result = compute(node, node.
|
|
801
|
+
const result = compute(node, node.F, node);
|
|
798
802
|
node.write(result, newFlags, true);
|
|
799
803
|
} catch (error) {
|
|
800
804
|
if (error instanceof NotReadyError) {
|
|
801
|
-
node.write(UNCHANGED, newFlags | LOADING_BIT | node.
|
|
805
|
+
node.write(UNCHANGED, newFlags | LOADING_BIT | node.g & UNINITIALIZED_BIT);
|
|
802
806
|
} else {
|
|
803
807
|
node.N(error);
|
|
804
808
|
}
|
|
@@ -858,20 +862,20 @@ function untrack(fn) {
|
|
|
858
862
|
}
|
|
859
863
|
function hasUpdated(fn) {
|
|
860
864
|
const current = updateCheck;
|
|
861
|
-
updateCheck = {
|
|
865
|
+
updateCheck = { k: false };
|
|
862
866
|
try {
|
|
863
867
|
fn();
|
|
864
|
-
return updateCheck.
|
|
868
|
+
return updateCheck.k;
|
|
865
869
|
} finally {
|
|
866
870
|
updateCheck = current;
|
|
867
871
|
}
|
|
868
872
|
}
|
|
869
873
|
function pendingCheck(fn, loadingValue) {
|
|
870
874
|
const current = staleCheck;
|
|
871
|
-
staleCheck = {
|
|
875
|
+
staleCheck = { k: false };
|
|
872
876
|
try {
|
|
873
877
|
latest(fn);
|
|
874
|
-
return staleCheck.
|
|
878
|
+
return staleCheck.k;
|
|
875
879
|
} catch (err) {
|
|
876
880
|
if (!(err instanceof NotReadyError))
|
|
877
881
|
return false;
|
|
@@ -916,7 +920,7 @@ function runWithObserver(observer, run) {
|
|
|
916
920
|
if (error instanceof NotReadyError) {
|
|
917
921
|
observer.write(
|
|
918
922
|
UNCHANGED,
|
|
919
|
-
newFlags | LOADING_BIT | observer.
|
|
923
|
+
newFlags | LOADING_BIT | observer.g & UNINITIALIZED_BIT
|
|
920
924
|
);
|
|
921
925
|
} else {
|
|
922
926
|
observer.N(error);
|
|
@@ -951,7 +955,7 @@ function compute(owner, fn, observer) {
|
|
|
951
955
|
currentMask = (observer == null ? void 0 : observer.aa) ?? DEFAULT_FLAGS;
|
|
952
956
|
notStale = true;
|
|
953
957
|
try {
|
|
954
|
-
return fn.call(observer, observer ? observer.
|
|
958
|
+
return fn.call(observer, observer ? observer.k : void 0);
|
|
955
959
|
} finally {
|
|
956
960
|
setOwner(prevOwner);
|
|
957
961
|
currentObserver = prevObserver;
|
|
@@ -975,25 +979,25 @@ var Effect = class extends Computation {
|
|
|
975
979
|
this._ = initialValue;
|
|
976
980
|
this.A = (options == null ? void 0 : options.render) ? EFFECT_RENDER : EFFECT_USER;
|
|
977
981
|
if (this.A === EFFECT_RENDER) {
|
|
978
|
-
this.
|
|
979
|
-
return !this.
|
|
982
|
+
this.F = function(p) {
|
|
983
|
+
return !this.h && clock > this.l.created && !(this.g & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
|
|
980
984
|
};
|
|
981
985
|
}
|
|
982
|
-
this.
|
|
986
|
+
this.I();
|
|
983
987
|
!(options == null ? void 0 : options.defer) && (this.A === EFFECT_USER ? this.l.enqueue(this.A, this.C.bind(this)) : this.C(this.A));
|
|
984
988
|
}
|
|
985
989
|
write(value, flags = 0) {
|
|
986
990
|
if (this.c == STATE_DIRTY) {
|
|
987
|
-
this.
|
|
991
|
+
this.g = flags;
|
|
988
992
|
if (this.A === EFFECT_RENDER) {
|
|
989
|
-
this.l.notify(this, LOADING_BIT | ERROR_BIT, this.
|
|
993
|
+
this.l.notify(this, LOADING_BIT | ERROR_BIT, this.g);
|
|
990
994
|
}
|
|
991
995
|
}
|
|
992
996
|
if (value === UNCHANGED)
|
|
993
|
-
return this.
|
|
994
|
-
this.
|
|
997
|
+
return this.k;
|
|
998
|
+
this.k = value;
|
|
995
999
|
this.ca = true;
|
|
996
|
-
this.
|
|
1000
|
+
this.L = void 0;
|
|
997
1001
|
return value;
|
|
998
1002
|
}
|
|
999
1003
|
x(state, skipQueue) {
|
|
@@ -1004,7 +1008,7 @@ var Effect = class extends Computation {
|
|
|
1004
1008
|
this.c = state;
|
|
1005
1009
|
}
|
|
1006
1010
|
Y(mask, newFlags2) {
|
|
1007
|
-
if (this.
|
|
1011
|
+
if (this.h) {
|
|
1008
1012
|
if (this.c >= STATE_DIRTY)
|
|
1009
1013
|
return;
|
|
1010
1014
|
if (mask & 3) {
|
|
@@ -1015,9 +1019,9 @@ var Effect = class extends Computation {
|
|
|
1015
1019
|
super.Y(mask, newFlags2);
|
|
1016
1020
|
}
|
|
1017
1021
|
N(error) {
|
|
1018
|
-
this.
|
|
1022
|
+
this.L = error;
|
|
1019
1023
|
this.l.notify(this, LOADING_BIT, 0);
|
|
1020
|
-
this.
|
|
1024
|
+
this.g = ERROR_BIT;
|
|
1021
1025
|
if (this.A === EFFECT_USER) {
|
|
1022
1026
|
try {
|
|
1023
1027
|
return this.Z ? this.Z(error, () => {
|
|
@@ -1032,7 +1036,7 @@ var Effect = class extends Computation {
|
|
|
1032
1036
|
if (!this.l.notify(this, ERROR_BIT, ERROR_BIT))
|
|
1033
1037
|
throw error;
|
|
1034
1038
|
}
|
|
1035
|
-
|
|
1039
|
+
K() {
|
|
1036
1040
|
var _a;
|
|
1037
1041
|
if (this.c === STATE_DISPOSED)
|
|
1038
1042
|
return;
|
|
@@ -1041,21 +1045,22 @@ var Effect = class extends Computation {
|
|
|
1041
1045
|
this.Z = void 0;
|
|
1042
1046
|
(_a = this.O) == null ? void 0 : _a.call(this);
|
|
1043
1047
|
this.O = void 0;
|
|
1044
|
-
|
|
1048
|
+
this.l.notify(this, ERROR_BIT | LOADING_BIT, 0);
|
|
1049
|
+
super.K();
|
|
1045
1050
|
}
|
|
1046
1051
|
C(type) {
|
|
1047
1052
|
var _a;
|
|
1048
1053
|
if (type) {
|
|
1049
|
-
const effect = this.
|
|
1054
|
+
const effect = this.h || this;
|
|
1050
1055
|
if (effect.ca && effect.c !== STATE_DISPOSED) {
|
|
1051
1056
|
(_a = effect.O) == null ? void 0 : _a.call(effect);
|
|
1052
1057
|
try {
|
|
1053
|
-
effect.O = effect.ba(effect.
|
|
1058
|
+
effect.O = effect.ba(effect.k, effect._);
|
|
1054
1059
|
} catch (e) {
|
|
1055
1060
|
if (!effect.l.notify(effect, ERROR_BIT, ERROR_BIT))
|
|
1056
1061
|
throw e;
|
|
1057
1062
|
} finally {
|
|
1058
|
-
effect._ = effect.
|
|
1063
|
+
effect._ = effect.k;
|
|
1059
1064
|
effect.ca = false;
|
|
1060
1065
|
}
|
|
1061
1066
|
}
|
|
@@ -1066,12 +1071,12 @@ var Effect = class extends Computation {
|
|
|
1066
1071
|
var EagerComputation = class extends Computation {
|
|
1067
1072
|
constructor(initialValue, compute2, options) {
|
|
1068
1073
|
super(initialValue, compute2, options);
|
|
1069
|
-
!(options == null ? void 0 : options.defer) && this.
|
|
1074
|
+
!(options == null ? void 0 : options.defer) && this.I();
|
|
1070
1075
|
}
|
|
1071
1076
|
x(state, skipQueue) {
|
|
1072
|
-
if (this.c >= state && !this.
|
|
1077
|
+
if (this.c >= state && !this.H)
|
|
1073
1078
|
return;
|
|
1074
|
-
if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.
|
|
1079
|
+
if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.H))
|
|
1075
1080
|
this.l.enqueue(EFFECT_PURE, this.C.bind(this));
|
|
1076
1081
|
super.x(state, skipQueue);
|
|
1077
1082
|
}
|
|
@@ -1085,12 +1090,12 @@ var FirewallComputation = class extends Computation {
|
|
|
1085
1090
|
super(void 0, compute2);
|
|
1086
1091
|
}
|
|
1087
1092
|
x(state, skipQueue) {
|
|
1088
|
-
if (this.c >= state && !this.
|
|
1093
|
+
if (this.c >= state && !this.H)
|
|
1089
1094
|
return;
|
|
1090
|
-
if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.
|
|
1095
|
+
if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.H))
|
|
1091
1096
|
this.l.enqueue(EFFECT_PURE, this.C.bind(this));
|
|
1092
1097
|
super.x(state, true);
|
|
1093
|
-
this.
|
|
1098
|
+
this.H = !!skipQueue;
|
|
1094
1099
|
}
|
|
1095
1100
|
C() {
|
|
1096
1101
|
this.c !== STATE_CLEAN && runTop(this);
|
|
@@ -1105,7 +1110,7 @@ function runTop(node) {
|
|
|
1105
1110
|
}
|
|
1106
1111
|
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
1107
1112
|
if (ancestors[i].c !== STATE_DISPOSED)
|
|
1108
|
-
ancestors[i].
|
|
1113
|
+
ancestors[i].I();
|
|
1109
1114
|
}
|
|
1110
1115
|
}
|
|
1111
1116
|
|
|
@@ -1240,7 +1245,7 @@ var storeTraps = {
|
|
|
1240
1245
|
return desc.get.call(receiver);
|
|
1241
1246
|
}
|
|
1242
1247
|
if (Writing == null ? void 0 : Writing.has(receiver)) {
|
|
1243
|
-
let value2 = tracked && (overridden || !proxySource) ? tracked.
|
|
1248
|
+
let value2 = tracked && (overridden || !proxySource) ? tracked.k : storeValue[property];
|
|
1244
1249
|
value2 === $DELETED && (value2 = void 0);
|
|
1245
1250
|
if (!isWrappable(value2))
|
|
1246
1251
|
return value2;
|
|
@@ -1785,7 +1790,7 @@ function createMemo(compute2, value, options) {
|
|
|
1785
1790
|
return resolvedValue;
|
|
1786
1791
|
}
|
|
1787
1792
|
resolvedValue = node.wait();
|
|
1788
|
-
if (!((_a = node.a) == null ? void 0 : _a.length) && ((_b = node.r) == null ? void 0 : _b.m) !== node && !(node.
|
|
1793
|
+
if (!((_a = node.a) == null ? void 0 : _a.length) && ((_b = node.r) == null ? void 0 : _b.m) !== node && !(node.g & UNINITIALIZED_BIT)) {
|
|
1789
1794
|
node.dispose();
|
|
1790
1795
|
node = void 0;
|
|
1791
1796
|
}
|
|
@@ -1847,12 +1852,12 @@ function createAsync(compute2, value, options) {
|
|
|
1847
1852
|
const read = node.wait.bind(node);
|
|
1848
1853
|
read.refresh = () => {
|
|
1849
1854
|
let n = node;
|
|
1850
|
-
if (ActiveTransition && !node.
|
|
1855
|
+
if (ActiveTransition && !node.h) {
|
|
1851
1856
|
n = cloneGraph(node);
|
|
1852
1857
|
}
|
|
1853
1858
|
n.c = STATE_DIRTY;
|
|
1854
1859
|
refreshing = true;
|
|
1855
|
-
n.
|
|
1860
|
+
n.I();
|
|
1856
1861
|
};
|
|
1857
1862
|
return read;
|
|
1858
1863
|
}
|
|
@@ -1920,7 +1925,7 @@ function createOptimistic(initial, compute2, key) {
|
|
|
1920
1925
|
if (!ActiveTransition)
|
|
1921
1926
|
throw new Error("createOptimistic can only be updated inside a transition");
|
|
1922
1927
|
ActiveTransition.addOptimistic(reset2);
|
|
1923
|
-
queueMicrotask(() => node.write(v));
|
|
1928
|
+
queueMicrotask(() => reset2.j && node.write(v));
|
|
1924
1929
|
};
|
|
1925
1930
|
var write = write2;
|
|
1926
1931
|
const node = new Computation(initial, null);
|
|
@@ -1951,7 +1956,7 @@ function createOptimistic(initial, compute2, key) {
|
|
|
1951
1956
|
throw new Error("createOptimistic can only be updated inside a transition");
|
|
1952
1957
|
ActiveTransition.addOptimistic(reset);
|
|
1953
1958
|
queueMicrotask(
|
|
1954
|
-
() => setStore((s) => {
|
|
1959
|
+
() => reset.j && setStore((s) => {
|
|
1955
1960
|
lastChange = typeof v === "function" ? v(lastChange) : v;
|
|
1956
1961
|
compute2(s.value, lastChange);
|
|
1957
1962
|
})
|
|
@@ -2169,11 +2174,11 @@ var BoundaryComputation = class extends EagerComputation {
|
|
|
2169
2174
|
}
|
|
2170
2175
|
write(value, flags) {
|
|
2171
2176
|
super.write(value, flags & ~this.U);
|
|
2172
|
-
if (this.U & LOADING_BIT && !(this.
|
|
2177
|
+
if (this.U & LOADING_BIT && !(this.g & UNINITIALIZED_BIT)) {
|
|
2173
2178
|
flags &= ~LOADING_BIT;
|
|
2174
2179
|
}
|
|
2175
2180
|
this.l.notify(this, this.U, flags);
|
|
2176
|
-
return this.
|
|
2181
|
+
return this.k;
|
|
2177
2182
|
}
|
|
2178
2183
|
};
|
|
2179
2184
|
function createBoundChildren(owner, fn, queue, mask) {
|
|
@@ -2230,12 +2235,12 @@ var ConditionalQueue = class extends Queue {
|
|
|
2230
2235
|
}
|
|
2231
2236
|
};
|
|
2232
2237
|
var CollectionQueue = class extends Queue {
|
|
2233
|
-
|
|
2238
|
+
G;
|
|
2234
2239
|
d = /* @__PURE__ */ new Set();
|
|
2235
2240
|
t = new Computation(false, null, { pureWrite: true });
|
|
2236
2241
|
constructor(type) {
|
|
2237
2242
|
super();
|
|
2238
|
-
this.
|
|
2243
|
+
this.G = type;
|
|
2239
2244
|
}
|
|
2240
2245
|
run(type) {
|
|
2241
2246
|
if (!type || this.t.read())
|
|
@@ -2245,9 +2250,9 @@ var CollectionQueue = class extends Queue {
|
|
|
2245
2250
|
notify(node, type, flags) {
|
|
2246
2251
|
if (ActiveTransition && ActiveTransition.u.has(this))
|
|
2247
2252
|
return ActiveTransition.u.get(this).notify(node, type, flags);
|
|
2248
|
-
if (!(type & this.
|
|
2253
|
+
if (!(type & this.G))
|
|
2249
2254
|
return super.notify(node, type, flags);
|
|
2250
|
-
if (flags & this.
|
|
2255
|
+
if (flags & this.G) {
|
|
2251
2256
|
this.d.add(node);
|
|
2252
2257
|
if (this.d.size === 1)
|
|
2253
2258
|
this.t.write(true);
|
|
@@ -2256,11 +2261,11 @@ var CollectionQueue = class extends Queue {
|
|
|
2256
2261
|
if (this.d.size === 0)
|
|
2257
2262
|
this.t.write(false);
|
|
2258
2263
|
}
|
|
2259
|
-
type &= ~this.
|
|
2264
|
+
type &= ~this.G;
|
|
2260
2265
|
return type ? super.notify(node, type, flags) : true;
|
|
2261
2266
|
}
|
|
2262
2267
|
merge(queue) {
|
|
2263
|
-
queue.d.forEach((n) => this.notify(n, this.
|
|
2268
|
+
queue.d.forEach((n) => this.notify(n, this.G, this.G));
|
|
2264
2269
|
super.merge(queue);
|
|
2265
2270
|
}
|
|
2266
2271
|
};
|
|
@@ -2303,11 +2308,11 @@ function createErrorBoundary(fn, fallback) {
|
|
|
2303
2308
|
return createCollectionBoundary(ERROR_BIT, fn, (queue) => {
|
|
2304
2309
|
let node = queue.d.values().next().value;
|
|
2305
2310
|
ActiveTransition && ActiveTransition.a.has(node) && (node = ActiveTransition.a.get(node));
|
|
2306
|
-
return fallback(node.
|
|
2311
|
+
return fallback(node.L, () => {
|
|
2307
2312
|
var _a;
|
|
2308
2313
|
incrementClock();
|
|
2309
2314
|
for (let node2 of queue.d) {
|
|
2310
|
-
if (ActiveTransition && !node2.
|
|
2315
|
+
if (ActiveTransition && !node2.h)
|
|
2311
2316
|
node2 = cloneGraph(node2);
|
|
2312
2317
|
node2.c = STATE_DIRTY;
|
|
2313
2318
|
(_a = node2.l) == null ? void 0 : _a.enqueue(node2.A, node2.C.bind(node2));
|