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