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