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.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +76 -76
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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
|
|
5
|
-
import { isObservable as _, from as w, of as p, defer as A, startWith as
|
|
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
|
|
23
|
-
const t =
|
|
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 =
|
|
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 =
|
|
35
|
+
), u = h(e), i = h(n), c = S(() => a.current, []), o = S(
|
|
36
36
|
(l) => {
|
|
37
|
-
const
|
|
38
|
-
i.current.defaultValue ?
|
|
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((
|
|
44
|
-
Y((
|
|
45
|
-
a.current =
|
|
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
|
-
$((
|
|
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 =
|
|
59
|
-
|
|
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 =
|
|
70
|
-
return t.current || (t.current = e()),
|
|
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 =
|
|
78
|
-
return
|
|
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 =
|
|
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 =
|
|
92
|
-
return
|
|
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 =
|
|
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
|
|
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 =
|
|
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 =
|
|
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 ?
|
|
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
|
-
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 (
|
|
422
|
+
return (m) => A(() => {
|
|
423
423
|
let b = 0;
|
|
424
|
-
const
|
|
425
|
-
return
|
|
426
|
-
H((
|
|
427
|
-
var
|
|
428
|
-
if (b++, !
|
|
429
|
-
const
|
|
430
|
-
if (!
|
|
431
|
-
return
|
|
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(() =>
|
|
435
|
+
x(() => d)
|
|
436
436
|
)
|
|
437
437
|
)
|
|
438
438
|
);
|
|
439
439
|
}),
|
|
440
|
-
$e((
|
|
441
|
-
Ne((
|
|
442
|
-
const
|
|
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
|
-
() =>
|
|
446
|
+
() => y(V, g) ? Ve(
|
|
447
447
|
Ue(
|
|
448
|
-
l(
|
|
448
|
+
l(V, i),
|
|
449
449
|
o
|
|
450
450
|
)
|
|
451
451
|
).pipe(
|
|
452
|
-
q((O) => n && !n(
|
|
453
|
-
) : x(() =>
|
|
452
|
+
q((O) => n && !n(V, g) ? x(() => g) : p(O))
|
|
453
|
+
) : x(() => g)
|
|
454
454
|
)
|
|
455
455
|
);
|
|
456
456
|
})
|
|
457
457
|
)),
|
|
458
|
-
H((
|
|
458
|
+
H((d) => {
|
|
459
459
|
if (e.catchError)
|
|
460
|
-
return e.catchError(b,
|
|
461
|
-
throw
|
|
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]),
|
|
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(
|
|
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),
|
|
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
|
|
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 =
|
|
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
|
|
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,
|
|
590
|
+
return new Promise((l, m) => {
|
|
591
591
|
(typeof e.mutationFn == "function" ? e.mutationFn(o) : e.mutationFn).pipe(Z(1)).subscribe({
|
|
592
|
-
next: (
|
|
593
|
-
f = { value:
|
|
592
|
+
next: (y) => {
|
|
593
|
+
f = { value: y };
|
|
594
594
|
},
|
|
595
|
-
error: (
|
|
596
|
-
|
|
595
|
+
error: (y) => {
|
|
596
|
+
m(y);
|
|
597
597
|
},
|
|
598
598
|
complete: () => {
|
|
599
599
|
if (f === void 0)
|
|
600
|
-
return
|
|
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
|
|
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 =
|
|
626
|
+
), i = S(
|
|
627
627
|
(o) => (n(), s(o)),
|
|
628
628
|
[s, n]
|
|
629
|
-
), c =
|
|
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
|
|
653
|
-
return (
|
|
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 =
|
|
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((
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
712
|
+
mt as useQuery$,
|
|
713
713
|
Ge as useQueryClient$,
|
|
714
714
|
ut as useSignal,
|
|
715
715
|
Te as useSignalValue,
|