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