@tanstack/query-core 5.95.0 → 5.95.2

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.
@@ -1,7 +1,3 @@
1
- import type { MockInstance } from 'vitest';
2
- import { Options } from 'tsup';
3
- import { UserConfig } from 'vite';
4
-
5
1
  export declare type Action<TData, TError, TVariables, TOnMutateResult> = ContinueAction_2 | ErrorAction_2<TError> | FailedAction_2<TError> | PendingAction<TVariables, TOnMutateResult> | PauseAction_2 | SuccessAction_2<TData>;
6
2
 
7
3
  export declare type Action_alias_1<TData, TError> = ContinueAction | ErrorAction<TError> | FailedAction<TError> | FetchAction | InvalidateAction | PauseAction | SetStateAction<TData, TError> | SuccessAction<TData>;
@@ -98,14 +94,6 @@ declare type dataTagSymbol = typeof dataTagSymbol;
98
94
  export { dataTagSymbol }
99
95
  export { dataTagSymbol as dataTagSymbol_alias_1 }
100
96
 
101
- export declare const default_alias: any[];
102
-
103
- export declare const default_alias_1: any[];
104
-
105
- export declare const default_alias_2: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
106
-
107
- export declare const default_alias_3: UserConfig;
108
-
109
97
  declare type DefaultedInfiniteQueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = WithRequired<InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, 'throwOnError' | 'refetchOnReconnect' | 'queryHash'>;
110
98
  export { DefaultedInfiniteQueryObserverOptions }
111
99
  export { DefaultedInfiniteQueryObserverOptions as DefaultedInfiniteQueryObserverOptions_alias_1 }
@@ -141,7 +129,7 @@ declare function defaultShouldDehydrateQuery(query: Query): boolean;
141
129
  export { defaultShouldDehydrateQuery }
142
130
  export { defaultShouldDehydrateQuery as defaultShouldDehydrateQuery_alias_1 }
143
131
 
144
- export declare const defaultTimeoutProvider: TimeoutProvider<ReturnType<typeof setTimeout>>;
132
+ export declare const defaultTimeoutProvider: TimeoutProvider;
145
133
 
146
134
  declare type DefinedInfiniteQueryObserverResult<TData = unknown, TError = DefaultError> = InfiniteQueryObserverRefetchErrorResult<TData, TError> | InfiniteQueryObserverSuccessResult<TData, TError>;
147
135
  export { DefinedInfiniteQueryObserverResult }
@@ -243,8 +231,6 @@ declare interface ErrorAction_2<TError> {
243
231
  error: TError;
244
232
  }
245
233
 
246
- export declare function executeMutation<TVariables>(queryClient: QueryClient, options: MutationOptions<any, any, TVariables, any>, variables: TVariables): Promise<any>;
247
-
248
234
  declare interface FailedAction<TError> {
249
235
  type: 'failed';
250
236
  failureCount: number;
@@ -669,15 +655,6 @@ declare function keepPreviousData<T>(previousData: T | undefined): T | undefined
669
655
  export { keepPreviousData }
670
656
  export { keepPreviousData as keepPreviousData_alias_1 }
671
657
 
672
- /**
673
- * @param {Object} opts - Options for building configurations.
674
- * @param {string[]} opts.entry - The entry array.
675
- * @returns {import('tsup').Options}
676
- */
677
- export declare function legacyConfig(opts: {
678
- entry: string[];
679
- }): Options;
680
-
681
658
  declare type Listener = (focused: boolean) => void;
682
659
 
683
660
  declare type Listener_2 = (online: boolean) => void;
@@ -702,17 +679,6 @@ declare function matchQuery(filters: QueryFilters, query: Query<any, any, any, a
702
679
  export { matchQuery }
703
680
  export { matchQuery as matchQuery_alias_1 }
704
681
 
705
- export declare function mockOnlineManagerIsOnline(value: boolean): MockInstance<() => boolean>;
706
-
707
- /**
708
- * @param {Object} opts - Options for building configurations.
709
- * @param {string[]} opts.entry - The entry array.
710
- * @returns {import('tsup').Options}
711
- */
712
- export declare function modernConfig(opts: {
713
- entry: string[];
714
- }): Options;
715
-
716
682
  declare type MutateFunction<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> = (variables: TVariables, options?: MutateOptions<TData, TError, TVariables, TOnMutateResult>) => Promise<TData>;
717
683
  export { MutateFunction }
718
684
  export { MutateFunction as MutateFunction_alias_1 }
@@ -2036,8 +2002,6 @@ declare interface SetDataOptions {
2036
2002
  export { SetDataOptions }
2037
2003
  export { SetDataOptions as SetDataOptions_alias_1 }
2038
2004
 
2039
- export declare function setIsServer(value: boolean): () => void;
2040
-
2041
2005
  declare interface SetStateAction<TData, TError> {
2042
2006
  type: 'setState';
2043
2007
  state: Partial<QueryState<TData, TError>>;
@@ -1,7 +1,3 @@
1
- import type { MockInstance } from 'vitest';
2
- import { Options } from 'tsup';
3
- import { UserConfig } from 'vite';
4
-
5
1
  export declare type Action<TData, TError, TVariables, TOnMutateResult> = ContinueAction_2 | ErrorAction_2<TError> | FailedAction_2<TError> | PendingAction<TVariables, TOnMutateResult> | PauseAction_2 | SuccessAction_2<TData>;
6
2
 
7
3
  export declare type Action_alias_1<TData, TError> = ContinueAction | ErrorAction<TError> | FailedAction<TError> | FetchAction | InvalidateAction | PauseAction | SetStateAction<TData, TError> | SuccessAction<TData>;
@@ -98,14 +94,6 @@ declare type dataTagSymbol = typeof dataTagSymbol;
98
94
  export { dataTagSymbol }
99
95
  export { dataTagSymbol as dataTagSymbol_alias_1 }
100
96
 
101
- export declare const default_alias: any[];
102
-
103
- export declare const default_alias_1: any[];
104
-
105
- export declare const default_alias_2: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
106
-
107
- export declare const default_alias_3: UserConfig;
108
-
109
97
  declare type DefaultedInfiniteQueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = WithRequired<InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, 'throwOnError' | 'refetchOnReconnect' | 'queryHash'>;
110
98
  export { DefaultedInfiniteQueryObserverOptions }
111
99
  export { DefaultedInfiniteQueryObserverOptions as DefaultedInfiniteQueryObserverOptions_alias_1 }
@@ -141,7 +129,7 @@ declare function defaultShouldDehydrateQuery(query: Query): boolean;
141
129
  export { defaultShouldDehydrateQuery }
142
130
  export { defaultShouldDehydrateQuery as defaultShouldDehydrateQuery_alias_1 }
143
131
 
144
- export declare const defaultTimeoutProvider: TimeoutProvider<ReturnType<typeof setTimeout>>;
132
+ export declare const defaultTimeoutProvider: TimeoutProvider;
145
133
 
146
134
  declare type DefinedInfiniteQueryObserverResult<TData = unknown, TError = DefaultError> = InfiniteQueryObserverRefetchErrorResult<TData, TError> | InfiniteQueryObserverSuccessResult<TData, TError>;
147
135
  export { DefinedInfiniteQueryObserverResult }
@@ -243,8 +231,6 @@ declare interface ErrorAction_2<TError> {
243
231
  error: TError;
244
232
  }
245
233
 
246
- export declare function executeMutation<TVariables>(queryClient: QueryClient, options: MutationOptions<any, any, TVariables, any>, variables: TVariables): Promise<any>;
247
-
248
234
  declare interface FailedAction<TError> {
249
235
  type: 'failed';
250
236
  failureCount: number;
@@ -669,15 +655,6 @@ declare function keepPreviousData<T>(previousData: T | undefined): T | undefined
669
655
  export { keepPreviousData }
670
656
  export { keepPreviousData as keepPreviousData_alias_1 }
671
657
 
672
- /**
673
- * @param {Object} opts - Options for building configurations.
674
- * @param {string[]} opts.entry - The entry array.
675
- * @returns {import('tsup').Options}
676
- */
677
- export declare function legacyConfig(opts: {
678
- entry: string[];
679
- }): Options;
680
-
681
658
  declare type Listener = (focused: boolean) => void;
682
659
 
683
660
  declare type Listener_2 = (online: boolean) => void;
@@ -702,17 +679,6 @@ declare function matchQuery(filters: QueryFilters, query: Query<any, any, any, a
702
679
  export { matchQuery }
703
680
  export { matchQuery as matchQuery_alias_1 }
704
681
 
705
- export declare function mockOnlineManagerIsOnline(value: boolean): MockInstance<() => boolean>;
706
-
707
- /**
708
- * @param {Object} opts - Options for building configurations.
709
- * @param {string[]} opts.entry - The entry array.
710
- * @returns {import('tsup').Options}
711
- */
712
- export declare function modernConfig(opts: {
713
- entry: string[];
714
- }): Options;
715
-
716
682
  declare type MutateFunction<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> = (variables: TVariables, options?: MutateOptions<TData, TError, TVariables, TOnMutateResult>) => Promise<TData>;
717
683
  export { MutateFunction }
718
684
  export { MutateFunction as MutateFunction_alias_1 }
@@ -2036,8 +2002,6 @@ declare interface SetDataOptions {
2036
2002
  export { SetDataOptions }
2037
2003
  export { SetDataOptions as SetDataOptions_alias_1 }
2038
2004
 
2039
- export declare function setIsServer(value: boolean): () => void;
2040
-
2041
2005
  declare interface SetStateAction<TData, TError> {
2042
2006
  type: 'setState';
2043
2007
  state: Partial<QueryState<TData, TError>>;
@@ -54,7 +54,8 @@ var TimeoutManager = class {
54
54
  constructor() {
55
55
  // We cannot have TimeoutManager<T> as we must instantiate it with a concrete
56
56
  // type at app boot; and if we leave that type, then any new timer provider
57
- // would need to support ReturnType<typeof setTimeout>, which is infeasible.
57
+ // would need to support the default provider's concrete timer ID, which is
58
+ // infeasible across environments.
58
59
  //
59
60
  // We settle for type safety for the TimeoutProvider type, and accept that
60
61
  // this class is unsafe internally to allow for extension.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/timeoutManager.ts"],"sourcesContent":["/**\n * {@link TimeoutManager} does not support passing arguments to the callback.\n *\n * `(_: void)` is the argument type inferred by TypeScript's default typings for\n * `setTimeout(cb, number)`.\n * If we don't accept a single void argument, then\n * `new Promise(resolve => timeoutManager.setTimeout(resolve, N))` is a type error.\n */\nexport type TimeoutCallback = (_: void) => void\n\n/**\n * Wrapping `setTimeout` is awkward from a typing perspective because platform\n * typings may extend the return type of `setTimeout`. For example, NodeJS\n * typings add `NodeJS.Timeout`; but a non-default `timeoutManager` may not be\n * able to return such a type.\n */\nexport type ManagedTimerId = number | { [Symbol.toPrimitive]: () => number }\n\n/**\n * Backend for timer functions.\n */\nexport type TimeoutProvider<TTimerId extends ManagedTimerId = ManagedTimerId> =\n {\n readonly setTimeout: (callback: TimeoutCallback, delay: number) => TTimerId\n readonly clearTimeout: (timeoutId: TTimerId | undefined) => void\n\n readonly setInterval: (callback: TimeoutCallback, delay: number) => TTimerId\n readonly clearInterval: (intervalId: TTimerId | undefined) => void\n }\n\nexport const defaultTimeoutProvider: TimeoutProvider<\n ReturnType<typeof setTimeout>\n> = {\n // We need the wrapper function syntax below instead of direct references to\n // global setTimeout etc.\n //\n // BAD: `setTimeout: setTimeout`\n // GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`\n //\n // If we use direct references here, then anything that wants to spy on or\n // replace the global setTimeout (like tests) won't work since we'll already\n // have a hard reference to the original implementation at the time when this\n // file was imported.\n setTimeout: (callback, delay) => setTimeout(callback, delay),\n clearTimeout: (timeoutId) => clearTimeout(timeoutId),\n\n setInterval: (callback, delay) => setInterval(callback, delay),\n clearInterval: (intervalId) => clearInterval(intervalId),\n}\n\n/**\n * Allows customization of how timeouts are created.\n *\n * @tanstack/query-core makes liberal use of timeouts to implement `staleTime`\n * and `gcTime`. The default TimeoutManager provider uses the platform's global\n * `setTimeout` implementation, which is known to have scalability issues with\n * thousands of timeouts on the event loop.\n *\n * If you hit this limitation, consider providing a custom TimeoutProvider that\n * coalesces timeouts.\n */\nexport class TimeoutManager implements Omit<TimeoutProvider, 'name'> {\n // We cannot have TimeoutManager<T> as we must instantiate it with a concrete\n // type at app boot; and if we leave that type, then any new timer provider\n // would need to support ReturnType<typeof setTimeout>, which is infeasible.\n //\n // We settle for type safety for the TimeoutProvider type, and accept that\n // this class is unsafe internally to allow for extension.\n #provider: TimeoutProvider<any> = defaultTimeoutProvider\n #providerCalled = false\n\n setTimeoutProvider<TTimerId extends ManagedTimerId>(\n provider: TimeoutProvider<TTimerId>,\n ): void {\n if (process.env.NODE_ENV !== 'production') {\n if (this.#providerCalled && provider !== this.#provider) {\n // After changing providers, `clearTimeout` will not work as expected for\n // timeouts from the previous provider.\n //\n // Since they may allocate the same timeout ID, clearTimeout may cancel an\n // arbitrary different timeout, or unexpected no-op.\n //\n // We could protect against this by mixing the timeout ID bits\n // deterministically with some per-provider bits.\n //\n // We could internally queue `setTimeout` calls to `TimeoutManager` until\n // some API call to set the initial provider.\n console.error(\n `[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.`,\n { previous: this.#provider, provider },\n )\n }\n }\n\n this.#provider = provider\n if (process.env.NODE_ENV !== 'production') {\n this.#providerCalled = false\n }\n }\n\n setTimeout(callback: TimeoutCallback, delay: number): ManagedTimerId {\n if (process.env.NODE_ENV !== 'production') {\n this.#providerCalled = true\n }\n return this.#provider.setTimeout(callback, delay)\n }\n\n clearTimeout(timeoutId: ManagedTimerId | undefined): void {\n this.#provider.clearTimeout(timeoutId)\n }\n\n setInterval(callback: TimeoutCallback, delay: number): ManagedTimerId {\n if (process.env.NODE_ENV !== 'production') {\n this.#providerCalled = true\n }\n return this.#provider.setInterval(callback, delay)\n }\n\n clearInterval(intervalId: ManagedTimerId | undefined): void {\n this.#provider.clearInterval(intervalId)\n }\n}\n\nexport const timeoutManager = new TimeoutManager()\n\n/**\n * In many cases code wants to delay to the next event loop tick; this is not\n * mediated by {@link timeoutManager}.\n *\n * This function is provided to make auditing the `tanstack/query-core` for\n * incorrect use of system `setTimeout` easier.\n */\nexport function systemSetTimeoutZero(callback: TimeoutCallback): void {\n setTimeout(callback, 0)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA8BO,IAAM,yBAET;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWF,YAAY,CAAC,UAAU,UAAU,WAAW,UAAU,KAAK;AAAA,EAC3D,cAAc,CAAC,cAAc,aAAa,SAAS;AAAA,EAEnD,aAAa,CAAC,UAAU,UAAU,YAAY,UAAU,KAAK;AAAA,EAC7D,eAAe,CAAC,eAAe,cAAc,UAAU;AACzD;AAhDA;AA6DO,IAAM,iBAAN,MAA8D;AAAA,EAA9D;AAOL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kCAAkC;AAClC,wCAAkB;AAAA;AAAA,EAElB,mBACE,UACM;AACN,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,UAAI,mBAAK,oBAAmB,aAAa,mBAAK,YAAW;AAYvD,gBAAQ;AAAA,UACN;AAAA,UACA,EAAE,UAAU,mBAAK,YAAW,SAAS;AAAA,QACvC;AAAA,MACF;AAAA,IACF;AAEA,uBAAK,WAAY;AACjB,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,yBAAK,iBAAkB;AAAA,IACzB;AAAA,EACF;AAAA,EAEA,WAAW,UAA2B,OAA+B;AACnE,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,yBAAK,iBAAkB;AAAA,IACzB;AACA,WAAO,mBAAK,WAAU,WAAW,UAAU,KAAK;AAAA,EAClD;AAAA,EAEA,aAAa,WAA6C;AACxD,uBAAK,WAAU,aAAa,SAAS;AAAA,EACvC;AAAA,EAEA,YAAY,UAA2B,OAA+B;AACpE,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,yBAAK,iBAAkB;AAAA,IACzB;AACA,WAAO,mBAAK,WAAU,YAAY,UAAU,KAAK;AAAA,EACnD;AAAA,EAEA,cAAc,YAA8C;AAC1D,uBAAK,WAAU,cAAc,UAAU;AAAA,EACzC;AACF;AArDE;AACA;AAsDK,IAAM,iBAAiB,IAAI,eAAe;AAS1C,SAAS,qBAAqB,UAAiC;AACpE,aAAW,UAAU,CAAC;AACxB;","names":[]}
1
+ {"version":3,"sources":["../../src/timeoutManager.ts"],"sourcesContent":["/**\n * {@link TimeoutManager} does not support passing arguments to the callback.\n *\n * `(_: void)` is the argument type inferred by TypeScript's default typings for\n * `setTimeout(cb, number)`.\n * If we don't accept a single void argument, then\n * `new Promise(resolve => timeoutManager.setTimeout(resolve, N))` is a type error.\n */\nexport type TimeoutCallback = (_: void) => void\n\n/**\n * Wrapping `setTimeout` is awkward from a typing perspective because platform\n * typings may extend the return type of `setTimeout`. For example, NodeJS\n * typings add `NodeJS.Timeout`; but a non-default `timeoutManager` may not be\n * able to return such a type.\n */\nexport type ManagedTimerId = number | { [Symbol.toPrimitive]: () => number }\n\n/**\n * Backend for timer functions.\n */\nexport type TimeoutProvider<TTimerId extends ManagedTimerId = ManagedTimerId> =\n {\n readonly setTimeout: (callback: TimeoutCallback, delay: number) => TTimerId\n readonly clearTimeout: (timeoutId: TTimerId | undefined) => void\n\n readonly setInterval: (callback: TimeoutCallback, delay: number) => TTimerId\n readonly clearInterval: (intervalId: TTimerId | undefined) => void\n }\n\ntype SystemTimerId = ReturnType<typeof setTimeout>\n\nexport const defaultTimeoutProvider: TimeoutProvider = {\n // We need the wrapper function syntax below instead of direct references to\n // global setTimeout etc.\n //\n // BAD: `setTimeout: setTimeout`\n // GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`\n //\n // If we use direct references here, then anything that wants to spy on or\n // replace the global setTimeout (like tests) won't work since we'll already\n // have a hard reference to the original implementation at the time when this\n // file was imported.\n setTimeout: (callback, delay) => setTimeout(callback, delay),\n clearTimeout: (timeoutId) =>\n clearTimeout(timeoutId as SystemTimerId | undefined),\n\n setInterval: (callback, delay) => setInterval(callback, delay),\n clearInterval: (intervalId) =>\n clearInterval(intervalId as SystemTimerId | undefined),\n}\n\n/**\n * Allows customization of how timeouts are created.\n *\n * @tanstack/query-core makes liberal use of timeouts to implement `staleTime`\n * and `gcTime`. The default TimeoutManager provider uses the platform's global\n * `setTimeout` implementation, which is known to have scalability issues with\n * thousands of timeouts on the event loop.\n *\n * If you hit this limitation, consider providing a custom TimeoutProvider that\n * coalesces timeouts.\n */\nexport class TimeoutManager implements Omit<TimeoutProvider, 'name'> {\n // We cannot have TimeoutManager<T> as we must instantiate it with a concrete\n // type at app boot; and if we leave that type, then any new timer provider\n // would need to support the default provider's concrete timer ID, which is\n // infeasible across environments.\n //\n // We settle for type safety for the TimeoutProvider type, and accept that\n // this class is unsafe internally to allow for extension.\n #provider: TimeoutProvider<any> = defaultTimeoutProvider\n #providerCalled = false\n\n setTimeoutProvider<TTimerId extends ManagedTimerId>(\n provider: TimeoutProvider<TTimerId>,\n ): void {\n if (process.env.NODE_ENV !== 'production') {\n if (this.#providerCalled && provider !== this.#provider) {\n // After changing providers, `clearTimeout` will not work as expected for\n // timeouts from the previous provider.\n //\n // Since they may allocate the same timeout ID, clearTimeout may cancel an\n // arbitrary different timeout, or unexpected no-op.\n //\n // We could protect against this by mixing the timeout ID bits\n // deterministically with some per-provider bits.\n //\n // We could internally queue `setTimeout` calls to `TimeoutManager` until\n // some API call to set the initial provider.\n console.error(\n `[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.`,\n { previous: this.#provider, provider },\n )\n }\n }\n\n this.#provider = provider\n if (process.env.NODE_ENV !== 'production') {\n this.#providerCalled = false\n }\n }\n\n setTimeout(callback: TimeoutCallback, delay: number): ManagedTimerId {\n if (process.env.NODE_ENV !== 'production') {\n this.#providerCalled = true\n }\n return this.#provider.setTimeout(callback, delay)\n }\n\n clearTimeout(timeoutId: ManagedTimerId | undefined): void {\n this.#provider.clearTimeout(timeoutId)\n }\n\n setInterval(callback: TimeoutCallback, delay: number): ManagedTimerId {\n if (process.env.NODE_ENV !== 'production') {\n this.#providerCalled = true\n }\n return this.#provider.setInterval(callback, delay)\n }\n\n clearInterval(intervalId: ManagedTimerId | undefined): void {\n this.#provider.clearInterval(intervalId)\n }\n}\n\nexport const timeoutManager = new TimeoutManager()\n\n/**\n * In many cases code wants to delay to the next event loop tick; this is not\n * mediated by {@link timeoutManager}.\n *\n * This function is provided to make auditing the `tanstack/query-core` for\n * incorrect use of system `setTimeout` easier.\n */\nexport function systemSetTimeoutZero(callback: TimeoutCallback): void {\n setTimeout(callback, 0)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgCO,IAAM,yBAA0C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWrD,YAAY,CAAC,UAAU,UAAU,WAAW,UAAU,KAAK;AAAA,EAC3D,cAAc,CAAC,cACb,aAAa,SAAsC;AAAA,EAErD,aAAa,CAAC,UAAU,UAAU,YAAY,UAAU,KAAK;AAAA,EAC7D,eAAe,CAAC,eACd,cAAc,UAAuC;AACzD;AAlDA;AA+DO,IAAM,iBAAN,MAA8D;AAAA,EAA9D;AAQL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kCAAkC;AAClC,wCAAkB;AAAA;AAAA,EAElB,mBACE,UACM;AACN,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,UAAI,mBAAK,oBAAmB,aAAa,mBAAK,YAAW;AAYvD,gBAAQ;AAAA,UACN;AAAA,UACA,EAAE,UAAU,mBAAK,YAAW,SAAS;AAAA,QACvC;AAAA,MACF;AAAA,IACF;AAEA,uBAAK,WAAY;AACjB,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,yBAAK,iBAAkB;AAAA,IACzB;AAAA,EACF;AAAA,EAEA,WAAW,UAA2B,OAA+B;AACnE,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,yBAAK,iBAAkB;AAAA,IACzB;AACA,WAAO,mBAAK,WAAU,WAAW,UAAU,KAAK;AAAA,EAClD;AAAA,EAEA,aAAa,WAA6C;AACxD,uBAAK,WAAU,aAAa,SAAS;AAAA,EACvC;AAAA,EAEA,YAAY,UAA2B,OAA+B;AACpE,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,yBAAK,iBAAkB;AAAA,IACzB;AACA,WAAO,mBAAK,WAAU,YAAY,UAAU,KAAK;AAAA,EACnD;AAAA,EAEA,cAAc,YAA8C;AAC1D,uBAAK,WAAU,cAAc,UAAU;AAAA,EACzC;AACF;AArDE;AACA;AAsDK,IAAM,iBAAiB,IAAI,eAAe;AAS1C,SAAS,qBAAqB,UAAiC;AACpE,aAAW,UAAU,CAAC;AACxB;","names":[]}
@@ -26,7 +26,8 @@ var TimeoutManager = class {
26
26
  constructor() {
27
27
  // We cannot have TimeoutManager<T> as we must instantiate it with a concrete
28
28
  // type at app boot; and if we leave that type, then any new timer provider
29
- // would need to support ReturnType<typeof setTimeout>, which is infeasible.
29
+ // would need to support the default provider's concrete timer ID, which is
30
+ // infeasible across environments.
30
31
  //
31
32
  // We settle for type safety for the TimeoutProvider type, and accept that
32
33
  // this class is unsafe internally to allow for extension.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/timeoutManager.ts"],"sourcesContent":["/**\n * {@link TimeoutManager} does not support passing arguments to the callback.\n *\n * `(_: void)` is the argument type inferred by TypeScript's default typings for\n * `setTimeout(cb, number)`.\n * If we don't accept a single void argument, then\n * `new Promise(resolve => timeoutManager.setTimeout(resolve, N))` is a type error.\n */\nexport type TimeoutCallback = (_: void) => void\n\n/**\n * Wrapping `setTimeout` is awkward from a typing perspective because platform\n * typings may extend the return type of `setTimeout`. For example, NodeJS\n * typings add `NodeJS.Timeout`; but a non-default `timeoutManager` may not be\n * able to return such a type.\n */\nexport type ManagedTimerId = number | { [Symbol.toPrimitive]: () => number }\n\n/**\n * Backend for timer functions.\n */\nexport type TimeoutProvider<TTimerId extends ManagedTimerId = ManagedTimerId> =\n {\n readonly setTimeout: (callback: TimeoutCallback, delay: number) => TTimerId\n readonly clearTimeout: (timeoutId: TTimerId | undefined) => void\n\n readonly setInterval: (callback: TimeoutCallback, delay: number) => TTimerId\n readonly clearInterval: (intervalId: TTimerId | undefined) => void\n }\n\nexport const defaultTimeoutProvider: TimeoutProvider<\n ReturnType<typeof setTimeout>\n> = {\n // We need the wrapper function syntax below instead of direct references to\n // global setTimeout etc.\n //\n // BAD: `setTimeout: setTimeout`\n // GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`\n //\n // If we use direct references here, then anything that wants to spy on or\n // replace the global setTimeout (like tests) won't work since we'll already\n // have a hard reference to the original implementation at the time when this\n // file was imported.\n setTimeout: (callback, delay) => setTimeout(callback, delay),\n clearTimeout: (timeoutId) => clearTimeout(timeoutId),\n\n setInterval: (callback, delay) => setInterval(callback, delay),\n clearInterval: (intervalId) => clearInterval(intervalId),\n}\n\n/**\n * Allows customization of how timeouts are created.\n *\n * @tanstack/query-core makes liberal use of timeouts to implement `staleTime`\n * and `gcTime`. The default TimeoutManager provider uses the platform's global\n * `setTimeout` implementation, which is known to have scalability issues with\n * thousands of timeouts on the event loop.\n *\n * If you hit this limitation, consider providing a custom TimeoutProvider that\n * coalesces timeouts.\n */\nexport class TimeoutManager implements Omit<TimeoutProvider, 'name'> {\n // We cannot have TimeoutManager<T> as we must instantiate it with a concrete\n // type at app boot; and if we leave that type, then any new timer provider\n // would need to support ReturnType<typeof setTimeout>, which is infeasible.\n //\n // We settle for type safety for the TimeoutProvider type, and accept that\n // this class is unsafe internally to allow for extension.\n #provider: TimeoutProvider<any> = defaultTimeoutProvider\n #providerCalled = false\n\n setTimeoutProvider<TTimerId extends ManagedTimerId>(\n provider: TimeoutProvider<TTimerId>,\n ): void {\n if (process.env.NODE_ENV !== 'production') {\n if (this.#providerCalled && provider !== this.#provider) {\n // After changing providers, `clearTimeout` will not work as expected for\n // timeouts from the previous provider.\n //\n // Since they may allocate the same timeout ID, clearTimeout may cancel an\n // arbitrary different timeout, or unexpected no-op.\n //\n // We could protect against this by mixing the timeout ID bits\n // deterministically with some per-provider bits.\n //\n // We could internally queue `setTimeout` calls to `TimeoutManager` until\n // some API call to set the initial provider.\n console.error(\n `[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.`,\n { previous: this.#provider, provider },\n )\n }\n }\n\n this.#provider = provider\n if (process.env.NODE_ENV !== 'production') {\n this.#providerCalled = false\n }\n }\n\n setTimeout(callback: TimeoutCallback, delay: number): ManagedTimerId {\n if (process.env.NODE_ENV !== 'production') {\n this.#providerCalled = true\n }\n return this.#provider.setTimeout(callback, delay)\n }\n\n clearTimeout(timeoutId: ManagedTimerId | undefined): void {\n this.#provider.clearTimeout(timeoutId)\n }\n\n setInterval(callback: TimeoutCallback, delay: number): ManagedTimerId {\n if (process.env.NODE_ENV !== 'production') {\n this.#providerCalled = true\n }\n return this.#provider.setInterval(callback, delay)\n }\n\n clearInterval(intervalId: ManagedTimerId | undefined): void {\n this.#provider.clearInterval(intervalId)\n }\n}\n\nexport const timeoutManager = new TimeoutManager()\n\n/**\n * In many cases code wants to delay to the next event loop tick; this is not\n * mediated by {@link timeoutManager}.\n *\n * This function is provided to make auditing the `tanstack/query-core` for\n * incorrect use of system `setTimeout` easier.\n */\nexport function systemSetTimeoutZero(callback: TimeoutCallback): void {\n setTimeout(callback, 0)\n}\n"],"mappings":";;;;;;;AA8BO,IAAM,yBAET;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWF,YAAY,CAAC,UAAU,UAAU,WAAW,UAAU,KAAK;AAAA,EAC3D,cAAc,CAAC,cAAc,aAAa,SAAS;AAAA,EAEnD,aAAa,CAAC,UAAU,UAAU,YAAY,UAAU,KAAK;AAAA,EAC7D,eAAe,CAAC,eAAe,cAAc,UAAU;AACzD;AAhDA;AA6DO,IAAM,iBAAN,MAA8D;AAAA,EAA9D;AAOL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kCAAkC;AAClC,wCAAkB;AAAA;AAAA,EAElB,mBACE,UACM;AACN,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,UAAI,mBAAK,oBAAmB,aAAa,mBAAK,YAAW;AAYvD,gBAAQ;AAAA,UACN;AAAA,UACA,EAAE,UAAU,mBAAK,YAAW,SAAS;AAAA,QACvC;AAAA,MACF;AAAA,IACF;AAEA,uBAAK,WAAY;AACjB,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,yBAAK,iBAAkB;AAAA,IACzB;AAAA,EACF;AAAA,EAEA,WAAW,UAA2B,OAA+B;AACnE,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,yBAAK,iBAAkB;AAAA,IACzB;AACA,WAAO,mBAAK,WAAU,WAAW,UAAU,KAAK;AAAA,EAClD;AAAA,EAEA,aAAa,WAA6C;AACxD,uBAAK,WAAU,aAAa,SAAS;AAAA,EACvC;AAAA,EAEA,YAAY,UAA2B,OAA+B;AACpE,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,yBAAK,iBAAkB;AAAA,IACzB;AACA,WAAO,mBAAK,WAAU,YAAY,UAAU,KAAK;AAAA,EACnD;AAAA,EAEA,cAAc,YAA8C;AAC1D,uBAAK,WAAU,cAAc,UAAU;AAAA,EACzC;AACF;AArDE;AACA;AAsDK,IAAM,iBAAiB,IAAI,eAAe;AAS1C,SAAS,qBAAqB,UAAiC;AACpE,aAAW,UAAU,CAAC;AACxB;","names":[]}
1
+ {"version":3,"sources":["../../src/timeoutManager.ts"],"sourcesContent":["/**\n * {@link TimeoutManager} does not support passing arguments to the callback.\n *\n * `(_: void)` is the argument type inferred by TypeScript's default typings for\n * `setTimeout(cb, number)`.\n * If we don't accept a single void argument, then\n * `new Promise(resolve => timeoutManager.setTimeout(resolve, N))` is a type error.\n */\nexport type TimeoutCallback = (_: void) => void\n\n/**\n * Wrapping `setTimeout` is awkward from a typing perspective because platform\n * typings may extend the return type of `setTimeout`. For example, NodeJS\n * typings add `NodeJS.Timeout`; but a non-default `timeoutManager` may not be\n * able to return such a type.\n */\nexport type ManagedTimerId = number | { [Symbol.toPrimitive]: () => number }\n\n/**\n * Backend for timer functions.\n */\nexport type TimeoutProvider<TTimerId extends ManagedTimerId = ManagedTimerId> =\n {\n readonly setTimeout: (callback: TimeoutCallback, delay: number) => TTimerId\n readonly clearTimeout: (timeoutId: TTimerId | undefined) => void\n\n readonly setInterval: (callback: TimeoutCallback, delay: number) => TTimerId\n readonly clearInterval: (intervalId: TTimerId | undefined) => void\n }\n\ntype SystemTimerId = ReturnType<typeof setTimeout>\n\nexport const defaultTimeoutProvider: TimeoutProvider = {\n // We need the wrapper function syntax below instead of direct references to\n // global setTimeout etc.\n //\n // BAD: `setTimeout: setTimeout`\n // GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`\n //\n // If we use direct references here, then anything that wants to spy on or\n // replace the global setTimeout (like tests) won't work since we'll already\n // have a hard reference to the original implementation at the time when this\n // file was imported.\n setTimeout: (callback, delay) => setTimeout(callback, delay),\n clearTimeout: (timeoutId) =>\n clearTimeout(timeoutId as SystemTimerId | undefined),\n\n setInterval: (callback, delay) => setInterval(callback, delay),\n clearInterval: (intervalId) =>\n clearInterval(intervalId as SystemTimerId | undefined),\n}\n\n/**\n * Allows customization of how timeouts are created.\n *\n * @tanstack/query-core makes liberal use of timeouts to implement `staleTime`\n * and `gcTime`. The default TimeoutManager provider uses the platform's global\n * `setTimeout` implementation, which is known to have scalability issues with\n * thousands of timeouts on the event loop.\n *\n * If you hit this limitation, consider providing a custom TimeoutProvider that\n * coalesces timeouts.\n */\nexport class TimeoutManager implements Omit<TimeoutProvider, 'name'> {\n // We cannot have TimeoutManager<T> as we must instantiate it with a concrete\n // type at app boot; and if we leave that type, then any new timer provider\n // would need to support the default provider's concrete timer ID, which is\n // infeasible across environments.\n //\n // We settle for type safety for the TimeoutProvider type, and accept that\n // this class is unsafe internally to allow for extension.\n #provider: TimeoutProvider<any> = defaultTimeoutProvider\n #providerCalled = false\n\n setTimeoutProvider<TTimerId extends ManagedTimerId>(\n provider: TimeoutProvider<TTimerId>,\n ): void {\n if (process.env.NODE_ENV !== 'production') {\n if (this.#providerCalled && provider !== this.#provider) {\n // After changing providers, `clearTimeout` will not work as expected for\n // timeouts from the previous provider.\n //\n // Since they may allocate the same timeout ID, clearTimeout may cancel an\n // arbitrary different timeout, or unexpected no-op.\n //\n // We could protect against this by mixing the timeout ID bits\n // deterministically with some per-provider bits.\n //\n // We could internally queue `setTimeout` calls to `TimeoutManager` until\n // some API call to set the initial provider.\n console.error(\n `[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.`,\n { previous: this.#provider, provider },\n )\n }\n }\n\n this.#provider = provider\n if (process.env.NODE_ENV !== 'production') {\n this.#providerCalled = false\n }\n }\n\n setTimeout(callback: TimeoutCallback, delay: number): ManagedTimerId {\n if (process.env.NODE_ENV !== 'production') {\n this.#providerCalled = true\n }\n return this.#provider.setTimeout(callback, delay)\n }\n\n clearTimeout(timeoutId: ManagedTimerId | undefined): void {\n this.#provider.clearTimeout(timeoutId)\n }\n\n setInterval(callback: TimeoutCallback, delay: number): ManagedTimerId {\n if (process.env.NODE_ENV !== 'production') {\n this.#providerCalled = true\n }\n return this.#provider.setInterval(callback, delay)\n }\n\n clearInterval(intervalId: ManagedTimerId | undefined): void {\n this.#provider.clearInterval(intervalId)\n }\n}\n\nexport const timeoutManager = new TimeoutManager()\n\n/**\n * In many cases code wants to delay to the next event loop tick; this is not\n * mediated by {@link timeoutManager}.\n *\n * This function is provided to make auditing the `tanstack/query-core` for\n * incorrect use of system `setTimeout` easier.\n */\nexport function systemSetTimeoutZero(callback: TimeoutCallback): void {\n setTimeout(callback, 0)\n}\n"],"mappings":";;;;;;;AAgCO,IAAM,yBAA0C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWrD,YAAY,CAAC,UAAU,UAAU,WAAW,UAAU,KAAK;AAAA,EAC3D,cAAc,CAAC,cACb,aAAa,SAAsC;AAAA,EAErD,aAAa,CAAC,UAAU,UAAU,YAAY,UAAU,KAAK;AAAA,EAC7D,eAAe,CAAC,eACd,cAAc,UAAuC;AACzD;AAlDA;AA+DO,IAAM,iBAAN,MAA8D;AAAA,EAA9D;AAQL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kCAAkC;AAClC,wCAAkB;AAAA;AAAA,EAElB,mBACE,UACM;AACN,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,UAAI,mBAAK,oBAAmB,aAAa,mBAAK,YAAW;AAYvD,gBAAQ;AAAA,UACN;AAAA,UACA,EAAE,UAAU,mBAAK,YAAW,SAAS;AAAA,QACvC;AAAA,MACF;AAAA,IACF;AAEA,uBAAK,WAAY;AACjB,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,yBAAK,iBAAkB;AAAA,IACzB;AAAA,EACF;AAAA,EAEA,WAAW,UAA2B,OAA+B;AACnE,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,yBAAK,iBAAkB;AAAA,IACzB;AACA,WAAO,mBAAK,WAAU,WAAW,UAAU,KAAK;AAAA,EAClD;AAAA,EAEA,aAAa,WAA6C;AACxD,uBAAK,WAAU,aAAa,SAAS;AAAA,EACvC;AAAA,EAEA,YAAY,UAA2B,OAA+B;AACpE,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,yBAAK,iBAAkB;AAAA,IACzB;AACA,WAAO,mBAAK,WAAU,YAAY,UAAU,KAAK;AAAA,EACnD;AAAA,EAEA,cAAc,YAA8C;AAC1D,uBAAK,WAAU,cAAc,UAAU;AAAA,EACzC;AACF;AArDE;AACA;AAsDK,IAAM,iBAAiB,IAAI,eAAe;AAS1C,SAAS,qBAAqB,UAAiC;AACpE,aAAW,UAAU,CAAC;AACxB;","names":[]}
@@ -1,7 +1,3 @@
1
- import type { MockInstance } from 'vitest';
2
- import { Options } from 'tsup';
3
- import { UserConfig } from 'vite';
4
-
5
1
  export declare type Action<TData, TError, TVariables, TOnMutateResult> = ContinueAction_2 | ErrorAction_2<TError> | FailedAction_2<TError> | PendingAction<TVariables, TOnMutateResult> | PauseAction_2 | SuccessAction_2<TData>;
6
2
 
7
3
  export declare type Action_alias_1<TData, TError> = ContinueAction | ErrorAction<TError> | FailedAction<TError> | FetchAction | InvalidateAction | PauseAction | SetStateAction<TData, TError> | SuccessAction<TData>;
@@ -98,14 +94,6 @@ declare type dataTagSymbol = typeof dataTagSymbol;
98
94
  export { dataTagSymbol }
99
95
  export { dataTagSymbol as dataTagSymbol_alias_1 }
100
96
 
101
- export declare const default_alias: any[];
102
-
103
- export declare const default_alias_1: any[];
104
-
105
- export declare const default_alias_2: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
106
-
107
- export declare const default_alias_3: UserConfig;
108
-
109
97
  declare type DefaultedInfiniteQueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = WithRequired<InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, 'throwOnError' | 'refetchOnReconnect' | 'queryHash'>;
110
98
  export { DefaultedInfiniteQueryObserverOptions }
111
99
  export { DefaultedInfiniteQueryObserverOptions as DefaultedInfiniteQueryObserverOptions_alias_1 }
@@ -141,7 +129,7 @@ declare function defaultShouldDehydrateQuery(query: Query): boolean;
141
129
  export { defaultShouldDehydrateQuery }
142
130
  export { defaultShouldDehydrateQuery as defaultShouldDehydrateQuery_alias_1 }
143
131
 
144
- export declare const defaultTimeoutProvider: TimeoutProvider<ReturnType<typeof setTimeout>>;
132
+ export declare const defaultTimeoutProvider: TimeoutProvider;
145
133
 
146
134
  declare type DefinedInfiniteQueryObserverResult<TData = unknown, TError = DefaultError> = InfiniteQueryObserverRefetchErrorResult<TData, TError> | InfiniteQueryObserverSuccessResult<TData, TError>;
147
135
  export { DefinedInfiniteQueryObserverResult }
@@ -243,8 +231,6 @@ declare interface ErrorAction_2<TError> {
243
231
  error: TError;
244
232
  }
245
233
 
246
- export declare function executeMutation<TVariables>(queryClient: QueryClient, options: MutationOptions<any, any, TVariables, any>, variables: TVariables): Promise<any>;
247
-
248
234
  declare interface FailedAction<TError> {
249
235
  type: 'failed';
250
236
  failureCount: number;
@@ -669,15 +655,6 @@ declare function keepPreviousData<T>(previousData: T | undefined): T | undefined
669
655
  export { keepPreviousData }
670
656
  export { keepPreviousData as keepPreviousData_alias_1 }
671
657
 
672
- /**
673
- * @param {Object} opts - Options for building configurations.
674
- * @param {string[]} opts.entry - The entry array.
675
- * @returns {import('tsup').Options}
676
- */
677
- export declare function legacyConfig(opts: {
678
- entry: string[];
679
- }): Options;
680
-
681
658
  declare type Listener = (focused: boolean) => void;
682
659
 
683
660
  declare type Listener_2 = (online: boolean) => void;
@@ -702,17 +679,6 @@ declare function matchQuery(filters: QueryFilters, query: Query<any, any, any, a
702
679
  export { matchQuery }
703
680
  export { matchQuery as matchQuery_alias_1 }
704
681
 
705
- export declare function mockOnlineManagerIsOnline(value: boolean): MockInstance<() => boolean>;
706
-
707
- /**
708
- * @param {Object} opts - Options for building configurations.
709
- * @param {string[]} opts.entry - The entry array.
710
- * @returns {import('tsup').Options}
711
- */
712
- export declare function modernConfig(opts: {
713
- entry: string[];
714
- }): Options;
715
-
716
682
  declare type MutateFunction<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> = (variables: TVariables, options?: MutateOptions<TData, TError, TVariables, TOnMutateResult>) => Promise<TData>;
717
683
  export { MutateFunction }
718
684
  export { MutateFunction as MutateFunction_alias_1 }
@@ -2036,8 +2002,6 @@ declare interface SetDataOptions {
2036
2002
  export { SetDataOptions }
2037
2003
  export { SetDataOptions as SetDataOptions_alias_1 }
2038
2004
 
2039
- export declare function setIsServer(value: boolean): () => void;
2040
-
2041
2005
  declare interface SetStateAction<TData, TError> {
2042
2006
  type: 'setState';
2043
2007
  state: Partial<QueryState<TData, TError>>;
@@ -1,7 +1,3 @@
1
- import type { MockInstance } from 'vitest';
2
- import { Options } from 'tsup';
3
- import { UserConfig } from 'vite';
4
-
5
1
  export declare type Action<TData, TError, TVariables, TOnMutateResult> = ContinueAction_2 | ErrorAction_2<TError> | FailedAction_2<TError> | PendingAction<TVariables, TOnMutateResult> | PauseAction_2 | SuccessAction_2<TData>;
6
2
 
7
3
  export declare type Action_alias_1<TData, TError> = ContinueAction | ErrorAction<TError> | FailedAction<TError> | FetchAction | InvalidateAction | PauseAction | SetStateAction<TData, TError> | SuccessAction<TData>;
@@ -98,14 +94,6 @@ declare type dataTagSymbol = typeof dataTagSymbol;
98
94
  export { dataTagSymbol }
99
95
  export { dataTagSymbol as dataTagSymbol_alias_1 }
100
96
 
101
- export declare const default_alias: any[];
102
-
103
- export declare const default_alias_1: any[];
104
-
105
- export declare const default_alias_2: Options | Options[] | ((overrideOptions: Options) => Options | Options[] | Promise<Options | Options[]>);
106
-
107
- export declare const default_alias_3: UserConfig;
108
-
109
97
  declare type DefaultedInfiniteQueryObserverOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> = WithRequired<InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>, 'throwOnError' | 'refetchOnReconnect' | 'queryHash'>;
110
98
  export { DefaultedInfiniteQueryObserverOptions }
111
99
  export { DefaultedInfiniteQueryObserverOptions as DefaultedInfiniteQueryObserverOptions_alias_1 }
@@ -141,7 +129,7 @@ declare function defaultShouldDehydrateQuery(query: Query): boolean;
141
129
  export { defaultShouldDehydrateQuery }
142
130
  export { defaultShouldDehydrateQuery as defaultShouldDehydrateQuery_alias_1 }
143
131
 
144
- export declare const defaultTimeoutProvider: TimeoutProvider<ReturnType<typeof setTimeout>>;
132
+ export declare const defaultTimeoutProvider: TimeoutProvider;
145
133
 
146
134
  declare type DefinedInfiniteQueryObserverResult<TData = unknown, TError = DefaultError> = InfiniteQueryObserverRefetchErrorResult<TData, TError> | InfiniteQueryObserverSuccessResult<TData, TError>;
147
135
  export { DefinedInfiniteQueryObserverResult }
@@ -243,8 +231,6 @@ declare interface ErrorAction_2<TError> {
243
231
  error: TError;
244
232
  }
245
233
 
246
- export declare function executeMutation<TVariables>(queryClient: QueryClient, options: MutationOptions<any, any, TVariables, any>, variables: TVariables): Promise<any>;
247
-
248
234
  declare interface FailedAction<TError> {
249
235
  type: 'failed';
250
236
  failureCount: number;
@@ -669,15 +655,6 @@ declare function keepPreviousData<T>(previousData: T | undefined): T | undefined
669
655
  export { keepPreviousData }
670
656
  export { keepPreviousData as keepPreviousData_alias_1 }
671
657
 
672
- /**
673
- * @param {Object} opts - Options for building configurations.
674
- * @param {string[]} opts.entry - The entry array.
675
- * @returns {import('tsup').Options}
676
- */
677
- export declare function legacyConfig(opts: {
678
- entry: string[];
679
- }): Options;
680
-
681
658
  declare type Listener = (focused: boolean) => void;
682
659
 
683
660
  declare type Listener_2 = (online: boolean) => void;
@@ -702,17 +679,6 @@ declare function matchQuery(filters: QueryFilters, query: Query<any, any, any, a
702
679
  export { matchQuery }
703
680
  export { matchQuery as matchQuery_alias_1 }
704
681
 
705
- export declare function mockOnlineManagerIsOnline(value: boolean): MockInstance<() => boolean>;
706
-
707
- /**
708
- * @param {Object} opts - Options for building configurations.
709
- * @param {string[]} opts.entry - The entry array.
710
- * @returns {import('tsup').Options}
711
- */
712
- export declare function modernConfig(opts: {
713
- entry: string[];
714
- }): Options;
715
-
716
682
  declare type MutateFunction<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> = (variables: TVariables, options?: MutateOptions<TData, TError, TVariables, TOnMutateResult>) => Promise<TData>;
717
683
  export { MutateFunction }
718
684
  export { MutateFunction as MutateFunction_alias_1 }
@@ -2036,8 +2002,6 @@ declare interface SetDataOptions {
2036
2002
  export { SetDataOptions }
2037
2003
  export { SetDataOptions as SetDataOptions_alias_1 }
2038
2004
 
2039
- export declare function setIsServer(value: boolean): () => void;
2040
-
2041
2005
  declare interface SetStateAction<TData, TError> {
2042
2006
  type: 'setState';
2043
2007
  state: Partial<QueryState<TData, TError>>;
@@ -45,7 +45,8 @@ var defaultTimeoutProvider = {
45
45
  var TimeoutManager = class {
46
46
  // We cannot have TimeoutManager<T> as we must instantiate it with a concrete
47
47
  // type at app boot; and if we leave that type, then any new timer provider
48
- // would need to support ReturnType<typeof setTimeout>, which is infeasible.
48
+ // would need to support the default provider's concrete timer ID, which is
49
+ // infeasible across environments.
49
50
  //
50
51
  // We settle for type safety for the TimeoutProvider type, and accept that
51
52
  // this class is unsafe internally to allow for extension.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/timeoutManager.ts"],"sourcesContent":["/**\n * {@link TimeoutManager} does not support passing arguments to the callback.\n *\n * `(_: void)` is the argument type inferred by TypeScript's default typings for\n * `setTimeout(cb, number)`.\n * If we don't accept a single void argument, then\n * `new Promise(resolve => timeoutManager.setTimeout(resolve, N))` is a type error.\n */\nexport type TimeoutCallback = (_: void) => void\n\n/**\n * Wrapping `setTimeout` is awkward from a typing perspective because platform\n * typings may extend the return type of `setTimeout`. For example, NodeJS\n * typings add `NodeJS.Timeout`; but a non-default `timeoutManager` may not be\n * able to return such a type.\n */\nexport type ManagedTimerId = number | { [Symbol.toPrimitive]: () => number }\n\n/**\n * Backend for timer functions.\n */\nexport type TimeoutProvider<TTimerId extends ManagedTimerId = ManagedTimerId> =\n {\n readonly setTimeout: (callback: TimeoutCallback, delay: number) => TTimerId\n readonly clearTimeout: (timeoutId: TTimerId | undefined) => void\n\n readonly setInterval: (callback: TimeoutCallback, delay: number) => TTimerId\n readonly clearInterval: (intervalId: TTimerId | undefined) => void\n }\n\nexport const defaultTimeoutProvider: TimeoutProvider<\n ReturnType<typeof setTimeout>\n> = {\n // We need the wrapper function syntax below instead of direct references to\n // global setTimeout etc.\n //\n // BAD: `setTimeout: setTimeout`\n // GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`\n //\n // If we use direct references here, then anything that wants to spy on or\n // replace the global setTimeout (like tests) won't work since we'll already\n // have a hard reference to the original implementation at the time when this\n // file was imported.\n setTimeout: (callback, delay) => setTimeout(callback, delay),\n clearTimeout: (timeoutId) => clearTimeout(timeoutId),\n\n setInterval: (callback, delay) => setInterval(callback, delay),\n clearInterval: (intervalId) => clearInterval(intervalId),\n}\n\n/**\n * Allows customization of how timeouts are created.\n *\n * @tanstack/query-core makes liberal use of timeouts to implement `staleTime`\n * and `gcTime`. The default TimeoutManager provider uses the platform's global\n * `setTimeout` implementation, which is known to have scalability issues with\n * thousands of timeouts on the event loop.\n *\n * If you hit this limitation, consider providing a custom TimeoutProvider that\n * coalesces timeouts.\n */\nexport class TimeoutManager implements Omit<TimeoutProvider, 'name'> {\n // We cannot have TimeoutManager<T> as we must instantiate it with a concrete\n // type at app boot; and if we leave that type, then any new timer provider\n // would need to support ReturnType<typeof setTimeout>, which is infeasible.\n //\n // We settle for type safety for the TimeoutProvider type, and accept that\n // this class is unsafe internally to allow for extension.\n #provider: TimeoutProvider<any> = defaultTimeoutProvider\n #providerCalled = false\n\n setTimeoutProvider<TTimerId extends ManagedTimerId>(\n provider: TimeoutProvider<TTimerId>,\n ): void {\n if (process.env.NODE_ENV !== 'production') {\n if (this.#providerCalled && provider !== this.#provider) {\n // After changing providers, `clearTimeout` will not work as expected for\n // timeouts from the previous provider.\n //\n // Since they may allocate the same timeout ID, clearTimeout may cancel an\n // arbitrary different timeout, or unexpected no-op.\n //\n // We could protect against this by mixing the timeout ID bits\n // deterministically with some per-provider bits.\n //\n // We could internally queue `setTimeout` calls to `TimeoutManager` until\n // some API call to set the initial provider.\n console.error(\n `[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.`,\n { previous: this.#provider, provider },\n )\n }\n }\n\n this.#provider = provider\n if (process.env.NODE_ENV !== 'production') {\n this.#providerCalled = false\n }\n }\n\n setTimeout(callback: TimeoutCallback, delay: number): ManagedTimerId {\n if (process.env.NODE_ENV !== 'production') {\n this.#providerCalled = true\n }\n return this.#provider.setTimeout(callback, delay)\n }\n\n clearTimeout(timeoutId: ManagedTimerId | undefined): void {\n this.#provider.clearTimeout(timeoutId)\n }\n\n setInterval(callback: TimeoutCallback, delay: number): ManagedTimerId {\n if (process.env.NODE_ENV !== 'production') {\n this.#providerCalled = true\n }\n return this.#provider.setInterval(callback, delay)\n }\n\n clearInterval(intervalId: ManagedTimerId | undefined): void {\n this.#provider.clearInterval(intervalId)\n }\n}\n\nexport const timeoutManager = new TimeoutManager()\n\n/**\n * In many cases code wants to delay to the next event loop tick; this is not\n * mediated by {@link timeoutManager}.\n *\n * This function is provided to make auditing the `tanstack/query-core` for\n * incorrect use of system `setTimeout` easier.\n */\nexport function systemSetTimeoutZero(callback: TimeoutCallback): void {\n setTimeout(callback, 0)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA8BO,IAAM,yBAET;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWF,YAAY,CAAC,UAAU,UAAU,WAAW,UAAU,KAAK;AAAA,EAC3D,cAAc,CAAC,cAAc,aAAa,SAAS;AAAA,EAEnD,aAAa,CAAC,UAAU,UAAU,YAAY,UAAU,KAAK;AAAA,EAC7D,eAAe,CAAC,eAAe,cAAc,UAAU;AACzD;AAaO,IAAM,iBAAN,MAA8D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOnE,YAAkC;AAAA,EAClC,kBAAkB;AAAA,EAElB,mBACE,UACM;AACN,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,UAAI,KAAK,mBAAmB,aAAa,KAAK,WAAW;AAYvD,gBAAQ;AAAA,UACN;AAAA,UACA,EAAE,UAAU,KAAK,WAAW,SAAS;AAAA,QACvC;AAAA,MACF;AAAA,IACF;AAEA,SAAK,YAAY;AACjB,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,WAAK,kBAAkB;AAAA,IACzB;AAAA,EACF;AAAA,EAEA,WAAW,UAA2B,OAA+B;AACnE,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,WAAK,kBAAkB;AAAA,IACzB;AACA,WAAO,KAAK,UAAU,WAAW,UAAU,KAAK;AAAA,EAClD;AAAA,EAEA,aAAa,WAA6C;AACxD,SAAK,UAAU,aAAa,SAAS;AAAA,EACvC;AAAA,EAEA,YAAY,UAA2B,OAA+B;AACpE,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,WAAK,kBAAkB;AAAA,IACzB;AACA,WAAO,KAAK,UAAU,YAAY,UAAU,KAAK;AAAA,EACnD;AAAA,EAEA,cAAc,YAA8C;AAC1D,SAAK,UAAU,cAAc,UAAU;AAAA,EACzC;AACF;AAEO,IAAM,iBAAiB,IAAI,eAAe;AAS1C,SAAS,qBAAqB,UAAiC;AACpE,aAAW,UAAU,CAAC;AACxB;","names":[]}
1
+ {"version":3,"sources":["../../src/timeoutManager.ts"],"sourcesContent":["/**\n * {@link TimeoutManager} does not support passing arguments to the callback.\n *\n * `(_: void)` is the argument type inferred by TypeScript's default typings for\n * `setTimeout(cb, number)`.\n * If we don't accept a single void argument, then\n * `new Promise(resolve => timeoutManager.setTimeout(resolve, N))` is a type error.\n */\nexport type TimeoutCallback = (_: void) => void\n\n/**\n * Wrapping `setTimeout` is awkward from a typing perspective because platform\n * typings may extend the return type of `setTimeout`. For example, NodeJS\n * typings add `NodeJS.Timeout`; but a non-default `timeoutManager` may not be\n * able to return such a type.\n */\nexport type ManagedTimerId = number | { [Symbol.toPrimitive]: () => number }\n\n/**\n * Backend for timer functions.\n */\nexport type TimeoutProvider<TTimerId extends ManagedTimerId = ManagedTimerId> =\n {\n readonly setTimeout: (callback: TimeoutCallback, delay: number) => TTimerId\n readonly clearTimeout: (timeoutId: TTimerId | undefined) => void\n\n readonly setInterval: (callback: TimeoutCallback, delay: number) => TTimerId\n readonly clearInterval: (intervalId: TTimerId | undefined) => void\n }\n\ntype SystemTimerId = ReturnType<typeof setTimeout>\n\nexport const defaultTimeoutProvider: TimeoutProvider = {\n // We need the wrapper function syntax below instead of direct references to\n // global setTimeout etc.\n //\n // BAD: `setTimeout: setTimeout`\n // GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`\n //\n // If we use direct references here, then anything that wants to spy on or\n // replace the global setTimeout (like tests) won't work since we'll already\n // have a hard reference to the original implementation at the time when this\n // file was imported.\n setTimeout: (callback, delay) => setTimeout(callback, delay),\n clearTimeout: (timeoutId) =>\n clearTimeout(timeoutId as SystemTimerId | undefined),\n\n setInterval: (callback, delay) => setInterval(callback, delay),\n clearInterval: (intervalId) =>\n clearInterval(intervalId as SystemTimerId | undefined),\n}\n\n/**\n * Allows customization of how timeouts are created.\n *\n * @tanstack/query-core makes liberal use of timeouts to implement `staleTime`\n * and `gcTime`. The default TimeoutManager provider uses the platform's global\n * `setTimeout` implementation, which is known to have scalability issues with\n * thousands of timeouts on the event loop.\n *\n * If you hit this limitation, consider providing a custom TimeoutProvider that\n * coalesces timeouts.\n */\nexport class TimeoutManager implements Omit<TimeoutProvider, 'name'> {\n // We cannot have TimeoutManager<T> as we must instantiate it with a concrete\n // type at app boot; and if we leave that type, then any new timer provider\n // would need to support the default provider's concrete timer ID, which is\n // infeasible across environments.\n //\n // We settle for type safety for the TimeoutProvider type, and accept that\n // this class is unsafe internally to allow for extension.\n #provider: TimeoutProvider<any> = defaultTimeoutProvider\n #providerCalled = false\n\n setTimeoutProvider<TTimerId extends ManagedTimerId>(\n provider: TimeoutProvider<TTimerId>,\n ): void {\n if (process.env.NODE_ENV !== 'production') {\n if (this.#providerCalled && provider !== this.#provider) {\n // After changing providers, `clearTimeout` will not work as expected for\n // timeouts from the previous provider.\n //\n // Since they may allocate the same timeout ID, clearTimeout may cancel an\n // arbitrary different timeout, or unexpected no-op.\n //\n // We could protect against this by mixing the timeout ID bits\n // deterministically with some per-provider bits.\n //\n // We could internally queue `setTimeout` calls to `TimeoutManager` until\n // some API call to set the initial provider.\n console.error(\n `[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.`,\n { previous: this.#provider, provider },\n )\n }\n }\n\n this.#provider = provider\n if (process.env.NODE_ENV !== 'production') {\n this.#providerCalled = false\n }\n }\n\n setTimeout(callback: TimeoutCallback, delay: number): ManagedTimerId {\n if (process.env.NODE_ENV !== 'production') {\n this.#providerCalled = true\n }\n return this.#provider.setTimeout(callback, delay)\n }\n\n clearTimeout(timeoutId: ManagedTimerId | undefined): void {\n this.#provider.clearTimeout(timeoutId)\n }\n\n setInterval(callback: TimeoutCallback, delay: number): ManagedTimerId {\n if (process.env.NODE_ENV !== 'production') {\n this.#providerCalled = true\n }\n return this.#provider.setInterval(callback, delay)\n }\n\n clearInterval(intervalId: ManagedTimerId | undefined): void {\n this.#provider.clearInterval(intervalId)\n }\n}\n\nexport const timeoutManager = new TimeoutManager()\n\n/**\n * In many cases code wants to delay to the next event loop tick; this is not\n * mediated by {@link timeoutManager}.\n *\n * This function is provided to make auditing the `tanstack/query-core` for\n * incorrect use of system `setTimeout` easier.\n */\nexport function systemSetTimeoutZero(callback: TimeoutCallback): void {\n setTimeout(callback, 0)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgCO,IAAM,yBAA0C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWrD,YAAY,CAAC,UAAU,UAAU,WAAW,UAAU,KAAK;AAAA,EAC3D,cAAc,CAAC,cACb,aAAa,SAAsC;AAAA,EAErD,aAAa,CAAC,UAAU,UAAU,YAAY,UAAU,KAAK;AAAA,EAC7D,eAAe,CAAC,eACd,cAAc,UAAuC;AACzD;AAaO,IAAM,iBAAN,MAA8D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQnE,YAAkC;AAAA,EAClC,kBAAkB;AAAA,EAElB,mBACE,UACM;AACN,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,UAAI,KAAK,mBAAmB,aAAa,KAAK,WAAW;AAYvD,gBAAQ;AAAA,UACN;AAAA,UACA,EAAE,UAAU,KAAK,WAAW,SAAS;AAAA,QACvC;AAAA,MACF;AAAA,IACF;AAEA,SAAK,YAAY;AACjB,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,WAAK,kBAAkB;AAAA,IACzB;AAAA,EACF;AAAA,EAEA,WAAW,UAA2B,OAA+B;AACnE,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,WAAK,kBAAkB;AAAA,IACzB;AACA,WAAO,KAAK,UAAU,WAAW,UAAU,KAAK;AAAA,EAClD;AAAA,EAEA,aAAa,WAA6C;AACxD,SAAK,UAAU,aAAa,SAAS;AAAA,EACvC;AAAA,EAEA,YAAY,UAA2B,OAA+B;AACpE,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,WAAK,kBAAkB;AAAA,IACzB;AACA,WAAO,KAAK,UAAU,YAAY,UAAU,KAAK;AAAA,EACnD;AAAA,EAEA,cAAc,YAA8C;AAC1D,SAAK,UAAU,cAAc,UAAU;AAAA,EACzC;AACF;AAEO,IAAM,iBAAiB,IAAI,eAAe;AAS1C,SAAS,qBAAqB,UAAiC;AACpE,aAAW,UAAU,CAAC;AACxB;","names":[]}
@@ -18,7 +18,8 @@ var defaultTimeoutProvider = {
18
18
  var TimeoutManager = class {
19
19
  // We cannot have TimeoutManager<T> as we must instantiate it with a concrete
20
20
  // type at app boot; and if we leave that type, then any new timer provider
21
- // would need to support ReturnType<typeof setTimeout>, which is infeasible.
21
+ // would need to support the default provider's concrete timer ID, which is
22
+ // infeasible across environments.
22
23
  //
23
24
  // We settle for type safety for the TimeoutProvider type, and accept that
24
25
  // this class is unsafe internally to allow for extension.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/timeoutManager.ts"],"sourcesContent":["/**\n * {@link TimeoutManager} does not support passing arguments to the callback.\n *\n * `(_: void)` is the argument type inferred by TypeScript's default typings for\n * `setTimeout(cb, number)`.\n * If we don't accept a single void argument, then\n * `new Promise(resolve => timeoutManager.setTimeout(resolve, N))` is a type error.\n */\nexport type TimeoutCallback = (_: void) => void\n\n/**\n * Wrapping `setTimeout` is awkward from a typing perspective because platform\n * typings may extend the return type of `setTimeout`. For example, NodeJS\n * typings add `NodeJS.Timeout`; but a non-default `timeoutManager` may not be\n * able to return such a type.\n */\nexport type ManagedTimerId = number | { [Symbol.toPrimitive]: () => number }\n\n/**\n * Backend for timer functions.\n */\nexport type TimeoutProvider<TTimerId extends ManagedTimerId = ManagedTimerId> =\n {\n readonly setTimeout: (callback: TimeoutCallback, delay: number) => TTimerId\n readonly clearTimeout: (timeoutId: TTimerId | undefined) => void\n\n readonly setInterval: (callback: TimeoutCallback, delay: number) => TTimerId\n readonly clearInterval: (intervalId: TTimerId | undefined) => void\n }\n\nexport const defaultTimeoutProvider: TimeoutProvider<\n ReturnType<typeof setTimeout>\n> = {\n // We need the wrapper function syntax below instead of direct references to\n // global setTimeout etc.\n //\n // BAD: `setTimeout: setTimeout`\n // GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`\n //\n // If we use direct references here, then anything that wants to spy on or\n // replace the global setTimeout (like tests) won't work since we'll already\n // have a hard reference to the original implementation at the time when this\n // file was imported.\n setTimeout: (callback, delay) => setTimeout(callback, delay),\n clearTimeout: (timeoutId) => clearTimeout(timeoutId),\n\n setInterval: (callback, delay) => setInterval(callback, delay),\n clearInterval: (intervalId) => clearInterval(intervalId),\n}\n\n/**\n * Allows customization of how timeouts are created.\n *\n * @tanstack/query-core makes liberal use of timeouts to implement `staleTime`\n * and `gcTime`. The default TimeoutManager provider uses the platform's global\n * `setTimeout` implementation, which is known to have scalability issues with\n * thousands of timeouts on the event loop.\n *\n * If you hit this limitation, consider providing a custom TimeoutProvider that\n * coalesces timeouts.\n */\nexport class TimeoutManager implements Omit<TimeoutProvider, 'name'> {\n // We cannot have TimeoutManager<T> as we must instantiate it with a concrete\n // type at app boot; and if we leave that type, then any new timer provider\n // would need to support ReturnType<typeof setTimeout>, which is infeasible.\n //\n // We settle for type safety for the TimeoutProvider type, and accept that\n // this class is unsafe internally to allow for extension.\n #provider: TimeoutProvider<any> = defaultTimeoutProvider\n #providerCalled = false\n\n setTimeoutProvider<TTimerId extends ManagedTimerId>(\n provider: TimeoutProvider<TTimerId>,\n ): void {\n if (process.env.NODE_ENV !== 'production') {\n if (this.#providerCalled && provider !== this.#provider) {\n // After changing providers, `clearTimeout` will not work as expected for\n // timeouts from the previous provider.\n //\n // Since they may allocate the same timeout ID, clearTimeout may cancel an\n // arbitrary different timeout, or unexpected no-op.\n //\n // We could protect against this by mixing the timeout ID bits\n // deterministically with some per-provider bits.\n //\n // We could internally queue `setTimeout` calls to `TimeoutManager` until\n // some API call to set the initial provider.\n console.error(\n `[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.`,\n { previous: this.#provider, provider },\n )\n }\n }\n\n this.#provider = provider\n if (process.env.NODE_ENV !== 'production') {\n this.#providerCalled = false\n }\n }\n\n setTimeout(callback: TimeoutCallback, delay: number): ManagedTimerId {\n if (process.env.NODE_ENV !== 'production') {\n this.#providerCalled = true\n }\n return this.#provider.setTimeout(callback, delay)\n }\n\n clearTimeout(timeoutId: ManagedTimerId | undefined): void {\n this.#provider.clearTimeout(timeoutId)\n }\n\n setInterval(callback: TimeoutCallback, delay: number): ManagedTimerId {\n if (process.env.NODE_ENV !== 'production') {\n this.#providerCalled = true\n }\n return this.#provider.setInterval(callback, delay)\n }\n\n clearInterval(intervalId: ManagedTimerId | undefined): void {\n this.#provider.clearInterval(intervalId)\n }\n}\n\nexport const timeoutManager = new TimeoutManager()\n\n/**\n * In many cases code wants to delay to the next event loop tick; this is not\n * mediated by {@link timeoutManager}.\n *\n * This function is provided to make auditing the `tanstack/query-core` for\n * incorrect use of system `setTimeout` easier.\n */\nexport function systemSetTimeoutZero(callback: TimeoutCallback): void {\n setTimeout(callback, 0)\n}\n"],"mappings":";AA8BO,IAAM,yBAET;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWF,YAAY,CAAC,UAAU,UAAU,WAAW,UAAU,KAAK;AAAA,EAC3D,cAAc,CAAC,cAAc,aAAa,SAAS;AAAA,EAEnD,aAAa,CAAC,UAAU,UAAU,YAAY,UAAU,KAAK;AAAA,EAC7D,eAAe,CAAC,eAAe,cAAc,UAAU;AACzD;AAaO,IAAM,iBAAN,MAA8D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOnE,YAAkC;AAAA,EAClC,kBAAkB;AAAA,EAElB,mBACE,UACM;AACN,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,UAAI,KAAK,mBAAmB,aAAa,KAAK,WAAW;AAYvD,gBAAQ;AAAA,UACN;AAAA,UACA,EAAE,UAAU,KAAK,WAAW,SAAS;AAAA,QACvC;AAAA,MACF;AAAA,IACF;AAEA,SAAK,YAAY;AACjB,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,WAAK,kBAAkB;AAAA,IACzB;AAAA,EACF;AAAA,EAEA,WAAW,UAA2B,OAA+B;AACnE,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,WAAK,kBAAkB;AAAA,IACzB;AACA,WAAO,KAAK,UAAU,WAAW,UAAU,KAAK;AAAA,EAClD;AAAA,EAEA,aAAa,WAA6C;AACxD,SAAK,UAAU,aAAa,SAAS;AAAA,EACvC;AAAA,EAEA,YAAY,UAA2B,OAA+B;AACpE,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,WAAK,kBAAkB;AAAA,IACzB;AACA,WAAO,KAAK,UAAU,YAAY,UAAU,KAAK;AAAA,EACnD;AAAA,EAEA,cAAc,YAA8C;AAC1D,SAAK,UAAU,cAAc,UAAU;AAAA,EACzC;AACF;AAEO,IAAM,iBAAiB,IAAI,eAAe;AAS1C,SAAS,qBAAqB,UAAiC;AACpE,aAAW,UAAU,CAAC;AACxB;","names":[]}
1
+ {"version":3,"sources":["../../src/timeoutManager.ts"],"sourcesContent":["/**\n * {@link TimeoutManager} does not support passing arguments to the callback.\n *\n * `(_: void)` is the argument type inferred by TypeScript's default typings for\n * `setTimeout(cb, number)`.\n * If we don't accept a single void argument, then\n * `new Promise(resolve => timeoutManager.setTimeout(resolve, N))` is a type error.\n */\nexport type TimeoutCallback = (_: void) => void\n\n/**\n * Wrapping `setTimeout` is awkward from a typing perspective because platform\n * typings may extend the return type of `setTimeout`. For example, NodeJS\n * typings add `NodeJS.Timeout`; but a non-default `timeoutManager` may not be\n * able to return such a type.\n */\nexport type ManagedTimerId = number | { [Symbol.toPrimitive]: () => number }\n\n/**\n * Backend for timer functions.\n */\nexport type TimeoutProvider<TTimerId extends ManagedTimerId = ManagedTimerId> =\n {\n readonly setTimeout: (callback: TimeoutCallback, delay: number) => TTimerId\n readonly clearTimeout: (timeoutId: TTimerId | undefined) => void\n\n readonly setInterval: (callback: TimeoutCallback, delay: number) => TTimerId\n readonly clearInterval: (intervalId: TTimerId | undefined) => void\n }\n\ntype SystemTimerId = ReturnType<typeof setTimeout>\n\nexport const defaultTimeoutProvider: TimeoutProvider = {\n // We need the wrapper function syntax below instead of direct references to\n // global setTimeout etc.\n //\n // BAD: `setTimeout: setTimeout`\n // GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`\n //\n // If we use direct references here, then anything that wants to spy on or\n // replace the global setTimeout (like tests) won't work since we'll already\n // have a hard reference to the original implementation at the time when this\n // file was imported.\n setTimeout: (callback, delay) => setTimeout(callback, delay),\n clearTimeout: (timeoutId) =>\n clearTimeout(timeoutId as SystemTimerId | undefined),\n\n setInterval: (callback, delay) => setInterval(callback, delay),\n clearInterval: (intervalId) =>\n clearInterval(intervalId as SystemTimerId | undefined),\n}\n\n/**\n * Allows customization of how timeouts are created.\n *\n * @tanstack/query-core makes liberal use of timeouts to implement `staleTime`\n * and `gcTime`. The default TimeoutManager provider uses the platform's global\n * `setTimeout` implementation, which is known to have scalability issues with\n * thousands of timeouts on the event loop.\n *\n * If you hit this limitation, consider providing a custom TimeoutProvider that\n * coalesces timeouts.\n */\nexport class TimeoutManager implements Omit<TimeoutProvider, 'name'> {\n // We cannot have TimeoutManager<T> as we must instantiate it with a concrete\n // type at app boot; and if we leave that type, then any new timer provider\n // would need to support the default provider's concrete timer ID, which is\n // infeasible across environments.\n //\n // We settle for type safety for the TimeoutProvider type, and accept that\n // this class is unsafe internally to allow for extension.\n #provider: TimeoutProvider<any> = defaultTimeoutProvider\n #providerCalled = false\n\n setTimeoutProvider<TTimerId extends ManagedTimerId>(\n provider: TimeoutProvider<TTimerId>,\n ): void {\n if (process.env.NODE_ENV !== 'production') {\n if (this.#providerCalled && provider !== this.#provider) {\n // After changing providers, `clearTimeout` will not work as expected for\n // timeouts from the previous provider.\n //\n // Since they may allocate the same timeout ID, clearTimeout may cancel an\n // arbitrary different timeout, or unexpected no-op.\n //\n // We could protect against this by mixing the timeout ID bits\n // deterministically with some per-provider bits.\n //\n // We could internally queue `setTimeout` calls to `TimeoutManager` until\n // some API call to set the initial provider.\n console.error(\n `[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.`,\n { previous: this.#provider, provider },\n )\n }\n }\n\n this.#provider = provider\n if (process.env.NODE_ENV !== 'production') {\n this.#providerCalled = false\n }\n }\n\n setTimeout(callback: TimeoutCallback, delay: number): ManagedTimerId {\n if (process.env.NODE_ENV !== 'production') {\n this.#providerCalled = true\n }\n return this.#provider.setTimeout(callback, delay)\n }\n\n clearTimeout(timeoutId: ManagedTimerId | undefined): void {\n this.#provider.clearTimeout(timeoutId)\n }\n\n setInterval(callback: TimeoutCallback, delay: number): ManagedTimerId {\n if (process.env.NODE_ENV !== 'production') {\n this.#providerCalled = true\n }\n return this.#provider.setInterval(callback, delay)\n }\n\n clearInterval(intervalId: ManagedTimerId | undefined): void {\n this.#provider.clearInterval(intervalId)\n }\n}\n\nexport const timeoutManager = new TimeoutManager()\n\n/**\n * In many cases code wants to delay to the next event loop tick; this is not\n * mediated by {@link timeoutManager}.\n *\n * This function is provided to make auditing the `tanstack/query-core` for\n * incorrect use of system `setTimeout` easier.\n */\nexport function systemSetTimeoutZero(callback: TimeoutCallback): void {\n setTimeout(callback, 0)\n}\n"],"mappings":";AAgCO,IAAM,yBAA0C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWrD,YAAY,CAAC,UAAU,UAAU,WAAW,UAAU,KAAK;AAAA,EAC3D,cAAc,CAAC,cACb,aAAa,SAAsC;AAAA,EAErD,aAAa,CAAC,UAAU,UAAU,YAAY,UAAU,KAAK;AAAA,EAC7D,eAAe,CAAC,eACd,cAAc,UAAuC;AACzD;AAaO,IAAM,iBAAN,MAA8D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQnE,YAAkC;AAAA,EAClC,kBAAkB;AAAA,EAElB,mBACE,UACM;AACN,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,UAAI,KAAK,mBAAmB,aAAa,KAAK,WAAW;AAYvD,gBAAQ;AAAA,UACN;AAAA,UACA,EAAE,UAAU,KAAK,WAAW,SAAS;AAAA,QACvC;AAAA,MACF;AAAA,IACF;AAEA,SAAK,YAAY;AACjB,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,WAAK,kBAAkB;AAAA,IACzB;AAAA,EACF;AAAA,EAEA,WAAW,UAA2B,OAA+B;AACnE,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,WAAK,kBAAkB;AAAA,IACzB;AACA,WAAO,KAAK,UAAU,WAAW,UAAU,KAAK;AAAA,EAClD;AAAA,EAEA,aAAa,WAA6C;AACxD,SAAK,UAAU,aAAa,SAAS;AAAA,EACvC;AAAA,EAEA,YAAY,UAA2B,OAA+B;AACpE,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,WAAK,kBAAkB;AAAA,IACzB;AACA,WAAO,KAAK,UAAU,YAAY,UAAU,KAAK;AAAA,EACnD;AAAA,EAEA,cAAc,YAA8C;AAC1D,SAAK,UAAU,cAAc,UAAU;AAAA,EACzC;AACF;AAEO,IAAM,iBAAiB,IAAI,eAAe;AAS1C,SAAS,qBAAqB,UAAiC;AACpE,aAAW,UAAU,CAAC;AACxB;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/query-core",
3
- "version": "5.95.0",
3
+ "version": "5.95.2",
4
4
  "description": "The framework agnostic core that powers TanStack Query",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -28,9 +28,9 @@ export type TimeoutProvider<TTimerId extends ManagedTimerId = ManagedTimerId> =
28
28
  readonly clearInterval: (intervalId: TTimerId | undefined) => void
29
29
  }
30
30
 
31
- export const defaultTimeoutProvider: TimeoutProvider<
32
- ReturnType<typeof setTimeout>
33
- > = {
31
+ type SystemTimerId = ReturnType<typeof setTimeout>
32
+
33
+ export const defaultTimeoutProvider: TimeoutProvider = {
34
34
  // We need the wrapper function syntax below instead of direct references to
35
35
  // global setTimeout etc.
36
36
  //
@@ -42,10 +42,12 @@ export const defaultTimeoutProvider: TimeoutProvider<
42
42
  // have a hard reference to the original implementation at the time when this
43
43
  // file was imported.
44
44
  setTimeout: (callback, delay) => setTimeout(callback, delay),
45
- clearTimeout: (timeoutId) => clearTimeout(timeoutId),
45
+ clearTimeout: (timeoutId) =>
46
+ clearTimeout(timeoutId as SystemTimerId | undefined),
46
47
 
47
48
  setInterval: (callback, delay) => setInterval(callback, delay),
48
- clearInterval: (intervalId) => clearInterval(intervalId),
49
+ clearInterval: (intervalId) =>
50
+ clearInterval(intervalId as SystemTimerId | undefined),
49
51
  }
50
52
 
51
53
  /**
@@ -62,7 +64,8 @@ export const defaultTimeoutProvider: TimeoutProvider<
62
64
  export class TimeoutManager implements Omit<TimeoutProvider, 'name'> {
63
65
  // We cannot have TimeoutManager<T> as we must instantiate it with a concrete
64
66
  // type at app boot; and if we leave that type, then any new timer provider
65
- // would need to support ReturnType<typeof setTimeout>, which is infeasible.
67
+ // would need to support the default provider's concrete timer ID, which is
68
+ // infeasible across environments.
66
69
  //
67
70
  // We settle for type safety for the TimeoutProvider type, and accept that
68
71
  // this class is unsafe internally to allow for extension.