gitxp 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.output/nitro.json +17 -0
- package/.output/public/assets/index-BGHvBNtP.js +11 -0
- package/.output/public/assets/routes-DuE8S6pX.js +60 -0
- package/.output/public/assets/styles-D5xbQNYu.css +1 -0
- package/.output/server/_chunks/ssr-renderer.mjs +26 -0
- package/.output/server/_libs/@floating-ui/core+[...].mjs +671 -0
- package/.output/server/_libs/@floating-ui/dom+[...].mjs +649 -0
- package/.output/server/_libs/@floating-ui/react-dom+[...].mjs +856 -0
- package/.output/server/_libs/@radix-ui/react-arrow+[...].mjs +258 -0
- package/.output/server/_libs/@radix-ui/react-dialog+[...].mjs +1862 -0
- package/.output/server/_libs/@radix-ui/react-popper+[...].mjs +320 -0
- package/.output/server/_libs/@radix-ui/react-tooltip+[...].mjs +534 -0
- package/.output/server/_libs/@tanstack/db+[...].mjs +14680 -0
- package/.output/server/_libs/@tanstack/react-router+[...].mjs +14563 -0
- package/.output/server/_libs/@tanstack/react-router-ssr-query+[...].mjs +126 -0
- package/.output/server/_libs/@tanstack/router-core+[...].mjs +3636 -0
- package/.output/server/_libs/class-variance-authority+clsx.mjs +69 -0
- package/.output/server/_libs/cmdk.mjs +504 -0
- package/.output/server/_libs/h3+rou3+srvx.mjs +1361 -0
- package/.output/server/_libs/h3-v2.mjs +285 -0
- package/.output/server/_libs/lucide-react.mjs +158 -0
- package/.output/server/_libs/radix-ui__primitive.mjs +44 -0
- package/.output/server/_libs/radix-ui__react-context.mjs +108 -0
- package/.output/server/_libs/tailwind-merge.mjs +3380 -0
- package/.output/server/_libs/tanstack__history.mjs +384 -0
- package/.output/server/_libs/tanstack__query-core.mjs +2225 -0
- package/.output/server/_libs/tanstack__react-db.mjs +242 -0
- package/.output/server/_libs/tanstack__react-query.mjs +140 -0
- package/.output/server/_libs/ufo.mjs +64 -0
- package/.output/server/_runtime.mjs +35 -0
- package/.output/server/_ssr/empty-plugin-adapters-D9UWiqvJ.mjs +5 -0
- package/.output/server/_ssr/events-BNrmOvgU.mjs +13 -0
- package/.output/server/_ssr/notifications-DUoENv6E.mjs +514 -0
- package/.output/server/_ssr/router-DsUHD4bT.mjs +179 -0
- package/.output/server/_ssr/routes-DIFfr242.mjs +982 -0
- package/.output/server/_ssr/ssr.mjs +1854 -0
- package/.output/server/_ssr/start-5Z2QO8AU.mjs +4 -0
- package/.output/server/_tanstack-start-manifest_v-CrD0YpZr.mjs +20 -0
- package/.output/server/index.mjs +310 -0
- package/.output/server/node_modules/tslib/modules/index.js +70 -0
- package/.output/server/node_modules/tslib/modules/package.json +3 -0
- package/.output/server/node_modules/tslib/package.json +47 -0
- package/.output/server/node_modules/tslib/tslib.js +484 -0
- package/.output/server/package.json +9 -0
- package/LICENSE +21 -0
- package/README.md +325 -0
- package/bin/gitxp.js +85 -0
- package/package.json +92 -0
|
@@ -0,0 +1,2225 @@
|
|
|
1
|
+
//#region node_modules/@tanstack/query-core/build/modern/timeoutManager.js
|
|
2
|
+
var defaultTimeoutProvider = {
|
|
3
|
+
setTimeout: (callback, delay) => setTimeout(callback, delay),
|
|
4
|
+
clearTimeout: (timeoutId) => clearTimeout(timeoutId),
|
|
5
|
+
setInterval: (callback, delay) => setInterval(callback, delay),
|
|
6
|
+
clearInterval: (intervalId) => clearInterval(intervalId)
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Allows customization of how timeouts are created.
|
|
10
|
+
*
|
|
11
|
+
* @tanstack/query-core makes liberal use of timeouts to implement `staleTime`
|
|
12
|
+
* and `gcTime`. The default TimeoutManager provider uses the platform's global
|
|
13
|
+
* `setTimeout` implementation, which is known to have scalability issues with
|
|
14
|
+
* thousands of timeouts on the event loop.
|
|
15
|
+
*
|
|
16
|
+
* If you hit this limitation, consider providing a custom TimeoutProvider that
|
|
17
|
+
* coalesces timeouts.
|
|
18
|
+
*/
|
|
19
|
+
var TimeoutManager = class {
|
|
20
|
+
#provider = defaultTimeoutProvider;
|
|
21
|
+
#providerCalled = false;
|
|
22
|
+
setTimeoutProvider(provider) {
|
|
23
|
+
this.#provider = provider;
|
|
24
|
+
}
|
|
25
|
+
setTimeout(callback, delay) {
|
|
26
|
+
return this.#provider.setTimeout(callback, delay);
|
|
27
|
+
}
|
|
28
|
+
clearTimeout(timeoutId) {
|
|
29
|
+
this.#provider.clearTimeout(timeoutId);
|
|
30
|
+
}
|
|
31
|
+
setInterval(callback, delay) {
|
|
32
|
+
return this.#provider.setInterval(callback, delay);
|
|
33
|
+
}
|
|
34
|
+
clearInterval(intervalId) {
|
|
35
|
+
this.#provider.clearInterval(intervalId);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var timeoutManager = new TimeoutManager();
|
|
39
|
+
/**
|
|
40
|
+
* In many cases code wants to delay to the next event loop tick; this is not
|
|
41
|
+
* mediated by {@link timeoutManager}.
|
|
42
|
+
*
|
|
43
|
+
* This function is provided to make auditing the `tanstack/query-core` for
|
|
44
|
+
* incorrect use of system `setTimeout` easier.
|
|
45
|
+
*/
|
|
46
|
+
function systemSetTimeoutZero(callback) {
|
|
47
|
+
setTimeout(callback, 0);
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region node_modules/@tanstack/query-core/build/modern/utils.js
|
|
51
|
+
/** @deprecated
|
|
52
|
+
* use `environmentManager.isServer()` instead.
|
|
53
|
+
*/
|
|
54
|
+
var isServer$1 = typeof window === "undefined" || "Deno" in globalThis;
|
|
55
|
+
function noop() {}
|
|
56
|
+
function functionalUpdate(updater, input) {
|
|
57
|
+
return typeof updater === "function" ? updater(input) : updater;
|
|
58
|
+
}
|
|
59
|
+
function isValidTimeout(value) {
|
|
60
|
+
return typeof value === "number" && value >= 0 && value !== Infinity;
|
|
61
|
+
}
|
|
62
|
+
function timeUntilStale(updatedAt, staleTime) {
|
|
63
|
+
return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0);
|
|
64
|
+
}
|
|
65
|
+
function resolveQueryValue(value, query) {
|
|
66
|
+
return typeof value === "function" ? value(query) : value;
|
|
67
|
+
}
|
|
68
|
+
function matchQuery(filters, query) {
|
|
69
|
+
const { type = "all", exact, fetchStatus, predicate, queryKey, stale } = filters;
|
|
70
|
+
if (queryKey) {
|
|
71
|
+
if (exact) {
|
|
72
|
+
if (query.queryHash !== hashQueryKeyByOptions(queryKey, query.options)) return false;
|
|
73
|
+
} else if (!partialMatchKey(query.queryKey, queryKey)) return false;
|
|
74
|
+
}
|
|
75
|
+
if (type !== "all") {
|
|
76
|
+
const isActive = query.isActive();
|
|
77
|
+
if (type === "active" && !isActive) return false;
|
|
78
|
+
if (type === "inactive" && isActive) return false;
|
|
79
|
+
}
|
|
80
|
+
if (typeof stale === "boolean" && query.isStale() !== stale) return false;
|
|
81
|
+
if (fetchStatus && fetchStatus !== query.state.fetchStatus) return false;
|
|
82
|
+
if (predicate && !predicate(query)) return false;
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
function matchMutation(filters, mutation) {
|
|
86
|
+
const { exact, status, predicate, mutationKey } = filters;
|
|
87
|
+
if (mutationKey) {
|
|
88
|
+
if (!mutation.options.mutationKey) return false;
|
|
89
|
+
if (exact) {
|
|
90
|
+
if (hashKey(mutation.options.mutationKey) !== hashKey(mutationKey)) return false;
|
|
91
|
+
} else if (!partialMatchKey(mutation.options.mutationKey, mutationKey)) return false;
|
|
92
|
+
}
|
|
93
|
+
if (status && mutation.state.status !== status) return false;
|
|
94
|
+
if (predicate && !predicate(mutation)) return false;
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
function hashQueryKeyByOptions(queryKey, options) {
|
|
98
|
+
return (options?.queryKeyHashFn || hashKey)(queryKey);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Default query & mutation keys hash function.
|
|
102
|
+
* Hashes the value into a stable hash.
|
|
103
|
+
*/
|
|
104
|
+
function hashKey(queryKey) {
|
|
105
|
+
return JSON.stringify(queryKey, (_, val) => isPlainObject(val) ? Object.keys(val).sort().reduce((result, key) => {
|
|
106
|
+
result[key] = val[key];
|
|
107
|
+
return result;
|
|
108
|
+
}, {}) : val);
|
|
109
|
+
}
|
|
110
|
+
function partialMatchKey(a, b) {
|
|
111
|
+
if (a === b) return true;
|
|
112
|
+
if (typeof a !== typeof b) return false;
|
|
113
|
+
if (a && b && typeof a === "object" && typeof b === "object") {
|
|
114
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
115
|
+
for (let i = 0; i < b.length; i++) if (!partialMatchKey(a[i], b[i])) return false;
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
const bKeys = Object.keys(b);
|
|
119
|
+
for (const key of bKeys) if (!partialMatchKey(a[key], b[key])) return false;
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
var hasOwn = Object.prototype.hasOwnProperty;
|
|
125
|
+
function replaceEqualDeep(a, b, depth = 0) {
|
|
126
|
+
if (a === b) return a;
|
|
127
|
+
if (depth > 500) return b;
|
|
128
|
+
const array = isPlainArray(a) && isPlainArray(b);
|
|
129
|
+
if (!array && !(isPlainObject(a) && isPlainObject(b))) return b;
|
|
130
|
+
const aSize = (array ? a : Object.keys(a)).length;
|
|
131
|
+
const bItems = array ? b : Object.keys(b);
|
|
132
|
+
const bSize = bItems.length;
|
|
133
|
+
const copy = array ? new Array(bSize) : {};
|
|
134
|
+
let equalItems = 0;
|
|
135
|
+
for (let i = 0; i < bSize; i++) {
|
|
136
|
+
const key = array ? i : bItems[i];
|
|
137
|
+
const aItem = a[key];
|
|
138
|
+
const bItem = b[key];
|
|
139
|
+
if (aItem === bItem) {
|
|
140
|
+
copy[key] = aItem;
|
|
141
|
+
if (array ? i < aSize : hasOwn.call(a, key)) equalItems++;
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
if (aItem === null || bItem === null || typeof aItem !== "object" || typeof bItem !== "object") {
|
|
145
|
+
copy[key] = bItem;
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
const v = replaceEqualDeep(aItem, bItem, depth + 1);
|
|
149
|
+
copy[key] = v;
|
|
150
|
+
if (v === aItem) equalItems++;
|
|
151
|
+
}
|
|
152
|
+
return aSize === bSize && equalItems === aSize ? a : copy;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Shallow compare objects.
|
|
156
|
+
*/
|
|
157
|
+
function shallowEqualObjects(a, b) {
|
|
158
|
+
if (!b || Object.keys(a).length !== Object.keys(b).length) return false;
|
|
159
|
+
for (const key in a) if (a[key] !== b[key]) return false;
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
function isPlainArray(value) {
|
|
163
|
+
return Array.isArray(value) && value.length === Object.keys(value).length;
|
|
164
|
+
}
|
|
165
|
+
function isPlainObject(o) {
|
|
166
|
+
if (!hasObjectPrototype(o)) return false;
|
|
167
|
+
const ctor = o.constructor;
|
|
168
|
+
if (ctor === void 0) return true;
|
|
169
|
+
const prot = ctor.prototype;
|
|
170
|
+
if (!hasObjectPrototype(prot)) return false;
|
|
171
|
+
if (!prot.hasOwnProperty("isPrototypeOf")) return false;
|
|
172
|
+
if (Object.getPrototypeOf(o) !== Object.prototype) return false;
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
function hasObjectPrototype(o) {
|
|
176
|
+
return Object.prototype.toString.call(o) === "[object Object]";
|
|
177
|
+
}
|
|
178
|
+
function sleep(timeout) {
|
|
179
|
+
return new Promise((resolve) => {
|
|
180
|
+
timeoutManager.setTimeout(resolve, timeout);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
function replaceData(prevData, data, options) {
|
|
184
|
+
if (typeof options.structuralSharing === "function") return options.structuralSharing(prevData, data);
|
|
185
|
+
else if (options.structuralSharing !== false) return replaceEqualDeep(prevData, data);
|
|
186
|
+
return data;
|
|
187
|
+
}
|
|
188
|
+
function addToEnd(items, item, max = 0) {
|
|
189
|
+
const newItems = [...items, item];
|
|
190
|
+
return max && newItems.length > max ? newItems.slice(1) : newItems;
|
|
191
|
+
}
|
|
192
|
+
function addToStart(items, item, max = 0) {
|
|
193
|
+
const newItems = [item, ...items];
|
|
194
|
+
return max && newItems.length > max ? newItems.slice(0, -1) : newItems;
|
|
195
|
+
}
|
|
196
|
+
var skipToken = Symbol();
|
|
197
|
+
function ensureQueryFn(options, fetchOptions) {
|
|
198
|
+
if (!options.queryFn && fetchOptions?.initialPromise) return () => fetchOptions.initialPromise;
|
|
199
|
+
if (!options.queryFn || options.queryFn === skipToken) return () => Promise.reject(/* @__PURE__ */ new Error(`Missing queryFn: '${options.queryHash}'`));
|
|
200
|
+
return options.queryFn;
|
|
201
|
+
}
|
|
202
|
+
function shouldThrowError(throwOnError, params) {
|
|
203
|
+
if (typeof throwOnError === "function") return throwOnError(...params);
|
|
204
|
+
return !!throwOnError;
|
|
205
|
+
}
|
|
206
|
+
function addConsumeAwareSignal(object, getSignal, onCancelled) {
|
|
207
|
+
let consumed = false;
|
|
208
|
+
let signal;
|
|
209
|
+
Object.defineProperty(object, "signal", {
|
|
210
|
+
enumerable: true,
|
|
211
|
+
get: () => {
|
|
212
|
+
signal ??= getSignal();
|
|
213
|
+
if (consumed) return signal;
|
|
214
|
+
consumed = true;
|
|
215
|
+
if (signal.aborted) onCancelled();
|
|
216
|
+
else signal.addEventListener("abort", onCancelled, { once: true });
|
|
217
|
+
return signal;
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
return object;
|
|
221
|
+
}
|
|
222
|
+
//#endregion
|
|
223
|
+
//#region node_modules/@tanstack/query-core/build/modern/environmentManager.js
|
|
224
|
+
var isServerFn = () => isServer$1;
|
|
225
|
+
/**
|
|
226
|
+
* Returns whether the current runtime should be treated as a server environment.
|
|
227
|
+
*/
|
|
228
|
+
var isServer = () => isServerFn();
|
|
229
|
+
//#endregion
|
|
230
|
+
//#region node_modules/@tanstack/query-core/build/modern/subscribable.js
|
|
231
|
+
var Subscribable = class {
|
|
232
|
+
constructor() {
|
|
233
|
+
this.listeners = /* @__PURE__ */ new Set();
|
|
234
|
+
this.subscribe = this.subscribe.bind(this);
|
|
235
|
+
}
|
|
236
|
+
subscribe(listener) {
|
|
237
|
+
this.listeners.add(listener);
|
|
238
|
+
this.onSubscribe();
|
|
239
|
+
return () => {
|
|
240
|
+
this.listeners.delete(listener);
|
|
241
|
+
this.onUnsubscribe();
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
hasListeners() {
|
|
245
|
+
return this.listeners.size > 0;
|
|
246
|
+
}
|
|
247
|
+
onSubscribe() {}
|
|
248
|
+
onUnsubscribe() {}
|
|
249
|
+
};
|
|
250
|
+
//#endregion
|
|
251
|
+
//#region node_modules/@tanstack/query-core/build/modern/focusManager.js
|
|
252
|
+
var FocusManager = class extends Subscribable {
|
|
253
|
+
#focused;
|
|
254
|
+
#cleanup;
|
|
255
|
+
#setup;
|
|
256
|
+
constructor() {
|
|
257
|
+
super();
|
|
258
|
+
this.#setup = (onFocus) => {
|
|
259
|
+
if (typeof window !== "undefined" && window.addEventListener) {
|
|
260
|
+
const listener = () => onFocus();
|
|
261
|
+
window.addEventListener("visibilitychange", listener, false);
|
|
262
|
+
return () => {
|
|
263
|
+
window.removeEventListener("visibilitychange", listener);
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
onSubscribe() {
|
|
269
|
+
if (!this.#cleanup) this.setEventListener(this.#setup);
|
|
270
|
+
}
|
|
271
|
+
onUnsubscribe() {
|
|
272
|
+
if (!this.hasListeners()) {
|
|
273
|
+
this.#cleanup?.();
|
|
274
|
+
this.#cleanup = void 0;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
setEventListener(setup) {
|
|
278
|
+
this.#setup = setup;
|
|
279
|
+
this.#cleanup?.();
|
|
280
|
+
this.#cleanup = setup((focused) => {
|
|
281
|
+
if (typeof focused === "boolean") this.setFocused(focused);
|
|
282
|
+
else this.onFocus();
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
setFocused(focused) {
|
|
286
|
+
if (this.#focused !== focused) {
|
|
287
|
+
this.#focused = focused;
|
|
288
|
+
this.onFocus();
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
onFocus() {
|
|
292
|
+
const isFocused = this.isFocused();
|
|
293
|
+
this.listeners.forEach((listener) => {
|
|
294
|
+
listener(isFocused);
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
isFocused() {
|
|
298
|
+
if (typeof this.#focused === "boolean") return this.#focused;
|
|
299
|
+
return globalThis.document?.visibilityState !== "hidden";
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
var focusManager = new FocusManager();
|
|
303
|
+
//#endregion
|
|
304
|
+
//#region node_modules/@tanstack/query-core/build/modern/hydration.js
|
|
305
|
+
function tryResolveSync(promise) {
|
|
306
|
+
let data;
|
|
307
|
+
promise.then((result) => {
|
|
308
|
+
data = result;
|
|
309
|
+
return result;
|
|
310
|
+
}, noop)?.catch?.(noop);
|
|
311
|
+
if (data !== void 0) return { data };
|
|
312
|
+
}
|
|
313
|
+
function dehydratePromise(query, serializeData, shouldRedactErrors) {
|
|
314
|
+
const promise = query.promise?.then(serializeData).catch((error) => {
|
|
315
|
+
if (shouldRedactErrors?.(error) === false) return Promise.reject(error);
|
|
316
|
+
return Promise.reject(/* @__PURE__ */ new Error("redacted"));
|
|
317
|
+
});
|
|
318
|
+
promise?.catch(noop);
|
|
319
|
+
return promise;
|
|
320
|
+
}
|
|
321
|
+
function dehydrateQuery(query, serializeData, shouldRedactErrors) {
|
|
322
|
+
return {
|
|
323
|
+
dehydratedAt: Date.now(),
|
|
324
|
+
state: {
|
|
325
|
+
...query.state,
|
|
326
|
+
...query.state.data !== void 0 && { data: serializeData ? serializeData(query.state.data) : query.state.data }
|
|
327
|
+
},
|
|
328
|
+
queryKey: query.queryKey,
|
|
329
|
+
queryHash: query.queryHash,
|
|
330
|
+
...query.state.status === "pending" && { promise: dehydratePromise(query, serializeData, shouldRedactErrors) },
|
|
331
|
+
...query.meta && { meta: query.meta },
|
|
332
|
+
...query.queryType && { queryType: query.queryType }
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
function hydrate(client, dehydratedState, options) {
|
|
336
|
+
const mutationCache = client.getMutationCache();
|
|
337
|
+
const queryCache = client.getQueryCache();
|
|
338
|
+
const deserializeData = options?.defaultOptions?.deserializeData ?? client.getDefaultOptions().hydrate?.deserializeData;
|
|
339
|
+
dehydratedState.mutations?.forEach(({ state, ...mutationOptions }) => {
|
|
340
|
+
mutationCache.build(client, {
|
|
341
|
+
...client.getDefaultOptions().hydrate?.mutations,
|
|
342
|
+
...options?.defaultOptions?.mutations,
|
|
343
|
+
...mutationOptions
|
|
344
|
+
}, state);
|
|
345
|
+
});
|
|
346
|
+
dehydratedState.queries?.forEach(({ queryKey, state, queryHash, meta, promise, dehydratedAt, queryType }) => {
|
|
347
|
+
const syncData = promise ? tryResolveSync(promise) : void 0;
|
|
348
|
+
const rawData = state.data === void 0 ? syncData?.data : state.data;
|
|
349
|
+
const data = rawData === void 0 ? rawData : deserializeData ? deserializeData(rawData) : rawData;
|
|
350
|
+
let query = queryCache.get(queryHash);
|
|
351
|
+
const existingQueryIsPending = query?.state.status === "pending";
|
|
352
|
+
const existingQueryIsFetching = query?.state.fetchStatus === "fetching";
|
|
353
|
+
if (query) {
|
|
354
|
+
const hasNewerSyncData = syncData && dehydratedAt !== void 0 && dehydratedAt > query.state.dataUpdatedAt;
|
|
355
|
+
if (state.dataUpdatedAt > query.state.dataUpdatedAt || hasNewerSyncData) {
|
|
356
|
+
const { fetchStatus: _ignored, ...serializedState } = state;
|
|
357
|
+
query.setState({
|
|
358
|
+
...serializedState,
|
|
359
|
+
data,
|
|
360
|
+
...state.status === "pending" && data !== void 0 && {
|
|
361
|
+
status: "success",
|
|
362
|
+
dataUpdatedAt: dehydratedAt ?? Date.now(),
|
|
363
|
+
...!existingQueryIsFetching && { fetchStatus: "idle" }
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
} else query = queryCache.build(client, {
|
|
368
|
+
...client.getDefaultOptions().hydrate?.queries,
|
|
369
|
+
...options?.defaultOptions?.queries,
|
|
370
|
+
queryKey,
|
|
371
|
+
queryHash,
|
|
372
|
+
meta,
|
|
373
|
+
_type: queryType
|
|
374
|
+
}, {
|
|
375
|
+
...state,
|
|
376
|
+
data,
|
|
377
|
+
fetchStatus: "idle",
|
|
378
|
+
status: state.status === "pending" && data !== void 0 ? "success" : state.status,
|
|
379
|
+
...state.status === "pending" && data !== void 0 && { dataUpdatedAt: dehydratedAt ?? Date.now() }
|
|
380
|
+
});
|
|
381
|
+
if (promise && !syncData && !existingQueryIsPending && !existingQueryIsFetching && (dehydratedAt === void 0 || dehydratedAt > query.state.dataUpdatedAt)) query.fetch(void 0, { initialPromise: Promise.resolve(promise).then(deserializeData) }).catch(noop);
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
//#endregion
|
|
385
|
+
//#region node_modules/@tanstack/query-core/build/modern/notifyManager.js
|
|
386
|
+
var defaultScheduler = systemSetTimeoutZero;
|
|
387
|
+
function createNotifyManager() {
|
|
388
|
+
let queue = [];
|
|
389
|
+
let transactions = 0;
|
|
390
|
+
let notifyFn = (callback) => {
|
|
391
|
+
callback();
|
|
392
|
+
};
|
|
393
|
+
let batchNotifyFn = (callback) => {
|
|
394
|
+
callback();
|
|
395
|
+
};
|
|
396
|
+
let scheduleFn = defaultScheduler;
|
|
397
|
+
const schedule = (callback) => {
|
|
398
|
+
if (transactions) queue.push(callback);
|
|
399
|
+
else scheduleFn(() => {
|
|
400
|
+
notifyFn(callback);
|
|
401
|
+
});
|
|
402
|
+
};
|
|
403
|
+
const flush = () => {
|
|
404
|
+
const originalQueue = queue;
|
|
405
|
+
queue = [];
|
|
406
|
+
if (originalQueue.length) scheduleFn(() => {
|
|
407
|
+
batchNotifyFn(() => {
|
|
408
|
+
originalQueue.forEach((callback) => {
|
|
409
|
+
notifyFn(callback);
|
|
410
|
+
});
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
};
|
|
414
|
+
return {
|
|
415
|
+
batch: (callback) => {
|
|
416
|
+
let result;
|
|
417
|
+
transactions++;
|
|
418
|
+
try {
|
|
419
|
+
result = callback();
|
|
420
|
+
} finally {
|
|
421
|
+
transactions--;
|
|
422
|
+
if (!transactions) flush();
|
|
423
|
+
}
|
|
424
|
+
return result;
|
|
425
|
+
},
|
|
426
|
+
/**
|
|
427
|
+
* All calls to the wrapped function will be batched.
|
|
428
|
+
*/
|
|
429
|
+
batchCalls: (callback) => {
|
|
430
|
+
return (...args) => {
|
|
431
|
+
schedule(() => {
|
|
432
|
+
callback(...args);
|
|
433
|
+
});
|
|
434
|
+
};
|
|
435
|
+
},
|
|
436
|
+
schedule,
|
|
437
|
+
/**
|
|
438
|
+
* Use this method to set a custom notify function.
|
|
439
|
+
* This can be used to for example wrap notifications with `React.act` while running tests.
|
|
440
|
+
*/
|
|
441
|
+
setNotifyFunction: (fn) => {
|
|
442
|
+
notifyFn = fn;
|
|
443
|
+
},
|
|
444
|
+
/**
|
|
445
|
+
* Use this method to set a custom function to batch notifications together into a single tick.
|
|
446
|
+
* By default React Query will use the batch function provided by ReactDOM or React Native.
|
|
447
|
+
*/
|
|
448
|
+
setBatchNotifyFunction: (fn) => {
|
|
449
|
+
batchNotifyFn = fn;
|
|
450
|
+
},
|
|
451
|
+
setScheduler: (fn) => {
|
|
452
|
+
scheduleFn = fn;
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
var notifyManager = createNotifyManager();
|
|
457
|
+
//#endregion
|
|
458
|
+
//#region node_modules/@tanstack/query-core/build/modern/onlineManager.js
|
|
459
|
+
var OnlineManager = class extends Subscribable {
|
|
460
|
+
#online = true;
|
|
461
|
+
#cleanup;
|
|
462
|
+
#setup;
|
|
463
|
+
constructor() {
|
|
464
|
+
super();
|
|
465
|
+
this.#setup = (onOnline) => {
|
|
466
|
+
if (typeof window !== "undefined" && window.addEventListener) {
|
|
467
|
+
const onlineListener = () => onOnline(true);
|
|
468
|
+
const offlineListener = () => onOnline(false);
|
|
469
|
+
window.addEventListener("online", onlineListener, false);
|
|
470
|
+
window.addEventListener("offline", offlineListener, false);
|
|
471
|
+
return () => {
|
|
472
|
+
window.removeEventListener("online", onlineListener);
|
|
473
|
+
window.removeEventListener("offline", offlineListener);
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
onSubscribe() {
|
|
479
|
+
if (!this.#cleanup) this.setEventListener(this.#setup);
|
|
480
|
+
}
|
|
481
|
+
onUnsubscribe() {
|
|
482
|
+
if (!this.hasListeners()) {
|
|
483
|
+
this.#cleanup?.();
|
|
484
|
+
this.#cleanup = void 0;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
setEventListener(setup) {
|
|
488
|
+
this.#setup = setup;
|
|
489
|
+
this.#cleanup?.();
|
|
490
|
+
this.#cleanup = setup(this.setOnline.bind(this));
|
|
491
|
+
}
|
|
492
|
+
setOnline(online) {
|
|
493
|
+
if (this.#online !== online) {
|
|
494
|
+
this.#online = online;
|
|
495
|
+
this.listeners.forEach((listener) => {
|
|
496
|
+
listener(online);
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
isOnline() {
|
|
501
|
+
return this.#online;
|
|
502
|
+
}
|
|
503
|
+
};
|
|
504
|
+
var onlineManager = new OnlineManager();
|
|
505
|
+
//#endregion
|
|
506
|
+
//#region node_modules/@tanstack/query-core/build/modern/retryer.js
|
|
507
|
+
function defaultRetryDelay(failureCount) {
|
|
508
|
+
return Math.min(1e3 * 2 ** failureCount, 3e4);
|
|
509
|
+
}
|
|
510
|
+
function canFetch(networkMode) {
|
|
511
|
+
return (networkMode ?? "online") === "online" ? onlineManager.isOnline() : true;
|
|
512
|
+
}
|
|
513
|
+
var CancelledError = class extends Error {
|
|
514
|
+
constructor(options) {
|
|
515
|
+
super("CancelledError");
|
|
516
|
+
this.revert = options?.revert;
|
|
517
|
+
this.silent = options?.silent;
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
function createRetryer(config) {
|
|
521
|
+
let isRetryCancelled = false;
|
|
522
|
+
let failureCount = 0;
|
|
523
|
+
let continueFn;
|
|
524
|
+
let status = "pending";
|
|
525
|
+
let promiseResolve;
|
|
526
|
+
let promiseReject;
|
|
527
|
+
const promise = new Promise((resolve, reject) => {
|
|
528
|
+
promiseResolve = resolve;
|
|
529
|
+
promiseReject = reject;
|
|
530
|
+
});
|
|
531
|
+
promise.catch(noop);
|
|
532
|
+
const isResolved = () => status !== "pending";
|
|
533
|
+
const cancel = (cancelOptions) => {
|
|
534
|
+
if (!isResolved()) {
|
|
535
|
+
const error = new CancelledError(cancelOptions);
|
|
536
|
+
reject(error);
|
|
537
|
+
config.onCancel?.(error);
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
const cancelRetry = () => {
|
|
541
|
+
isRetryCancelled = true;
|
|
542
|
+
};
|
|
543
|
+
const continueRetry = () => {
|
|
544
|
+
isRetryCancelled = false;
|
|
545
|
+
};
|
|
546
|
+
const canContinue = () => focusManager.isFocused() && (config.networkMode === "always" || onlineManager.isOnline()) && config.canRun();
|
|
547
|
+
const canStart = () => canFetch(config.networkMode) && config.canRun();
|
|
548
|
+
const resolve = (value) => {
|
|
549
|
+
if (!isResolved()) {
|
|
550
|
+
continueFn?.();
|
|
551
|
+
status = "resolved";
|
|
552
|
+
promiseResolve(value);
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
const reject = (value) => {
|
|
556
|
+
if (!isResolved()) {
|
|
557
|
+
continueFn?.();
|
|
558
|
+
status = "rejected";
|
|
559
|
+
promiseReject(value);
|
|
560
|
+
}
|
|
561
|
+
};
|
|
562
|
+
const pause = () => {
|
|
563
|
+
return new Promise((continueResolve) => {
|
|
564
|
+
continueFn = (value) => {
|
|
565
|
+
if (isResolved() || canContinue()) continueResolve(value);
|
|
566
|
+
};
|
|
567
|
+
config.onPause?.();
|
|
568
|
+
}).then(() => {
|
|
569
|
+
continueFn = void 0;
|
|
570
|
+
if (!isResolved()) config.onContinue?.();
|
|
571
|
+
});
|
|
572
|
+
};
|
|
573
|
+
const run = () => {
|
|
574
|
+
if (isResolved()) return;
|
|
575
|
+
let promiseOrValue;
|
|
576
|
+
const initialPromise = failureCount === 0 ? config.initialPromise : void 0;
|
|
577
|
+
try {
|
|
578
|
+
promiseOrValue = initialPromise ?? config.fn();
|
|
579
|
+
} catch (error) {
|
|
580
|
+
promiseOrValue = Promise.reject(error);
|
|
581
|
+
}
|
|
582
|
+
Promise.resolve(promiseOrValue).then(resolve).catch((error) => {
|
|
583
|
+
if (isResolved()) return;
|
|
584
|
+
const retry = config.retry ?? (isServer() ? 0 : 3);
|
|
585
|
+
const retryDelay = config.retryDelay ?? defaultRetryDelay;
|
|
586
|
+
const delay = typeof retryDelay === "function" ? retryDelay(failureCount, error) : retryDelay;
|
|
587
|
+
const shouldRetry = retry === true || typeof retry === "number" && failureCount < retry || typeof retry === "function" && retry(failureCount, error);
|
|
588
|
+
if (isRetryCancelled || !shouldRetry) {
|
|
589
|
+
reject(error);
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
failureCount++;
|
|
593
|
+
config.onFail?.(failureCount, error);
|
|
594
|
+
sleep(delay).then(() => {
|
|
595
|
+
return canContinue() ? void 0 : pause();
|
|
596
|
+
}).then(() => {
|
|
597
|
+
if (isRetryCancelled) reject(error);
|
|
598
|
+
else run();
|
|
599
|
+
});
|
|
600
|
+
});
|
|
601
|
+
};
|
|
602
|
+
return {
|
|
603
|
+
promise,
|
|
604
|
+
status: () => status,
|
|
605
|
+
cancel,
|
|
606
|
+
continue: () => {
|
|
607
|
+
continueFn?.();
|
|
608
|
+
return promise;
|
|
609
|
+
},
|
|
610
|
+
cancelRetry,
|
|
611
|
+
continueRetry,
|
|
612
|
+
canStart,
|
|
613
|
+
start: () => {
|
|
614
|
+
if (canStart()) run();
|
|
615
|
+
else pause().then(run);
|
|
616
|
+
return promise;
|
|
617
|
+
}
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
//#endregion
|
|
621
|
+
//#region node_modules/@tanstack/query-core/build/modern/removable.js
|
|
622
|
+
var Removable = class {
|
|
623
|
+
#gcTimeout;
|
|
624
|
+
destroy() {
|
|
625
|
+
this.clearGcTimeout();
|
|
626
|
+
}
|
|
627
|
+
scheduleGc() {
|
|
628
|
+
this.clearGcTimeout();
|
|
629
|
+
if (isValidTimeout(this.gcTime)) this.#gcTimeout = timeoutManager.setTimeout(() => {
|
|
630
|
+
this.optionalRemove();
|
|
631
|
+
}, this.gcTime);
|
|
632
|
+
}
|
|
633
|
+
updateGcTime(newGcTime) {
|
|
634
|
+
this.gcTime = Math.max(this.gcTime || 0, newGcTime ?? (isServer() ? Infinity : 3e5));
|
|
635
|
+
}
|
|
636
|
+
clearGcTimeout() {
|
|
637
|
+
if (this.#gcTimeout !== void 0) {
|
|
638
|
+
timeoutManager.clearTimeout(this.#gcTimeout);
|
|
639
|
+
this.#gcTimeout = void 0;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
};
|
|
643
|
+
//#endregion
|
|
644
|
+
//#region node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js
|
|
645
|
+
function infiniteQueryBehavior(pages) {
|
|
646
|
+
return { onFetch: (context, query) => {
|
|
647
|
+
const options = context.options;
|
|
648
|
+
const direction = context.fetchOptions?.meta?.fetchMore?.direction;
|
|
649
|
+
const oldPages = context.state.data?.pages || [];
|
|
650
|
+
const oldPageParams = context.state.data?.pageParams || [];
|
|
651
|
+
let result = {
|
|
652
|
+
pages: [],
|
|
653
|
+
pageParams: []
|
|
654
|
+
};
|
|
655
|
+
let currentPage = 0;
|
|
656
|
+
const fetchFn = async () => {
|
|
657
|
+
let cancelled = false;
|
|
658
|
+
const addSignalProperty = (object) => {
|
|
659
|
+
addConsumeAwareSignal(object, () => context.signal, () => cancelled = true);
|
|
660
|
+
};
|
|
661
|
+
const queryFn = ensureQueryFn(context.options, context.fetchOptions);
|
|
662
|
+
const fetchPage = async (data, param, previous) => {
|
|
663
|
+
if (cancelled) return Promise.reject(context.signal.reason);
|
|
664
|
+
if (param == null && data.pages.length) return Promise.resolve(data);
|
|
665
|
+
const createQueryFnContext = () => {
|
|
666
|
+
const queryFnContext = {
|
|
667
|
+
client: context.client,
|
|
668
|
+
queryKey: context.queryKey,
|
|
669
|
+
pageParam: param,
|
|
670
|
+
direction: previous ? "backward" : "forward",
|
|
671
|
+
meta: context.options.meta
|
|
672
|
+
};
|
|
673
|
+
addSignalProperty(queryFnContext);
|
|
674
|
+
return queryFnContext;
|
|
675
|
+
};
|
|
676
|
+
const queryFnContext = createQueryFnContext();
|
|
677
|
+
const page = await queryFn(queryFnContext);
|
|
678
|
+
const { maxPages } = context.options;
|
|
679
|
+
const addTo = previous ? addToStart : addToEnd;
|
|
680
|
+
return {
|
|
681
|
+
pages: addTo(data.pages, page, maxPages),
|
|
682
|
+
pageParams: addTo(data.pageParams, param, maxPages)
|
|
683
|
+
};
|
|
684
|
+
};
|
|
685
|
+
if (direction && oldPages.length) {
|
|
686
|
+
const previous = direction === "backward";
|
|
687
|
+
const pageParamFn = previous ? getPreviousPageParam : getNextPageParam;
|
|
688
|
+
const oldData = {
|
|
689
|
+
pages: oldPages,
|
|
690
|
+
pageParams: oldPageParams
|
|
691
|
+
};
|
|
692
|
+
result = await fetchPage(oldData, pageParamFn(options, oldData), previous);
|
|
693
|
+
} else {
|
|
694
|
+
const remainingPages = pages ?? oldPages.length;
|
|
695
|
+
do {
|
|
696
|
+
const param = currentPage === 0 ? oldPageParams[0] ?? options.initialPageParam : getNextPageParam(options, result);
|
|
697
|
+
if (currentPage > 0 && param == null) break;
|
|
698
|
+
result = await fetchPage(result, param);
|
|
699
|
+
currentPage++;
|
|
700
|
+
} while (currentPage < remainingPages);
|
|
701
|
+
}
|
|
702
|
+
return result;
|
|
703
|
+
};
|
|
704
|
+
if (context.options.persister) context.fetchFn = () => {
|
|
705
|
+
return context.options.persister?.(fetchFn, {
|
|
706
|
+
client: context.client,
|
|
707
|
+
queryKey: context.queryKey,
|
|
708
|
+
meta: context.options.meta,
|
|
709
|
+
signal: context.signal
|
|
710
|
+
}, query);
|
|
711
|
+
};
|
|
712
|
+
else context.fetchFn = fetchFn;
|
|
713
|
+
} };
|
|
714
|
+
}
|
|
715
|
+
function getNextPageParam(options, { pages, pageParams }) {
|
|
716
|
+
const lastIndex = pages.length - 1;
|
|
717
|
+
return pages.length > 0 ? options.getNextPageParam(pages[lastIndex], pages, pageParams[lastIndex], pageParams) : void 0;
|
|
718
|
+
}
|
|
719
|
+
function getPreviousPageParam(options, { pages, pageParams }) {
|
|
720
|
+
return pages.length > 0 ? options.getPreviousPageParam?.(pages[0], pages, pageParams[0], pageParams) : void 0;
|
|
721
|
+
}
|
|
722
|
+
//#endregion
|
|
723
|
+
//#region node_modules/@tanstack/query-core/build/modern/query.js
|
|
724
|
+
var Query = class extends Removable {
|
|
725
|
+
#queryType;
|
|
726
|
+
#initialState;
|
|
727
|
+
#revertState;
|
|
728
|
+
#cache;
|
|
729
|
+
#client;
|
|
730
|
+
#retryer;
|
|
731
|
+
#defaultOptions;
|
|
732
|
+
#abortSignalConsumed;
|
|
733
|
+
constructor(config) {
|
|
734
|
+
super();
|
|
735
|
+
this.#abortSignalConsumed = false;
|
|
736
|
+
this.#defaultOptions = config.defaultOptions;
|
|
737
|
+
this.setOptions(config.options);
|
|
738
|
+
this.observers = [];
|
|
739
|
+
this.#client = config.client;
|
|
740
|
+
this.#cache = this.#client.getQueryCache();
|
|
741
|
+
this.queryKey = config.queryKey;
|
|
742
|
+
this.queryHash = config.queryHash;
|
|
743
|
+
this.#initialState = getDefaultState$1(this.options);
|
|
744
|
+
this.state = config.state ?? this.#initialState;
|
|
745
|
+
this.scheduleGc();
|
|
746
|
+
}
|
|
747
|
+
get meta() {
|
|
748
|
+
return this.options.meta;
|
|
749
|
+
}
|
|
750
|
+
get queryType() {
|
|
751
|
+
return this.#queryType;
|
|
752
|
+
}
|
|
753
|
+
get promise() {
|
|
754
|
+
return this.#retryer?.promise;
|
|
755
|
+
}
|
|
756
|
+
setOptions(options) {
|
|
757
|
+
this.options = {
|
|
758
|
+
...this.#defaultOptions,
|
|
759
|
+
...options
|
|
760
|
+
};
|
|
761
|
+
if (options?._type) this.#queryType = options._type;
|
|
762
|
+
this.updateGcTime(this.options.gcTime);
|
|
763
|
+
if (this.state && this.state.data === void 0) {
|
|
764
|
+
const defaultState = getDefaultState$1(this.options);
|
|
765
|
+
if (defaultState.data !== void 0) {
|
|
766
|
+
this.setState(successState(defaultState.data, defaultState.dataUpdatedAt));
|
|
767
|
+
this.#initialState = defaultState;
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
optionalRemove() {
|
|
772
|
+
if (!this.observers.length && this.state.fetchStatus === "idle") this.#cache.remove(this);
|
|
773
|
+
}
|
|
774
|
+
setData(newData, options) {
|
|
775
|
+
const data = replaceData(this.state.data, newData, this.options);
|
|
776
|
+
this.#dispatch({
|
|
777
|
+
data,
|
|
778
|
+
type: "success",
|
|
779
|
+
dataUpdatedAt: options?.updatedAt,
|
|
780
|
+
manual: options?.manual
|
|
781
|
+
});
|
|
782
|
+
return data;
|
|
783
|
+
}
|
|
784
|
+
setState(state) {
|
|
785
|
+
this.#dispatch({
|
|
786
|
+
type: "setState",
|
|
787
|
+
state
|
|
788
|
+
});
|
|
789
|
+
}
|
|
790
|
+
cancel(options) {
|
|
791
|
+
const promise = this.#retryer?.promise;
|
|
792
|
+
this.#retryer?.cancel(options);
|
|
793
|
+
return promise ? promise.then(noop).catch(noop) : Promise.resolve();
|
|
794
|
+
}
|
|
795
|
+
destroy() {
|
|
796
|
+
super.destroy();
|
|
797
|
+
this.cancel({ silent: true });
|
|
798
|
+
}
|
|
799
|
+
get resetState() {
|
|
800
|
+
return this.#initialState;
|
|
801
|
+
}
|
|
802
|
+
reset() {
|
|
803
|
+
this.destroy();
|
|
804
|
+
this.setState(this.resetState);
|
|
805
|
+
}
|
|
806
|
+
isActive() {
|
|
807
|
+
return this.observers.some((observer) => resolveQueryValue(observer.options.enabled, this) !== false);
|
|
808
|
+
}
|
|
809
|
+
isDisabled() {
|
|
810
|
+
if (this.getObserversCount() > 0) return !this.isActive();
|
|
811
|
+
return this.options.queryFn === skipToken || !this.isFetched();
|
|
812
|
+
}
|
|
813
|
+
isFetched() {
|
|
814
|
+
return this.state.dataUpdateCount + this.state.errorUpdateCount > 0;
|
|
815
|
+
}
|
|
816
|
+
isStatic() {
|
|
817
|
+
if (this.getObserversCount() > 0) return this.observers.some((observer) => resolveQueryValue(observer.options.staleTime, this) === "static");
|
|
818
|
+
return false;
|
|
819
|
+
}
|
|
820
|
+
isStale() {
|
|
821
|
+
if (this.getObserversCount() > 0) return this.observers.some((observer) => observer.getCurrentResult().isStale);
|
|
822
|
+
return this.state.data === void 0 || this.state.isInvalidated;
|
|
823
|
+
}
|
|
824
|
+
isStaleByTime(staleTime = 0) {
|
|
825
|
+
if (this.state.data === void 0) return true;
|
|
826
|
+
if (staleTime === "static") return false;
|
|
827
|
+
if (this.state.isInvalidated) return true;
|
|
828
|
+
return !timeUntilStale(this.state.dataUpdatedAt, staleTime);
|
|
829
|
+
}
|
|
830
|
+
onFocus() {
|
|
831
|
+
this.observers.find((x) => x.shouldFetchOnWindowFocus())?.refetch({ cancelRefetch: false });
|
|
832
|
+
this.#retryer?.continue();
|
|
833
|
+
}
|
|
834
|
+
onOnline() {
|
|
835
|
+
this.observers.find((x) => x.shouldFetchOnReconnect())?.refetch({ cancelRefetch: false });
|
|
836
|
+
this.#retryer?.continue();
|
|
837
|
+
}
|
|
838
|
+
addObserver(observer) {
|
|
839
|
+
if (!this.observers.includes(observer)) {
|
|
840
|
+
this.observers.push(observer);
|
|
841
|
+
this.clearGcTimeout();
|
|
842
|
+
this.#cache.notify({
|
|
843
|
+
type: "observerAdded",
|
|
844
|
+
query: this,
|
|
845
|
+
observer
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
removeObserver(observer) {
|
|
850
|
+
const index = this.observers.indexOf(observer);
|
|
851
|
+
if (index !== -1) {
|
|
852
|
+
this.observers.splice(index, 1);
|
|
853
|
+
if (!this.observers.length) {
|
|
854
|
+
if (this.#retryer) {
|
|
855
|
+
if (this.#abortSignalConsumed || this.state.fetchStatus === "paused" && this.state.status === "pending") this.#retryer.cancel({ revert: true });
|
|
856
|
+
else this.#retryer.cancelRetry();
|
|
857
|
+
}
|
|
858
|
+
this.scheduleGc();
|
|
859
|
+
}
|
|
860
|
+
this.#cache.notify({
|
|
861
|
+
type: "observerRemoved",
|
|
862
|
+
query: this,
|
|
863
|
+
observer
|
|
864
|
+
});
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
getObserversCount() {
|
|
868
|
+
return this.observers.length;
|
|
869
|
+
}
|
|
870
|
+
invalidate() {
|
|
871
|
+
if (!this.state.isInvalidated) this.#dispatch({ type: "invalidate" });
|
|
872
|
+
}
|
|
873
|
+
async fetch(options, fetchOptions) {
|
|
874
|
+
if (this.state.fetchStatus !== "idle" && this.#retryer?.status() !== "rejected") {
|
|
875
|
+
if (this.state.data !== void 0 && fetchOptions?.cancelRefetch) this.cancel({ silent: true });
|
|
876
|
+
else if (this.#retryer) {
|
|
877
|
+
this.#retryer.continueRetry();
|
|
878
|
+
return this.#retryer.promise;
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
if (options) this.setOptions(options);
|
|
882
|
+
if (!this.options.queryFn) {
|
|
883
|
+
const observer = this.observers.find((x) => x.options.queryFn);
|
|
884
|
+
if (observer) this.setOptions(observer.options);
|
|
885
|
+
}
|
|
886
|
+
const abortController = new AbortController();
|
|
887
|
+
const addSignalProperty = (object) => {
|
|
888
|
+
Object.defineProperty(object, "signal", {
|
|
889
|
+
enumerable: true,
|
|
890
|
+
get: () => {
|
|
891
|
+
this.#abortSignalConsumed = true;
|
|
892
|
+
return abortController.signal;
|
|
893
|
+
}
|
|
894
|
+
});
|
|
895
|
+
};
|
|
896
|
+
const fetchFn = () => {
|
|
897
|
+
const queryFn = ensureQueryFn(this.options, fetchOptions);
|
|
898
|
+
const createQueryFnContext = () => {
|
|
899
|
+
const queryFnContext = {
|
|
900
|
+
client: this.#client,
|
|
901
|
+
queryKey: this.queryKey,
|
|
902
|
+
meta: this.meta
|
|
903
|
+
};
|
|
904
|
+
addSignalProperty(queryFnContext);
|
|
905
|
+
return queryFnContext;
|
|
906
|
+
};
|
|
907
|
+
const queryFnContext = createQueryFnContext();
|
|
908
|
+
this.#abortSignalConsumed = false;
|
|
909
|
+
if (this.options.persister) return this.options.persister(queryFn, queryFnContext, this);
|
|
910
|
+
return queryFn(queryFnContext);
|
|
911
|
+
};
|
|
912
|
+
const createFetchContext = () => {
|
|
913
|
+
const context = {
|
|
914
|
+
fetchOptions,
|
|
915
|
+
options: this.options,
|
|
916
|
+
queryKey: this.queryKey,
|
|
917
|
+
client: this.#client,
|
|
918
|
+
state: this.state,
|
|
919
|
+
fetchFn
|
|
920
|
+
};
|
|
921
|
+
addSignalProperty(context);
|
|
922
|
+
return context;
|
|
923
|
+
};
|
|
924
|
+
const context = createFetchContext();
|
|
925
|
+
(this.#queryType === "infinite" ? infiniteQueryBehavior(this.options.pages) : this.options.behavior)?.onFetch(context, this);
|
|
926
|
+
this.#revertState = this.state;
|
|
927
|
+
if (this.state.fetchStatus === "idle" || this.state.fetchMeta !== context.fetchOptions?.meta) this.#dispatch({
|
|
928
|
+
type: "fetch",
|
|
929
|
+
meta: context.fetchOptions?.meta
|
|
930
|
+
});
|
|
931
|
+
const retryer = this.#retryer = createRetryer({
|
|
932
|
+
initialPromise: fetchOptions?.initialPromise,
|
|
933
|
+
fn: context.fetchFn,
|
|
934
|
+
onCancel: (error) => {
|
|
935
|
+
if (error instanceof CancelledError && error.revert) this.setState({
|
|
936
|
+
...this.#revertState,
|
|
937
|
+
fetchStatus: "idle"
|
|
938
|
+
});
|
|
939
|
+
abortController.abort();
|
|
940
|
+
},
|
|
941
|
+
onFail: (failureCount, error) => {
|
|
942
|
+
this.#dispatch({
|
|
943
|
+
type: "failed",
|
|
944
|
+
failureCount,
|
|
945
|
+
error
|
|
946
|
+
});
|
|
947
|
+
},
|
|
948
|
+
onPause: () => {
|
|
949
|
+
this.#dispatch({ type: "pause" });
|
|
950
|
+
},
|
|
951
|
+
onContinue: () => {
|
|
952
|
+
this.#dispatch({ type: "continue" });
|
|
953
|
+
},
|
|
954
|
+
retry: context.options.retry,
|
|
955
|
+
retryDelay: context.options.retryDelay,
|
|
956
|
+
networkMode: context.options.networkMode,
|
|
957
|
+
canRun: () => true
|
|
958
|
+
});
|
|
959
|
+
try {
|
|
960
|
+
const data = await retryer.start();
|
|
961
|
+
if (data === void 0) throw new Error(`${this.queryHash} data is undefined`);
|
|
962
|
+
this.setData(data);
|
|
963
|
+
this.#cache.config.onSuccess?.(data, this);
|
|
964
|
+
this.#cache.config.onSettled?.(data, this.state.error, this);
|
|
965
|
+
return data;
|
|
966
|
+
} catch (error) {
|
|
967
|
+
if (error instanceof CancelledError) {
|
|
968
|
+
if (error.silent) return this.#retryer.promise;
|
|
969
|
+
else if (error.revert) {
|
|
970
|
+
if (this.state.data === void 0) throw error;
|
|
971
|
+
return this.state.data;
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
this.#dispatch({
|
|
975
|
+
type: "error",
|
|
976
|
+
error
|
|
977
|
+
});
|
|
978
|
+
this.#cache.config.onError?.(error, this);
|
|
979
|
+
this.#cache.config.onSettled?.(this.state.data, error, this);
|
|
980
|
+
throw error;
|
|
981
|
+
} finally {
|
|
982
|
+
if (this.#retryer === retryer) this.#retryer = void 0;
|
|
983
|
+
this.scheduleGc();
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
#dispatch(action) {
|
|
987
|
+
const reducer = (state) => {
|
|
988
|
+
switch (action.type) {
|
|
989
|
+
case "failed": return {
|
|
990
|
+
...state,
|
|
991
|
+
fetchFailureCount: action.failureCount,
|
|
992
|
+
fetchFailureReason: action.error
|
|
993
|
+
};
|
|
994
|
+
case "pause": return {
|
|
995
|
+
...state,
|
|
996
|
+
fetchStatus: "paused"
|
|
997
|
+
};
|
|
998
|
+
case "continue": return {
|
|
999
|
+
...state,
|
|
1000
|
+
fetchStatus: "fetching"
|
|
1001
|
+
};
|
|
1002
|
+
case "fetch": return {
|
|
1003
|
+
...state,
|
|
1004
|
+
...fetchState(state.data, this.options),
|
|
1005
|
+
fetchMeta: action.meta ?? null
|
|
1006
|
+
};
|
|
1007
|
+
case "success":
|
|
1008
|
+
const newState = {
|
|
1009
|
+
...state,
|
|
1010
|
+
...successState(action.data, action.dataUpdatedAt),
|
|
1011
|
+
dataUpdateCount: state.dataUpdateCount + 1,
|
|
1012
|
+
...!action.manual && {
|
|
1013
|
+
fetchStatus: "idle",
|
|
1014
|
+
fetchFailureCount: 0,
|
|
1015
|
+
fetchFailureReason: null
|
|
1016
|
+
}
|
|
1017
|
+
};
|
|
1018
|
+
this.#revertState = action.manual ? newState : void 0;
|
|
1019
|
+
return newState;
|
|
1020
|
+
case "error":
|
|
1021
|
+
const error = action.error;
|
|
1022
|
+
return {
|
|
1023
|
+
...state,
|
|
1024
|
+
error,
|
|
1025
|
+
errorUpdateCount: state.errorUpdateCount + 1,
|
|
1026
|
+
errorUpdatedAt: Date.now(),
|
|
1027
|
+
fetchFailureCount: state.fetchFailureCount + 1,
|
|
1028
|
+
fetchFailureReason: error,
|
|
1029
|
+
fetchStatus: "idle",
|
|
1030
|
+
status: "error",
|
|
1031
|
+
isInvalidated: true
|
|
1032
|
+
};
|
|
1033
|
+
case "invalidate": return {
|
|
1034
|
+
...state,
|
|
1035
|
+
isInvalidated: true
|
|
1036
|
+
};
|
|
1037
|
+
case "setState": return {
|
|
1038
|
+
...state,
|
|
1039
|
+
...action.state
|
|
1040
|
+
};
|
|
1041
|
+
}
|
|
1042
|
+
};
|
|
1043
|
+
this.state = reducer(this.state);
|
|
1044
|
+
notifyManager.batch(() => {
|
|
1045
|
+
this.observers.slice().forEach((observer) => {
|
|
1046
|
+
observer.onQueryUpdate();
|
|
1047
|
+
});
|
|
1048
|
+
this.#cache.notify({
|
|
1049
|
+
query: this,
|
|
1050
|
+
type: "updated",
|
|
1051
|
+
action
|
|
1052
|
+
});
|
|
1053
|
+
});
|
|
1054
|
+
}
|
|
1055
|
+
};
|
|
1056
|
+
function fetchState(data, options) {
|
|
1057
|
+
return {
|
|
1058
|
+
fetchFailureCount: 0,
|
|
1059
|
+
fetchFailureReason: null,
|
|
1060
|
+
fetchStatus: canFetch(options.networkMode) ? "fetching" : "paused",
|
|
1061
|
+
...data === void 0 && {
|
|
1062
|
+
error: null,
|
|
1063
|
+
status: "pending"
|
|
1064
|
+
}
|
|
1065
|
+
};
|
|
1066
|
+
}
|
|
1067
|
+
function successState(data, dataUpdatedAt) {
|
|
1068
|
+
return {
|
|
1069
|
+
data,
|
|
1070
|
+
dataUpdatedAt: dataUpdatedAt ?? Date.now(),
|
|
1071
|
+
error: null,
|
|
1072
|
+
isInvalidated: false,
|
|
1073
|
+
status: "success"
|
|
1074
|
+
};
|
|
1075
|
+
}
|
|
1076
|
+
function getDefaultState$1(options) {
|
|
1077
|
+
const data = typeof options.initialData === "function" ? options.initialData() : options.initialData;
|
|
1078
|
+
const hasData = data !== void 0;
|
|
1079
|
+
const initialDataUpdatedAt = hasData ? typeof options.initialDataUpdatedAt === "function" ? options.initialDataUpdatedAt() : options.initialDataUpdatedAt : 0;
|
|
1080
|
+
return {
|
|
1081
|
+
data,
|
|
1082
|
+
dataUpdateCount: 0,
|
|
1083
|
+
dataUpdatedAt: hasData ? initialDataUpdatedAt ?? Date.now() : 0,
|
|
1084
|
+
error: null,
|
|
1085
|
+
errorUpdateCount: 0,
|
|
1086
|
+
errorUpdatedAt: 0,
|
|
1087
|
+
fetchFailureCount: 0,
|
|
1088
|
+
fetchFailureReason: null,
|
|
1089
|
+
fetchMeta: null,
|
|
1090
|
+
isInvalidated: false,
|
|
1091
|
+
status: hasData ? "success" : "pending",
|
|
1092
|
+
fetchStatus: "idle"
|
|
1093
|
+
};
|
|
1094
|
+
}
|
|
1095
|
+
//#endregion
|
|
1096
|
+
//#region node_modules/@tanstack/query-core/build/modern/queryObserver.js
|
|
1097
|
+
var QueryObserver = class extends Subscribable {
|
|
1098
|
+
#client;
|
|
1099
|
+
#currentQuery = void 0;
|
|
1100
|
+
#currentQueryInitialState = void 0;
|
|
1101
|
+
#currentResult = void 0;
|
|
1102
|
+
#currentResultState;
|
|
1103
|
+
#currentResultOptions;
|
|
1104
|
+
#selectError;
|
|
1105
|
+
#selectFn;
|
|
1106
|
+
#selectResult;
|
|
1107
|
+
#lastQueryWithDefinedData;
|
|
1108
|
+
#staleTimeoutId;
|
|
1109
|
+
#refetchIntervalId;
|
|
1110
|
+
#currentRefetchInterval;
|
|
1111
|
+
#trackedProps = /* @__PURE__ */ new Set();
|
|
1112
|
+
constructor(client, options) {
|
|
1113
|
+
super();
|
|
1114
|
+
this.options = options;
|
|
1115
|
+
this.#client = client;
|
|
1116
|
+
this.#selectError = null;
|
|
1117
|
+
this.bindMethods();
|
|
1118
|
+
this.setOptions(options);
|
|
1119
|
+
}
|
|
1120
|
+
bindMethods() {
|
|
1121
|
+
this.refetch = this.refetch.bind(this);
|
|
1122
|
+
}
|
|
1123
|
+
onSubscribe() {
|
|
1124
|
+
if (this.listeners.size === 1) {
|
|
1125
|
+
this.#currentQuery.addObserver(this);
|
|
1126
|
+
if (shouldFetchOnMount(this.#currentQuery, this.options)) this.#executeFetch();
|
|
1127
|
+
else this.updateResult();
|
|
1128
|
+
this.#updateTimers();
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
onUnsubscribe() {
|
|
1132
|
+
if (!this.hasListeners()) this.destroy();
|
|
1133
|
+
}
|
|
1134
|
+
shouldFetchOnReconnect() {
|
|
1135
|
+
return shouldFetchOn(this.#currentQuery, this.options, this.options.refetchOnReconnect);
|
|
1136
|
+
}
|
|
1137
|
+
shouldFetchOnWindowFocus() {
|
|
1138
|
+
return shouldFetchOn(this.#currentQuery, this.options, this.options.refetchOnWindowFocus);
|
|
1139
|
+
}
|
|
1140
|
+
destroy() {
|
|
1141
|
+
this.listeners = /* @__PURE__ */ new Set();
|
|
1142
|
+
this.#clearStaleTimeout();
|
|
1143
|
+
this.#clearRefetchInterval();
|
|
1144
|
+
this.#currentQuery.removeObserver(this);
|
|
1145
|
+
}
|
|
1146
|
+
setOptions(options) {
|
|
1147
|
+
const prevOptions = this.options;
|
|
1148
|
+
const prevQuery = this.#currentQuery;
|
|
1149
|
+
this.options = this.#client.defaultQueryOptions(options);
|
|
1150
|
+
if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean" && typeof this.options.enabled !== "function" && typeof resolveQueryValue(this.options.enabled, this.#currentQuery) !== "boolean") throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");
|
|
1151
|
+
this.#updateQuery();
|
|
1152
|
+
this.#currentQuery.setOptions(this.options);
|
|
1153
|
+
if (prevOptions._defaulted && !shallowEqualObjects(this.options, prevOptions)) this.#client.getQueryCache().notify({
|
|
1154
|
+
type: "observerOptionsUpdated",
|
|
1155
|
+
query: this.#currentQuery,
|
|
1156
|
+
observer: this
|
|
1157
|
+
});
|
|
1158
|
+
const mounted = this.hasListeners();
|
|
1159
|
+
if (mounted && shouldFetchOptionally(this.#currentQuery, prevQuery, this.options, prevOptions)) this.#executeFetch();
|
|
1160
|
+
this.updateResult();
|
|
1161
|
+
if (mounted && (this.#currentQuery !== prevQuery || resolveQueryValue(this.options.enabled, this.#currentQuery) !== resolveQueryValue(prevOptions.enabled, this.#currentQuery) || resolveQueryValue(this.options.staleTime, this.#currentQuery) !== resolveQueryValue(prevOptions.staleTime, this.#currentQuery))) this.#updateStaleTimeout();
|
|
1162
|
+
const nextRefetchInterval = this.#computeRefetchInterval();
|
|
1163
|
+
if (mounted && (this.#currentQuery !== prevQuery || resolveQueryValue(this.options.enabled, this.#currentQuery) !== resolveQueryValue(prevOptions.enabled, this.#currentQuery) || nextRefetchInterval !== this.#currentRefetchInterval)) this.#updateRefetchInterval(nextRefetchInterval);
|
|
1164
|
+
}
|
|
1165
|
+
getOptimisticResult(options) {
|
|
1166
|
+
const query = this.#client.getQueryCache().build(this.#client, options);
|
|
1167
|
+
const result = this.createResult(query, options);
|
|
1168
|
+
if (!shallowEqualObjects(this.getCurrentResult(), result)) {
|
|
1169
|
+
this.#currentResult = result;
|
|
1170
|
+
this.#currentResultOptions = this.options;
|
|
1171
|
+
this.#currentResultState = this.#currentQuery.state;
|
|
1172
|
+
}
|
|
1173
|
+
return result;
|
|
1174
|
+
}
|
|
1175
|
+
getCurrentResult() {
|
|
1176
|
+
return this.#currentResult;
|
|
1177
|
+
}
|
|
1178
|
+
trackResult(result, onPropTracked) {
|
|
1179
|
+
return new Proxy(result, { get: (target, key) => {
|
|
1180
|
+
this.trackProp(key);
|
|
1181
|
+
onPropTracked?.(key);
|
|
1182
|
+
return Reflect.get(target, key);
|
|
1183
|
+
} });
|
|
1184
|
+
}
|
|
1185
|
+
trackProp(key) {
|
|
1186
|
+
this.#trackedProps.add(key);
|
|
1187
|
+
}
|
|
1188
|
+
getCurrentQuery() {
|
|
1189
|
+
return this.#currentQuery;
|
|
1190
|
+
}
|
|
1191
|
+
refetch({ ...options } = {}) {
|
|
1192
|
+
return this.fetch({ ...options });
|
|
1193
|
+
}
|
|
1194
|
+
fetchOptimistic(options) {
|
|
1195
|
+
const defaultedOptions = this.#client.defaultQueryOptions(options);
|
|
1196
|
+
const query = this.#client.getQueryCache().build(this.#client, defaultedOptions);
|
|
1197
|
+
let unsubscribe = () => {};
|
|
1198
|
+
let resolveEarly;
|
|
1199
|
+
const cachePromise = new Promise((resolve) => {
|
|
1200
|
+
resolveEarly = resolve;
|
|
1201
|
+
unsubscribe = this.#client.getQueryCache().subscribe((event) => {
|
|
1202
|
+
if (event.type === "updated" && event.query.queryHash === query.queryHash && query.state.data !== void 0) {
|
|
1203
|
+
unsubscribe();
|
|
1204
|
+
resolve(this.createResult(query, defaultedOptions));
|
|
1205
|
+
}
|
|
1206
|
+
});
|
|
1207
|
+
});
|
|
1208
|
+
return Promise.race([query.fetch().then(() => {
|
|
1209
|
+
const result = this.createResult(query, defaultedOptions);
|
|
1210
|
+
resolveEarly?.(result);
|
|
1211
|
+
return result;
|
|
1212
|
+
}).finally(() => {
|
|
1213
|
+
unsubscribe();
|
|
1214
|
+
}), cachePromise]);
|
|
1215
|
+
}
|
|
1216
|
+
fetch(fetchOptions) {
|
|
1217
|
+
return this.#executeFetch({
|
|
1218
|
+
...fetchOptions,
|
|
1219
|
+
cancelRefetch: fetchOptions.cancelRefetch ?? true
|
|
1220
|
+
}).then(() => {
|
|
1221
|
+
this.updateResult();
|
|
1222
|
+
return this.#currentResult;
|
|
1223
|
+
});
|
|
1224
|
+
}
|
|
1225
|
+
#executeFetch(fetchOptions) {
|
|
1226
|
+
this.#updateQuery();
|
|
1227
|
+
let promise = this.#currentQuery.fetch(this.options, fetchOptions);
|
|
1228
|
+
if (!fetchOptions?.throwOnError) promise = promise.catch(noop);
|
|
1229
|
+
return promise;
|
|
1230
|
+
}
|
|
1231
|
+
#shouldScheduleTimer(timeout) {
|
|
1232
|
+
return !isServer() && resolveQueryValue(this.options.enabled, this.#currentQuery) !== false && isValidTimeout(timeout);
|
|
1233
|
+
}
|
|
1234
|
+
#updateStaleTimeout() {
|
|
1235
|
+
this.#clearStaleTimeout();
|
|
1236
|
+
const staleTime = resolveQueryValue(this.options.staleTime, this.#currentQuery);
|
|
1237
|
+
if (this.#currentResult.isStale || !this.#shouldScheduleTimer(staleTime)) return;
|
|
1238
|
+
const timeout = timeUntilStale(this.#currentResult.dataUpdatedAt, staleTime) + 1;
|
|
1239
|
+
this.#staleTimeoutId = timeoutManager.setTimeout(() => {
|
|
1240
|
+
if (!this.#currentResult.isStale) this.updateResult();
|
|
1241
|
+
}, timeout);
|
|
1242
|
+
}
|
|
1243
|
+
#computeRefetchInterval() {
|
|
1244
|
+
return (typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(this.#currentQuery) : this.options.refetchInterval) ?? false;
|
|
1245
|
+
}
|
|
1246
|
+
#updateRefetchInterval(nextInterval) {
|
|
1247
|
+
this.#clearRefetchInterval();
|
|
1248
|
+
this.#currentRefetchInterval = nextInterval;
|
|
1249
|
+
if (this.#currentRefetchInterval === 0 || !this.#shouldScheduleTimer(this.#currentRefetchInterval)) return;
|
|
1250
|
+
this.#refetchIntervalId = timeoutManager.setInterval(() => {
|
|
1251
|
+
if (this.options.refetchIntervalInBackground || focusManager.isFocused()) this.#executeFetch();
|
|
1252
|
+
}, this.#currentRefetchInterval);
|
|
1253
|
+
}
|
|
1254
|
+
#updateTimers() {
|
|
1255
|
+
this.#updateStaleTimeout();
|
|
1256
|
+
this.#updateRefetchInterval(this.#computeRefetchInterval());
|
|
1257
|
+
}
|
|
1258
|
+
#clearStaleTimeout() {
|
|
1259
|
+
if (this.#staleTimeoutId !== void 0) {
|
|
1260
|
+
timeoutManager.clearTimeout(this.#staleTimeoutId);
|
|
1261
|
+
this.#staleTimeoutId = void 0;
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
#clearRefetchInterval() {
|
|
1265
|
+
if (this.#refetchIntervalId !== void 0) {
|
|
1266
|
+
timeoutManager.clearInterval(this.#refetchIntervalId);
|
|
1267
|
+
this.#refetchIntervalId = void 0;
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
createResult(query, options) {
|
|
1271
|
+
const prevQuery = this.#currentQuery;
|
|
1272
|
+
const prevOptions = this.options;
|
|
1273
|
+
const prevResult = this.#currentResult;
|
|
1274
|
+
const prevResultState = this.#currentResultState;
|
|
1275
|
+
const prevResultOptions = this.#currentResultOptions;
|
|
1276
|
+
const queryInitialState = query !== prevQuery ? query.state : this.#currentQueryInitialState;
|
|
1277
|
+
const { state } = query;
|
|
1278
|
+
let newState = { ...state };
|
|
1279
|
+
let isPlaceholderData = false;
|
|
1280
|
+
let data;
|
|
1281
|
+
if (options._optimisticResults) {
|
|
1282
|
+
const mounted = this.hasListeners();
|
|
1283
|
+
const fetchOnMount = !mounted && shouldFetchOnMount(query, options);
|
|
1284
|
+
const fetchOptionally = mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions);
|
|
1285
|
+
if (fetchOnMount || fetchOptionally) newState = {
|
|
1286
|
+
...newState,
|
|
1287
|
+
...fetchState(state.data, query.options)
|
|
1288
|
+
};
|
|
1289
|
+
if (options._optimisticResults === "isRestoring") newState.fetchStatus = "idle";
|
|
1290
|
+
}
|
|
1291
|
+
let { error, errorUpdatedAt, status } = newState;
|
|
1292
|
+
data = newState.data;
|
|
1293
|
+
let skipSelect = false;
|
|
1294
|
+
if (options.placeholderData !== void 0 && data === void 0 && status === "pending") {
|
|
1295
|
+
let placeholderData;
|
|
1296
|
+
if (prevResult?.isPlaceholderData && options.placeholderData === prevResultOptions?.placeholderData) {
|
|
1297
|
+
placeholderData = prevResult.data;
|
|
1298
|
+
skipSelect = true;
|
|
1299
|
+
} else placeholderData = typeof options.placeholderData === "function" ? options.placeholderData(this.#lastQueryWithDefinedData?.state.data, this.#lastQueryWithDefinedData) : options.placeholderData;
|
|
1300
|
+
if (placeholderData !== void 0) {
|
|
1301
|
+
status = "success";
|
|
1302
|
+
data = replaceData(prevResult?.data, placeholderData, options);
|
|
1303
|
+
isPlaceholderData = true;
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
if (options.select && data !== void 0 && !skipSelect) {
|
|
1307
|
+
if (prevResult && data === prevResultState?.data && options.select === this.#selectFn) data = this.#selectResult;
|
|
1308
|
+
else try {
|
|
1309
|
+
this.#selectFn = options.select;
|
|
1310
|
+
data = options.select(data);
|
|
1311
|
+
data = replaceData(prevResult?.data, data, options);
|
|
1312
|
+
this.#selectResult = data;
|
|
1313
|
+
this.#selectError = null;
|
|
1314
|
+
} catch (selectError) {
|
|
1315
|
+
this.#selectError = selectError;
|
|
1316
|
+
}
|
|
1317
|
+
} else if (data === void 0) this.#selectError = null;
|
|
1318
|
+
if (this.#selectError) {
|
|
1319
|
+
error = this.#selectError;
|
|
1320
|
+
data = this.#selectResult;
|
|
1321
|
+
errorUpdatedAt = Date.now();
|
|
1322
|
+
status = "error";
|
|
1323
|
+
isPlaceholderData = false;
|
|
1324
|
+
}
|
|
1325
|
+
const isFetching = newState.fetchStatus === "fetching";
|
|
1326
|
+
const isPending = status === "pending";
|
|
1327
|
+
const isError = status === "error";
|
|
1328
|
+
const isLoading = isPending && isFetching;
|
|
1329
|
+
const hasData = data !== void 0;
|
|
1330
|
+
return {
|
|
1331
|
+
status,
|
|
1332
|
+
fetchStatus: newState.fetchStatus,
|
|
1333
|
+
isPending,
|
|
1334
|
+
isSuccess: status === "success",
|
|
1335
|
+
isError,
|
|
1336
|
+
isInitialLoading: isLoading,
|
|
1337
|
+
isLoading,
|
|
1338
|
+
data,
|
|
1339
|
+
dataUpdatedAt: newState.dataUpdatedAt,
|
|
1340
|
+
error,
|
|
1341
|
+
errorUpdatedAt,
|
|
1342
|
+
failureCount: newState.fetchFailureCount,
|
|
1343
|
+
failureReason: newState.fetchFailureReason,
|
|
1344
|
+
errorUpdateCount: newState.errorUpdateCount,
|
|
1345
|
+
isFetched: query.isFetched(),
|
|
1346
|
+
isFetchedAfterMount: newState.dataUpdateCount > queryInitialState.dataUpdateCount || newState.errorUpdateCount > queryInitialState.errorUpdateCount,
|
|
1347
|
+
isFetching,
|
|
1348
|
+
isRefetching: isFetching && !isPending,
|
|
1349
|
+
isLoadingError: isError && !hasData,
|
|
1350
|
+
isPaused: newState.fetchStatus === "paused",
|
|
1351
|
+
isPlaceholderData,
|
|
1352
|
+
isRefetchError: isError && hasData,
|
|
1353
|
+
isStale: isStale(query, options),
|
|
1354
|
+
refetch: this.refetch,
|
|
1355
|
+
isEnabled: resolveQueryValue(options.enabled, query) !== false
|
|
1356
|
+
};
|
|
1357
|
+
}
|
|
1358
|
+
updateResult() {
|
|
1359
|
+
const prevResult = this.#currentResult;
|
|
1360
|
+
const nextResult = this.createResult(this.#currentQuery, this.options);
|
|
1361
|
+
this.#currentResultState = this.#currentQuery.state;
|
|
1362
|
+
this.#currentResultOptions = this.options;
|
|
1363
|
+
if (this.#currentResultState.data !== void 0) this.#lastQueryWithDefinedData = this.#currentQuery;
|
|
1364
|
+
if (shallowEqualObjects(nextResult, prevResult)) return;
|
|
1365
|
+
this.#currentResult = nextResult;
|
|
1366
|
+
const shouldNotifyListeners = () => {
|
|
1367
|
+
if (!prevResult) return true;
|
|
1368
|
+
const { notifyOnChangeProps } = this.options;
|
|
1369
|
+
const notifyOnChangePropsValue = typeof notifyOnChangeProps === "function" ? notifyOnChangeProps() : notifyOnChangeProps;
|
|
1370
|
+
if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !this.#trackedProps.size) return true;
|
|
1371
|
+
const includedProps = new Set(notifyOnChangePropsValue ?? this.#trackedProps);
|
|
1372
|
+
if (this.options.throwOnError) includedProps.add("error");
|
|
1373
|
+
return Object.keys(this.#currentResult).some((key) => {
|
|
1374
|
+
const typedKey = key;
|
|
1375
|
+
return this.#currentResult[typedKey] !== prevResult[typedKey] && includedProps.has(typedKey);
|
|
1376
|
+
});
|
|
1377
|
+
};
|
|
1378
|
+
const notifyListeners = shouldNotifyListeners();
|
|
1379
|
+
notifyManager.batch(() => {
|
|
1380
|
+
if (notifyListeners) this.listeners.forEach((listener) => {
|
|
1381
|
+
listener(this.#currentResult);
|
|
1382
|
+
});
|
|
1383
|
+
this.#client.getQueryCache().notify({
|
|
1384
|
+
query: this.#currentQuery,
|
|
1385
|
+
type: "observerResultsUpdated"
|
|
1386
|
+
});
|
|
1387
|
+
});
|
|
1388
|
+
}
|
|
1389
|
+
#updateQuery() {
|
|
1390
|
+
const query = this.#client.getQueryCache().build(this.#client, this.options);
|
|
1391
|
+
if (query === this.#currentQuery) return;
|
|
1392
|
+
const prevQuery = this.#currentQuery;
|
|
1393
|
+
this.#currentQuery = query;
|
|
1394
|
+
this.#currentQueryInitialState = query.state;
|
|
1395
|
+
if (this.hasListeners()) {
|
|
1396
|
+
prevQuery?.removeObserver(this);
|
|
1397
|
+
query.addObserver(this);
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
onQueryUpdate() {
|
|
1401
|
+
this.updateResult();
|
|
1402
|
+
if (this.hasListeners()) this.#updateTimers();
|
|
1403
|
+
}
|
|
1404
|
+
};
|
|
1405
|
+
function shouldLoadOnMount(query, options) {
|
|
1406
|
+
return resolveQueryValue(options.enabled, query) !== false && query.state.data === void 0 && !(query.state.status === "error" && resolveQueryValue(options.retryOnMount, query) === false);
|
|
1407
|
+
}
|
|
1408
|
+
function shouldFetchOnMount(query, options) {
|
|
1409
|
+
return shouldLoadOnMount(query, options) || query.state.data !== void 0 && shouldFetchOn(query, options, options.refetchOnMount);
|
|
1410
|
+
}
|
|
1411
|
+
function shouldFetchOn(query, options, field) {
|
|
1412
|
+
if (resolveQueryValue(options.enabled, query) !== false && resolveQueryValue(options.staleTime, query) !== "static") {
|
|
1413
|
+
const value = typeof field === "function" ? field(query) : field;
|
|
1414
|
+
return value === "always" || value !== false && isStale(query, options);
|
|
1415
|
+
}
|
|
1416
|
+
return false;
|
|
1417
|
+
}
|
|
1418
|
+
function shouldFetchOptionally(query, prevQuery, options, prevOptions) {
|
|
1419
|
+
return (query !== prevQuery || resolveQueryValue(prevOptions.enabled, query) === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options);
|
|
1420
|
+
}
|
|
1421
|
+
function isStale(query, options) {
|
|
1422
|
+
return resolveQueryValue(options.enabled, query) !== false && query.isStaleByTime(resolveQueryValue(options.staleTime, query));
|
|
1423
|
+
}
|
|
1424
|
+
//#endregion
|
|
1425
|
+
//#region node_modules/@tanstack/query-core/build/modern/mutation.js
|
|
1426
|
+
var Mutation = class extends Removable {
|
|
1427
|
+
#client;
|
|
1428
|
+
#observers;
|
|
1429
|
+
#mutationCache;
|
|
1430
|
+
#retryer;
|
|
1431
|
+
constructor(config) {
|
|
1432
|
+
super();
|
|
1433
|
+
this.#client = config.client;
|
|
1434
|
+
this.mutationId = config.mutationId;
|
|
1435
|
+
this.#mutationCache = config.mutationCache;
|
|
1436
|
+
this.#observers = [];
|
|
1437
|
+
this.state = config.state || getDefaultState();
|
|
1438
|
+
this.setOptions(config.options);
|
|
1439
|
+
this.scheduleGc();
|
|
1440
|
+
}
|
|
1441
|
+
setOptions(options) {
|
|
1442
|
+
this.options = options;
|
|
1443
|
+
this.updateGcTime(this.options.gcTime);
|
|
1444
|
+
}
|
|
1445
|
+
get meta() {
|
|
1446
|
+
return this.options.meta;
|
|
1447
|
+
}
|
|
1448
|
+
addObserver(observer) {
|
|
1449
|
+
if (!this.#observers.includes(observer)) {
|
|
1450
|
+
this.#observers.push(observer);
|
|
1451
|
+
this.clearGcTimeout();
|
|
1452
|
+
this.#mutationCache.notify({
|
|
1453
|
+
type: "observerAdded",
|
|
1454
|
+
mutation: this,
|
|
1455
|
+
observer
|
|
1456
|
+
});
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
removeObserver(observer) {
|
|
1460
|
+
this.#observers = this.#observers.filter((x) => x !== observer);
|
|
1461
|
+
this.scheduleGc();
|
|
1462
|
+
this.#mutationCache.notify({
|
|
1463
|
+
type: "observerRemoved",
|
|
1464
|
+
mutation: this,
|
|
1465
|
+
observer
|
|
1466
|
+
});
|
|
1467
|
+
}
|
|
1468
|
+
optionalRemove() {
|
|
1469
|
+
if (!this.#observers.length) {
|
|
1470
|
+
if (this.state.status === "pending") this.scheduleGc();
|
|
1471
|
+
else this.#mutationCache.remove(this);
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
continue() {
|
|
1475
|
+
return this.#retryer?.continue() ?? (this.state.status === "pending" ? this.execute(this.state.variables) : Promise.resolve());
|
|
1476
|
+
}
|
|
1477
|
+
async execute(variables) {
|
|
1478
|
+
const onContinue = () => {
|
|
1479
|
+
this.#dispatch({ type: "continue" });
|
|
1480
|
+
};
|
|
1481
|
+
const mutationFnContext = {
|
|
1482
|
+
client: this.#client,
|
|
1483
|
+
meta: this.options.meta,
|
|
1484
|
+
mutationKey: this.options.mutationKey
|
|
1485
|
+
};
|
|
1486
|
+
const retryer = this.#retryer = createRetryer({
|
|
1487
|
+
fn: () => {
|
|
1488
|
+
if (!this.options.mutationFn) return Promise.reject(/* @__PURE__ */ new Error("No mutationFn found"));
|
|
1489
|
+
return this.options.mutationFn(variables, mutationFnContext);
|
|
1490
|
+
},
|
|
1491
|
+
onFail: (failureCount, error) => {
|
|
1492
|
+
this.#dispatch({
|
|
1493
|
+
type: "failed",
|
|
1494
|
+
failureCount,
|
|
1495
|
+
error
|
|
1496
|
+
});
|
|
1497
|
+
},
|
|
1498
|
+
onPause: () => {
|
|
1499
|
+
this.#dispatch({ type: "pause" });
|
|
1500
|
+
},
|
|
1501
|
+
onContinue,
|
|
1502
|
+
retry: this.options.retry ?? 0,
|
|
1503
|
+
retryDelay: this.options.retryDelay,
|
|
1504
|
+
networkMode: this.options.networkMode,
|
|
1505
|
+
canRun: () => this.#mutationCache.canRun(this)
|
|
1506
|
+
});
|
|
1507
|
+
const restored = this.state.status === "pending";
|
|
1508
|
+
const isPaused = !retryer.canStart();
|
|
1509
|
+
try {
|
|
1510
|
+
if (restored) onContinue();
|
|
1511
|
+
else {
|
|
1512
|
+
this.#dispatch({
|
|
1513
|
+
type: "pending",
|
|
1514
|
+
variables,
|
|
1515
|
+
isPaused
|
|
1516
|
+
});
|
|
1517
|
+
if (this.#mutationCache.config.onMutate) await this.#mutationCache.config.onMutate(variables, this, mutationFnContext);
|
|
1518
|
+
const context = await this.options.onMutate?.(variables, mutationFnContext);
|
|
1519
|
+
if (context !== this.state.context) this.#dispatch({
|
|
1520
|
+
type: "pending",
|
|
1521
|
+
context,
|
|
1522
|
+
variables,
|
|
1523
|
+
isPaused
|
|
1524
|
+
});
|
|
1525
|
+
}
|
|
1526
|
+
const data = await retryer.start();
|
|
1527
|
+
await this.#mutationCache.config.onSuccess?.(data, variables, this.state.context, this, mutationFnContext);
|
|
1528
|
+
await this.options.onSuccess?.(data, variables, this.state.context, mutationFnContext);
|
|
1529
|
+
await this.#mutationCache.config.onSettled?.(data, null, this.state.variables, this.state.context, this, mutationFnContext);
|
|
1530
|
+
await this.options.onSettled?.(data, null, variables, this.state.context, mutationFnContext);
|
|
1531
|
+
this.#dispatch({
|
|
1532
|
+
type: "success",
|
|
1533
|
+
data
|
|
1534
|
+
});
|
|
1535
|
+
return data;
|
|
1536
|
+
} catch (error) {
|
|
1537
|
+
try {
|
|
1538
|
+
await this.#mutationCache.config.onError?.(error, variables, this.state.context, this, mutationFnContext);
|
|
1539
|
+
} catch (e) {
|
|
1540
|
+
Promise.reject(e);
|
|
1541
|
+
}
|
|
1542
|
+
try {
|
|
1543
|
+
await this.options.onError?.(error, variables, this.state.context, mutationFnContext);
|
|
1544
|
+
} catch (e) {
|
|
1545
|
+
Promise.reject(e);
|
|
1546
|
+
}
|
|
1547
|
+
try {
|
|
1548
|
+
await this.#mutationCache.config.onSettled?.(void 0, error, this.state.variables, this.state.context, this, mutationFnContext);
|
|
1549
|
+
} catch (e) {
|
|
1550
|
+
Promise.reject(e);
|
|
1551
|
+
}
|
|
1552
|
+
try {
|
|
1553
|
+
await this.options.onSettled?.(void 0, error, variables, this.state.context, mutationFnContext);
|
|
1554
|
+
} catch (e) {
|
|
1555
|
+
Promise.reject(e);
|
|
1556
|
+
}
|
|
1557
|
+
this.#dispatch({
|
|
1558
|
+
type: "error",
|
|
1559
|
+
error
|
|
1560
|
+
});
|
|
1561
|
+
throw error;
|
|
1562
|
+
} finally {
|
|
1563
|
+
if (this.#retryer === retryer) this.#retryer = void 0;
|
|
1564
|
+
this.#mutationCache.runNext(this);
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
#dispatch(action) {
|
|
1568
|
+
const reducer = (state) => {
|
|
1569
|
+
switch (action.type) {
|
|
1570
|
+
case "failed": return {
|
|
1571
|
+
...state,
|
|
1572
|
+
failureCount: action.failureCount,
|
|
1573
|
+
failureReason: action.error
|
|
1574
|
+
};
|
|
1575
|
+
case "pause": return {
|
|
1576
|
+
...state,
|
|
1577
|
+
isPaused: true
|
|
1578
|
+
};
|
|
1579
|
+
case "continue": return {
|
|
1580
|
+
...state,
|
|
1581
|
+
isPaused: false
|
|
1582
|
+
};
|
|
1583
|
+
case "pending": return {
|
|
1584
|
+
...state,
|
|
1585
|
+
context: action.context,
|
|
1586
|
+
data: void 0,
|
|
1587
|
+
failureCount: 0,
|
|
1588
|
+
failureReason: null,
|
|
1589
|
+
error: null,
|
|
1590
|
+
isPaused: action.isPaused,
|
|
1591
|
+
status: "pending",
|
|
1592
|
+
variables: action.variables,
|
|
1593
|
+
submittedAt: Date.now()
|
|
1594
|
+
};
|
|
1595
|
+
case "success": return {
|
|
1596
|
+
...state,
|
|
1597
|
+
data: action.data,
|
|
1598
|
+
failureCount: 0,
|
|
1599
|
+
failureReason: null,
|
|
1600
|
+
error: null,
|
|
1601
|
+
status: "success",
|
|
1602
|
+
isPaused: false
|
|
1603
|
+
};
|
|
1604
|
+
case "error": return {
|
|
1605
|
+
...state,
|
|
1606
|
+
data: void 0,
|
|
1607
|
+
error: action.error,
|
|
1608
|
+
failureCount: state.failureCount + 1,
|
|
1609
|
+
failureReason: action.error,
|
|
1610
|
+
isPaused: false,
|
|
1611
|
+
status: "error"
|
|
1612
|
+
};
|
|
1613
|
+
}
|
|
1614
|
+
};
|
|
1615
|
+
this.state = reducer(this.state);
|
|
1616
|
+
notifyManager.batch(() => {
|
|
1617
|
+
this.#observers.forEach((observer) => {
|
|
1618
|
+
observer.onMutationUpdate(action);
|
|
1619
|
+
});
|
|
1620
|
+
this.#mutationCache.notify({
|
|
1621
|
+
mutation: this,
|
|
1622
|
+
type: "updated",
|
|
1623
|
+
action
|
|
1624
|
+
});
|
|
1625
|
+
});
|
|
1626
|
+
}
|
|
1627
|
+
};
|
|
1628
|
+
function getDefaultState() {
|
|
1629
|
+
return {
|
|
1630
|
+
context: void 0,
|
|
1631
|
+
data: void 0,
|
|
1632
|
+
error: null,
|
|
1633
|
+
failureCount: 0,
|
|
1634
|
+
failureReason: null,
|
|
1635
|
+
isPaused: false,
|
|
1636
|
+
status: "idle",
|
|
1637
|
+
variables: void 0,
|
|
1638
|
+
submittedAt: 0
|
|
1639
|
+
};
|
|
1640
|
+
}
|
|
1641
|
+
//#endregion
|
|
1642
|
+
//#region node_modules/@tanstack/query-core/build/modern/mutationCache.js
|
|
1643
|
+
var MutationCache = class extends Subscribable {
|
|
1644
|
+
#mutations;
|
|
1645
|
+
#scopes;
|
|
1646
|
+
#mutationId;
|
|
1647
|
+
constructor(config = {}) {
|
|
1648
|
+
super();
|
|
1649
|
+
this.config = config;
|
|
1650
|
+
this.#mutations = /* @__PURE__ */ new Set();
|
|
1651
|
+
this.#scopes = /* @__PURE__ */ new Map();
|
|
1652
|
+
this.#mutationId = 0;
|
|
1653
|
+
}
|
|
1654
|
+
build(client, options, state) {
|
|
1655
|
+
const mutation = new Mutation({
|
|
1656
|
+
client,
|
|
1657
|
+
mutationCache: this,
|
|
1658
|
+
mutationId: ++this.#mutationId,
|
|
1659
|
+
options: client.defaultMutationOptions(options),
|
|
1660
|
+
state
|
|
1661
|
+
});
|
|
1662
|
+
this.add(mutation);
|
|
1663
|
+
return mutation;
|
|
1664
|
+
}
|
|
1665
|
+
add(mutation) {
|
|
1666
|
+
this.#mutations.add(mutation);
|
|
1667
|
+
const scope = scopeFor(mutation);
|
|
1668
|
+
if (typeof scope === "string") {
|
|
1669
|
+
const scopedMutations = this.#scopes.get(scope);
|
|
1670
|
+
if (scopedMutations) scopedMutations.push(mutation);
|
|
1671
|
+
else this.#scopes.set(scope, [mutation]);
|
|
1672
|
+
}
|
|
1673
|
+
this.notify({
|
|
1674
|
+
type: "added",
|
|
1675
|
+
mutation
|
|
1676
|
+
});
|
|
1677
|
+
}
|
|
1678
|
+
remove(mutation) {
|
|
1679
|
+
if (this.#mutations.delete(mutation)) {
|
|
1680
|
+
const scope = scopeFor(mutation);
|
|
1681
|
+
if (typeof scope === "string") {
|
|
1682
|
+
const scopedMutations = this.#scopes.get(scope);
|
|
1683
|
+
if (scopedMutations) {
|
|
1684
|
+
if (scopedMutations.length > 1) {
|
|
1685
|
+
const index = scopedMutations.indexOf(mutation);
|
|
1686
|
+
if (index !== -1) scopedMutations.splice(index, 1);
|
|
1687
|
+
} else if (scopedMutations[0] === mutation) this.#scopes.delete(scope);
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
this.notify({
|
|
1692
|
+
type: "removed",
|
|
1693
|
+
mutation
|
|
1694
|
+
});
|
|
1695
|
+
}
|
|
1696
|
+
canRun(mutation) {
|
|
1697
|
+
const scope = scopeFor(mutation);
|
|
1698
|
+
if (typeof scope === "string") {
|
|
1699
|
+
const firstPendingMutation = this.#scopes.get(scope)?.find((m) => m.state.status === "pending");
|
|
1700
|
+
return !firstPendingMutation || firstPendingMutation === mutation;
|
|
1701
|
+
} else return true;
|
|
1702
|
+
}
|
|
1703
|
+
runNext(mutation) {
|
|
1704
|
+
const scope = scopeFor(mutation);
|
|
1705
|
+
if (typeof scope === "string") return (this.#scopes.get(scope)?.find((m) => m !== mutation && m.state.isPaused))?.continue() ?? Promise.resolve();
|
|
1706
|
+
else return Promise.resolve();
|
|
1707
|
+
}
|
|
1708
|
+
clear() {
|
|
1709
|
+
notifyManager.batch(() => {
|
|
1710
|
+
this.#mutations.forEach((mutation) => {
|
|
1711
|
+
this.notify({
|
|
1712
|
+
type: "removed",
|
|
1713
|
+
mutation
|
|
1714
|
+
});
|
|
1715
|
+
});
|
|
1716
|
+
this.#mutations.clear();
|
|
1717
|
+
this.#scopes.clear();
|
|
1718
|
+
});
|
|
1719
|
+
}
|
|
1720
|
+
getAll() {
|
|
1721
|
+
return Array.from(this.#mutations);
|
|
1722
|
+
}
|
|
1723
|
+
find(filters) {
|
|
1724
|
+
const defaultedFilters = {
|
|
1725
|
+
exact: true,
|
|
1726
|
+
...filters
|
|
1727
|
+
};
|
|
1728
|
+
return this.getAll().find((mutation) => matchMutation(defaultedFilters, mutation));
|
|
1729
|
+
}
|
|
1730
|
+
findAll(filters = {}) {
|
|
1731
|
+
return this.getAll().filter((mutation) => matchMutation(filters, mutation));
|
|
1732
|
+
}
|
|
1733
|
+
notify(event) {
|
|
1734
|
+
notifyManager.batch(() => {
|
|
1735
|
+
this.listeners.forEach((listener) => {
|
|
1736
|
+
listener(event);
|
|
1737
|
+
});
|
|
1738
|
+
});
|
|
1739
|
+
}
|
|
1740
|
+
resumePausedMutations() {
|
|
1741
|
+
const pausedMutations = this.getAll().filter((x) => x.state.isPaused);
|
|
1742
|
+
return notifyManager.batch(() => Promise.all(pausedMutations.map((mutation) => mutation.continue().catch(noop))));
|
|
1743
|
+
}
|
|
1744
|
+
};
|
|
1745
|
+
function scopeFor(mutation) {
|
|
1746
|
+
return mutation.options.scope?.id;
|
|
1747
|
+
}
|
|
1748
|
+
//#endregion
|
|
1749
|
+
//#region node_modules/@tanstack/query-core/build/modern/mutationObserver.js
|
|
1750
|
+
var MutationObserver = class extends Subscribable {
|
|
1751
|
+
#client;
|
|
1752
|
+
#currentResult = void 0;
|
|
1753
|
+
#currentMutation;
|
|
1754
|
+
#mutateOptions;
|
|
1755
|
+
constructor(client, options) {
|
|
1756
|
+
super();
|
|
1757
|
+
this.#client = client;
|
|
1758
|
+
this.setOptions(options);
|
|
1759
|
+
this.bindMethods();
|
|
1760
|
+
this.#updateResult();
|
|
1761
|
+
}
|
|
1762
|
+
bindMethods() {
|
|
1763
|
+
this.mutate = this.mutate.bind(this);
|
|
1764
|
+
this.reset = this.reset.bind(this);
|
|
1765
|
+
}
|
|
1766
|
+
setOptions(options) {
|
|
1767
|
+
const prevOptions = this.options;
|
|
1768
|
+
this.options = this.#client.defaultMutationOptions(options);
|
|
1769
|
+
if (!shallowEqualObjects(this.options, prevOptions)) this.#client.getMutationCache().notify({
|
|
1770
|
+
type: "observerOptionsUpdated",
|
|
1771
|
+
mutation: this.#currentMutation,
|
|
1772
|
+
observer: this
|
|
1773
|
+
});
|
|
1774
|
+
if (prevOptions?.mutationKey && this.options.mutationKey && hashKey(prevOptions.mutationKey) !== hashKey(this.options.mutationKey)) this.reset();
|
|
1775
|
+
else if (this.#currentMutation?.state.status === "pending") this.#currentMutation.setOptions(this.options);
|
|
1776
|
+
}
|
|
1777
|
+
onSubscribe() {
|
|
1778
|
+
if (this.listeners.size === 1 && this.#currentMutation) {
|
|
1779
|
+
this.#currentMutation.addObserver(this);
|
|
1780
|
+
this.#updateResult();
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1783
|
+
onUnsubscribe() {
|
|
1784
|
+
if (!this.hasListeners()) this.#currentMutation?.removeObserver(this);
|
|
1785
|
+
}
|
|
1786
|
+
onMutationUpdate(action) {
|
|
1787
|
+
this.#updateResult();
|
|
1788
|
+
this.#notify(action);
|
|
1789
|
+
}
|
|
1790
|
+
getCurrentResult() {
|
|
1791
|
+
return this.#currentResult;
|
|
1792
|
+
}
|
|
1793
|
+
reset() {
|
|
1794
|
+
this.#currentMutation?.removeObserver(this);
|
|
1795
|
+
this.#currentMutation = void 0;
|
|
1796
|
+
this.#updateResult();
|
|
1797
|
+
this.#notify();
|
|
1798
|
+
}
|
|
1799
|
+
mutate(variables, options) {
|
|
1800
|
+
this.#mutateOptions = options;
|
|
1801
|
+
this.#currentMutation?.removeObserver(this);
|
|
1802
|
+
this.#currentMutation = this.#client.getMutationCache().build(this.#client, this.options);
|
|
1803
|
+
this.#currentMutation.addObserver(this);
|
|
1804
|
+
return this.#currentMutation.execute(variables);
|
|
1805
|
+
}
|
|
1806
|
+
#updateResult() {
|
|
1807
|
+
const state = this.#currentMutation?.state ?? getDefaultState();
|
|
1808
|
+
this.#currentResult = {
|
|
1809
|
+
...state,
|
|
1810
|
+
isPending: state.status === "pending",
|
|
1811
|
+
isSuccess: state.status === "success",
|
|
1812
|
+
isError: state.status === "error",
|
|
1813
|
+
isIdle: state.status === "idle",
|
|
1814
|
+
mutate: this.mutate,
|
|
1815
|
+
reset: this.reset
|
|
1816
|
+
};
|
|
1817
|
+
}
|
|
1818
|
+
#notify(action) {
|
|
1819
|
+
notifyManager.batch(() => {
|
|
1820
|
+
if (this.#mutateOptions && this.hasListeners()) {
|
|
1821
|
+
const variables = this.#currentResult.variables;
|
|
1822
|
+
const onMutateResult = this.#currentResult.context;
|
|
1823
|
+
const context = {
|
|
1824
|
+
client: this.#client,
|
|
1825
|
+
meta: this.options.meta,
|
|
1826
|
+
mutationKey: this.options.mutationKey
|
|
1827
|
+
};
|
|
1828
|
+
if (action?.type === "success") {
|
|
1829
|
+
try {
|
|
1830
|
+
this.#mutateOptions.onSuccess?.(action.data, variables, onMutateResult, context);
|
|
1831
|
+
} catch (e) {
|
|
1832
|
+
Promise.reject(e);
|
|
1833
|
+
}
|
|
1834
|
+
try {
|
|
1835
|
+
this.#mutateOptions.onSettled?.(action.data, null, variables, onMutateResult, context);
|
|
1836
|
+
} catch (e) {
|
|
1837
|
+
Promise.reject(e);
|
|
1838
|
+
}
|
|
1839
|
+
} else if (action?.type === "error") {
|
|
1840
|
+
try {
|
|
1841
|
+
this.#mutateOptions.onError?.(action.error, variables, onMutateResult, context);
|
|
1842
|
+
} catch (e) {
|
|
1843
|
+
Promise.reject(e);
|
|
1844
|
+
}
|
|
1845
|
+
try {
|
|
1846
|
+
this.#mutateOptions.onSettled?.(void 0, action.error, variables, onMutateResult, context);
|
|
1847
|
+
} catch (e) {
|
|
1848
|
+
Promise.reject(e);
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
}
|
|
1852
|
+
this.listeners.forEach((listener) => {
|
|
1853
|
+
listener(this.#currentResult);
|
|
1854
|
+
});
|
|
1855
|
+
});
|
|
1856
|
+
}
|
|
1857
|
+
};
|
|
1858
|
+
//#endregion
|
|
1859
|
+
//#region node_modules/@tanstack/query-core/build/modern/queryCache.js
|
|
1860
|
+
var QueryCache = class extends Subscribable {
|
|
1861
|
+
#queries;
|
|
1862
|
+
constructor(config = {}) {
|
|
1863
|
+
super();
|
|
1864
|
+
this.config = config;
|
|
1865
|
+
this.#queries = /* @__PURE__ */ new Map();
|
|
1866
|
+
}
|
|
1867
|
+
build(client, options, state) {
|
|
1868
|
+
const queryKey = options.queryKey;
|
|
1869
|
+
const queryHash = options.queryHash ?? hashQueryKeyByOptions(queryKey, options);
|
|
1870
|
+
let query = this.get(queryHash);
|
|
1871
|
+
if (!query) {
|
|
1872
|
+
query = new Query({
|
|
1873
|
+
client,
|
|
1874
|
+
queryKey,
|
|
1875
|
+
queryHash,
|
|
1876
|
+
options: client.defaultQueryOptions(options),
|
|
1877
|
+
state,
|
|
1878
|
+
defaultOptions: client.getQueryDefaults(queryKey)
|
|
1879
|
+
});
|
|
1880
|
+
this.add(query);
|
|
1881
|
+
}
|
|
1882
|
+
return query;
|
|
1883
|
+
}
|
|
1884
|
+
add(query) {
|
|
1885
|
+
if (!this.#queries.has(query.queryHash)) {
|
|
1886
|
+
this.#queries.set(query.queryHash, query);
|
|
1887
|
+
this.notify({
|
|
1888
|
+
type: "added",
|
|
1889
|
+
query
|
|
1890
|
+
});
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
remove(query) {
|
|
1894
|
+
const queryInMap = this.#queries.get(query.queryHash);
|
|
1895
|
+
if (queryInMap) {
|
|
1896
|
+
query.destroy();
|
|
1897
|
+
if (queryInMap === query) this.#queries.delete(query.queryHash);
|
|
1898
|
+
this.notify({
|
|
1899
|
+
type: "removed",
|
|
1900
|
+
query
|
|
1901
|
+
});
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
clear() {
|
|
1905
|
+
notifyManager.batch(() => {
|
|
1906
|
+
this.getAll().forEach((query) => {
|
|
1907
|
+
this.remove(query);
|
|
1908
|
+
});
|
|
1909
|
+
});
|
|
1910
|
+
}
|
|
1911
|
+
get(queryHash) {
|
|
1912
|
+
return this.#queries.get(queryHash);
|
|
1913
|
+
}
|
|
1914
|
+
getAll() {
|
|
1915
|
+
return [...this.#queries.values()];
|
|
1916
|
+
}
|
|
1917
|
+
find(filters) {
|
|
1918
|
+
const defaultedFilters = {
|
|
1919
|
+
exact: true,
|
|
1920
|
+
...filters
|
|
1921
|
+
};
|
|
1922
|
+
return this.getAll().find((query) => matchQuery(defaultedFilters, query));
|
|
1923
|
+
}
|
|
1924
|
+
findAll(filters = {}) {
|
|
1925
|
+
const queries = this.getAll();
|
|
1926
|
+
return Object.keys(filters).length > 0 ? queries.filter((query) => matchQuery(filters, query)) : queries;
|
|
1927
|
+
}
|
|
1928
|
+
notify(event) {
|
|
1929
|
+
notifyManager.batch(() => {
|
|
1930
|
+
this.listeners.forEach((listener) => {
|
|
1931
|
+
listener(event);
|
|
1932
|
+
});
|
|
1933
|
+
});
|
|
1934
|
+
}
|
|
1935
|
+
onFocus() {
|
|
1936
|
+
notifyManager.batch(() => {
|
|
1937
|
+
this.getAll().forEach((query) => {
|
|
1938
|
+
query.onFocus();
|
|
1939
|
+
});
|
|
1940
|
+
});
|
|
1941
|
+
}
|
|
1942
|
+
onOnline() {
|
|
1943
|
+
notifyManager.batch(() => {
|
|
1944
|
+
this.getAll().forEach((query) => {
|
|
1945
|
+
query.onOnline();
|
|
1946
|
+
});
|
|
1947
|
+
});
|
|
1948
|
+
}
|
|
1949
|
+
};
|
|
1950
|
+
//#endregion
|
|
1951
|
+
//#region node_modules/@tanstack/query-core/build/modern/queryClient.js
|
|
1952
|
+
var QueryClient = class {
|
|
1953
|
+
#queryCache;
|
|
1954
|
+
#mutationCache;
|
|
1955
|
+
#defaultOptions;
|
|
1956
|
+
#queryDefaults;
|
|
1957
|
+
#mutationDefaults;
|
|
1958
|
+
#mountCount;
|
|
1959
|
+
#unsubscribeFocus;
|
|
1960
|
+
#unsubscribeOnline;
|
|
1961
|
+
constructor(config = {}) {
|
|
1962
|
+
this.#queryCache = config.queryCache || new QueryCache();
|
|
1963
|
+
this.#mutationCache = config.mutationCache || new MutationCache();
|
|
1964
|
+
this.#defaultOptions = config.defaultOptions || {};
|
|
1965
|
+
this.#queryDefaults = /* @__PURE__ */ new Map();
|
|
1966
|
+
this.#mutationDefaults = /* @__PURE__ */ new Map();
|
|
1967
|
+
this.#mountCount = 0;
|
|
1968
|
+
}
|
|
1969
|
+
mount() {
|
|
1970
|
+
this.#mountCount++;
|
|
1971
|
+
if (this.#mountCount !== 1) return;
|
|
1972
|
+
this.#unsubscribeFocus = focusManager.subscribe(async (focused) => {
|
|
1973
|
+
if (focused) {
|
|
1974
|
+
await this.resumePausedMutations();
|
|
1975
|
+
this.#queryCache.onFocus();
|
|
1976
|
+
}
|
|
1977
|
+
});
|
|
1978
|
+
this.#unsubscribeOnline = onlineManager.subscribe(async (online) => {
|
|
1979
|
+
if (online) {
|
|
1980
|
+
await this.resumePausedMutations();
|
|
1981
|
+
this.#queryCache.onOnline();
|
|
1982
|
+
}
|
|
1983
|
+
});
|
|
1984
|
+
}
|
|
1985
|
+
unmount() {
|
|
1986
|
+
this.#mountCount--;
|
|
1987
|
+
if (this.#mountCount !== 0) return;
|
|
1988
|
+
this.#unsubscribeFocus?.();
|
|
1989
|
+
this.#unsubscribeFocus = void 0;
|
|
1990
|
+
this.#unsubscribeOnline?.();
|
|
1991
|
+
this.#unsubscribeOnline = void 0;
|
|
1992
|
+
}
|
|
1993
|
+
isFetching(filters) {
|
|
1994
|
+
return this.#queryCache.findAll({
|
|
1995
|
+
...filters,
|
|
1996
|
+
fetchStatus: "fetching"
|
|
1997
|
+
}).length;
|
|
1998
|
+
}
|
|
1999
|
+
isMutating(filters) {
|
|
2000
|
+
return this.#mutationCache.findAll({
|
|
2001
|
+
...filters,
|
|
2002
|
+
status: "pending"
|
|
2003
|
+
}).length;
|
|
2004
|
+
}
|
|
2005
|
+
/**
|
|
2006
|
+
* Imperative (non-reactive) way to retrieve data for a QueryKey.
|
|
2007
|
+
* Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates.
|
|
2008
|
+
*
|
|
2009
|
+
* Hint: Do not use this function inside a component, because it won't receive updates.
|
|
2010
|
+
* Use `useQuery` to create a `QueryObserver` that subscribes to changes.
|
|
2011
|
+
*/
|
|
2012
|
+
getQueryData(queryKey) {
|
|
2013
|
+
const options = this.defaultQueryOptions({ queryKey });
|
|
2014
|
+
return this.#queryCache.get(options.queryHash)?.state.data;
|
|
2015
|
+
}
|
|
2016
|
+
/**
|
|
2017
|
+
* @deprecated Use queryClient.query({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version.
|
|
2018
|
+
*/
|
|
2019
|
+
ensureQueryData(options) {
|
|
2020
|
+
const defaultedOptions = this.defaultQueryOptions(options);
|
|
2021
|
+
const query = this.#queryCache.build(this, defaultedOptions);
|
|
2022
|
+
const cachedData = query.state.data;
|
|
2023
|
+
if (cachedData === void 0) return this.fetchQuery(options);
|
|
2024
|
+
if (options.revalidateIfStale && query.isStaleByTime(resolveQueryValue(defaultedOptions.staleTime, query))) this.prefetchQuery(defaultedOptions);
|
|
2025
|
+
return Promise.resolve(cachedData);
|
|
2026
|
+
}
|
|
2027
|
+
getQueriesData(filters) {
|
|
2028
|
+
return this.#queryCache.findAll(filters).map(({ queryKey, state }) => {
|
|
2029
|
+
return [queryKey, state.data];
|
|
2030
|
+
});
|
|
2031
|
+
}
|
|
2032
|
+
setQueryData(queryKey, updater, options) {
|
|
2033
|
+
const defaultedOptions = this.defaultQueryOptions({ queryKey });
|
|
2034
|
+
const prevData = this.#queryCache.get(defaultedOptions.queryHash)?.state.data;
|
|
2035
|
+
const data = functionalUpdate(updater, prevData);
|
|
2036
|
+
if (data === void 0) return;
|
|
2037
|
+
return this.#queryCache.build(this, defaultedOptions).setData(data, {
|
|
2038
|
+
...options,
|
|
2039
|
+
manual: true
|
|
2040
|
+
});
|
|
2041
|
+
}
|
|
2042
|
+
setQueriesData(filters, updater, options) {
|
|
2043
|
+
return notifyManager.batch(() => this.#queryCache.findAll(filters).map(({ queryKey }) => [queryKey, this.setQueryData(queryKey, updater, options)]));
|
|
2044
|
+
}
|
|
2045
|
+
getQueryState(queryKey) {
|
|
2046
|
+
const options = this.defaultQueryOptions({ queryKey });
|
|
2047
|
+
return this.#queryCache.get(options.queryHash)?.state;
|
|
2048
|
+
}
|
|
2049
|
+
removeQueries(filters) {
|
|
2050
|
+
const queryCache = this.#queryCache;
|
|
2051
|
+
notifyManager.batch(() => {
|
|
2052
|
+
queryCache.findAll(filters).forEach((query) => {
|
|
2053
|
+
queryCache.remove(query);
|
|
2054
|
+
});
|
|
2055
|
+
});
|
|
2056
|
+
}
|
|
2057
|
+
resetQueries(filters, options) {
|
|
2058
|
+
const queryCache = this.#queryCache;
|
|
2059
|
+
return notifyManager.batch(() => {
|
|
2060
|
+
const matched = queryCache.findAll(filters);
|
|
2061
|
+
const queriesToRefetch = new Set(matched);
|
|
2062
|
+
matched.forEach((query) => {
|
|
2063
|
+
query.reset();
|
|
2064
|
+
});
|
|
2065
|
+
return this.refetchQueries({
|
|
2066
|
+
type: "active",
|
|
2067
|
+
predicate: (query) => queriesToRefetch.has(query)
|
|
2068
|
+
}, options);
|
|
2069
|
+
});
|
|
2070
|
+
}
|
|
2071
|
+
cancelQueries(filters, cancelOptions = {}) {
|
|
2072
|
+
const defaultedCancelOptions = {
|
|
2073
|
+
revert: true,
|
|
2074
|
+
...cancelOptions
|
|
2075
|
+
};
|
|
2076
|
+
const promises = notifyManager.batch(() => this.#queryCache.findAll(filters).map((query) => query.cancel(defaultedCancelOptions)));
|
|
2077
|
+
return Promise.all(promises).then(noop).catch(noop);
|
|
2078
|
+
}
|
|
2079
|
+
invalidateQueries(filters, options = {}) {
|
|
2080
|
+
return notifyManager.batch(() => {
|
|
2081
|
+
this.#queryCache.findAll(filters).forEach((query) => {
|
|
2082
|
+
query.invalidate();
|
|
2083
|
+
});
|
|
2084
|
+
if (filters?.refetchType === "none") return Promise.resolve();
|
|
2085
|
+
return this.refetchQueries({
|
|
2086
|
+
...filters,
|
|
2087
|
+
type: filters?.refetchType ?? filters?.type ?? "active"
|
|
2088
|
+
}, options);
|
|
2089
|
+
});
|
|
2090
|
+
}
|
|
2091
|
+
refetchQueries(filters, options = {}) {
|
|
2092
|
+
const fetchOptions = {
|
|
2093
|
+
...options,
|
|
2094
|
+
cancelRefetch: options.cancelRefetch ?? true
|
|
2095
|
+
};
|
|
2096
|
+
const promises = notifyManager.batch(() => this.#queryCache.findAll(filters).filter((query) => !query.isDisabled() && !query.isStatic()).map((query) => {
|
|
2097
|
+
let promise = query.fetch(void 0, fetchOptions);
|
|
2098
|
+
if (!fetchOptions.throwOnError) promise = promise.catch(noop);
|
|
2099
|
+
return query.state.fetchStatus === "paused" ? Promise.resolve() : promise;
|
|
2100
|
+
}));
|
|
2101
|
+
return Promise.all(promises).then(noop);
|
|
2102
|
+
}
|
|
2103
|
+
async query(options) {
|
|
2104
|
+
const defaultedOptions = this.defaultQueryOptions(options);
|
|
2105
|
+
if (defaultedOptions.retry === void 0) defaultedOptions.retry = false;
|
|
2106
|
+
const query = this.#queryCache.build(this, defaultedOptions);
|
|
2107
|
+
const queryData = query.isStaleByTime(resolveQueryValue(defaultedOptions.staleTime, query)) ? await query.fetch(defaultedOptions) : query.state.data;
|
|
2108
|
+
const select = defaultedOptions.select;
|
|
2109
|
+
if (select) return select(queryData);
|
|
2110
|
+
return queryData;
|
|
2111
|
+
}
|
|
2112
|
+
/**
|
|
2113
|
+
* @deprecated Use queryClient.query(options) instead. This method will be removed in the next major version.
|
|
2114
|
+
*/
|
|
2115
|
+
fetchQuery(options) {
|
|
2116
|
+
const defaultedOptions = this.defaultQueryOptions(options);
|
|
2117
|
+
if (defaultedOptions.retry === void 0) defaultedOptions.retry = false;
|
|
2118
|
+
const query = this.#queryCache.build(this, defaultedOptions);
|
|
2119
|
+
return query.isStaleByTime(resolveQueryValue(defaultedOptions.staleTime, query)) ? query.fetch(defaultedOptions) : Promise.resolve(query.state.data);
|
|
2120
|
+
}
|
|
2121
|
+
/**
|
|
2122
|
+
* @deprecated Use queryClient.query(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version.
|
|
2123
|
+
*/
|
|
2124
|
+
prefetchQuery(options) {
|
|
2125
|
+
return this.fetchQuery(options).then(noop).catch(noop);
|
|
2126
|
+
}
|
|
2127
|
+
infiniteQuery(options) {
|
|
2128
|
+
options._type = "infinite";
|
|
2129
|
+
return this.query(options);
|
|
2130
|
+
}
|
|
2131
|
+
/**
|
|
2132
|
+
* @deprecated Use queryClient.infiniteQuery(options) instead. This method will be removed in the next major version.
|
|
2133
|
+
*/
|
|
2134
|
+
fetchInfiniteQuery(options) {
|
|
2135
|
+
options._type = "infinite";
|
|
2136
|
+
return this.fetchQuery(options);
|
|
2137
|
+
}
|
|
2138
|
+
/**
|
|
2139
|
+
* @deprecated Use queryClient.infiniteQuery(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version.
|
|
2140
|
+
*/
|
|
2141
|
+
prefetchInfiniteQuery(options) {
|
|
2142
|
+
return this.fetchInfiniteQuery(options).then(noop).catch(noop);
|
|
2143
|
+
}
|
|
2144
|
+
/**
|
|
2145
|
+
* @deprecated Use queryClient.infiniteQuery({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version.
|
|
2146
|
+
*/
|
|
2147
|
+
ensureInfiniteQueryData(options) {
|
|
2148
|
+
options._type = "infinite";
|
|
2149
|
+
return this.ensureQueryData(options);
|
|
2150
|
+
}
|
|
2151
|
+
resumePausedMutations() {
|
|
2152
|
+
if (onlineManager.isOnline()) return this.#mutationCache.resumePausedMutations();
|
|
2153
|
+
return Promise.resolve();
|
|
2154
|
+
}
|
|
2155
|
+
getQueryCache() {
|
|
2156
|
+
return this.#queryCache;
|
|
2157
|
+
}
|
|
2158
|
+
getMutationCache() {
|
|
2159
|
+
return this.#mutationCache;
|
|
2160
|
+
}
|
|
2161
|
+
getDefaultOptions() {
|
|
2162
|
+
return this.#defaultOptions;
|
|
2163
|
+
}
|
|
2164
|
+
setDefaultOptions(options) {
|
|
2165
|
+
this.#defaultOptions = options;
|
|
2166
|
+
}
|
|
2167
|
+
setQueryDefaults(queryKey, options) {
|
|
2168
|
+
this.#queryDefaults.set(hashKey(queryKey), {
|
|
2169
|
+
queryKey,
|
|
2170
|
+
defaultOptions: options
|
|
2171
|
+
});
|
|
2172
|
+
}
|
|
2173
|
+
getQueryDefaults(queryKey) {
|
|
2174
|
+
const defaults = [...this.#queryDefaults.values()];
|
|
2175
|
+
const result = {};
|
|
2176
|
+
defaults.forEach((queryDefault) => {
|
|
2177
|
+
if (partialMatchKey(queryKey, queryDefault.queryKey)) Object.assign(result, queryDefault.defaultOptions);
|
|
2178
|
+
});
|
|
2179
|
+
return result;
|
|
2180
|
+
}
|
|
2181
|
+
setMutationDefaults(mutationKey, options) {
|
|
2182
|
+
this.#mutationDefaults.set(hashKey(mutationKey), {
|
|
2183
|
+
mutationKey,
|
|
2184
|
+
defaultOptions: options
|
|
2185
|
+
});
|
|
2186
|
+
}
|
|
2187
|
+
getMutationDefaults(mutationKey) {
|
|
2188
|
+
const defaults = [...this.#mutationDefaults.values()];
|
|
2189
|
+
const result = {};
|
|
2190
|
+
defaults.forEach((queryDefault) => {
|
|
2191
|
+
if (partialMatchKey(mutationKey, queryDefault.mutationKey)) Object.assign(result, queryDefault.defaultOptions);
|
|
2192
|
+
});
|
|
2193
|
+
return result;
|
|
2194
|
+
}
|
|
2195
|
+
defaultQueryOptions(options) {
|
|
2196
|
+
if (options._defaulted) return options;
|
|
2197
|
+
const defaultedOptions = {
|
|
2198
|
+
...this.#defaultOptions.queries,
|
|
2199
|
+
...this.getQueryDefaults(options.queryKey),
|
|
2200
|
+
...options,
|
|
2201
|
+
_defaulted: true
|
|
2202
|
+
};
|
|
2203
|
+
if (!defaultedOptions.queryHash) defaultedOptions.queryHash = hashQueryKeyByOptions(defaultedOptions.queryKey, defaultedOptions);
|
|
2204
|
+
if (defaultedOptions.refetchOnReconnect === void 0) defaultedOptions.refetchOnReconnect = defaultedOptions.networkMode !== "always";
|
|
2205
|
+
if (defaultedOptions.throwOnError === void 0) defaultedOptions.throwOnError = !!defaultedOptions.suspense;
|
|
2206
|
+
if (!defaultedOptions.networkMode && defaultedOptions.persister) defaultedOptions.networkMode = "offlineFirst";
|
|
2207
|
+
if (defaultedOptions.queryFn === skipToken) defaultedOptions.enabled = false;
|
|
2208
|
+
return defaultedOptions;
|
|
2209
|
+
}
|
|
2210
|
+
defaultMutationOptions(options) {
|
|
2211
|
+
if (options?._defaulted) return options;
|
|
2212
|
+
return {
|
|
2213
|
+
...this.#defaultOptions.mutations,
|
|
2214
|
+
...options?.mutationKey && this.getMutationDefaults(options.mutationKey),
|
|
2215
|
+
...options,
|
|
2216
|
+
_defaulted: true
|
|
2217
|
+
};
|
|
2218
|
+
}
|
|
2219
|
+
clear() {
|
|
2220
|
+
this.#queryCache.clear();
|
|
2221
|
+
this.#mutationCache.clear();
|
|
2222
|
+
}
|
|
2223
|
+
};
|
|
2224
|
+
//#endregion
|
|
2225
|
+
export { dehydrateQuery as a, shouldThrowError as c, notifyManager as i, MutationObserver as n, hydrate as o, QueryObserver as r, noop as s, QueryClient as t };
|