reactjrx 1.114.0 → 1.115.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,8 +1,8 @@
1
1
  var ce = Object.defineProperty;
2
2
  var ae = (e, t, r) => t in e ? ce(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
3
  var k = (e, t, r) => ae(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { useRef as V, useMemo as oe, useCallback as v, useSyncExternalStore as ie, useEffect as h, useState as L, createContext as le, memo as fe, useContext as ye } from "react";
5
- import { isObservable as _, from as w, of as p, defer as A, startWith as me, identity as U, distinctUntilChanged as J, tap as Y, catchError as $, EMPTY as Q, Subject as j, BehaviorSubject as N, retry as de, skip as pe, first as G, map as R, switchMap as F, zip as be, share as W, merge as M, throttleTime as ve, asyncScheduler as Se, concatMap as ge, scan as he, throwError as x, timer as Ie, takeUntil as X, fromEvent as Ve, take as Z, delay as Ee, defaultIfEmpty as we, filter as Fe, noop as D } from "rxjs";
4
+ import { useRef as v, useMemo as oe, useCallback as S, useSyncExternalStore as ie, useEffect as I, useState as L, createContext as le, memo as fe, useContext as de } from "react";
5
+ import { isObservable as _, from as w, of as p, defer as A, startWith as ye, identity as U, distinctUntilChanged as J, tap as Y, catchError as $, EMPTY as Q, Subject as j, BehaviorSubject as N, retry as me, skip as pe, first as G, map as R, switchMap as F, zip as be, share as W, merge as M, throttleTime as Se, asyncScheduler as ge, concatMap as he, scan as Ie, throwError as x, timer as Ve, takeUntil as X, fromEvent as ve, take as Z, delay as Ee, defaultIfEmpty as we, filter as Fe, noop as D } from "rxjs";
6
6
  import { catchError as H, mergeMap as q, retryWhen as $e, concatMap as Ne, first as Me, tap as Oe } from "rxjs/operators";
7
7
  import { hashKey as B, useQueryClient as ee, useQuery as xe, useMutation as qe } from "@tanstack/react-query";
8
8
  import { jsx as Pe } from "react/jsx-runtime";
@@ -19,8 +19,8 @@ function C(e) {
19
19
  return K(n) ? w(n) : _(n) ? n : p(n);
20
20
  });
21
21
  }
22
- const g = (e) => {
23
- const t = V(e);
22
+ const h = (e) => {
23
+ const t = v(e);
24
24
  return oe(() => {
25
25
  t.current = e;
26
26
  }, [e]), t;
@@ -30,21 +30,21 @@ function te(e, t, r) {
30
30
  defaultValue: void 0,
31
31
  unsubscribeOnUnmount: !0,
32
32
  compareFn: void 0
33
- }, s = !r && Array.isArray(t) ? t : typeof e == "function" ? r ?? [] : [e], a = V(
33
+ }, s = !r && Array.isArray(t) ? t : typeof e == "function" ? r ?? [] : [e], a = v(
34
34
  "getValue" in e && typeof e.getValue == "function" ? e.getValue() : n.defaultValue
35
- ), u = g(e), i = g(n), c = v(() => a.current, []), o = v(
35
+ ), u = h(e), i = h(n), c = S(() => a.current, []), o = S(
36
36
  (l) => {
37
- const d = u.current, b = C(d)().pipe(
38
- i.current.defaultValue ? me(i.current.defaultValue) : U,
37
+ const m = u.current, b = C(m)().pipe(
38
+ i.current.defaultValue ? ye(i.current.defaultValue) : U,
39
39
  /**
40
40
  * @important there is already a Object.is comparison in place from react
41
41
  * so we only add a custom compareFn if provided
42
42
  */
43
- J((m, y) => i.current.compareFn ? m === void 0 || y === void 0 ? !1 : i.current.compareFn(m, y) : !1),
44
- Y((m) => {
45
- a.current = m;
43
+ J((y, d) => i.current.compareFn ? y === void 0 || d === void 0 ? !1 : i.current.compareFn(y, d) : !1),
44
+ Y((y) => {
45
+ a.current = y;
46
46
  }),
47
- $((m) => (console.error(m), Q))
47
+ $((y) => (console.error(y), Q))
48
48
  ).subscribe(l);
49
49
  return () => {
50
50
  i.current.unsubscribeOnUnmount !== !1 && b.unsubscribe();
@@ -52,11 +52,11 @@ function te(e, t, r) {
52
52
  },
53
53
  [...s]
54
54
  );
55
- return ie(o, c);
55
+ return ie(o, c, c);
56
56
  }
57
57
  function Re(e, t = []) {
58
- const r = g(e);
59
- h(() => {
58
+ const r = h(e);
59
+ I(() => {
60
60
  const n = C(r.current)().pipe(
61
61
  $((s) => (console.error(s), Q))
62
62
  ).subscribe();
@@ -66,16 +66,16 @@ function Re(e, t = []) {
66
66
  }, [...t, r]);
67
67
  }
68
68
  const re = (e) => {
69
- const t = V(void 0);
70
- return t.current || (t.current = e()), h(() => {
69
+ const t = v(void 0);
70
+ return t.current || (t.current = e()), I(() => {
71
71
  process.env.NODE_ENV;
72
72
  }, []), t;
73
73
  }, ne = ({
74
74
  onBeforeComplete: e,
75
75
  completeOnUnmount: t = !0
76
76
  } = {}) => {
77
- const r = re(() => new j()), n = V(!1), s = g(e), a = g(t);
78
- return h(() => (n.current && (r.current = new j(), n.current = !1), () => {
77
+ const r = re(() => new j()), n = v(!1), s = h(e), a = h(t);
78
+ return I(() => (n.current && (r.current = new j(), n.current = !1), () => {
79
79
  if (!a.current) {
80
80
  n.current = !0;
81
81
  return;
@@ -83,17 +83,17 @@ const re = (e) => {
83
83
  n.current || (s.current != null && s.current(), r.current.complete(), n.current = !0);
84
84
  }), [a, s, r]), r;
85
85
  }, Ae = () => {
86
- const e = ne(), t = v((r) => {
86
+ const e = ne(), t = S((r) => {
87
87
  e.current.next(r);
88
88
  }, []);
89
89
  return [e.current, t];
90
90
  }, T = (e) => {
91
- const t = re(() => new N(e)), r = V(!1), n = V(e);
92
- return h(() => (r.current && (t.current = new N(n.current), r.current = !1), () => {
91
+ const t = re(() => new N(e)), r = v(!1), n = v(e);
92
+ return I(() => (r.current && (t.current = new N(n.current), r.current = !1), () => {
93
93
  r.current || (t.current.complete(), r.current = !0);
94
94
  }), [t]), t;
95
95
  }, rt = (e) => {
96
- const t = T(e), r = g(t.current.asObservable()), n = v(
96
+ const t = T(e), r = h(t.current.asObservable()), n = S(
97
97
  (s) => {
98
98
  t.current.next(s);
99
99
  },
@@ -102,21 +102,21 @@ const re = (e) => {
102
102
  return [r.current, n, t.current.getValue()];
103
103
  }, z = (e) => {
104
104
  const t = T(e);
105
- return h(() => {
105
+ return I(() => {
106
106
  t.current.next(e);
107
107
  }, [e, t]), t;
108
108
  };
109
109
  function nt(e, t, r = []) {
110
- const n = t != null && !Array.isArray(t) ? t : {}, s = n.retry ?? !0, a = g(
110
+ const n = t != null && !Array.isArray(t) ? t : {}, s = n.retry ?? !0, a = h(
111
111
  n.onError ?? ((c) => {
112
112
  console.error(c);
113
113
  })
114
- ), u = v(() => C(e)(), r), i = v(
114
+ ), u = S(() => C(e)(), r), i = S(
115
115
  () => u().pipe(
116
116
  $((c) => {
117
117
  throw a.current(c), c;
118
118
  }),
119
- s ? de() : U
119
+ s ? me() : U
120
120
  ),
121
121
  [u, s, a]
122
122
  );
@@ -320,7 +320,7 @@ function ze({
320
320
  () => M(
321
321
  ...e.map(
322
322
  (u) => u.signal.subject.pipe(
323
- ve(500, Se, {
323
+ Se(500, ge, {
324
324
  trailing: !0
325
325
  }),
326
326
  F(
@@ -354,13 +354,13 @@ function ct({
354
354
  onHydrated: t,
355
355
  adapter: r
356
356
  }) {
357
- const n = g(t), s = z(r), a = z(e);
357
+ const n = h(t), s = z(r), a = z(e);
358
358
  return te(
359
359
  () => s.current.pipe(
360
360
  F((i) => i ? M(
361
361
  p({ type: "reset" }),
362
362
  a.current.pipe(
363
- ge(
363
+ he(
364
364
  (c) => ze({
365
365
  adapter: i,
366
366
  entries: c,
@@ -373,7 +373,7 @@ function ct({
373
373
  )
374
374
  ) : p({ type: "reset" }))
375
375
  ).pipe(
376
- he(
376
+ Ie(
377
377
  (i, c) => c.type === "reset" ? { isHydrated: !1 } : c.type === "hydrated" ? { isHydrated: !0 } : i,
378
378
  { isHydrated: !1 }
379
379
  )
@@ -390,7 +390,7 @@ const at = () => {
390
390
  });
391
391
  return e;
392
392
  }, Le = (e) => {
393
- h(e, []);
393
+ I(e, []);
394
394
  }, ot = (e) => {
395
395
  Le(() => {
396
396
  e();
@@ -419,46 +419,46 @@ function it(e) {
419
419
  resetOnSuccess: f = !1,
420
420
  backoffDelay: l = Je
421
421
  } = c;
422
- return (d) => A(() => {
422
+ return (m) => A(() => {
423
423
  let b = 0;
424
- const m = (y, S) => y < a ? u(y, S) : !1;
425
- return d.pipe(
426
- H((y) => {
427
- var I;
428
- if (b++, !m(b - 1, y)) throw y;
429
- const S = (I = e.caughtError) == null ? void 0 : I.call(e, b, y);
430
- if (!S) throw y;
431
- return S.pipe(
424
+ const y = (d, g) => d < a ? u(d, g) : !1;
425
+ return m.pipe(
426
+ H((d) => {
427
+ var V;
428
+ if (b++, !y(b - 1, d)) throw d;
429
+ const g = (V = e.caughtError) == null ? void 0 : V.call(e, b, d);
430
+ if (!g) throw d;
431
+ return g.pipe(
432
432
  q(
433
433
  (O) => M(
434
434
  p(O),
435
- x(() => y)
435
+ x(() => d)
436
436
  )
437
437
  )
438
438
  );
439
439
  }),
440
- $e((y) => y.pipe(
441
- Ne((S) => {
442
- const I = b - 1;
440
+ $e((d) => d.pipe(
441
+ Ne((g) => {
442
+ const V = b - 1;
443
443
  return s().pipe(
444
444
  Me(),
445
445
  q(
446
- () => m(I, S) ? Ie(
446
+ () => y(V, g) ? Ve(
447
447
  Ue(
448
- l(I, i),
448
+ l(V, i),
449
449
  o
450
450
  )
451
451
  ).pipe(
452
- q((O) => n && !n(I, S) ? x(() => S) : p(O))
453
- ) : x(() => S)
452
+ q((O) => n && !n(V, g) ? x(() => g) : p(O))
453
+ ) : x(() => g)
454
454
  )
455
455
  );
456
456
  })
457
457
  )),
458
- H((y) => {
458
+ H((d) => {
459
459
  if (e.catchError)
460
- return e.catchError(b, y);
461
- throw y;
460
+ return e.catchError(b, d);
461
+ throw d;
462
462
  }),
463
463
  Oe(() => {
464
464
  f && (b = 0);
@@ -469,7 +469,7 @@ function it(e) {
469
469
  function lt(e) {
470
470
  return e != null;
471
471
  }
472
- const ft = (e, t) => e.length === t.length && e.every((r, n) => r === t[n]), yt = typeof window > "u" || "Deno" in window;
472
+ const ft = (e, t) => e.length === t.length && e.every((r, n) => r === t[n]), dt = typeof window > "u" || "Deno" in window;
473
473
  class Ye {
474
474
  constructor() {
475
475
  k(this, "queryMap", /* @__PURE__ */ new Map());
@@ -485,7 +485,7 @@ class Ye {
485
485
  * - unmounting the component
486
486
  * @see https://tanstack.com/query/latest/docs/framework/react/guides/query-cancellation
487
487
  */
488
- X(Ve(n, "abort")),
488
+ X(ve(n, "abort")),
489
489
  W()
490
490
  ), u = {
491
491
  query$: a,
@@ -516,25 +516,25 @@ class Ye {
516
516
  });
517
517
  }
518
518
  }
519
- const ue = le(void 0), mt = fe(
519
+ const ue = le(void 0), yt = fe(
520
520
  ({
521
521
  children: e,
522
522
  client: t
523
523
  }) => {
524
524
  const [r] = L(() => t ?? new Ye());
525
- return h(() => () => {
525
+ return I(() => () => {
526
526
  r.destroy();
527
527
  }, [r]), /* @__PURE__ */ Pe(ue.Provider, { value: r, children: e });
528
528
  }
529
529
  ), Ge = () => {
530
- const e = ye(ue);
530
+ const e = de(ue);
531
531
  if (!e)
532
532
  throw new Error(
533
533
  "useReactJrxQueryClient must be used within a ReactJrxQueryProvider"
534
534
  );
535
535
  return e;
536
536
  };
537
- function dt(e, t) {
537
+ function mt(e, t) {
538
538
  const r = ee(t), n = Ge();
539
539
  return xe(
540
540
  {
@@ -587,17 +587,17 @@ function se(e, t) {
587
587
  ...e,
588
588
  mutationFn: (o) => {
589
589
  let f;
590
- return new Promise((l, d) => {
590
+ return new Promise((l, m) => {
591
591
  (typeof e.mutationFn == "function" ? e.mutationFn(o) : e.mutationFn).pipe(Z(1)).subscribe({
592
- next: (m) => {
593
- f = { value: m };
592
+ next: (y) => {
593
+ f = { value: y };
594
594
  },
595
- error: (m) => {
596
- d(m);
595
+ error: (y) => {
596
+ m(y);
597
597
  },
598
598
  complete: () => {
599
599
  if (f === void 0)
600
- return d(new Error("Stream completed without any data"));
600
+ return m(new Error("Stream completed without any data"));
601
601
  l(f.value);
602
602
  }
603
603
  });
@@ -606,7 +606,7 @@ function se(e, t) {
606
606
  },
607
607
  t
608
608
  ), { status: s, isPending: a, isError: u, isSuccess: i, isIdle: c } = n;
609
- return h(() => {
609
+ return I(() => {
610
610
  r.current.next({
611
611
  status: s,
612
612
  isPending: a,
@@ -623,10 +623,10 @@ function pt(e, t) {
623
623
  mutationFn: (o) => (typeof e.mutationFn == "function" ? e.mutationFn(o) : e.mutationFn).pipe(X(r), we(null))
624
624
  },
625
625
  t
626
- ), i = v(
626
+ ), i = S(
627
627
  (o) => (n(), s(o)),
628
628
  [s, n]
629
- ), c = v(
629
+ ), c = S(
630
630
  (o) => (n(), a(o)),
631
631
  [a, n]
632
632
  );
@@ -649,8 +649,8 @@ function bt(e, t) {
649
649
  return (l = e.onError) == null ? void 0 : l.call(e, c, o.variables, f);
650
650
  },
651
651
  onSettled(c, o, f, l) {
652
- var d;
653
- return (d = e.onSettled) == null ? void 0 : d.call(e, c, o, f.variables, l);
652
+ var m;
653
+ return (m = e.onSettled) == null ? void 0 : m.call(e, c, o, f.variables, l);
654
654
  },
655
655
  mutationFn: ({ ready$: c, variables: o }) => {
656
656
  const f = typeof e.mutationFn == "function" ? e.mutationFn(o) : e.mutationFn;
@@ -662,20 +662,20 @@ function bt(e, t) {
662
662
  }
663
663
  },
664
664
  t
665
- ), u = v(
665
+ ), u = S(
666
666
  async (c) => {
667
667
  const o = r.getMutationCache().findAll({
668
668
  mutationKey: n,
669
669
  exact: !0
670
670
  }), f = new N(!1), l = s({ variables: c, ready$: f });
671
671
  return await Promise.all(
672
- o.map((d) => d.continue().catch(D))
672
+ o.map((m) => m.continue().catch(D))
673
673
  ), f.next(!0), await l.finally(() => {
674
674
  f.complete();
675
675
  });
676
676
  },
677
677
  [s, r, n]
678
- ), i = v(
678
+ ), i = S(
679
679
  (c) => {
680
680
  u(c).catch(D);
681
681
  },
@@ -686,7 +686,7 @@ function bt(e, t) {
686
686
  export {
687
687
  ue as Context,
688
688
  Ye as QueryClient$,
689
- mt as QueryClientProvider$,
689
+ yt as QueryClientProvider$,
690
690
  Qe as SIGNAL_RESET,
691
691
  ft as arrayEqual,
692
692
  _e as createLocalStorageAdapter,
@@ -695,21 +695,21 @@ export {
695
695
  Ue as getDelay,
696
696
  lt as isDefined,
697
697
  K as isPromiseLike,
698
- yt as isServer,
698
+ dt as isServer,
699
699
  it as retryBackoff,
700
700
  Ce as signal,
701
701
  T as useBehaviorSubject,
702
702
  bt as useContactMutation$,
703
703
  Le as useEffectOnce,
704
704
  z as useLiveBehaviorSubject,
705
- g as useLiveRef,
705
+ h as useLiveRef,
706
706
  ot as useMount,
707
707
  se as useMutation$,
708
708
  Ae as useObservableCallback,
709
709
  rt as useObservableState,
710
710
  te as useObserve,
711
711
  ct as usePersistSignals,
712
- dt as useQuery$,
712
+ mt as useQuery$,
713
713
  Ge as useQueryClient$,
714
714
  ut as useSignal,
715
715
  Te as useSignalValue,