reactjrx 1.128.2 → 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,22 +64,22 @@ 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(() => {
69
+ ), a = _(() => {
70
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]), y = S(() => {
82
+ }, [...s, u, i, o, l]), y = S(() => {
83
83
  if (!a.subscribed) {
84
84
  a.subscribed = !0;
85
85
  const p = a.observable.subscribe((f) => {
@@ -92,11 +92,11 @@ function ye(e, t, r) {
92
92
  (p) => {
93
93
  a.subscribed = !0;
94
94
  const f = a.observable.pipe(
95
- l.current.defaultValue ? Ie(l.current.defaultValue) : ne,
96
- k((m) => {
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
102
  l.current.unsubscribeOnUnmount !== !1 && f.unsubscribe();
@@ -104,49 +104,55 @@ function ye(e, t, r) {
104
104
  },
105
105
  [a]
106
106
  );
107
- return Se(d, y, y);
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,15 +202,15 @@ 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) => {
@@ -227,71 +233,71 @@ function me(e, t) {
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, { variables: i }, ...a) {
249
- return e.onSuccess?.(s, i, ...a);
254
+ onSuccess(u, { variables: i }, ...a) {
255
+ return e.onSuccess?.(u, i, ...a);
250
256
  },
251
- onError(s, { variables: i }, ...a) {
252
- return e.onError?.(s, i, ...a);
257
+ onError(u, { variables: i }, ...a) {
258
+ return e.onError?.(u, i, ...a);
253
259
  },
254
- onSettled(s, i, { variables: a }, ...y) {
255
- return e.onSettled?.(s, i, a, ...y);
260
+ onSettled(u, i, { variables: a }, ...y) {
261
+ return e.onSettled?.(u, i, a, ...y);
256
262
  },
257
- mutationFn: ({ ready$: s, variables: i }) => {
263
+ mutationFn: ({ ready$: u, variables: i }) => {
258
264
  const a = typeof e.mutationFn == "function" ? e.mutationFn(i) : e.mutationFn;
259
- return s.pipe(
260
- Ce((y) => y),
265
+ return u.pipe(
266
+ xe((y) => y),
261
267
  ce(),
262
- M(() => a)
268
+ V(() => a)
263
269
  );
264
270
  }
265
271
  },
266
272
  t
267
273
  ), o = S(
268
- async (s) => {
274
+ async (u) => {
269
275
  const i = r.getMutationCache().findAll({
270
276
  mutationKey: n,
271
277
  exact: !0
272
- }), a = new E(!1), y = u({ variables: s, ready$: a });
278
+ }), a = new C(!1), y = s({ variables: u, ready$: a });
273
279
  return await Promise.all(
274
- i.map((d) => d.continue().catch(L))
280
+ i.map((d) => d.continue().catch(U))
275
281
  ), a.next(!0), await y.finally(() => {
276
282
  a.complete();
277
283
  });
278
284
  },
279
- [u, r, n]
285
+ [s, r, n]
280
286
  ), l = S(
281
- (s) => {
282
- o(s).catch(L);
287
+ (u) => {
288
+ o(u).catch(U);
283
289
  },
284
290
  [o]
285
291
  );
286
292
  return { ...c, mutate: l, mutateAsync: o };
287
293
  }
288
- function ft(e, t) {
289
- const r = le(t), n = je();
290
- return Oe(
294
+ function dt(e, t) {
295
+ const r = le(t), n = ze();
296
+ return Te(
291
297
  {
292
298
  ...e,
293
- queryFn: (o) => new Promise((l, s) => {
294
- const i = () => D(
299
+ queryFn: (o) => new Promise((l, u) => {
300
+ const i = () => k(
295
301
  () => typeof e.queryFn == "function" ? e.queryFn(o) : e.queryFn
296
302
  ), a = ie(o.queryKey), y = n.getQuery(a), d = y ?? n.setQuery(o.queryKey, i(), o.signal), g = () => {
297
303
  d?.isCompleted === !1 && setTimeout(() => {
@@ -312,9 +318,9 @@ function ft(e, t) {
312
318
  * keep the last value. This is unfortunate but it's the best we can do
313
319
  * for now.
314
320
  */
315
- xe(1)
321
+ Me(1)
316
322
  ).subscribe({
317
- error: (f) => s(f),
323
+ error: (f) => u(f),
318
324
  complete: () => {
319
325
  if (d?.lastData === void 0)
320
326
  return d.signal.aborted || (console.log(
@@ -332,51 +338,51 @@ function ft(e, t) {
332
338
  t
333
339
  );
334
340
  }
335
- class X extends Error {
341
+ class Z extends Error {
336
342
  constructor(t = "Mutation canceled") {
337
343
  super(t), this.name = "SwitchMutationCancelError";
338
344
  }
339
345
  }
340
- function yt(e, t) {
341
- 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(
342
348
  {
343
349
  ...e,
344
- mutationFn: ({ variables: s, abort: i }) => {
350
+ mutationFn: ({ variables: u, abort: i }) => {
345
351
  if (i.aborted)
346
- throw new X();
347
- const a = typeof e.mutationFn == "function" ? e.mutationFn(s) : e.mutationFn;
348
- return V(
352
+ throw new Z();
353
+ const a = typeof e.mutationFn == "function" ? e.mutationFn(u) : e.mutationFn;
354
+ return F(
349
355
  a,
350
356
  se(i, "abort").pipe(
351
- k(() => {
352
- throw new X();
357
+ H(() => {
358
+ throw new Z();
353
359
  }),
354
- Me()
360
+ Ve()
355
361
  )
356
- ).pipe(ce(), Ve(null));
362
+ ).pipe(ce(), Fe(null));
357
363
  },
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)
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)
362
368
  },
363
369
  t
364
370
  ), o = S(
365
- (s) => (r.current.abort(), r.current = new AbortController(), n({
366
- variables: s,
371
+ (u) => (r.current.abort(), r.current = new AbortController(), n({
372
+ variables: u,
367
373
  abort: r.current.signal
368
374
  })),
369
375
  [n]
370
376
  ), l = S(
371
- (s) => (r.current.abort(), r.current = new AbortController(), u({
372
- variables: s,
377
+ (u) => (r.current.abort(), r.current = new AbortController(), s({
378
+ variables: u,
373
379
  abort: r.current.signal
374
380
  })),
375
- [u]
381
+ [s]
376
382
  );
377
383
  return { ...c, mutate: o, mutateAsync: l };
378
384
  }
379
- const ze = Symbol("SIGNAL_RESET"), dt = (e) => ({
385
+ const Je = Symbol("SIGNAL_RESET"), pt = (e) => ({
380
386
  getItem: async (t) => {
381
387
  const r = await e.getItem(t);
382
388
  if (r)
@@ -392,31 +398,31 @@ const ze = Symbol("SIGNAL_RESET"), dt = (e) => ({
392
398
  }), O = (e) => {
393
399
  if (!(!e || typeof e != "object"))
394
400
  return e;
395
- }, Je = ({
401
+ }, Le = ({
396
402
  adapter: e,
397
403
  key: t
398
404
  }) => ({
399
405
  clear: async () => await e.removeItem(t),
400
406
  removeItem: async (r) => {
401
- const n = await e.getItem(t), { [r]: u, ...c } = (
407
+ const n = await e.getItem(t), { [r]: s, ...c } = (
402
408
  // biome-ignore lint/suspicious/noExplicitAny: TODO
403
409
  O(n) ?? {}
404
410
  );
405
411
  await e.setItem(t, c);
406
412
  },
407
413
  getItem: async (r) => {
408
- const n = await e.getItem(t), u = O(n) ?? {};
409
- if (r in u)
410
- return u[r];
414
+ const n = await e.getItem(t), s = O(n) ?? {};
415
+ if (r in s)
416
+ return s[r];
411
417
  },
412
418
  setItem: async (r, n) => {
413
- const u = await e.getItem(t), c = O(u) ?? {};
419
+ const s = await e.getItem(t), c = O(s) ?? {};
414
420
  await e.setItem(t, { ...c, [r]: n });
415
421
  }
416
- }), Le = ({
422
+ }), Ye = ({
417
423
  key: e
418
- } = {}) => e ? Je({
419
- adapter: Le(),
424
+ } = {}) => e ? Le({
425
+ adapter: Ye(),
420
426
  key: e
421
427
  }) : {
422
428
  clear: async () => {
@@ -434,12 +440,12 @@ const ze = Symbol("SIGNAL_RESET"), dt = (e) => ({
434
440
  localStorage.setItem(t, JSON.stringify(r));
435
441
  }
436
442
  };
437
- class pe extends E {
443
+ class pe extends C {
438
444
  constructor(t) {
439
445
  super(t.default), this.config = t;
440
446
  }
441
447
  update = (t) => {
442
- if (t === ze)
448
+ if (t === Je)
443
449
  super.next(this.config.default);
444
450
  else if (typeof t == "function") {
445
451
  const r = t;
@@ -461,29 +467,29 @@ class pe extends E {
461
467
  return this.config.key;
462
468
  }
463
469
  }
464
- class Q {
470
+ class T {
465
471
  constructor(t) {
466
472
  this.config = t;
467
473
  }
468
474
  }
469
- function mt(e = {}) {
475
+ function bt(e = {}) {
470
476
  return new pe({
471
477
  key: void 0,
472
478
  ...e,
473
479
  default: e.default ?? void 0
474
480
  });
475
481
  }
476
- function pt(e) {
477
- return new Q(e);
482
+ function gt(e) {
483
+ return new T(e);
478
484
  }
479
- class T {
485
+ class Q {
480
486
  /**
481
487
  * items only get added as they are created. The only time we should cleanup
482
488
  * are on context destroy. This is to ensure later re-use of virtual signals
483
489
  * return the same persisted state.
484
490
  */
485
491
  // biome-ignore lint/suspicious/noExplicitAny: TODO
486
- signals = new E(/* @__PURE__ */ new Map());
492
+ signals = new C(/* @__PURE__ */ new Map());
487
493
  isDestroyed = !1;
488
494
  getOrCreateSignal(t) {
489
495
  const r = this.signals.value.get(t);
@@ -499,31 +505,31 @@ class T {
499
505
  }
500
506
  }
501
507
  const be = B(
502
- new T()
503
- ), bt = ee(
508
+ new Q()
509
+ ), ht = ee(
504
510
  ({ children: e }) => {
505
- const t = K(
506
- () => new T()
507
- ), r = t.current, [n, u] = _(!1);
508
- 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));
509
515
  const c = r;
510
516
  return I(() => () => {
511
- t.current?.destroy(), u(!0);
517
+ t.current?.destroy(), s(!0);
512
518
  }, [t]), /* @__PURE__ */ ae(be.Provider, { value: c, children: e });
513
519
  }
514
- ), ge = () => te(be), Ye = (e) => {
520
+ ), ge = () => te(be), Ue = (e) => {
515
521
  const t = ge();
516
522
  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)
523
+ }, x = "__reactjrx", Ge = (e) => {
524
+ if (typeof e == "object" && e !== null && x in e && e[x] === x)
519
525
  return e;
520
- }, Ge = ({
526
+ }, We = ({
521
527
  adapter: e,
522
528
  config: t
523
529
  }) => {
524
530
  const { signal: r, version: n } = t, c = {
525
531
  value: r.getValue(),
526
- [C]: C,
532
+ [x]: x,
527
533
  migrationVersion: n
528
534
  };
529
535
  return process.env.NODE_ENV === "development" && console.log(
@@ -531,21 +537,21 @@ const be = B(
531
537
  "Persist value",
532
538
  c,
533
539
  `for signal ${r.config.key}`
534
- ), x(e.setItem(r.config.key, c)).pipe(
535
- F((o) => (console.error(o), b(null)))
540
+ ), M(e.setItem(r.config.key, c)).pipe(
541
+ R((o) => (console.error(o), b(null)))
536
542
  );
537
543
  };
538
- function We({
544
+ function Xe({
539
545
  adapter: e,
540
546
  config: t
541
547
  }) {
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);
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);
546
552
  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)
553
+ const l = typeof o.migrationVersion != "number", u = o.migrationVersion !== void 0 && s > o.migrationVersion;
554
+ if (l || u || o.value === void 0)
549
555
  return b(c);
550
556
  const i = o.value;
551
557
  return process.env.NODE_ENV === "development" && console.log(
@@ -553,37 +559,37 @@ function We({
553
559
  "Hydrate value",
554
560
  o,
555
561
  `for signal ${n.config.key}`
556
- ), n.setValue(r({ value: i, version: u })), b(c);
562
+ ), n.setValue(r({ value: i, version: s })), b(c);
557
563
  })
558
564
  );
559
565
  }
560
- function Xe({
566
+ function Ze({
561
567
  entries: e = [],
562
568
  onHydrated: t,
563
569
  adapter: r
564
570
  }) {
565
- const u = (e.length === 0 ? b([]) : Fe(
571
+ const s = (e.length === 0 ? b([]) : Re(
566
572
  ...e.map(
567
- (o) => We({
573
+ (o) => Xe({
568
574
  adapter: r,
569
575
  config: o
570
576
  })
571
577
  )
572
578
  )).pipe(
573
- k(t),
574
- F((o) => (console.error("Unable to hydrate", o), H)),
579
+ H(t),
580
+ R((o) => (console.error("Unable to hydrate", o), K)),
575
581
  ue()
576
- ), c = u.pipe(
577
- M(
578
- () => V(
582
+ ), c = s.pipe(
583
+ V(
584
+ () => F(
579
585
  ...e.map(
580
586
  (o) => o.signal.pipe(
581
587
  $e(500, qe, {
582
588
  trailing: !0
583
589
  }),
584
- M(
585
- () => x(
586
- Ge({
590
+ V(
591
+ () => M(
592
+ We({
587
593
  adapter: r,
588
594
  config: o
589
595
  })
@@ -594,8 +600,8 @@ function Xe({
594
600
  )
595
601
  )
596
602
  );
597
- return V(
598
- u.pipe(
603
+ return F(
604
+ s.pipe(
599
605
  $(() => ({
600
606
  type: "hydrated"
601
607
  }))
@@ -607,21 +613,21 @@ function Xe({
607
613
  )
608
614
  );
609
615
  }
610
- function gt({
616
+ function St({
611
617
  entries: e = [],
612
618
  onHydrated: t,
613
619
  adapter: r
614
620
  }) {
615
- const n = v(t), u = G(r), c = G(e);
621
+ const n = v(t), s = W(r), c = W(e);
616
622
  return ye(
617
- () => u.pipe(
618
- M((l) => l ? V(
623
+ () => s.pipe(
624
+ V((l) => l ? F(
619
625
  b({ type: "reset" }),
620
626
  c.pipe(
621
627
  Ne(
622
- (s) => Xe({
628
+ (u) => Ze({
623
629
  adapter: l,
624
- entries: s,
630
+ entries: u,
625
631
  onHydrated: () => {
626
632
  n.current?.();
627
633
  }
@@ -630,120 +636,131 @@ function gt({
630
636
  )
631
637
  ) : b({ type: "reset" }))
632
638
  ).pipe(
633
- Re(
634
- (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,
635
641
  { isHydrated: !1 }
636
642
  )
637
643
  ),
638
644
  { defaultValue: { isHydrated: !1 }, compareFn: fe },
639
- [u, c]
645
+ [s, c]
640
646
  );
641
647
  }
642
- function z(e) {
648
+ function J(e) {
643
649
  const t = ge();
644
- if (e instanceof Q && !t)
650
+ if (e instanceof T && !t)
645
651
  throw new Error(
646
652
  "useSignalValue must be used within a SignalContextProvider"
647
653
  );
648
- return Ye(
649
- e instanceof Q ? e : void 0
654
+ return Ue(
655
+ e instanceof T ? e : void 0
650
656
  ) ?? e;
651
657
  }
652
- function Ze(e) {
653
- return z(e).update;
658
+ function Be(e) {
659
+ return J(e).update;
654
660
  }
655
- const ht = (e, t) => e.length === t.length && e.every((r, n) => r === t[n]);
656
- function St(e) {
661
+ const vt = (e, t) => e.length === t.length && e.every((r, n) => r === t[n]);
662
+ function It(e) {
657
663
  return e != null;
658
664
  }
659
- const vt = typeof window > "u" || "Deno" in window;
660
- function Be(e, t) {
665
+ const wt = typeof window > "u" || "Deno" in window;
666
+ function et(e, t) {
661
667
  return Math.min(e, t);
662
668
  }
663
- function et(e, t) {
669
+ function tt(e, t) {
664
670
  return 2 ** e * t;
665
671
  }
666
- function It(e) {
672
+ function Et(e) {
667
673
  const {
668
674
  retry: t,
669
675
  retryDelay: r,
670
676
  retryAfterDelay: n,
671
- retryAfter: u = () => b(!0)
677
+ retryAfter: s = () => b(!0)
672
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" ? (
673
679
  // ? (attempt: number, error: TError) => of(retry(attempt, error))
674
680
  t
675
- ) : () => !0, l = typeof r == "number" ? r : 100, s = {
681
+ ) : () => !0, l = typeof r == "number" ? r : 100, u = {
676
682
  ...e
677
683
  }, {
678
684
  maxInterval: i = Number.POSITIVE_INFINITY,
679
685
  resetOnSuccess: a = !1,
680
- backoffDelay: y = et
681
- } = s;
682
- return (d) => D(() => {
686
+ backoffDelay: y = tt
687
+ } = u;
688
+ return (d) => k(() => {
683
689
  let g = 0;
684
690
  const p = (f, m) => f < c ? o(f, m) : !1;
685
691
  return d.pipe(
686
- U((f) => {
692
+ G((f) => {
687
693
  if (g++, !p(g - 1, f)) throw f;
688
694
  const m = e.caughtError?.(g, f);
689
695
  if (!m) throw f;
690
696
  return m.pipe(
691
697
  P(
692
- (w) => V(
693
- b(w),
698
+ (E) => F(
699
+ b(E),
694
700
  A(() => f)
695
701
  )
696
702
  )
697
703
  );
698
704
  }),
699
705
  Qe((f) => f.pipe(
700
- Te((m) => {
701
- const w = g - 1;
702
- return u().pipe(
703
- _e(),
706
+ _e((m) => {
707
+ const E = g - 1;
708
+ return s().pipe(
709
+ De(),
704
710
  P(
705
- () => p(w, m) ? Ae(
706
- Be(
707
- y(w, l),
711
+ () => p(E, m) ? Pe(
712
+ et(
713
+ y(E, l),
708
714
  i
709
715
  )
710
716
  ).pipe(
711
- P((h) => n && !n(w, m) ? A(() => m) : b(h))
717
+ P((h) => n && !n(E, m) ? A(() => m) : b(h))
712
718
  ) : A(() => m)
713
719
  )
714
720
  );
715
721
  })
716
722
  )),
717
- U((f) => {
723
+ G((f) => {
718
724
  if (e.catchError)
719
725
  return e.catchError(g, f);
720
726
  throw f;
721
727
  }),
722
- De(() => {
728
+ ke(() => {
723
729
  a && (g = 0);
724
730
  })
725
731
  );
726
732
  });
727
733
  }
728
- const tt = (e) => {
734
+ const he = (e) => {
729
735
  I(e, []);
730
- }, wt = (e) => {
731
- 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(() => {
732
754
  e();
733
755
  });
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
756
  };
740
- function he(e, t) {
741
- const r = v(t), n = z(e);
757
+ function Se(e, t) {
758
+ const r = v(t), n = J(e);
742
759
  return ye(
743
760
  () => {
744
- const u = r.current ?? ((o) => o);
761
+ const s = r.current ?? ((o) => o);
745
762
  return n.pipe(
746
- $(u),
763
+ $(s),
747
764
  re()
748
765
  );
749
766
  },
@@ -753,56 +770,60 @@ function he(e, t) {
753
770
  [n]
754
771
  );
755
772
  }
756
- function Ct(e) {
757
- 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);
758
775
  return [r, n, t];
759
776
  }
760
- const xt = (e) => {
761
- const t = N(e);
762
- return [he(t), t];
777
+ const Ft = (e) => {
778
+ const t = q(e);
779
+ return [Se(t), t];
763
780
  };
764
781
  export {
765
782
  de as Context,
766
- Ke as QueryClient$,
767
- it as QueryClientProvider$,
768
- ze as SIGNAL_RESET,
783
+ je as QueryClient$,
784
+ ft as QueryClientProvider$,
785
+ Je as SIGNAL_RESET,
769
786
  pe as Signal,
770
- bt as SignalContextProvider,
787
+ ht as SignalContextProvider,
771
788
  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,
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,
788
806
  v as useLiveRef,
789
- Ye as useMakeOrRetrieveSignal,
790
- wt as useMount,
807
+ Ue as useMakeOrRetrieveSignal,
808
+ xt as useMemoCompare,
809
+ Mt as useMount,
791
810
  me as useMutation$,
792
- ct as useObservableState,
811
+ at as useObservableState,
793
812
  ye as useObserve,
794
- gt as usePersistSignals,
795
- ft as useQuery$,
796
- je as useQueryClient$,
797
- Ze as useSetSignal,
798
- 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,
799
819
  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
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
807
828
  };
808
829
  //# sourceMappingURL=index.js.map