reactjrx 1.92.1 → 1.93.1
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.js +698 -704
- package/dist/lib/binding/useObserve.d.ts +1 -1
- package/dist/lib/binding/useSubscribe.d.ts +1 -1
- package/dist/lib/binding/useSubscribeEffect.d.ts +1 -1
- package/dist/lib/queries/client/QueryClient.d.ts +11 -11
- package/dist/lib/queries/client/keys/hashKey.d.ts +1 -1
- package/dist/lib/queries/client/mutations/cache/MutationCache.d.ts +5 -5
- package/dist/lib/queries/client/mutations/cache/types.d.ts +2 -2
- package/dist/lib/queries/client/mutations/mutation/Mutation.d.ts +3 -3
- package/dist/lib/queries/client/mutations/mutation/observeUntilFinished.d.ts +1 -1
- package/dist/lib/queries/client/mutations/mutation/types.d.ts +3 -3
- package/dist/lib/queries/client/mutations/observers/MutationObserver.d.ts +6 -6
- package/dist/lib/queries/client/mutations/observers/types.d.ts +2 -2
- package/dist/lib/queries/client/mutations/runner/MutationRunner.d.ts +4 -4
- package/dist/lib/queries/client/mutations/types.d.ts +3 -3
- package/dist/lib/queries/client/mutations/utils/distinctUntilStateChanged.d.ts +1 -1
- package/dist/lib/queries/client/queries/cache/QueryCache.d.ts +7 -7
- package/dist/lib/queries/client/queries/cache/types.d.ts +4 -4
- package/dist/lib/queries/client/queries/observer/QueryObserver.d.ts +7 -7
- package/dist/lib/queries/client/queries/observer/queryStateHelpers.d.ts +2 -2
- package/dist/lib/queries/client/queries/observer/types.d.ts +4 -4
- package/dist/lib/queries/client/queries/query/Query.d.ts +7 -7
- package/dist/lib/queries/client/queries/query/delayOnNetworkMode.d.ts +2 -2
- package/dist/lib/queries/client/queries/query/execution/executeQuery.d.ts +3 -3
- package/dist/lib/queries/client/queries/query/getDefaultState.d.ts +2 -2
- package/dist/lib/queries/client/queries/query/operators.d.ts +2 -2
- package/dist/lib/queries/client/queries/query/state/whenNewData.d.ts +1 -1
- package/dist/lib/queries/client/queries/query/types.d.ts +4 -4
- package/dist/lib/queries/client/queries/types.d.ts +6 -6
- package/dist/lib/queries/client/queries/utils.d.ts +2 -2
- package/dist/lib/queries/client/tests/utils.d.ts +2 -2
- package/dist/lib/queries/client/types.d.ts +2 -2
- package/dist/lib/queries/react/QueryClientProvider.d.ts +1 -1
- package/dist/lib/queries/react/mutations/types.d.ts +2 -2
- package/dist/lib/queries/react/mutations/useIsMutating.d.ts +1 -1
- package/dist/lib/queries/react/mutations/useMutation.d.ts +2 -2
- package/dist/lib/queries/react/mutations/useMutationState.d.ts +3 -3
- package/dist/lib/queries/react/queries/errorBoundaryUtils.d.ts +4 -4
- package/dist/lib/queries/react/queries/queryOptions.d.ts +3 -3
- package/dist/lib/queries/react/queries/types.d.ts +3 -3
- package/dist/lib/queries/react/queries/useBaseQuery.d.ts +4 -4
- package/dist/lib/queries/react/queries/useForeverQuery.d.ts +4 -4
- package/dist/lib/queries/react/queries/useIsFetching.d.ts +1 -1
- package/dist/lib/queries/react/queries/useQuery.d.ts +4 -4
- package/dist/lib/state/persistance/types.d.ts +1 -1
- package/dist/lib/state/signal.d.ts +1 -1
- package/dist/tests/utils.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
if (!e.has(s))
|
|
5
|
-
throw TypeError("Cannot " + t);
|
|
1
|
+
var Yt = Object.defineProperty;
|
|
2
|
+
var yt = (s) => {
|
|
3
|
+
throw TypeError(s);
|
|
6
4
|
};
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
e instanceof WeakSet ? e.add(s) : e.set(s, t);
|
|
11
|
-
}, M = (s, e, t, r) => (yt(s, e, "write to private field"), r ? r.call(s, t) : e.set(s, t), t);
|
|
5
|
+
var Bt = (s, e, t) => e in s ? Yt(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
6
|
+
var g = (s, e, t) => Bt(s, typeof e != "symbol" ? e + "" : e, t), bt = (s, e, t) => e.has(s) || yt("Cannot " + t);
|
|
7
|
+
var a = (s, e, t) => (bt(s, e, "read from private field"), t ? t.call(s) : e.get(s)), w = (s, e, t) => e.has(s) ? yt("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(s) : e.set(s, t), A = (s, e, t, r) => (bt(s, e, "write to private field"), r ? r.call(s, t) : e.set(s, t), t);
|
|
12
8
|
import * as Ge from "react";
|
|
13
|
-
import { useRef as me, useMemo as ut, useCallback as
|
|
14
|
-
import { distinctUntilChanged as
|
|
15
|
-
import { catchError as
|
|
16
|
-
import { jsxs as
|
|
17
|
-
const
|
|
9
|
+
import { useRef as me, useMemo as ut, useCallback as de, useSyncExternalStore as Xt, useEffect as Y, createContext as Zt, memo as es, useContext as ts, useState as jt } from "react";
|
|
10
|
+
import { distinctUntilChanged as U, tap as R, catchError as J, EMPTY as B, isObservable as gt, from as Se, of as v, defer as Ae, Subject as I, BehaviorSubject as X, skip as at, first as Je, map as b, switchMap as j, zip as ss, filter as O, merge as C, throttleTime as rs, asyncScheduler as ns, throwError as Oe, timer as Qe, Observable as is, takeWhile as Ye, concatMap as us, last as Ke, mergeMap as q, takeUntil as ne, identity as Mt, shareReplay as Ue, ignoreElements as ie, scan as Be, fromEvent as Ne, noop as N, startWith as he, pairwise as At, NEVER as qe, delay as ot, interval as as, withLatestFrom as mt, retry as os, iif as cs, share as ue, isEmpty as ls, concat as Te, toArray as ke, take as He, combineLatest as hs, endWith as ds, lastValueFrom as fs } from "rxjs";
|
|
11
|
+
import { catchError as St, mergeMap as tt, retryWhen as ps, concatMap as ys, first as bs, tap as Qt } from "rxjs/operators";
|
|
12
|
+
import { jsxs as gs, jsx as ms } from "react/jsx-runtime";
|
|
13
|
+
const H = (s) => {
|
|
18
14
|
const e = me(s);
|
|
19
15
|
return ut(() => {
|
|
20
16
|
e.current = s;
|
|
21
17
|
}, [s]), e;
|
|
22
18
|
};
|
|
23
|
-
function
|
|
19
|
+
function Ss(s, e) {
|
|
24
20
|
return typeof s == "string" && s === e || typeof s == "number" && s === e || typeof s == "boolean" && s === e || typeof s == "symbol" && s === e || typeof s == "bigint" && s === e || typeof s > "u" && s === e || s === null && s === e;
|
|
25
21
|
}
|
|
26
22
|
function Xe(s, e, t) {
|
|
@@ -29,50 +25,49 @@ function Xe(s, e, t) {
|
|
|
29
25
|
unsubscribeOnUnmount: !0
|
|
30
26
|
}, n = !t && Array.isArray(e) ? e : typeof s == "function" ? t ?? [] : [s], u = me(
|
|
31
27
|
"getValue" in s && typeof s.getValue == "function" ? s.getValue() : r.defaultValue
|
|
32
|
-
), i =
|
|
28
|
+
), i = H(s), c = H(r), l = de(
|
|
33
29
|
(p) => {
|
|
34
|
-
const
|
|
30
|
+
const F = i.current, f = (typeof F == "function" ? F : () => F)().pipe(
|
|
35
31
|
/**
|
|
36
32
|
* @important
|
|
37
33
|
* We only check primitives because underlying subscription might
|
|
38
34
|
* be using objects and keeping same reference but pushing new
|
|
39
35
|
* properties values
|
|
40
36
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
u.current =
|
|
37
|
+
U(Ss),
|
|
38
|
+
R((y) => {
|
|
39
|
+
u.current = y;
|
|
44
40
|
}),
|
|
45
|
-
|
|
41
|
+
J((y) => (console.error(y), B))
|
|
46
42
|
).subscribe(p);
|
|
47
43
|
return () => {
|
|
48
|
-
c.current.unsubscribeOnUnmount !== !1 &&
|
|
44
|
+
c.current.unsubscribeOnUnmount !== !1 && f.unsubscribe();
|
|
49
45
|
};
|
|
50
46
|
},
|
|
51
47
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
52
48
|
[...n]
|
|
53
|
-
), h =
|
|
54
|
-
return
|
|
49
|
+
), h = de(() => u.current, []);
|
|
50
|
+
return Xt(l, h, h);
|
|
55
51
|
}
|
|
56
|
-
function
|
|
52
|
+
function vt(s) {
|
|
57
53
|
return s instanceof Promise || s && typeof s.then == "function" && typeof s.catch == "function";
|
|
58
54
|
}
|
|
59
|
-
function
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
if (
|
|
63
|
-
return Se(s);
|
|
64
|
-
if (typeof s != "function")
|
|
65
|
-
return v(s);
|
|
55
|
+
function V(s) {
|
|
56
|
+
if (gt(s)) return s;
|
|
57
|
+
if (vt(s)) return Se(s);
|
|
58
|
+
if (typeof s != "function") return v(s);
|
|
66
59
|
const e = s;
|
|
67
60
|
return Ae(() => {
|
|
68
61
|
const t = e();
|
|
69
|
-
return
|
|
62
|
+
return vt(t) ? Se(t) : gt(t) ? t : v(t);
|
|
70
63
|
});
|
|
71
64
|
}
|
|
72
|
-
function
|
|
73
|
-
const t =
|
|
74
|
-
|
|
75
|
-
const r =
|
|
65
|
+
function Ut(s, e = []) {
|
|
66
|
+
const t = H(s);
|
|
67
|
+
Y(() => {
|
|
68
|
+
const r = V(t.current).pipe(
|
|
69
|
+
J((n) => (console.error(n), B))
|
|
70
|
+
).subscribe();
|
|
76
71
|
return () => {
|
|
77
72
|
r.unsubscribe();
|
|
78
73
|
};
|
|
@@ -84,23 +79,23 @@ function Qt(s, e = []) {
|
|
|
84
79
|
}
|
|
85
80
|
const Ze = (s) => {
|
|
86
81
|
const e = me();
|
|
87
|
-
return e.current || (e.current = s()),
|
|
82
|
+
return e.current || (e.current = s()), Y(() => {
|
|
88
83
|
process.env.NODE_ENV;
|
|
89
84
|
}, []), e;
|
|
90
|
-
},
|
|
85
|
+
}, Vt = ({
|
|
91
86
|
onBeforeComplete: s,
|
|
92
87
|
completeOnUnmount: e = !0
|
|
93
88
|
} = {}) => {
|
|
94
|
-
const t = Ze(() => new I()), r = me(!1), n =
|
|
95
|
-
return
|
|
89
|
+
const t = Ze(() => new I()), r = me(!1), n = H(s), u = H(e);
|
|
90
|
+
return Y(() => (r.current && (t.current = new I(), r.current = !1), () => {
|
|
96
91
|
if (!u.current) {
|
|
97
92
|
r.current = !0;
|
|
98
93
|
return;
|
|
99
94
|
}
|
|
100
95
|
r.current || (n.current != null && n.current(), t.current.complete(), r.current = !0);
|
|
101
96
|
}), [u, n, t]), t;
|
|
102
|
-
},
|
|
103
|
-
const s =
|
|
97
|
+
}, br = () => {
|
|
98
|
+
const s = Vt(), e = H(s.current.asObservable()), t = de(
|
|
104
99
|
(r) => {
|
|
105
100
|
s.current.next(r);
|
|
106
101
|
},
|
|
@@ -109,12 +104,12 @@ const Ze = (s) => {
|
|
|
109
104
|
);
|
|
110
105
|
return [e.current, t];
|
|
111
106
|
}, It = (s) => {
|
|
112
|
-
const e = Ze(() => new
|
|
113
|
-
return
|
|
107
|
+
const e = Ze(() => new X(s)), t = me(!1), r = me(s);
|
|
108
|
+
return Y(() => (t.current && (e.current = new X(r.current), t.current = !1), () => {
|
|
114
109
|
t.current || (e.current.complete(), t.current = !0);
|
|
115
110
|
}), [e]), e;
|
|
116
|
-
},
|
|
117
|
-
const e = It(s), t =
|
|
111
|
+
}, gr = (s) => {
|
|
112
|
+
const e = It(s), t = H(e.current.asObservable()), r = de(
|
|
118
113
|
(n) => {
|
|
119
114
|
e.current.next(n);
|
|
120
115
|
},
|
|
@@ -122,20 +117,19 @@ const Ze = (s) => {
|
|
|
122
117
|
[e.current]
|
|
123
118
|
);
|
|
124
119
|
return [t.current, r, e.current.getValue()];
|
|
125
|
-
},
|
|
126
|
-
function
|
|
120
|
+
}, vs = Symbol("SIGNAL_RESET");
|
|
121
|
+
function mr(s = {}) {
|
|
127
122
|
const e = {
|
|
128
123
|
default: s.default,
|
|
129
124
|
key: s.key
|
|
130
|
-
}, { default: t } = e ?? {}, r = new
|
|
125
|
+
}, { default: t } = e ?? {}, r = new X(t), n = (i) => {
|
|
131
126
|
if (typeof i == "function") {
|
|
132
127
|
const c = i(r.getValue());
|
|
133
|
-
if (c === r.getValue())
|
|
134
|
-
return;
|
|
128
|
+
if (c === r.getValue()) return;
|
|
135
129
|
r.next(c);
|
|
136
130
|
return;
|
|
137
131
|
}
|
|
138
|
-
if (i ===
|
|
132
|
+
if (i === vs) {
|
|
139
133
|
r.next(t ?? void 0);
|
|
140
134
|
return;
|
|
141
135
|
}
|
|
@@ -160,12 +154,12 @@ function br(s = {}) {
|
|
|
160
154
|
subject: r
|
|
161
155
|
};
|
|
162
156
|
}
|
|
163
|
-
function
|
|
157
|
+
function Sr(s, e) {
|
|
164
158
|
const r = e ?? (() => s.getValue());
|
|
165
159
|
return Xe(
|
|
166
160
|
() => s.subject.pipe(
|
|
167
|
-
|
|
168
|
-
|
|
161
|
+
b((u) => r(u)),
|
|
162
|
+
U()
|
|
169
163
|
),
|
|
170
164
|
{
|
|
171
165
|
defaultValue: r(s.getValue())
|
|
@@ -173,7 +167,7 @@ function gr(s, e) {
|
|
|
173
167
|
[]
|
|
174
168
|
);
|
|
175
169
|
}
|
|
176
|
-
const
|
|
170
|
+
const vr = (s) => ({
|
|
177
171
|
getItem: async (e) => {
|
|
178
172
|
const t = await s.getItem(e);
|
|
179
173
|
if (t)
|
|
@@ -189,7 +183,7 @@ const mr = (s) => ({
|
|
|
189
183
|
}), st = (s) => {
|
|
190
184
|
if (!(!s || typeof s != "object"))
|
|
191
185
|
return s;
|
|
192
|
-
},
|
|
186
|
+
}, Os = ({
|
|
193
187
|
adapter: s,
|
|
194
188
|
key: e
|
|
195
189
|
}) => ({
|
|
@@ -207,10 +201,10 @@ const mr = (s) => ({
|
|
|
207
201
|
const n = await s.getItem(e), u = st(n) ?? {};
|
|
208
202
|
await s.setItem(e, { ...u, [t]: r });
|
|
209
203
|
}
|
|
210
|
-
}),
|
|
204
|
+
}), $s = ({
|
|
211
205
|
key: s
|
|
212
|
-
} = {}) => s ?
|
|
213
|
-
adapter:
|
|
206
|
+
} = {}) => s ? Os({
|
|
207
|
+
adapter: $s(),
|
|
214
208
|
key: s
|
|
215
209
|
}) : {
|
|
216
210
|
clear: async () => {
|
|
@@ -227,19 +221,19 @@ const mr = (s) => ({
|
|
|
227
221
|
setItem: async (e, t) => {
|
|
228
222
|
localStorage.setItem(e, JSON.stringify(t));
|
|
229
223
|
}
|
|
230
|
-
}, $e = "__reactjrx",
|
|
224
|
+
}, $e = "__reactjrx", ws = (s) => {
|
|
231
225
|
if (typeof s == "object" && s !== null && $e in s && s[$e] === $e)
|
|
232
226
|
return s;
|
|
233
227
|
};
|
|
234
228
|
function rt(s) {
|
|
235
229
|
return s != null;
|
|
236
230
|
}
|
|
237
|
-
const
|
|
231
|
+
const Ot = (s) => {
|
|
238
232
|
const e = It(s);
|
|
239
|
-
return
|
|
233
|
+
return Y(() => {
|
|
240
234
|
e.current.next(s);
|
|
241
235
|
}, [s, e]), e;
|
|
242
|
-
},
|
|
236
|
+
}, Cs = ({
|
|
243
237
|
adapter: s,
|
|
244
238
|
config: e
|
|
245
239
|
}) => {
|
|
@@ -249,19 +243,18 @@ const vt = (s) => {
|
|
|
249
243
|
migrationVersion: r
|
|
250
244
|
};
|
|
251
245
|
return Se(s.setItem(t.config.key, u)).pipe(
|
|
252
|
-
|
|
246
|
+
J((i) => (console.error(i), v(null)))
|
|
253
247
|
);
|
|
254
248
|
};
|
|
255
|
-
function
|
|
249
|
+
function Fs({
|
|
256
250
|
adapter: s,
|
|
257
251
|
config: e
|
|
258
252
|
}) {
|
|
259
253
|
const { hydrate: t = ({ value: u }) => u, signal: r, version: n } = e;
|
|
260
254
|
return Se(s.getItem(r.config.key)).pipe(
|
|
261
|
-
|
|
262
|
-
const i =
|
|
263
|
-
if (!i)
|
|
264
|
-
return v(u);
|
|
255
|
+
j((u) => {
|
|
256
|
+
const i = ws(u);
|
|
257
|
+
if (!i) return v(u);
|
|
265
258
|
if (i.migrationVersion !== void 0 && n > i.migrationVersion || i.value === void 0)
|
|
266
259
|
return v(u);
|
|
267
260
|
const c = i.value;
|
|
@@ -269,48 +262,48 @@ function ws({
|
|
|
269
262
|
})
|
|
270
263
|
);
|
|
271
264
|
}
|
|
272
|
-
function
|
|
265
|
+
function Or({
|
|
273
266
|
entries: s = [],
|
|
274
267
|
onReady: e,
|
|
275
268
|
adapter: t
|
|
276
269
|
}) {
|
|
277
|
-
const r =
|
|
270
|
+
const r = H(s), n = H(e), u = Ot(t), i = Xe(
|
|
278
271
|
() => {
|
|
279
272
|
const l = r.current;
|
|
280
273
|
return u.current.pipe(
|
|
281
|
-
|
|
274
|
+
j((h) => (l.length === 0 || !h ? v(!0) : ss(
|
|
282
275
|
...l.map(
|
|
283
|
-
(p) =>
|
|
276
|
+
(p) => Fs({
|
|
284
277
|
adapter: h,
|
|
285
278
|
config: p
|
|
286
279
|
})
|
|
287
280
|
)
|
|
288
|
-
).pipe(
|
|
289
|
-
|
|
281
|
+
).pipe(b(() => !0))).pipe(
|
|
282
|
+
R(() => {
|
|
290
283
|
n.current != null && n.current();
|
|
291
284
|
}),
|
|
292
|
-
|
|
285
|
+
J((p) => (console.error("Unable to hydrate", p), B))
|
|
293
286
|
))
|
|
294
287
|
);
|
|
295
288
|
},
|
|
296
289
|
{ defaultValue: !1 },
|
|
297
290
|
[u, r]
|
|
298
|
-
), c =
|
|
299
|
-
return
|
|
291
|
+
), c = Ot(i);
|
|
292
|
+
return Ut(
|
|
300
293
|
() => c.current.pipe(
|
|
301
294
|
O((l) => l),
|
|
302
|
-
|
|
295
|
+
j(() => u.current),
|
|
303
296
|
O(rt),
|
|
304
|
-
|
|
305
|
-
(l) =>
|
|
297
|
+
j(
|
|
298
|
+
(l) => C(
|
|
306
299
|
...r.current.map(
|
|
307
300
|
(h) => h.signal.subject.pipe(
|
|
308
|
-
|
|
301
|
+
rs(500, ns, {
|
|
309
302
|
trailing: !0
|
|
310
303
|
}),
|
|
311
|
-
|
|
304
|
+
j(
|
|
312
305
|
() => Se(
|
|
313
|
-
|
|
306
|
+
Cs({
|
|
314
307
|
adapter: l,
|
|
315
308
|
config: h
|
|
316
309
|
})
|
|
@@ -324,21 +317,21 @@ function Sr({
|
|
|
324
317
|
[c, u]
|
|
325
318
|
), { isHydrated: i };
|
|
326
319
|
}
|
|
327
|
-
const
|
|
328
|
-
const s =
|
|
320
|
+
const $r = () => {
|
|
321
|
+
const s = Vt({
|
|
329
322
|
onBeforeComplete: () => {
|
|
330
323
|
s.current.next();
|
|
331
324
|
}
|
|
332
325
|
});
|
|
333
326
|
return s;
|
|
334
327
|
};
|
|
335
|
-
function
|
|
328
|
+
function Es(s, e) {
|
|
336
329
|
return Math.min(s, e);
|
|
337
330
|
}
|
|
338
|
-
function
|
|
331
|
+
function xs(s, e) {
|
|
339
332
|
return Math.pow(2, s) * e;
|
|
340
333
|
}
|
|
341
|
-
function
|
|
334
|
+
function Pt(s) {
|
|
342
335
|
const {
|
|
343
336
|
retry: e,
|
|
344
337
|
retryDelay: t,
|
|
@@ -353,75 +346,73 @@ function Vt(s) {
|
|
|
353
346
|
}, {
|
|
354
347
|
maxInterval: h = 1 / 0,
|
|
355
348
|
resetOnSuccess: o = !1,
|
|
356
|
-
backoffDelay: p =
|
|
349
|
+
backoffDelay: p = xs
|
|
357
350
|
} = l;
|
|
358
|
-
return (
|
|
359
|
-
let
|
|
360
|
-
const
|
|
361
|
-
return
|
|
362
|
-
|
|
363
|
-
var
|
|
364
|
-
if (
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
throw b;
|
|
369
|
-
return $.pipe(
|
|
351
|
+
return (F) => Ae(() => {
|
|
352
|
+
let d = 0;
|
|
353
|
+
const f = (y, x) => y < u ? i(y, x) : !1;
|
|
354
|
+
return F.pipe(
|
|
355
|
+
St((y) => {
|
|
356
|
+
var E;
|
|
357
|
+
if (d++, !f(d - 1, y)) throw y;
|
|
358
|
+
const x = (E = s.caughtError) == null ? void 0 : E.call(s, d, y);
|
|
359
|
+
if (!x) throw y;
|
|
360
|
+
return x.pipe(
|
|
370
361
|
tt(
|
|
371
|
-
(
|
|
372
|
-
v(
|
|
373
|
-
Oe(() =>
|
|
362
|
+
($) => C(
|
|
363
|
+
v($),
|
|
364
|
+
Oe(() => y)
|
|
374
365
|
)
|
|
375
366
|
)
|
|
376
367
|
);
|
|
377
368
|
}),
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
const
|
|
369
|
+
ps((y) => y.pipe(
|
|
370
|
+
ys((x) => {
|
|
371
|
+
const E = d - 1;
|
|
381
372
|
return n().pipe(
|
|
382
|
-
|
|
373
|
+
bs(),
|
|
383
374
|
tt(
|
|
384
|
-
() =>
|
|
385
|
-
|
|
386
|
-
p(
|
|
375
|
+
() => f(E, x) ? Qe(
|
|
376
|
+
Es(
|
|
377
|
+
p(E, c),
|
|
387
378
|
h
|
|
388
379
|
)
|
|
389
380
|
).pipe(
|
|
390
|
-
tt((
|
|
391
|
-
) : Oe(() =>
|
|
381
|
+
tt(($) => r && !r(E, x) ? Oe(() => x) : v($))
|
|
382
|
+
) : Oe(() => x)
|
|
392
383
|
)
|
|
393
384
|
);
|
|
394
385
|
})
|
|
395
386
|
)),
|
|
396
|
-
|
|
387
|
+
St((y) => {
|
|
397
388
|
if (s.catchError)
|
|
398
|
-
return s.catchError(
|
|
399
|
-
throw
|
|
389
|
+
return s.catchError(d, y);
|
|
390
|
+
throw y;
|
|
400
391
|
}),
|
|
401
|
-
|
|
402
|
-
o && (
|
|
392
|
+
Qt(() => {
|
|
393
|
+
o && (d = 0);
|
|
403
394
|
})
|
|
404
395
|
);
|
|
405
396
|
});
|
|
406
397
|
}
|
|
407
|
-
const
|
|
408
|
-
|
|
409
|
-
},
|
|
410
|
-
|
|
398
|
+
const wr = (s, e) => s.length === e.length && s.every((t, r) => t === e[r]), Rs = (s) => {
|
|
399
|
+
Y(s, []);
|
|
400
|
+
}, Cr = (s) => {
|
|
401
|
+
Rs(() => {
|
|
411
402
|
s();
|
|
412
403
|
});
|
|
413
404
|
};
|
|
414
|
-
function
|
|
405
|
+
function $t(s) {
|
|
415
406
|
return Object.prototype.toString.call(s) === "[object Object]";
|
|
416
407
|
}
|
|
417
408
|
function nt(s) {
|
|
418
|
-
if (
|
|
409
|
+
if (!$t(s))
|
|
419
410
|
return !1;
|
|
420
411
|
const e = s.constructor;
|
|
421
412
|
if (typeof e > "u")
|
|
422
413
|
return !0;
|
|
423
414
|
const t = e.prototype;
|
|
424
|
-
return !(
|
|
415
|
+
return !(!$t(t) || !t.hasOwnProperty("isPrototypeOf"));
|
|
425
416
|
}
|
|
426
417
|
const ve = (s) => JSON.stringify(
|
|
427
418
|
s,
|
|
@@ -440,7 +431,7 @@ const ve = (s) => JSON.stringify(
|
|
|
440
431
|
function lt(s) {
|
|
441
432
|
let e = 0;
|
|
442
433
|
return function(r) {
|
|
443
|
-
return new
|
|
434
|
+
return new is((n) => {
|
|
444
435
|
e++;
|
|
445
436
|
const u = r.subscribe(n);
|
|
446
437
|
return s(e), () => {
|
|
@@ -456,40 +447,40 @@ const we = (s) => s.pipe(
|
|
|
456
447
|
)
|
|
457
448
|
);
|
|
458
449
|
var ee;
|
|
459
|
-
class
|
|
450
|
+
class js {
|
|
460
451
|
constructor({
|
|
461
452
|
__queryFinalizeHook: e
|
|
462
453
|
} = {}) {
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
const t = new
|
|
454
|
+
w(this, ee, new I());
|
|
455
|
+
g(this, "state$");
|
|
456
|
+
const t = new X(0), r = t.pipe(
|
|
466
457
|
O((n) => n === 0)
|
|
467
458
|
);
|
|
468
459
|
this.state$ = a(this, ee).pipe(
|
|
469
|
-
|
|
460
|
+
us(({ args: n, mutation: u, options: i }) => {
|
|
470
461
|
const c = i.mapOperator ?? "merge", l = a(this, ee).pipe(
|
|
471
462
|
O(() => c === "merge")
|
|
472
463
|
), h = a(this, ee).pipe(
|
|
473
464
|
O(() => c === "switch"),
|
|
474
|
-
|
|
465
|
+
R(() => {
|
|
475
466
|
u.cancel();
|
|
476
467
|
})
|
|
477
|
-
), o = Ae(() => (u.execute(n),
|
|
468
|
+
), o = Ae(() => (u.execute(n), B)), p = u.state$.pipe(
|
|
478
469
|
we,
|
|
479
470
|
Ke(),
|
|
480
|
-
|
|
471
|
+
q(() => u.state$),
|
|
481
472
|
ne(a(this, ee))
|
|
482
|
-
),
|
|
473
|
+
), F = u.state$.pipe(
|
|
483
474
|
we,
|
|
484
475
|
at(1)
|
|
485
|
-
),
|
|
476
|
+
), d = C(
|
|
486
477
|
r,
|
|
487
478
|
l,
|
|
488
479
|
h,
|
|
489
480
|
u.cancelled$
|
|
490
481
|
);
|
|
491
|
-
return
|
|
492
|
-
|
|
482
|
+
return C(
|
|
483
|
+
F,
|
|
493
484
|
p,
|
|
494
485
|
/**
|
|
495
486
|
* We defer execution so that we return at least
|
|
@@ -497,9 +488,9 @@ class xs {
|
|
|
497
488
|
*/
|
|
498
489
|
o
|
|
499
490
|
).pipe(
|
|
500
|
-
|
|
501
|
-
e ??
|
|
502
|
-
ne(
|
|
491
|
+
b((f) => ({ state: f, mutation: u })),
|
|
492
|
+
e ?? Mt,
|
|
493
|
+
ne(d)
|
|
503
494
|
);
|
|
504
495
|
}),
|
|
505
496
|
Ue({
|
|
@@ -524,7 +515,7 @@ function et(s, e) {
|
|
|
524
515
|
return s === e ? !0 : typeof s != typeof e ? !1 : s && e && typeof s == "object" && typeof e == "object" ? !Object.keys(e).some((t) => !et(s[t], e[t])) : !1;
|
|
525
516
|
}
|
|
526
517
|
const _e = (s, e, { exact: t = !1 } = {}) => t ? ve(s) === ve(e) : et(s, e);
|
|
527
|
-
function
|
|
518
|
+
function P(s, e) {
|
|
528
519
|
if (s == null || e === void 0 || typeof s != "object" || typeof e != "object")
|
|
529
520
|
return s === e;
|
|
530
521
|
if (s.constructor !== (e == null ? void 0 : e.constructor))
|
|
@@ -537,24 +528,24 @@ function V(s, e) {
|
|
|
537
528
|
return !1;
|
|
538
529
|
return !0;
|
|
539
530
|
}
|
|
540
|
-
const
|
|
541
|
-
|
|
542
|
-
({ data: e, ...t }, { data: r, ...n }) =>
|
|
531
|
+
const Dt = (s) => s.pipe(
|
|
532
|
+
U(
|
|
533
|
+
({ data: e, ...t }, { data: r, ...n }) => P(t, n) && P(e, r)
|
|
543
534
|
)
|
|
544
535
|
);
|
|
545
|
-
var
|
|
546
|
-
class
|
|
536
|
+
var ae, L;
|
|
537
|
+
class Ms {
|
|
547
538
|
constructor(e, t = {}, r) {
|
|
548
|
-
|
|
549
|
-
|
|
539
|
+
w(this, ae);
|
|
540
|
+
w(this, L, new X(void 0));
|
|
550
541
|
/**
|
|
551
542
|
* @important
|
|
552
543
|
* Used to maintain persistance to latest mutation. This ensure
|
|
553
544
|
* - mutation does not get garbage collected
|
|
554
545
|
* - mutation mutate options are run on finish
|
|
555
546
|
*/
|
|
556
|
-
|
|
557
|
-
|
|
547
|
+
g(this, "observed$");
|
|
548
|
+
g(this, "getObserverResultFromState", (e) => ({
|
|
558
549
|
...fe(),
|
|
559
550
|
...e,
|
|
560
551
|
isSuccess: e.status === "success",
|
|
@@ -567,24 +558,24 @@ class Rs {
|
|
|
567
558
|
reset: this.reset
|
|
568
559
|
}));
|
|
569
560
|
var n;
|
|
570
|
-
this.client = e, this.options = t, this.options.mutationKey = ((n = this.options) == null ? void 0 : n.mutationKey) ?? [ct()],
|
|
561
|
+
this.client = e, this.options = t, this.options.mutationKey = ((n = this.options) == null ? void 0 : n.mutationKey) ?? [ct()], A(this, ae, r ?? new js(this.options)), this.mutate = this.mutate.bind(this), this.reset = this.reset.bind(this), a(this, L).pipe(
|
|
571
562
|
O(rt),
|
|
572
|
-
|
|
573
|
-
(u) => a(this,
|
|
563
|
+
q(
|
|
564
|
+
(u) => a(this, ae).state$.pipe(
|
|
574
565
|
ne(
|
|
575
566
|
u.mutation.state$.pipe(we, Ke())
|
|
576
567
|
)
|
|
577
568
|
)
|
|
578
569
|
)
|
|
579
570
|
).subscribe(), this.observed$ = a(this, L).pipe(
|
|
580
|
-
|
|
571
|
+
j((u) => (u == null ? void 0 : u.mutation.state$.pipe(
|
|
581
572
|
// last(),
|
|
582
|
-
|
|
573
|
+
b((i) => ({
|
|
583
574
|
state: i,
|
|
584
575
|
options: u.options
|
|
585
576
|
}))
|
|
586
|
-
)) ??
|
|
587
|
-
|
|
577
|
+
)) ?? B),
|
|
578
|
+
R(({ state: u, options: i }) => {
|
|
588
579
|
u.status === "error" && (i != null && i.onError && (i == null || i.onError(
|
|
589
580
|
u.error,
|
|
590
581
|
u.variables,
|
|
@@ -605,7 +596,7 @@ class Rs {
|
|
|
605
596
|
u.context
|
|
606
597
|
)));
|
|
607
598
|
}),
|
|
608
|
-
|
|
599
|
+
ie()
|
|
609
600
|
);
|
|
610
601
|
}
|
|
611
602
|
setOptions(e) {
|
|
@@ -624,11 +615,11 @@ class Rs {
|
|
|
624
615
|
var u;
|
|
625
616
|
const e = this.getObserverResultFromState(
|
|
626
617
|
((u = a(this, L).getValue()) == null ? void 0 : u.mutation.state) ?? fe()
|
|
627
|
-
), t = a(this,
|
|
628
|
-
|
|
629
|
-
({ mutation: i, state: { data: c, ...l } }, { mutation: h, state: { data: o, ...p } }) => i === h &&
|
|
618
|
+
), t = a(this, ae).state$.pipe(
|
|
619
|
+
U(
|
|
620
|
+
({ mutation: i, state: { data: c, ...l } }, { mutation: h, state: { data: o, ...p } }) => i === h && P(l, p) && P(c, o)
|
|
630
621
|
),
|
|
631
|
-
|
|
622
|
+
b(({ state: i }) => i),
|
|
632
623
|
Be((i, c) => ({
|
|
633
624
|
...i,
|
|
634
625
|
...c,
|
|
@@ -639,17 +630,17 @@ class Rs {
|
|
|
639
630
|
error: c.error ?? i.error
|
|
640
631
|
}
|
|
641
632
|
})),
|
|
642
|
-
|
|
633
|
+
b((i) => this.getObserverResultFromState(i))
|
|
643
634
|
), r = a(this, L).pipe(
|
|
644
635
|
O(rt),
|
|
645
|
-
|
|
646
|
-
|
|
636
|
+
j((i) => i.mutation.cancelled$),
|
|
637
|
+
b(() => this.getObserverResultFromState(fe()))
|
|
647
638
|
);
|
|
648
|
-
return { result$:
|
|
639
|
+
return { result$: C(
|
|
649
640
|
this.observed$,
|
|
650
641
|
t,
|
|
651
642
|
r
|
|
652
|
-
).pipe(
|
|
643
|
+
).pipe(Dt), lastValue: e };
|
|
653
644
|
}
|
|
654
645
|
/**
|
|
655
646
|
* @important
|
|
@@ -665,7 +656,7 @@ class Rs {
|
|
|
665
656
|
}
|
|
666
657
|
async mutate(e, t = {}) {
|
|
667
658
|
const r = this.client.getMutationCache().build(this.client, this.options);
|
|
668
|
-
return a(this, L).next({ mutation: r, options: t }), a(this,
|
|
659
|
+
return a(this, L).next({ mutation: r, options: t }), a(this, ae).trigger({
|
|
669
660
|
args: e,
|
|
670
661
|
options: this.options,
|
|
671
662
|
mutation: r
|
|
@@ -692,67 +683,67 @@ class Rs {
|
|
|
692
683
|
a(this, L).next(void 0), e == null || e.cancel();
|
|
693
684
|
}
|
|
694
685
|
}
|
|
695
|
-
|
|
696
|
-
const
|
|
686
|
+
ae = new WeakMap(), L = new WeakMap();
|
|
687
|
+
const Tt = Zt(void 0), As = ({ client: s }) => (Y(() => (s.mount(), () => {
|
|
697
688
|
s.unmount();
|
|
698
|
-
}), [s]), null),
|
|
689
|
+
}), [s]), null), Fr = es(
|
|
699
690
|
({ children: s, client: e }) => {
|
|
700
691
|
const t = ut(() => e, [e]);
|
|
701
|
-
return /* @__PURE__ */
|
|
702
|
-
/* @__PURE__ */
|
|
692
|
+
return /* @__PURE__ */ gs(Tt.Provider, { value: t, children: [
|
|
693
|
+
/* @__PURE__ */ ms(As, { client: e }),
|
|
703
694
|
s
|
|
704
695
|
] });
|
|
705
696
|
}
|
|
706
697
|
), kt = (s) => {
|
|
707
|
-
const e =
|
|
698
|
+
const e = ts(Tt);
|
|
708
699
|
if (s)
|
|
709
700
|
return s;
|
|
710
701
|
if (!e)
|
|
711
702
|
throw new Error("No QueryClient set, use QueryClientProvider to set one");
|
|
712
703
|
return e;
|
|
713
704
|
};
|
|
714
|
-
function
|
|
705
|
+
function Qs() {
|
|
715
706
|
}
|
|
716
|
-
function
|
|
717
|
-
const t = kt(e), r =
|
|
718
|
-
() => new
|
|
707
|
+
function Er(s, e) {
|
|
708
|
+
const t = kt(e), r = H(s), n = Ze(() => [ct()]), u = ve(s.mutationKey ?? n.current), [i] = jt(
|
|
709
|
+
() => new Ms(
|
|
719
710
|
t,
|
|
720
711
|
s
|
|
721
712
|
)
|
|
722
713
|
);
|
|
723
|
-
|
|
714
|
+
Y(() => {
|
|
724
715
|
i.setOptions(s);
|
|
725
716
|
}, [i, s]);
|
|
726
|
-
const c = ut(() => i.observe(), [u, i]), l = Xe(c.result$) ?? c.lastValue, h =
|
|
717
|
+
const c = ut(() => i.observe(), [u, i]), l = Xe(c.result$) ?? c.lastValue, h = de(
|
|
727
718
|
(o, p) => {
|
|
728
|
-
i.mutate(o, p).catch(
|
|
719
|
+
i.mutate(o, p).catch(Qs);
|
|
729
720
|
},
|
|
730
721
|
[i]
|
|
731
722
|
);
|
|
732
|
-
return
|
|
723
|
+
return Y(() => () => {
|
|
733
724
|
r.current.cancelOnUnMount && i.reset();
|
|
734
725
|
}, [i, r]), { ...l, mutate: h, mutateAsync: l.mutate };
|
|
735
726
|
}
|
|
736
|
-
function
|
|
727
|
+
function Us(s) {
|
|
737
728
|
return (e) => e.pipe(
|
|
738
|
-
|
|
729
|
+
Qt((t) => {
|
|
739
730
|
s.next(t);
|
|
740
731
|
})
|
|
741
732
|
);
|
|
742
733
|
}
|
|
743
734
|
const pe = typeof window > "u" || "Deno" in window;
|
|
744
|
-
class
|
|
735
|
+
class Vs {
|
|
745
736
|
constructor() {
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
737
|
+
g(this, "isOnlineSubject", new X(!0));
|
|
738
|
+
g(this, "online$", this.isOnlineSubject.pipe(U()));
|
|
739
|
+
g(this, "backToOnline$", this.online$.pipe(
|
|
749
740
|
O((e) => e),
|
|
750
741
|
Je()
|
|
751
742
|
));
|
|
752
|
-
|
|
753
|
-
pe ?
|
|
754
|
-
pe ?
|
|
755
|
-
).pipe(
|
|
743
|
+
C(
|
|
744
|
+
pe ? B : Ne(window, "offline").pipe(b(() => !1)),
|
|
745
|
+
pe ? B : Ne(window, "online").pipe(b(() => !0))
|
|
746
|
+
).pipe(Us(this.isOnlineSubject)).subscribe();
|
|
756
747
|
}
|
|
757
748
|
isOnline() {
|
|
758
749
|
return this.isOnlineSubject.getValue();
|
|
@@ -761,51 +752,51 @@ class Qs {
|
|
|
761
752
|
this.isOnlineSubject.getValue() !== e && this.isOnlineSubject.next(e);
|
|
762
753
|
}
|
|
763
754
|
}
|
|
764
|
-
const re = new
|
|
755
|
+
const re = new Vs();
|
|
765
756
|
function ht(s, e) {
|
|
766
757
|
return s.isStaleByTime(e.staleTime);
|
|
767
758
|
}
|
|
768
|
-
function
|
|
759
|
+
function Is(s, e) {
|
|
769
760
|
return e.enabled !== !1 && !s.state.dataUpdatedAt && !(s.state.status === "error" && e.retryOnMount === !1) && s.state.fetchStatus !== "fetching";
|
|
770
761
|
}
|
|
771
|
-
function
|
|
772
|
-
return
|
|
762
|
+
function wt(s, e) {
|
|
763
|
+
return Is(s, e) || s.state.dataUpdatedAt > 0 && Kt(s, e, e.refetchOnMount);
|
|
773
764
|
}
|
|
774
|
-
function
|
|
765
|
+
function Ct(s, e, t, r) {
|
|
775
766
|
return s.state.fetchStatus !== "fetching" && t.enabled !== !1 && (s !== e || r.enabled === !1) && (!t.suspense || s.state.status !== "error") && ht(s, t);
|
|
776
767
|
}
|
|
777
|
-
function
|
|
778
|
-
return
|
|
768
|
+
function Ps(s, e) {
|
|
769
|
+
return Kt(s, e, e.refetchOnWindowFocus);
|
|
779
770
|
}
|
|
780
|
-
function
|
|
771
|
+
function Kt(s, e, t) {
|
|
781
772
|
if (e.enabled !== !1) {
|
|
782
773
|
const r = typeof t == "function" ? t(s) : t;
|
|
783
774
|
return r === "idle" ? s.state.fetchStatus === "idle" : r === "always" || r !== !1 && ht(s, e);
|
|
784
775
|
}
|
|
785
776
|
return !1;
|
|
786
777
|
}
|
|
787
|
-
function
|
|
778
|
+
function Ds(s) {
|
|
788
779
|
return (s ?? "online") === "online" ? re.isOnline() : !0;
|
|
789
780
|
}
|
|
790
|
-
function
|
|
781
|
+
function Ft(s, e) {
|
|
791
782
|
return e.reduce(
|
|
792
783
|
(t, r) => r in s ? { ...t, [r]: s[r] } : t,
|
|
793
784
|
{}
|
|
794
785
|
);
|
|
795
786
|
}
|
|
796
|
-
function
|
|
787
|
+
function Et(s) {
|
|
797
788
|
return Array.isArray(s) && s.length === Object.keys(s).length;
|
|
798
789
|
}
|
|
799
|
-
function
|
|
790
|
+
function Nt(s, e) {
|
|
800
791
|
if (s === e)
|
|
801
792
|
return s;
|
|
802
|
-
const t =
|
|
793
|
+
const t = Et(s) && Et(e);
|
|
803
794
|
if (t || nt(s) && nt(e)) {
|
|
804
795
|
const r = t ? s : Object.keys(s), n = r.length, u = t ? e : Object.keys(e), i = u.length, c = t ? [] : {};
|
|
805
796
|
let l = 0;
|
|
806
797
|
for (let h = 0; h < i; h++) {
|
|
807
798
|
const o = t ? h : u[h];
|
|
808
|
-
!t && s[o] === void 0 && e[o] === void 0 && r.includes(o) ? (c[o] = void 0, l++) : (c[o] =
|
|
799
|
+
!t && s[o] === void 0 && e[o] === void 0 && r.includes(o) ? (c[o] = void 0, l++) : (c[o] = Nt(s[o], e[o]), c[o] === s[o] && s[o] !== void 0 && l++);
|
|
809
800
|
}
|
|
810
801
|
return n === i && l === n ? s : c;
|
|
811
802
|
}
|
|
@@ -814,7 +805,7 @@ function Kt(s, e) {
|
|
|
814
805
|
function dt(s, e) {
|
|
815
806
|
return ((e == null ? void 0 : e.queryKeyHashFn) ?? ve)(s);
|
|
816
807
|
}
|
|
817
|
-
function
|
|
808
|
+
function xt(s, e) {
|
|
818
809
|
const {
|
|
819
810
|
type: t = "all",
|
|
820
811
|
exact: r,
|
|
@@ -837,70 +828,69 @@ function Et(s, e) {
|
|
|
837
828
|
}
|
|
838
829
|
return !(typeof c == "boolean" && e.isStale() !== c || typeof n < "u" && n !== e.state.fetchStatus || u && !u(e));
|
|
839
830
|
}
|
|
840
|
-
function
|
|
831
|
+
function Ts(s, e) {
|
|
841
832
|
return Math.max(s + (e ?? 0) - Date.now(), 0);
|
|
842
833
|
}
|
|
843
|
-
function
|
|
834
|
+
function ks(s, e) {
|
|
844
835
|
return typeof s == "function" ? s(e) : s;
|
|
845
836
|
}
|
|
846
837
|
function Le(s, e, t) {
|
|
847
|
-
return typeof t.structuralSharing == "function" ? t.structuralSharing(s, e) : t.structuralSharing !== !1 ?
|
|
838
|
+
return typeof t.structuralSharing == "function" ? t.structuralSharing(s, e) : t.structuralSharing !== !1 ? Nt(s, e) : e;
|
|
848
839
|
}
|
|
849
|
-
const it = Symbol(),
|
|
840
|
+
const it = Symbol(), Ks = ({
|
|
850
841
|
getOptions: s,
|
|
851
842
|
getState: e,
|
|
852
843
|
initialState: t
|
|
853
844
|
}) => (r) => r.pipe(
|
|
854
845
|
Be((n, { command: u, state: i }) => {
|
|
855
|
-
if (u === "reset")
|
|
856
|
-
return { ...n, ...i };
|
|
846
|
+
if (u === "reset") return { ...n, ...i };
|
|
857
847
|
if (u === "cancel") {
|
|
858
|
-
const
|
|
859
|
-
return { ...n, ...i, status:
|
|
848
|
+
const S = n.status === "pending" ? "pending" : i.status ?? n.status;
|
|
849
|
+
return { ...n, ...i, status: S };
|
|
860
850
|
}
|
|
861
|
-
const c = i.data, l = c !== void 0 && c !== n.data, h = "data" in i, o = i.status === "success", p = n.data !== void 0,
|
|
862
|
-
(p ||
|
|
851
|
+
const c = i.data, l = c !== void 0 && c !== n.data, h = "data" in i, o = i.status === "success", p = n.data !== void 0, F = n.error !== void 0 || n.error !== null, d = i.status ?? n.status, f = l ? Le(e().data, c, s()) : h ? i.data : n.data, y = n.status === "error" || n.status === "success", x = i.status === "error" && (n.status === "error" && n.fetchStatus === "fetching" || n.status !== "error") ? n.errorUpdateCount + 1 : n.errorUpdateCount, E = l ? n.dataUpdateCount + 1 : i.dataUpdateCount ?? n.dataUpdateCount, $ = i.status === "pending" && y && // (dataUpdateCount !== 0 || errorUpdateCount !== 0)
|
|
852
|
+
(p || F), D = d === "pending" ? null : i.error ?? n.error;
|
|
863
853
|
return {
|
|
864
854
|
...n,
|
|
865
855
|
...i,
|
|
866
|
-
status:
|
|
867
|
-
error:
|
|
868
|
-
errorUpdateCount:
|
|
856
|
+
status: d,
|
|
857
|
+
error: D,
|
|
858
|
+
errorUpdateCount: x,
|
|
869
859
|
...o && {
|
|
870
860
|
isInvalidated: !1
|
|
871
861
|
},
|
|
872
|
-
data:
|
|
873
|
-
dataUpdateCount:
|
|
874
|
-
|
|
862
|
+
data: f,
|
|
863
|
+
dataUpdateCount: E,
|
|
864
|
+
...$ && {
|
|
875
865
|
status: n.status
|
|
876
866
|
}
|
|
877
867
|
};
|
|
878
868
|
}, t)
|
|
879
|
-
),
|
|
880
|
-
|
|
869
|
+
), Ns = (s) => s.pipe(
|
|
870
|
+
b(
|
|
881
871
|
({ status: e, fetchStatus: t }) => t === "idle" && (e === "success" || e === "error")
|
|
882
872
|
)
|
|
883
|
-
),
|
|
873
|
+
), qt = (s) => s.pipe(
|
|
884
874
|
Ye((e) => e.fetchStatus !== "idle", !0)
|
|
885
875
|
);
|
|
886
876
|
var We, te;
|
|
887
|
-
class
|
|
877
|
+
class qs {
|
|
888
878
|
constructor() {
|
|
889
|
-
|
|
890
|
-
pe ?
|
|
891
|
-
pe ?
|
|
892
|
-
).pipe(
|
|
893
|
-
|
|
879
|
+
w(this, We, C(
|
|
880
|
+
pe ? B : Ne(document, "visibilitychange"),
|
|
881
|
+
pe ? B : Ne(window, "visibilitychange")
|
|
882
|
+
).pipe(b(() => document.visibilityState)));
|
|
883
|
+
w(this, te, new X(
|
|
894
884
|
pe ? !0 : document.visibilityState === "visible"
|
|
895
885
|
));
|
|
896
886
|
// public readonly focused$ = this.#focusedSubject.pipe(distinctUntilChanged())
|
|
897
|
-
|
|
898
|
-
|
|
887
|
+
g(this, "focused$", a(this, te));
|
|
888
|
+
g(this, "focusRegained$", this.focused$.pipe(
|
|
899
889
|
at(1),
|
|
900
890
|
O((e) => e)
|
|
901
891
|
));
|
|
902
892
|
a(this, We).pipe(
|
|
903
|
-
|
|
893
|
+
R((e) => {
|
|
904
894
|
a(this, te).next(e === "visible");
|
|
905
895
|
})
|
|
906
896
|
).subscribe();
|
|
@@ -929,41 +919,41 @@ class Ks {
|
|
|
929
919
|
}
|
|
930
920
|
}
|
|
931
921
|
We = new WeakMap(), te = new WeakMap();
|
|
932
|
-
const ze = new
|
|
922
|
+
const ze = new qs(), Hs = (s) => s.pipe(
|
|
933
923
|
O((e) => e.status === "success"),
|
|
934
|
-
|
|
924
|
+
b((e) => ({
|
|
935
925
|
data: e.data,
|
|
936
926
|
status: e.status,
|
|
937
927
|
dataUpdatedAt: e.dataUpdatedAt
|
|
938
928
|
})),
|
|
939
|
-
|
|
929
|
+
U(P)
|
|
940
930
|
);
|
|
941
|
-
var
|
|
942
|
-
class
|
|
931
|
+
var Z, M, Ce, oe, T, ye, Fe;
|
|
932
|
+
class Ht {
|
|
943
933
|
constructor(e, t) {
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
934
|
+
w(this, Z);
|
|
935
|
+
w(this, M);
|
|
936
|
+
w(this, Ce, new I());
|
|
947
937
|
/**
|
|
948
938
|
* Used to subscribe to changes in either query or options (or both).
|
|
949
939
|
* We need to be able to track change to both of them at the same time
|
|
950
940
|
* in order to react accordingly and in order (such as refetch on options change)
|
|
951
941
|
*/
|
|
952
|
-
|
|
942
|
+
g(this, "queryUpdateSubject", new I());
|
|
953
943
|
/**
|
|
954
944
|
* Mostly used to compare the state before and after mount
|
|
955
945
|
*/
|
|
956
|
-
|
|
946
|
+
w(this, oe);
|
|
957
947
|
/**
|
|
958
948
|
* Mostly used for internal optimization such as not
|
|
959
949
|
* running selectors twice, etc
|
|
960
950
|
*/
|
|
961
|
-
|
|
951
|
+
w(this, T);
|
|
962
952
|
// This property keeps track of the last query with defined data.
|
|
963
953
|
// It will be used to pass the previous data and query to the placeholder function between renders.
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
954
|
+
w(this, ye);
|
|
955
|
+
w(this, Fe, 0);
|
|
956
|
+
g(this, "getObserverResultFromQuery", ({
|
|
967
957
|
options: e,
|
|
968
958
|
query: t,
|
|
969
959
|
optimisticResult: r,
|
|
@@ -977,30 +967,30 @@ class qt {
|
|
|
977
967
|
}
|
|
978
968
|
}) => {
|
|
979
969
|
var De;
|
|
980
|
-
const o = t.state, p = t.state.status === "pending",
|
|
981
|
-
let { errorUpdatedAt:
|
|
970
|
+
const o = t.state, p = t.state.status === "pending", F = a(this, M), d = this.options, y = t !== F ? t.state : a(this, oe);
|
|
971
|
+
let { errorUpdatedAt: x, fetchStatus: E, error: $ } = o;
|
|
982
972
|
if (r) {
|
|
983
|
-
const k = !!a(this, Fe), pt = !k &&
|
|
984
|
-
(pt ||
|
|
973
|
+
const k = !!a(this, Fe), pt = !k && wt(t, e), Jt = k && Ct(t, F, e, d);
|
|
974
|
+
(pt || Jt) && (E = Ds(t.options.networkMode) ? "fetching" : "paused");
|
|
985
975
|
}
|
|
986
|
-
const
|
|
987
|
-
let
|
|
976
|
+
const D = p && E === "fetching";
|
|
977
|
+
let S, m = l, z = c ?? null, W = h;
|
|
988
978
|
if (e.select && typeof o.data < "u")
|
|
989
979
|
if (n && o.data === (i == null ? void 0 : i.data) && e.select === c)
|
|
990
|
-
|
|
980
|
+
S = h;
|
|
991
981
|
else
|
|
992
982
|
try {
|
|
993
|
-
z = e.select,
|
|
983
|
+
z = e.select, S = e.select(o.data), S = Le(n == null ? void 0 : n.data, S, e), W = S, m = null;
|
|
994
984
|
} catch (k) {
|
|
995
|
-
|
|
985
|
+
S = h, m = k;
|
|
996
986
|
}
|
|
997
987
|
else
|
|
998
|
-
|
|
999
|
-
let _ =
|
|
1000
|
-
|
|
1001
|
-
const
|
|
1002
|
-
let
|
|
1003
|
-
if (typeof e.placeholderData < "u" && typeof
|
|
988
|
+
S = o.data, m = null;
|
|
989
|
+
let _ = E !== "idle" && !o.dataUpdatedAt ? "pending" : o.status;
|
|
990
|
+
m && ($ = m, S = h, x = (n == null ? void 0 : n.errorUpdatedAt) ?? x, _ = "error");
|
|
991
|
+
const Ve = _ === "error";
|
|
992
|
+
let Ie = !1;
|
|
993
|
+
if (typeof e.placeholderData < "u" && typeof S > "u" && _ === "pending") {
|
|
1004
994
|
let k;
|
|
1005
995
|
if (n != null && n.isPlaceholderData && e.placeholderData === (u == null ? void 0 : u.placeholderData))
|
|
1006
996
|
k = n.data;
|
|
@@ -1012,49 +1002,49 @@ class qt {
|
|
|
1012
1002
|
k = e.select(k);
|
|
1013
1003
|
} catch {
|
|
1014
1004
|
}
|
|
1015
|
-
typeof k < "u" && (_ = "success",
|
|
1005
|
+
typeof k < "u" && (_ = "success", S = Le(
|
|
1016
1006
|
n == null ? void 0 : n.data,
|
|
1017
1007
|
k,
|
|
1018
1008
|
e
|
|
1019
|
-
),
|
|
1009
|
+
), Ie = !0);
|
|
1020
1010
|
}
|
|
1021
|
-
const Pe =
|
|
1011
|
+
const Pe = E === "fetching";
|
|
1022
1012
|
return {
|
|
1023
1013
|
result: {
|
|
1024
1014
|
status: _,
|
|
1025
|
-
fetchStatus:
|
|
1015
|
+
fetchStatus: E,
|
|
1026
1016
|
isPending: p,
|
|
1027
1017
|
isSuccess: _ === "success",
|
|
1028
|
-
isError:
|
|
1029
|
-
isInitialLoading:
|
|
1030
|
-
isLoading:
|
|
1031
|
-
data:
|
|
1018
|
+
isError: Ve,
|
|
1019
|
+
isInitialLoading: D,
|
|
1020
|
+
isLoading: D,
|
|
1021
|
+
data: S,
|
|
1032
1022
|
dataUpdatedAt: o.dataUpdatedAt,
|
|
1033
|
-
error:
|
|
1034
|
-
errorUpdatedAt:
|
|
1023
|
+
error: $,
|
|
1024
|
+
errorUpdatedAt: x,
|
|
1035
1025
|
failureCount: o.fetchFailureCount,
|
|
1036
1026
|
failureReason: o.fetchFailureReason,
|
|
1037
1027
|
errorUpdateCount: o.errorUpdateCount,
|
|
1038
1028
|
isFetched: o.dataUpdateCount > 0 || o.errorUpdateCount > 0,
|
|
1039
|
-
isFetchedAfterMount: o.dataUpdateCount >
|
|
1029
|
+
isFetchedAfterMount: o.dataUpdateCount > y.dataUpdateCount || o.errorUpdateCount > y.errorUpdateCount,
|
|
1040
1030
|
isFetching: Pe,
|
|
1041
1031
|
isRefetching: Pe && !p,
|
|
1042
|
-
isLoadingError:
|
|
1043
|
-
isPaused:
|
|
1044
|
-
isPlaceholderData:
|
|
1045
|
-
isRefetchError:
|
|
1032
|
+
isLoadingError: Ve && o.dataUpdatedAt === 0,
|
|
1033
|
+
isPaused: E === "paused",
|
|
1034
|
+
isPlaceholderData: Ie,
|
|
1035
|
+
isRefetchError: Ve && o.dataUpdatedAt !== 0,
|
|
1046
1036
|
isStale: ht(t, e),
|
|
1047
1037
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
1048
1038
|
refetch: this.refetch
|
|
1049
1039
|
},
|
|
1050
|
-
selectError:
|
|
1040
|
+
selectError: m,
|
|
1051
1041
|
select: z,
|
|
1052
1042
|
selectResult: W
|
|
1053
1043
|
};
|
|
1054
1044
|
});
|
|
1055
|
-
this.options = t,
|
|
1056
|
-
const r = a(this,
|
|
1057
|
-
|
|
1045
|
+
this.options = t, A(this, Z, e), this.bindMethods(), A(this, M, this.setOptions(t));
|
|
1046
|
+
const r = a(this, M);
|
|
1047
|
+
A(this, oe, r.state);
|
|
1058
1048
|
const { result: n, select: u } = this.getObserverResultFromQuery({
|
|
1059
1049
|
query: r,
|
|
1060
1050
|
options: this.options,
|
|
@@ -1063,7 +1053,7 @@ class qt {
|
|
|
1063
1053
|
state: r.state
|
|
1064
1054
|
}
|
|
1065
1055
|
});
|
|
1066
|
-
|
|
1056
|
+
A(this, T, {
|
|
1067
1057
|
state: r.state,
|
|
1068
1058
|
options: t,
|
|
1069
1059
|
result: n,
|
|
@@ -1075,40 +1065,40 @@ class qt {
|
|
|
1075
1065
|
}
|
|
1076
1066
|
setOptions(e) {
|
|
1077
1067
|
const t = this.options;
|
|
1078
|
-
if (this.options = a(this,
|
|
1068
|
+
if (this.options = a(this, Z).defaultQueryOptions(e), P(this.options, t) || a(this, Z).getQueryCache().notify({
|
|
1079
1069
|
type: "observerOptionsUpdated",
|
|
1080
|
-
query: a(this,
|
|
1070
|
+
query: a(this, M),
|
|
1081
1071
|
observer: this
|
|
1082
1072
|
}), typeof this.options.enabled < "u" && typeof this.options.enabled != "boolean")
|
|
1083
1073
|
throw new Error("Expected enabled to be a boolean");
|
|
1084
1074
|
const r = this.buildQuery(this.options);
|
|
1085
|
-
return r !== a(this,
|
|
1075
|
+
return r !== a(this, M) && (A(this, oe, r.state), A(this, M, r)), this.queryUpdateSubject.next({
|
|
1086
1076
|
options: this.options,
|
|
1087
1077
|
query: r
|
|
1088
1078
|
}), r;
|
|
1089
1079
|
}
|
|
1090
1080
|
buildQuery(e) {
|
|
1091
|
-
const t = a(this,
|
|
1081
|
+
const t = a(this, Z).getQueryCache().build(a(this, Z), e);
|
|
1092
1082
|
return !t.options.queryFn && this.options.queryFn && t.setOptions(e), t;
|
|
1093
1083
|
}
|
|
1094
1084
|
getCurrentResult() {
|
|
1095
1085
|
return this.getObserverResultFromQuery({
|
|
1096
1086
|
options: this.options,
|
|
1097
|
-
prevResult: a(this,
|
|
1098
|
-
query: a(this,
|
|
1087
|
+
prevResult: a(this, T),
|
|
1088
|
+
query: a(this, M)
|
|
1099
1089
|
}).result;
|
|
1100
1090
|
}
|
|
1101
1091
|
getCurrentQuery() {
|
|
1102
|
-
return a(this,
|
|
1092
|
+
return a(this, M);
|
|
1103
1093
|
}
|
|
1104
1094
|
getOptimisticResult(e) {
|
|
1105
1095
|
const t = this.buildQuery(e), r = this.getObserverResultFromQuery({
|
|
1106
1096
|
query: t,
|
|
1107
1097
|
options: e,
|
|
1108
1098
|
optimisticResult: !0,
|
|
1109
|
-
prevResult: a(this,
|
|
1099
|
+
prevResult: a(this, T)
|
|
1110
1100
|
});
|
|
1111
|
-
return
|
|
1101
|
+
return _s(this, r.result) && this.updateResult({ query: t, ...r }), r.result;
|
|
1112
1102
|
}
|
|
1113
1103
|
updateResult({
|
|
1114
1104
|
query: e,
|
|
@@ -1117,8 +1107,8 @@ class qt {
|
|
|
1117
1107
|
select: n,
|
|
1118
1108
|
selectResult: u
|
|
1119
1109
|
}) {
|
|
1120
|
-
a(this,
|
|
1121
|
-
query: a(this,
|
|
1110
|
+
a(this, T).state = e.state, a(this, T).result = t, a(this, T).selectResult = u, r !== void 0 && (a(this, T).selectError = r), n !== void 0 && (a(this, T).select = n), a(this, T).options = this.options, e.state.data !== void 0 && A(this, ye, e), a(this, Z).getQueryCache().notify({
|
|
1111
|
+
query: a(this, M),
|
|
1122
1112
|
type: "observerResultsUpdated"
|
|
1123
1113
|
});
|
|
1124
1114
|
}
|
|
@@ -1129,7 +1119,7 @@ class qt {
|
|
|
1129
1119
|
}
|
|
1130
1120
|
async fetch(e) {
|
|
1131
1121
|
const t = this.buildQuery(this.options);
|
|
1132
|
-
t !== a(this,
|
|
1122
|
+
t !== a(this, M) && (A(this, M, t), A(this, oe, t.state), this.queryUpdateSubject.next({
|
|
1133
1123
|
options: this.options,
|
|
1134
1124
|
query: t
|
|
1135
1125
|
}));
|
|
@@ -1137,14 +1127,14 @@ class qt {
|
|
|
1137
1127
|
...e,
|
|
1138
1128
|
cancelRefetch: (e == null ? void 0 : e.cancelRefetch) ?? !0
|
|
1139
1129
|
};
|
|
1140
|
-
a(this,
|
|
1130
|
+
a(this, M).fetch(this.options, r).catch(N), a(this, Ce).next({
|
|
1141
1131
|
query: t,
|
|
1142
1132
|
fetchOptions: r
|
|
1143
1133
|
}), await t.getFetchResultAsPromise();
|
|
1144
1134
|
const { result: n } = this.getObserverResultFromQuery({
|
|
1145
1135
|
query: t,
|
|
1146
1136
|
options: this.options,
|
|
1147
|
-
prevResult: a(this,
|
|
1137
|
+
prevResult: a(this, T)
|
|
1148
1138
|
});
|
|
1149
1139
|
return n;
|
|
1150
1140
|
}
|
|
@@ -1158,27 +1148,27 @@ class qt {
|
|
|
1158
1148
|
};
|
|
1159
1149
|
}
|
|
1160
1150
|
observe() {
|
|
1161
|
-
const e = a(this,
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1151
|
+
const e = a(this, M), t = this.queryUpdateSubject.pipe(
|
|
1152
|
+
b(({ query: i }) => i),
|
|
1153
|
+
he(a(this, M)),
|
|
1154
|
+
U()
|
|
1165
1155
|
), r = this.queryUpdateSubject.pipe(
|
|
1166
|
-
|
|
1167
|
-
query: a(this,
|
|
1156
|
+
he({
|
|
1157
|
+
query: a(this, M),
|
|
1168
1158
|
options: this.options
|
|
1169
1159
|
}),
|
|
1170
|
-
|
|
1171
|
-
|
|
1160
|
+
At(),
|
|
1161
|
+
R(
|
|
1172
1162
|
([{ options: i, query: c }, { options: l, query: h }]) => {
|
|
1173
|
-
|
|
1163
|
+
Ct(h, c, l, i) && this.fetch().catch(N);
|
|
1174
1164
|
}
|
|
1175
1165
|
),
|
|
1176
|
-
|
|
1166
|
+
ie()
|
|
1177
1167
|
), n = t.pipe(
|
|
1178
|
-
|
|
1179
|
-
|
|
1168
|
+
j((i) => i.observe(this)),
|
|
1169
|
+
ie()
|
|
1180
1170
|
);
|
|
1181
|
-
return
|
|
1171
|
+
return C(
|
|
1182
1172
|
/**
|
|
1183
1173
|
* It's important to observe the query before we subscribe to its result
|
|
1184
1174
|
* later in the chain of merge to get the first result right after fetch
|
|
@@ -1186,95 +1176,95 @@ class qt {
|
|
|
1186
1176
|
n,
|
|
1187
1177
|
r,
|
|
1188
1178
|
t.pipe(
|
|
1189
|
-
|
|
1179
|
+
j((i) => {
|
|
1190
1180
|
const c = this.options, l = this.queryUpdateSubject.pipe(
|
|
1191
|
-
|
|
1192
|
-
O((
|
|
1193
|
-
|
|
1194
|
-
|
|
1181
|
+
he({ query: i, options: c }),
|
|
1182
|
+
O((m) => m.query === i),
|
|
1183
|
+
b((m) => m.options),
|
|
1184
|
+
U(),
|
|
1195
1185
|
Ue(1)
|
|
1196
1186
|
), h = a(this, Ce).pipe(
|
|
1197
|
-
O((
|
|
1187
|
+
O((m) => m.query === i)
|
|
1198
1188
|
), o = i.state$.pipe(
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
(
|
|
1189
|
+
Hs,
|
|
1190
|
+
j(
|
|
1191
|
+
(m) => this.options.staleTime === 1 / 0 ? qe : (this.options.staleTime ?? 0) <= 0 ? v(m).pipe(ot(1)) : Qe(this.options.staleTime ?? 1)
|
|
1202
1192
|
),
|
|
1203
1193
|
Ye(() => this.options.enabled ?? !0)
|
|
1204
|
-
), p = (
|
|
1194
|
+
), p = (m, z) => {
|
|
1205
1195
|
const W = c.notifyOnChangeProps, _ = typeof W == "function" ? W() : W;
|
|
1206
|
-
return (Array.isArray(_) ? _.length === 0 ? () => !0 : (
|
|
1207
|
-
const ft =
|
|
1208
|
-
|
|
1196
|
+
return (Array.isArray(_) ? _.length === 0 ? () => !0 : (Ie, Pe) => {
|
|
1197
|
+
const ft = Ft(
|
|
1198
|
+
Ie,
|
|
1209
1199
|
_
|
|
1210
|
-
), De =
|
|
1200
|
+
), De = Ft(
|
|
1211
1201
|
Pe,
|
|
1212
1202
|
_
|
|
1213
1203
|
);
|
|
1214
|
-
return
|
|
1215
|
-
} :
|
|
1216
|
-
},
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
),
|
|
1220
|
-
|
|
1221
|
-
refetchInterval: (typeof
|
|
1204
|
+
return P(ft, De);
|
|
1205
|
+
} : P)(m, z);
|
|
1206
|
+
}, F = h.pipe(
|
|
1207
|
+
j(() => i.state$),
|
|
1208
|
+
qt
|
|
1209
|
+
), d = l.pipe(
|
|
1210
|
+
b(({ refetchInterval: m, refetchIntervalInBackground: z }) => ({
|
|
1211
|
+
refetchInterval: (typeof m == "function" ? m(a(this, M)) : m) ?? !1,
|
|
1222
1212
|
refetchIntervalInBackground: z
|
|
1223
1213
|
})),
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1214
|
+
U(P),
|
|
1215
|
+
j(({ refetchInterval: m, refetchIntervalInBackground: z }) => m ? as(m).pipe(
|
|
1216
|
+
R(() => {
|
|
1227
1217
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
1228
|
-
(z || ze.isFocused()) && this.fetch({ cancelRefetch: !1 }).catch(
|
|
1218
|
+
(z || ze.isFocused()) && this.fetch({ cancelRefetch: !1 }).catch(N);
|
|
1229
1219
|
})
|
|
1230
1220
|
) : qe),
|
|
1231
|
-
|
|
1232
|
-
),
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
),
|
|
1236
|
-
O((
|
|
1237
|
-
|
|
1238
|
-
),
|
|
1239
|
-
O((
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1221
|
+
ie()
|
|
1222
|
+
), f = l.pipe(
|
|
1223
|
+
b(({ enabled: m }) => m ?? !0),
|
|
1224
|
+
U()
|
|
1225
|
+
), y = f.pipe(
|
|
1226
|
+
O((m) => !m),
|
|
1227
|
+
b(() => i.state)
|
|
1228
|
+
), x = f.pipe(
|
|
1229
|
+
O((m) => m),
|
|
1230
|
+
j(() => ze.focusRegained$),
|
|
1231
|
+
mt(l),
|
|
1232
|
+
R(([, m]) => {
|
|
1233
|
+
Ps(i, m) && this.fetch({ cancelRefetch: !1 }).catch(N);
|
|
1244
1234
|
}),
|
|
1245
|
-
|
|
1246
|
-
),
|
|
1247
|
-
|
|
1248
|
-
),
|
|
1249
|
-
|
|
1250
|
-
|
|
1235
|
+
ie()
|
|
1236
|
+
), E = y.pipe(
|
|
1237
|
+
b(() => i.state)
|
|
1238
|
+
), $ = (m) => m.pipe(
|
|
1239
|
+
mt(l),
|
|
1240
|
+
b(([, z]) => {
|
|
1251
1241
|
const W = this.getObserverResultFromQuery({
|
|
1252
1242
|
query: i,
|
|
1253
1243
|
options: z,
|
|
1254
|
-
prevResult: a(this,
|
|
1244
|
+
prevResult: a(this, T)
|
|
1255
1245
|
});
|
|
1256
1246
|
return this.updateResult({ query: i, ...W }), W.result;
|
|
1257
1247
|
})
|
|
1258
|
-
),
|
|
1259
|
-
|
|
1260
|
-
|
|
1248
|
+
), S = C(
|
|
1249
|
+
E,
|
|
1250
|
+
F,
|
|
1261
1251
|
i.state$,
|
|
1262
1252
|
// options$,
|
|
1263
1253
|
o
|
|
1264
1254
|
).pipe(
|
|
1265
|
-
|
|
1255
|
+
$,
|
|
1266
1256
|
// This one ensure we don't re-trigger same state
|
|
1267
|
-
|
|
1257
|
+
U(P),
|
|
1268
1258
|
// This one make sure we dispatch based on user preference
|
|
1269
|
-
|
|
1259
|
+
U(p)
|
|
1270
1260
|
);
|
|
1271
|
-
return
|
|
1261
|
+
return C(d, x, S);
|
|
1272
1262
|
})
|
|
1273
1263
|
).pipe(
|
|
1274
|
-
lt((i) =>
|
|
1275
|
-
|
|
1264
|
+
lt((i) => A(this, Fe, i)),
|
|
1265
|
+
R({
|
|
1276
1266
|
subscribe: () => {
|
|
1277
|
-
|
|
1267
|
+
wt(e, this.options) && this.fetch().catch(N);
|
|
1278
1268
|
}
|
|
1279
1269
|
})
|
|
1280
1270
|
)
|
|
@@ -1283,13 +1273,13 @@ class qt {
|
|
|
1283
1273
|
destroy() {
|
|
1284
1274
|
}
|
|
1285
1275
|
}
|
|
1286
|
-
|
|
1287
|
-
function
|
|
1288
|
-
return !
|
|
1276
|
+
Z = new WeakMap(), M = new WeakMap(), Ce = new WeakMap(), oe = new WeakMap(), T = new WeakMap(), ye = new WeakMap(), Fe = new WeakMap();
|
|
1277
|
+
function _s(s, e) {
|
|
1278
|
+
return !P(s.getCurrentResult(), e);
|
|
1289
1279
|
}
|
|
1290
|
-
const
|
|
1291
|
-
|
|
1292
|
-
function
|
|
1280
|
+
const _t = Ge.createContext(!1), Ls = () => Ge.useContext(_t);
|
|
1281
|
+
_t.Provider;
|
|
1282
|
+
function zs() {
|
|
1293
1283
|
let s = !1;
|
|
1294
1284
|
return {
|
|
1295
1285
|
clearReset: () => {
|
|
@@ -1301,29 +1291,29 @@ function _s() {
|
|
|
1301
1291
|
isReset: () => s
|
|
1302
1292
|
};
|
|
1303
1293
|
}
|
|
1304
|
-
const
|
|
1305
|
-
function
|
|
1294
|
+
const Ws = Ge.createContext(zs()), Gs = () => Ge.useContext(Ws);
|
|
1295
|
+
function Js(s, e) {
|
|
1306
1296
|
return typeof s == "function" ? s(...e) : !!s;
|
|
1307
1297
|
}
|
|
1308
|
-
const
|
|
1298
|
+
const Ys = ({
|
|
1309
1299
|
result: s,
|
|
1310
1300
|
errorResetBoundary: e,
|
|
1311
1301
|
throwOnError: t,
|
|
1312
1302
|
query: r
|
|
1313
|
-
}) => s.isError && !e.isReset() && !s.isFetching && r &&
|
|
1314
|
-
function
|
|
1303
|
+
}) => s.isError && !e.isReset() && !s.isFetching && r && Js(t, [s.error, r]);
|
|
1304
|
+
function Lt(s, e, t) {
|
|
1315
1305
|
if (process.env.NODE_ENV !== "production" && (typeof s != "object" || Array.isArray(s)))
|
|
1316
1306
|
throw new Error(
|
|
1317
1307
|
'Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object'
|
|
1318
1308
|
);
|
|
1319
|
-
const r = kt(t), n =
|
|
1309
|
+
const r = kt(t), n = Ls(), u = Gs(), i = r.defaultQueryOptions(s);
|
|
1320
1310
|
i._optimisticResults = n ? "isRestoring" : "optimistic";
|
|
1321
|
-
const [c] =
|
|
1311
|
+
const [c] = jt(
|
|
1322
1312
|
() => new e(
|
|
1323
1313
|
r,
|
|
1324
1314
|
i
|
|
1325
1315
|
)
|
|
1326
|
-
), l = Ze(() => c.observe()), h =
|
|
1316
|
+
), l = Ze(() => c.observe()), h = H(
|
|
1327
1317
|
c.getOptimisticResult(i)
|
|
1328
1318
|
), o = h.current;
|
|
1329
1319
|
Xe(
|
|
@@ -1333,14 +1323,14 @@ function _t(s, e, t) {
|
|
|
1333
1323
|
* It's important to not skip the first result (even tho most of the time they are equal).
|
|
1334
1324
|
* We only skip if they are the same.
|
|
1335
1325
|
*/
|
|
1336
|
-
O((
|
|
1326
|
+
O((F) => !P(F, h.current))
|
|
1337
1327
|
),
|
|
1338
1328
|
[]
|
|
1339
|
-
),
|
|
1329
|
+
), Y(() => {
|
|
1340
1330
|
c.setOptions(i);
|
|
1341
1331
|
}, [i, c]);
|
|
1342
1332
|
const p = o.error;
|
|
1343
|
-
if (p &&
|
|
1333
|
+
if (p && Ys({
|
|
1344
1334
|
result: o,
|
|
1345
1335
|
errorResetBoundary: u,
|
|
1346
1336
|
throwOnError: i.throwOnError,
|
|
@@ -1349,11 +1339,11 @@ function _t(s, e, t) {
|
|
|
1349
1339
|
throw p;
|
|
1350
1340
|
return h.current;
|
|
1351
1341
|
}
|
|
1352
|
-
function
|
|
1353
|
-
return
|
|
1342
|
+
function xr(s, e) {
|
|
1343
|
+
return Lt(s, Ht, e);
|
|
1354
1344
|
}
|
|
1355
|
-
function
|
|
1356
|
-
return
|
|
1345
|
+
function Rr(s, e) {
|
|
1346
|
+
return Lt(
|
|
1357
1347
|
{
|
|
1358
1348
|
refetchOnMount: "idle",
|
|
1359
1349
|
refetchOnReconnect: !1,
|
|
@@ -1361,41 +1351,41 @@ function Er(s, e) {
|
|
|
1361
1351
|
refetchOnWindowFocus: !1,
|
|
1362
1352
|
...s
|
|
1363
1353
|
},
|
|
1364
|
-
|
|
1354
|
+
Ht,
|
|
1365
1355
|
e
|
|
1366
1356
|
);
|
|
1367
1357
|
}
|
|
1368
|
-
function
|
|
1369
|
-
const r = e != null && !Array.isArray(e) ? e : {}, n = r.retry ?? !0, u =
|
|
1358
|
+
function jr(s, e, t = []) {
|
|
1359
|
+
const r = e != null && !Array.isArray(e) ? e : {}, n = r.retry ?? !0, u = H(
|
|
1370
1360
|
r.onError ?? ((l) => {
|
|
1371
1361
|
console.error(l);
|
|
1372
1362
|
})
|
|
1373
|
-
), i =
|
|
1363
|
+
), i = de(() => V(s), t), c = de(
|
|
1374
1364
|
() => i().pipe(
|
|
1375
|
-
|
|
1365
|
+
J((l) => {
|
|
1376
1366
|
throw u.current(l), l;
|
|
1377
1367
|
}),
|
|
1378
|
-
n ?
|
|
1368
|
+
n ? os() : Mt
|
|
1379
1369
|
),
|
|
1380
1370
|
[i, n, u]
|
|
1381
1371
|
);
|
|
1382
|
-
|
|
1372
|
+
Ut(c, t);
|
|
1383
1373
|
}
|
|
1384
|
-
const
|
|
1374
|
+
const zt = () => (s) => C(
|
|
1385
1375
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
1386
1376
|
v({ isPaused: !0 }),
|
|
1387
1377
|
re.backToOnline$.pipe(
|
|
1388
|
-
|
|
1378
|
+
q(
|
|
1389
1379
|
() => (
|
|
1390
1380
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
1391
|
-
|
|
1381
|
+
C(v({ isPaused: !1 }), s)
|
|
1392
1382
|
)
|
|
1393
1383
|
)
|
|
1394
1384
|
)
|
|
1395
|
-
),
|
|
1385
|
+
), Bs = (s) => {
|
|
1396
1386
|
let e = 0;
|
|
1397
1387
|
return s.pipe(
|
|
1398
|
-
|
|
1388
|
+
J((t) => (e++, e <= 1 && !re.isOnline() ? C(
|
|
1399
1389
|
v({
|
|
1400
1390
|
failureCount: e,
|
|
1401
1391
|
failureReason: t
|
|
@@ -1405,35 +1395,33 @@ const Lt = () => (s) => F(
|
|
|
1405
1395
|
* timer needed to be iso RQ, so the state returned by mutation include both previous and next one
|
|
1406
1396
|
*/
|
|
1407
1397
|
Qe(1).pipe(
|
|
1408
|
-
|
|
1409
|
-
() => Oe(() => t).pipe(
|
|
1398
|
+
q(
|
|
1399
|
+
() => Oe(() => t).pipe(zt())
|
|
1410
1400
|
)
|
|
1411
1401
|
)
|
|
1412
1402
|
) : Oe(() => t)))
|
|
1413
1403
|
);
|
|
1414
|
-
},
|
|
1404
|
+
}, Xs = ({
|
|
1415
1405
|
variables: s,
|
|
1416
1406
|
state: e,
|
|
1417
1407
|
options: t
|
|
1418
1408
|
}) => {
|
|
1419
|
-
const r = e.isPaused, n = async () => await Promise.reject(new Error("No mutationFn found")), u = t.mutationFn ?? n,
|
|
1420
|
-
|
|
1421
|
-
v(e.context),
|
|
1422
|
-
U(
|
|
1423
|
-
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
1424
|
-
() => {
|
|
1425
|
-
var d;
|
|
1426
|
-
return ((d = t.onMutate) == null ? void 0 : d.call(t, s)) ?? void 0;
|
|
1427
|
-
}
|
|
1428
|
-
)
|
|
1429
|
-
).pipe(Ue(1)), l = (d, f, y) => U(
|
|
1409
|
+
const r = e.isPaused, n = async () => await Promise.reject(new Error("No mutationFn found")), u = t.mutationFn ?? n, i = V(
|
|
1410
|
+
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
1430
1411
|
() => {
|
|
1431
|
-
var
|
|
1432
|
-
return (
|
|
1412
|
+
var d;
|
|
1413
|
+
return ((d = t.onMutate) == null ? void 0 : d.call(t, s)) ?? void 0;
|
|
1414
|
+
}
|
|
1415
|
+
), c = v(e.context), l = cs(() => r, c, i).pipe(
|
|
1416
|
+
Ue(1)
|
|
1417
|
+
), h = (d, f, y) => V(
|
|
1418
|
+
() => {
|
|
1419
|
+
var E;
|
|
1420
|
+
return (E = t.onError) == null ? void 0 : E.call(t, d, s, f);
|
|
1433
1421
|
}
|
|
1434
1422
|
).pipe(
|
|
1435
|
-
|
|
1436
|
-
|
|
1423
|
+
J(() => v(d)),
|
|
1424
|
+
b(
|
|
1437
1425
|
() => ({
|
|
1438
1426
|
failureCount: y,
|
|
1439
1427
|
error: d,
|
|
@@ -1442,50 +1430,57 @@ const Lt = () => (s) => F(
|
|
|
1442
1430
|
status: "error"
|
|
1443
1431
|
})
|
|
1444
1432
|
)
|
|
1445
|
-
),
|
|
1446
|
-
|
|
1433
|
+
), o = l.pipe(
|
|
1434
|
+
j((d) => {
|
|
1447
1435
|
const y = (typeof u == "function" ? (
|
|
1448
1436
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
1449
|
-
|
|
1450
|
-
) : u).pipe(
|
|
1451
|
-
|
|
1452
|
-
|
|
1437
|
+
V(() => u(s))
|
|
1438
|
+
) : u).pipe(ue()), x = y.pipe(
|
|
1439
|
+
ls(),
|
|
1440
|
+
R(($) => {
|
|
1441
|
+
if ($)
|
|
1442
|
+
throw new Error("Mutation completed without any emission (EMPTY)");
|
|
1443
|
+
}),
|
|
1444
|
+
ie()
|
|
1445
|
+
), E = C(y, x).pipe(
|
|
1446
|
+
b(
|
|
1447
|
+
($) => ({
|
|
1453
1448
|
result: {
|
|
1454
|
-
data:
|
|
1449
|
+
data: $
|
|
1455
1450
|
},
|
|
1456
1451
|
error: null,
|
|
1457
1452
|
context: d
|
|
1458
1453
|
})
|
|
1459
1454
|
),
|
|
1460
|
-
|
|
1461
|
-
|
|
1455
|
+
Bs,
|
|
1456
|
+
Pt({
|
|
1462
1457
|
...t,
|
|
1463
|
-
retry: (
|
|
1464
|
-
const
|
|
1465
|
-
return typeof
|
|
1458
|
+
retry: ($, D) => {
|
|
1459
|
+
const S = t.retry ?? 0;
|
|
1460
|
+
return typeof S == "function" ? S($, D) : typeof S == "boolean" ? S : $ < S;
|
|
1466
1461
|
},
|
|
1467
|
-
caughtError: (
|
|
1462
|
+
caughtError: ($, D) => (
|
|
1468
1463
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
1469
1464
|
v({
|
|
1470
|
-
failureCount:
|
|
1471
|
-
failureReason:
|
|
1465
|
+
failureCount: $,
|
|
1466
|
+
failureReason: D
|
|
1472
1467
|
})
|
|
1473
1468
|
),
|
|
1474
|
-
catchError: (
|
|
1475
|
-
|
|
1476
|
-
...
|
|
1469
|
+
catchError: ($, D) => h(D, d, $).pipe(
|
|
1470
|
+
b((S) => ({
|
|
1471
|
+
...S,
|
|
1477
1472
|
result: void 0
|
|
1478
1473
|
}))
|
|
1479
1474
|
)
|
|
1480
1475
|
}),
|
|
1481
1476
|
Ye(
|
|
1482
|
-
({ result:
|
|
1477
|
+
({ result: $, error: D }) => ($ == null ? void 0 : $.data) === void 0 && D === void 0,
|
|
1483
1478
|
!0
|
|
1484
1479
|
)
|
|
1485
1480
|
);
|
|
1486
|
-
return re.isOnline() || t.networkMode === "offlineFirst" || t.networkMode === "always" ?
|
|
1481
|
+
return re.isOnline() || t.networkMode === "offlineFirst" || t.networkMode === "always" ? E : E.pipe(zt());
|
|
1487
1482
|
})
|
|
1488
|
-
),
|
|
1483
|
+
), p = v({
|
|
1489
1484
|
...e,
|
|
1490
1485
|
variables: s,
|
|
1491
1486
|
status: "pending",
|
|
@@ -1494,30 +1489,30 @@ const Lt = () => (s) => F(
|
|
|
1494
1489
|
failureReason: null,
|
|
1495
1490
|
submittedAt: e.submittedAt ?? (/* @__PURE__ */ new Date()).getTime()
|
|
1496
1491
|
});
|
|
1497
|
-
return
|
|
1498
|
-
|
|
1492
|
+
return C(
|
|
1493
|
+
p,
|
|
1499
1494
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1495
|
+
l.pipe(b((d) => ({ context: d }))),
|
|
1496
|
+
o.pipe(
|
|
1497
|
+
j(({ result: d, error: f, ...y }) => {
|
|
1503
1498
|
if (!d && !f)
|
|
1504
1499
|
return v({
|
|
1505
1500
|
...y
|
|
1506
1501
|
});
|
|
1507
|
-
const
|
|
1502
|
+
const x = f ? v(null) : V(
|
|
1508
1503
|
() => {
|
|
1509
|
-
var
|
|
1510
|
-
return (
|
|
1504
|
+
var S;
|
|
1505
|
+
return (S = t.onSuccess) == null ? void 0 : S.call(
|
|
1511
1506
|
t,
|
|
1512
1507
|
d == null ? void 0 : d.data,
|
|
1513
1508
|
s,
|
|
1514
1509
|
y.context
|
|
1515
1510
|
);
|
|
1516
1511
|
}
|
|
1517
|
-
),
|
|
1512
|
+
), $ = V(
|
|
1518
1513
|
() => {
|
|
1519
|
-
var
|
|
1520
|
-
return (
|
|
1514
|
+
var S;
|
|
1515
|
+
return (S = t.onSettled) == null ? void 0 : S.call(
|
|
1521
1516
|
t,
|
|
1522
1517
|
d == null ? void 0 : d.data,
|
|
1523
1518
|
f,
|
|
@@ -1526,11 +1521,11 @@ const Lt = () => (s) => F(
|
|
|
1526
1521
|
);
|
|
1527
1522
|
}
|
|
1528
1523
|
).pipe(
|
|
1529
|
-
|
|
1524
|
+
J((S) => d ? v(d) : v(S))
|
|
1530
1525
|
);
|
|
1531
|
-
return
|
|
1532
|
-
|
|
1533
|
-
|
|
1526
|
+
return Te(x, $).pipe(
|
|
1527
|
+
ke(),
|
|
1528
|
+
b(
|
|
1534
1529
|
() => f ? {
|
|
1535
1530
|
error: f,
|
|
1536
1531
|
data: void 0,
|
|
@@ -1546,10 +1541,10 @@ const Lt = () => (s) => F(
|
|
|
1546
1541
|
...y
|
|
1547
1542
|
}
|
|
1548
1543
|
),
|
|
1549
|
-
|
|
1550
|
-
(
|
|
1551
|
-
|
|
1552
|
-
...
|
|
1544
|
+
J(
|
|
1545
|
+
(S) => h(S, y.context, 0).pipe(
|
|
1546
|
+
b((m) => ({
|
|
1547
|
+
...m,
|
|
1553
1548
|
data: void 0
|
|
1554
1549
|
}))
|
|
1555
1550
|
)
|
|
@@ -1567,75 +1562,75 @@ const Lt = () => (s) => F(
|
|
|
1567
1562
|
);
|
|
1568
1563
|
};
|
|
1569
1564
|
var Ee, se, be;
|
|
1570
|
-
class
|
|
1565
|
+
class Zs {
|
|
1571
1566
|
constructor({
|
|
1572
1567
|
options: e,
|
|
1573
1568
|
mutationCache: t,
|
|
1574
1569
|
state: r
|
|
1575
1570
|
}) {
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1571
|
+
w(this, Ee, new X(0));
|
|
1572
|
+
w(this, se, new I());
|
|
1573
|
+
w(this, be, new I());
|
|
1574
|
+
g(this, "state", fe());
|
|
1575
|
+
g(this, "state$");
|
|
1576
|
+
g(this, "options");
|
|
1577
|
+
g(this, "observerCount$", a(this, Ee).asObservable());
|
|
1578
|
+
g(this, "cancelled$", a(this, se).asObservable());
|
|
1584
1579
|
this.options = e, this.state = r ?? this.state;
|
|
1585
1580
|
const n = a(this, se).pipe(
|
|
1586
1581
|
O(() => this.state.status === "pending"),
|
|
1587
|
-
|
|
1582
|
+
b(() => ({
|
|
1588
1583
|
status: "idle"
|
|
1589
1584
|
}))
|
|
1590
1585
|
), u = a(this, be).pipe(
|
|
1591
|
-
|
|
1592
|
-
(c) =>
|
|
1586
|
+
j(
|
|
1587
|
+
(c) => Xs({
|
|
1593
1588
|
options: {
|
|
1594
1589
|
...this.options,
|
|
1595
1590
|
onMutate: (l) => {
|
|
1596
|
-
const h =
|
|
1591
|
+
const h = V(
|
|
1597
1592
|
() => {
|
|
1598
|
-
var
|
|
1599
|
-
return (
|
|
1600
|
-
|
|
1593
|
+
var d, f;
|
|
1594
|
+
return (f = (d = t.config).onMutate) == null ? void 0 : f.call(
|
|
1595
|
+
d,
|
|
1601
1596
|
l,
|
|
1602
1597
|
this
|
|
1603
1598
|
);
|
|
1604
1599
|
}
|
|
1605
|
-
), p =
|
|
1606
|
-
var
|
|
1607
|
-
return (
|
|
1600
|
+
), p = V(() => {
|
|
1601
|
+
var d, f;
|
|
1602
|
+
return (f = (d = this.options).onMutate) == null ? void 0 : f.call(d, l);
|
|
1608
1603
|
});
|
|
1609
1604
|
return h.pipe(
|
|
1610
|
-
|
|
1605
|
+
q(() => p)
|
|
1611
1606
|
);
|
|
1612
1607
|
},
|
|
1613
1608
|
onError: (l, h, o) => {
|
|
1614
|
-
const p =
|
|
1609
|
+
const p = V(
|
|
1615
1610
|
() => {
|
|
1616
|
-
var
|
|
1617
|
-
return (
|
|
1618
|
-
|
|
1611
|
+
var d, f;
|
|
1612
|
+
return (f = (d = t.config).onError) == null ? void 0 : f.call(
|
|
1613
|
+
d,
|
|
1619
1614
|
l,
|
|
1620
1615
|
h,
|
|
1621
1616
|
o,
|
|
1622
1617
|
this
|
|
1623
1618
|
);
|
|
1624
1619
|
}
|
|
1625
|
-
),
|
|
1620
|
+
), F = V(
|
|
1626
1621
|
() => {
|
|
1627
|
-
var
|
|
1628
|
-
return (
|
|
1622
|
+
var d, f;
|
|
1623
|
+
return (f = (d = this.options).onError) == null ? void 0 : f.call(d, l, h, o);
|
|
1629
1624
|
}
|
|
1630
1625
|
);
|
|
1631
|
-
return
|
|
1626
|
+
return Te(p, F).pipe(ke());
|
|
1632
1627
|
},
|
|
1633
1628
|
onSettled: (l, h, o, p) => {
|
|
1634
|
-
const
|
|
1629
|
+
const F = V(
|
|
1635
1630
|
() => {
|
|
1636
|
-
var
|
|
1637
|
-
return (
|
|
1638
|
-
|
|
1631
|
+
var f, y;
|
|
1632
|
+
return (y = (f = t.config).onSettled) == null ? void 0 : y.call(
|
|
1633
|
+
f,
|
|
1639
1634
|
l,
|
|
1640
1635
|
h,
|
|
1641
1636
|
o,
|
|
@@ -1643,42 +1638,42 @@ class Bs {
|
|
|
1643
1638
|
this
|
|
1644
1639
|
);
|
|
1645
1640
|
}
|
|
1646
|
-
),
|
|
1641
|
+
), d = V(
|
|
1647
1642
|
() => {
|
|
1648
|
-
var
|
|
1649
|
-
return (
|
|
1643
|
+
var f, y;
|
|
1644
|
+
return (y = (f = this.options).onSettled) == null ? void 0 : y.call(f, l, h, o, p);
|
|
1650
1645
|
}
|
|
1651
1646
|
);
|
|
1652
|
-
return
|
|
1647
|
+
return Te(F, d).pipe(ke());
|
|
1653
1648
|
},
|
|
1654
1649
|
onSuccess: (l, h, o) => {
|
|
1655
|
-
const p =
|
|
1650
|
+
const p = V(
|
|
1656
1651
|
() => {
|
|
1657
|
-
var
|
|
1658
|
-
return (
|
|
1659
|
-
|
|
1652
|
+
var d, f;
|
|
1653
|
+
return (f = (d = t.config).onSuccess) == null ? void 0 : f.call(
|
|
1654
|
+
d,
|
|
1660
1655
|
l,
|
|
1661
1656
|
h,
|
|
1662
1657
|
o,
|
|
1663
1658
|
this
|
|
1664
1659
|
);
|
|
1665
1660
|
}
|
|
1666
|
-
),
|
|
1661
|
+
), F = V(
|
|
1667
1662
|
() => {
|
|
1668
|
-
var
|
|
1669
|
-
return (
|
|
1663
|
+
var d, f;
|
|
1664
|
+
return (f = (d = this.options).onSuccess) == null ? void 0 : f.call(d, l, h, o);
|
|
1670
1665
|
}
|
|
1671
1666
|
);
|
|
1672
|
-
return
|
|
1667
|
+
return Te(p, F).pipe(ke());
|
|
1673
1668
|
}
|
|
1674
1669
|
},
|
|
1675
1670
|
state: this.state,
|
|
1676
1671
|
variables: c
|
|
1677
1672
|
}).pipe(ne(a(this, se)))
|
|
1678
1673
|
)
|
|
1679
|
-
), i =
|
|
1674
|
+
), i = C(n, u);
|
|
1680
1675
|
this.state$ = i.pipe(
|
|
1681
|
-
|
|
1676
|
+
he(this.state),
|
|
1682
1677
|
Be(
|
|
1683
1678
|
(c, l) => ({
|
|
1684
1679
|
...c,
|
|
@@ -1686,8 +1681,8 @@ class Bs {
|
|
|
1686
1681
|
}),
|
|
1687
1682
|
this.state
|
|
1688
1683
|
),
|
|
1689
|
-
|
|
1690
|
-
|
|
1684
|
+
Dt,
|
|
1685
|
+
R((c) => {
|
|
1691
1686
|
this.state = c;
|
|
1692
1687
|
}),
|
|
1693
1688
|
Ue(1),
|
|
@@ -1723,41 +1718,41 @@ class Bs {
|
|
|
1723
1718
|
}
|
|
1724
1719
|
}
|
|
1725
1720
|
Ee = new WeakMap(), se = new WeakMap(), be = new WeakMap();
|
|
1726
|
-
const
|
|
1721
|
+
const Rt = ({
|
|
1727
1722
|
mutationKey: s,
|
|
1728
1723
|
status: e,
|
|
1729
1724
|
predicate: t,
|
|
1730
1725
|
exact: r = !0
|
|
1731
1726
|
} = {}) => (u) => r && s !== void 0 && u.options.mutationKey !== void 0 && !_e(u.options.mutationKey, s, { exact: r }) || !r && s !== void 0 && u.options.mutationKey !== void 0 && !_e(u.options.mutationKey, s, { exact: r }) || e && u.state.status !== e ? !1 : t ? t(u) : !0;
|
|
1732
|
-
class
|
|
1727
|
+
class Wt {
|
|
1733
1728
|
constructor() {
|
|
1734
1729
|
/**
|
|
1735
1730
|
* @important
|
|
1736
1731
|
* Query store. Could be turned into a map for more performance.
|
|
1737
1732
|
*/
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1733
|
+
g(this, "entriesSubject", new X([]));
|
|
1734
|
+
g(this, "changeSubject", new I());
|
|
1735
|
+
g(this, "entries$", this.entriesSubject.pipe(ue()));
|
|
1736
|
+
g(this, "added$", this.changeSubject.pipe(
|
|
1742
1737
|
O(({ type: e }) => e === "added"),
|
|
1743
|
-
|
|
1744
|
-
|
|
1738
|
+
b(({ entity: e }) => e),
|
|
1739
|
+
ue()
|
|
1745
1740
|
));
|
|
1746
|
-
|
|
1741
|
+
g(this, "removed$", this.changeSubject.pipe(
|
|
1747
1742
|
O(({ type: e }) => e === "removed"),
|
|
1748
|
-
|
|
1749
|
-
|
|
1743
|
+
b(({ entity: e }) => e),
|
|
1744
|
+
ue()
|
|
1750
1745
|
));
|
|
1751
|
-
|
|
1746
|
+
g(this, "stateChange$", C(
|
|
1752
1747
|
this.entriesSubject.pipe(
|
|
1753
1748
|
Je(),
|
|
1754
|
-
|
|
1749
|
+
q((e) => Se(e))
|
|
1755
1750
|
),
|
|
1756
1751
|
this.added$
|
|
1757
1752
|
).pipe(
|
|
1758
|
-
|
|
1753
|
+
q(
|
|
1759
1754
|
(e) => e.state$.pipe(
|
|
1760
|
-
|
|
1755
|
+
b(() => e),
|
|
1761
1756
|
ne(
|
|
1762
1757
|
this.removed$.pipe(
|
|
1763
1758
|
O((t) => t === e)
|
|
@@ -1765,7 +1760,7 @@ class zt {
|
|
|
1765
1760
|
)
|
|
1766
1761
|
)
|
|
1767
1762
|
),
|
|
1768
|
-
|
|
1763
|
+
ue()
|
|
1769
1764
|
));
|
|
1770
1765
|
}
|
|
1771
1766
|
getValues() {
|
|
@@ -1783,14 +1778,14 @@ class zt {
|
|
|
1783
1778
|
return this.entriesSubject.getValue().find(e);
|
|
1784
1779
|
}
|
|
1785
1780
|
}
|
|
1786
|
-
var
|
|
1787
|
-
class
|
|
1781
|
+
var K;
|
|
1782
|
+
class er {
|
|
1788
1783
|
constructor(e = {}) {
|
|
1789
|
-
|
|
1784
|
+
w(this, K, new Wt());
|
|
1790
1785
|
this.config = e;
|
|
1791
1786
|
}
|
|
1792
1787
|
build(e, t, r) {
|
|
1793
|
-
const n = new
|
|
1788
|
+
const n = new Zs({
|
|
1794
1789
|
mutationCache: this,
|
|
1795
1790
|
options: e.defaultMutationOptions(t),
|
|
1796
1791
|
state: r
|
|
@@ -1801,63 +1796,63 @@ class Xs {
|
|
|
1801
1796
|
* we start the process of cleaning it up based on gc settings
|
|
1802
1797
|
*/
|
|
1803
1798
|
O(({ status: u }) => u === "success" || u === "error"),
|
|
1804
|
-
|
|
1799
|
+
j(
|
|
1805
1800
|
() => n.observerCount$.pipe(
|
|
1806
1801
|
O((u) => u <= 1),
|
|
1807
1802
|
He(1)
|
|
1808
1803
|
)
|
|
1809
1804
|
),
|
|
1810
1805
|
// defaults to 5mn
|
|
1811
|
-
|
|
1806
|
+
j(() => Qe(n.options.gcTime ?? 5 * 60 * 1e3)),
|
|
1812
1807
|
He(1)
|
|
1813
1808
|
).subscribe({
|
|
1814
1809
|
complete: () => {
|
|
1815
1810
|
this.remove(n);
|
|
1816
1811
|
}
|
|
1817
|
-
}), a(this,
|
|
1812
|
+
}), a(this, K).add(n), n;
|
|
1818
1813
|
}
|
|
1819
1814
|
getAll() {
|
|
1820
1815
|
return this.findAll();
|
|
1821
1816
|
}
|
|
1822
1817
|
remove(e) {
|
|
1823
|
-
const t = a(this,
|
|
1824
|
-
t == null || t.cancel(), a(this,
|
|
1818
|
+
const t = a(this, K).getValues().find((r) => r === e);
|
|
1819
|
+
t == null || t.cancel(), a(this, K).remove(e);
|
|
1825
1820
|
}
|
|
1826
1821
|
find(e) {
|
|
1827
|
-
const t = { exact: !0, ...e }, r =
|
|
1828
|
-
return a(this,
|
|
1822
|
+
const t = { exact: !0, ...e }, r = Rt(t);
|
|
1823
|
+
return a(this, K).getValues().find((n) => r(n));
|
|
1829
1824
|
}
|
|
1830
1825
|
findAll(e = {}) {
|
|
1831
|
-
const t = { exact: !0, ...e }, r =
|
|
1832
|
-
return a(this,
|
|
1826
|
+
const t = { exact: !0, ...e }, r = Rt(t);
|
|
1827
|
+
return a(this, K).getValues().filter((n) => r(n)).map((n) => n);
|
|
1833
1828
|
}
|
|
1834
1829
|
observe() {
|
|
1835
|
-
return a(this,
|
|
1830
|
+
return a(this, K).stateChange$.pipe(he());
|
|
1836
1831
|
}
|
|
1837
1832
|
/**
|
|
1838
1833
|
* @important
|
|
1839
1834
|
* ISO api react-query
|
|
1840
1835
|
*/
|
|
1841
1836
|
subscribe(e) {
|
|
1842
|
-
const t =
|
|
1843
|
-
a(this,
|
|
1844
|
-
|
|
1837
|
+
const t = C(
|
|
1838
|
+
a(this, K).added$.pipe(
|
|
1839
|
+
R((r) => {
|
|
1845
1840
|
e({
|
|
1846
1841
|
type: "added",
|
|
1847
1842
|
mutation: r
|
|
1848
1843
|
});
|
|
1849
1844
|
})
|
|
1850
1845
|
),
|
|
1851
|
-
a(this,
|
|
1852
|
-
|
|
1846
|
+
a(this, K).removed$.pipe(
|
|
1847
|
+
R((r) => {
|
|
1853
1848
|
e({
|
|
1854
1849
|
type: "removed",
|
|
1855
1850
|
mutation: r
|
|
1856
1851
|
});
|
|
1857
1852
|
})
|
|
1858
1853
|
),
|
|
1859
|
-
a(this,
|
|
1860
|
-
|
|
1854
|
+
a(this, K).stateChange$.pipe(
|
|
1855
|
+
R((r) => {
|
|
1861
1856
|
e({
|
|
1862
1857
|
type: "updated",
|
|
1863
1858
|
action: {
|
|
@@ -1877,10 +1872,9 @@ class Xs {
|
|
|
1877
1872
|
const e = this.findAll({
|
|
1878
1873
|
predicate: (r) => r.state.isPaused
|
|
1879
1874
|
});
|
|
1880
|
-
if (!e.length)
|
|
1881
|
-
return Z;
|
|
1875
|
+
if (!e.length) return B;
|
|
1882
1876
|
const t = e.map((r) => r.continue());
|
|
1883
|
-
return
|
|
1877
|
+
return hs(t);
|
|
1884
1878
|
}
|
|
1885
1879
|
clear() {
|
|
1886
1880
|
this.getAll().forEach((e) => {
|
|
@@ -1888,8 +1882,8 @@ class Xs {
|
|
|
1888
1882
|
});
|
|
1889
1883
|
}
|
|
1890
1884
|
}
|
|
1891
|
-
|
|
1892
|
-
function
|
|
1885
|
+
K = new WeakMap();
|
|
1886
|
+
function tr(s) {
|
|
1893
1887
|
const e = typeof s.initialData == "function" ? s.initialData() : s.initialData, t = typeof e < "u", r = t ? typeof s.initialDataUpdatedAt == "function" ? s.initialDataUpdatedAt() : s.initialDataUpdatedAt : 0;
|
|
1894
1888
|
return {
|
|
1895
1889
|
data: e,
|
|
@@ -1906,26 +1900,26 @@ function Zs(s) {
|
|
|
1906
1900
|
fetchStatus: "idle"
|
|
1907
1901
|
};
|
|
1908
1902
|
}
|
|
1909
|
-
const
|
|
1903
|
+
const sr = (s) => Ae(() => ze.isFocused() ? s : ze.focusRegained$.pipe(q(() => s))), rr = (s) => {
|
|
1910
1904
|
let e = 0;
|
|
1911
1905
|
return (t) => {
|
|
1912
1906
|
const r = re.backToOnline$.pipe(
|
|
1913
|
-
|
|
1914
|
-
() =>
|
|
1907
|
+
q(
|
|
1908
|
+
() => C(
|
|
1915
1909
|
v({ fetchStatus: "fetching" }),
|
|
1916
1910
|
t
|
|
1917
1911
|
)
|
|
1918
1912
|
)
|
|
1919
1913
|
);
|
|
1920
|
-
return Ae(() => (e++, !re.isOnline() && s.networkMode === "offlineFirst" && e > 1 ?
|
|
1914
|
+
return Ae(() => (e++, !re.isOnline() && s.networkMode === "offlineFirst" && e > 1 ? C(
|
|
1921
1915
|
v({ fetchStatus: "paused" }),
|
|
1922
1916
|
r
|
|
1923
|
-
) : !re.isOnline() && s.networkMode !== "always" && s.networkMode !== "offlineFirst" ?
|
|
1917
|
+
) : !re.isOnline() && s.networkMode !== "always" && s.networkMode !== "offlineFirst" ? C(
|
|
1924
1918
|
v({ fetchStatus: "paused" }),
|
|
1925
1919
|
r
|
|
1926
1920
|
) : t));
|
|
1927
1921
|
};
|
|
1928
|
-
},
|
|
1922
|
+
}, nr = (s) => (e) => {
|
|
1929
1923
|
const t = new I(), r = t.pipe(
|
|
1930
1924
|
Je(),
|
|
1931
1925
|
/**
|
|
@@ -1933,15 +1927,15 @@ const er = (s) => Ae(() => ze.isFocused() ? s : ze.focusRegained$.pipe(N(() => s
|
|
|
1933
1927
|
* for the next tick to make sure observable chain received this data at least
|
|
1934
1928
|
*/
|
|
1935
1929
|
ot(1),
|
|
1936
|
-
|
|
1930
|
+
q(() => s.pipe(O((n) => n === 0)))
|
|
1937
1931
|
);
|
|
1938
1932
|
return e.pipe(
|
|
1939
|
-
|
|
1933
|
+
R(() => {
|
|
1940
1934
|
t.next();
|
|
1941
1935
|
}),
|
|
1942
1936
|
ne(r)
|
|
1943
1937
|
);
|
|
1944
|
-
},
|
|
1938
|
+
}, ir = (s) => {
|
|
1945
1939
|
const e = async () => await Promise.reject(new Error("No query found"));
|
|
1946
1940
|
process.env.NODE_ENV !== "production" && s.queryFn === it && console.error(
|
|
1947
1941
|
`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${s.queryHash}'`
|
|
@@ -1959,26 +1953,26 @@ const er = (s) => Ae(() => ze.isFocused() ? s : ze.focusRegained$.pipe(N(() => s
|
|
|
1959
1953
|
})(u);
|
|
1960
1954
|
const l = (typeof r == "function" ? (
|
|
1961
1955
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
1962
|
-
|
|
1956
|
+
V(
|
|
1963
1957
|
() => r(u)
|
|
1964
1958
|
)
|
|
1965
1959
|
) : r).pipe(
|
|
1966
|
-
|
|
1967
|
-
|
|
1960
|
+
nr(s.observers$),
|
|
1961
|
+
R({
|
|
1968
1962
|
complete: () => {
|
|
1969
1963
|
t = !0;
|
|
1970
1964
|
}
|
|
1971
1965
|
}),
|
|
1972
|
-
|
|
1966
|
+
b(
|
|
1973
1967
|
(o) => ({
|
|
1974
1968
|
data: o
|
|
1975
1969
|
})
|
|
1976
1970
|
),
|
|
1977
1971
|
// takeUntil(hasDataAndNoObservers$),
|
|
1978
|
-
|
|
1979
|
-
|
|
1972
|
+
rr(s),
|
|
1973
|
+
Pt({
|
|
1980
1974
|
...s,
|
|
1981
|
-
retryAfter: () => v(!0).pipe(
|
|
1975
|
+
retryAfter: () => v(!0).pipe(sr),
|
|
1982
1976
|
catchError: (o, p) => v({
|
|
1983
1977
|
status: "error",
|
|
1984
1978
|
fetchStatus: "idle",
|
|
@@ -1994,7 +1988,7 @@ const er = (s) => Ae(() => ze.isFocused() ? s : ze.focusRegained$.pipe(N(() => s
|
|
|
1994
1988
|
})
|
|
1995
1989
|
)
|
|
1996
1990
|
}),
|
|
1997
|
-
|
|
1991
|
+
q((o) => "data" in o ? v({
|
|
1998
1992
|
...o,
|
|
1999
1993
|
status: "success",
|
|
2000
1994
|
fetchStatus: "idle",
|
|
@@ -2018,7 +2012,7 @@ const er = (s) => Ae(() => ze.isFocused() ? s : ze.focusRegained$.pipe(N(() => s
|
|
|
2018
2012
|
* There is in theory no problem associated to that.
|
|
2019
2013
|
*/
|
|
2020
2014
|
ot(1),
|
|
2021
|
-
|
|
2015
|
+
b(
|
|
2022
2016
|
(p) => t ? p : { ...p, fetchStatus: "fetching" }
|
|
2023
2017
|
)
|
|
2024
2018
|
) : v(o)),
|
|
@@ -2027,30 +2021,30 @@ const er = (s) => Ae(() => ze.isFocused() ? s : ze.focusRegained$.pipe(N(() => s
|
|
|
2027
2021
|
* before shallow compare will not update the state, otherwise it's our chance to catch
|
|
2028
2022
|
* the end of observable fn.
|
|
2029
2023
|
*/
|
|
2030
|
-
|
|
2031
|
-
|
|
2024
|
+
ds({ fetchStatus: "idle" }),
|
|
2025
|
+
ue()
|
|
2032
2026
|
), h = v({
|
|
2033
2027
|
status: "pending",
|
|
2034
2028
|
fetchStatus: re.isOnline() ? "fetching" : "paused"
|
|
2035
2029
|
});
|
|
2036
2030
|
return {
|
|
2037
|
-
state$:
|
|
2031
|
+
state$: C(
|
|
2038
2032
|
h,
|
|
2039
2033
|
l
|
|
2040
2034
|
// emitOnComplete$
|
|
2041
|
-
).pipe(
|
|
2035
|
+
).pipe(ue()),
|
|
2042
2036
|
abortController: n
|
|
2043
2037
|
};
|
|
2044
2038
|
};
|
|
2045
|
-
class
|
|
2039
|
+
class ur {
|
|
2046
2040
|
constructor(e) {
|
|
2047
|
-
|
|
2048
|
-
|
|
2041
|
+
g(this, "revert");
|
|
2042
|
+
g(this, "silent");
|
|
2049
2043
|
this.revert = e == null ? void 0 : e.revert, this.silent = e == null ? void 0 : e.silent;
|
|
2050
2044
|
}
|
|
2051
2045
|
}
|
|
2052
|
-
const
|
|
2053
|
-
function
|
|
2046
|
+
const ar = { backgroundColor: "transparent", color: "inherit" };
|
|
2047
|
+
function Gt(s) {
|
|
2054
2048
|
const e = {
|
|
2055
2049
|
namespaces: [
|
|
2056
2050
|
{
|
|
@@ -2059,10 +2053,10 @@ function Wt(s) {
|
|
|
2059
2053
|
}
|
|
2060
2054
|
],
|
|
2061
2055
|
namespace(t, r) {
|
|
2062
|
-
const n =
|
|
2056
|
+
const n = Gt();
|
|
2063
2057
|
return n.namespaces.push({
|
|
2064
2058
|
name: t,
|
|
2065
|
-
style: r ??
|
|
2059
|
+
style: r ?? ar
|
|
2066
2060
|
}), n;
|
|
2067
2061
|
},
|
|
2068
2062
|
printNamespaces() {
|
|
@@ -2097,36 +2091,36 @@ function Wt(s) {
|
|
|
2097
2091
|
};
|
|
2098
2092
|
return e;
|
|
2099
2093
|
}
|
|
2100
|
-
const
|
|
2101
|
-
var xe,
|
|
2102
|
-
class
|
|
2094
|
+
const or = Gt();
|
|
2095
|
+
var xe, ce;
|
|
2096
|
+
class cr {
|
|
2103
2097
|
constructor(e) {
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2098
|
+
g(this, "queryKey");
|
|
2099
|
+
g(this, "queryHash");
|
|
2100
|
+
g(this, "gcTime");
|
|
2101
|
+
g(this, "options");
|
|
2102
|
+
w(this, xe);
|
|
2103
|
+
w(this, ce);
|
|
2104
|
+
g(this, "state");
|
|
2111
2105
|
// @todo to share with mutation
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2106
|
+
g(this, "executeSubject", new I());
|
|
2107
|
+
g(this, "cancelSubject", new I());
|
|
2108
|
+
g(this, "setDataSubject", new I());
|
|
2109
|
+
g(this, "invalidatedSubject", new I());
|
|
2110
|
+
g(this, "resetSubject", new I());
|
|
2111
|
+
g(this, "destroySubject", new I());
|
|
2112
|
+
g(this, "observersSubject", new X([]));
|
|
2113
|
+
g(this, "abortSignalConsumed", !1);
|
|
2114
|
+
g(this, "observerCount$", this.observersSubject.asObservable().pipe(b((e) => e.length)));
|
|
2115
|
+
g(this, "observers$", this.observersSubject.asObservable());
|
|
2116
|
+
g(this, "state$");
|
|
2117
|
+
A(this, xe, e.defaultOptions), this.options = this.setOptions(e.options), this.queryKey = e.queryKey, this.queryHash = e.queryHash, A(this, ce, e.state ?? tr(this.options)), this.state = a(this, ce), this.gcTime = this.updateGcTime(this.options.gcTime), this.state$ = C(
|
|
2124
2118
|
this.resetSubject.pipe(
|
|
2125
|
-
|
|
2119
|
+
b(() => ({ command: "reset", state: a(this, ce) }))
|
|
2126
2120
|
),
|
|
2127
2121
|
this.invalidatedSubject.pipe(
|
|
2128
2122
|
O(() => !this.state.isInvalidated),
|
|
2129
|
-
|
|
2123
|
+
b(() => ({
|
|
2130
2124
|
command: "invalidate",
|
|
2131
2125
|
state: {
|
|
2132
2126
|
isInvalidated: !0
|
|
@@ -2135,29 +2129,29 @@ class ar {
|
|
|
2135
2129
|
),
|
|
2136
2130
|
this.cancelSubject.pipe(
|
|
2137
2131
|
O(() => !(this.state.error && this.state.status === "error")),
|
|
2138
|
-
|
|
2132
|
+
b((t) => ({
|
|
2139
2133
|
command: "cancel",
|
|
2140
2134
|
state: {
|
|
2141
2135
|
status: t != null && t.revert ? this.state.status : "error",
|
|
2142
2136
|
fetchStatus: "idle",
|
|
2143
|
-
error: new
|
|
2137
|
+
error: new ur(t)
|
|
2144
2138
|
}
|
|
2145
2139
|
}))
|
|
2146
2140
|
),
|
|
2147
2141
|
this.executeSubject.pipe(
|
|
2148
|
-
|
|
2142
|
+
q(() => {
|
|
2149
2143
|
let t = !1;
|
|
2150
2144
|
const r = this.executeSubject.pipe(
|
|
2151
2145
|
// should not be needed since the fetch return current promise
|
|
2152
2146
|
// in case we don't cancel
|
|
2153
2147
|
O((h) => (h == null ? void 0 : h.cancelRefetch) !== !1)
|
|
2154
2148
|
), n = this.observers$.pipe(
|
|
2155
|
-
|
|
2156
|
-
|
|
2149
|
+
At(),
|
|
2150
|
+
R(([h, o]) => {
|
|
2157
2151
|
o.length === 0 && h.length > 0 ? t = !0 : t = !1;
|
|
2158
2152
|
}),
|
|
2159
|
-
|
|
2160
|
-
), { state$: u, abortController: i } =
|
|
2153
|
+
ie()
|
|
2154
|
+
), { state$: u, abortController: i } = ir({
|
|
2161
2155
|
...this.options,
|
|
2162
2156
|
observers$: this.observerCount$,
|
|
2163
2157
|
queryKey: this.queryKey,
|
|
@@ -2171,21 +2165,21 @@ class ar {
|
|
|
2171
2165
|
}
|
|
2172
2166
|
}), c = this.observerCount$.pipe(
|
|
2173
2167
|
O((h) => h === 0 && this.abortSignalConsumed),
|
|
2174
|
-
|
|
2168
|
+
R(() => {
|
|
2175
2169
|
this.cancelSubject.next({ revert: !0 });
|
|
2176
2170
|
})
|
|
2177
|
-
), l =
|
|
2171
|
+
), l = C(
|
|
2178
2172
|
this.cancelSubject,
|
|
2179
2173
|
r,
|
|
2180
2174
|
this.resetSubject,
|
|
2181
2175
|
c
|
|
2182
2176
|
).pipe(
|
|
2183
|
-
|
|
2177
|
+
R(() => {
|
|
2184
2178
|
this.abortSignalConsumed && i.abort();
|
|
2185
2179
|
})
|
|
2186
2180
|
);
|
|
2187
|
-
return
|
|
2188
|
-
|
|
2181
|
+
return C(u, n).pipe(
|
|
2182
|
+
b((h) => ({
|
|
2189
2183
|
command: "execute",
|
|
2190
2184
|
state: h
|
|
2191
2185
|
})),
|
|
@@ -2194,7 +2188,7 @@ class ar {
|
|
|
2194
2188
|
})
|
|
2195
2189
|
),
|
|
2196
2190
|
this.setDataSubject.pipe(
|
|
2197
|
-
|
|
2191
|
+
b(({ data: t, options: r }) => ({
|
|
2198
2192
|
command: "setData",
|
|
2199
2193
|
state: {
|
|
2200
2194
|
status: "success",
|
|
@@ -2204,18 +2198,18 @@ class ar {
|
|
|
2204
2198
|
}))
|
|
2205
2199
|
)
|
|
2206
2200
|
).pipe(
|
|
2207
|
-
|
|
2201
|
+
Ks({
|
|
2208
2202
|
initialState: this.state,
|
|
2209
2203
|
getOptions: () => this.options,
|
|
2210
2204
|
getState: () => this.state
|
|
2211
2205
|
}),
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2206
|
+
he(a(this, ce)),
|
|
2207
|
+
U(P),
|
|
2208
|
+
R((t) => {
|
|
2215
2209
|
this.state = t;
|
|
2216
2210
|
}),
|
|
2217
|
-
|
|
2218
|
-
throw
|
|
2211
|
+
J((t) => {
|
|
2212
|
+
throw or.error(t), t;
|
|
2219
2213
|
}),
|
|
2220
2214
|
ne(this.destroySubject),
|
|
2221
2215
|
Ue({ bufferSize: 1, refCount: !1 })
|
|
@@ -2229,28 +2223,28 @@ class ar {
|
|
|
2229
2223
|
}
|
|
2230
2224
|
get success$() {
|
|
2231
2225
|
return this.state$.pipe(
|
|
2232
|
-
|
|
2233
|
-
|
|
2226
|
+
b(({ data: e, status: t }) => ({ data: e, status: t })),
|
|
2227
|
+
U(P),
|
|
2234
2228
|
O(({ status: e }) => e === "success")
|
|
2235
2229
|
);
|
|
2236
2230
|
}
|
|
2237
2231
|
get error$() {
|
|
2238
2232
|
return this.state$.pipe(
|
|
2239
|
-
|
|
2240
|
-
|
|
2233
|
+
b(({ error: e, status: t }) => ({ error: e, status: t })),
|
|
2234
|
+
U(P),
|
|
2241
2235
|
O(({ status: e }) => e === "error")
|
|
2242
2236
|
);
|
|
2243
2237
|
}
|
|
2244
2238
|
get settled$() {
|
|
2245
2239
|
return this.state$.pipe(
|
|
2246
|
-
|
|
2247
|
-
|
|
2240
|
+
b(({ status: e }) => ({ status: e })),
|
|
2241
|
+
U(P),
|
|
2248
2242
|
O(({ status: e }) => e === "success" || e === "error")
|
|
2249
2243
|
);
|
|
2250
2244
|
}
|
|
2251
2245
|
observe(e) {
|
|
2252
2246
|
return this.state$.pipe(
|
|
2253
|
-
|
|
2247
|
+
R({
|
|
2254
2248
|
subscribe: () => {
|
|
2255
2249
|
this.observersSubject.next([
|
|
2256
2250
|
e,
|
|
@@ -2285,11 +2279,11 @@ class ar {
|
|
|
2285
2279
|
return this.state.isInvalidated || !this.state.dataUpdatedAt || this.observersSubject.getValue().some((e) => e.getCurrentResult().isStale);
|
|
2286
2280
|
}
|
|
2287
2281
|
isStaleByTime(e = 0) {
|
|
2288
|
-
return this.state.isInvalidated || !this.state.dataUpdatedAt || !
|
|
2282
|
+
return this.state.isInvalidated || !this.state.dataUpdatedAt || !Ts(this.state.dataUpdatedAt, e);
|
|
2289
2283
|
}
|
|
2290
2284
|
async getFetchResultAsPromise() {
|
|
2291
2285
|
return await new Promise((e, t) => {
|
|
2292
|
-
this.state$.pipe(
|
|
2286
|
+
this.state$.pipe(qt, Ke()).subscribe({
|
|
2293
2287
|
error: t,
|
|
2294
2288
|
next: (r) => {
|
|
2295
2289
|
r.error ? t(r.error) : e(r.data);
|
|
@@ -2320,14 +2314,14 @@ class ar {
|
|
|
2320
2314
|
this.resetSubject.next();
|
|
2321
2315
|
}
|
|
2322
2316
|
}
|
|
2323
|
-
xe = new WeakMap(),
|
|
2317
|
+
xe = new WeakMap(), ce = new WeakMap();
|
|
2324
2318
|
var Re, G;
|
|
2325
|
-
class
|
|
2319
|
+
class lr {
|
|
2326
2320
|
// protected mountSubscriptions: Subscription[]
|
|
2327
2321
|
constructor(e = {}) {
|
|
2328
2322
|
// readonly #queries: QueryStore = new Map<string, Query>()
|
|
2329
|
-
|
|
2330
|
-
|
|
2323
|
+
w(this, Re, new I());
|
|
2324
|
+
w(this, G, new Wt());
|
|
2331
2325
|
this.config = e;
|
|
2332
2326
|
}
|
|
2333
2327
|
mount() {
|
|
@@ -2340,12 +2334,12 @@ class or {
|
|
|
2340
2334
|
observeIsFetching(e) {
|
|
2341
2335
|
return a(this, G).stateChange$.pipe(
|
|
2342
2336
|
// we force a first result
|
|
2343
|
-
|
|
2344
|
-
|
|
2337
|
+
he(),
|
|
2338
|
+
b(() => this.findAll({
|
|
2345
2339
|
...e,
|
|
2346
2340
|
fetchStatus: "fetching"
|
|
2347
2341
|
}).length),
|
|
2348
|
-
|
|
2342
|
+
U()
|
|
2349
2343
|
);
|
|
2350
2344
|
}
|
|
2351
2345
|
getAll() {
|
|
@@ -2353,12 +2347,12 @@ class or {
|
|
|
2353
2347
|
}
|
|
2354
2348
|
findAll(e = {}) {
|
|
2355
2349
|
const t = this.getAll();
|
|
2356
|
-
return Object.keys(e).length > 0 ? t.filter((r) =>
|
|
2350
|
+
return Object.keys(e).length > 0 ? t.filter((r) => xt(e, r)) : t;
|
|
2357
2351
|
}
|
|
2358
2352
|
build(e, t, r) {
|
|
2359
2353
|
const n = t.queryKey ?? [ct()], u = t.queryHash ?? dt(n, t);
|
|
2360
2354
|
let i = this.get(u);
|
|
2361
|
-
return i || (i = new
|
|
2355
|
+
return i || (i = new cr({
|
|
2362
2356
|
cache: this,
|
|
2363
2357
|
queryKey: n,
|
|
2364
2358
|
queryHash: u,
|
|
@@ -2393,10 +2387,10 @@ class or {
|
|
|
2393
2387
|
* Once a mutation is finished and there are no more observers than us
|
|
2394
2388
|
* we start the process of cleaning it up based on gc settings
|
|
2395
2389
|
*/
|
|
2396
|
-
|
|
2397
|
-
|
|
2390
|
+
Ns,
|
|
2391
|
+
j((r) => r ? t.pipe(
|
|
2398
2392
|
// defaults to 5mn
|
|
2399
|
-
|
|
2393
|
+
j(() => e.gcTime === 1 / 0 ? qe : (setTimeout(N, e.gcTime), Qe(e.gcTime)))
|
|
2400
2394
|
) : qe),
|
|
2401
2395
|
He(1)
|
|
2402
2396
|
).subscribe({
|
|
@@ -2412,12 +2406,12 @@ class or {
|
|
|
2412
2406
|
find(e) {
|
|
2413
2407
|
const t = { exact: !0, ...e };
|
|
2414
2408
|
return this.getAll().find(
|
|
2415
|
-
(r) =>
|
|
2409
|
+
(r) => xt(t, r)
|
|
2416
2410
|
);
|
|
2417
2411
|
}
|
|
2418
2412
|
subscribe(e) {
|
|
2419
|
-
const t =
|
|
2420
|
-
a(this, Re).pipe(
|
|
2413
|
+
const t = C(
|
|
2414
|
+
a(this, Re).pipe(R(e))
|
|
2421
2415
|
// this.#store.added$.pipe(
|
|
2422
2416
|
// mergeMap((query) => {
|
|
2423
2417
|
// fn({
|
|
@@ -2454,30 +2448,30 @@ class or {
|
|
|
2454
2448
|
}
|
|
2455
2449
|
}
|
|
2456
2450
|
Re = new WeakMap(), G = new WeakMap();
|
|
2457
|
-
var
|
|
2458
|
-
class
|
|
2451
|
+
var le, Q, je, Me, ge;
|
|
2452
|
+
class Mr {
|
|
2459
2453
|
// #destroy = () => {}
|
|
2460
2454
|
constructor({
|
|
2461
2455
|
mutationCache: e,
|
|
2462
2456
|
queryCache: t,
|
|
2463
2457
|
defaultOptions: r
|
|
2464
2458
|
} = {}) {
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2459
|
+
w(this, le);
|
|
2460
|
+
w(this, Q);
|
|
2461
|
+
w(this, je, /* @__PURE__ */ new Map());
|
|
2462
|
+
w(this, Me, /* @__PURE__ */ new Map());
|
|
2463
|
+
w(this, ge);
|
|
2464
|
+
A(this, le, e ?? new er()), A(this, Q, t ?? new lr()), A(this, ge, r ?? {});
|
|
2471
2465
|
}
|
|
2472
2466
|
mount() {
|
|
2473
2467
|
}
|
|
2474
2468
|
unmount() {
|
|
2475
2469
|
}
|
|
2476
2470
|
getMutationCache() {
|
|
2477
|
-
return a(this,
|
|
2471
|
+
return a(this, le);
|
|
2478
2472
|
}
|
|
2479
2473
|
getQueryCache() {
|
|
2480
|
-
return a(this,
|
|
2474
|
+
return a(this, Q);
|
|
2481
2475
|
}
|
|
2482
2476
|
defaultMutationOptions(e) {
|
|
2483
2477
|
return {
|
|
@@ -2503,14 +2497,14 @@ class Rr {
|
|
|
2503
2497
|
async fetchQuery(e) {
|
|
2504
2498
|
const t = this.defaultQueryOptions(e);
|
|
2505
2499
|
typeof t.retry > "u" && (t.retry = !1);
|
|
2506
|
-
const r = a(this,
|
|
2500
|
+
const r = a(this, Q).build(this, t);
|
|
2507
2501
|
return r.isStaleByTime(t.staleTime) ? await r.fetch(t) : await Promise.resolve(r.state.data);
|
|
2508
2502
|
}
|
|
2509
2503
|
async prefetchQuery(e) {
|
|
2510
|
-
await this.fetchQuery(e).then(
|
|
2504
|
+
await this.fetchQuery(e).then(N).catch(N);
|
|
2511
2505
|
}
|
|
2512
2506
|
async resetQueries(e, t) {
|
|
2513
|
-
const r = a(this,
|
|
2507
|
+
const r = a(this, Q), n = {
|
|
2514
2508
|
type: "active",
|
|
2515
2509
|
...e
|
|
2516
2510
|
};
|
|
@@ -2522,23 +2516,23 @@ class Rr {
|
|
|
2522
2516
|
const r = {
|
|
2523
2517
|
...t,
|
|
2524
2518
|
cancelRefetch: (t == null ? void 0 : t.cancelRefetch) ?? !0
|
|
2525
|
-
}, n = a(this,
|
|
2519
|
+
}, n = a(this, Q).findAll(e).filter((u) => !u.isDisabled()).map(async (u) => {
|
|
2526
2520
|
let i = u.fetch(void 0, r);
|
|
2527
|
-
return r.throwOnError || (i = i.catch(
|
|
2521
|
+
return r.throwOnError || (i = i.catch(N)), u.state.fetchStatus === "paused" ? void 0 : await i;
|
|
2528
2522
|
});
|
|
2529
|
-
await Promise.all(n).then(
|
|
2523
|
+
await Promise.all(n).then(N);
|
|
2530
2524
|
}
|
|
2531
2525
|
getQueryData(e) {
|
|
2532
2526
|
var r;
|
|
2533
2527
|
const t = this.defaultQueryOptions({ queryKey: e });
|
|
2534
|
-
return (r = a(this,
|
|
2528
|
+
return (r = a(this, Q).get(t.queryHash)) == null ? void 0 : r.state.data;
|
|
2535
2529
|
}
|
|
2536
2530
|
setQueryData(e, t, r) {
|
|
2537
|
-
const n = this.defaultQueryOptions({ queryKey: e }), u = a(this,
|
|
2531
|
+
const n = this.defaultQueryOptions({ queryKey: e }), u = a(this, Q).get(
|
|
2538
2532
|
n.queryHash
|
|
2539
|
-
), i = u == null ? void 0 : u.state.data, c =
|
|
2533
|
+
), i = u == null ? void 0 : u.state.data, c = ks(t, i);
|
|
2540
2534
|
if (c !== void 0)
|
|
2541
|
-
return a(this,
|
|
2535
|
+
return a(this, Q).build(this, n).setData(c, { ...r, manual: !0 });
|
|
2542
2536
|
}
|
|
2543
2537
|
getMutationDefaults(e) {
|
|
2544
2538
|
const t = [...a(this, je).values()];
|
|
@@ -2549,7 +2543,7 @@ class Rr {
|
|
|
2549
2543
|
}
|
|
2550
2544
|
getQueryState(e) {
|
|
2551
2545
|
var t;
|
|
2552
|
-
return (t = a(this,
|
|
2546
|
+
return (t = a(this, Q).find({ queryKey: e })) == null ? void 0 : t.state;
|
|
2553
2547
|
}
|
|
2554
2548
|
setMutationDefaults(e, t) {
|
|
2555
2549
|
a(this, je).set(ve(e), {
|
|
@@ -2571,19 +2565,19 @@ class Rr {
|
|
|
2571
2565
|
}), r;
|
|
2572
2566
|
}
|
|
2573
2567
|
removeQueries(e) {
|
|
2574
|
-
const t = a(this,
|
|
2568
|
+
const t = a(this, Q);
|
|
2575
2569
|
t.findAll(e).forEach((r) => {
|
|
2576
2570
|
t.remove(r);
|
|
2577
2571
|
});
|
|
2578
2572
|
}
|
|
2579
2573
|
async cancelQueries(e = {}, t = {}) {
|
|
2580
|
-
const r = { revert: !0, ...t }, n = a(this,
|
|
2574
|
+
const r = { revert: !0, ...t }, n = a(this, Q).findAll(e).map(async (u) => {
|
|
2581
2575
|
await u.cancel(r);
|
|
2582
2576
|
});
|
|
2583
|
-
await Promise.all(n).then(
|
|
2577
|
+
await Promise.all(n).then(N).catch(N);
|
|
2584
2578
|
}
|
|
2585
2579
|
async invalidateQueries(e = {}, t = {}) {
|
|
2586
|
-
if (a(this,
|
|
2580
|
+
if (a(this, Q).findAll(e).forEach((n) => {
|
|
2587
2581
|
n.invalidate();
|
|
2588
2582
|
}), e.refetchType === "none") {
|
|
2589
2583
|
await Promise.resolve();
|
|
@@ -2596,45 +2590,45 @@ class Rr {
|
|
|
2596
2590
|
await this.refetchQueries(r, t);
|
|
2597
2591
|
}
|
|
2598
2592
|
async resumePausedMutations() {
|
|
2599
|
-
return await
|
|
2593
|
+
return await fs(a(this, le).resumePausedMutations());
|
|
2600
2594
|
}
|
|
2601
2595
|
isFetching(e) {
|
|
2602
|
-
return a(this,
|
|
2596
|
+
return a(this, Q).findAll({ ...e, fetchStatus: "fetching" }).length;
|
|
2603
2597
|
}
|
|
2604
2598
|
clear() {
|
|
2605
|
-
a(this,
|
|
2599
|
+
a(this, Q).clear(), a(this, le).clear();
|
|
2606
2600
|
}
|
|
2607
2601
|
}
|
|
2608
|
-
|
|
2602
|
+
le = new WeakMap(), Q = new WeakMap(), je = new WeakMap(), Me = new WeakMap(), ge = new WeakMap();
|
|
2609
2603
|
export {
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2604
|
+
er as MutationCache,
|
|
2605
|
+
lr as QueryCache,
|
|
2606
|
+
Mr as QueryClient,
|
|
2607
|
+
Fr as QueryClientProvider,
|
|
2608
|
+
vs as SIGNAL_RESET,
|
|
2609
|
+
wr as arrayEqual,
|
|
2610
|
+
$s as createLocalStorageAdapter,
|
|
2611
|
+
vr as createLocalforageAdapter,
|
|
2612
|
+
xs as exponentialBackoffDelay,
|
|
2613
|
+
Es as getDelay,
|
|
2620
2614
|
rt as isDefined,
|
|
2621
|
-
|
|
2622
|
-
|
|
2615
|
+
Pt as retryBackoff,
|
|
2616
|
+
mr as signal,
|
|
2623
2617
|
It as useBehaviorSubject,
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2618
|
+
Rs as useEffectOnce,
|
|
2619
|
+
Rr as useForeverQuery,
|
|
2620
|
+
H as useLiveRef,
|
|
2621
|
+
Cr as useMount,
|
|
2622
|
+
Er as useMutation,
|
|
2623
|
+
gr as useObservableState,
|
|
2630
2624
|
Xe as useObserve,
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2625
|
+
br as useObserveCallback,
|
|
2626
|
+
Or as usePersistSignals,
|
|
2627
|
+
xr as useQuery,
|
|
2634
2628
|
kt as useQueryClient,
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2629
|
+
Sr as useSignalValue,
|
|
2630
|
+
Vt as useSubject,
|
|
2631
|
+
Ut as useSubscribe,
|
|
2632
|
+
jr as useSubscribeEffect,
|
|
2633
|
+
$r as useUnmountObservable
|
|
2640
2634
|
};
|