@solidjs/signals 0.9.11 → 0.10.0

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 CHANGED
@@ -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;
@@ -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
- function restoreTransition(transition, fn) {
563
- globalQueue.initTransition(transition);
564
- const result = fn();
565
- flush();
566
- return result;
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 action(genFn) {
569
- return (...args) =>
570
- new Promise((resolve, reject) => {
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
- GlobalQueue._update = recompute;
607
- GlobalQueue._dispose = disposeChildren;
608
- let tracking = false;
609
- let stale = false;
610
- let refreshing = false;
611
- let pendingCheckActive = false;
612
- let foundPending = false;
613
- let pendingReadActive = false;
614
- let context = null;
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 recompute(el, create = false) {
620
- const isEffect = el._type;
621
- if (!create) {
622
- if (el._transition && (!isEffect || activeTransition) && activeTransition !== el._transition)
623
- globalQueue.initTransition(el._transition);
624
- deleteFromHeap(el, el._flags & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
625
- if (el._transition || isEffect === EFFECT_TRACKED) disposeChildren(el);
626
- else {
627
- markDisposal(el);
628
- el._pendingDisposal = el._disposal;
629
- el._pendingFirstChild = el._firstChild;
630
- el._disposal = null;
631
- el._firstChild = null;
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
- const isOptimisticDirty = !!(el._flags & REACTIVE_OPTIMISTIC_DIRTY);
635
- const hasOverride = hasActiveOverride(el);
636
- const wasPending = !!(el._statusFlags & STATUS_PENDING);
637
- const oldcontext = context;
638
- context = el;
639
- el._depsTail = null;
640
- el._flags = REACTIVE_RECOMPUTING_DEPS;
641
- el._time = clock;
642
- let value = el._pendingValue === NOT_PENDING ? el._value : el._pendingValue;
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
- try {
652
- value = handleAsync(el, el._fn(value));
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 resolvedLane = resolveLane(el);
655
- if (resolvedLane) {
656
- resolvedLane._pendingAsync.delete(el);
657
- updatePendingSignal(resolvedLane._source);
658
- }
659
- } catch (e) {
660
- if (e instanceof NotReadyError && currentOptimisticLane) {
661
- const lane = findLane(currentOptimisticLane);
662
- if (lane._source !== el) {
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) {
@@ -886,86 +717,102 @@ function notifyStatus(el, status, error, blockStatus, lane) {
886
717
  }
887
718
  }
888
719
  }
889
- function updateIfNecessary(el) {
890
- if (el._flags & REACTIVE_CHECK) {
891
- for (let d = el._deps; d; d = d._nextDep) {
892
- const dep1 = d._dep;
893
- const dep = dep1._firewall || dep1;
894
- if (dep._fn) {
895
- updateIfNecessary(dep);
896
- }
897
- if (el._flags & REACTIVE_DIRTY) {
898
- break;
899
- }
900
- }
901
- }
902
- if (el._flags & (REACTIVE_DIRTY | REACTIVE_OPTIMISTIC_DIRTY) || (el._error && el._time < clock)) {
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
- return nextDep;
923
- }
924
- function unobserved(el) {
925
- deleteFromHeap(el, el._flags & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
926
- let dep = el._deps;
927
- while (dep !== null) {
928
- dep = unlinkSubs(dep);
929
- }
930
- el._deps = null;
931
- disposeChildren(el, true);
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 link(dep, sub) {
934
- const prevDep = sub._depsTail;
935
- if (prevDep !== null && prevDep._dep === dep) return;
936
- let nextDep = null;
937
- const isRecomputing = sub._flags & REACTIVE_RECOMPUTING_DEPS;
938
- if (isRecomputing) {
939
- nextDep = prevDep !== null ? prevDep._nextDep : sub._deps;
940
- if (nextDep !== null && nextDep._dep === dep) {
941
- sub._depsTail = nextDep;
942
- return;
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 isValidLink(checkLink, sub) {
958
- const depsTail = sub._depsTail;
959
- if (depsTail !== null) {
960
- let link = sub._deps;
961
- do {
962
- if (link === checkLink) return true;
963
- if (link === depsTail) break;
964
- link = link._nextDep;
965
- } while (link !== null);
966
- }
967
- return false;
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 computed(fn, initialValue, options) {
1040
- const self = {
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 effect(compute, effect, error, initialValue, options) {
1459
- let initialized = false;
1460
- const node = computed(
1461
- options?.render ? p => staleValues(() => compute(p)) : compute,
1462
- initialValue,
1463
- {
1464
- ...options,
1465
- equals: () => {
1466
- node._modified = !node._error;
1467
- if (initialized) node._queue.enqueue(node._type, runEffect.bind(node));
1468
- return false;
1469
- },
1470
- lazy: true
1471
- }
1472
- );
1473
- node._prevValue = initialValue;
1474
- node._effectFn = effect;
1475
- node._errorFn = error;
1476
- node._cleanup = undefined;
1477
- node._type = options?.render ? EFFECT_RENDER : EFFECT_USER;
1478
- node._notifyStatus = (status, error) => {
1479
- const actualStatus = status !== undefined ? status : node._statusFlags;
1480
- const actualError = error !== undefined ? error : node._error;
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
- return node._errorFn
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
- err = e;
1528
+ return done(undefined, e);
1494
1529
  }
1495
- }
1496
- if (!node._queue.notify(node, STATUS_ERROR, STATUS_ERROR)) throw err;
1497
- } else if (node._type === EFFECT_RENDER)
1498
- node._queue.notify(node, STATUS_PENDING | STATUS_ERROR, actualStatus, actualError);
1499
- };
1500
- recompute(node, true);
1501
- !options?.defer &&
1502
- (node._type === EFFECT_USER
1503
- ? node._queue.enqueue(node._type, runEffect.bind(node))
1504
- : runEffect.call(node));
1505
- initialized = true;
1506
- onCleanup(() => node._cleanup?.());
1507
- if (!node._parent)
1508
- console.warn("Effects created outside a reactive context will never be disposed");
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") {
@@ -2732,36 +2726,6 @@ function createBoundChildren(owner, fn, queue, mask) {
2732
2726
  return boundaryComputed(() => staleValues(() => flatten(read(c))), mask);
2733
2727
  });
2734
2728
  }
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
2729
  class CollectionQueue extends Queue {
2766
2730
  _collectionType;
2767
2731
  _sources = new Set();
@@ -2799,31 +2763,6 @@ class CollectionQueue extends Queue {
2799
2763
  if (!this._sources.size) setSignal(this._disabled, false);
2800
2764
  }
2801
2765
  }
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
2766
  function createCollectionBoundary(type, fn, fallback) {
2828
2767
  const owner = createOwner();
2829
2768
  const queue = new CollectionQueue(type);
@@ -2918,7 +2857,6 @@ export {
2918
2857
  NotReadyError,
2919
2858
  SUPPORTS_PROXY,
2920
2859
  action,
2921
- createBoundary,
2922
2860
  createContext,
2923
2861
  createEffect,
2924
2862
  createErrorBoundary,
@@ -2926,6 +2864,7 @@ export {
2926
2864
  createMemo,
2927
2865
  createOptimistic,
2928
2866
  createOptimisticStore,
2867
+ createOwner,
2929
2868
  createProjection,
2930
2869
  createReaction,
2931
2870
  createRenderEffect,