@solidjs/signals 0.9.11 → 0.10.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 +559 -618
- package/dist/node.cjs +1024 -1075
- package/dist/prod.js +961 -1012
- package/dist/types/boundaries.d.ts +0 -5
- package/dist/types/core/action.d.ts +1 -0
- package/dist/types/core/async.d.ts +5 -0
- package/dist/types/core/context.d.ts +1 -1
- package/dist/types/core/core.d.ts +25 -104
- package/dist/types/core/effect.d.ts +4 -3
- package/dist/types/core/error.d.ts +4 -4
- package/dist/types/core/graph.d.ts +3 -0
- package/dist/types/core/heap.d.ts +1 -1
- package/dist/types/core/index.d.ts +4 -2
- package/dist/types/core/lanes.d.ts +52 -0
- package/dist/types/core/owner.d.ts +22 -0
- package/dist/types/core/scheduler.d.ts +6 -59
- package/dist/types/core/types.d.ts +74 -0
- package/dist/types/index.d.ts +3 -3
- package/dist/types/signals.d.ts +73 -76
- package/dist/types/store/index.d.ts +1 -1
- package/dist/types/store/optimistic.d.ts +9 -12
- package/dist/types/store/projection.d.ts +12 -4
- package/dist/types/store/store.d.ts +26 -1
- package/package.json +2 -2
package/dist/dev.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
class NotReadyError extends Error {
|
|
2
|
-
|
|
3
|
-
constructor(
|
|
2
|
+
source;
|
|
3
|
+
constructor(source) {
|
|
4
4
|
super();
|
|
5
|
-
this.
|
|
5
|
+
this.source = source;
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
class StatusError extends Error {
|
|
9
|
-
|
|
10
|
-
constructor(
|
|
9
|
+
source;
|
|
10
|
+
constructor(source, original) {
|
|
11
11
|
super(original instanceof Error ? original.message : String(original), { cause: original });
|
|
12
|
-
this.
|
|
12
|
+
this.source = source;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
class NoOwnerError extends Error {
|
|
@@ -147,81 +147,6 @@ let clock = 0;
|
|
|
147
147
|
let activeTransition = null;
|
|
148
148
|
let scheduled = false;
|
|
149
149
|
let projectionWriteActive = false;
|
|
150
|
-
const signalLanes = new WeakMap();
|
|
151
|
-
const activeLanes = new Set();
|
|
152
|
-
let currentOptimisticLane = null;
|
|
153
|
-
function setCurrentOptimisticLane(lane) {
|
|
154
|
-
currentOptimisticLane = lane;
|
|
155
|
-
}
|
|
156
|
-
function getOrCreateLane(signal) {
|
|
157
|
-
let lane = signalLanes.get(signal);
|
|
158
|
-
if (lane) {
|
|
159
|
-
return findLane(lane);
|
|
160
|
-
}
|
|
161
|
-
const parentSource = signal._parentSource;
|
|
162
|
-
const parentLane = parentSource?._optimisticLane ? findLane(parentSource._optimisticLane) : null;
|
|
163
|
-
lane = {
|
|
164
|
-
_source: signal,
|
|
165
|
-
_pendingAsync: new Set(),
|
|
166
|
-
_effectQueues: [[], []],
|
|
167
|
-
_mergedInto: null,
|
|
168
|
-
_transition: activeTransition,
|
|
169
|
-
_parentLane: parentLane
|
|
170
|
-
};
|
|
171
|
-
signalLanes.set(signal, lane);
|
|
172
|
-
activeLanes.add(lane);
|
|
173
|
-
signal._laneVersion = signal._overrideVersion || 0;
|
|
174
|
-
return lane;
|
|
175
|
-
}
|
|
176
|
-
function findLane(lane) {
|
|
177
|
-
while (lane._mergedInto) lane = lane._mergedInto;
|
|
178
|
-
return lane;
|
|
179
|
-
}
|
|
180
|
-
function mergeLanes(lane1, lane2) {
|
|
181
|
-
lane1 = findLane(lane1);
|
|
182
|
-
lane2 = findLane(lane2);
|
|
183
|
-
if (lane1 === lane2) return lane1;
|
|
184
|
-
lane2._mergedInto = lane1;
|
|
185
|
-
for (const node of lane2._pendingAsync) lane1._pendingAsync.add(node);
|
|
186
|
-
lane1._effectQueues[0].push(...lane2._effectQueues[0]);
|
|
187
|
-
lane1._effectQueues[1].push(...lane2._effectQueues[1]);
|
|
188
|
-
return lane1;
|
|
189
|
-
}
|
|
190
|
-
function clearLaneEntry(signal) {
|
|
191
|
-
signalLanes.delete(signal);
|
|
192
|
-
}
|
|
193
|
-
function resolveLane(el) {
|
|
194
|
-
const lane = el._optimisticLane;
|
|
195
|
-
if (!lane) return undefined;
|
|
196
|
-
const root = findLane(lane);
|
|
197
|
-
if (activeLanes.has(root)) return root;
|
|
198
|
-
el._optimisticLane = undefined;
|
|
199
|
-
return undefined;
|
|
200
|
-
}
|
|
201
|
-
function hasActiveOverride(el) {
|
|
202
|
-
return !!(el._optimistic && el._pendingValue !== NOT_PENDING);
|
|
203
|
-
}
|
|
204
|
-
function assignOrMergeLane(el, sourceLane) {
|
|
205
|
-
const sourceRoot = findLane(sourceLane);
|
|
206
|
-
const existing = el._optimisticLane;
|
|
207
|
-
if (existing) {
|
|
208
|
-
if (existing._mergedInto) {
|
|
209
|
-
el._optimisticLane = sourceLane;
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
const existingRoot = findLane(existing);
|
|
213
|
-
if (activeLanes.has(existingRoot)) {
|
|
214
|
-
if (existingRoot !== sourceRoot && !hasActiveOverride(el)) {
|
|
215
|
-
if (sourceRoot._parentLane && findLane(sourceRoot._parentLane) === existingRoot) {
|
|
216
|
-
el._optimisticLane = sourceLane;
|
|
217
|
-
} else if (existingRoot._parentLane && findLane(existingRoot._parentLane) === sourceRoot);
|
|
218
|
-
else mergeLanes(sourceRoot, existingRoot);
|
|
219
|
-
}
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
el._optimisticLane = sourceLane;
|
|
224
|
-
}
|
|
225
150
|
function runLaneEffects(type) {
|
|
226
151
|
for (const lane of activeLanes) {
|
|
227
152
|
if (lane._mergedInto || lane._pendingAsync.size > 0) continue;
|
|
@@ -363,9 +288,9 @@ class GlobalQueue extends Queue {
|
|
|
363
288
|
if (
|
|
364
289
|
activeTransition &&
|
|
365
290
|
actualError &&
|
|
366
|
-
!activeTransition._asyncNodes.includes(actualError.
|
|
291
|
+
!activeTransition._asyncNodes.includes(actualError.source)
|
|
367
292
|
) {
|
|
368
|
-
activeTransition._asyncNodes.push(actualError.
|
|
293
|
+
activeTransition._asyncNodes.push(actualError.source);
|
|
369
294
|
schedule();
|
|
370
295
|
}
|
|
371
296
|
}
|
|
@@ -538,7 +463,7 @@ function transitionComplete(transition) {
|
|
|
538
463
|
let done = true;
|
|
539
464
|
for (let i = 0; i < transition._asyncNodes.length; i++) {
|
|
540
465
|
const node = transition._asyncNodes[i];
|
|
541
|
-
if (node._statusFlags & STATUS_PENDING && node._error?.
|
|
466
|
+
if (node._statusFlags & STATUS_PENDING && node._error?.source === node) {
|
|
542
467
|
done = false;
|
|
543
468
|
break;
|
|
544
469
|
}
|
|
@@ -550,6 +475,9 @@ function currentTransition(transition) {
|
|
|
550
475
|
while (transition._done && typeof transition._done === "object") transition = transition._done;
|
|
551
476
|
return transition;
|
|
552
477
|
}
|
|
478
|
+
function setActiveTransition(transition) {
|
|
479
|
+
activeTransition = transition;
|
|
480
|
+
}
|
|
553
481
|
function runInTransition(transition, fn) {
|
|
554
482
|
const prevTransition = activeTransition;
|
|
555
483
|
try {
|
|
@@ -559,201 +487,104 @@ function runInTransition(transition, fn) {
|
|
|
559
487
|
activeTransition = prevTransition;
|
|
560
488
|
}
|
|
561
489
|
}
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
490
|
+
const signalLanes = new WeakMap();
|
|
491
|
+
const activeLanes = new Set();
|
|
492
|
+
function getOrCreateLane(signal) {
|
|
493
|
+
let lane = signalLanes.get(signal);
|
|
494
|
+
if (lane) {
|
|
495
|
+
return findLane(lane);
|
|
496
|
+
}
|
|
497
|
+
const parentSource = signal._parentSource;
|
|
498
|
+
const parentLane = parentSource?._optimisticLane ? findLane(parentSource._optimisticLane) : null;
|
|
499
|
+
lane = {
|
|
500
|
+
_source: signal,
|
|
501
|
+
_pendingAsync: new Set(),
|
|
502
|
+
_effectQueues: [[], []],
|
|
503
|
+
_mergedInto: null,
|
|
504
|
+
_transition: activeTransition,
|
|
505
|
+
_parentLane: parentLane
|
|
506
|
+
};
|
|
507
|
+
signalLanes.set(signal, lane);
|
|
508
|
+
activeLanes.add(lane);
|
|
509
|
+
signal._laneVersion = signal._overrideVersion || 0;
|
|
510
|
+
return lane;
|
|
567
511
|
}
|
|
568
|
-
function
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
const it = genFn(...args);
|
|
572
|
-
globalQueue.initTransition();
|
|
573
|
-
let ctx = activeTransition;
|
|
574
|
-
ctx._actions.push(it);
|
|
575
|
-
const done = (v, e) => {
|
|
576
|
-
ctx = currentTransition(ctx);
|
|
577
|
-
const i = ctx._actions.indexOf(it);
|
|
578
|
-
if (i >= 0) ctx._actions.splice(i, 1);
|
|
579
|
-
activeTransition = ctx;
|
|
580
|
-
schedule();
|
|
581
|
-
e ? reject(e) : resolve(v);
|
|
582
|
-
};
|
|
583
|
-
const step = (v, err) => {
|
|
584
|
-
let r;
|
|
585
|
-
try {
|
|
586
|
-
r = err ? it.throw(v) : it.next(v);
|
|
587
|
-
} catch (e) {
|
|
588
|
-
return done(undefined, e);
|
|
589
|
-
}
|
|
590
|
-
if (r instanceof Promise)
|
|
591
|
-
return void r.then(run, e => restoreTransition(ctx, () => step(e, true)));
|
|
592
|
-
run(r);
|
|
593
|
-
};
|
|
594
|
-
const run = r => {
|
|
595
|
-
if (r.done) return done(r.value);
|
|
596
|
-
if (r.value instanceof Promise)
|
|
597
|
-
return void r.value.then(
|
|
598
|
-
v => restoreTransition(ctx, () => step(v)),
|
|
599
|
-
e => restoreTransition(ctx, () => step(e, true))
|
|
600
|
-
);
|
|
601
|
-
restoreTransition(ctx, () => step(r.value));
|
|
602
|
-
};
|
|
603
|
-
step();
|
|
604
|
-
});
|
|
512
|
+
function findLane(lane) {
|
|
513
|
+
while (lane._mergedInto) lane = lane._mergedInto;
|
|
514
|
+
return lane;
|
|
605
515
|
}
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
let leafEffectActive = false;
|
|
616
|
-
function setLeafEffectActive(v) {
|
|
617
|
-
leafEffectActive = v;
|
|
516
|
+
function mergeLanes(lane1, lane2) {
|
|
517
|
+
lane1 = findLane(lane1);
|
|
518
|
+
lane2 = findLane(lane2);
|
|
519
|
+
if (lane1 === lane2) return lane1;
|
|
520
|
+
lane2._mergedInto = lane1;
|
|
521
|
+
for (const node of lane2._pendingAsync) lane1._pendingAsync.add(node);
|
|
522
|
+
lane1._effectQueues[0].push(...lane2._effectQueues[0]);
|
|
523
|
+
lane1._effectQueues[1].push(...lane2._effectQueues[1]);
|
|
524
|
+
return lane1;
|
|
618
525
|
}
|
|
619
|
-
function
|
|
620
|
-
const
|
|
621
|
-
if (!
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
526
|
+
function resolveLane(el) {
|
|
527
|
+
const lane = el._optimisticLane;
|
|
528
|
+
if (!lane) return undefined;
|
|
529
|
+
const root = findLane(lane);
|
|
530
|
+
if (activeLanes.has(root)) return root;
|
|
531
|
+
el._optimisticLane = undefined;
|
|
532
|
+
return undefined;
|
|
533
|
+
}
|
|
534
|
+
function hasActiveOverride(el) {
|
|
535
|
+
return !!(el._optimistic && el._pendingValue !== NOT_PENDING);
|
|
536
|
+
}
|
|
537
|
+
function assignOrMergeLane(el, sourceLane) {
|
|
538
|
+
const sourceRoot = findLane(sourceLane);
|
|
539
|
+
const existing = el._optimisticLane;
|
|
540
|
+
if (existing) {
|
|
541
|
+
if (existing._mergedInto) {
|
|
542
|
+
el._optimisticLane = sourceLane;
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
const existingRoot = findLane(existing);
|
|
546
|
+
if (activeLanes.has(existingRoot)) {
|
|
547
|
+
if (existingRoot !== sourceRoot && !hasActiveOverride(el)) {
|
|
548
|
+
if (sourceRoot._parentLane && findLane(sourceRoot._parentLane) === existingRoot) {
|
|
549
|
+
el._optimisticLane = sourceLane;
|
|
550
|
+
} else if (existingRoot._parentLane && findLane(existingRoot._parentLane) === sourceRoot);
|
|
551
|
+
else mergeLanes(sourceRoot, existingRoot);
|
|
552
|
+
}
|
|
553
|
+
return;
|
|
632
554
|
}
|
|
633
555
|
}
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
const
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
let oldHeight = el._height;
|
|
644
|
-
let prevTracking = tracking;
|
|
645
|
-
let prevLane = currentOptimisticLane;
|
|
646
|
-
tracking = true;
|
|
647
|
-
if (isOptimisticDirty) {
|
|
648
|
-
const lane = resolveLane(el);
|
|
649
|
-
if (lane) setCurrentOptimisticLane(lane);
|
|
556
|
+
el._optimisticLane = sourceLane;
|
|
557
|
+
}
|
|
558
|
+
function handleAsync(el, result, setter) {
|
|
559
|
+
const isObject = typeof result === "object" && result !== null;
|
|
560
|
+
const iterator = isObject && untrack(() => result[Symbol.asyncIterator]);
|
|
561
|
+
const isThenable = !iterator && isObject && untrack(() => typeof result.then === "function");
|
|
562
|
+
if (!isThenable && !iterator) {
|
|
563
|
+
el._inFlight = null;
|
|
564
|
+
return result;
|
|
650
565
|
}
|
|
651
|
-
|
|
652
|
-
|
|
566
|
+
el._inFlight = result;
|
|
567
|
+
let syncValue;
|
|
568
|
+
const handleError = error => {
|
|
569
|
+
if (el._inFlight !== result) return;
|
|
570
|
+
globalQueue.initTransition(el._transition);
|
|
571
|
+
notifyStatus(el, error instanceof NotReadyError ? STATUS_PENDING : STATUS_ERROR, error);
|
|
572
|
+
el._time = clock;
|
|
573
|
+
};
|
|
574
|
+
const asyncWrite = (value, then) => {
|
|
575
|
+
if (el._inFlight !== result) return;
|
|
576
|
+
if (el._flags & (REACTIVE_DIRTY | REACTIVE_OPTIMISTIC_DIRTY)) return;
|
|
577
|
+
globalQueue.initTransition(el._transition);
|
|
653
578
|
clearStatus(el);
|
|
654
|
-
const
|
|
655
|
-
if (
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
lane._pendingAsync.add(el);
|
|
664
|
-
el._optimisticLane = lane;
|
|
665
|
-
updatePendingSignal(lane._source);
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
notifyStatus(
|
|
669
|
-
el,
|
|
670
|
-
e instanceof NotReadyError ? STATUS_PENDING : STATUS_ERROR,
|
|
671
|
-
e,
|
|
672
|
-
undefined,
|
|
673
|
-
e instanceof NotReadyError ? el._optimisticLane : undefined
|
|
674
|
-
);
|
|
675
|
-
} finally {
|
|
676
|
-
tracking = prevTracking;
|
|
677
|
-
el._flags = REACTIVE_NONE;
|
|
678
|
-
context = oldcontext;
|
|
679
|
-
}
|
|
680
|
-
if (!el._error) {
|
|
681
|
-
const depsTail = el._depsTail;
|
|
682
|
-
let toRemove = depsTail !== null ? depsTail._nextDep : el._deps;
|
|
683
|
-
if (toRemove !== null) {
|
|
684
|
-
do {
|
|
685
|
-
toRemove = unlinkSubs(toRemove);
|
|
686
|
-
} while (toRemove !== null);
|
|
687
|
-
if (depsTail !== null) depsTail._nextDep = null;
|
|
688
|
-
else el._deps = null;
|
|
689
|
-
}
|
|
690
|
-
const compareValue = hasOverride
|
|
691
|
-
? el._value
|
|
692
|
-
: el._pendingValue === NOT_PENDING
|
|
693
|
-
? el._value
|
|
694
|
-
: el._pendingValue;
|
|
695
|
-
const valueChanged = !el._equals || !el._equals(compareValue, value);
|
|
696
|
-
if (valueChanged) {
|
|
697
|
-
const prevVisible = hasOverride ? el._value : undefined;
|
|
698
|
-
if (create || (isEffect && activeTransition !== el._transition) || isOptimisticDirty)
|
|
699
|
-
el._value = value;
|
|
700
|
-
else el._pendingValue = value;
|
|
701
|
-
if (hasOverride && !isOptimisticDirty && wasPending) {
|
|
702
|
-
const ov = el._overrideVersion || 0;
|
|
703
|
-
const lv = el._laneVersion || 0;
|
|
704
|
-
if (ov <= lv) el._value = value;
|
|
705
|
-
}
|
|
706
|
-
if (!hasOverride || isOptimisticDirty || el._value !== prevVisible) {
|
|
707
|
-
insertSubs(el, isOptimisticDirty || hasOverride);
|
|
708
|
-
}
|
|
709
|
-
} else if (hasOverride) {
|
|
710
|
-
el._pendingValue = value;
|
|
711
|
-
} else if (el._height != oldHeight) {
|
|
712
|
-
for (let s = el._subs; s !== null; s = s._nextSub) {
|
|
713
|
-
insertIntoHeapHeight(s._sub, s._sub._flags & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
setCurrentOptimisticLane(prevLane);
|
|
718
|
-
(!create || el._statusFlags & STATUS_PENDING) &&
|
|
719
|
-
!el._transition &&
|
|
720
|
-
!(activeTransition && el._optimistic) &&
|
|
721
|
-
globalQueue._pendingNodes.push(el);
|
|
722
|
-
el._transition &&
|
|
723
|
-
isEffect &&
|
|
724
|
-
activeTransition !== el._transition &&
|
|
725
|
-
runInTransition(el._transition, () => recompute(el));
|
|
726
|
-
}
|
|
727
|
-
function handleAsync(el, result, setter) {
|
|
728
|
-
const isObject = typeof result === "object" && result !== null;
|
|
729
|
-
const iterator = isObject && untrack(() => result[Symbol.asyncIterator]);
|
|
730
|
-
const isThenable = !iterator && isObject && untrack(() => typeof result.then === "function");
|
|
731
|
-
if (!isThenable && !iterator) {
|
|
732
|
-
el._inFlight = null;
|
|
733
|
-
return result;
|
|
734
|
-
}
|
|
735
|
-
el._inFlight = result;
|
|
736
|
-
let syncValue;
|
|
737
|
-
const handleError = error => {
|
|
738
|
-
if (el._inFlight !== result) return;
|
|
739
|
-
globalQueue.initTransition(el._transition);
|
|
740
|
-
notifyStatus(el, error instanceof NotReadyError ? STATUS_PENDING : STATUS_ERROR, error);
|
|
741
|
-
el._time = clock;
|
|
742
|
-
};
|
|
743
|
-
const asyncWrite = (value, then) => {
|
|
744
|
-
if (el._inFlight !== result) return;
|
|
745
|
-
if (el._flags & (REACTIVE_DIRTY | REACTIVE_OPTIMISTIC_DIRTY)) return;
|
|
746
|
-
globalQueue.initTransition(el._transition);
|
|
747
|
-
clearStatus(el);
|
|
748
|
-
const lane = resolveLane(el);
|
|
749
|
-
if (lane) lane._pendingAsync.delete(el);
|
|
750
|
-
if (setter) setter(value);
|
|
751
|
-
else if (el._optimistic) {
|
|
752
|
-
const hadOverride = el._pendingValue !== NOT_PENDING;
|
|
753
|
-
if (el._fn) el._pendingValue = value;
|
|
754
|
-
if (!hadOverride) {
|
|
755
|
-
el._value = value;
|
|
756
|
-
insertSubs(el);
|
|
579
|
+
const lane = resolveLane(el);
|
|
580
|
+
if (lane) lane._pendingAsync.delete(el);
|
|
581
|
+
if (setter) setter(value);
|
|
582
|
+
else if (el._optimistic) {
|
|
583
|
+
const hadOverride = el._pendingValue !== NOT_PENDING;
|
|
584
|
+
if (el._fn) el._pendingValue = value;
|
|
585
|
+
if (!hadOverride) {
|
|
586
|
+
el._value = value;
|
|
587
|
+
insertSubs(el);
|
|
757
588
|
}
|
|
758
589
|
el._time = clock;
|
|
759
590
|
} else if (lane) {
|
|
@@ -841,7 +672,7 @@ function notifyStatus(el, status, error, blockStatus, lane) {
|
|
|
841
672
|
!(error instanceof NotReadyError)
|
|
842
673
|
)
|
|
843
674
|
error = new StatusError(el, error);
|
|
844
|
-
const isSource = error instanceof NotReadyError && error.
|
|
675
|
+
const isSource = error instanceof NotReadyError && error.source === el;
|
|
845
676
|
const isOptimisticBoundary = status === STATUS_PENDING && el._optimistic && !isSource;
|
|
846
677
|
const startsBlocking = isOptimisticBoundary && hasActiveOverride(el);
|
|
847
678
|
if (!blockStatus) {
|
|
@@ -854,7 +685,7 @@ function notifyStatus(el, status, error, blockStatus, lane) {
|
|
|
854
685
|
assignOrMergeLane(el, lane);
|
|
855
686
|
}
|
|
856
687
|
if (startsBlocking && activeTransition && error instanceof NotReadyError) {
|
|
857
|
-
const source = error.
|
|
688
|
+
const source = error.source;
|
|
858
689
|
if (!activeTransition._asyncNodes.includes(source)) {
|
|
859
690
|
activeTransition._asyncNodes.push(source);
|
|
860
691
|
}
|
|
@@ -886,86 +717,102 @@ function notifyStatus(el, status, error, blockStatus, lane) {
|
|
|
886
717
|
}
|
|
887
718
|
}
|
|
888
719
|
}
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
recompute(el);
|
|
904
|
-
}
|
|
905
|
-
el._flags = REACTIVE_NONE;
|
|
906
|
-
}
|
|
907
|
-
function unlinkSubs(link) {
|
|
908
|
-
const dep = link._dep;
|
|
909
|
-
const nextDep = link._nextDep;
|
|
910
|
-
const nextSub = link._nextSub;
|
|
911
|
-
const prevSub = link._prevSub;
|
|
912
|
-
if (nextSub !== null) nextSub._prevSub = prevSub;
|
|
913
|
-
else dep._subsTail = prevSub;
|
|
914
|
-
if (prevSub !== null) prevSub._nextSub = nextSub;
|
|
915
|
-
else {
|
|
916
|
-
dep._subs = nextSub;
|
|
917
|
-
if (nextSub === null) {
|
|
918
|
-
dep._unobserved?.();
|
|
919
|
-
dep._fn && !dep._preventAutoDisposal && unobserved(dep);
|
|
720
|
+
let leafEffectActive = false;
|
|
721
|
+
function effect(compute, effect, error, initialValue, options) {
|
|
722
|
+
let initialized = false;
|
|
723
|
+
const node = computed(
|
|
724
|
+
options?.render ? p => staleValues(() => compute(p)) : compute,
|
|
725
|
+
initialValue,
|
|
726
|
+
{
|
|
727
|
+
...options,
|
|
728
|
+
equals: () => {
|
|
729
|
+
node._modified = !node._error;
|
|
730
|
+
if (initialized) node._queue.enqueue(node._type, runEffect.bind(node));
|
|
731
|
+
return false;
|
|
732
|
+
},
|
|
733
|
+
lazy: true
|
|
920
734
|
}
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
735
|
+
);
|
|
736
|
+
node._prevValue = initialValue;
|
|
737
|
+
node._effectFn = effect;
|
|
738
|
+
node._errorFn = error;
|
|
739
|
+
node._cleanup = undefined;
|
|
740
|
+
node._type = options?.render ? EFFECT_RENDER : EFFECT_USER;
|
|
741
|
+
node._notifyStatus = (status, error) => {
|
|
742
|
+
const actualStatus = status !== undefined ? status : node._statusFlags;
|
|
743
|
+
const actualError = error !== undefined ? error : node._error;
|
|
744
|
+
if (actualStatus & STATUS_ERROR) {
|
|
745
|
+
let err = actualError;
|
|
746
|
+
node._queue.notify(node, STATUS_PENDING, 0);
|
|
747
|
+
if (node._type === EFFECT_USER) {
|
|
748
|
+
try {
|
|
749
|
+
return node._errorFn
|
|
750
|
+
? node._errorFn(err, () => {
|
|
751
|
+
node._cleanup?.();
|
|
752
|
+
node._cleanup = undefined;
|
|
753
|
+
})
|
|
754
|
+
: console.error(err);
|
|
755
|
+
} catch (e) {
|
|
756
|
+
err = e;
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
if (!node._queue.notify(node, STATUS_ERROR, STATUS_ERROR)) throw err;
|
|
760
|
+
} else if (node._type === EFFECT_RENDER)
|
|
761
|
+
node._queue.notify(node, STATUS_PENDING | STATUS_ERROR, actualStatus, actualError);
|
|
762
|
+
};
|
|
763
|
+
recompute(node, true);
|
|
764
|
+
!options?.defer &&
|
|
765
|
+
(node._type === EFFECT_USER
|
|
766
|
+
? node._queue.enqueue(node._type, runEffect.bind(node))
|
|
767
|
+
: runEffect.call(node));
|
|
768
|
+
initialized = true;
|
|
769
|
+
onCleanup(() => node._cleanup?.());
|
|
770
|
+
if (!node._parent)
|
|
771
|
+
console.warn("Effects created outside a reactive context will never be disposed");
|
|
932
772
|
}
|
|
933
|
-
function
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
if (
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
773
|
+
function runEffect() {
|
|
774
|
+
if (!this._modified || this._flags & REACTIVE_DISPOSED) return;
|
|
775
|
+
this._cleanup?.();
|
|
776
|
+
this._cleanup = undefined;
|
|
777
|
+
try {
|
|
778
|
+
this._cleanup = this._effectFn(this._value, this._prevValue);
|
|
779
|
+
} catch (error) {
|
|
780
|
+
if (!this._queue.notify(this, STATUS_ERROR, STATUS_ERROR)) throw error;
|
|
781
|
+
} finally {
|
|
782
|
+
this._prevValue = this._value;
|
|
783
|
+
this._modified = false;
|
|
944
784
|
}
|
|
945
|
-
const prevSub = dep._subsTail;
|
|
946
|
-
if (prevSub !== null && prevSub._sub === sub && (!isRecomputing || isValidLink(prevSub, sub)))
|
|
947
|
-
return;
|
|
948
|
-
const newLink =
|
|
949
|
-
(sub._depsTail =
|
|
950
|
-
dep._subsTail =
|
|
951
|
-
{ _dep: dep, _sub: sub, _nextDep: nextDep, _prevSub: prevSub, _nextSub: null });
|
|
952
|
-
if (prevDep !== null) prevDep._nextDep = newLink;
|
|
953
|
-
else sub._deps = newLink;
|
|
954
|
-
if (prevSub !== null) prevSub._nextSub = newLink;
|
|
955
|
-
else dep._subs = newLink;
|
|
956
785
|
}
|
|
957
|
-
function
|
|
958
|
-
const
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
786
|
+
function trackedEffect(fn, options) {
|
|
787
|
+
const run = () => {
|
|
788
|
+
if (!node._modified || node._flags & REACTIVE_DISPOSED) return;
|
|
789
|
+
node._modified = false;
|
|
790
|
+
recompute(node);
|
|
791
|
+
};
|
|
792
|
+
const node = computed(
|
|
793
|
+
() => {
|
|
794
|
+
leafEffectActive = true;
|
|
795
|
+
try {
|
|
796
|
+
node._cleanup?.();
|
|
797
|
+
node._cleanup = undefined;
|
|
798
|
+
node._cleanup = staleValues(fn) || undefined;
|
|
799
|
+
} finally {
|
|
800
|
+
leafEffectActive = false;
|
|
801
|
+
}
|
|
802
|
+
},
|
|
803
|
+
undefined,
|
|
804
|
+
{ ...options, lazy: true, pureWrite: true }
|
|
805
|
+
);
|
|
806
|
+
node._cleanup = undefined;
|
|
807
|
+
node._modified = true;
|
|
808
|
+
node._type = EFFECT_TRACKED;
|
|
809
|
+
node._run = run;
|
|
810
|
+
node._queue.enqueue(EFFECT_USER, run);
|
|
811
|
+
onCleanup(() => node._cleanup?.());
|
|
812
|
+
if (!node._parent)
|
|
813
|
+
console.warn("Effects created outside a reactive context will never be disposed");
|
|
968
814
|
}
|
|
815
|
+
const PENDING_OWNER = {};
|
|
969
816
|
function markDisposal(el) {
|
|
970
817
|
let child = el._firstChild;
|
|
971
818
|
while (child) {
|
|
@@ -1036,8 +883,257 @@ function formatId(prefix, id) {
|
|
|
1036
883
|
len = num.length - 1;
|
|
1037
884
|
return prefix + (len ? String.fromCharCode(64 + len) : "") + num;
|
|
1038
885
|
}
|
|
1039
|
-
function
|
|
1040
|
-
|
|
886
|
+
function getObserver() {
|
|
887
|
+
if (pendingCheckActive || pendingReadActive) return PENDING_OWNER;
|
|
888
|
+
return tracking ? context : null;
|
|
889
|
+
}
|
|
890
|
+
function getOwner() {
|
|
891
|
+
return context;
|
|
892
|
+
}
|
|
893
|
+
function onCleanup(fn) {
|
|
894
|
+
if (!context) return fn;
|
|
895
|
+
if (!context._disposal) context._disposal = fn;
|
|
896
|
+
else if (Array.isArray(context._disposal)) context._disposal.push(fn);
|
|
897
|
+
else context._disposal = [context._disposal, fn];
|
|
898
|
+
return fn;
|
|
899
|
+
}
|
|
900
|
+
function createOwner(options) {
|
|
901
|
+
const parent = context;
|
|
902
|
+
const owner = {
|
|
903
|
+
id: options?.id ?? (parent?.id != null ? getNextChildId(parent) : undefined),
|
|
904
|
+
_root: true,
|
|
905
|
+
_parentComputed: parent?._root ? parent._parentComputed : parent,
|
|
906
|
+
_firstChild: null,
|
|
907
|
+
_nextSibling: null,
|
|
908
|
+
_disposal: null,
|
|
909
|
+
_queue: parent?._queue ?? globalQueue,
|
|
910
|
+
_context: parent?._context || defaultContext,
|
|
911
|
+
_childCount: 0,
|
|
912
|
+
_pendingDisposal: null,
|
|
913
|
+
_pendingFirstChild: null,
|
|
914
|
+
_parent: parent,
|
|
915
|
+
dispose(self = true) {
|
|
916
|
+
disposeChildren(owner, self);
|
|
917
|
+
}
|
|
918
|
+
};
|
|
919
|
+
if (leafEffectActive && parent) {
|
|
920
|
+
throw new Error("Cannot create reactive primitives inside createTrackedEffect");
|
|
921
|
+
}
|
|
922
|
+
if (parent) {
|
|
923
|
+
const lastChild = parent._firstChild;
|
|
924
|
+
if (lastChild === null) {
|
|
925
|
+
parent._firstChild = owner;
|
|
926
|
+
} else {
|
|
927
|
+
owner._nextSibling = lastChild;
|
|
928
|
+
parent._firstChild = owner;
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
return owner;
|
|
932
|
+
}
|
|
933
|
+
function createRoot(init, options) {
|
|
934
|
+
const owner = createOwner(options);
|
|
935
|
+
return runWithOwner(owner, () => init(owner.dispose));
|
|
936
|
+
}
|
|
937
|
+
function unlinkSubs(link) {
|
|
938
|
+
const dep = link._dep;
|
|
939
|
+
const nextDep = link._nextDep;
|
|
940
|
+
const nextSub = link._nextSub;
|
|
941
|
+
const prevSub = link._prevSub;
|
|
942
|
+
if (nextSub !== null) nextSub._prevSub = prevSub;
|
|
943
|
+
else dep._subsTail = prevSub;
|
|
944
|
+
if (prevSub !== null) prevSub._nextSub = nextSub;
|
|
945
|
+
else {
|
|
946
|
+
dep._subs = nextSub;
|
|
947
|
+
if (nextSub === null) {
|
|
948
|
+
dep._unobserved?.();
|
|
949
|
+
dep._fn && !dep._preventAutoDisposal && unobserved(dep);
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
return nextDep;
|
|
953
|
+
}
|
|
954
|
+
function unobserved(el) {
|
|
955
|
+
deleteFromHeap(el, el._flags & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
956
|
+
let dep = el._deps;
|
|
957
|
+
while (dep !== null) {
|
|
958
|
+
dep = unlinkSubs(dep);
|
|
959
|
+
}
|
|
960
|
+
el._deps = null;
|
|
961
|
+
disposeChildren(el, true);
|
|
962
|
+
}
|
|
963
|
+
function link(dep, sub) {
|
|
964
|
+
const prevDep = sub._depsTail;
|
|
965
|
+
if (prevDep !== null && prevDep._dep === dep) return;
|
|
966
|
+
let nextDep = null;
|
|
967
|
+
const isRecomputing = sub._flags & REACTIVE_RECOMPUTING_DEPS;
|
|
968
|
+
if (isRecomputing) {
|
|
969
|
+
nextDep = prevDep !== null ? prevDep._nextDep : sub._deps;
|
|
970
|
+
if (nextDep !== null && nextDep._dep === dep) {
|
|
971
|
+
sub._depsTail = nextDep;
|
|
972
|
+
return;
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
const prevSub = dep._subsTail;
|
|
976
|
+
if (prevSub !== null && prevSub._sub === sub && (!isRecomputing || isValidLink(prevSub, sub)))
|
|
977
|
+
return;
|
|
978
|
+
const newLink =
|
|
979
|
+
(sub._depsTail =
|
|
980
|
+
dep._subsTail =
|
|
981
|
+
{ _dep: dep, _sub: sub, _nextDep: nextDep, _prevSub: prevSub, _nextSub: null });
|
|
982
|
+
if (prevDep !== null) prevDep._nextDep = newLink;
|
|
983
|
+
else sub._deps = newLink;
|
|
984
|
+
if (prevSub !== null) prevSub._nextSub = newLink;
|
|
985
|
+
else dep._subs = newLink;
|
|
986
|
+
}
|
|
987
|
+
function isValidLink(checkLink, sub) {
|
|
988
|
+
const depsTail = sub._depsTail;
|
|
989
|
+
if (depsTail !== null) {
|
|
990
|
+
let link = sub._deps;
|
|
991
|
+
do {
|
|
992
|
+
if (link === checkLink) return true;
|
|
993
|
+
if (link === depsTail) break;
|
|
994
|
+
link = link._nextDep;
|
|
995
|
+
} while (link !== null);
|
|
996
|
+
}
|
|
997
|
+
return false;
|
|
998
|
+
}
|
|
999
|
+
GlobalQueue._update = recompute;
|
|
1000
|
+
GlobalQueue._dispose = disposeChildren;
|
|
1001
|
+
let tracking = false;
|
|
1002
|
+
let stale = false;
|
|
1003
|
+
let refreshing = false;
|
|
1004
|
+
let pendingCheckActive = false;
|
|
1005
|
+
let foundPending = false;
|
|
1006
|
+
let pendingReadActive = false;
|
|
1007
|
+
let context = null;
|
|
1008
|
+
let currentOptimisticLane = null;
|
|
1009
|
+
function recompute(el, create = false) {
|
|
1010
|
+
const isEffect = el._type;
|
|
1011
|
+
if (!create) {
|
|
1012
|
+
if (el._transition && (!isEffect || activeTransition) && activeTransition !== el._transition)
|
|
1013
|
+
globalQueue.initTransition(el._transition);
|
|
1014
|
+
deleteFromHeap(el, el._flags & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
1015
|
+
if (el._transition || isEffect === EFFECT_TRACKED) disposeChildren(el);
|
|
1016
|
+
else {
|
|
1017
|
+
markDisposal(el);
|
|
1018
|
+
el._pendingDisposal = el._disposal;
|
|
1019
|
+
el._pendingFirstChild = el._firstChild;
|
|
1020
|
+
el._disposal = null;
|
|
1021
|
+
el._firstChild = null;
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
const isOptimisticDirty = !!(el._flags & REACTIVE_OPTIMISTIC_DIRTY);
|
|
1025
|
+
const hasOverride = hasActiveOverride(el);
|
|
1026
|
+
const wasPending = !!(el._statusFlags & STATUS_PENDING);
|
|
1027
|
+
const oldcontext = context;
|
|
1028
|
+
context = el;
|
|
1029
|
+
el._depsTail = null;
|
|
1030
|
+
el._flags = REACTIVE_RECOMPUTING_DEPS;
|
|
1031
|
+
el._time = clock;
|
|
1032
|
+
let value = el._pendingValue === NOT_PENDING ? el._value : el._pendingValue;
|
|
1033
|
+
let oldHeight = el._height;
|
|
1034
|
+
let prevTracking = tracking;
|
|
1035
|
+
let prevLane = currentOptimisticLane;
|
|
1036
|
+
tracking = true;
|
|
1037
|
+
if (isOptimisticDirty) {
|
|
1038
|
+
const lane = resolveLane(el);
|
|
1039
|
+
if (lane) currentOptimisticLane = lane;
|
|
1040
|
+
}
|
|
1041
|
+
try {
|
|
1042
|
+
value = handleAsync(el, el._fn(value));
|
|
1043
|
+
clearStatus(el);
|
|
1044
|
+
const resolvedLane = resolveLane(el);
|
|
1045
|
+
if (resolvedLane) {
|
|
1046
|
+
resolvedLane._pendingAsync.delete(el);
|
|
1047
|
+
updatePendingSignal(resolvedLane._source);
|
|
1048
|
+
}
|
|
1049
|
+
} catch (e) {
|
|
1050
|
+
if (e instanceof NotReadyError && currentOptimisticLane) {
|
|
1051
|
+
const lane = findLane(currentOptimisticLane);
|
|
1052
|
+
if (lane._source !== el) {
|
|
1053
|
+
lane._pendingAsync.add(el);
|
|
1054
|
+
el._optimisticLane = lane;
|
|
1055
|
+
updatePendingSignal(lane._source);
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
notifyStatus(
|
|
1059
|
+
el,
|
|
1060
|
+
e instanceof NotReadyError ? STATUS_PENDING : STATUS_ERROR,
|
|
1061
|
+
e,
|
|
1062
|
+
undefined,
|
|
1063
|
+
e instanceof NotReadyError ? el._optimisticLane : undefined
|
|
1064
|
+
);
|
|
1065
|
+
} finally {
|
|
1066
|
+
tracking = prevTracking;
|
|
1067
|
+
el._flags = REACTIVE_NONE;
|
|
1068
|
+
context = oldcontext;
|
|
1069
|
+
}
|
|
1070
|
+
if (!el._error) {
|
|
1071
|
+
const depsTail = el._depsTail;
|
|
1072
|
+
let toRemove = depsTail !== null ? depsTail._nextDep : el._deps;
|
|
1073
|
+
if (toRemove !== null) {
|
|
1074
|
+
do {
|
|
1075
|
+
toRemove = unlinkSubs(toRemove);
|
|
1076
|
+
} while (toRemove !== null);
|
|
1077
|
+
if (depsTail !== null) depsTail._nextDep = null;
|
|
1078
|
+
else el._deps = null;
|
|
1079
|
+
}
|
|
1080
|
+
const compareValue = hasOverride
|
|
1081
|
+
? el._value
|
|
1082
|
+
: el._pendingValue === NOT_PENDING
|
|
1083
|
+
? el._value
|
|
1084
|
+
: el._pendingValue;
|
|
1085
|
+
const valueChanged = !el._equals || !el._equals(compareValue, value);
|
|
1086
|
+
if (valueChanged) {
|
|
1087
|
+
const prevVisible = hasOverride ? el._value : undefined;
|
|
1088
|
+
if (create || (isEffect && activeTransition !== el._transition) || isOptimisticDirty)
|
|
1089
|
+
el._value = value;
|
|
1090
|
+
else el._pendingValue = value;
|
|
1091
|
+
if (hasOverride && !isOptimisticDirty && wasPending) {
|
|
1092
|
+
const ov = el._overrideVersion || 0;
|
|
1093
|
+
const lv = el._laneVersion || 0;
|
|
1094
|
+
if (ov <= lv) el._value = value;
|
|
1095
|
+
}
|
|
1096
|
+
if (!hasOverride || isOptimisticDirty || el._value !== prevVisible) {
|
|
1097
|
+
insertSubs(el, isOptimisticDirty || hasOverride);
|
|
1098
|
+
}
|
|
1099
|
+
} else if (hasOverride) {
|
|
1100
|
+
el._pendingValue = value;
|
|
1101
|
+
} else if (el._height != oldHeight) {
|
|
1102
|
+
for (let s = el._subs; s !== null; s = s._nextSub) {
|
|
1103
|
+
insertIntoHeapHeight(s._sub, s._sub._flags & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
currentOptimisticLane = prevLane;
|
|
1108
|
+
(!create || el._statusFlags & STATUS_PENDING) &&
|
|
1109
|
+
!el._transition &&
|
|
1110
|
+
!(activeTransition && el._optimistic) &&
|
|
1111
|
+
globalQueue._pendingNodes.push(el);
|
|
1112
|
+
el._transition &&
|
|
1113
|
+
isEffect &&
|
|
1114
|
+
activeTransition !== el._transition &&
|
|
1115
|
+
runInTransition(el._transition, () => recompute(el));
|
|
1116
|
+
}
|
|
1117
|
+
function updateIfNecessary(el) {
|
|
1118
|
+
if (el._flags & REACTIVE_CHECK) {
|
|
1119
|
+
for (let d = el._deps; d; d = d._nextDep) {
|
|
1120
|
+
const dep1 = d._dep;
|
|
1121
|
+
const dep = dep1._firewall || dep1;
|
|
1122
|
+
if (dep._fn) {
|
|
1123
|
+
updateIfNecessary(dep);
|
|
1124
|
+
}
|
|
1125
|
+
if (el._flags & REACTIVE_DIRTY) {
|
|
1126
|
+
break;
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
if (el._flags & (REACTIVE_DIRTY | REACTIVE_OPTIMISTIC_DIRTY) || (el._error && el._time < clock)) {
|
|
1131
|
+
recompute(el);
|
|
1132
|
+
}
|
|
1133
|
+
el._flags = REACTIVE_NONE;
|
|
1134
|
+
}
|
|
1135
|
+
function computed(fn, initialValue, options) {
|
|
1136
|
+
const self = {
|
|
1041
1137
|
id: options?.id ?? (context?.id != null ? getNextChildId(context) : undefined),
|
|
1042
1138
|
_equals: options?.equals != null ? options.equals : isEqual,
|
|
1043
1139
|
_pureWrite: !!options?.pureWrite,
|
|
@@ -1111,66 +1207,8 @@ function optimisticSignal(v, options) {
|
|
|
1111
1207
|
}
|
|
1112
1208
|
function optimisticComputed(fn, initialValue, options) {
|
|
1113
1209
|
const c = computed(fn, initialValue, options);
|
|
1114
|
-
c._optimistic = true;
|
|
1115
|
-
return c;
|
|
1116
|
-
}
|
|
1117
|
-
function getPendingSignal(el) {
|
|
1118
|
-
if (!el._pendingSignal) {
|
|
1119
|
-
el._pendingSignal = optimisticSignal(false, { pureWrite: true });
|
|
1120
|
-
if (el._parentSource) {
|
|
1121
|
-
el._pendingSignal._parentSource = el;
|
|
1122
|
-
}
|
|
1123
|
-
if (computePendingState(el)) setSignal(el._pendingSignal, true);
|
|
1124
|
-
}
|
|
1125
|
-
return el._pendingSignal;
|
|
1126
|
-
}
|
|
1127
|
-
function computePendingState(el) {
|
|
1128
|
-
const comp = el;
|
|
1129
|
-
if (el._optimistic && el._pendingValue !== NOT_PENDING) {
|
|
1130
|
-
if (comp._statusFlags & STATUS_PENDING && !(comp._statusFlags & STATUS_UNINITIALIZED))
|
|
1131
|
-
return true;
|
|
1132
|
-
if (el._parentSource) {
|
|
1133
|
-
const lane = el._optimisticLane ? findLane(el._optimisticLane) : null;
|
|
1134
|
-
return !!(lane && lane._pendingAsync.size > 0);
|
|
1135
|
-
}
|
|
1136
|
-
return true;
|
|
1137
|
-
}
|
|
1138
|
-
if (el._pendingValue !== NOT_PENDING && !(comp._statusFlags & STATUS_UNINITIALIZED)) return true;
|
|
1139
|
-
return !!(comp._statusFlags & STATUS_PENDING && !(comp._statusFlags & STATUS_UNINITIALIZED));
|
|
1140
|
-
}
|
|
1141
|
-
function getPendingValueComputed(el) {
|
|
1142
|
-
if (!el._pendingValueComputed) {
|
|
1143
|
-
const prevPending = pendingReadActive;
|
|
1144
|
-
pendingReadActive = false;
|
|
1145
|
-
const prevCheck = pendingCheckActive;
|
|
1146
|
-
pendingCheckActive = false;
|
|
1147
|
-
const prevContext = context;
|
|
1148
|
-
context = null;
|
|
1149
|
-
el._pendingValueComputed = optimisticComputed(() => read(el));
|
|
1150
|
-
el._pendingValueComputed._parentSource = el;
|
|
1151
|
-
context = prevContext;
|
|
1152
|
-
pendingCheckActive = prevCheck;
|
|
1153
|
-
pendingReadActive = prevPending;
|
|
1154
|
-
}
|
|
1155
|
-
return el._pendingValueComputed;
|
|
1156
|
-
}
|
|
1157
|
-
function updatePendingSignal(el) {
|
|
1158
|
-
if (el._pendingSignal) {
|
|
1159
|
-
const pending = computePendingState(el);
|
|
1160
|
-
const sig = el._pendingSignal;
|
|
1161
|
-
setSignal(sig, pending);
|
|
1162
|
-
if (!pending && sig._optimisticLane) {
|
|
1163
|
-
const sourceLane = resolveLane(el);
|
|
1164
|
-
if (sourceLane && sourceLane._pendingAsync.size > 0) {
|
|
1165
|
-
const sigLane = findLane(sig._optimisticLane);
|
|
1166
|
-
if (sigLane !== sourceLane) {
|
|
1167
|
-
mergeLanes(sourceLane, sigLane);
|
|
1168
|
-
}
|
|
1169
|
-
}
|
|
1170
|
-
clearLaneEntry(sig);
|
|
1171
|
-
sig._optimisticLane = undefined;
|
|
1172
|
-
}
|
|
1173
|
-
}
|
|
1210
|
+
c._optimistic = true;
|
|
1211
|
+
return c;
|
|
1174
1212
|
}
|
|
1175
1213
|
function isEqual(a, b) {
|
|
1176
1214
|
return a === b;
|
|
@@ -1311,58 +1349,6 @@ function setSignal(el, v) {
|
|
|
1311
1349
|
schedule();
|
|
1312
1350
|
return v;
|
|
1313
1351
|
}
|
|
1314
|
-
const PENDING_OWNER = {};
|
|
1315
|
-
function getObserver() {
|
|
1316
|
-
if (pendingCheckActive || pendingReadActive) return PENDING_OWNER;
|
|
1317
|
-
return tracking ? context : null;
|
|
1318
|
-
}
|
|
1319
|
-
function getOwner() {
|
|
1320
|
-
return context;
|
|
1321
|
-
}
|
|
1322
|
-
function onCleanup(fn) {
|
|
1323
|
-
if (!context) return fn;
|
|
1324
|
-
if (!context._disposal) context._disposal = fn;
|
|
1325
|
-
else if (Array.isArray(context._disposal)) context._disposal.push(fn);
|
|
1326
|
-
else context._disposal = [context._disposal, fn];
|
|
1327
|
-
return fn;
|
|
1328
|
-
}
|
|
1329
|
-
function createOwner(options) {
|
|
1330
|
-
const parent = context;
|
|
1331
|
-
const owner = {
|
|
1332
|
-
id: options?.id ?? (parent?.id != null ? getNextChildId(parent) : undefined),
|
|
1333
|
-
_root: true,
|
|
1334
|
-
_parentComputed: parent?._root ? parent._parentComputed : parent,
|
|
1335
|
-
_firstChild: null,
|
|
1336
|
-
_nextSibling: null,
|
|
1337
|
-
_disposal: null,
|
|
1338
|
-
_queue: parent?._queue ?? globalQueue,
|
|
1339
|
-
_context: parent?._context || defaultContext,
|
|
1340
|
-
_childCount: 0,
|
|
1341
|
-
_pendingDisposal: null,
|
|
1342
|
-
_pendingFirstChild: null,
|
|
1343
|
-
_parent: parent,
|
|
1344
|
-
dispose(self = true) {
|
|
1345
|
-
disposeChildren(owner, self);
|
|
1346
|
-
}
|
|
1347
|
-
};
|
|
1348
|
-
if (leafEffectActive && parent) {
|
|
1349
|
-
throw new Error("Cannot create reactive primitives inside createTrackedEffect");
|
|
1350
|
-
}
|
|
1351
|
-
if (parent) {
|
|
1352
|
-
const lastChild = parent._firstChild;
|
|
1353
|
-
if (lastChild === null) {
|
|
1354
|
-
parent._firstChild = owner;
|
|
1355
|
-
} else {
|
|
1356
|
-
owner._nextSibling = lastChild;
|
|
1357
|
-
parent._firstChild = owner;
|
|
1358
|
-
}
|
|
1359
|
-
}
|
|
1360
|
-
return owner;
|
|
1361
|
-
}
|
|
1362
|
-
function createRoot(init, options) {
|
|
1363
|
-
const owner = createOwner(options);
|
|
1364
|
-
return runWithOwner(owner, () => init(owner.dispose));
|
|
1365
|
-
}
|
|
1366
1352
|
function runWithOwner(owner, fn) {
|
|
1367
1353
|
const oldContext = context;
|
|
1368
1354
|
const prevTracking = tracking;
|
|
@@ -1375,6 +1361,64 @@ function runWithOwner(owner, fn) {
|
|
|
1375
1361
|
tracking = prevTracking;
|
|
1376
1362
|
}
|
|
1377
1363
|
}
|
|
1364
|
+
function getPendingSignal(el) {
|
|
1365
|
+
if (!el._pendingSignal) {
|
|
1366
|
+
el._pendingSignal = optimisticSignal(false, { pureWrite: true });
|
|
1367
|
+
if (el._parentSource) {
|
|
1368
|
+
el._pendingSignal._parentSource = el;
|
|
1369
|
+
}
|
|
1370
|
+
if (computePendingState(el)) setSignal(el._pendingSignal, true);
|
|
1371
|
+
}
|
|
1372
|
+
return el._pendingSignal;
|
|
1373
|
+
}
|
|
1374
|
+
function computePendingState(el) {
|
|
1375
|
+
const comp = el;
|
|
1376
|
+
if (el._optimistic && el._pendingValue !== NOT_PENDING) {
|
|
1377
|
+
if (comp._statusFlags & STATUS_PENDING && !(comp._statusFlags & STATUS_UNINITIALIZED))
|
|
1378
|
+
return true;
|
|
1379
|
+
if (el._parentSource) {
|
|
1380
|
+
const lane = el._optimisticLane ? findLane(el._optimisticLane) : null;
|
|
1381
|
+
return !!(lane && lane._pendingAsync.size > 0);
|
|
1382
|
+
}
|
|
1383
|
+
return true;
|
|
1384
|
+
}
|
|
1385
|
+
if (el._pendingValue !== NOT_PENDING && !(comp._statusFlags & STATUS_UNINITIALIZED)) return true;
|
|
1386
|
+
return !!(comp._statusFlags & STATUS_PENDING && !(comp._statusFlags & STATUS_UNINITIALIZED));
|
|
1387
|
+
}
|
|
1388
|
+
function updatePendingSignal(el) {
|
|
1389
|
+
if (el._pendingSignal) {
|
|
1390
|
+
const pending = computePendingState(el);
|
|
1391
|
+
const sig = el._pendingSignal;
|
|
1392
|
+
setSignal(sig, pending);
|
|
1393
|
+
if (!pending && sig._optimisticLane) {
|
|
1394
|
+
const sourceLane = resolveLane(el);
|
|
1395
|
+
if (sourceLane && sourceLane._pendingAsync.size > 0) {
|
|
1396
|
+
const sigLane = findLane(sig._optimisticLane);
|
|
1397
|
+
if (sigLane !== sourceLane) {
|
|
1398
|
+
mergeLanes(sourceLane, sigLane);
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
signalLanes.delete(sig);
|
|
1402
|
+
sig._optimisticLane = undefined;
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
function getPendingValueComputed(el) {
|
|
1407
|
+
if (!el._pendingValueComputed) {
|
|
1408
|
+
const prevPending = pendingReadActive;
|
|
1409
|
+
pendingReadActive = false;
|
|
1410
|
+
const prevCheck = pendingCheckActive;
|
|
1411
|
+
pendingCheckActive = false;
|
|
1412
|
+
const prevContext = context;
|
|
1413
|
+
context = null;
|
|
1414
|
+
el._pendingValueComputed = optimisticComputed(() => read(el));
|
|
1415
|
+
el._pendingValueComputed._parentSource = el;
|
|
1416
|
+
context = prevContext;
|
|
1417
|
+
pendingCheckActive = prevCheck;
|
|
1418
|
+
pendingReadActive = prevPending;
|
|
1419
|
+
}
|
|
1420
|
+
return el._pendingValueComputed;
|
|
1421
|
+
}
|
|
1378
1422
|
function staleValues(fn, set = true) {
|
|
1379
1423
|
const prevStale = stale;
|
|
1380
1424
|
stale = set;
|
|
@@ -1455,99 +1499,49 @@ function hasContext(context, owner) {
|
|
|
1455
1499
|
function isUndefined(value) {
|
|
1456
1500
|
return typeof value === "undefined";
|
|
1457
1501
|
}
|
|
1458
|
-
function
|
|
1459
|
-
|
|
1460
|
-
const
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
if (actualStatus & STATUS_ERROR) {
|
|
1482
|
-
let err = actualError;
|
|
1483
|
-
node._queue.notify(node, STATUS_PENDING, 0);
|
|
1484
|
-
if (node._type === EFFECT_USER) {
|
|
1502
|
+
function restoreTransition(transition, fn) {
|
|
1503
|
+
globalQueue.initTransition(transition);
|
|
1504
|
+
const result = fn();
|
|
1505
|
+
flush();
|
|
1506
|
+
return result;
|
|
1507
|
+
}
|
|
1508
|
+
function action(genFn) {
|
|
1509
|
+
return (...args) =>
|
|
1510
|
+
new Promise((resolve, reject) => {
|
|
1511
|
+
const it = genFn(...args);
|
|
1512
|
+
globalQueue.initTransition();
|
|
1513
|
+
let ctx = activeTransition;
|
|
1514
|
+
ctx._actions.push(it);
|
|
1515
|
+
const done = (v, e) => {
|
|
1516
|
+
ctx = currentTransition(ctx);
|
|
1517
|
+
const i = ctx._actions.indexOf(it);
|
|
1518
|
+
if (i >= 0) ctx._actions.splice(i, 1);
|
|
1519
|
+
setActiveTransition(ctx);
|
|
1520
|
+
schedule();
|
|
1521
|
+
e ? reject(e) : resolve(v);
|
|
1522
|
+
};
|
|
1523
|
+
const step = (v, err) => {
|
|
1524
|
+
let r;
|
|
1485
1525
|
try {
|
|
1486
|
-
|
|
1487
|
-
? node._errorFn(err, () => {
|
|
1488
|
-
node._cleanup?.();
|
|
1489
|
-
node._cleanup = undefined;
|
|
1490
|
-
})
|
|
1491
|
-
: console.error(err);
|
|
1526
|
+
r = err ? it.throw(v) : it.next(v);
|
|
1492
1527
|
} catch (e) {
|
|
1493
|
-
|
|
1528
|
+
return done(undefined, e);
|
|
1494
1529
|
}
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
}
|
|
1510
|
-
function runEffect() {
|
|
1511
|
-
if (!this._modified || this._flags & REACTIVE_DISPOSED) return;
|
|
1512
|
-
this._cleanup?.();
|
|
1513
|
-
this._cleanup = undefined;
|
|
1514
|
-
try {
|
|
1515
|
-
this._cleanup = this._effectFn(this._value, this._prevValue);
|
|
1516
|
-
} catch (error) {
|
|
1517
|
-
if (!this._queue.notify(this, STATUS_ERROR, STATUS_ERROR)) throw error;
|
|
1518
|
-
} finally {
|
|
1519
|
-
this._prevValue = this._value;
|
|
1520
|
-
this._modified = false;
|
|
1521
|
-
}
|
|
1522
|
-
}
|
|
1523
|
-
function trackedEffect(fn, options) {
|
|
1524
|
-
const run = () => {
|
|
1525
|
-
if (!node._modified || node._flags & REACTIVE_DISPOSED) return;
|
|
1526
|
-
node._modified = false;
|
|
1527
|
-
recompute(node);
|
|
1528
|
-
};
|
|
1529
|
-
const node = computed(
|
|
1530
|
-
() => {
|
|
1531
|
-
setLeafEffectActive(true);
|
|
1532
|
-
try {
|
|
1533
|
-
node._cleanup?.();
|
|
1534
|
-
node._cleanup = undefined;
|
|
1535
|
-
node._cleanup = staleValues(fn) || undefined;
|
|
1536
|
-
} finally {
|
|
1537
|
-
setLeafEffectActive(false);
|
|
1538
|
-
}
|
|
1539
|
-
},
|
|
1540
|
-
undefined,
|
|
1541
|
-
{ ...options, lazy: true, pureWrite: true }
|
|
1542
|
-
);
|
|
1543
|
-
node._cleanup = undefined;
|
|
1544
|
-
node._modified = true;
|
|
1545
|
-
node._type = EFFECT_TRACKED;
|
|
1546
|
-
node._run = run;
|
|
1547
|
-
node._queue.enqueue(EFFECT_USER, run);
|
|
1548
|
-
onCleanup(() => node._cleanup?.());
|
|
1549
|
-
if (!node._parent)
|
|
1550
|
-
console.warn("Effects created outside a reactive context will never be disposed");
|
|
1530
|
+
if (r instanceof Promise)
|
|
1531
|
+
return void r.then(run, e => restoreTransition(ctx, () => step(e, true)));
|
|
1532
|
+
run(r);
|
|
1533
|
+
};
|
|
1534
|
+
const run = r => {
|
|
1535
|
+
if (r.done) return done(r.value);
|
|
1536
|
+
if (r.value instanceof Promise)
|
|
1537
|
+
return void r.value.then(
|
|
1538
|
+
v => restoreTransition(ctx, () => step(v)),
|
|
1539
|
+
e => restoreTransition(ctx, () => step(e, true))
|
|
1540
|
+
);
|
|
1541
|
+
restoreTransition(ctx, () => step(r.value));
|
|
1542
|
+
};
|
|
1543
|
+
step();
|
|
1544
|
+
});
|
|
1551
1545
|
}
|
|
1552
1546
|
function createSignal(first, second, third) {
|
|
1553
1547
|
if (typeof first === "function") {
|
|
@@ -1629,7 +1623,8 @@ function onSettled(callback) {
|
|
|
1629
1623
|
function unwrap(value) {
|
|
1630
1624
|
return value?.[$TARGET]?.[STORE_NODE] ?? value;
|
|
1631
1625
|
}
|
|
1632
|
-
function getOverrideValue(value, override, nodes, key) {
|
|
1626
|
+
function getOverrideValue(value, override, nodes, key, optOverride) {
|
|
1627
|
+
if (optOverride && key in optOverride) return optOverride[key];
|
|
1633
1628
|
return override && key in override ? override[key] : value[key];
|
|
1634
1629
|
}
|
|
1635
1630
|
function getAllKeys(value, override, next) {
|
|
@@ -1642,20 +1637,21 @@ function applyState(next, state, keyFn, all) {
|
|
|
1642
1637
|
if (!target) return;
|
|
1643
1638
|
const previous = target[STORE_VALUE];
|
|
1644
1639
|
const override = target[STORE_OVERRIDE];
|
|
1640
|
+
const optOverride = target[STORE_OPTIMISTIC_OVERRIDE];
|
|
1645
1641
|
let nodes = target[STORE_NODE];
|
|
1646
|
-
if (next === previous && !override) return;
|
|
1642
|
+
if (next === previous && !override && !optOverride) return;
|
|
1647
1643
|
(target[STORE_LOOKUP] || storeLookup).set(next, target[$PROXY]);
|
|
1648
1644
|
target[STORE_VALUE] = next;
|
|
1649
1645
|
target[STORE_OVERRIDE] = undefined;
|
|
1650
1646
|
if (Array.isArray(previous)) {
|
|
1651
1647
|
let changed = false;
|
|
1652
|
-
const prevLength = getOverrideValue(previous, override, nodes, "length");
|
|
1648
|
+
const prevLength = getOverrideValue(previous, override, nodes, "length", optOverride);
|
|
1653
1649
|
if (next.length && prevLength && next[0] && keyFn(next[0]) != null) {
|
|
1654
1650
|
let i, j, start, end, newEnd, item, newIndicesNext, keyVal;
|
|
1655
1651
|
for (
|
|
1656
1652
|
start = 0, end = Math.min(prevLength, next.length);
|
|
1657
1653
|
start < end &&
|
|
1658
|
-
((item = getOverrideValue(previous, override, nodes, start)) === next[start] ||
|
|
1654
|
+
((item = getOverrideValue(previous, override, nodes, start, optOverride)) === next[start] ||
|
|
1659
1655
|
(item && next[start] && keyFn(item) === keyFn(next[start])));
|
|
1660
1656
|
start++
|
|
1661
1657
|
) {
|
|
@@ -1667,7 +1663,7 @@ function applyState(next, state, keyFn, all) {
|
|
|
1667
1663
|
end = prevLength - 1, newEnd = next.length - 1;
|
|
1668
1664
|
end >= start &&
|
|
1669
1665
|
newEnd >= start &&
|
|
1670
|
-
((item = getOverrideValue(previous, override, nodes, end)) === next[newEnd] ||
|
|
1666
|
+
((item = getOverrideValue(previous, override, nodes, end, optOverride)) === next[newEnd] ||
|
|
1671
1667
|
(item && next[newEnd] && keyFn(item) === keyFn(next[newEnd])));
|
|
1672
1668
|
end--, newEnd--
|
|
1673
1669
|
) {
|
|
@@ -1699,7 +1695,7 @@ function applyState(next, state, keyFn, all) {
|
|
|
1699
1695
|
newIndices.set(keyVal, j);
|
|
1700
1696
|
}
|
|
1701
1697
|
for (i = start; i <= end; i++) {
|
|
1702
|
-
item = getOverrideValue(previous, override, nodes, i);
|
|
1698
|
+
item = getOverrideValue(previous, override, nodes, i, optOverride);
|
|
1703
1699
|
keyVal = item ? keyFn(item) : item;
|
|
1704
1700
|
j = newIndices.get(keyVal);
|
|
1705
1701
|
if (j !== undefined && j !== -1) {
|
|
@@ -1718,7 +1714,7 @@ function applyState(next, state, keyFn, all) {
|
|
|
1718
1714
|
if (start < next.length) changed = true;
|
|
1719
1715
|
} else if (next.length) {
|
|
1720
1716
|
for (let i = 0, len = next.length; i < len; i++) {
|
|
1721
|
-
const item = getOverrideValue(previous, override, nodes, i);
|
|
1717
|
+
const item = getOverrideValue(previous, override, nodes, i, optOverride);
|
|
1722
1718
|
isWrappable(item)
|
|
1723
1719
|
? applyState(next[i], wrap(item, target), keyFn, all)
|
|
1724
1720
|
: target[STORE_NODE][i] && setSignal(target[STORE_NODE][i], next[i]);
|
|
@@ -1737,7 +1733,7 @@ function applyState(next, state, keyFn, all) {
|
|
|
1737
1733
|
for (let i = 0, len = keys.length; i < len; i++) {
|
|
1738
1734
|
const key = keys[i];
|
|
1739
1735
|
const node = nodes[key];
|
|
1740
|
-
const previousValue = unwrap(getOverrideValue(previous, override, nodes, key));
|
|
1736
|
+
const previousValue = unwrap(getOverrideValue(previous, override, nodes, key, optOverride));
|
|
1741
1737
|
let nextValue = unwrap(next[key]);
|
|
1742
1738
|
if (previousValue === nextValue) continue;
|
|
1743
1739
|
if (
|
|
@@ -2732,36 +2728,6 @@ function createBoundChildren(owner, fn, queue, mask) {
|
|
|
2732
2728
|
return boundaryComputed(() => staleValues(() => flatten(read(c))), mask);
|
|
2733
2729
|
});
|
|
2734
2730
|
}
|
|
2735
|
-
class ConditionalQueue extends Queue {
|
|
2736
|
-
_disabled;
|
|
2737
|
-
_errorNodes = new Set();
|
|
2738
|
-
_pendingNodes = new Set();
|
|
2739
|
-
constructor(disabled) {
|
|
2740
|
-
super();
|
|
2741
|
-
this._disabled = disabled;
|
|
2742
|
-
}
|
|
2743
|
-
run(type) {
|
|
2744
|
-
if (!type || read(this._disabled)) return;
|
|
2745
|
-
return super.run(type);
|
|
2746
|
-
}
|
|
2747
|
-
notify(node, type, flags, error) {
|
|
2748
|
-
if (read(this._disabled)) {
|
|
2749
|
-
if (type & STATUS_PENDING) {
|
|
2750
|
-
if (flags & STATUS_PENDING) {
|
|
2751
|
-
this._pendingNodes.add(node);
|
|
2752
|
-
type &= ~STATUS_PENDING;
|
|
2753
|
-
} else if (this._pendingNodes.delete(node)) type &= ~STATUS_PENDING;
|
|
2754
|
-
}
|
|
2755
|
-
if (type & STATUS_ERROR) {
|
|
2756
|
-
if (flags & STATUS_ERROR) {
|
|
2757
|
-
this._errorNodes.add(node);
|
|
2758
|
-
type &= ~STATUS_ERROR;
|
|
2759
|
-
} else if (this._errorNodes.delete(node)) type &= ~STATUS_ERROR;
|
|
2760
|
-
}
|
|
2761
|
-
}
|
|
2762
|
-
return type ? super.notify(node, type, flags, error ?? node._error) : true;
|
|
2763
|
-
}
|
|
2764
|
-
}
|
|
2765
2731
|
class CollectionQueue extends Queue {
|
|
2766
2732
|
_collectionType;
|
|
2767
2733
|
_sources = new Set();
|
|
@@ -2782,7 +2748,7 @@ class CollectionQueue extends Queue {
|
|
|
2782
2748
|
)
|
|
2783
2749
|
return super.notify(node, type, flags, error);
|
|
2784
2750
|
if (flags & this._collectionType) {
|
|
2785
|
-
const source = error?.
|
|
2751
|
+
const source = error?.source || node._error?.source;
|
|
2786
2752
|
if (source) {
|
|
2787
2753
|
const wasEmpty = this._sources.size === 0;
|
|
2788
2754
|
this._sources.add(source);
|
|
@@ -2799,31 +2765,6 @@ class CollectionQueue extends Queue {
|
|
|
2799
2765
|
if (!this._sources.size) setSignal(this._disabled, false);
|
|
2800
2766
|
}
|
|
2801
2767
|
}
|
|
2802
|
-
var BoundaryMode;
|
|
2803
|
-
(function (BoundaryMode) {
|
|
2804
|
-
BoundaryMode["VISIBLE"] = "visible";
|
|
2805
|
-
BoundaryMode["HIDDEN"] = "hidden";
|
|
2806
|
-
})(BoundaryMode || (BoundaryMode = {}));
|
|
2807
|
-
function createBoundary(fn, condition) {
|
|
2808
|
-
const owner = createOwner();
|
|
2809
|
-
const queue = new ConditionalQueue(computed(() => condition() === BoundaryMode.HIDDEN));
|
|
2810
|
-
const tree = createBoundChildren(owner, fn, queue, 0);
|
|
2811
|
-
computed(() => {
|
|
2812
|
-
const disabled = read(queue._disabled);
|
|
2813
|
-
tree._propagationMask = disabled ? STATUS_ERROR | STATUS_PENDING : 0;
|
|
2814
|
-
if (!disabled) {
|
|
2815
|
-
queue._pendingNodes.forEach(node =>
|
|
2816
|
-
queue.notify(node, STATUS_PENDING, STATUS_PENDING, node._error)
|
|
2817
|
-
);
|
|
2818
|
-
queue._errorNodes.forEach(node =>
|
|
2819
|
-
queue.notify(node, STATUS_ERROR, STATUS_ERROR, node._error)
|
|
2820
|
-
);
|
|
2821
|
-
queue._pendingNodes.clear();
|
|
2822
|
-
queue._errorNodes.clear();
|
|
2823
|
-
}
|
|
2824
|
-
});
|
|
2825
|
-
return () => (read(queue._disabled) ? undefined : read(tree));
|
|
2826
|
-
}
|
|
2827
2768
|
function createCollectionBoundary(type, fn, fallback) {
|
|
2828
2769
|
const owner = createOwner();
|
|
2829
2770
|
const queue = new CollectionQueue(type);
|
|
@@ -2918,7 +2859,6 @@ export {
|
|
|
2918
2859
|
NotReadyError,
|
|
2919
2860
|
SUPPORTS_PROXY,
|
|
2920
2861
|
action,
|
|
2921
|
-
createBoundary,
|
|
2922
2862
|
createContext,
|
|
2923
2863
|
createEffect,
|
|
2924
2864
|
createErrorBoundary,
|
|
@@ -2926,6 +2866,7 @@ export {
|
|
|
2926
2866
|
createMemo,
|
|
2927
2867
|
createOptimistic,
|
|
2928
2868
|
createOptimisticStore,
|
|
2869
|
+
createOwner,
|
|
2929
2870
|
createProjection,
|
|
2930
2871
|
createReaction,
|
|
2931
2872
|
createRenderEffect,
|