@tanstack/query-core 5.104.1 → 5.104.3
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-Bf0oMcwO.d.ts} +1411 -129
- package/build/legacy/hydration-Bf0oMcwO.d.ts.map +1 -0
- package/build/legacy/{hydration-Br9VIGXa.d.cts → hydration-C6zghADG.d.cts} +1411 -129
- package/build/legacy/hydration-C6zghADG.d.cts.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-Bf0oMcwO.d.ts} +1411 -129
- package/build/modern/hydration-Bf0oMcwO.d.ts.map +1 -0
- package/build/modern/{hydration-Br9VIGXa.d.cts → hydration-C6zghADG.d.cts} +1411 -129
- package/build/modern/hydration-C6zghADG.d.cts.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 +3 -3
- 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 +114 -42
- 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hydration-C6zghADG.d.cts","names":["FailedAction","SuccessAction","ErrorAction","PauseAction","ContinueAction","Action","Action"],"sources":["../../src/queryObserver.ts","../../src/query.ts","../../src/mutationObserver.ts","../../src/mutationCache.ts","../../src/mutation.ts","../../src/utils.ts","../../src/queryCache.ts","../../src/queryClient.ts","../../src/retryer.ts","../../src/types.ts","../../src/hydration.ts"],"mappings":";;;KA4BK,sBAAsB,OAAO,WAChC,QAAQ,oBAAoB,OAAO;UAG3B,6BAA6B;EACrC;;;;;;;;;;;;;;;;;;;;;cAsBW,cACX,wBACA,SAAS,cACT,QAAQ,cACR,aAAa,cACb,kBAAkB,WAAW,kBACrB,aAAa,sBAAsB,OAAO;;EA0BzC,SAAS,qBACd,cACA,QACA,OACA,YACA;EANF,YAAA,QAAQ,aACD,SAAS,qBACd,cACA,QACA,OACA,YACA;;;;;YAgBM;YAIS;YAcA;;;;;;;EAYnB;;;;;;;EAcA;;;;;;EAaA;;;;;;;;;;;;;;;;;EAuBA,WACE,SAAS,qBACP,cACA,QACA,OACA,YACA;;;;;;;;;EAsFJ,oBACE,SAAS,8BACP,cACA,QACA,OACA,YACA,aAED,oBAAoB,OAAO;;;;;;;;;;;;;EAyC9B,oBAAoB,oBAAoB,OAAO;;;;;;;;;;EAa/C,YACE,QAAQ,oBAAoB,OAAO,SACnC,iBAAiB,WAAW,+BAC3B,oBAAoB,OAAO;;;;;;;;EAiB9B,UAAU,WAAW;;;;;EAQrB,mBAAmB,MAAM,cAAc,QAAQ,YAAY;;;;;;;;;;;;;EAgB3D,aAAa,YAAW,iBAAsB,QAC5C,oBAAoB,OAAO;;;;;;;;;;;;;;;;;;EAwB7B,gBACE,SAAS,qBACP,cACA,QACA,OACA,YACA,aAED,QAAQ,oBAAoB,OAAO;;;;;;;YAmD5B,MACR,cAAc,uBACb,QAAQ,oBAAoB,OAAO;;;;;;;;YAoH5B,aACR,OAAO,MAAM,cAAc,QAAQ,YAAY,YAC/C,SAAS,qBACP,cACA,QACA,OACA,YACA,aAED,oBAAoB,OAAO;;;;;;EAuK9B;;;;;;EAi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1,13 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_utils = require("./utils.cjs");
|
|
3
3
|
//#region src/hydration.ts
|
|
4
|
+
/**
|
|
5
|
+
* Reads the value of a promise synchronously if it has already resolved, e.g. a thenable that
|
|
6
|
+
* resolves within its `then` call.
|
|
7
|
+
* @param promise - The promise to read.
|
|
8
|
+
* @returns An object with the resolved `data`, or `undefined` if the promise hasn't resolved
|
|
9
|
+
* synchronously (or resolved with `undefined`).
|
|
10
|
+
*/
|
|
4
11
|
function tryResolveSync(promise) {
|
|
5
12
|
let data;
|
|
6
13
|
promise.then((result) => {
|
|
@@ -9,6 +16,11 @@ function tryResolveSync(promise) {
|
|
|
9
16
|
}, require_utils.noop)?.catch?.(require_utils.noop);
|
|
10
17
|
if (data !== void 0) return { data };
|
|
11
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Dehydrates a single `Mutation` into a serializable snapshot of its key, state, scope, and meta.
|
|
21
|
+
* @param mutation - The mutation to dehydrate.
|
|
22
|
+
* @returns The dehydrated mutation.
|
|
23
|
+
*/
|
|
12
24
|
function dehydrateMutation(mutation) {
|
|
13
25
|
return {
|
|
14
26
|
mutationKey: mutation.options.mutationKey,
|
|
@@ -17,6 +29,16 @@ function dehydrateMutation(mutation) {
|
|
|
17
29
|
...mutation.meta && { meta: mutation.meta }
|
|
18
30
|
};
|
|
19
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Prepares the in-flight promise of a pending query for dehydration: applies `serializeData` to its
|
|
34
|
+
* result, and redacts its rejection error unless `shouldRedactErrors` returns `false` for it.
|
|
35
|
+
* @param query - The pending query whose promise is dehydrated.
|
|
36
|
+
* @param serializeData - Optional transform applied to the resolved data.
|
|
37
|
+
* @param shouldRedactErrors - Optional predicate; if it returns `false` for the rejection error,
|
|
38
|
+
* that
|
|
39
|
+
* error is kept as-is instead of being redacted.
|
|
40
|
+
* @returns The transformed promise, or `undefined` if the query has no in-flight promise.
|
|
41
|
+
*/
|
|
20
42
|
function dehydratePromise(query, serializeData, shouldRedactErrors) {
|
|
21
43
|
const promise = query.promise?.then(serializeData).catch((error) => {
|
|
22
44
|
if (shouldRedactErrors?.(error) === false) return Promise.reject(error);
|
|
@@ -35,6 +57,7 @@ function dehydratePromise(query, serializeData, shouldRedactErrors) {
|
|
|
35
57
|
* @param serializeData - Optional transform applied to `query.state.data` before it is included in the snapshot.
|
|
36
58
|
* @param shouldRedactErrors - Optional predicate; if it returns `false` for the promise's rejection error, that
|
|
37
59
|
* error is kept as-is instead of being redacted.
|
|
60
|
+
* @returns The dehydrated query.
|
|
38
61
|
*/
|
|
39
62
|
function dehydrateQuery(query, serializeData, shouldRedactErrors) {
|
|
40
63
|
return {
|
|
@@ -53,6 +76,8 @@ function dehydrateQuery(query, serializeData, shouldRedactErrors) {
|
|
|
53
76
|
/**
|
|
54
77
|
* The default `shouldDehydrateMutation` predicate used by `dehydrate`. Only dehydrates mutations that are
|
|
55
78
|
* currently paused (e.g. paused by `networkMode` while offline).
|
|
79
|
+
* @param mutation - The mutation to check.
|
|
80
|
+
* @returns `true` if the mutation is paused.
|
|
56
81
|
*/
|
|
57
82
|
function defaultShouldDehydrateMutation(mutation) {
|
|
58
83
|
return mutation.state.isPaused;
|
|
@@ -60,6 +85,8 @@ function defaultShouldDehydrateMutation(mutation) {
|
|
|
60
85
|
/**
|
|
61
86
|
* The default `shouldDehydrateQuery` predicate used by `dehydrate`. Only dehydrates queries whose status is
|
|
62
87
|
* `'success'`.
|
|
88
|
+
* @param query - The query to check.
|
|
89
|
+
* @returns `true` if the query's status is `'success'`.
|
|
63
90
|
*/
|
|
64
91
|
function defaultShouldDehydrateQuery(query) {
|
|
65
92
|
return query.state.status === "success";
|
|
@@ -70,6 +97,10 @@ function defaultShouldDehydrateQuery(query) {
|
|
|
70
97
|
* Which queries/mutations are included, and how their data/errors are transformed, is controlled by `options`,
|
|
71
98
|
* falling back to the client's `dehydrate` default options, and finally to `defaultShouldDehydrateQuery` /
|
|
72
99
|
* `defaultShouldDehydrateMutation`.
|
|
100
|
+
* @param client - The client whose cache is dehydrated.
|
|
101
|
+
* @param options - Controls which queries and mutations are included and how their data and errors
|
|
102
|
+
* are transformed. Each option falls back to the client's `defaultOptions.dehydrate`.
|
|
103
|
+
* @returns The dehydrated state, with the included `queries` and `mutations`.
|
|
73
104
|
* @example
|
|
74
105
|
* ```ts
|
|
75
106
|
* const queryClient = new QueryClient()
|
|
@@ -101,6 +132,10 @@ function dehydrate(client, options = {}) {
|
|
|
101
132
|
* to `'idle'` so they don't hydrate stuck in a fetching state. If a dehydrated query still had an in-flight
|
|
102
133
|
* promise, it is resumed via `query.fetch()` (reusing that promise as `initialPromise`) rather than re-invoking
|
|
103
134
|
* `queryFn`.
|
|
135
|
+
* @param client - The client whose cache is restored into.
|
|
136
|
+
* @param dehydratedState - The dehydrated state, e.g. produced by `dehydrate` on the server.
|
|
137
|
+
* @param options - `defaultOptions` merged into every restored query and mutation (on top of the
|
|
138
|
+
* client's `defaultOptions.hydrate`), and `deserializeData` to reverse `serializeData`.
|
|
104
139
|
* @example
|
|
105
140
|
* ```ts
|
|
106
141
|
* // dehydratedState was produced by `dehydrate` on the server
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hydration.cjs","names":["noop"],"sources":["../../src/hydration.ts"],"sourcesContent":["import { noop } from './utils'\nimport type {\n DefaultError,\n MutationKey,\n MutationMeta,\n MutationOptions,\n MutationScope,\n QueryKey,\n QueryMeta,\n QueryOptions,\n} from './types'\nimport type { QueryClient } from './queryClient'\nimport type { Query, QueryState } from './query'\nimport type { Mutation, MutationState } from './mutation'\n\n// TYPES\ntype TransformerFn = (data: any) => any\n\nfunction tryResolveSync(promise: PromiseLike<unknown>) {\n let data: unknown\n\n const thenResult = promise.then((result) => {\n data = result\n return result\n }, noop) as Promise<unknown> | undefined\n\n // .catch can be unavailable on certain kinds of thenable's\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n thenResult?.catch?.(noop)\n\n if (data !== undefined) {\n return { data }\n }\n\n return undefined\n}\n\n/**\n * Options for `dehydrate`, controlling which queries/mutations are included in the resulting `DehydratedState` and\n * how their data/errors are transformed before being serialized (e.g. for embedding in server-rendered markup).\n */\nexport interface DehydrateOptions {\n /** Transforms a query's `data` before it is dehydrated. Useful for non-JSON-serializable data. */\n serializeData?: TransformerFn\n /** Predicate to decide whether a given `Mutation` should be dehydrated. Defaults to `defaultShouldDehydrateMutation`. */\n shouldDehydrateMutation?: (mutation: Mutation) => boolean\n /** Predicate to decide whether a given `Query` should be dehydrated. Defaults to `defaultShouldDehydrateQuery`. */\n shouldDehydrateQuery?: (query: Query) => boolean\n /**\n * Predicate to decide whether a query's error should be redacted before dehydration. Errors are redacted\n * (replaced with a generic `Error('redacted')`) unless this function is provided and returns `false` for the\n * given error, in which case the original error is kept.\n */\n shouldRedactErrors?: (error: unknown) => boolean\n}\n\n/**\n * Options for `hydrate`, controlling the default options applied to queries/mutations restored from a\n * `DehydratedState`, and how to reverse any transformation applied by `DehydrateOptions.serializeData`.\n */\nexport interface HydrateOptions {\n /** Options applied to the queries and mutations restored from the dehydrated state. */\n defaultOptions?: {\n /** Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. */\n deserializeData?: TransformerFn\n /** Default options merged into every query restored from the dehydrated state. */\n queries?: QueryOptions\n /** Default options merged into every mutation restored from the dehydrated state. */\n mutations?: MutationOptions<unknown, DefaultError, unknown, unknown>\n }\n}\n\ninterface DehydratedMutation {\n mutationKey?: MutationKey\n state: MutationState\n meta?: MutationMeta\n scope?: MutationScope\n}\n\ninterface DehydratedQuery {\n queryHash: string\n queryKey: QueryKey\n state: QueryState\n dehydratedAt: number\n promise?: Promise<unknown>\n meta?: QueryMeta\n queryType?: 'infinite'\n}\n\n/**\n * A serializable snapshot of a `QueryClient`'s cache, as produced by `dehydrate` and consumed by `hydrate`. Typically\n * transported from server to client (e.g. embedded in server-rendered markup) to seed the client's cache with data\n * that has already been fetched, avoiding a redundant fetch on the client.\n */\nexport interface DehydratedState {\n mutations: Array<DehydratedMutation>\n queries: Array<DehydratedQuery>\n}\n\n// FUNCTIONS\n\nfunction dehydrateMutation(mutation: Mutation): DehydratedMutation {\n return {\n mutationKey: mutation.options.mutationKey,\n state: mutation.state,\n ...(mutation.options.scope && { scope: mutation.options.scope }),\n ...(mutation.meta && { meta: mutation.meta }),\n }\n}\n\nfunction dehydratePromise(\n query: Query,\n serializeData?: TransformerFn,\n shouldRedactErrors?: (error: unknown) => boolean,\n): Promise<unknown> | undefined {\n const promise = query.promise?.then(serializeData).catch((error) => {\n if (shouldRedactErrors?.(error) === false) {\n // Reject original error if it should not be redacted\n return Promise.reject(error)\n }\n // If not in production, log original error before rejecting redacted error\n if (process.env.NODE_ENV !== 'production') {\n console.error(\n `A query that was dehydrated as pending ended up rejecting. [${query.queryHash}]: ${error}; The error will be redacted in production builds`,\n )\n }\n return Promise.reject(new Error('redacted'))\n })\n\n // Avoid unhandled promise rejections\n // We need the promise we dehydrate to reject to get the correct result into\n // the query cache, but we also want to avoid unhandled promise rejections\n // in whatever environment the prefetches are happening in.\n promise?.catch(noop)\n\n return promise\n}\n\n/**\n * Dehydrates a single `Query` into a serializable `DehydratedQuery` snapshot. Note that most query config (e.g.\n * `queryFn`, `staleTime`) is not dehydrated but instead meant to be configured again when consuming the\n * de/rehydrated data, typically with `useQuery` on the client. If the query is still `pending`, its in-flight\n * promise is dehydrated too so it can be resumed on the other side instead of re-fetched.\n * @param query - The query to dehydrate.\n * @param serializeData - Optional transform applied to `query.state.data` before it is included in the snapshot.\n * @param shouldRedactErrors - Optional predicate; if it returns `false` for the promise's rejection error, that\n * error is kept as-is instead of being redacted.\n */\nexport function dehydrateQuery(\n query: Query,\n serializeData?: TransformerFn,\n shouldRedactErrors?: (error: unknown) => boolean,\n): DehydratedQuery {\n return {\n dehydratedAt: Date.now(),\n state: {\n ...query.state,\n ...(query.state.data !== undefined && {\n data: serializeData\n ? serializeData(query.state.data)\n : query.state.data,\n }),\n },\n queryKey: query.queryKey,\n queryHash: query.queryHash,\n ...(query.state.status === 'pending' && {\n promise: dehydratePromise(query, serializeData, shouldRedactErrors),\n }),\n ...(query.meta && { meta: query.meta }),\n ...(query.queryType && { queryType: query.queryType }),\n }\n}\n\n/**\n * The default `shouldDehydrateMutation` predicate used by `dehydrate`. Only dehydrates mutations that are\n * currently paused (e.g. paused by `networkMode` while offline).\n */\nexport function defaultShouldDehydrateMutation(mutation: Mutation) {\n return mutation.state.isPaused\n}\n\n/**\n * The default `shouldDehydrateQuery` predicate used by `dehydrate`. Only dehydrates queries whose status is\n * `'success'`.\n */\nexport function defaultShouldDehydrateQuery(query: Query) {\n return query.state.status === 'success'\n}\n\n/**\n * Dehydrates a `QueryClient`'s cache (queries and mutations) into a plain, serializable `DehydratedState`,\n * typically to embed in server-rendered markup and later restore into a client-side `QueryClient` via `hydrate`.\n * Which queries/mutations are included, and how their data/errors are transformed, is controlled by `options`,\n * falling back to the client's `dehydrate` default options, and finally to `defaultShouldDehydrateQuery` /\n * `defaultShouldDehydrateMutation`.\n * @example\n * ```ts\n * const queryClient = new QueryClient()\n *\n * await queryClient.prefetchQuery({\n * queryKey: ['posts'],\n * queryFn: getPosts,\n * })\n *\n * const dehydratedState = dehydrate(queryClient)\n * ```\n */\nexport function dehydrate(\n client: QueryClient,\n options: DehydrateOptions = {},\n): DehydratedState {\n const filterMutation =\n options.shouldDehydrateMutation ??\n client.getDefaultOptions().dehydrate?.shouldDehydrateMutation ??\n defaultShouldDehydrateMutation\n\n const mutations = client\n .getMutationCache()\n .getAll()\n .flatMap((mutation) =>\n filterMutation(mutation) ? [dehydrateMutation(mutation)] : [],\n )\n\n const filterQuery =\n options.shouldDehydrateQuery ??\n client.getDefaultOptions().dehydrate?.shouldDehydrateQuery ??\n defaultShouldDehydrateQuery\n\n const shouldRedactErrors =\n options.shouldRedactErrors ??\n client.getDefaultOptions().dehydrate?.shouldRedactErrors\n\n const serializeData =\n options.serializeData ?? client.getDefaultOptions().dehydrate?.serializeData\n\n const queries = client\n .getQueryCache()\n .getAll()\n .flatMap((query) =>\n filterQuery(query)\n ? [dehydrateQuery(query, serializeData, shouldRedactErrors)]\n : [],\n )\n\n return { mutations, queries }\n}\n\n/**\n * Restores a `DehydratedState` (as produced by `dehydrate`) into a `QueryClient`'s cache, typically to seed the\n * client with data already fetched on the server. `mutations` and `queries` are each optional on `dehydratedState`.\n * Queries not yet in the cache are built from the dehydrated snapshot; queries that already exist are only updated\n * when the dehydrated data is newer than what's already cached. Newly built queries have their `fetchStatus` reset\n * to `'idle'` so they don't hydrate stuck in a fetching state. If a dehydrated query still had an in-flight\n * promise, it is resumed via `query.fetch()` (reusing that promise as `initialPromise`) rather than re-invoking\n * `queryFn`.\n * @example\n * ```ts\n * // dehydratedState was produced by `dehydrate` on the server\n * // and sent to the client, e.g. embedded in server-rendered markup.\n * const queryClient = new QueryClient()\n *\n * hydrate(queryClient, dehydratedState)\n * ```\n */\nexport function hydrate(\n client: QueryClient,\n dehydratedState: Partial<DehydratedState>,\n options?: HydrateOptions,\n): void {\n const mutationCache = client.getMutationCache()\n const queryCache = client.getQueryCache()\n const deserializeData =\n options?.defaultOptions?.deserializeData ??\n client.getDefaultOptions().hydrate?.deserializeData\n\n dehydratedState.mutations?.forEach(({ state, ...mutationOptions }) => {\n mutationCache.build(\n client,\n {\n ...client.getDefaultOptions().hydrate?.mutations,\n ...options?.defaultOptions?.mutations,\n ...mutationOptions,\n },\n state,\n )\n })\n\n dehydratedState.queries?.forEach(\n ({\n queryKey,\n state,\n queryHash,\n meta,\n promise,\n dehydratedAt,\n queryType,\n }) => {\n const syncData = promise ? tryResolveSync(promise) : undefined\n const rawData = state.data === undefined ? syncData?.data : state.data\n const data =\n rawData === undefined\n ? rawData\n : deserializeData\n ? deserializeData(rawData)\n : rawData\n\n let query = queryCache.get(queryHash)\n const existingQueryIsPending = query?.state.status === 'pending'\n const existingQueryIsFetching = query?.state.fetchStatus === 'fetching'\n\n // Do not hydrate if an existing query exists with newer data\n if (query) {\n const hasNewerSyncData =\n syncData && dehydratedAt > query.state.dataUpdatedAt\n if (\n state.dataUpdatedAt > query.state.dataUpdatedAt ||\n hasNewerSyncData\n ) {\n // Omit fetchStatus from dehydrated state so that query stays in its current fetchStatus\n const { fetchStatus: _ignored, ...serializedState } = state\n query.setState({\n ...serializedState,\n data,\n // If the query was pending at the moment of dehydration, but resolved to have data\n // before hydration, we can assume the query should be hydrated as successful.\n //\n // Since you can opt into dehydrating failed queries, and those can have data from\n // previous successful fetches, we make sure we only do this for pending queries.\n ...(state.status === 'pending' &&\n data !== undefined && {\n status: 'success' as const,\n dataUpdatedAt: dehydratedAt,\n // Preserve existing fetchStatus if the existing query is actively fetching.\n ...(!existingQueryIsFetching && {\n fetchStatus: 'idle' as const,\n }),\n }),\n })\n }\n } else {\n // Restore query\n query = queryCache.build(\n client,\n {\n ...client.getDefaultOptions().hydrate?.queries,\n ...options?.defaultOptions?.queries,\n queryKey,\n queryHash,\n meta,\n _type: queryType,\n },\n // Reset fetch status to idle to avoid\n // query being stuck in fetching state upon hydration\n {\n ...state,\n data,\n fetchStatus: 'idle',\n // Like above, if the query was pending at the moment of dehydration but has data,\n // we can assume it should be hydrated as successful.\n status:\n state.status === 'pending' && data !== undefined\n ? 'success'\n : state.status,\n ...(state.status === 'pending' &&\n data !== undefined && {\n dataUpdatedAt: dehydratedAt,\n }),\n },\n )\n }\n\n if (\n promise &&\n // If the data was synchronously available, there is no need to set up\n // a retryer and thus no reason to call fetch\n !syncData &&\n !existingQueryIsPending &&\n !existingQueryIsFetching &&\n // Only hydrate if dehydration is newer than any existing data,\n // this is always true for new queries\n dehydratedAt > query.state.dataUpdatedAt\n ) {\n // This doesn't actually fetch - it just creates a retryer\n // which will re-use the passed `initialPromise`\n query\n .fetch(undefined, {\n // RSC transformed promises are not thenable\n initialPromise: Promise.resolve(promise).then(deserializeData),\n })\n // Avoid unhandled promise rejections\n .catch(noop)\n }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Content":["import { noop } from './utils'\nimport type {\n DefaultError,\n MutationKey,\n MutationMeta,\n MutationOptions,\n MutationScope,\n QueryKey,\n QueryMeta,\n QueryOptions,\n} from './types'\nimport type { QueryClient } from './queryClient'\nimport type { Query, QueryState } from './query'\nimport type { Mutation, MutationState } from './mutation'\n\n// TYPES\ntype TransformerFn = (data: any) => any\n\n/**\n * Reads the value of a promise synchronously if it has already resolved, e.g. a thenable that\n * resolves within its `then` call.\n * @param promise - The promise to read.\n * @returns An object with the resolved `data`, or `undefined` if the promise hasn't resolved\n * synchronously (or resolved with `undefined`).\n */\nfunction tryResolveSync(promise: PromiseLike<unknown>) {\n let data: unknown\n\n const thenResult = promise.then((result) => {\n data = result\n return result\n }, noop) as Promise<unknown> | undefined\n\n // .catch can be unavailable on certain kinds of thenable's\n // oxlint-disable-next-line typescript/no-unnecessary-condition\n thenResult?.catch?.(noop)\n\n if (data !== undefined) {\n return { data }\n }\n\n return undefined\n}\n\n/**\n * Options for `dehydrate`, controlling which queries/mutations are included in the resulting `DehydratedState` and\n * how their data/errors are transformed before being serialized (e.g. for embedding in server-rendered markup).\n */\nexport interface DehydrateOptions {\n /** Transforms a query's `data` before it is dehydrated. Useful for non-JSON-serializable data. */\n serializeData?: TransformerFn\n /** Predicate to decide whether a given `Mutation` should be dehydrated. Defaults to `defaultShouldDehydrateMutation`. */\n shouldDehydrateMutation?: (mutation: Mutation) => boolean\n /** Predicate to decide whether a given `Query` should be dehydrated. Defaults to `defaultShouldDehydrateQuery`. */\n shouldDehydrateQuery?: (query: Query) => boolean\n /**\n * Predicate to decide whether a query's error should be redacted before dehydration. Errors are redacted\n * (replaced with a generic `Error('redacted')`) unless this function is provided and returns `false` for the\n * given error, in which case the original error is kept.\n */\n shouldRedactErrors?: (error: unknown) => boolean\n}\n\n/**\n * Options for `hydrate`, controlling the default options applied to queries/mutations restored from a\n * `DehydratedState`, and how to reverse any transformation applied by `DehydrateOptions.serializeData`.\n */\nexport interface HydrateOptions {\n /** Options applied to the queries and mutations restored from the dehydrated state. */\n defaultOptions?: {\n /** Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. */\n deserializeData?: TransformerFn\n /** Default options merged into every query restored from the dehydrated state. */\n queries?: QueryOptions\n /** Default options merged into every mutation restored from the dehydrated state. */\n mutations?: MutationOptions<unknown, DefaultError, unknown, unknown>\n }\n}\n\ninterface DehydratedMutation {\n mutationKey?: MutationKey\n state: MutationState\n meta?: MutationMeta\n scope?: MutationScope\n}\n\ninterface DehydratedQuery {\n queryHash: string\n queryKey: QueryKey\n state: QueryState\n dehydratedAt: number\n promise?: Promise<unknown>\n meta?: QueryMeta\n queryType?: 'infinite'\n}\n\n/**\n * A serializable snapshot of a `QueryClient`'s cache, as produced by `dehydrate` and consumed by `hydrate`. Typically\n * transported from server to client (e.g. embedded in server-rendered markup) to seed the client's cache with data\n * that has already been fetched, avoiding a redundant fetch on the client.\n */\nexport interface DehydratedState {\n /**\n * The dehydrated mutations, by default only the paused ones.\n */\n mutations: Array<DehydratedMutation>\n /**\n * The dehydrated queries, by default only the successful ones.\n */\n queries: Array<DehydratedQuery>\n}\n\n// FUNCTIONS\n\n/**\n * Dehydrates a single `Mutation` into a serializable snapshot of its key, state, scope, and meta.\n * @param mutation - The mutation to dehydrate.\n * @returns The dehydrated mutation.\n */\nfunction dehydrateMutation(mutation: Mutation): DehydratedMutation {\n return {\n mutationKey: mutation.options.mutationKey,\n state: mutation.state,\n ...(mutation.options.scope && { scope: mutation.options.scope }),\n ...(mutation.meta && { meta: mutation.meta }),\n }\n}\n\n/**\n * Prepares the in-flight promise of a pending query for dehydration: applies `serializeData` to its\n * result, and redacts its rejection error unless `shouldRedactErrors` returns `false` for it.\n * @param query - The pending query whose promise is dehydrated.\n * @param serializeData - Optional transform applied to the resolved data.\n * @param shouldRedactErrors - Optional predicate; if it returns `false` for the rejection error,\n * that\n * error is kept as-is instead of being redacted.\n * @returns The transformed promise, or `undefined` if the query has no in-flight promise.\n */\nfunction dehydratePromise(\n query: Query,\n serializeData?: TransformerFn,\n shouldRedactErrors?: (error: unknown) => boolean,\n): Promise<unknown> | undefined {\n const promise = query.promise?.then(serializeData).catch((error) => {\n if (shouldRedactErrors?.(error) === false) {\n // Reject original error if it should not be redacted\n return Promise.reject(error)\n }\n // If not in production, log original error before rejecting redacted error\n if (process.env.NODE_ENV !== 'production') {\n console.error(\n `A query that was dehydrated as pending ended up rejecting. [${query.queryHash}]: ${error}; The error will be redacted in production builds`,\n )\n }\n return Promise.reject(new Error('redacted'))\n })\n\n // Avoid unhandled promise rejections\n // We need the promise we dehydrate to reject to get the correct result into\n // the query cache, but we also want to avoid unhandled promise rejections\n // in whatever environment the prefetches are happening in.\n promise?.catch(noop)\n\n return promise\n}\n\n/**\n * Dehydrates a single `Query` into a serializable `DehydratedQuery` snapshot. Note that most query config (e.g.\n * `queryFn`, `staleTime`) is not dehydrated but instead meant to be configured again when consuming the\n * de/rehydrated data, typically with `useQuery` on the client. If the query is still `pending`, its in-flight\n * promise is dehydrated too so it can be resumed on the other side instead of re-fetched.\n * @param query - The query to dehydrate.\n * @param serializeData - Optional transform applied to `query.state.data` before it is included in the snapshot.\n * @param shouldRedactErrors - Optional predicate; if it returns `false` for the promise's rejection error, that\n * error is kept as-is instead of being redacted.\n * @returns The dehydrated query.\n */\nexport function dehydrateQuery(\n query: Query,\n serializeData?: TransformerFn,\n shouldRedactErrors?: (error: unknown) => boolean,\n): DehydratedQuery {\n return {\n dehydratedAt: Date.now(),\n state: {\n ...query.state,\n ...(query.state.data !== undefined && {\n data: serializeData\n ? serializeData(query.state.data)\n : query.state.data,\n }),\n },\n queryKey: query.queryKey,\n queryHash: query.queryHash,\n ...(query.state.status === 'pending' && {\n promise: dehydratePromise(query, serializeData, shouldRedactErrors),\n }),\n ...(query.meta && { meta: query.meta }),\n ...(query.queryType && { queryType: query.queryType }),\n }\n}\n\n/**\n * The default `shouldDehydrateMutation` predicate used by `dehydrate`. Only dehydrates mutations that are\n * currently paused (e.g. paused by `networkMode` while offline).\n * @param mutation - The mutation to check.\n * @returns `true` if the mutation is paused.\n */\nexport function defaultShouldDehydrateMutation(mutation: Mutation) {\n return mutation.state.isPaused\n}\n\n/**\n * The default `shouldDehydrateQuery` predicate used by `dehydrate`. Only dehydrates queries whose status is\n * `'success'`.\n * @param query - The query to check.\n * @returns `true` if the query's status is `'success'`.\n */\nexport function defaultShouldDehydrateQuery(query: Query) {\n return query.state.status === 'success'\n}\n\n/**\n * Dehydrates a `QueryClient`'s cache (queries and mutations) into a plain, serializable `DehydratedState`,\n * typically to embed in server-rendered markup and later restore into a client-side `QueryClient` via `hydrate`.\n * Which queries/mutations are included, and how their data/errors are transformed, is controlled by `options`,\n * falling back to the client's `dehydrate` default options, and finally to `defaultShouldDehydrateQuery` /\n * `defaultShouldDehydrateMutation`.\n * @param client - The client whose cache is dehydrated.\n * @param options - Controls which queries and mutations are included and how their data and errors\n * are transformed. Each option falls back to the client's `defaultOptions.dehydrate`.\n * @returns The dehydrated state, with the included `queries` and `mutations`.\n * @example\n * ```ts\n * const queryClient = new QueryClient()\n *\n * await queryClient.prefetchQuery({\n * queryKey: ['posts'],\n * queryFn: getPosts,\n * })\n *\n * const dehydratedState = dehydrate(queryClient)\n * ```\n */\nexport function dehydrate(\n client: QueryClient,\n options: DehydrateOptions = {},\n): DehydratedState {\n const filterMutation =\n options.shouldDehydrateMutation ??\n client.getDefaultOptions().dehydrate?.shouldDehydrateMutation ??\n defaultShouldDehydrateMutation\n\n const mutations = client\n .getMutationCache()\n .getAll()\n .flatMap((mutation) =>\n filterMutation(mutation) ? [dehydrateMutation(mutation)] : [],\n )\n\n const filterQuery =\n options.shouldDehydrateQuery ??\n client.getDefaultOptions().dehydrate?.shouldDehydrateQuery ??\n defaultShouldDehydrateQuery\n\n const shouldRedactErrors =\n options.shouldRedactErrors ??\n client.getDefaultOptions().dehydrate?.shouldRedactErrors\n\n const serializeData =\n options.serializeData ?? client.getDefaultOptions().dehydrate?.serializeData\n\n const queries = client\n .getQueryCache()\n .getAll()\n .flatMap((query) =>\n filterQuery(query)\n ? [dehydrateQuery(query, serializeData, shouldRedactErrors)]\n : [],\n )\n\n return { mutations, queries }\n}\n\n/**\n * Restores a `DehydratedState` (as produced by `dehydrate`) into a `QueryClient`'s cache, typically to seed the\n * client with data already fetched on the server. `mutations` and `queries` are each optional on `dehydratedState`.\n * Queries not yet in the cache are built from the dehydrated snapshot; queries that already exist are only updated\n * when the dehydrated data is newer than what's already cached. Newly built queries have their `fetchStatus` reset\n * to `'idle'` so they don't hydrate stuck in a fetching state. If a dehydrated query still had an in-flight\n * promise, it is resumed via `query.fetch()` (reusing that promise as `initialPromise`) rather than re-invoking\n * `queryFn`.\n * @param client - The client whose cache is restored into.\n * @param dehydratedState - The dehydrated state, e.g. produced by `dehydrate` on the server.\n * @param options - `defaultOptions` merged into every restored query and mutation (on top of the\n * client's `defaultOptions.hydrate`), and `deserializeData` to reverse `serializeData`.\n * @example\n * ```ts\n * // dehydratedState was produced by `dehydrate` on the server\n * // and sent to the client, e.g. embedded in server-rendered markup.\n * const queryClient = new QueryClient()\n *\n * hydrate(queryClient, dehydratedState)\n * ```\n */\nexport function hydrate(\n client: QueryClient,\n dehydratedState: Partial<DehydratedState>,\n options?: HydrateOptions,\n): void {\n const mutationCache = client.getMutationCache()\n const queryCache = client.getQueryCache()\n const deserializeData =\n options?.defaultOptions?.deserializeData ??\n client.getDefaultOptions().hydrate?.deserializeData\n\n dehydratedState.mutations?.forEach(({ state, ...mutationOptions }) => {\n mutationCache.build(\n client,\n {\n ...client.getDefaultOptions().hydrate?.mutations,\n ...options?.defaultOptions?.mutations,\n ...mutationOptions,\n },\n state,\n )\n })\n\n dehydratedState.queries?.forEach(\n ({\n queryKey,\n state,\n queryHash,\n meta,\n promise,\n dehydratedAt,\n queryType,\n }) => {\n const syncData = promise ? tryResolveSync(promise) : undefined\n const rawData = state.data === undefined ? syncData?.data : state.data\n const data =\n rawData === undefined\n ? rawData\n : deserializeData\n ? deserializeData(rawData)\n : rawData\n\n let query = queryCache.get(queryHash)\n const existingQueryIsPending = query?.state.status === 'pending'\n const existingQueryIsFetching = query?.state.fetchStatus === 'fetching'\n\n // Do not hydrate if an existing query exists with newer data\n if (query) {\n const hasNewerSyncData =\n syncData && dehydratedAt > query.state.dataUpdatedAt\n if (\n state.dataUpdatedAt > query.state.dataUpdatedAt ||\n hasNewerSyncData\n ) {\n // Omit fetchStatus from dehydrated state so that query stays in its current fetchStatus\n const { fetchStatus: _ignored, ...serializedState } = state\n query.setState({\n ...serializedState,\n data,\n // If the query was pending at the moment of dehydration, but resolved to have data\n // before hydration, we can assume the query should be hydrated as successful.\n //\n // Since you can opt into dehydrating failed queries, and those can have data from\n // previous successful fetches, we make sure we only do this for pending queries.\n ...(state.status === 'pending' &&\n data !== undefined && {\n status: 'success' as const,\n dataUpdatedAt: dehydratedAt,\n // Preserve existing fetchStatus if the existing query is actively fetching.\n ...(!existingQueryIsFetching && {\n fetchStatus: 'idle' as const,\n }),\n }),\n })\n }\n } else {\n // Restore query\n query = queryCache.build(\n client,\n {\n ...client.getDefaultOptions().hydrate?.queries,\n ...options?.defaultOptions?.queries,\n queryKey,\n queryHash,\n meta,\n _type: queryType,\n },\n // Reset fetch status to idle to avoid\n // query being stuck in fetching state upon hydration\n {\n ...state,\n data,\n fetchStatus: 'idle',\n // Like above, if the query was pending at the moment of dehydration but has data,\n // we can assume it should be hydrated as successful.\n status:\n state.status === 'pending' && data !== undefined\n ? 'success'\n : state.status,\n ...(state.status === 'pending' &&\n data !== undefined && {\n dataUpdatedAt: dehydratedAt,\n }),\n },\n )\n }\n\n if (\n promise &&\n // If the data was synchronously available, there is no need to set up\n // a retryer and thus no reason to call fetch\n !syncData &&\n !existingQueryIsPending &&\n !existingQueryIsFetching &&\n // Only hydrate if dehydration is newer than any existing data,\n // this is always true for new queries\n dehydratedAt > query.state.dataUpdatedAt\n ) {\n // This doesn't actually fetch - it just creates a retryer\n // which will re-use the passed `initialPromise`\n query\n .fetch(undefined, {\n // RSC transformed promises are not thenable\n initialPromise: Promise.resolve(promise).then(deserializeData),\n })\n // Avoid unhandled promise rejections\n .catch(noop)\n }\n },\n )\n}\n"],"mappings":";;;;;;;;;;AAyBA,SAAS,eAAe,SAA+B;CACrD,IAAI;CASJ,QAP2B,MAAM,WAAW;EAC1C,OAAO;EACP,OAAO;CACT,GAAGA,cAAAA,IAIM,CAAC,EAAE,QAAQA,cAAAA,IAAI;CAExB,IAAI,SAAS,KAAA,GACX,OAAO,EAAE,KAAK;AAIlB;;;;;;AA6EA,SAAS,kBAAkB,UAAwC;CACjE,OAAO;EACL,aAAa,SAAS,QAAQ;EAC9B,OAAO,SAAS;EAChB,GAAI,SAAS,QAAQ,SAAS,EAAE,OAAO,SAAS,QAAQ,MAAM;EAC9D,GAAI,SAAS,QAAQ,EAAE,MAAM,SAAS,KAAK;CAC7C;AACF;;;;;;;;;;;AAYA,SAAS,iBACP,OACA,eACA,oBAC8B;CAC9B,MAAM,UAAU,MAAM,SAAS,KAAK,aAAa,CAAC,CAAC,OAAO,UAAU;EAClE,IAAI,qBAAqB,KAAK,MAAM,OAElC,OAAO,QAAQ,OAAO,KAAK;EAG7B,IAAI,QAAQ,IAAI,aAAa,cAC3B,QAAQ,MACN,+DAA+D,MAAM,UAAU,KAAK,MAAM,kDAC5F;EAEF,OAAO,QAAQ,uBAAO,IAAI,MAAM,UAAU,CAAC;CAC7C,CAAC;CAMD,SAAS,MAAMA,cAAAA,IAAI;CAEnB,OAAO;AACT;;;;;;;;;;;;AAaA,SAAgB,eACd,OACA,eACA,oBACiB;CACjB,OAAO;EACL,cAAc,KAAK,IAAI;EACvB,OAAO;GACL,GAAG,MAAM;GACT,GAAI,MAAM,MAAM,SAAS,KAAA,KAAa,EACpC,MAAM,gBACF,cAAc,MAAM,MAAM,IAAI,IAC9B,MAAM,MAAM,KAClB;EACF;EACA,UAAU,MAAM;EAChB,WAAW,MAAM;EACjB,GAAI,MAAM,MAAM,WAAW,aAAa,EACtC,S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Ae,EAC/D,CAAC,CAAC,CAED,MAAMA,cAAAA,IAAI;CAEjB,CACF;AACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as defaultShouldDehydrateQuery, c as hydrate, i as defaultShouldDehydrateMutation, n as DehydratedState, o as dehydrate, r as HydrateOptions, s as dehydrateQuery, t as DehydrateOptions } from "./hydration-
|
|
1
|
+
import { a as defaultShouldDehydrateQuery, c as hydrate, i as defaultShouldDehydrateMutation, n as DehydratedState, o as dehydrate, r as HydrateOptions, s as dehydrateQuery, t as DehydrateOptions } from "./hydration-C6zghADG.cjs";
|
|
2
2
|
export { DehydrateOptions, DehydratedState, HydrateOptions, defaultShouldDehydrateMutation, defaultShouldDehydrateQuery, dehydrate, dehydrateQuery, hydrate };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as defaultShouldDehydrateQuery, c as hydrate, i as defaultShouldDehydrateMutation, n as DehydratedState, o as dehydrate, r as HydrateOptions, s as dehydrateQuery, t as DehydrateOptions } from "./hydration-
|
|
1
|
+
import { a as defaultShouldDehydrateQuery, c as hydrate, i as defaultShouldDehydrateMutation, n as DehydratedState, o as dehydrate, r as HydrateOptions, s as dehydrateQuery, t as DehydrateOptions } from "./hydration-Bf0oMcwO.js";
|
|
2
2
|
export { DehydrateOptions, DehydratedState, HydrateOptions, defaultShouldDehydrateMutation, defaultShouldDehydrateQuery, dehydrate, dehydrateQuery, hydrate };
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { noop } from "./utils.js";
|
|
2
2
|
//#region src/hydration.ts
|
|
3
|
+
/**
|
|
4
|
+
* Reads the value of a promise synchronously if it has already resolved, e.g. a thenable that
|
|
5
|
+
* resolves within its `then` call.
|
|
6
|
+
* @param promise - The promise to read.
|
|
7
|
+
* @returns An object with the resolved `data`, or `undefined` if the promise hasn't resolved
|
|
8
|
+
* synchronously (or resolved with `undefined`).
|
|
9
|
+
*/
|
|
3
10
|
function tryResolveSync(promise) {
|
|
4
11
|
let data;
|
|
5
12
|
promise.then((result) => {
|
|
@@ -8,6 +15,11 @@ function tryResolveSync(promise) {
|
|
|
8
15
|
}, noop)?.catch?.(noop);
|
|
9
16
|
if (data !== void 0) return { data };
|
|
10
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Dehydrates a single `Mutation` into a serializable snapshot of its key, state, scope, and meta.
|
|
20
|
+
* @param mutation - The mutation to dehydrate.
|
|
21
|
+
* @returns The dehydrated mutation.
|
|
22
|
+
*/
|
|
11
23
|
function dehydrateMutation(mutation) {
|
|
12
24
|
return {
|
|
13
25
|
mutationKey: mutation.options.mutationKey,
|
|
@@ -16,6 +28,16 @@ function dehydrateMutation(mutation) {
|
|
|
16
28
|
...mutation.meta && { meta: mutation.meta }
|
|
17
29
|
};
|
|
18
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Prepares the in-flight promise of a pending query for dehydration: applies `serializeData` to its
|
|
33
|
+
* result, and redacts its rejection error unless `shouldRedactErrors` returns `false` for it.
|
|
34
|
+
* @param query - The pending query whose promise is dehydrated.
|
|
35
|
+
* @param serializeData - Optional transform applied to the resolved data.
|
|
36
|
+
* @param shouldRedactErrors - Optional predicate; if it returns `false` for the rejection error,
|
|
37
|
+
* that
|
|
38
|
+
* error is kept as-is instead of being redacted.
|
|
39
|
+
* @returns The transformed promise, or `undefined` if the query has no in-flight promise.
|
|
40
|
+
*/
|
|
19
41
|
function dehydratePromise(query, serializeData, shouldRedactErrors) {
|
|
20
42
|
const promise = query.promise?.then(serializeData).catch((error) => {
|
|
21
43
|
if (shouldRedactErrors?.(error) === false) return Promise.reject(error);
|
|
@@ -34,6 +56,7 @@ function dehydratePromise(query, serializeData, shouldRedactErrors) {
|
|
|
34
56
|
* @param serializeData - Optional transform applied to `query.state.data` before it is included in the snapshot.
|
|
35
57
|
* @param shouldRedactErrors - Optional predicate; if it returns `false` for the promise's rejection error, that
|
|
36
58
|
* error is kept as-is instead of being redacted.
|
|
59
|
+
* @returns The dehydrated query.
|
|
37
60
|
*/
|
|
38
61
|
function dehydrateQuery(query, serializeData, shouldRedactErrors) {
|
|
39
62
|
return {
|
|
@@ -52,6 +75,8 @@ function dehydrateQuery(query, serializeData, shouldRedactErrors) {
|
|
|
52
75
|
/**
|
|
53
76
|
* The default `shouldDehydrateMutation` predicate used by `dehydrate`. Only dehydrates mutations that are
|
|
54
77
|
* currently paused (e.g. paused by `networkMode` while offline).
|
|
78
|
+
* @param mutation - The mutation to check.
|
|
79
|
+
* @returns `true` if the mutation is paused.
|
|
55
80
|
*/
|
|
56
81
|
function defaultShouldDehydrateMutation(mutation) {
|
|
57
82
|
return mutation.state.isPaused;
|
|
@@ -59,6 +84,8 @@ function defaultShouldDehydrateMutation(mutation) {
|
|
|
59
84
|
/**
|
|
60
85
|
* The default `shouldDehydrateQuery` predicate used by `dehydrate`. Only dehydrates queries whose status is
|
|
61
86
|
* `'success'`.
|
|
87
|
+
* @param query - The query to check.
|
|
88
|
+
* @returns `true` if the query's status is `'success'`.
|
|
62
89
|
*/
|
|
63
90
|
function defaultShouldDehydrateQuery(query) {
|
|
64
91
|
return query.state.status === "success";
|
|
@@ -69,6 +96,10 @@ function defaultShouldDehydrateQuery(query) {
|
|
|
69
96
|
* Which queries/mutations are included, and how their data/errors are transformed, is controlled by `options`,
|
|
70
97
|
* falling back to the client's `dehydrate` default options, and finally to `defaultShouldDehydrateQuery` /
|
|
71
98
|
* `defaultShouldDehydrateMutation`.
|
|
99
|
+
* @param client - The client whose cache is dehydrated.
|
|
100
|
+
* @param options - Controls which queries and mutations are included and how their data and errors
|
|
101
|
+
* are transformed. Each option falls back to the client's `defaultOptions.dehydrate`.
|
|
102
|
+
* @returns The dehydrated state, with the included `queries` and `mutations`.
|
|
72
103
|
* @example
|
|
73
104
|
* ```ts
|
|
74
105
|
* const queryClient = new QueryClient()
|
|
@@ -100,6 +131,10 @@ function dehydrate(client, options = {}) {
|
|
|
100
131
|
* to `'idle'` so they don't hydrate stuck in a fetching state. If a dehydrated query still had an in-flight
|
|
101
132
|
* promise, it is resumed via `query.fetch()` (reusing that promise as `initialPromise`) rather than re-invoking
|
|
102
133
|
* `queryFn`.
|
|
134
|
+
* @param client - The client whose cache is restored into.
|
|
135
|
+
* @param dehydratedState - The dehydrated state, e.g. produced by `dehydrate` on the server.
|
|
136
|
+
* @param options - `defaultOptions` merged into every restored query and mutation (on top of the
|
|
137
|
+
* client's `defaultOptions.hydrate`), and `deserializeData` to reverse `serializeData`.
|
|
103
138
|
* @example
|
|
104
139
|
* ```ts
|
|
105
140
|
* // dehydratedState was produced by `dehydrate` on the server
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hydration.js","names":[],"sources":["../../src/hydration.ts"],"sourcesContent":["import { noop } from './utils'\nimport type {\n DefaultError,\n MutationKey,\n MutationMeta,\n MutationOptions,\n MutationScope,\n QueryKey,\n QueryMeta,\n QueryOptions,\n} from './types'\nimport type { QueryClient } from './queryClient'\nimport type { Query, QueryState } from './query'\nimport type { Mutation, MutationState } from './mutation'\n\n// TYPES\ntype TransformerFn = (data: any) => any\n\nfunction tryResolveSync(promise: PromiseLike<unknown>) {\n let data: unknown\n\n const thenResult = promise.then((result) => {\n data = result\n return result\n }, noop) as Promise<unknown> | undefined\n\n // .catch can be unavailable on certain kinds of thenable's\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n thenResult?.catch?.(noop)\n\n if (data !== undefined) {\n return { data }\n }\n\n return undefined\n}\n\n/**\n * Options for `dehydrate`, controlling which queries/mutations are included in the resulting `DehydratedState` and\n * how their data/errors are transformed before being serialized (e.g. for embedding in server-rendered markup).\n */\nexport interface DehydrateOptions {\n /** Transforms a query's `data` before it is dehydrated. Useful for non-JSON-serializable data. */\n serializeData?: TransformerFn\n /** Predicate to decide whether a given `Mutation` should be dehydrated. Defaults to `defaultShouldDehydrateMutation`. */\n shouldDehydrateMutation?: (mutation: Mutation) => boolean\n /** Predicate to decide whether a given `Query` should be dehydrated. Defaults to `defaultShouldDehydrateQuery`. */\n shouldDehydrateQuery?: (query: Query) => boolean\n /**\n * Predicate to decide whether a query's error should be redacted before dehydration. Errors are redacted\n * (replaced with a generic `Error('redacted')`) unless this function is provided and returns `false` for the\n * given error, in which case the original error is kept.\n */\n shouldRedactErrors?: (error: unknown) => boolean\n}\n\n/**\n * Options for `hydrate`, controlling the default options applied to queries/mutations restored from a\n * `DehydratedState`, and how to reverse any transformation applied by `DehydrateOptions.serializeData`.\n */\nexport interface HydrateOptions {\n /** Options applied to the queries and mutations restored from the dehydrated state. */\n defaultOptions?: {\n /** Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. */\n deserializeData?: TransformerFn\n /** Default options merged into every query restored from the dehydrated state. */\n queries?: QueryOptions\n /** Default options merged into every mutation restored from the dehydrated state. */\n mutations?: MutationOptions<unknown, DefaultError, unknown, unknown>\n }\n}\n\ninterface DehydratedMutation {\n mutationKey?: MutationKey\n state: MutationState\n meta?: MutationMeta\n scope?: MutationScope\n}\n\ninterface DehydratedQuery {\n queryHash: string\n queryKey: QueryKey\n state: QueryState\n dehydratedAt: number\n promise?: Promise<unknown>\n meta?: QueryMeta\n queryType?: 'infinite'\n}\n\n/**\n * A serializable snapshot of a `QueryClient`'s cache, as produced by `dehydrate` and consumed by `hydrate`. Typically\n * transported from server to client (e.g. embedded in server-rendered markup) to seed the client's cache with data\n * that has already been fetched, avoiding a redundant fetch on the client.\n */\nexport interface DehydratedState {\n mutations: Array<DehydratedMutation>\n queries: Array<DehydratedQuery>\n}\n\n// FUNCTIONS\n\nfunction dehydrateMutation(mutation: Mutation): DehydratedMutation {\n return {\n mutationKey: mutation.options.mutationKey,\n state: mutation.state,\n ...(mutation.options.scope && { scope: mutation.options.scope }),\n ...(mutation.meta && { meta: mutation.meta }),\n }\n}\n\nfunction dehydratePromise(\n query: Query,\n serializeData?: TransformerFn,\n shouldRedactErrors?: (error: unknown) => boolean,\n): Promise<unknown> | undefined {\n const promise = query.promise?.then(serializeData).catch((error) => {\n if (shouldRedactErrors?.(error) === false) {\n // Reject original error if it should not be redacted\n return Promise.reject(error)\n }\n // If not in production, log original error before rejecting redacted error\n if (process.env.NODE_ENV !== 'production') {\n console.error(\n `A query that was dehydrated as pending ended up rejecting. [${query.queryHash}]: ${error}; The error will be redacted in production builds`,\n )\n }\n return Promise.reject(new Error('redacted'))\n })\n\n // Avoid unhandled promise rejections\n // We need the promise we dehydrate to reject to get the correct result into\n // the query cache, but we also want to avoid unhandled promise rejections\n // in whatever environment the prefetches are happening in.\n promise?.catch(noop)\n\n return promise\n}\n\n/**\n * Dehydrates a single `Query` into a serializable `DehydratedQuery` snapshot. Note that most query config (e.g.\n * `queryFn`, `staleTime`) is not dehydrated but instead meant to be configured again when consuming the\n * de/rehydrated data, typically with `useQuery` on the client. If the query is still `pending`, its in-flight\n * promise is dehydrated too so it can be resumed on the other side instead of re-fetched.\n * @param query - The query to dehydrate.\n * @param serializeData - Optional transform applied to `query.state.data` before it is included in the snapshot.\n * @param shouldRedactErrors - Optional predicate; if it returns `false` for the promise's rejection error, that\n * error is kept as-is instead of being redacted.\n */\nexport function dehydrateQuery(\n query: Query,\n serializeData?: TransformerFn,\n shouldRedactErrors?: (error: unknown) => boolean,\n): DehydratedQuery {\n return {\n dehydratedAt: Date.now(),\n state: {\n ...query.state,\n ...(query.state.data !== undefined && {\n data: serializeData\n ? serializeData(query.state.data)\n : query.state.data,\n }),\n },\n queryKey: query.queryKey,\n queryHash: query.queryHash,\n ...(query.state.status === 'pending' && {\n promise: dehydratePromise(query, serializeData, shouldRedactErrors),\n }),\n ...(query.meta && { meta: query.meta }),\n ...(query.queryType && { queryType: query.queryType }),\n }\n}\n\n/**\n * The default `shouldDehydrateMutation` predicate used by `dehydrate`. Only dehydrates mutations that are\n * currently paused (e.g. paused by `networkMode` while offline).\n */\nexport function defaultShouldDehydrateMutation(mutation: Mutation) {\n return mutation.state.isPaused\n}\n\n/**\n * The default `shouldDehydrateQuery` predicate used by `dehydrate`. Only dehydrates queries whose status is\n * `'success'`.\n */\nexport function defaultShouldDehydrateQuery(query: Query) {\n return query.state.status === 'success'\n}\n\n/**\n * Dehydrates a `QueryClient`'s cache (queries and mutations) into a plain, serializable `DehydratedState`,\n * typically to embed in server-rendered markup and later restore into a client-side `QueryClient` via `hydrate`.\n * Which queries/mutations are included, and how their data/errors are transformed, is controlled by `options`,\n * falling back to the client's `dehydrate` default options, and finally to `defaultShouldDehydrateQuery` /\n * `defaultShouldDehydrateMutation`.\n * @example\n * ```ts\n * const queryClient = new QueryClient()\n *\n * await queryClient.prefetchQuery({\n * queryKey: ['posts'],\n * queryFn: getPosts,\n * })\n *\n * const dehydratedState = dehydrate(queryClient)\n * ```\n */\nexport function dehydrate(\n client: QueryClient,\n options: DehydrateOptions = {},\n): DehydratedState {\n const filterMutation =\n options.shouldDehydrateMutation ??\n client.getDefaultOptions().dehydrate?.shouldDehydrateMutation ??\n defaultShouldDehydrateMutation\n\n const mutations = client\n .getMutationCache()\n .getAll()\n .flatMap((mutation) =>\n filterMutation(mutation) ? [dehydrateMutation(mutation)] : [],\n )\n\n const filterQuery =\n options.shouldDehydrateQuery ??\n client.getDefaultOptions().dehydrate?.shouldDehydrateQuery ??\n defaultShouldDehydrateQuery\n\n const shouldRedactErrors =\n options.shouldRedactErrors ??\n client.getDefaultOptions().dehydrate?.shouldRedactErrors\n\n const serializeData =\n options.serializeData ?? client.getDefaultOptions().dehydrate?.serializeData\n\n const queries = client\n .getQueryCache()\n .getAll()\n .flatMap((query) =>\n filterQuery(query)\n ? [dehydrateQuery(query, serializeData, shouldRedactErrors)]\n : [],\n )\n\n return { mutations, queries }\n}\n\n/**\n * Restores a `DehydratedState` (as produced by `dehydrate`) into a `QueryClient`'s cache, typically to seed the\n * client with data already fetched on the server. `mutations` and `queries` are each optional on `dehydratedState`.\n * Queries not yet in the cache are built from the dehydrated snapshot; queries that already exist are only updated\n * when the dehydrated data is newer than what's already cached. Newly built queries have their `fetchStatus` reset\n * to `'idle'` so they don't hydrate stuck in a fetching state. If a dehydrated query still had an in-flight\n * promise, it is resumed via `query.fetch()` (reusing that promise as `initialPromise`) rather than re-invoking\n * `queryFn`.\n * @example\n * ```ts\n * // dehydratedState was produced by `dehydrate` on the server\n * // and sent to the client, e.g. embedded in server-rendered markup.\n * const queryClient = new QueryClient()\n *\n * hydrate(queryClient, dehydratedState)\n * ```\n */\nexport function hydrate(\n client: QueryClient,\n dehydratedState: Partial<DehydratedState>,\n options?: HydrateOptions,\n): void {\n const mutationCache = client.getMutationCache()\n const queryCache = client.getQueryCache()\n const deserializeData =\n options?.defaultOptions?.deserializeData ??\n client.getDefaultOptions().hydrate?.deserializeData\n\n dehydratedState.mutations?.forEach(({ state, ...mutationOptions }) => {\n mutationCache.build(\n client,\n {\n ...client.getDefaultOptions().hydrate?.mutations,\n ...options?.defaultOptions?.mutations,\n ...mutationOptions,\n },\n state,\n )\n })\n\n dehydratedState.queries?.forEach(\n ({\n queryKey,\n state,\n queryHash,\n meta,\n promise,\n dehydratedAt,\n queryType,\n }) => {\n const syncData = promise ? tryResolveSync(promise) : undefined\n const rawData = state.data === undefined ? syncData?.data : state.data\n const data =\n rawData === undefined\n ? rawData\n : deserializeData\n ? deserializeData(rawData)\n : rawData\n\n let query = queryCache.get(queryHash)\n const existingQueryIsPending = query?.state.status === 'pending'\n const existingQueryIsFetching = query?.state.fetchStatus === 'fetching'\n\n // Do not hydrate if an existing query exists with newer data\n if (query) {\n const hasNewerSyncData =\n syncData && dehydratedAt > query.state.dataUpdatedAt\n if (\n state.dataUpdatedAt > query.state.dataUpdatedAt ||\n hasNewerSyncData\n ) {\n // Omit fetchStatus from dehydrated state so that query stays in its current fetchStatus\n const { fetchStatus: _ignored, ...serializedState } = state\n query.setState({\n ...serializedState,\n data,\n // If the query was pending at the moment of dehydration, but resolved to have data\n // before hydration, we can assume the query should be hydrated as successful.\n //\n // Since you can opt into dehydrating failed queries, and those can have data from\n // previous successful fetches, we make sure we only do this for pending queries.\n ...(state.status === 'pending' &&\n data !== undefined && {\n status: 'success' as const,\n dataUpdatedAt: dehydratedAt,\n // Preserve existing fetchStatus if the existing query is actively fetching.\n ...(!existingQueryIsFetching && {\n fetchStatus: 'idle' as const,\n }),\n }),\n })\n }\n } else {\n // Restore query\n query = queryCache.build(\n client,\n {\n ...client.getDefaultOptions().hydrate?.queries,\n ...options?.defaultOptions?.queries,\n queryKey,\n queryHash,\n meta,\n _type: queryType,\n },\n // Reset fetch status to idle to avoid\n // query being stuck in fetching state upon hydration\n {\n ...state,\n data,\n fetchStatus: 'idle',\n // Like above, if the query was pending at the moment of dehydration but has data,\n // we can assume it should be hydrated as successful.\n status:\n state.status === 'pending' && data !== undefined\n ? 'success'\n : state.status,\n ...(state.status === 'pending' &&\n data !== undefined && {\n dataUpdatedAt: dehydratedAt,\n }),\n },\n )\n }\n\n if (\n promise &&\n // If the data was synchronously available, there is no need to set up\n // a retryer and thus no reason to call fetch\n !syncData &&\n !existingQueryIsPending &&\n !existingQueryIsFetching &&\n // Only hydrate if dehydration is newer than any existing data,\n // this is always true for new queries\n dehydratedAt > query.state.dataUpdatedAt\n ) {\n // This doesn't actually fetch - it just creates a retryer\n // which will re-use the passed `initialPromise`\n query\n .fetch(undefined, {\n // RSC transformed promises are not thenable\n initialPromise: Promise.resolve(promise).then(deserializeData),\n })\n // Avoid unhandled promise rejections\n .catch(noop)\n }\n },\n )\n}\n"],"mappings":";;AAkBA,SAAS,eAAe,SAA+B;CACrD,IAAI;CASJ,QAP2B,MAAM,WAAW;EAC1C,OAAO;EACP,OAAO;CACT,GAAG,IAIM,CAAC,EAAE,QAAQ,IAAI;CAExB,IAAI,SAAS,KAAA,GACX,OAAO,EAAE,KAAK;AAIlB;AAkEA,SAAS,kBAAkB,UAAwC;CACjE,OAAO;EACL,aAAa,SAAS,QAAQ;EAC9B,OAAO,SAAS;EAChB,GAAI,SAAS,QAAQ,SAAS,EAAE,OAAO,SAAS,QAAQ,MAAM;EAC9D,GAAI,SAAS,QAAQ,EAAE,MAAM,SAAS,KA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M,EAAE,aAAa,UAAU,GAAG,oBAAoB;IACtD,MAAM,SAAS;KACb,GAAG;KACH;KAMA,GAAI,MAAM,WAAW,aACnB,SAAS,KAAA,KAAa;MACpB,QAAQ;MACR,eAAe;MAEf,GAAI,CAAC,2BAA2B,EAC9B,aAAa,OACf;KACF;IACJ,CAAC;GACH;EACF,OAEE,QAAQ,WAAW,MACjB,QACA;GACE,GAAG,OAAO,kBAAkB,CAAC,CAAC,SAAS;GACvC,GAAG,SAAS,gBAAgB;GAC5B;GACA;GACA;GACA,OAAO;EACT,GAGA;GACE,GAAG;GACH;GACA,aAAa;GAGb,QACE,MAAM,WAAW,aAAa,SAAS,KAAA,IACnC,YACA,MAAM;GACZ,GAAI,MAAM,WAAW,aACnB,SAAS,KAAA,KAAa,EACpB,eAAe,aACjB;EACJ,CACF;EAGF,IACE,WAGA,CAAC,YACD,CAAC,0BACD,CAAC,2BAGD,eAAe,MAAM,MAAM,eAI3B,MACG,MAAM,KAAA,GAAW,EAEhB,gBAAgB,QAAQ,QAAQ,OAAO,CAAC,CAAC,KAAK,eAAe,EAC/D,CAAC,CAAC,CAED,MAAM,IAAI;CAEjB,CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"hydration.js","names":[],"sources":["../../src/hydration.ts"],"sourcesContent":["import { noop } from './utils'\nimport type {\n DefaultError,\n MutationKey,\n MutationMeta,\n MutationOptions,\n MutationScope,\n QueryKey,\n QueryMeta,\n QueryOptions,\n} from './types'\nimport type { QueryClient } from './queryClient'\nimport type { Query, QueryState } from './query'\nimport type { Mutation, MutationState } from './mutation'\n\n// TYPES\ntype TransformerFn = (data: any) => any\n\n/**\n * Reads the value of a promise synchronously if it has already resolved, e.g. a thenable that\n * resolves within its `then` call.\n * @param promise - The promise to read.\n * @returns An object with the resolved `data`, or `undefined` if the promise hasn't resolved\n * synchronously (or resolved with `undefined`).\n */\nfunction tryResolveSync(promise: PromiseLike<unknown>) {\n let data: unknown\n\n const thenResult = promise.then((result) => {\n data = result\n return result\n }, noop) as Promise<unknown> | undefined\n\n // .catch can be unavailable on certain kinds of thenable's\n // oxlint-disable-next-line typescript/no-unnecessary-condition\n thenResult?.catch?.(noop)\n\n if (data !== undefined) {\n return { data }\n }\n\n return undefined\n}\n\n/**\n * Options for `dehydrate`, controlling which queries/mutations are included in the resulting `DehydratedState` and\n * how their data/errors are transformed before being serialized (e.g. for embedding in server-rendered markup).\n */\nexport interface DehydrateOptions {\n /** Transforms a query's `data` before it is dehydrated. Useful for non-JSON-serializable data. */\n serializeData?: TransformerFn\n /** Predicate to decide whether a given `Mutation` should be dehydrated. Defaults to `defaultShouldDehydrateMutation`. */\n shouldDehydrateMutation?: (mutation: Mutation) => boolean\n /** Predicate to decide whether a given `Query` should be dehydrated. Defaults to `defaultShouldDehydrateQuery`. */\n shouldDehydrateQuery?: (query: Query) => boolean\n /**\n * Predicate to decide whether a query's error should be redacted before dehydration. Errors are redacted\n * (replaced with a generic `Error('redacted')`) unless this function is provided and returns `false` for the\n * given error, in which case the original error is kept.\n */\n shouldRedactErrors?: (error: unknown) => boolean\n}\n\n/**\n * Options for `hydrate`, controlling the default options applied to queries/mutations restored from a\n * `DehydratedState`, and how to reverse any transformation applied by `DehydrateOptions.serializeData`.\n */\nexport interface HydrateOptions {\n /** Options applied to the queries and mutations restored from the dehydrated state. */\n defaultOptions?: {\n /** Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. */\n deserializeData?: TransformerFn\n /** Default options merged into every query restored from the dehydrated state. */\n queries?: QueryOptions\n /** Default options merged into every mutation restored from the dehydrated state. */\n mutations?: MutationOptions<unknown, DefaultError, unknown, unknown>\n }\n}\n\ninterface DehydratedMutation {\n mutationKey?: MutationKey\n state: MutationState\n meta?: MutationMeta\n scope?: MutationScope\n}\n\ninterface DehydratedQuery {\n queryHash: string\n queryKey: QueryKey\n state: QueryState\n dehydratedAt: number\n promise?: Promise<unknown>\n meta?: QueryMeta\n queryType?: 'infinite'\n}\n\n/**\n * A serializable snapshot of a `QueryClient`'s cache, as produced by `dehydrate` and consumed by `hydrate`. Typically\n * transported from server to client (e.g. embedded in server-rendered markup) to seed the client's cache with data\n * that has already been fetched, avoiding a redundant fetch on the client.\n */\nexport interface DehydratedState {\n /**\n * The dehydrated mutations, by default only the paused ones.\n */\n mutations: Array<DehydratedMutation>\n /**\n * The dehydrated queries, by default only the successful ones.\n */\n queries: Array<DehydratedQuery>\n}\n\n// FUNCTIONS\n\n/**\n * Dehydrates a single `Mutation` into a serializable snapshot of its key, state, scope, and meta.\n * @param mutation - The mutation to dehydrate.\n * @returns The dehydrated mutation.\n */\nfunction dehydrateMutation(mutation: Mutation): DehydratedMutation {\n return {\n mutationKey: mutation.options.mutationKey,\n state: mutation.state,\n ...(mutation.options.scope && { scope: mutation.options.scope }),\n ...(mutation.meta && { meta: mutation.meta }),\n }\n}\n\n/**\n * Prepares the in-flight promise of a pending query for dehydration: applies `serializeData` to its\n * result, and redacts its rejection error unless `shouldRedactErrors` returns `false` for it.\n * @param query - The pending query whose promise is dehydrated.\n * @param serializeData - Optional transform applied to the resolved data.\n * @param shouldRedactErrors - Optional predicate; if it returns `false` for the rejection error,\n * that\n * error is kept as-is instead of being redacted.\n * @returns The transformed promise, or `undefined` if the query has no in-flight promise.\n */\nfunction dehydratePromise(\n query: Query,\n serializeData?: TransformerFn,\n shouldRedactErrors?: (error: unknown) => boolean,\n): Promise<unknown> | undefined {\n const promise = query.promise?.then(serializeData).catch((error) => {\n if (shouldRedactErrors?.(error) === false) {\n // Reject original error if it should not be redacted\n return Promise.reject(error)\n }\n // If not in production, log original error before rejecting redacted error\n if (process.env.NODE_ENV !== 'production') {\n console.error(\n `A query that was dehydrated as pending ended up rejecting. [${query.queryHash}]: ${error}; The error will be redacted in production builds`,\n )\n }\n return Promise.reject(new Error('redacted'))\n })\n\n // Avoid unhandled promise rejections\n // We need the promise we dehydrate to reject to get the correct result into\n // the query cache, but we also want to avoid unhandled promise rejections\n // in whatever environment the prefetches are happening in.\n promise?.catch(noop)\n\n return promise\n}\n\n/**\n * Dehydrates a single `Query` into a serializable `DehydratedQuery` snapshot. Note that most query config (e.g.\n * `queryFn`, `staleTime`) is not dehydrated but instead meant to be configured again when consuming the\n * de/rehydrated data, typically with `useQuery` on the client. If the query is still `pending`, its in-flight\n * promise is dehydrated too so it can be resumed on the other side instead of re-fetched.\n * @param query - The query to dehydrate.\n * @param serializeData - Optional transform applied to `query.state.data` before it is included in the snapshot.\n * @param shouldRedactErrors - Optional predicate; if it returns `false` for the promise's rejection error, that\n * error is kept as-is instead of being redacted.\n * @returns The dehydrated query.\n */\nexport function dehydrateQuery(\n query: Query,\n serializeData?: TransformerFn,\n shouldRedactErrors?: (error: unknown) => boolean,\n): DehydratedQuery {\n return {\n dehydratedAt: Date.now(),\n state: {\n ...query.state,\n ...(query.state.data !== undefined && {\n data: serializeData\n ? serializeData(query.state.data)\n : query.state.data,\n }),\n },\n queryKey: query.queryKey,\n queryHash: query.queryHash,\n ...(query.state.status === 'pending' && {\n promise: dehydratePromise(query, serializeData, shouldRedactErrors),\n }),\n ...(query.meta && { meta: query.meta }),\n ...(query.queryType && { queryType: query.queryType }),\n }\n}\n\n/**\n * The default `shouldDehydrateMutation` predicate used by `dehydrate`. Only dehydrates mutations that are\n * currently paused (e.g. paused by `networkMode` while offline).\n * @param mutation - The mutation to check.\n * @returns `true` if the mutation is paused.\n */\nexport function defaultShouldDehydrateMutation(mutation: Mutation) {\n return mutation.state.isPaused\n}\n\n/**\n * The default `shouldDehydrateQuery` predicate used by `dehydrate`. Only dehydrates queries whose status is\n * `'success'`.\n * @param query - The query to check.\n * @returns `true` if the query's status is `'success'`.\n */\nexport function defaultShouldDehydrateQuery(query: Query) {\n return query.state.status === 'success'\n}\n\n/**\n * Dehydrates a `QueryClient`'s cache (queries and mutations) into a plain, serializable `DehydratedState`,\n * typically to embed in server-rendered markup and later restore into a client-side `QueryClient` via `hydrate`.\n * Which queries/mutations are included, and how their data/errors are transformed, is controlled by `options`,\n * falling back to the client's `dehydrate` default options, and finally to `defaultShouldDehydrateQuery` /\n * `defaultShouldDehydrateMutation`.\n * @param client - The client whose cache is dehydrated.\n * @param options - Controls which queries and mutations are included and how their data and errors\n * are transformed. Each option falls back to the client's `defaultOptions.dehydrate`.\n * @returns The dehydrated state, with the included `queries` and `mutations`.\n * @example\n * ```ts\n * const queryClient = new QueryClient()\n *\n * await queryClient.prefetchQuery({\n * queryKey: ['posts'],\n * queryFn: getPosts,\n * })\n *\n * const dehydratedState = dehydrate(queryClient)\n * ```\n */\nexport function dehydrate(\n client: QueryClient,\n options: DehydrateOptions = {},\n): DehydratedState {\n const filterMutation =\n options.shouldDehydrateMutation ??\n client.getDefaultOptions().dehydrate?.shouldDehydrateMutation ??\n defaultShouldDehydrateMutation\n\n const mutations = client\n .getMutationCache()\n .getAll()\n .flatMap((mutation) =>\n filterMutation(mutation) ? [dehydrateMutation(mutation)] : [],\n )\n\n const filterQuery =\n options.shouldDehydrateQuery ??\n client.getDefaultOptions().dehydrate?.shouldDehydrateQuery ??\n defaultShouldDehydrateQuery\n\n const shouldRedactErrors =\n options.shouldRedactErrors ??\n client.getDefaultOptions().dehydrate?.shouldRedactErrors\n\n const serializeData =\n options.serializeData ?? client.getDefaultOptions().dehydrate?.serializeData\n\n const queries = client\n .getQueryCache()\n .getAll()\n .flatMap((query) =>\n filterQuery(query)\n ? [dehydrateQuery(query, serializeData, shouldRedactErrors)]\n : [],\n )\n\n return { mutations, queries }\n}\n\n/**\n * Restores a `DehydratedState` (as produced by `dehydrate`) into a `QueryClient`'s cache, typically to seed the\n * client with data already fetched on the server. `mutations` and `queries` are each optional on `dehydratedState`.\n * Queries not yet in the cache are built from the dehydrated snapshot; queries that already exist are only updated\n * when the dehydrated data is newer than what's already cached. Newly built queries have their `fetchStatus` reset\n * to `'idle'` so they don't hydrate stuck in a fetching state. If a dehydrated query still had an in-flight\n * promise, it is resumed via `query.fetch()` (reusing that promise as `initialPromise`) rather than re-invoking\n * `queryFn`.\n * @param client - The client whose cache is restored into.\n * @param dehydratedState - The dehydrated state, e.g. produced by `dehydrate` on the server.\n * @param options - `defaultOptions` merged into every restored query and mutation (on top of the\n * client's `defaultOptions.hydrate`), and `deserializeData` to reverse `serializeData`.\n * @example\n * ```ts\n * // dehydratedState was produced by `dehydrate` on the server\n * // and sent to the client, e.g. embedded in server-rendered markup.\n * const queryClient = new QueryClient()\n *\n * hydrate(queryClient, dehydratedState)\n * ```\n */\nexport function hydrate(\n client: QueryClient,\n dehydratedState: Partial<DehydratedState>,\n options?: HydrateOptions,\n): void {\n const mutationCache = client.getMutationCache()\n const queryCache = client.getQueryCache()\n const deserializeData =\n options?.defaultOptions?.deserializeData ??\n client.getDefaultOptions().hydrate?.deserializeData\n\n dehydratedState.mutations?.forEach(({ state, ...mutationOptions }) => {\n mutationCache.build(\n client,\n {\n ...client.getDefaultOptions().hydrate?.mutations,\n ...options?.defaultOptions?.mutations,\n ...mutationOptions,\n },\n state,\n )\n })\n\n dehydratedState.queries?.forEach(\n ({\n queryKey,\n state,\n queryHash,\n meta,\n promise,\n dehydratedAt,\n queryType,\n }) => {\n const syncData = promise ? tryResolveSync(promise) : undefined\n const rawData = state.data === undefined ? syncData?.data : state.data\n const data =\n rawData === undefined\n ? rawData\n : deserializeData\n ? deserializeData(rawData)\n : rawData\n\n let query = queryCache.get(queryHash)\n const existingQueryIsPending = query?.state.status === 'pending'\n const existingQueryIsFetching = query?.state.fetchStatus === 'fetching'\n\n // Do not hydrate if an existing query exists with newer data\n if (query) {\n const hasNewerSyncData =\n syncData && dehydratedAt > query.state.dataUpdatedAt\n if (\n state.dataUpdatedAt > query.state.dataUpdatedAt ||\n hasNewerSyncData\n ) {\n // Omit fetchStatus from dehydrated state so that query stays in its current fetchStatus\n const { fetchStatus: _ignored, ...serializedState } = state\n query.setState({\n ...serializedState,\n data,\n // If the query was pending at the moment of dehydration, but resolved to have data\n // before hydration, we can assume the query should be hydrated as successful.\n //\n // Since you can opt into dehydrating failed queries, and those can have data from\n // previous successful fetches, we make sure we only do this for pending queries.\n ...(state.status === 'pending' &&\n data !== undefined && {\n status: 'success' as const,\n dataUpdatedAt: dehydratedAt,\n // Preserve existing fetchStatus if the existing query is actively fetching.\n ...(!existingQueryIsFetching && {\n fetchStatus: 'idle' as const,\n }),\n }),\n })\n }\n } else {\n // Restore query\n query = queryCache.build(\n client,\n {\n ...client.getDefaultOptions().hydrate?.queries,\n ...options?.defaultOptions?.queries,\n queryKey,\n queryHash,\n meta,\n _type: queryType,\n },\n // Reset fetch status to idle to avoid\n // query being stuck in fetching state upon hydration\n {\n ...state,\n data,\n fetchStatus: 'idle',\n // Like above, if the query was pending at the moment of dehydration but has data,\n // we can assume it should be hydrated as successful.\n status:\n state.status === 'pending' && data !== undefined\n ? 'success'\n : state.status,\n ...(state.status === 'pending' &&\n data !== undefined && {\n dataUpdatedAt: dehydratedAt,\n }),\n },\n )\n }\n\n if (\n promise &&\n // If the data was synchronously available, there is no need to set up\n // a retryer and thus no reason to call fetch\n !syncData &&\n !existingQueryIsPending &&\n !existingQueryIsFetching &&\n // Only hydrate if dehydration is newer than any existing data,\n // this is always true for new queries\n dehydratedAt > query.state.dataUpdatedAt\n ) {\n // This doesn't actually fetch - it just creates a retryer\n // which will re-use the passed `initialPromise`\n query\n .fetch(undefined, {\n // RSC transformed promises are not thenable\n initialPromise: Promise.resolve(promise).then(deserializeData),\n })\n // Avoid unhandled promise rejections\n .catch(noop)\n }\n },\n )\n}\n"],"mappings":";;;;;;;;;AAyBA,SAAS,eAAe,SAA+B;CACrD,IAAI;CASJ,QAP2B,MAAM,WAAW;EAC1C,OAAO;EACP,OAAO;CACT,GAAG,IAIM,CAAC,EAAE,QAAQ,IAAI;CAExB,IAAI,SAAS,KAAA,GACX,OAAO,EAAE,KAAK;AAIlB;;;;;;AA6EA,SAAS,kBAAkB,UAAwC;CACjE,OAAO;EACL,aAAa,SAAS,QAAQ;EAC9B,OAAO,SAAS;EAChB,GAAI,SAAS,QAAQ,SAAS,EAAE,OAA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AAM,mBACJ,YAAY,eAAe,MAAM,MAAM;GACzC,IACE,MAAM,gBAAgB,MAAM,MAAM,iBAClC,kBACA;IAEA,MAAM,EAAE,aAAa,UAAU,GAAG,oBAAoB;IACtD,MAAM,SAAS;KACb,GAAG;KACH;KAMA,GAAI,MAAM,WAAW,aACnB,SAAS,KAAA,KAAa;MACpB,QAAQ;MACR,eAAe;MAEf,GAAI,CAAC,2BAA2B,EAC9B,aAAa,OACf;KACF;IACJ,CAAC;GACH;EACF,OAEE,QAAQ,WAAW,MACjB,QACA;GACE,GAAG,OAAO,kBAAkB,CAAC,CAAC,SAAS;GACvC,GAAG,SAAS,gBAAgB;GAC5B;GACA;GACA;GACA,OAAO;EACT,GAGA;GACE,GAAG;GACH;GACA,aAAa;GAGb,QACE,MAAM,WAAW,aAAa,SAAS,KAAA,IACnC,YACA,MAAM;GACZ,GAAI,MAAM,WAAW,aACnB,SAAS,KAAA,KAAa,EACpB,eAAe,aACjB;EACJ,CACF;EAGF,IACE,WAGA,CAAC,YACD,CAAC,0BACD,CAAC,2BAGD,eAAe,MAAM,MAAM,eAI3B,MACG,MAAM,KAAA,GAAW,EAEhB,gBAAgB,QAAQ,QAAQ,OAAO,CAAC,CAAC,KAAK,eAAe,EAC/D,CAAC,CAAC,CAED,MAAM,IAAI;CAEjB,CACF;AACF"}
|
package/build/modern/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { environmentManager } from "./environmentManager.cjs";
|
|
2
2
|
import { FocusManager, focusManager } from "./focusManager.cjs";
|
|
3
|
-
import { $ as MutationObserverBaseResult, $n as Query, $t as CancelledError, A as InfiniteData, An as noop, At as QueryObserverOptions, B as InfiniteQueryObserverSuccessResult, Bt as RefetchQueryFilters, C as FetchPreviousPageOptions, Ct as QueryKey, D as GetPreviousPageParamFunction, Dn as keepPreviousData, Dt as QueryObserverBaseResult, E as GetNextPageParamFunction, Et as QueryMeta, F as InfiniteQueryObserverOptions, Ft as QueryObserverSuccessResult, G as InvalidateQueryFilters, Gn as MutationCacheConfig, Gt as StaleTime, H as InitialDataFunction, Hn as MutationState, Ht as ResetOptions, I as InfiniteQueryObserverPendingResult, In as shouldThrowError, It as QueryOptions, J as MutateOptions, Jt as UnsetMarker, K as MutateFunction, Kn as MutationCacheNotifyEvent, Kt as StaleTimeFunction, L as InfiniteQueryObserverPlaceholderResult, Ln as skipToken, Lt as QueryPersister, M as InfiniteQueryObserverBaseResult, Mt as QueryObserverPlaceholderResult, N as InfiniteQueryObserverLoadingErrorResult, Nn as replaceEqualDeep, Nt as QueryObserverRefetchErrorResult, O as InferDataFromTag, On as matchMutation, Ot as QueryObserverLoadingErrorResult, P as InfiniteQueryObserverLoadingResult, Pt as QueryObserverResult, Q as MutationMeta, Qt as unsetMarker, R as InfiniteQueryObserverRefetchErrorResult, Rt as QueryStatus, S as FetchNextPageOptions, St as QueryFunctionContext, T as FetchStatus, Tn as isServer, Tt as QueryKeyWithDataTag, U as InitialPageParam, Ut as ResultOptions, V as InfiniteQueryPageParamsOptions, Vn as Mutation, Vt as Register, W as InvalidateOptions, Wn as MutationCache, Wt as SetDataOptions, X as MutationFunctionContext, Xt as dataTagErrorSymbol, Y as MutationFunction, Yt as WithRequired, Z as MutationKey, Zt as dataTagSymbol, _ as DefinedQueryObserverResult, _t as QueriesPlaceholderDataFunction, a as defaultShouldDehydrateQuery, an as isCancelledError, at as MutationObserverSuccessResult, b as EnsureQueryDataOptions, bt as QueryExecuteOptions, c as hydrate, cn as QueryCacheConfig, ct as MutationStatus, d as DataTag, dn as MutationFilters, dt as NotifyEvent, et as MutationObserverErrorResult, f as DefaultError, fn as QueryFilters, ft as NotifyEventType, g as DefinedInfiniteQueryObserverResult, gt as PlaceholderDataFunction, h as DefaultedQueryObserverOptions, hn as Updater, ht as Override, i as defaultShouldDehydrateMutation, it as MutationObserverResult, j as InfiniteQueryExecuteOptions, jn as partialMatchKey, jt as QueryObserverPendingResult, k as InferErrorFromTag, kn as matchQuery, kt as QueryObserverLoadingResult, l as AnyDataTag, ln as QueryCacheNotifyEvent, lt as NetworkMode, m as DefaultedInfiniteQueryObserverOptions, mn as SkipToken, mt as OmitKeyof, n as DehydratedState, nt as MutationObserverLoadingResult, o as dehydrate, on as QueryClient, ot as MutationOptions, p as DefaultOptions, pt as NotifyOnChangeProps, q as MutateFunctionRest, qn as MutationObserver, qt as ThrowOnError, r as HydrateOptions, rr as QueryObserver, rt as MutationObserverOptions, s as dehydrateQuery, sn as QueryCache, st as MutationScope, t as DehydrateOptions, tr as QueryState, tt as MutationObserverIdleResult, u as CancelOptions, ut as NonUndefinedGuard, v as DistributiveOmit, vt as QueryBooleanOption, w as FetchQueryOptions, wt as QueryKeyHashFunction, x as FetchInfiniteQueryOptions, xn as hashKey, xt as QueryFunction, y as EnsureInfiniteQueryDataOptions, yt as QueryClientConfig, z as InfiniteQueryObserverResult, zt as RefetchOptions } from "./hydration-
|
|
3
|
+
import { $ as MutationObserverBaseResult, $n as Query, $t as CancelledError, A as InfiniteData, An as noop, At as QueryObserverOptions, B as InfiniteQueryObserverSuccessResult, Bt as RefetchQueryFilters, C as FetchPreviousPageOptions, Ct as QueryKey, D as GetPreviousPageParamFunction, Dn as keepPreviousData, Dt as QueryObserverBaseResult, E as GetNextPageParamFunction, Et as QueryMeta, F as InfiniteQueryObserverOptions, Ft as QueryObserverSuccessResult, G as InvalidateQueryFilters, Gn as MutationCacheConfig, Gt as StaleTime, H as InitialDataFunction, Hn as MutationState, Ht as ResetOptions, I as InfiniteQueryObserverPendingResult, In as shouldThrowError, It as QueryOptions, J as MutateOptions, Jt as UnsetMarker, K as MutateFunction, Kn as MutationCacheNotifyEvent, Kt as StaleTimeFunction, L as InfiniteQueryObserverPlaceholderResult, Ln as skipToken, Lt as QueryPersister, M as InfiniteQueryObserverBaseResult, Mt as QueryObserverPlaceholderResult, N as InfiniteQueryObserverLoadingErrorResult, Nn as replaceEqualDeep, Nt as QueryObserverRefetchErrorResult, O as InferDataFromTag, On as matchMutation, Ot as QueryObserverLoadingErrorResult, P as InfiniteQueryObserverLoadingResult, Pt as QueryObserverResult, Q as MutationMeta, Qt as unsetMarker, R as InfiniteQueryObserverRefetchErrorResult, Rt as QueryStatus, S as FetchNextPageOptions, St as QueryFunctionContext, T as FetchStatus, Tn as isServer, Tt as QueryKeyWithDataTag, U as InitialPageParam, Ut as ResultOptions, V as InfiniteQueryPageParamsOptions, Vn as Mutation, Vt as Register, W as InvalidateOptions, Wn as MutationCache, Wt as SetDataOptions, X as MutationFunctionContext, Xt as dataTagErrorSymbol, Y as MutationFunction, Yt as WithRequired, Z as MutationKey, Zt as dataTagSymbol, _ as DefinedQueryObserverResult, _t as QueriesPlaceholderDataFunction, a as defaultShouldDehydrateQuery, an as isCancelledError, at as MutationObserverSuccessResult, b as EnsureQueryDataOptions, bt as QueryExecuteOptions, c as hydrate, cn as QueryCacheConfig, ct as MutationStatus, d as DataTag, dn as MutationFilters, dt as NotifyEvent, et as MutationObserverErrorResult, f as DefaultError, fn as QueryFilters, ft as NotifyEventType, g as DefinedInfiniteQueryObserverResult, gt as PlaceholderDataFunction, h as DefaultedQueryObserverOptions, hn as Updater, ht as Override, i as defaultShouldDehydrateMutation, it as MutationObserverResult, j as InfiniteQueryExecuteOptions, jn as partialMatchKey, jt as QueryObserverPendingResult, k as InferErrorFromTag, kn as matchQuery, kt as QueryObserverLoadingResult, l as AnyDataTag, ln as QueryCacheNotifyEvent, lt as NetworkMode, m as DefaultedInfiniteQueryObserverOptions, mn as SkipToken, mt as OmitKeyof, n as DehydratedState, nt as MutationObserverLoadingResult, o as dehydrate, on as QueryClient, ot as MutationOptions, p as DefaultOptions, pt as NotifyOnChangeProps, q as MutateFunctionRest, qn as MutationObserver, qt as ThrowOnError, r as HydrateOptions, rr as QueryObserver, rt as MutationObserverOptions, s as dehydrateQuery, sn as QueryCache, st as MutationScope, t as DehydrateOptions, tr as QueryState, tt as MutationObserverIdleResult, u as CancelOptions, ut as NonUndefinedGuard, v as DistributiveOmit, vt as QueryBooleanOption, w as FetchQueryOptions, wt as QueryKeyHashFunction, x as FetchInfiniteQueryOptions, xn as hashKey, xt as QueryFunction, y as EnsureInfiniteQueryDataOptions, yt as QueryClientConfig, z as InfiniteQueryObserverResult, zt as RefetchOptions } from "./hydration-C6zghADG.cjs";
|
|
4
4
|
import { InfiniteQueryObserver } from "./infiniteQueryObserver.cjs";
|
|
5
5
|
import { defaultScheduler, notifyManager } from "./notifyManager.cjs";
|
|
6
6
|
import { OnlineManager, onlineManager } from "./onlineManager.cjs";
|
package/build/modern/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { environmentManager } from "./environmentManager.js";
|
|
2
2
|
import { FocusManager, focusManager } from "./focusManager.js";
|
|
3
|
-
import { $ as MutationObserverBaseResult, $n as Query, $t as CancelledError, A as InfiniteData, An as noop, At as QueryObserverOptions, B as InfiniteQueryObserverSuccessResult, Bt as RefetchQueryFilters, C as FetchPreviousPageOptions, Ct as QueryKey, D as GetPreviousPageParamFunction, Dn as keepPreviousData, Dt as QueryObserverBaseResult, E as GetNextPageParamFunction, Et as QueryMeta, F as InfiniteQueryObserverOptions, Ft as QueryObserverSuccessResult, G as InvalidateQueryFilters, Gn as MutationCacheConfig, Gt as StaleTime, H as InitialDataFunction, Hn as MutationState, Ht as ResetOptions, I as InfiniteQueryObserverPendingResult, In as shouldThrowError, It as QueryOptions, J as MutateOptions, Jt as UnsetMarker, K as MutateFunction, Kn as MutationCacheNotifyEvent, Kt as StaleTimeFunction, L as InfiniteQueryObserverPlaceholderResult, Ln as skipToken, Lt as QueryPersister, M as InfiniteQueryObserverBaseResult, Mt as QueryObserverPlaceholderResult, N as InfiniteQueryObserverLoadingErrorResult, Nn as replaceEqualDeep, Nt as QueryObserverRefetchErrorResult, O as InferDataFromTag, On as matchMutation, Ot as QueryObserverLoadingErrorResult, P as InfiniteQueryObserverLoadingResult, Pt as QueryObserverResult, Q as MutationMeta, Qt as unsetMarker, R as InfiniteQueryObserverRefetchErrorResult, Rt as QueryStatus, S as FetchNextPageOptions, St as QueryFunctionContext, T as FetchStatus, Tn as isServer, Tt as QueryKeyWithDataTag, U as InitialPageParam, Ut as ResultOptions, V as InfiniteQueryPageParamsOptions, Vn as Mutation, Vt as Register, W as InvalidateOptions, Wn as MutationCache, Wt as SetDataOptions, X as MutationFunctionContext, Xt as dataTagErrorSymbol, Y as MutationFunction, Yt as WithRequired, Z as MutationKey, Zt as dataTagSymbol, _ as DefinedQueryObserverResult, _t as QueriesPlaceholderDataFunction, a as defaultShouldDehydrateQuery, an as isCancelledError, at as MutationObserverSuccessResult, b as EnsureQueryDataOptions, bt as QueryExecuteOptions, c as hydrate, cn as QueryCacheConfig, ct as MutationStatus, d as DataTag, dn as MutationFilters, dt as NotifyEvent, et as MutationObserverErrorResult, f as DefaultError, fn as QueryFilters, ft as NotifyEventType, g as DefinedInfiniteQueryObserverResult, gt as PlaceholderDataFunction, h as DefaultedQueryObserverOptions, hn as Updater, ht as Override, i as defaultShouldDehydrateMutation, it as MutationObserverResult, j as InfiniteQueryExecuteOptions, jn as partialMatchKey, jt as QueryObserverPendingResult, k as InferErrorFromTag, kn as matchQuery, kt as QueryObserverLoadingResult, l as AnyDataTag, ln as QueryCacheNotifyEvent, lt as NetworkMode, m as DefaultedInfiniteQueryObserverOptions, mn as SkipToken, mt as OmitKeyof, n as DehydratedState, nt as MutationObserverLoadingResult, o as dehydrate, on as QueryClient, ot as MutationOptions, p as DefaultOptions, pt as NotifyOnChangeProps, q as MutateFunctionRest, qn as MutationObserver, qt as ThrowOnError, r as HydrateOptions, rr as QueryObserver, rt as MutationObserverOptions, s as dehydrateQuery, sn as QueryCache, st as MutationScope, t as DehydrateOptions, tr as QueryState, tt as MutationObserverIdleResult, u as CancelOptions, ut as NonUndefinedGuard, v as DistributiveOmit, vt as QueryBooleanOption, w as FetchQueryOptions, wt as QueryKeyHashFunction, x as FetchInfiniteQueryOptions, xn as hashKey, xt as QueryFunction, y as EnsureInfiniteQueryDataOptions, yt as QueryClientConfig, z as InfiniteQueryObserverResult, zt as RefetchOptions } from "./hydration-
|
|
3
|
+
import { $ as MutationObserverBaseResult, $n as Query, $t as CancelledError, A as InfiniteData, An as noop, At as QueryObserverOptions, B as InfiniteQueryObserverSuccessResult, Bt as RefetchQueryFilters, C as FetchPreviousPageOptions, Ct as QueryKey, D as GetPreviousPageParamFunction, Dn as keepPreviousData, Dt as QueryObserverBaseResult, E as GetNextPageParamFunction, Et as QueryMeta, F as InfiniteQueryObserverOptions, Ft as QueryObserverSuccessResult, G as InvalidateQueryFilters, Gn as MutationCacheConfig, Gt as StaleTime, H as InitialDataFunction, Hn as MutationState, Ht as ResetOptions, I as InfiniteQueryObserverPendingResult, In as shouldThrowError, It as QueryOptions, J as MutateOptions, Jt as UnsetMarker, K as MutateFunction, Kn as MutationCacheNotifyEvent, Kt as StaleTimeFunction, L as InfiniteQueryObserverPlaceholderResult, Ln as skipToken, Lt as QueryPersister, M as InfiniteQueryObserverBaseResult, Mt as QueryObserverPlaceholderResult, N as InfiniteQueryObserverLoadingErrorResult, Nn as replaceEqualDeep, Nt as QueryObserverRefetchErrorResult, O as InferDataFromTag, On as matchMutation, Ot as QueryObserverLoadingErrorResult, P as InfiniteQueryObserverLoadingResult, Pt as QueryObserverResult, Q as MutationMeta, Qt as unsetMarker, R as InfiniteQueryObserverRefetchErrorResult, Rt as QueryStatus, S as FetchNextPageOptions, St as QueryFunctionContext, T as FetchStatus, Tn as isServer, Tt as QueryKeyWithDataTag, U as InitialPageParam, Ut as ResultOptions, V as InfiniteQueryPageParamsOptions, Vn as Mutation, Vt as Register, W as InvalidateOptions, Wn as MutationCache, Wt as SetDataOptions, X as MutationFunctionContext, Xt as dataTagErrorSymbol, Y as MutationFunction, Yt as WithRequired, Z as MutationKey, Zt as dataTagSymbol, _ as DefinedQueryObserverResult, _t as QueriesPlaceholderDataFunction, a as defaultShouldDehydrateQuery, an as isCancelledError, at as MutationObserverSuccessResult, b as EnsureQueryDataOptions, bt as QueryExecuteOptions, c as hydrate, cn as QueryCacheConfig, ct as MutationStatus, d as DataTag, dn as MutationFilters, dt as NotifyEvent, et as MutationObserverErrorResult, f as DefaultError, fn as QueryFilters, ft as NotifyEventType, g as DefinedInfiniteQueryObserverResult, gt as PlaceholderDataFunction, h as DefaultedQueryObserverOptions, hn as Updater, ht as Override, i as defaultShouldDehydrateMutation, it as MutationObserverResult, j as InfiniteQueryExecuteOptions, jn as partialMatchKey, jt as QueryObserverPendingResult, k as InferErrorFromTag, kn as matchQuery, kt as QueryObserverLoadingResult, l as AnyDataTag, ln as QueryCacheNotifyEvent, lt as NetworkMode, m as DefaultedInfiniteQueryObserverOptions, mn as SkipToken, mt as OmitKeyof, n as DehydratedState, nt as MutationObserverLoadingResult, o as dehydrate, on as QueryClient, ot as MutationOptions, p as DefaultOptions, pt as NotifyOnChangeProps, q as MutateFunctionRest, qn as MutationObserver, qt as ThrowOnError, r as HydrateOptions, rr as QueryObserver, rt as MutationObserverOptions, s as dehydrateQuery, sn as QueryCache, st as MutationScope, t as DehydrateOptions, tr as QueryState, tt as MutationObserverIdleResult, u as CancelOptions, ut as NonUndefinedGuard, v as DistributiveOmit, vt as QueryBooleanOption, w as FetchQueryOptions, wt as QueryKeyHashFunction, x as FetchInfiniteQueryOptions, xn as hashKey, xt as QueryFunction, y as EnsureInfiniteQueryDataOptions, yt as QueryClientConfig, z as InfiniteQueryObserverResult, zt as RefetchOptions } from "./hydration-Bf0oMcwO.js";
|
|
4
4
|
import { InfiniteQueryObserver } from "./infiniteQueryObserver.js";
|
|
5
5
|
import { defaultScheduler, notifyManager } from "./notifyManager.js";
|
|
6
6
|
import { OnlineManager, onlineManager } from "./onlineManager.js";
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_utils = require("./utils.cjs");
|
|
3
3
|
//#region src/infiniteQueryBehavior.ts
|
|
4
|
+
/**
|
|
5
|
+
* Creates the behavior that fetches the pages of an infinite query: the next or previous page for
|
|
6
|
+
* `fetchNextPage`/`fetchPreviousPage`, or all pages again from the start on a refetch.
|
|
7
|
+
* @param pages - The number of pages to fetch from the start when all pages are fetched again,
|
|
8
|
+
* e.g. from the `pages` option of `queryClient.infiniteQuery`. Defaults to the number of cached
|
|
9
|
+
* pages.
|
|
10
|
+
* @returns The query behavior to set on an infinite query.
|
|
11
|
+
*/
|
|
4
12
|
function infiniteQueryBehavior(pages) {
|
|
5
13
|
return { onFetch: (context, query) => {
|
|
6
14
|
const options = context.options;
|
|
@@ -71,15 +79,32 @@ function infiniteQueryBehavior(pages) {
|
|
|
71
79
|
else context.fetchFn = fetchFn;
|
|
72
80
|
} };
|
|
73
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Computes the page param of the page after the last one, with the `getNextPageParam` option.
|
|
84
|
+
* @param options - The infinite query options.
|
|
85
|
+
* @param data - The current pages and page params.
|
|
86
|
+
* @returns The next page param, or `undefined` if there are no pages yet.
|
|
87
|
+
*/
|
|
74
88
|
function getNextPageParam(options, { pages, pageParams }) {
|
|
75
89
|
const lastIndex = pages.length - 1;
|
|
76
90
|
return pages.length > 0 ? options.getNextPageParam(pages[lastIndex], pages, pageParams[lastIndex], pageParams) : void 0;
|
|
77
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Computes the page param of the page before the first one, with the `getPreviousPageParam`
|
|
94
|
+
* option.
|
|
95
|
+
* @param options - The infinite query options.
|
|
96
|
+
* @param data - The current pages and page params.
|
|
97
|
+
* @returns The previous page param, or `undefined` if there are no pages yet or no
|
|
98
|
+
* `getPreviousPageParam` option.
|
|
99
|
+
*/
|
|
78
100
|
function getPreviousPageParam(options, { pages, pageParams }) {
|
|
79
101
|
return pages.length > 0 ? options.getPreviousPageParam?.(pages[0], pages, pageParams[0], pageParams) : void 0;
|
|
80
102
|
}
|
|
81
103
|
/**
|
|
82
104
|
* Checks if there is a next page.
|
|
105
|
+
* @param options - The infinite query options with `getNextPageParam`.
|
|
106
|
+
* @param data - The current pages and page params.
|
|
107
|
+
* @returns `true` if `getNextPageParam` returns a value other than `null` or `undefined`.
|
|
83
108
|
*/
|
|
84
109
|
function hasNextPage(options, data) {
|
|
85
110
|
if (!data) return false;
|
|
@@ -87,6 +112,10 @@ function hasNextPage(options, data) {
|
|
|
87
112
|
}
|
|
88
113
|
/**
|
|
89
114
|
* Checks if there is a previous page.
|
|
115
|
+
* @param options - The infinite query options with `getPreviousPageParam`.
|
|
116
|
+
* @param data - The current pages and page params.
|
|
117
|
+
* @returns `true` if `getPreviousPageParam` is set and returns a value other than `null` or
|
|
118
|
+
* `undefined`.
|
|
90
119
|
*/
|
|
91
120
|
function hasPreviousPage(options, data) {
|
|
92
121
|
if (!data || !options.getPreviousPageParam) return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"infiniteQueryBehavior.cjs","names":["ensureQueryFn","addToStart","addToEnd"],"sources":["../../src/infiniteQueryBehavior.ts"],"sourcesContent":["import {\n addConsumeAwareSignal,\n addToEnd,\n addToStart,\n ensureQueryFn,\n} from './utils'\nimport type { QueryBehavior } from './query'\nimport type {\n InfiniteData,\n InfiniteQueryPageParamsOptions,\n OmitKeyof,\n QueryFunctionContext,\n QueryKey,\n} from './types'\n\nexport function infiniteQueryBehavior<TQueryFnData, TError, TData, TPageParam>(\n pages?: number,\n): QueryBehavior<TQueryFnData, TError, InfiniteData<TData, TPageParam>> {\n return {\n onFetch: (context, query) => {\n const options = context.options as InfiniteQueryPageParamsOptions<TData>\n const direction = context.fetchOptions?.meta?.fetchMore?.direction\n const oldPages = context.state.data?.pages || []\n const oldPageParams = context.state.data?.pageParams || []\n let result: InfiniteData<unknown> = { pages: [], pageParams: [] }\n let currentPage = 0\n\n const fetchFn = async () => {\n let cancelled = false\n const addSignalProperty = (object: unknown) => {\n addConsumeAwareSignal(\n object,\n () => context.signal,\n () => (cancelled = true),\n )\n }\n\n const queryFn = ensureQueryFn(context.options, context.fetchOptions)\n\n // Create function to fetch a page\n const fetchPage = async (\n data: InfiniteData<unknown>,\n param: unknown,\n previous?: boolean,\n ): Promise<InfiniteData<unknown>> => {\n if (cancelled) {\n return Promise.reject(context.signal.reason)\n }\n\n if (param == null && data.pages.length) {\n return Promise.resolve(data)\n }\n\n const createQueryFnContext = () => {\n const queryFnContext: OmitKeyof<\n QueryFunctionContext<QueryKey, unknown>,\n 'signal'\n > = {\n client: context.client,\n queryKey: context.queryKey,\n pageParam: param,\n direction: previous ? 'backward' : 'forward',\n meta: context.options.meta,\n }\n addSignalProperty(queryFnContext)\n return queryFnContext as QueryFunctionContext<QueryKey, unknown>\n }\n\n const queryFnContext = createQueryFnContext()\n\n const page = await queryFn(queryFnContext)\n\n const { maxPages } = context.options\n const addTo = previous ? addToStart : addToEnd\n\n return {\n pages: addTo(data.pages, page, maxPages),\n pageParams: addTo(data.pageParams, param, maxPages),\n }\n }\n\n // fetch next / previous page?\n if (direction && oldPages.length) {\n const previous = direction === 'backward'\n const pageParamFn = previous ? getPreviousPageParam : getNextPageParam\n const oldData = {\n pages: oldPages,\n pageParams: oldPageParams,\n }\n const param = pageParamFn(options, oldData)\n\n result = await fetchPage(oldData, param, previous)\n } else {\n const remainingPages = pages ?? oldPages.length\n\n // Fetch all pages\n do {\n const param =\n currentPage === 0\n ? (oldPageParams[0] ?? options.initialPageParam)\n : getNextPageParam(options, result)\n if (currentPage > 0 && param == null) {\n break\n }\n result = await fetchPage(result, param)\n currentPage++\n } while (currentPage < remainingPages)\n }\n\n return result\n }\n if (context.options.persister) {\n context.fetchFn = () => {\n return context.options.persister?.(\n fetchFn as any,\n {\n client: context.client,\n queryKey: context.queryKey,\n meta: context.options.meta,\n signal: context.signal,\n },\n query,\n )\n }\n } else {\n context.fetchFn = fetchFn\n }\n },\n }\n}\n\nfunction getNextPageParam(\n options: InfiniteQueryPageParamsOptions<any>,\n { pages, pageParams }: InfiniteData<unknown>,\n): unknown | undefined {\n const lastIndex = pages.length - 1\n return pages.length > 0\n ? options.getNextPageParam(\n pages[lastIndex],\n pages,\n pageParams[lastIndex],\n pageParams,\n )\n : undefined\n}\n\nfunction getPreviousPageParam(\n options: InfiniteQueryPageParamsOptions<any>,\n { pages, pageParams }: InfiniteData<unknown>,\n): unknown | undefined {\n return pages.length > 0\n ? options.getPreviousPageParam?.(pages[0], pages, pageParams[0], pageParams)\n : undefined\n}\n\n/**\n * Checks if there is a next page.\n */\nexport function hasNextPage(\n options: InfiniteQueryPageParamsOptions<any, any>,\n data?: InfiniteData<unknown>,\n): boolean {\n if (!data) return false\n return getNextPageParam(options, data) != null\n}\n\n/**\n * Checks if there is a previous page.\n */\nexport function hasPreviousPage(\n options: InfiniteQueryPageParamsOptions<any, any>,\n data?: InfiniteData<unknown>,\n): boolean {\n if (!data || !options.getPreviousPageParam) return false\n return getPreviousPageParam(options, data) != null\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"infiniteQueryBehavior.cjs","names":["ensureQueryFn","addToStart","addToEnd"],"sources":["../../src/infiniteQueryBehavior.ts"],"sourcesContent":["import {\n addConsumeAwareSignal,\n addToEnd,\n addToStart,\n ensureQueryFn,\n} from './utils'\nimport type { QueryBehavior } from './query'\nimport type {\n InfiniteData,\n InfiniteQueryPageParamsOptions,\n OmitKeyof,\n QueryFunctionContext,\n QueryKey,\n} from './types'\n\n/**\n * Creates the behavior that fetches the pages of an infinite query: the next or previous page for\n * `fetchNextPage`/`fetchPreviousPage`, or all pages again from the start on a refetch.\n * @param pages - The number of pages to fetch from the start when all pages are fetched again,\n * e.g. from the `pages` option of `queryClient.infiniteQuery`. Defaults to the number of cached\n * pages.\n * @returns The query behavior to set on an infinite query.\n */\nexport function infiniteQueryBehavior<TQueryFnData, TError, TData, TPageParam>(\n pages?: number,\n): QueryBehavior<TQueryFnData, TError, InfiniteData<TData, TPageParam>> {\n return {\n onFetch: (context, query) => {\n const options = context.options as InfiniteQueryPageParamsOptions<TData>\n const direction = context.fetchOptions?.meta?.fetchMore?.direction\n const oldPages = context.state.data?.pages || []\n const oldPageParams = context.state.data?.pageParams || []\n let result: InfiniteData<unknown> = { pages: [], pageParams: [] }\n let currentPage = 0\n\n const fetchFn = async () => {\n let cancelled = false\n const addSignalProperty = (object: unknown) => {\n addConsumeAwareSignal(\n object,\n () => context.signal,\n () => (cancelled = true),\n )\n }\n\n const queryFn = ensureQueryFn(context.options, context.fetchOptions)\n\n // Create function to fetch a page\n const fetchPage = async (\n data: InfiniteData<unknown>,\n param: unknown,\n previous?: boolean,\n ): Promise<InfiniteData<unknown>> => {\n if (cancelled) {\n return Promise.reject(context.signal.reason)\n }\n\n if (param == null && data.pages.length) {\n return Promise.resolve(data)\n }\n\n const createQueryFnContext = () => {\n const queryFnContext: OmitKeyof<\n QueryFunctionContext<QueryKey, unknown>,\n 'signal'\n > = {\n client: context.client,\n queryKey: context.queryKey,\n pageParam: param,\n direction: previous ? 'backward' : 'forward',\n meta: context.options.meta,\n }\n addSignalProperty(queryFnContext)\n return queryFnContext as QueryFunctionContext<QueryKey, unknown>\n }\n\n const queryFnContext = createQueryFnContext()\n\n const page = await queryFn(queryFnContext)\n\n const { maxPages } = context.options\n const addTo = previous ? addToStart : addToEnd\n\n return {\n pages: addTo(data.pages, page, maxPages),\n pageParams: addTo(data.pageParams, param, maxPages),\n }\n }\n\n // fetch next / previous page?\n if (direction && oldPages.length) {\n const previous = direction === 'backward'\n const pageParamFn = previous ? getPreviousPageParam : getNextPageParam\n const oldData = {\n pages: oldPages,\n pageParams: oldPageParams,\n }\n const param = pageParamFn(options, oldData)\n\n result = await fetchPage(oldData, param, previous)\n } else {\n const remainingPages = pages ?? oldPages.length\n\n // Fetch all pages\n do {\n const param =\n currentPage === 0\n ? (oldPageParams[0] ?? options.initialPageParam)\n : getNextPageParam(options, result)\n if (currentPage > 0 && param == null) {\n break\n }\n result = await fetchPage(result, param)\n currentPage++\n } while (currentPage < remainingPages)\n }\n\n return result\n }\n if (context.options.persister) {\n context.fetchFn = () => {\n return context.options.persister?.(\n fetchFn as any,\n {\n client: context.client,\n queryKey: context.queryKey,\n meta: context.options.meta,\n signal: context.signal,\n },\n query,\n )\n }\n } else {\n context.fetchFn = fetchFn\n }\n },\n }\n}\n\n/**\n * Computes the page param of the page after the last one, with the `getNextPageParam` option.\n * @param options - The infinite query options.\n * @param data - The current pages and page params.\n * @returns The next page param, or `undefined` if there are no pages yet.\n */\nfunction getNextPageParam(\n options: InfiniteQueryPageParamsOptions<any>,\n { pages, pageParams }: InfiniteData<unknown>,\n): unknown | undefined {\n const lastIndex = pages.length - 1\n return pages.length > 0\n ? options.getNextPageParam(\n pages[lastIndex],\n pages,\n pageParams[lastIndex],\n pageParams,\n )\n : undefined\n}\n\n/**\n * Computes the page param of the page before the first one, with the `getPreviousPageParam`\n * option.\n * @param options - The infinite query options.\n * @param data - The current pages and page params.\n * @returns The previous page param, or `undefined` if there are no pages yet or no\n * `getPreviousPageParam` option.\n */\nfunction getPreviousPageParam(\n options: InfiniteQueryPageParamsOptions<any>,\n { pages, pageParams }: InfiniteData<unknown>,\n): unknown | undefined {\n return pages.length > 0\n ? options.getPreviousPageParam?.(pages[0], pages, pageParams[0], pageParams)\n : undefined\n}\n\n/**\n * Checks if there is a next page.\n * @param options - The infinite query options with `getNextPageParam`.\n * @param data - The current pages and page params.\n * @returns `true` if `getNextPageParam` returns a value other than `null` or `undefined`.\n */\nexport function hasNextPage(\n options: InfiniteQueryPageParamsOptions<any, any>,\n data?: InfiniteData<unknown>,\n): boolean {\n if (!data) return false\n return getNextPageParam(options, data) != null\n}\n\n/**\n * Checks if there is a previous page.\n * @param options - The infinite query options with `getPreviousPageParam`.\n * @param data - The current pages and page params.\n * @returns `true` if `getPreviousPageParam` is set and returns a value other than `null` or\n * `undefined`.\n */\nexport function hasPreviousPage(\n options: InfiniteQueryPageParamsOptions<any, any>,\n data?: InfiniteData<unknown>,\n): boolean {\n if (!data || !options.getPreviousPageParam) return false\n return getPreviousPageParam(options, data) != null\n}\n"],"mappings":";;;;;;;;;;;AA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IACd;IAGA,SAAS,MAAM,UAAU,SAFX,YAAY,SAAS,OAEG,GAAG,QAAQ;GACnD,OAAO;IACL,MAAM,iBAAiB,SAAS,SAAS;IAGzC,GAAG;KACD,MAAM,QACJ,gBAAgB,IACX,cAAc,MAAM,QAAQ,mBAC7B,iBAAiB,SAAS,MAAM;KACtC,IAAI,cAAc,KAAK,SAAS,MAC9B;KAEF,SAAS,MAAM,UAAU,QAAQ,KAAK;KACtC;IACF,SAAS,cAAc;GACzB;GAEA,OAAO;EACT;EACA,IAAI,QAAQ,QAAQ,WAClB,QAAQ,gBAAgB;GACtB,OAAO,QAAQ,QAAQ,YACrB,SACA;IACE,QAAQ,QAAQ;IAChB,UAAU,QAAQ;IAClB,MAAM,QAAQ,QAAQ;IACtB,QAAQ,QAAQ;GAClB,GACA,KACF;EACF;OAEA,QAAQ,UAAU;CAEtB,EACF;AACF;;;;;;;AAQA,SAAS,iBACP,SACA,EAAE,OAAO,cACY;CACrB,MAAM,YAAY,MAAM,SAAS;CACjC,OAAO,MAAM,SAAS,IAClB,QAAQ,iBACN,MAAM,YACN,OACA,WAAW,YACX,UACF,IACA,KAAA;AACN;;;;;;;;;AAUA,SAAS,qBACP,SACA,EAAE,OAAO,cACY;CACrB,OAAO,MAAM,SAAS,IAClB,QAAQ,uBAAuB,MAAM,IAAI,OAAO,WAAW,IAAI,UAAU,IACzE,KAAA;AACN;;;;;;;AAQA,SAAgB,YACd,SACA,MACS;CACT,IAAI,CAAC,MAAM,OAAO;CAClB,OAAO,iBAAiB,SAAS,IAAI,KAAK;AAC5C;;;;;;;;AASA,SAAgB,gBACd,SACA,MACS;CACT,IAAI,CAAC,QAAQ,CAAC,QAAQ,sBAAsB,OAAO;CACnD,OAAO,qBAAqB,SAAS,IAAI,KAAK;AAChD"}
|
|
@@ -1,12 +1,27 @@
|
|
|
1
|
-
import { A as InfiniteData, V as InfiniteQueryPageParamsOptions, er as QueryBehavior } from "./hydration-
|
|
1
|
+
import { A as InfiniteData, V as InfiniteQueryPageParamsOptions, er as QueryBehavior } from "./hydration-C6zghADG.cjs";
|
|
2
2
|
//#region src/infiniteQueryBehavior.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates the behavior that fetches the pages of an infinite query: the next or previous page for
|
|
5
|
+
* `fetchNextPage`/`fetchPreviousPage`, or all pages again from the start on a refetch.
|
|
6
|
+
* @param pages - The number of pages to fetch from the start when all pages are fetched again,
|
|
7
|
+
* e.g. from the `pages` option of `queryClient.infiniteQuery`. Defaults to the number of cached
|
|
8
|
+
* pages.
|
|
9
|
+
* @returns The query behavior to set on an infinite query.
|
|
10
|
+
*/
|
|
3
11
|
export declare function infiniteQueryBehavior<TQueryFnData, TError, TData, TPageParam>(pages?: number): QueryBehavior<TQueryFnData, TError, InfiniteData<TData, TPageParam>>;
|
|
4
12
|
/**
|
|
5
13
|
* Checks if there is a next page.
|
|
14
|
+
* @param options - The infinite query options with `getNextPageParam`.
|
|
15
|
+
* @param data - The current pages and page params.
|
|
16
|
+
* @returns `true` if `getNextPageParam` returns a value other than `null` or `undefined`.
|
|
6
17
|
*/
|
|
7
18
|
export declare function hasNextPage(options: InfiniteQueryPageParamsOptions<any, any>, data?: InfiniteData<unknown>): boolean;
|
|
8
19
|
/**
|
|
9
20
|
* Checks if there is a previous page.
|
|
21
|
+
* @param options - The infinite query options with `getPreviousPageParam`.
|
|
22
|
+
* @param data - The current pages and page params.
|
|
23
|
+
* @returns `true` if `getPreviousPageParam` is set and returns a value other than `null` or
|
|
24
|
+
* `undefined`.
|
|
10
25
|
*/
|
|
11
26
|
export declare function hasPreviousPage(options: InfiniteQueryPageParamsOptions<any, any>, data?: InfiniteData<unknown>): boolean;
|
|
12
27
|
//#endregion
|
|
@@ -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":";;;;;;;;;;wBAuBgB,sBAAsB,cAAc,QAAQ,OAAO,YACjE,iBACC,cAAc,cAAc,QAAQ,aAAa,OAAO;;;;;;;wBA8J3C,YACd,SAAS,0CACT,OAAO;;;;;;;;wBAaO,gBACd,SAAS,0CACT,OAAO"}
|