@tanstack/solid-query-persist-client 6.0.0-alpha.1 → 6.0.0-beta.3

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/build/dev.cjs CHANGED
@@ -6,7 +6,7 @@ var solidQuery = require('@tanstack/solid-query');
6
6
 
7
7
  // src/index.ts
8
8
 
9
- // ../../node_modules/.pnpm/@solidjs+signals@0.13.6/node_modules/@solidjs/signals/dist/prod.js
9
+ // ../../node_modules/.pnpm/@solidjs+signals@0.13.9/node_modules/@solidjs/signals/dist/prod.js
10
10
  var NotReadyError = class extends Error {
11
11
  source;
12
12
  constructor(e) {
@@ -568,39 +568,125 @@ function assignOrMergeLane(e, t) {
568
568
  }
569
569
  e.q = t;
570
570
  }
571
+ function unlinkSubs(e) {
572
+ const t = e.m;
573
+ const n = e.D;
574
+ const i = e.p;
575
+ const r = e.Ie;
576
+ if (i !== null) i.Ie = r;
577
+ else t.pe = r;
578
+ if (r !== null) r.p = i;
579
+ else {
580
+ t.I = i;
581
+ if (i === null) {
582
+ t.he?.();
583
+ t.L && !t.Ae && !(t.O & REACTIVE_ZOMBIE) && unobserved(t);
584
+ }
585
+ }
586
+ return n;
587
+ }
588
+ function unobserved(e) {
589
+ deleteFromHeap(e, e.O & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
590
+ let t = e.C;
591
+ while (t !== null) {
592
+ t = unlinkSubs(t);
593
+ }
594
+ e.C = null;
595
+ disposeChildren(e, true);
596
+ }
597
+ function markDisposal(e) {
598
+ let t = e.Pe;
599
+ while (t) {
600
+ t.O |= REACTIVE_ZOMBIE;
601
+ if (t.O & REACTIVE_IN_HEAP) {
602
+ deleteFromHeap(t, dirtyQueue);
603
+ insertIntoHeap(t, zombieQueue);
604
+ }
605
+ markDisposal(t);
606
+ t = t.ge;
607
+ }
608
+ }
609
+ function disposeChildren(e, t = false, n) {
610
+ if (e.O & REACTIVE_DISPOSED) return;
611
+ if (t) e.O = REACTIVE_DISPOSED;
612
+ if (t && e.L) e.Ce = null;
613
+ let i = n ? e.De : e.Pe;
614
+ while (i) {
615
+ const e2 = i.ge;
616
+ if (i.C) {
617
+ const e3 = i;
618
+ deleteFromHeap(e3, e3.O & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
619
+ let t2 = e3.C;
620
+ do {
621
+ t2 = unlinkSubs(t2);
622
+ } while (t2 !== null);
623
+ e3.C = null;
624
+ e3.Ne = null;
625
+ }
626
+ disposeChildren(i, true);
627
+ i = e2;
628
+ }
629
+ if (n) {
630
+ e.De = null;
631
+ } else {
632
+ e.Pe = null;
633
+ e.ye = 0;
634
+ }
635
+ runDisposal(e, n);
636
+ }
637
+ function runDisposal(e, t) {
638
+ let n = t ? e.ve : e.me;
639
+ if (!n) return;
640
+ if (Array.isArray(n)) {
641
+ for (let e2 = 0; e2 < n.length; e2++) {
642
+ const t2 = n[e2];
643
+ t2.call(t2);
644
+ }
645
+ } else {
646
+ n.call(n);
647
+ }
648
+ t ? e.ve = null : e.me = null;
649
+ }
650
+ function cleanup(e) {
651
+ if (!context) return e;
652
+ if (!context.me) context.me = e;
653
+ else if (Array.isArray(context.me)) context.me.push(e);
654
+ else context.me = [context.me, e];
655
+ return e;
656
+ }
571
657
  function addPendingSource(e, t) {
572
- if (e.Ie === t || e.pe?.has(t)) return false;
573
- if (!e.Ie) {
574
- e.Ie = t;
658
+ if (e.be === t || e.Le?.has(t)) return false;
659
+ if (!e.be) {
660
+ e.be = t;
575
661
  return true;
576
662
  }
577
- if (!e.pe) {
578
- e.pe = /* @__PURE__ */ new Set([e.Ie, t]);
663
+ if (!e.Le) {
664
+ e.Le = /* @__PURE__ */ new Set([e.be, t]);
579
665
  } else {
580
- e.pe.add(t);
666
+ e.Le.add(t);
581
667
  }
582
- e.Ie = void 0;
668
+ e.be = void 0;
583
669
  return true;
584
670
  }
585
671
  function removePendingSource(e, t) {
586
- if (e.Ie) {
587
- if (e.Ie !== t) return false;
588
- e.Ie = void 0;
672
+ if (e.be) {
673
+ if (e.be !== t) return false;
674
+ e.be = void 0;
589
675
  return true;
590
676
  }
591
- if (!e.pe?.delete(t)) return false;
592
- if (e.pe.size === 1) {
593
- e.Ie = e.pe.values().next().value;
594
- e.pe = void 0;
595
- } else if (e.pe.size === 0) {
596
- e.pe = void 0;
677
+ if (!e.Le?.delete(t)) return false;
678
+ if (e.Le.size === 1) {
679
+ e.be = e.Le.values().next().value;
680
+ e.Le = void 0;
681
+ } else if (e.Le.size === 0) {
682
+ e.Le = void 0;
597
683
  }
598
684
  return true;
599
685
  }
600
686
  function clearPendingSources(e) {
601
- e.Ie = void 0;
602
- e.pe?.clear();
603
- e.pe = void 0;
687
+ e.be = void 0;
688
+ e.Le?.clear();
689
+ e.Le = void 0;
604
690
  }
605
691
  function setPendingError(e, t, n) {
606
692
  if (!t) {
@@ -629,7 +715,7 @@ function settlePendingSource(e) {
629
715
  if (n.has(i) || !removePendingSource(i, e)) return;
630
716
  n.add(i);
631
717
  i.Ee = clock;
632
- const r = i.Ie ?? i.pe?.values().next().value;
718
+ const r = i.be ?? i.Le?.values().next().value;
633
719
  if (r) {
634
720
  setPendingError(i, r);
635
721
  updatePendingSignal(i);
@@ -637,7 +723,7 @@ function settlePendingSource(e) {
637
723
  i.Se &= ~STATUS_PENDING;
638
724
  setPendingError(i);
639
725
  updatePendingSignal(i);
640
- if (i.he) {
726
+ if (i.Ue) {
641
727
  if (i.W === EFFECT_TRACKED) {
642
728
  const e2 = i;
643
729
  if (!e2.H) {
@@ -651,7 +737,7 @@ function settlePendingSource(e) {
651
737
  }
652
738
  t = true;
653
739
  }
654
- i.he = false;
740
+ i.Ue = false;
655
741
  }
656
742
  forEachDependent(i, settle);
657
743
  };
@@ -663,19 +749,19 @@ function handleAsync(e, t, n) {
663
749
  const r = i && untrack(() => t[Symbol.asyncIterator]);
664
750
  const s = !r && i && untrack(() => typeof t.then === "function");
665
751
  if (!s && !r) {
666
- e.Ae = null;
752
+ e.Ce = null;
667
753
  return t;
668
754
  }
669
- e.Ae = t;
755
+ e.Ce = t;
670
756
  let o;
671
757
  const handleError = (n2) => {
672
- if (e.Ae !== t) return;
758
+ if (e.Ce !== t) return;
673
759
  globalQueue.initTransition(resolveTransition(e));
674
760
  notifyStatus(e, n2 instanceof NotReadyError ? STATUS_PENDING : STATUS_ERROR, n2);
675
761
  e.Ee = clock;
676
762
  };
677
763
  const asyncWrite = (i2, r2) => {
678
- if (e.Ae !== t) return;
764
+ if (e.Ce !== t) return;
679
765
  if (e.O & (REACTIVE_DIRTY | REACTIVE_OPTIMISTIC_DIRTY)) return;
680
766
  globalQueue.initTransition(resolveTransition(e));
681
767
  clearStatus(e);
@@ -690,12 +776,12 @@ function handleAsync(e, t, n) {
690
776
  e.Ee = clock;
691
777
  } else if (s2) {
692
778
  const t2 = e.J;
693
- const n2 = e.Ne;
779
+ const n2 = e.ke;
694
780
  if (!n2 || !n2(i2, t2)) {
695
781
  e.J = i2;
696
782
  e.Ee = clock;
697
- if (e.Pe) {
698
- setSignal(e.Pe, i2);
783
+ if (e.Ge) {
784
+ setSignal(e.Ge, i2);
699
785
  }
700
786
  insertSubs(e, true);
701
787
  }
@@ -729,33 +815,53 @@ function handleAsync(e, t, n) {
729
815
  if (r) {
730
816
  const n2 = t[Symbol.asyncIterator]();
731
817
  let i2 = false;
818
+ let r2 = false;
819
+ cleanup(() => {
820
+ if (r2) return;
821
+ r2 = true;
822
+ try {
823
+ const e2 = n2.return?.();
824
+ if (e2 && typeof e2.then === "function") {
825
+ e2.then(void 0, () => {
826
+ });
827
+ }
828
+ } catch {
829
+ }
830
+ });
732
831
  const iterate = () => {
733
- let e2, t2 = false, r3 = true;
832
+ let s3, u = false, c = true;
734
833
  n2.next().then(
735
834
  (n3) => {
736
- if (r3) {
737
- e2 = n3;
738
- t2 = true;
835
+ if (c) {
836
+ s3 = n3;
837
+ u = true;
838
+ if (n3.done) r2 = true;
839
+ } else if (e.Ce !== t) {
840
+ return;
739
841
  } else if (!n3.done) asyncWrite(n3.value, iterate);
740
842
  else {
843
+ r2 = true;
741
844
  schedule();
742
845
  flush();
743
846
  }
744
847
  },
745
- (e3) => {
746
- if (!r3) handleError(e3);
848
+ (n3) => {
849
+ if (!c && e.Ce === t) {
850
+ r2 = true;
851
+ handleError(n3);
852
+ }
747
853
  }
748
854
  );
749
- r3 = false;
750
- if (t2 && !e2.done) {
751
- o = e2.value;
855
+ c = false;
856
+ if (u && !s3.done) {
857
+ o = s3.value;
752
858
  i2 = true;
753
859
  return iterate();
754
860
  }
755
- return t2 && e2.done;
861
+ return u && s3.done;
756
862
  };
757
- const r2 = iterate();
758
- if (!i2 && !r2) {
863
+ const s2 = iterate();
864
+ if (!i2 && !s2) {
759
865
  globalQueue.initTransition(resolveTransition(e));
760
866
  throw new NotReadyError(context);
761
867
  }
@@ -764,11 +870,11 @@ function handleAsync(e, t, n) {
764
870
  }
765
871
  function clearStatus(e, t = false) {
766
872
  clearPendingSources(e);
767
- e.he = false;
873
+ e.Ue = false;
768
874
  e.Se = t ? 0 : e.Se & STATUS_UNINITIALIZED;
769
875
  setPendingError(e);
770
876
  updatePendingSignal(e);
771
- e.ge?.();
877
+ e.xe?.();
772
878
  }
773
879
  function notifyStatus(e, t, n, i, r) {
774
880
  if (t === STATUS_ERROR && !(n instanceof StatusError) && !(n instanceof NotReadyError))
@@ -794,104 +900,26 @@ function notifyStatus(e, t, n, i, r) {
794
900
  }
795
901
  const a = i || c;
796
902
  const f = i || u ? void 0 : r;
797
- if (e.ge) {
903
+ if (e.xe) {
798
904
  if (i && t === STATUS_PENDING) {
799
905
  return;
800
906
  }
801
907
  if (a) {
802
- e.ge(t, n);
908
+ e.xe(t, n);
803
909
  } else {
804
- e.ge();
910
+ e.xe();
805
911
  }
806
912
  return;
807
913
  }
808
914
  forEachDependent(e, (e2) => {
809
915
  e2.Ee = clock;
810
- if (t === STATUS_PENDING && s && e2.Ie !== s && !e2.pe?.has(s) || t !== STATUS_PENDING && (e2.le !== n || e2.Ie || e2.pe)) {
916
+ if (t === STATUS_PENDING && s && e2.be !== s && !e2.Le?.has(s) || t !== STATUS_PENDING && (e2.le !== n || e2.be || e2.Le)) {
811
917
  if (!a && !e2.K) globalQueue.se.push(e2);
812
918
  notifyStatus(e2, t, n, a, f);
813
919
  }
814
920
  });
815
921
  }
816
922
  var externalSourceConfig = null;
817
- function markDisposal(e) {
818
- let t = e.Ce;
819
- while (t) {
820
- t.O |= REACTIVE_ZOMBIE;
821
- if (t.O & REACTIVE_IN_HEAP) {
822
- deleteFromHeap(t, dirtyQueue);
823
- insertIntoHeap(t, zombieQueue);
824
- }
825
- markDisposal(t);
826
- t = t.De;
827
- }
828
- }
829
- function disposeChildren(e, t = false, n) {
830
- if (e.O & REACTIVE_DISPOSED) return;
831
- if (t) e.O = REACTIVE_DISPOSED;
832
- let i = n ? e.me : e.Ce;
833
- while (i) {
834
- const e2 = i.De;
835
- if (i.C) {
836
- const e3 = i;
837
- deleteFromHeap(e3, e3.O & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
838
- let t2 = e3.C;
839
- do {
840
- t2 = unlinkSubs(t2);
841
- } while (t2 !== null);
842
- e3.C = null;
843
- e3.ye = null;
844
- }
845
- disposeChildren(i, true);
846
- i = e2;
847
- }
848
- if (n) {
849
- e.me = null;
850
- } else {
851
- e.Ce = null;
852
- e.ve = 0;
853
- }
854
- runDisposal(e, n);
855
- }
856
- function runDisposal(e, t) {
857
- let n = t ? e.we : e.be;
858
- if (!n) return;
859
- if (Array.isArray(n)) {
860
- for (let e2 = 0; e2 < n.length; e2++) {
861
- const t2 = n[e2];
862
- t2.call(t2);
863
- }
864
- } else {
865
- n.call(n);
866
- }
867
- t ? e.we = null : e.be = null;
868
- }
869
- function unlinkSubs(e) {
870
- const t = e.m;
871
- const n = e.D;
872
- const i = e.p;
873
- const r = e.Ue;
874
- if (i !== null) i.Ue = r;
875
- else t.ke = r;
876
- if (r !== null) r.p = i;
877
- else {
878
- t.I = i;
879
- if (i === null) {
880
- t.Ge?.();
881
- t.L && !t.xe && !(t.O & REACTIVE_ZOMBIE) && unobserved(t);
882
- }
883
- }
884
- return n;
885
- }
886
- function unobserved(e) {
887
- deleteFromHeap(e, e.O & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
888
- let t = e.C;
889
- while (t !== null) {
890
- t = unlinkSubs(t);
891
- }
892
- e.C = null;
893
- disposeChildren(e, true);
894
- }
895
923
  GlobalQueue.oe = recompute;
896
924
  GlobalQueue.ue = disposeChildren;
897
925
  var tracking = false;
@@ -903,14 +931,15 @@ function recompute(e, t = false) {
903
931
  if (e.K && (!n || activeTransition) && activeTransition !== e.K)
904
932
  globalQueue.initTransition(e.K);
905
933
  deleteFromHeap(e, e.O & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
934
+ e.Ce = null;
906
935
  if (e.K || n === EFFECT_TRACKED) disposeChildren(e);
907
936
  else {
908
937
  markDisposal(e);
909
- e.we = e.be;
910
- e.me = e.Ce;
911
- e.be = null;
912
- e.Ce = null;
913
- e.ve = 0;
938
+ e.ve = e.me;
939
+ e.De = e.Pe;
940
+ e.me = null;
941
+ e.Pe = null;
942
+ e.ye = 0;
914
943
  }
915
944
  }
916
945
  const i = !!(e.O & REACTIVE_OPTIMISTIC_DIRTY);
@@ -918,7 +947,7 @@ function recompute(e, t = false) {
918
947
  const s = !!(e.Se & STATUS_PENDING);
919
948
  const o = context;
920
949
  context = e;
921
- e.ye = null;
950
+ e.Ne = null;
922
951
  e.O = REACTIVE_RECOMPUTING_DEPS;
923
952
  e.Ee = clock;
924
953
  let u = e.X === NOT_PENDING ? e.J : e.X;
@@ -947,7 +976,7 @@ function recompute(e, t = false) {
947
976
  updatePendingSignal(t3.te);
948
977
  }
949
978
  }
950
- if (t2 instanceof NotReadyError) e.he = true;
979
+ if (t2 instanceof NotReadyError) e.Ue = true;
951
980
  notifyStatus(
952
981
  e,
953
982
  t2 instanceof NotReadyError ? STATUS_PENDING : STATUS_ERROR,
@@ -961,7 +990,7 @@ function recompute(e, t = false) {
961
990
  context = o;
962
991
  }
963
992
  if (!e.le) {
964
- const o2 = e.ye;
993
+ const o2 = e.Ne;
965
994
  let a2 = o2 !== null ? o2.D : e.C;
966
995
  if (a2 !== null) {
967
996
  do {
@@ -971,7 +1000,7 @@ function recompute(e, t = false) {
971
1000
  else e.C = null;
972
1001
  }
973
1002
  const f2 = r ? e.ee : e.X === NOT_PENDING ? e.J : e.X;
974
- const l = !e.Ne || !e.Ne(f2, u);
1003
+ const l = !e.ke || !e.ke(f2, u);
975
1004
  if (l) {
976
1005
  const o3 = r ? e.ee : void 0;
977
1006
  if (t || n && activeTransition !== e.K || i) {
@@ -1012,7 +1041,7 @@ function setSignal(e, t) {
1012
1041
  const i = e.ee !== void 0 && e.ee !== NOT_PENDING;
1013
1042
  const r = n ? i ? e.ee : e.J : e.X === NOT_PENDING ? e.J : e.X;
1014
1043
  if (typeof t === "function") t = t(r);
1015
- const s = !e.Ne || !e.Ne(r, t) || !!(e.Se & STATUS_UNINITIALIZED);
1044
+ const s = !e.ke || !e.ke(r, t) || !!(e.Se & STATUS_UNINITIALIZED);
1016
1045
  if (!s) {
1017
1046
  if (n && i && e.L) {
1018
1047
  insertSubs(e, true);
@@ -1036,8 +1065,8 @@ function setSignal(e, t) {
1036
1065
  e.X = t;
1037
1066
  }
1038
1067
  updatePendingSignal(e);
1039
- if (e.Pe) {
1040
- setSignal(e.Pe, t);
1068
+ if (e.Ge) {
1069
+ setSignal(e.Ge, t);
1041
1070
  }
1042
1071
  e.Ee = clock;
1043
1072
  insertSubs(e, n);
@@ -1048,7 +1077,7 @@ function computePendingState(e) {
1048
1077
  const t = e;
1049
1078
  const n = e.V;
1050
1079
  if (n && e.X !== NOT_PENDING) {
1051
- return !n.Ae && !(n.Se & STATUS_PENDING);
1080
+ return !n.Ce && !(n.Se & STATUS_PENDING);
1052
1081
  }
1053
1082
  if (e.ee !== void 0 && e.ee !== NOT_PENDING) {
1054
1083
  if (t.Se & STATUS_PENDING && !(t.Se & STATUS_UNINITIALIZED)) return true;
@@ -1083,7 +1112,7 @@ function updatePendingSignal(e) {
1083
1112
  }
1084
1113
  }
1085
1114
  function isWrappable(e) {
1086
- return e != null && typeof e === "object" && !Object.isFrozen(e);
1115
+ return e != null && typeof e === "object" && !Object.isFrozen(e) && !(typeof Node !== "undefined" && e instanceof Node);
1087
1116
  }
1088
1117
  var DELETE = /* @__PURE__ */ Symbol(0);
1089
1118
  function updatePath(e, t, n = 0) {