@solidjs/signals 0.9.10 → 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,83 +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 {
219
- mergeLanes(sourceRoot, existingRoot);
220
- }
221
- }
222
- return;
223
- }
224
- }
225
- el._optimisticLane = sourceLane;
226
- }
227
150
  function runLaneEffects(type) {
228
151
  for (const lane of activeLanes) {
229
152
  if (lane._mergedInto || lane._pendingAsync.size > 0) continue;
@@ -552,6 +475,9 @@ function currentTransition(transition) {
552
475
  while (transition._done && typeof transition._done === "object") transition = transition._done;
553
476
  return transition;
554
477
  }
478
+ function setActiveTransition(transition) {
479
+ activeTransition = transition;
480
+ }
555
481
  function runInTransition(transition, fn) {
556
482
  const prevTransition = activeTransition;
557
483
  try {
@@ -561,201 +487,104 @@ function runInTransition(transition, fn) {
561
487
  activeTransition = prevTransition;
562
488
  }
563
489
  }
564
- function restoreTransition(transition, fn) {
565
- globalQueue.initTransition(transition);
566
- const result = fn();
567
- flush();
568
- 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;
569
511
  }
570
- function action(genFn) {
571
- return (...args) =>
572
- new Promise((resolve, reject) => {
573
- const it = genFn(...args);
574
- globalQueue.initTransition();
575
- let ctx = activeTransition;
576
- ctx._actions.push(it);
577
- const done = (v, e) => {
578
- ctx = currentTransition(ctx);
579
- const i = ctx._actions.indexOf(it);
580
- if (i >= 0) ctx._actions.splice(i, 1);
581
- activeTransition = ctx;
582
- schedule();
583
- e ? reject(e) : resolve(v);
584
- };
585
- const step = (v, err) => {
586
- let r;
587
- try {
588
- r = err ? it.throw(v) : it.next(v);
589
- } catch (e) {
590
- return done(undefined, e);
591
- }
592
- if (r instanceof Promise)
593
- return void r.then(run, e => restoreTransition(ctx, () => step(e, true)));
594
- run(r);
595
- };
596
- const run = r => {
597
- if (r.done) return done(r.value);
598
- if (r.value instanceof Promise)
599
- return void r.value.then(
600
- v => restoreTransition(ctx, () => step(v)),
601
- e => restoreTransition(ctx, () => step(e, true))
602
- );
603
- restoreTransition(ctx, () => step(r.value));
604
- };
605
- step();
606
- });
512
+ function findLane(lane) {
513
+ while (lane._mergedInto) lane = lane._mergedInto;
514
+ return lane;
607
515
  }
608
- GlobalQueue._update = recompute;
609
- GlobalQueue._dispose = disposeChildren;
610
- let tracking = false;
611
- let stale = false;
612
- let refreshing = false;
613
- let pendingCheckActive = false;
614
- let foundPending = false;
615
- let pendingReadActive = false;
616
- let context = null;
617
- let leafEffectActive = false;
618
- function setLeafEffectActive(v) {
619
- 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;
620
525
  }
621
- function recompute(el, create = false) {
622
- const isEffect = el._type;
623
- if (!create) {
624
- if (el._transition && (!isEffect || activeTransition) && activeTransition !== el._transition)
625
- globalQueue.initTransition(el._transition);
626
- deleteFromHeap(el, el._flags & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
627
- if (el._transition || isEffect === EFFECT_TRACKED) disposeChildren(el);
628
- else {
629
- markDisposal(el);
630
- el._pendingDisposal = el._disposal;
631
- el._pendingFirstChild = el._firstChild;
632
- el._disposal = null;
633
- 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;
634
554
  }
635
555
  }
636
- const isOptimisticDirty = !!(el._flags & REACTIVE_OPTIMISTIC_DIRTY);
637
- const hasOverride = hasActiveOverride(el);
638
- const wasPending = !!(el._statusFlags & STATUS_PENDING);
639
- const oldcontext = context;
640
- context = el;
641
- el._depsTail = null;
642
- el._flags = REACTIVE_RECOMPUTING_DEPS;
643
- el._time = clock;
644
- let value = el._pendingValue === NOT_PENDING ? el._value : el._pendingValue;
645
- let oldHeight = el._height;
646
- let prevTracking = tracking;
647
- let prevLane = currentOptimisticLane;
648
- tracking = true;
649
- if (isOptimisticDirty) {
650
- const lane = resolveLane(el);
651
- 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;
652
565
  }
653
- try {
654
- 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);
655
578
  clearStatus(el);
656
- const resolvedLane = resolveLane(el);
657
- if (resolvedLane) {
658
- resolvedLane._pendingAsync.delete(el);
659
- updatePendingSignal(resolvedLane._source);
660
- }
661
- } catch (e) {
662
- if (e instanceof NotReadyError && currentOptimisticLane) {
663
- const lane = findLane(currentOptimisticLane);
664
- if (lane._source !== el) {
665
- lane._pendingAsync.add(el);
666
- el._optimisticLane = lane;
667
- updatePendingSignal(lane._source);
668
- }
669
- }
670
- notifyStatus(
671
- el,
672
- e instanceof NotReadyError ? STATUS_PENDING : STATUS_ERROR,
673
- e,
674
- undefined,
675
- e instanceof NotReadyError ? el._optimisticLane : undefined
676
- );
677
- } finally {
678
- tracking = prevTracking;
679
- el._flags = REACTIVE_NONE;
680
- context = oldcontext;
681
- }
682
- if (!el._error) {
683
- const depsTail = el._depsTail;
684
- let toRemove = depsTail !== null ? depsTail._nextDep : el._deps;
685
- if (toRemove !== null) {
686
- do {
687
- toRemove = unlinkSubs(toRemove);
688
- } while (toRemove !== null);
689
- if (depsTail !== null) depsTail._nextDep = null;
690
- else el._deps = null;
691
- }
692
- const compareValue = hasOverride
693
- ? el._value
694
- : el._pendingValue === NOT_PENDING
695
- ? el._value
696
- : el._pendingValue;
697
- const valueChanged = !el._equals || !el._equals(compareValue, value);
698
- if (valueChanged) {
699
- const prevVisible = hasOverride ? el._value : undefined;
700
- if (create || (isEffect && activeTransition !== el._transition) || isOptimisticDirty)
701
- el._value = value;
702
- else el._pendingValue = value;
703
- if (hasOverride && !isOptimisticDirty && wasPending) {
704
- const ov = el._overrideVersion || 0;
705
- const lv = el._laneVersion || 0;
706
- if (ov <= lv) el._value = value;
707
- }
708
- if (!hasOverride || isOptimisticDirty || el._value !== prevVisible) {
709
- insertSubs(el, isOptimisticDirty || hasOverride);
710
- }
711
- } else if (hasOverride) {
712
- el._pendingValue = value;
713
- } else if (el._height != oldHeight) {
714
- for (let s = el._subs; s !== null; s = s._nextSub) {
715
- insertIntoHeapHeight(s._sub, s._sub._flags & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
716
- }
717
- }
718
- }
719
- setCurrentOptimisticLane(prevLane);
720
- (!create || el._statusFlags & STATUS_PENDING) &&
721
- !el._transition &&
722
- !(activeTransition && el._optimistic) &&
723
- globalQueue._pendingNodes.push(el);
724
- el._transition &&
725
- isEffect &&
726
- activeTransition !== el._transition &&
727
- runInTransition(el._transition, () => recompute(el));
728
- }
729
- function handleAsync(el, result, setter) {
730
- const isObject = typeof result === "object" && result !== null;
731
- const iterator = isObject && untrack(() => result[Symbol.asyncIterator]);
732
- const isThenable = !iterator && isObject && untrack(() => typeof result.then === "function");
733
- if (!isThenable && !iterator) {
734
- el._inFlight = null;
735
- return result;
736
- }
737
- el._inFlight = result;
738
- let syncValue;
739
- const handleError = error => {
740
- if (el._inFlight !== result) return;
741
- globalQueue.initTransition(el._transition);
742
- notifyStatus(el, error instanceof NotReadyError ? STATUS_PENDING : STATUS_ERROR, error);
743
- el._time = clock;
744
- };
745
- const asyncWrite = (value, then) => {
746
- if (el._inFlight !== result) return;
747
- if (el._flags & (REACTIVE_DIRTY | REACTIVE_OPTIMISTIC_DIRTY)) return;
748
- globalQueue.initTransition(el._transition);
749
- clearStatus(el);
750
- const lane = resolveLane(el);
751
- if (lane) lane._pendingAsync.delete(el);
752
- if (setter) setter(value);
753
- else if (el._optimistic) {
754
- const hadOverride = el._pendingValue !== NOT_PENDING;
755
- if (el._fn) el._pendingValue = value;
756
- if (!hadOverride) {
757
- el._value = value;
758
- 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);
759
588
  }
760
589
  el._time = clock;
761
590
  } else if (lane) {
@@ -888,86 +717,102 @@ function notifyStatus(el, status, error, blockStatus, lane) {
888
717
  }
889
718
  }
890
719
  }
891
- function updateIfNecessary(el) {
892
- if (el._flags & REACTIVE_CHECK) {
893
- for (let d = el._deps; d; d = d._nextDep) {
894
- const dep1 = d._dep;
895
- const dep = dep1._firewall || dep1;
896
- if (dep._fn) {
897
- updateIfNecessary(dep);
898
- }
899
- if (el._flags & REACTIVE_DIRTY) {
900
- break;
901
- }
902
- }
903
- }
904
- if (el._flags & (REACTIVE_DIRTY | REACTIVE_OPTIMISTIC_DIRTY) || (el._error && el._time < clock)) {
905
- recompute(el);
906
- }
907
- el._flags = REACTIVE_NONE;
908
- }
909
- function unlinkSubs(link) {
910
- const dep = link._dep;
911
- const nextDep = link._nextDep;
912
- const nextSub = link._nextSub;
913
- const prevSub = link._prevSub;
914
- if (nextSub !== null) nextSub._prevSub = prevSub;
915
- else dep._subsTail = prevSub;
916
- if (prevSub !== null) prevSub._nextSub = nextSub;
917
- else {
918
- dep._subs = nextSub;
919
- if (nextSub === null) {
920
- dep._unobserved?.();
921
- 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
922
734
  }
923
- }
924
- return nextDep;
925
- }
926
- function unobserved(el) {
927
- deleteFromHeap(el, el._flags & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
928
- let dep = el._deps;
929
- while (dep !== null) {
930
- dep = unlinkSubs(dep);
931
- }
932
- el._deps = null;
933
- 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");
934
772
  }
935
- function link(dep, sub) {
936
- const prevDep = sub._depsTail;
937
- if (prevDep !== null && prevDep._dep === dep) return;
938
- let nextDep = null;
939
- const isRecomputing = sub._flags & REACTIVE_RECOMPUTING_DEPS;
940
- if (isRecomputing) {
941
- nextDep = prevDep !== null ? prevDep._nextDep : sub._deps;
942
- if (nextDep !== null && nextDep._dep === dep) {
943
- sub._depsTail = nextDep;
944
- return;
945
- }
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;
946
784
  }
947
- const prevSub = dep._subsTail;
948
- if (prevSub !== null && prevSub._sub === sub && (!isRecomputing || isValidLink(prevSub, sub)))
949
- return;
950
- const newLink =
951
- (sub._depsTail =
952
- dep._subsTail =
953
- { _dep: dep, _sub: sub, _nextDep: nextDep, _prevSub: prevSub, _nextSub: null });
954
- if (prevDep !== null) prevDep._nextDep = newLink;
955
- else sub._deps = newLink;
956
- if (prevSub !== null) prevSub._nextSub = newLink;
957
- else dep._subs = newLink;
958
785
  }
959
- function isValidLink(checkLink, sub) {
960
- const depsTail = sub._depsTail;
961
- if (depsTail !== null) {
962
- let link = sub._deps;
963
- do {
964
- if (link === checkLink) return true;
965
- if (link === depsTail) break;
966
- link = link._nextDep;
967
- } while (link !== null);
968
- }
969
- 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");
970
814
  }
815
+ const PENDING_OWNER = {};
971
816
  function markDisposal(el) {
972
817
  let child = el._firstChild;
973
818
  while (child) {
@@ -1038,9 +883,258 @@ function formatId(prefix, id) {
1038
883
  len = num.length - 1;
1039
884
  return prefix + (len ? String.fromCharCode(64 + len) : "") + num;
1040
885
  }
1041
- function computed(fn, initialValue, options) {
1042
- const self = {
1043
- id: options?.id ?? (context?.id != null ? getNextChildId(context) : undefined),
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 = {
1137
+ id: options?.id ?? (context?.id != null ? getNextChildId(context) : undefined),
1044
1138
  _equals: options?.equals != null ? options.equals : isEqual,
1045
1139
  _pureWrite: !!options?.pureWrite,
1046
1140
  _unobserved: options?.unobserved,
@@ -1113,66 +1207,8 @@ function optimisticSignal(v, options) {
1113
1207
  }
1114
1208
  function optimisticComputed(fn, initialValue, options) {
1115
1209
  const c = computed(fn, initialValue, options);
1116
- c._optimistic = true;
1117
- return c;
1118
- }
1119
- function getPendingSignal(el) {
1120
- if (!el._pendingSignal) {
1121
- el._pendingSignal = optimisticSignal(false, { pureWrite: true });
1122
- if (el._parentSource) {
1123
- el._pendingSignal._parentSource = el;
1124
- }
1125
- if (computePendingState(el)) setSignal(el._pendingSignal, true);
1126
- }
1127
- return el._pendingSignal;
1128
- }
1129
- function computePendingState(el) {
1130
- const comp = el;
1131
- if (el._optimistic && el._pendingValue !== NOT_PENDING) {
1132
- if (comp._statusFlags & STATUS_PENDING && !(comp._statusFlags & STATUS_UNINITIALIZED))
1133
- return true;
1134
- if (el._parentSource) {
1135
- const lane = el._optimisticLane ? findLane(el._optimisticLane) : null;
1136
- return !!(lane && lane._pendingAsync.size > 0);
1137
- }
1138
- return true;
1139
- }
1140
- if (el._pendingValue !== NOT_PENDING && !(comp._statusFlags & STATUS_UNINITIALIZED)) return true;
1141
- return !!(comp._statusFlags & STATUS_PENDING && !(comp._statusFlags & STATUS_UNINITIALIZED));
1142
- }
1143
- function getPendingValueComputed(el) {
1144
- if (!el._pendingValueComputed) {
1145
- const prevPending = pendingReadActive;
1146
- pendingReadActive = false;
1147
- const prevCheck = pendingCheckActive;
1148
- pendingCheckActive = false;
1149
- const prevContext = context;
1150
- context = null;
1151
- el._pendingValueComputed = optimisticComputed(() => read(el));
1152
- el._pendingValueComputed._parentSource = el;
1153
- context = prevContext;
1154
- pendingCheckActive = prevCheck;
1155
- pendingReadActive = prevPending;
1156
- }
1157
- return el._pendingValueComputed;
1158
- }
1159
- function updatePendingSignal(el) {
1160
- if (el._pendingSignal) {
1161
- const pending = computePendingState(el);
1162
- const sig = el._pendingSignal;
1163
- setSignal(sig, pending);
1164
- if (!pending && sig._optimisticLane) {
1165
- const sourceLane = resolveLane(el);
1166
- if (sourceLane && sourceLane._pendingAsync.size > 0) {
1167
- const sigLane = findLane(sig._optimisticLane);
1168
- if (sigLane !== sourceLane) {
1169
- mergeLanes(sourceLane, sigLane);
1170
- }
1171
- }
1172
- clearLaneEntry(sig);
1173
- sig._optimisticLane = undefined;
1174
- }
1175
- }
1210
+ c._optimistic = true;
1211
+ return c;
1176
1212
  }
1177
1213
  function isEqual(a, b) {
1178
1214
  return a === b;
@@ -1313,58 +1349,6 @@ function setSignal(el, v) {
1313
1349
  schedule();
1314
1350
  return v;
1315
1351
  }
1316
- const PENDING_OWNER = {};
1317
- function getObserver() {
1318
- if (pendingCheckActive || pendingReadActive) return PENDING_OWNER;
1319
- return tracking ? context : null;
1320
- }
1321
- function getOwner() {
1322
- return context;
1323
- }
1324
- function onCleanup(fn) {
1325
- if (!context) return fn;
1326
- if (!context._disposal) context._disposal = fn;
1327
- else if (Array.isArray(context._disposal)) context._disposal.push(fn);
1328
- else context._disposal = [context._disposal, fn];
1329
- return fn;
1330
- }
1331
- function createOwner(options) {
1332
- const parent = context;
1333
- const owner = {
1334
- id: options?.id ?? (parent?.id != null ? getNextChildId(parent) : undefined),
1335
- _root: true,
1336
- _parentComputed: parent?._root ? parent._parentComputed : parent,
1337
- _firstChild: null,
1338
- _nextSibling: null,
1339
- _disposal: null,
1340
- _queue: parent?._queue ?? globalQueue,
1341
- _context: parent?._context || defaultContext,
1342
- _childCount: 0,
1343
- _pendingDisposal: null,
1344
- _pendingFirstChild: null,
1345
- _parent: parent,
1346
- dispose(self = true) {
1347
- disposeChildren(owner, self);
1348
- }
1349
- };
1350
- if (leafEffectActive && parent) {
1351
- throw new Error("Cannot create reactive primitives inside createTrackedEffect");
1352
- }
1353
- if (parent) {
1354
- const lastChild = parent._firstChild;
1355
- if (lastChild === null) {
1356
- parent._firstChild = owner;
1357
- } else {
1358
- owner._nextSibling = lastChild;
1359
- parent._firstChild = owner;
1360
- }
1361
- }
1362
- return owner;
1363
- }
1364
- function createRoot(init, options) {
1365
- const owner = createOwner(options);
1366
- return runWithOwner(owner, () => init(owner.dispose));
1367
- }
1368
1352
  function runWithOwner(owner, fn) {
1369
1353
  const oldContext = context;
1370
1354
  const prevTracking = tracking;
@@ -1377,6 +1361,64 @@ function runWithOwner(owner, fn) {
1377
1361
  tracking = prevTracking;
1378
1362
  }
1379
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
+ }
1380
1422
  function staleValues(fn, set = true) {
1381
1423
  const prevStale = stale;
1382
1424
  stale = set;
@@ -1457,99 +1499,49 @@ function hasContext(context, owner) {
1457
1499
  function isUndefined(value) {
1458
1500
  return typeof value === "undefined";
1459
1501
  }
1460
- function effect(compute, effect, error, initialValue, options) {
1461
- let initialized = false;
1462
- const node = computed(
1463
- options?.render ? p => staleValues(() => compute(p)) : compute,
1464
- initialValue,
1465
- {
1466
- ...options,
1467
- equals: () => {
1468
- node._modified = !node._error;
1469
- if (initialized) node._queue.enqueue(node._type, runEffect.bind(node));
1470
- return false;
1471
- },
1472
- lazy: true
1473
- }
1474
- );
1475
- node._prevValue = initialValue;
1476
- node._effectFn = effect;
1477
- node._errorFn = error;
1478
- node._cleanup = undefined;
1479
- node._type = options?.render ? EFFECT_RENDER : EFFECT_USER;
1480
- node._notifyStatus = (status, error) => {
1481
- const actualStatus = status !== undefined ? status : node._statusFlags;
1482
- const actualError = error !== undefined ? error : node._error;
1483
- if (actualStatus & STATUS_ERROR) {
1484
- let err = actualError;
1485
- node._queue.notify(node, STATUS_PENDING, 0);
1486
- 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;
1487
1525
  try {
1488
- return node._errorFn
1489
- ? node._errorFn(err, () => {
1490
- node._cleanup?.();
1491
- node._cleanup = undefined;
1492
- })
1493
- : console.error(err);
1526
+ r = err ? it.throw(v) : it.next(v);
1494
1527
  } catch (e) {
1495
- err = e;
1528
+ return done(undefined, e);
1496
1529
  }
1497
- }
1498
- if (!node._queue.notify(node, STATUS_ERROR, STATUS_ERROR)) throw err;
1499
- } else if (node._type === EFFECT_RENDER)
1500
- node._queue.notify(node, STATUS_PENDING | STATUS_ERROR, actualStatus, actualError);
1501
- };
1502
- recompute(node, true);
1503
- !options?.defer &&
1504
- (node._type === EFFECT_USER
1505
- ? node._queue.enqueue(node._type, runEffect.bind(node))
1506
- : runEffect.call(node));
1507
- initialized = true;
1508
- onCleanup(() => node._cleanup?.());
1509
- if (!node._parent)
1510
- console.warn("Effects created outside a reactive context will never be disposed");
1511
- }
1512
- function runEffect() {
1513
- if (!this._modified || this._flags & REACTIVE_DISPOSED) return;
1514
- this._cleanup?.();
1515
- this._cleanup = undefined;
1516
- try {
1517
- this._cleanup = this._effectFn(this._value, this._prevValue);
1518
- } catch (error) {
1519
- if (!this._queue.notify(this, STATUS_ERROR, STATUS_ERROR)) throw error;
1520
- } finally {
1521
- this._prevValue = this._value;
1522
- this._modified = false;
1523
- }
1524
- }
1525
- function trackedEffect(fn, options) {
1526
- const run = () => {
1527
- if (!node._modified || node._flags & REACTIVE_DISPOSED) return;
1528
- node._modified = false;
1529
- recompute(node);
1530
- };
1531
- const node = computed(
1532
- () => {
1533
- setLeafEffectActive(true);
1534
- try {
1535
- node._cleanup?.();
1536
- node._cleanup = undefined;
1537
- node._cleanup = staleValues(fn) || undefined;
1538
- } finally {
1539
- setLeafEffectActive(false);
1540
- }
1541
- },
1542
- undefined,
1543
- { ...options, lazy: true, pureWrite: true }
1544
- );
1545
- node._cleanup = undefined;
1546
- node._modified = true;
1547
- node._type = EFFECT_TRACKED;
1548
- node._run = run;
1549
- node._queue.enqueue(EFFECT_USER, run);
1550
- onCleanup(() => node._cleanup?.());
1551
- if (!node._parent)
1552
- 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
+ });
1553
1545
  }
1554
1546
  function createSignal(first, second, third) {
1555
1547
  if (typeof first === "function") {
@@ -1745,6 +1737,7 @@ function applyState(next, state, keyFn, all) {
1745
1737
  if (
1746
1738
  !previousValue ||
1747
1739
  !isWrappable(previousValue) ||
1740
+ !isWrappable(nextValue) ||
1748
1741
  (keyFn(previousValue) != null && keyFn(previousValue) !== keyFn(nextValue))
1749
1742
  ) {
1750
1743
  tracked && setSignal(tracked, void 0);
@@ -2733,36 +2726,6 @@ function createBoundChildren(owner, fn, queue, mask) {
2733
2726
  return boundaryComputed(() => staleValues(() => flatten(read(c))), mask);
2734
2727
  });
2735
2728
  }
2736
- class ConditionalQueue extends Queue {
2737
- _disabled;
2738
- _errorNodes = new Set();
2739
- _pendingNodes = new Set();
2740
- constructor(disabled) {
2741
- super();
2742
- this._disabled = disabled;
2743
- }
2744
- run(type) {
2745
- if (!type || read(this._disabled)) return;
2746
- return super.run(type);
2747
- }
2748
- notify(node, type, flags, error) {
2749
- if (read(this._disabled)) {
2750
- if (type & STATUS_PENDING) {
2751
- if (flags & STATUS_PENDING) {
2752
- this._pendingNodes.add(node);
2753
- type &= ~STATUS_PENDING;
2754
- } else if (this._pendingNodes.delete(node)) type &= ~STATUS_PENDING;
2755
- }
2756
- if (type & STATUS_ERROR) {
2757
- if (flags & STATUS_ERROR) {
2758
- this._errorNodes.add(node);
2759
- type &= ~STATUS_ERROR;
2760
- } else if (this._errorNodes.delete(node)) type &= ~STATUS_ERROR;
2761
- }
2762
- }
2763
- return type ? super.notify(node, type, flags, error ?? node._error) : true;
2764
- }
2765
- }
2766
2729
  class CollectionQueue extends Queue {
2767
2730
  _collectionType;
2768
2731
  _sources = new Set();
@@ -2800,31 +2763,6 @@ class CollectionQueue extends Queue {
2800
2763
  if (!this._sources.size) setSignal(this._disabled, false);
2801
2764
  }
2802
2765
  }
2803
- var BoundaryMode;
2804
- (function (BoundaryMode) {
2805
- BoundaryMode["VISIBLE"] = "visible";
2806
- BoundaryMode["HIDDEN"] = "hidden";
2807
- })(BoundaryMode || (BoundaryMode = {}));
2808
- function createBoundary(fn, condition) {
2809
- const owner = createOwner();
2810
- const queue = new ConditionalQueue(computed(() => condition() === BoundaryMode.HIDDEN));
2811
- const tree = createBoundChildren(owner, fn, queue, 0);
2812
- computed(() => {
2813
- const disabled = read(queue._disabled);
2814
- tree._propagationMask = disabled ? STATUS_ERROR | STATUS_PENDING : 0;
2815
- if (!disabled) {
2816
- queue._pendingNodes.forEach(node =>
2817
- queue.notify(node, STATUS_PENDING, STATUS_PENDING, node._error)
2818
- );
2819
- queue._errorNodes.forEach(node =>
2820
- queue.notify(node, STATUS_ERROR, STATUS_ERROR, node._error)
2821
- );
2822
- queue._pendingNodes.clear();
2823
- queue._errorNodes.clear();
2824
- }
2825
- });
2826
- return () => (read(queue._disabled) ? undefined : read(tree));
2827
- }
2828
2766
  function createCollectionBoundary(type, fn, fallback) {
2829
2767
  const owner = createOwner();
2830
2768
  const queue = new CollectionQueue(type);
@@ -2919,7 +2857,6 @@ export {
2919
2857
  NotReadyError,
2920
2858
  SUPPORTS_PROXY,
2921
2859
  action,
2922
- createBoundary,
2923
2860
  createContext,
2924
2861
  createEffect,
2925
2862
  createErrorBoundary,
@@ -2927,6 +2864,7 @@ export {
2927
2864
  createMemo,
2928
2865
  createOptimistic,
2929
2866
  createOptimisticStore,
2867
+ createOwner,
2930
2868
  createProjection,
2931
2869
  createReaction,
2932
2870
  createRenderEffect,