@hot-updater/console 0.36.16 → 0.36.17

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.
Files changed (24) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/assets/dist-BI6FSMS0.js +3 -0
  3. package/.output/public/assets/index-C4PncbHt.js +11 -0
  4. package/.output/public/assets/routes-6EQXztxs.js +54 -0
  5. package/.output/server/{__23tanstack-start-server-fn-resolver-CgwgZ0-i.mjs → __23tanstack-start-server-fn-resolver-CNUWOV2f.mjs} +15 -15
  6. package/.output/server/_libs/@tanstack/react-form+[...].mjs +6 -6
  7. package/.output/server/_libs/@tanstack/react-router+[...].mjs +3730 -4032
  8. package/.output/server/_libs/tanstack__history.mjs +68 -41
  9. package/.output/server/_libs/tanstack__query-core.mjs +1570 -256
  10. package/.output/server/_libs/tanstack__react-query.mjs +254 -19
  11. package/.output/server/_ssr/{api-rpc-BIbDUKSz.mjs → api-rpc-irQMOQXO.mjs} +2 -2
  12. package/.output/server/_ssr/{createServerFn-DzU0k62V.mjs → createServerFn-CwIQ_zCm.mjs} +41 -56
  13. package/.output/server/_ssr/{empty-plugin-adapters-B4HCzgmM.mjs → empty-plugin-adapters-DvRHA3Ns.mjs} +1 -1
  14. package/.output/server/_ssr/{router-C3hqEy3k.mjs → router-bOwIHAiQ.mjs} +3 -3
  15. package/.output/server/_ssr/{routes-B0lQvvlC.mjs → routes-D6eq6WM0.mjs} +3 -3
  16. package/.output/server/_ssr/ssr.mjs +5103 -4246
  17. package/.output/server/_ssr/start-CQ99Z6e_.mjs +4 -0
  18. package/.output/server/{_tanstack-start-manifest_v-Bpx52WOU.mjs → _tanstack-start-manifest_v-D42dM0BV.mjs} +4 -4
  19. package/.output/server/index.mjs +34 -34
  20. package/package.json +13 -13
  21. package/.output/public/assets/dist-DJX53faP.js +0 -3
  22. package/.output/public/assets/index-Iylis5kY.js +0 -10
  23. package/.output/public/assets/routes-HT21hs0C.js +0 -54
  24. package/.output/server/_ssr/start-02sLteYG.mjs +0 -4
@@ -1,110 +1,156 @@
1
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/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.101.0/node_modules/@tanstack/query-core/build/modern/focusManager.js
23
- var FocusManager = class extends Subscribable {
24
- #focused;
25
- #cleanup;
26
- #setup;
27
- constructor() {
28
- super();
29
- this.#setup = (onFocus) => {
30
- if (typeof window !== "undefined" && window.addEventListener) {
31
- const listener = () => onFocus();
32
- window.addEventListener("visibilitychange", listener, false);
33
- return () => {
34
- window.removeEventListener("visibilitychange", listener);
35
- };
36
- }
37
- };
38
- }
39
- onSubscribe() {
40
- if (!this.#cleanup) this.setEventListener(this.#setup);
41
- }
42
- onUnsubscribe() {
43
- if (!this.hasListeners()) {
44
- this.#cleanup?.();
45
- this.#cleanup = void 0;
46
- }
47
- }
48
- setEventListener(setup) {
49
- this.#setup = setup;
50
- this.#cleanup?.();
51
- this.#cleanup = setup((focused) => {
52
- if (typeof focused === "boolean") this.setFocused(focused);
53
- else this.onFocus();
54
- });
55
- }
56
- setFocused(focused) {
57
- if (this.#focused !== focused) {
58
- this.#focused = focused;
59
- this.onFocus();
60
- }
61
- }
62
- onFocus() {
63
- const isFocused = this.isFocused();
64
- this.listeners.forEach((listener) => {
65
- listener(isFocused);
66
- });
67
- }
68
- isFocused() {
69
- if (typeof this.#focused === "boolean") return this.#focused;
70
- return globalThis.document?.visibilityState !== "hidden";
71
- }
72
- };
73
- var focusManager = new FocusManager();
74
- //#endregion
75
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/timeoutManager.js
1
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/timeoutManager.js
76
2
  var defaultTimeoutProvider = {
77
3
  setTimeout: (callback, delay) => setTimeout(callback, delay),
78
4
  clearTimeout: (timeoutId) => clearTimeout(timeoutId),
79
5
  setInterval: (callback, delay) => setInterval(callback, delay),
80
6
  clearInterval: (intervalId) => clearInterval(intervalId)
81
7
  };
8
+ /**
9
+ * Allows customization of how timeouts are created.
10
+ *
11
+ * @tanstack/query-core makes liberal use of timeouts to implement `staleTime`
12
+ * and `gcTime`. The default TimeoutManager provider uses the platform's global
13
+ * `setTimeout` implementation, which is known to have scalability issues with
14
+ * thousands of timeouts on the event loop.
15
+ *
16
+ * If you hit this limitation, consider providing a custom TimeoutProvider that
17
+ * coalesces timeouts.
18
+ */
82
19
  var TimeoutManager = class {
83
20
  #provider = defaultTimeoutProvider;
84
21
  #providerCalled = false;
22
+ /**
23
+ * `setTimeoutProvider` can be used to set a custom implementation of the
24
+ * `setTimeout`, `clearTimeout`, `setInterval`, `clearInterval` functions,
25
+ * called a `TimeoutProvider`.
26
+ *
27
+ * This may be useful if you notice event loop performance issues with
28
+ * thousands of queries. A custom TimeoutProvider could also support timer
29
+ * delays longer than the global `setTimeout` maximum delay value of about
30
+ * 24 days.
31
+ *
32
+ * It is important to call `setTimeoutProvider` before creating a
33
+ * QueryClient or queries, so that the same provider is used consistently
34
+ * for all timers in the application, since different TimeoutProviders
35
+ * cannot cancel each others' timers.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * import { timeoutManager, QueryClient } from '@tanstack/query-core'
40
+ * import { CustomTimeoutProvider } from './CustomTimeoutProvider'
41
+ *
42
+ * timeoutManager.setTimeoutProvider(new CustomTimeoutProvider())
43
+ *
44
+ * export const queryClient = new QueryClient()
45
+ * ```
46
+ */
85
47
  setTimeoutProvider(provider) {
86
48
  this.#provider = provider;
87
49
  }
50
+ /**
51
+ * `setTimeout` schedules a callback to run after approximately `delay`
52
+ * milliseconds, like the global `setTimeout` function. The callback can be
53
+ * canceled with `clearTimeout`.
54
+ *
55
+ * It returns a timer ID, which may be a number or an object that can be
56
+ * coerced to a number via `Symbol.toPrimitive`.
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * import { timeoutManager } from '@tanstack/query-core'
61
+ *
62
+ * const timeoutId = timeoutManager.setTimeout(
63
+ * () => console.log('ran at:', new Date()),
64
+ * 1000,
65
+ * )
66
+ *
67
+ * const timeoutIdNumber: number = Number(timeoutId)
68
+ * ```
69
+ */
88
70
  setTimeout(callback, delay) {
89
71
  return this.#provider.setTimeout(callback, delay);
90
72
  }
73
+ /**
74
+ * `clearTimeout` cancels a timeout callback scheduled with `setTimeout`,
75
+ * like the global `clearTimeout` function. It should be called with a
76
+ * timer ID returned by `setTimeout`.
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * import { timeoutManager } from '@tanstack/query-core'
81
+ *
82
+ * const timeoutId = timeoutManager.setTimeout(
83
+ * () => console.log('ran at:', new Date()),
84
+ * 1000,
85
+ * )
86
+ *
87
+ * timeoutManager.clearTimeout(timeoutId)
88
+ * ```
89
+ */
91
90
  clearTimeout(timeoutId) {
92
91
  this.#provider.clearTimeout(timeoutId);
93
92
  }
93
+ /**
94
+ * `setInterval` schedules a callback to be called approximately every
95
+ * `delay` milliseconds, like the global `setInterval` function.
96
+ *
97
+ * Like `setTimeout`, it returns a timer ID, which may be a number or an
98
+ * object that can be coerced to a number via `Symbol.toPrimitive`.
99
+ *
100
+ * @example
101
+ * ```ts
102
+ * import { timeoutManager } from '@tanstack/query-core'
103
+ *
104
+ * const intervalId = timeoutManager.setInterval(
105
+ * () => console.log('ran at:', new Date()),
106
+ * 1000,
107
+ * )
108
+ * ```
109
+ */
94
110
  setInterval(callback, delay) {
95
111
  return this.#provider.setInterval(callback, delay);
96
112
  }
113
+ /**
114
+ * `clearInterval` can be used to cancel an interval, like the global
115
+ * `clearInterval` function. It should be called with an interval ID
116
+ * returned by `setInterval`.
117
+ *
118
+ * @example
119
+ * ```ts
120
+ * import { timeoutManager } from '@tanstack/query-core'
121
+ *
122
+ * const intervalId = timeoutManager.setInterval(
123
+ * () => console.log('ran at:', new Date()),
124
+ * 1000,
125
+ * )
126
+ *
127
+ * timeoutManager.clearInterval(intervalId)
128
+ * ```
129
+ */
97
130
  clearInterval(intervalId) {
98
131
  this.#provider.clearInterval(intervalId);
99
132
  }
100
133
  };
134
+ /**
135
+ * Singleton instance of {@link TimeoutManager}, used throughout TanStack Query to schedule and cancel timers.
136
+ */
101
137
  var timeoutManager = new TimeoutManager();
138
+ /**
139
+ * In many cases code wants to delay to the next event loop tick; this is not
140
+ * mediated by {@link timeoutManager}.
141
+ *
142
+ * This function is provided to make auditing the `tanstack/query-core` for
143
+ * incorrect use of system `setTimeout` easier.
144
+ */
102
145
  function systemSetTimeoutZero(callback) {
103
146
  setTimeout(callback, 0);
104
147
  }
105
148
  //#endregion
106
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/utils.js
107
- var isServer = typeof window === "undefined" || "Deno" in globalThis;
149
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/utils.js
150
+ /** @deprecated
151
+ * use `environmentManager.isServer()` instead.
152
+ */
153
+ var isServer$1 = typeof window === "undefined" || "Deno" in globalThis;
108
154
  function noop() {}
109
155
  function functionalUpdate(updater, input) {
110
156
  return typeof updater === "function" ? updater(input) : updater;
@@ -115,12 +161,22 @@ function isValidTimeout(value) {
115
161
  function timeUntilStale(updatedAt, staleTime) {
116
162
  return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0);
117
163
  }
118
- function resolveStaleTime(staleTime, query) {
119
- return typeof staleTime === "function" ? staleTime(query) : staleTime;
120
- }
121
- function resolveQueryBoolean(option, query) {
122
- return typeof option === "function" ? option(query) : option;
164
+ function resolveQueryValue(value, query) {
165
+ return typeof value === "function" ? value(query) : value;
123
166
  }
167
+ /**
168
+ * Checks whether a query matches the given {@link QueryFilters}.
169
+ * Every filter that is specified must match; filters that are left unspecified are ignored.
170
+ *
171
+ * @example
172
+ * ```ts
173
+ * const queryCache = queryClient.getQueryCache()
174
+ *
175
+ * const matchingQueries = queryCache
176
+ * .getAll()
177
+ * .filter((query) => matchQuery({ queryKey: ['posts'] }, query))
178
+ * ```
179
+ */
124
180
  function matchQuery(filters, query) {
125
181
  const { type = "all", exact, fetchStatus, predicate, queryKey, stale } = filters;
126
182
  if (queryKey) {
@@ -138,6 +194,20 @@ function matchQuery(filters, query) {
138
194
  if (predicate && !predicate(query)) return false;
139
195
  return true;
140
196
  }
197
+ /**
198
+ * Checks whether a mutation matches the given {@link MutationFilters}.
199
+ * Every filter that is specified must match; filters that are left unspecified are ignored.
200
+ * If a `mutationKey` filter is provided but the mutation has no `mutationKey` of its own, it does not match.
201
+ *
202
+ * @example
203
+ * ```ts
204
+ * const mutationCache = queryClient.getMutationCache()
205
+ *
206
+ * const matchingMutations = mutationCache
207
+ * .getAll()
208
+ * .filter((mutation) => matchMutation({ mutationKey: ['addPost'] }, mutation))
209
+ * ```
210
+ */
141
211
  function matchMutation(filters, mutation) {
142
212
  const { exact, status, predicate, mutationKey } = filters;
143
213
  if (mutationKey) {
@@ -153,6 +223,16 @@ function matchMutation(filters, mutation) {
153
223
  function hashQueryKeyByOptions(queryKey, options) {
154
224
  return (options?.queryKeyHashFn || hashKey)(queryKey);
155
225
  }
226
+ /**
227
+ * Default query & mutation keys hash function.
228
+ * Hashes the value into a stable hash.
229
+ *
230
+ * @example
231
+ * ```ts
232
+ * // Object keys are sorted, so key order doesn't affect the hash:
233
+ * hashKey(['todos', { page: 1, filter: 'done' }]) // === '["todos",{"filter":"done","page":1}]'
234
+ * ```
235
+ */
156
236
  function hashKey(queryKey) {
157
237
  return JSON.stringify(queryKey, (_, val) => isPlainObject(val) ? Object.keys(val).sort().reduce((result, key) => {
158
238
  result[key] = val[key];
@@ -162,7 +242,16 @@ function hashKey(queryKey) {
162
242
  function partialMatchKey(a, b) {
163
243
  if (a === b) return true;
164
244
  if (typeof a !== typeof b) return false;
165
- if (a && b && typeof a === "object" && typeof b === "object") return Object.keys(b).every((key) => partialMatchKey(a[key], b[key]));
245
+ if (a && b && typeof a === "object" && typeof b === "object") {
246
+ if (Array.isArray(a) && Array.isArray(b)) {
247
+ if (b.length > a.length) return false;
248
+ for (let i = 0; i < b.length; i++) if (!partialMatchKey(a[i], b[i])) return false;
249
+ return true;
250
+ }
251
+ const bKeys = Object.keys(b);
252
+ for (const key of bKeys) if (!partialMatchKey(a[key], b[key])) return false;
253
+ return true;
254
+ }
166
255
  return false;
167
256
  }
168
257
  var hasOwn = Object.prototype.hasOwnProperty;
@@ -195,6 +284,9 @@ function replaceEqualDeep(a, b, depth = 0) {
195
284
  }
196
285
  return aSize === bSize && equalItems === aSize ? a : copy;
197
286
  }
287
+ /**
288
+ * Shallow compare objects.
289
+ */
198
290
  function shallowEqualObjects(a, b) {
199
291
  if (!b || Object.keys(a).length !== Object.keys(b).length) return false;
200
292
  for (const key in a) if (a[key] !== b[key]) return false;
@@ -205,12 +297,14 @@ function isPlainArray(value) {
205
297
  }
206
298
  function isPlainObject(o) {
207
299
  if (!hasObjectPrototype(o)) return false;
208
- const ctor = o.constructor;
300
+ const objectPrototype = Object.getPrototypeOf(o);
301
+ const ctor = objectPrototype?.constructor;
209
302
  if (ctor === void 0) return true;
303
+ if (typeof ctor !== "function") return false;
210
304
  const prot = ctor.prototype;
211
305
  if (!hasObjectPrototype(prot)) return false;
212
306
  if (!prot.hasOwnProperty("isPrototypeOf")) return false;
213
- if (Object.getPrototypeOf(o) !== Object.prototype) return false;
307
+ if (objectPrototype !== Object.prototype) return false;
214
308
  return true;
215
309
  }
216
310
  function hasObjectPrototype(o) {
@@ -234,12 +328,40 @@ function addToStart(items, item, max = 0) {
234
328
  const newItems = [item, ...items];
235
329
  return max && newItems.length > max ? newItems.slice(0, -1) : newItems;
236
330
  }
237
- var skipToken = /* @__PURE__ */ Symbol();
331
+ /**
332
+ * Sentinel value that can be passed as a query's `queryFn` to conditionally disable the query (equivalent
333
+ * to `enabled: false`) while preserving full type inference for the query's data. Unlike `enabled: false`,
334
+ * a query disabled via `skipToken` cannot be triggered with `refetch`.
335
+ *
336
+ * @example
337
+ * ```ts
338
+ * new QueryObserver(queryClient, {
339
+ * queryKey: ['post', postId],
340
+ * queryFn: postId != null ? () => fetchPost(postId) : skipToken,
341
+ * })
342
+ * ```
343
+ */
344
+ var skipToken = Symbol();
238
345
  function ensureQueryFn(options, fetchOptions) {
239
346
  if (!options.queryFn && fetchOptions?.initialPromise) return () => fetchOptions.initialPromise;
240
347
  if (!options.queryFn || options.queryFn === skipToken) return () => Promise.reject(/* @__PURE__ */ new Error(`Missing queryFn: '${options.queryHash}'`));
241
348
  return options.queryFn;
242
349
  }
350
+ /**
351
+ * Resolves a `throwOnError` option to a boolean.
352
+ * If `throwOnError` is a function, it is called with `params` (e.g. the error and, depending on the caller,
353
+ * additional context such as the query or mutation) and its result is returned, allowing the throwing
354
+ * behavior to be decided per error. Otherwise, `throwOnError` itself is coerced to a boolean (`undefined`
355
+ * resolves to `false`).
356
+ *
357
+ * @example
358
+ * ```ts
359
+ * const throwOnError =
360
+ * query.state.error && typeof options.throwOnError === 'function'
361
+ * ? shouldThrowError(options.throwOnError, [query.state.error, query])
362
+ * : options.throwOnError
363
+ * ```
364
+ */
243
365
  function shouldThrowError(throwOnError, params) {
244
366
  if (typeof throwOnError === "function") return throwOnError(...params);
245
367
  return !!throwOnError;
@@ -261,52 +383,171 @@ function addConsumeAwareSignal(object, getSignal, onCancelled) {
261
383
  return object;
262
384
  }
263
385
  //#endregion
264
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/environmentManager.js
265
- var environmentManager = /* @__PURE__ */ (() => {
266
- let isServerFn = () => isServer;
267
- return {
268
- isServer() {
269
- return isServerFn();
270
- },
271
- setIsServer(isServerValue) {
272
- isServerFn = isServerValue;
273
- }
274
- };
275
- })();
386
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/environmentManager.js
387
+ var isServerFn = () => isServer$1;
388
+ /**
389
+ * Returns whether the current runtime should be treated as a server environment.
390
+ */
391
+ var isServer = () => isServerFn();
276
392
  //#endregion
277
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/thenable.js
278
- function pendingThenable() {
279
- let resolve;
280
- let reject;
281
- const thenable = new Promise((_resolve, _reject) => {
282
- resolve = _resolve;
283
- reject = _reject;
284
- });
285
- thenable.status = "pending";
286
- thenable.catch(() => {});
287
- function finalize(data) {
288
- Object.assign(thenable, data);
289
- delete thenable.resolve;
290
- delete thenable.reject;
291
- }
292
- thenable.resolve = (value) => {
293
- finalize({
294
- status: "fulfilled",
295
- value
393
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/subscribable.js
394
+ /**
395
+ * The base class behind everything in Query that you can subscribe to: `QueryCache`, `MutationCache`,
396
+ * the observers, and the `FocusManager`/`OnlineManager` behind `focusManager` and `onlineManager`.
397
+ * Subclasses decide what a listener receives and when it is called.
398
+ */
399
+ var Subscribable = class {
400
+ constructor() {
401
+ this.listeners = /* @__PURE__ */ new Set();
402
+ this.subscribe = this.subscribe.bind(this);
403
+ }
404
+ /**
405
+ * Registers a listener to be called on every update this object notifies about. Returns a function
406
+ * that removes the listener again — call it to stop listening. The base class never drops a listener
407
+ * on its own, though some subclasses clear all of theirs in `destroy()`.
408
+ * @param listener - Called on each update, with whatever the subclass passes to its subscribers.
409
+ * @example
410
+ * ```ts
411
+ * const unsubscribe = subscribable.subscribe(() => {
412
+ * // react to the update
413
+ * })
414
+ *
415
+ * unsubscribe()
416
+ * ```
417
+ */
418
+ subscribe(listener) {
419
+ this.listeners.add(listener);
420
+ this.onSubscribe();
421
+ return () => {
422
+ this.listeners.delete(listener);
423
+ this.onUnsubscribe();
424
+ };
425
+ }
426
+ /**
427
+ * Returns `true` while at least one listener is registered, `false` once they have all unsubscribed.
428
+ */
429
+ hasListeners() {
430
+ return this.listeners.size > 0;
431
+ }
432
+ onSubscribe() {}
433
+ onUnsubscribe() {}
434
+ };
435
+ //#endregion
436
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/focusManager.js
437
+ /**
438
+ * The `FocusManager` manages the focus state within TanStack Query.
439
+ *
440
+ * It can be used to change the default event listeners or to manually change the focus state.
441
+ */
442
+ var FocusManager = class extends Subscribable {
443
+ #focused;
444
+ #cleanup;
445
+ #setup;
446
+ constructor() {
447
+ super();
448
+ this.#setup = (onFocus) => {
449
+ if (typeof window !== "undefined" && window.addEventListener) {
450
+ const listener = () => onFocus();
451
+ window.addEventListener("visibilitychange", listener, false);
452
+ return () => {
453
+ window.removeEventListener("visibilitychange", listener);
454
+ };
455
+ }
456
+ };
457
+ }
458
+ onSubscribe() {
459
+ if (!this.#cleanup) this.setEventListener(this.#setup);
460
+ }
461
+ onUnsubscribe() {
462
+ if (!this.hasListeners()) {
463
+ this.#cleanup?.();
464
+ this.#cleanup = void 0;
465
+ }
466
+ }
467
+ /**
468
+ * `setEventListener` can be used to set a custom event listener that will
469
+ * be used to determine the focus state. The provided `setup` function
470
+ * receives a `setFocused` callback: call it with a `boolean` to manually
471
+ * set the focus state, or with no arguments to re-evaluate the current
472
+ * focus state and notify subscribers.
473
+ *
474
+ * @example
475
+ * ```ts
476
+ * import { focusManager } from '@tanstack/query-core'
477
+ *
478
+ * focusManager.setEventListener((handleFocus) => {
479
+ * const listener = () => handleFocus()
480
+ * // Listen to visibilitychange
481
+ * if (typeof window !== 'undefined' && window.addEventListener) {
482
+ * window.addEventListener('visibilitychange', listener, false)
483
+ * }
484
+ *
485
+ * return () => {
486
+ * // Be sure to unsubscribe if a new handler is set
487
+ * window.removeEventListener('visibilitychange', listener)
488
+ * }
489
+ * })
490
+ * ```
491
+ */
492
+ setEventListener(setup) {
493
+ this.#setup = setup;
494
+ this.#cleanup?.();
495
+ this.#cleanup = setup((focused) => {
496
+ if (typeof focused === "boolean") this.setFocused(focused);
497
+ else this.onFocus();
296
498
  });
297
- resolve(value);
298
- };
299
- thenable.reject = (reason) => {
300
- finalize({
301
- status: "rejected",
302
- reason
499
+ }
500
+ /**
501
+ * `setFocused` can be used to manually set the focus state. Set `undefined`
502
+ * to fall back to the default focus check.
503
+ *
504
+ * @example
505
+ * ```ts
506
+ * import { focusManager } from '@tanstack/query-core'
507
+ *
508
+ * // Set focused
509
+ * focusManager.setFocused(true)
510
+ *
511
+ * // Set unfocused
512
+ * focusManager.setFocused(false)
513
+ *
514
+ * // Fallback to the default focus check
515
+ * focusManager.setFocused(undefined)
516
+ * ```
517
+ */
518
+ setFocused(focused) {
519
+ if (this.#focused !== focused) {
520
+ this.#focused = focused;
521
+ this.onFocus();
522
+ }
523
+ }
524
+ /**
525
+ * `onFocus` notifies all subscribed listeners with the current focus state.
526
+ */
527
+ onFocus() {
528
+ const isFocused = this.isFocused();
529
+ this.listeners.forEach((listener) => {
530
+ listener(isFocused);
303
531
  });
304
- reject(reason);
305
- };
306
- return thenable;
307
- }
532
+ }
533
+ /**
534
+ * `isFocused` can be used to get the current focus state.
535
+ */
536
+ isFocused() {
537
+ if (typeof this.#focused === "boolean") return this.#focused;
538
+ return globalThis.document?.visibilityState !== "hidden";
539
+ }
540
+ };
541
+ /**
542
+ * Singleton instance of {@link FocusManager}, used to manage and observe the focus state within TanStack Query.
543
+ */
544
+ var focusManager = new FocusManager();
308
545
  //#endregion
309
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/notifyManager.js
546
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/notifyManager.js
547
+ /**
548
+ * Default scheduling function used by the notify manager.
549
+ * Schedules the callback with the system's `setTimeout(callback, 0)`.
550
+ */
310
551
  var defaultScheduler = systemSetTimeoutZero;
311
552
  function createNotifyManager() {
312
553
  let queue = [];
@@ -366,9 +607,21 @@ function createNotifyManager() {
366
607
  }
367
608
  };
368
609
  }
610
+ /**
611
+ * Handles scheduling and batching callbacks in TanStack Query.
612
+ */
369
613
  var notifyManager = createNotifyManager();
370
614
  //#endregion
371
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/onlineManager.js
615
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/onlineManager.js
616
+ /**
617
+ * The `OnlineManager` manages the online state within TanStack Query. It can
618
+ * be used to change the default event listeners or to manually change the
619
+ * online state.
620
+ *
621
+ * By default, the `onlineManager` assumes an active network connection, and
622
+ * listens to the `online` and `offline` events on the `window` object to
623
+ * detect changes.
624
+ */
372
625
  var OnlineManager = class extends Subscribable {
373
626
  #online = true;
374
627
  #cleanup;
@@ -397,11 +650,43 @@ var OnlineManager = class extends Subscribable {
397
650
  this.#cleanup = void 0;
398
651
  }
399
652
  }
653
+ /**
654
+ * `setEventListener` can be used to set a custom event listener that will
655
+ * be used to determine the online state. The provided `setup` function
656
+ * receives a `setOnline` callback that should be called with a `boolean`
657
+ * whenever the online state changes.
658
+ *
659
+ * @example
660
+ * ```ts
661
+ * import NetInfo from '@react-native-community/netinfo'
662
+ * import { onlineManager } from '@tanstack/query-core'
663
+ *
664
+ * onlineManager.setEventListener((setOnline) => {
665
+ * return NetInfo.addEventListener((state) => {
666
+ * setOnline(!!state.isConnected)
667
+ * })
668
+ * })
669
+ * ```
670
+ */
400
671
  setEventListener(setup) {
401
672
  this.#setup = setup;
402
673
  this.#cleanup?.();
403
674
  this.#cleanup = setup(this.setOnline.bind(this));
404
675
  }
676
+ /**
677
+ * `setOnline` can be used to manually set the online state.
678
+ *
679
+ * @example
680
+ * ```ts
681
+ * import { onlineManager } from '@tanstack/query-core'
682
+ *
683
+ * // Set to online
684
+ * onlineManager.setOnline(true)
685
+ *
686
+ * // Set to offline
687
+ * onlineManager.setOnline(false)
688
+ * ```
689
+ */
405
690
  setOnline(online) {
406
691
  if (this.#online !== online) {
407
692
  this.#online = online;
@@ -410,19 +695,43 @@ var OnlineManager = class extends Subscribable {
410
695
  });
411
696
  }
412
697
  }
698
+ /**
699
+ * `isOnline` can be used to get the current online state.
700
+ */
413
701
  isOnline() {
414
702
  return this.#online;
415
703
  }
416
704
  };
705
+ /**
706
+ * Singleton instance of {@link OnlineManager}, used to manage and observe the online state within TanStack Query.
707
+ */
417
708
  var onlineManager = new OnlineManager();
418
709
  //#endregion
419
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/retryer.js
710
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/retryer.js
420
711
  function defaultRetryDelay(failureCount) {
421
712
  return Math.min(1e3 * 2 ** failureCount, 3e4);
422
713
  }
423
714
  function canFetch(networkMode) {
424
715
  return (networkMode ?? "online") === "online" ? onlineManager.isOnline() : true;
425
716
  }
717
+ /**
718
+ * The error thrown by a `Retryer` (and surfaced to `query.promise`/`mutation`) when a fetch is cancelled, e.g. via
719
+ * `query.cancel()`. `revert`, if `true`, tells the caller to restore the state the query was in before the fetch
720
+ * started instead of surfacing the error. `silent`, if `true`, tells the caller to suppress this error and instead
721
+ * resolve with the promise of the fetch that triggered the cancellation.
722
+ * @example
723
+ * ```ts
724
+ * query.cancel()
725
+ *
726
+ * try {
727
+ * await query.promise
728
+ * } catch (error) {
729
+ * if (error instanceof CancelledError) {
730
+ * // the fetch was cancelled, e.g. via `query.cancel()`
731
+ * }
732
+ * }
733
+ * ```
734
+ */
426
735
  var CancelledError = class extends Error {
427
736
  constructor(options) {
428
737
  super("CancelledError");
@@ -434,8 +743,15 @@ function createRetryer(config) {
434
743
  let isRetryCancelled = false;
435
744
  let failureCount = 0;
436
745
  let continueFn;
437
- const thenable = pendingThenable();
438
- const isResolved = () => thenable.status !== "pending";
746
+ let status = "pending";
747
+ let promiseResolve;
748
+ let promiseReject;
749
+ const promise = new Promise((resolve, reject) => {
750
+ promiseResolve = resolve;
751
+ promiseReject = reject;
752
+ });
753
+ promise.catch(noop);
754
+ const isResolved = () => status !== "pending";
439
755
  const cancel = (cancelOptions) => {
440
756
  if (!isResolved()) {
441
757
  const error = new CancelledError(cancelOptions);
@@ -454,13 +770,15 @@ function createRetryer(config) {
454
770
  const resolve = (value) => {
455
771
  if (!isResolved()) {
456
772
  continueFn?.();
457
- thenable.resolve(value);
773
+ status = "resolved";
774
+ promiseResolve(value);
458
775
  }
459
776
  };
460
777
  const reject = (value) => {
461
778
  if (!isResolved()) {
462
779
  continueFn?.();
463
- thenable.reject(value);
780
+ status = "rejected";
781
+ promiseReject(value);
464
782
  }
465
783
  };
466
784
  const pause = () => {
@@ -485,7 +803,7 @@ function createRetryer(config) {
485
803
  }
486
804
  Promise.resolve(promiseOrValue).then(resolve).catch((error) => {
487
805
  if (isResolved()) return;
488
- const retry = config.retry ?? (environmentManager.isServer() ? 0 : 3);
806
+ const retry = config.retry ?? (isServer() ? 0 : 3);
489
807
  const retryDelay = config.retryDelay ?? defaultRetryDelay;
490
808
  const delay = typeof retryDelay === "function" ? retryDelay(failureCount, error) : retryDelay;
491
809
  const shouldRetry = retry === true || typeof retry === "number" && failureCount < retry || typeof retry === "function" && retry(failureCount, error);
@@ -504,12 +822,12 @@ function createRetryer(config) {
504
822
  });
505
823
  };
506
824
  return {
507
- promise: thenable,
508
- status: () => thenable.status,
825
+ promise,
826
+ status: () => status,
509
827
  cancel,
510
828
  continue: () => {
511
829
  continueFn?.();
512
- return thenable;
830
+ return promise;
513
831
  },
514
832
  cancelRetry,
515
833
  continueRetry,
@@ -517,14 +835,23 @@ function createRetryer(config) {
517
835
  start: () => {
518
836
  if (canStart()) run();
519
837
  else pause().then(run);
520
- return thenable;
838
+ return promise;
521
839
  }
522
840
  };
523
841
  }
524
842
  //#endregion
525
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/removable.js
843
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/removable.js
844
+ /**
845
+ * The base class for cache entries that are garbage collected once nothing is using them —
846
+ * `Query` and `Mutation` both extend it. `gcTime` controls how long an unused entry is kept.
847
+ */
526
848
  var Removable = class {
527
849
  #gcTimeout;
850
+ /**
851
+ * Clears the pending garbage collection timeout, so the entry is no longer scheduled for removal.
852
+ * A subclass may override this to release what it holds on to as well — `Query` also cancels any
853
+ * in-flight fetch.
854
+ */
528
855
  destroy() {
529
856
  this.clearGcTimeout();
530
857
  }
@@ -535,7 +862,7 @@ var Removable = class {
535
862
  }, this.gcTime);
536
863
  }
537
864
  updateGcTime(newGcTime) {
538
- this.gcTime = Math.max(this.gcTime || 0, newGcTime ?? (environmentManager.isServer() ? Infinity : 300 * 1e3));
865
+ this.gcTime = Math.max(this.gcTime || 0, newGcTime ?? (isServer() ? Infinity : 3e5));
539
866
  }
540
867
  clearGcTimeout() {
541
868
  if (this.#gcTimeout !== void 0) {
@@ -545,7 +872,7 @@ var Removable = class {
545
872
  }
546
873
  };
547
874
  //#endregion
548
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js
875
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js
549
876
  function infiniteQueryBehavior(pages) {
550
877
  return { onFetch: (context, query) => {
551
878
  const options = context.options;
@@ -567,15 +894,15 @@ function infiniteQueryBehavior(pages) {
567
894
  if (cancelled) return Promise.reject(context.signal.reason);
568
895
  if (param == null && data.pages.length) return Promise.resolve(data);
569
896
  const createQueryFnContext = () => {
570
- const queryFnContext2 = {
897
+ const queryFnContext = {
571
898
  client: context.client,
572
899
  queryKey: context.queryKey,
573
900
  pageParam: param,
574
901
  direction: previous ? "backward" : "forward",
575
902
  meta: context.options.meta
576
903
  };
577
- addSignalProperty(queryFnContext2);
578
- return queryFnContext2;
904
+ addSignalProperty(queryFnContext);
905
+ return queryFnContext;
579
906
  };
580
907
  const page = await queryFn(createQueryFnContext());
581
908
  const { maxPages } = context.options;
@@ -623,7 +950,26 @@ function getPreviousPageParam(options, { pages, pageParams }) {
623
950
  return pages.length > 0 ? options.getPreviousPageParam?.(pages[0], pages, pageParams[0], pageParams) : void 0;
624
951
  }
625
952
  //#endregion
626
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/query.js
953
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/query.js
954
+ /**
955
+ * Represents a single cached query. A `Query` holds the query's key, options,
956
+ * state (data/error/status), and the observers currently subscribed to it.
957
+ *
958
+ * Instances are created and managed internally by `QueryCache`; application
959
+ * code typically interacts with queries indirectly through `QueryClient` or
960
+ * a framework hook like `useQuery`. Direct access to a `Query` instance is
961
+ * possible via `queryCache.find()`/`findAll()` for inspecting cache state.
962
+ *
963
+ * @example
964
+ * ```ts
965
+ * const queryCache = queryClient.getQueryCache()
966
+ * const query = queryCache.find({ queryKey: ['posts'] })
967
+ *
968
+ * if (query) {
969
+ * console.log(query.state.dataUpdatedAt)
970
+ * }
971
+ * ```
972
+ */
627
973
  var Query = class extends Removable {
628
974
  #queryType;
629
975
  #initialState;
@@ -647,15 +993,24 @@ var Query = class extends Removable {
647
993
  this.state = config.state ?? this.#initialState;
648
994
  this.scheduleGc();
649
995
  }
996
+ /**
997
+ * The `meta` object passed in the query's options, if any.
998
+ */
650
999
  get meta() {
651
1000
  return this.options.meta;
652
1001
  }
1002
+ /** @internal */
653
1003
  get queryType() {
654
1004
  return this.#queryType;
655
1005
  }
1006
+ /**
1007
+ * The promise for the currently in-flight fetch, if the query is fetching.
1008
+ * `undefined` when the query is not fetching.
1009
+ */
656
1010
  get promise() {
657
1011
  return this.#retryer?.promise;
658
1012
  }
1013
+ /** @internal */
659
1014
  setOptions(options) {
660
1015
  this.options = {
661
1016
  ...this.#defaultOptions,
@@ -674,6 +1029,7 @@ var Query = class extends Removable {
674
1029
  optionalRemove() {
675
1030
  if (!this.observers.length && this.state.fetchStatus === "idle") this.#cache.remove(this);
676
1031
  }
1032
+ /** @internal */
677
1033
  setData(newData, options) {
678
1034
  const data = replaceData(this.state.data, newData, this.options);
679
1035
  this.#dispatch({
@@ -684,60 +1040,141 @@ var Query = class extends Removable {
684
1040
  });
685
1041
  return data;
686
1042
  }
1043
+ /**
1044
+ * Merges the given partial state directly into this query's state, notifying observers. Used
1045
+ * by persistence and broadcast plugins to restore a state snapshot, and by devtools to let a
1046
+ * user manually trigger a loading/error state or edit the cached data.
1047
+ */
687
1048
  setState(state) {
688
1049
  this.#dispatch({
689
1050
  type: "setState",
690
1051
  state
691
1052
  });
692
1053
  }
1054
+ /**
1055
+ * Cancels the query's currently in-flight fetch, if any.
1056
+ * - Returns a promise that resolves once the cancellation has settled.
1057
+ * - If no fetch is in progress, resolves immediately.
1058
+ *
1059
+ * @example
1060
+ * ```ts
1061
+ * await query.cancel()
1062
+ * ```
1063
+ */
693
1064
  cancel(options) {
694
1065
  const promise = this.#retryer?.promise;
695
1066
  this.#retryer?.cancel(options);
696
1067
  return promise ? promise.then(noop).catch(noop) : Promise.resolve();
697
1068
  }
1069
+ /**
1070
+ * Clears the query's garbage collection timeout and silently cancels any
1071
+ * in-flight fetch. Called by `QueryCache` when the query is removed from
1072
+ * the cache.
1073
+ *
1074
+ * @see {@link Query#cancel}
1075
+ */
698
1076
  destroy() {
699
1077
  super.destroy();
700
1078
  this.cancel({ silent: true });
701
1079
  }
1080
+ /** @internal */
702
1081
  get resetState() {
703
1082
  return this.#initialState;
704
1083
  }
1084
+ /**
1085
+ * Resets the query back to its initial state (the state it had when it was
1086
+ * first created, e.g. any `initialData`), destroying it first to cancel any
1087
+ * in-flight fetch.
1088
+ */
705
1089
  reset() {
706
1090
  this.destroy();
707
1091
  this.setState(this.resetState);
708
1092
  }
1093
+ /**
1094
+ * Returns `true` if the query has at least one observer for which `enabled`
1095
+ * does not resolve to `false`.
1096
+ */
709
1097
  isActive() {
710
- return this.observers.some((observer) => resolveQueryBoolean(observer.options.enabled, this) !== false);
1098
+ return this.observers.some((observer) => resolveQueryValue(observer.options.enabled, this) !== false);
711
1099
  }
1100
+ /**
1101
+ * Returns `true` if the query is disabled, meaning it will not fetch
1102
+ * automatically.
1103
+ * - If the query has observers, it is disabled when none of them are active
1104
+ * (see `isActive`).
1105
+ * - If the query has no observers, it is disabled when its `queryFn` is
1106
+ * `skipToken` or it has never been fetched.
1107
+ */
712
1108
  isDisabled() {
713
1109
  if (this.getObserversCount() > 0) return !this.isActive();
714
1110
  return this.options.queryFn === skipToken || !this.isFetched();
715
1111
  }
1112
+ /**
1113
+ * Returns `true` if the query has been fetched, i.e. it has resolved with
1114
+ * either data or an error at least once.
1115
+ */
716
1116
  isFetched() {
717
1117
  return this.state.dataUpdateCount + this.state.errorUpdateCount > 0;
718
1118
  }
1119
+ /**
1120
+ * Returns `true` if the query has at least one observer configured with
1121
+ * `staleTime: 'static'`, meaning it is treated as never stale.
1122
+ */
719
1123
  isStatic() {
720
- if (this.getObserversCount() > 0) return this.observers.some((observer) => resolveStaleTime(observer.options.staleTime, this) === "static");
1124
+ if (this.getObserversCount() > 0) return this.observers.some((observer) => resolveQueryValue(observer.options.staleTime, this) === "static");
721
1125
  return false;
722
1126
  }
1127
+ /**
1128
+ * Returns `true` if the query is stale.
1129
+ * - If the query has observers, defers to whether any observer's current
1130
+ * result reports `isStale` (which accounts for each observer's own
1131
+ * `staleTime` and `enabled` state).
1132
+ * - If the query has no observers, it is considered stale when it has no
1133
+ * data or has been invalidated.
1134
+ *
1135
+ * @see {@link Query#isStaleByTime}
1136
+ * @example
1137
+ * ```ts
1138
+ * if (query.isStale()) {
1139
+ * // refetch or otherwise treat the cached data as outdated
1140
+ * }
1141
+ * ```
1142
+ */
723
1143
  isStale() {
724
1144
  if (this.getObserversCount() > 0) return this.observers.some((observer) => observer.getCurrentResult().isStale);
725
1145
  return this.state.data === void 0 || this.state.isInvalidated;
726
1146
  }
1147
+ /**
1148
+ * Returns `true` if the query's data is stale relative to the given
1149
+ * `staleTime` (defaults to `0`).
1150
+ * - A query with no data is always stale.
1151
+ * - `staleTime: 'static'` is never stale.
1152
+ * - An invalidated query is always stale.
1153
+ * - Otherwise, staleness is based on elapsed time since `dataUpdatedAt`.
1154
+ *
1155
+ * @see {@link Query#isStale}
1156
+ * @example
1157
+ * ```ts
1158
+ * const isStale = query.isStaleByTime(1000 * 60)
1159
+ * ```
1160
+ */
727
1161
  isStaleByTime(staleTime = 0) {
728
1162
  if (this.state.data === void 0) return true;
729
1163
  if (staleTime === "static") return false;
730
1164
  if (this.state.isInvalidated) return true;
731
1165
  return !timeUntilStale(this.state.dataUpdatedAt, staleTime);
732
1166
  }
1167
+ /** @internal */
733
1168
  onFocus() {
734
1169
  this.observers.find((x) => x.shouldFetchOnWindowFocus())?.refetch({ cancelRefetch: false });
735
1170
  this.#retryer?.continue();
736
1171
  }
1172
+ /** @internal */
737
1173
  onOnline() {
738
1174
  this.observers.find((x) => x.shouldFetchOnReconnect())?.refetch({ cancelRefetch: false });
739
1175
  this.#retryer?.continue();
740
1176
  }
1177
+ /** @internal */
741
1178
  addObserver(observer) {
742
1179
  if (!this.observers.includes(observer)) {
743
1180
  this.observers.push(observer);
@@ -749,11 +1186,13 @@ var Query = class extends Removable {
749
1186
  });
750
1187
  }
751
1188
  }
1189
+ /** @internal */
752
1190
  removeObserver(observer) {
753
- if (this.observers.includes(observer)) {
754
- this.observers = this.observers.filter((x) => x !== observer);
1191
+ const index = this.observers.indexOf(observer);
1192
+ if (index !== -1) {
1193
+ this.observers.splice(index, 1);
755
1194
  if (!this.observers.length) {
756
- if (this.#retryer) if (this.#abortSignalConsumed || this.#isInitialPausedFetch()) this.#retryer.cancel({ revert: true });
1195
+ if (this.#retryer) if (this.#abortSignalConsumed || this.state.fetchStatus === "paused" && this.state.status === "pending") this.#retryer.cancel({ revert: true });
757
1196
  else this.#retryer.cancelRetry();
758
1197
  this.scheduleGc();
759
1198
  }
@@ -764,15 +1203,42 @@ var Query = class extends Removable {
764
1203
  });
765
1204
  }
766
1205
  }
1206
+ /**
1207
+ * Returns the number of observers currently subscribed to this query.
1208
+ *
1209
+ * @example
1210
+ * ```ts
1211
+ * if (query.getObserversCount() === 0) {
1212
+ * // no component is currently watching this query
1213
+ * }
1214
+ * ```
1215
+ */
767
1216
  getObserversCount() {
768
1217
  return this.observers.length;
769
1218
  }
770
- #isInitialPausedFetch() {
771
- return this.state.fetchStatus === "paused" && this.state.status === "pending";
772
- }
1219
+ /**
1220
+ * Marks the query as invalidated, unless it is already invalidated. This
1221
+ * updates `state.isInvalidated` and notifies observers, but does not by
1222
+ * itself trigger a refetch.
1223
+ *
1224
+ * @example
1225
+ * ```ts
1226
+ * query.invalidate()
1227
+ * ```
1228
+ */
773
1229
  invalidate() {
774
1230
  if (!this.state.isInvalidated) this.#dispatch({ type: "invalidate" });
775
1231
  }
1232
+ /**
1233
+ * Fetches the query, i.e. runs its `queryFn` (through any configured
1234
+ * retryer/behavior) and updates the query's state with the result.
1235
+ * - If a fetch is already in flight, returns its promise instead of
1236
+ * starting a new one, unless `fetchOptions.cancelRefetch` is set and the
1237
+ * query already has data, in which case the current fetch is silently
1238
+ * cancelled first.
1239
+ * - If `options` is passed, it replaces the query's current options
1240
+ * before fetching.
1241
+ */
776
1242
  async fetch(options, fetchOptions) {
777
1243
  if (this.state.fetchStatus !== "idle" && this.#retryer?.status() !== "rejected") {
778
1244
  if (this.state.data !== void 0 && fetchOptions?.cancelRefetch) this.cancel({ silent: true });
@@ -799,13 +1265,13 @@ var Query = class extends Removable {
799
1265
  const fetchFn = () => {
800
1266
  const queryFn = ensureQueryFn(this.options, fetchOptions);
801
1267
  const createQueryFnContext = () => {
802
- const queryFnContext2 = {
1268
+ const queryFnContext = {
803
1269
  client: this.#client,
804
1270
  queryKey: this.queryKey,
805
1271
  meta: this.meta
806
1272
  };
807
- addSignalProperty(queryFnContext2);
808
- return queryFnContext2;
1273
+ addSignalProperty(queryFnContext);
1274
+ return queryFnContext;
809
1275
  };
810
1276
  const queryFnContext = createQueryFnContext();
811
1277
  this.#abortSignalConsumed = false;
@@ -813,7 +1279,7 @@ var Query = class extends Removable {
813
1279
  return queryFn(queryFnContext);
814
1280
  };
815
1281
  const createFetchContext = () => {
816
- const context2 = {
1282
+ const context = {
817
1283
  fetchOptions,
818
1284
  options: this.options,
819
1285
  queryKey: this.queryKey,
@@ -821,8 +1287,8 @@ var Query = class extends Removable {
821
1287
  state: this.state,
822
1288
  fetchFn
823
1289
  };
824
- addSignalProperty(context2);
825
- return context2;
1290
+ addSignalProperty(context);
1291
+ return context;
826
1292
  };
827
1293
  const context = createFetchContext();
828
1294
  (this.#queryType === "infinite" ? infiniteQueryBehavior(this.options.pages) : this.options.behavior)?.onFetch(context, this);
@@ -831,7 +1297,7 @@ var Query = class extends Removable {
831
1297
  type: "fetch",
832
1298
  meta: context.fetchOptions?.meta
833
1299
  });
834
- this.#retryer = createRetryer({
1300
+ const retryer = this.#retryer = createRetryer({
835
1301
  initialPromise: fetchOptions?.initialPromise,
836
1302
  fn: context.fetchFn,
837
1303
  onCancel: (error) => {
@@ -860,7 +1326,7 @@ var Query = class extends Removable {
860
1326
  canRun: () => true
861
1327
  });
862
1328
  try {
863
- const data = await this.#retryer.start();
1329
+ const data = await retryer.start();
864
1330
  if (data === void 0) throw new Error(`${this.queryHash} data is undefined`);
865
1331
  this.setData(data);
866
1332
  this.#cache.config.onSuccess?.(data, this);
@@ -882,6 +1348,7 @@ var Query = class extends Removable {
882
1348
  this.#cache.config.onSettled?.(this.state.data, error, this);
883
1349
  throw error;
884
1350
  } finally {
1351
+ if (this.#retryer === retryer) this.#retryer = void 0;
885
1352
  this.scheduleGc();
886
1353
  }
887
1354
  }
@@ -944,7 +1411,7 @@ var Query = class extends Removable {
944
1411
  };
945
1412
  this.state = reducer(this.state);
946
1413
  notifyManager.batch(() => {
947
- this.observers.forEach((observer) => {
1414
+ this.observers.slice().forEach((observer) => {
948
1415
  observer.onQueryUpdate();
949
1416
  });
950
1417
  this.#cache.notify({
@@ -995,24 +1462,34 @@ function getDefaultState$1(options) {
995
1462
  };
996
1463
  }
997
1464
  //#endregion
998
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/queryObserver.js
1465
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/queryObserver.js
1466
+ /**
1467
+ * A `QueryObserver` watches a single query in the `QueryCache` and computes a
1468
+ * `QueryObserverResult` from its state, recomputing and notifying subscribers
1469
+ * whenever the underlying query (or the observer's options) changes. It is
1470
+ * the primitive that framework adapters (e.g. `useQuery`) build their hooks
1471
+ * on top of, but it can also be used directly to observe and switch between
1472
+ * queries outside of any framework.
1473
+ *
1474
+ * @example
1475
+ * ```ts
1476
+ * const observer = new QueryObserver(queryClient, {
1477
+ * queryKey: ['posts'],
1478
+ * queryFn: fetchPosts,
1479
+ * })
1480
+ *
1481
+ * const unsubscribe = observer.subscribe((result) => {
1482
+ * console.log(result.data)
1483
+ * })
1484
+ * ```
1485
+ */
999
1486
  var QueryObserver = class extends Subscribable {
1000
- constructor(client, options) {
1001
- super();
1002
- this.options = options;
1003
- this.#client = client;
1004
- this.#selectError = null;
1005
- this.#currentThenable = pendingThenable();
1006
- this.bindMethods();
1007
- this.setOptions(options);
1008
- }
1009
1487
  #client;
1010
1488
  #currentQuery = void 0;
1011
1489
  #currentQueryInitialState = void 0;
1012
1490
  #currentResult = void 0;
1013
1491
  #currentResultState;
1014
1492
  #currentResultOptions;
1015
- #currentThenable;
1016
1493
  #selectError;
1017
1494
  #selectFn;
1018
1495
  #selectResult;
@@ -1021,6 +1498,14 @@ var QueryObserver = class extends Subscribable {
1021
1498
  #refetchIntervalId;
1022
1499
  #currentRefetchInterval;
1023
1500
  #trackedProps = /* @__PURE__ */ new Set();
1501
+ constructor(client, options) {
1502
+ super();
1503
+ this.options = options;
1504
+ this.#client = client;
1505
+ this.#selectError = null;
1506
+ this.bindMethods();
1507
+ this.setOptions(options);
1508
+ }
1024
1509
  bindMethods() {
1025
1510
  this.refetch = this.refetch.bind(this);
1026
1511
  }
@@ -1035,23 +1520,52 @@ var QueryObserver = class extends Subscribable {
1035
1520
  onUnsubscribe() {
1036
1521
  if (!this.hasListeners()) this.destroy();
1037
1522
  }
1523
+ /**
1524
+ * Returns whether the observed query is currently stale and configured
1525
+ * (via the `refetchOnReconnect` option) to refetch when the network
1526
+ * reconnects.
1527
+ */
1038
1528
  shouldFetchOnReconnect() {
1039
1529
  return shouldFetchOn(this.#currentQuery, this.options, this.options.refetchOnReconnect);
1040
1530
  }
1531
+ /**
1532
+ * Returns whether the observed query is currently stale and configured
1533
+ * (via the `refetchOnWindowFocus` option) to refetch when the window
1534
+ * regains focus.
1535
+ */
1041
1536
  shouldFetchOnWindowFocus() {
1042
1537
  return shouldFetchOn(this.#currentQuery, this.options, this.options.refetchOnWindowFocus);
1043
1538
  }
1539
+ /**
1540
+ * Stops observing the current query: clears all listeners, cancels the
1541
+ * stale and refetch-interval timers, and removes this observer from the
1542
+ * query it was observing.
1543
+ */
1044
1544
  destroy() {
1045
1545
  this.listeners = /* @__PURE__ */ new Set();
1046
1546
  this.#clearStaleTimeout();
1047
1547
  this.#clearRefetchInterval();
1048
1548
  this.#currentQuery.removeObserver(this);
1049
1549
  }
1550
+ /**
1551
+ * Updates the observer's options. This will re-resolve the query being
1552
+ * observed (switching to a different query if the `queryKey` changed),
1553
+ * trigger a fetch if the new options require one and the observer has
1554
+ * subscribers, recompute the current result, and reschedule the stale and
1555
+ * refetch-interval timers as needed.
1556
+ *
1557
+ * @example
1558
+ * ```ts
1559
+ * observer.setOptions({ queryKey: ['posts', 1], queryFn: () => fetchPost(1) })
1560
+ * // later: switch to a different query, reusing the same observer
1561
+ * observer.setOptions({ queryKey: ['posts', 2], queryFn: () => fetchPost(2) })
1562
+ * ```
1563
+ */
1050
1564
  setOptions(options) {
1051
1565
  const prevOptions = this.options;
1052
1566
  const prevQuery = this.#currentQuery;
1053
1567
  this.options = this.#client.defaultQueryOptions(options);
1054
- if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean" && typeof this.options.enabled !== "function" && typeof resolveQueryBoolean(this.options.enabled, this.#currentQuery) !== "boolean") throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");
1568
+ if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean" && typeof this.options.enabled !== "function" && typeof resolveQueryValue(this.options.enabled, this.#currentQuery) !== "boolean") throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");
1055
1569
  this.#updateQuery();
1056
1570
  this.#currentQuery.setOptions(this.options);
1057
1571
  if (prevOptions._defaulted && !shallowEqualObjects(this.options, prevOptions)) this.#client.getQueryCache().notify({
@@ -1062,47 +1576,119 @@ var QueryObserver = class extends Subscribable {
1062
1576
  const mounted = this.hasListeners();
1063
1577
  if (mounted && shouldFetchOptionally(this.#currentQuery, prevQuery, this.options, prevOptions)) this.#executeFetch();
1064
1578
  this.updateResult();
1065
- if (mounted && (this.#currentQuery !== prevQuery || resolveQueryBoolean(this.options.enabled, this.#currentQuery) !== resolveQueryBoolean(prevOptions.enabled, this.#currentQuery) || resolveStaleTime(this.options.staleTime, this.#currentQuery) !== resolveStaleTime(prevOptions.staleTime, this.#currentQuery))) this.#updateStaleTimeout();
1579
+ if (mounted && (this.#currentQuery !== prevQuery || resolveQueryValue(this.options.enabled, this.#currentQuery) !== resolveQueryValue(prevOptions.enabled, this.#currentQuery) || resolveQueryValue(this.options.staleTime, this.#currentQuery) !== resolveQueryValue(prevOptions.staleTime, this.#currentQuery))) this.#updateStaleTimeout();
1066
1580
  const nextRefetchInterval = this.#computeRefetchInterval();
1067
- if (mounted && (this.#currentQuery !== prevQuery || resolveQueryBoolean(this.options.enabled, this.#currentQuery) !== resolveQueryBoolean(prevOptions.enabled, this.#currentQuery) || nextRefetchInterval !== this.#currentRefetchInterval)) this.#updateRefetchInterval(nextRefetchInterval);
1581
+ if (mounted && (this.#currentQuery !== prevQuery || resolveQueryValue(this.options.enabled, this.#currentQuery) !== resolveQueryValue(prevOptions.enabled, this.#currentQuery) || nextRefetchInterval !== this.#currentRefetchInterval)) this.#updateRefetchInterval(nextRefetchInterval);
1068
1582
  }
1583
+ /**
1584
+ * Computes the result the observer would produce for the given (already-defaulted) options
1585
+ * right now, building the underlying `Query` if it doesn't exist yet, without waiting for a
1586
+ * subscription callback. Called by framework adapters on every render (e.g. `useQuery`) so the
1587
+ * returned value is available synchronously, ahead of `setOptions` triggering an actual fetch.
1588
+ */
1069
1589
  getOptimisticResult(options) {
1070
1590
  const query = this.#client.getQueryCache().build(this.#client, options);
1071
1591
  const result = this.createResult(query, options);
1072
- if (shouldAssignObserverCurrentProperties(this, result)) {
1592
+ if (!shallowEqualObjects(this.getCurrentResult(), result)) {
1073
1593
  this.#currentResult = result;
1074
1594
  this.#currentResultOptions = this.options;
1075
1595
  this.#currentResultState = this.#currentQuery.state;
1076
1596
  }
1077
1597
  return result;
1078
1598
  }
1599
+ /**
1600
+ * Returns the most recently computed `QueryObserverResult` for the
1601
+ * observed query. This is a point-in-time read; to be notified of updates
1602
+ * as they happen, subscribe to the observer instead (its inherited
1603
+ * `subscribe` method).
1604
+ *
1605
+ * @example
1606
+ * ```ts
1607
+ * const result = observer.getCurrentResult()
1608
+ * console.log(result.status, result.data)
1609
+ * ```
1610
+ */
1079
1611
  getCurrentResult() {
1080
1612
  return this.#currentResult;
1081
1613
  }
1614
+ /**
1615
+ * Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via
1616
+ * {@link QueryObserver#trackProp} (and an optional `onPropTracked` callback). Used by framework
1617
+ * adapters when `notifyOnChangeProps` is not set, to implement its default "only re-render on
1618
+ * properties you actually read" behavior.
1619
+ */
1082
1620
  trackResult(result, onPropTracked) {
1083
1621
  return new Proxy(result, { get: (target, key) => {
1084
1622
  this.trackProp(key);
1085
1623
  onPropTracked?.(key);
1086
- if (key === "promise") {
1087
- this.trackProp("data");
1088
- if (!this.options.experimental_prefetchInRender && this.#currentThenable.status === "pending") this.#currentThenable.reject(/* @__PURE__ */ new Error("experimental_prefetchInRender feature flag is not enabled"));
1089
- }
1090
1624
  return Reflect.get(target, key);
1091
1625
  } });
1092
1626
  }
1627
+ /**
1628
+ * Records that the given `QueryObserverResult` property was read, so a subsequent update only
1629
+ * notifies this observer if a tracked property actually changed. Normally called indirectly via
1630
+ * {@link QueryObserver#trackResult}'s proxy; exposed directly for adapters that track property
1631
+ * access themselves (e.g. through their own reactivity system) instead of via the proxy.
1632
+ */
1093
1633
  trackProp(key) {
1094
1634
  this.#trackedProps.add(key);
1095
1635
  }
1636
+ /**
1637
+ * Returns the `Query` instance this observer is currently observing.
1638
+ */
1096
1639
  getCurrentQuery() {
1097
1640
  return this.#currentQuery;
1098
1641
  }
1642
+ /**
1643
+ * Refetches the observed query and returns a promise that resolves with
1644
+ * the resulting `QueryObserverResult`.
1645
+ *
1646
+ * @example
1647
+ * ```ts
1648
+ * const result = await observer.refetch({ cancelRefetch: false })
1649
+ * console.log(result.data)
1650
+ * ```
1651
+ */
1099
1652
  refetch({ ...options } = {}) {
1100
1653
  return this.fetch({ ...options });
1101
1654
  }
1655
+ /**
1656
+ * Fetches a query defined by the given options without affecting this
1657
+ * observer's own tracked query or result, and returns a promise that
1658
+ * resolves with the `QueryObserverResult` for that fetch. This is useful
1659
+ * for prefetching data that another observer (e.g. a query about to be
1660
+ * navigated to) will need, ahead of time.
1661
+ *
1662
+ * @example
1663
+ * ```ts
1664
+ * const result = await observer.fetchOptimistic({
1665
+ * queryKey: ['posts', 2],
1666
+ * queryFn: () => fetchPost(2),
1667
+ * })
1668
+ * console.log(result.data)
1669
+ * ```
1670
+ */
1102
1671
  fetchOptimistic(options) {
1103
1672
  const defaultedOptions = this.#client.defaultQueryOptions(options);
1104
1673
  const query = this.#client.getQueryCache().build(this.#client, defaultedOptions);
1105
- return query.fetch().then(() => this.createResult(query, defaultedOptions));
1674
+ let unsubscribe = () => {};
1675
+ let resolveEarly;
1676
+ const cachePromise = new Promise((resolve) => {
1677
+ resolveEarly = resolve;
1678
+ unsubscribe = this.#client.getQueryCache().subscribe((event) => {
1679
+ if (event.type === "updated" && event.query.queryHash === query.queryHash && query.state.data !== void 0) {
1680
+ unsubscribe();
1681
+ resolve(this.createResult(query, defaultedOptions));
1682
+ }
1683
+ });
1684
+ });
1685
+ return Promise.race([query.fetch().then(() => {
1686
+ const result = this.createResult(query, defaultedOptions);
1687
+ resolveEarly?.(result);
1688
+ return result;
1689
+ }).finally(() => {
1690
+ unsubscribe();
1691
+ }), cachePromise]);
1106
1692
  }
1107
1693
  fetch(fetchOptions) {
1108
1694
  return this.#executeFetch({
@@ -1119,22 +1705,25 @@ var QueryObserver = class extends Subscribable {
1119
1705
  if (!fetchOptions?.throwOnError) promise = promise.catch(noop);
1120
1706
  return promise;
1121
1707
  }
1708
+ #shouldScheduleTimer(timeout) {
1709
+ return !isServer() && resolveQueryValue(this.options.enabled, this.#currentQuery) !== false && isValidTimeout(timeout);
1710
+ }
1122
1711
  #updateStaleTimeout() {
1123
1712
  this.#clearStaleTimeout();
1124
- const staleTime = resolveStaleTime(this.options.staleTime, this.#currentQuery);
1125
- if (environmentManager.isServer() || this.#currentResult.isStale || !isValidTimeout(staleTime)) return;
1713
+ const staleTime = resolveQueryValue(this.options.staleTime, this.#currentQuery);
1714
+ if (this.#currentResult.isStale || !this.#shouldScheduleTimer(staleTime)) return;
1126
1715
  const timeout = timeUntilStale(this.#currentResult.dataUpdatedAt, staleTime) + 1;
1127
1716
  this.#staleTimeoutId = timeoutManager.setTimeout(() => {
1128
1717
  if (!this.#currentResult.isStale) this.updateResult();
1129
1718
  }, timeout);
1130
1719
  }
1131
1720
  #computeRefetchInterval() {
1132
- return (typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(this.#currentQuery) : this.options.refetchInterval) ?? false;
1721
+ return resolveQueryValue(this.options.refetchInterval, this.#currentQuery) ?? false;
1133
1722
  }
1134
1723
  #updateRefetchInterval(nextInterval) {
1135
1724
  this.#clearRefetchInterval();
1136
1725
  this.#currentRefetchInterval = nextInterval;
1137
- if (environmentManager.isServer() || resolveQueryBoolean(this.options.enabled, this.#currentQuery) === false || !isValidTimeout(this.#currentRefetchInterval) || this.#currentRefetchInterval === 0) return;
1726
+ if (this.#currentRefetchInterval === 0 || !this.#shouldScheduleTimer(this.#currentRefetchInterval)) return;
1138
1727
  this.#refetchIntervalId = timeoutManager.setInterval(() => {
1139
1728
  if (this.options.refetchIntervalInBackground || focusManager.isFocused()) this.#executeFetch();
1140
1729
  }, this.#currentRefetchInterval);
@@ -1201,18 +1790,20 @@ var QueryObserver = class extends Subscribable {
1201
1790
  } catch (selectError) {
1202
1791
  this.#selectError = selectError;
1203
1792
  }
1793
+ else if (data === void 0) this.#selectError = null;
1204
1794
  if (this.#selectError) {
1205
1795
  error = this.#selectError;
1206
1796
  data = this.#selectResult;
1207
1797
  errorUpdatedAt = Date.now();
1208
1798
  status = "error";
1799
+ isPlaceholderData = false;
1209
1800
  }
1210
1801
  const isFetching = newState.fetchStatus === "fetching";
1211
1802
  const isPending = status === "pending";
1212
1803
  const isError = status === "error";
1213
1804
  const isLoading = isPending && isFetching;
1214
1805
  const hasData = data !== void 0;
1215
- const nextResult = {
1806
+ return {
1216
1807
  status,
1217
1808
  fetchStatus: newState.fetchStatus,
1218
1809
  isPending,
@@ -1237,34 +1828,14 @@ var QueryObserver = class extends Subscribable {
1237
1828
  isRefetchError: isError && hasData,
1238
1829
  isStale: isStale(query, options),
1239
1830
  refetch: this.refetch,
1240
- promise: this.#currentThenable,
1241
- isEnabled: resolveQueryBoolean(options.enabled, query) !== false
1831
+ isEnabled: resolveQueryValue(options.enabled, query) !== false
1242
1832
  };
1243
- if (this.options.experimental_prefetchInRender) {
1244
- const hasResultData = nextResult.data !== void 0;
1245
- const isErrorWithoutData = nextResult.status === "error" && !hasResultData;
1246
- const finalizeThenableIfPossible = (thenable) => {
1247
- if (isErrorWithoutData) thenable.reject(nextResult.error);
1248
- else if (hasResultData) thenable.resolve(nextResult.data);
1249
- };
1250
- const recreateThenable = () => {
1251
- finalizeThenableIfPossible(this.#currentThenable = nextResult.promise = pendingThenable());
1252
- };
1253
- const prevThenable = this.#currentThenable;
1254
- switch (prevThenable.status) {
1255
- case "pending":
1256
- if (query.queryHash === prevQuery.queryHash) finalizeThenableIfPossible(prevThenable);
1257
- break;
1258
- case "fulfilled":
1259
- if (isErrorWithoutData || nextResult.data !== prevThenable.value) recreateThenable();
1260
- break;
1261
- case "rejected":
1262
- if (!isErrorWithoutData || nextResult.error !== prevThenable.reason) recreateThenable();
1263
- break;
1264
- }
1265
- }
1266
- return nextResult;
1267
1833
  }
1834
+ /**
1835
+ * Recomputes and stores the current result from the current query/options, notifying listeners
1836
+ * if it changed. Framework adapters call this right after subscribing to make sure no query
1837
+ * update was missed in the gap between creating the observer and subscribing to it.
1838
+ */
1268
1839
  updateResult() {
1269
1840
  const prevResult = this.#currentResult;
1270
1841
  const nextResult = this.createResult(this.#currentQuery, this.options);
@@ -1285,7 +1856,16 @@ var QueryObserver = class extends Subscribable {
1285
1856
  return this.#currentResult[typedKey] !== prevResult[typedKey] && includedProps.has(typedKey);
1286
1857
  });
1287
1858
  };
1288
- this.#notify({ listeners: shouldNotifyListeners() });
1859
+ const notifyListeners = shouldNotifyListeners();
1860
+ notifyManager.batch(() => {
1861
+ if (notifyListeners) this.listeners.forEach((listener) => {
1862
+ listener(this.#currentResult);
1863
+ });
1864
+ this.#client.getQueryCache().notify({
1865
+ query: this.#currentQuery,
1866
+ type: "observerResultsUpdated"
1867
+ });
1868
+ });
1289
1869
  }
1290
1870
  #updateQuery() {
1291
1871
  const query = this.#client.getQueryCache().build(this.#client, this.options);
@@ -1298,47 +1878,50 @@ var QueryObserver = class extends Subscribable {
1298
1878
  query.addObserver(this);
1299
1879
  }
1300
1880
  }
1881
+ /** @internal */
1301
1882
  onQueryUpdate() {
1302
1883
  this.updateResult();
1303
1884
  if (this.hasListeners()) this.#updateTimers();
1304
1885
  }
1305
- #notify(notifyOptions) {
1306
- notifyManager.batch(() => {
1307
- if (notifyOptions.listeners) this.listeners.forEach((listener) => {
1308
- listener(this.#currentResult);
1309
- });
1310
- this.#client.getQueryCache().notify({
1311
- query: this.#currentQuery,
1312
- type: "observerResultsUpdated"
1313
- });
1314
- });
1315
- }
1316
1886
  };
1317
1887
  function shouldLoadOnMount(query, options) {
1318
- return resolveQueryBoolean(options.enabled, query) !== false && query.state.data === void 0 && !(query.state.status === "error" && resolveQueryBoolean(options.retryOnMount, query) === false);
1888
+ return resolveQueryValue(options.enabled, query) !== false && query.state.data === void 0 && !(query.state.status === "error" && resolveQueryValue(options.retryOnMount, query) === false);
1319
1889
  }
1320
1890
  function shouldFetchOnMount(query, options) {
1321
1891
  return shouldLoadOnMount(query, options) || query.state.data !== void 0 && shouldFetchOn(query, options, options.refetchOnMount);
1322
1892
  }
1323
1893
  function shouldFetchOn(query, options, field) {
1324
- if (resolveQueryBoolean(options.enabled, query) !== false && resolveStaleTime(options.staleTime, query) !== "static") {
1325
- const value = typeof field === "function" ? field(query) : field;
1894
+ if (resolveQueryValue(options.enabled, query) !== false && resolveQueryValue(options.staleTime, query) !== "static") {
1895
+ const value = resolveQueryValue(field, query);
1326
1896
  return value === "always" || value !== false && isStale(query, options);
1327
1897
  }
1328
1898
  return false;
1329
1899
  }
1330
1900
  function shouldFetchOptionally(query, prevQuery, options, prevOptions) {
1331
- return (query !== prevQuery || resolveQueryBoolean(prevOptions.enabled, query) === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options);
1901
+ return (query !== prevQuery || resolveQueryValue(prevOptions.enabled, query) === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options);
1332
1902
  }
1333
1903
  function isStale(query, options) {
1334
- return resolveQueryBoolean(options.enabled, query) !== false && query.isStaleByTime(resolveStaleTime(options.staleTime, query));
1335
- }
1336
- function shouldAssignObserverCurrentProperties(observer, optimisticResult) {
1337
- if (!shallowEqualObjects(observer.getCurrentResult(), optimisticResult)) return true;
1338
- return false;
1904
+ return resolveQueryValue(options.enabled, query) !== false && query.isStaleByTime(resolveQueryValue(options.staleTime, query));
1339
1905
  }
1340
1906
  //#endregion
1341
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/mutation.js
1907
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/mutation.js
1908
+ /**
1909
+ * Represents a single mutation attempt. A `Mutation` holds the mutation's
1910
+ * options, state (data/error/status), and the `MutationObserver`s currently
1911
+ * subscribed to it.
1912
+ *
1913
+ * Instances are created and managed internally by `MutationCache`; application
1914
+ * code typically interacts with mutations indirectly through `QueryClient` or
1915
+ * a framework hook like `useMutation`. Direct access to a `Mutation` instance
1916
+ * is possible via `mutationCache.find()`/`getAll()` for inspecting cache state.
1917
+ *
1918
+ * @example
1919
+ * ```ts
1920
+ * const mutationCache = queryClient.getMutationCache()
1921
+ *
1922
+ * const mutation = mutationCache.find({ mutationKey: ['addPost'] })
1923
+ * ```
1924
+ */
1342
1925
  var Mutation = class extends Removable {
1343
1926
  #client;
1344
1927
  #observers;
@@ -1354,13 +1937,18 @@ var Mutation = class extends Removable {
1354
1937
  this.setOptions(config.options);
1355
1938
  this.scheduleGc();
1356
1939
  }
1940
+ /** @internal */
1357
1941
  setOptions(options) {
1358
1942
  this.options = options;
1359
1943
  this.updateGcTime(this.options.gcTime);
1360
1944
  }
1945
+ /**
1946
+ * The `meta` object passed in the mutation's options, if any.
1947
+ */
1361
1948
  get meta() {
1362
1949
  return this.options.meta;
1363
1950
  }
1951
+ /** @internal */
1364
1952
  addObserver(observer) {
1365
1953
  if (!this.#observers.includes(observer)) {
1366
1954
  this.#observers.push(observer);
@@ -1372,6 +1960,7 @@ var Mutation = class extends Removable {
1372
1960
  });
1373
1961
  }
1374
1962
  }
1963
+ /** @internal */
1375
1964
  removeObserver(observer) {
1376
1965
  this.#observers = this.#observers.filter((x) => x !== observer);
1377
1966
  this.scheduleGc();
@@ -1385,9 +1974,60 @@ var Mutation = class extends Removable {
1385
1974
  if (!this.#observers.length) if (this.state.status === "pending") this.scheduleGc();
1386
1975
  else this.#mutationCache.remove(this);
1387
1976
  }
1977
+ /**
1978
+ * Resumes a mutation that is currently paused or was restored from a
1979
+ * dehydrated, still-`pending` state.
1980
+ *
1981
+ * - If this mutation has an active retryer (it paused mid-attempt, e.g. due
1982
+ * to the network mode or scope-based queuing), its retryer is resumed.
1983
+ * - Otherwise, if the mutation's status is still `pending` (e.g. it was
1984
+ * dehydrated while an attempt was in flight and never got a retryer in
1985
+ * this instance), `execute` is called again with the last known variables.
1986
+ * - Otherwise the mutation has already settled and this resolves immediately
1987
+ * without running anything again.
1988
+ *
1989
+ * @example
1990
+ * ```ts
1991
+ * // typically driven by reconnect handling, e.g. queryClient.resumePausedMutations()
1992
+ * const mutation = mutationCache.find({ mutationKey: ['addPost'] })
1993
+ * await mutation?.continue()
1994
+ * ```
1995
+ *
1996
+ * @see {@link Mutation#execute}
1997
+ */
1388
1998
  continue() {
1389
- return this.#retryer?.continue() ?? this.execute(this.state.variables);
1999
+ return this.#retryer?.continue() ?? (this.state.status === "pending" ? this.execute(this.state.variables) : Promise.resolve());
1390
2000
  }
2001
+ /**
2002
+ * Runs the mutation function for the given variables through a retryer, and
2003
+ * drives the mutation's state and lifecycle callbacks through to settlement.
2004
+ *
2005
+ * If this mutation's state is already `pending` when `execute` is called
2006
+ * (i.e. it was restored, still in-flight, from a dehydrated state), the
2007
+ * `onMutate` step is skipped and a `continue` action is dispatched to
2008
+ * unpause it; otherwise a `pending` action is dispatched first, then the
2009
+ * mutation cache's `onMutate` and the mutation's own `onMutate` option are
2010
+ * awaited in that order, and the resulting context is stored.
2011
+ *
2012
+ * The mutation function is then run (subject to `retry`/`retryDelay`/
2013
+ * `networkMode`, and to the mutation cache's scope-based serialization).
2014
+ * On success, the cache's `onSuccess`/`onSettled` callbacks run before the
2015
+ * mutation's own `onSuccess`/`onSettled` options, a `success` action is
2016
+ * dispatched, and the resolved data is returned. On failure, the same
2017
+ * cache-then-option ordering is used for `onError`/`onSettled`, but each of
2018
+ * those four callbacks is individually caught so that a throwing callback
2019
+ * cannot mask the original error; an `error` action is then dispatched and
2020
+ * the original error is re-thrown.
2021
+ *
2022
+ * @example
2023
+ * ```ts
2024
+ * // Called internally by `MutationObserver.mutate` and `Mutation.continue` —
2025
+ * // applications normally trigger mutations through those, not this method.
2026
+ * const data = await mutation.execute(variables)
2027
+ * ```
2028
+ *
2029
+ * @see {@link Mutation#continue}
2030
+ */
1391
2031
  async execute(variables) {
1392
2032
  const onContinue = () => {
1393
2033
  this.#dispatch({ type: "continue" });
@@ -1397,7 +2037,7 @@ var Mutation = class extends Removable {
1397
2037
  meta: this.options.meta,
1398
2038
  mutationKey: this.options.mutationKey
1399
2039
  };
1400
- this.#retryer = createRetryer({
2040
+ const retryer = this.#retryer = createRetryer({
1401
2041
  fn: () => {
1402
2042
  if (!this.options.mutationFn) return Promise.reject(/* @__PURE__ */ new Error("No mutationFn found"));
1403
2043
  return this.options.mutationFn(variables, mutationFnContext);
@@ -1419,7 +2059,7 @@ var Mutation = class extends Removable {
1419
2059
  canRun: () => this.#mutationCache.canRun(this)
1420
2060
  });
1421
2061
  const restored = this.state.status === "pending";
1422
- const isPaused = !this.#retryer.canStart();
2062
+ const isPaused = !retryer.canStart();
1423
2063
  try {
1424
2064
  if (restored) onContinue();
1425
2065
  else {
@@ -1437,7 +2077,7 @@ var Mutation = class extends Removable {
1437
2077
  isPaused
1438
2078
  });
1439
2079
  }
1440
- const data = await this.#retryer.start();
2080
+ const data = await retryer.start();
1441
2081
  await this.#mutationCache.config.onSuccess?.(data, variables, this.state.context, this, mutationFnContext);
1442
2082
  await this.options.onSuccess?.(data, variables, this.state.context, mutationFnContext);
1443
2083
  await this.#mutationCache.config.onSettled?.(data, null, this.state.variables, this.state.context, this, mutationFnContext);
@@ -1474,6 +2114,7 @@ var Mutation = class extends Removable {
1474
2114
  });
1475
2115
  throw error;
1476
2116
  } finally {
2117
+ if (this.#retryer === retryer) this.#retryer = void 0;
1477
2118
  this.#mutationCache.runNext(this);
1478
2119
  }
1479
2120
  }
@@ -1552,8 +2193,25 @@ function getDefaultState() {
1552
2193
  };
1553
2194
  }
1554
2195
  //#endregion
1555
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/mutationCache.js
2196
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/mutationCache.js
2197
+ /**
2198
+ * The `MutationCache` is the storage for mutations.
2199
+ *
2200
+ * Normally, you will not interact with the `MutationCache` directly and instead use a
2201
+ * `QueryClient`. You can subscribe to it (inherited from `Subscribable`) to be informed of
2202
+ * safe/known updates to the cache, such as mutations being added, removed, or updated.
2203
+ *
2204
+ * @example
2205
+ * ```ts
2206
+ * const unsubscribe = mutationCache.subscribe((event) => {
2207
+ * console.log(event.type, event.mutation)
2208
+ * })
2209
+ * ```
2210
+ */
1556
2211
  var MutationCache = class extends Subscribable {
2212
+ #mutations;
2213
+ #scopes;
2214
+ #mutationId;
1557
2215
  constructor(config = {}) {
1558
2216
  super();
1559
2217
  this.config = config;
@@ -1561,9 +2219,7 @@ var MutationCache = class extends Subscribable {
1561
2219
  this.#scopes = /* @__PURE__ */ new Map();
1562
2220
  this.#mutationId = 0;
1563
2221
  }
1564
- #mutations;
1565
- #scopes;
1566
- #mutationId;
2222
+ /** @internal */
1567
2223
  build(client, options, state) {
1568
2224
  const mutation = new Mutation({
1569
2225
  client,
@@ -1575,6 +2231,7 @@ var MutationCache = class extends Subscribable {
1575
2231
  this.add(mutation);
1576
2232
  return mutation;
1577
2233
  }
2234
+ /** @internal */
1578
2235
  add(mutation) {
1579
2236
  this.#mutations.add(mutation);
1580
2237
  const scope = scopeFor(mutation);
@@ -1588,6 +2245,7 @@ var MutationCache = class extends Subscribable {
1588
2245
  mutation
1589
2246
  });
1590
2247
  }
2248
+ /** @internal */
1591
2249
  remove(mutation) {
1592
2250
  if (this.#mutations.delete(mutation)) {
1593
2251
  const scope = scopeFor(mutation);
@@ -1606,6 +2264,7 @@ var MutationCache = class extends Subscribable {
1606
2264
  mutation
1607
2265
  });
1608
2266
  }
2267
+ /** @internal */
1609
2268
  canRun(mutation) {
1610
2269
  const scope = scopeFor(mutation);
1611
2270
  if (typeof scope === "string") {
@@ -1613,11 +2272,22 @@ var MutationCache = class extends Subscribable {
1613
2272
  return !firstPendingMutation || firstPendingMutation === mutation;
1614
2273
  } else return true;
1615
2274
  }
2275
+ /** @internal */
1616
2276
  runNext(mutation) {
1617
2277
  const scope = scopeFor(mutation);
1618
2278
  if (typeof scope === "string") return (this.#scopes.get(scope)?.find((m) => m !== mutation && m.state.isPaused))?.continue() ?? Promise.resolve();
1619
2279
  else return Promise.resolve();
1620
2280
  }
2281
+ /**
2282
+ * Removes all mutations from the cache.
2283
+ *
2284
+ * @example
2285
+ * ```ts
2286
+ * const mutationCache = queryClient.getMutationCache()
2287
+ *
2288
+ * mutationCache.clear()
2289
+ * ```
2290
+ */
1621
2291
  clear() {
1622
2292
  notifyManager.batch(() => {
1623
2293
  this.#mutations.forEach((mutation) => {
@@ -1630,9 +2300,37 @@ var MutationCache = class extends Subscribable {
1630
2300
  this.#scopes.clear();
1631
2301
  });
1632
2302
  }
2303
+ /**
2304
+ * Returns all mutations within the cache.
2305
+ *
2306
+ * This is not typically needed for most applications, but can come in handy when needing more
2307
+ * information about a mutation in rare scenarios.
2308
+ *
2309
+ * @example
2310
+ * ```ts
2311
+ * const mutationCache = queryClient.getMutationCache()
2312
+ *
2313
+ * const mutations = mutationCache.getAll()
2314
+ * ```
2315
+ */
1633
2316
  getAll() {
1634
2317
  return Array.from(this.#mutations);
1635
2318
  }
2319
+ /**
2320
+ * A slightly more advanced method that can be used to get an existing mutation instance from
2321
+ * the cache. If the mutation does not exist, `undefined` is returned.
2322
+ *
2323
+ * This is not typically needed for most applications, but can come in handy when needing more
2324
+ * information about a mutation in rare scenarios.
2325
+ *
2326
+ * @see {@link MutationCache#findAll}
2327
+ * @example
2328
+ * ```ts
2329
+ * const mutationCache = queryClient.getMutationCache()
2330
+ *
2331
+ * const mutation = mutationCache.find({ mutationKey: ['addPost'] })
2332
+ * ```
2333
+ */
1636
2334
  find(filters) {
1637
2335
  const defaultedFilters = {
1638
2336
  exact: true,
@@ -1640,9 +2338,25 @@ var MutationCache = class extends Subscribable {
1640
2338
  };
1641
2339
  return this.getAll().find((mutation) => matchMutation(defaultedFilters, mutation));
1642
2340
  }
2341
+ /**
2342
+ * An even more advanced method that can be used to get existing mutation instances from the
2343
+ * cache that match the given filters. If no mutations match, an empty array is returned.
2344
+ *
2345
+ * This is not typically needed for most applications, but can come in handy when needing more
2346
+ * information about mutations in rare scenarios.
2347
+ *
2348
+ * @see {@link MutationCache#find}
2349
+ * @example
2350
+ * ```ts
2351
+ * const mutationCache = queryClient.getMutationCache()
2352
+ *
2353
+ * const mutations = mutationCache.findAll({ mutationKey: ['addPost'] })
2354
+ * ```
2355
+ */
1643
2356
  findAll(filters = {}) {
1644
2357
  return this.getAll().filter((mutation) => matchMutation(filters, mutation));
1645
2358
  }
2359
+ /** @internal */
1646
2360
  notify(event) {
1647
2361
  notifyManager.batch(() => {
1648
2362
  this.listeners.forEach((listener) => {
@@ -1650,6 +2364,7 @@ var MutationCache = class extends Subscribable {
1650
2364
  });
1651
2365
  });
1652
2366
  }
2367
+ /** @internal */
1653
2368
  resumePausedMutations() {
1654
2369
  const pausedMutations = this.getAll().filter((x) => x.state.isPaused);
1655
2370
  return notifyManager.batch(() => Promise.all(pausedMutations.map((mutation) => mutation.continue().catch(noop))));
@@ -1659,7 +2374,22 @@ function scopeFor(mutation) {
1659
2374
  return mutation.options.scope?.id;
1660
2375
  }
1661
2376
  //#endregion
1662
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/mutationObserver.js
2377
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/mutationObserver.js
2378
+ /**
2379
+ * Observes a single mutation and derives a `MutationObserverResult` from it.
2380
+ * A framework hook like `useMutation` creates one `MutationObserver` per hook
2381
+ * call, keeps it stable across re-renders, calls `setOptions` when the options
2382
+ * passed to the hook change, subscribes to it to re-render on updates, and
2383
+ * reads `getCurrentResult()` for the value to return. Calling `mutate()`
2384
+ * builds a new underlying `Mutation` in the `MutationCache` and executes it.
2385
+ *
2386
+ * @example
2387
+ * ```ts
2388
+ * const observer = new MutationObserver(queryClient, {
2389
+ * mutationFn: (variables: { title: string }) => addPost(variables),
2390
+ * })
2391
+ * ```
2392
+ */
1663
2393
  var MutationObserver = class extends Subscribable {
1664
2394
  #client;
1665
2395
  #currentResult = void 0;
@@ -1676,6 +2406,22 @@ var MutationObserver = class extends Subscribable {
1676
2406
  this.mutate = this.mutate.bind(this);
1677
2407
  this.reset = this.reset.bind(this);
1678
2408
  }
2409
+ /**
2410
+ * Updates the observer's options.
2411
+ *
2412
+ * If the new `mutationKey` differs from the previous one (and both were
2413
+ * defined), the observer is reset, detaching it from the mutation it was
2414
+ * observing. Otherwise, if the currently observed mutation is still
2415
+ * `pending`, its options are updated in place as well.
2416
+ *
2417
+ * @example
2418
+ * ```ts
2419
+ * observer.setOptions({
2420
+ * mutationFn: (variables: { title: string }) => addPost(variables),
2421
+ * onSuccess: (data) => console.log(data),
2422
+ * })
2423
+ * ```
2424
+ */
1679
2425
  setOptions(options) {
1680
2426
  const prevOptions = this.options;
1681
2427
  this.options = this.#client.defaultMutationOptions(options);
@@ -1687,22 +2433,68 @@ var MutationObserver = class extends Subscribable {
1687
2433
  if (prevOptions?.mutationKey && this.options.mutationKey && hashKey(prevOptions.mutationKey) !== hashKey(this.options.mutationKey)) this.reset();
1688
2434
  else if (this.#currentMutation?.state.status === "pending") this.#currentMutation.setOptions(this.options);
1689
2435
  }
2436
+ onSubscribe() {
2437
+ if (this.listeners.size === 1 && this.#currentMutation) {
2438
+ this.#currentMutation.addObserver(this);
2439
+ this.#updateResult();
2440
+ }
2441
+ }
1690
2442
  onUnsubscribe() {
1691
2443
  if (!this.hasListeners()) this.#currentMutation?.removeObserver(this);
1692
2444
  }
2445
+ /** @internal */
1693
2446
  onMutationUpdate(action) {
1694
2447
  this.#updateResult();
1695
2448
  this.#notify(action);
1696
2449
  }
2450
+ /**
2451
+ * Returns the observer's current result, derived from the observed
2452
+ * mutation's state (or the default, `idle` state if no mutation has been
2453
+ * built yet, e.g. before the first `mutate()` call or after `reset()`).
2454
+ */
1697
2455
  getCurrentResult() {
1698
2456
  return this.#currentResult;
1699
2457
  }
2458
+ /**
2459
+ * Detaches the observer from the mutation it is currently observing (if
2460
+ * any) and resets the observed result back to its default, `idle` state.
2461
+ *
2462
+ * This does not cancel an in-flight mutation; the mutation itself keeps
2463
+ * running to completion and its own callbacks still fire, but this
2464
+ * observer stops reflecting its state and a subsequent `mutate()` call
2465
+ * will build a brand new mutation.
2466
+ *
2467
+ * @example
2468
+ * ```ts
2469
+ * observer.reset()
2470
+ * ```
2471
+ *
2472
+ * @see {@link MutationObserver#mutate}
2473
+ */
1700
2474
  reset() {
1701
2475
  this.#currentMutation?.removeObserver(this);
1702
2476
  this.#currentMutation = void 0;
1703
2477
  this.#updateResult();
1704
2478
  this.#notify();
1705
2479
  }
2480
+ /**
2481
+ * Builds a new `Mutation` in the `MutationCache` using the observer's
2482
+ * current options, detaches this observer from any previously observed
2483
+ * mutation, attaches it to the new one, and executes it with the given
2484
+ * variables.
2485
+ *
2486
+ * The optional per-call `options` (`onSuccess`/`onError`/`onSettled`) are
2487
+ * invoked once the mutation settles, in addition to any callbacks defined
2488
+ * on the observer's own options.
2489
+ *
2490
+ * @example
2491
+ * ```ts
2492
+ * await observer.mutate(
2493
+ * { title: 'New post' },
2494
+ * { onSuccess: (data) => console.log(data) },
2495
+ * )
2496
+ * ```
2497
+ */
1706
2498
  mutate(variables, options) {
1707
2499
  this.#mutateOptions = options;
1708
2500
  this.#currentMutation?.removeObserver(this);
@@ -1763,14 +2555,47 @@ var MutationObserver = class extends Subscribable {
1763
2555
  }
1764
2556
  };
1765
2557
  //#endregion
1766
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/queryCache.js
2558
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/queryCache.js
2559
+ /**
2560
+ * The `QueryCache` is the storage mechanism for TanStack Query. It stores all the data, meta
2561
+ * information, and state of the queries it contains.
2562
+ *
2563
+ * Normally, you will not interact with the `QueryCache` directly and instead use a `QueryClient`
2564
+ * for a specific cache. You can subscribe to it (inherited from `Subscribable`) to be informed of
2565
+ * safe/known updates to the cache, such as queries being added, removed, or updated — updates made
2566
+ * outside of the cache's own tracked mechanisms (e.g. mutating a query's state object directly) do
2567
+ * not notify subscribers.
2568
+ *
2569
+ * @example
2570
+ * ```ts
2571
+ * const unsubscribe = queryCache.subscribe((event) => {
2572
+ * console.log(event.type, event.query)
2573
+ * })
2574
+ * ```
2575
+ */
1767
2576
  var QueryCache = class extends Subscribable {
2577
+ #queries;
1768
2578
  constructor(config = {}) {
1769
2579
  super();
1770
2580
  this.config = config;
1771
2581
  this.#queries = /* @__PURE__ */ new Map();
1772
2582
  }
1773
- #queries;
2583
+ /**
2584
+ * Returns the existing `Query` instance for the given options' `queryKey`/`queryHash`, or
2585
+ * builds and adds a new one to the cache if none exists yet. Used by framework adapters and
2586
+ * plugins (e.g. broadcast/persistence) that need to get-or-create a `Query` directly, bypassing
2587
+ * the reactive `QueryObserver` machinery.
2588
+ *
2589
+ * @example
2590
+ * ```ts
2591
+ * const queryCache = queryClient.getQueryCache()
2592
+ *
2593
+ * const query = queryCache.build(queryClient, {
2594
+ * queryKey: ['posts'],
2595
+ * queryFn: fetchPosts,
2596
+ * })
2597
+ * ```
2598
+ */
1774
2599
  build(client, options, state) {
1775
2600
  const queryKey = options.queryKey;
1776
2601
  const queryHash = options.queryHash ?? hashQueryKeyByOptions(queryKey, options);
@@ -1788,6 +2613,7 @@ var QueryCache = class extends Subscribable {
1788
2613
  }
1789
2614
  return query;
1790
2615
  }
2616
+ /** @internal */
1791
2617
  add(query) {
1792
2618
  if (!this.#queries.has(query.queryHash)) {
1793
2619
  this.#queries.set(query.queryHash, query);
@@ -1797,17 +2623,42 @@ var QueryCache = class extends Subscribable {
1797
2623
  });
1798
2624
  }
1799
2625
  }
2626
+ /**
2627
+ * Destroys the given `Query` and removes it from the cache, notifying subscribers with a
2628
+ * `'removed'` event. A no-op if the query is no longer the one currently stored under its hash
2629
+ * (e.g. it was already replaced). Used by plugins (e.g. the broadcast client) that mirror
2630
+ * removals across `QueryCache` instances.
2631
+ *
2632
+ * @example
2633
+ * ```ts
2634
+ * const queryCache = queryClient.getQueryCache()
2635
+ * const query = queryCache.find({ queryKey: ['posts'] })
2636
+ *
2637
+ * if (query) {
2638
+ * queryCache.remove(query)
2639
+ * }
2640
+ * ```
2641
+ */
1800
2642
  remove(query) {
1801
- const queryInMap = this.#queries.get(query.queryHash);
1802
- if (queryInMap) {
2643
+ if (this.#queries.get(query.queryHash) === query) {
1803
2644
  query.destroy();
1804
- if (queryInMap === query) this.#queries.delete(query.queryHash);
2645
+ this.#queries.delete(query.queryHash);
1805
2646
  this.notify({
1806
2647
  type: "removed",
1807
2648
  query
1808
2649
  });
1809
2650
  }
1810
2651
  }
2652
+ /**
2653
+ * Removes all queries from the cache.
2654
+ *
2655
+ * @example
2656
+ * ```ts
2657
+ * const queryCache = queryClient.getQueryCache()
2658
+ *
2659
+ * queryCache.clear()
2660
+ * ```
2661
+ */
1811
2662
  clear() {
1812
2663
  notifyManager.batch(() => {
1813
2664
  this.getAll().forEach((query) => {
@@ -1815,12 +2666,54 @@ var QueryCache = class extends Subscribable {
1815
2666
  });
1816
2667
  });
1817
2668
  }
2669
+ /**
2670
+ * Returns the `Query` instance stored under the given `queryHash`, or `undefined` if none
2671
+ * exists. Unlike {@link QueryCache#find}, this looks up by the already-computed hash rather
2672
+ * than by `QueryFilters`. Used by plugins (e.g. broadcast/hydration) that already have a hash
2673
+ * to look up directly.
2674
+ *
2675
+ * @example
2676
+ * ```ts
2677
+ * const queryCache = queryClient.getQueryCache()
2678
+ * const queryHash = hashKey(['posts'])
2679
+ *
2680
+ * const query = queryCache.get(queryHash)
2681
+ * ```
2682
+ */
1818
2683
  get(queryHash) {
1819
2684
  return this.#queries.get(queryHash);
1820
2685
  }
2686
+ /**
2687
+ * Returns all queries within the cache.
2688
+ *
2689
+ * @example
2690
+ * ```ts
2691
+ * const queryCache = queryClient.getQueryCache()
2692
+ *
2693
+ * const queries = queryCache.getAll()
2694
+ * ```
2695
+ */
1821
2696
  getAll() {
1822
2697
  return [...this.#queries.values()];
1823
2698
  }
2699
+ /**
2700
+ * A slightly more advanced method that can be used to get an existing query instance from the
2701
+ * cache. This instance not only contains all the state for the query, but all of the instances,
2702
+ * and underlying guts of the query as well. If the query does not exist, `undefined` is
2703
+ * returned.
2704
+ *
2705
+ * This is not typically needed for most applications, but can come in handy when needing more
2706
+ * information about a query in rare scenarios (e.g. looking at `query.state.dataUpdatedAt` to
2707
+ * decide whether a query is fresh enough to be used as an initial value).
2708
+ *
2709
+ * @see {@link QueryCache#findAll}
2710
+ * @example
2711
+ * ```ts
2712
+ * const queryCache = queryClient.getQueryCache()
2713
+ *
2714
+ * const query = queryCache.find({ queryKey: ['posts'] })
2715
+ * ```
2716
+ */
1824
2717
  find(filters) {
1825
2718
  const defaultedFilters = {
1826
2719
  exact: true,
@@ -1828,10 +2721,26 @@ var QueryCache = class extends Subscribable {
1828
2721
  };
1829
2722
  return this.getAll().find((query) => matchQuery(defaultedFilters, query));
1830
2723
  }
2724
+ /**
2725
+ * An even more advanced method that can be used to get existing query instances from the cache
2726
+ * that partially match a query key. If no queries match, an empty array is returned.
2727
+ *
2728
+ * This is not typically needed for most applications, but can come in handy when needing more
2729
+ * information about queries in rare scenarios.
2730
+ *
2731
+ * @see {@link QueryCache#find}
2732
+ * @example
2733
+ * ```ts
2734
+ * const queryCache = queryClient.getQueryCache()
2735
+ *
2736
+ * const queries = queryCache.findAll({ queryKey: ['posts'] })
2737
+ * ```
2738
+ */
1831
2739
  findAll(filters = {}) {
1832
2740
  const queries = this.getAll();
1833
2741
  return Object.keys(filters).length > 0 ? queries.filter((query) => matchQuery(filters, query)) : queries;
1834
2742
  }
2743
+ /** @internal */
1835
2744
  notify(event) {
1836
2745
  notifyManager.batch(() => {
1837
2746
  this.listeners.forEach((listener) => {
@@ -1839,6 +2748,7 @@ var QueryCache = class extends Subscribable {
1839
2748
  });
1840
2749
  });
1841
2750
  }
2751
+ /** @internal */
1842
2752
  onFocus() {
1843
2753
  notifyManager.batch(() => {
1844
2754
  this.getAll().forEach((query) => {
@@ -1846,6 +2756,7 @@ var QueryCache = class extends Subscribable {
1846
2756
  });
1847
2757
  });
1848
2758
  }
2759
+ /** @internal */
1849
2760
  onOnline() {
1850
2761
  notifyManager.batch(() => {
1851
2762
  this.getAll().forEach((query) => {
@@ -1855,7 +2766,25 @@ var QueryCache = class extends Subscribable {
1855
2766
  }
1856
2767
  };
1857
2768
  //#endregion
1858
- //#region ../../node_modules/.pnpm/@tanstack+query-core@5.101.0/node_modules/@tanstack/query-core/build/modern/queryClient.js
2769
+ //#region ../../node_modules/.pnpm/@tanstack+query-core@5.104.0/node_modules/@tanstack/query-core/build/modern/queryClient.js
2770
+ /**
2771
+ * `QueryClient` is used to interact with a cache of queries and mutations. It owns a
2772
+ * `QueryCache` and a `MutationCache` (creating default ones if none are passed in) and holds
2773
+ * the default options that are applied to queries and mutations created through it.
2774
+ *
2775
+ * @example
2776
+ * ```ts
2777
+ * const queryClient = new QueryClient({
2778
+ * defaultOptions: {
2779
+ * queries: {
2780
+ * staleTime: Infinity,
2781
+ * },
2782
+ * },
2783
+ * })
2784
+ *
2785
+ * await queryClient.query({ queryKey: ['posts'], queryFn: fetchPosts })
2786
+ * ```
2787
+ */
1859
2788
  var QueryClient = class {
1860
2789
  #queryCache;
1861
2790
  #mutationCache;
@@ -1873,6 +2802,12 @@ var QueryClient = class {
1873
2802
  this.#mutationDefaults = /* @__PURE__ */ new Map();
1874
2803
  this.#mountCount = 0;
1875
2804
  }
2805
+ /**
2806
+ * Called by a framework adapter's `QueryClientProvider`-equivalent when it mounts, to start
2807
+ * listening for focus/online events and resume paused mutations. Ref-counted via an internal
2808
+ * mount count, so nested or multiple providers sharing the same `QueryClient` don't tear down
2809
+ * the shared listeners until the last one unmounts.
2810
+ */
1876
2811
  mount() {
1877
2812
  this.#mountCount++;
1878
2813
  if (this.#mountCount !== 1) return;
@@ -1889,6 +2824,11 @@ var QueryClient = class {
1889
2824
  }
1890
2825
  });
1891
2826
  }
2827
+ /**
2828
+ * The inverse of {@link QueryClient#mount} — called by a framework adapter's
2829
+ * `QueryClientProvider`-equivalent when it unmounts. Only tears down the focus/online
2830
+ * listeners once the mount count returns to `0`.
2831
+ */
1892
2832
  unmount() {
1893
2833
  this.#mountCount--;
1894
2834
  if (this.#mountCount !== 0) return;
@@ -1897,12 +2837,35 @@ var QueryClient = class {
1897
2837
  this.#unsubscribeOnline?.();
1898
2838
  this.#unsubscribeOnline = void 0;
1899
2839
  }
2840
+ /**
2841
+ * Returns the number of queries in the cache that are currently fetching, optionally
2842
+ * matching a set of filters. This includes background-fetching, loading new pages, and
2843
+ * loading more infinite query results.
2844
+ *
2845
+ * @example
2846
+ * ```ts
2847
+ * if (queryClient.isFetching()) {
2848
+ * console.log('At least one query is fetching!')
2849
+ * }
2850
+ * ```
2851
+ */
1900
2852
  isFetching(filters) {
1901
2853
  return this.#queryCache.findAll({
1902
2854
  ...filters,
1903
2855
  fetchStatus: "fetching"
1904
2856
  }).length;
1905
2857
  }
2858
+ /**
2859
+ * Returns the number of mutations in the cache that are currently pending, optionally
2860
+ * matching a set of filters.
2861
+ *
2862
+ * @example
2863
+ * ```ts
2864
+ * if (queryClient.isMutating()) {
2865
+ * console.log('At least one mutation is pending!')
2866
+ * }
2867
+ * ```
2868
+ */
1906
2869
  isMutating(filters) {
1907
2870
  return this.#mutationCache.findAll({
1908
2871
  ...filters,
@@ -1915,24 +2878,72 @@ var QueryClient = class {
1915
2878
  *
1916
2879
  * Hint: Do not use this function inside a component, because it won't receive updates.
1917
2880
  * Use `useQuery` to create a `QueryObserver` that subscribes to changes.
2881
+ *
2882
+ * @returns The cached data for the query, or `undefined` if no query with this key has been observed yet.
2883
+ * @see {@link QueryClient#getQueriesData}
1918
2884
  */
1919
2885
  getQueryData(queryKey) {
1920
2886
  const options = this.defaultQueryOptions({ queryKey });
1921
2887
  return this.#queryCache.get(options.queryHash)?.state.data;
1922
2888
  }
2889
+ /**
2890
+ * @deprecated Use queryClient.query({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version.
2891
+ */
1923
2892
  ensureQueryData(options) {
1924
2893
  const defaultedOptions = this.defaultQueryOptions(options);
1925
2894
  const query = this.#queryCache.build(this, defaultedOptions);
1926
2895
  const cachedData = query.state.data;
1927
2896
  if (cachedData === void 0) return this.fetchQuery(options);
1928
- if (options.revalidateIfStale && query.isStaleByTime(resolveStaleTime(defaultedOptions.staleTime, query))) this.prefetchQuery(defaultedOptions);
2897
+ if (options.revalidateIfStale && query.isStaleByTime(resolveQueryValue(defaultedOptions.staleTime, query))) this.prefetchQuery(defaultedOptions);
1929
2898
  return Promise.resolve(cachedData);
1930
2899
  }
2900
+ /**
2901
+ * Imperative (non-reactive) way to retrieve the cached data of multiple queries at once.
2902
+ * Only queries matching the given filters are returned; if none match, an empty array is
2903
+ * returned.
2904
+ *
2905
+ * Because the matched queries can hold data of different shapes (e.g. a broad filter can match
2906
+ * queries with unrelated data types), the `TQueryFnData` generic defaults to `unknown` rather
2907
+ * than being inferred. Passing a more specific type is a convenience for call sites that know
2908
+ * every matched query holds the same shape — it is not checked against the actual cache
2909
+ * contents.
2910
+ *
2911
+ * @returns An array of query key and data pairs. The data is `undefined` for a query with no cached data.
2912
+ * @see {@link QueryClient#getQueryData}
2913
+ * @example
2914
+ * ```ts
2915
+ * const data = queryClient.getQueriesData({ queryKey: ['posts'] })
2916
+ * ```
2917
+ */
1931
2918
  getQueriesData(filters) {
1932
2919
  return this.#queryCache.findAll(filters).map(({ queryKey, state }) => {
1933
2920
  return [queryKey, state.data];
1934
2921
  });
1935
2922
  }
2923
+ /**
2924
+ * Synchronous way to immediately update a query's cached data. If the updater (or the value
2925
+ * passed) resolves to `undefined`, the cache is left untouched and no query is created;
2926
+ * otherwise, if the query does not exist yet, it will be created. To update multiple queries
2927
+ * at once by partially matching query keys, use {@link QueryClient#setQueriesData} instead.
2928
+ *
2929
+ * Updates must be performed immutably: do not mutate `oldData`, or data previously retrieved
2930
+ * via {@link QueryClient#getQueryData}, in place.
2931
+ *
2932
+ * @param queryKey - The query key to set data for.
2933
+ * @param updater - Either the new data, or a function that receives the current data (which
2934
+ * may be `undefined`) and returns the new data.
2935
+ * @param options - Set `updatedAt` to override the timestamp the written data is recorded with.
2936
+ * @returns The data that was written, or `undefined` if the updater returned `undefined` — in that case
2937
+ * the write is skipped and the cache is left unchanged.
2938
+ *
2939
+ * @example
2940
+ * ```ts
2941
+ * queryClient.setQueryData(['posts'], newPosts)
2942
+ *
2943
+ * // Or, using an updater function that receives the current data:
2944
+ * queryClient.setQueryData(['posts'], (oldPosts) => [...oldPosts, newPost])
2945
+ * ```
2946
+ */
1936
2947
  setQueryData(queryKey, updater, options) {
1937
2948
  const defaultedOptions = this.defaultQueryOptions({ queryKey });
1938
2949
  const prevData = this.#queryCache.get(defaultedOptions.queryHash)?.state.data;
@@ -1943,13 +2954,49 @@ var QueryClient = class {
1943
2954
  manual: true
1944
2955
  });
1945
2956
  }
2957
+ /**
2958
+ * Synchronous way to immediately update the cached data of multiple queries at once, using
2959
+ * filters or partial query key matching. Only queries that already exist and match the given
2960
+ * filters are updated; no new cache entries are created. Internally this calls
2961
+ * {@link QueryClient#setQueryData} for each matching query.
2962
+ *
2963
+ * @returns One `[queryKey, data]` tuple per matched query, in the same shape and with the same
2964
+ * `undefined` case as {@link QueryClient#setQueryData}.
2965
+ * @example
2966
+ * ```ts
2967
+ * queryClient.setQueriesData({ queryKey: ['posts'] }, (oldPosts) =>
2968
+ * oldPosts ? oldPosts.filter((post) => post.id !== deletedId) : oldPosts,
2969
+ * )
2970
+ * ```
2971
+ */
1946
2972
  setQueriesData(filters, updater, options) {
1947
2973
  return notifyManager.batch(() => this.#queryCache.findAll(filters).map(({ queryKey }) => [queryKey, this.setQueryData(queryKey, updater, options)]));
1948
2974
  }
2975
+ /**
2976
+ * Imperative (non-reactive) way to retrieve an existing query's state. If the query does not
2977
+ * exist, `undefined` is returned.
2978
+ *
2979
+ * @example
2980
+ * ```ts
2981
+ * const state = queryClient.getQueryState(['posts'])
2982
+ * console.log(state?.dataUpdatedAt)
2983
+ * ```
2984
+ */
1949
2985
  getQueryState(queryKey) {
1950
2986
  const options = this.defaultQueryOptions({ queryKey });
1951
2987
  return this.#queryCache.get(options.queryHash)?.state;
1952
2988
  }
2989
+ /**
2990
+ * Removes queries from the cache that match the given filters. Unlike
2991
+ * {@link QueryClient#invalidateQueries} or {@link QueryClient#refetchQueries}, this removes
2992
+ * matching queries from the cache instead of refetching them. Without filters, every query in
2993
+ * the cache is removed.
2994
+ *
2995
+ * @example
2996
+ * ```ts
2997
+ * queryClient.removeQueries({ queryKey: ['posts'], exact: true })
2998
+ * ```
2999
+ */
1953
3000
  removeQueries(filters) {
1954
3001
  const queryCache = this.#queryCache;
1955
3002
  notifyManager.batch(() => {
@@ -1958,18 +3005,43 @@ var QueryClient = class {
1958
3005
  });
1959
3006
  });
1960
3007
  }
3008
+ /**
3009
+ * Resets queries matching the given filters back to their initial state (e.g. any
3010
+ * `initialData`), notifying subscribers rather than removing them. Active queries among the
3011
+ * matched set are then refetched, and the returned promise resolves once that refetch settles.
3012
+ *
3013
+ * @example
3014
+ * ```ts
3015
+ * await queryClient.resetQueries({ queryKey: ['posts'], exact: true })
3016
+ * ```
3017
+ */
1961
3018
  resetQueries(filters, options) {
1962
3019
  const queryCache = this.#queryCache;
1963
3020
  return notifyManager.batch(() => {
1964
- queryCache.findAll(filters).forEach((query) => {
3021
+ const matched = queryCache.findAll(filters);
3022
+ const queriesToRefetch = new Set(matched);
3023
+ matched.forEach((query) => {
1965
3024
  query.reset();
1966
3025
  });
1967
3026
  return this.refetchQueries({
1968
3027
  type: "active",
1969
- ...filters
3028
+ predicate: (query) => queriesToRefetch.has(query)
1970
3029
  }, options);
1971
3030
  });
1972
3031
  }
3032
+ /**
3033
+ * Cancels outgoing fetches for queries matching the given filters. Most useful when performing
3034
+ * optimistic updates, since any outgoing refetch that resolves afterwards would otherwise
3035
+ * overwrite the optimistic update. By default (`revert: true`), a cancelled query's data is
3036
+ * reverted to its state before the outgoing fetch started.
3037
+ *
3038
+ * The returned promise never rejects, even if individual cancellations fail.
3039
+ *
3040
+ * @example
3041
+ * ```ts
3042
+ * await queryClient.cancelQueries({ queryKey: ['posts'], exact: true })
3043
+ * ```
3044
+ */
1973
3045
  cancelQueries(filters, cancelOptions = {}) {
1974
3046
  const defaultedCancelOptions = {
1975
3047
  revert: true,
@@ -1978,6 +3050,19 @@ var QueryClient = class {
1978
3050
  const promises = notifyManager.batch(() => this.#queryCache.findAll(filters).map((query) => query.cancel(defaultedCancelOptions)));
1979
3051
  return Promise.all(promises).then(noop).catch(noop);
1980
3052
  }
3053
+ /**
3054
+ * Marks queries matching the given filters as invalidated. Unlike
3055
+ * {@link QueryClient#removeQueries}, invalidated queries stay in the cache.
3056
+ *
3057
+ * Unless `filters.refetchType` is `'none'`, matching queries are then refetched via
3058
+ * {@link QueryClient#refetchQueries}, using `filters.refetchType` if set, otherwise
3059
+ * `filters.type`, otherwise `'active'`.
3060
+ *
3061
+ * @example
3062
+ * ```ts
3063
+ * await queryClient.invalidateQueries({ queryKey: ['posts'], refetchType: 'active' })
3064
+ * ```
3065
+ */
1981
3066
  invalidateQueries(filters, options = {}) {
1982
3067
  return notifyManager.batch(() => {
1983
3068
  this.#queryCache.findAll(filters).forEach((query) => {
@@ -1990,6 +3075,21 @@ var QueryClient = class {
1990
3075
  }, options);
1991
3076
  });
1992
3077
  }
3078
+ /**
3079
+ * Refetches queries matching the given filters, regardless of whether they are stale. Without
3080
+ * filters, every query in the cache is refetched. Queries that are disabled, or static (only
3081
+ * have observers with a static `staleTime`), are never refetched.
3082
+ *
3083
+ * By default (`cancelRefetch: true`), a currently running fetch is cancelled before the new
3084
+ * one starts. The returned promise resolves once all matching queries have settled; it does
3085
+ * not reject on individual query failures unless `throwOnError` is set.
3086
+ *
3087
+ * @example
3088
+ * ```ts
3089
+ * // refetch all active queries partially matching a query key:
3090
+ * await queryClient.refetchQueries({ queryKey: ['posts'], type: 'active' })
3091
+ * ```
3092
+ */
1993
3093
  refetchQueries(filters, options = {}) {
1994
3094
  const fetchOptions = {
1995
3095
  ...options,
@@ -2002,48 +3102,218 @@ var QueryClient = class {
2002
3102
  }));
2003
3103
  return Promise.all(promises).then(noop);
2004
3104
  }
3105
+ /**
3106
+ * Asynchronous method to fetch and cache a query, resolving with the data or throwing with
3107
+ * the error.
3108
+ *
3109
+ * If the query already exists in the cache and its data is not stale (per the given
3110
+ * `staleTime`), the cached data is returned without fetching. Otherwise, the query is fetched
3111
+ * and the promise resolves once the fetch settles. If a `select` function is provided, it is
3112
+ * applied to the data in both cases (cached or freshly fetched) before it is returned.
3113
+ *
3114
+ * Unlike a reactive observer, retries are disabled by default here (`retry: false`) unless
3115
+ * explicitly configured, since there is no component to catch a thrown error and retry through
3116
+ * re-render.
3117
+ *
3118
+ * The accepted options are `QueryObserverOptions` minus the fields that only make sense for a
3119
+ * reactive observer — `enabled`, `refetchInterval`, `refetchIntervalInBackground`,
3120
+ * `refetchOnWindowFocus`, `refetchOnReconnect`, `refetchOnMount`, `retryOnMount`,
3121
+ * `notifyOnChangeProps`, `throwOnError`, `suspense`, and `placeholderData` are not part of this
3122
+ * method's options.
3123
+ *
3124
+ * This method replaces the deprecated `fetchQuery`, and — combined with
3125
+ * `{ staleTime: 'static' }` — the deprecated `ensureQueryData`.
3126
+ *
3127
+ * @example
3128
+ * ```ts
3129
+ * try {
3130
+ * const data = await queryClient.query({ queryKey, queryFn, staleTime: 10000 })
3131
+ * } catch (error) {
3132
+ * console.log(error)
3133
+ * }
3134
+ * ```
3135
+ */
3136
+ async query(options) {
3137
+ const defaultedOptions = this.defaultQueryOptions(options);
3138
+ if (defaultedOptions.retry === void 0) defaultedOptions.retry = false;
3139
+ const query = this.#queryCache.build(this, defaultedOptions);
3140
+ const queryData = query.isStaleByTime(resolveQueryValue(defaultedOptions.staleTime, query)) ? await query.fetch(defaultedOptions) : query.state.data;
3141
+ const select = defaultedOptions.select;
3142
+ if (select) return select(queryData);
3143
+ return queryData;
3144
+ }
3145
+ /**
3146
+ * @deprecated Use queryClient.query(options) instead. This method will be removed in the next major version.
3147
+ */
2005
3148
  fetchQuery(options) {
2006
3149
  const defaultedOptions = this.defaultQueryOptions(options);
2007
3150
  if (defaultedOptions.retry === void 0) defaultedOptions.retry = false;
2008
3151
  const query = this.#queryCache.build(this, defaultedOptions);
2009
- return query.isStaleByTime(resolveStaleTime(defaultedOptions.staleTime, query)) ? query.fetch(defaultedOptions) : Promise.resolve(query.state.data);
3152
+ return query.isStaleByTime(resolveQueryValue(defaultedOptions.staleTime, query)) ? query.fetch(defaultedOptions) : Promise.resolve(query.state.data);
2010
3153
  }
3154
+ /**
3155
+ * @deprecated Use queryClient.query(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version.
3156
+ */
2011
3157
  prefetchQuery(options) {
2012
3158
  return this.fetchQuery(options).then(noop).catch(noop);
2013
3159
  }
3160
+ /**
3161
+ * Asynchronous method to fetch and cache an infinite query, resolving with an
3162
+ * {@link InfiniteData} object or throwing with the error.
3163
+ *
3164
+ * Behaves like {@link QueryClient#query}, accepting the same options (minus
3165
+ * `initialPageParam`), plus the required `initialPageParam`, and an optional `pages` /
3166
+ * `getNextPageParam` pair used to refetch a fixed number of pages from the start.
3167
+ *
3168
+ * This method replaces the deprecated `fetchInfiniteQuery`, and — combined with
3169
+ * `{ staleTime: 'static' }` — the deprecated `ensureInfiniteQueryData`.
3170
+ *
3171
+ * @example
3172
+ * ```ts
3173
+ * try {
3174
+ * const data = await queryClient.infiniteQuery({ queryKey, queryFn, initialPageParam: 0 })
3175
+ * console.log(data.pages)
3176
+ * } catch (error) {
3177
+ * console.log(error)
3178
+ * }
3179
+ * ```
3180
+ */
3181
+ infiniteQuery(options) {
3182
+ options._type = "infinite";
3183
+ return this.query(options);
3184
+ }
3185
+ /**
3186
+ * @deprecated Use queryClient.infiniteQuery(options) instead. This method will be removed in the next major version.
3187
+ */
2014
3188
  fetchInfiniteQuery(options) {
2015
3189
  options._type = "infinite";
2016
3190
  return this.fetchQuery(options);
2017
3191
  }
3192
+ /**
3193
+ * @deprecated Use queryClient.infiniteQuery(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version.
3194
+ */
2018
3195
  prefetchInfiniteQuery(options) {
2019
3196
  return this.fetchInfiniteQuery(options).then(noop).catch(noop);
2020
3197
  }
3198
+ /**
3199
+ * @deprecated Use queryClient.infiniteQuery({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version.
3200
+ */
2021
3201
  ensureInfiniteQueryData(options) {
2022
3202
  options._type = "infinite";
2023
3203
  return this.ensureQueryData(options);
2024
3204
  }
3205
+ /**
3206
+ * Resumes mutations that were paused because there was no network connection. Does nothing
3207
+ * (resolving immediately) if the client is currently offline.
3208
+ *
3209
+ * @example
3210
+ * ```ts
3211
+ * import { QueryClient } from '@tanstack/query-core'
3212
+ *
3213
+ * const queryClient = new QueryClient()
3214
+ * await queryClient.resumePausedMutations()
3215
+ * ```
3216
+ */
2025
3217
  resumePausedMutations() {
2026
3218
  if (onlineManager.isOnline()) return this.#mutationCache.resumePausedMutations();
2027
3219
  return Promise.resolve();
2028
3220
  }
3221
+ /**
3222
+ * Returns the query cache this client is connected to.
3223
+ *
3224
+ * @example
3225
+ * ```ts
3226
+ * import { QueryClient } from '@tanstack/query-core'
3227
+ *
3228
+ * const queryClient = new QueryClient()
3229
+ * const queryCache = queryClient.getQueryCache()
3230
+ * const queries = queryCache.findAll({ queryKey: ['posts'] })
3231
+ * ```
3232
+ */
2029
3233
  getQueryCache() {
2030
3234
  return this.#queryCache;
2031
3235
  }
3236
+ /**
3237
+ * Returns the mutation cache this client is connected to.
3238
+ *
3239
+ * @example
3240
+ * ```ts
3241
+ * import { QueryClient } from '@tanstack/query-core'
3242
+ *
3243
+ * const queryClient = new QueryClient()
3244
+ * const mutationCache = queryClient.getMutationCache()
3245
+ * const mutations = mutationCache.findAll({ status: 'pending' })
3246
+ * ```
3247
+ */
2032
3248
  getMutationCache() {
2033
3249
  return this.#mutationCache;
2034
3250
  }
3251
+ /**
3252
+ * Returns the default options that were set when creating the client, or via
3253
+ * {@link QueryClient#setDefaultOptions}.
3254
+ *
3255
+ * @example
3256
+ * ```ts
3257
+ * import { QueryClient } from '@tanstack/query-core'
3258
+ *
3259
+ * const queryClient = new QueryClient()
3260
+ * const defaultOptions = queryClient.getDefaultOptions()
3261
+ * ```
3262
+ */
2035
3263
  getDefaultOptions() {
2036
3264
  return this.#defaultOptions;
2037
3265
  }
3266
+ /**
3267
+ * Dynamically sets the default options for this client, overwriting any previously defined
3268
+ * default options.
3269
+ *
3270
+ * @see {@link QueryClient#getDefaultOptions}
3271
+ * @example
3272
+ * ```ts
3273
+ * import { QueryClient } from '@tanstack/query-core'
3274
+ *
3275
+ * const queryClient = new QueryClient()
3276
+ * queryClient.setDefaultOptions({
3277
+ * queries: {
3278
+ * staleTime: Infinity,
3279
+ * },
3280
+ * })
3281
+ * ```
3282
+ */
2038
3283
  setDefaultOptions(options) {
2039
3284
  this.#defaultOptions = options;
2040
3285
  }
3286
+ /**
3287
+ * Sets default options for queries whose query key partially matches the given `queryKey`.
3288
+ *
3289
+ * If several registered query defaults match a given query key, they are merged together in
3290
+ * registration order by {@link QueryClient#getQueryDefaults}, so register defaults from the
3291
+ * most generic key to the least generic one — more specific defaults should be registered
3292
+ * after more generic ones so they take precedence.
3293
+ *
3294
+ * @example
3295
+ * ```ts
3296
+ * queryClient.setQueryDefaults(['posts'], { queryFn: fetchPosts })
3297
+ *
3298
+ * await queryClient.query({ queryKey: ['posts'] })
3299
+ * ```
3300
+ */
2041
3301
  setQueryDefaults(queryKey, options) {
2042
3302
  this.#queryDefaults.set(hashKey(queryKey), {
2043
3303
  queryKey,
2044
3304
  defaultOptions: options
2045
3305
  });
2046
3306
  }
3307
+ /**
3308
+ * Returns the default options registered for queries whose query key partially matches the
3309
+ * given `queryKey`, via {@link QueryClient#setQueryDefaults}. If multiple registered defaults
3310
+ * match, they are merged together in registration order.
3311
+ *
3312
+ * @example
3313
+ * ```ts
3314
+ * const defaultOptions = queryClient.getQueryDefaults(['posts'])
3315
+ * ```
3316
+ */
2047
3317
  getQueryDefaults(queryKey) {
2048
3318
  const defaults = [...this.#queryDefaults.values()];
2049
3319
  const result = {};
@@ -2052,12 +3322,33 @@ var QueryClient = class {
2052
3322
  });
2053
3323
  return result;
2054
3324
  }
3325
+ /**
3326
+ * Sets default options for mutations whose mutation key partially matches the given
3327
+ * `mutationKey`. As with {@link QueryClient#setQueryDefaults}, the order of registration
3328
+ * matters when several registered defaults match the same mutation key.
3329
+ *
3330
+ * @see {@link QueryClient#getMutationDefaults}
3331
+ * @example
3332
+ * ```ts
3333
+ * queryClient.setMutationDefaults(['addPost'], { mutationFn: addPost })
3334
+ * ```
3335
+ */
2055
3336
  setMutationDefaults(mutationKey, options) {
2056
3337
  this.#mutationDefaults.set(hashKey(mutationKey), {
2057
3338
  mutationKey,
2058
3339
  defaultOptions: options
2059
3340
  });
2060
3341
  }
3342
+ /**
3343
+ * Returns the default options registered for mutations whose mutation key partially matches
3344
+ * the given `mutationKey`, via {@link QueryClient#setMutationDefaults}. If multiple registered
3345
+ * defaults match, they are merged together in registration order.
3346
+ *
3347
+ * @example
3348
+ * ```ts
3349
+ * const defaultOptions = queryClient.getMutationDefaults(['addPost'])
3350
+ * ```
3351
+ */
2061
3352
  getMutationDefaults(mutationKey) {
2062
3353
  const defaults = [...this.#mutationDefaults.values()];
2063
3354
  const result = {};
@@ -2066,6 +3357,12 @@ var QueryClient = class {
2066
3357
  });
2067
3358
  return result;
2068
3359
  }
3360
+ /**
3361
+ * Called by framework adapters (e.g. inside `useQuery`) to resolve the options passed by the
3362
+ * caller into their final, defaulted form: merging `queryClient.setQueryDefaults` for the
3363
+ * given `queryKey`, then the client's own `defaultOptions.queries`, then the caller's options
3364
+ * on top. A no-op if the options are already defaulted (`_defaulted: true`).
3365
+ */
2069
3366
  defaultQueryOptions(options) {
2070
3367
  if (options._defaulted) return options;
2071
3368
  const defaultedOptions = {
@@ -2081,6 +3378,12 @@ var QueryClient = class {
2081
3378
  if (defaultedOptions.queryFn === skipToken) defaultedOptions.enabled = false;
2082
3379
  return defaultedOptions;
2083
3380
  }
3381
+ /**
3382
+ * The mutation counterpart of {@link QueryClient#defaultQueryOptions}. Called by framework
3383
+ * adapters (e.g. inside `useMutation`) to merge `queryClient.setMutationDefaults` for the
3384
+ * given `mutationKey`, then the client's `defaultOptions.mutations`, then the caller's options
3385
+ * on top. A no-op if the options are already defaulted (`_defaulted: true`).
3386
+ */
2084
3387
  defaultMutationOptions(options) {
2085
3388
  if (options?._defaulted) return options;
2086
3389
  return {
@@ -2090,10 +3393,21 @@ var QueryClient = class {
2090
3393
  _defaulted: true
2091
3394
  };
2092
3395
  }
3396
+ /**
3397
+ * Clears both the query cache and the mutation cache this client is connected to.
3398
+ *
3399
+ * @example
3400
+ * ```ts
3401
+ * import { QueryClient } from '@tanstack/query-core'
3402
+ *
3403
+ * const queryClient = new QueryClient()
3404
+ * queryClient.clear()
3405
+ * ```
3406
+ */
2093
3407
  clear() {
2094
3408
  this.#queryCache.clear();
2095
3409
  this.#mutationCache.clear();
2096
3410
  }
2097
3411
  };
2098
3412
  //#endregion
2099
- export { environmentManager as a, notifyManager as i, MutationObserver as n, noop as o, QueryObserver as r, shouldThrowError as s, QueryClient as t };
3413
+ export { noop as a, notifyManager as i, MutationObserver as n, shouldThrowError as o, QueryObserver as r, QueryClient as t };