reactjrx 1.128.2 → 1.130.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.
Files changed (38) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.ts +5 -4
  4. package/dist/index.js +803 -667
  5. package/dist/index.js.map +1 -1
  6. package/dist/lib/binding/useObserve/store.d.ts +21 -0
  7. package/dist/lib/binding/useObserve/types.d.ts +5 -0
  8. package/dist/lib/binding/useObserve/useObserve.d.ts +15 -0
  9. package/dist/lib/binding/useObserve/useStore.d.ts +17 -0
  10. package/dist/lib/queries/useConcatMutation$.d.ts +1 -1
  11. package/dist/lib/queries/useMutation$.d.ts +18 -18
  12. package/dist/lib/queries/useQuery$.d.ts +1 -1
  13. package/dist/lib/queries/useSwitchMutation$.d.ts +9 -9
  14. package/dist/lib/state/Signal.d.ts +10 -2
  15. package/dist/lib/state/index.d.ts +1 -1
  16. package/dist/lib/state/persistence/constants.d.ts +1 -0
  17. package/dist/lib/state/{persistance → persistence}/helpers.d.ts +2 -2
  18. package/dist/lib/state/{persistance → persistence}/types.d.ts +3 -3
  19. package/dist/lib/state/react/usePersistSignals.d.ts +4 -4
  20. package/dist/lib/utils/index.d.ts +1 -5
  21. package/dist/lib/utils/react/index.d.ts +9 -0
  22. package/dist/lib/utils/react/useDebounced.d.ts +8 -0
  23. package/dist/lib/utils/react/useMemoCompare.d.ts +1 -0
  24. package/dist/lib/utils/react/useUnmount.d.ts +1 -0
  25. package/package.json +8 -6
  26. package/dist/lib/binding/useObserve.d.ts +0 -21
  27. package/dist/lib/state/persistance/constants.d.ts +0 -1
  28. /package/dist/lib/binding/{useObserve.compare.test.d.ts → useObserve/useObserve.compare.test.d.ts} +0 -0
  29. /package/dist/lib/binding/{useObserve.selector.test.d.ts → useObserve/useObserve.selector.test.d.ts} +0 -0
  30. /package/dist/lib/binding/{useObserve.test.d.ts → useObserve/useObserve.test.d.ts} +0 -0
  31. /package/dist/lib/{utils/react → binding}/useUnmountObservable.d.ts +0 -0
  32. /package/dist/lib/{utils/react → binding}/useUnmountObservable.test.d.ts +0 -0
  33. /package/dist/lib/state/{persistance → persistence}/adapters/Adapter.d.ts +0 -0
  34. /package/dist/lib/state/{persistance → persistence}/adapters/MockAdapter.d.ts +0 -0
  35. /package/dist/lib/state/{persistance → persistence}/adapters/createLocalStorageAdapter.d.ts +0 -0
  36. /package/dist/lib/state/{persistance → persistence}/adapters/createLocalforageAdapter.d.ts +0 -0
  37. /package/dist/lib/state/{persistance → persistence}/persistSignals.d.ts +0 -0
  38. /package/dist/lib/state/{persistance → persistence}/persistSignals.test.d.ts +0 -0
package/dist/index.js CHANGED
@@ -1,423 +1,649 @@
1
- import { useRef as q, useEffect as I, useMemo as Z, useCallback as S, useSyncExternalStore as Se, createContext as B, memo as ee, useState as _, useContext as te } from "react";
2
- import { BehaviorSubject as E, isObservable as J, from as x, of as b, defer as D, map as $, distinctUntilChanged as re, shareReplay as ve, startWith as Ie, identity as ne, tap as k, catchError as F, EMPTY as H, retry as we, takeUntil as Ee, fromEvent as se, share as ue, take as oe, noop as L, filter as Ce, first as ce, switchMap as M, delay as xe, merge as V, ignoreElements as Me, defaultIfEmpty as Ve, zip as Fe, throttleTime as $e, asyncScheduler as qe, concatMap as Ne, scan as Re, throwError as A, timer as Ae, ReplaySubject as Y } from "rxjs";
3
- import { jsx as ae } from "react/jsx-runtime";
4
- import { hashKey as ie, useMutation as Pe, useQueryClient as le, useQuery as Oe } from "@tanstack/react-query";
5
- import { catchError as U, mergeMap as P, retryWhen as Qe, concatMap as Te, first as _e, tap as De } from "rxjs/operators";
6
- const K = (e) => {
7
- const t = q(void 0);
8
- return t.current || (t.current = e()), I(() => {
9
- process.env.NODE_ENV;
10
- }, []), t;
11
- }, N = (e) => K(e).current, G = (e) => {
12
- const t = N(() => new E(e));
13
- return I(() => {
14
- t.next(e);
15
- }, [e, t]), t;
16
- }, v = (e) => {
17
- const t = q(e);
18
- return Z(() => {
19
- t.current = e;
20
- }, [e]), t;
21
- }, ct = (e) => {
22
- const t = N(() => new E(e)), r = v(t), n = S(
23
- (u) => {
24
- t.next(u);
25
- },
26
- [t]
27
- );
28
- return [r.current, n, t.getValue()];
29
- };
30
- function ke(e, t) {
31
- return t.reduce(
32
- (r, n) => n in e ? { ...r, [n]: e[n] } : r,
33
- {}
34
- );
35
- }
36
- function W(e) {
37
- return e instanceof Promise || e && typeof e == "object" && "then" in e && typeof e.then == "function" && "catch" in e && e.catch === "function";
38
- }
39
- function j(e) {
40
- if (J(e)) return () => e;
41
- if (W(e)) return () => x(e);
42
- if (typeof e != "function") return () => b(e);
43
- const t = e;
44
- return (r) => D(() => {
45
- const n = t(r);
46
- return W(n) ? x(n) : J(n) ? n : b(n);
1
+ import { c as E } from "react/compiler-runtime";
2
+ import { useRef as R, useEffect as N, useMemo as ie, useState as G, useSyncExternalStore as Ve, useCallback as ee, createContext as ue, memo as ae, useContext as le } from "react";
3
+ import { BehaviorSubject as V, of as w, defer as W, merge as A, throwError as j, timer as Re, ReplaySubject as te, NEVER as qe, distinctUntilChanged as fe, tap as X, share as Z, isObservable as re, from as T, catchError as D, EMPTY as ye, retry as Fe, identity as Pe, takeUntil as Ae, fromEvent as de, take as pe, filter as Te, first as me, switchMap as O, noop as be, delay as Oe, ignoreElements as Qe, defaultIfEmpty as ke, zip as De, throttleTime as He, asyncScheduler as Ke, map as Y, concatMap as je, scan as Le } from "rxjs";
4
+ import { catchError as ne, mergeMap as L, retryWhen as ze, concatMap as Ye, first as Je, tap as Ue } from "rxjs/operators";
5
+ import { jsx as he } from "react/jsx-runtime";
6
+ import { hashKey as ve, useMutation as Ge, useQueryClient as ge, useQuery as We } from "@tanstack/react-query";
7
+ const se = /* @__PURE__ */ Symbol("UNSET"), H = (r) => {
8
+ const t = R(se);
9
+ return t.current === se && (t.current = r()), t;
10
+ }, K = (r) => H(r).current, oe = (r) => {
11
+ const t = E(6);
12
+ let e;
13
+ t[0] !== r ? (e = () => new V(r), t[0] = r, t[1] = e) : e = t[1];
14
+ const n = K(e);
15
+ let s, o;
16
+ return t[2] !== r || t[3] !== n ? (s = () => {
17
+ n.next(r);
18
+ }, o = [r, n], t[2] = r, t[3] = n, t[4] = s, t[5] = o) : (s = t[4], o = t[5]), N(s, o), n;
19
+ }, q = (r) => {
20
+ const t = R(r);
21
+ return ie(() => {
22
+ t.current = r;
23
+ }, [r]), t;
24
+ }, Rt = (r) => {
25
+ const t = E(10);
26
+ let e;
27
+ t[0] !== r ? (e = () => new V(r), t[0] = r, t[1] = e) : e = t[1];
28
+ const n = K(e), s = q(n);
29
+ let o;
30
+ t[2] !== n ? (o = (p) => {
31
+ n.next(p);
32
+ }, t[2] = n, t[3] = o) : o = t[3];
33
+ const c = o, u = s.current;
34
+ let i;
35
+ t[4] !== n ? (i = n.getValue(), t[4] = n, t[5] = i) : i = t[5];
36
+ let a;
37
+ return t[6] !== c || t[7] !== s.current || t[8] !== i ? (a = [u, c, i], t[6] = c, t[7] = s.current, t[8] = i, t[9] = a) : a = t[9], a;
38
+ }, Xe = (r, t) => r.length === t.length && r.every((e, n) => e === t[n]);
39
+ function qt(r) {
40
+ return r != null;
41
+ }
42
+ function ce(r) {
43
+ return r instanceof Promise || r && typeof r == "object" && "then" in r && typeof r.then == "function" && "catch" in r && r.catch === "function";
44
+ }
45
+ const Ft = typeof window > "u" || "Deno" in window;
46
+ function Ze(r, t) {
47
+ return Math.min(r, t);
48
+ }
49
+ function Be(r, t) {
50
+ return 2 ** r * t;
51
+ }
52
+ function Pt(r) {
53
+ const {
54
+ retry: t,
55
+ retryDelay: e,
56
+ retryAfterDelay: n,
57
+ retryAfter: s = () => w(!0)
58
+ } = r, o = typeof t != "function" ? t === !1 ? 0 : t === !0 ? Number.POSITIVE_INFINITY : t ?? Number.POSITIVE_INFINITY : Number.POSITIVE_INFINITY, c = typeof t == "function" ? (
59
+ // ? (attempt: number, error: TError) => of(retry(attempt, error))
60
+ t
61
+ ) : () => !0, u = typeof e == "number" ? e : 100, i = {
62
+ ...r
63
+ }, {
64
+ maxInterval: a = Number.POSITIVE_INFINITY,
65
+ resetOnSuccess: p = !1,
66
+ backoffDelay: l = Be
67
+ } = i;
68
+ return (y) => W(() => {
69
+ let m = 0;
70
+ const v = (d, b) => d < o ? c(d, b) : !1;
71
+ return y.pipe(ne((d) => {
72
+ if (m++, !v(m - 1, d)) throw d;
73
+ const b = r.caughtError?.(m, d);
74
+ if (!b) throw d;
75
+ return b.pipe(L((f) => A(w(f), j(() => d))));
76
+ }), ze((d) => d.pipe(Ye((b) => {
77
+ const f = m - 1;
78
+ return s().pipe(Je(), L(() => v(f, b) ? Re(Ze(l(f, u), a)).pipe(L((h) => n && !n(f, b) ? j(() => b) : w(h))) : j(() => b)));
79
+ }))), ne((d) => {
80
+ if (r.catchError)
81
+ return r.catchError(m, d);
82
+ throw d;
83
+ }), Ue(() => {
84
+ p && (m = 0);
85
+ }));
47
86
  });
48
87
  }
49
- function fe(e, t) {
50
- if (e == null || t === void 0 || typeof e != "object" || typeof t != "object")
51
- return e === t;
52
- if (e.constructor !== t?.constructor)
53
- return !1;
54
- const r = Object.keys(e), n = Object.keys(t);
55
- if (r.length !== n.length)
56
- return !1;
57
- for (const u of r)
58
- if (!t.hasOwnProperty(u) || e[u] !== t[u])
59
- return !1;
60
- return !0;
88
+ const At = () => {
89
+ const r = H(() => new te(1)), [t, e] = G(!1);
90
+ return t && (r.current = new te(1), e(!1)), N(() => () => {
91
+ r.current.next(void 0), e(!0);
92
+ }, [r]), r.current;
93
+ }, Se = (r) => {
94
+ const t = E(1);
95
+ let e;
96
+ t[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (e = [], t[0] = e) : e = t[0], N(r, e);
97
+ }, et = (r) => {
98
+ const t = R(r);
99
+ t.current = r, Se(() => () => t.current());
100
+ }, Tt = (r, t, e) => {
101
+ const n = E(7);
102
+ let s;
103
+ n[0] !== e ? (s = e === void 0 ? {} : e, n[0] = e, n[1] = s) : s = n[1];
104
+ const o = s, {
105
+ cancelOnUnmount: c
106
+ } = o, u = c === void 0 ? !1 : c, i = R(null);
107
+ let a;
108
+ n[2] !== r || n[3] !== t ? (a = (y) => {
109
+ i.current !== null && clearTimeout(i.current), i.current = setTimeout(() => r(y), t);
110
+ }, n[2] = r, n[3] = t, n[4] = a) : a = n[4];
111
+ const p = a;
112
+ let l;
113
+ return n[5] !== u ? (l = () => {
114
+ u && i.current && clearTimeout(i.current);
115
+ }, n[5] = u, n[6] = l) : l = n[6], et(l), p;
116
+ }, Ot = (r, t) => {
117
+ const e = R({
118
+ value: r
119
+ });
120
+ return ie(() => t(r, e.current.value) ? e.current.value : (e.current = {
121
+ value: r
122
+ }, r), [r, t]);
123
+ }, Qt = (r) => {
124
+ const t = E(2);
125
+ let e;
126
+ t[0] !== r ? (e = () => {
127
+ r();
128
+ }, t[0] = r, t[1] = e) : e = t[1], Se(e);
129
+ };
130
+ class tt {
131
+ state;
132
+ source$;
133
+ sub;
134
+ constructor({
135
+ source$: t,
136
+ defaultValue: e,
137
+ compareFn: n
138
+ }) {
139
+ const s = typeof t == "function" ? t() : t, o = s === void 0;
140
+ this.state = {
141
+ data: s instanceof V ? s.value : e,
142
+ status: o ? "success" : "pending",
143
+ observableState: o ? "complete" : "live",
144
+ error: void 0
145
+ }, this.source$ = (s ?? qe).pipe(fe(n), X({
146
+ complete: () => {
147
+ this.state = {
148
+ ...this.state,
149
+ status: "success",
150
+ observableState: "complete"
151
+ };
152
+ },
153
+ error: (c) => {
154
+ this.state = {
155
+ ...this.state,
156
+ observableState: "error",
157
+ status: "error",
158
+ error: c
159
+ };
160
+ },
161
+ next: (c) => {
162
+ this.state = {
163
+ ...this.state,
164
+ data: c
165
+ };
166
+ }
167
+ }), Z()), this.sub = this.source$.subscribe();
168
+ }
169
+ subscribe = (t) => {
170
+ if (this.state.observableState === "complete")
171
+ return () => {
172
+ };
173
+ const e = this.source$.subscribe({
174
+ complete: t,
175
+ error: t,
176
+ next: t
177
+ });
178
+ return () => {
179
+ e.unsubscribe();
180
+ };
181
+ };
182
+ getSnapshot = () => this.state;
61
183
  }
62
- function ye(e, t, r) {
63
- const n = t != null && !Array.isArray(t) ? t : {
184
+ const rt = (r, t, e) => {
185
+ const n = q(t), s = R(void 0);
186
+ (!s.current || !Xe([...e], [...s.current.deps])) && (s.current = {
187
+ deps: e,
188
+ store: new tt({
189
+ source$: r,
190
+ defaultValue: n.current.defaultValue,
191
+ compareFn: (c, u) => n.current?.compareFn?.(c, u) ?? c === u
192
+ })
193
+ });
194
+ const o = s.current.store;
195
+ return N(() => () => {
196
+ o.sub.unsubscribe();
197
+ }, [o]), o;
198
+ };
199
+ function Ee(r, t, e) {
200
+ const n = E(6);
201
+ let s;
202
+ n[0] !== t ? (s = t != null && !Array.isArray(t) ? t : {
64
203
  defaultValue: void 0,
65
- unsubscribeOnUnmount: !0,
66
204
  compareFn: void 0
67
- }, u = !r && Array.isArray(t) ? t : typeof e == "function" ? r ?? [] : [e], c = q(void 0), o = v(e), l = v(n), s = typeof e != "function" && Array.isArray(t) ? JSON.stringify(t) : void 0, i = v(
68
- typeof e != "function" && Array.isArray(t) ? t : void 0
69
- ), a = Z(() => {
70
- const p = i.current, f = l.current.compareFn, m = f || (p ? fe : void 0);
71
- return {
72
- observable: j(o.current)().pipe(
73
- // Maybe selector
74
- $((h) => p && typeof h == "object" && h !== null ? ke(h, p) : h),
75
- // Maybe compareFn
76
- re((h, R) => h === void 0 || R === void 0 ? !1 : m ? m(h, R) : h === R),
77
- ve({ refCount: !0, bufferSize: 1 })
78
- ),
79
- subscribed: !1,
80
- snapshotSub: void 0
81
- };
82
- }, [...u, s, i, o, l]), y = S(() => {
83
- if (!a.subscribed) {
84
- a.subscribed = !0;
85
- const p = a.observable.subscribe((f) => {
86
- c.current = { value: f };
87
- });
88
- a.snapshotSub = p;
89
- }
90
- return c.current === void 0 ? l.current.defaultValue : c.current?.value;
91
- }, [a, l]), d = S(
92
- (p) => {
93
- a.subscribed = !0;
94
- const f = a.observable.pipe(
95
- l.current.defaultValue ? Ie(l.current.defaultValue) : ne,
96
- k((m) => {
97
- c.current = { value: m };
98
- }),
99
- F((m) => (console.error(m), H))
100
- ).subscribe(p);
101
- return a.snapshotSub?.unsubscribe(), () => {
102
- l.current.unsubscribeOnUnmount !== !1 && f.unsubscribe();
103
- };
104
- },
105
- [a]
106
- );
107
- return Se(d, y, y);
108
- }
109
- function He(e, t = []) {
110
- const r = v(e);
111
- I(() => {
112
- const n = j(r.current)().pipe(
113
- F((u) => (console.error(u), H))
114
- ).subscribe();
205
+ }, n[0] = t, n[1] = s) : s = n[1];
206
+ const o = s;
207
+ let c;
208
+ n[2] !== e || n[3] !== t || n[4] !== r ? (c = !e && Array.isArray(t) ? t : typeof r == "function" ? e ?? [] : [r], n[2] = e, n[3] = t, n[4] = r, n[5] = c) : c = n[5];
209
+ const i = rt(r, o, c);
210
+ return Ve(i.subscribe, i.getSnapshot, i.getSnapshot);
211
+ }
212
+ function Ie(r) {
213
+ if (re(r)) return () => r;
214
+ if (ce(r)) return () => T(r);
215
+ if (typeof r != "function") return () => w(r);
216
+ const t = r;
217
+ return (e) => W(() => {
218
+ const n = t(e);
219
+ return ce(n) ? T(n) : re(n) ? n : w(n);
220
+ });
221
+ }
222
+ function nt(r, t) {
223
+ const e = E(7);
224
+ let n;
225
+ e[0] !== t ? (n = t === void 0 ? [] : t, e[0] = t, e[1] = n) : n = e[1];
226
+ const s = n, o = q(r);
227
+ let c;
228
+ e[2] !== o ? (c = () => {
229
+ const i = Ie(o.current)().pipe(D(st)).subscribe();
115
230
  return () => {
116
- n.unsubscribe();
231
+ i.unsubscribe();
117
232
  };
118
- }, [...t, r]);
233
+ }, e[2] = o, e[3] = c) : c = e[3];
234
+ let u;
235
+ e[4] !== s || e[5] !== o ? (u = [...s, o], e[4] = s, e[5] = o, e[6] = u) : u = e[6], N(c, u);
119
236
  }
120
- function at(e, t, r = []) {
121
- const n = t != null && !Array.isArray(t) ? t : {}, u = n.retry ?? !0, c = v(
122
- n.onError ?? ((s) => {
123
- console.error(s);
124
- })
125
- ), o = S(() => j(e)(), r), l = S(
126
- () => o().pipe(
127
- F((s) => {
128
- throw c.current(s), s;
129
- }),
130
- u ? we() : ne
131
- ),
132
- [o, u, c]
133
- );
134
- He(l, r);
135
- }
136
- class Ke {
237
+ function st(r) {
238
+ return console.error(r), ye;
239
+ }
240
+ function kt(r, t, e = []) {
241
+ const n = t != null && !Array.isArray(t) ? t : {}, s = n.retry ?? !0, o = q(n.onError ?? ((i) => {
242
+ console.error(i);
243
+ })), c = ee(() => Ie(r)(), e), u = ee(() => c().pipe(D((i) => {
244
+ throw o.current(i), i;
245
+ }), s ? Fe() : Pe), [c, s, o]);
246
+ nt(u, e);
247
+ }
248
+ class ot {
137
249
  queryMap = /* @__PURE__ */ new Map();
138
250
  getQuery(t) {
139
251
  return this.queryMap.get(t);
140
252
  }
141
- setQuery(t, r, n) {
142
- const u = ie(t), c = r.pipe(
253
+ setQuery(t, e, n) {
254
+ const s = ve(t), o = e.pipe(
143
255
  /**
144
256
  * abort signal is triggered on:
145
257
  * - manual cancellation from user
146
258
  * - unmounting the component
147
259
  * @see https://tanstack.com/query/latest/docs/framework/react/guides/query-cancellation
148
260
  */
149
- Ee(se(n, "abort")),
150
- ue()
151
- ), o = {
152
- query$: c,
261
+ Ae(de(n, "abort")),
262
+ Z()
263
+ ), c = {
264
+ query$: o,
153
265
  signal: n,
154
266
  sub: void 0,
155
267
  isCompleted: !1,
156
268
  lastData: void 0
157
269
  };
158
- this.queryMap.set(u, o);
159
- const l = c.subscribe({
160
- next: (s) => {
161
- const i = this.queryMap.get(u);
162
- i && (i.lastData = { value: s });
270
+ this.queryMap.set(s, c);
271
+ const u = o.subscribe({
272
+ next: (i) => {
273
+ const a = this.queryMap.get(s);
274
+ a && (a.lastData = {
275
+ value: i
276
+ });
163
277
  },
164
278
  complete: () => {
165
- this.deleteQuery(u);
279
+ this.deleteQuery(s);
166
280
  }
167
281
  });
168
- return o.sub = l, o;
282
+ return c.sub = u, c;
169
283
  }
170
284
  deleteQuery(t) {
171
- const r = this.queryMap.get(t);
172
- r && (r.sub && (r.sub.unsubscribe(), r.sub = void 0), r.isCompleted = !0, this.queryMap.delete(t));
285
+ const e = this.queryMap.get(t);
286
+ e && (e.sub && (e.sub.unsubscribe(), e.sub = void 0), e.isCompleted = !0, this.queryMap.delete(t));
173
287
  }
174
288
  destroy() {
175
- this.queryMap.forEach((t, r) => {
176
- this.deleteQuery(r);
289
+ this.queryMap.forEach((t, e) => {
290
+ this.deleteQuery(e);
177
291
  });
178
292
  }
179
293
  }
180
- const de = B(void 0), it = ee(
181
- ({
294
+ const we = ue(void 0), Dt = ae((r) => {
295
+ const t = E(8), {
182
296
  children: e,
183
- client: t
184
- }) => {
185
- const [r] = _(() => t ?? new Ke());
186
- return I(() => () => {
187
- r.destroy();
188
- }, [r]), /* @__PURE__ */ ae(de.Provider, { value: r, children: e });
189
- }
190
- ), je = () => {
191
- const e = te(de);
192
- if (!e)
193
- throw new Error(
194
- "useReactJrxQueryClient must be used within a ReactJrxQueryProvider"
195
- );
196
- return e;
297
+ client: n
298
+ } = r;
299
+ let s;
300
+ t[0] !== n ? (s = () => n ?? new ot(), t[0] = n, t[1] = s) : s = t[1];
301
+ const [o] = G(s);
302
+ let c, u;
303
+ t[2] !== o ? (c = () => () => {
304
+ o.destroy();
305
+ }, u = [o], t[2] = o, t[3] = c, t[4] = u) : (c = t[3], u = t[4]), N(c, u);
306
+ let i;
307
+ return t[5] !== e || t[6] !== o ? (i = /* @__PURE__ */ he(we.Provider, { value: o, children: e }), t[5] = e, t[6] = o, t[7] = i) : i = t[7], i;
308
+ }), ct = () => {
309
+ const r = le(we);
310
+ if (!r)
311
+ throw new Error("useReactJrxQueryClient must be used within a ReactJrxQueryProvider");
312
+ return r;
197
313
  };
198
- function me(e, t) {
199
- const r = N(
200
- () => new E({
201
- status: "idle",
202
- isPending: !1,
203
- isError: !1,
204
- isSuccess: !1,
205
- isIdle: !0
206
- })
207
- ), n = Pe(
208
- {
209
- ...e,
210
- mutationFn: (i) => {
211
- let a;
212
- return new Promise((y, d) => {
213
- (typeof e.mutationFn == "function" ? e.mutationFn(i) : e.mutationFn).pipe(oe(1)).subscribe({
214
- next: (p) => {
215
- a = { value: p };
216
- },
217
- error: (p) => {
218
- d(p);
219
- },
220
- complete: () => {
221
- if (a === void 0)
222
- return d(new Error("Stream completed without any data"));
223
- y(a.value);
224
- }
225
- });
226
- });
227
- }
228
- },
229
- t
230
- ), { status: u, isPending: c, isError: o, isSuccess: l, isIdle: s } = n;
231
- return I(() => {
232
- r.next({
314
+ function $e(r, t) {
315
+ const e = E(16), n = K(it);
316
+ let s;
317
+ e[0] !== r ? (s = (d) => {
318
+ let b;
319
+ return new Promise((f, h) => {
320
+ (typeof r.mutationFn == "function" ? r.mutationFn(d) : r.mutationFn).pipe(pe(1)).subscribe({
321
+ next: (S) => {
322
+ b = {
323
+ value: S
324
+ };
325
+ },
326
+ error: (S) => {
327
+ h(S);
328
+ },
329
+ complete: () => {
330
+ if (b === void 0)
331
+ return h(new Error("Stream completed without any data"));
332
+ f(b.value);
333
+ }
334
+ });
335
+ });
336
+ }, e[0] = r, e[1] = s) : s = e[1];
337
+ let o;
338
+ e[2] !== r || e[3] !== s ? (o = {
339
+ ...r,
340
+ mutationFn: s
341
+ }, e[2] = r, e[3] = s, e[4] = o) : o = e[4];
342
+ const c = Ge(o, t), {
343
+ status: u,
344
+ isPending: i,
345
+ isError: a,
346
+ isSuccess: p,
347
+ isIdle: l
348
+ } = c;
349
+ let y, m;
350
+ e[5] !== a || e[6] !== l || e[7] !== i || e[8] !== p || e[9] !== n || e[10] !== u ? (y = () => {
351
+ n.next({
233
352
  status: u,
234
- isPending: c,
235
- isError: o,
236
- isSuccess: l,
237
- isIdle: s
353
+ isPending: i,
354
+ isError: a,
355
+ isSuccess: p,
356
+ isIdle: l
238
357
  });
239
- }, [u, c, o, l, s, r]), { ...n, state$: r };
240
- }
241
- function lt(e, t) {
242
- const r = le(t), n = e.mutationKey, { mutateAsync: u, ...c } = me(
243
- {
244
- ...e,
245
- onMutate({ variables: s }, ...i) {
246
- return e.onMutate?.(s, ...i);
247
- },
248
- onSuccess(s, { variables: i }, ...a) {
249
- return e.onSuccess?.(s, i, ...a);
358
+ }, m = [u, i, a, p, l, n], e[5] = a, e[6] = l, e[7] = i, e[8] = p, e[9] = n, e[10] = u, e[11] = y, e[12] = m) : (y = e[11], m = e[12]), N(y, m);
359
+ let v;
360
+ return e[13] !== c || e[14] !== n ? (v = {
361
+ ...c,
362
+ state$: n
363
+ }, e[13] = c, e[14] = n, e[15] = v) : v = e[15], v;
364
+ }
365
+ function it() {
366
+ return new V({
367
+ status: "idle",
368
+ isPending: !1,
369
+ isError: !1,
370
+ isSuccess: !1,
371
+ isIdle: !0
372
+ });
373
+ }
374
+ function Ht(r, t) {
375
+ const e = E(23);
376
+ let n, s;
377
+ e[0] !== r ? ({
378
+ onMutate: n,
379
+ ...s
380
+ } = r, e[0] = r, e[1] = n, e[2] = s) : (n = e[1], s = e[2]);
381
+ const o = ge(t), c = s.mutationKey;
382
+ let u;
383
+ e[3] !== n ? (u = n ? (f, ...h) => {
384
+ const {
385
+ variables: g
386
+ } = f;
387
+ return n(g, ...h);
388
+ } : void 0, e[3] = n, e[4] = u) : u = e[4];
389
+ let i;
390
+ if (e[5] !== s || e[6] !== u) {
391
+ let f;
392
+ e[8] !== s ? (f = (h) => {
393
+ const {
394
+ ready$: g,
395
+ variables: S
396
+ } = h, $ = typeof s.mutationFn == "function" ? s.mutationFn(S) : s.mutationFn;
397
+ return g.pipe(Te(at), me(), O(() => $));
398
+ }, e[8] = s, e[9] = f) : f = e[9], i = {
399
+ ...s,
400
+ onMutate: u,
401
+ onSuccess(h, g, ...S) {
402
+ const {
403
+ variables: $
404
+ } = g, _ = S;
405
+ return s.onSuccess?.(h, $, ..._);
250
406
  },
251
- onError(s, { variables: i }, ...a) {
252
- return e.onError?.(s, i, ...a);
407
+ onError(h, g, ...S) {
408
+ const {
409
+ variables: $
410
+ } = g, _ = S;
411
+ return s.onError?.(h, $, ..._);
253
412
  },
254
- onSettled(s, i, { variables: a }, ...y) {
255
- return e.onSettled?.(s, i, a, ...y);
413
+ onSettled(h, g, S, ...$) {
414
+ const {
415
+ variables: _
416
+ } = S, F = $;
417
+ return s.onSettled?.(h, g, _, ...F);
256
418
  },
257
- mutationFn: ({ ready$: s, variables: i }) => {
258
- const a = typeof e.mutationFn == "function" ? e.mutationFn(i) : e.mutationFn;
259
- return s.pipe(
260
- Ce((y) => y),
261
- ce(),
262
- M(() => a)
263
- );
264
- }
265
- },
266
- t
267
- ), o = S(
268
- async (s) => {
269
- const i = r.getMutationCache().findAll({
270
- mutationKey: n,
271
- exact: !0
272
- }), a = new E(!1), y = u({ variables: s, ready$: a });
273
- return await Promise.all(
274
- i.map((d) => d.continue().catch(L))
275
- ), a.next(!0), await y.finally(() => {
276
- a.complete();
277
- });
278
- },
279
- [u, r, n]
280
- ), l = S(
281
- (s) => {
282
- o(s).catch(L);
283
- },
284
- [o]
285
- );
286
- return { ...c, mutate: l, mutateAsync: o };
287
- }
288
- function ft(e, t) {
289
- const r = le(t), n = je();
290
- return Oe(
291
- {
292
- ...e,
293
- queryFn: (o) => new Promise((l, s) => {
294
- const i = () => D(
295
- () => typeof e.queryFn == "function" ? e.queryFn(o) : e.queryFn
296
- ), a = ie(o.queryKey), y = n.getQuery(a), d = y ?? n.setQuery(o.queryKey, i(), o.signal), g = () => {
297
- d?.isCompleted === !1 && setTimeout(() => {
298
- r?.refetchQueries({
299
- queryKey: o.queryKey,
300
- exact: !0
301
- });
302
- });
303
- };
304
- if (!y && d.lastData !== void 0) {
305
- l(d.lastData.value), g();
306
- return;
307
- }
308
- d.query$.pipe(
309
- oe(1),
310
- /**
311
- * If several values are emitted during this delay, we will only
312
- * keep the last value. This is unfortunate but it's the best we can do
313
- * for now.
314
- */
315
- xe(1)
316
- ).subscribe({
317
- error: (f) => s(f),
318
- complete: () => {
319
- if (d?.lastData === void 0)
320
- return d.signal.aborted || (console.log(
321
- `cancelled due to stream completing without data for query ${a}`,
322
- d?.lastData
323
- ), r.cancelQueries({
324
- queryKey: o.queryKey,
325
- exact: !0
326
- })), l(void 0);
327
- l(d.lastData.value), g();
328
- }
419
+ mutationFn: f
420
+ }, e[5] = s, e[6] = u, e[7] = i;
421
+ } else
422
+ i = e[7];
423
+ const a = $e(i, t);
424
+ let p, l;
425
+ e[10] !== a ? ({
426
+ mutateAsync: p,
427
+ ...l
428
+ } = a, e[10] = a, e[11] = p, e[12] = l) : (p = e[11], l = e[12]);
429
+ let y;
430
+ e[13] !== o || e[14] !== p || e[15] !== c ? (y = async (f) => {
431
+ const h = o.getMutationCache().findAll({
432
+ mutationKey: c,
433
+ exact: !0
434
+ }), g = new V(!1), S = p({
435
+ variables: f,
436
+ ready$: g
437
+ });
438
+ return await Promise.all(h.map(ut)), g.next(!0), await S.finally(() => {
439
+ g.complete();
440
+ });
441
+ }, e[13] = o, e[14] = p, e[15] = c, e[16] = y) : y = e[16];
442
+ const m = y;
443
+ let v;
444
+ e[17] !== m ? (v = (f) => {
445
+ m(f).catch(be);
446
+ }, e[17] = m, e[18] = v) : v = e[18];
447
+ const d = v;
448
+ let b;
449
+ return e[19] !== m || e[20] !== d || e[21] !== l ? (b = {
450
+ ...l,
451
+ mutate: d,
452
+ mutateAsync: m
453
+ }, e[19] = m, e[20] = d, e[21] = l, e[22] = b) : b = e[22], b;
454
+ }
455
+ function ut(r) {
456
+ return r.continue().catch(be);
457
+ }
458
+ function at(r) {
459
+ return r;
460
+ }
461
+ function Kt(r, t) {
462
+ const e = E(10);
463
+ let n, s;
464
+ e[0] !== r ? ({
465
+ queryFn: s,
466
+ ...n
467
+ } = r, e[0] = r, e[1] = n, e[2] = s) : (n = e[1], s = e[2]);
468
+ const o = ge(t), c = ct();
469
+ let u;
470
+ e[3] !== o || e[4] !== c || e[5] !== s ? (u = (l) => new Promise((y, m) => {
471
+ const v = () => W(() => typeof s == "function" ? s(l) : s), d = ve(l.queryKey), b = c.getQuery(d), f = b ?? c.setQuery(l.queryKey, v(), l.signal), h = () => {
472
+ f?.isCompleted === !1 && setTimeout(() => {
473
+ o?.refetchQueries({
474
+ queryKey: l.queryKey,
475
+ exact: !0
329
476
  });
330
- })
331
- },
332
- t
333
- );
477
+ });
478
+ };
479
+ if (!b && f.lastData !== void 0) {
480
+ y(f.lastData.value), h();
481
+ return;
482
+ }
483
+ f.query$.pipe(pe(1), Oe(1)).subscribe({
484
+ error: (S) => m(S),
485
+ complete: () => {
486
+ if (f?.lastData === void 0)
487
+ return f.signal.aborted || (console.log(`cancelled due to stream completing without data for query ${d}`, f?.lastData), o.cancelQueries({
488
+ queryKey: l.queryKey,
489
+ exact: !0
490
+ })), y(void 0);
491
+ y(f.lastData.value), h();
492
+ }
493
+ });
494
+ }), e[3] = o, e[4] = c, e[5] = s, e[6] = u) : u = e[6];
495
+ const i = u;
496
+ let a;
497
+ return e[7] !== n || e[8] !== i ? (a = {
498
+ ...n,
499
+ queryFn: i
500
+ }, e[7] = n, e[8] = i, e[9] = a) : a = e[9], We(a, t);
334
501
  }
335
- class X extends Error {
502
+ class _e extends Error {
336
503
  constructor(t = "Mutation canceled") {
337
504
  super(t), this.name = "SwitchMutationCancelError";
338
505
  }
339
506
  }
340
- function yt(e, t) {
341
- const r = q(new AbortController()), { mutate: n, mutateAsync: u, ...c } = me(
342
- {
343
- ...e,
344
- mutationFn: ({ variables: s, abort: i }) => {
345
- if (i.aborted)
346
- throw new X();
347
- const a = typeof e.mutationFn == "function" ? e.mutationFn(s) : e.mutationFn;
348
- return V(
349
- a,
350
- se(i, "abort").pipe(
351
- k(() => {
352
- throw new X();
353
- }),
354
- Me()
355
- )
356
- ).pipe(ce(), Ve(null));
357
- },
358
- onMutate: ({ variables: s }, ...i) => e.onMutate?.(s, ...i),
359
- onSuccess: (s, { variables: i }, ...a) => e.onSuccess?.(s, i, ...a),
360
- onError: (s, { variables: i }, ...a) => e.onError?.(s, i, ...a),
361
- onSettled: (s, i, { variables: a }, ...y) => e.onSettled?.(s, i, a, ...y)
362
- },
363
- t
364
- ), o = S(
365
- (s) => (r.current.abort(), r.current = new AbortController(), n({
366
- variables: s,
367
- abort: r.current.signal
368
- })),
369
- [n]
370
- ), l = S(
371
- (s) => (r.current.abort(), r.current = new AbortController(), u({
372
- variables: s,
373
- abort: r.current.signal
374
- })),
375
- [u]
376
- );
377
- return { ...c, mutate: o, mutateAsync: l };
378
- }
379
- const ze = Symbol("SIGNAL_RESET"), dt = (e) => ({
507
+ function jt(r, t) {
508
+ const e = E(37);
509
+ let n, s, o, c, u;
510
+ e[0] !== r ? ({
511
+ mutationFn: n,
512
+ onMutate: o,
513
+ onError: s,
514
+ onSettled: c,
515
+ ...u
516
+ } = r, e[0] = r, e[1] = n, e[2] = s, e[3] = o, e[4] = c, e[5] = u) : (n = e[1], s = e[2], o = e[3], c = e[4], u = e[5]);
517
+ const i = H(ft);
518
+ let a;
519
+ e[6] !== n ? (a = (I) => {
520
+ const {
521
+ variables: M,
522
+ abort: C
523
+ } = I;
524
+ if (C.aborted)
525
+ throw new _e();
526
+ const x = typeof n == "function" ? n(M) : n;
527
+ return A(x, de(C, "abort").pipe(X(lt), Qe())).pipe(me(), ke(null));
528
+ }, e[6] = n, e[7] = a) : a = e[7];
529
+ const p = a;
530
+ let l;
531
+ e[8] !== o ? (l = o ? (I, ...M) => {
532
+ const {
533
+ variables: C
534
+ } = I;
535
+ return o(C, ...M);
536
+ } : void 0, e[8] = o, e[9] = l) : l = e[9];
537
+ let y;
538
+ e[10] !== u ? (y = (I, M, ...C) => {
539
+ const {
540
+ variables: x
541
+ } = M, k = C;
542
+ return u.onSuccess?.(I, x, ...k);
543
+ }, e[10] = u, e[11] = y) : y = e[11];
544
+ let m;
545
+ e[12] !== s ? (m = (I, M, ...C) => {
546
+ const {
547
+ variables: x
548
+ } = M;
549
+ return s?.(I, x, ...C);
550
+ }, e[12] = s, e[13] = m) : m = e[13];
551
+ let v;
552
+ e[14] !== c ? (v = (I, M, C, ...x) => {
553
+ const {
554
+ variables: k
555
+ } = C;
556
+ return c?.(I, M, k, ...x);
557
+ }, e[14] = c, e[15] = v) : v = e[15];
558
+ let d;
559
+ e[16] !== u || e[17] !== p || e[18] !== l || e[19] !== y || e[20] !== m || e[21] !== v ? (d = {
560
+ ...u,
561
+ mutationFn: p,
562
+ onMutate: l,
563
+ onSuccess: y,
564
+ onError: m,
565
+ onSettled: v
566
+ }, e[16] = u, e[17] = p, e[18] = l, e[19] = y, e[20] = m, e[21] = v, e[22] = d) : d = e[22];
567
+ const b = $e(d, t);
568
+ let f, h, g;
569
+ e[23] !== b ? ({
570
+ mutate: f,
571
+ mutateAsync: h,
572
+ ...g
573
+ } = b, e[23] = b, e[24] = f, e[25] = h, e[26] = g) : (f = e[24], h = e[25], g = e[26]);
574
+ let S;
575
+ e[27] !== f || e[28] !== i ? (S = (I) => (i.current.abort(), i.current = new AbortController(), f({
576
+ variables: I,
577
+ abort: i.current.signal
578
+ })), e[27] = f, e[28] = i, e[29] = S) : S = e[29];
579
+ const $ = S;
580
+ let _;
581
+ e[30] !== h || e[31] !== i ? (_ = (I) => (i.current.abort(), i.current = new AbortController(), h({
582
+ variables: I,
583
+ abort: i.current.signal
584
+ })), e[30] = h, e[31] = i, e[32] = _) : _ = e[32];
585
+ const F = _;
586
+ let Q;
587
+ return e[33] !== F || e[34] !== $ || e[35] !== g ? (Q = {
588
+ ...g,
589
+ mutate: $,
590
+ mutateAsync: F
591
+ }, e[33] = F, e[34] = $, e[35] = g, e[36] = Q) : Q = e[36], Q;
592
+ }
593
+ function lt() {
594
+ throw new _e();
595
+ }
596
+ function ft() {
597
+ return new AbortController();
598
+ }
599
+ const yt = /* @__PURE__ */ Symbol("SIGNAL_RESET"), Lt = (r) => ({
380
600
  getItem: async (t) => {
381
- const r = await e.getItem(t);
382
- if (r)
383
- return JSON.parse(r);
601
+ const e = await r.getItem(t);
602
+ if (e)
603
+ return JSON.parse(e);
384
604
  },
385
- setItem: async (t, r) => {
386
- await e.setItem(t, JSON.stringify(r));
605
+ setItem: async (t, e) => {
606
+ await r.setItem(t, JSON.stringify(e));
387
607
  },
388
608
  removeItem: async (t) => {
389
609
  },
390
610
  clear: async () => {
391
611
  }
392
- }), O = (e) => {
393
- if (!(!e || typeof e != "object"))
394
- return e;
395
- }, Je = ({
396
- adapter: e,
612
+ }), z = (r) => {
613
+ if (!(!r || typeof r != "object"))
614
+ return r;
615
+ }, dt = ({
616
+ adapter: r,
397
617
  key: t
398
618
  }) => ({
399
- clear: async () => await e.removeItem(t),
400
- removeItem: async (r) => {
401
- const n = await e.getItem(t), { [r]: u, ...c } = (
619
+ clear: async () => await r.removeItem(t),
620
+ removeItem: async (e) => {
621
+ const n = await r.getItem(t), {
622
+ [e]: s,
623
+ ...o
624
+ } = (
402
625
  // biome-ignore lint/suspicious/noExplicitAny: TODO
403
- O(n) ?? {}
626
+ z(n) ?? {}
404
627
  );
405
- await e.setItem(t, c);
628
+ await r.setItem(t, o);
406
629
  },
407
- getItem: async (r) => {
408
- const n = await e.getItem(t), u = O(n) ?? {};
409
- if (r in u)
410
- return u[r];
630
+ getItem: async (e) => {
631
+ const n = await r.getItem(t), s = z(n) ?? {};
632
+ if (e in s)
633
+ return s[e];
411
634
  },
412
- setItem: async (r, n) => {
413
- const u = await e.getItem(t), c = O(u) ?? {};
414
- await e.setItem(t, { ...c, [r]: n });
635
+ setItem: async (e, n) => {
636
+ const s = await r.getItem(t), o = z(s) ?? {};
637
+ await r.setItem(t, {
638
+ ...o,
639
+ [e]: n
640
+ });
415
641
  }
416
- }), Le = ({
417
- key: e
418
- } = {}) => e ? Je({
419
- adapter: Le(),
420
- key: e
642
+ }), pt = ({
643
+ key: r
644
+ } = {}) => r ? dt({
645
+ adapter: pt(),
646
+ key: r
421
647
  }) : {
422
648
  clear: async () => {
423
649
  localStorage.clear();
@@ -426,24 +652,24 @@ const ze = Symbol("SIGNAL_RESET"), dt = (e) => ({
426
652
  localStorage.removeItem(t);
427
653
  },
428
654
  getItem: async (t) => {
429
- const r = localStorage.getItem(t);
430
- if (r)
431
- return JSON.parse(r);
655
+ const e = localStorage.getItem(t);
656
+ if (e)
657
+ return JSON.parse(e);
432
658
  },
433
- setItem: async (t, r) => {
434
- localStorage.setItem(t, JSON.stringify(r));
659
+ setItem: async (t, e) => {
660
+ localStorage.setItem(t, JSON.stringify(e));
435
661
  }
436
662
  };
437
- class pe extends E {
663
+ class Ce extends V {
438
664
  constructor(t) {
439
665
  super(t.default), this.config = t;
440
666
  }
441
667
  update = (t) => {
442
- if (t === ze)
668
+ if (t === yt)
443
669
  super.next(this.config.default);
444
670
  else if (typeof t == "function") {
445
- const r = t;
446
- super.next(r(this.value));
671
+ const e = t;
672
+ super.next(e(this.value));
447
673
  } else
448
674
  super.next(t);
449
675
  };
@@ -461,35 +687,38 @@ class pe extends E {
461
687
  return this.config.key;
462
688
  }
463
689
  }
464
- class Q {
690
+ class J {
465
691
  constructor(t) {
466
692
  this.config = t;
467
693
  }
468
694
  }
469
- function mt(e = {}) {
470
- return new pe({
695
+ function zt(r = {}) {
696
+ return new Ce({
471
697
  key: void 0,
472
- ...e,
473
- default: e.default ?? void 0
698
+ ...r,
699
+ default: r.default ?? void 0
474
700
  });
475
701
  }
476
- function pt(e) {
477
- return new Q(e);
702
+ function Yt(r) {
703
+ return new J(r);
478
704
  }
479
- class T {
705
+ class U {
480
706
  /**
481
707
  * items only get added as they are created. The only time we should cleanup
482
708
  * are on context destroy. This is to ensure later re-use of virtual signals
483
709
  * return the same persisted state.
484
710
  */
485
711
  // biome-ignore lint/suspicious/noExplicitAny: TODO
486
- signals = new E(/* @__PURE__ */ new Map());
712
+ signals = new V(/* @__PURE__ */ new Map());
487
713
  isDestroyed = !1;
488
714
  getOrCreateSignal(t) {
489
- const r = this.signals.value.get(t);
490
- if (r)
491
- return r;
492
- const n = new pe({ ...t.config, key: void 0 });
715
+ const e = this.signals.value.get(t);
716
+ if (e)
717
+ return e;
718
+ const n = new Ce({
719
+ ...t.config,
720
+ key: void 0
721
+ });
493
722
  return this.signals.value.set(t, n), this.signals.next(this.signals.value), n;
494
723
  }
495
724
  destroy() {
@@ -498,311 +727,218 @@ class T {
498
727
  }), this.signals.value.clear(), this.signals.complete(), this.isDestroyed = !0;
499
728
  }
500
729
  }
501
- const be = B(
502
- new T()
503
- ), bt = ee(
504
- ({ children: e }) => {
505
- const t = K(
506
- () => new T()
507
- ), r = t.current, [n, u] = _(!1);
508
- n && (t.current = new T(), u(!1));
509
- const c = r;
510
- return I(() => () => {
511
- t.current?.destroy(), u(!0);
512
- }, [t]), /* @__PURE__ */ ae(be.Provider, { value: c, children: e });
513
- }
514
- ), ge = () => te(be), Ye = (e) => {
515
- const t = ge();
516
- return e ? t.getOrCreateSignal(e) : void 0;
517
- }, C = "__reactjrx", Ue = (e) => {
518
- if (typeof e == "object" && e !== null && C in e && e[C] === C)
519
- return e;
520
- }, Ge = ({
521
- adapter: e,
730
+ const Me = ue(new U()), Jt = ae(({
731
+ children: r
732
+ }) => {
733
+ const t = H(() => new U()), e = t.current, [n, s] = G(!1);
734
+ n && (t.current = new U(), s(!1));
735
+ const o = e;
736
+ return N(() => () => {
737
+ t.current?.destroy(), s(!0);
738
+ }, [t]), /* @__PURE__ */ he(Me.Provider, { value: o, children: r });
739
+ }), xe = () => le(Me), mt = (r) => {
740
+ const t = E(3), e = xe();
741
+ let n;
742
+ return t[0] !== e || t[1] !== r ? (n = r ? e.getOrCreateSignal(r) : void 0, t[0] = e, t[1] = r, t[2] = n) : n = t[2], n;
743
+ };
744
+ function bt(r, t) {
745
+ if (r == null || t === void 0 || typeof r != "object" || typeof t != "object")
746
+ return r === t;
747
+ if (r.constructor !== t?.constructor)
748
+ return !1;
749
+ const e = Object.keys(r), n = Object.keys(t);
750
+ if (e.length !== n.length)
751
+ return !1;
752
+ for (const s of e)
753
+ if (!t.hasOwnProperty(s) || r[s] !== t[s])
754
+ return !1;
755
+ return !0;
756
+ }
757
+ const P = "__reactjrx", ht = (r) => {
758
+ if (typeof r == "object" && r !== null && P in r && r[P] === P)
759
+ return r;
760
+ }, vt = ({
761
+ adapter: r,
522
762
  config: t
523
763
  }) => {
524
- const { signal: r, version: n } = t, c = {
525
- value: r.getValue(),
526
- [C]: C,
764
+ const {
765
+ signal: e,
766
+ version: n
767
+ } = t, o = {
768
+ value: e.getValue(),
769
+ [P]: P,
527
770
  migrationVersion: n
528
771
  };
529
- return process.env.NODE_ENV === "development" && console.log(
530
- "[reactjrx][state][persistance]:",
531
- "Persist value",
532
- c,
533
- `for signal ${r.config.key}`
534
- ), x(e.setItem(r.config.key, c)).pipe(
535
- F((o) => (console.error(o), b(null)))
536
- );
772
+ return process.env.NODE_ENV === "development" && console.log("[reactjrx][state][persistance]:", "Persist value", o, `for signal ${e.config.key}`), T(r.setItem(e.config.key, o)).pipe(D((c) => (console.error(c), w(null))));
537
773
  };
538
- function We({
539
- adapter: e,
774
+ function gt({
775
+ adapter: r,
540
776
  config: t
541
777
  }) {
542
- const { hydrate: r = ({ value: c }) => c, signal: n, version: u } = t;
543
- return x(e.getItem(n.config.key)).pipe(
544
- M((c) => {
545
- const o = Ue(c);
546
- if (!o) return b(c);
547
- const l = typeof o.migrationVersion != "number", s = o.migrationVersion !== void 0 && u > o.migrationVersion;
548
- if (l || s || o.value === void 0)
549
- return b(c);
550
- const i = o.value;
551
- return process.env.NODE_ENV === "development" && console.log(
552
- "[reactjrx][state][persistance]:",
553
- "Hydrate value",
554
- o,
555
- `for signal ${n.config.key}`
556
- ), n.setValue(r({ value: i, version: u })), b(c);
557
- })
558
- );
559
- }
560
- function Xe({
561
- entries: e = [],
562
- onHydrated: t,
563
- adapter: r
564
- }) {
565
- const u = (e.length === 0 ? b([]) : Fe(
566
- ...e.map(
567
- (o) => We({
568
- adapter: r,
569
- config: o
570
- })
571
- )
572
- )).pipe(
573
- k(t),
574
- F((o) => (console.error("Unable to hydrate", o), H)),
575
- ue()
576
- ), c = u.pipe(
577
- M(
578
- () => V(
579
- ...e.map(
580
- (o) => o.signal.pipe(
581
- $e(500, qe, {
582
- trailing: !0
583
- }),
584
- M(
585
- () => x(
586
- Ge({
587
- adapter: r,
588
- config: o
589
- })
590
- )
591
- )
592
- )
593
- )
594
- )
595
- )
596
- );
597
- return V(
598
- u.pipe(
599
- $(() => ({
600
- type: "hydrated"
601
- }))
602
- ),
603
- c.pipe(
604
- $(() => ({
605
- type: "persisted"
606
- }))
607
- )
608
- );
778
+ const {
779
+ hydrate: e = ({
780
+ value: o
781
+ }) => o,
782
+ signal: n,
783
+ version: s
784
+ } = t;
785
+ return T(r.getItem(n.config.key)).pipe(O((o) => {
786
+ const c = ht(o);
787
+ if (!c) return w(o);
788
+ const u = typeof c.migrationVersion != "number", i = c.migrationVersion !== void 0 && s > c.migrationVersion;
789
+ if (u || i || c.value === void 0)
790
+ return w(o);
791
+ const a = c.value;
792
+ return process.env.NODE_ENV === "development" && console.log("[reactjrx][state][persistance]:", "Hydrate value", c, `for signal ${n.config.key}`), n.setValue(e({
793
+ value: a,
794
+ version: s
795
+ })), w(o);
796
+ }));
609
797
  }
610
- function gt({
611
- entries: e = [],
798
+ function St({
799
+ entries: r = [],
612
800
  onHydrated: t,
613
- adapter: r
801
+ adapter: e
614
802
  }) {
615
- const n = v(t), u = G(r), c = G(e);
616
- return ye(
617
- () => u.pipe(
618
- M((l) => l ? V(
619
- b({ type: "reset" }),
620
- c.pipe(
621
- Ne(
622
- (s) => Xe({
623
- adapter: l,
624
- entries: s,
625
- onHydrated: () => {
626
- n.current?.();
627
- }
628
- })
629
- )
630
- )
631
- ) : b({ type: "reset" }))
632
- ).pipe(
633
- Re(
634
- (l, s) => s.type === "reset" ? { isHydrated: !1 } : s.type === "hydrated" ? { isHydrated: !0 } : l,
635
- { isHydrated: !1 }
636
- )
637
- ),
638
- { defaultValue: { isHydrated: !1 }, compareFn: fe },
639
- [u, c]
640
- );
641
- }
642
- function z(e) {
643
- const t = ge();
644
- if (e instanceof Q && !t)
645
- throw new Error(
646
- "useSignalValue must be used within a SignalContextProvider"
647
- );
648
- return Ye(
649
- e instanceof Q ? e : void 0
650
- ) ?? e;
803
+ const s = (r.length === 0 ? w([]) : De(...r.map((c) => gt({
804
+ adapter: e,
805
+ config: c
806
+ })))).pipe(X(t), D((c) => (console.error("Unable to hydrate", c), ye)), Z()), o = s.pipe(O(() => A(...r.map((c) => c.signal.pipe(He(500, Ke, {
807
+ trailing: !0
808
+ }), O(() => T(vt({
809
+ adapter: e,
810
+ config: c
811
+ }))))))));
812
+ return A(s.pipe(Y(() => ({
813
+ type: "hydrated"
814
+ }))), o.pipe(Y(() => ({
815
+ type: "persisted"
816
+ }))));
651
817
  }
652
- function Ze(e) {
653
- return z(e).update;
818
+ function Ut(r) {
819
+ const t = E(10), {
820
+ entries: e,
821
+ onHydrated: n,
822
+ adapter: s
823
+ } = r;
824
+ let o;
825
+ t[0] !== e ? (o = e === void 0 ? [] : e, t[0] = e, t[1] = o) : o = t[1];
826
+ const c = o, u = q(n), i = oe(s), a = oe(c);
827
+ let p;
828
+ t[2] !== i || t[3] !== a || t[4] !== u ? (p = () => i.pipe(O((d) => d ? A(w({
829
+ type: "reset"
830
+ }), a.pipe(je((b) => St({
831
+ adapter: d,
832
+ entries: b,
833
+ onHydrated: () => {
834
+ u.current?.();
835
+ }
836
+ })))) : w({
837
+ type: "reset"
838
+ }))).pipe(Le(Et, {
839
+ isHydrated: !1
840
+ })), t[2] = i, t[3] = a, t[4] = u, t[5] = p) : p = t[5];
841
+ let l;
842
+ t[6] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (l = {
843
+ defaultValue: {
844
+ isHydrated: !1
845
+ },
846
+ compareFn: bt
847
+ }, t[6] = l) : l = t[6];
848
+ let y;
849
+ return t[7] !== i || t[8] !== a ? (y = [i, a], t[7] = i, t[8] = a, t[9] = y) : y = t[9], Ee(p, l, y).data;
654
850
  }
655
- const ht = (e, t) => e.length === t.length && e.every((r, n) => r === t[n]);
656
- function St(e) {
657
- return e != null;
851
+ function Et(r, t) {
852
+ return t.type === "reset" ? {
853
+ isHydrated: !1
854
+ } : t.type === "hydrated" ? {
855
+ isHydrated: !0
856
+ } : r;
658
857
  }
659
- const vt = typeof window > "u" || "Deno" in window;
660
- function Be(e, t) {
661
- return Math.min(e, t);
858
+ function B(r) {
859
+ const t = xe();
860
+ if (r instanceof J && !t)
861
+ throw new Error("useSignalValue must be used within a SignalContextProvider");
862
+ return mt(r instanceof J ? r : void 0) ?? r;
662
863
  }
663
- function et(e, t) {
664
- return 2 ** e * t;
864
+ function It(r) {
865
+ return B(r).update;
665
866
  }
666
- function It(e) {
667
- const {
668
- retry: t,
669
- retryDelay: r,
670
- retryAfterDelay: n,
671
- retryAfter: u = () => b(!0)
672
- } = e, c = typeof t != "function" ? t === !1 ? 0 : t === !0 ? Number.POSITIVE_INFINITY : t ?? Number.POSITIVE_INFINITY : Number.POSITIVE_INFINITY, o = typeof t == "function" ? (
673
- // ? (attempt: number, error: TError) => of(retry(attempt, error))
674
- t
675
- ) : () => !0, l = typeof r == "number" ? r : 100, s = {
676
- ...e
677
- }, {
678
- maxInterval: i = Number.POSITIVE_INFINITY,
679
- resetOnSuccess: a = !1,
680
- backoffDelay: y = et
681
- } = s;
682
- return (d) => D(() => {
683
- let g = 0;
684
- const p = (f, m) => f < c ? o(f, m) : !1;
685
- return d.pipe(
686
- U((f) => {
687
- if (g++, !p(g - 1, f)) throw f;
688
- const m = e.caughtError?.(g, f);
689
- if (!m) throw f;
690
- return m.pipe(
691
- P(
692
- (w) => V(
693
- b(w),
694
- A(() => f)
695
- )
696
- )
697
- );
698
- }),
699
- Qe((f) => f.pipe(
700
- Te((m) => {
701
- const w = g - 1;
702
- return u().pipe(
703
- _e(),
704
- P(
705
- () => p(w, m) ? Ae(
706
- Be(
707
- y(w, l),
708
- i
709
- )
710
- ).pipe(
711
- P((h) => n && !n(w, m) ? A(() => m) : b(h))
712
- ) : A(() => m)
713
- )
714
- );
715
- })
716
- )),
717
- U((f) => {
718
- if (e.catchError)
719
- return e.catchError(g, f);
720
- throw f;
721
- }),
722
- De(() => {
723
- a && (g = 0);
724
- })
725
- );
726
- });
867
+ function Ne(r, t) {
868
+ const e = E(10), n = q(t), s = B(r);
869
+ let o;
870
+ e[0] !== s || e[1] !== n ? (o = () => {
871
+ const a = n.current ?? wt;
872
+ return s.pipe(Y(a), fe());
873
+ }, e[0] = s, e[1] = n, e[2] = o) : o = e[2];
874
+ let c;
875
+ e[3] !== s.value || e[4] !== t ? (c = t ? t?.(s.value) : s.value, e[3] = s.value, e[4] = t, e[5] = c) : c = e[5];
876
+ let u;
877
+ e[6] !== c ? (u = {
878
+ defaultValue: c
879
+ }, e[6] = c, e[7] = u) : u = e[7];
880
+ let i;
881
+ return e[8] !== s ? (i = [s], e[8] = s, e[9] = i) : i = e[9], Ee(o, u, i).data;
727
882
  }
728
- const tt = (e) => {
729
- I(e, []);
730
- }, wt = (e) => {
731
- tt(() => {
732
- e();
733
- });
734
- }, Et = () => {
735
- const e = K(() => new Y(1)), [t, r] = _(!1);
736
- return t && (e.current = new Y(1), r(!1)), I(() => () => {
737
- e.current.next(void 0), r(!0);
738
- }, [e]), e.current;
739
- };
740
- function he(e, t) {
741
- const r = v(t), n = z(e);
742
- return ye(
743
- () => {
744
- const u = r.current ?? ((o) => o);
745
- return n.pipe(
746
- $(u),
747
- re()
748
- );
749
- },
750
- {
751
- defaultValue: t ? t?.(n.value) : n.value
752
- },
753
- [n]
754
- );
883
+ function wt(r) {
884
+ return r;
755
885
  }
756
- function Ct(e) {
757
- const t = z(e), r = he(e), n = Ze(e);
758
- return [r, n, t];
886
+ function Gt(r) {
887
+ const t = E(4), e = B(r), n = Ne(r), s = It(r);
888
+ let o;
889
+ return t[0] !== e || t[1] !== s || t[2] !== n ? (o = [n, s, e], t[0] = e, t[1] = s, t[2] = n, t[3] = o) : o = t[3], o;
759
890
  }
760
- const xt = (e) => {
761
- const t = N(e);
762
- return [he(t), t];
891
+ const Wt = (r) => {
892
+ const t = E(3), e = K(r), n = Ne(e);
893
+ let s;
894
+ return t[0] !== e || t[1] !== n ? (s = [n, e], t[0] = e, t[1] = n, t[2] = s) : s = t[2], s;
763
895
  };
764
896
  export {
765
- de as Context,
766
- Ke as QueryClient$,
767
- it as QueryClientProvider$,
768
- ze as SIGNAL_RESET,
769
- pe as Signal,
770
- bt as SignalContextProvider,
771
- be as SignalReactContext,
772
- X as SwitchMutationCancelError,
773
- Q as VirtualSignal,
774
- ht as arrayEqual,
775
- Le as createLocalStorageAdapter,
776
- dt as createLocalforageAdapter,
777
- et as exponentialBackoffDelay,
778
- Be as getDelay,
779
- St as isDefined,
780
- W as isPromiseLike,
781
- vt as isServer,
782
- It as retryBackoff,
783
- mt as signal,
784
- N as useConstant,
785
- lt as useContactMutation$,
786
- tt as useEffectOnce,
787
- G as useLiveBehaviorSubject,
788
- v as useLiveRef,
789
- Ye as useMakeOrRetrieveSignal,
790
- wt as useMount,
791
- me as useMutation$,
792
- ct as useObservableState,
793
- ye as useObserve,
794
- gt as usePersistSignals,
795
- ft as useQuery$,
796
- je as useQueryClient$,
797
- Ze as useSetSignal,
798
- Ct as useSignal,
799
- ge as useSignalContext,
800
- xt as useSignalState,
801
- he as useSignalValue,
802
- He as useSubscribe,
803
- at as useSubscribeEffect,
804
- yt as useSwitchMutation$,
805
- Et as useUnmountObservable,
806
- pt as virtualSignal
897
+ we as Context,
898
+ ot as QueryClient$,
899
+ Dt as QueryClientProvider$,
900
+ yt as SIGNAL_RESET,
901
+ Ce as Signal,
902
+ Jt as SignalContextProvider,
903
+ Me as SignalReactContext,
904
+ _e as SwitchMutationCancelError,
905
+ J as VirtualSignal,
906
+ Xe as arrayEqual,
907
+ pt as createLocalStorageAdapter,
908
+ Lt as createLocalforageAdapter,
909
+ Be as exponentialBackoffDelay,
910
+ Ze as getDelay,
911
+ qt as isDefined,
912
+ ce as isPromiseLike,
913
+ Ft as isServer,
914
+ Pt as retryBackoff,
915
+ zt as signal,
916
+ K as useConstant,
917
+ Ht as useContactMutation$,
918
+ Tt as useDebounced,
919
+ Se as useEffectOnce,
920
+ oe as useLiveBehaviorSubject,
921
+ q as useLiveRef,
922
+ mt as useMakeOrRetrieveSignal,
923
+ Ot as useMemoCompare,
924
+ Qt as useMount,
925
+ $e as useMutation$,
926
+ Rt as useObservableState,
927
+ Ee as useObserve,
928
+ Ut as usePersistSignals,
929
+ Kt as useQuery$,
930
+ ct as useQueryClient$,
931
+ H as useRefOnce,
932
+ It as useSetSignal,
933
+ Gt as useSignal,
934
+ xe as useSignalContext,
935
+ Wt as useSignalState,
936
+ Ne as useSignalValue,
937
+ nt as useSubscribe,
938
+ kt as useSubscribeEffect,
939
+ jt as useSwitchMutation$,
940
+ et as useUnmount,
941
+ At as useUnmountObservable,
942
+ Yt as virtualSignal
807
943
  };
808
944
  //# sourceMappingURL=index.js.map