reactjrx 1.113.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.d.ts +1 -1
- package/dist/index.js +193 -188
- package/dist/index.js.map +1 -1
- package/dist/lib/binding/useObserve.d.ts +1 -1
- package/dist/lib/binding/useSubject.d.ts +1 -1
- package/dist/lib/queries/QueryClientProvider$.d.ts +1 -1
- package/dist/lib/state/index.d.ts +1 -1
- package/dist/lib/state/persistance/adapters/createLocalStorageAdapter.d.ts +1 -1
- package/dist/lib/state/persistance/helpers.d.ts +3 -3
- package/dist/lib/state/persistance/persistSignals.d.ts +2 -2
- package/dist/lib/state/persistance/types.d.ts +1 -1
- package/dist/lib/state/react/usePersistSignals.d.ts +2 -2
- package/dist/lib/utils/operators/retryBackoff.d.ts +1 -1
- package/dist/tests/utils.d.ts +0 -5
- package/package.json +68 -78
package/dist/index.js
CHANGED
|
@@ -1,118 +1,108 @@
|
|
|
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
|
-
var
|
|
4
|
-
import { useRef as
|
|
5
|
-
import { isObservable as _, from as
|
|
6
|
-
import { catchError as
|
|
7
|
-
import { hashKey as B, useQueryClient as ee, useQuery as
|
|
8
|
-
import { jsx as
|
|
9
|
-
|
|
10
|
-
const t = I(e);
|
|
11
|
-
return oe(() => {
|
|
12
|
-
t.current = e;
|
|
13
|
-
}, [e]), t;
|
|
14
|
-
};
|
|
15
|
-
function T(e) {
|
|
3
|
+
var k = (e, t, r) => ae(e, typeof t != "symbol" ? t + "" : t, r);
|
|
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
|
+
import { catchError as H, mergeMap as q, retryWhen as $e, concatMap as Ne, first as Me, tap as Oe } from "rxjs/operators";
|
|
7
|
+
import { hashKey as B, useQueryClient as ee, useQuery as xe, useMutation as qe } from "@tanstack/react-query";
|
|
8
|
+
import { jsx as Pe } from "react/jsx-runtime";
|
|
9
|
+
function K(e) {
|
|
16
10
|
return e instanceof Promise || e && typeof e == "object" && "then" in e && typeof e.then == "function" && "catch" in e && e.catch === "function";
|
|
17
11
|
}
|
|
18
|
-
function
|
|
12
|
+
function C(e) {
|
|
19
13
|
if (_(e)) return () => e;
|
|
20
|
-
if (
|
|
14
|
+
if (K(e)) return () => w(e);
|
|
21
15
|
if (typeof e != "function") return () => p(e);
|
|
22
16
|
const t = e;
|
|
23
|
-
return (r) =>
|
|
17
|
+
return (r) => A(() => {
|
|
24
18
|
const n = t(r);
|
|
25
|
-
return
|
|
19
|
+
return K(n) ? w(n) : _(n) ? n : p(n);
|
|
26
20
|
});
|
|
27
21
|
}
|
|
22
|
+
const h = (e) => {
|
|
23
|
+
const t = v(e);
|
|
24
|
+
return oe(() => {
|
|
25
|
+
t.current = e;
|
|
26
|
+
}, [e]), t;
|
|
27
|
+
};
|
|
28
28
|
function te(e, t, r) {
|
|
29
29
|
const n = t != null && !Array.isArray(t) ? t : {
|
|
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 = h(e), i = h(n), c =
|
|
35
|
+
), u = h(e), i = h(n), c = S(() => a.current, []), o = S(
|
|
36
36
|
(l) => {
|
|
37
|
-
const m = u.current, b =
|
|
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
|
-
i.current.compareFn ?
|
|
44
|
-
|
|
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();
|
|
51
51
|
};
|
|
52
52
|
},
|
|
53
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
54
53
|
[...s]
|
|
55
54
|
);
|
|
56
|
-
return ie(o, c);
|
|
55
|
+
return ie(o, c, c);
|
|
57
56
|
}
|
|
58
|
-
function
|
|
57
|
+
function Re(e, t = []) {
|
|
59
58
|
const r = h(e);
|
|
60
|
-
|
|
61
|
-
const n =
|
|
62
|
-
|
|
59
|
+
I(() => {
|
|
60
|
+
const n = C(r.current)().pipe(
|
|
61
|
+
$((s) => (console.error(s), Q))
|
|
63
62
|
).subscribe();
|
|
64
63
|
return () => {
|
|
65
64
|
n.unsubscribe();
|
|
66
65
|
};
|
|
67
|
-
}, [
|
|
68
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
69
|
-
...t,
|
|
70
|
-
r
|
|
71
|
-
]);
|
|
66
|
+
}, [...t, r]);
|
|
72
67
|
}
|
|
73
68
|
const re = (e) => {
|
|
74
|
-
const t =
|
|
75
|
-
return t.current || (t.current = e()),
|
|
69
|
+
const t = v(void 0);
|
|
70
|
+
return t.current || (t.current = e()), I(() => {
|
|
76
71
|
process.env.NODE_ENV;
|
|
77
72
|
}, []), t;
|
|
78
73
|
}, ne = ({
|
|
79
74
|
onBeforeComplete: e,
|
|
80
75
|
completeOnUnmount: t = !0
|
|
81
76
|
} = {}) => {
|
|
82
|
-
const r = re(() => new
|
|
83
|
-
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), () => {
|
|
84
79
|
if (!a.current) {
|
|
85
80
|
n.current = !0;
|
|
86
81
|
return;
|
|
87
82
|
}
|
|
88
83
|
n.current || (s.current != null && s.current(), r.current.complete(), n.current = !0);
|
|
89
84
|
}), [a, s, r]), r;
|
|
90
|
-
},
|
|
91
|
-
const e = ne(), t =
|
|
92
|
-
(r)
|
|
93
|
-
|
|
94
|
-
},
|
|
95
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
96
|
-
[]
|
|
97
|
-
);
|
|
85
|
+
}, Ae = () => {
|
|
86
|
+
const e = ne(), t = S((r) => {
|
|
87
|
+
e.current.next(r);
|
|
88
|
+
}, []);
|
|
98
89
|
return [e.current, t];
|
|
99
|
-
},
|
|
100
|
-
const t = re(() => new
|
|
101
|
-
return
|
|
90
|
+
}, T = (e) => {
|
|
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), () => {
|
|
102
93
|
r.current || (t.current.complete(), r.current = !0);
|
|
103
94
|
}), [t]), t;
|
|
104
95
|
}, rt = (e) => {
|
|
105
|
-
const t =
|
|
96
|
+
const t = T(e), r = h(t.current.asObservable()), n = S(
|
|
106
97
|
(s) => {
|
|
107
98
|
t.current.next(s);
|
|
108
99
|
},
|
|
109
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
110
100
|
[t.current]
|
|
111
101
|
);
|
|
112
102
|
return [r.current, n, t.current.getValue()];
|
|
113
|
-
},
|
|
114
|
-
const t =
|
|
115
|
-
return
|
|
103
|
+
}, z = (e) => {
|
|
104
|
+
const t = T(e);
|
|
105
|
+
return I(() => {
|
|
116
106
|
t.current.next(e);
|
|
117
107
|
}, [e, t]), t;
|
|
118
108
|
};
|
|
@@ -121,41 +111,46 @@ function nt(e, t, r = []) {
|
|
|
121
111
|
n.onError ?? ((c) => {
|
|
122
112
|
console.error(c);
|
|
123
113
|
})
|
|
124
|
-
), u =
|
|
114
|
+
), u = S(() => C(e)(), r), i = S(
|
|
125
115
|
() => u().pipe(
|
|
126
|
-
|
|
116
|
+
$((c) => {
|
|
127
117
|
throw a.current(c), c;
|
|
128
118
|
}),
|
|
129
|
-
s ? me() :
|
|
119
|
+
s ? me() : U
|
|
130
120
|
),
|
|
131
121
|
[u, s, a]
|
|
132
122
|
);
|
|
133
|
-
|
|
123
|
+
Re(i, r);
|
|
134
124
|
}
|
|
135
|
-
const
|
|
136
|
-
function
|
|
125
|
+
const Qe = Symbol("SIGNAL_RESET");
|
|
126
|
+
function Ce(e = {}) {
|
|
137
127
|
const t = {
|
|
128
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
138
129
|
default: e.default,
|
|
130
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
139
131
|
key: e.key
|
|
140
|
-
}, { default: r } = t, n = new
|
|
132
|
+
}, { default: r } = t, n = new N(r), s = (u) => {
|
|
141
133
|
const i = (c) => {
|
|
142
134
|
"key" in e && console.log(
|
|
143
135
|
"[reactjrx][state][signal]:",
|
|
144
136
|
`Value update for signal ${e.key}`,
|
|
145
|
-
{
|
|
137
|
+
{
|
|
138
|
+
prev: n.getValue(),
|
|
139
|
+
curr: c
|
|
140
|
+
}
|
|
146
141
|
), n.next(c);
|
|
147
142
|
};
|
|
148
143
|
if (typeof u == "function") {
|
|
149
144
|
const c = u(n.getValue());
|
|
150
145
|
return c === n.getValue() ? void 0 : i(c);
|
|
151
146
|
}
|
|
152
|
-
if (u ===
|
|
147
|
+
if (u === Qe)
|
|
153
148
|
return r === n.getValue() ? void 0 : i(r ?? void 0);
|
|
154
149
|
if (u !== n.getValue())
|
|
155
150
|
return i(u);
|
|
156
151
|
}, a = () => n.getValue();
|
|
157
152
|
if ("get" in e) {
|
|
158
|
-
const u = (c) => (c.subject.pipe(pe(1),
|
|
153
|
+
const u = (c) => (c.subject.pipe(pe(1), G()).subscribe(() => {
|
|
159
154
|
var f;
|
|
160
155
|
const o = (f = e.get) == null ? void 0 : f.call(e, u);
|
|
161
156
|
s(o);
|
|
@@ -169,15 +164,16 @@ function Ne(e = {}) {
|
|
|
169
164
|
return {
|
|
170
165
|
setValue: s,
|
|
171
166
|
getValue: a,
|
|
167
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
172
168
|
config: t,
|
|
173
169
|
subject: n
|
|
174
170
|
};
|
|
175
171
|
}
|
|
176
|
-
function
|
|
172
|
+
function Te(e, t) {
|
|
177
173
|
const n = t ?? (() => e.getValue());
|
|
178
174
|
return te(
|
|
179
175
|
() => e.subject.pipe(
|
|
180
|
-
|
|
176
|
+
R((a) => n(a)),
|
|
181
177
|
J()
|
|
182
178
|
),
|
|
183
179
|
{
|
|
@@ -187,8 +183,8 @@ function ke(e, t) {
|
|
|
187
183
|
);
|
|
188
184
|
}
|
|
189
185
|
const ut = (e) => {
|
|
190
|
-
const [t] =
|
|
191
|
-
return [
|
|
186
|
+
const [t] = L(() => Ce(e));
|
|
187
|
+
return [Te(t), t];
|
|
192
188
|
}, st = (e) => ({
|
|
193
189
|
getItem: async (t) => {
|
|
194
190
|
const r = await e.getItem(t);
|
|
@@ -198,36 +194,38 @@ const ut = (e) => {
|
|
|
198
194
|
setItem: async (t, r) => {
|
|
199
195
|
await e.setItem(t, JSON.stringify(r));
|
|
200
196
|
},
|
|
201
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
202
197
|
removeItem: async (t) => {
|
|
203
198
|
},
|
|
204
199
|
clear: async () => {
|
|
205
200
|
}
|
|
206
|
-
}),
|
|
201
|
+
}), P = (e) => {
|
|
207
202
|
if (!(!e || typeof e != "object"))
|
|
208
203
|
return e;
|
|
209
|
-
},
|
|
204
|
+
}, ke = ({
|
|
210
205
|
adapter: e,
|
|
211
206
|
key: t
|
|
212
207
|
}) => ({
|
|
213
208
|
clear: async () => await e.removeItem(t),
|
|
214
209
|
removeItem: async (r) => {
|
|
215
|
-
const n = await e.getItem(t), { [r]: s, ...a } =
|
|
210
|
+
const n = await e.getItem(t), { [r]: s, ...a } = (
|
|
211
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
212
|
+
P(n) ?? {}
|
|
213
|
+
);
|
|
216
214
|
await e.setItem(t, a);
|
|
217
215
|
},
|
|
218
216
|
getItem: async (r) => {
|
|
219
|
-
const n = await e.getItem(t), s =
|
|
217
|
+
const n = await e.getItem(t), s = P(n) ?? {};
|
|
220
218
|
if (r in s)
|
|
221
219
|
return s[r];
|
|
222
220
|
},
|
|
223
221
|
setItem: async (r, n) => {
|
|
224
|
-
const s = await e.getItem(t), a =
|
|
222
|
+
const s = await e.getItem(t), a = P(s) ?? {};
|
|
225
223
|
await e.setItem(t, { ...a, [r]: n });
|
|
226
224
|
}
|
|
227
|
-
}),
|
|
225
|
+
}), _e = ({
|
|
228
226
|
key: e
|
|
229
|
-
} = {}) => e ?
|
|
230
|
-
adapter:
|
|
227
|
+
} = {}) => e ? ke({
|
|
228
|
+
adapter: _e(),
|
|
231
229
|
key: e
|
|
232
230
|
}) : {
|
|
233
231
|
clear: async () => {
|
|
@@ -244,8 +242,22 @@ const ut = (e) => {
|
|
|
244
242
|
setItem: async (t, r) => {
|
|
245
243
|
localStorage.setItem(t, JSON.stringify(r));
|
|
246
244
|
}
|
|
247
|
-
}
|
|
248
|
-
|
|
245
|
+
};
|
|
246
|
+
function je(e, t) {
|
|
247
|
+
if (e == null || t === void 0 || typeof e != "object" || typeof t != "object")
|
|
248
|
+
return e === t;
|
|
249
|
+
if (e.constructor !== (t == null ? void 0 : t.constructor))
|
|
250
|
+
return !1;
|
|
251
|
+
const r = Object.keys(e), n = Object.keys(t);
|
|
252
|
+
if (r.length !== n.length)
|
|
253
|
+
return !1;
|
|
254
|
+
for (const s of r)
|
|
255
|
+
if (!t.hasOwnProperty(s) || e[s] !== t[s])
|
|
256
|
+
return !1;
|
|
257
|
+
return !0;
|
|
258
|
+
}
|
|
259
|
+
const E = "__reactjrx", De = (e) => {
|
|
260
|
+
if (typeof e == "object" && e !== null && E in e && e[E] === E)
|
|
249
261
|
return e;
|
|
250
262
|
}, He = ({
|
|
251
263
|
adapter: e,
|
|
@@ -253,7 +265,7 @@ const ut = (e) => {
|
|
|
253
265
|
}) => {
|
|
254
266
|
const { signal: r, version: n } = t, a = {
|
|
255
267
|
value: r.getValue(),
|
|
256
|
-
[
|
|
268
|
+
[E]: E,
|
|
257
269
|
migrationVersion: n
|
|
258
270
|
};
|
|
259
271
|
return process.env.NODE_ENV === "development" && console.log(
|
|
@@ -261,8 +273,8 @@ const ut = (e) => {
|
|
|
261
273
|
"Persist value",
|
|
262
274
|
a,
|
|
263
275
|
`for signal ${r.config.key}`
|
|
264
|
-
),
|
|
265
|
-
|
|
276
|
+
), w(e.setItem(r.config.key, a)).pipe(
|
|
277
|
+
$((u) => (console.error(u), p(null)))
|
|
266
278
|
);
|
|
267
279
|
};
|
|
268
280
|
function Ke({
|
|
@@ -270,9 +282,9 @@ function Ke({
|
|
|
270
282
|
config: t
|
|
271
283
|
}) {
|
|
272
284
|
const { hydrate: r = ({ value: a }) => a, signal: n, version: s } = t;
|
|
273
|
-
return
|
|
274
|
-
|
|
275
|
-
const u =
|
|
285
|
+
return w(e.getItem(n.config.key)).pipe(
|
|
286
|
+
F((a) => {
|
|
287
|
+
const u = De(a);
|
|
276
288
|
if (!u) return p(a);
|
|
277
289
|
const i = typeof u.migrationVersion != "number", c = u.migrationVersion !== void 0 && s > u.migrationVersion;
|
|
278
290
|
if (i || c || u.value === void 0)
|
|
@@ -300,19 +312,19 @@ function ze({
|
|
|
300
312
|
})
|
|
301
313
|
)
|
|
302
314
|
)).pipe(
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
315
|
+
Y(t),
|
|
316
|
+
$((u) => (console.error("Unable to hydrate", u), Q)),
|
|
317
|
+
W()
|
|
306
318
|
), a = s.pipe(
|
|
307
|
-
|
|
308
|
-
() =>
|
|
319
|
+
F(
|
|
320
|
+
() => M(
|
|
309
321
|
...e.map(
|
|
310
322
|
(u) => u.signal.subject.pipe(
|
|
311
|
-
|
|
323
|
+
Se(500, ge, {
|
|
312
324
|
trailing: !0
|
|
313
325
|
}),
|
|
314
|
-
|
|
315
|
-
() =>
|
|
326
|
+
F(
|
|
327
|
+
() => w(
|
|
316
328
|
He({
|
|
317
329
|
adapter: r,
|
|
318
330
|
config: u
|
|
@@ -324,41 +336,28 @@ function ze({
|
|
|
324
336
|
)
|
|
325
337
|
)
|
|
326
338
|
);
|
|
327
|
-
return
|
|
339
|
+
return M(
|
|
328
340
|
s.pipe(
|
|
329
|
-
|
|
341
|
+
R(() => ({
|
|
330
342
|
type: "hydrated"
|
|
331
343
|
}))
|
|
332
344
|
),
|
|
333
345
|
a.pipe(
|
|
334
|
-
|
|
346
|
+
R(() => ({
|
|
335
347
|
type: "persisted"
|
|
336
348
|
}))
|
|
337
349
|
)
|
|
338
350
|
);
|
|
339
351
|
}
|
|
340
|
-
function Te(e, t) {
|
|
341
|
-
if (e == null || t === void 0 || typeof e != "object" || typeof t != "object")
|
|
342
|
-
return e === t;
|
|
343
|
-
if (e.constructor !== (t == null ? void 0 : t.constructor))
|
|
344
|
-
return !1;
|
|
345
|
-
const r = Object.keys(e), n = Object.keys(t);
|
|
346
|
-
if (r.length !== n.length)
|
|
347
|
-
return !1;
|
|
348
|
-
for (const s of r)
|
|
349
|
-
if (!t.hasOwnProperty(s) || e[s] !== t[s])
|
|
350
|
-
return !1;
|
|
351
|
-
return !0;
|
|
352
|
-
}
|
|
353
352
|
function ct({
|
|
354
353
|
entries: e = [],
|
|
355
354
|
onHydrated: t,
|
|
356
355
|
adapter: r
|
|
357
356
|
}) {
|
|
358
|
-
const n = h(t), s =
|
|
357
|
+
const n = h(t), s = z(r), a = z(e);
|
|
359
358
|
return te(
|
|
360
359
|
() => s.current.pipe(
|
|
361
|
-
|
|
360
|
+
F((i) => i ? M(
|
|
362
361
|
p({ type: "reset" }),
|
|
363
362
|
a.current.pipe(
|
|
364
363
|
he(
|
|
@@ -374,12 +373,12 @@ function ct({
|
|
|
374
373
|
)
|
|
375
374
|
) : p({ type: "reset" }))
|
|
376
375
|
).pipe(
|
|
377
|
-
|
|
376
|
+
Ie(
|
|
378
377
|
(i, c) => c.type === "reset" ? { isHydrated: !1 } : c.type === "hydrated" ? { isHydrated: !0 } : i,
|
|
379
378
|
{ isHydrated: !1 }
|
|
380
379
|
)
|
|
381
380
|
),
|
|
382
|
-
{ defaultValue: { isHydrated: !1 }, compareFn:
|
|
381
|
+
{ defaultValue: { isHydrated: !1 }, compareFn: je },
|
|
383
382
|
[s, a]
|
|
384
383
|
);
|
|
385
384
|
}
|
|
@@ -391,7 +390,7 @@ const at = () => {
|
|
|
391
390
|
});
|
|
392
391
|
return e;
|
|
393
392
|
}, Le = (e) => {
|
|
394
|
-
|
|
393
|
+
I(e, []);
|
|
395
394
|
}, ot = (e) => {
|
|
396
395
|
Le(() => {
|
|
397
396
|
e();
|
|
@@ -401,7 +400,7 @@ function Ue(e, t) {
|
|
|
401
400
|
return Math.min(e, t);
|
|
402
401
|
}
|
|
403
402
|
function Je(e, t) {
|
|
404
|
-
return
|
|
403
|
+
return 2 ** e * t;
|
|
405
404
|
}
|
|
406
405
|
function it(e) {
|
|
407
406
|
const {
|
|
@@ -409,59 +408,59 @@ function it(e) {
|
|
|
409
408
|
retryDelay: r,
|
|
410
409
|
retryAfterDelay: n,
|
|
411
410
|
retryAfter: s = () => p(!0)
|
|
412
|
-
} = e, a = typeof t != "function" ? t === !1 ? 0 : t === !0 ?
|
|
411
|
+
} = e, a = typeof t != "function" ? t === !1 ? 0 : t === !0 ? Number.POSITIVE_INFINITY : t ?? Number.POSITIVE_INFINITY : Number.POSITIVE_INFINITY, u = typeof t == "function" ? (
|
|
413
412
|
// ? (attempt: number, error: TError) => of(retry(attempt, error))
|
|
414
413
|
t
|
|
415
414
|
) : () => !0, i = typeof r == "number" ? r : 100, c = {
|
|
416
415
|
shouldRetry: u,
|
|
417
416
|
...e
|
|
418
417
|
}, {
|
|
419
|
-
maxInterval: o =
|
|
418
|
+
maxInterval: o = Number.POSITIVE_INFINITY,
|
|
420
419
|
resetOnSuccess: f = !1,
|
|
421
420
|
backoffDelay: l = Je
|
|
422
421
|
} = c;
|
|
423
|
-
return (m) =>
|
|
422
|
+
return (m) => A(() => {
|
|
424
423
|
let b = 0;
|
|
425
|
-
const
|
|
424
|
+
const y = (d, g) => d < a ? u(d, g) : !1;
|
|
426
425
|
return m.pipe(
|
|
427
|
-
|
|
426
|
+
H((d) => {
|
|
428
427
|
var V;
|
|
429
|
-
if (b++, !
|
|
430
|
-
const g = (V = e.caughtError) == null ? void 0 : V.call(e, b,
|
|
431
|
-
if (!g) throw
|
|
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;
|
|
432
431
|
return g.pipe(
|
|
433
|
-
|
|
434
|
-
(
|
|
435
|
-
p(
|
|
436
|
-
|
|
432
|
+
q(
|
|
433
|
+
(O) => M(
|
|
434
|
+
p(O),
|
|
435
|
+
x(() => d)
|
|
437
436
|
)
|
|
438
437
|
)
|
|
439
438
|
);
|
|
440
439
|
}),
|
|
441
|
-
|
|
442
|
-
|
|
440
|
+
$e((d) => d.pipe(
|
|
441
|
+
Ne((g) => {
|
|
443
442
|
const V = b - 1;
|
|
444
443
|
return s().pipe(
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
() =>
|
|
444
|
+
Me(),
|
|
445
|
+
q(
|
|
446
|
+
() => y(V, g) ? Ve(
|
|
448
447
|
Ue(
|
|
449
448
|
l(V, i),
|
|
450
449
|
o
|
|
451
450
|
)
|
|
452
451
|
).pipe(
|
|
453
|
-
|
|
454
|
-
) :
|
|
452
|
+
q((O) => n && !n(V, g) ? x(() => g) : p(O))
|
|
453
|
+
) : x(() => g)
|
|
455
454
|
)
|
|
456
455
|
);
|
|
457
456
|
})
|
|
458
457
|
)),
|
|
459
|
-
|
|
458
|
+
H((d) => {
|
|
460
459
|
if (e.catchError)
|
|
461
|
-
return e.catchError(b,
|
|
462
|
-
throw
|
|
460
|
+
return e.catchError(b, d);
|
|
461
|
+
throw d;
|
|
463
462
|
}),
|
|
464
|
-
|
|
463
|
+
Oe(() => {
|
|
465
464
|
f && (b = 0);
|
|
466
465
|
})
|
|
467
466
|
);
|
|
@@ -470,10 +469,10 @@ function it(e) {
|
|
|
470
469
|
function lt(e) {
|
|
471
470
|
return e != null;
|
|
472
471
|
}
|
|
473
|
-
const ft = (e, t) => e.length === t.length && e.every((r, n) => r === t[n]),
|
|
474
|
-
class
|
|
472
|
+
const ft = (e, t) => e.length === t.length && e.every((r, n) => r === t[n]), dt = typeof window > "u" || "Deno" in window;
|
|
473
|
+
class Ye {
|
|
475
474
|
constructor() {
|
|
476
|
-
|
|
475
|
+
k(this, "queryMap", /* @__PURE__ */ new Map());
|
|
477
476
|
}
|
|
478
477
|
getQuery(t) {
|
|
479
478
|
return this.queryMap.get(t);
|
|
@@ -486,8 +485,8 @@ class Ge {
|
|
|
486
485
|
* - unmounting the component
|
|
487
486
|
* @see https://tanstack.com/query/latest/docs/framework/react/guides/query-cancellation
|
|
488
487
|
*/
|
|
489
|
-
X(
|
|
490
|
-
|
|
488
|
+
X(ve(n, "abort")),
|
|
489
|
+
W()
|
|
491
490
|
), u = {
|
|
492
491
|
query$: a,
|
|
493
492
|
signal: n,
|
|
@@ -517,18 +516,18 @@ class Ge {
|
|
|
517
516
|
});
|
|
518
517
|
}
|
|
519
518
|
}
|
|
520
|
-
const ue = le(void 0),
|
|
519
|
+
const ue = le(void 0), yt = fe(
|
|
521
520
|
({
|
|
522
521
|
children: e,
|
|
523
522
|
client: t
|
|
524
523
|
}) => {
|
|
525
|
-
const [r] =
|
|
526
|
-
return
|
|
524
|
+
const [r] = L(() => t ?? new Ye());
|
|
525
|
+
return I(() => () => {
|
|
527
526
|
r.destroy();
|
|
528
|
-
}, [r]), /* @__PURE__ */
|
|
527
|
+
}, [r]), /* @__PURE__ */ Pe(ue.Provider, { value: r, children: e });
|
|
529
528
|
}
|
|
530
|
-
),
|
|
531
|
-
const e =
|
|
529
|
+
), Ge = () => {
|
|
530
|
+
const e = de(ue);
|
|
532
531
|
if (!e)
|
|
533
532
|
throw new Error(
|
|
534
533
|
"useReactJrxQueryClient must be used within a ReactJrxQueryProvider"
|
|
@@ -536,12 +535,12 @@ const ue = le(void 0), dt = fe(
|
|
|
536
535
|
return e;
|
|
537
536
|
};
|
|
538
537
|
function mt(e, t) {
|
|
539
|
-
const r = ee(t), n =
|
|
540
|
-
return
|
|
538
|
+
const r = ee(t), n = Ge();
|
|
539
|
+
return xe(
|
|
541
540
|
{
|
|
542
541
|
...e,
|
|
543
542
|
queryFn: (u) => new Promise((i, c) => {
|
|
544
|
-
const o = () =>
|
|
543
|
+
const o = () => A(
|
|
545
544
|
() => typeof e.queryFn == "function" ? e.queryFn(u) : e.queryFn
|
|
546
545
|
), f = B(u.queryKey), l = n.getQuery(f) ?? n.setQuery(u.queryKey, o(), u.signal);
|
|
547
546
|
l.query$.pipe(
|
|
@@ -551,7 +550,7 @@ function mt(e, t) {
|
|
|
551
550
|
* keep the last value. This is unfortunate but it's the best we can do
|
|
552
551
|
* for now.
|
|
553
552
|
*/
|
|
554
|
-
|
|
553
|
+
Ee(1)
|
|
555
554
|
).subscribe({
|
|
556
555
|
error: (b) => c(b),
|
|
557
556
|
complete: () => {
|
|
@@ -577,24 +576,24 @@ function mt(e, t) {
|
|
|
577
576
|
);
|
|
578
577
|
}
|
|
579
578
|
function se(e, t) {
|
|
580
|
-
const r =
|
|
579
|
+
const r = T({
|
|
581
580
|
status: "idle",
|
|
582
581
|
isPending: !1,
|
|
583
582
|
isError: !1,
|
|
584
583
|
isSuccess: !1,
|
|
585
584
|
isIdle: !0
|
|
586
|
-
}), n =
|
|
585
|
+
}), n = qe(
|
|
587
586
|
{
|
|
588
587
|
...e,
|
|
589
588
|
mutationFn: (o) => {
|
|
590
589
|
let f;
|
|
591
590
|
return new Promise((l, m) => {
|
|
592
591
|
(typeof e.mutationFn == "function" ? e.mutationFn(o) : e.mutationFn).pipe(Z(1)).subscribe({
|
|
593
|
-
next: (
|
|
594
|
-
f = { value:
|
|
592
|
+
next: (y) => {
|
|
593
|
+
f = { value: y };
|
|
595
594
|
},
|
|
596
|
-
error: (
|
|
597
|
-
m(
|
|
595
|
+
error: (y) => {
|
|
596
|
+
m(y);
|
|
598
597
|
},
|
|
599
598
|
complete: () => {
|
|
600
599
|
if (f === void 0)
|
|
@@ -607,21 +606,27 @@ function se(e, t) {
|
|
|
607
606
|
},
|
|
608
607
|
t
|
|
609
608
|
), { status: s, isPending: a, isError: u, isSuccess: i, isIdle: c } = n;
|
|
610
|
-
return
|
|
611
|
-
r.current.next({
|
|
609
|
+
return I(() => {
|
|
610
|
+
r.current.next({
|
|
611
|
+
status: s,
|
|
612
|
+
isPending: a,
|
|
613
|
+
isError: u,
|
|
614
|
+
isSuccess: i,
|
|
615
|
+
isIdle: c
|
|
616
|
+
});
|
|
612
617
|
}, [s, a, u, i, c, r]), { ...n, state$: r.current };
|
|
613
618
|
}
|
|
614
619
|
function pt(e, t) {
|
|
615
|
-
const [r, n] =
|
|
620
|
+
const [r, n] = Ae(), { mutate: s, mutateAsync: a, ...u } = se(
|
|
616
621
|
{
|
|
617
622
|
...e,
|
|
618
|
-
mutationFn: (o) => (typeof e.mutationFn == "function" ? e.mutationFn(o) : e.mutationFn).pipe(X(r),
|
|
623
|
+
mutationFn: (o) => (typeof e.mutationFn == "function" ? e.mutationFn(o) : e.mutationFn).pipe(X(r), we(null))
|
|
619
624
|
},
|
|
620
625
|
t
|
|
621
|
-
), i =
|
|
626
|
+
), i = S(
|
|
622
627
|
(o) => (n(), s(o)),
|
|
623
628
|
[s, n]
|
|
624
|
-
), c =
|
|
629
|
+
), c = S(
|
|
625
630
|
(o) => (n(), a(o)),
|
|
626
631
|
[a, n]
|
|
627
632
|
);
|
|
@@ -650,29 +655,29 @@ function bt(e, t) {
|
|
|
650
655
|
mutationFn: ({ ready$: c, variables: o }) => {
|
|
651
656
|
const f = typeof e.mutationFn == "function" ? e.mutationFn(o) : e.mutationFn;
|
|
652
657
|
return c.pipe(
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
658
|
+
Fe((l) => l),
|
|
659
|
+
G(),
|
|
660
|
+
F(() => f)
|
|
656
661
|
);
|
|
657
662
|
}
|
|
658
663
|
},
|
|
659
664
|
t
|
|
660
|
-
), u =
|
|
665
|
+
), u = S(
|
|
661
666
|
async (c) => {
|
|
662
667
|
const o = r.getMutationCache().findAll({
|
|
663
668
|
mutationKey: n,
|
|
664
669
|
exact: !0
|
|
665
|
-
}), f = new
|
|
670
|
+
}), f = new N(!1), l = s({ variables: c, ready$: f });
|
|
666
671
|
return await Promise.all(
|
|
667
|
-
o.map((m) => m.continue().catch(
|
|
672
|
+
o.map((m) => m.continue().catch(D))
|
|
668
673
|
), f.next(!0), await l.finally(() => {
|
|
669
674
|
f.complete();
|
|
670
675
|
});
|
|
671
676
|
},
|
|
672
677
|
[s, r, n]
|
|
673
|
-
), i =
|
|
678
|
+
), i = S(
|
|
674
679
|
(c) => {
|
|
675
|
-
u(c).catch(
|
|
680
|
+
u(c).catch(D);
|
|
676
681
|
},
|
|
677
682
|
[u]
|
|
678
683
|
);
|
|
@@ -680,36 +685,36 @@ function bt(e, t) {
|
|
|
680
685
|
}
|
|
681
686
|
export {
|
|
682
687
|
ue as Context,
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
688
|
+
Ye as QueryClient$,
|
|
689
|
+
yt as QueryClientProvider$,
|
|
690
|
+
Qe as SIGNAL_RESET,
|
|
686
691
|
ft as arrayEqual,
|
|
687
|
-
|
|
692
|
+
_e as createLocalStorageAdapter,
|
|
688
693
|
st as createLocalforageAdapter,
|
|
689
694
|
Je as exponentialBackoffDelay,
|
|
690
695
|
Ue as getDelay,
|
|
691
696
|
lt as isDefined,
|
|
692
|
-
|
|
693
|
-
|
|
697
|
+
K as isPromiseLike,
|
|
698
|
+
dt as isServer,
|
|
694
699
|
it as retryBackoff,
|
|
695
|
-
|
|
696
|
-
|
|
700
|
+
Ce as signal,
|
|
701
|
+
T as useBehaviorSubject,
|
|
697
702
|
bt as useContactMutation$,
|
|
698
703
|
Le as useEffectOnce,
|
|
699
|
-
|
|
704
|
+
z as useLiveBehaviorSubject,
|
|
700
705
|
h as useLiveRef,
|
|
701
706
|
ot as useMount,
|
|
702
707
|
se as useMutation$,
|
|
703
|
-
|
|
708
|
+
Ae as useObservableCallback,
|
|
704
709
|
rt as useObservableState,
|
|
705
710
|
te as useObserve,
|
|
706
711
|
ct as usePersistSignals,
|
|
707
712
|
mt as useQuery$,
|
|
708
|
-
|
|
713
|
+
Ge as useQueryClient$,
|
|
709
714
|
ut as useSignal,
|
|
710
|
-
|
|
715
|
+
Te as useSignalValue,
|
|
711
716
|
ne as useSubject,
|
|
712
|
-
|
|
717
|
+
Re as useSubscribe,
|
|
713
718
|
nt as useSubscribeEffect,
|
|
714
719
|
pt as useSwitchMutation$,
|
|
715
720
|
at as useUnmountObservable
|