@tanstack/query-core 5.104.0 → 5.104.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.
- package/build/legacy/environmentManager.cjs +3 -1
- package/build/legacy/environmentManager.cjs.map +1 -1
- package/build/legacy/environmentManager.d.cts +6 -1
- package/build/legacy/environmentManager.d.cts.map +1 -1
- package/build/legacy/environmentManager.d.ts +6 -1
- package/build/legacy/environmentManager.d.ts.map +1 -1
- package/build/legacy/environmentManager.js +3 -1
- package/build/legacy/environmentManager.js.map +1 -1
- package/build/legacy/focusManager.cjs +4 -2
- package/build/legacy/focusManager.cjs.map +1 -1
- package/build/legacy/focusManager.d.cts +5 -3
- package/build/legacy/focusManager.d.cts.map +1 -1
- package/build/legacy/focusManager.d.ts +5 -3
- package/build/legacy/focusManager.d.ts.map +1 -1
- package/build/legacy/focusManager.js +4 -2
- package/build/legacy/focusManager.js.map +1 -1
- package/build/legacy/{hydration-B9t5w6NC.d.ts → hydration-Dfuxd5FW.d.cts} +1410 -128
- package/build/legacy/hydration-Dfuxd5FW.d.cts.map +1 -0
- package/build/legacy/{hydration-Br9VIGXa.d.cts → hydration-UAqdtMIf.d.ts} +1410 -128
- package/build/legacy/hydration-UAqdtMIf.d.ts.map +1 -0
- package/build/legacy/hydration.cjs +35 -0
- package/build/legacy/hydration.cjs.map +1 -1
- package/build/legacy/hydration.d.cts +1 -1
- package/build/legacy/hydration.d.ts +1 -1
- package/build/legacy/hydration.js +35 -0
- package/build/legacy/hydration.js.map +1 -1
- package/build/legacy/index.d.cts +1 -1
- package/build/legacy/index.d.ts +1 -1
- package/build/legacy/infiniteQueryBehavior.cjs +29 -0
- package/build/legacy/infiniteQueryBehavior.cjs.map +1 -1
- package/build/legacy/infiniteQueryBehavior.d.cts +16 -1
- package/build/legacy/infiniteQueryBehavior.d.cts.map +1 -1
- package/build/legacy/infiniteQueryBehavior.d.ts +16 -1
- package/build/legacy/infiniteQueryBehavior.d.ts.map +1 -1
- package/build/legacy/infiniteQueryBehavior.js +29 -0
- package/build/legacy/infiniteQueryBehavior.js.map +1 -1
- package/build/legacy/infiniteQueryObserver.cjs +13 -7
- package/build/legacy/infiniteQueryObserver.cjs.map +1 -1
- package/build/legacy/infiniteQueryObserver.d.cts +15 -9
- package/build/legacy/infiniteQueryObserver.d.cts.map +1 -1
- package/build/legacy/infiniteQueryObserver.d.ts +15 -9
- package/build/legacy/infiniteQueryObserver.d.ts.map +1 -1
- package/build/legacy/infiniteQueryObserver.js +13 -7
- package/build/legacy/infiniteQueryObserver.js.map +1 -1
- package/build/legacy/mutation.cjs +27 -10
- package/build/legacy/mutation.cjs.map +1 -1
- package/build/legacy/mutation.d.cts +1 -1
- package/build/legacy/mutation.d.ts +1 -1
- package/build/legacy/mutation.js +27 -10
- package/build/legacy/mutation.js.map +1 -1
- package/build/legacy/mutationCache.cjs +53 -12
- package/build/legacy/mutationCache.cjs.map +1 -1
- package/build/legacy/mutationCache.d.cts +1 -1
- package/build/legacy/mutationCache.d.ts +1 -1
- package/build/legacy/mutationCache.js +53 -12
- package/build/legacy/mutationCache.js.map +1 -1
- package/build/legacy/mutationObserver.cjs +27 -16
- package/build/legacy/mutationObserver.cjs.map +1 -1
- package/build/legacy/mutationObserver.d.cts +1 -1
- package/build/legacy/mutationObserver.d.ts +1 -1
- package/build/legacy/mutationObserver.js +27 -16
- package/build/legacy/mutationObserver.js.map +1 -1
- package/build/legacy/notifyManager.cjs +12 -2
- package/build/legacy/notifyManager.cjs.map +1 -1
- package/build/legacy/notifyManager.d.cts +19 -4
- package/build/legacy/notifyManager.d.cts.map +1 -1
- package/build/legacy/notifyManager.d.ts +19 -4
- package/build/legacy/notifyManager.d.ts.map +1 -1
- package/build/legacy/notifyManager.js +12 -2
- package/build/legacy/notifyManager.js.map +1 -1
- package/build/legacy/onlineManager.cjs +4 -2
- package/build/legacy/onlineManager.cjs.map +1 -1
- package/build/legacy/onlineManager.d.cts +5 -3
- package/build/legacy/onlineManager.d.cts.map +1 -1
- package/build/legacy/onlineManager.d.ts +5 -3
- package/build/legacy/onlineManager.d.ts.map +1 -1
- package/build/legacy/onlineManager.js +4 -2
- package/build/legacy/onlineManager.js.map +1 -1
- package/build/legacy/queriesObserver.cjs +15 -3
- package/build/legacy/queriesObserver.cjs.map +1 -1
- package/build/legacy/queriesObserver.d.cts +14 -5
- package/build/legacy/queriesObserver.d.cts.map +1 -1
- package/build/legacy/queriesObserver.d.ts +14 -5
- package/build/legacy/queriesObserver.d.ts.map +1 -1
- package/build/legacy/queriesObserver.js +15 -3
- package/build/legacy/queriesObserver.js.map +1 -1
- package/build/legacy/query.cjs +89 -15
- package/build/legacy/query.cjs.map +1 -1
- package/build/legacy/query.d.cts +1 -1
- package/build/legacy/query.d.ts +1 -1
- package/build/legacy/query.js +89 -15
- package/build/legacy/query.js.map +1 -1
- package/build/legacy/queryCache.cjs +34 -12
- package/build/legacy/queryCache.cjs.map +1 -1
- package/build/legacy/queryCache.d.cts +1 -1
- package/build/legacy/queryCache.d.ts +1 -1
- package/build/legacy/queryCache.js +34 -12
- package/build/legacy/queryCache.js.map +1 -1
- package/build/legacy/queryClient.cjs +104 -32
- package/build/legacy/queryClient.cjs.map +1 -1
- package/build/legacy/queryClient.d.cts +1 -1
- package/build/legacy/queryClient.d.ts +1 -1
- package/build/legacy/queryClient.js +104 -32
- package/build/legacy/queryClient.js.map +1 -1
- package/build/legacy/queryObserver.cjs +78 -6
- package/build/legacy/queryObserver.cjs.map +1 -1
- package/build/legacy/queryObserver.d.cts +1 -1
- package/build/legacy/queryObserver.d.ts +1 -1
- package/build/legacy/queryObserver.js +78 -6
- package/build/legacy/queryObserver.js.map +1 -1
- package/build/{modern/removable-0GzhW1PK.d.cts → legacy/removable-Cw9GNGyK.d.cts} +17 -1
- package/build/legacy/removable-Cw9GNGyK.d.cts.map +1 -0
- package/build/legacy/{removable-0GzhW1PK.d.cts → removable-Cw9GNGyK.d.ts} +17 -1
- package/build/legacy/removable-Cw9GNGyK.d.ts.map +1 -0
- package/build/legacy/removable.cjs +12 -0
- package/build/legacy/removable.cjs.map +1 -1
- package/build/legacy/removable.d.cts +1 -1
- package/build/legacy/removable.d.ts +1 -1
- package/build/legacy/removable.js +12 -0
- package/build/legacy/removable.js.map +1 -1
- package/build/legacy/retryer.cjs +26 -4
- package/build/legacy/retryer.cjs.map +1 -1
- package/build/legacy/retryer.d.cts +1 -1
- package/build/legacy/retryer.d.ts +1 -1
- package/build/legacy/retryer.js +26 -4
- package/build/legacy/retryer.js.map +1 -1
- package/build/legacy/streamedQuery.cjs +3 -1
- package/build/legacy/streamedQuery.cjs.map +1 -1
- package/build/legacy/streamedQuery.d.cts +4 -2
- package/build/legacy/streamedQuery.d.cts.map +1 -1
- package/build/legacy/streamedQuery.d.ts +4 -2
- package/build/legacy/streamedQuery.d.ts.map +1 -1
- package/build/legacy/streamedQuery.js +3 -1
- package/build/legacy/streamedQuery.js.map +1 -1
- package/build/{modern/subscribable-CysQ0tne.d.cts → legacy/subscribable-czlHOxMP.d.cts} +11 -1
- package/build/legacy/subscribable-czlHOxMP.d.cts.map +1 -0
- package/build/legacy/{subscribable-CysQ0tne.d.cts → subscribable-czlHOxMP.d.ts} +11 -1
- package/build/legacy/subscribable-czlHOxMP.d.ts.map +1 -0
- package/build/legacy/subscribable.cjs +10 -0
- package/build/legacy/subscribable.cjs.map +1 -1
- package/build/legacy/subscribable.d.cts +1 -1
- package/build/legacy/subscribable.d.ts +1 -1
- package/build/legacy/subscribable.js +10 -0
- package/build/legacy/subscribable.js.map +1 -1
- package/build/legacy/timeoutManager.cjs +11 -6
- package/build/legacy/timeoutManager.cjs.map +1 -1
- package/build/legacy/timeoutManager.d.cts +23 -6
- package/build/legacy/timeoutManager.d.cts.map +1 -1
- package/build/legacy/timeoutManager.d.ts +23 -6
- package/build/legacy/timeoutManager.d.ts.map +1 -1
- package/build/legacy/timeoutManager.js +11 -6
- package/build/legacy/timeoutManager.js.map +1 -1
- package/build/legacy/types.cjs.map +1 -1
- package/build/legacy/types.d.cts +1 -1
- package/build/legacy/types.d.ts +1 -1
- package/build/legacy/types.js.map +1 -1
- package/build/legacy/utils.cjs +117 -8
- package/build/legacy/utils.cjs.map +1 -1
- package/build/legacy/utils.d.cts +1 -1
- package/build/legacy/utils.d.ts +1 -1
- package/build/legacy/utils.js +117 -8
- package/build/legacy/utils.js.map +1 -1
- package/build/modern/environmentManager.cjs +3 -1
- package/build/modern/environmentManager.cjs.map +1 -1
- package/build/modern/environmentManager.d.cts +6 -1
- package/build/modern/environmentManager.d.cts.map +1 -1
- package/build/modern/environmentManager.d.ts +6 -1
- package/build/modern/environmentManager.d.ts.map +1 -1
- package/build/modern/environmentManager.js +3 -1
- package/build/modern/environmentManager.js.map +1 -1
- package/build/modern/focusManager.cjs +4 -2
- package/build/modern/focusManager.cjs.map +1 -1
- package/build/modern/focusManager.d.cts +5 -3
- package/build/modern/focusManager.d.cts.map +1 -1
- package/build/modern/focusManager.d.ts +5 -3
- package/build/modern/focusManager.d.ts.map +1 -1
- package/build/modern/focusManager.js +4 -2
- package/build/modern/focusManager.js.map +1 -1
- package/build/modern/{hydration-B9t5w6NC.d.ts → hydration-Dfuxd5FW.d.cts} +1410 -128
- package/build/modern/hydration-Dfuxd5FW.d.cts.map +1 -0
- package/build/modern/{hydration-Br9VIGXa.d.cts → hydration-UAqdtMIf.d.ts} +1410 -128
- package/build/modern/hydration-UAqdtMIf.d.ts.map +1 -0
- package/build/modern/hydration.cjs +35 -0
- package/build/modern/hydration.cjs.map +1 -1
- package/build/modern/hydration.d.cts +1 -1
- package/build/modern/hydration.d.ts +1 -1
- package/build/modern/hydration.js +35 -0
- package/build/modern/hydration.js.map +1 -1
- package/build/modern/index.d.cts +1 -1
- package/build/modern/index.d.ts +1 -1
- package/build/modern/infiniteQueryBehavior.cjs +29 -0
- package/build/modern/infiniteQueryBehavior.cjs.map +1 -1
- package/build/modern/infiniteQueryBehavior.d.cts +16 -1
- package/build/modern/infiniteQueryBehavior.d.cts.map +1 -1
- package/build/modern/infiniteQueryBehavior.d.ts +16 -1
- package/build/modern/infiniteQueryBehavior.d.ts.map +1 -1
- package/build/modern/infiniteQueryBehavior.js +29 -0
- package/build/modern/infiniteQueryBehavior.js.map +1 -1
- package/build/modern/infiniteQueryObserver.cjs +13 -7
- package/build/modern/infiniteQueryObserver.cjs.map +1 -1
- package/build/modern/infiniteQueryObserver.d.cts +15 -9
- package/build/modern/infiniteQueryObserver.d.cts.map +1 -1
- package/build/modern/infiniteQueryObserver.d.ts +15 -9
- package/build/modern/infiniteQueryObserver.d.ts.map +1 -1
- package/build/modern/infiniteQueryObserver.js +13 -7
- package/build/modern/infiniteQueryObserver.js.map +1 -1
- package/build/modern/mutation.cjs +27 -10
- package/build/modern/mutation.cjs.map +1 -1
- package/build/modern/mutation.d.cts +1 -1
- package/build/modern/mutation.d.ts +1 -1
- package/build/modern/mutation.js +27 -10
- package/build/modern/mutation.js.map +1 -1
- package/build/modern/mutationCache.cjs +53 -12
- package/build/modern/mutationCache.cjs.map +1 -1
- package/build/modern/mutationCache.d.cts +1 -1
- package/build/modern/mutationCache.d.ts +1 -1
- package/build/modern/mutationCache.js +53 -12
- package/build/modern/mutationCache.js.map +1 -1
- package/build/modern/mutationObserver.cjs +23 -12
- package/build/modern/mutationObserver.cjs.map +1 -1
- package/build/modern/mutationObserver.d.cts +1 -1
- package/build/modern/mutationObserver.d.ts +1 -1
- package/build/modern/mutationObserver.js +23 -12
- package/build/modern/mutationObserver.js.map +1 -1
- package/build/modern/notifyManager.cjs +12 -2
- package/build/modern/notifyManager.cjs.map +1 -1
- package/build/modern/notifyManager.d.cts +19 -4
- package/build/modern/notifyManager.d.cts.map +1 -1
- package/build/modern/notifyManager.d.ts +19 -4
- package/build/modern/notifyManager.d.ts.map +1 -1
- package/build/modern/notifyManager.js +12 -2
- package/build/modern/notifyManager.js.map +1 -1
- package/build/modern/onlineManager.cjs +4 -2
- package/build/modern/onlineManager.cjs.map +1 -1
- package/build/modern/onlineManager.d.cts +5 -3
- package/build/modern/onlineManager.d.cts.map +1 -1
- package/build/modern/onlineManager.d.ts +5 -3
- package/build/modern/onlineManager.d.ts.map +1 -1
- package/build/modern/onlineManager.js +4 -2
- package/build/modern/onlineManager.js.map +1 -1
- package/build/modern/queriesObserver.cjs +15 -3
- package/build/modern/queriesObserver.cjs.map +1 -1
- package/build/modern/queriesObserver.d.cts +14 -5
- package/build/modern/queriesObserver.d.cts.map +1 -1
- package/build/modern/queriesObserver.d.ts +14 -5
- package/build/modern/queriesObserver.d.ts.map +1 -1
- package/build/modern/queriesObserver.js +15 -3
- package/build/modern/queriesObserver.js.map +1 -1
- package/build/modern/query.cjs +89 -15
- package/build/modern/query.cjs.map +1 -1
- package/build/modern/query.d.cts +1 -1
- package/build/modern/query.d.ts +1 -1
- package/build/modern/query.js +89 -15
- package/build/modern/query.js.map +1 -1
- package/build/modern/queryCache.cjs +34 -12
- package/build/modern/queryCache.cjs.map +1 -1
- package/build/modern/queryCache.d.cts +1 -1
- package/build/modern/queryCache.d.ts +1 -1
- package/build/modern/queryCache.js +34 -12
- package/build/modern/queryCache.js.map +1 -1
- package/build/modern/queryClient.cjs +104 -32
- package/build/modern/queryClient.cjs.map +1 -1
- package/build/modern/queryClient.d.cts +1 -1
- package/build/modern/queryClient.d.ts +1 -1
- package/build/modern/queryClient.js +104 -32
- package/build/modern/queryClient.js.map +1 -1
- package/build/modern/queryObserver.cjs +78 -6
- package/build/modern/queryObserver.cjs.map +1 -1
- package/build/modern/queryObserver.d.cts +1 -1
- package/build/modern/queryObserver.d.ts +1 -1
- package/build/modern/queryObserver.js +78 -6
- package/build/modern/queryObserver.js.map +1 -1
- package/build/modern/{removable-0GzhW1PK.d.ts → removable-Cw9GNGyK.d.cts} +17 -1
- package/build/modern/removable-Cw9GNGyK.d.cts.map +1 -0
- package/build/{legacy/removable-0GzhW1PK.d.ts → modern/removable-Cw9GNGyK.d.ts} +17 -1
- package/build/modern/removable-Cw9GNGyK.d.ts.map +1 -0
- package/build/modern/removable.cjs +12 -0
- package/build/modern/removable.cjs.map +1 -1
- package/build/modern/removable.d.cts +1 -1
- package/build/modern/removable.d.ts +1 -1
- package/build/modern/removable.js +12 -0
- package/build/modern/removable.js.map +1 -1
- package/build/modern/retryer.cjs +26 -4
- package/build/modern/retryer.cjs.map +1 -1
- package/build/modern/retryer.d.cts +1 -1
- package/build/modern/retryer.d.ts +1 -1
- package/build/modern/retryer.js +26 -4
- package/build/modern/retryer.js.map +1 -1
- package/build/modern/streamedQuery.cjs +3 -1
- package/build/modern/streamedQuery.cjs.map +1 -1
- package/build/modern/streamedQuery.d.cts +4 -2
- package/build/modern/streamedQuery.d.cts.map +1 -1
- package/build/modern/streamedQuery.d.ts +4 -2
- package/build/modern/streamedQuery.d.ts.map +1 -1
- package/build/modern/streamedQuery.js +3 -1
- package/build/modern/streamedQuery.js.map +1 -1
- package/build/modern/{subscribable-CysQ0tne.d.ts → subscribable-czlHOxMP.d.cts} +11 -1
- package/build/modern/subscribable-czlHOxMP.d.cts.map +1 -0
- package/build/{legacy/subscribable-CysQ0tne.d.ts → modern/subscribable-czlHOxMP.d.ts} +11 -1
- package/build/modern/subscribable-czlHOxMP.d.ts.map +1 -0
- package/build/modern/subscribable.cjs +10 -0
- package/build/modern/subscribable.cjs.map +1 -1
- package/build/modern/subscribable.d.cts +1 -1
- package/build/modern/subscribable.d.ts +1 -1
- package/build/modern/subscribable.js +10 -0
- package/build/modern/subscribable.js.map +1 -1
- package/build/modern/timeoutManager.cjs +11 -6
- package/build/modern/timeoutManager.cjs.map +1 -1
- package/build/modern/timeoutManager.d.cts +23 -6
- package/build/modern/timeoutManager.d.cts.map +1 -1
- package/build/modern/timeoutManager.d.ts +23 -6
- package/build/modern/timeoutManager.d.ts.map +1 -1
- package/build/modern/timeoutManager.js +11 -6
- package/build/modern/timeoutManager.js.map +1 -1
- package/build/modern/types.cjs.map +1 -1
- package/build/modern/types.d.cts +1 -1
- package/build/modern/types.d.ts +1 -1
- package/build/modern/types.js.map +1 -1
- package/build/modern/utils.cjs +117 -8
- package/build/modern/utils.cjs.map +1 -1
- package/build/modern/utils.d.cts +1 -1
- package/build/modern/utils.d.ts +1 -1
- package/build/modern/utils.js +117 -8
- package/build/modern/utils.js.map +1 -1
- package/package.json +4 -4
- package/src/environmentManager.ts +6 -1
- package/src/focusManager.ts +8 -6
- package/src/hydration.ts +42 -1
- package/src/infiniteQueryBehavior.ts +29 -0
- package/src/infiniteQueryObserver.ts +20 -14
- package/src/mutation.ts +32 -11
- package/src/mutationCache.ts +53 -12
- package/src/mutationObserver.ts +29 -14
- package/src/notifyManager.ts +12 -2
- package/src/onlineManager.ts +7 -5
- package/src/queriesObserver.ts +20 -5
- package/src/query.ts +153 -20
- package/src/queryCache.ts +54 -13
- package/src/queryClient.ts +110 -38
- package/src/queryObserver.ts +88 -12
- package/src/removable.ts +16 -0
- package/src/retryer.ts +57 -4
- package/src/streamedQuery.ts +4 -3
- package/src/subscribable.ts +10 -0
- package/src/timeoutManager.ts +23 -6
- package/src/types.ts +801 -27
- package/src/utils.ts +130 -10
- package/build/legacy/hydration-B9t5w6NC.d.ts.map +0 -1
- package/build/legacy/hydration-Br9VIGXa.d.cts.map +0 -1
- package/build/legacy/removable-0GzhW1PK.d.cts.map +0 -1
- package/build/legacy/removable-0GzhW1PK.d.ts.map +0 -1
- package/build/legacy/subscribable-CysQ0tne.d.cts.map +0 -1
- package/build/legacy/subscribable-CysQ0tne.d.ts.map +0 -1
- package/build/modern/hydration-B9t5w6NC.d.ts.map +0 -1
- package/build/modern/hydration-Br9VIGXa.d.cts.map +0 -1
- package/build/modern/removable-0GzhW1PK.d.cts.map +0 -1
- package/build/modern/removable-0GzhW1PK.d.ts.map +0 -1
- package/build/modern/subscribable-CysQ0tne.d.cts.map +0 -1
- package/build/modern/subscribable-CysQ0tne.d.ts.map +0 -1
|
@@ -4,6 +4,7 @@ const require_utils = require("./utils.cjs");
|
|
|
4
4
|
let isServerFn = () => require_utils.isServer;
|
|
5
5
|
/**
|
|
6
6
|
* Returns whether the current runtime should be treated as a server environment.
|
|
7
|
+
* @returns `true` if the runtime is treated as a server.
|
|
7
8
|
*/
|
|
8
9
|
const isServer = () => isServerFn();
|
|
9
10
|
/**
|
|
@@ -15,7 +16,6 @@ const isServer = () => isServerFn();
|
|
|
15
16
|
* Override this for runtimes where that default detection would give the wrong answer — for
|
|
16
17
|
* example, a Service Worker, where `window` is undefined even though the environment should
|
|
17
18
|
* behave like a client.
|
|
18
|
-
*
|
|
19
19
|
* @example
|
|
20
20
|
* ```ts
|
|
21
21
|
* import { environmentManager } from '@tanstack/query-core'
|
|
@@ -27,6 +27,8 @@ const environmentManager = {
|
|
|
27
27
|
isServer,
|
|
28
28
|
/**
|
|
29
29
|
* Overrides the server check globally.
|
|
30
|
+
* @param isServerValue - A function that returns whether the runtime should be treated as a
|
|
31
|
+
* server.
|
|
30
32
|
*/
|
|
31
33
|
setIsServer(isServerValue) {
|
|
32
34
|
isServerFn = isServerValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environmentManager.cjs","names":["defaultIsServer"],"sources":["../../src/environmentManager.ts"],"sourcesContent":["import { isServer as defaultIsServer } from './utils'\n\nexport type IsServerValue = () => boolean\n\nlet isServerFn: IsServerValue = () => defaultIsServer\n\n/**\n * Returns whether the current runtime should be treated as a server environment.\n */\nexport const isServer = (): boolean => isServerFn()\n\n/**\n * Manages how TanStack Query detects whether the current runtime should be treated as\n * server-side, which disables scheduling refetch timers and changes the default `retry` count\n * and `gcTime`. By default, the detection treats a missing `window` (or the presence of a\n * `Deno` global) as server.\n *\n * Override this for runtimes where that default detection would give the wrong answer — for\n * example, a Service Worker, where `window` is undefined even though the environment should\n * behave like a client.\n
|
|
1
|
+
{"version":3,"file":"environmentManager.cjs","names":["defaultIsServer"],"sources":["../../src/environmentManager.ts"],"sourcesContent":["import { isServer as defaultIsServer } from './utils'\n\n/**\n * A function that returns whether the code is running on the server.\n */\nexport type IsServerValue = () => boolean\n\nlet isServerFn: IsServerValue = () => defaultIsServer\n\n/**\n * Returns whether the current runtime should be treated as a server environment.\n * @returns `true` if the runtime is treated as a server.\n */\nexport const isServer = (): boolean => isServerFn()\n\n/**\n * Manages how TanStack Query detects whether the current runtime should be treated as\n * server-side, which disables scheduling refetch timers and changes the default `retry` count\n * and `gcTime`. By default, the detection treats a missing `window` (or the presence of a\n * `Deno` global) as server.\n *\n * Override this for runtimes where that default detection would give the wrong answer — for\n * example, a Service Worker, where `window` is undefined even though the environment should\n * behave like a client.\n * @example\n * ```ts\n * import { environmentManager } from '@tanstack/query-core'\n *\n * environmentManager.setIsServer(() => false)\n * ```\n */\nexport const environmentManager = {\n isServer,\n /**\n * Overrides the server check globally.\n * @param isServerValue - A function that returns whether the runtime should be treated as a\n * server.\n */\n setIsServer(isServerValue: IsServerValue): void {\n isServerFn = isServerValue\n },\n}\n"],"mappings":";;;AAOA,IAAI,mBAAkCA,cAAAA;;;;;AAMtC,MAAa,iBAA0B,WAAW;;;;;;;;;;;;;;;;;AAkBlD,MAAa,qBAAqB;CAChC;;;;;;CAMA,YAAY,eAAoC;EAC9C,aAAa;CACf;AACF"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
//#region src/environmentManager.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* A function that returns whether the code is running on the server.
|
|
4
|
+
*/
|
|
2
5
|
export type IsServerValue = () => boolean;
|
|
3
6
|
/**
|
|
4
7
|
* Returns whether the current runtime should be treated as a server environment.
|
|
8
|
+
* @returns `true` if the runtime is treated as a server.
|
|
5
9
|
*/
|
|
6
10
|
export declare const isServer: () => boolean;
|
|
7
11
|
/**
|
|
@@ -13,7 +17,6 @@ export declare const isServer: () => boolean;
|
|
|
13
17
|
* Override this for runtimes where that default detection would give the wrong answer — for
|
|
14
18
|
* example, a Service Worker, where `window` is undefined even though the environment should
|
|
15
19
|
* behave like a client.
|
|
16
|
-
*
|
|
17
20
|
* @example
|
|
18
21
|
* ```ts
|
|
19
22
|
* import { environmentManager } from '@tanstack/query-core'
|
|
@@ -25,6 +28,8 @@ export declare const environmentManager: {
|
|
|
25
28
|
isServer: () => boolean;
|
|
26
29
|
/**
|
|
27
30
|
* Overrides the server check globally.
|
|
31
|
+
* @param isServerValue - A function that returns whether the runtime should be treated as a
|
|
32
|
+
* server.
|
|
28
33
|
*/
|
|
29
34
|
setIsServer(isServerValue: IsServerValue): void;
|
|
30
35
|
};
|
|
@@ -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":";;;;YAKY;;;;;qBAQC;;;;;;;;;;;;;;;;;qBAkBA;EAlBe;;;;;;EAyBC,YAAA,eAAA"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
//#region src/environmentManager.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* A function that returns whether the code is running on the server.
|
|
4
|
+
*/
|
|
2
5
|
export type IsServerValue = () => boolean;
|
|
3
6
|
/**
|
|
4
7
|
* Returns whether the current runtime should be treated as a server environment.
|
|
8
|
+
* @returns `true` if the runtime is treated as a server.
|
|
5
9
|
*/
|
|
6
10
|
export declare const isServer: () => boolean;
|
|
7
11
|
/**
|
|
@@ -13,7 +17,6 @@ export declare const isServer: () => boolean;
|
|
|
13
17
|
* Override this for runtimes where that default detection would give the wrong answer — for
|
|
14
18
|
* example, a Service Worker, where `window` is undefined even though the environment should
|
|
15
19
|
* behave like a client.
|
|
16
|
-
*
|
|
17
20
|
* @example
|
|
18
21
|
* ```ts
|
|
19
22
|
* import { environmentManager } from '@tanstack/query-core'
|
|
@@ -25,6 +28,8 @@ export declare const environmentManager: {
|
|
|
25
28
|
isServer: () => boolean;
|
|
26
29
|
/**
|
|
27
30
|
* Overrides the server check globally.
|
|
31
|
+
* @param isServerValue - A function that returns whether the runtime should be treated as a
|
|
32
|
+
* server.
|
|
28
33
|
*/
|
|
29
34
|
setIsServer(isServerValue: IsServerValue): void;
|
|
30
35
|
};
|
|
@@ -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":";;;;YAKY;;;;;qBAQC;;;;;;;;;;;;;;;;;qBAkBA;EAlBe;;;;;;EAyBC,YAAA,eAAA"}
|
|
@@ -3,6 +3,7 @@ import { isServer as isServer$1 } from "./utils.js";
|
|
|
3
3
|
let isServerFn = () => isServer$1;
|
|
4
4
|
/**
|
|
5
5
|
* Returns whether the current runtime should be treated as a server environment.
|
|
6
|
+
* @returns `true` if the runtime is treated as a server.
|
|
6
7
|
*/
|
|
7
8
|
const isServer = () => isServerFn();
|
|
8
9
|
/**
|
|
@@ -14,7 +15,6 @@ const isServer = () => isServerFn();
|
|
|
14
15
|
* Override this for runtimes where that default detection would give the wrong answer — for
|
|
15
16
|
* example, a Service Worker, where `window` is undefined even though the environment should
|
|
16
17
|
* behave like a client.
|
|
17
|
-
*
|
|
18
18
|
* @example
|
|
19
19
|
* ```ts
|
|
20
20
|
* import { environmentManager } from '@tanstack/query-core'
|
|
@@ -26,6 +26,8 @@ const environmentManager = {
|
|
|
26
26
|
isServer,
|
|
27
27
|
/**
|
|
28
28
|
* Overrides the server check globally.
|
|
29
|
+
* @param isServerValue - A function that returns whether the runtime should be treated as a
|
|
30
|
+
* server.
|
|
29
31
|
*/
|
|
30
32
|
setIsServer(isServerValue) {
|
|
31
33
|
isServerFn = isServerValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environmentManager.js","names":["defaultIsServer"],"sources":["../../src/environmentManager.ts"],"sourcesContent":["import { isServer as defaultIsServer } from './utils'\n\nexport type IsServerValue = () => boolean\n\nlet isServerFn: IsServerValue = () => defaultIsServer\n\n/**\n * Returns whether the current runtime should be treated as a server environment.\n */\nexport const isServer = (): boolean => isServerFn()\n\n/**\n * Manages how TanStack Query detects whether the current runtime should be treated as\n * server-side, which disables scheduling refetch timers and changes the default `retry` count\n * and `gcTime`. By default, the detection treats a missing `window` (or the presence of a\n * `Deno` global) as server.\n *\n * Override this for runtimes where that default detection would give the wrong answer — for\n * example, a Service Worker, where `window` is undefined even though the environment should\n * behave like a client.\n
|
|
1
|
+
{"version":3,"file":"environmentManager.js","names":["defaultIsServer"],"sources":["../../src/environmentManager.ts"],"sourcesContent":["import { isServer as defaultIsServer } from './utils'\n\n/**\n * A function that returns whether the code is running on the server.\n */\nexport type IsServerValue = () => boolean\n\nlet isServerFn: IsServerValue = () => defaultIsServer\n\n/**\n * Returns whether the current runtime should be treated as a server environment.\n * @returns `true` if the runtime is treated as a server.\n */\nexport const isServer = (): boolean => isServerFn()\n\n/**\n * Manages how TanStack Query detects whether the current runtime should be treated as\n * server-side, which disables scheduling refetch timers and changes the default `retry` count\n * and `gcTime`. By default, the detection treats a missing `window` (or the presence of a\n * `Deno` global) as server.\n *\n * Override this for runtimes where that default detection would give the wrong answer — for\n * example, a Service Worker, where `window` is undefined even though the environment should\n * behave like a client.\n * @example\n * ```ts\n * import { environmentManager } from '@tanstack/query-core'\n *\n * environmentManager.setIsServer(() => false)\n * ```\n */\nexport const environmentManager = {\n isServer,\n /**\n * Overrides the server check globally.\n * @param isServerValue - A function that returns whether the runtime should be treated as a\n * server.\n */\n setIsServer(isServerValue: IsServerValue): void {\n isServerFn = isServerValue\n },\n}\n"],"mappings":";;AAOA,IAAI,mBAAkCA;;;;;AAMtC,MAAa,iBAA0B,WAAW;;;;;;;;;;;;;;;;;AAkBlD,MAAa,qBAAqB;CAChC;;;;;;CAMA,YAAY,eAAoC;EAC9C,aAAa;CACf;AACF"}
|
|
@@ -42,7 +42,8 @@ var FocusManager = class extends require_subscribable.Subscribable {
|
|
|
42
42
|
* receives a `setFocused` callback: call it with a `boolean` to manually
|
|
43
43
|
* set the focus state, or with no arguments to re-evaluate the current
|
|
44
44
|
* focus state and notify subscribers.
|
|
45
|
-
*
|
|
45
|
+
* @param setup - Receives the `setFocused` callback, registers the event listener, and may return
|
|
46
|
+
* a cleanup function that is called when the listener is replaced or no longer needed.
|
|
46
47
|
* @example
|
|
47
48
|
* ```ts
|
|
48
49
|
* import { focusManager } from '@tanstack/query-core'
|
|
@@ -73,7 +74,7 @@ var FocusManager = class extends require_subscribable.Subscribable {
|
|
|
73
74
|
/**
|
|
74
75
|
* `setFocused` can be used to manually set the focus state. Set `undefined`
|
|
75
76
|
* to fall back to the default focus check.
|
|
76
|
-
*
|
|
77
|
+
* @param focused - The focus state, or `undefined` to use the default focus check.
|
|
77
78
|
* @example
|
|
78
79
|
* ```ts
|
|
79
80
|
* import { focusManager } from '@tanstack/query-core'
|
|
@@ -105,6 +106,7 @@ var FocusManager = class extends require_subscribable.Subscribable {
|
|
|
105
106
|
}
|
|
106
107
|
/**
|
|
107
108
|
* `isFocused` can be used to get the current focus state.
|
|
109
|
+
* @returns The focus state set with `setFocused`, or otherwise whether the document is visible.
|
|
108
110
|
*/
|
|
109
111
|
isFocused() {
|
|
110
112
|
var _globalThis$document;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focusManager.cjs","names":["Subscribable"],"sources":["../../src/focusManager.ts"],"sourcesContent":["import { Subscribable } from './subscribable'\n\ntype Listener = (focused: boolean) => void\n\ntype SetupFn = (\n setFocused: (focused?: boolean) => void,\n) => (() => void) | undefined\n\n/**\n * The `FocusManager` manages the focus state within TanStack Query.\n *\n * It can be used to change the default event listeners or to manually change the focus state.\n */\nexport class FocusManager extends Subscribable<Listener> {\n #focused?: boolean\n #cleanup?: () => void\n\n #setup: SetupFn\n\n constructor() {\n super()\n this.#setup = (onFocus) => {\n // addEventListener does not exist in React Native, but window does\n //
|
|
1
|
+
{"version":3,"file":"focusManager.cjs","names":["Subscribable"],"sources":["../../src/focusManager.ts"],"sourcesContent":["import { Subscribable } from './subscribable'\n\ntype Listener = (focused: boolean) => void\n\ntype SetupFn = (\n setFocused: (focused?: boolean) => void,\n) => (() => void) | undefined\n\n/**\n * The `FocusManager` manages the focus state within TanStack Query.\n *\n * It can be used to change the default event listeners or to manually change the focus state.\n */\nexport class FocusManager extends Subscribable<Listener> {\n #focused?: boolean\n #cleanup?: () => void\n\n #setup: SetupFn\n\n constructor() {\n super()\n this.#setup = (onFocus) => {\n // addEventListener does not exist in React Native, but window does\n // oxlint-disable-next-line typescript/no-unnecessary-condition\n if (typeof window !== 'undefined' && window.addEventListener) {\n const listener = () => onFocus()\n // Listen to visibilitychange\n window.addEventListener('visibilitychange', listener, false)\n\n return () => {\n // Be sure to unsubscribe if a new handler is set\n window.removeEventListener('visibilitychange', listener)\n }\n }\n return\n }\n }\n\n protected override onSubscribe(): void {\n if (!this.#cleanup) {\n this.setEventListener(this.#setup)\n }\n }\n\n protected override onUnsubscribe() {\n if (!this.hasListeners()) {\n this.#cleanup?.()\n this.#cleanup = undefined\n }\n }\n\n /**\n * `setEventListener` can be used to set a custom event listener that will\n * be used to determine the focus state. The provided `setup` function\n * receives a `setFocused` callback: call it with a `boolean` to manually\n * set the focus state, or with no arguments to re-evaluate the current\n * focus state and notify subscribers.\n * @param setup - Receives the `setFocused` callback, registers the event listener, and may return\n * a cleanup function that is called when the listener is replaced or no longer needed.\n * @example\n * ```ts\n * import { focusManager } from '@tanstack/query-core'\n *\n * focusManager.setEventListener((handleFocus) => {\n * const listener = () => handleFocus()\n * // Listen to visibilitychange\n * if (typeof window !== 'undefined' && window.addEventListener) {\n * window.addEventListener('visibilitychange', listener, false)\n * }\n *\n * return () => {\n * // Be sure to unsubscribe if a new handler is set\n * window.removeEventListener('visibilitychange', listener)\n * }\n * })\n * ```\n */\n setEventListener(setup: SetupFn): void {\n this.#setup = setup\n this.#cleanup?.()\n this.#cleanup = setup((focused) => {\n if (typeof focused === 'boolean') {\n this.setFocused(focused)\n } else {\n this.onFocus()\n }\n })\n }\n\n /**\n * `setFocused` can be used to manually set the focus state. Set `undefined`\n * to fall back to the default focus check.\n * @param focused - The focus state, or `undefined` to use the default focus check.\n * @example\n * ```ts\n * import { focusManager } from '@tanstack/query-core'\n *\n * // Set focused\n * focusManager.setFocused(true)\n *\n * // Set unfocused\n * focusManager.setFocused(false)\n *\n * // Fallback to the default focus check\n * focusManager.setFocused(undefined)\n * ```\n */\n setFocused(focused?: boolean): void {\n const changed = this.#focused !== focused\n if (changed) {\n this.#focused = focused\n this.onFocus()\n }\n }\n\n /**\n * `onFocus` notifies all subscribed listeners with the current focus state.\n */\n onFocus(): void {\n const isFocused = this.isFocused()\n this.listeners.forEach((listener) => {\n listener(isFocused)\n })\n }\n\n /**\n * `isFocused` can be used to get the current focus state.\n * @returns The focus state set with `setFocused`, or otherwise whether the document is visible.\n */\n isFocused(): boolean {\n if (typeof this.#focused === 'boolean') {\n return this.#focused\n }\n\n // document global can be unavailable in react native\n // oxlint-disable-next-line typescript/no-unnecessary-condition\n return globalThis.document?.visibilityState !== 'hidden'\n }\n}\n\n/**\n * Singleton instance of {@link FocusManager}, used to manage and observe the focus state within TanStack Query.\n */\nexport const focusManager = new FocusManager()\n"],"mappings":";;;;;;;;;;;;AAaA,IAAa,eAAb,cAAkCA,qBAAAA,aAAuB;CAMvD,cAAc;EACZ,MAAM;;;;EACN,8BAAA,uBAAA,QAAA,OAAe,YAAY;GAGzB,IAAI,OAAO,WAAW,eAAe,OAAO,kBAAkB;IAC5D,MAAM,iBAAiB,QAAQ;IAE/B,OAAO,iBAAiB,oBAAoB,UAAU,KAAK;IAE3D,aAAa;KAEX,OAAO,oBAAoB,oBAAoB,QAAQ;IACzD;GACF;EAEF,CAAA;CACF;CAEA,cAAuC;EACrC,IAAI,CAAA,8BAAA,uBAAA,UAAC,IAAA,GACH,KAAK,iBAAA,8BAAA,uBAAA,QAAiB,IAAA,CAAW;CAErC;CAEA,gBAAmC;EACjC,IAAI,CAAC,KAAK,aAAa,GAAG;;GACxB,CAAA,2BAAA,8BAAA,uBAAA,UAAA,IAAA,OAAA,QAAA,6BAAA,KAAA,KAAA,yBAAA,KAAA,IAAgB;GAChB,8BAAA,uBAAA,UAAA,MAAgB,KAAA,CAAA;EAClB;CACF;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BA,iBAAiB,OAAsB;;EACrC,8BAAA,uBAAA,QAAA,MAAc,KAAA;EACd,CAAA,yBAAA,8BAAA,uBAAA,UAAA,IAAA,OAAA,QAAA,2BAAA,KAAA,KAAA,uBAAA,KAAA,IAAgB;EAChB,8BAAA,uBAAA,UAAA,MAAgB,OAAO,YAAY;GACjC,IAAI,OAAO,YAAY,WACrB,KAAK,WAAW,OAAO;QAEvB,KAAK,QAAQ;EAEjB,CAAC,CAAA;CACH;;;;;;;;;;;;;;;;;;;CAoBA,WAAW,SAAyB;EAElC,IAAA,8BAAA,uBAAA,UADgB,IAAA,MAAkB,SACrB;GACX,8BAAA,uBAAA,UAAA,MAAgB,OAAA;GAChB,KAAK,QAAQ;EACf;CACF;;;;CAKA,UAAgB;EACd,MAAM,YAAY,KAAK,UAAU;EACjC,KAAK,UAAU,SAAS,aAAa;GACnC,SAAS,SAAS;EACpB,CAAC;CACH;;;;;CAMA,YAAqB;;EACnB,IAAI,OAAA,8BAAA,uBAAA,UAAO,IAAA,MAAkB,WAC3B,OAAA,8BAAA,uBAAA,UAAO,IAAA;EAKT,SAAA,uBAAO,WAAW,cAAA,QAAA,yBAAA,KAAA,IAAA,KAAA,IAAA,qBAAU,qBAAoB;CAClD;AACF;;;;AAKA,MAAa,eAAe,IAAI,aAAa"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as Subscribable } from "./subscribable-
|
|
1
|
+
import { t as Subscribable } from "./subscribable-czlHOxMP.cjs";
|
|
2
2
|
//#region src/focusManager.d.ts
|
|
3
3
|
type Listener = (focused: boolean) => void;
|
|
4
4
|
type SetupFn = (setFocused: (focused?: boolean) => void) => (() => void) | undefined;
|
|
@@ -18,7 +18,8 @@ export declare class FocusManager extends Subscribable<Listener> {
|
|
|
18
18
|
* receives a `setFocused` callback: call it with a `boolean` to manually
|
|
19
19
|
* set the focus state, or with no arguments to re-evaluate the current
|
|
20
20
|
* focus state and notify subscribers.
|
|
21
|
-
*
|
|
21
|
+
* @param setup - Receives the `setFocused` callback, registers the event listener, and may return
|
|
22
|
+
* a cleanup function that is called when the listener is replaced or no longer needed.
|
|
22
23
|
* @example
|
|
23
24
|
* ```ts
|
|
24
25
|
* import { focusManager } from '@tanstack/query-core'
|
|
@@ -41,7 +42,7 @@ export declare class FocusManager extends Subscribable<Listener> {
|
|
|
41
42
|
/**
|
|
42
43
|
* `setFocused` can be used to manually set the focus state. Set `undefined`
|
|
43
44
|
* to fall back to the default focus check.
|
|
44
|
-
*
|
|
45
|
+
* @param focused - The focus state, or `undefined` to use the default focus check.
|
|
45
46
|
* @example
|
|
46
47
|
* ```ts
|
|
47
48
|
* import { focusManager } from '@tanstack/query-core'
|
|
@@ -63,6 +64,7 @@ export declare class FocusManager extends Subscribable<Listener> {
|
|
|
63
64
|
onFocus(): void;
|
|
64
65
|
/**
|
|
65
66
|
* `isFocused` can be used to get the current focus state.
|
|
67
|
+
* @returns The focus state set with `setFocused`, or otherwise whether the document is visible.
|
|
66
68
|
*/
|
|
67
69
|
isFocused(): boolean;
|
|
68
70
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focusManager.d.cts","names":[],"sources":["../../src/focusManager.ts"],"mappings":";;KAEK,YAAY;KAEZ,WACH,aAAa;;;;;;qBAQF,qBAAqB,aAAa;;;
|
|
1
|
+
{"version":3,"file":"focusManager.d.cts","names":[],"sources":["../../src/focusManager.ts"],"mappings":";;KAEK,YAAY;KAEZ,WACH,aAAa;;;;;;qBAQF,qBAAqB,aAAa;;;YAyB1B;YAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiCnB,iBAAiB,OAAO;;;;;;;;;;;;;;;;;;;EA8BxB,WAAW;;;;EAWX;;;;;EAWA;;;;;qBAcW,cAAY"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as Subscribable } from "./subscribable-
|
|
1
|
+
import { t as Subscribable } from "./subscribable-czlHOxMP.js";
|
|
2
2
|
//#region src/focusManager.d.ts
|
|
3
3
|
type Listener = (focused: boolean) => void;
|
|
4
4
|
type SetupFn = (setFocused: (focused?: boolean) => void) => (() => void) | undefined;
|
|
@@ -18,7 +18,8 @@ export declare class FocusManager extends Subscribable<Listener> {
|
|
|
18
18
|
* receives a `setFocused` callback: call it with a `boolean` to manually
|
|
19
19
|
* set the focus state, or with no arguments to re-evaluate the current
|
|
20
20
|
* focus state and notify subscribers.
|
|
21
|
-
*
|
|
21
|
+
* @param setup - Receives the `setFocused` callback, registers the event listener, and may return
|
|
22
|
+
* a cleanup function that is called when the listener is replaced or no longer needed.
|
|
22
23
|
* @example
|
|
23
24
|
* ```ts
|
|
24
25
|
* import { focusManager } from '@tanstack/query-core'
|
|
@@ -41,7 +42,7 @@ export declare class FocusManager extends Subscribable<Listener> {
|
|
|
41
42
|
/**
|
|
42
43
|
* `setFocused` can be used to manually set the focus state. Set `undefined`
|
|
43
44
|
* to fall back to the default focus check.
|
|
44
|
-
*
|
|
45
|
+
* @param focused - The focus state, or `undefined` to use the default focus check.
|
|
45
46
|
* @example
|
|
46
47
|
* ```ts
|
|
47
48
|
* import { focusManager } from '@tanstack/query-core'
|
|
@@ -63,6 +64,7 @@ export declare class FocusManager extends Subscribable<Listener> {
|
|
|
63
64
|
onFocus(): void;
|
|
64
65
|
/**
|
|
65
66
|
* `isFocused` can be used to get the current focus state.
|
|
67
|
+
* @returns The focus state set with `setFocused`, or otherwise whether the document is visible.
|
|
66
68
|
*/
|
|
67
69
|
isFocused(): boolean;
|
|
68
70
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focusManager.d.ts","names":[],"sources":["../../src/focusManager.ts"],"mappings":";;KAEK,YAAY;KAEZ,WACH,aAAa;;;;;;qBAQF,qBAAqB,aAAa;;;
|
|
1
|
+
{"version":3,"file":"focusManager.d.ts","names":[],"sources":["../../src/focusManager.ts"],"mappings":";;KAEK,YAAY;KAEZ,WACH,aAAa;;;;;;qBAQF,qBAAqB,aAAa;;;YAyB1B;YAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiCnB,iBAAiB,OAAO;;;;;;;;;;;;;;;;;;;EA8BxB,WAAW;;;;EAWX;;;;;EAWA;;;;;qBAcW,cAAY"}
|
|
@@ -41,7 +41,8 @@ var FocusManager = class extends Subscribable {
|
|
|
41
41
|
* receives a `setFocused` callback: call it with a `boolean` to manually
|
|
42
42
|
* set the focus state, or with no arguments to re-evaluate the current
|
|
43
43
|
* focus state and notify subscribers.
|
|
44
|
-
*
|
|
44
|
+
* @param setup - Receives the `setFocused` callback, registers the event listener, and may return
|
|
45
|
+
* a cleanup function that is called when the listener is replaced or no longer needed.
|
|
45
46
|
* @example
|
|
46
47
|
* ```ts
|
|
47
48
|
* import { focusManager } from '@tanstack/query-core'
|
|
@@ -72,7 +73,7 @@ var FocusManager = class extends Subscribable {
|
|
|
72
73
|
/**
|
|
73
74
|
* `setFocused` can be used to manually set the focus state. Set `undefined`
|
|
74
75
|
* to fall back to the default focus check.
|
|
75
|
-
*
|
|
76
|
+
* @param focused - The focus state, or `undefined` to use the default focus check.
|
|
76
77
|
* @example
|
|
77
78
|
* ```ts
|
|
78
79
|
* import { focusManager } from '@tanstack/query-core'
|
|
@@ -104,6 +105,7 @@ var FocusManager = class extends Subscribable {
|
|
|
104
105
|
}
|
|
105
106
|
/**
|
|
106
107
|
* `isFocused` can be used to get the current focus state.
|
|
108
|
+
* @returns The focus state set with `setFocused`, or otherwise whether the document is visible.
|
|
107
109
|
*/
|
|
108
110
|
isFocused() {
|
|
109
111
|
var _globalThis$document;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focusManager.js","names":[],"sources":["../../src/focusManager.ts"],"sourcesContent":["import { Subscribable } from './subscribable'\n\ntype Listener = (focused: boolean) => void\n\ntype SetupFn = (\n setFocused: (focused?: boolean) => void,\n) => (() => void) | undefined\n\n/**\n * The `FocusManager` manages the focus state within TanStack Query.\n *\n * It can be used to change the default event listeners or to manually change the focus state.\n */\nexport class FocusManager extends Subscribable<Listener> {\n #focused?: boolean\n #cleanup?: () => void\n\n #setup: SetupFn\n\n constructor() {\n super()\n this.#setup = (onFocus) => {\n // addEventListener does not exist in React Native, but window does\n //
|
|
1
|
+
{"version":3,"file":"focusManager.js","names":[],"sources":["../../src/focusManager.ts"],"sourcesContent":["import { Subscribable } from './subscribable'\n\ntype Listener = (focused: boolean) => void\n\ntype SetupFn = (\n setFocused: (focused?: boolean) => void,\n) => (() => void) | undefined\n\n/**\n * The `FocusManager` manages the focus state within TanStack Query.\n *\n * It can be used to change the default event listeners or to manually change the focus state.\n */\nexport class FocusManager extends Subscribable<Listener> {\n #focused?: boolean\n #cleanup?: () => void\n\n #setup: SetupFn\n\n constructor() {\n super()\n this.#setup = (onFocus) => {\n // addEventListener does not exist in React Native, but window does\n // oxlint-disable-next-line typescript/no-unnecessary-condition\n if (typeof window !== 'undefined' && window.addEventListener) {\n const listener = () => onFocus()\n // Listen to visibilitychange\n window.addEventListener('visibilitychange', listener, false)\n\n return () => {\n // Be sure to unsubscribe if a new handler is set\n window.removeEventListener('visibilitychange', listener)\n }\n }\n return\n }\n }\n\n protected override onSubscribe(): void {\n if (!this.#cleanup) {\n this.setEventListener(this.#setup)\n }\n }\n\n protected override onUnsubscribe() {\n if (!this.hasListeners()) {\n this.#cleanup?.()\n this.#cleanup = undefined\n }\n }\n\n /**\n * `setEventListener` can be used to set a custom event listener that will\n * be used to determine the focus state. The provided `setup` function\n * receives a `setFocused` callback: call it with a `boolean` to manually\n * set the focus state, or with no arguments to re-evaluate the current\n * focus state and notify subscribers.\n * @param setup - Receives the `setFocused` callback, registers the event listener, and may return\n * a cleanup function that is called when the listener is replaced or no longer needed.\n * @example\n * ```ts\n * import { focusManager } from '@tanstack/query-core'\n *\n * focusManager.setEventListener((handleFocus) => {\n * const listener = () => handleFocus()\n * // Listen to visibilitychange\n * if (typeof window !== 'undefined' && window.addEventListener) {\n * window.addEventListener('visibilitychange', listener, false)\n * }\n *\n * return () => {\n * // Be sure to unsubscribe if a new handler is set\n * window.removeEventListener('visibilitychange', listener)\n * }\n * })\n * ```\n */\n setEventListener(setup: SetupFn): void {\n this.#setup = setup\n this.#cleanup?.()\n this.#cleanup = setup((focused) => {\n if (typeof focused === 'boolean') {\n this.setFocused(focused)\n } else {\n this.onFocus()\n }\n })\n }\n\n /**\n * `setFocused` can be used to manually set the focus state. Set `undefined`\n * to fall back to the default focus check.\n * @param focused - The focus state, or `undefined` to use the default focus check.\n * @example\n * ```ts\n * import { focusManager } from '@tanstack/query-core'\n *\n * // Set focused\n * focusManager.setFocused(true)\n *\n * // Set unfocused\n * focusManager.setFocused(false)\n *\n * // Fallback to the default focus check\n * focusManager.setFocused(undefined)\n * ```\n */\n setFocused(focused?: boolean): void {\n const changed = this.#focused !== focused\n if (changed) {\n this.#focused = focused\n this.onFocus()\n }\n }\n\n /**\n * `onFocus` notifies all subscribed listeners with the current focus state.\n */\n onFocus(): void {\n const isFocused = this.isFocused()\n this.listeners.forEach((listener) => {\n listener(isFocused)\n })\n }\n\n /**\n * `isFocused` can be used to get the current focus state.\n * @returns The focus state set with `setFocused`, or otherwise whether the document is visible.\n */\n isFocused(): boolean {\n if (typeof this.#focused === 'boolean') {\n return this.#focused\n }\n\n // document global can be unavailable in react native\n // oxlint-disable-next-line typescript/no-unnecessary-condition\n return globalThis.document?.visibilityState !== 'hidden'\n }\n}\n\n/**\n * Singleton instance of {@link FocusManager}, used to manage and observe the focus state within TanStack Query.\n */\nexport const focusManager = new FocusManager()\n"],"mappings":";;;;;;;;;;;AAaA,IAAa,eAAb,cAAkC,aAAuB;CAMvD,cAAc;EACZ,MAAM;;;;EACN,uBAAA,QAAA,OAAe,YAAY;GAGzB,IAAI,OAAO,WAAW,eAAe,OAAO,kBAAkB;IAC5D,MAAM,iBAAiB,QAAQ;IAE/B,OAAO,iBAAiB,oBAAoB,UAAU,KAAK;IAE3D,aAAa;KAEX,OAAO,oBAAoB,oBAAoB,QAAQ;IACzD;GACF;EAEF,CAAA;CACF;CAEA,cAAuC;EACrC,IAAI,CAAA,uBAAA,UAAC,IAAA,GACH,KAAK,iBAAA,uBAAA,QAAiB,IAAA,CAAW;CAErC;CAEA,gBAAmC;EACjC,IAAI,CAAC,KAAK,aAAa,GAAG;;GACxB,CAAA,2BAAA,uBAAA,UAAA,IAAA,OAAA,QAAA,6BAAA,KAAA,KAAA,yBAAA,KAAA,IAAgB;GAChB,uBAAA,UAAA,MAAgB,KAAA,CAAA;EAClB;CACF;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BA,iBAAiB,OAAsB;;EACrC,uBAAA,QAAA,MAAc,KAAA;EACd,CAAA,yBAAA,uBAAA,UAAA,IAAA,OAAA,QAAA,2BAAA,KAAA,KAAA,uBAAA,KAAA,IAAgB;EAChB,uBAAA,UAAA,MAAgB,OAAO,YAAY;GACjC,IAAI,OAAO,YAAY,WACrB,KAAK,WAAW,OAAO;QAEvB,KAAK,QAAQ;EAEjB,CAAC,CAAA;CACH;;;;;;;;;;;;;;;;;;;CAoBA,WAAW,SAAyB;EAElC,IAAA,uBAAA,UADgB,IAAA,MAAkB,SACrB;GACX,uBAAA,UAAA,MAAgB,OAAA;GAChB,KAAK,QAAQ;EACf;CACF;;;;CAKA,UAAgB;EACd,MAAM,YAAY,KAAK,UAAU;EACjC,KAAK,UAAU,SAAS,aAAa;GACnC,SAAS,SAAS;EACpB,CAAC;CACH;;;;;CAMA,YAAqB;;EACnB,IAAI,OAAA,uBAAA,UAAO,IAAA,MAAkB,WAC3B,OAAA,uBAAA,UAAO,IAAA;EAKT,SAAA,uBAAO,WAAW,cAAA,QAAA,yBAAA,KAAA,IAAA,KAAA,IAAA,qBAAU,qBAAoB;CAClD;AACF;;;;AAKA,MAAa,eAAe,IAAI,aAAa"}
|