reactjrx 1.71.0 → 1.73.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 +542 -516
- package/dist/lib/queries/client/queries/query/execution/completeFnIfNotMoreObservers.d.ts +2 -0
- package/dist/lib/queries/client/queries/query/{executeQuery.d.ts → execution/executeQuery.d.ts} +6 -4
- package/dist/lib/queries/client/queries/query/query.test.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var y = (s, e, t) => (
|
|
1
|
+
var Ht = Object.defineProperty;
|
|
2
|
+
var qt = (s, e, t) => e in s ? Ht(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var y = (s, e, t) => (qt(s, typeof e != "symbol" ? e + "" : e, t), t), ot = (s, e, t) => {
|
|
4
4
|
if (!e.has(s))
|
|
5
5
|
throw TypeError("Cannot " + t);
|
|
6
6
|
};
|
|
7
|
-
var a = (s, e, t) => (
|
|
7
|
+
var a = (s, e, t) => (ot(s, e, "read from private field"), t ? t.call(s) : e.get(s)), w = (s, e, t) => {
|
|
8
8
|
if (e.has(s))
|
|
9
9
|
throw TypeError("Cannot add the same private member more than once");
|
|
10
10
|
e instanceof WeakSet ? e.add(s) : e.set(s, t);
|
|
11
|
-
}, M = (s, e, t, r) => (
|
|
11
|
+
}, M = (s, e, t, r) => (ot(s, e, "write to private field"), r ? r.call(s, t) : e.set(s, t), t);
|
|
12
12
|
import * as We from "react";
|
|
13
|
-
import { useRef as
|
|
14
|
-
import { distinctUntilChanged as P, tap as F, finalize as
|
|
15
|
-
import { catchError as
|
|
13
|
+
import { useRef as ye, useMemo as et, useCallback as le, useSyncExternalStore as zt, useEffect as re, createContext as Lt, memo as _t, useContext as Wt, useState as wt } from "react";
|
|
14
|
+
import { distinctUntilChanged as P, tap as F, finalize as Gt, catchError as te, EMPTY as be, isObservable as lt, from as ve, of as v, defer as Qe, Subject as U, BehaviorSubject as G, map as g, zip as Jt, merge as C, throttleTime as Yt, asyncScheduler as Bt, switchMap as Q, throwError as me, timer as Ae, Observable as Xt, takeWhile as Ge, filter as $, concatMap as Zt, last as Ke, mergeMap as q, takeUntil as Y, skip as Ct, identity as Et, scan as tt, shareReplay as Ue, ignoreElements as he, first as st, fromEvent as Ne, noop as H, startWith as oe, pairwise as Ft, NEVER as Oe, interval as es, withLatestFrom as ht, retry as ts, iif as ss, concat as ke, toArray as Te, share as fe, take as He, combineLatest as rs, delay as xt, endWith as ns, lastValueFrom as is } from "rxjs";
|
|
15
|
+
import { catchError as ft, mergeMap as Xe, retryWhen as us, concatMap as as, first as cs, tap as Rt } from "rxjs/operators";
|
|
16
16
|
import { jsxs as os, jsx as ls } from "react/jsx-runtime";
|
|
17
17
|
const k = (s) => {
|
|
18
|
-
const e =
|
|
18
|
+
const e = ye(s);
|
|
19
19
|
return et(() => {
|
|
20
20
|
e.current = s;
|
|
21
21
|
}, [s]), e;
|
|
@@ -28,10 +28,10 @@ function Je(s, e, t) {
|
|
|
28
28
|
defaultValue: void 0,
|
|
29
29
|
key: "",
|
|
30
30
|
unsubscribeOnUnmount: !0
|
|
31
|
-
}, n = t == null && Array.isArray(e) ? e : typeof s == "function" ? t ?? [] : [s], u =
|
|
31
|
+
}, n = t == null && Array.isArray(e) ? e : typeof s == "function" ? t ?? [] : [s], u = ye(
|
|
32
32
|
"getValue" in s && typeof s.getValue == "function" ? s.getValue() : r.defaultValue
|
|
33
|
-
), i = k(s),
|
|
34
|
-
(
|
|
33
|
+
), i = k(s), l = k(r), f = le(
|
|
34
|
+
(d) => {
|
|
35
35
|
const c = i.current, E = (typeof c == "function" ? c : () => c)().pipe(
|
|
36
36
|
/**
|
|
37
37
|
* @important
|
|
@@ -43,37 +43,37 @@ function Je(s, e, t) {
|
|
|
43
43
|
F((p) => {
|
|
44
44
|
u.current = p;
|
|
45
45
|
}),
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
).subscribe(
|
|
46
|
+
Gt(d),
|
|
47
|
+
te((p) => (console.error(p), u.current = void 0, be))
|
|
48
|
+
).subscribe(d);
|
|
49
49
|
return () => {
|
|
50
|
-
|
|
50
|
+
l.current.unsubscribeOnUnmount !== !1 && E.unsubscribe();
|
|
51
51
|
};
|
|
52
52
|
},
|
|
53
53
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
54
54
|
[...n]
|
|
55
|
-
), h =
|
|
56
|
-
return
|
|
55
|
+
), h = le(() => u.current, []);
|
|
56
|
+
return zt(f, h, h);
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function dt(s) {
|
|
59
59
|
return s instanceof Promise || s && typeof s.then == "function" && typeof s.catch == "function";
|
|
60
60
|
}
|
|
61
61
|
function A(s) {
|
|
62
|
-
if (
|
|
62
|
+
if (lt(s))
|
|
63
63
|
return s;
|
|
64
|
-
if (
|
|
64
|
+
if (dt(s))
|
|
65
65
|
return ve(s);
|
|
66
66
|
if (typeof s != "function")
|
|
67
67
|
return v(s);
|
|
68
68
|
const e = s;
|
|
69
69
|
return Qe(() => {
|
|
70
70
|
const t = e();
|
|
71
|
-
return
|
|
71
|
+
return dt(t) ? ve(t) : lt(t) ? t : v(t);
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
|
-
function
|
|
74
|
+
function Mt(s, e = []) {
|
|
75
75
|
const t = k(s);
|
|
76
|
-
|
|
76
|
+
re(() => {
|
|
77
77
|
const r = A(t.current).subscribe();
|
|
78
78
|
return () => {
|
|
79
79
|
r.unsubscribe();
|
|
@@ -85,24 +85,24 @@ function Rt(s, e = []) {
|
|
|
85
85
|
]);
|
|
86
86
|
}
|
|
87
87
|
const Ye = (s) => {
|
|
88
|
-
const e =
|
|
89
|
-
return e.current || (e.current = s()),
|
|
88
|
+
const e = ye();
|
|
89
|
+
return e.current || (e.current = s()), re(() => {
|
|
90
90
|
process.env.NODE_ENV;
|
|
91
91
|
}, []), e;
|
|
92
|
-
},
|
|
92
|
+
}, jt = ({
|
|
93
93
|
onBeforeComplete: s,
|
|
94
94
|
completeOnUnmount: e = !0
|
|
95
95
|
} = {}) => {
|
|
96
|
-
const t = Ye(() => new
|
|
97
|
-
return
|
|
96
|
+
const t = Ye(() => new U()), r = ye(!1), n = k(s), u = k(e);
|
|
97
|
+
return re(() => (r.current && (t.current = new U(), r.current = !1), () => {
|
|
98
98
|
if (!u.current) {
|
|
99
99
|
r.current = !0;
|
|
100
100
|
return;
|
|
101
101
|
}
|
|
102
102
|
r.current || (n.current != null && n.current(), t.current.complete(), r.current = !0);
|
|
103
103
|
}), [u, n, t]), t;
|
|
104
|
-
},
|
|
105
|
-
const s =
|
|
104
|
+
}, or = () => {
|
|
105
|
+
const s = jt(), e = k(s.current.asObservable()), t = le(
|
|
106
106
|
(r) => {
|
|
107
107
|
s.current.next(r);
|
|
108
108
|
},
|
|
@@ -111,12 +111,12 @@ const Ye = (s) => {
|
|
|
111
111
|
);
|
|
112
112
|
return [e, t];
|
|
113
113
|
}, fs = (s) => {
|
|
114
|
-
const e = Ye(() => new G(s)), t =
|
|
115
|
-
return
|
|
114
|
+
const e = Ye(() => new G(s)), t = ye(!1), r = ye(s);
|
|
115
|
+
return re(() => (t.current && (e.current = new G(r.current), t.current = !1), () => {
|
|
116
116
|
t.current || (e.current.complete(), t.current = !0);
|
|
117
117
|
}), [e]), e;
|
|
118
|
-
},
|
|
119
|
-
const e = fs(s), t = k(e.current.asObservable()), r =
|
|
118
|
+
}, lr = (s) => {
|
|
119
|
+
const e = fs(s), t = k(e.current.asObservable()), r = le(
|
|
120
120
|
(n) => {
|
|
121
121
|
e.current.next(n);
|
|
122
122
|
},
|
|
@@ -125,7 +125,7 @@ const Ye = (s) => {
|
|
|
125
125
|
);
|
|
126
126
|
return [t.current, r, e.current.getValue()];
|
|
127
127
|
}, ds = Symbol("SIGNAL_RESET");
|
|
128
|
-
function
|
|
128
|
+
function hr(s) {
|
|
129
129
|
const { default: e } = s ?? {}, t = new G(e);
|
|
130
130
|
return {
|
|
131
131
|
setValue: (u) => {
|
|
@@ -147,7 +147,7 @@ function lr(s) {
|
|
|
147
147
|
subject: t
|
|
148
148
|
};
|
|
149
149
|
}
|
|
150
|
-
function
|
|
150
|
+
function fr(s, e) {
|
|
151
151
|
const t = e ?? ((r) => r);
|
|
152
152
|
return Je(
|
|
153
153
|
() => s.subject.pipe(
|
|
@@ -160,23 +160,23 @@ function hr(s, e) {
|
|
|
160
160
|
[]
|
|
161
161
|
);
|
|
162
162
|
}
|
|
163
|
-
const
|
|
163
|
+
const pt = (s) => {
|
|
164
164
|
if (!(!s || typeof s != "object"))
|
|
165
165
|
return s;
|
|
166
|
-
},
|
|
166
|
+
}, dr = ({
|
|
167
167
|
adapter: s,
|
|
168
168
|
key: e
|
|
169
169
|
}) => ({
|
|
170
170
|
getItem: async (t) => {
|
|
171
|
-
const r = await s.getItem(e), n =
|
|
171
|
+
const r = await s.getItem(e), n = pt(r) ?? {};
|
|
172
172
|
if (t in n)
|
|
173
173
|
return n[t];
|
|
174
174
|
},
|
|
175
175
|
setItem: async (t, r) => {
|
|
176
|
-
const n = await s.getItem(e), u =
|
|
176
|
+
const n = await s.getItem(e), u = pt(n) ?? {};
|
|
177
177
|
await s.setItem(e, { ...u, [t]: r });
|
|
178
178
|
}
|
|
179
|
-
}),
|
|
179
|
+
}), pr = (s) => ({
|
|
180
180
|
getItem: async (e) => {
|
|
181
181
|
const t = await s.getItem(e);
|
|
182
182
|
if (t)
|
|
@@ -217,48 +217,48 @@ const dt = (s) => {
|
|
|
217
217
|
const n = ys(r);
|
|
218
218
|
return n ? n.migrationVersion !== void 0 && e > n.migrationVersion ? v(r) : (t.setValue(r.value), v(r)) : v(r);
|
|
219
219
|
})
|
|
220
|
-
),
|
|
220
|
+
), yr = ({
|
|
221
221
|
entries: s = [],
|
|
222
222
|
onReady: e,
|
|
223
223
|
adapter: t = ps(localStorage)
|
|
224
224
|
}) => {
|
|
225
225
|
const r = k(s), n = k(e), u = k(t), i = Je(
|
|
226
226
|
() => {
|
|
227
|
-
const
|
|
228
|
-
return (
|
|
229
|
-
...
|
|
230
|
-
({ signal: h, version:
|
|
227
|
+
const l = r.current;
|
|
228
|
+
return (l.length === 0 ? v(!0) : Jt(
|
|
229
|
+
...l.map(
|
|
230
|
+
({ signal: h, version: o }) => gs({
|
|
231
231
|
adapter: u.current,
|
|
232
232
|
signal: h,
|
|
233
|
-
version:
|
|
233
|
+
version: o
|
|
234
234
|
})
|
|
235
235
|
)
|
|
236
236
|
).pipe(g(() => !0))).pipe(
|
|
237
237
|
F(() => {
|
|
238
238
|
n.current != null && n.current();
|
|
239
239
|
}),
|
|
240
|
-
|
|
240
|
+
te((h) => (console.error("Unable to hydrate", h), be))
|
|
241
241
|
);
|
|
242
242
|
},
|
|
243
243
|
{ defaultValue: !1 },
|
|
244
244
|
[]
|
|
245
245
|
);
|
|
246
|
-
return
|
|
246
|
+
return Mt(() => i ? C(
|
|
247
247
|
...r.current.map(
|
|
248
|
-
({ signal:
|
|
249
|
-
|
|
248
|
+
({ signal: l, version: f }) => l.subject.pipe(
|
|
249
|
+
Yt(500, Bt, {
|
|
250
250
|
trailing: !0
|
|
251
251
|
}),
|
|
252
252
|
Q(
|
|
253
253
|
() => ve(
|
|
254
|
-
bs({ adapter: u.current, signal:
|
|
254
|
+
bs({ adapter: u.current, signal: l, version: f })
|
|
255
255
|
)
|
|
256
256
|
)
|
|
257
257
|
)
|
|
258
258
|
)
|
|
259
|
-
) :
|
|
260
|
-
},
|
|
261
|
-
const s =
|
|
259
|
+
) : be, [i, u]), { isHydrated: i };
|
|
260
|
+
}, br = () => {
|
|
261
|
+
const s = jt({
|
|
262
262
|
onBeforeComplete: () => {
|
|
263
263
|
s.current.next();
|
|
264
264
|
}
|
|
@@ -271,7 +271,7 @@ function ms(s, e) {
|
|
|
271
271
|
function Ss(s, e) {
|
|
272
272
|
return Math.pow(2, s) * e;
|
|
273
273
|
}
|
|
274
|
-
function
|
|
274
|
+
function Qt(s) {
|
|
275
275
|
const {
|
|
276
276
|
retry: e,
|
|
277
277
|
retryDelay: t,
|
|
@@ -280,19 +280,19 @@ function jt(s) {
|
|
|
280
280
|
} = s, u = typeof e != "function" ? e === !1 ? 0 : e === !0 ? 1 / 0 : e ?? 1 / 0 : 1 / 0, i = typeof e == "function" ? (
|
|
281
281
|
// ? (attempt: number, error: TError) => of(retry(attempt, error))
|
|
282
282
|
e
|
|
283
|
-
) : () => !0,
|
|
283
|
+
) : () => !0, l = typeof t == "number" ? t : 100, f = {
|
|
284
284
|
shouldRetry: i,
|
|
285
285
|
...s
|
|
286
286
|
}, {
|
|
287
287
|
maxInterval: h = 1 / 0,
|
|
288
|
-
resetOnSuccess:
|
|
289
|
-
backoffDelay:
|
|
290
|
-
} =
|
|
288
|
+
resetOnSuccess: o = !1,
|
|
289
|
+
backoffDelay: d = Ss
|
|
290
|
+
} = f;
|
|
291
291
|
return (c) => Qe(() => {
|
|
292
292
|
let b = 0;
|
|
293
293
|
const E = (p, S) => p < u ? i(p, S) : !1;
|
|
294
294
|
return c.pipe(
|
|
295
|
-
|
|
295
|
+
ft((p) => {
|
|
296
296
|
var O;
|
|
297
297
|
if (b++, !E(b - 1, p))
|
|
298
298
|
throw p;
|
|
@@ -301,8 +301,8 @@ function jt(s) {
|
|
|
301
301
|
throw p;
|
|
302
302
|
return S.pipe(
|
|
303
303
|
Xe(
|
|
304
|
-
(
|
|
305
|
-
v(
|
|
304
|
+
(z) => C(
|
|
305
|
+
v(z),
|
|
306
306
|
me(() => p)
|
|
307
307
|
)
|
|
308
308
|
)
|
|
@@ -316,46 +316,46 @@ function jt(s) {
|
|
|
316
316
|
Xe(
|
|
317
317
|
() => E(O, S) ? Ae(
|
|
318
318
|
ms(
|
|
319
|
-
|
|
319
|
+
d(O, l),
|
|
320
320
|
h
|
|
321
321
|
)
|
|
322
322
|
).pipe(
|
|
323
|
-
Xe((
|
|
323
|
+
Xe((z) => r && !r(O, S) ? me(() => S) : v(z))
|
|
324
324
|
) : me(() => S)
|
|
325
325
|
)
|
|
326
326
|
);
|
|
327
327
|
})
|
|
328
328
|
)),
|
|
329
|
-
|
|
329
|
+
ft((p) => {
|
|
330
330
|
if (s.catchError)
|
|
331
331
|
return s.catchError(b, p);
|
|
332
332
|
throw p;
|
|
333
333
|
}),
|
|
334
|
-
|
|
335
|
-
|
|
334
|
+
Rt(() => {
|
|
335
|
+
o && (b = 0);
|
|
336
336
|
})
|
|
337
337
|
);
|
|
338
338
|
});
|
|
339
339
|
}
|
|
340
|
-
function
|
|
340
|
+
function yt(s) {
|
|
341
341
|
return s != null;
|
|
342
342
|
}
|
|
343
|
-
function
|
|
343
|
+
function bt(s) {
|
|
344
344
|
return Object.prototype.toString.call(s) === "[object Object]";
|
|
345
345
|
}
|
|
346
346
|
function Ze(s) {
|
|
347
|
-
if (!
|
|
347
|
+
if (!bt(s))
|
|
348
348
|
return !1;
|
|
349
349
|
const e = s.constructor;
|
|
350
350
|
if (typeof e > "u")
|
|
351
351
|
return !0;
|
|
352
352
|
const t = e.prototype;
|
|
353
|
-
return !(!
|
|
353
|
+
return !(!bt(t) || !t.hasOwnProperty("isPrototypeOf"));
|
|
354
354
|
}
|
|
355
|
-
const
|
|
355
|
+
const ge = (s) => JSON.stringify(
|
|
356
356
|
s,
|
|
357
357
|
(e, t) => Ze(t) ? Object.keys(t).sort().reduce((r, n) => (r[n] = t[n], r), {}) : t
|
|
358
|
-
),
|
|
358
|
+
), rt = (s = 21) => crypto.getRandomValues(new Uint8Array(s)).reduce((e, t) => (t &= 63, t < 36 ? e += t.toString(36) : t < 62 ? e += (t - 26).toString(36).toUpperCase() : t > 62 ? e += "-" : e += "_", e), ""), ne = () => ({
|
|
359
359
|
context: void 0,
|
|
360
360
|
data: void 0,
|
|
361
361
|
error: null,
|
|
@@ -379,10 +379,10 @@ function D(s, e) {
|
|
|
379
379
|
return !1;
|
|
380
380
|
return !0;
|
|
381
381
|
}
|
|
382
|
-
function
|
|
382
|
+
function nt(s) {
|
|
383
383
|
let e = 0;
|
|
384
384
|
return function(r) {
|
|
385
|
-
return new
|
|
385
|
+
return new Xt((n) => {
|
|
386
386
|
e++;
|
|
387
387
|
const u = r.subscribe(n);
|
|
388
388
|
return s(e), () => {
|
|
@@ -397,50 +397,50 @@ const $e = (s) => s.pipe(
|
|
|
397
397
|
!0
|
|
398
398
|
)
|
|
399
399
|
);
|
|
400
|
-
var
|
|
400
|
+
var X;
|
|
401
401
|
class vs {
|
|
402
402
|
constructor({
|
|
403
403
|
__queryFinalizeHook: e
|
|
404
404
|
} = {}) {
|
|
405
|
-
|
|
405
|
+
w(this, X, new U());
|
|
406
406
|
y(this, "state$");
|
|
407
407
|
const t = new G(0), r = t.pipe(
|
|
408
|
-
|
|
408
|
+
$((n) => n === 0)
|
|
409
409
|
);
|
|
410
|
-
this.state$ = a(this,
|
|
411
|
-
|
|
412
|
-
const
|
|
413
|
-
|
|
414
|
-
), h = a(this,
|
|
415
|
-
|
|
410
|
+
this.state$ = a(this, X).pipe(
|
|
411
|
+
Zt(({ args: n, mutation: u, options: i }) => {
|
|
412
|
+
const l = i.mapOperator ?? "merge", f = a(this, X).pipe(
|
|
413
|
+
$(() => l === "merge")
|
|
414
|
+
), h = a(this, X).pipe(
|
|
415
|
+
$(() => l === "switch"),
|
|
416
416
|
F(() => {
|
|
417
417
|
u.cancel();
|
|
418
418
|
})
|
|
419
|
-
),
|
|
419
|
+
), o = Qe(() => (u.execute(n), be)), d = u.state$.pipe(
|
|
420
420
|
$e,
|
|
421
421
|
Ke(),
|
|
422
|
-
|
|
423
|
-
|
|
422
|
+
q(() => u.state$),
|
|
423
|
+
Y(a(this, X))
|
|
424
424
|
), c = u.state$.pipe(
|
|
425
425
|
$e,
|
|
426
|
-
|
|
426
|
+
Ct(1)
|
|
427
427
|
), b = C(
|
|
428
428
|
r,
|
|
429
|
-
|
|
429
|
+
f,
|
|
430
430
|
h,
|
|
431
431
|
u.cancelled$
|
|
432
432
|
);
|
|
433
433
|
return C(
|
|
434
434
|
c,
|
|
435
|
-
|
|
435
|
+
d,
|
|
436
436
|
/**
|
|
437
437
|
* We defer execution so that we return at least
|
|
438
438
|
* the current state first (same mechanism is used for query)
|
|
439
439
|
*/
|
|
440
|
-
|
|
440
|
+
o
|
|
441
441
|
).pipe(
|
|
442
|
-
e ??
|
|
443
|
-
|
|
442
|
+
e ?? Et,
|
|
443
|
+
Y(b)
|
|
444
444
|
);
|
|
445
445
|
}),
|
|
446
446
|
tt((n, u) => ({
|
|
@@ -452,15 +452,15 @@ class vs {
|
|
|
452
452
|
...u.status === "pending" && {
|
|
453
453
|
error: u.error ?? n.error
|
|
454
454
|
}
|
|
455
|
-
}),
|
|
455
|
+
}), ne()),
|
|
456
456
|
P(
|
|
457
|
-
({ data: n, ...u }, { data: i, ...
|
|
457
|
+
({ data: n, ...u }, { data: i, ...l }) => D(u, l) && D(n, i)
|
|
458
458
|
),
|
|
459
459
|
Ue({
|
|
460
460
|
refCount: !0,
|
|
461
461
|
bufferSize: 1
|
|
462
462
|
}),
|
|
463
|
-
|
|
463
|
+
nt((n) => {
|
|
464
464
|
t.next(n);
|
|
465
465
|
})
|
|
466
466
|
);
|
|
@@ -470,19 +470,19 @@ class vs {
|
|
|
470
470
|
options: t,
|
|
471
471
|
mutation: r
|
|
472
472
|
}) {
|
|
473
|
-
a(this,
|
|
473
|
+
a(this, X).next({ args: e, options: t, mutation: r });
|
|
474
474
|
}
|
|
475
475
|
}
|
|
476
|
-
|
|
476
|
+
X = new WeakMap();
|
|
477
477
|
function Be(s, e) {
|
|
478
478
|
return s === e ? !0 : typeof s != typeof e ? !1 : s && e && typeof s == "object" && typeof e == "object" ? !Object.keys(e).some((t) => !Be(s[t], e[t])) : !1;
|
|
479
479
|
}
|
|
480
|
-
const qe = (s, e, { exact: t = !1 } = {}) => t ?
|
|
481
|
-
var
|
|
480
|
+
const qe = (s, e, { exact: t = !1 } = {}) => t ? ge(s) === ge(e) : Be(s, e);
|
|
481
|
+
var ie, _;
|
|
482
482
|
class Os {
|
|
483
483
|
constructor(e, t = {}, r) {
|
|
484
|
-
|
|
485
|
-
|
|
484
|
+
w(this, ie, void 0);
|
|
485
|
+
w(this, _, new G(void 0));
|
|
486
486
|
/**
|
|
487
487
|
* @important
|
|
488
488
|
* Used to maintain persistance to latest mutation. This ensure
|
|
@@ -491,7 +491,7 @@ class Os {
|
|
|
491
491
|
*/
|
|
492
492
|
y(this, "observed$");
|
|
493
493
|
y(this, "getObserverResultFromState", (e) => ({
|
|
494
|
-
...
|
|
494
|
+
...ne(),
|
|
495
495
|
...e,
|
|
496
496
|
isSuccess: e.status === "success",
|
|
497
497
|
isPending: e.status === "pending",
|
|
@@ -503,23 +503,23 @@ class Os {
|
|
|
503
503
|
reset: this.reset
|
|
504
504
|
}));
|
|
505
505
|
var n;
|
|
506
|
-
this.client = e, this.options = t, this.options.mutationKey = ((n = this.options) == null ? void 0 : n.mutationKey) ?? [
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
(u) => a(this,
|
|
510
|
-
|
|
506
|
+
this.client = e, this.options = t, this.options.mutationKey = ((n = this.options) == null ? void 0 : n.mutationKey) ?? [rt()], M(this, ie, r ?? new vs(this.options)), this.mutate = this.mutate.bind(this), this.reset = this.reset.bind(this), a(this, _).pipe(
|
|
507
|
+
$(yt),
|
|
508
|
+
q(
|
|
509
|
+
(u) => a(this, ie).state$.pipe(
|
|
510
|
+
Y(
|
|
511
511
|
u.mutation.state$.pipe($e, Ke())
|
|
512
512
|
)
|
|
513
513
|
)
|
|
514
514
|
)
|
|
515
|
-
).subscribe(), this.observed$ = a(this,
|
|
515
|
+
).subscribe(), this.observed$ = a(this, _).pipe(
|
|
516
516
|
Q((u) => (u == null ? void 0 : u.mutation.state$.pipe(
|
|
517
517
|
// last(),
|
|
518
518
|
g((i) => ({
|
|
519
519
|
state: i,
|
|
520
520
|
options: u.options
|
|
521
521
|
}))
|
|
522
|
-
)) ??
|
|
522
|
+
)) ?? be),
|
|
523
523
|
F(({ state: u, options: i }) => {
|
|
524
524
|
u.status === "error" && (i != null && i.onError && (i == null || i.onError(
|
|
525
525
|
u.error,
|
|
@@ -541,7 +541,7 @@ class Os {
|
|
|
541
541
|
u.context
|
|
542
542
|
)));
|
|
543
543
|
}),
|
|
544
|
-
|
|
544
|
+
he()
|
|
545
545
|
);
|
|
546
546
|
}
|
|
547
547
|
setOptions(e) {
|
|
@@ -551,7 +551,7 @@ class Os {
|
|
|
551
551
|
mutationKey: this.options.mutationKey,
|
|
552
552
|
...e
|
|
553
553
|
});
|
|
554
|
-
const r = (n = a(this,
|
|
554
|
+
const r = (n = a(this, _).getValue()) == null ? void 0 : n.mutation;
|
|
555
555
|
this.options.mutationKey && t.mutationKey && !qe(this.options.mutationKey, t.mutationKey, {
|
|
556
556
|
exact: !0
|
|
557
557
|
}) ? this.reset() : r == null || r.setOptions(this.options);
|
|
@@ -559,13 +559,13 @@ class Os {
|
|
|
559
559
|
observe() {
|
|
560
560
|
var u;
|
|
561
561
|
const e = this.getObserverResultFromState(
|
|
562
|
-
((u = a(this,
|
|
563
|
-
), t = a(this,
|
|
562
|
+
((u = a(this, _).getValue()) == null ? void 0 : u.mutation.state) ?? ne()
|
|
563
|
+
), t = a(this, ie).state$.pipe(
|
|
564
564
|
g((i) => this.getObserverResultFromState(i))
|
|
565
|
-
), r = a(this,
|
|
566
|
-
|
|
565
|
+
), r = a(this, _).pipe(
|
|
566
|
+
$(yt),
|
|
567
567
|
Q((i) => i.mutation.cancelled$),
|
|
568
|
-
g(() => this.getObserverResultFromState(
|
|
568
|
+
g(() => this.getObserverResultFromState(ne()))
|
|
569
569
|
);
|
|
570
570
|
return { result$: C(
|
|
571
571
|
this.observed$,
|
|
@@ -587,7 +587,7 @@ class Os {
|
|
|
587
587
|
}
|
|
588
588
|
async mutate(e, t = {}) {
|
|
589
589
|
const r = this.client.getMutationCache().build(this.client, this.options);
|
|
590
|
-
return a(this,
|
|
590
|
+
return a(this, _).next({ mutation: r, options: t }), a(this, ie).trigger({
|
|
591
591
|
args: e,
|
|
592
592
|
options: this.options,
|
|
593
593
|
mutation: r
|
|
@@ -606,27 +606,27 @@ class Os {
|
|
|
606
606
|
var t;
|
|
607
607
|
const e = this.client.getMutationCache().find({ exact: !0, mutationKey: (t = this.options) == null ? void 0 : t.mutationKey });
|
|
608
608
|
return this.getObserverResultFromState(
|
|
609
|
-
(e == null ? void 0 : e.state) ??
|
|
609
|
+
(e == null ? void 0 : e.state) ?? ne()
|
|
610
610
|
);
|
|
611
611
|
}
|
|
612
612
|
reset() {
|
|
613
|
-
const { mutation: e } = a(this,
|
|
614
|
-
a(this,
|
|
613
|
+
const { mutation: e } = a(this, _).getValue() ?? {};
|
|
614
|
+
a(this, _).next(void 0), e == null || e.cancel();
|
|
615
615
|
}
|
|
616
616
|
}
|
|
617
|
-
|
|
618
|
-
const
|
|
617
|
+
ie = new WeakMap(), _ = new WeakMap();
|
|
618
|
+
const At = Lt(void 0), $s = ({ client: s }) => (re(() => (s.mount(), () => {
|
|
619
619
|
s.unmount();
|
|
620
|
-
}), [s]), null),
|
|
620
|
+
}), [s]), null), gr = _t(
|
|
621
621
|
({ children: s, client: e }) => {
|
|
622
622
|
const t = et(() => e, [e]);
|
|
623
|
-
return /* @__PURE__ */ os(
|
|
623
|
+
return /* @__PURE__ */ os(At.Provider, { value: t, children: [
|
|
624
624
|
/* @__PURE__ */ ls($s, { client: e }),
|
|
625
625
|
s
|
|
626
626
|
] });
|
|
627
627
|
}
|
|
628
|
-
),
|
|
629
|
-
const e =
|
|
628
|
+
), Ut = (s) => {
|
|
629
|
+
const e = Wt(At);
|
|
630
630
|
if (s)
|
|
631
631
|
return s;
|
|
632
632
|
if (!e)
|
|
@@ -635,29 +635,29 @@ const Qt = zt(void 0), $s = ({ client: s }) => (se(() => (s.mount(), () => {
|
|
|
635
635
|
};
|
|
636
636
|
function ws() {
|
|
637
637
|
}
|
|
638
|
-
function
|
|
639
|
-
const t =
|
|
638
|
+
function mr(s, e) {
|
|
639
|
+
const t = Ut(e), r = k(s), n = Ye(() => [rt()]), u = ge(s.mutationKey ?? n.current), [i] = wt(
|
|
640
640
|
() => new Os(
|
|
641
641
|
t,
|
|
642
642
|
s
|
|
643
643
|
)
|
|
644
644
|
);
|
|
645
|
-
|
|
645
|
+
re(() => {
|
|
646
646
|
i.setOptions(s);
|
|
647
647
|
}, [i, s]);
|
|
648
|
-
const
|
|
649
|
-
(
|
|
650
|
-
i.mutate(
|
|
648
|
+
const l = et(() => i.observe(), [u, i]), f = Je(l.result$) ?? l.lastValue, h = le(
|
|
649
|
+
(o, d) => {
|
|
650
|
+
i.mutate(o, d).catch(ws);
|
|
651
651
|
},
|
|
652
652
|
[i]
|
|
653
653
|
);
|
|
654
|
-
return
|
|
654
|
+
return re(() => () => {
|
|
655
655
|
r.current.cancelOnUnMount && i.reset();
|
|
656
|
-
}, [i, r]), { ...
|
|
656
|
+
}, [i, r]), { ...f, mutate: h, mutateAsync: f.mutate };
|
|
657
657
|
}
|
|
658
658
|
function Cs(s) {
|
|
659
659
|
return (e) => e.pipe(
|
|
660
|
-
|
|
660
|
+
Rt((t) => {
|
|
661
661
|
s.next(t);
|
|
662
662
|
})
|
|
663
663
|
);
|
|
@@ -667,8 +667,8 @@ class Es {
|
|
|
667
667
|
y(this, "isOnlineSubject", new G(!0));
|
|
668
668
|
y(this, "online$", this.isOnlineSubject.pipe(P()));
|
|
669
669
|
y(this, "backToOnline$", this.online$.pipe(
|
|
670
|
-
|
|
671
|
-
|
|
670
|
+
$((e) => e),
|
|
671
|
+
st()
|
|
672
672
|
));
|
|
673
673
|
C(
|
|
674
674
|
Ne(window, "offline").pipe(g(() => !1)),
|
|
@@ -682,81 +682,81 @@ class Es {
|
|
|
682
682
|
this.isOnlineSubject.getValue() !== e && this.isOnlineSubject.next(e);
|
|
683
683
|
}
|
|
684
684
|
}
|
|
685
|
-
const
|
|
686
|
-
function
|
|
685
|
+
const se = new Es();
|
|
686
|
+
function it(s, e) {
|
|
687
687
|
return s.isStaleByTime(e.staleTime);
|
|
688
688
|
}
|
|
689
689
|
function Fs(s, e) {
|
|
690
690
|
return e.enabled !== !1 && !s.state.dataUpdatedAt && !(s.state.status === "error" && e.retryOnMount === !1);
|
|
691
691
|
}
|
|
692
|
-
function
|
|
693
|
-
return Fs(s, e) || s.state.dataUpdatedAt > 0 &&
|
|
692
|
+
function gt(s, e) {
|
|
693
|
+
return Fs(s, e) || s.state.dataUpdatedAt > 0 && It(s, e, e.refetchOnMount);
|
|
694
694
|
}
|
|
695
|
-
function
|
|
696
|
-
return s.state.fetchStatus !== "fetching" && t.enabled !== !1 && (s !== e || r.enabled === !1) && (!t.suspense || s.state.status !== "error") &&
|
|
695
|
+
function mt(s, e, t, r) {
|
|
696
|
+
return s.state.fetchStatus !== "fetching" && t.enabled !== !1 && (s !== e || r.enabled === !1) && (!t.suspense || s.state.status !== "error") && it(s, t);
|
|
697
697
|
}
|
|
698
698
|
function xs(s, e) {
|
|
699
|
-
return
|
|
699
|
+
return It(s, e, e.refetchOnWindowFocus);
|
|
700
700
|
}
|
|
701
|
-
function
|
|
701
|
+
function It(s, e, t) {
|
|
702
702
|
if (e.enabled !== !1) {
|
|
703
703
|
const r = typeof t == "function" ? t(s) : t;
|
|
704
|
-
return r === "always" || r !== !1 &&
|
|
704
|
+
return r === "always" || r !== !1 && it(s, e);
|
|
705
705
|
}
|
|
706
706
|
return !1;
|
|
707
707
|
}
|
|
708
708
|
function Rs(s) {
|
|
709
|
-
return (s ?? "online") === "online" ?
|
|
709
|
+
return (s ?? "online") === "online" ? se.isOnline() : !0;
|
|
710
710
|
}
|
|
711
|
-
function
|
|
711
|
+
function St(s, e) {
|
|
712
712
|
return e.reduce(
|
|
713
713
|
(t, r) => r in s ? { ...t, [r]: s[r] } : t,
|
|
714
714
|
{}
|
|
715
715
|
);
|
|
716
716
|
}
|
|
717
|
-
function
|
|
717
|
+
function vt(s) {
|
|
718
718
|
return Array.isArray(s) && s.length === Object.keys(s).length;
|
|
719
719
|
}
|
|
720
|
-
function
|
|
720
|
+
function Pt(s, e) {
|
|
721
721
|
if (s === e)
|
|
722
722
|
return s;
|
|
723
|
-
const t =
|
|
723
|
+
const t = vt(s) && vt(e);
|
|
724
724
|
if (t || Ze(s) && Ze(e)) {
|
|
725
|
-
const r = t ? s : Object.keys(s), n = r.length, u = t ? e : Object.keys(e), i = u.length,
|
|
726
|
-
let
|
|
725
|
+
const r = t ? s : Object.keys(s), n = r.length, u = t ? e : Object.keys(e), i = u.length, l = t ? [] : {};
|
|
726
|
+
let f = 0;
|
|
727
727
|
for (let h = 0; h < i; h++) {
|
|
728
|
-
const
|
|
729
|
-
!t && s[
|
|
728
|
+
const o = t ? h : u[h];
|
|
729
|
+
!t && s[o] === void 0 && e[o] === void 0 && r.includes(o) ? (l[o] = void 0, f++) : (l[o] = Pt(s[o], e[o]), l[o] === s[o] && s[o] !== void 0 && f++);
|
|
730
730
|
}
|
|
731
|
-
return n === i &&
|
|
731
|
+
return n === i && f === n ? s : l;
|
|
732
732
|
}
|
|
733
733
|
return e;
|
|
734
734
|
}
|
|
735
|
-
function
|
|
736
|
-
return ((e == null ? void 0 : e.queryKeyHashFn) ??
|
|
735
|
+
function ut(s, e) {
|
|
736
|
+
return ((e == null ? void 0 : e.queryKeyHashFn) ?? ge)(s);
|
|
737
737
|
}
|
|
738
|
-
function
|
|
738
|
+
function Ot(s, e) {
|
|
739
739
|
const {
|
|
740
740
|
type: t = "all",
|
|
741
741
|
exact: r,
|
|
742
742
|
fetchStatus: n,
|
|
743
743
|
predicate: u,
|
|
744
744
|
queryKey: i,
|
|
745
|
-
stale:
|
|
745
|
+
stale: l
|
|
746
746
|
} = s;
|
|
747
747
|
if (i) {
|
|
748
748
|
if (r) {
|
|
749
|
-
if (e.queryHash !==
|
|
749
|
+
if (e.queryHash !== ut(i, e.options))
|
|
750
750
|
return !1;
|
|
751
751
|
} else if (!Be(e.queryKey, i))
|
|
752
752
|
return !1;
|
|
753
753
|
}
|
|
754
754
|
if (t !== "all") {
|
|
755
|
-
const
|
|
756
|
-
if (t === "active" && !
|
|
755
|
+
const f = e.isActive();
|
|
756
|
+
if (t === "active" && !f || t === "inactive" && f)
|
|
757
757
|
return !1;
|
|
758
758
|
}
|
|
759
|
-
return !(typeof
|
|
759
|
+
return !(typeof l == "boolean" && e.isStale() !== l || typeof n < "u" && n !== e.state.fetchStatus || u && !u(e));
|
|
760
760
|
}
|
|
761
761
|
function Ms(s, e) {
|
|
762
762
|
return Math.max(s + (e ?? 0) - Date.now(), 0);
|
|
@@ -765,7 +765,7 @@ function js(s, e) {
|
|
|
765
765
|
return typeof s == "function" ? s(e) : s;
|
|
766
766
|
}
|
|
767
767
|
function ze(s, e, t) {
|
|
768
|
-
return typeof t.structuralSharing == "function" ? t.structuralSharing(s, e) : t.structuralSharing !== !1 ?
|
|
768
|
+
return typeof t.structuralSharing == "function" ? t.structuralSharing(s, e) : t.structuralSharing !== !1 ? Pt(s, e) : e;
|
|
769
769
|
}
|
|
770
770
|
const Qs = ({
|
|
771
771
|
getOptions: s,
|
|
@@ -779,20 +779,20 @@ const Qs = ({
|
|
|
779
779
|
const R = n.status === "pending" ? "pending" : i.status ?? n.status;
|
|
780
780
|
return { ...n, ...i, status: R };
|
|
781
781
|
}
|
|
782
|
-
const
|
|
783
|
-
(
|
|
782
|
+
const l = i.data, f = l !== void 0 && l !== n.data, h = "data" in i, o = i.status === "success", d = n.data !== void 0, c = n.error !== void 0 || n.error !== null, b = i.status ?? n.status, E = f ? ze(e().data, l, s()) : h ? i.data : n.data, p = n.status === "error" || n.status === "success", S = i.status === "error" && (n.status === "error" && n.fetchStatus === "fetching" || n.status !== "error") ? n.errorUpdateCount + 1 : n.errorUpdateCount, O = f ? n.dataUpdateCount + 1 : i.dataUpdateCount ?? n.dataUpdateCount, z = i.status === "pending" && p && // (dataUpdateCount !== 0 || errorUpdateCount !== 0)
|
|
783
|
+
(d || c), I = b === "pending" ? null : i.error ?? n.error;
|
|
784
784
|
return {
|
|
785
785
|
...n,
|
|
786
786
|
...i,
|
|
787
787
|
status: b,
|
|
788
|
-
error:
|
|
788
|
+
error: I,
|
|
789
789
|
errorUpdateCount: S,
|
|
790
|
-
...
|
|
790
|
+
...o && {
|
|
791
791
|
isInvalidated: !1
|
|
792
792
|
},
|
|
793
793
|
data: E,
|
|
794
794
|
dataUpdateCount: O,
|
|
795
|
-
...
|
|
795
|
+
...z && {
|
|
796
796
|
status: n.status
|
|
797
797
|
}
|
|
798
798
|
};
|
|
@@ -801,36 +801,36 @@ const Qs = ({
|
|
|
801
801
|
g(
|
|
802
802
|
({ status: e, fetchStatus: t }) => t === "idle" && (e === "success" || e === "error")
|
|
803
803
|
)
|
|
804
|
-
),
|
|
804
|
+
), Vt = (s) => s.pipe(
|
|
805
805
|
Ge((e) => e.fetchStatus !== "idle", !0)
|
|
806
806
|
);
|
|
807
|
-
var _e,
|
|
807
|
+
var _e, Z;
|
|
808
808
|
class Us {
|
|
809
809
|
constructor() {
|
|
810
|
-
|
|
810
|
+
w(this, _e, C(
|
|
811
811
|
Ne(document, "visibilitychange"),
|
|
812
812
|
Ne(window, "visibilitychange")
|
|
813
813
|
).pipe(g(() => document.visibilityState)));
|
|
814
|
-
|
|
814
|
+
w(this, Z, new G(
|
|
815
815
|
document.visibilityState === "visible"
|
|
816
816
|
));
|
|
817
817
|
// public readonly focused$ = this.#focusedSubject.pipe(distinctUntilChanged())
|
|
818
|
-
y(this, "focused$", a(this,
|
|
818
|
+
y(this, "focused$", a(this, Z));
|
|
819
819
|
y(this, "focusRegained$", this.focused$.pipe(
|
|
820
|
-
|
|
821
|
-
|
|
820
|
+
Ct(1),
|
|
821
|
+
$((e) => e)
|
|
822
822
|
));
|
|
823
823
|
a(this, _e).pipe(
|
|
824
824
|
F((e) => {
|
|
825
|
-
a(this,
|
|
825
|
+
a(this, Z).next(e === "visible");
|
|
826
826
|
})
|
|
827
827
|
).subscribe();
|
|
828
828
|
}
|
|
829
829
|
isFocused() {
|
|
830
|
-
return a(this,
|
|
830
|
+
return a(this, Z).getValue();
|
|
831
831
|
}
|
|
832
832
|
setFocused(e) {
|
|
833
|
-
a(this,
|
|
833
|
+
a(this, Z).getValue() !== (e ?? !0) && a(this, Z).next(e ?? !0);
|
|
834
834
|
}
|
|
835
835
|
subscribe(e) {
|
|
836
836
|
const t = this.focused$.subscribe(e);
|
|
@@ -849,33 +849,33 @@ class Us {
|
|
|
849
849
|
document.dispatchEvent(new Event("visibilitychange"));
|
|
850
850
|
}
|
|
851
851
|
}
|
|
852
|
-
_e = new WeakMap(),
|
|
852
|
+
_e = new WeakMap(), Z = new WeakMap();
|
|
853
853
|
const Le = new Us();
|
|
854
|
-
var J, x, we,
|
|
854
|
+
var J, x, we, ue, V, de, Ce;
|
|
855
855
|
class Is {
|
|
856
856
|
constructor(e, t) {
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
857
|
+
w(this, J, void 0);
|
|
858
|
+
w(this, x, void 0);
|
|
859
|
+
w(this, we, new U());
|
|
860
860
|
/**
|
|
861
861
|
* Used to subscribe to changes in either query or options (or both).
|
|
862
862
|
* We need to be able to track change to both of them at the same time
|
|
863
863
|
* in order to react accordingly and in order (such as refetch on options change)
|
|
864
864
|
*/
|
|
865
|
-
y(this, "queryUpdateSubject", new
|
|
865
|
+
y(this, "queryUpdateSubject", new U());
|
|
866
866
|
/**
|
|
867
867
|
* Mostly used to compare the state before and after mount
|
|
868
868
|
*/
|
|
869
|
-
|
|
869
|
+
w(this, ue, void 0);
|
|
870
870
|
/**
|
|
871
871
|
* Mostly used for internal optimization such as not
|
|
872
872
|
* running selectors twice, etc
|
|
873
873
|
*/
|
|
874
|
-
|
|
874
|
+
w(this, V, void 0);
|
|
875
875
|
// This property keeps track of the last query with defined data.
|
|
876
876
|
// It will be used to pass the previous data and query to the placeholder function between renders.
|
|
877
|
-
|
|
878
|
-
|
|
877
|
+
w(this, de, void 0);
|
|
878
|
+
w(this, Ce, 0);
|
|
879
879
|
y(this, "getObserverResultFromQuery", ({
|
|
880
880
|
options: e,
|
|
881
881
|
query: t,
|
|
@@ -884,48 +884,48 @@ class Is {
|
|
|
884
884
|
result: n,
|
|
885
885
|
options: u,
|
|
886
886
|
state: i,
|
|
887
|
-
select:
|
|
888
|
-
selectError:
|
|
887
|
+
select: l,
|
|
888
|
+
selectError: f,
|
|
889
889
|
selectResult: h
|
|
890
890
|
}
|
|
891
891
|
}) => {
|
|
892
892
|
var De;
|
|
893
|
-
const
|
|
894
|
-
let { errorUpdatedAt: S, fetchStatus: O, error:
|
|
893
|
+
const o = t.state, d = t.state.status === "pending", c = a(this, x), b = this.options, p = t !== c ? t.state : a(this, ue);
|
|
894
|
+
let { errorUpdatedAt: S, fetchStatus: O, error: z } = o;
|
|
895
895
|
if (r) {
|
|
896
|
-
const K = !!a(this, Ce),
|
|
897
|
-
(
|
|
896
|
+
const K = !!a(this, Ce), ct = !K && gt(t, e), Nt = K && mt(t, c, e, b);
|
|
897
|
+
(ct || Nt) && (O = Rs(t.options.networkMode) ? "fetching" : "paused");
|
|
898
898
|
}
|
|
899
|
-
const
|
|
900
|
-
let R, m =
|
|
901
|
-
if (e.select && typeof
|
|
902
|
-
if (n &&
|
|
899
|
+
const I = d && O === "fetching";
|
|
900
|
+
let R, m = f, B = l ?? null, T = h;
|
|
901
|
+
if (e.select && typeof o.data < "u")
|
|
902
|
+
if (n && o.data === (i == null ? void 0 : i.data) && e.select === l)
|
|
903
903
|
R = h;
|
|
904
904
|
else
|
|
905
905
|
try {
|
|
906
|
-
|
|
906
|
+
B = e.select, R = e.select(o.data), R = ze(n == null ? void 0 : n.data, R, e), T = R, m = null;
|
|
907
907
|
} catch (K) {
|
|
908
908
|
R = h, m = K;
|
|
909
909
|
}
|
|
910
910
|
else
|
|
911
|
-
R =
|
|
912
|
-
let
|
|
913
|
-
m && (
|
|
914
|
-
const Ie =
|
|
911
|
+
R = o.data, m = null;
|
|
912
|
+
let L = O !== "idle" && !o.dataUpdatedAt ? "pending" : o.status;
|
|
913
|
+
m && (z = m, R = h, S = (n == null ? void 0 : n.errorUpdatedAt) ?? S, L = "error");
|
|
914
|
+
const Ie = L === "error";
|
|
915
915
|
let Pe = !1;
|
|
916
|
-
if (typeof e.placeholderData < "u" && typeof R > "u" &&
|
|
916
|
+
if (typeof e.placeholderData < "u" && typeof R > "u" && L === "pending") {
|
|
917
917
|
let K;
|
|
918
918
|
if (n != null && n.isPlaceholderData && e.placeholderData === (u == null ? void 0 : u.placeholderData))
|
|
919
919
|
K = n.data;
|
|
920
920
|
else if (K = typeof e.placeholderData == "function" ? e.placeholderData(
|
|
921
|
-
(De = a(this,
|
|
922
|
-
a(this,
|
|
921
|
+
(De = a(this, de)) == null ? void 0 : De.state.data,
|
|
922
|
+
a(this, de)
|
|
923
923
|
) : e.placeholderData, e.select && typeof K < "u")
|
|
924
924
|
try {
|
|
925
925
|
K = e.select(K);
|
|
926
926
|
} catch {
|
|
927
927
|
}
|
|
928
|
-
typeof K < "u" && (
|
|
928
|
+
typeof K < "u" && (L = "success", R = ze(
|
|
929
929
|
n == null ? void 0 : n.data,
|
|
930
930
|
K,
|
|
931
931
|
e
|
|
@@ -934,40 +934,40 @@ class Is {
|
|
|
934
934
|
const Ve = O === "fetching";
|
|
935
935
|
return {
|
|
936
936
|
result: {
|
|
937
|
-
status:
|
|
937
|
+
status: L,
|
|
938
938
|
fetchStatus: O,
|
|
939
|
-
isPending:
|
|
940
|
-
isSuccess:
|
|
939
|
+
isPending: d,
|
|
940
|
+
isSuccess: L === "success",
|
|
941
941
|
isError: Ie,
|
|
942
|
-
isInitialLoading:
|
|
943
|
-
isLoading:
|
|
942
|
+
isInitialLoading: I,
|
|
943
|
+
isLoading: I,
|
|
944
944
|
data: R,
|
|
945
|
-
dataUpdatedAt:
|
|
946
|
-
error:
|
|
945
|
+
dataUpdatedAt: o.dataUpdatedAt,
|
|
946
|
+
error: z,
|
|
947
947
|
errorUpdatedAt: S,
|
|
948
|
-
failureCount:
|
|
949
|
-
failureReason:
|
|
950
|
-
errorUpdateCount:
|
|
951
|
-
isFetched:
|
|
952
|
-
isFetchedAfterMount:
|
|
948
|
+
failureCount: o.fetchFailureCount,
|
|
949
|
+
failureReason: o.fetchFailureReason,
|
|
950
|
+
errorUpdateCount: o.errorUpdateCount,
|
|
951
|
+
isFetched: o.dataUpdateCount > 0 || o.errorUpdateCount > 0,
|
|
952
|
+
isFetchedAfterMount: o.dataUpdateCount > p.dataUpdateCount || o.errorUpdateCount > p.errorUpdateCount,
|
|
953
953
|
isFetching: Ve,
|
|
954
|
-
isRefetching: Ve && !
|
|
955
|
-
isLoadingError: Ie &&
|
|
954
|
+
isRefetching: Ve && !d,
|
|
955
|
+
isLoadingError: Ie && o.dataUpdatedAt === 0,
|
|
956
956
|
isPaused: O === "paused",
|
|
957
957
|
isPlaceholderData: Pe,
|
|
958
|
-
isRefetchError: Ie &&
|
|
959
|
-
isStale:
|
|
958
|
+
isRefetchError: Ie && o.dataUpdatedAt !== 0,
|
|
959
|
+
isStale: it(t, e),
|
|
960
960
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
961
961
|
refetch: this.refetch
|
|
962
962
|
},
|
|
963
963
|
selectError: m,
|
|
964
|
-
select:
|
|
964
|
+
select: B,
|
|
965
965
|
selectResult: T
|
|
966
966
|
};
|
|
967
967
|
});
|
|
968
968
|
this.options = t, M(this, J, e), this.bindMethods(), M(this, x, this.setOptions(t));
|
|
969
969
|
const r = a(this, x);
|
|
970
|
-
M(this,
|
|
970
|
+
M(this, ue, r.state);
|
|
971
971
|
const { result: n, select: u } = this.getObserverResultFromQuery({
|
|
972
972
|
query: r,
|
|
973
973
|
options: this.options,
|
|
@@ -995,7 +995,7 @@ class Is {
|
|
|
995
995
|
}), typeof this.options.enabled < "u" && typeof this.options.enabled != "boolean")
|
|
996
996
|
throw new Error("Expected enabled to be a boolean");
|
|
997
997
|
const r = this.buildQuery(this.options);
|
|
998
|
-
return r !== a(this, x) && (M(this,
|
|
998
|
+
return r !== a(this, x) && (M(this, ue, r.state), M(this, x, r)), this.queryUpdateSubject.next({
|
|
999
999
|
options: this.options,
|
|
1000
1000
|
query: r
|
|
1001
1001
|
}), r;
|
|
@@ -1030,7 +1030,7 @@ class Is {
|
|
|
1030
1030
|
select: n,
|
|
1031
1031
|
selectResult: u
|
|
1032
1032
|
}) {
|
|
1033
|
-
a(this, V).state = e.state, a(this, V).result = t, a(this, V).selectResult = u, r !== void 0 && (a(this, V).selectError = r), n !== void 0 && (a(this, V).select = n), a(this, V).options = this.options, e.state.data !== void 0 && M(this,
|
|
1033
|
+
a(this, V).state = e.state, a(this, V).result = t, a(this, V).selectResult = u, r !== void 0 && (a(this, V).selectError = r), n !== void 0 && (a(this, V).select = n), a(this, V).options = this.options, e.state.data !== void 0 && M(this, de, e), a(this, J).getQueryCache().notify({
|
|
1034
1034
|
query: a(this, x),
|
|
1035
1035
|
type: "observerResultsUpdated"
|
|
1036
1036
|
});
|
|
@@ -1042,7 +1042,7 @@ class Is {
|
|
|
1042
1042
|
}
|
|
1043
1043
|
async fetch(e) {
|
|
1044
1044
|
const t = this.buildQuery(this.options);
|
|
1045
|
-
t !== a(this, x) && (M(this, x, t), M(this,
|
|
1045
|
+
t !== a(this, x) && (M(this, x, t), M(this, ue, t.state), this.queryUpdateSubject.next({
|
|
1046
1046
|
options: this.options,
|
|
1047
1047
|
query: t
|
|
1048
1048
|
}));
|
|
@@ -1073,23 +1073,23 @@ class Is {
|
|
|
1073
1073
|
observe() {
|
|
1074
1074
|
const e = a(this, x), t = this.queryUpdateSubject.pipe(
|
|
1075
1075
|
g(({ query: i }) => i),
|
|
1076
|
-
|
|
1076
|
+
oe(a(this, x)),
|
|
1077
1077
|
P()
|
|
1078
1078
|
), r = this.queryUpdateSubject.pipe(
|
|
1079
|
-
|
|
1079
|
+
oe({
|
|
1080
1080
|
query: a(this, x),
|
|
1081
1081
|
options: this.options
|
|
1082
1082
|
}),
|
|
1083
1083
|
Ft(),
|
|
1084
1084
|
F(
|
|
1085
|
-
([{ options: i, query:
|
|
1086
|
-
|
|
1085
|
+
([{ options: i, query: l }, { options: f, query: h }]) => {
|
|
1086
|
+
mt(h, l, f, i) && this.fetch().catch(H);
|
|
1087
1087
|
}
|
|
1088
1088
|
),
|
|
1089
|
-
|
|
1089
|
+
he()
|
|
1090
1090
|
), n = t.pipe(
|
|
1091
1091
|
Q((i) => i.observe(this)),
|
|
1092
|
-
|
|
1092
|
+
he()
|
|
1093
1093
|
);
|
|
1094
1094
|
return C(
|
|
1095
1095
|
/**
|
|
@@ -1100,68 +1100,68 @@ class Is {
|
|
|
1100
1100
|
r,
|
|
1101
1101
|
t.pipe(
|
|
1102
1102
|
Q((i) => {
|
|
1103
|
-
const
|
|
1104
|
-
|
|
1105
|
-
|
|
1103
|
+
const l = this.options, f = this.queryUpdateSubject.pipe(
|
|
1104
|
+
oe({ query: i, options: l }),
|
|
1105
|
+
$((m) => m.query === i),
|
|
1106
1106
|
g((m) => m.options),
|
|
1107
1107
|
P(),
|
|
1108
1108
|
Ue(1)
|
|
1109
1109
|
), h = a(this, we).pipe(
|
|
1110
|
-
|
|
1111
|
-
),
|
|
1112
|
-
|
|
1110
|
+
$((m) => m.query === i)
|
|
1111
|
+
), o = i.state$.pipe(
|
|
1112
|
+
$((m) => m.status === "success"),
|
|
1113
1113
|
Q(
|
|
1114
1114
|
(m) => this.options.staleTime === 1 / 0 ? Oe : Ae(this.options.staleTime ?? 1).pipe(g(() => m))
|
|
1115
1115
|
),
|
|
1116
1116
|
Ge(() => this.options.enabled ?? !0)
|
|
1117
|
-
),
|
|
1118
|
-
const T =
|
|
1119
|
-
return (Array.isArray(
|
|
1120
|
-
const
|
|
1117
|
+
), d = (m, B) => {
|
|
1118
|
+
const T = l.notifyOnChangeProps, L = typeof T == "function" ? T() : T;
|
|
1119
|
+
return (Array.isArray(L) ? L.length === 0 ? () => !0 : (Pe, Ve) => {
|
|
1120
|
+
const at = St(
|
|
1121
1121
|
Pe,
|
|
1122
|
-
|
|
1123
|
-
), De =
|
|
1122
|
+
L
|
|
1123
|
+
), De = St(
|
|
1124
1124
|
Ve,
|
|
1125
|
-
|
|
1125
|
+
L
|
|
1126
1126
|
);
|
|
1127
|
-
return D(
|
|
1128
|
-
} : D)(m,
|
|
1127
|
+
return D(at, De);
|
|
1128
|
+
} : D)(m, B);
|
|
1129
1129
|
}, c = h.pipe(
|
|
1130
1130
|
Q(() => i.state$),
|
|
1131
|
-
|
|
1132
|
-
), b =
|
|
1131
|
+
Vt
|
|
1132
|
+
), b = f.pipe(
|
|
1133
1133
|
Q(() => {
|
|
1134
|
-
const { refetchInterval: m, refetchIntervalInBackground:
|
|
1135
|
-
return T ?
|
|
1134
|
+
const { refetchInterval: m, refetchIntervalInBackground: B } = this.options, T = (typeof m == "function" ? m(a(this, x)) : m) ?? !1;
|
|
1135
|
+
return T ? es(T).pipe(
|
|
1136
1136
|
F(() => {
|
|
1137
1137
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
1138
|
-
(
|
|
1138
|
+
(B || Le.isFocused()) && this.fetch({ cancelRefetch: !1 }).catch(H);
|
|
1139
1139
|
})
|
|
1140
1140
|
) : Oe;
|
|
1141
1141
|
}),
|
|
1142
|
-
|
|
1143
|
-
), E =
|
|
1142
|
+
he()
|
|
1143
|
+
), E = f.pipe(
|
|
1144
1144
|
g(({ enabled: m }) => m ?? !0),
|
|
1145
1145
|
P()
|
|
1146
1146
|
), p = E.pipe(
|
|
1147
|
-
|
|
1147
|
+
$((m) => !m),
|
|
1148
1148
|
g(() => i.state)
|
|
1149
1149
|
), S = E.pipe(
|
|
1150
|
-
|
|
1150
|
+
$((m) => m),
|
|
1151
1151
|
Q(() => Le.focusRegained$),
|
|
1152
|
-
|
|
1152
|
+
ht(f),
|
|
1153
1153
|
F(([, m]) => {
|
|
1154
1154
|
xs(i, m) && this.fetch({ cancelRefetch: !1 }).catch(H);
|
|
1155
1155
|
}),
|
|
1156
|
-
|
|
1156
|
+
he()
|
|
1157
1157
|
), O = p.pipe(
|
|
1158
1158
|
g(() => i.state)
|
|
1159
|
-
),
|
|
1160
|
-
|
|
1161
|
-
g(([,
|
|
1159
|
+
), z = (m) => m.pipe(
|
|
1160
|
+
ht(f),
|
|
1161
|
+
g(([, B]) => {
|
|
1162
1162
|
const T = this.getObserverResultFromQuery({
|
|
1163
1163
|
query: i,
|
|
1164
|
-
options:
|
|
1164
|
+
options: B,
|
|
1165
1165
|
prevResult: a(this, V)
|
|
1166
1166
|
});
|
|
1167
1167
|
return this.updateResult({ query: i, ...T }), T.result;
|
|
@@ -1171,21 +1171,21 @@ class Is {
|
|
|
1171
1171
|
c,
|
|
1172
1172
|
i.state$,
|
|
1173
1173
|
// options$,
|
|
1174
|
-
|
|
1174
|
+
o
|
|
1175
1175
|
).pipe(
|
|
1176
|
-
|
|
1176
|
+
z,
|
|
1177
1177
|
// This one ensure we don't re-trigger same state
|
|
1178
1178
|
P(D),
|
|
1179
1179
|
// This one make sure we dispatch based on user preference
|
|
1180
|
-
P(
|
|
1180
|
+
P(d)
|
|
1181
1181
|
);
|
|
1182
1182
|
return C(b, S, R);
|
|
1183
1183
|
})
|
|
1184
1184
|
).pipe(
|
|
1185
|
-
|
|
1185
|
+
nt((i) => M(this, Ce, i)),
|
|
1186
1186
|
F({
|
|
1187
1187
|
subscribe: () => {
|
|
1188
|
-
|
|
1188
|
+
gt(e, this.options) && this.fetch().catch(H);
|
|
1189
1189
|
}
|
|
1190
1190
|
})
|
|
1191
1191
|
)
|
|
@@ -1194,12 +1194,12 @@ class Is {
|
|
|
1194
1194
|
destroy() {
|
|
1195
1195
|
}
|
|
1196
1196
|
}
|
|
1197
|
-
J = new WeakMap(), x = new WeakMap(), we = new WeakMap(),
|
|
1197
|
+
J = new WeakMap(), x = new WeakMap(), we = new WeakMap(), ue = new WeakMap(), V = new WeakMap(), de = new WeakMap(), Ce = new WeakMap();
|
|
1198
1198
|
function Ps(s, e) {
|
|
1199
1199
|
return !D(s.getCurrentResult(), e);
|
|
1200
1200
|
}
|
|
1201
|
-
const
|
|
1202
|
-
|
|
1201
|
+
const Dt = We.createContext(!1), Vs = () => We.useContext(Dt);
|
|
1202
|
+
Dt.Provider;
|
|
1203
1203
|
function Ds() {
|
|
1204
1204
|
let s = !1;
|
|
1205
1205
|
return {
|
|
@@ -1227,65 +1227,65 @@ function Hs(s, e, t) {
|
|
|
1227
1227
|
throw new Error(
|
|
1228
1228
|
'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'
|
|
1229
1229
|
);
|
|
1230
|
-
const r =
|
|
1230
|
+
const r = Ut(t), n = Vs(), u = Ts(), i = r.defaultQueryOptions(s);
|
|
1231
1231
|
i._optimisticResults = n ? "isRestoring" : "optimistic";
|
|
1232
|
-
const [
|
|
1232
|
+
const [l] = wt(
|
|
1233
1233
|
() => new e(
|
|
1234
1234
|
r,
|
|
1235
1235
|
i
|
|
1236
1236
|
)
|
|
1237
|
-
),
|
|
1238
|
-
|
|
1239
|
-
),
|
|
1237
|
+
), f = Ye(() => l.observe()), h = k(
|
|
1238
|
+
l.getOptimisticResult(i)
|
|
1239
|
+
), o = h.current;
|
|
1240
1240
|
Je(
|
|
1241
|
-
() =>
|
|
1241
|
+
() => f.current.pipe(
|
|
1242
1242
|
/**
|
|
1243
1243
|
* By the time this observer runs the result may have changed (eg: synchronous setData).
|
|
1244
1244
|
* It's important to not skip the first result (even tho most of the time they are equal).
|
|
1245
1245
|
* We only skip if they are the same.
|
|
1246
1246
|
*/
|
|
1247
|
-
|
|
1247
|
+
$((c) => !D(c, h.current))
|
|
1248
1248
|
),
|
|
1249
1249
|
[]
|
|
1250
|
-
),
|
|
1251
|
-
|
|
1252
|
-
}, [i,
|
|
1253
|
-
const
|
|
1254
|
-
if (
|
|
1255
|
-
result:
|
|
1250
|
+
), re(() => {
|
|
1251
|
+
l.setOptions(i);
|
|
1252
|
+
}, [i, l]);
|
|
1253
|
+
const d = o.error;
|
|
1254
|
+
if (d && Ns({
|
|
1255
|
+
result: o,
|
|
1256
1256
|
errorResetBoundary: u,
|
|
1257
1257
|
throwOnError: i.throwOnError,
|
|
1258
1258
|
query: r.getQueryCache().get(
|
|
1259
1259
|
i.queryHash
|
|
1260
1260
|
)
|
|
1261
1261
|
}))
|
|
1262
|
-
throw
|
|
1262
|
+
throw d;
|
|
1263
1263
|
return h.current;
|
|
1264
1264
|
}
|
|
1265
|
-
function
|
|
1265
|
+
function Sr(s, e) {
|
|
1266
1266
|
return Hs(s, Is, e);
|
|
1267
1267
|
}
|
|
1268
|
-
function
|
|
1268
|
+
function vr(s, e, t = []) {
|
|
1269
1269
|
const r = e != null && !Array.isArray(e) ? e : {}, n = r.retry ?? !0, u = k(
|
|
1270
|
-
r.onError ?? ((
|
|
1271
|
-
console.error(
|
|
1270
|
+
r.onError ?? ((f) => {
|
|
1271
|
+
console.error(f);
|
|
1272
1272
|
})
|
|
1273
|
-
), i =
|
|
1273
|
+
), i = le(() => A(s), t), l = le(
|
|
1274
1274
|
() => i().pipe(
|
|
1275
|
-
|
|
1276
|
-
throw u.current(
|
|
1275
|
+
te((f) => {
|
|
1276
|
+
throw u.current(f), f;
|
|
1277
1277
|
}),
|
|
1278
|
-
n ?
|
|
1278
|
+
n ? ts() : Et
|
|
1279
1279
|
),
|
|
1280
1280
|
[i, n, u]
|
|
1281
1281
|
);
|
|
1282
|
-
|
|
1282
|
+
Mt(l, t);
|
|
1283
1283
|
}
|
|
1284
|
-
const
|
|
1284
|
+
const kt = () => (s) => C(
|
|
1285
1285
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
1286
1286
|
v({ isPaused: !0 }),
|
|
1287
|
-
|
|
1288
|
-
|
|
1287
|
+
se.backToOnline$.pipe(
|
|
1288
|
+
q(
|
|
1289
1289
|
() => (
|
|
1290
1290
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
1291
1291
|
C(v({ isPaused: !1 }), s)
|
|
@@ -1295,7 +1295,7 @@ const Dt = () => (s) => C(
|
|
|
1295
1295
|
), qs = (s) => {
|
|
1296
1296
|
let e = 0;
|
|
1297
1297
|
return s.pipe(
|
|
1298
|
-
|
|
1298
|
+
te((t) => (e++, e <= 1 && !se.isOnline() ? C(
|
|
1299
1299
|
v({
|
|
1300
1300
|
failureCount: e,
|
|
1301
1301
|
failureReason: t
|
|
@@ -1305,7 +1305,7 @@ const Dt = () => (s) => C(
|
|
|
1305
1305
|
* timer needed to be iso RQ, so the state returned by mutation include both previous and next one
|
|
1306
1306
|
*/
|
|
1307
1307
|
Ae(1).pipe(
|
|
1308
|
-
|
|
1308
|
+
q(() => me(() => t).pipe(kt()))
|
|
1309
1309
|
)
|
|
1310
1310
|
) : me(() => t)))
|
|
1311
1311
|
);
|
|
@@ -1314,7 +1314,7 @@ const Dt = () => (s) => C(
|
|
|
1314
1314
|
state: e,
|
|
1315
1315
|
options: t
|
|
1316
1316
|
}) => {
|
|
1317
|
-
const r = e.isPaused, n = async () => await Promise.reject(new Error("No mutationFn found")), u = t.mutationFn ?? n,
|
|
1317
|
+
const r = e.isPaused, n = async () => await Promise.reject(new Error("No mutationFn found")), u = t.mutationFn ?? n, l = ss(
|
|
1318
1318
|
() => r,
|
|
1319
1319
|
v(e.context),
|
|
1320
1320
|
A(
|
|
@@ -1324,13 +1324,13 @@ const Dt = () => (s) => C(
|
|
|
1324
1324
|
return ((c = t.onMutate) == null ? void 0 : c.call(t, s)) ?? void 0;
|
|
1325
1325
|
}
|
|
1326
1326
|
)
|
|
1327
|
-
).pipe(Ue(1)),
|
|
1327
|
+
).pipe(Ue(1)), f = (c, b, E) => (console.error(c), A(
|
|
1328
1328
|
() => {
|
|
1329
1329
|
var S;
|
|
1330
1330
|
return (S = t.onError) == null ? void 0 : S.call(t, c, s, b);
|
|
1331
1331
|
}
|
|
1332
1332
|
).pipe(
|
|
1333
|
-
|
|
1333
|
+
te(() => v(c)),
|
|
1334
1334
|
g(
|
|
1335
1335
|
() => ({
|
|
1336
1336
|
failureCount: E,
|
|
@@ -1340,7 +1340,7 @@ const Dt = () => (s) => C(
|
|
|
1340
1340
|
status: "error"
|
|
1341
1341
|
})
|
|
1342
1342
|
)
|
|
1343
|
-
)), h =
|
|
1343
|
+
)), h = l.pipe(
|
|
1344
1344
|
Q((c) => {
|
|
1345
1345
|
const E = (typeof u == "function" ? (
|
|
1346
1346
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
@@ -1356,7 +1356,7 @@ const Dt = () => (s) => C(
|
|
|
1356
1356
|
})
|
|
1357
1357
|
),
|
|
1358
1358
|
qs,
|
|
1359
|
-
|
|
1359
|
+
Qt({
|
|
1360
1360
|
...t,
|
|
1361
1361
|
retry: (p, S) => {
|
|
1362
1362
|
const O = t.retry ?? 0;
|
|
@@ -1369,7 +1369,7 @@ const Dt = () => (s) => C(
|
|
|
1369
1369
|
failureReason: S
|
|
1370
1370
|
})
|
|
1371
1371
|
),
|
|
1372
|
-
catchError: (p, S) =>
|
|
1372
|
+
catchError: (p, S) => f(S, c, p).pipe(
|
|
1373
1373
|
g((O) => ({
|
|
1374
1374
|
...O,
|
|
1375
1375
|
result: void 0
|
|
@@ -1381,9 +1381,9 @@ const Dt = () => (s) => C(
|
|
|
1381
1381
|
!0
|
|
1382
1382
|
)
|
|
1383
1383
|
);
|
|
1384
|
-
return
|
|
1384
|
+
return se.isOnline() || t.networkMode === "offlineFirst" ? E : E.pipe(kt());
|
|
1385
1385
|
})
|
|
1386
|
-
),
|
|
1386
|
+
), o = v({
|
|
1387
1387
|
...e,
|
|
1388
1388
|
variables: s,
|
|
1389
1389
|
status: "pending",
|
|
@@ -1393,9 +1393,9 @@ const Dt = () => (s) => C(
|
|
|
1393
1393
|
submittedAt: e.submittedAt ?? (/* @__PURE__ */ new Date()).getTime()
|
|
1394
1394
|
});
|
|
1395
1395
|
return C(
|
|
1396
|
-
|
|
1396
|
+
o,
|
|
1397
1397
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
1398
|
-
|
|
1398
|
+
l.pipe(g((c) => ({ context: c }))),
|
|
1399
1399
|
h.pipe(
|
|
1400
1400
|
Q(({ result: c, error: b, ...E }) => {
|
|
1401
1401
|
if (!c && !b)
|
|
@@ -1404,8 +1404,8 @@ const Dt = () => (s) => C(
|
|
|
1404
1404
|
});
|
|
1405
1405
|
const p = b ? v(null) : A(
|
|
1406
1406
|
() => {
|
|
1407
|
-
var
|
|
1408
|
-
return (
|
|
1407
|
+
var I;
|
|
1408
|
+
return (I = t.onSuccess) == null ? void 0 : I.call(
|
|
1409
1409
|
t,
|
|
1410
1410
|
c == null ? void 0 : c.data,
|
|
1411
1411
|
s,
|
|
@@ -1414,8 +1414,8 @@ const Dt = () => (s) => C(
|
|
|
1414
1414
|
}
|
|
1415
1415
|
), O = A(
|
|
1416
1416
|
() => {
|
|
1417
|
-
var
|
|
1418
|
-
return (
|
|
1417
|
+
var I;
|
|
1418
|
+
return (I = t.onSettled) == null ? void 0 : I.call(
|
|
1419
1419
|
t,
|
|
1420
1420
|
c == null ? void 0 : c.data,
|
|
1421
1421
|
b,
|
|
@@ -1424,7 +1424,7 @@ const Dt = () => (s) => C(
|
|
|
1424
1424
|
);
|
|
1425
1425
|
}
|
|
1426
1426
|
).pipe(
|
|
1427
|
-
|
|
1427
|
+
te((I) => c ? v(c) : v(I))
|
|
1428
1428
|
);
|
|
1429
1429
|
return ke(p, O).pipe(
|
|
1430
1430
|
Te(),
|
|
@@ -1444,8 +1444,8 @@ const Dt = () => (s) => C(
|
|
|
1444
1444
|
...E
|
|
1445
1445
|
}
|
|
1446
1446
|
),
|
|
1447
|
-
|
|
1448
|
-
(
|
|
1447
|
+
te(
|
|
1448
|
+
(I) => f(I, E.context, 0).pipe(
|
|
1449
1449
|
g((R) => ({
|
|
1450
1450
|
...R,
|
|
1451
1451
|
data: void 0
|
|
@@ -1461,116 +1461,116 @@ const Dt = () => (s) => C(
|
|
|
1461
1461
|
...b,
|
|
1462
1462
|
data: b.data ?? c.data,
|
|
1463
1463
|
error: b.error ?? c.error
|
|
1464
|
-
}),
|
|
1464
|
+
}), ne()),
|
|
1465
1465
|
P(
|
|
1466
1466
|
({ data: c, ...b }, { data: E, ...p }) => D(b, p) && D(c, E)
|
|
1467
1467
|
)
|
|
1468
1468
|
);
|
|
1469
1469
|
};
|
|
1470
|
-
var Ee,
|
|
1470
|
+
var Ee, ee, pe;
|
|
1471
1471
|
class Ls {
|
|
1472
1472
|
constructor({
|
|
1473
1473
|
options: e,
|
|
1474
1474
|
mutationCache: t,
|
|
1475
1475
|
state: r
|
|
1476
1476
|
}) {
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
y(this, "state",
|
|
1477
|
+
w(this, Ee, new G(0));
|
|
1478
|
+
w(this, ee, new U());
|
|
1479
|
+
w(this, pe, new U());
|
|
1480
|
+
y(this, "state", ne());
|
|
1481
1481
|
y(this, "state$");
|
|
1482
1482
|
y(this, "options");
|
|
1483
1483
|
y(this, "observerCount$", a(this, Ee).asObservable());
|
|
1484
|
-
y(this, "cancelled$", a(this,
|
|
1484
|
+
y(this, "cancelled$", a(this, ee).asObservable());
|
|
1485
1485
|
this.options = e, this.state = r ?? this.state;
|
|
1486
|
-
const n = a(this,
|
|
1486
|
+
const n = a(this, pe).pipe(
|
|
1487
1487
|
Q(
|
|
1488
1488
|
(u) => zs({
|
|
1489
1489
|
options: {
|
|
1490
1490
|
...this.options,
|
|
1491
1491
|
onMutate: (i) => {
|
|
1492
|
-
const
|
|
1492
|
+
const l = A(
|
|
1493
1493
|
() => {
|
|
1494
|
-
var
|
|
1495
|
-
return (c = (
|
|
1496
|
-
|
|
1494
|
+
var d, c;
|
|
1495
|
+
return (c = (d = t.config).onMutate) == null ? void 0 : c.call(
|
|
1496
|
+
d,
|
|
1497
1497
|
i,
|
|
1498
1498
|
this
|
|
1499
1499
|
);
|
|
1500
1500
|
}
|
|
1501
1501
|
), h = A(() => {
|
|
1502
|
-
var
|
|
1503
|
-
return (c = (
|
|
1502
|
+
var d, c;
|
|
1503
|
+
return (c = (d = this.options).onMutate) == null ? void 0 : c.call(d, i);
|
|
1504
1504
|
});
|
|
1505
|
-
return
|
|
1506
|
-
|
|
1505
|
+
return l.pipe(
|
|
1506
|
+
q(() => h)
|
|
1507
1507
|
);
|
|
1508
1508
|
},
|
|
1509
|
-
onError: (i,
|
|
1509
|
+
onError: (i, l, f) => {
|
|
1510
1510
|
const h = A(
|
|
1511
1511
|
() => {
|
|
1512
|
-
var
|
|
1513
|
-
return (c = (
|
|
1514
|
-
f,
|
|
1515
|
-
i,
|
|
1516
|
-
o,
|
|
1512
|
+
var d, c;
|
|
1513
|
+
return (c = (d = t.config).onError) == null ? void 0 : c.call(
|
|
1517
1514
|
d,
|
|
1515
|
+
i,
|
|
1516
|
+
l,
|
|
1517
|
+
f,
|
|
1518
1518
|
this
|
|
1519
1519
|
);
|
|
1520
1520
|
}
|
|
1521
|
-
),
|
|
1521
|
+
), o = A(
|
|
1522
1522
|
() => {
|
|
1523
|
-
var
|
|
1524
|
-
return (c = (
|
|
1523
|
+
var d, c;
|
|
1524
|
+
return (c = (d = this.options).onError) == null ? void 0 : c.call(d, i, l, f);
|
|
1525
1525
|
}
|
|
1526
1526
|
);
|
|
1527
|
-
return ke(h,
|
|
1527
|
+
return ke(h, o).pipe(Te());
|
|
1528
1528
|
},
|
|
1529
|
-
onSettled: (i,
|
|
1530
|
-
const
|
|
1529
|
+
onSettled: (i, l, f, h) => {
|
|
1530
|
+
const o = A(
|
|
1531
1531
|
() => {
|
|
1532
1532
|
var c, b;
|
|
1533
1533
|
return (b = (c = t.config).onSettled) == null ? void 0 : b.call(
|
|
1534
1534
|
c,
|
|
1535
1535
|
i,
|
|
1536
|
-
|
|
1537
|
-
|
|
1536
|
+
l,
|
|
1537
|
+
f,
|
|
1538
1538
|
h,
|
|
1539
1539
|
this
|
|
1540
1540
|
);
|
|
1541
1541
|
}
|
|
1542
|
-
),
|
|
1542
|
+
), d = A(
|
|
1543
1543
|
() => {
|
|
1544
1544
|
var c, b;
|
|
1545
|
-
return (b = (c = this.options).onSettled) == null ? void 0 : b.call(c, i,
|
|
1545
|
+
return (b = (c = this.options).onSettled) == null ? void 0 : b.call(c, i, l, f, h);
|
|
1546
1546
|
}
|
|
1547
1547
|
);
|
|
1548
|
-
return ke(
|
|
1548
|
+
return ke(o, d).pipe(Te());
|
|
1549
1549
|
},
|
|
1550
|
-
onSuccess: (i,
|
|
1550
|
+
onSuccess: (i, l, f) => {
|
|
1551
1551
|
const h = A(
|
|
1552
1552
|
() => {
|
|
1553
|
-
var
|
|
1554
|
-
return (c = (
|
|
1555
|
-
f,
|
|
1556
|
-
i,
|
|
1557
|
-
o,
|
|
1553
|
+
var d, c;
|
|
1554
|
+
return (c = (d = t.config).onSuccess) == null ? void 0 : c.call(
|
|
1558
1555
|
d,
|
|
1556
|
+
i,
|
|
1557
|
+
l,
|
|
1558
|
+
f,
|
|
1559
1559
|
this
|
|
1560
1560
|
);
|
|
1561
1561
|
}
|
|
1562
|
-
),
|
|
1562
|
+
), o = A(
|
|
1563
1563
|
() => {
|
|
1564
|
-
var
|
|
1565
|
-
return (c = (
|
|
1564
|
+
var d, c;
|
|
1565
|
+
return (c = (d = this.options).onSuccess) == null ? void 0 : c.call(d, i, l, f);
|
|
1566
1566
|
}
|
|
1567
1567
|
);
|
|
1568
|
-
return ke(h,
|
|
1568
|
+
return ke(h, o).pipe(Te());
|
|
1569
1569
|
}
|
|
1570
1570
|
},
|
|
1571
1571
|
state: this.state,
|
|
1572
1572
|
variables: u
|
|
1573
|
-
}).pipe(
|
|
1573
|
+
}).pipe(Y(a(this, ee)))
|
|
1574
1574
|
)
|
|
1575
1575
|
);
|
|
1576
1576
|
this.state$ = C(
|
|
@@ -1581,18 +1581,18 @@ class Ls {
|
|
|
1581
1581
|
*/
|
|
1582
1582
|
Oe
|
|
1583
1583
|
).pipe(
|
|
1584
|
-
|
|
1584
|
+
oe(this.state),
|
|
1585
1585
|
F((u) => {
|
|
1586
1586
|
this.state = { ...this.state, ...u };
|
|
1587
1587
|
}),
|
|
1588
|
-
|
|
1588
|
+
Y(a(this, ee)),
|
|
1589
1589
|
/**
|
|
1590
1590
|
* refCount as true somewhat make NEVER complete when there are
|
|
1591
1591
|
* no more observers. I thought I should have to complete manually (which is
|
|
1592
1592
|
* why we still cancel the observable when we remove it from cache)
|
|
1593
1593
|
*/
|
|
1594
1594
|
Ue({ bufferSize: 1, refCount: !1 }),
|
|
1595
|
-
|
|
1595
|
+
nt((u) => {
|
|
1596
1596
|
a(this, Ee).next(u);
|
|
1597
1597
|
})
|
|
1598
1598
|
);
|
|
@@ -1609,60 +1609,60 @@ class Ls {
|
|
|
1609
1609
|
* is over, unlike the state which can be re-subscribed later.
|
|
1610
1610
|
*/
|
|
1611
1611
|
execute(e) {
|
|
1612
|
-
return a(this,
|
|
1612
|
+
return a(this, pe).next(e), a(this, pe).complete(), this.state$.pipe($e);
|
|
1613
1613
|
}
|
|
1614
1614
|
continue() {
|
|
1615
1615
|
return this.execute(this.state.variables);
|
|
1616
1616
|
}
|
|
1617
1617
|
// @todo merge with query
|
|
1618
1618
|
cancel() {
|
|
1619
|
-
a(this,
|
|
1619
|
+
a(this, ee).next(), a(this, ee).complete();
|
|
1620
1620
|
}
|
|
1621
1621
|
}
|
|
1622
|
-
Ee = new WeakMap(),
|
|
1623
|
-
const
|
|
1622
|
+
Ee = new WeakMap(), ee = new WeakMap(), pe = new WeakMap();
|
|
1623
|
+
const $t = ({
|
|
1624
1624
|
mutationKey: s,
|
|
1625
1625
|
status: e,
|
|
1626
1626
|
predicate: t,
|
|
1627
1627
|
exact: r = !0
|
|
1628
1628
|
} = {}) => (u) => r && s !== void 0 && u.options.mutationKey !== void 0 && !qe(u.options.mutationKey, s, { exact: r }) || !r && s !== void 0 && u.options.mutationKey !== void 0 && !qe(u.options.mutationKey, s, { exact: r }) || e && u.state.status !== e ? !1 : t ? t(u) : !0;
|
|
1629
|
-
class
|
|
1629
|
+
class Tt {
|
|
1630
1630
|
constructor() {
|
|
1631
1631
|
/**
|
|
1632
1632
|
* @important
|
|
1633
1633
|
* Query store. Could be turned into a map for more performance.
|
|
1634
1634
|
*/
|
|
1635
1635
|
y(this, "entriesSubject", new G([]));
|
|
1636
|
-
y(this, "changeSubject", new
|
|
1637
|
-
y(this, "entries$", this.entriesSubject.pipe(
|
|
1636
|
+
y(this, "changeSubject", new U());
|
|
1637
|
+
y(this, "entries$", this.entriesSubject.pipe(fe()));
|
|
1638
1638
|
y(this, "added$", this.changeSubject.pipe(
|
|
1639
|
-
|
|
1639
|
+
$(({ type: e }) => e === "added"),
|
|
1640
1640
|
g(({ entity: e }) => e),
|
|
1641
|
-
|
|
1641
|
+
fe()
|
|
1642
1642
|
));
|
|
1643
1643
|
y(this, "removed$", this.changeSubject.pipe(
|
|
1644
|
-
|
|
1644
|
+
$(({ type: e }) => e === "removed"),
|
|
1645
1645
|
g(({ entity: e }) => e),
|
|
1646
|
-
|
|
1646
|
+
fe()
|
|
1647
1647
|
));
|
|
1648
1648
|
y(this, "stateChange$", C(
|
|
1649
1649
|
this.entriesSubject.pipe(
|
|
1650
|
-
|
|
1651
|
-
|
|
1650
|
+
st(),
|
|
1651
|
+
q((e) => ve(e))
|
|
1652
1652
|
),
|
|
1653
1653
|
this.added$
|
|
1654
1654
|
).pipe(
|
|
1655
|
-
|
|
1655
|
+
q(
|
|
1656
1656
|
(e) => e.state$.pipe(
|
|
1657
1657
|
g(() => e),
|
|
1658
|
-
|
|
1658
|
+
Y(
|
|
1659
1659
|
this.removed$.pipe(
|
|
1660
|
-
|
|
1660
|
+
$((t) => t === e)
|
|
1661
1661
|
)
|
|
1662
1662
|
)
|
|
1663
1663
|
)
|
|
1664
1664
|
),
|
|
1665
|
-
|
|
1665
|
+
fe()
|
|
1666
1666
|
));
|
|
1667
1667
|
}
|
|
1668
1668
|
getValues() {
|
|
@@ -1683,7 +1683,7 @@ class kt {
|
|
|
1683
1683
|
var N;
|
|
1684
1684
|
class _s {
|
|
1685
1685
|
constructor(e = {}) {
|
|
1686
|
-
|
|
1686
|
+
w(this, N, new Tt());
|
|
1687
1687
|
this.config = e;
|
|
1688
1688
|
}
|
|
1689
1689
|
build(e, t, r) {
|
|
@@ -1697,10 +1697,10 @@ class _s {
|
|
|
1697
1697
|
* Once a mutation is finished and there are no more observers than us
|
|
1698
1698
|
* we start the process of cleaning it up based on gc settings
|
|
1699
1699
|
*/
|
|
1700
|
-
|
|
1700
|
+
$(({ status: u }) => u === "success" || u === "error"),
|
|
1701
1701
|
Q(
|
|
1702
1702
|
() => n.observerCount$.pipe(
|
|
1703
|
-
|
|
1703
|
+
$((u) => u <= 1),
|
|
1704
1704
|
He(1)
|
|
1705
1705
|
)
|
|
1706
1706
|
),
|
|
@@ -1721,15 +1721,15 @@ class _s {
|
|
|
1721
1721
|
t == null || t.cancel(), a(this, N).remove(e);
|
|
1722
1722
|
}
|
|
1723
1723
|
find(e) {
|
|
1724
|
-
const t = { exact: !0, ...e }, r =
|
|
1724
|
+
const t = { exact: !0, ...e }, r = $t(t);
|
|
1725
1725
|
return a(this, N).getValues().find((n) => r(n));
|
|
1726
1726
|
}
|
|
1727
1727
|
findAll(e = {}) {
|
|
1728
|
-
const t = { exact: !0, ...e }, r =
|
|
1728
|
+
const t = { exact: !0, ...e }, r = $t(t);
|
|
1729
1729
|
return a(this, N).getValues().filter((n) => r(n)).map((n) => n);
|
|
1730
1730
|
}
|
|
1731
1731
|
observe() {
|
|
1732
|
-
return a(this, N).stateChange$.pipe(
|
|
1732
|
+
return a(this, N).stateChange$.pipe(oe());
|
|
1733
1733
|
}
|
|
1734
1734
|
/**
|
|
1735
1735
|
* @important
|
|
@@ -1775,9 +1775,9 @@ class _s {
|
|
|
1775
1775
|
predicate: (r) => r.state.isPaused
|
|
1776
1776
|
});
|
|
1777
1777
|
if (!e.length)
|
|
1778
|
-
return
|
|
1778
|
+
return be;
|
|
1779
1779
|
const t = e.map((r) => r.continue());
|
|
1780
|
-
return
|
|
1780
|
+
return rs(t);
|
|
1781
1781
|
}
|
|
1782
1782
|
clear() {
|
|
1783
1783
|
this.getAll().forEach((e) => {
|
|
@@ -1804,75 +1804,93 @@ function Gs(s) {
|
|
|
1804
1804
|
fetchStatus: "idle"
|
|
1805
1805
|
};
|
|
1806
1806
|
}
|
|
1807
|
-
const Js = (s) => Qe(() => Le.isFocused() ? s : Le.focusRegained$.pipe(
|
|
1807
|
+
const Js = (s) => Qe(() => Le.isFocused() ? s : Le.focusRegained$.pipe(q(() => s))), Ys = (s) => {
|
|
1808
1808
|
let e = 0;
|
|
1809
1809
|
return (t) => {
|
|
1810
|
-
const r =
|
|
1811
|
-
|
|
1810
|
+
const r = se.backToOnline$.pipe(
|
|
1811
|
+
q(
|
|
1812
1812
|
() => C(
|
|
1813
1813
|
v({ fetchStatus: "fetching" }),
|
|
1814
1814
|
t
|
|
1815
1815
|
)
|
|
1816
1816
|
)
|
|
1817
1817
|
);
|
|
1818
|
-
return Qe(() => (e++, !
|
|
1818
|
+
return Qe(() => (e++, !se.isOnline() && s.networkMode === "offlineFirst" && e > 1 ? C(
|
|
1819
1819
|
v({ fetchStatus: "paused" }),
|
|
1820
1820
|
r
|
|
1821
|
-
) : !
|
|
1821
|
+
) : !se.isOnline() && s.networkMode !== "always" && s.networkMode !== "offlineFirst" ? C(
|
|
1822
1822
|
v({ fetchStatus: "paused" }),
|
|
1823
1823
|
r
|
|
1824
1824
|
) : t));
|
|
1825
1825
|
};
|
|
1826
|
-
}, Bs = (s) => {
|
|
1826
|
+
}, Bs = (s) => (e) => {
|
|
1827
|
+
const t = new U(), r = t.pipe(
|
|
1828
|
+
st(),
|
|
1829
|
+
/**
|
|
1830
|
+
* Since we set hasDataSubject synchronously, we need to wait
|
|
1831
|
+
* for the next tick to make sure observable chain received this data at least
|
|
1832
|
+
*/
|
|
1833
|
+
xt(1),
|
|
1834
|
+
q(() => s.pipe($((n) => n === 0)))
|
|
1835
|
+
);
|
|
1836
|
+
return e.pipe(
|
|
1837
|
+
F(() => {
|
|
1838
|
+
t.next();
|
|
1839
|
+
}),
|
|
1840
|
+
Y(r)
|
|
1841
|
+
);
|
|
1842
|
+
}, Xs = (s) => {
|
|
1827
1843
|
const e = async () => await Promise.reject(new Error("No query found"));
|
|
1828
1844
|
let t = !1;
|
|
1829
1845
|
const r = s.queryFn ?? e, n = new AbortController(), u = {
|
|
1830
1846
|
meta: s.meta,
|
|
1831
1847
|
queryKey: s.queryKey
|
|
1832
1848
|
};
|
|
1833
|
-
((
|
|
1834
|
-
Object.defineProperty(
|
|
1849
|
+
((o) => {
|
|
1850
|
+
Object.defineProperty(o, "signal", {
|
|
1835
1851
|
enumerable: !0,
|
|
1836
1852
|
get: () => (s.onSignalConsumed(), n.signal)
|
|
1837
1853
|
});
|
|
1838
1854
|
})(u);
|
|
1839
|
-
const
|
|
1855
|
+
const f = (typeof r == "function" ? (
|
|
1840
1856
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
1841
1857
|
A(
|
|
1842
1858
|
() => r(u)
|
|
1843
1859
|
)
|
|
1844
1860
|
) : r).pipe(
|
|
1861
|
+
Bs(s.observers$),
|
|
1845
1862
|
F({
|
|
1846
1863
|
complete: () => {
|
|
1847
|
-
t = !0;
|
|
1864
|
+
console.log("Query.execution$.complete"), t = !0;
|
|
1848
1865
|
}
|
|
1849
1866
|
}),
|
|
1850
1867
|
g(
|
|
1851
|
-
(
|
|
1852
|
-
data:
|
|
1868
|
+
(o) => ({
|
|
1869
|
+
data: o
|
|
1853
1870
|
})
|
|
1854
1871
|
),
|
|
1872
|
+
// takeUntil(hasDataAndNoObservers$),
|
|
1855
1873
|
Ys(s),
|
|
1856
|
-
|
|
1874
|
+
Qt({
|
|
1857
1875
|
...s,
|
|
1858
1876
|
retryAfter: () => v(!0).pipe(Js),
|
|
1859
|
-
catchError: (
|
|
1877
|
+
catchError: (o, d) => v({
|
|
1860
1878
|
status: "error",
|
|
1861
1879
|
fetchStatus: "idle",
|
|
1862
|
-
fetchFailureCount:
|
|
1863
|
-
fetchFailureReason:
|
|
1864
|
-
error:
|
|
1880
|
+
fetchFailureCount: o,
|
|
1881
|
+
fetchFailureReason: d,
|
|
1882
|
+
error: d
|
|
1865
1883
|
}),
|
|
1866
|
-
caughtError: (
|
|
1884
|
+
caughtError: (o, d) => (
|
|
1867
1885
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
1868
1886
|
v({
|
|
1869
|
-
fetchFailureCount:
|
|
1870
|
-
fetchFailureReason:
|
|
1887
|
+
fetchFailureCount: o,
|
|
1888
|
+
fetchFailureReason: d
|
|
1871
1889
|
})
|
|
1872
1890
|
)
|
|
1873
1891
|
}),
|
|
1874
|
-
|
|
1875
|
-
...
|
|
1892
|
+
q((o) => "data" in o ? v({
|
|
1893
|
+
...o,
|
|
1876
1894
|
status: "success",
|
|
1877
1895
|
fetchStatus: "idle",
|
|
1878
1896
|
fetchFailureCount: 0,
|
|
@@ -1894,33 +1912,40 @@ const Js = (s) => Qe(() => Le.isFocused() ? s : Le.focusRegained$.pipe(_(() => s
|
|
|
1894
1912
|
*
|
|
1895
1913
|
* There is in theory no problem associated to that.
|
|
1896
1914
|
*/
|
|
1897
|
-
|
|
1915
|
+
xt(1),
|
|
1898
1916
|
g(
|
|
1899
|
-
(
|
|
1917
|
+
(d) => t ? d : { ...d, fetchStatus: "fetching" }
|
|
1900
1918
|
)
|
|
1901
|
-
) : v(
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1919
|
+
) : v(o)),
|
|
1920
|
+
/**
|
|
1921
|
+
* When the fn complete we can release the fetch status, if it was already released
|
|
1922
|
+
* before shallow compare will not update the state, otherwise it's our chance to catch
|
|
1923
|
+
* the end of observable fn.
|
|
1924
|
+
*/
|
|
1925
|
+
ns({ fetchStatus: "idle" }),
|
|
1926
|
+
fe()
|
|
1927
|
+
), h = v({
|
|
1907
1928
|
status: "pending",
|
|
1908
|
-
fetchStatus:
|
|
1929
|
+
fetchStatus: se.isOnline() ? "fetching" : "paused"
|
|
1909
1930
|
});
|
|
1910
1931
|
return {
|
|
1911
|
-
state$: C(
|
|
1932
|
+
state$: C(
|
|
1933
|
+
h,
|
|
1934
|
+
f
|
|
1935
|
+
// emitOnComplete$
|
|
1936
|
+
).pipe(fe()),
|
|
1912
1937
|
abortController: n
|
|
1913
1938
|
};
|
|
1914
1939
|
};
|
|
1915
|
-
class
|
|
1940
|
+
class Zs {
|
|
1916
1941
|
constructor(e) {
|
|
1917
1942
|
y(this, "revert");
|
|
1918
1943
|
y(this, "silent");
|
|
1919
1944
|
this.revert = e == null ? void 0 : e.revert, this.silent = e == null ? void 0 : e.silent;
|
|
1920
1945
|
}
|
|
1921
1946
|
}
|
|
1922
|
-
const
|
|
1923
|
-
function
|
|
1947
|
+
const er = { backgroundColor: "transparent", color: "inherit" };
|
|
1948
|
+
function Kt(s) {
|
|
1924
1949
|
const e = {
|
|
1925
1950
|
namespaces: [
|
|
1926
1951
|
{
|
|
@@ -1929,10 +1954,10 @@ function Tt(s) {
|
|
|
1929
1954
|
}
|
|
1930
1955
|
],
|
|
1931
1956
|
namespace(t, r) {
|
|
1932
|
-
const n =
|
|
1957
|
+
const n = Kt(s);
|
|
1933
1958
|
return n.namespaces.push({
|
|
1934
1959
|
name: t,
|
|
1935
|
-
style: r ??
|
|
1960
|
+
style: r ?? er
|
|
1936
1961
|
}), n;
|
|
1937
1962
|
},
|
|
1938
1963
|
printNamespaces() {
|
|
@@ -1971,35 +1996,35 @@ function Tt(s) {
|
|
|
1971
1996
|
};
|
|
1972
1997
|
return e;
|
|
1973
1998
|
}
|
|
1974
|
-
const
|
|
1975
|
-
var Fe,
|
|
1976
|
-
class
|
|
1999
|
+
const tr = Kt("production");
|
|
2000
|
+
var Fe, ae;
|
|
2001
|
+
class sr {
|
|
1977
2002
|
constructor(e) {
|
|
1978
2003
|
y(this, "queryKey");
|
|
1979
2004
|
y(this, "queryHash");
|
|
1980
2005
|
y(this, "gcTime");
|
|
1981
2006
|
y(this, "options");
|
|
1982
|
-
|
|
1983
|
-
|
|
2007
|
+
w(this, Fe, void 0);
|
|
2008
|
+
w(this, ae, void 0);
|
|
1984
2009
|
y(this, "state");
|
|
1985
2010
|
// @todo to share with mutation
|
|
1986
|
-
y(this, "executeSubject", new
|
|
1987
|
-
y(this, "cancelSubject", new
|
|
1988
|
-
y(this, "setDataSubject", new
|
|
1989
|
-
y(this, "invalidatedSubject", new
|
|
1990
|
-
y(this, "resetSubject", new
|
|
1991
|
-
y(this, "destroySubject", new
|
|
2011
|
+
y(this, "executeSubject", new U());
|
|
2012
|
+
y(this, "cancelSubject", new U());
|
|
2013
|
+
y(this, "setDataSubject", new U());
|
|
2014
|
+
y(this, "invalidatedSubject", new U());
|
|
2015
|
+
y(this, "resetSubject", new U());
|
|
2016
|
+
y(this, "destroySubject", new U());
|
|
1992
2017
|
y(this, "observersSubject", new G([]));
|
|
1993
2018
|
y(this, "abortSignalConsumed", !1);
|
|
1994
2019
|
y(this, "observerCount$", this.observersSubject.asObservable().pipe(g((e) => e.length)));
|
|
1995
2020
|
y(this, "observers$", this.observersSubject.asObservable());
|
|
1996
2021
|
y(this, "state$");
|
|
1997
|
-
M(this, Fe, e.defaultOptions), this.options = this.setOptions(e.options), this.queryKey = e.queryKey, this.queryHash = e.queryHash, M(this,
|
|
2022
|
+
M(this, Fe, e.defaultOptions), this.options = this.setOptions(e.options), this.queryKey = e.queryKey, this.queryHash = e.queryHash, M(this, ae, e.state ?? Gs(this.options)), this.state = a(this, ae), this.gcTime = this.updateGcTime(this.options.gcTime), this.state$ = C(
|
|
1998
2023
|
this.resetSubject.pipe(
|
|
1999
|
-
g(() => ({ command: "reset", state: a(this,
|
|
2024
|
+
g(() => ({ command: "reset", state: a(this, ae) }))
|
|
2000
2025
|
),
|
|
2001
2026
|
this.invalidatedSubject.pipe(
|
|
2002
|
-
|
|
2027
|
+
$(() => !this.state.isInvalidated),
|
|
2003
2028
|
g(() => ({
|
|
2004
2029
|
command: "invalidate",
|
|
2005
2030
|
state: {
|
|
@@ -2008,50 +2033,51 @@ class tr {
|
|
|
2008
2033
|
}))
|
|
2009
2034
|
),
|
|
2010
2035
|
this.cancelSubject.pipe(
|
|
2011
|
-
|
|
2036
|
+
$(() => !(this.state.error && this.state.status === "error")),
|
|
2012
2037
|
g((t) => ({
|
|
2013
2038
|
command: "cancel",
|
|
2014
2039
|
state: {
|
|
2015
2040
|
status: t != null && t.revert ? this.state.status : "error",
|
|
2016
2041
|
fetchStatus: "idle",
|
|
2017
|
-
error: new
|
|
2042
|
+
error: new Zs(t)
|
|
2018
2043
|
}
|
|
2019
2044
|
}))
|
|
2020
2045
|
),
|
|
2021
2046
|
this.executeSubject.pipe(
|
|
2022
|
-
|
|
2047
|
+
q(() => {
|
|
2023
2048
|
let t = !1;
|
|
2024
2049
|
const r = this.executeSubject.pipe(
|
|
2025
2050
|
// should not be needed since the fetch return current promise
|
|
2026
2051
|
// in case we don't cancel
|
|
2027
|
-
|
|
2052
|
+
$((h) => (h == null ? void 0 : h.cancelRefetch) !== !1)
|
|
2028
2053
|
), n = this.observers$.pipe(
|
|
2029
2054
|
Ft(),
|
|
2030
|
-
F(([h,
|
|
2031
|
-
|
|
2055
|
+
F(([h, o]) => {
|
|
2056
|
+
o.length === 0 && h.length > 0 ? t = !0 : t = !1;
|
|
2032
2057
|
}),
|
|
2033
|
-
|
|
2034
|
-
), { state$: u, abortController: i } =
|
|
2058
|
+
he()
|
|
2059
|
+
), { state$: u, abortController: i } = Xs({
|
|
2035
2060
|
...this.options,
|
|
2061
|
+
observers$: this.observerCount$,
|
|
2036
2062
|
queryKey: this.queryKey,
|
|
2037
|
-
retry: (h,
|
|
2038
|
-
const
|
|
2039
|
-
return typeof
|
|
2063
|
+
retry: (h, o) => {
|
|
2064
|
+
const d = this.options.retry ?? !0;
|
|
2065
|
+
return typeof d == "function" ? d(h, o) : typeof d == "boolean" ? d : h < d;
|
|
2040
2066
|
},
|
|
2041
2067
|
retryAfterDelay: () => !t,
|
|
2042
2068
|
onSignalConsumed: () => {
|
|
2043
2069
|
this.abortSignalConsumed = !0;
|
|
2044
2070
|
}
|
|
2045
|
-
}),
|
|
2046
|
-
|
|
2071
|
+
}), l = this.observerCount$.pipe(
|
|
2072
|
+
$((h) => h === 0 && this.abortSignalConsumed),
|
|
2047
2073
|
F(() => {
|
|
2048
2074
|
this.cancelSubject.next({ revert: !0 });
|
|
2049
2075
|
})
|
|
2050
|
-
),
|
|
2076
|
+
), f = C(
|
|
2051
2077
|
this.cancelSubject,
|
|
2052
2078
|
r,
|
|
2053
2079
|
this.resetSubject,
|
|
2054
|
-
|
|
2080
|
+
l
|
|
2055
2081
|
).pipe(
|
|
2056
2082
|
F(() => {
|
|
2057
2083
|
this.abortSignalConsumed && i.abort();
|
|
@@ -2062,7 +2088,7 @@ class tr {
|
|
|
2062
2088
|
command: "execute",
|
|
2063
2089
|
state: h
|
|
2064
2090
|
})),
|
|
2065
|
-
|
|
2091
|
+
Y(f)
|
|
2066
2092
|
);
|
|
2067
2093
|
})
|
|
2068
2094
|
),
|
|
@@ -2082,16 +2108,16 @@ class tr {
|
|
|
2082
2108
|
getOptions: () => this.options,
|
|
2083
2109
|
getState: () => this.state
|
|
2084
2110
|
}),
|
|
2085
|
-
|
|
2111
|
+
oe(a(this, ae)),
|
|
2086
2112
|
P(D),
|
|
2087
2113
|
F((t) => {
|
|
2088
2114
|
this.state = t;
|
|
2089
2115
|
}),
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
})
|
|
2116
|
+
te((t) => {
|
|
2117
|
+
throw tr.error(t), t;
|
|
2118
|
+
}),
|
|
2119
|
+
Y(this.destroySubject),
|
|
2120
|
+
Ue({ bufferSize: 1, refCount: !1 })
|
|
2095
2121
|
);
|
|
2096
2122
|
}
|
|
2097
2123
|
setOptions(e) {
|
|
@@ -2104,21 +2130,21 @@ class tr {
|
|
|
2104
2130
|
return this.state$.pipe(
|
|
2105
2131
|
g(({ data: e, status: t }) => ({ data: e, status: t })),
|
|
2106
2132
|
P(D),
|
|
2107
|
-
|
|
2133
|
+
$(({ status: e }) => e === "success")
|
|
2108
2134
|
);
|
|
2109
2135
|
}
|
|
2110
2136
|
get error$() {
|
|
2111
2137
|
return this.state$.pipe(
|
|
2112
2138
|
g(({ error: e, status: t }) => ({ error: e, status: t })),
|
|
2113
2139
|
P(D),
|
|
2114
|
-
|
|
2140
|
+
$(({ status: e }) => e === "error")
|
|
2115
2141
|
);
|
|
2116
2142
|
}
|
|
2117
2143
|
get settled$() {
|
|
2118
2144
|
return this.state$.pipe(
|
|
2119
2145
|
g(({ status: e }) => ({ status: e })),
|
|
2120
2146
|
P(D),
|
|
2121
|
-
|
|
2147
|
+
$(({ status: e }) => e === "success" || e === "error")
|
|
2122
2148
|
);
|
|
2123
2149
|
}
|
|
2124
2150
|
observe(e) {
|
|
@@ -2162,7 +2188,7 @@ class tr {
|
|
|
2162
2188
|
}
|
|
2163
2189
|
async getFetchResultAsPromise() {
|
|
2164
2190
|
return await new Promise((e, t) => {
|
|
2165
|
-
this.state$.pipe(
|
|
2191
|
+
this.state$.pipe(Vt, Ke()).subscribe({
|
|
2166
2192
|
error: t,
|
|
2167
2193
|
next: (r) => {
|
|
2168
2194
|
r.error ? t(r.error) : e(r.data);
|
|
@@ -2193,14 +2219,14 @@ class tr {
|
|
|
2193
2219
|
this.resetSubject.next();
|
|
2194
2220
|
}
|
|
2195
2221
|
}
|
|
2196
|
-
Fe = new WeakMap(),
|
|
2222
|
+
Fe = new WeakMap(), ae = new WeakMap();
|
|
2197
2223
|
var xe, W;
|
|
2198
|
-
class
|
|
2224
|
+
class rr {
|
|
2199
2225
|
// protected mountSubscriptions: Subscription[]
|
|
2200
2226
|
constructor(e = {}) {
|
|
2201
2227
|
// readonly #queries: QueryStore = new Map<string, Query>()
|
|
2202
|
-
|
|
2203
|
-
|
|
2228
|
+
w(this, xe, new U());
|
|
2229
|
+
w(this, W, new Tt());
|
|
2204
2230
|
this.config = e;
|
|
2205
2231
|
}
|
|
2206
2232
|
mount() {
|
|
@@ -2213,7 +2239,7 @@ class sr {
|
|
|
2213
2239
|
observeIsFetching(e) {
|
|
2214
2240
|
return a(this, W).stateChange$.pipe(
|
|
2215
2241
|
// we force a first result
|
|
2216
|
-
|
|
2242
|
+
oe(),
|
|
2217
2243
|
g(() => this.findAll({
|
|
2218
2244
|
...e,
|
|
2219
2245
|
fetchStatus: "fetching"
|
|
@@ -2226,12 +2252,12 @@ class sr {
|
|
|
2226
2252
|
}
|
|
2227
2253
|
findAll(e = {}) {
|
|
2228
2254
|
const t = this.getAll();
|
|
2229
|
-
return Object.keys(e).length > 0 ? t.filter((r) =>
|
|
2255
|
+
return Object.keys(e).length > 0 ? t.filter((r) => Ot(e, r)) : t;
|
|
2230
2256
|
}
|
|
2231
2257
|
build(e, t, r) {
|
|
2232
|
-
const n = t.queryKey ?? [
|
|
2258
|
+
const n = t.queryKey ?? [rt()], u = t.queryHash ?? ut(n, t);
|
|
2233
2259
|
let i = this.get(u);
|
|
2234
|
-
return i || (i = new
|
|
2260
|
+
return i || (i = new sr({
|
|
2235
2261
|
cache: this,
|
|
2236
2262
|
queryKey: n,
|
|
2237
2263
|
queryHash: u,
|
|
@@ -2244,7 +2270,7 @@ class sr {
|
|
|
2244
2270
|
if (!a(this, W).find((t) => t.queryHash === e.queryHash)) {
|
|
2245
2271
|
a(this, W).add(e);
|
|
2246
2272
|
const t = e.observerCount$.pipe(
|
|
2247
|
-
|
|
2273
|
+
$((r) => r < 1),
|
|
2248
2274
|
He(1)
|
|
2249
2275
|
);
|
|
2250
2276
|
e.success$.subscribe(() => {
|
|
@@ -2285,7 +2311,7 @@ class sr {
|
|
|
2285
2311
|
find(e) {
|
|
2286
2312
|
const t = { exact: !0, ...e };
|
|
2287
2313
|
return this.getAll().find(
|
|
2288
|
-
(r) =>
|
|
2314
|
+
(r) => Ot(t, r)
|
|
2289
2315
|
);
|
|
2290
2316
|
}
|
|
2291
2317
|
subscribe(e) {
|
|
@@ -2327,27 +2353,27 @@ class sr {
|
|
|
2327
2353
|
}
|
|
2328
2354
|
}
|
|
2329
2355
|
xe = new WeakMap(), W = new WeakMap();
|
|
2330
|
-
var
|
|
2331
|
-
class
|
|
2356
|
+
var ce, j, Re, Me, je;
|
|
2357
|
+
class Or {
|
|
2332
2358
|
// #destroy = () => {}
|
|
2333
2359
|
constructor({
|
|
2334
2360
|
mutationCache: e,
|
|
2335
2361
|
queryCache: t,
|
|
2336
2362
|
defaultOptions: r
|
|
2337
2363
|
} = {}) {
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
M(this,
|
|
2364
|
+
w(this, ce, void 0);
|
|
2365
|
+
w(this, j, void 0);
|
|
2366
|
+
w(this, Re, /* @__PURE__ */ new Map());
|
|
2367
|
+
w(this, Me, /* @__PURE__ */ new Map());
|
|
2368
|
+
w(this, je, void 0);
|
|
2369
|
+
M(this, ce, e ?? new _s()), M(this, j, t ?? new rr()), M(this, je, r ?? {});
|
|
2344
2370
|
}
|
|
2345
2371
|
mount() {
|
|
2346
2372
|
}
|
|
2347
2373
|
unmount() {
|
|
2348
2374
|
}
|
|
2349
2375
|
getMutationCache() {
|
|
2350
|
-
return a(this,
|
|
2376
|
+
return a(this, ce);
|
|
2351
2377
|
}
|
|
2352
2378
|
getQueryCache() {
|
|
2353
2379
|
return a(this, j);
|
|
@@ -2367,7 +2393,7 @@ class vr {
|
|
|
2367
2393
|
...e,
|
|
2368
2394
|
_defaulted: !0
|
|
2369
2395
|
};
|
|
2370
|
-
return t.queryHash || (t.queryHash =
|
|
2396
|
+
return t.queryHash || (t.queryHash = ut(
|
|
2371
2397
|
t.queryKey,
|
|
2372
2398
|
t
|
|
2373
2399
|
)), 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;
|
|
@@ -2409,8 +2435,8 @@ class vr {
|
|
|
2409
2435
|
const n = a(this, j).find({ queryKey: e }), u = n == null ? void 0 : n.state.data, i = js(t, u);
|
|
2410
2436
|
if (typeof i > "u")
|
|
2411
2437
|
return;
|
|
2412
|
-
const
|
|
2413
|
-
return a(this, j).build(this,
|
|
2438
|
+
const l = this.defaultQueryOptions({ queryKey: e });
|
|
2439
|
+
return a(this, j).build(this, l).setData(i, { ...r, manual: !0 });
|
|
2414
2440
|
}
|
|
2415
2441
|
getMutationDefaults(e) {
|
|
2416
2442
|
const t = [...a(this, Re).values()];
|
|
@@ -2424,13 +2450,13 @@ class vr {
|
|
|
2424
2450
|
return (t = a(this, j).find({ queryKey: e })) == null ? void 0 : t.state;
|
|
2425
2451
|
}
|
|
2426
2452
|
setMutationDefaults(e, t) {
|
|
2427
|
-
a(this, Re).set(
|
|
2453
|
+
a(this, Re).set(ge(e), {
|
|
2428
2454
|
mutationKey: e,
|
|
2429
2455
|
defaultOptions: t
|
|
2430
2456
|
});
|
|
2431
2457
|
}
|
|
2432
2458
|
setQueryDefaults(e, t) {
|
|
2433
|
-
a(this, Me).set(
|
|
2459
|
+
a(this, Me).set(ge(e), {
|
|
2434
2460
|
queryKey: e,
|
|
2435
2461
|
defaultOptions: t
|
|
2436
2462
|
});
|
|
@@ -2468,40 +2494,40 @@ class vr {
|
|
|
2468
2494
|
await this.refetchQueries(r, t);
|
|
2469
2495
|
}
|
|
2470
2496
|
async resumePausedMutations() {
|
|
2471
|
-
return await is(a(this,
|
|
2497
|
+
return await is(a(this, ce).resumePausedMutations());
|
|
2472
2498
|
}
|
|
2473
2499
|
isFetching(e) {
|
|
2474
2500
|
return a(this, j).findAll({ ...e, fetchStatus: "fetching" }).length;
|
|
2475
2501
|
}
|
|
2476
2502
|
clear() {
|
|
2477
|
-
a(this, j).clear(), a(this,
|
|
2503
|
+
a(this, j).clear(), a(this, ce).clear();
|
|
2478
2504
|
}
|
|
2479
2505
|
}
|
|
2480
|
-
|
|
2506
|
+
ce = new WeakMap(), j = new WeakMap(), Re = new WeakMap(), Me = new WeakMap(), je = new WeakMap();
|
|
2481
2507
|
export {
|
|
2482
2508
|
_s as MutationCache,
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2509
|
+
rr as QueryCache,
|
|
2510
|
+
Or as QueryClient,
|
|
2511
|
+
gr as QueryClientProvider,
|
|
2486
2512
|
ds as SIGNAL_RESET,
|
|
2487
|
-
|
|
2488
|
-
|
|
2513
|
+
pr as createLocalforageAdapter,
|
|
2514
|
+
dr as createSharedStoreAdapter,
|
|
2489
2515
|
Ss as exponentialBackoffDelay,
|
|
2490
2516
|
ms as getDelay,
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2517
|
+
yt as isDefined,
|
|
2518
|
+
Qt as retryBackoff,
|
|
2519
|
+
hr as signal,
|
|
2494
2520
|
fs as useBehaviorSubject,
|
|
2495
2521
|
k as useLiveRef,
|
|
2496
|
-
|
|
2497
|
-
|
|
2522
|
+
mr as useMutation,
|
|
2523
|
+
lr as useObservableState,
|
|
2498
2524
|
Je as useObserve,
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2525
|
+
or as useObserveCallback,
|
|
2526
|
+
yr as usePersistSignals,
|
|
2527
|
+
Sr as useQuery,
|
|
2528
|
+
fr as useSignalValue,
|
|
2529
|
+
jt as useSubject,
|
|
2530
|
+
Mt as useSubscribe,
|
|
2531
|
+
vr as useSubscribeEffect,
|
|
2532
|
+
br as useUnmountObservable
|
|
2507
2533
|
};
|