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