@tanstack/query-core 5.103.3 → 5.104.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/legacy/environmentManager.d.cts +3 -4
- package/build/legacy/environmentManager.d.cts.map +1 -1
- package/build/legacy/environmentManager.d.ts +3 -4
- package/build/legacy/environmentManager.d.ts.map +1 -1
- package/build/legacy/focusManager.d.cts +2 -3
- package/build/legacy/focusManager.d.cts.map +1 -1
- package/build/legacy/focusManager.d.ts +2 -3
- package/build/legacy/focusManager.d.ts.map +1 -1
- package/build/legacy/infiniteQueryBehavior.d.cts +3 -4
- package/build/legacy/infiniteQueryBehavior.d.cts.map +1 -1
- package/build/legacy/infiniteQueryBehavior.d.ts +3 -4
- package/build/legacy/infiniteQueryBehavior.d.ts.map +1 -1
- package/build/legacy/infiniteQueryObserver.d.cts +1 -2
- package/build/legacy/infiniteQueryObserver.d.cts.map +1 -1
- package/build/legacy/infiniteQueryObserver.d.ts +1 -2
- package/build/legacy/infiniteQueryObserver.d.ts.map +1 -1
- package/build/legacy/notifyManager.d.cts +3 -4
- package/build/legacy/notifyManager.d.cts.map +1 -1
- package/build/legacy/notifyManager.d.ts +3 -4
- package/build/legacy/notifyManager.d.ts.map +1 -1
- package/build/legacy/onlineManager.d.cts +2 -3
- package/build/legacy/onlineManager.d.cts.map +1 -1
- package/build/legacy/onlineManager.d.ts +2 -3
- package/build/legacy/onlineManager.d.ts.map +1 -1
- package/build/legacy/queriesObserver.d.cts +2 -3
- package/build/legacy/queriesObserver.d.cts.map +1 -1
- package/build/legacy/queriesObserver.d.ts +2 -3
- package/build/legacy/queriesObserver.d.ts.map +1 -1
- package/build/legacy/streamedQuery.cjs.map +1 -1
- package/build/legacy/streamedQuery.d.cts +1 -2
- package/build/legacy/streamedQuery.d.cts.map +1 -1
- package/build/legacy/streamedQuery.d.ts +1 -2
- package/build/legacy/streamedQuery.d.ts.map +1 -1
- package/build/legacy/streamedQuery.js.map +1 -1
- package/build/legacy/timeoutManager.d.cts +7 -8
- package/build/legacy/timeoutManager.d.cts.map +1 -1
- package/build/legacy/timeoutManager.d.ts +7 -8
- package/build/legacy/timeoutManager.d.ts.map +1 -1
- package/build/modern/environmentManager.d.cts +3 -4
- package/build/modern/environmentManager.d.cts.map +1 -1
- package/build/modern/environmentManager.d.ts +3 -4
- package/build/modern/environmentManager.d.ts.map +1 -1
- package/build/modern/focusManager.d.cts +2 -3
- package/build/modern/focusManager.d.cts.map +1 -1
- package/build/modern/focusManager.d.ts +2 -3
- package/build/modern/focusManager.d.ts.map +1 -1
- package/build/modern/infiniteQueryBehavior.d.cts +3 -4
- package/build/modern/infiniteQueryBehavior.d.cts.map +1 -1
- package/build/modern/infiniteQueryBehavior.d.ts +3 -4
- package/build/modern/infiniteQueryBehavior.d.ts.map +1 -1
- package/build/modern/infiniteQueryObserver.d.cts +1 -2
- package/build/modern/infiniteQueryObserver.d.cts.map +1 -1
- package/build/modern/infiniteQueryObserver.d.ts +1 -2
- package/build/modern/infiniteQueryObserver.d.ts.map +1 -1
- package/build/modern/notifyManager.d.cts +3 -4
- package/build/modern/notifyManager.d.cts.map +1 -1
- package/build/modern/notifyManager.d.ts +3 -4
- package/build/modern/notifyManager.d.ts.map +1 -1
- package/build/modern/onlineManager.d.cts +2 -3
- package/build/modern/onlineManager.d.cts.map +1 -1
- package/build/modern/onlineManager.d.ts +2 -3
- package/build/modern/onlineManager.d.ts.map +1 -1
- package/build/modern/queriesObserver.d.cts +2 -3
- package/build/modern/queriesObserver.d.cts.map +1 -1
- package/build/modern/queriesObserver.d.ts +2 -3
- package/build/modern/queriesObserver.d.ts.map +1 -1
- package/build/modern/streamedQuery.cjs.map +1 -1
- package/build/modern/streamedQuery.d.cts +1 -2
- package/build/modern/streamedQuery.d.cts.map +1 -1
- package/build/modern/streamedQuery.d.ts +1 -2
- package/build/modern/streamedQuery.d.ts.map +1 -1
- package/build/modern/streamedQuery.js.map +1 -1
- package/build/modern/timeoutManager.d.cts +7 -8
- package/build/modern/timeoutManager.d.cts.map +1 -1
- package/build/modern/timeoutManager.d.ts +7 -8
- package/build/modern/timeoutManager.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/streamedQuery.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeoutManager.d.ts","names":[],"sources":["../../src/timeoutManager.ts"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"timeoutManager.d.ts","names":[],"sources":["../../src/timeoutManager.ts"],"mappings":";;;;;;;;;YAQY,mBAAmB;;;;;;;YAQnB;GAA6B,OAAO;;;;;;;;;;;YAWpC,gBAAgB,iBAAiB,iBAAiB;WAEjD,aAAa,UAAU,iBAAiB,kBAAkB;WAC1D,eAAe,WAAW;WAE1B,cAAc,UAAU,iBAAiB,kBAAkB;WAC3D,gBAAgB,YAAY;;qBAK5B,wBAAwB;;;;;;;;;;;;qBA+BxB,0BAA0B,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoC1C,mBAAmB,iBAAiB,gBAClC,UAAU,gBAAgB;;;;;;;;;;;;;;;;;;;;;EAgD5B,WAAW,UAAU,iBAAiB,gBAAgB;;;;;;;;;;;;;;;;;;EAwBtD,aAAa,WAAW;;;;;;;;;;;;;;;;;;EAqBxB,YAAY,UAAU,iBAAiB,gBAAgB;;;;;;;;;;;;;;;;;;EAwBvD,cAAc,YAAY;;;;;qBAQf,gBAAc;;;;;;;;wBASX,qBAAqB,UAAU"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
//#region src/environmentManager.d.ts
|
|
2
|
-
type IsServerValue = () => boolean;
|
|
2
|
+
export type IsServerValue = () => boolean;
|
|
3
3
|
/**
|
|
4
4
|
* Returns whether the current runtime should be treated as a server environment.
|
|
5
5
|
*/
|
|
6
|
-
declare const isServer: () => boolean;
|
|
6
|
+
export declare const isServer: () => boolean;
|
|
7
7
|
/**
|
|
8
8
|
* Manages how TanStack Query detects whether the current runtime should be treated as
|
|
9
9
|
* server-side, which disables scheduling refetch timers and changes the default `retry` count
|
|
@@ -21,7 +21,7 @@ declare const isServer: () => boolean;
|
|
|
21
21
|
* environmentManager.setIsServer(() => false)
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
|
-
declare const environmentManager: {
|
|
24
|
+
export declare const environmentManager: {
|
|
25
25
|
isServer: () => boolean;
|
|
26
26
|
/**
|
|
27
27
|
* Overrides the server check globally.
|
|
@@ -29,5 +29,4 @@ declare const environmentManager: {
|
|
|
29
29
|
setIsServer(isServerValue: IsServerValue): void;
|
|
30
30
|
};
|
|
31
31
|
//#endregion
|
|
32
|
-
export { IsServerValue, environmentManager, isServer };
|
|
33
32
|
//# sourceMappingURL=environmentManager.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environmentManager.d.cts","names":[],"sources":["../../src/environmentManager.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"environmentManager.d.cts","names":[],"sources":["../../src/environmentManager.ts"],"mappings":";YAEY;;;;qBAOC;;;;;;;;;;;;;;;;;;qBAmBA;EAnBe;;;;EAwBC,YAAA,eAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
//#region src/environmentManager.d.ts
|
|
2
|
-
type IsServerValue = () => boolean;
|
|
2
|
+
export type IsServerValue = () => boolean;
|
|
3
3
|
/**
|
|
4
4
|
* Returns whether the current runtime should be treated as a server environment.
|
|
5
5
|
*/
|
|
6
|
-
declare const isServer: () => boolean;
|
|
6
|
+
export declare const isServer: () => boolean;
|
|
7
7
|
/**
|
|
8
8
|
* Manages how TanStack Query detects whether the current runtime should be treated as
|
|
9
9
|
* server-side, which disables scheduling refetch timers and changes the default `retry` count
|
|
@@ -21,7 +21,7 @@ declare const isServer: () => boolean;
|
|
|
21
21
|
* environmentManager.setIsServer(() => false)
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
|
-
declare const environmentManager: {
|
|
24
|
+
export declare const environmentManager: {
|
|
25
25
|
isServer: () => boolean;
|
|
26
26
|
/**
|
|
27
27
|
* Overrides the server check globally.
|
|
@@ -29,5 +29,4 @@ declare const environmentManager: {
|
|
|
29
29
|
setIsServer(isServerValue: IsServerValue): void;
|
|
30
30
|
};
|
|
31
31
|
//#endregion
|
|
32
|
-
export { IsServerValue, environmentManager, isServer };
|
|
33
32
|
//# sourceMappingURL=environmentManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environmentManager.d.ts","names":[],"sources":["../../src/environmentManager.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"environmentManager.d.ts","names":[],"sources":["../../src/environmentManager.ts"],"mappings":";YAEY;;;;qBAOC;;;;;;;;;;;;;;;;;;qBAmBA;EAnBe;;;;EAwBC,YAAA,eAAA"}
|
|
@@ -7,7 +7,7 @@ type SetupFn = (setFocused: (focused?: boolean) => void) => (() => void) | undef
|
|
|
7
7
|
*
|
|
8
8
|
* It can be used to change the default event listeners or to manually change the focus state.
|
|
9
9
|
*/
|
|
10
|
-
declare class FocusManager extends Subscribable<Listener> {
|
|
10
|
+
export declare class FocusManager extends Subscribable<Listener> {
|
|
11
11
|
#private;
|
|
12
12
|
constructor();
|
|
13
13
|
protected onSubscribe(): void;
|
|
@@ -69,7 +69,6 @@ declare class FocusManager extends Subscribable<Listener> {
|
|
|
69
69
|
/**
|
|
70
70
|
* Singleton instance of {@link FocusManager}, used to manage and observe the focus state within TanStack Query.
|
|
71
71
|
*/
|
|
72
|
-
declare const focusManager: FocusManager;
|
|
72
|
+
export declare const focusManager: FocusManager;
|
|
73
73
|
//#endregion
|
|
74
|
-
export { FocusManager, focusManager };
|
|
75
74
|
//# sourceMappingURL=focusManager.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focusManager.d.cts","names":[],"sources":["../../src/focusManager.ts"],"mappings":";;KAEK,YAAY;KAEZ,WACH,aAAa;;;;;;
|
|
1
|
+
{"version":3,"file":"focusManager.d.cts","names":[],"sources":["../../src/focusManager.ts"],"mappings":";;KAEK,YAAY;KAEZ,WACH,aAAa;;;;;;qBAQF,qBAAqB,aAAa;;;YAyBnC;YAMA;;;;;;;;;;;;;;;;;;;;;;;;;;EAgCV,iBAAiB,OAAO;;;;;;;;;;;;;;;;;;;EA8BxB,WAAW;;;;EAWX;;;;EAUA;;;;;qBAcW,cAAY"}
|
|
@@ -7,7 +7,7 @@ type SetupFn = (setFocused: (focused?: boolean) => void) => (() => void) | undef
|
|
|
7
7
|
*
|
|
8
8
|
* It can be used to change the default event listeners or to manually change the focus state.
|
|
9
9
|
*/
|
|
10
|
-
declare class FocusManager extends Subscribable<Listener> {
|
|
10
|
+
export declare class FocusManager extends Subscribable<Listener> {
|
|
11
11
|
#private;
|
|
12
12
|
constructor();
|
|
13
13
|
protected onSubscribe(): void;
|
|
@@ -69,7 +69,6 @@ declare class FocusManager extends Subscribable<Listener> {
|
|
|
69
69
|
/**
|
|
70
70
|
* Singleton instance of {@link FocusManager}, used to manage and observe the focus state within TanStack Query.
|
|
71
71
|
*/
|
|
72
|
-
declare const focusManager: FocusManager;
|
|
72
|
+
export declare const focusManager: FocusManager;
|
|
73
73
|
//#endregion
|
|
74
|
-
export { FocusManager, focusManager };
|
|
75
74
|
//# sourceMappingURL=focusManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focusManager.d.ts","names":[],"sources":["../../src/focusManager.ts"],"mappings":";;KAEK,YAAY;KAEZ,WACH,aAAa;;;;;;
|
|
1
|
+
{"version":3,"file":"focusManager.d.ts","names":[],"sources":["../../src/focusManager.ts"],"mappings":";;KAEK,YAAY;KAEZ,WACH,aAAa;;;;;;qBAQF,qBAAqB,aAAa;;;YAyBnC;YAMA;;;;;;;;;;;;;;;;;;;;;;;;;;EAgCV,iBAAiB,OAAO;;;;;;;;;;;;;;;;;;;EA8BxB,WAAW;;;;EAWX;;;;EAUA;;;;;qBAcW,cAAY"}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { A as InfiniteData, V as InfiniteQueryPageParamsOptions, er as QueryBehavior } from "./hydration-Br9VIGXa.cjs";
|
|
2
2
|
//#region src/infiniteQueryBehavior.d.ts
|
|
3
|
-
declare function infiniteQueryBehavior<TQueryFnData, TError, TData, TPageParam>(pages?: number): QueryBehavior<TQueryFnData, TError, InfiniteData<TData, TPageParam>>;
|
|
3
|
+
export declare function infiniteQueryBehavior<TQueryFnData, TError, TData, TPageParam>(pages?: number): QueryBehavior<TQueryFnData, TError, InfiniteData<TData, TPageParam>>;
|
|
4
4
|
/**
|
|
5
5
|
* Checks if there is a next page.
|
|
6
6
|
*/
|
|
7
|
-
declare function hasNextPage(options: InfiniteQueryPageParamsOptions<any, any>, data?: InfiniteData<unknown>): boolean;
|
|
7
|
+
export declare function hasNextPage(options: InfiniteQueryPageParamsOptions<any, any>, data?: InfiniteData<unknown>): boolean;
|
|
8
8
|
/**
|
|
9
9
|
* Checks if there is a previous page.
|
|
10
10
|
*/
|
|
11
|
-
declare function hasPreviousPage(options: InfiniteQueryPageParamsOptions<any, any>, data?: InfiniteData<unknown>): boolean;
|
|
11
|
+
export declare function hasPreviousPage(options: InfiniteQueryPageParamsOptions<any, any>, data?: InfiniteData<unknown>): boolean;
|
|
12
12
|
//#endregion
|
|
13
|
-
export { hasNextPage, hasPreviousPage, infiniteQueryBehavior };
|
|
14
13
|
//# sourceMappingURL=infiniteQueryBehavior.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"infiniteQueryBehavior.d.cts","names":[],"sources":["../../src/infiniteQueryBehavior.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"infiniteQueryBehavior.d.cts","names":[],"sources":["../../src/infiniteQueryBehavior.ts"],"mappings":";;wBAegB,sBAAsB,cAAc,QAAQ,OAAO,YACjE,iBACC,cAAc,cAAc,QAAQ,aAAa,OAAO;;;;wBA6I3C,YACd,SAAS,0CACT,OAAO;;;;wBASO,gBACd,SAAS,0CACT,OAAO"}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { A as InfiniteData, V as InfiniteQueryPageParamsOptions, er as QueryBehavior } from "./hydration-B9t5w6NC.js";
|
|
2
2
|
//#region src/infiniteQueryBehavior.d.ts
|
|
3
|
-
declare function infiniteQueryBehavior<TQueryFnData, TError, TData, TPageParam>(pages?: number): QueryBehavior<TQueryFnData, TError, InfiniteData<TData, TPageParam>>;
|
|
3
|
+
export declare function infiniteQueryBehavior<TQueryFnData, TError, TData, TPageParam>(pages?: number): QueryBehavior<TQueryFnData, TError, InfiniteData<TData, TPageParam>>;
|
|
4
4
|
/**
|
|
5
5
|
* Checks if there is a next page.
|
|
6
6
|
*/
|
|
7
|
-
declare function hasNextPage(options: InfiniteQueryPageParamsOptions<any, any>, data?: InfiniteData<unknown>): boolean;
|
|
7
|
+
export declare function hasNextPage(options: InfiniteQueryPageParamsOptions<any, any>, data?: InfiniteData<unknown>): boolean;
|
|
8
8
|
/**
|
|
9
9
|
* Checks if there is a previous page.
|
|
10
10
|
*/
|
|
11
|
-
declare function hasPreviousPage(options: InfiniteQueryPageParamsOptions<any, any>, data?: InfiniteData<unknown>): boolean;
|
|
11
|
+
export declare function hasPreviousPage(options: InfiniteQueryPageParamsOptions<any, any>, data?: InfiniteData<unknown>): boolean;
|
|
12
12
|
//#endregion
|
|
13
|
-
export { hasNextPage, hasPreviousPage, infiniteQueryBehavior };
|
|
14
13
|
//# sourceMappingURL=infiniteQueryBehavior.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"infiniteQueryBehavior.d.ts","names":[],"sources":["../../src/infiniteQueryBehavior.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"infiniteQueryBehavior.d.ts","names":[],"sources":["../../src/infiniteQueryBehavior.ts"],"mappings":";;wBAegB,sBAAsB,cAAc,QAAQ,OAAO,YACjE,iBACC,cAAc,cAAc,QAAQ,aAAa,OAAO;;;;wBA6I3C,YACd,SAAS,0CACT,OAAO;;;;wBASO,gBACd,SAAS,0CACT,OAAO"}
|
|
@@ -21,7 +21,7 @@ type InfiniteQueryObserverListener<TData, TError> = (result: InfiniteQueryObserv
|
|
|
21
21
|
* const unsubscribe = observer.subscribe((result) => console.log(result))
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
|
-
declare class InfiniteQueryObserver<TQueryFnData = unknown, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> extends QueryObserver<TQueryFnData, TError, TData, InfiniteData<TQueryFnData, TPageParam>, TQueryKey> {
|
|
24
|
+
export declare class InfiniteQueryObserver<TQueryFnData = unknown, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> extends QueryObserver<TQueryFnData, TError, TData, InfiniteData<TQueryFnData, TPageParam>, TQueryKey> {
|
|
25
25
|
subscribe: Subscribable<InfiniteQueryObserverListener<TData, TError>>['subscribe'];
|
|
26
26
|
getCurrentResult: ReplaceReturnType<QueryObserver<TQueryFnData, TError, TData, InfiniteData<TQueryFnData, TPageParam>, TQueryKey>['getCurrentResult'], InfiniteQueryObserverResult<TData, TError>>;
|
|
27
27
|
protected fetch: ReplaceReturnType<QueryObserver<TQueryFnData, TError, TData, InfiniteData<TQueryFnData, TPageParam>, TQueryKey>['fetch'], Promise<InfiniteQueryObserverResult<TData, TError>>>;
|
|
@@ -83,5 +83,4 @@ declare class InfiniteQueryObserver<TQueryFnData = unknown, TError = DefaultErro
|
|
|
83
83
|
}
|
|
84
84
|
type ReplaceReturnType<TFunction extends (...args: Array<any>) => unknown, TReturn> = (...args: Parameters<TFunction>) => TReturn;
|
|
85
85
|
//#endregion
|
|
86
|
-
export { InfiniteQueryObserver };
|
|
87
86
|
//# sourceMappingURL=infiniteQueryObserver.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"infiniteQueryObserver.d.cts","names":[],"sources":["../../src/infiniteQueryObserver.ts"],"mappings":";;;KAiBK,8BAA8B,OAAO,WACxC,QAAQ,4BAA4B,OAAO;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"infiniteQueryObserver.d.cts","names":[],"sources":["../../src/infiniteQueryObserver.ts"],"mappings":";;;KAiBK,8BAA8B,OAAO,WACxC,QAAQ,4BAA4B,OAAO;;;;;;;;;;;;;;;;;;;;qBAsBhC,sBACX,wBACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,8BACQ,cACR,cACA,QACA,OACA,aAAa,cAAc,aAC3B;EAGA,WAAY,aACV,8BAA8B,OAAO;EAIvC,kBAAmB,kBACjB,cACE,cACA,QACA,OACA,aAAa,cAAc,aAC3B,gCAEF,4BAA4B,OAAO;YAI3B,OAAQ,kBAChB,cACE,cACA,QACA,OACA,aAAa,cAAc,aAC3B,qBAEF,QAAQ,4BAA4B,OAAO;EAI3C,YAAA,QAAQ,aACR,SAAS,6BACP,cACA,QACA,OACA,WACA;YAMM;;;;;;;EAYV,WACE,SAAS,6BACP,cACA,QACA,OACA,WACA;;;;;;;EAaJ,oBACE,SAAS,sCACP,cACA,QACA,OACA,WACA,cAED,4BAA4B,OAAO;;;;;;;;;;;;;;;;;;;EA0BtC,cACE,UAAU,uBACT,QAAQ,4BAA4B,OAAO;;;;;;;;;;;;;;;;;;;EA2B9C,kBACE,UAAU,2BACT,QAAQ,4BAA4B,OAAO;YASpC,aACR,OAAO,MACL,cACA,QACA,aAAa,cAAc,aAC3B,YAEF,SAAS,6BACP,cACA,QACA,OACA,WACA,cAED,4BAA4B,OAAO;;KAiCnC,kBACH,sBAAsB,MAAM,wBAC5B,eACM,MAAM,WAAW,eAAe"}
|
|
@@ -21,7 +21,7 @@ type InfiniteQueryObserverListener<TData, TError> = (result: InfiniteQueryObserv
|
|
|
21
21
|
* const unsubscribe = observer.subscribe((result) => console.log(result))
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
|
-
declare class InfiniteQueryObserver<TQueryFnData = unknown, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> extends QueryObserver<TQueryFnData, TError, TData, InfiniteData<TQueryFnData, TPageParam>, TQueryKey> {
|
|
24
|
+
export declare class InfiniteQueryObserver<TQueryFnData = unknown, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown> extends QueryObserver<TQueryFnData, TError, TData, InfiniteData<TQueryFnData, TPageParam>, TQueryKey> {
|
|
25
25
|
subscribe: Subscribable<InfiniteQueryObserverListener<TData, TError>>['subscribe'];
|
|
26
26
|
getCurrentResult: ReplaceReturnType<QueryObserver<TQueryFnData, TError, TData, InfiniteData<TQueryFnData, TPageParam>, TQueryKey>['getCurrentResult'], InfiniteQueryObserverResult<TData, TError>>;
|
|
27
27
|
protected fetch: ReplaceReturnType<QueryObserver<TQueryFnData, TError, TData, InfiniteData<TQueryFnData, TPageParam>, TQueryKey>['fetch'], Promise<InfiniteQueryObserverResult<TData, TError>>>;
|
|
@@ -83,5 +83,4 @@ declare class InfiniteQueryObserver<TQueryFnData = unknown, TError = DefaultErro
|
|
|
83
83
|
}
|
|
84
84
|
type ReplaceReturnType<TFunction extends (...args: Array<any>) => unknown, TReturn> = (...args: Parameters<TFunction>) => TReturn;
|
|
85
85
|
//#endregion
|
|
86
|
-
export { InfiniteQueryObserver };
|
|
87
86
|
//# sourceMappingURL=infiniteQueryObserver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"infiniteQueryObserver.d.ts","names":[],"sources":["../../src/infiniteQueryObserver.ts"],"mappings":";;;KAiBK,8BAA8B,OAAO,WACxC,QAAQ,4BAA4B,OAAO;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"infiniteQueryObserver.d.ts","names":[],"sources":["../../src/infiniteQueryObserver.ts"],"mappings":";;;KAiBK,8BAA8B,OAAO,WACxC,QAAQ,4BAA4B,OAAO;;;;;;;;;;;;;;;;;;;;qBAsBhC,sBACX,wBACA,SAAS,cACT,QAAQ,aAAa,eACrB,kBAAkB,WAAW,UAC7B,8BACQ,cACR,cACA,QACA,OACA,aAAa,cAAc,aAC3B;EAGA,WAAY,aACV,8BAA8B,OAAO;EAIvC,kBAAmB,kBACjB,cACE,cACA,QACA,OACA,aAAa,cAAc,aAC3B,gCAEF,4BAA4B,OAAO;YAI3B,OAAQ,kBAChB,cACE,cACA,QACA,OACA,aAAa,cAAc,aAC3B,qBAEF,QAAQ,4BAA4B,OAAO;EAI3C,YAAA,QAAQ,aACR,SAAS,6BACP,cACA,QACA,OACA,WACA;YAMM;;;;;;;EAYV,WACE,SAAS,6BACP,cACA,QACA,OACA,WACA;;;;;;;EAaJ,oBACE,SAAS,sCACP,cACA,QACA,OACA,WACA,cAED,4BAA4B,OAAO;;;;;;;;;;;;;;;;;;;EA0BtC,cACE,UAAU,uBACT,QAAQ,4BAA4B,OAAO;;;;;;;;;;;;;;;;;;;EA2B9C,kBACE,UAAU,2BACT,QAAQ,4BAA4B,OAAO;YASpC,aACR,OAAO,MACL,cACA,QACA,aAAa,cAAc,aAC3B,YAEF,SAAS,6BACP,cACA,QACA,OACA,WACA,cAED,4BAA4B,OAAO;;KAiCnC,kBACH,sBAAsB,MAAM,wBAC5B,eACM,MAAM,WAAW,eAAe"}
|
|
@@ -8,8 +8,8 @@ type ScheduleFunction = (callback: () => void) => void;
|
|
|
8
8
|
* Default scheduling function used by the notify manager.
|
|
9
9
|
* Schedules the callback with the system's `setTimeout(callback, 0)`.
|
|
10
10
|
*/
|
|
11
|
-
declare const defaultScheduler: ScheduleFunction;
|
|
12
|
-
declare function createNotifyManager(): {
|
|
11
|
+
export declare const defaultScheduler: ScheduleFunction;
|
|
12
|
+
export declare function createNotifyManager(): {
|
|
13
13
|
/**
|
|
14
14
|
* Batches all updates scheduled inside the passed callback.
|
|
15
15
|
* This is mainly used internally to optimize query client updating.
|
|
@@ -68,7 +68,7 @@ declare function createNotifyManager(): {
|
|
|
68
68
|
/**
|
|
69
69
|
* Handles scheduling and batching callbacks in TanStack Query.
|
|
70
70
|
*/
|
|
71
|
-
declare const notifyManager: {
|
|
71
|
+
export declare const notifyManager: {
|
|
72
72
|
/**
|
|
73
73
|
* Batches all updates scheduled inside the passed callback.
|
|
74
74
|
* This is mainly used internally to optimize query client updating.
|
|
@@ -125,5 +125,4 @@ declare const notifyManager: {
|
|
|
125
125
|
readonly setScheduler: (fn: ScheduleFunction) => void;
|
|
126
126
|
};
|
|
127
127
|
//#endregion
|
|
128
|
-
export { createNotifyManager, defaultScheduler, notifyManager };
|
|
129
128
|
//# sourceMappingURL=notifyManager.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifyManager.d.cts","names":[],"sources":["../../src/notifyManager.ts"],"mappings":";KAIK;KAEA,kBAAkB;KAElB,uBAAuB;KAEvB,mBAAmB,UAAU,sBAAsB,MAAM;KAEzD,oBAAoB;;;;;
|
|
1
|
+
{"version":3,"file":"notifyManager.d.cts","names":[],"sources":["../../src/notifyManager.ts"],"mappings":";KAIK;KAEA,kBAAkB;KAElB,uBAAuB;KAEvB,mBAAmB,UAAU,sBAAsB,MAAM;KAEzD,oBAAoB;;;;;qBAMZ,kBAAkB;wBAEf;;;;;;;WAyCJ,QAAA,GAAC,gBAAkB,MAAI;;;;WAgBlB,aAAA,UAAU,gBAAc,UACzB,mBAAmB,OAC5B,mBAAmB;;;;;WAhDI,WAAA,UAAA;;;;;WAgEF,oBAAA,IAAA;;;;;;;;;;;;;;WAgBK,yBAAA,IAAA;;;;;;;;;;;;;;;;;;;WAqBV,eAAA,IAAA;;;;;qBAWV;;;;;;;WAlFD,QAAA,GAAC,gBAAkB,MAAI;;;;WAgBlB,aAAA,UAAU,gBAAc,UACzB,mBAAmB,OAC5B,mBAAmB;;;;;WAhDI,WAAA,UAAA;;;;;WAgEF,oBAAA,IAAA;;;;;;;;;;;;;;WAgBK,yBAAA,IAAA;;;;;;;;;;;;;;;;;;;WAqBV,eAAA,IAAA"}
|
|
@@ -8,8 +8,8 @@ type ScheduleFunction = (callback: () => void) => void;
|
|
|
8
8
|
* Default scheduling function used by the notify manager.
|
|
9
9
|
* Schedules the callback with the system's `setTimeout(callback, 0)`.
|
|
10
10
|
*/
|
|
11
|
-
declare const defaultScheduler: ScheduleFunction;
|
|
12
|
-
declare function createNotifyManager(): {
|
|
11
|
+
export declare const defaultScheduler: ScheduleFunction;
|
|
12
|
+
export declare function createNotifyManager(): {
|
|
13
13
|
/**
|
|
14
14
|
* Batches all updates scheduled inside the passed callback.
|
|
15
15
|
* This is mainly used internally to optimize query client updating.
|
|
@@ -68,7 +68,7 @@ declare function createNotifyManager(): {
|
|
|
68
68
|
/**
|
|
69
69
|
* Handles scheduling and batching callbacks in TanStack Query.
|
|
70
70
|
*/
|
|
71
|
-
declare const notifyManager: {
|
|
71
|
+
export declare const notifyManager: {
|
|
72
72
|
/**
|
|
73
73
|
* Batches all updates scheduled inside the passed callback.
|
|
74
74
|
* This is mainly used internally to optimize query client updating.
|
|
@@ -125,5 +125,4 @@ declare const notifyManager: {
|
|
|
125
125
|
readonly setScheduler: (fn: ScheduleFunction) => void;
|
|
126
126
|
};
|
|
127
127
|
//#endregion
|
|
128
|
-
export { createNotifyManager, defaultScheduler, notifyManager };
|
|
129
128
|
//# sourceMappingURL=notifyManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifyManager.d.ts","names":[],"sources":["../../src/notifyManager.ts"],"mappings":";KAIK;KAEA,kBAAkB;KAElB,uBAAuB;KAEvB,mBAAmB,UAAU,sBAAsB,MAAM;KAEzD,oBAAoB;;;;;
|
|
1
|
+
{"version":3,"file":"notifyManager.d.ts","names":[],"sources":["../../src/notifyManager.ts"],"mappings":";KAIK;KAEA,kBAAkB;KAElB,uBAAuB;KAEvB,mBAAmB,UAAU,sBAAsB,MAAM;KAEzD,oBAAoB;;;;;qBAMZ,kBAAkB;wBAEf;;;;;;;WAyCJ,QAAA,GAAC,gBAAkB,MAAI;;;;WAgBlB,aAAA,UAAU,gBAAc,UACzB,mBAAmB,OAC5B,mBAAmB;;;;;WAhDI,WAAA,UAAA;;;;;WAgEF,oBAAA,IAAA;;;;;;;;;;;;;;WAgBK,yBAAA,IAAA;;;;;;;;;;;;;;;;;;;WAqBV,eAAA,IAAA;;;;;qBAWV;;;;;;;WAlFD,QAAA,GAAC,gBAAkB,MAAI;;;;WAgBlB,aAAA,UAAU,gBAAc,UACzB,mBAAmB,OAC5B,mBAAmB;;;;;WAhDI,WAAA,UAAA;;;;;WAgEF,oBAAA,IAAA;;;;;;;;;;;;;;WAgBK,yBAAA,IAAA;;;;;;;;;;;;;;;;;;;WAqBV,eAAA,IAAA"}
|
|
@@ -11,7 +11,7 @@ type SetupFn = (setOnline: Listener) => (() => void) | undefined;
|
|
|
11
11
|
* listens to the `online` and `offline` events on the `window` object to
|
|
12
12
|
* detect changes.
|
|
13
13
|
*/
|
|
14
|
-
declare class OnlineManager extends Subscribable<Listener> {
|
|
14
|
+
export declare class OnlineManager extends Subscribable<Listener> {
|
|
15
15
|
#private;
|
|
16
16
|
constructor();
|
|
17
17
|
protected onSubscribe(): void;
|
|
@@ -58,7 +58,6 @@ declare class OnlineManager extends Subscribable<Listener> {
|
|
|
58
58
|
/**
|
|
59
59
|
* Singleton instance of {@link OnlineManager}, used to manage and observe the online state within TanStack Query.
|
|
60
60
|
*/
|
|
61
|
-
declare const onlineManager: OnlineManager;
|
|
61
|
+
export declare const onlineManager: OnlineManager;
|
|
62
62
|
//#endregion
|
|
63
|
-
export { OnlineManager, onlineManager };
|
|
64
63
|
//# sourceMappingURL=onlineManager.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"onlineManager.d.cts","names":[],"sources":["../../src/onlineManager.ts"],"mappings":";;KAEK,YAAY;KACZ,WAAW,WAAW;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"onlineManager.d.cts","names":[],"sources":["../../src/onlineManager.ts"],"mappings":";;KAEK,YAAY;KACZ,WAAW,WAAW;;;;;;;;;;qBAWd,sBAAsB,aAAa;;;YA6BpC;YAMA;;;;;;;;;;;;;;;;;;;EAyBV,iBAAiB,OAAO;;;;;;;;;;;;;;;EAoBxB,UAAU;;;;EAcV;;;;;qBAQW,eAAa"}
|
|
@@ -11,7 +11,7 @@ type SetupFn = (setOnline: Listener) => (() => void) | undefined;
|
|
|
11
11
|
* listens to the `online` and `offline` events on the `window` object to
|
|
12
12
|
* detect changes.
|
|
13
13
|
*/
|
|
14
|
-
declare class OnlineManager extends Subscribable<Listener> {
|
|
14
|
+
export declare class OnlineManager extends Subscribable<Listener> {
|
|
15
15
|
#private;
|
|
16
16
|
constructor();
|
|
17
17
|
protected onSubscribe(): void;
|
|
@@ -58,7 +58,6 @@ declare class OnlineManager extends Subscribable<Listener> {
|
|
|
58
58
|
/**
|
|
59
59
|
* Singleton instance of {@link OnlineManager}, used to manage and observe the online state within TanStack Query.
|
|
60
60
|
*/
|
|
61
|
-
declare const onlineManager: OnlineManager;
|
|
61
|
+
export declare const onlineManager: OnlineManager;
|
|
62
62
|
//#endregion
|
|
63
|
-
export { OnlineManager, onlineManager };
|
|
64
63
|
//# sourceMappingURL=onlineManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"onlineManager.d.ts","names":[],"sources":["../../src/onlineManager.ts"],"mappings":";;KAEK,YAAY;KACZ,WAAW,WAAW;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"onlineManager.d.ts","names":[],"sources":["../../src/onlineManager.ts"],"mappings":";;KAEK,YAAY;KACZ,WAAW,WAAW;;;;;;;;;;qBAWd,sBAAsB,aAAa;;;YA6BpC;YAMA;;;;;;;;;;;;;;;;;;;EAyBV,iBAAiB,OAAO;;;;;;;;;;;;;;;EAoBxB,UAAU;;;;EAcV;;;;;qBAQW,eAAa"}
|
|
@@ -3,7 +3,7 @@ import { $n as Query, At as QueryObserverOptions, Pt as QueryObserverResult, on
|
|
|
3
3
|
//#region src/queriesObserver.d.ts
|
|
4
4
|
type QueriesObserverListener = (result: Array<QueryObserverResult>) => void;
|
|
5
5
|
type CombineFn<TCombinedResult> = (result: Array<QueryObserverResult>) => TCombinedResult;
|
|
6
|
-
interface QueriesObserverOptions<TCombinedResult = Array<QueryObserverResult>> {
|
|
6
|
+
export interface QueriesObserverOptions<TCombinedResult = Array<QueryObserverResult>> {
|
|
7
7
|
/**
|
|
8
8
|
* A function that combines the array of `QueryObserverResult`s (one per
|
|
9
9
|
* observed query) into a single value. The combined value is memoized and
|
|
@@ -33,7 +33,7 @@ interface QueriesObserverOptions<TCombinedResult = Array<QueryObserverResult>> {
|
|
|
33
33
|
* })
|
|
34
34
|
* ```
|
|
35
35
|
*/
|
|
36
|
-
declare class QueriesObserver<TCombinedResult = Array<QueryObserverResult>> extends Subscribable<QueriesObserverListener> {
|
|
36
|
+
export declare class QueriesObserver<TCombinedResult = Array<QueryObserverResult>> extends Subscribable<QueriesObserverListener> {
|
|
37
37
|
#private;
|
|
38
38
|
constructor(client: QueryClient, queries: Array<QueryObserverOptions<any, any, any, any, any>>, options?: QueriesObserverOptions<TCombinedResult>);
|
|
39
39
|
protected onSubscribe(): void;
|
|
@@ -91,5 +91,4 @@ declare class QueriesObserver<TCombinedResult = Array<QueryObserverResult>> exte
|
|
|
91
91
|
getOptimisticResult(queries: Array<QueryObserverOptions>, combine: CombineFn<TCombinedResult> | undefined): [rawResult: Array<QueryObserverResult>, combineResult: (r?: Array<QueryObserverResult>) => TCombinedResult, trackResult: () => Array<QueryObserverResult>];
|
|
92
92
|
}
|
|
93
93
|
//#endregion
|
|
94
|
-
export { QueriesObserver, QueriesObserverOptions };
|
|
95
94
|
//# sourceMappingURL=queriesObserver.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queriesObserver.d.cts","names":["_$__query0.Query"],"sources":["../../src/queriesObserver.ts"],"mappings":";;;KAgBK,2BAA2B,QAAQ,MAAM;KAEzC,UAAU,oBACb,QAAQ,MAAM,yBACX;
|
|
1
|
+
{"version":3,"file":"queriesObserver.d.cts","names":["_$__query0.Query"],"sources":["../../src/queriesObserver.ts"],"mappings":";;;KAgBK,2BAA2B,QAAQ,MAAM;KAEzC,UAAU,oBACb,QAAQ,MAAM,yBACX;iBAEY,uBACf,kBAAkB,MAAM;;;;;;;;;EAUxB,UAAU,UAAU;;;;;;;;;;;;;;;;;;;;;qBAsBT,gBACX,kBAAkB,MAAM,8BAChB,aAAa;;EAanB,YAAA,QAAQ,aACR,SAAS,MAAM,gDACf,UAAU,uBAAuB;YAazB;YAUA;;;;;EAUV;;;;;;;;;;;;;;;EAqBA,WACE,SAAS,MAAM,uBACf,UAAU,uBAAuB;;;;;;;;;;;;EAiFnC,oBAAoB,MAAM;;;;;EAQ1B,cAAUA,eAAA;;;;;;EASV,gBAAY,uBAAA;;;;;;;;EAWZ,oBACE,SAAS,MAAM,uBACf,SAAS,UAAU,gCAEnB,WAAW,MAAM,sBACjB,gBAAgB,IAAI,MAAM,yBAAyB,iBACnD,mBAAmB,MAAM"}
|
|
@@ -3,7 +3,7 @@ import { $n as Query, At as QueryObserverOptions, Pt as QueryObserverResult, on
|
|
|
3
3
|
//#region src/queriesObserver.d.ts
|
|
4
4
|
type QueriesObserverListener = (result: Array<QueryObserverResult>) => void;
|
|
5
5
|
type CombineFn<TCombinedResult> = (result: Array<QueryObserverResult>) => TCombinedResult;
|
|
6
|
-
interface QueriesObserverOptions<TCombinedResult = Array<QueryObserverResult>> {
|
|
6
|
+
export interface QueriesObserverOptions<TCombinedResult = Array<QueryObserverResult>> {
|
|
7
7
|
/**
|
|
8
8
|
* A function that combines the array of `QueryObserverResult`s (one per
|
|
9
9
|
* observed query) into a single value. The combined value is memoized and
|
|
@@ -33,7 +33,7 @@ interface QueriesObserverOptions<TCombinedResult = Array<QueryObserverResult>> {
|
|
|
33
33
|
* })
|
|
34
34
|
* ```
|
|
35
35
|
*/
|
|
36
|
-
declare class QueriesObserver<TCombinedResult = Array<QueryObserverResult>> extends Subscribable<QueriesObserverListener> {
|
|
36
|
+
export declare class QueriesObserver<TCombinedResult = Array<QueryObserverResult>> extends Subscribable<QueriesObserverListener> {
|
|
37
37
|
#private;
|
|
38
38
|
constructor(client: QueryClient, queries: Array<QueryObserverOptions<any, any, any, any, any>>, options?: QueriesObserverOptions<TCombinedResult>);
|
|
39
39
|
protected onSubscribe(): void;
|
|
@@ -91,5 +91,4 @@ declare class QueriesObserver<TCombinedResult = Array<QueryObserverResult>> exte
|
|
|
91
91
|
getOptimisticResult(queries: Array<QueryObserverOptions>, combine: CombineFn<TCombinedResult> | undefined): [rawResult: Array<QueryObserverResult>, combineResult: (r?: Array<QueryObserverResult>) => TCombinedResult, trackResult: () => Array<QueryObserverResult>];
|
|
92
92
|
}
|
|
93
93
|
//#endregion
|
|
94
|
-
export { QueriesObserver, QueriesObserverOptions };
|
|
95
94
|
//# sourceMappingURL=queriesObserver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queriesObserver.d.ts","names":["_$__query0.Query"],"sources":["../../src/queriesObserver.ts"],"mappings":";;;KAgBK,2BAA2B,QAAQ,MAAM;KAEzC,UAAU,oBACb,QAAQ,MAAM,yBACX;
|
|
1
|
+
{"version":3,"file":"queriesObserver.d.ts","names":["_$__query0.Query"],"sources":["../../src/queriesObserver.ts"],"mappings":";;;KAgBK,2BAA2B,QAAQ,MAAM;KAEzC,UAAU,oBACb,QAAQ,MAAM,yBACX;iBAEY,uBACf,kBAAkB,MAAM;;;;;;;;;EAUxB,UAAU,UAAU;;;;;;;;;;;;;;;;;;;;;qBAsBT,gBACX,kBAAkB,MAAM,8BAChB,aAAa;;EAanB,YAAA,QAAQ,aACR,SAAS,MAAM,gDACf,UAAU,uBAAuB;YAazB;YAUA;;;;;EAUV;;;;;;;;;;;;;;;EAqBA,WACE,SAAS,MAAM,uBACf,UAAU,uBAAuB;;;;;;;;;;;;EAiFnC,oBAAoB,MAAM;;;;;EAQ1B,cAAUA,eAAA;;;;;;EASV,gBAAY,uBAAA;;;;;;;;EAWZ,oBACE,SAAS,MAAM,uBACf,SAAS,UAAU,gCAEnB,WAAW,MAAM,sBACjB,gBAAgB,IAAI,MAAM,yBAAyB,iBACnD,mBAAmB,MAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamedQuery.cjs","names":["addToEnd","addConsumeAwareSignal"],"sources":["../../src/streamedQuery.ts"],"sourcesContent":["import { addConsumeAwareSignal, addToEnd } from './utils'\nimport type {\n OmitKeyof,\n QueryFunction,\n QueryFunctionContext,\n QueryKey,\n} from './types'\n\ntype BaseStreamedQueryParams<TQueryFnData, TQueryKey extends QueryKey> = {\n /** The function that returns an `AsyncIterable` to stream data from. */\n streamFn: (\n context: QueryFunctionContext<TQueryKey>,\n ) => AsyncIterable<TQueryFnData> | Promise<AsyncIterable<TQueryFnData>>\n /**\n * Defines how refetches are handled.\n * - `'reset'` (default): erases all data and puts the query back into `pending` state.\n * - `'append'`: appends new data to the existing data.\n * - `'replace'`: writes all data to the cache once the stream ends.\n */\n refetchMode?: 'append' | 'reset' | 'replace'\n}\n\ntype SimpleStreamedQueryParams<\n TQueryFnData,\n TQueryKey extends QueryKey,\n> = BaseStreamedQueryParams<TQueryFnData, TQueryKey> & {\n reducer?: never\n initialValue?: never\n}\n\ntype ReducibleStreamedQueryParams<\n TQueryFnData,\n TData,\n TQueryKey extends QueryKey,\n> = BaseStreamedQueryParams<TQueryFnData, TQueryKey> & {\n /**\n * Reduces streamed chunks into the final data shape. Required whenever `TData` is not an\n * array, since there is no default way to accumulate non-array chunks.\n */\n reducer: (acc: TData, chunk: TQueryFnData) => TData\n /**\n * The value used while the first chunk is being fetched, and returned if the stream yields no\n * values. Required together with a custom `reducer`.\n */\n initialValue: TData\n}\n\ntype StreamedQueryParams<TQueryFnData, TData, TQueryKey extends QueryKey> =\n | SimpleStreamedQueryParams<TQueryFnData, TQueryKey>\n | ReducibleStreamedQueryParams<TQueryFnData, TData, TQueryKey>\n\n/**\n * This is a helper function to create a query function that streams data from an AsyncIterable.\n * Data will be an Array of all the chunks received.\n * The query will be in a 'pending' state until the first chunk of data is received, but will go to 'success' after that.\n * The query will stay in fetchStatus 'fetching' until the stream ends.\n * @param streamFn - The function that returns an AsyncIterable to stream data from.\n * @example\n * ```ts\n * await queryClient.query({\n * queryKey: ['data'],\n * queryFn: streamedQuery({\n * streamFn: fetchDataInChunks,\n * }),\n * })\n * ```\n */\nexport function streamedQuery<\n TQueryFnData = unknown,\n TData = Array<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n>({\n streamFn,\n refetchMode = 'reset',\n reducer = (items, chunk) =>\n addToEnd(items as Array<TQueryFnData>, chunk) as TData,\n initialValue = [] as TData,\n}: StreamedQueryParams<TQueryFnData, TData, TQueryKey>): QueryFunction<\n TData,\n TQueryKey\n> {\n return async (context) => {\n const query = context.client\n .getQueryCache()\n .find({ queryKey: context.queryKey, exact: true })\n const isRefetch = !!query && query.isFetched()\n if (isRefetch && refetchMode === 'reset') {\n query.setState({\n ...query.resetState,\n fetchStatus: 'fetching',\n })\n }\n\n let result = initialValue\n\n let cancelled: boolean = false as boolean\n const streamFnContext = addConsumeAwareSignal<\n OmitKeyof<typeof context, 'signal'>\n >(\n {\n client: context.client,\n meta: context.meta,\n queryKey: context.queryKey,\n pageParam: context.pageParam,\n direction: context.direction,\n },\n () => context.signal,\n () => (cancelled = true),\n )\n\n const stream = await streamFn(streamFnContext)\n\n const isReplaceRefetch = isRefetch && refetchMode === 'replace'\n\n for await (const chunk of stream) {\n if (cancelled) {\n break\n }\n\n if (isReplaceRefetch) {\n // don't append to the cache directly when replace-refetching\n result = reducer(result, chunk)\n } else {\n context.client.setQueryData<TData>(context.queryKey, (prev) =>\n reducer(prev === undefined ? initialValue : prev, chunk),\n )\n }\n }\n\n // finalize result: replace-refetching needs to write to the cache\n if (isReplaceRefetch && !cancelled) {\n context.client.setQueryData<TData>(context.queryKey, result)\n }\n\n const data = context.client.getQueryData<TData>(context.queryKey)\n return data === undefined ? initialValue : data\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmEA,SAAgB,cAId,EACA,UACA,cAAc,SACd,WAAW,OAAO,UAChBA,cAAAA,SAAS,OAA8B,KAAK,GAC9C,eAAe,CAAC,KAIhB;CACA,OAAO,OAAO,YAAY;EACxB,MAAM,QAAQ,QAAQ,OACnB,cAAc,CAAC,CACf,KAAK;GAAE,UAAU,QAAQ;GAAU,OAAO;EAAK,CAAC;EACnD,MAAM,YAAY,CAAC,CAAC,SAAS,MAAM,UAAU;EAC7C,IAAI,aAAa,gBAAgB,SAC/B,MAAM,SAAS;GACb,GAAG,MAAM;GACT,aAAa;EACf,CAAC;EAGH,IAAI,SAAS;
|
|
1
|
+
{"version":3,"file":"streamedQuery.cjs","names":["addToEnd","addConsumeAwareSignal"],"sources":["../../src/streamedQuery.ts"],"sourcesContent":["import { addConsumeAwareSignal, addToEnd } from './utils'\nimport type {\n OmitKeyof,\n QueryFunction,\n QueryFunctionContext,\n QueryKey,\n} from './types'\n\ntype BaseStreamedQueryParams<TQueryFnData, TQueryKey extends QueryKey> = {\n /** The function that returns an `AsyncIterable` to stream data from. */\n streamFn: (\n context: QueryFunctionContext<TQueryKey>,\n ) => AsyncIterable<TQueryFnData> | Promise<AsyncIterable<TQueryFnData>>\n /**\n * Defines how refetches are handled.\n * - `'reset'` (default): erases all data and puts the query back into `pending` state.\n * - `'append'`: appends new data to the existing data.\n * - `'replace'`: writes all data to the cache once the stream ends.\n */\n refetchMode?: 'append' | 'reset' | 'replace'\n}\n\ntype SimpleStreamedQueryParams<\n TQueryFnData,\n TQueryKey extends QueryKey,\n> = BaseStreamedQueryParams<TQueryFnData, TQueryKey> & {\n reducer?: never\n initialValue?: never\n}\n\ntype ReducibleStreamedQueryParams<\n TQueryFnData,\n TData,\n TQueryKey extends QueryKey,\n> = BaseStreamedQueryParams<TQueryFnData, TQueryKey> & {\n /**\n * Reduces streamed chunks into the final data shape. Required whenever `TData` is not an\n * array, since there is no default way to accumulate non-array chunks.\n */\n reducer: (acc: TData, chunk: TQueryFnData) => TData\n /**\n * The value used while the first chunk is being fetched, and returned if the stream yields no\n * values. Required together with a custom `reducer`.\n */\n initialValue: TData\n}\n\ntype StreamedQueryParams<TQueryFnData, TData, TQueryKey extends QueryKey> =\n | SimpleStreamedQueryParams<TQueryFnData, TQueryKey>\n | ReducibleStreamedQueryParams<TQueryFnData, TData, TQueryKey>\n\n/**\n * This is a helper function to create a query function that streams data from an AsyncIterable.\n * Data will be an Array of all the chunks received.\n * The query will be in a 'pending' state until the first chunk of data is received, but will go to 'success' after that.\n * The query will stay in fetchStatus 'fetching' until the stream ends.\n * @param streamFn - The function that returns an AsyncIterable to stream data from.\n * @example\n * ```ts\n * await queryClient.query({\n * queryKey: ['data'],\n * queryFn: streamedQuery({\n * streamFn: fetchDataInChunks,\n * }),\n * })\n * ```\n */\nexport function streamedQuery<\n TQueryFnData = unknown,\n TData = Array<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n>({\n streamFn,\n refetchMode = 'reset',\n reducer = (items, chunk) =>\n addToEnd(items as Array<TQueryFnData>, chunk) as TData,\n initialValue = [] as TData,\n}: StreamedQueryParams<TQueryFnData, TData, TQueryKey>): QueryFunction<\n TData,\n TQueryKey\n> {\n return async (context) => {\n const query = context.client\n .getQueryCache()\n .find({ queryKey: context.queryKey, exact: true })\n const isRefetch = !!query && query.isFetched()\n if (isRefetch && refetchMode === 'reset') {\n query.setState({\n ...query.resetState,\n fetchStatus: 'fetching',\n })\n }\n\n let result = initialValue\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n let cancelled: boolean = false as boolean\n const streamFnContext = addConsumeAwareSignal<\n OmitKeyof<typeof context, 'signal'>\n >(\n {\n client: context.client,\n meta: context.meta,\n queryKey: context.queryKey,\n pageParam: context.pageParam,\n direction: context.direction,\n },\n () => context.signal,\n () => (cancelled = true),\n )\n\n const stream = await streamFn(streamFnContext)\n\n const isReplaceRefetch = isRefetch && refetchMode === 'replace'\n\n for await (const chunk of stream) {\n if (cancelled) {\n break\n }\n\n if (isReplaceRefetch) {\n // don't append to the cache directly when replace-refetching\n result = reducer(result, chunk)\n } else {\n context.client.setQueryData<TData>(context.queryKey, (prev) =>\n reducer(prev === undefined ? initialValue : prev, chunk),\n )\n }\n }\n\n // finalize result: replace-refetching needs to write to the cache\n if (isReplaceRefetch && !cancelled) {\n context.client.setQueryData<TData>(context.queryKey, result)\n }\n\n const data = context.client.getQueryData<TData>(context.queryKey)\n return data === undefined ? initialValue : data\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmEA,SAAgB,cAId,EACA,UACA,cAAc,SACd,WAAW,OAAO,UAChBA,cAAAA,SAAS,OAA8B,KAAK,GAC9C,eAAe,CAAC,KAIhB;CACA,OAAO,OAAO,YAAY;EACxB,MAAM,QAAQ,QAAQ,OACnB,cAAc,CAAC,CACf,KAAK;GAAE,UAAU,QAAQ;GAAU,OAAO;EAAK,CAAC;EACnD,MAAM,YAAY,CAAC,CAAC,SAAS,MAAM,UAAU;EAC7C,IAAI,aAAa,gBAAgB,SAC/B,MAAM,SAAS;GACb,GAAG,MAAM;GACT,aAAa;EACf,CAAC;EAGH,IAAI,SAAS;EAGb,IAAI,YAAqB;EAezB,MAAM,SAAS,MAAM,SAdGC,cAAAA,sBAGtB;GACE,QAAQ,QAAQ;GAChB,MAAM,QAAQ;GACd,UAAU,QAAQ;GAClB,WAAW,QAAQ;GACnB,WAAW,QAAQ;EACrB,SACM,QAAQ,cACP,YAAY,IAGuB,CAAC;EAE7C,MAAM,mBAAmB,aAAa,gBAAgB;EAEtD,WAAW,MAAM,SAAS,QAAQ;GAChC,IAAI,WACF;GAGF,IAAI,kBAEF,SAAS,QAAQ,QAAQ,KAAK;QAE9B,QAAQ,OAAO,aAAoB,QAAQ,WAAW,SACpD,QAAQ,SAAS,KAAA,IAAY,eAAe,MAAM,KAAK,CACzD;EAEJ;EAGA,IAAI,oBAAoB,CAAC,WACvB,QAAQ,OAAO,aAAoB,QAAQ,UAAU,MAAM;EAG7D,MAAM,OAAO,QAAQ,OAAO,aAAoB,QAAQ,QAAQ;EAChE,OAAO,SAAS,KAAA,IAAY,eAAe;CAC7C;AACF"}
|
|
@@ -44,7 +44,6 @@ type StreamedQueryParams<TQueryFnData, TData, TQueryKey extends QueryKey> = Simp
|
|
|
44
44
|
* })
|
|
45
45
|
* ```
|
|
46
46
|
*/
|
|
47
|
-
declare function streamedQuery<TQueryFnData = unknown, TData = Array<TQueryFnData>, TQueryKey extends QueryKey = QueryKey>({ streamFn, refetchMode, reducer, initialValue }: StreamedQueryParams<TQueryFnData, TData, TQueryKey>): QueryFunction<TData, TQueryKey>;
|
|
47
|
+
export declare function streamedQuery<TQueryFnData = unknown, TData = Array<TQueryFnData>, TQueryKey extends QueryKey = QueryKey>({ streamFn, refetchMode, reducer, initialValue }: StreamedQueryParams<TQueryFnData, TData, TQueryKey>): QueryFunction<TData, TQueryKey>;
|
|
48
48
|
//#endregion
|
|
49
|
-
export { streamedQuery };
|
|
50
49
|
//# sourceMappingURL=streamedQuery.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamedQuery.d.cts","names":[],"sources":["../../src/streamedQuery.ts"],"mappings":";;KAQK,wBAAwB,cAAc,kBAAkB;;EAE3D,WACE,SAAS,qBAAqB,eAC3B,cAAc,gBAAgB,QAAQ,cAAc;;;;;;;EAOzD;;KAGG,0BACH,cACA,kBAAkB,YAChB,wBAAwB,cAAc;EACxC;EACA;;KAGG,6BACH,cACA,OACA,kBAAkB,YAChB,wBAAwB,cAAc;;;;;EAKxC,UAAU,KAAK,OAAO,OAAO,iBAAiB;;;;;EAK9C,cAAc;;KAGX,oBAAoB,cAAc,OAAO,kBAAkB,YAC5D,0BAA0B,cAAc,aACxC,6BAA6B,cAAc,OAAO;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"streamedQuery.d.cts","names":[],"sources":["../../src/streamedQuery.ts"],"mappings":";;KAQK,wBAAwB,cAAc,kBAAkB;;EAE3D,WACE,SAAS,qBAAqB,eAC3B,cAAc,gBAAgB,QAAQ,cAAc;;;;;;;EAOzD;;KAGG,0BACH,cACA,kBAAkB,YAChB,wBAAwB,cAAc;EACxC;EACA;;KAGG,6BACH,cACA,OACA,kBAAkB,YAChB,wBAAwB,cAAc;;;;;EAKxC,UAAU,KAAK,OAAO,OAAO,iBAAiB;;;;;EAK9C,cAAc;;KAGX,oBAAoB,cAAc,OAAO,kBAAkB,YAC5D,0BAA0B,cAAc,aACxC,6BAA6B,cAAc,OAAO;;;;;;;;;;;;;;;;;wBAkBtC,cACd,wBACA,QAAQ,MAAM,eACd,kBAAkB,WAAW,YAE7B,UACA,aACA,SAEA,gBACC,oBAAoB,cAAc,OAAO,aAAa,cACvD,OACA"}
|
|
@@ -44,7 +44,6 @@ type StreamedQueryParams<TQueryFnData, TData, TQueryKey extends QueryKey> = Simp
|
|
|
44
44
|
* })
|
|
45
45
|
* ```
|
|
46
46
|
*/
|
|
47
|
-
declare function streamedQuery<TQueryFnData = unknown, TData = Array<TQueryFnData>, TQueryKey extends QueryKey = QueryKey>({ streamFn, refetchMode, reducer, initialValue }: StreamedQueryParams<TQueryFnData, TData, TQueryKey>): QueryFunction<TData, TQueryKey>;
|
|
47
|
+
export declare function streamedQuery<TQueryFnData = unknown, TData = Array<TQueryFnData>, TQueryKey extends QueryKey = QueryKey>({ streamFn, refetchMode, reducer, initialValue }: StreamedQueryParams<TQueryFnData, TData, TQueryKey>): QueryFunction<TData, TQueryKey>;
|
|
48
48
|
//#endregion
|
|
49
|
-
export { streamedQuery };
|
|
50
49
|
//# sourceMappingURL=streamedQuery.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamedQuery.d.ts","names":[],"sources":["../../src/streamedQuery.ts"],"mappings":";;KAQK,wBAAwB,cAAc,kBAAkB;;EAE3D,WACE,SAAS,qBAAqB,eAC3B,cAAc,gBAAgB,QAAQ,cAAc;;;;;;;EAOzD;;KAGG,0BACH,cACA,kBAAkB,YAChB,wBAAwB,cAAc;EACxC;EACA;;KAGG,6BACH,cACA,OACA,kBAAkB,YAChB,wBAAwB,cAAc;;;;;EAKxC,UAAU,KAAK,OAAO,OAAO,iBAAiB;;;;;EAK9C,cAAc;;KAGX,oBAAoB,cAAc,OAAO,kBAAkB,YAC5D,0BAA0B,cAAc,aACxC,6BAA6B,cAAc,OAAO;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"streamedQuery.d.ts","names":[],"sources":["../../src/streamedQuery.ts"],"mappings":";;KAQK,wBAAwB,cAAc,kBAAkB;;EAE3D,WACE,SAAS,qBAAqB,eAC3B,cAAc,gBAAgB,QAAQ,cAAc;;;;;;;EAOzD;;KAGG,0BACH,cACA,kBAAkB,YAChB,wBAAwB,cAAc;EACxC;EACA;;KAGG,6BACH,cACA,OACA,kBAAkB,YAChB,wBAAwB,cAAc;;;;;EAKxC,UAAU,KAAK,OAAO,OAAO,iBAAiB;;;;;EAK9C,cAAc;;KAGX,oBAAoB,cAAc,OAAO,kBAAkB,YAC5D,0BAA0B,cAAc,aACxC,6BAA6B,cAAc,OAAO;;;;;;;;;;;;;;;;;wBAkBtC,cACd,wBACA,QAAQ,MAAM,eACd,kBAAkB,WAAW,YAE7B,UACA,aACA,SAEA,gBACC,oBAAoB,cAAc,OAAO,aAAa,cACvD,OACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamedQuery.js","names":[],"sources":["../../src/streamedQuery.ts"],"sourcesContent":["import { addConsumeAwareSignal, addToEnd } from './utils'\nimport type {\n OmitKeyof,\n QueryFunction,\n QueryFunctionContext,\n QueryKey,\n} from './types'\n\ntype BaseStreamedQueryParams<TQueryFnData, TQueryKey extends QueryKey> = {\n /** The function that returns an `AsyncIterable` to stream data from. */\n streamFn: (\n context: QueryFunctionContext<TQueryKey>,\n ) => AsyncIterable<TQueryFnData> | Promise<AsyncIterable<TQueryFnData>>\n /**\n * Defines how refetches are handled.\n * - `'reset'` (default): erases all data and puts the query back into `pending` state.\n * - `'append'`: appends new data to the existing data.\n * - `'replace'`: writes all data to the cache once the stream ends.\n */\n refetchMode?: 'append' | 'reset' | 'replace'\n}\n\ntype SimpleStreamedQueryParams<\n TQueryFnData,\n TQueryKey extends QueryKey,\n> = BaseStreamedQueryParams<TQueryFnData, TQueryKey> & {\n reducer?: never\n initialValue?: never\n}\n\ntype ReducibleStreamedQueryParams<\n TQueryFnData,\n TData,\n TQueryKey extends QueryKey,\n> = BaseStreamedQueryParams<TQueryFnData, TQueryKey> & {\n /**\n * Reduces streamed chunks into the final data shape. Required whenever `TData` is not an\n * array, since there is no default way to accumulate non-array chunks.\n */\n reducer: (acc: TData, chunk: TQueryFnData) => TData\n /**\n * The value used while the first chunk is being fetched, and returned if the stream yields no\n * values. Required together with a custom `reducer`.\n */\n initialValue: TData\n}\n\ntype StreamedQueryParams<TQueryFnData, TData, TQueryKey extends QueryKey> =\n | SimpleStreamedQueryParams<TQueryFnData, TQueryKey>\n | ReducibleStreamedQueryParams<TQueryFnData, TData, TQueryKey>\n\n/**\n * This is a helper function to create a query function that streams data from an AsyncIterable.\n * Data will be an Array of all the chunks received.\n * The query will be in a 'pending' state until the first chunk of data is received, but will go to 'success' after that.\n * The query will stay in fetchStatus 'fetching' until the stream ends.\n * @param streamFn - The function that returns an AsyncIterable to stream data from.\n * @example\n * ```ts\n * await queryClient.query({\n * queryKey: ['data'],\n * queryFn: streamedQuery({\n * streamFn: fetchDataInChunks,\n * }),\n * })\n * ```\n */\nexport function streamedQuery<\n TQueryFnData = unknown,\n TData = Array<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n>({\n streamFn,\n refetchMode = 'reset',\n reducer = (items, chunk) =>\n addToEnd(items as Array<TQueryFnData>, chunk) as TData,\n initialValue = [] as TData,\n}: StreamedQueryParams<TQueryFnData, TData, TQueryKey>): QueryFunction<\n TData,\n TQueryKey\n> {\n return async (context) => {\n const query = context.client\n .getQueryCache()\n .find({ queryKey: context.queryKey, exact: true })\n const isRefetch = !!query && query.isFetched()\n if (isRefetch && refetchMode === 'reset') {\n query.setState({\n ...query.resetState,\n fetchStatus: 'fetching',\n })\n }\n\n let result = initialValue\n\n let cancelled: boolean = false as boolean\n const streamFnContext = addConsumeAwareSignal<\n OmitKeyof<typeof context, 'signal'>\n >(\n {\n client: context.client,\n meta: context.meta,\n queryKey: context.queryKey,\n pageParam: context.pageParam,\n direction: context.direction,\n },\n () => context.signal,\n () => (cancelled = true),\n )\n\n const stream = await streamFn(streamFnContext)\n\n const isReplaceRefetch = isRefetch && refetchMode === 'replace'\n\n for await (const chunk of stream) {\n if (cancelled) {\n break\n }\n\n if (isReplaceRefetch) {\n // don't append to the cache directly when replace-refetching\n result = reducer(result, chunk)\n } else {\n context.client.setQueryData<TData>(context.queryKey, (prev) =>\n reducer(prev === undefined ? initialValue : prev, chunk),\n )\n }\n }\n\n // finalize result: replace-refetching needs to write to the cache\n if (isReplaceRefetch && !cancelled) {\n context.client.setQueryData<TData>(context.queryKey, result)\n }\n\n const data = context.client.getQueryData<TData>(context.queryKey)\n return data === undefined ? initialValue : data\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmEA,SAAgB,cAId,EACA,UACA,cAAc,SACd,WAAW,OAAO,UAChB,SAAS,OAA8B,KAAK,GAC9C,eAAe,CAAC,KAIhB;CACA,OAAO,OAAO,YAAY;EACxB,MAAM,QAAQ,QAAQ,OACnB,cAAc,CAAC,CACf,KAAK;GAAE,UAAU,QAAQ;GAAU,OAAO;EAAK,CAAC;EACnD,MAAM,YAAY,CAAC,CAAC,SAAS,MAAM,UAAU;EAC7C,IAAI,aAAa,gBAAgB,SAC/B,MAAM,SAAS;GACb,GAAG,MAAM;GACT,aAAa;EACf,CAAC;EAGH,IAAI,SAAS;
|
|
1
|
+
{"version":3,"file":"streamedQuery.js","names":[],"sources":["../../src/streamedQuery.ts"],"sourcesContent":["import { addConsumeAwareSignal, addToEnd } from './utils'\nimport type {\n OmitKeyof,\n QueryFunction,\n QueryFunctionContext,\n QueryKey,\n} from './types'\n\ntype BaseStreamedQueryParams<TQueryFnData, TQueryKey extends QueryKey> = {\n /** The function that returns an `AsyncIterable` to stream data from. */\n streamFn: (\n context: QueryFunctionContext<TQueryKey>,\n ) => AsyncIterable<TQueryFnData> | Promise<AsyncIterable<TQueryFnData>>\n /**\n * Defines how refetches are handled.\n * - `'reset'` (default): erases all data and puts the query back into `pending` state.\n * - `'append'`: appends new data to the existing data.\n * - `'replace'`: writes all data to the cache once the stream ends.\n */\n refetchMode?: 'append' | 'reset' | 'replace'\n}\n\ntype SimpleStreamedQueryParams<\n TQueryFnData,\n TQueryKey extends QueryKey,\n> = BaseStreamedQueryParams<TQueryFnData, TQueryKey> & {\n reducer?: never\n initialValue?: never\n}\n\ntype ReducibleStreamedQueryParams<\n TQueryFnData,\n TData,\n TQueryKey extends QueryKey,\n> = BaseStreamedQueryParams<TQueryFnData, TQueryKey> & {\n /**\n * Reduces streamed chunks into the final data shape. Required whenever `TData` is not an\n * array, since there is no default way to accumulate non-array chunks.\n */\n reducer: (acc: TData, chunk: TQueryFnData) => TData\n /**\n * The value used while the first chunk is being fetched, and returned if the stream yields no\n * values. Required together with a custom `reducer`.\n */\n initialValue: TData\n}\n\ntype StreamedQueryParams<TQueryFnData, TData, TQueryKey extends QueryKey> =\n | SimpleStreamedQueryParams<TQueryFnData, TQueryKey>\n | ReducibleStreamedQueryParams<TQueryFnData, TData, TQueryKey>\n\n/**\n * This is a helper function to create a query function that streams data from an AsyncIterable.\n * Data will be an Array of all the chunks received.\n * The query will be in a 'pending' state until the first chunk of data is received, but will go to 'success' after that.\n * The query will stay in fetchStatus 'fetching' until the stream ends.\n * @param streamFn - The function that returns an AsyncIterable to stream data from.\n * @example\n * ```ts\n * await queryClient.query({\n * queryKey: ['data'],\n * queryFn: streamedQuery({\n * streamFn: fetchDataInChunks,\n * }),\n * })\n * ```\n */\nexport function streamedQuery<\n TQueryFnData = unknown,\n TData = Array<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n>({\n streamFn,\n refetchMode = 'reset',\n reducer = (items, chunk) =>\n addToEnd(items as Array<TQueryFnData>, chunk) as TData,\n initialValue = [] as TData,\n}: StreamedQueryParams<TQueryFnData, TData, TQueryKey>): QueryFunction<\n TData,\n TQueryKey\n> {\n return async (context) => {\n const query = context.client\n .getQueryCache()\n .find({ queryKey: context.queryKey, exact: true })\n const isRefetch = !!query && query.isFetched()\n if (isRefetch && refetchMode === 'reset') {\n query.setState({\n ...query.resetState,\n fetchStatus: 'fetching',\n })\n }\n\n let result = initialValue\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n let cancelled: boolean = false as boolean\n const streamFnContext = addConsumeAwareSignal<\n OmitKeyof<typeof context, 'signal'>\n >(\n {\n client: context.client,\n meta: context.meta,\n queryKey: context.queryKey,\n pageParam: context.pageParam,\n direction: context.direction,\n },\n () => context.signal,\n () => (cancelled = true),\n )\n\n const stream = await streamFn(streamFnContext)\n\n const isReplaceRefetch = isRefetch && refetchMode === 'replace'\n\n for await (const chunk of stream) {\n if (cancelled) {\n break\n }\n\n if (isReplaceRefetch) {\n // don't append to the cache directly when replace-refetching\n result = reducer(result, chunk)\n } else {\n context.client.setQueryData<TData>(context.queryKey, (prev) =>\n reducer(prev === undefined ? initialValue : prev, chunk),\n )\n }\n }\n\n // finalize result: replace-refetching needs to write to the cache\n if (isReplaceRefetch && !cancelled) {\n context.client.setQueryData<TData>(context.queryKey, result)\n }\n\n const data = context.client.getQueryData<TData>(context.queryKey)\n return data === undefined ? initialValue : data\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmEA,SAAgB,cAId,EACA,UACA,cAAc,SACd,WAAW,OAAO,UAChB,SAAS,OAA8B,KAAK,GAC9C,eAAe,CAAC,KAIhB;CACA,OAAO,OAAO,YAAY;EACxB,MAAM,QAAQ,QAAQ,OACnB,cAAc,CAAC,CACf,KAAK;GAAE,UAAU,QAAQ;GAAU,OAAO;EAAK,CAAC;EACnD,MAAM,YAAY,CAAC,CAAC,SAAS,MAAM,UAAU;EAC7C,IAAI,aAAa,gBAAgB,SAC/B,MAAM,SAAS;GACb,GAAG,MAAM;GACT,aAAa;EACf,CAAC;EAGH,IAAI,SAAS;EAGb,IAAI,YAAqB;EAezB,MAAM,SAAS,MAAM,SAdG,sBAGtB;GACE,QAAQ,QAAQ;GAChB,MAAM,QAAQ;GACd,UAAU,QAAQ;GAClB,WAAW,QAAQ;GACnB,WAAW,QAAQ;EACrB,SACM,QAAQ,cACP,YAAY,IAGuB,CAAC;EAE7C,MAAM,mBAAmB,aAAa,gBAAgB;EAEtD,WAAW,MAAM,SAAS,QAAQ;GAChC,IAAI,WACF;GAGF,IAAI,kBAEF,SAAS,QAAQ,QAAQ,KAAK;QAE9B,QAAQ,OAAO,aAAoB,QAAQ,WAAW,SACpD,QAAQ,SAAS,KAAA,IAAY,eAAe,MAAM,KAAK,CACzD;EAEJ;EAGA,IAAI,oBAAoB,CAAC,WACvB,QAAQ,OAAO,aAAoB,QAAQ,UAAU,MAAM;EAG7D,MAAM,OAAO,QAAQ,OAAO,aAAoB,QAAQ,QAAQ;EAChE,OAAO,SAAS,KAAA,IAAY,eAAe;CAC7C;AACF"}
|
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
* If we don't accept a single void argument, then
|
|
8
8
|
* `new Promise(resolve => timeoutManager.setTimeout(resolve, N))` is a type error.
|
|
9
9
|
*/
|
|
10
|
-
type TimeoutCallback = (_: void) => void;
|
|
10
|
+
export type TimeoutCallback = (_: void) => void;
|
|
11
11
|
/**
|
|
12
12
|
* Wrapping `setTimeout` is awkward from a typing perspective because platform
|
|
13
13
|
* typings may extend the return type of `setTimeout`. For example, NodeJS
|
|
14
14
|
* typings add `NodeJS.Timeout`; but a non-default `timeoutManager` may not be
|
|
15
15
|
* able to return such a type.
|
|
16
16
|
*/
|
|
17
|
-
type ManagedTimerId = number | {
|
|
17
|
+
export type ManagedTimerId = number | {
|
|
18
18
|
[Symbol.toPrimitive]: () => number;
|
|
19
19
|
};
|
|
20
20
|
/**
|
|
@@ -26,13 +26,13 @@ type ManagedTimerId = number | {
|
|
|
26
26
|
* `setTimeout`/`setInterval`) does not do. A custom provider can implement coalescing, and can
|
|
27
27
|
* also support delays longer than the ~24-day maximum of the global `setTimeout`.
|
|
28
28
|
*/
|
|
29
|
-
type TimeoutProvider<TTimerId extends ManagedTimerId = ManagedTimerId> = {
|
|
29
|
+
export type TimeoutProvider<TTimerId extends ManagedTimerId = ManagedTimerId> = {
|
|
30
30
|
readonly setTimeout: (callback: TimeoutCallback, delay: number) => TTimerId;
|
|
31
31
|
readonly clearTimeout: (timeoutId: TTimerId | undefined) => void;
|
|
32
32
|
readonly setInterval: (callback: TimeoutCallback, delay: number) => TTimerId;
|
|
33
33
|
readonly clearInterval: (intervalId: TTimerId | undefined) => void;
|
|
34
34
|
};
|
|
35
|
-
declare const defaultTimeoutProvider: TimeoutProvider;
|
|
35
|
+
export declare const defaultTimeoutProvider: TimeoutProvider;
|
|
36
36
|
/**
|
|
37
37
|
* Allows customization of how timeouts are created.
|
|
38
38
|
*
|
|
@@ -44,7 +44,7 @@ declare const defaultTimeoutProvider: TimeoutProvider;
|
|
|
44
44
|
* If you hit this limitation, consider providing a custom TimeoutProvider that
|
|
45
45
|
* coalesces timeouts.
|
|
46
46
|
*/
|
|
47
|
-
declare class TimeoutManager implements Omit<TimeoutProvider, 'name'> {
|
|
47
|
+
export declare class TimeoutManager implements Omit<TimeoutProvider, 'name'> {
|
|
48
48
|
#private;
|
|
49
49
|
/**
|
|
50
50
|
* `setTimeoutProvider` can be used to set a custom implementation of the
|
|
@@ -151,7 +151,7 @@ declare class TimeoutManager implements Omit<TimeoutProvider, 'name'> {
|
|
|
151
151
|
/**
|
|
152
152
|
* Singleton instance of {@link TimeoutManager}, used throughout TanStack Query to schedule and cancel timers.
|
|
153
153
|
*/
|
|
154
|
-
declare const timeoutManager: TimeoutManager;
|
|
154
|
+
export declare const timeoutManager: TimeoutManager;
|
|
155
155
|
/**
|
|
156
156
|
* In many cases code wants to delay to the next event loop tick; this is not
|
|
157
157
|
* mediated by {@link timeoutManager}.
|
|
@@ -159,7 +159,6 @@ declare const timeoutManager: TimeoutManager;
|
|
|
159
159
|
* This function is provided to make auditing the `tanstack/query-core` for
|
|
160
160
|
* incorrect use of system `setTimeout` easier.
|
|
161
161
|
*/
|
|
162
|
-
declare function systemSetTimeoutZero(callback: TimeoutCallback): void;
|
|
162
|
+
export declare function systemSetTimeoutZero(callback: TimeoutCallback): void;
|
|
163
163
|
//#endregion
|
|
164
|
-
export { ManagedTimerId, TimeoutCallback, TimeoutManager, TimeoutProvider, defaultTimeoutProvider, systemSetTimeoutZero, timeoutManager };
|
|
165
164
|
//# sourceMappingURL=timeoutManager.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeoutManager.d.cts","names":[],"sources":["../../src/timeoutManager.ts"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"timeoutManager.d.cts","names":[],"sources":["../../src/timeoutManager.ts"],"mappings":";;;;;;;;;YAQY,mBAAmB;;;;;;;YAQnB;GAA6B,OAAO;;;;;;;;;;;YAWpC,gBAAgB,iBAAiB,iBAAiB;WAEjD,aAAa,UAAU,iBAAiB,kBAAkB;WAC1D,eAAe,WAAW;WAE1B,cAAc,UAAU,iBAAiB,kBAAkB;WAC3D,gBAAgB,YAAY;;qBAK5B,wBAAwB;;;;;;;;;;;;qBA+BxB,0BAA0B,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoC1C,mBAAmB,iBAAiB,gBAClC,UAAU,gBAAgB;;;;;;;;;;;;;;;;;;;;;EAgD5B,WAAW,UAAU,iBAAiB,gBAAgB;;;;;;;;;;;;;;;;;;EAwBtD,aAAa,WAAW;;;;;;;;;;;;;;;;;;EAqBxB,YAAY,UAAU,iBAAiB,gBAAgB;;;;;;;;;;;;;;;;;;EAwBvD,cAAc,YAAY;;;;;qBAQf,gBAAc;;;;;;;;wBASX,qBAAqB,UAAU"}
|