reactjrx 1.65.0 → 1.67.4
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 -2396
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1584 -2042
- package/dist/lib/queries/client/cache/registerResultInCache.d.ts +1 -1
- package/dist/lib/queries/client/createClient.d.ts +11 -9
- package/dist/lib/queries/client/fetch/notifyQueryResult.d.ts +1 -1
- package/dist/lib/queries/client/fetch/queryFetch.d.ts +2 -2
- package/dist/lib/queries/client/mutations/cache/MutationCache.d.ts +19 -27
- package/dist/lib/queries/client/mutations/cache/types.d.ts +8 -1
- package/dist/lib/queries/client/mutations/defaultMutationState.d.ts +1 -1
- package/dist/lib/queries/client/mutations/filters.d.ts +1 -1
- package/dist/lib/queries/client/mutations/mutation/Mutation.d.ts +36 -0
- package/dist/lib/queries/client/mutations/mutation/executeMutation.d.ts +6 -0
- package/dist/lib/queries/client/mutations/mutation/types.d.ts +51 -0
- package/dist/lib/queries/client/mutations/mutations.test.d.ts +1 -0
- package/dist/lib/queries/client/mutations/observers/MutationObserver.d.ts +27 -11
- package/dist/lib/queries/client/mutations/observers/mutationObserver.rq.test.d.ts +1 -0
- package/dist/lib/queries/client/mutations/observers/types.d.ts +7 -1
- package/dist/lib/queries/client/mutations/runner/MutationRunner.d.ts +17 -0
- package/dist/lib/queries/client/mutations/runner/mutationRunner.test.d.ts +1 -0
- package/dist/lib/queries/client/mutations/types.d.ts +4 -45
- package/dist/lib/queries/client/operators.d.ts +6 -2
- package/dist/lib/queries/client/refetch/client.d.ts +1 -1
- package/dist/lib/queries/client/store/createQueryStore.d.ts +1 -1
- package/dist/lib/queries/client/store/updateStoreWithNewQuery.d.ts +1 -1
- package/dist/lib/queries/client/tests/utils.d.ts +2 -2
- package/dist/lib/queries/client/triggers.d.ts +1 -1
- package/dist/lib/queries/client/types.d.ts +2 -1
- package/dist/lib/queries/react/mutations/types.d.ts +18 -0
- package/dist/lib/queries/react/mutations/useMutation.d.ts +2 -19
- package/dist/lib/queries/react/mutations/useMutation.rq.test.d.ts +1 -0
- package/dist/lib/queries/react/mutations/useMutationState.d.ts +3 -2
- package/dist/lib/queries/react/queries/helpers.d.ts +1 -0
- package/dist/lib/utils/{retryBackoff.d.ts → operators/retryBackoff.d.ts} +5 -3
- package/dist/lib/utils/operators/trackSubscriptions.d.ts +2 -0
- package/package.json +2 -1
- package/dist/lib/queries/client/mutations/Mutation.d.ts +0 -27
- package/dist/lib/queries/client/mutations/operators.d.ts +0 -3
- package/dist/lib/queries/client/mutations/runners/MutationRunner.d.ts +0 -19
- package/dist/lib/queries/client/mutations/runners/MutationRunners.d.ts +0 -54
- package/dist/lib/utils/trackSubscriptions.d.ts +0 -2
- /package/dist/lib/queries/{react/mutations/useMutation.cancel.test.d.ts → client/mutations/mutation/mutation.options.test.d.ts} +0 -0
- /package/dist/lib/utils/{emitToSubject.d.ts → operators/emitToSubject.d.ts} +0 -0
- /package/dist/lib/utils/{shareLatest.d.ts → operators/shareLatest.d.ts} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,655 +1,667 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
var ze = Object.defineProperty;
|
|
2
|
+
var Je = (t, e, r) => e in t ? ze(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
|
+
var y = (t, e, r) => (Je(t, typeof e != "symbol" ? e + "" : e, r), r), We = (t, e, r) => {
|
|
4
|
+
if (!e.has(t))
|
|
5
|
+
throw TypeError("Cannot " + r);
|
|
6
6
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const useLiveRef = (value) => {
|
|
12
|
-
const ref = useRef(value);
|
|
13
|
-
useMemo(() => {
|
|
14
|
-
ref.current = value;
|
|
15
|
-
}, [value]);
|
|
16
|
-
return ref;
|
|
7
|
+
var k = (t, e, r) => (We(t, e, "read from private field"), r ? r.call(t) : e.get(t)), de = (t, e, r) => {
|
|
8
|
+
if (e.has(t))
|
|
9
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
10
|
+
e instanceof WeakSet ? e.add(t) : e.set(t, r);
|
|
17
11
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return true;
|
|
31
|
-
if (objA === null && objA === objB)
|
|
32
|
-
return true;
|
|
33
|
-
return false;
|
|
12
|
+
import { useRef as H, useMemo as ye, useCallback as Y, useSyncExternalStore as Ye, useEffect as K, createContext as Ge, memo as He, useContext as De, useState as Xe } from "react";
|
|
13
|
+
import { distinctUntilChanged as R, tap as x, finalize as ae, catchError as A, EMPTY as M, Subject as F, identity as le, BehaviorSubject as I, map as p, of as S, zip as Ze, merge as O, throttleTime as Ve, asyncScheduler as qe, switchMap as w, from as ne, defer as se, throwError as Re, iif as Te, timer as ie, Observable as Me, filter as $, mergeMap as _, takeUntil as P, skip as B, last as ge, scan as pe, shareReplay as $e, concatMap as Be, fromEvent as me, withLatestFrom as D, retry as et, endWith as tt, delay as rt, take as be, share as J, startWith as Ie, pairwise as oe, NEVER as Qe, combineLatest as Fe, takeWhile as ve, concat as ue, toArray as ce, lastValueFrom as nt } from "rxjs";
|
|
14
|
+
import { catchError as Ce, retryWhen as st, concatMap as it, tap as ut } from "rxjs/operators";
|
|
15
|
+
import { jsxs as ct, jsx as ot } from "react/jsx-runtime";
|
|
16
|
+
const U = (t) => {
|
|
17
|
+
const e = H(t);
|
|
18
|
+
return ye(() => {
|
|
19
|
+
e.current = t;
|
|
20
|
+
}, [t]), e;
|
|
21
|
+
};
|
|
22
|
+
function at(t, e) {
|
|
23
|
+
return typeof t == "string" && t === e || typeof t == "number" && t === e || typeof t == "boolean" && t === e || typeof t == "symbol" && t === e || typeof t == "bigint" && t === e || typeof t > "u" && t === e || t === null && t === e;
|
|
34
24
|
}
|
|
35
|
-
function
|
|
36
|
-
const
|
|
25
|
+
function fe(t, e, r) {
|
|
26
|
+
const n = e != null && !Array.isArray(e) ? e : {
|
|
37
27
|
defaultValue: void 0,
|
|
38
28
|
key: "",
|
|
39
|
-
unsubscribeOnUnmount:
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const sourceRef = useLiveRef(source$);
|
|
46
|
-
const optionsRef = useLiveRef(options);
|
|
47
|
-
const subscribe = useCallback(
|
|
48
|
-
(next) => {
|
|
49
|
-
const source = sourceRef.current;
|
|
50
|
-
const makeObservable = typeof source === "function" ? source : () => source;
|
|
51
|
-
const sub = makeObservable().pipe(
|
|
29
|
+
unsubscribeOnUnmount: !0
|
|
30
|
+
}, s = r == null && Array.isArray(e) ? e : typeof t == "function" ? r ?? [] : [t], i = H(
|
|
31
|
+
"getValue" in t && typeof t.getValue == "function" ? t.getValue() : n.defaultValue
|
|
32
|
+
), u = U(t), l = U(n), f = Y(
|
|
33
|
+
(g) => {
|
|
34
|
+
const a = u.current, o = (typeof a == "function" ? a : () => a)().pipe(
|
|
52
35
|
/**
|
|
53
36
|
* @important
|
|
54
37
|
* We only check primitives because underlying subscription might
|
|
55
38
|
* be using objects and keeping same reference but pushing new
|
|
56
39
|
* properties values
|
|
57
40
|
*/
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
41
|
+
R(at),
|
|
42
|
+
x((m) => {
|
|
43
|
+
i.current = m;
|
|
61
44
|
}),
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
valueRef.current = void 0;
|
|
66
|
-
return EMPTY;
|
|
67
|
-
})
|
|
68
|
-
).subscribe(next);
|
|
45
|
+
ae(g),
|
|
46
|
+
A((m) => (console.error(m), i.current = void 0, M))
|
|
47
|
+
).subscribe(g);
|
|
69
48
|
return () => {
|
|
70
|
-
|
|
71
|
-
return;
|
|
72
|
-
sub.unsubscribe();
|
|
49
|
+
l.current.unsubscribeOnUnmount !== !1 && o.unsubscribe();
|
|
73
50
|
};
|
|
74
51
|
},
|
|
75
52
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
76
|
-
[...
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
return valueRef.current;
|
|
80
|
-
}, []);
|
|
81
|
-
const result = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
82
|
-
return result;
|
|
53
|
+
[...s]
|
|
54
|
+
), d = Y(() => i.current, []);
|
|
55
|
+
return Ye(f, d, d);
|
|
83
56
|
}
|
|
84
|
-
function
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
catchError((error) => {
|
|
92
|
-
console.error(
|
|
93
|
-
"Uncaught error at useSubscribe. Please consider adding a catchError or other handling."
|
|
94
|
-
);
|
|
95
|
-
console.error(error);
|
|
96
|
-
return EMPTY;
|
|
97
|
-
})
|
|
57
|
+
function Se(t, e = []) {
|
|
58
|
+
const r = U(t), n = typeof t == "function" ? void 0 : t;
|
|
59
|
+
K(() => {
|
|
60
|
+
const s = r.current, u = (typeof s == "function" ? s : () => s)().pipe(
|
|
61
|
+
A((l) => (console.error(
|
|
62
|
+
"Uncaught error at useSubscribe. Please consider adding a catchError or other handling."
|
|
63
|
+
), console.error(l), M))
|
|
98
64
|
).subscribe();
|
|
99
65
|
return () => {
|
|
100
|
-
|
|
66
|
+
u.unsubscribe();
|
|
101
67
|
};
|
|
102
68
|
}, [
|
|
103
69
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
104
|
-
...
|
|
105
|
-
|
|
106
|
-
|
|
70
|
+
...e,
|
|
71
|
+
n,
|
|
72
|
+
r
|
|
107
73
|
]);
|
|
108
74
|
}
|
|
109
|
-
const
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}, []);
|
|
118
|
-
return ref;
|
|
119
|
-
};
|
|
120
|
-
const useSubject = ({
|
|
121
|
-
onBeforeComplete,
|
|
122
|
-
completeOnUnmount = true
|
|
75
|
+
const we = (t) => {
|
|
76
|
+
const e = H();
|
|
77
|
+
return e.current || (e.current = t()), K(() => {
|
|
78
|
+
process.env.NODE_ENV;
|
|
79
|
+
}, []), e;
|
|
80
|
+
}, Oe = ({
|
|
81
|
+
onBeforeComplete: t,
|
|
82
|
+
completeOnUnmount: e = !0
|
|
123
83
|
} = {}) => {
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if (completed.current) {
|
|
130
|
-
subject.current = new Subject();
|
|
131
|
-
completed.current = false;
|
|
84
|
+
const r = we(() => new F()), n = H(!1), s = U(t), i = U(e);
|
|
85
|
+
return K(() => (n.current && (r.current = new F(), n.current = !1), () => {
|
|
86
|
+
if (!i.current) {
|
|
87
|
+
n.current = !0;
|
|
88
|
+
return;
|
|
132
89
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
onBeforeCompleteRef.current();
|
|
141
|
-
subject.current.complete();
|
|
142
|
-
completed.current = true;
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
}, [completeOnUnmountRef, onBeforeCompleteRef, subject]);
|
|
146
|
-
return subject;
|
|
90
|
+
n.current || (s.current != null && s.current(), r.current.complete(), n.current = !0);
|
|
91
|
+
}), [i, s, r]), r;
|
|
92
|
+
}, ar = (t, e) => {
|
|
93
|
+
const r = Oe();
|
|
94
|
+
return Se(() => t(r.current), [r, ...e]), [Y((s) => {
|
|
95
|
+
r.current.next(s);
|
|
96
|
+
}, [r]), r];
|
|
147
97
|
};
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
useSubscribe(() => callback(trigger$.current), [trigger$, ...deps]);
|
|
151
|
-
const trigger2 = useCallback((arg) => {
|
|
152
|
-
trigger$.current.next(arg);
|
|
153
|
-
}, [trigger$]);
|
|
154
|
-
return [trigger2, trigger$];
|
|
155
|
-
};
|
|
156
|
-
function trigger(mapper = identity) {
|
|
157
|
-
const subject = new Subject();
|
|
98
|
+
function lr(t = le) {
|
|
99
|
+
const e = new F();
|
|
158
100
|
return [
|
|
159
|
-
|
|
160
|
-
(...
|
|
161
|
-
|
|
101
|
+
e.asObservable(),
|
|
102
|
+
(...r) => {
|
|
103
|
+
e.next(t(...r));
|
|
162
104
|
}
|
|
163
105
|
];
|
|
164
106
|
}
|
|
165
|
-
const
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
if (
|
|
176
|
-
|
|
177
|
-
|
|
107
|
+
const lt = (t) => {
|
|
108
|
+
const e = we(() => new I(t)), r = H(!1), n = H(t);
|
|
109
|
+
return K(() => (r.current && (e.current = new I(n.current), r.current = !1), () => {
|
|
110
|
+
r.current || (e.current.complete(), r.current = !0);
|
|
111
|
+
}), [e]), e;
|
|
112
|
+
}, pt = Symbol("SIGNAL_RESET");
|
|
113
|
+
function pr(t) {
|
|
114
|
+
const { default: e } = t ?? {}, r = new I(e);
|
|
115
|
+
return {
|
|
116
|
+
setValue: (i) => {
|
|
117
|
+
if (typeof i == "function") {
|
|
118
|
+
const u = i(r.getValue());
|
|
119
|
+
if (u === r.getValue())
|
|
120
|
+
return;
|
|
121
|
+
r.next(u);
|
|
122
|
+
return;
|
|
178
123
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
return subject;
|
|
182
|
-
};
|
|
183
|
-
const SIGNAL_RESET = Symbol("SIGNAL_RESET");
|
|
184
|
-
function signal(config) {
|
|
185
|
-
const { default: defaultValue2 } = config ?? {};
|
|
186
|
-
const subject = new BehaviorSubject(defaultValue2);
|
|
187
|
-
const setValue = (arg) => {
|
|
188
|
-
if (typeof arg === "function") {
|
|
189
|
-
const change = arg(subject.getValue());
|
|
190
|
-
if (change === subject.getValue())
|
|
124
|
+
if (i === pt) {
|
|
125
|
+
r.next(e ?? void 0);
|
|
191
126
|
return;
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}
|
|
199
|
-
subject.next(arg);
|
|
200
|
-
};
|
|
201
|
-
const getValue = () => subject.getValue();
|
|
202
|
-
return {
|
|
203
|
-
setValue,
|
|
204
|
-
getValue,
|
|
205
|
-
config,
|
|
206
|
-
subject
|
|
127
|
+
}
|
|
128
|
+
r.next(i);
|
|
129
|
+
},
|
|
130
|
+
getValue: () => r.getValue(),
|
|
131
|
+
config: t,
|
|
132
|
+
subject: r
|
|
207
133
|
};
|
|
208
134
|
}
|
|
209
|
-
function
|
|
210
|
-
const
|
|
211
|
-
return
|
|
212
|
-
() =>
|
|
213
|
-
|
|
214
|
-
|
|
135
|
+
function fr(t, e) {
|
|
136
|
+
const r = e ?? ((n) => n);
|
|
137
|
+
return fe(
|
|
138
|
+
() => t.subject.pipe(
|
|
139
|
+
p((n) => r(n)),
|
|
140
|
+
R()
|
|
215
141
|
),
|
|
216
142
|
{
|
|
217
|
-
defaultValue:
|
|
143
|
+
defaultValue: r(t.getValue())
|
|
218
144
|
},
|
|
219
145
|
[]
|
|
220
146
|
);
|
|
221
147
|
}
|
|
222
|
-
const
|
|
223
|
-
if (!
|
|
224
|
-
return
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
const createSharedStoreAdapter = ({
|
|
229
|
-
adapter,
|
|
230
|
-
key
|
|
148
|
+
const xe = (t) => {
|
|
149
|
+
if (!(!t || typeof t != "object"))
|
|
150
|
+
return t;
|
|
151
|
+
}, dr = ({
|
|
152
|
+
adapter: t,
|
|
153
|
+
key: e
|
|
231
154
|
}) => ({
|
|
232
|
-
getItem: async (
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
return store[itemKey];
|
|
237
|
-
}
|
|
238
|
-
return void 0;
|
|
155
|
+
getItem: async (r) => {
|
|
156
|
+
const n = await t.getItem(e), s = xe(n) ?? {};
|
|
157
|
+
if (r in s)
|
|
158
|
+
return s[r];
|
|
239
159
|
},
|
|
240
|
-
setItem: async (
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
await adapter.setItem(key, { ...store, [itemKey]: value });
|
|
160
|
+
setItem: async (r, n) => {
|
|
161
|
+
const s = await t.getItem(e), i = xe(s) ?? {};
|
|
162
|
+
await t.setItem(e, { ...i, [r]: n });
|
|
244
163
|
}
|
|
245
|
-
})
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
return void 0;
|
|
251
|
-
return JSON.parse(serializedValue);
|
|
164
|
+
}), hr = (t) => ({
|
|
165
|
+
getItem: async (e) => {
|
|
166
|
+
const r = await t.getItem(e);
|
|
167
|
+
if (r)
|
|
168
|
+
return JSON.parse(r);
|
|
252
169
|
},
|
|
253
|
-
setItem: async (
|
|
254
|
-
await
|
|
170
|
+
setItem: async (e, r) => {
|
|
171
|
+
await t.setItem(e, JSON.stringify(r));
|
|
255
172
|
}
|
|
256
|
-
})
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
return void 0;
|
|
262
|
-
return JSON.parse(serializedValue);
|
|
173
|
+
}), ft = (t) => ({
|
|
174
|
+
getItem: async (e) => {
|
|
175
|
+
const r = t.getItem(e);
|
|
176
|
+
if (r)
|
|
177
|
+
return JSON.parse(r);
|
|
263
178
|
},
|
|
264
|
-
setItem: async (
|
|
265
|
-
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
const IDENTIFIER_PERSISTANCE_KEY = "__reactjrx";
|
|
269
|
-
const getNormalizedPersistanceValue = (unknownValue) => {
|
|
270
|
-
if (typeof unknownValue === "object" && unknownValue !== null && IDENTIFIER_PERSISTANCE_KEY in unknownValue && unknownValue[IDENTIFIER_PERSISTANCE_KEY] === IDENTIFIER_PERSISTANCE_KEY) {
|
|
271
|
-
return unknownValue;
|
|
179
|
+
setItem: async (e, r) => {
|
|
180
|
+
t.setItem(e, JSON.stringify(r));
|
|
272
181
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
182
|
+
}), Z = "__reactjrx", dt = (t) => {
|
|
183
|
+
if (typeof t == "object" && t !== null && Z in t && t[Z] === Z)
|
|
184
|
+
return t;
|
|
185
|
+
}, ht = async ({
|
|
186
|
+
adapter: t,
|
|
187
|
+
signal: e,
|
|
188
|
+
version: r
|
|
279
189
|
}) => {
|
|
280
|
-
const
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
migrationVersion: version
|
|
190
|
+
const s = {
|
|
191
|
+
value: e.getValue(),
|
|
192
|
+
[Z]: Z,
|
|
193
|
+
migrationVersion: r
|
|
285
194
|
};
|
|
286
|
-
await
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}
|
|
301
|
-
signal2.setValue(value.value);
|
|
302
|
-
return of(value);
|
|
303
|
-
})
|
|
304
|
-
);
|
|
305
|
-
};
|
|
306
|
-
const usePersistSignals = ({
|
|
307
|
-
entries = [],
|
|
308
|
-
onReady,
|
|
309
|
-
adapter = createLocalStorageAdapter(localStorage)
|
|
195
|
+
await t.setItem(e.config.key, s);
|
|
196
|
+
}, gt = ({
|
|
197
|
+
adapter: t,
|
|
198
|
+
version: e,
|
|
199
|
+
signal: r
|
|
200
|
+
}) => ne(t.getItem(r.config.key)).pipe(
|
|
201
|
+
w((n) => {
|
|
202
|
+
const s = dt(n);
|
|
203
|
+
return s ? s.migrationVersion !== void 0 && e > s.migrationVersion ? S(n) : (r.setValue(n.value), S(n)) : S(n);
|
|
204
|
+
})
|
|
205
|
+
), gr = ({
|
|
206
|
+
entries: t = [],
|
|
207
|
+
onReady: e,
|
|
208
|
+
adapter: r = ft(localStorage)
|
|
310
209
|
}) => {
|
|
311
|
-
const
|
|
312
|
-
const onReadyRef = useLiveRef(onReady);
|
|
313
|
-
const adapterRef = useLiveRef(adapter);
|
|
314
|
-
const isHydrated = useObserve(
|
|
210
|
+
const n = U(t), s = U(e), i = U(r), u = fe(
|
|
315
211
|
() => {
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
...
|
|
319
|
-
({ signal:
|
|
320
|
-
adapter:
|
|
321
|
-
signal:
|
|
322
|
-
version
|
|
212
|
+
const l = n.current;
|
|
213
|
+
return (l.length === 0 ? S(!0) : Ze(
|
|
214
|
+
...l.map(
|
|
215
|
+
({ signal: d, version: h }) => gt({
|
|
216
|
+
adapter: i.current,
|
|
217
|
+
signal: d,
|
|
218
|
+
version: h
|
|
323
219
|
})
|
|
324
220
|
)
|
|
325
|
-
).pipe(
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
if (onReadyRef.current != null)
|
|
329
|
-
onReadyRef.current();
|
|
221
|
+
).pipe(p(() => !0))).pipe(
|
|
222
|
+
x(() => {
|
|
223
|
+
s.current != null && s.current();
|
|
330
224
|
}),
|
|
331
|
-
|
|
332
|
-
console.error("Unable to hydrate", error);
|
|
333
|
-
return EMPTY;
|
|
334
|
-
})
|
|
225
|
+
A((d) => (console.error("Unable to hydrate", d), M))
|
|
335
226
|
);
|
|
336
227
|
},
|
|
337
|
-
{ defaultValue:
|
|
228
|
+
{ defaultValue: !1 },
|
|
338
229
|
[]
|
|
339
230
|
);
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
(
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
(
|
|
349
|
-
persistValue({ adapter: adapterRef.current, signal: signal2, version })
|
|
350
|
-
)
|
|
231
|
+
return Se(() => u ? O(
|
|
232
|
+
...n.current.map(
|
|
233
|
+
({ signal: l, version: f }) => l.subject.pipe(
|
|
234
|
+
Ve(500, qe, {
|
|
235
|
+
trailing: !0
|
|
236
|
+
}),
|
|
237
|
+
w(
|
|
238
|
+
() => ne(
|
|
239
|
+
ht({ adapter: i.current, signal: l, version: f })
|
|
351
240
|
)
|
|
352
241
|
)
|
|
353
242
|
)
|
|
354
|
-
)
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
const useUnmountObservable = () => {
|
|
359
|
-
const subject = useSubject({
|
|
243
|
+
)
|
|
244
|
+
) : M, [u, i]), { isHydrated: u };
|
|
245
|
+
}, mr = () => {
|
|
246
|
+
const t = Oe({
|
|
360
247
|
onBeforeComplete: () => {
|
|
361
|
-
|
|
248
|
+
t.current.next();
|
|
362
249
|
}
|
|
363
250
|
});
|
|
364
|
-
return
|
|
251
|
+
return t;
|
|
365
252
|
};
|
|
366
|
-
function
|
|
367
|
-
return Math.min(
|
|
253
|
+
function mt(t, e) {
|
|
254
|
+
return Math.min(t, e);
|
|
368
255
|
}
|
|
369
|
-
function
|
|
370
|
-
return Math.pow(2,
|
|
256
|
+
function bt(t, e) {
|
|
257
|
+
return Math.pow(2, t) * e;
|
|
371
258
|
}
|
|
372
|
-
function
|
|
259
|
+
function yt(t) {
|
|
373
260
|
const {
|
|
374
|
-
initialInterval,
|
|
375
|
-
maxRetries =
|
|
376
|
-
maxInterval =
|
|
377
|
-
shouldRetry = () =>
|
|
378
|
-
resetOnSuccess =
|
|
379
|
-
backoffDelay =
|
|
380
|
-
} =
|
|
381
|
-
return (
|
|
382
|
-
let
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
})
|
|
261
|
+
initialInterval: e,
|
|
262
|
+
maxRetries: r = 1 / 0,
|
|
263
|
+
maxInterval: n = 1 / 0,
|
|
264
|
+
shouldRetry: s = () => !0,
|
|
265
|
+
resetOnSuccess: i = !1,
|
|
266
|
+
backoffDelay: u = bt
|
|
267
|
+
} = t;
|
|
268
|
+
return (l) => se(() => {
|
|
269
|
+
let f = 0;
|
|
270
|
+
const d = (h, g) => h < r && s(h, g);
|
|
271
|
+
return l.pipe(
|
|
272
|
+
Ce((h) => {
|
|
273
|
+
var a;
|
|
274
|
+
if (f++, !d(f - 1, h))
|
|
275
|
+
throw h;
|
|
276
|
+
const g = (a = t.caughtError) == null ? void 0 : a.call(t, f, h);
|
|
277
|
+
if (!g)
|
|
278
|
+
throw h;
|
|
279
|
+
return O(
|
|
280
|
+
g,
|
|
281
|
+
Re(() => h)
|
|
396
282
|
);
|
|
397
283
|
}),
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
284
|
+
st((h) => h.pipe(
|
|
285
|
+
it((g) => {
|
|
286
|
+
const a = f - 1;
|
|
287
|
+
return Te(
|
|
288
|
+
() => d(a, g),
|
|
289
|
+
ie(
|
|
290
|
+
mt(u(a, e), n)
|
|
291
|
+
),
|
|
292
|
+
Re(() => g)
|
|
293
|
+
);
|
|
294
|
+
})
|
|
295
|
+
)),
|
|
296
|
+
Ce((h) => {
|
|
297
|
+
if (t.catchError)
|
|
298
|
+
return t.catchError(f, h);
|
|
299
|
+
throw h;
|
|
300
|
+
}),
|
|
301
|
+
ut(() => {
|
|
302
|
+
i && (f = 0);
|
|
402
303
|
})
|
|
403
304
|
);
|
|
404
305
|
});
|
|
405
306
|
}
|
|
406
|
-
const
|
|
307
|
+
const _e = Ge({
|
|
407
308
|
client: null
|
|
408
|
-
})
|
|
409
|
-
const
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
({ children, client }) => {
|
|
420
|
-
const value = useMemo(() => ({ client }), [client]);
|
|
421
|
-
return /* @__PURE__ */ jsxs(Context.Provider, { value, children: [
|
|
422
|
-
/* @__PURE__ */ jsx(ClientEffect, { client: value.client }),
|
|
423
|
-
children
|
|
309
|
+
}), $t = ({ client: t }) => (K(() => {
|
|
310
|
+
const e = t.mount();
|
|
311
|
+
return () => {
|
|
312
|
+
e();
|
|
313
|
+
};
|
|
314
|
+
}, [t]), null), br = He(
|
|
315
|
+
({ children: t, client: e }) => {
|
|
316
|
+
const r = ye(() => ({ client: e }), [e]);
|
|
317
|
+
return /* @__PURE__ */ ct(_e.Provider, { value: r, children: [
|
|
318
|
+
/* @__PURE__ */ ot($t, { client: r.client }),
|
|
319
|
+
t
|
|
424
320
|
] });
|
|
425
321
|
}
|
|
426
|
-
)
|
|
427
|
-
|
|
428
|
-
unsafe = false
|
|
322
|
+
), Pe = ({
|
|
323
|
+
unsafe: t = !1
|
|
429
324
|
} = {}) => {
|
|
430
|
-
const
|
|
431
|
-
if (!
|
|
325
|
+
const e = De(_e);
|
|
326
|
+
if (!t && e.client === null)
|
|
432
327
|
throw new Error("You forgot to register the provider");
|
|
328
|
+
return e.client;
|
|
329
|
+
}, ee = (t) => Array.isArray(t) ? t.reduce((e, r, n) => n === t.length - 1 ? `${e}${ee(r)}]` : `${e}${ee(r)},`, "[") : t === void 0 ? "" : JSON.stringify(t, Object.keys(t).sort()), N = (t) => t.length === 0 ? "[]" : ee(t), Ne = (t = 21) => crypto.getRandomValues(new Uint8Array(t)).reduce((e, r) => (r &= 63, r < 36 ? e += r.toString(36) : r < 62 ? e += (r - 26).toString(36).toUpperCase() : r > 62 ? e += "-" : e += "_", e), ""), W = () => ({
|
|
330
|
+
context: void 0,
|
|
331
|
+
data: void 0,
|
|
332
|
+
error: null,
|
|
333
|
+
status: "idle",
|
|
334
|
+
submittedAt: 0,
|
|
335
|
+
variables: void 0,
|
|
336
|
+
failureCount: 0,
|
|
337
|
+
failureReason: null,
|
|
338
|
+
isPaused: !1
|
|
339
|
+
});
|
|
340
|
+
function G(t) {
|
|
341
|
+
return t != null;
|
|
342
|
+
}
|
|
343
|
+
function T(t, e) {
|
|
344
|
+
if (t == null || e === void 0 || typeof t != "object" || typeof e != "object")
|
|
345
|
+
return t === e;
|
|
346
|
+
if (t.constructor !== (e == null ? void 0 : e.constructor))
|
|
347
|
+
return !1;
|
|
348
|
+
const r = Object.keys(t), n = Object.keys(e);
|
|
349
|
+
if (r.length !== n.length)
|
|
350
|
+
return !1;
|
|
351
|
+
for (const s of r)
|
|
352
|
+
if (!e.hasOwnProperty(s) || t[s] !== e[s])
|
|
353
|
+
return !1;
|
|
354
|
+
return !0;
|
|
355
|
+
}
|
|
356
|
+
function ke(t) {
|
|
357
|
+
let e = 0;
|
|
358
|
+
return function(n) {
|
|
359
|
+
return new Me((s) => {
|
|
360
|
+
e++, t(e);
|
|
361
|
+
const i = n.subscribe(s);
|
|
362
|
+
return () => {
|
|
363
|
+
e--, t(e), i.unsubscribe();
|
|
364
|
+
};
|
|
365
|
+
});
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
class vt {
|
|
369
|
+
constructor({
|
|
370
|
+
__queryFinalizeHook: e
|
|
371
|
+
} = {}) {
|
|
372
|
+
y(this, "trigger$", new F());
|
|
373
|
+
y(this, "mapOperator$", new I("merge"));
|
|
374
|
+
y(this, "state$");
|
|
375
|
+
const r = new I(0), n = r.pipe(
|
|
376
|
+
$((i) => i === 0)
|
|
377
|
+
), s = this.mapOperator$.pipe(
|
|
378
|
+
$(G),
|
|
379
|
+
R()
|
|
380
|
+
);
|
|
381
|
+
this.state$ = s.pipe(
|
|
382
|
+
_((i) => {
|
|
383
|
+
const u = i === "concat" ? Be : i === "switch" ? w : _, l = this.trigger$.pipe(
|
|
384
|
+
$(() => i === "merge")
|
|
385
|
+
);
|
|
386
|
+
return this.trigger$.pipe(
|
|
387
|
+
P(s.pipe(B(1))),
|
|
388
|
+
u(({ args: f, mutation: d }) => {
|
|
389
|
+
const h = se(() => (d.execute(f), M)), g = d.observeTillFinished().pipe(
|
|
390
|
+
ge(),
|
|
391
|
+
_(() => d.state$),
|
|
392
|
+
P(this.trigger$)
|
|
393
|
+
), a = d.observeTillFinished().pipe(B(1));
|
|
394
|
+
return O(a, g, h).pipe(
|
|
395
|
+
e ?? le,
|
|
396
|
+
P(O(n, l))
|
|
397
|
+
);
|
|
398
|
+
}),
|
|
399
|
+
pe((f, d) => ({
|
|
400
|
+
...f,
|
|
401
|
+
...d,
|
|
402
|
+
...d.status === "pending" && {
|
|
403
|
+
data: d.data ?? f.data
|
|
404
|
+
},
|
|
405
|
+
...d.status === "pending" && {
|
|
406
|
+
error: d.error ?? f.error
|
|
407
|
+
}
|
|
408
|
+
}), W()),
|
|
409
|
+
R(
|
|
410
|
+
({ data: f, ...d }, { data: h, ...g }) => T(d, g) && T(f, h)
|
|
411
|
+
)
|
|
412
|
+
);
|
|
413
|
+
}),
|
|
414
|
+
$e({
|
|
415
|
+
refCount: !0,
|
|
416
|
+
bufferSize: 1
|
|
417
|
+
}),
|
|
418
|
+
ke((i) => {
|
|
419
|
+
r.next(i);
|
|
420
|
+
})
|
|
421
|
+
);
|
|
433
422
|
}
|
|
434
|
-
|
|
435
|
-
};
|
|
436
|
-
const serializeObject = (object) => {
|
|
437
|
-
if (Array.isArray(object)) {
|
|
438
|
-
return object.reduce((acc, value, index) => {
|
|
439
|
-
if (index === object.length - 1)
|
|
440
|
-
return `${acc}${serializeObject(value)}]`;
|
|
441
|
-
return `${acc}${serializeObject(value)},`;
|
|
442
|
-
}, "[");
|
|
443
|
-
}
|
|
444
|
-
if (object === void 0)
|
|
445
|
-
return "";
|
|
446
|
-
return JSON.stringify(object, Object.keys(object).sort());
|
|
447
|
-
};
|
|
448
|
-
const serializeKey = (key) => {
|
|
449
|
-
if (key.length === 0)
|
|
450
|
-
return "[]";
|
|
451
|
-
return serializeObject(key);
|
|
452
|
-
};
|
|
453
|
-
const nanoid = (size = 21) => crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
|
|
454
|
-
byte &= 63;
|
|
455
|
-
if (byte < 36) {
|
|
456
|
-
id += byte.toString(36);
|
|
457
|
-
} else if (byte < 62) {
|
|
458
|
-
id += (byte - 26).toString(36).toUpperCase();
|
|
459
|
-
} else if (byte > 62) {
|
|
460
|
-
id += "-";
|
|
461
|
-
} else {
|
|
462
|
-
id += "_";
|
|
423
|
+
trigger({ args: e, options: r, mutation: n }) {
|
|
424
|
+
r.mapOperator && this.mapOperator$.next(r.mapOperator), this.trigger$.next({ args: e, options: r, mutation: n });
|
|
463
425
|
}
|
|
464
|
-
return id;
|
|
465
|
-
}, "");
|
|
466
|
-
function noop() {
|
|
467
426
|
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
})
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
427
|
+
const te = (t, e, { exact: r = !1 } = {}) => r ? N(t) === N(e) : t.reduce((n, s, i) => n ? s === void 0 && !t.slice(i, t.length - 1).some((l) => l !== void 0) ? !0 : ee(s) === ee(e[i]) : !1, !0);
|
|
428
|
+
var L;
|
|
429
|
+
class St {
|
|
430
|
+
constructor(e, r = {}, n) {
|
|
431
|
+
y(this, "numberOfObservers", 0);
|
|
432
|
+
y(this, "mutationRunner");
|
|
433
|
+
de(this, L, new I(void 0));
|
|
434
|
+
y(this, "observed$");
|
|
435
|
+
y(this, "result$");
|
|
436
|
+
y(this, "getObserverResultFromState", (e) => ({
|
|
437
|
+
...W(),
|
|
438
|
+
...e,
|
|
439
|
+
isSuccess: e.status === "success",
|
|
440
|
+
isPending: e.status === "pending",
|
|
441
|
+
isIdle: e.status === "idle",
|
|
442
|
+
isError: e.status === "error",
|
|
443
|
+
mutate: this.mutate,
|
|
444
|
+
reset: this.reset
|
|
445
|
+
}));
|
|
446
|
+
var s;
|
|
447
|
+
this.client = e, this.options = r, this.options.mutationKey = ((s = this.options) == null ? void 0 : s.mutationKey) ?? [Ne()], this.mutationRunner = n ?? new vt(this.options), this.mutate = this.mutate.bind(this), this.reset = this.reset.bind(this), this.result$ = this.mutationRunner.state$.pipe(
|
|
448
|
+
p((i) => ({
|
|
449
|
+
state: this.getObserverResultFromState(i),
|
|
450
|
+
options: {}
|
|
451
|
+
}))
|
|
452
|
+
), k(this, L).pipe(
|
|
453
|
+
$(G),
|
|
454
|
+
_(
|
|
455
|
+
(i) => this.mutationRunner.state$.pipe(
|
|
456
|
+
P(i.mutation.observeTillFinished().pipe(ge()))
|
|
457
|
+
)
|
|
458
|
+
)
|
|
459
|
+
).subscribe(), this.observed$ = k(this, L).pipe(
|
|
460
|
+
w(
|
|
461
|
+
(i) => (i == null ? void 0 : i.mutation.state$.pipe(
|
|
462
|
+
p((u) => ({
|
|
463
|
+
state: this.getObserverResultFromState(u),
|
|
464
|
+
options: i.options
|
|
465
|
+
}))
|
|
466
|
+
)) ?? M
|
|
467
|
+
),
|
|
468
|
+
_(({ state: i, options: u }) => (i.status === "error" && (u != null && u.onError && (u == null || u.onError(
|
|
469
|
+
i.error,
|
|
470
|
+
i.variables,
|
|
471
|
+
i.context
|
|
472
|
+
)), u != null && u.onSettled && (u == null || u.onSettled(
|
|
473
|
+
i.data,
|
|
474
|
+
i.error,
|
|
475
|
+
i.variables,
|
|
476
|
+
i.context
|
|
477
|
+
))), i.status === "success" && (u != null && u.onSuccess && (u == null || u.onSuccess(
|
|
478
|
+
i.data,
|
|
479
|
+
i.variables,
|
|
480
|
+
i.context
|
|
481
|
+
)), u != null && u.onSettled && (u == null || u.onSettled(
|
|
482
|
+
i.data,
|
|
483
|
+
i.error,
|
|
484
|
+
i.variables,
|
|
485
|
+
i.context
|
|
486
|
+
))), M))
|
|
487
|
+
);
|
|
488
|
+
}
|
|
489
|
+
setOptions(e) {
|
|
490
|
+
var n;
|
|
491
|
+
const r = this.options;
|
|
492
|
+
this.options = this.client.defaultMutationOptions({
|
|
493
|
+
mutationKey: this.options.mutationKey,
|
|
494
|
+
...e
|
|
495
|
+
}), (n = k(this, L).getValue()) == null || n.mutation.setOptions(this.options), this.options.mutationKey && r.mutationKey && !te(this.options.mutationKey, r.mutationKey, {
|
|
496
|
+
exact: !0
|
|
497
|
+
}) && this.reset();
|
|
498
|
+
}
|
|
499
|
+
observe() {
|
|
500
|
+
var n;
|
|
501
|
+
const e = this.getObserverResultFromState(
|
|
502
|
+
((n = k(this, L).getValue()) == null ? void 0 : n.mutation.state) ?? W()
|
|
503
|
+
);
|
|
504
|
+
return { result$: O(this.observed$, this.result$).pipe(
|
|
505
|
+
p(({ state: s }) => (console.log({ state: s }), s))
|
|
506
|
+
), lastValue: e };
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* @important
|
|
510
|
+
* Compliance react-query only
|
|
511
|
+
*/
|
|
512
|
+
subscribe(e) {
|
|
513
|
+
const r = this.observe().result$.subscribe((n) => {
|
|
514
|
+
e(n);
|
|
502
515
|
});
|
|
503
|
-
}, []);
|
|
504
|
-
useEffect(() => {
|
|
505
516
|
return () => {
|
|
506
|
-
|
|
507
|
-
cancel();
|
|
508
|
-
}
|
|
517
|
+
r.unsubscribe();
|
|
509
518
|
};
|
|
510
|
-
}, [cancel, optionsRef]);
|
|
511
|
-
return { mutate, cancel, ...result };
|
|
512
|
-
}
|
|
513
|
-
const arrayEqual = (a, b) => a.length === b.length && a.every((v, i) => v === b[i]);
|
|
514
|
-
function shallowEqual(objA, objB) {
|
|
515
|
-
if (objA === null || objA === void 0 || objB === void 0) {
|
|
516
|
-
return objA === objB;
|
|
517
|
-
}
|
|
518
|
-
if (typeof objA !== "object" || typeof objB !== "object") {
|
|
519
|
-
return objA === objB;
|
|
520
519
|
}
|
|
521
|
-
|
|
522
|
-
|
|
520
|
+
async mutate(e, r = {}) {
|
|
521
|
+
const n = this.client.getMutationCache().build(this.client, this.options);
|
|
522
|
+
return k(this, L).next({ mutation: n, options: r }), this.mutationRunner.trigger({
|
|
523
|
+
args: e,
|
|
524
|
+
options: this.options,
|
|
525
|
+
mutation: n
|
|
526
|
+
}), await new Promise((s, i) => {
|
|
527
|
+
n.observeTillFinished().pipe(ge()).subscribe({
|
|
528
|
+
error: (u) => {
|
|
529
|
+
i(u);
|
|
530
|
+
},
|
|
531
|
+
next: (u) => {
|
|
532
|
+
u.error ? i(u.error) : s(u.data);
|
|
533
|
+
}
|
|
534
|
+
});
|
|
535
|
+
});
|
|
523
536
|
}
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
return
|
|
537
|
+
getCurrentResult() {
|
|
538
|
+
var r;
|
|
539
|
+
const e = this.client.getMutationCache().find({ exact: !0, mutationKey: (r = this.options) == null ? void 0 : r.mutationKey });
|
|
540
|
+
return this.getObserverResultFromState(
|
|
541
|
+
(e == null ? void 0 : e.state) ?? W()
|
|
542
|
+
);
|
|
528
543
|
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
}
|
|
544
|
+
reset() {
|
|
545
|
+
var e;
|
|
546
|
+
(e = k(this, L).getValue()) == null || e.mutation.reset();
|
|
533
547
|
}
|
|
534
|
-
return true;
|
|
535
548
|
}
|
|
536
|
-
|
|
537
|
-
|
|
549
|
+
L = new WeakMap();
|
|
550
|
+
function wt() {
|
|
538
551
|
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
filter(() => !document.hidden),
|
|
546
|
-
map(() => ({
|
|
547
|
-
type: "refetch",
|
|
548
|
-
ignoreStale: shouldRunTrigger === "always"
|
|
549
|
-
}))
|
|
550
|
-
),
|
|
551
|
-
fromEvent(window, "focus").pipe(
|
|
552
|
-
map(() => ({
|
|
553
|
-
type: "refetch",
|
|
554
|
-
ignoreStale: shouldRunTrigger === "always"
|
|
555
|
-
}))
|
|
556
|
-
)
|
|
557
|
-
) : EMPTY;
|
|
558
|
-
})
|
|
552
|
+
function yr(t, e) {
|
|
553
|
+
const r = Pe({ unsafe: !!e }), n = e ?? r, s = U(t), i = we(() => [Ne()]), u = N(t.mutationKey ?? i.current), [l] = Xe(
|
|
554
|
+
() => new St(
|
|
555
|
+
n,
|
|
556
|
+
t
|
|
557
|
+
)
|
|
559
558
|
);
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
559
|
+
K(() => {
|
|
560
|
+
l.setOptions(t);
|
|
561
|
+
}, [l, t]);
|
|
562
|
+
const f = ye(() => l.observe(), [u, l]), d = fe(f.result$) ?? f.lastValue, h = Y(
|
|
563
|
+
(g, a) => {
|
|
564
|
+
l.mutate(g, a).catch(wt);
|
|
565
|
+
},
|
|
566
|
+
[l]
|
|
567
|
+
);
|
|
568
|
+
return K(() => () => {
|
|
569
|
+
s.current.cancelOnUnMount && l.reset();
|
|
570
|
+
}, [l, s]), { ...d, mutate: h, mutateAsync: d.mutate };
|
|
571
|
+
}
|
|
572
|
+
const Le = (t, e) => t.length === e.length && t.every((r, n) => r === e[n]), Ot = (t) => t.pipe(
|
|
573
|
+
w(({ options: { refetchOnWindowFocus: e = !0 } }) => {
|
|
574
|
+
const r = typeof e == "function" ? e({}) : e;
|
|
575
|
+
return r !== !1 ? O(
|
|
576
|
+
me(document, "visibilitychange").pipe(
|
|
577
|
+
$(() => !document.hidden),
|
|
578
|
+
p(() => ({
|
|
567
579
|
type: "refetch",
|
|
568
|
-
ignoreStale:
|
|
580
|
+
ignoreStale: r === "always"
|
|
569
581
|
}))
|
|
570
|
-
)
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
582
|
+
),
|
|
583
|
+
me(window, "focus").pipe(
|
|
584
|
+
p(() => ({
|
|
585
|
+
type: "refetch",
|
|
586
|
+
ignoreStale: r === "always"
|
|
587
|
+
}))
|
|
588
|
+
)
|
|
589
|
+
) : M;
|
|
590
|
+
})
|
|
591
|
+
), Et = (t) => t.pipe(
|
|
592
|
+
w(({ options: { refetchOnReconnect: e = !0 } }) => {
|
|
593
|
+
const r = typeof e == "function" ? e({}) : e;
|
|
594
|
+
return r !== !1 ? me(window, "online").pipe(
|
|
595
|
+
p(() => ({
|
|
596
|
+
type: "refetch",
|
|
597
|
+
ignoreStale: r === "always"
|
|
598
|
+
}))
|
|
599
|
+
) : M;
|
|
600
|
+
})
|
|
601
|
+
), Rt = ({
|
|
602
|
+
queryKey: t,
|
|
603
|
+
queryFn: e,
|
|
604
|
+
...r
|
|
578
605
|
}) => {
|
|
579
|
-
const
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
queryKey,
|
|
583
|
-
options,
|
|
584
|
-
queryFn
|
|
606
|
+
const n = lt({ queryKey: t, options: r, queryFn: e });
|
|
607
|
+
return K(() => {
|
|
608
|
+
n.current.next({
|
|
609
|
+
queryKey: t,
|
|
610
|
+
options: r,
|
|
611
|
+
queryFn: e
|
|
585
612
|
});
|
|
586
|
-
}, [
|
|
587
|
-
|
|
588
|
-
};
|
|
589
|
-
const defaultValue = {
|
|
613
|
+
}, [t, r, e, n]), n;
|
|
614
|
+
}, Ct = {
|
|
590
615
|
data: void 0,
|
|
591
|
-
isLoading:
|
|
616
|
+
isLoading: !0,
|
|
592
617
|
error: void 0,
|
|
593
618
|
status: "loading",
|
|
594
619
|
fetchStatus: "idle"
|
|
595
620
|
};
|
|
596
|
-
function
|
|
597
|
-
queryKey,
|
|
598
|
-
queryFn,
|
|
599
|
-
...
|
|
621
|
+
function $r({
|
|
622
|
+
queryKey: t,
|
|
623
|
+
queryFn: e,
|
|
624
|
+
...r
|
|
600
625
|
}) {
|
|
601
|
-
const
|
|
602
|
-
const client = useQueryClient();
|
|
603
|
-
const params$ = useQueryParams({ queryFn, queryKey, ...options });
|
|
604
|
-
const result = useObserve(
|
|
626
|
+
const n = Oe(), s = Pe(), i = Rt({ queryFn: e, queryKey: t, ...r }), u = fe(
|
|
605
627
|
() => {
|
|
606
|
-
const
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
628
|
+
const f = i.current.pipe(p(({ queryKey: v }) => v ?? [])), d = S(null), h = f.pipe(
|
|
629
|
+
R(Le),
|
|
630
|
+
B(1)
|
|
631
|
+
), g = (v) => !!v && typeof v != "function", a = i.current.pipe(
|
|
632
|
+
p(({ queryFn: v }) => v),
|
|
633
|
+
$(g),
|
|
634
|
+
R(T),
|
|
635
|
+
g(i.current.getValue().queryFn) ? B(1) : le
|
|
636
|
+
), c = i.current.pipe(
|
|
637
|
+
p(({ queryFn: v }) => v),
|
|
638
|
+
$(G)
|
|
639
|
+
), o = i.current.pipe(p(({ options: v }) => v)), m = Ot(i.current), C = Et(i.current), b = O(
|
|
640
|
+
d,
|
|
641
|
+
h,
|
|
642
|
+
a
|
|
643
|
+
), j = O(
|
|
644
|
+
n.current,
|
|
645
|
+
O(m, C).pipe(Ve(500))
|
|
622
646
|
);
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
const trigger$ = merge(
|
|
632
|
-
internalRefresh$.current,
|
|
633
|
-
merge(activityRefetch$, networkRefetch$).pipe(throttleTime(500))
|
|
634
|
-
);
|
|
635
|
-
return newQueryTrigger$.pipe(
|
|
636
|
-
withLatestFrom(key$),
|
|
637
|
-
switchMap(([, key]) => {
|
|
638
|
-
const { result$ } = client.client.query({
|
|
639
|
-
key,
|
|
640
|
-
fn$,
|
|
641
|
-
options$,
|
|
642
|
-
trigger$
|
|
647
|
+
return b.pipe(
|
|
648
|
+
D(f),
|
|
649
|
+
w(([, v]) => {
|
|
650
|
+
const { result$: E } = s.client.query({
|
|
651
|
+
key: v,
|
|
652
|
+
fn$: c,
|
|
653
|
+
options$: o,
|
|
654
|
+
trigger$: j
|
|
643
655
|
});
|
|
644
|
-
return
|
|
645
|
-
|
|
646
|
-
(
|
|
656
|
+
return E.pipe(
|
|
657
|
+
pe(
|
|
658
|
+
(Q, { data: z, ...Ee }) => ({
|
|
647
659
|
data: void 0,
|
|
648
|
-
...
|
|
649
|
-
...
|
|
650
|
-
isLoading:
|
|
651
|
-
...
|
|
652
|
-
data:
|
|
660
|
+
...Q,
|
|
661
|
+
...Ee,
|
|
662
|
+
isLoading: Ee.status === "loading",
|
|
663
|
+
...z && {
|
|
664
|
+
data: z.result
|
|
653
665
|
}
|
|
654
666
|
}),
|
|
655
667
|
{}
|
|
@@ -669,53 +681,49 @@ function useQuery({
|
|
|
669
681
|
},
|
|
670
682
|
{
|
|
671
683
|
defaultValue: {
|
|
672
|
-
...
|
|
673
|
-
isLoading:
|
|
684
|
+
...Ct,
|
|
685
|
+
isLoading: i.current.getValue().options.enabled !== !1
|
|
674
686
|
}
|
|
675
687
|
},
|
|
676
|
-
[
|
|
677
|
-
)
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
return { ...result, refetch };
|
|
688
|
+
[s]
|
|
689
|
+
), l = Y(() => {
|
|
690
|
+
n.current.next({ type: "refetch", ignoreStale: !0 });
|
|
691
|
+
}, [n]);
|
|
692
|
+
return { ...u, refetch: l };
|
|
682
693
|
}
|
|
683
|
-
function
|
|
684
|
-
const
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
const enhancerMakeObservable = useCallback(
|
|
692
|
-
() => makeObservable().pipe(
|
|
693
|
-
catchError((error) => {
|
|
694
|
-
console.error(error);
|
|
695
|
-
throw error;
|
|
694
|
+
function vr(t, e, r = []) {
|
|
695
|
+
const s = (e != null && !Array.isArray(e) ? e : {}).retry ?? !0, i = typeof t == "function", u = Y(
|
|
696
|
+
i ? t : () => t,
|
|
697
|
+
i ? r : [t]
|
|
698
|
+
), l = Y(
|
|
699
|
+
() => u().pipe(
|
|
700
|
+
A((f) => {
|
|
701
|
+
throw console.error(f), f;
|
|
696
702
|
}),
|
|
697
|
-
|
|
703
|
+
s ? et() : le
|
|
698
704
|
),
|
|
699
|
-
[
|
|
705
|
+
[u, s]
|
|
700
706
|
);
|
|
701
|
-
|
|
707
|
+
Se(l, r);
|
|
702
708
|
}
|
|
703
|
-
const
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
709
|
+
const Ue = ({
|
|
710
|
+
retryDelay: t,
|
|
711
|
+
retry: e,
|
|
712
|
+
...r
|
|
713
|
+
}) => yt({
|
|
714
|
+
initialInterval: typeof t == "number" ? t : 100,
|
|
715
|
+
...typeof e == "function" ? {
|
|
716
|
+
shouldRetry: e
|
|
707
717
|
} : {
|
|
708
|
-
maxRetries:
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
(
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
};
|
|
718
|
-
},
|
|
718
|
+
maxRetries: e === !1 ? 0 : e ?? 0
|
|
719
|
+
},
|
|
720
|
+
...r
|
|
721
|
+
}), xt = (t) => t.pipe(
|
|
722
|
+
pe(
|
|
723
|
+
(e, r) => ({
|
|
724
|
+
...e,
|
|
725
|
+
...r
|
|
726
|
+
}),
|
|
719
727
|
{
|
|
720
728
|
data: void 0,
|
|
721
729
|
error: void 0,
|
|
@@ -723,347 +731,273 @@ const mergeResults$1 = (stream$) => stream$.pipe(
|
|
|
723
731
|
status: "loading"
|
|
724
732
|
}
|
|
725
733
|
),
|
|
726
|
-
|
|
727
|
-
({ data:
|
|
734
|
+
R(
|
|
735
|
+
({ data: e, ...r }, { data: n, ...s }) => T(r, s) && T(e, n)
|
|
728
736
|
)
|
|
729
|
-
);
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
const _logger = {
|
|
737
|
+
), Vt = { backgroundColor: "transparent", color: "inherit" };
|
|
738
|
+
function je(t) {
|
|
739
|
+
const e = {
|
|
733
740
|
namespaces: [
|
|
734
741
|
{
|
|
735
742
|
name: "@reactjrx",
|
|
736
743
|
style: { backgroundColor: "#d02f4e", color: "white" }
|
|
737
744
|
}
|
|
738
745
|
],
|
|
739
|
-
namespace(
|
|
740
|
-
const
|
|
741
|
-
|
|
742
|
-
name,
|
|
743
|
-
style:
|
|
744
|
-
});
|
|
745
|
-
return logger2;
|
|
746
|
+
namespace(r, n) {
|
|
747
|
+
const s = je(t);
|
|
748
|
+
return s.namespaces.push({
|
|
749
|
+
name: r,
|
|
750
|
+
style: n ?? Vt
|
|
751
|
+
}), s;
|
|
746
752
|
},
|
|
747
753
|
printNamespaces() {
|
|
748
754
|
return {
|
|
749
|
-
namespaces:
|
|
750
|
-
styles:
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
);
|
|
754
|
-
acc.push("background-color: transparent; color: inherit;");
|
|
755
|
-
return acc;
|
|
756
|
-
}, [])
|
|
755
|
+
namespaces: e.namespaces.map(({ name: r }) => `%c ${r} %c`).join(" "),
|
|
756
|
+
styles: e.namespaces.reduce((r, { style: n }) => (r.push(
|
|
757
|
+
`background-color: ${n.backgroundColor}; color: ${n.color};`
|
|
758
|
+
), r.push("background-color: transparent; color: inherit;"), r), [])
|
|
757
759
|
};
|
|
758
760
|
},
|
|
759
|
-
print(
|
|
760
|
-
if (
|
|
761
|
-
const { namespaces, styles } =
|
|
762
|
-
console[
|
|
761
|
+
print(r, ...n) {
|
|
762
|
+
if (t === "development") {
|
|
763
|
+
const { namespaces: s, styles: i } = e.printNamespaces();
|
|
764
|
+
console[r](s, ...i, ...n);
|
|
763
765
|
}
|
|
764
|
-
return
|
|
766
|
+
return e;
|
|
765
767
|
},
|
|
766
|
-
printWithoutNamespace(
|
|
767
|
-
|
|
768
|
-
console[method](...message);
|
|
769
|
-
}
|
|
770
|
-
return _logger;
|
|
768
|
+
printWithoutNamespace(r, ...n) {
|
|
769
|
+
return t === "development" && console[r](...n), e;
|
|
771
770
|
},
|
|
772
|
-
log(...
|
|
773
|
-
return
|
|
771
|
+
log(...r) {
|
|
772
|
+
return e.print("log", ...r);
|
|
774
773
|
},
|
|
775
|
-
warn(...
|
|
776
|
-
return
|
|
774
|
+
warn(...r) {
|
|
775
|
+
return e.print("warn", ...r);
|
|
777
776
|
},
|
|
778
|
-
error(...
|
|
779
|
-
return
|
|
777
|
+
error(...r) {
|
|
778
|
+
return e.print("error", ...r);
|
|
780
779
|
},
|
|
781
|
-
group(...
|
|
782
|
-
return
|
|
780
|
+
group(...r) {
|
|
781
|
+
return e.print("group", ...r);
|
|
783
782
|
},
|
|
784
783
|
groupEnd() {
|
|
785
|
-
|
|
786
|
-
console.groupEnd();
|
|
787
|
-
}
|
|
788
|
-
return _logger;
|
|
784
|
+
return t === "development" && console.groupEnd(), e;
|
|
789
785
|
}
|
|
790
786
|
};
|
|
791
|
-
return
|
|
787
|
+
return e;
|
|
792
788
|
}
|
|
793
|
-
const
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
const
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
existingObject.next({
|
|
839
|
-
...existingObject.getValue(),
|
|
840
|
-
...value(existingObject.getValue())
|
|
841
|
-
});
|
|
842
|
-
} else {
|
|
843
|
-
existingObject.next({ ...existingObject.getValue(), ...value });
|
|
844
|
-
}
|
|
845
|
-
store$.next(store);
|
|
846
|
-
};
|
|
847
|
-
const updateMany = (value, predicate = () => true) => {
|
|
848
|
-
store.forEach((oldValue$) => {
|
|
849
|
-
const oldValue = oldValue$.getValue();
|
|
850
|
-
if (predicate(oldValue)) {
|
|
851
|
-
oldValue$.next({ ...oldValue, ...value });
|
|
852
|
-
}
|
|
853
|
-
});
|
|
854
|
-
store$.next(store);
|
|
855
|
-
};
|
|
856
|
-
const deleteValue = (key) => {
|
|
857
|
-
store.delete(key);
|
|
858
|
-
store$.next(store);
|
|
859
|
-
};
|
|
860
|
-
const addRunner = (key, stream) => {
|
|
861
|
-
updateValue(key, (old) => ({
|
|
862
|
-
...old,
|
|
863
|
-
runners: [...old.runners, stream]
|
|
789
|
+
const X = je("production"), Tt = X.namespace("store"), Mt = (t) => t.pipe(
|
|
790
|
+
p(
|
|
791
|
+
(e) => [...e.keys()].reduce((r, n) => {
|
|
792
|
+
var s;
|
|
793
|
+
return r[n] = (s = e.get(n)) == null ? void 0 : s.getValue(), r;
|
|
794
|
+
}, {})
|
|
795
|
+
),
|
|
796
|
+
R(T)
|
|
797
|
+
).subscribe((e) => {
|
|
798
|
+
Tt.log("store", "update", e);
|
|
799
|
+
}), It = () => {
|
|
800
|
+
const t = /* @__PURE__ */ new Map(), e = new I(t), r = new F(), n = new F(), s = () => {
|
|
801
|
+
e.next(t);
|
|
802
|
+
}, i = (c, o) => {
|
|
803
|
+
t.set(c, new I(o)), s();
|
|
804
|
+
}, u = (c) => {
|
|
805
|
+
var o;
|
|
806
|
+
return (o = t.get(c)) == null ? void 0 : o.getValue();
|
|
807
|
+
}, l = (c) => e.pipe(
|
|
808
|
+
p(() => t.get(c)),
|
|
809
|
+
$(G),
|
|
810
|
+
p((o) => o.getValue()),
|
|
811
|
+
R(T)
|
|
812
|
+
), f = (c, o) => {
|
|
813
|
+
const m = t.get(c);
|
|
814
|
+
m && (typeof o == "function" ? m.next({
|
|
815
|
+
...m.getValue(),
|
|
816
|
+
...o(m.getValue())
|
|
817
|
+
}) : m.next({ ...m.getValue(), ...o }), e.next(t));
|
|
818
|
+
}, d = (c, o = () => !0) => {
|
|
819
|
+
t.forEach((m) => {
|
|
820
|
+
const C = m.getValue();
|
|
821
|
+
o(C) && m.next({ ...C, ...c });
|
|
822
|
+
}), e.next(t);
|
|
823
|
+
}, h = (c) => {
|
|
824
|
+
t.delete(c), e.next(t);
|
|
825
|
+
}, g = (c, o) => (f(c, (m) => ({
|
|
826
|
+
...m,
|
|
827
|
+
runners: [...m.runners, o]
|
|
828
|
+
})), () => {
|
|
829
|
+
var C;
|
|
830
|
+
const m = ((C = t.get(c)) == null ? void 0 : C.getValue().runners.filter((b) => b !== o)) ?? [];
|
|
831
|
+
f(c, (b) => ({
|
|
832
|
+
...b,
|
|
833
|
+
runners: m
|
|
864
834
|
}));
|
|
835
|
+
}), a = () => {
|
|
836
|
+
const c = Mt(e);
|
|
865
837
|
return () => {
|
|
866
|
-
|
|
867
|
-
const newListeners = ((_a = store.get(key)) == null ? void 0 : _a.getValue().runners.filter((reference) => reference !== stream)) ?? [];
|
|
868
|
-
updateValue(key, (old) => ({
|
|
869
|
-
...old,
|
|
870
|
-
runners: newListeners
|
|
871
|
-
}));
|
|
872
|
-
};
|
|
873
|
-
};
|
|
874
|
-
const start = () => {
|
|
875
|
-
const debugger$ = createDebugger(store$);
|
|
876
|
-
return () => {
|
|
877
|
-
debugger$.unsubscribe();
|
|
838
|
+
c.unsubscribe();
|
|
878
839
|
};
|
|
879
840
|
};
|
|
880
841
|
return {
|
|
881
|
-
set:
|
|
882
|
-
get:
|
|
883
|
-
get$:
|
|
884
|
-
delete:
|
|
885
|
-
update:
|
|
886
|
-
keys: () =>
|
|
887
|
-
updateMany,
|
|
888
|
-
addRunner,
|
|
889
|
-
store
|
|
890
|
-
queryEvent$:
|
|
891
|
-
dispatchQueryEvent: (
|
|
892
|
-
|
|
842
|
+
set: i,
|
|
843
|
+
get: u,
|
|
844
|
+
get$: l,
|
|
845
|
+
delete: h,
|
|
846
|
+
update: f,
|
|
847
|
+
keys: () => t.keys(),
|
|
848
|
+
updateMany: d,
|
|
849
|
+
addRunner: g,
|
|
850
|
+
store$: e,
|
|
851
|
+
queryEvent$: r.asObservable(),
|
|
852
|
+
dispatchQueryEvent: (c) => {
|
|
853
|
+
r.next(c);
|
|
893
854
|
},
|
|
894
|
-
queryTrigger$:
|
|
895
|
-
dispatchQueryTrigger: (
|
|
896
|
-
|
|
855
|
+
queryTrigger$: n.asObservable(),
|
|
856
|
+
dispatchQueryTrigger: (c) => {
|
|
857
|
+
n.next(c);
|
|
897
858
|
},
|
|
898
|
-
size: () =>
|
|
899
|
-
start
|
|
859
|
+
size: () => t.size,
|
|
860
|
+
start: a
|
|
900
861
|
};
|
|
901
|
-
}
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
key
|
|
862
|
+
}, Qt = ({
|
|
863
|
+
options$: t,
|
|
864
|
+
queryStore: e,
|
|
865
|
+
key: r
|
|
906
866
|
}) => {
|
|
907
|
-
const
|
|
908
|
-
|
|
909
|
-
|
|
867
|
+
const s = t.pipe(
|
|
868
|
+
p(({ enabled: i = !0 }) => i),
|
|
869
|
+
R()
|
|
870
|
+
).pipe(
|
|
871
|
+
B(1),
|
|
872
|
+
$((i) => i)
|
|
910
873
|
);
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
return merge(
|
|
916
|
-
queryStore.queryTrigger$.pipe(
|
|
917
|
-
filter((event) => key === event.key),
|
|
918
|
-
map(({ trigger: trigger2 }) => trigger2)
|
|
874
|
+
return O(
|
|
875
|
+
e.queryTrigger$.pipe(
|
|
876
|
+
$((i) => r === i.key),
|
|
877
|
+
p(({ trigger: i }) => i)
|
|
919
878
|
),
|
|
920
|
-
|
|
921
|
-
|
|
879
|
+
s.pipe(
|
|
880
|
+
p(() => ({
|
|
922
881
|
type: "enabled",
|
|
923
|
-
ignoreStale:
|
|
882
|
+
ignoreStale: !1
|
|
924
883
|
}))
|
|
925
884
|
)
|
|
926
885
|
);
|
|
927
|
-
}
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
const deleteFromStore = () => {
|
|
938
|
-
var _a2;
|
|
939
|
-
if (((_a2 = queryStore.get(key)) == null ? void 0 : _a2.deduplication_fn) === sourceToDeduplicate) {
|
|
940
|
-
queryStore.update(key, {
|
|
941
|
-
deduplication_fn: void 0
|
|
942
|
-
});
|
|
943
|
-
}
|
|
944
|
-
};
|
|
945
|
-
sourceToDeduplicate = source.pipe(
|
|
946
|
-
/**
|
|
947
|
-
* Ideally we would want to remove the query from the store only on finalize,
|
|
948
|
-
* which means whenever the query complete or error. Unfortunately finalize is
|
|
949
|
-
* triggered after a new stream arrive which create a concurrency issue.
|
|
950
|
-
* tap is triggered correctly synchronously and before a new query arrive.
|
|
951
|
-
*/
|
|
952
|
-
tap({
|
|
953
|
-
error: deleteFromStore,
|
|
954
|
-
complete: deleteFromStore
|
|
955
|
-
}),
|
|
956
|
-
/**
|
|
957
|
-
* Because tap is not called on unsubscription we still need to handle the case.
|
|
958
|
-
*/
|
|
959
|
-
finalize(deleteFromStore),
|
|
960
|
-
shareReplay({
|
|
961
|
-
refCount: true,
|
|
962
|
-
bufferSize: 1
|
|
963
|
-
})
|
|
964
|
-
);
|
|
965
|
-
queryStore.update(key, {
|
|
966
|
-
deduplication_fn: sourceToDeduplicate
|
|
886
|
+
}, Ft = (t, e) => (r) => t === N([]) ? r : se(() => {
|
|
887
|
+
var u;
|
|
888
|
+
const n = (u = e.get(t)) == null ? void 0 : u.deduplication_fn;
|
|
889
|
+
if (n)
|
|
890
|
+
return n;
|
|
891
|
+
let s;
|
|
892
|
+
const i = () => {
|
|
893
|
+
var l;
|
|
894
|
+
((l = e.get(t)) == null ? void 0 : l.deduplication_fn) === s && e.update(t, {
|
|
895
|
+
deduplication_fn: void 0
|
|
967
896
|
});
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
}
|
|
980
|
-
|
|
897
|
+
};
|
|
898
|
+
return s = r.pipe(
|
|
899
|
+
/**
|
|
900
|
+
* Ideally we would want to remove the query from the store only on finalize,
|
|
901
|
+
* which means whenever the query complete or error. Unfortunately finalize is
|
|
902
|
+
* triggered after a new stream arrive which create a concurrency issue.
|
|
903
|
+
* tap is triggered correctly synchronously and before a new query arrive.
|
|
904
|
+
*/
|
|
905
|
+
x({
|
|
906
|
+
error: i,
|
|
907
|
+
complete: i
|
|
908
|
+
}),
|
|
909
|
+
/**
|
|
910
|
+
* Because tap is not called on unsubscription we still need to handle the case.
|
|
911
|
+
*/
|
|
912
|
+
ae(i),
|
|
913
|
+
$e({
|
|
914
|
+
refCount: !0,
|
|
915
|
+
bufferSize: 1
|
|
916
|
+
})
|
|
917
|
+
), e.update(t, {
|
|
918
|
+
deduplication_fn: s
|
|
919
|
+
}), s;
|
|
920
|
+
}), _t = (t) => (e) => e.pipe(
|
|
921
|
+
D(t),
|
|
922
|
+
p(([r, n]) => {
|
|
923
|
+
var s, i;
|
|
924
|
+
return r.error ? (s = n.onError) == null || s.call(n, r.error) : (i = n.onSuccess) == null || i.call(n, r), r;
|
|
981
925
|
})
|
|
982
|
-
)
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
cache_fnResult: { result }
|
|
926
|
+
), Pt = ({
|
|
927
|
+
queryStore: t,
|
|
928
|
+
serializedKey: e,
|
|
929
|
+
options: r
|
|
930
|
+
}) => (n) => n.pipe(
|
|
931
|
+
x(({ data: s }) => {
|
|
932
|
+
if (s != null && s.result) {
|
|
933
|
+
const i = s == null ? void 0 : s.result;
|
|
934
|
+
t.update(e, {
|
|
935
|
+
...r.cacheTime !== 0 && {
|
|
936
|
+
cache_fnResult: { result: i }
|
|
994
937
|
}
|
|
995
938
|
});
|
|
996
939
|
}
|
|
997
940
|
})
|
|
998
|
-
)
|
|
999
|
-
|
|
1000
|
-
options
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
trigger
|
|
1006
|
-
trigger$
|
|
941
|
+
), Nt = ({
|
|
942
|
+
options$: t,
|
|
943
|
+
options: e,
|
|
944
|
+
fn: r,
|
|
945
|
+
queryStore: n,
|
|
946
|
+
serializedKey: s,
|
|
947
|
+
trigger: i,
|
|
948
|
+
trigger$: u
|
|
1007
949
|
}) => {
|
|
1008
|
-
const
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
)
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
tap(() => {
|
|
1024
|
-
queryStore.dispatchQueryEvent({
|
|
1025
|
-
key: serializedKey,
|
|
950
|
+
const f = t.pipe(
|
|
951
|
+
p(({ enabled: b = !0 }) => b),
|
|
952
|
+
R()
|
|
953
|
+
).pipe(
|
|
954
|
+
R(),
|
|
955
|
+
$((b) => !b)
|
|
956
|
+
), h = se(() => {
|
|
957
|
+
const b = typeof r == "function" ? r() : r;
|
|
958
|
+
return ne(b);
|
|
959
|
+
}).pipe(
|
|
960
|
+
Ue(e),
|
|
961
|
+
Ft(s, n),
|
|
962
|
+
x(() => {
|
|
963
|
+
n.dispatchQueryEvent({
|
|
964
|
+
key: s,
|
|
1026
965
|
type: "fetchSuccess"
|
|
1027
|
-
})
|
|
1028
|
-
queryStore.update(serializedKey, {
|
|
966
|
+
}), n.update(s, {
|
|
1029
967
|
lastFetchedAt: (/* @__PURE__ */ new Date()).getTime()
|
|
1030
968
|
});
|
|
1031
969
|
}),
|
|
1032
|
-
|
|
970
|
+
p((b) => ({
|
|
1033
971
|
status: "success",
|
|
1034
|
-
data: { result },
|
|
972
|
+
data: { result: b },
|
|
1035
973
|
error: void 0
|
|
1036
974
|
})),
|
|
1037
|
-
|
|
975
|
+
tt({
|
|
1038
976
|
fetchStatus: "idle"
|
|
1039
977
|
}),
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
);
|
|
1055
|
-
const newCache$ = queryStore.queryEvent$.pipe(
|
|
1056
|
-
filter(
|
|
1057
|
-
(event) => event.key === serializedKey && event.type === "queryDataSet"
|
|
978
|
+
A((b) => (n.dispatchQueryEvent({
|
|
979
|
+
key: s,
|
|
980
|
+
type: "fetchError"
|
|
981
|
+
}), S({
|
|
982
|
+
fetchStatus: "idle",
|
|
983
|
+
status: "error",
|
|
984
|
+
data: void 0,
|
|
985
|
+
error: b
|
|
986
|
+
}))),
|
|
987
|
+
_t(t),
|
|
988
|
+
Pt({ serializedKey: s, options: e, queryStore: n })
|
|
989
|
+
), g = n.queryEvent$.pipe(
|
|
990
|
+
$(
|
|
991
|
+
(b) => b.key === s && b.type === "queryDataSet"
|
|
1058
992
|
),
|
|
1059
|
-
|
|
1060
|
-
var
|
|
1061
|
-
return (
|
|
993
|
+
p(() => {
|
|
994
|
+
var b, j;
|
|
995
|
+
return (j = (b = n.get(s)) == null ? void 0 : b.cache_fnResult) == null ? void 0 : j.result;
|
|
1062
996
|
}),
|
|
1063
|
-
|
|
1064
|
-
|
|
997
|
+
$(G),
|
|
998
|
+
p((b) => ({
|
|
1065
999
|
status: "success",
|
|
1066
|
-
data: { result }
|
|
1000
|
+
data: { result: b }
|
|
1067
1001
|
})),
|
|
1068
1002
|
/**
|
|
1069
1003
|
* @important
|
|
@@ -1071,815 +1005,574 @@ const createQueryFetch = ({
|
|
|
1071
1005
|
* For example if user set query data inside onSuccess callback, we simulate
|
|
1072
1006
|
* a small delay to ensure it happens after.
|
|
1073
1007
|
*/
|
|
1074
|
-
|
|
1075
|
-
)
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
map(() => ({
|
|
1008
|
+
rt(1)
|
|
1009
|
+
), a = O(
|
|
1010
|
+
f.pipe(
|
|
1011
|
+
be(1),
|
|
1012
|
+
p(() => ({
|
|
1080
1013
|
fetchStatus: "idle"
|
|
1081
1014
|
}))
|
|
1082
1015
|
),
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
).pipe(
|
|
1087
|
-
|
|
1088
|
-
).pipe(
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
);
|
|
1111
|
-
}
|
|
1112
|
-
}
|
|
1113
|
-
return execution$;
|
|
1114
|
-
};
|
|
1115
|
-
const compareKeys = (keyA, keyB, { exact = false } = {}) => {
|
|
1116
|
-
if (exact) {
|
|
1117
|
-
return serializeKey(keyA) === serializeKey(keyB);
|
|
1118
|
-
}
|
|
1119
|
-
return keyA.reduce((acc, value, index) => {
|
|
1120
|
-
if (!acc)
|
|
1121
|
-
return false;
|
|
1122
|
-
if (value === void 0) {
|
|
1123
|
-
const hasNextItemInLineNotUndefined = keyA.slice(index, keyA.length - 1).some((item) => item !== void 0);
|
|
1124
|
-
if (!hasNextItemInLineNotUndefined) {
|
|
1125
|
-
return true;
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1128
|
-
return serializeObject(value) === serializeObject(keyB[index]);
|
|
1129
|
-
}, true);
|
|
1130
|
-
};
|
|
1131
|
-
const logger$2 = Logger.namespace("invalidation");
|
|
1132
|
-
const createInvalidationClient = ({
|
|
1133
|
-
queryStore
|
|
1134
|
-
}) => {
|
|
1135
|
-
const invalidateQueries = ({
|
|
1136
|
-
queryKey,
|
|
1137
|
-
exact = false,
|
|
1138
|
-
predicate
|
|
1016
|
+
O(
|
|
1017
|
+
S({ fetchStatus: "fetching", error: void 0 }),
|
|
1018
|
+
h
|
|
1019
|
+
).pipe(P(f)),
|
|
1020
|
+
g
|
|
1021
|
+
).pipe(P(u)), c = n.get(s), o = c == null ? void 0 : c.cache_fnResult, m = !!o, C = i.type === "refetch" && i.ignoreStale;
|
|
1022
|
+
return m ? !(c != null && c.isStale) && !C ? S({
|
|
1023
|
+
fetchStatus: "idle",
|
|
1024
|
+
status: "success",
|
|
1025
|
+
data: { result: o.result },
|
|
1026
|
+
error: void 0
|
|
1027
|
+
}) : O(
|
|
1028
|
+
S({
|
|
1029
|
+
fetchStatus: "fetching",
|
|
1030
|
+
status: "success",
|
|
1031
|
+
data: { result: o.result },
|
|
1032
|
+
error: void 0
|
|
1033
|
+
}),
|
|
1034
|
+
a
|
|
1035
|
+
) : a;
|
|
1036
|
+
}, q = X.namespace("invalidation"), kt = ({
|
|
1037
|
+
queryStore: t
|
|
1038
|
+
}) => ({
|
|
1039
|
+
invalidateQueries: ({
|
|
1040
|
+
queryKey: r,
|
|
1041
|
+
exact: n = !1,
|
|
1042
|
+
predicate: s
|
|
1139
1043
|
} = {}) => {
|
|
1140
|
-
let
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
});
|
|
1150
|
-
} else if (predicate) {
|
|
1151
|
-
queryStore.updateMany({ isStale: true }, (entry) => {
|
|
1152
|
-
const isValid = predicate(entry);
|
|
1153
|
-
if (isValid) {
|
|
1154
|
-
keysToRefetch.push(serializeKey(entry.queryKey));
|
|
1155
|
-
}
|
|
1156
|
-
return isValid;
|
|
1157
|
-
});
|
|
1158
|
-
} else {
|
|
1159
|
-
logger$2.log(`Invalidation requested for all queries`);
|
|
1160
|
-
queryStore.updateMany({ isStale: true });
|
|
1161
|
-
keysToRefetch = Array.from(queryStore.keys());
|
|
1162
|
-
}
|
|
1163
|
-
keysToRefetch.forEach((key) => {
|
|
1164
|
-
queryStore.update(key, {
|
|
1044
|
+
let i = [];
|
|
1045
|
+
r ? (q.log("invalidation requested for", r), t.updateMany({ isStale: !0 }, (u) => {
|
|
1046
|
+
const l = te(r, u.queryKey, { exact: n });
|
|
1047
|
+
return l && i.push(N(u.queryKey)), l;
|
|
1048
|
+
})) : s ? t.updateMany({ isStale: !0 }, (u) => {
|
|
1049
|
+
const l = s(u);
|
|
1050
|
+
return l && i.push(N(u.queryKey)), l;
|
|
1051
|
+
}) : (q.log("Invalidation requested for all queries"), t.updateMany({ isStale: !0 }), i = Array.from(t.keys())), i.forEach((u) => {
|
|
1052
|
+
t.update(u, {
|
|
1165
1053
|
deduplication_fn: void 0
|
|
1166
|
-
})
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
trigger: { ignoreStale: true, type: "refetch" }
|
|
1054
|
+
}), t.dispatchQueryTrigger({
|
|
1055
|
+
key: u,
|
|
1056
|
+
trigger: { ignoreStale: !0, type: "refetch" }
|
|
1170
1057
|
});
|
|
1171
1058
|
});
|
|
1172
|
-
}
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
}
|
|
1177
|
-
const
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
sharedStream,
|
|
1184
|
-
sharedStream.pipe(
|
|
1185
|
-
filter(
|
|
1186
|
-
(result) => !!result.data && result.fetchStatus !== "fetching"
|
|
1059
|
+
}
|
|
1060
|
+
}), Lt = (t) => ({
|
|
1061
|
+
pipeQueryResult: ({
|
|
1062
|
+
options$: n
|
|
1063
|
+
}) => (s) => {
|
|
1064
|
+
const i = s.pipe(J());
|
|
1065
|
+
return O(
|
|
1066
|
+
i,
|
|
1067
|
+
i.pipe(
|
|
1068
|
+
$(
|
|
1069
|
+
(u) => !!u.data && u.fetchStatus !== "fetching"
|
|
1187
1070
|
),
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
switchMap(() => EMPTY)
|
|
1200
|
-
);
|
|
1201
|
-
}
|
|
1202
|
-
return EMPTY;
|
|
1203
|
-
})
|
|
1071
|
+
R((u, l) => u.data === l.data),
|
|
1072
|
+
D(n),
|
|
1073
|
+
p(([, { refetchInterval: u }]) => u),
|
|
1074
|
+
$(G),
|
|
1075
|
+
w((u) => typeof u == "number" ? ie(u).pipe(
|
|
1076
|
+
p(() => ({
|
|
1077
|
+
type: "refetch",
|
|
1078
|
+
ignoreStale: !0
|
|
1079
|
+
})),
|
|
1080
|
+
w(() => M)
|
|
1081
|
+
) : M)
|
|
1204
1082
|
)
|
|
1205
1083
|
);
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1208
|
-
}
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
const
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
const newKeys = difference(currentKeys, previousKeys);
|
|
1221
|
-
return merge(
|
|
1222
|
-
...newKeys.map((key) => {
|
|
1223
|
-
const deleted$ = store.store$.pipe(
|
|
1224
|
-
map(() => store.get(key)),
|
|
1225
|
-
filter((item) => item === void 0)
|
|
1084
|
+
},
|
|
1085
|
+
refetchQueries: (n) => {
|
|
1086
|
+
}
|
|
1087
|
+
}), Ut = (t, e) => t.filter((r) => !e.includes(r)), jt = (t, e) => t.store$.pipe(
|
|
1088
|
+
p((r) => [...r.keys()]),
|
|
1089
|
+
Ie([]),
|
|
1090
|
+
oe(),
|
|
1091
|
+
_(([r, n]) => {
|
|
1092
|
+
const s = Ut(n, r);
|
|
1093
|
+
return O(
|
|
1094
|
+
...s.map((i) => {
|
|
1095
|
+
const u = t.store$.pipe(
|
|
1096
|
+
p(() => t.get(i)),
|
|
1097
|
+
$((l) => l === void 0)
|
|
1226
1098
|
);
|
|
1227
|
-
return
|
|
1228
|
-
|
|
1099
|
+
return O(Qe, S(i)).pipe(
|
|
1100
|
+
x(() => {
|
|
1229
1101
|
}),
|
|
1230
|
-
|
|
1231
|
-
|
|
1102
|
+
e,
|
|
1103
|
+
ae(() => {
|
|
1232
1104
|
}),
|
|
1233
|
-
|
|
1105
|
+
P(u)
|
|
1234
1106
|
);
|
|
1235
1107
|
})
|
|
1236
1108
|
);
|
|
1237
1109
|
})
|
|
1238
|
-
)
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
acc.lowestStaleTime ?? Infinity
|
|
1252
|
-
)
|
|
1253
|
-
};
|
|
1254
|
-
},
|
|
1110
|
+
), Ae = (t) => t.pipe(
|
|
1111
|
+
w((e) => Fe(e.runners)),
|
|
1112
|
+
p((e) => e.map(({ options: r }) => r))
|
|
1113
|
+
), At = (t) => t.pipe(
|
|
1114
|
+
p(
|
|
1115
|
+
(e) => e.reduce(
|
|
1116
|
+
(r, n) => ({
|
|
1117
|
+
...r,
|
|
1118
|
+
lowestStaleTime: n.staleTime === void 0 ? r.lowestStaleTime : Math.min(
|
|
1119
|
+
n.staleTime ?? 1 / 0,
|
|
1120
|
+
r.lowestStaleTime ?? 1 / 0
|
|
1121
|
+
)
|
|
1122
|
+
}),
|
|
1255
1123
|
{ lowestStaleTime: void 0 }
|
|
1256
1124
|
)
|
|
1257
1125
|
),
|
|
1258
|
-
|
|
1259
|
-
)
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
(event) => event.key === key && (event.type === "fetchError" || event.type === "fetchSuccess")
|
|
1126
|
+
R(T)
|
|
1127
|
+
), Kt = (t) => (e) => e.pipe(
|
|
1128
|
+
$(
|
|
1129
|
+
(r) => r.key === t && (r.type === "fetchError" || r.type === "fetchSuccess")
|
|
1263
1130
|
)
|
|
1264
|
-
)
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
queryStore.update(key, { isStale: true });
|
|
1283
|
-
} else if ((_a = queryStore.get(key)) == null ? void 0 : _a.isStale) {
|
|
1284
|
-
logger$2.log(key, "marked non stale", {
|
|
1285
|
-
staleTime: lowestStaleTime
|
|
1286
|
-
});
|
|
1287
|
-
queryStore.update(key, { isStale: false });
|
|
1288
|
-
}
|
|
1131
|
+
), zt = ({
|
|
1132
|
+
queryStore: t
|
|
1133
|
+
}) => (e) => e.pipe(
|
|
1134
|
+
w((r) => {
|
|
1135
|
+
const n = t.get$(r);
|
|
1136
|
+
return t.queryEvent$.pipe(
|
|
1137
|
+
Kt(r),
|
|
1138
|
+
w(
|
|
1139
|
+
() => n.pipe(
|
|
1140
|
+
Ae,
|
|
1141
|
+
At,
|
|
1142
|
+
x(({ lowestStaleTime: s = 0 }) => {
|
|
1143
|
+
var i;
|
|
1144
|
+
s === 0 ? (q.log(r, "marked as stale!", {
|
|
1145
|
+
staleTime: s
|
|
1146
|
+
}), t.update(r, { isStale: !0 })) : (i = t.get(r)) != null && i.isStale && (q.log(r, "marked non stale", {
|
|
1147
|
+
staleTime: s
|
|
1148
|
+
}), t.update(r, { isStale: !1 }));
|
|
1289
1149
|
}),
|
|
1290
|
-
|
|
1291
|
-
({ lowestStaleTime }) =>
|
|
1150
|
+
$(
|
|
1151
|
+
({ lowestStaleTime: s }) => s !== 1 / 0 && s !== 0
|
|
1292
1152
|
),
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
var
|
|
1296
|
-
|
|
1297
|
-
logger$2.log(key, "marked as stale!");
|
|
1298
|
-
queryStore.update(key, { isStale: true });
|
|
1299
|
-
}
|
|
1153
|
+
w(({ lowestStaleTime: s = 0 }) => ie(s)),
|
|
1154
|
+
x(() => {
|
|
1155
|
+
var s;
|
|
1156
|
+
(s = t.get(r)) != null && s.isStale || (q.log(r, "marked as stale!"), t.update(r, { isStale: !0 }));
|
|
1300
1157
|
})
|
|
1301
1158
|
)
|
|
1302
1159
|
),
|
|
1303
|
-
|
|
1160
|
+
p(() => r)
|
|
1304
1161
|
);
|
|
1305
1162
|
})
|
|
1306
|
-
)
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
lowestCacheTime
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
)
|
|
1317
|
-
};
|
|
1318
|
-
},
|
|
1163
|
+
), Jt = (t) => t.pipe(
|
|
1164
|
+
p(
|
|
1165
|
+
(e) => e.reduce(
|
|
1166
|
+
(r, n) => ({
|
|
1167
|
+
...r,
|
|
1168
|
+
lowestCacheTime: n.cacheTime === void 0 ? r.lowestCacheTime : Math.min(
|
|
1169
|
+
n.cacheTime ?? 1 / 0,
|
|
1170
|
+
r.lowestCacheTime ?? 1 / 0
|
|
1171
|
+
)
|
|
1172
|
+
}),
|
|
1319
1173
|
{ lowestCacheTime: void 0 }
|
|
1320
1174
|
)
|
|
1321
1175
|
),
|
|
1322
|
-
|
|
1323
|
-
)
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
mapOptionsToOption,
|
|
1339
|
-
switchMap(
|
|
1176
|
+
R(T)
|
|
1177
|
+
), Wt = (t) => t.pipe(
|
|
1178
|
+
p((e) => e.cache_fnResult),
|
|
1179
|
+
R(T)
|
|
1180
|
+
), Yt = ({
|
|
1181
|
+
queryStore: t
|
|
1182
|
+
}) => (e) => e.pipe(
|
|
1183
|
+
w((r) => {
|
|
1184
|
+
const n = t.get$(r);
|
|
1185
|
+
return n.pipe(
|
|
1186
|
+
Wt,
|
|
1187
|
+
w(
|
|
1188
|
+
() => n.pipe(
|
|
1189
|
+
Ae,
|
|
1190
|
+
Jt,
|
|
1191
|
+
w(
|
|
1340
1192
|
({
|
|
1341
|
-
lowestCacheTime = 5 * 60 * 1e3
|
|
1193
|
+
lowestCacheTime: i = 5 * 60 * 1e3
|
|
1342
1194
|
/* 5mn */
|
|
1343
|
-
}) =>
|
|
1344
|
-
|
|
1345
|
-
|
|
1195
|
+
}) => ie(i).pipe(
|
|
1196
|
+
x(() => {
|
|
1197
|
+
t.update(r, { cache_fnResult: void 0 });
|
|
1346
1198
|
})
|
|
1347
1199
|
)
|
|
1348
1200
|
)
|
|
1349
1201
|
)
|
|
1350
1202
|
)
|
|
1351
|
-
);
|
|
1352
|
-
return invalidateCache$.pipe(map(() => key));
|
|
1203
|
+
).pipe(p(() => r));
|
|
1353
1204
|
})
|
|
1354
|
-
)
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
})
|
|
1371
|
-
);
|
|
1372
|
-
const getInitialQueryEntity = ({ key }) => ({
|
|
1373
|
-
isStale: true,
|
|
1374
|
-
queryKey: key,
|
|
1205
|
+
), Gt = ({
|
|
1206
|
+
queryStore: t
|
|
1207
|
+
}) => (e) => e.pipe(
|
|
1208
|
+
w((r) => t.get$(r).pipe(
|
|
1209
|
+
$((s) => !s.cache_fnResult),
|
|
1210
|
+
p((s) => s.runners.length > 0),
|
|
1211
|
+
oe(),
|
|
1212
|
+
$(([s, i]) => s && !i),
|
|
1213
|
+
x(() => {
|
|
1214
|
+
t.delete(r);
|
|
1215
|
+
}),
|
|
1216
|
+
p(() => r)
|
|
1217
|
+
))
|
|
1218
|
+
), Ke = ({ key: t }) => ({
|
|
1219
|
+
isStale: !0,
|
|
1220
|
+
queryKey: t,
|
|
1375
1221
|
runners: []
|
|
1376
|
-
})
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
if (trigger2.type !== "initial")
|
|
1389
|
-
return [trigger2, void 0];
|
|
1390
|
-
if (!queryStore.get(serializedKey)) {
|
|
1391
|
-
queryStore.set(serializedKey, getInitialQueryEntity({ key }));
|
|
1392
|
-
} else {
|
|
1393
|
-
queryStore.update(serializedKey, {
|
|
1394
|
-
queryKey: key,
|
|
1395
|
-
...options.markStale && {
|
|
1396
|
-
isStale: true
|
|
1397
|
-
}
|
|
1398
|
-
});
|
|
1222
|
+
}), Ht = ({
|
|
1223
|
+
queryStore: t,
|
|
1224
|
+
serializedKey: e,
|
|
1225
|
+
runner$: r,
|
|
1226
|
+
options$: n,
|
|
1227
|
+
key: s
|
|
1228
|
+
}) => (i) => i.pipe(
|
|
1229
|
+
D(n),
|
|
1230
|
+
p(([u, l]) => s.length === 0 ? [u, void 0] : u.type !== "initial" ? [u, void 0] : (t.get(e) ? t.update(e, {
|
|
1231
|
+
queryKey: s,
|
|
1232
|
+
...l.markStale && {
|
|
1233
|
+
isStale: !0
|
|
1399
1234
|
}
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
const setQueryData = ({
|
|
1408
|
-
queryKey,
|
|
1409
|
-
updater
|
|
1235
|
+
}) : t.set(e, Ke({ key: s })), [u, t.addRunner(e, r)]))
|
|
1236
|
+
), Dt = X.namespace("cache"), Xt = ({
|
|
1237
|
+
queryStore: t
|
|
1238
|
+
}) => ({
|
|
1239
|
+
setQueryData: ({
|
|
1240
|
+
queryKey: r,
|
|
1241
|
+
updater: n
|
|
1410
1242
|
}) => {
|
|
1411
|
-
const
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
...entity,
|
|
1424
|
-
cache_fnResult: {
|
|
1425
|
-
result: callableUpdater(
|
|
1426
|
-
(_a = entity.cache_fnResult) == null ? void 0 : _a.result
|
|
1427
|
-
)
|
|
1428
|
-
}
|
|
1429
|
-
};
|
|
1430
|
-
}
|
|
1431
|
-
return {
|
|
1432
|
-
...entity,
|
|
1243
|
+
const s = N(r);
|
|
1244
|
+
r.length !== 0 && (Dt.log("set cache for query", N), t.get(s) || t.set(s, Ke({ key: r })), t.update(s, (i) => {
|
|
1245
|
+
var u;
|
|
1246
|
+
return typeof n == "function" ? {
|
|
1247
|
+
...i,
|
|
1248
|
+
cache_fnResult: {
|
|
1249
|
+
result: n(
|
|
1250
|
+
(u = i.cache_fnResult) == null ? void 0 : u.result
|
|
1251
|
+
)
|
|
1252
|
+
}
|
|
1253
|
+
} : {
|
|
1254
|
+
...i,
|
|
1433
1255
|
cache_fnResult: {
|
|
1434
|
-
result:
|
|
1256
|
+
result: n
|
|
1435
1257
|
}
|
|
1436
1258
|
};
|
|
1437
|
-
})
|
|
1438
|
-
|
|
1439
|
-
key: serializedKey,
|
|
1259
|
+
}), t.dispatchQueryEvent({
|
|
1260
|
+
key: s,
|
|
1440
1261
|
type: "queryDataSet"
|
|
1441
|
-
});
|
|
1442
|
-
}
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
};
|
|
1467
|
-
const dispatchExternalRefetchToAllQueries = ({
|
|
1468
|
-
queryStore,
|
|
1469
|
-
serializedKey
|
|
1470
|
-
}) => (stream) => stream.pipe(
|
|
1471
|
-
tap((trigger2) => {
|
|
1472
|
-
if (trigger2.type === "refetch") {
|
|
1473
|
-
queryStore.update(serializedKey, {
|
|
1474
|
-
deduplication_fn: void 0
|
|
1475
|
-
});
|
|
1476
|
-
queryStore.dispatchQueryTrigger({
|
|
1477
|
-
key: serializedKey,
|
|
1478
|
-
trigger: trigger2
|
|
1479
|
-
});
|
|
1480
|
-
}
|
|
1262
|
+
}));
|
|
1263
|
+
}
|
|
1264
|
+
}), Zt = X.namespace("refetch"), qt = ({
|
|
1265
|
+
key: t,
|
|
1266
|
+
serializedKey: e,
|
|
1267
|
+
queryStore: r
|
|
1268
|
+
}) => (n) => n.pipe(
|
|
1269
|
+
x((s) => {
|
|
1270
|
+
if (s.type !== "refetch")
|
|
1271
|
+
return;
|
|
1272
|
+
const i = r.get(e);
|
|
1273
|
+
i && s.ignoreStale && !i.isStale && (Zt.log(t, "marked stale by trigger!"), r.update(e, {
|
|
1274
|
+
isStale: !0
|
|
1275
|
+
}));
|
|
1276
|
+
})
|
|
1277
|
+
), Bt = ({
|
|
1278
|
+
queryStore: t,
|
|
1279
|
+
serializedKey: e
|
|
1280
|
+
}) => (r) => r.pipe(
|
|
1281
|
+
x((n) => {
|
|
1282
|
+
n.type === "refetch" && (t.update(e, {
|
|
1283
|
+
deduplication_fn: void 0
|
|
1284
|
+
}), t.dispatchQueryTrigger({
|
|
1285
|
+
key: e,
|
|
1286
|
+
trigger: n
|
|
1287
|
+
}));
|
|
1481
1288
|
}),
|
|
1482
|
-
|
|
1483
|
-
)
|
|
1484
|
-
const
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
variables: void 0
|
|
1491
|
-
});
|
|
1492
|
-
const mergeResults = (stream$) => stream$.pipe(
|
|
1493
|
-
scan((acc, current) => {
|
|
1494
|
-
return {
|
|
1495
|
-
...acc,
|
|
1496
|
-
...current,
|
|
1497
|
-
data: current.data ?? acc.data,
|
|
1498
|
-
error: current.error ?? acc.error
|
|
1499
|
-
};
|
|
1500
|
-
}, getDefaultMutationState()),
|
|
1501
|
-
distinctUntilChanged(
|
|
1502
|
-
({ data: prevData, ...prev }, { data: currData, ...curr }) => shallowEqual(prev, curr) && shallowEqual(prevData, currData)
|
|
1503
|
-
)
|
|
1504
|
-
);
|
|
1505
|
-
const createMutationRunner = ({
|
|
1506
|
-
__queryFinalizeHook,
|
|
1507
|
-
__queryInitHook,
|
|
1508
|
-
__queryTriggerHook,
|
|
1509
|
-
mutationKey,
|
|
1510
|
-
mutationCache
|
|
1289
|
+
$((n) => n.type !== "refetch")
|
|
1290
|
+
), V = (t) => se(() => {
|
|
1291
|
+
const e = t();
|
|
1292
|
+
return e instanceof Promise ? ne(e) : e instanceof Me ? e : S(e);
|
|
1293
|
+
}), er = ({
|
|
1294
|
+
variables: t,
|
|
1295
|
+
state: e,
|
|
1296
|
+
options: r
|
|
1511
1297
|
}) => {
|
|
1512
|
-
const
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1298
|
+
const n = e.isPaused, s = async () => await Promise.reject(new Error("No mutationFn found")), i = r.mutationFn ?? s, l = Te(
|
|
1299
|
+
() => n,
|
|
1300
|
+
S(e.context),
|
|
1301
|
+
V(
|
|
1302
|
+
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
1303
|
+
() => {
|
|
1304
|
+
var a;
|
|
1305
|
+
return ((a = r.onMutate) == null ? void 0 : a.call(r, t)) ?? void 0;
|
|
1306
|
+
}
|
|
1307
|
+
)
|
|
1308
|
+
).pipe(J()), f = (a, c, o) => (console.error(a), V(
|
|
1309
|
+
() => {
|
|
1310
|
+
var C;
|
|
1311
|
+
return (C = r.onError) == null ? void 0 : C.call(r, a, t, c);
|
|
1521
1312
|
}
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1313
|
+
).pipe(
|
|
1314
|
+
A(() => S(a)),
|
|
1315
|
+
p(
|
|
1316
|
+
() => ({
|
|
1317
|
+
failureCount: o,
|
|
1318
|
+
error: a,
|
|
1319
|
+
failureReason: a,
|
|
1320
|
+
context: c,
|
|
1321
|
+
status: "error"
|
|
1322
|
+
})
|
|
1323
|
+
)
|
|
1324
|
+
)), d = l.pipe(
|
|
1325
|
+
w((a) => (typeof i == "function" ? (
|
|
1326
|
+
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
1327
|
+
V(() => i(t))
|
|
1328
|
+
) : i).pipe(
|
|
1329
|
+
p(
|
|
1330
|
+
(o) => ({
|
|
1331
|
+
result: {
|
|
1332
|
+
data: o
|
|
1333
|
+
},
|
|
1334
|
+
error: null,
|
|
1335
|
+
context: a
|
|
1336
|
+
})
|
|
1337
|
+
),
|
|
1338
|
+
Ue({
|
|
1339
|
+
...r,
|
|
1340
|
+
caughtError: (o, m) => S({
|
|
1341
|
+
failureCount: o,
|
|
1342
|
+
failureReason: m
|
|
1343
|
+
}),
|
|
1344
|
+
catchError: (o, m) => f(m, a, o).pipe(
|
|
1345
|
+
p((C) => ({
|
|
1346
|
+
...C,
|
|
1347
|
+
result: void 0
|
|
1348
|
+
}))
|
|
1349
|
+
)
|
|
1350
|
+
}),
|
|
1351
|
+
ve(
|
|
1352
|
+
({ result: o, error: m }) => (o == null ? void 0 : o.data) === void 0 && m === void 0,
|
|
1353
|
+
!0
|
|
1354
|
+
)
|
|
1355
|
+
))
|
|
1356
|
+
), h = S({
|
|
1357
|
+
...e,
|
|
1358
|
+
variables: t,
|
|
1359
|
+
status: "pending",
|
|
1360
|
+
isPaused: !1,
|
|
1361
|
+
failureCount: 0,
|
|
1362
|
+
failureReason: null,
|
|
1363
|
+
submittedAt: e.submittedAt ?? (/* @__PURE__ */ new Date()).getTime()
|
|
1364
|
+
});
|
|
1365
|
+
return O(
|
|
1366
|
+
h,
|
|
1367
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
1368
|
+
l.pipe(p((a) => ({ context: a }))),
|
|
1369
|
+
d.pipe(
|
|
1370
|
+
w(({ result: a, error: c, ...o }) => {
|
|
1371
|
+
if (!a && !c)
|
|
1372
|
+
return S({
|
|
1373
|
+
...o
|
|
1542
1374
|
});
|
|
1543
|
-
|
|
1544
|
-
|
|
1375
|
+
const m = c ? S(null) : V(
|
|
1376
|
+
() => {
|
|
1377
|
+
var v;
|
|
1378
|
+
return (v = r.onSuccess) == null ? void 0 : v.call(
|
|
1379
|
+
r,
|
|
1380
|
+
a == null ? void 0 : a.data,
|
|
1381
|
+
t,
|
|
1382
|
+
o.context
|
|
1383
|
+
);
|
|
1545
1384
|
}
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1385
|
+
), b = V(
|
|
1386
|
+
() => {
|
|
1387
|
+
var v;
|
|
1388
|
+
return (v = r.onSettled) == null ? void 0 : v.call(
|
|
1389
|
+
r,
|
|
1390
|
+
a == null ? void 0 : a.data,
|
|
1391
|
+
c,
|
|
1392
|
+
t,
|
|
1393
|
+
o.context
|
|
1394
|
+
);
|
|
1395
|
+
}
|
|
1396
|
+
).pipe(
|
|
1397
|
+
A((v) => a ? S(a) : S(v))
|
|
1398
|
+
);
|
|
1399
|
+
return ue(m, b).pipe(
|
|
1400
|
+
ce(),
|
|
1401
|
+
p(
|
|
1402
|
+
() => c ? {
|
|
1403
|
+
error: c,
|
|
1404
|
+
data: void 0,
|
|
1405
|
+
variables: t,
|
|
1406
|
+
...o
|
|
1407
|
+
} : {
|
|
1408
|
+
status: "success",
|
|
1409
|
+
error: c,
|
|
1410
|
+
data: a == null ? void 0 : a.data,
|
|
1411
|
+
variables: t,
|
|
1412
|
+
...o
|
|
1413
|
+
}
|
|
1414
|
+
),
|
|
1415
|
+
A(
|
|
1416
|
+
(v) => f(v, o.context, 0).pipe(
|
|
1417
|
+
p((E) => ({
|
|
1418
|
+
...E,
|
|
1419
|
+
data: void 0
|
|
1420
|
+
}))
|
|
1551
1421
|
)
|
|
1552
|
-
)
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
}
|
|
1567
|
-
return result;
|
|
1568
|
-
}),
|
|
1569
|
-
mergeResults
|
|
1570
|
-
);
|
|
1571
|
-
return result$;
|
|
1572
|
-
}),
|
|
1573
|
-
mergeResults,
|
|
1574
|
-
__queryTriggerHook ?? identity
|
|
1575
|
-
);
|
|
1576
|
-
}),
|
|
1577
|
-
__queryFinalizeHook ?? identity,
|
|
1578
|
-
shareReplay(1)
|
|
1422
|
+
)
|
|
1423
|
+
);
|
|
1424
|
+
})
|
|
1425
|
+
)
|
|
1426
|
+
).pipe(
|
|
1427
|
+
pe((a, c) => ({
|
|
1428
|
+
...a,
|
|
1429
|
+
...c,
|
|
1430
|
+
data: c.data ?? a.data,
|
|
1431
|
+
error: c.error ?? a.error
|
|
1432
|
+
}), W()),
|
|
1433
|
+
R(
|
|
1434
|
+
({ data: a, ...c }, { data: o, ...m }) => T(c, m) && T(a, o)
|
|
1435
|
+
)
|
|
1579
1436
|
);
|
|
1580
|
-
cancel$.subscribe(() => {
|
|
1581
|
-
var _a;
|
|
1582
|
-
(_a = mutationCache.findAll({
|
|
1583
|
-
mutationKey,
|
|
1584
|
-
exact: true
|
|
1585
|
-
})) == null ? void 0 : _a.forEach((mutation) => {
|
|
1586
|
-
mutation.cancel();
|
|
1587
|
-
});
|
|
1588
|
-
});
|
|
1589
|
-
return {
|
|
1590
|
-
mutationKey,
|
|
1591
|
-
runner$,
|
|
1592
|
-
trigger: ({
|
|
1593
|
-
args,
|
|
1594
|
-
options
|
|
1595
|
-
}) => {
|
|
1596
|
-
mapOperator$.next(options.mapOperator);
|
|
1597
|
-
trigger$.next({ args, options });
|
|
1598
|
-
},
|
|
1599
|
-
cancel$,
|
|
1600
|
-
destroy,
|
|
1601
|
-
getClosed: () => closed
|
|
1602
|
-
};
|
|
1603
1437
|
};
|
|
1604
|
-
class
|
|
1605
|
-
constructor(client) {
|
|
1606
|
-
/**
|
|
1607
|
-
* Contain all active mutation for a given key.
|
|
1608
|
-
* A mutation ca have several triggers running (it is not necessarily one function running)
|
|
1609
|
-
*
|
|
1610
|
-
* @important
|
|
1611
|
-
* - automatically cleaned as soon as the last mutation is done for a given key
|
|
1612
|
-
*/
|
|
1613
|
-
__publicField(this, "mutationRunnersByKey$", new BehaviorSubject(/* @__PURE__ */ new Map()));
|
|
1614
|
-
this.client = client;
|
|
1615
|
-
}
|
|
1616
|
-
/**
|
|
1617
|
-
* @helper
|
|
1618
|
-
*/
|
|
1619
|
-
setMutationRunnersByKey(key, value) {
|
|
1620
|
-
const map2 = this.mutationRunnersByKey$.getValue();
|
|
1621
|
-
map2.set(key, value);
|
|
1622
|
-
this.mutationRunnersByKey$.next(map2);
|
|
1623
|
-
}
|
|
1624
|
-
/**
|
|
1625
|
-
* @helper
|
|
1626
|
-
*/
|
|
1627
|
-
deleteMutationRunnersByKey(key) {
|
|
1628
|
-
const map2 = this.mutationRunnersByKey$.getValue();
|
|
1629
|
-
map2.delete(key);
|
|
1630
|
-
this.mutationRunnersByKey$.next(map2);
|
|
1631
|
-
}
|
|
1632
|
-
/**
|
|
1633
|
-
* @helper
|
|
1634
|
-
*/
|
|
1635
|
-
getMutationRunnersByKey(key) {
|
|
1636
|
-
return this.mutationRunnersByKey$.getValue().get(key);
|
|
1637
|
-
}
|
|
1638
|
-
async mutate(params) {
|
|
1639
|
-
const { mutationKey } = params.options;
|
|
1640
|
-
const serializedMutationKey = serializeKey(mutationKey);
|
|
1641
|
-
let mutationForKey = this.getMutationRunnersByKey(serializedMutationKey);
|
|
1642
|
-
if (!mutationForKey) {
|
|
1643
|
-
mutationForKey = {
|
|
1644
|
-
...createMutationRunner({
|
|
1645
|
-
...params.options,
|
|
1646
|
-
client: this.client,
|
|
1647
|
-
mutationCache: this.client.getMutationCache()
|
|
1648
|
-
}),
|
|
1649
|
-
mutationKey
|
|
1650
|
-
};
|
|
1651
|
-
this.setMutationRunnersByKey(serializedMutationKey, mutationForKey);
|
|
1652
|
-
mutationForKey.runner$.subscribe();
|
|
1653
|
-
this.client.getMutationCache().mutationsBy({
|
|
1654
|
-
exact: true,
|
|
1655
|
-
mutationKey
|
|
1656
|
-
}).pipe(
|
|
1657
|
-
distinctUntilChanged(shallowEqual),
|
|
1658
|
-
skip(1),
|
|
1659
|
-
filter((items) => items.length === 0),
|
|
1660
|
-
take(1)
|
|
1661
|
-
).subscribe(() => {
|
|
1662
|
-
mutationForKey == null ? void 0 : mutationForKey.destroy();
|
|
1663
|
-
this.deleteMutationRunnersByKey(serializedMutationKey);
|
|
1664
|
-
});
|
|
1665
|
-
}
|
|
1666
|
-
const mutation = this.client.getMutationCache().build(this.client, params.options);
|
|
1667
|
-
mutationForKey.trigger(params);
|
|
1668
|
-
return await new Promise((resolve, reject) => {
|
|
1669
|
-
mutation.observeTillFinished().pipe(last()).subscribe({
|
|
1670
|
-
error: reject,
|
|
1671
|
-
next: resolve
|
|
1672
|
-
});
|
|
1673
|
-
});
|
|
1674
|
-
}
|
|
1675
|
-
destroy() {
|
|
1676
|
-
this.mutationRunnersByKey$.complete();
|
|
1677
|
-
}
|
|
1678
|
-
}
|
|
1679
|
-
const functionAsObservable = (fn) => {
|
|
1680
|
-
return defer(() => {
|
|
1681
|
-
const result = fn();
|
|
1682
|
-
if (result instanceof Promise) {
|
|
1683
|
-
return from(result);
|
|
1684
|
-
}
|
|
1685
|
-
if (result instanceof Observable) {
|
|
1686
|
-
return result;
|
|
1687
|
-
}
|
|
1688
|
-
return of(result);
|
|
1689
|
-
});
|
|
1690
|
-
};
|
|
1691
|
-
class Mutation {
|
|
1438
|
+
class tr {
|
|
1692
1439
|
constructor({
|
|
1693
|
-
options,
|
|
1694
|
-
mutationCache
|
|
1440
|
+
options: e,
|
|
1441
|
+
mutationCache: r,
|
|
1442
|
+
state: n
|
|
1695
1443
|
}) {
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
this
|
|
1705
|
-
this
|
|
1706
|
-
this.state
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1444
|
+
y(this, "mutationCache");
|
|
1445
|
+
y(this, "observerCount", new I(0));
|
|
1446
|
+
y(this, "destroySubject", new F());
|
|
1447
|
+
y(this, "resetSubject", new F());
|
|
1448
|
+
y(this, "executeSubject", new F());
|
|
1449
|
+
y(this, "state", W());
|
|
1450
|
+
y(this, "state$");
|
|
1451
|
+
y(this, "options");
|
|
1452
|
+
y(this, "observerCount$", this.observerCount.asObservable());
|
|
1453
|
+
y(this, "destroyed$", this.destroySubject.asObservable());
|
|
1454
|
+
this.options = e, this.mutationCache = r, this.state = n ?? this.state;
|
|
1455
|
+
const s = S(this.state), i = this.resetSubject.pipe(
|
|
1456
|
+
p(() => W())
|
|
1457
|
+
), u = this.executeSubject.pipe(
|
|
1458
|
+
w(
|
|
1459
|
+
(l) => er({
|
|
1460
|
+
options: {
|
|
1461
|
+
...this.options,
|
|
1462
|
+
onMutate: (f) => {
|
|
1463
|
+
const d = V(
|
|
1464
|
+
() => {
|
|
1465
|
+
var g, a;
|
|
1466
|
+
return (a = (g = r.config).onMutate) == null ? void 0 : a.call(
|
|
1467
|
+
g,
|
|
1468
|
+
f,
|
|
1469
|
+
this
|
|
1470
|
+
);
|
|
1471
|
+
}
|
|
1472
|
+
), h = V(
|
|
1473
|
+
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
1474
|
+
() => {
|
|
1475
|
+
var g, a;
|
|
1476
|
+
return ((a = (g = this.options).onMutate) == null ? void 0 : a.call(g, f)) ?? void 0;
|
|
1477
|
+
}
|
|
1478
|
+
);
|
|
1479
|
+
return d.pipe(_(() => h));
|
|
1480
|
+
},
|
|
1481
|
+
onError: (f, d, h) => {
|
|
1482
|
+
const g = V(
|
|
1483
|
+
() => {
|
|
1484
|
+
var c, o;
|
|
1485
|
+
return (o = (c = r.config).onError) == null ? void 0 : o.call(
|
|
1486
|
+
c,
|
|
1487
|
+
f,
|
|
1488
|
+
d,
|
|
1489
|
+
h,
|
|
1490
|
+
this
|
|
1491
|
+
);
|
|
1492
|
+
}
|
|
1493
|
+
), a = V(
|
|
1494
|
+
() => {
|
|
1495
|
+
var c, o;
|
|
1496
|
+
return (o = (c = this.options).onError) == null ? void 0 : o.call(c, f, d, h);
|
|
1497
|
+
}
|
|
1498
|
+
);
|
|
1499
|
+
return ue(g, a).pipe(ce());
|
|
1500
|
+
},
|
|
1501
|
+
onSettled: (f, d, h, g) => {
|
|
1502
|
+
const a = V(
|
|
1503
|
+
() => {
|
|
1504
|
+
var o, m;
|
|
1505
|
+
return (m = (o = r.config).onSettled) == null ? void 0 : m.call(
|
|
1506
|
+
o,
|
|
1507
|
+
f,
|
|
1508
|
+
d,
|
|
1509
|
+
h,
|
|
1510
|
+
g,
|
|
1511
|
+
this
|
|
1512
|
+
);
|
|
1513
|
+
}
|
|
1514
|
+
), c = V(
|
|
1515
|
+
() => {
|
|
1516
|
+
var o, m;
|
|
1517
|
+
return (m = (o = this.options).onSettled) == null ? void 0 : m.call(o, f, d, h, g);
|
|
1518
|
+
}
|
|
1519
|
+
);
|
|
1520
|
+
return ue(a, c).pipe(ce());
|
|
1521
|
+
},
|
|
1522
|
+
onSuccess: (f, d, h) => {
|
|
1523
|
+
const g = V(
|
|
1524
|
+
() => {
|
|
1525
|
+
var c, o;
|
|
1526
|
+
return (o = (c = r.config).onSuccess) == null ? void 0 : o.call(
|
|
1527
|
+
c,
|
|
1528
|
+
f,
|
|
1529
|
+
d,
|
|
1530
|
+
h,
|
|
1531
|
+
this
|
|
1532
|
+
);
|
|
1533
|
+
}
|
|
1534
|
+
), a = V(
|
|
1535
|
+
() => {
|
|
1536
|
+
var c, o;
|
|
1537
|
+
return (o = (c = this.options).onSuccess) == null ? void 0 : o.call(c, f, d, h);
|
|
1538
|
+
}
|
|
1539
|
+
);
|
|
1540
|
+
return ue(g, a).pipe(ce());
|
|
1541
|
+
}
|
|
1542
|
+
},
|
|
1543
|
+
state: this.state,
|
|
1544
|
+
variables: l
|
|
1545
|
+
})
|
|
1714
1546
|
),
|
|
1715
|
-
|
|
1716
|
-
|
|
1547
|
+
x((l) => {
|
|
1548
|
+
this.state = { ...this.state, ...l };
|
|
1549
|
+
}),
|
|
1550
|
+
P(this.destroySubject)
|
|
1551
|
+
);
|
|
1552
|
+
this.state$ = O(s, u, i).pipe(
|
|
1717
1553
|
/**
|
|
1718
1554
|
* refCount as true somewhat make NEVER complete when there are
|
|
1719
1555
|
* no more observers. I thought I should have to complete manually (which is
|
|
1720
1556
|
* why we still cancel the observable when we remove it from cache)
|
|
1721
1557
|
*/
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
(
|
|
1725
|
-
|
|
1726
|
-
(observer) => {
|
|
1727
|
-
this.observerCount.next(this.observerCount.getValue() + 1);
|
|
1728
|
-
const sub = source.subscribe(observer);
|
|
1729
|
-
return () => {
|
|
1730
|
-
this.observerCount.next(this.observerCount.getValue() - 1);
|
|
1731
|
-
sub.unsubscribe();
|
|
1732
|
-
};
|
|
1733
|
-
}
|
|
1734
|
-
);
|
|
1735
|
-
}
|
|
1736
|
-
);
|
|
1737
|
-
}
|
|
1738
|
-
createMutation(variables) {
|
|
1739
|
-
const mutationFn = this.options.mutationFn;
|
|
1740
|
-
const onCacheMutate$ = functionAsObservable(
|
|
1741
|
-
() => {
|
|
1742
|
-
var _a, _b;
|
|
1743
|
-
return (_b = (_a = this.mutationCache.config).onMutate) == null ? void 0 : _b.call(
|
|
1744
|
-
_a,
|
|
1745
|
-
variables,
|
|
1746
|
-
this
|
|
1747
|
-
);
|
|
1748
|
-
}
|
|
1749
|
-
);
|
|
1750
|
-
const onMutate = concat(
|
|
1751
|
-
onCacheMutate$.pipe(
|
|
1752
|
-
mergeMap(() => {
|
|
1753
|
-
const onMutate$ = functionAsObservable(
|
|
1754
|
-
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
1755
|
-
() => {
|
|
1756
|
-
var _a, _b;
|
|
1757
|
-
return ((_b = (_a = this.options).onMutate) == null ? void 0 : _b.call(_a, variables)) ?? void 0;
|
|
1758
|
-
}
|
|
1759
|
-
);
|
|
1760
|
-
return onMutate$;
|
|
1761
|
-
})
|
|
1762
|
-
)
|
|
1763
|
-
);
|
|
1764
|
-
const queryRunner$ = onMutate.pipe(
|
|
1765
|
-
switchMap((context) => {
|
|
1766
|
-
const fn$ = typeof mutationFn === "function" ? (
|
|
1767
|
-
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
1768
|
-
functionAsObservable(() => mutationFn(variables))
|
|
1769
|
-
) : mutationFn;
|
|
1770
|
-
return fn$.pipe(
|
|
1771
|
-
retryOnError(this.options),
|
|
1772
|
-
take(1),
|
|
1773
|
-
map((data) => ({ data, context, isError: false })),
|
|
1774
|
-
catchError((error) => {
|
|
1775
|
-
console.error(error);
|
|
1776
|
-
const onCacheError$ = functionAsObservable(
|
|
1777
|
-
() => {
|
|
1778
|
-
var _a, _b;
|
|
1779
|
-
return (_b = (_a = this.mutationCache.config).onError) == null ? void 0 : _b.call(_a, error, variables, context, this);
|
|
1780
|
-
}
|
|
1781
|
-
);
|
|
1782
|
-
const onError$ = functionAsObservable(
|
|
1783
|
-
() => {
|
|
1784
|
-
var _a, _b;
|
|
1785
|
-
return (_b = (_a = this.options).onError) == null ? void 0 : _b.call(_a, error, variables, context);
|
|
1786
|
-
}
|
|
1787
|
-
);
|
|
1788
|
-
return concat(onCacheError$, onError$).pipe(
|
|
1789
|
-
toArray(),
|
|
1790
|
-
map(() => ({ data: error, context, isError: true }))
|
|
1791
|
-
);
|
|
1792
|
-
})
|
|
1793
|
-
);
|
|
1558
|
+
$e({ bufferSize: 1, refCount: !1 }),
|
|
1559
|
+
P(this.destroySubject),
|
|
1560
|
+
ke((l) => {
|
|
1561
|
+
this.observerCount.next(l);
|
|
1794
1562
|
})
|
|
1795
1563
|
);
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
}
|
|
1802
|
-
const mutation$ = merge(
|
|
1803
|
-
initState$,
|
|
1804
|
-
queryRunner$.pipe(
|
|
1805
|
-
switchMap(({ data: dataOrError, isError, context }) => {
|
|
1806
|
-
const error = isError ? dataOrError : null;
|
|
1807
|
-
const data = isError ? void 0 : dataOrError;
|
|
1808
|
-
const onCacheSuccess$ = isError ? of(null) : functionAsObservable(
|
|
1809
|
-
() => {
|
|
1810
|
-
var _a, _b;
|
|
1811
|
-
return (_b = (_a = this.mutationCache.config).onSuccess) == null ? void 0 : _b.call(
|
|
1812
|
-
_a,
|
|
1813
|
-
data,
|
|
1814
|
-
variables,
|
|
1815
|
-
context,
|
|
1816
|
-
this
|
|
1817
|
-
);
|
|
1818
|
-
}
|
|
1819
|
-
);
|
|
1820
|
-
const onSuccess$ = isError ? of(null) : functionAsObservable(
|
|
1821
|
-
() => {
|
|
1822
|
-
var _a, _b;
|
|
1823
|
-
return (_b = (_a = this.options).onSuccess) == null ? void 0 : _b.call(_a, data, variables, context);
|
|
1824
|
-
}
|
|
1825
|
-
);
|
|
1826
|
-
const onCacheSettled$ = functionAsObservable(
|
|
1827
|
-
() => {
|
|
1828
|
-
var _a, _b;
|
|
1829
|
-
return (_b = (_a = this.mutationCache.config).onSettled) == null ? void 0 : _b.call(
|
|
1830
|
-
_a,
|
|
1831
|
-
data,
|
|
1832
|
-
error,
|
|
1833
|
-
variables,
|
|
1834
|
-
context,
|
|
1835
|
-
this
|
|
1836
|
-
);
|
|
1837
|
-
}
|
|
1838
|
-
);
|
|
1839
|
-
const onSettled$ = functionAsObservable(
|
|
1840
|
-
() => {
|
|
1841
|
-
var _a, _b;
|
|
1842
|
-
return (_b = (_a = this.options).onSettled) == null ? void 0 : _b.call(_a, data, error, variables, context);
|
|
1843
|
-
}
|
|
1844
|
-
);
|
|
1845
|
-
const result$ = concat(
|
|
1846
|
-
onCacheSuccess$,
|
|
1847
|
-
onSuccess$,
|
|
1848
|
-
onCacheSettled$,
|
|
1849
|
-
onSettled$
|
|
1850
|
-
).pipe(
|
|
1851
|
-
toArray(),
|
|
1852
|
-
map(
|
|
1853
|
-
() => isError ? {
|
|
1854
|
-
status: "error",
|
|
1855
|
-
error,
|
|
1856
|
-
data,
|
|
1857
|
-
context,
|
|
1858
|
-
variables
|
|
1859
|
-
} : {
|
|
1860
|
-
status: "success",
|
|
1861
|
-
error,
|
|
1862
|
-
data,
|
|
1863
|
-
context,
|
|
1864
|
-
variables
|
|
1865
|
-
}
|
|
1866
|
-
)
|
|
1867
|
-
);
|
|
1868
|
-
return result$;
|
|
1869
|
-
})
|
|
1870
|
-
)
|
|
1871
|
-
).pipe(
|
|
1872
|
-
mergeResults,
|
|
1873
|
-
this.options.__queryRunnerHook ?? identity,
|
|
1874
|
-
takeUntil(this.cancelSubject)
|
|
1875
|
-
);
|
|
1876
|
-
return mutation$;
|
|
1564
|
+
}
|
|
1565
|
+
get meta() {
|
|
1566
|
+
return this.options.meta;
|
|
1567
|
+
}
|
|
1568
|
+
setOptions(e) {
|
|
1569
|
+
this.options = { ...this.options, ...e };
|
|
1877
1570
|
}
|
|
1878
1571
|
observeTillFinished() {
|
|
1879
1572
|
return this.state$.pipe(
|
|
1880
|
-
|
|
1881
|
-
(
|
|
1882
|
-
|
|
1573
|
+
ve(
|
|
1574
|
+
(e) => e.status !== "error" && e.status !== "success",
|
|
1575
|
+
!0
|
|
1883
1576
|
)
|
|
1884
1577
|
);
|
|
1885
1578
|
}
|
|
@@ -1888,509 +1581,358 @@ class Mutation {
|
|
|
1888
1581
|
* The resulting observable will complete as soon as the mutation
|
|
1889
1582
|
* is over, unlike the state which can be re-subscribed later.
|
|
1890
1583
|
*/
|
|
1891
|
-
execute(
|
|
1892
|
-
this.executeSubject.next(
|
|
1893
|
-
this.executeSubject.complete();
|
|
1894
|
-
return this.observeTillFinished();
|
|
1584
|
+
execute(e) {
|
|
1585
|
+
return this.executeSubject.next(e), this.executeSubject.complete(), this.observeTillFinished();
|
|
1895
1586
|
}
|
|
1896
|
-
|
|
1897
|
-
this.
|
|
1898
|
-
|
|
1899
|
-
|
|
1587
|
+
continue() {
|
|
1588
|
+
return this.execute(this.state.variables);
|
|
1589
|
+
}
|
|
1590
|
+
destroy() {
|
|
1591
|
+
this.destroySubject.next(), this.destroySubject.complete(), this.executeSubject.complete();
|
|
1592
|
+
}
|
|
1593
|
+
reset() {
|
|
1594
|
+
this.resetSubject.next(), this.resetSubject.complete(), this.destroy();
|
|
1900
1595
|
}
|
|
1901
1596
|
}
|
|
1902
|
-
const
|
|
1903
|
-
mutationKey,
|
|
1904
|
-
status,
|
|
1905
|
-
predicate,
|
|
1906
|
-
exact =
|
|
1907
|
-
} = {}) => {
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
if (status && mutation.state.status !== status)
|
|
1916
|
-
return false;
|
|
1917
|
-
if (predicate) {
|
|
1918
|
-
return predicate(mutation);
|
|
1919
|
-
}
|
|
1920
|
-
return true;
|
|
1921
|
-
};
|
|
1922
|
-
return finalPredicate;
|
|
1923
|
-
};
|
|
1924
|
-
class MutationCache {
|
|
1925
|
-
constructor(config = {}) {
|
|
1926
|
-
__publicField(this, "mutationsSubject", new BehaviorSubject([]));
|
|
1927
|
-
__publicField(this, "mutations$", this.mutationsSubject.pipe(
|
|
1928
|
-
map((mutations) => mutations.map(({ mutation }) => mutation)),
|
|
1929
|
-
distinctUntilChanged(arrayEqual),
|
|
1930
|
-
share()
|
|
1597
|
+
const he = ({
|
|
1598
|
+
mutationKey: t,
|
|
1599
|
+
status: e,
|
|
1600
|
+
predicate: r,
|
|
1601
|
+
exact: n = !0
|
|
1602
|
+
} = {}) => (i) => n && t !== void 0 && i.options.mutationKey !== void 0 && !te(i.options.mutationKey, t, { exact: n }) || !n && t !== void 0 && i.options.mutationKey !== void 0 && !te(t, i.options.mutationKey, { exact: n }) || e && i.state.status !== e ? !1 : r ? r(i) : !0;
|
|
1603
|
+
class rr {
|
|
1604
|
+
constructor(e = {}) {
|
|
1605
|
+
y(this, "mutationsSubject", new I([]));
|
|
1606
|
+
y(this, "mutations$", this.mutationsSubject.pipe(
|
|
1607
|
+
p((e) => e.map((r) => r)),
|
|
1608
|
+
R(Le),
|
|
1609
|
+
J()
|
|
1931
1610
|
));
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
([
|
|
1611
|
+
y(this, "added$", this.mutations$.pipe(
|
|
1612
|
+
oe(),
|
|
1613
|
+
p(
|
|
1614
|
+
([e, r]) => r.filter((n) => !e.includes(n))[0]
|
|
1936
1615
|
),
|
|
1937
|
-
|
|
1938
|
-
|
|
1616
|
+
$(G),
|
|
1617
|
+
J()
|
|
1939
1618
|
));
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
([
|
|
1619
|
+
y(this, "removed$", this.mutations$.pipe(
|
|
1620
|
+
oe(),
|
|
1621
|
+
p(
|
|
1622
|
+
([e, r]) => e.filter((n) => !r.includes(n))
|
|
1944
1623
|
),
|
|
1945
|
-
|
|
1946
|
-
|
|
1624
|
+
_((e) => ne(e)),
|
|
1625
|
+
J()
|
|
1947
1626
|
));
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
(
|
|
1951
|
-
|
|
1952
|
-
|
|
1627
|
+
y(this, "stateChange$", this.added$.pipe(
|
|
1628
|
+
_(
|
|
1629
|
+
(e) => e.state$.pipe(
|
|
1630
|
+
p(() => e),
|
|
1631
|
+
P(
|
|
1953
1632
|
this.removed$.pipe(
|
|
1954
|
-
|
|
1633
|
+
$((r) => r === e)
|
|
1955
1634
|
)
|
|
1956
1635
|
)
|
|
1957
1636
|
)
|
|
1958
1637
|
),
|
|
1959
|
-
|
|
1638
|
+
J()
|
|
1960
1639
|
));
|
|
1961
|
-
this.config =
|
|
1962
|
-
}
|
|
1963
|
-
subscribe(listener) {
|
|
1964
|
-
const sub = merge(
|
|
1965
|
-
this.added$.pipe(
|
|
1966
|
-
tap((mutation) => {
|
|
1967
|
-
listener({
|
|
1968
|
-
type: "added",
|
|
1969
|
-
mutation
|
|
1970
|
-
});
|
|
1971
|
-
})
|
|
1972
|
-
),
|
|
1973
|
-
this.removed$.pipe(
|
|
1974
|
-
tap((mutation) => {
|
|
1975
|
-
listener({
|
|
1976
|
-
type: "removed",
|
|
1977
|
-
mutation
|
|
1978
|
-
});
|
|
1979
|
-
})
|
|
1980
|
-
),
|
|
1981
|
-
this.stateChange$.pipe(
|
|
1982
|
-
tap((mutation) => {
|
|
1983
|
-
listener({
|
|
1984
|
-
type: "updated",
|
|
1985
|
-
action: {
|
|
1986
|
-
...mutation.state,
|
|
1987
|
-
// @todo
|
|
1988
|
-
type: "success"
|
|
1989
|
-
},
|
|
1990
|
-
mutation
|
|
1991
|
-
});
|
|
1992
|
-
})
|
|
1993
|
-
)
|
|
1994
|
-
).subscribe();
|
|
1995
|
-
return () => {
|
|
1996
|
-
sub.unsubscribe();
|
|
1997
|
-
};
|
|
1640
|
+
this.config = e;
|
|
1998
1641
|
}
|
|
1999
|
-
build(
|
|
2000
|
-
const
|
|
1642
|
+
build(e, r, n) {
|
|
1643
|
+
const s = new tr({
|
|
2001
1644
|
mutationCache: this,
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
// state
|
|
1645
|
+
options: e.defaultMutationOptions(r),
|
|
1646
|
+
state: n
|
|
2005
1647
|
});
|
|
2006
|
-
|
|
1648
|
+
return s.state$.pipe(
|
|
2007
1649
|
/**
|
|
2008
1650
|
* Once a mutation is finished and there are no more observers than us
|
|
2009
1651
|
* we start the process of cleaning it up based on gc settings
|
|
2010
1652
|
*/
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
() =>
|
|
2014
|
-
|
|
2015
|
-
|
|
1653
|
+
$(({ status: i }) => i === "success" || i === "error"),
|
|
1654
|
+
w(
|
|
1655
|
+
() => s.observerCount$.pipe(
|
|
1656
|
+
$((i) => i <= 1),
|
|
1657
|
+
be(1)
|
|
2016
1658
|
)
|
|
2017
1659
|
),
|
|
2018
|
-
|
|
2019
|
-
|
|
1660
|
+
// defaults to 5mn
|
|
1661
|
+
w(() => ie(s.options.gcTime ?? 5 * 60 * 1e3)),
|
|
1662
|
+
be(1)
|
|
2020
1663
|
).subscribe({
|
|
2021
1664
|
complete: () => {
|
|
2022
|
-
this.
|
|
1665
|
+
this.mutationsSubject.next(
|
|
1666
|
+
this.mutationsSubject.getValue().filter((i) => s !== i)
|
|
1667
|
+
);
|
|
2023
1668
|
}
|
|
2024
|
-
});
|
|
2025
|
-
this.mutationsSubject.next([
|
|
2026
|
-
...this.mutationsSubject.getValue(),
|
|
2027
|
-
{ mutation, sub }
|
|
2028
|
-
]);
|
|
2029
|
-
return mutation;
|
|
1669
|
+
}), this.mutationsSubject.next([...this.mutationsSubject.getValue(), s]), s;
|
|
2030
1670
|
}
|
|
2031
1671
|
getAll() {
|
|
2032
1672
|
return this.findAll();
|
|
2033
1673
|
}
|
|
2034
|
-
remove(
|
|
2035
|
-
this.
|
|
2036
|
-
|
|
2037
|
-
removeBy(filters) {
|
|
2038
|
-
const defaultedFilters = { exact: true, ...filters };
|
|
2039
|
-
const predicate = createPredicateForFilters(defaultedFilters);
|
|
2040
|
-
const toRemove = this.mutationsSubject.getValue().filter(({ mutation }) => {
|
|
2041
|
-
return predicate(mutation);
|
|
2042
|
-
}).map(({ mutation, sub }) => {
|
|
2043
|
-
mutation.cancel();
|
|
2044
|
-
sub.unsubscribe();
|
|
2045
|
-
return mutation;
|
|
2046
|
-
});
|
|
2047
|
-
this.mutationsSubject.next(
|
|
2048
|
-
this.mutationsSubject.getValue().filter(({ mutation }) => !toRemove.includes(mutation))
|
|
2049
|
-
);
|
|
2050
|
-
}
|
|
2051
|
-
find(filters) {
|
|
2052
|
-
var _a;
|
|
2053
|
-
const defaultedFilters = { exact: true, ...filters };
|
|
2054
|
-
const predicate = createPredicateForFilters(defaultedFilters);
|
|
2055
|
-
return (_a = this.mutationsSubject.getValue().find(({ mutation }) => predicate(mutation))) == null ? void 0 : _a.mutation;
|
|
1674
|
+
remove(e) {
|
|
1675
|
+
const r = this.mutationsSubject.getValue().find((n) => n === e);
|
|
1676
|
+
r == null || r.destroy();
|
|
2056
1677
|
}
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
const predicate = createPredicateForFilters(defaultedFilters);
|
|
2061
|
-
return (_a = this.mutationsSubject.getValue().slice().reverse().find(({ mutation }) => predicate(mutation))) == null ? void 0 : _a.mutation;
|
|
1678
|
+
find(e) {
|
|
1679
|
+
const r = { exact: !0, ...e }, n = he(r);
|
|
1680
|
+
return this.mutationsSubject.getValue().find((s) => n(s));
|
|
2062
1681
|
}
|
|
2063
|
-
findAll(
|
|
2064
|
-
const
|
|
2065
|
-
|
|
2066
|
-
return this.mutationsSubject.getValue().filter(({ mutation }) => predicate(mutation)).map(({ mutation }) => mutation);
|
|
1682
|
+
findAll(e = {}) {
|
|
1683
|
+
const r = { exact: !0, ...e }, n = he(r);
|
|
1684
|
+
return this.mutationsSubject.getValue().filter((s) => n(s)).map((s) => s);
|
|
2067
1685
|
}
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
return this.mutations$.pipe(
|
|
2072
|
-
map((mutations) => mutations.filter(predicate)),
|
|
2073
|
-
distinctUntilChanged(arrayEqual)
|
|
2074
|
-
);
|
|
2075
|
-
}
|
|
2076
|
-
mutationStateBy({
|
|
2077
|
-
filters,
|
|
2078
|
-
select
|
|
1686
|
+
observe({
|
|
1687
|
+
filters: e,
|
|
1688
|
+
select: r
|
|
2079
1689
|
} = {}) {
|
|
2080
|
-
const
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
const value$ = this.stateChange$.pipe(
|
|
2087
|
-
startWith(),
|
|
2088
|
-
map(() => {
|
|
2089
|
-
const filteredMutations = this.getAll().filter(predicate);
|
|
2090
|
-
return filteredMutations.map(finalSelect);
|
|
2091
|
-
}),
|
|
2092
|
-
distinctUntilChanged(shallowEqual)
|
|
2093
|
-
);
|
|
2094
|
-
return { value$, lastValue };
|
|
2095
|
-
}
|
|
2096
|
-
cancelBy(filters) {
|
|
2097
|
-
this.findAll(filters).forEach((mutation) => {
|
|
2098
|
-
mutation.cancel();
|
|
2099
|
-
});
|
|
1690
|
+
const n = he(e), s = r ?? ((l) => l.state), i = this.getAll().reduce((l, f) => [...l, f], []).filter(n).map((l) => s(l));
|
|
1691
|
+
return { value$: this.stateChange$.pipe(
|
|
1692
|
+
Ie(),
|
|
1693
|
+
p(() => this.getAll().filter(n).map(s)),
|
|
1694
|
+
R(T)
|
|
1695
|
+
), lastValue: i };
|
|
2100
1696
|
}
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
isPending: state.status === "pending",
|
|
2115
|
-
isIdle: state.status === "idle",
|
|
2116
|
-
isError: state.status === "error"
|
|
2117
|
-
};
|
|
2118
|
-
});
|
|
2119
|
-
this.client = client;
|
|
2120
|
-
this.options = options;
|
|
2121
|
-
}
|
|
2122
|
-
observeBy(filters) {
|
|
2123
|
-
const reduceStateFromMutation = (values) => {
|
|
2124
|
-
var _a;
|
|
2125
|
-
return values.reduce(
|
|
2126
|
-
(acc, { state, options }) => {
|
|
2127
|
-
if (options.mapOperator === "switch")
|
|
2128
|
-
return state;
|
|
2129
|
-
if (acc && state.submittedAt >= acc.submittedAt) {
|
|
2130
|
-
return {
|
|
2131
|
-
...state,
|
|
2132
|
-
data: state.data ?? acc.data,
|
|
2133
|
-
error: state.error ?? acc.error
|
|
2134
|
-
};
|
|
2135
|
-
}
|
|
2136
|
-
return acc;
|
|
2137
|
-
},
|
|
2138
|
-
((_a = values[0]) == null ? void 0 : _a.state) ?? getDefaultMutationState()
|
|
2139
|
-
);
|
|
2140
|
-
};
|
|
2141
|
-
const mutations = this.client.getMutationCache().findAll(filters);
|
|
2142
|
-
const lastValue = this.getDerivedState(
|
|
2143
|
-
reduceStateFromMutation(mutations)
|
|
2144
|
-
);
|
|
2145
|
-
const result$ = this.client.getMutationCache().mutationsBy(filters).pipe(
|
|
2146
|
-
switchMap(
|
|
2147
|
-
(mutations2) => combineLatest(
|
|
2148
|
-
mutations2.map(
|
|
2149
|
-
(mutation) => this.observe(mutation).pipe(
|
|
2150
|
-
map((state) => ({ state, options: mutation.options }))
|
|
2151
|
-
)
|
|
2152
|
-
)
|
|
2153
|
-
)
|
|
1697
|
+
/**
|
|
1698
|
+
* @important
|
|
1699
|
+
* ISO api react-query
|
|
1700
|
+
*/
|
|
1701
|
+
subscribe(e) {
|
|
1702
|
+
const r = O(
|
|
1703
|
+
this.added$.pipe(
|
|
1704
|
+
x((n) => {
|
|
1705
|
+
e({
|
|
1706
|
+
type: "added",
|
|
1707
|
+
mutation: n
|
|
1708
|
+
});
|
|
1709
|
+
})
|
|
2154
1710
|
),
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
)
|
|
2173
|
-
)
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
).subscribe(subscription);
|
|
1711
|
+
this.removed$.pipe(
|
|
1712
|
+
x((n) => {
|
|
1713
|
+
e({
|
|
1714
|
+
type: "removed",
|
|
1715
|
+
mutation: n
|
|
1716
|
+
});
|
|
1717
|
+
})
|
|
1718
|
+
),
|
|
1719
|
+
this.stateChange$.pipe(
|
|
1720
|
+
x((n) => {
|
|
1721
|
+
e({
|
|
1722
|
+
type: "updated",
|
|
1723
|
+
action: {
|
|
1724
|
+
...n.state,
|
|
1725
|
+
type: "success"
|
|
1726
|
+
},
|
|
1727
|
+
mutation: n
|
|
1728
|
+
});
|
|
1729
|
+
})
|
|
1730
|
+
)
|
|
1731
|
+
).subscribe();
|
|
2177
1732
|
return () => {
|
|
2178
|
-
|
|
1733
|
+
r.unsubscribe();
|
|
2179
1734
|
};
|
|
2180
1735
|
}
|
|
2181
|
-
|
|
2182
|
-
const
|
|
2183
|
-
|
|
2184
|
-
...options
|
|
2185
|
-
};
|
|
2186
|
-
return await this.client.mutationRunners.mutate({
|
|
2187
|
-
args: variables,
|
|
2188
|
-
options: {
|
|
2189
|
-
mutationFn: async () => void 0,
|
|
2190
|
-
...mergedOptions,
|
|
2191
|
-
mutationKey: mergedOptions.mutationKey ?? [nanoid()]
|
|
2192
|
-
}
|
|
1736
|
+
resumePausedMutations() {
|
|
1737
|
+
const e = this.findAll({
|
|
1738
|
+
predicate: (n) => n.state.isPaused
|
|
2193
1739
|
});
|
|
1740
|
+
if (!e.length)
|
|
1741
|
+
return M;
|
|
1742
|
+
const r = e.map((n) => n.continue());
|
|
1743
|
+
return Fe(r);
|
|
2194
1744
|
}
|
|
2195
|
-
|
|
2196
|
-
this.
|
|
2197
|
-
|
|
1745
|
+
clear() {
|
|
1746
|
+
this.getAll().forEach((e) => {
|
|
1747
|
+
this.remove(e);
|
|
2198
1748
|
});
|
|
2199
1749
|
}
|
|
2200
|
-
destroy() {
|
|
2201
|
-
}
|
|
2202
1750
|
}
|
|
2203
|
-
const
|
|
2204
|
-
const queryStore =
|
|
2205
|
-
|
|
2206
|
-
const
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
fn: maybeFn,
|
|
2213
|
-
trigger$: externalTrigger$ = new Subject(),
|
|
2214
|
-
options$ = new BehaviorSubject({})
|
|
1751
|
+
const nr = () => {
|
|
1752
|
+
const t = It(), e = kt({ queryStore: t }), r = Xt({ queryStore: t }), n = Lt();
|
|
1753
|
+
let s = !1;
|
|
1754
|
+
const i = ({
|
|
1755
|
+
key: d,
|
|
1756
|
+
fn$: h,
|
|
1757
|
+
fn: g,
|
|
1758
|
+
trigger$: a = new F(),
|
|
1759
|
+
options$: c = new I({})
|
|
2215
1760
|
}) => {
|
|
2216
|
-
if (!
|
|
1761
|
+
if (!s)
|
|
2217
1762
|
throw new Error("You forgot to start client");
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
const
|
|
2221
|
-
|
|
2222
|
-
const runner$ = options$.pipe(map((options) => ({ options })));
|
|
2223
|
-
let deleteRunner = () => {
|
|
1763
|
+
const o = N(d), m = h ?? (g ? S(g) : Qe);
|
|
1764
|
+
X.log("query$)", o);
|
|
1765
|
+
const C = c.pipe(p((E) => ({ options: E })));
|
|
1766
|
+
let b = () => {
|
|
2224
1767
|
};
|
|
2225
|
-
const
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
queryStore,
|
|
2229
|
-
serializedKey
|
|
1768
|
+
const j = O(
|
|
1769
|
+
a.pipe(
|
|
1770
|
+
Bt({
|
|
1771
|
+
queryStore: t,
|
|
1772
|
+
serializedKey: o
|
|
2230
1773
|
})
|
|
2231
1774
|
),
|
|
2232
|
-
|
|
2233
|
-
options
|
|
2234
|
-
key:
|
|
2235
|
-
queryStore
|
|
1775
|
+
Qt({
|
|
1776
|
+
options$: c,
|
|
1777
|
+
key: o,
|
|
1778
|
+
queryStore: t
|
|
2236
1779
|
})
|
|
2237
|
-
).pipe(
|
|
2238
|
-
const result$ = merge(
|
|
2239
|
-
of({
|
|
2240
|
-
type: "initial"
|
|
2241
|
-
}),
|
|
2242
|
-
trigger$
|
|
2243
|
-
).pipe(
|
|
2244
|
-
updateStoreWithNewQuery({
|
|
2245
|
-
key,
|
|
2246
|
-
queryStore,
|
|
2247
|
-
runner$,
|
|
2248
|
-
serializedKey,
|
|
2249
|
-
options$
|
|
2250
|
-
}),
|
|
2251
|
-
map(([value, deleteRunnerFn]) => {
|
|
2252
|
-
if (deleteRunnerFn) {
|
|
2253
|
-
deleteRunner = deleteRunnerFn;
|
|
2254
|
-
}
|
|
2255
|
-
return value;
|
|
2256
|
-
}),
|
|
2257
|
-
markQueryAsStaleIfRefetch({
|
|
2258
|
-
key,
|
|
2259
|
-
options$,
|
|
2260
|
-
queryStore,
|
|
2261
|
-
serializedKey
|
|
2262
|
-
}),
|
|
2263
|
-
withLatestFrom(fn$, options$),
|
|
2264
|
-
map(([trigger2, fn, options]) => ({ trigger: trigger2, fn, options })),
|
|
2265
|
-
map((value) => {
|
|
2266
|
-
Logger.log(serializedKey, "query trigger", {
|
|
2267
|
-
trigger: value.trigger,
|
|
2268
|
-
options: value.options
|
|
2269
|
-
});
|
|
2270
|
-
return value;
|
|
2271
|
-
}),
|
|
2272
|
-
filter(({ options }) => options.enabled !== false),
|
|
2273
|
-
mergeMap(
|
|
2274
|
-
({ fn, options, trigger: trigger2 }) => createQueryFetch({
|
|
2275
|
-
options$,
|
|
2276
|
-
options,
|
|
2277
|
-
fn,
|
|
2278
|
-
queryStore,
|
|
2279
|
-
serializedKey,
|
|
2280
|
-
trigger: trigger2,
|
|
2281
|
-
trigger$
|
|
2282
|
-
})
|
|
2283
|
-
),
|
|
2284
|
-
mergeResults$1,
|
|
2285
|
-
withLatestFrom(options$),
|
|
2286
|
-
takeWhile(([result, options]) => {
|
|
2287
|
-
const shouldStop = result.data !== void 0 && options.terminateOnFirstResult;
|
|
2288
|
-
return !shouldStop;
|
|
2289
|
-
}, true),
|
|
2290
|
-
map(([result]) => result),
|
|
2291
|
-
finalize(() => {
|
|
2292
|
-
deleteRunner();
|
|
2293
|
-
})
|
|
2294
|
-
);
|
|
1780
|
+
).pipe(J());
|
|
2295
1781
|
return {
|
|
2296
|
-
result
|
|
1782
|
+
result$: O(
|
|
1783
|
+
S({
|
|
1784
|
+
type: "initial"
|
|
1785
|
+
}),
|
|
1786
|
+
j
|
|
1787
|
+
).pipe(
|
|
1788
|
+
Ht({
|
|
1789
|
+
key: d,
|
|
1790
|
+
queryStore: t,
|
|
1791
|
+
runner$: C,
|
|
1792
|
+
serializedKey: o,
|
|
1793
|
+
options$: c
|
|
1794
|
+
}),
|
|
1795
|
+
p(([E, Q]) => (Q && (b = Q), E)),
|
|
1796
|
+
qt({
|
|
1797
|
+
key: d,
|
|
1798
|
+
options$: c,
|
|
1799
|
+
queryStore: t,
|
|
1800
|
+
serializedKey: o
|
|
1801
|
+
}),
|
|
1802
|
+
D(m, c),
|
|
1803
|
+
p(([E, Q, z]) => ({ trigger: E, fn: Q, options: z })),
|
|
1804
|
+
p((E) => (X.log(o, "query trigger", {
|
|
1805
|
+
trigger: E.trigger,
|
|
1806
|
+
options: E.options
|
|
1807
|
+
}), E)),
|
|
1808
|
+
$(({ options: E }) => E.enabled !== !1),
|
|
1809
|
+
_(
|
|
1810
|
+
({ fn: E, options: Q, trigger: z }) => Nt({
|
|
1811
|
+
options$: c,
|
|
1812
|
+
options: Q,
|
|
1813
|
+
fn: E,
|
|
1814
|
+
queryStore: t,
|
|
1815
|
+
serializedKey: o,
|
|
1816
|
+
trigger: z,
|
|
1817
|
+
trigger$: j
|
|
1818
|
+
})
|
|
1819
|
+
),
|
|
1820
|
+
xt,
|
|
1821
|
+
D(c),
|
|
1822
|
+
ve(([E, Q]) => !(E.data !== void 0 && Q.terminateOnFirstResult), !0),
|
|
1823
|
+
p(([E]) => E),
|
|
1824
|
+
ae(() => {
|
|
1825
|
+
b();
|
|
1826
|
+
})
|
|
1827
|
+
)
|
|
2297
1828
|
};
|
|
2298
|
-
}
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
})(key$)
|
|
1829
|
+
}, u = jt(
|
|
1830
|
+
t,
|
|
1831
|
+
(d) => d.pipe(
|
|
1832
|
+
w((h) => {
|
|
1833
|
+
const g = S(h);
|
|
1834
|
+
return O(
|
|
1835
|
+
Yt({
|
|
1836
|
+
queryStore: t
|
|
1837
|
+
})(g),
|
|
1838
|
+
zt({
|
|
1839
|
+
queryStore: t
|
|
1840
|
+
})(g),
|
|
1841
|
+
Gt({
|
|
1842
|
+
queryStore: t
|
|
1843
|
+
})(g)
|
|
2314
1844
|
);
|
|
2315
1845
|
})
|
|
2316
1846
|
)
|
|
2317
1847
|
);
|
|
2318
|
-
const destroy = () => {
|
|
2319
|
-
};
|
|
2320
|
-
const start = () => {
|
|
2321
|
-
hasCalledStart = true;
|
|
2322
|
-
const queryListenerSub = queryListener$.subscribe();
|
|
2323
|
-
const started = [queryStore.start()];
|
|
2324
|
-
return () => {
|
|
2325
|
-
started.forEach((destroy2) => {
|
|
2326
|
-
destroy2();
|
|
2327
|
-
});
|
|
2328
|
-
queryListenerSub.unsubscribe();
|
|
2329
|
-
};
|
|
2330
|
-
};
|
|
2331
1848
|
return {
|
|
2332
|
-
start
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
1849
|
+
start: () => {
|
|
1850
|
+
s = !0;
|
|
1851
|
+
const d = u.subscribe(), h = [t.start()];
|
|
1852
|
+
return () => {
|
|
1853
|
+
h.forEach((g) => {
|
|
1854
|
+
g();
|
|
1855
|
+
}), d.unsubscribe();
|
|
1856
|
+
};
|
|
1857
|
+
},
|
|
1858
|
+
query: i,
|
|
1859
|
+
queryStore: t,
|
|
1860
|
+
...e,
|
|
1861
|
+
...r,
|
|
1862
|
+
...n,
|
|
1863
|
+
destroy: () => {
|
|
1864
|
+
}
|
|
2339
1865
|
};
|
|
2340
1866
|
};
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
1867
|
+
var re;
|
|
1868
|
+
class Sr {
|
|
1869
|
+
constructor({ mutationCache: e } = {
|
|
1870
|
+
mutationCache: new rr()
|
|
2344
1871
|
}) {
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
this.mutationCache = mutationCache;
|
|
2350
|
-
this.mutationRunners = new MutationRunners(this);
|
|
2351
|
-
this.mutationObserver = new MutationObserver(this);
|
|
2352
|
-
this.client = createClient();
|
|
1872
|
+
y(this, "client");
|
|
1873
|
+
y(this, "mutationCache");
|
|
1874
|
+
de(this, re, /* @__PURE__ */ new Map());
|
|
1875
|
+
this.mutationCache = e, this.client = nr();
|
|
2353
1876
|
}
|
|
2354
1877
|
mount() {
|
|
2355
|
-
const
|
|
1878
|
+
const e = this.client.start();
|
|
2356
1879
|
return () => {
|
|
2357
|
-
|
|
2358
|
-
stop();
|
|
1880
|
+
e();
|
|
2359
1881
|
};
|
|
2360
1882
|
}
|
|
2361
1883
|
getMutationCache() {
|
|
2362
1884
|
return this.mutationCache;
|
|
2363
1885
|
}
|
|
2364
|
-
defaultMutationOptions(
|
|
2365
|
-
return
|
|
1886
|
+
defaultMutationOptions(e) {
|
|
1887
|
+
return {
|
|
1888
|
+
...(e == null ? void 0 : e.mutationKey) && this.getMutationDefaults(e.mutationKey),
|
|
1889
|
+
...e
|
|
1890
|
+
};
|
|
1891
|
+
}
|
|
1892
|
+
getMutationDefaults(e) {
|
|
1893
|
+
const r = [...k(this, re).values()];
|
|
1894
|
+
let n = {};
|
|
1895
|
+
return r.forEach((s) => {
|
|
1896
|
+
te(e, s.mutationKey) && (n = { ...n, ...s.defaultOptions });
|
|
1897
|
+
}), n;
|
|
1898
|
+
}
|
|
1899
|
+
setMutationDefaults(e, r) {
|
|
1900
|
+
k(this, re).set(N(e), {
|
|
1901
|
+
mutationKey: e,
|
|
1902
|
+
defaultOptions: r
|
|
1903
|
+
});
|
|
1904
|
+
}
|
|
1905
|
+
async resumePausedMutations() {
|
|
1906
|
+
return await nt(this.mutationCache.resumePausedMutations());
|
|
2366
1907
|
}
|
|
2367
1908
|
clear() {
|
|
2368
1909
|
}
|
|
2369
1910
|
}
|
|
1911
|
+
re = new WeakMap();
|
|
2370
1912
|
export {
|
|
2371
|
-
MutationCache,
|
|
2372
|
-
QueryClient,
|
|
2373
|
-
QueryClientProvider,
|
|
2374
|
-
SIGNAL_RESET,
|
|
2375
|
-
createClient,
|
|
2376
|
-
createLocalforageAdapter,
|
|
2377
|
-
createSharedStoreAdapter,
|
|
2378
|
-
exponentialBackoffDelay,
|
|
2379
|
-
getDelay,
|
|
2380
|
-
retryBackoff,
|
|
2381
|
-
signal,
|
|
2382
|
-
trigger,
|
|
2383
|
-
useBehaviorSubject,
|
|
2384
|
-
useLiveRef,
|
|
2385
|
-
useMutation,
|
|
2386
|
-
useObserve,
|
|
2387
|
-
useObserveCallback,
|
|
2388
|
-
usePersistSignals,
|
|
2389
|
-
useQuery,
|
|
2390
|
-
useQueryClient,
|
|
2391
|
-
useSignalValue,
|
|
2392
|
-
useSubject,
|
|
2393
|
-
useSubscribe,
|
|
2394
|
-
useSubscribeEffect,
|
|
2395
|
-
useUnmountObservable
|
|
1913
|
+
rr as MutationCache,
|
|
1914
|
+
Sr as QueryClient,
|
|
1915
|
+
br as QueryClientProvider,
|
|
1916
|
+
pt as SIGNAL_RESET,
|
|
1917
|
+
nr as createClient,
|
|
1918
|
+
hr as createLocalforageAdapter,
|
|
1919
|
+
dr as createSharedStoreAdapter,
|
|
1920
|
+
bt as exponentialBackoffDelay,
|
|
1921
|
+
mt as getDelay,
|
|
1922
|
+
yt as retryBackoff,
|
|
1923
|
+
pr as signal,
|
|
1924
|
+
lr as trigger,
|
|
1925
|
+
lt as useBehaviorSubject,
|
|
1926
|
+
U as useLiveRef,
|
|
1927
|
+
yr as useMutation,
|
|
1928
|
+
fe as useObserve,
|
|
1929
|
+
ar as useObserveCallback,
|
|
1930
|
+
gr as usePersistSignals,
|
|
1931
|
+
$r as useQuery,
|
|
1932
|
+
Pe as useQueryClient,
|
|
1933
|
+
fr as useSignalValue,
|
|
1934
|
+
Oe as useSubject,
|
|
1935
|
+
Se as useSubscribe,
|
|
1936
|
+
vr as useSubscribeEffect,
|
|
1937
|
+
mr as useUnmountObservable
|
|
2396
1938
|
};
|