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