@tanstack/query-core 5.101.4 → 5.102.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/legacy/classPrivateFieldSet2-Bo0ZyOIv.cjs +56 -0
- package/build/legacy/classPrivateFieldSet2-CV7wyte-.js +27 -0
- package/build/legacy/classPrivateMethodInitSpec-CBwa_Y7C.js +7 -0
- package/build/legacy/classPrivateMethodInitSpec-DVhcLejn.cjs +12 -0
- package/build/legacy/environmentManager.cjs +25 -46
- package/build/legacy/environmentManager.cjs.map +1 -1
- package/build/legacy/environmentManager.d.cts +18 -2
- package/build/legacy/environmentManager.d.cts.map +1 -0
- package/build/legacy/environmentManager.d.ts +18 -2
- package/build/legacy/environmentManager.d.ts.map +1 -0
- package/build/legacy/environmentManager.js +23 -22
- package/build/legacy/environmentManager.js.map +1 -1
- package/build/legacy/focusManager.cjs +63 -104
- package/build/legacy/focusManager.cjs.map +1 -1
- package/build/legacy/focusManager.d.cts +18 -2
- package/build/legacy/focusManager.d.cts.map +1 -0
- package/build/legacy/focusManager.d.ts +18 -2
- package/build/legacy/focusManager.d.ts.map +1 -0
- package/build/legacy/focusManager.js +60 -76
- package/build/legacy/focusManager.js.map +1 -1
- package/build/legacy/hydration-D1E7ZbjZ.d.ts +1374 -0
- package/build/legacy/hydration-D1E7ZbjZ.d.ts.map +1 -0
- package/build/legacy/hydration-NBquRCHe.d.cts +1374 -0
- package/build/legacy/hydration-NBquRCHe.d.cts.map +1 -0
- package/build/legacy/hydration.cjs +114 -194
- package/build/legacy/hydration.cjs.map +1 -1
- package/build/legacy/hydration.d.cts +2 -7
- package/build/legacy/hydration.d.ts +2 -7
- package/build/legacy/hydration.js +108 -167
- package/build/legacy/hydration.js.map +1 -1
- package/build/legacy/index.cjs +59 -111
- package/build/legacy/index.cjs.map +1 -1
- package/build/legacy/index.d.cts +10 -141
- package/build/legacy/index.d.ts +10 -141
- package/build/legacy/index.js +16 -66
- package/build/legacy/index.js.map +1 -1
- package/build/legacy/infiniteQueryBehavior.cjs +92 -135
- package/build/legacy/infiniteQueryBehavior.cjs.map +1 -1
- package/build/legacy/infiniteQueryBehavior.d.cts +14 -3
- package/build/legacy/infiniteQueryBehavior.d.cts.map +1 -0
- package/build/legacy/infiniteQueryBehavior.d.ts +14 -3
- package/build/legacy/infiniteQueryBehavior.d.ts.map +1 -0
- package/build/legacy/infiniteQueryBehavior.js +89 -115
- package/build/legacy/infiniteQueryBehavior.js.map +1 -1
- package/build/legacy/infiniteQueryObserver.cjs +59 -88
- package/build/legacy/infiniteQueryObserver.cjs.map +1 -1
- package/build/legacy/infiniteQueryObserver.d.cts +20 -1
- package/build/legacy/infiniteQueryObserver.d.cts.map +1 -0
- package/build/legacy/infiniteQueryObserver.d.ts +20 -1
- package/build/legacy/infiniteQueryObserver.d.ts.map +1 -0
- package/build/legacy/infiniteQueryObserver.js +57 -64
- package/build/legacy/infiniteQueryObserver.js.map +1 -1
- package/build/legacy/mutation.cjs +236 -329
- package/build/legacy/mutation.cjs.map +1 -1
- package/build/legacy/mutation.d.cts +2 -4
- package/build/legacy/mutation.d.ts +2 -4
- package/build/legacy/mutation.js +231 -299
- package/build/legacy/mutation.js.map +1 -1
- package/build/legacy/mutationCache.cjs +121 -166
- package/build/legacy/mutationCache.cjs.map +1 -1
- package/build/legacy/mutationCache.d.cts +2 -2
- package/build/legacy/mutationCache.d.ts +2 -2
- package/build/legacy/mutationCache.js +117 -130
- package/build/legacy/mutationCache.js.map +1 -1
- package/build/legacy/mutationObserver.cjs +134 -187
- package/build/legacy/mutationObserver.cjs.map +1 -1
- package/build/legacy/mutationObserver.d.cts +2 -1
- package/build/legacy/mutationObserver.d.ts +2 -1
- package/build/legacy/mutationObserver.js +132 -160
- package/build/legacy/mutationObserver.js.map +1 -1
- package/build/legacy/notifyManager.cjs +76 -110
- package/build/legacy/notifyManager.cjs.map +1 -1
- package/build/legacy/notifyManager.d.cts +48 -3
- package/build/legacy/notifyManager.d.cts.map +1 -0
- package/build/legacy/notifyManager.d.ts +48 -3
- package/build/legacy/notifyManager.d.ts.map +1 -0
- package/build/legacy/notifyManager.js +73 -84
- package/build/legacy/notifyManager.js.map +1 -1
- package/build/legacy/onlineManager.cjs +57 -93
- package/build/legacy/onlineManager.cjs.map +1 -1
- package/build/legacy/onlineManager.d.cts +17 -2
- package/build/legacy/onlineManager.d.cts.map +1 -0
- package/build/legacy/onlineManager.d.ts +17 -2
- package/build/legacy/onlineManager.d.ts.map +1 -0
- package/build/legacy/onlineManager.js +54 -65
- package/build/legacy/onlineManager.js.map +1 -1
- package/build/legacy/queriesObserver.cjs +203 -262
- package/build/legacy/queriesObserver.cjs.map +1 -1
- package/build/legacy/queriesObserver.d.cts +23 -2
- package/build/legacy/queriesObserver.d.cts.map +1 -0
- package/build/legacy/queriesObserver.d.ts +23 -2
- package/build/legacy/queriesObserver.d.ts.map +1 -0
- package/build/legacy/queriesObserver.js +199 -233
- package/build/legacy/queriesObserver.js.map +1 -1
- package/build/legacy/query.cjs +409 -491
- package/build/legacy/query.cjs.map +1 -1
- package/build/legacy/query.d.cts +2 -9
- package/build/legacy/query.d.ts +2 -9
- package/build/legacy/query.js +402 -467
- package/build/legacy/query.js.map +1 -1
- package/build/legacy/queryCache.cjs +99 -128
- package/build/legacy/queryCache.cjs.map +1 -1
- package/build/legacy/queryCache.d.cts +2 -3
- package/build/legacy/queryCache.d.ts +2 -3
- package/build/legacy/queryCache.js +96 -100
- package/build/legacy/queryCache.js.map +1 -1
- package/build/legacy/queryClient.cjs +295 -345
- package/build/legacy/queryClient.cjs.map +1 -1
- package/build/legacy/queryClient.d.cts +2 -1
- package/build/legacy/queryClient.d.ts +2 -1
- package/build/legacy/queryClient.js +292 -318
- package/build/legacy/queryClient.js.map +1 -1
- package/build/legacy/queryObserver.cjs +350 -502
- package/build/legacy/queryObserver.cjs.map +1 -1
- package/build/legacy/queryObserver.d.cts +2 -1
- package/build/legacy/queryObserver.d.ts +2 -1
- package/build/legacy/queryObserver.js +345 -480
- package/build/legacy/queryObserver.js.map +1 -1
- package/build/legacy/removable-DeMjhW5M.d.cts +13 -0
- package/build/legacy/removable-DeMjhW5M.d.cts.map +1 -0
- package/build/legacy/removable-DeMjhW5M.d.ts +13 -0
- package/build/legacy/removable-DeMjhW5M.d.ts.map +1 -0
- package/build/legacy/removable.cjs +31 -67
- package/build/legacy/removable.cjs.map +1 -1
- package/build/legacy/removable.d.cts +2 -1
- package/build/legacy/removable.d.ts +2 -1
- package/build/legacy/removable.js +28 -39
- package/build/legacy/removable.js.map +1 -1
- package/build/legacy/retryer.cjs +127 -155
- package/build/legacy/retryer.cjs.map +1 -1
- package/build/legacy/retryer.d.cts +2 -7
- package/build/legacy/retryer.d.ts +2 -7
- package/build/legacy/retryer.js +121 -127
- package/build/legacy/retryer.js.map +1 -1
- package/build/legacy/streamedQuery.cjs +49 -78
- package/build/legacy/streamedQuery.cjs.map +1 -1
- package/build/legacy/streamedQuery.d.cts +33 -1
- package/build/legacy/streamedQuery.d.cts.map +1 -0
- package/build/legacy/streamedQuery.d.ts +33 -1
- package/build/legacy/streamedQuery.d.ts.map +1 -0
- package/build/legacy/streamedQuery.js +47 -54
- package/build/legacy/streamedQuery.js.map +1 -1
- package/build/legacy/subscribable-CbifVTKz.d.cts +12 -0
- package/build/legacy/subscribable-CbifVTKz.d.cts.map +1 -0
- package/build/legacy/subscribable-CbifVTKz.d.ts +12 -0
- package/build/legacy/subscribable-CbifVTKz.d.ts.map +1 -0
- package/build/legacy/subscribable.cjs +22 -48
- package/build/legacy/subscribable.cjs.map +1 -1
- package/build/legacy/subscribable.d.cts +2 -1
- package/build/legacy/subscribable.d.ts +2 -1
- package/build/legacy/subscribable.js +21 -25
- package/build/legacy/subscribable.js.map +1 -1
- package/build/legacy/timeoutManager.cjs +64 -105
- package/build/legacy/timeoutManager.cjs.map +1 -1
- package/build/legacy/timeoutManager.d.cts +60 -7
- package/build/legacy/timeoutManager.d.cts.map +1 -0
- package/build/legacy/timeoutManager.d.ts +60 -7
- package/build/legacy/timeoutManager.d.ts.map +1 -0
- package/build/legacy/timeoutManager.js +60 -76
- package/build/legacy/timeoutManager.js.map +1 -1
- package/build/legacy/types.cjs +10 -35
- package/build/legacy/types.cjs.map +1 -1
- package/build/legacy/types.d.cts +2 -94
- package/build/legacy/types.d.ts +2 -94
- package/build/legacy/types.js +7 -10
- package/build/legacy/types.js.map +1 -1
- package/build/legacy/utils.cjs +175 -300
- package/build/legacy/utils.cjs.map +1 -1
- package/build/legacy/utils.d.cts +2 -30
- package/build/legacy/utils.d.ts +2 -30
- package/build/legacy/utils.js +149 -252
- package/build/legacy/utils.js.map +1 -1
- package/build/modern/environmentManager.cjs +25 -46
- package/build/modern/environmentManager.cjs.map +1 -1
- package/build/modern/environmentManager.d.cts +18 -2
- package/build/modern/environmentManager.d.cts.map +1 -0
- package/build/modern/environmentManager.d.ts +18 -2
- package/build/modern/environmentManager.d.ts.map +1 -0
- package/build/modern/environmentManager.js +23 -20
- package/build/modern/environmentManager.js.map +1 -1
- package/build/modern/focusManager.cjs +56 -90
- package/build/modern/focusManager.cjs.map +1 -1
- package/build/modern/focusManager.d.cts +18 -2
- package/build/modern/focusManager.d.cts.map +1 -0
- package/build/modern/focusManager.d.ts +18 -2
- package/build/modern/focusManager.d.ts.map +1 -0
- package/build/modern/focusManager.js +53 -63
- package/build/modern/focusManager.js.map +1 -1
- package/build/modern/hydration-D1E7ZbjZ.d.ts +1374 -0
- package/build/modern/hydration-D1E7ZbjZ.d.ts.map +1 -0
- package/build/modern/hydration-NBquRCHe.d.cts +1374 -0
- package/build/modern/hydration-NBquRCHe.d.cts.map +1 -0
- package/build/modern/hydration.cjs +105 -189
- package/build/modern/hydration.cjs.map +1 -1
- package/build/modern/hydration.d.cts +2 -7
- package/build/modern/hydration.d.ts +2 -7
- package/build/modern/hydration.js +99 -160
- package/build/modern/hydration.js.map +1 -1
- package/build/modern/index.cjs +59 -111
- package/build/modern/index.cjs.map +1 -1
- package/build/modern/index.d.cts +10 -141
- package/build/modern/index.d.ts +10 -141
- package/build/modern/index.js +16 -64
- package/build/modern/index.js.map +1 -1
- package/build/modern/infiniteQueryBehavior.cjs +89 -131
- package/build/modern/infiniteQueryBehavior.cjs.map +1 -1
- package/build/modern/infiniteQueryBehavior.d.cts +14 -3
- package/build/modern/infiniteQueryBehavior.d.cts.map +1 -0
- package/build/modern/infiniteQueryBehavior.d.ts +14 -3
- package/build/modern/infiniteQueryBehavior.d.ts.map +1 -0
- package/build/modern/infiniteQueryBehavior.js +86 -109
- package/build/modern/infiniteQueryBehavior.js.map +1 -1
- package/build/modern/infiniteQueryObserver.cjs +58 -87
- package/build/modern/infiniteQueryObserver.cjs.map +1 -1
- package/build/modern/infiniteQueryObserver.d.cts +20 -1
- package/build/modern/infiniteQueryObserver.d.cts.map +1 -0
- package/build/modern/infiniteQueryObserver.d.ts +20 -1
- package/build/modern/infiniteQueryObserver.d.ts.map +1 -0
- package/build/modern/infiniteQueryObserver.js +56 -61
- package/build/modern/infiniteQueryObserver.js.map +1 -1
- package/build/modern/mutation.cjs +221 -303
- package/build/modern/mutation.cjs.map +1 -1
- package/build/modern/mutation.d.cts +2 -4
- package/build/modern/mutation.d.ts +2 -4
- package/build/modern/mutation.js +216 -274
- package/build/modern/mutation.js.map +1 -1
- package/build/modern/mutationCache.cjs +111 -145
- package/build/modern/mutationCache.cjs.map +1 -1
- package/build/modern/mutationCache.d.cts +2 -2
- package/build/modern/mutationCache.d.ts +2 -2
- package/build/modern/mutationCache.js +107 -117
- package/build/modern/mutationCache.js.map +1 -1
- package/build/modern/mutationObserver.cjs +115 -162
- package/build/modern/mutationObserver.cjs.map +1 -1
- package/build/modern/mutationObserver.d.cts +2 -1
- package/build/modern/mutationObserver.d.ts +2 -1
- package/build/modern/mutationObserver.js +113 -136
- package/build/modern/mutationObserver.js.map +1 -1
- package/build/modern/notifyManager.cjs +76 -110
- package/build/modern/notifyManager.cjs.map +1 -1
- package/build/modern/notifyManager.d.cts +48 -3
- package/build/modern/notifyManager.d.cts.map +1 -0
- package/build/modern/notifyManager.d.ts +48 -3
- package/build/modern/notifyManager.d.ts.map +1 -0
- package/build/modern/notifyManager.js +73 -82
- package/build/modern/notifyManager.js.map +1 -1
- package/build/modern/onlineManager.cjs +51 -80
- package/build/modern/onlineManager.cjs.map +1 -1
- package/build/modern/onlineManager.d.cts +17 -2
- package/build/modern/onlineManager.d.cts.map +1 -0
- package/build/modern/onlineManager.d.ts +17 -2
- package/build/modern/onlineManager.d.ts.map +1 -0
- package/build/modern/onlineManager.js +48 -53
- package/build/modern/onlineManager.js.map +1 -1
- package/build/modern/queriesObserver.cjs +185 -237
- package/build/modern/queriesObserver.cjs.map +1 -1
- package/build/modern/queriesObserver.d.cts +23 -2
- package/build/modern/queriesObserver.d.cts.map +1 -0
- package/build/modern/queriesObserver.d.ts +23 -2
- package/build/modern/queriesObserver.d.ts.map +1 -0
- package/build/modern/queriesObserver.js +181 -209
- package/build/modern/queriesObserver.js.map +1 -1
- package/build/modern/query.cjs +384 -464
- package/build/modern/query.cjs.map +1 -1
- package/build/modern/query.d.cts +2 -9
- package/build/modern/query.d.ts +2 -9
- package/build/modern/query.js +377 -441
- package/build/modern/query.js.map +1 -1
- package/build/modern/queryCache.cjs +97 -119
- package/build/modern/queryCache.cjs.map +1 -1
- package/build/modern/queryCache.d.cts +2 -3
- package/build/modern/queryCache.d.ts +2 -3
- package/build/modern/queryCache.js +94 -92
- package/build/modern/queryCache.js.map +1 -1
- package/build/modern/queryClient.cjs +281 -318
- package/build/modern/queryClient.cjs.map +1 -1
- package/build/modern/queryClient.d.cts +2 -1
- package/build/modern/queryClient.d.ts +2 -1
- package/build/modern/queryClient.js +278 -299
- package/build/modern/queryClient.js.map +1 -1
- package/build/modern/queryObserver.cjs +329 -475
- package/build/modern/queryObserver.cjs.map +1 -1
- package/build/modern/queryObserver.d.cts +2 -1
- package/build/modern/queryObserver.d.ts +2 -1
- package/build/modern/queryObserver.js +324 -454
- package/build/modern/queryObserver.js.map +1 -1
- package/build/modern/removable-DeMjhW5M.d.cts +13 -0
- package/build/modern/removable-DeMjhW5M.d.cts.map +1 -0
- package/build/modern/removable-DeMjhW5M.d.ts +13 -0
- package/build/modern/removable-DeMjhW5M.d.ts.map +1 -0
- package/build/modern/removable.cjs +27 -56
- package/build/modern/removable.cjs.map +1 -1
- package/build/modern/removable.d.cts +2 -1
- package/build/modern/removable.d.ts +2 -1
- package/build/modern/removable.js +24 -29
- package/build/modern/removable.js.map +1 -1
- package/build/modern/retryer.cjs +121 -151
- package/build/modern/retryer.cjs.map +1 -1
- package/build/modern/retryer.d.cts +2 -7
- package/build/modern/retryer.d.ts +2 -7
- package/build/modern/retryer.js +115 -121
- package/build/modern/retryer.js.map +1 -1
- package/build/modern/streamedQuery.cjs +49 -78
- package/build/modern/streamedQuery.cjs.map +1 -1
- package/build/modern/streamedQuery.d.cts +33 -1
- package/build/modern/streamedQuery.d.cts.map +1 -0
- package/build/modern/streamedQuery.d.ts +33 -1
- package/build/modern/streamedQuery.d.ts.map +1 -0
- package/build/modern/streamedQuery.js +47 -52
- package/build/modern/streamedQuery.js.map +1 -1
- package/build/modern/subscribable-CbifVTKz.d.cts +12 -0
- package/build/modern/subscribable-CbifVTKz.d.cts.map +1 -0
- package/build/modern/subscribable-CbifVTKz.d.ts +12 -0
- package/build/modern/subscribable-CbifVTKz.d.ts.map +1 -0
- package/build/modern/subscribable.cjs +22 -48
- package/build/modern/subscribable.cjs.map +1 -1
- package/build/modern/subscribable.d.cts +2 -1
- package/build/modern/subscribable.d.ts +2 -1
- package/build/modern/subscribable.js +21 -23
- package/build/modern/subscribable.js.map +1 -1
- package/build/modern/timeoutManager.cjs +59 -93
- package/build/modern/timeoutManager.cjs.map +1 -1
- package/build/modern/timeoutManager.d.cts +60 -7
- package/build/modern/timeoutManager.d.cts.map +1 -0
- package/build/modern/timeoutManager.d.ts +60 -7
- package/build/modern/timeoutManager.d.ts.map +1 -0
- package/build/modern/timeoutManager.js +55 -65
- package/build/modern/timeoutManager.js.map +1 -1
- package/build/modern/types.cjs +10 -35
- package/build/modern/types.cjs.map +1 -1
- package/build/modern/types.d.cts +2 -94
- package/build/modern/types.d.ts +2 -94
- package/build/modern/types.js +8 -9
- package/build/modern/types.js.map +1 -1
- package/build/modern/utils.cjs +175 -300
- package/build/modern/utils.cjs.map +1 -1
- package/build/modern/utils.d.cts +2 -30
- package/build/modern/utils.d.ts +2 -30
- package/build/modern/utils.js +149 -250
- package/build/modern/utils.js.map +1 -1
- package/package.json +3 -5
- package/src/hydration.ts +62 -44
- package/src/index.ts +1 -0
- package/src/mutation.ts +14 -6
- package/src/mutationObserver.ts +8 -0
- package/src/queriesObserver.ts +14 -8
- package/src/query.ts +14 -6
- package/src/queryClient.ts +90 -2
- package/src/queryObserver.ts +41 -64
- package/src/retryer.ts +20 -12
- package/src/types.ts +70 -58
- package/build/legacy/_tsup-dts-rollup.d.cts +0 -2188
- package/build/legacy/_tsup-dts-rollup.d.ts +0 -2188
- package/build/legacy/chunk-PXG64RU4.js +0 -25
- package/build/legacy/chunk-PXG64RU4.js.map +0 -1
- package/build/legacy/thenable.cjs +0 -76
- package/build/legacy/thenable.cjs.map +0 -1
- package/build/legacy/thenable.d.cts +0 -6
- package/build/legacy/thenable.d.ts +0 -6
- package/build/legacy/thenable.js +0 -52
- package/build/legacy/thenable.js.map +0 -1
- package/build/modern/_tsup-dts-rollup.d.cts +0 -2188
- package/build/modern/_tsup-dts-rollup.d.ts +0 -2188
- package/build/modern/thenable.cjs +0 -75
- package/build/modern/thenable.cjs.map +0 -1
- package/build/modern/thenable.d.cts +0 -6
- package/build/modern/thenable.d.ts +0 -6
- package/build/modern/thenable.js +0 -49
- package/build/modern/thenable.js.map +0 -1
- package/src/thenable.ts +0 -111
|
@@ -1,498 +1,363 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
__privateMethod,
|
|
5
|
-
__privateSet
|
|
6
|
-
} from "./chunk-PXG64RU4.js";
|
|
7
|
-
|
|
8
|
-
// src/queryObserver.ts
|
|
9
|
-
import { focusManager } from "./focusManager.js";
|
|
1
|
+
import { i as _classPrivateFieldInitSpec, n as _classPrivateFieldGet2, r as _assertClassBrand, t as _classPrivateFieldSet2 } from "./classPrivateFieldSet2-CV7wyte-.js";
|
|
2
|
+
import { timeoutManager } from "./timeoutManager.js";
|
|
3
|
+
import { isValidTimeout, noop, replaceData, resolveQueryBoolean, resolveStaleTime, shallowEqualObjects, timeUntilStale } from "./utils.js";
|
|
10
4
|
import { environmentManager } from "./environmentManager.js";
|
|
5
|
+
import { Subscribable } from "./subscribable.js";
|
|
6
|
+
import { focusManager } from "./focusManager.js";
|
|
11
7
|
import { notifyManager } from "./notifyManager.js";
|
|
8
|
+
import { t as _classPrivateMethodInitSpec } from "./classPrivateMethodInitSpec-CBwa_Y7C.js";
|
|
12
9
|
import { fetchState } from "./query.js";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
var
|
|
10
|
+
//#region src/queryObserver.ts
|
|
11
|
+
var _client = /* @__PURE__ */ new WeakMap();
|
|
12
|
+
var _currentQuery = /* @__PURE__ */ new WeakMap();
|
|
13
|
+
var _currentQueryInitialState = /* @__PURE__ */ new WeakMap();
|
|
14
|
+
var _currentResult = /* @__PURE__ */ new WeakMap();
|
|
15
|
+
var _currentResultState = /* @__PURE__ */ new WeakMap();
|
|
16
|
+
var _currentResultOptions = /* @__PURE__ */ new WeakMap();
|
|
17
|
+
var _selectError = /* @__PURE__ */ new WeakMap();
|
|
18
|
+
var _selectFn = /* @__PURE__ */ new WeakMap();
|
|
19
|
+
var _selectResult = /* @__PURE__ */ new WeakMap();
|
|
20
|
+
var _lastQueryWithDefinedData = /* @__PURE__ */ new WeakMap();
|
|
21
|
+
var _staleTimeoutId = /* @__PURE__ */ new WeakMap();
|
|
22
|
+
var _refetchIntervalId = /* @__PURE__ */ new WeakMap();
|
|
23
|
+
var _currentRefetchInterval = /* @__PURE__ */ new WeakMap();
|
|
24
|
+
var _trackedProps = /* @__PURE__ */ new WeakMap();
|
|
25
|
+
var _QueryObserver_brand = /* @__PURE__ */ new WeakSet();
|
|
26
26
|
var QueryObserver = class extends Subscribable {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
dataUpdatedAt: newState.dataUpdatedAt,
|
|
273
|
-
error,
|
|
274
|
-
errorUpdatedAt,
|
|
275
|
-
failureCount: newState.fetchFailureCount,
|
|
276
|
-
failureReason: newState.fetchFailureReason,
|
|
277
|
-
errorUpdateCount: newState.errorUpdateCount,
|
|
278
|
-
isFetched: query.isFetched(),
|
|
279
|
-
isFetchedAfterMount: newState.dataUpdateCount > queryInitialState.dataUpdateCount || newState.errorUpdateCount > queryInitialState.errorUpdateCount,
|
|
280
|
-
isFetching,
|
|
281
|
-
isRefetching: isFetching && !isPending,
|
|
282
|
-
isLoadingError: isError && !hasData,
|
|
283
|
-
isPaused: newState.fetchStatus === "paused",
|
|
284
|
-
isPlaceholderData,
|
|
285
|
-
isRefetchError: isError && hasData,
|
|
286
|
-
isStale: isStale(query, options),
|
|
287
|
-
refetch: this.refetch,
|
|
288
|
-
promise: __privateGet(this, _currentThenable),
|
|
289
|
-
isEnabled: resolveQueryBoolean(options.enabled, query) !== false
|
|
290
|
-
};
|
|
291
|
-
const nextResult = result;
|
|
292
|
-
if (this.options.experimental_prefetchInRender) {
|
|
293
|
-
const hasResultData = nextResult.data !== void 0;
|
|
294
|
-
const isErrorWithoutData = nextResult.status === "error" && !hasResultData;
|
|
295
|
-
const finalizeThenableIfPossible = (thenable) => {
|
|
296
|
-
if (isErrorWithoutData) {
|
|
297
|
-
thenable.reject(nextResult.error);
|
|
298
|
-
} else if (hasResultData) {
|
|
299
|
-
thenable.resolve(nextResult.data);
|
|
300
|
-
}
|
|
301
|
-
};
|
|
302
|
-
const recreateThenable = () => {
|
|
303
|
-
const pending = __privateSet(this, _currentThenable, nextResult.promise = pendingThenable());
|
|
304
|
-
finalizeThenableIfPossible(pending);
|
|
305
|
-
};
|
|
306
|
-
const prevThenable = __privateGet(this, _currentThenable);
|
|
307
|
-
switch (prevThenable.status) {
|
|
308
|
-
case "pending":
|
|
309
|
-
if (query.queryHash === prevQuery.queryHash) {
|
|
310
|
-
finalizeThenableIfPossible(prevThenable);
|
|
311
|
-
}
|
|
312
|
-
break;
|
|
313
|
-
case "fulfilled":
|
|
314
|
-
if (isErrorWithoutData || nextResult.data !== prevThenable.value) {
|
|
315
|
-
recreateThenable();
|
|
316
|
-
}
|
|
317
|
-
break;
|
|
318
|
-
case "rejected":
|
|
319
|
-
if (!isErrorWithoutData || nextResult.error !== prevThenable.reason) {
|
|
320
|
-
recreateThenable();
|
|
321
|
-
}
|
|
322
|
-
break;
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
return nextResult;
|
|
326
|
-
}
|
|
327
|
-
updateResult() {
|
|
328
|
-
const prevResult = __privateGet(this, _currentResult);
|
|
329
|
-
const nextResult = this.createResult(__privateGet(this, _currentQuery), this.options);
|
|
330
|
-
__privateSet(this, _currentResultState, __privateGet(this, _currentQuery).state);
|
|
331
|
-
__privateSet(this, _currentResultOptions, this.options);
|
|
332
|
-
if (__privateGet(this, _currentResultState).data !== void 0) {
|
|
333
|
-
__privateSet(this, _lastQueryWithDefinedData, __privateGet(this, _currentQuery));
|
|
334
|
-
}
|
|
335
|
-
if (shallowEqualObjects(nextResult, prevResult)) {
|
|
336
|
-
return;
|
|
337
|
-
}
|
|
338
|
-
__privateSet(this, _currentResult, nextResult);
|
|
339
|
-
const shouldNotifyListeners = () => {
|
|
340
|
-
if (!prevResult) {
|
|
341
|
-
return true;
|
|
342
|
-
}
|
|
343
|
-
const { notifyOnChangeProps } = this.options;
|
|
344
|
-
const notifyOnChangePropsValue = typeof notifyOnChangeProps === "function" ? notifyOnChangeProps() : notifyOnChangeProps;
|
|
345
|
-
if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !__privateGet(this, _trackedProps).size) {
|
|
346
|
-
return true;
|
|
347
|
-
}
|
|
348
|
-
const includedProps = new Set(
|
|
349
|
-
notifyOnChangePropsValue ?? __privateGet(this, _trackedProps)
|
|
350
|
-
);
|
|
351
|
-
if (this.options.throwOnError) {
|
|
352
|
-
includedProps.add("error");
|
|
353
|
-
}
|
|
354
|
-
return Object.keys(__privateGet(this, _currentResult)).some((key) => {
|
|
355
|
-
const typedKey = key;
|
|
356
|
-
const changed = __privateGet(this, _currentResult)[typedKey] !== prevResult[typedKey];
|
|
357
|
-
return changed && includedProps.has(typedKey);
|
|
358
|
-
});
|
|
359
|
-
};
|
|
360
|
-
__privateMethod(this, _QueryObserver_instances, notify_fn).call(this, { listeners: shouldNotifyListeners() });
|
|
361
|
-
}
|
|
362
|
-
onQueryUpdate() {
|
|
363
|
-
this.updateResult();
|
|
364
|
-
if (this.hasListeners()) {
|
|
365
|
-
__privateMethod(this, _QueryObserver_instances, updateTimers_fn).call(this);
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
};
|
|
369
|
-
_client = new WeakMap();
|
|
370
|
-
_currentQuery = new WeakMap();
|
|
371
|
-
_currentQueryInitialState = new WeakMap();
|
|
372
|
-
_currentResult = new WeakMap();
|
|
373
|
-
_currentResultState = new WeakMap();
|
|
374
|
-
_currentResultOptions = new WeakMap();
|
|
375
|
-
_currentThenable = new WeakMap();
|
|
376
|
-
_selectError = new WeakMap();
|
|
377
|
-
_selectFn = new WeakMap();
|
|
378
|
-
_selectResult = new WeakMap();
|
|
379
|
-
_lastQueryWithDefinedData = new WeakMap();
|
|
380
|
-
_staleTimeoutId = new WeakMap();
|
|
381
|
-
_refetchIntervalId = new WeakMap();
|
|
382
|
-
_currentRefetchInterval = new WeakMap();
|
|
383
|
-
_trackedProps = new WeakMap();
|
|
384
|
-
_QueryObserver_instances = new WeakSet();
|
|
385
|
-
executeFetch_fn = function(fetchOptions) {
|
|
386
|
-
__privateMethod(this, _QueryObserver_instances, updateQuery_fn).call(this);
|
|
387
|
-
let promise = __privateGet(this, _currentQuery).fetch(
|
|
388
|
-
this.options,
|
|
389
|
-
fetchOptions
|
|
390
|
-
);
|
|
391
|
-
if (!(fetchOptions == null ? void 0 : fetchOptions.throwOnError)) {
|
|
392
|
-
promise = promise.catch(noop);
|
|
393
|
-
}
|
|
394
|
-
return promise;
|
|
395
|
-
};
|
|
396
|
-
updateStaleTimeout_fn = function() {
|
|
397
|
-
__privateMethod(this, _QueryObserver_instances, clearStaleTimeout_fn).call(this);
|
|
398
|
-
const staleTime = resolveStaleTime(
|
|
399
|
-
this.options.staleTime,
|
|
400
|
-
__privateGet(this, _currentQuery)
|
|
401
|
-
);
|
|
402
|
-
if (environmentManager.isServer() || __privateGet(this, _currentResult).isStale || !isValidTimeout(staleTime)) {
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
405
|
-
const time = timeUntilStale(__privateGet(this, _currentResult).dataUpdatedAt, staleTime);
|
|
406
|
-
const timeout = time + 1;
|
|
407
|
-
__privateSet(this, _staleTimeoutId, timeoutManager.setTimeout(() => {
|
|
408
|
-
if (!__privateGet(this, _currentResult).isStale) {
|
|
409
|
-
this.updateResult();
|
|
410
|
-
}
|
|
411
|
-
}, timeout));
|
|
412
|
-
};
|
|
413
|
-
computeRefetchInterval_fn = function() {
|
|
414
|
-
return (typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(__privateGet(this, _currentQuery)) : this.options.refetchInterval) ?? false;
|
|
415
|
-
};
|
|
416
|
-
updateRefetchInterval_fn = function(nextInterval) {
|
|
417
|
-
__privateMethod(this, _QueryObserver_instances, clearRefetchInterval_fn).call(this);
|
|
418
|
-
__privateSet(this, _currentRefetchInterval, nextInterval);
|
|
419
|
-
if (environmentManager.isServer() || resolveQueryBoolean(this.options.enabled, __privateGet(this, _currentQuery)) === false || !isValidTimeout(__privateGet(this, _currentRefetchInterval)) || __privateGet(this, _currentRefetchInterval) === 0) {
|
|
420
|
-
return;
|
|
421
|
-
}
|
|
422
|
-
__privateSet(this, _refetchIntervalId, timeoutManager.setInterval(() => {
|
|
423
|
-
if (this.options.refetchIntervalInBackground || focusManager.isFocused()) {
|
|
424
|
-
__privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this);
|
|
425
|
-
}
|
|
426
|
-
}, __privateGet(this, _currentRefetchInterval)));
|
|
427
|
-
};
|
|
428
|
-
updateTimers_fn = function() {
|
|
429
|
-
__privateMethod(this, _QueryObserver_instances, updateStaleTimeout_fn).call(this);
|
|
430
|
-
__privateMethod(this, _QueryObserver_instances, updateRefetchInterval_fn).call(this, __privateMethod(this, _QueryObserver_instances, computeRefetchInterval_fn).call(this));
|
|
431
|
-
};
|
|
432
|
-
clearStaleTimeout_fn = function() {
|
|
433
|
-
if (__privateGet(this, _staleTimeoutId) !== void 0) {
|
|
434
|
-
timeoutManager.clearTimeout(__privateGet(this, _staleTimeoutId));
|
|
435
|
-
__privateSet(this, _staleTimeoutId, void 0);
|
|
436
|
-
}
|
|
437
|
-
};
|
|
438
|
-
clearRefetchInterval_fn = function() {
|
|
439
|
-
if (__privateGet(this, _refetchIntervalId) !== void 0) {
|
|
440
|
-
timeoutManager.clearInterval(__privateGet(this, _refetchIntervalId));
|
|
441
|
-
__privateSet(this, _refetchIntervalId, void 0);
|
|
442
|
-
}
|
|
443
|
-
};
|
|
444
|
-
updateQuery_fn = function() {
|
|
445
|
-
const query = __privateGet(this, _client).getQueryCache().build(__privateGet(this, _client), this.options);
|
|
446
|
-
if (query === __privateGet(this, _currentQuery)) {
|
|
447
|
-
return;
|
|
448
|
-
}
|
|
449
|
-
const prevQuery = __privateGet(this, _currentQuery);
|
|
450
|
-
__privateSet(this, _currentQuery, query);
|
|
451
|
-
__privateSet(this, _currentQueryInitialState, query.state);
|
|
452
|
-
if (this.hasListeners()) {
|
|
453
|
-
prevQuery == null ? void 0 : prevQuery.removeObserver(this);
|
|
454
|
-
query.addObserver(this);
|
|
455
|
-
}
|
|
456
|
-
};
|
|
457
|
-
notify_fn = function(notifyOptions) {
|
|
458
|
-
notifyManager.batch(() => {
|
|
459
|
-
if (notifyOptions.listeners) {
|
|
460
|
-
this.listeners.forEach((listener) => {
|
|
461
|
-
listener(__privateGet(this, _currentResult));
|
|
462
|
-
});
|
|
463
|
-
}
|
|
464
|
-
__privateGet(this, _client).getQueryCache().notify({
|
|
465
|
-
query: __privateGet(this, _currentQuery),
|
|
466
|
-
type: "observerResultsUpdated"
|
|
467
|
-
});
|
|
468
|
-
});
|
|
27
|
+
constructor(client, options) {
|
|
28
|
+
super();
|
|
29
|
+
this.options = options;
|
|
30
|
+
_classPrivateMethodInitSpec(this, _QueryObserver_brand);
|
|
31
|
+
_classPrivateFieldInitSpec(this, _client, void 0);
|
|
32
|
+
_classPrivateFieldInitSpec(this, _currentQuery, void 0);
|
|
33
|
+
_classPrivateFieldInitSpec(this, _currentQueryInitialState, void 0);
|
|
34
|
+
_classPrivateFieldInitSpec(this, _currentResult, void 0);
|
|
35
|
+
_classPrivateFieldInitSpec(this, _currentResultState, void 0);
|
|
36
|
+
_classPrivateFieldInitSpec(this, _currentResultOptions, void 0);
|
|
37
|
+
_classPrivateFieldInitSpec(this, _selectError, void 0);
|
|
38
|
+
_classPrivateFieldInitSpec(this, _selectFn, void 0);
|
|
39
|
+
_classPrivateFieldInitSpec(this, _selectResult, void 0);
|
|
40
|
+
_classPrivateFieldInitSpec(this, _lastQueryWithDefinedData, void 0);
|
|
41
|
+
_classPrivateFieldInitSpec(this, _staleTimeoutId, void 0);
|
|
42
|
+
_classPrivateFieldInitSpec(this, _refetchIntervalId, void 0);
|
|
43
|
+
_classPrivateFieldInitSpec(this, _currentRefetchInterval, void 0);
|
|
44
|
+
_classPrivateFieldInitSpec(this, _trackedProps, /* @__PURE__ */ new Set());
|
|
45
|
+
_classPrivateFieldSet2(_client, this, client);
|
|
46
|
+
_classPrivateFieldSet2(_selectError, this, null);
|
|
47
|
+
this.bindMethods();
|
|
48
|
+
this.setOptions(options);
|
|
49
|
+
}
|
|
50
|
+
bindMethods() {
|
|
51
|
+
this.refetch = this.refetch.bind(this);
|
|
52
|
+
}
|
|
53
|
+
onSubscribe() {
|
|
54
|
+
if (this.listeners.size === 1) {
|
|
55
|
+
_classPrivateFieldGet2(_currentQuery, this).addObserver(this);
|
|
56
|
+
if (shouldFetchOnMount(_classPrivateFieldGet2(_currentQuery, this), this.options)) _assertClassBrand(_QueryObserver_brand, this, _executeFetch).call(this);
|
|
57
|
+
else this.updateResult();
|
|
58
|
+
_assertClassBrand(_QueryObserver_brand, this, _updateTimers).call(this);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
onUnsubscribe() {
|
|
62
|
+
if (!this.hasListeners()) this.destroy();
|
|
63
|
+
}
|
|
64
|
+
shouldFetchOnReconnect() {
|
|
65
|
+
return shouldFetchOn(_classPrivateFieldGet2(_currentQuery, this), this.options, this.options.refetchOnReconnect);
|
|
66
|
+
}
|
|
67
|
+
shouldFetchOnWindowFocus() {
|
|
68
|
+
return shouldFetchOn(_classPrivateFieldGet2(_currentQuery, this), this.options, this.options.refetchOnWindowFocus);
|
|
69
|
+
}
|
|
70
|
+
destroy() {
|
|
71
|
+
this.listeners = /* @__PURE__ */ new Set();
|
|
72
|
+
_assertClassBrand(_QueryObserver_brand, this, _clearStaleTimeout).call(this);
|
|
73
|
+
_assertClassBrand(_QueryObserver_brand, this, _clearRefetchInterval).call(this);
|
|
74
|
+
_classPrivateFieldGet2(_currentQuery, this).removeObserver(this);
|
|
75
|
+
}
|
|
76
|
+
setOptions(options) {
|
|
77
|
+
const prevOptions = this.options;
|
|
78
|
+
const prevQuery = _classPrivateFieldGet2(_currentQuery, this);
|
|
79
|
+
this.options = _classPrivateFieldGet2(_client, this).defaultQueryOptions(options);
|
|
80
|
+
if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean" && typeof this.options.enabled !== "function" && typeof resolveQueryBoolean(this.options.enabled, _classPrivateFieldGet2(_currentQuery, this)) !== "boolean") throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");
|
|
81
|
+
_assertClassBrand(_QueryObserver_brand, this, _updateQuery).call(this);
|
|
82
|
+
_classPrivateFieldGet2(_currentQuery, this).setOptions(this.options);
|
|
83
|
+
if (prevOptions._defaulted && !shallowEqualObjects(this.options, prevOptions)) _classPrivateFieldGet2(_client, this).getQueryCache().notify({
|
|
84
|
+
type: "observerOptionsUpdated",
|
|
85
|
+
query: _classPrivateFieldGet2(_currentQuery, this),
|
|
86
|
+
observer: this
|
|
87
|
+
});
|
|
88
|
+
const mounted = this.hasListeners();
|
|
89
|
+
if (mounted && shouldFetchOptionally(_classPrivateFieldGet2(_currentQuery, this), prevQuery, this.options, prevOptions)) _assertClassBrand(_QueryObserver_brand, this, _executeFetch).call(this);
|
|
90
|
+
this.updateResult();
|
|
91
|
+
if (mounted && (_classPrivateFieldGet2(_currentQuery, this) !== prevQuery || resolveQueryBoolean(this.options.enabled, _classPrivateFieldGet2(_currentQuery, this)) !== resolveQueryBoolean(prevOptions.enabled, _classPrivateFieldGet2(_currentQuery, this)) || resolveStaleTime(this.options.staleTime, _classPrivateFieldGet2(_currentQuery, this)) !== resolveStaleTime(prevOptions.staleTime, _classPrivateFieldGet2(_currentQuery, this)))) _assertClassBrand(_QueryObserver_brand, this, _updateStaleTimeout).call(this);
|
|
92
|
+
const nextRefetchInterval = _assertClassBrand(_QueryObserver_brand, this, _computeRefetchInterval).call(this);
|
|
93
|
+
if (mounted && (_classPrivateFieldGet2(_currentQuery, this) !== prevQuery || resolveQueryBoolean(this.options.enabled, _classPrivateFieldGet2(_currentQuery, this)) !== resolveQueryBoolean(prevOptions.enabled, _classPrivateFieldGet2(_currentQuery, this)) || nextRefetchInterval !== _classPrivateFieldGet2(_currentRefetchInterval, this))) _assertClassBrand(_QueryObserver_brand, this, _updateRefetchInterval).call(this, nextRefetchInterval);
|
|
94
|
+
}
|
|
95
|
+
getOptimisticResult(options) {
|
|
96
|
+
const query = _classPrivateFieldGet2(_client, this).getQueryCache().build(_classPrivateFieldGet2(_client, this), options);
|
|
97
|
+
const result = this.createResult(query, options);
|
|
98
|
+
if (shouldAssignObserverCurrentProperties(this, result)) {
|
|
99
|
+
_classPrivateFieldSet2(_currentResult, this, result);
|
|
100
|
+
_classPrivateFieldSet2(_currentResultOptions, this, this.options);
|
|
101
|
+
_classPrivateFieldSet2(_currentResultState, this, _classPrivateFieldGet2(_currentQuery, this).state);
|
|
102
|
+
}
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
getCurrentResult() {
|
|
106
|
+
return _classPrivateFieldGet2(_currentResult, this);
|
|
107
|
+
}
|
|
108
|
+
trackResult(result, onPropTracked) {
|
|
109
|
+
return new Proxy(result, { get: (target, key) => {
|
|
110
|
+
this.trackProp(key);
|
|
111
|
+
onPropTracked === null || onPropTracked === void 0 || onPropTracked(key);
|
|
112
|
+
return Reflect.get(target, key);
|
|
113
|
+
} });
|
|
114
|
+
}
|
|
115
|
+
trackProp(key) {
|
|
116
|
+
_classPrivateFieldGet2(_trackedProps, this).add(key);
|
|
117
|
+
}
|
|
118
|
+
getCurrentQuery() {
|
|
119
|
+
return _classPrivateFieldGet2(_currentQuery, this);
|
|
120
|
+
}
|
|
121
|
+
refetch({ ...options } = {}) {
|
|
122
|
+
return this.fetch({ ...options });
|
|
123
|
+
}
|
|
124
|
+
fetchOptimistic(options) {
|
|
125
|
+
const defaultedOptions = _classPrivateFieldGet2(_client, this).defaultQueryOptions(options);
|
|
126
|
+
const query = _classPrivateFieldGet2(_client, this).getQueryCache().build(_classPrivateFieldGet2(_client, this), defaultedOptions);
|
|
127
|
+
let unsubscribe = () => {};
|
|
128
|
+
let resolveEarly;
|
|
129
|
+
const cachePromise = new Promise((resolve) => {
|
|
130
|
+
resolveEarly = resolve;
|
|
131
|
+
unsubscribe = _classPrivateFieldGet2(_client, this).getQueryCache().subscribe((event) => {
|
|
132
|
+
if (event.type === "updated" && event.query.queryHash === query.queryHash && query.state.data !== void 0) {
|
|
133
|
+
unsubscribe();
|
|
134
|
+
resolve(this.createResult(query, defaultedOptions));
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
return Promise.race([query.fetch().then(() => {
|
|
139
|
+
const result = this.createResult(query, defaultedOptions);
|
|
140
|
+
resolveEarly === null || resolveEarly === void 0 || resolveEarly(result);
|
|
141
|
+
return result;
|
|
142
|
+
}).finally(() => {
|
|
143
|
+
unsubscribe();
|
|
144
|
+
}), cachePromise]);
|
|
145
|
+
}
|
|
146
|
+
fetch(fetchOptions) {
|
|
147
|
+
return _assertClassBrand(_QueryObserver_brand, this, _executeFetch).call(this, {
|
|
148
|
+
...fetchOptions,
|
|
149
|
+
cancelRefetch: fetchOptions.cancelRefetch ?? true
|
|
150
|
+
}).then(() => {
|
|
151
|
+
this.updateResult();
|
|
152
|
+
return _classPrivateFieldGet2(_currentResult, this);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
createResult(query, options) {
|
|
156
|
+
const prevQuery = _classPrivateFieldGet2(_currentQuery, this);
|
|
157
|
+
const prevOptions = this.options;
|
|
158
|
+
const prevResult = _classPrivateFieldGet2(_currentResult, this);
|
|
159
|
+
const prevResultState = _classPrivateFieldGet2(_currentResultState, this);
|
|
160
|
+
const prevResultOptions = _classPrivateFieldGet2(_currentResultOptions, this);
|
|
161
|
+
const queryInitialState = query !== prevQuery ? query.state : _classPrivateFieldGet2(_currentQueryInitialState, this);
|
|
162
|
+
const { state } = query;
|
|
163
|
+
let newState = { ...state };
|
|
164
|
+
let isPlaceholderData = false;
|
|
165
|
+
let data;
|
|
166
|
+
if (options._optimisticResults) {
|
|
167
|
+
const mounted = this.hasListeners();
|
|
168
|
+
const fetchOnMount = !mounted && shouldFetchOnMount(query, options);
|
|
169
|
+
const fetchOptionally = mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions);
|
|
170
|
+
if (fetchOnMount || fetchOptionally) newState = {
|
|
171
|
+
...newState,
|
|
172
|
+
...fetchState(state.data, query.options)
|
|
173
|
+
};
|
|
174
|
+
if (options._optimisticResults === "isRestoring") newState.fetchStatus = "idle";
|
|
175
|
+
}
|
|
176
|
+
let { error, errorUpdatedAt, status } = newState;
|
|
177
|
+
data = newState.data;
|
|
178
|
+
let skipSelect = false;
|
|
179
|
+
if (options.placeholderData !== void 0 && data === void 0 && status === "pending") {
|
|
180
|
+
let placeholderData;
|
|
181
|
+
if ((prevResult === null || prevResult === void 0 ? void 0 : prevResult.isPlaceholderData) && options.placeholderData === (prevResultOptions === null || prevResultOptions === void 0 ? void 0 : prevResultOptions.placeholderData)) {
|
|
182
|
+
placeholderData = prevResult.data;
|
|
183
|
+
skipSelect = true;
|
|
184
|
+
} else {
|
|
185
|
+
var _classPrivateFieldGet2$1;
|
|
186
|
+
placeholderData = typeof options.placeholderData === "function" ? options.placeholderData((_classPrivateFieldGet2$1 = _classPrivateFieldGet2(_lastQueryWithDefinedData, this)) === null || _classPrivateFieldGet2$1 === void 0 ? void 0 : _classPrivateFieldGet2$1.state.data, _classPrivateFieldGet2(_lastQueryWithDefinedData, this)) : options.placeholderData;
|
|
187
|
+
}
|
|
188
|
+
if (placeholderData !== void 0) {
|
|
189
|
+
status = "success";
|
|
190
|
+
data = replaceData(prevResult === null || prevResult === void 0 ? void 0 : prevResult.data, placeholderData, options);
|
|
191
|
+
isPlaceholderData = true;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (options.select && data !== void 0 && !skipSelect) {
|
|
195
|
+
if (prevResult && data === (prevResultState === null || prevResultState === void 0 ? void 0 : prevResultState.data) && options.select === _classPrivateFieldGet2(_selectFn, this)) data = _classPrivateFieldGet2(_selectResult, this);
|
|
196
|
+
else try {
|
|
197
|
+
_classPrivateFieldSet2(_selectFn, this, options.select);
|
|
198
|
+
data = options.select(data);
|
|
199
|
+
data = replaceData(prevResult === null || prevResult === void 0 ? void 0 : prevResult.data, data, options);
|
|
200
|
+
_classPrivateFieldSet2(_selectResult, this, data);
|
|
201
|
+
_classPrivateFieldSet2(_selectError, this, null);
|
|
202
|
+
} catch (selectError) {
|
|
203
|
+
_classPrivateFieldSet2(_selectError, this, selectError);
|
|
204
|
+
}
|
|
205
|
+
} else if (data === void 0) _classPrivateFieldSet2(_selectError, this, null);
|
|
206
|
+
if (_classPrivateFieldGet2(_selectError, this)) {
|
|
207
|
+
error = _classPrivateFieldGet2(_selectError, this);
|
|
208
|
+
data = _classPrivateFieldGet2(_selectResult, this);
|
|
209
|
+
errorUpdatedAt = Date.now();
|
|
210
|
+
status = "error";
|
|
211
|
+
isPlaceholderData = false;
|
|
212
|
+
}
|
|
213
|
+
const isFetching = newState.fetchStatus === "fetching";
|
|
214
|
+
const isPending = status === "pending";
|
|
215
|
+
const isError = status === "error";
|
|
216
|
+
const isLoading = isPending && isFetching;
|
|
217
|
+
const hasData = data !== void 0;
|
|
218
|
+
return {
|
|
219
|
+
status,
|
|
220
|
+
fetchStatus: newState.fetchStatus,
|
|
221
|
+
isPending,
|
|
222
|
+
isSuccess: status === "success",
|
|
223
|
+
isError,
|
|
224
|
+
isInitialLoading: isLoading,
|
|
225
|
+
isLoading,
|
|
226
|
+
data,
|
|
227
|
+
dataUpdatedAt: newState.dataUpdatedAt,
|
|
228
|
+
error,
|
|
229
|
+
errorUpdatedAt,
|
|
230
|
+
failureCount: newState.fetchFailureCount,
|
|
231
|
+
failureReason: newState.fetchFailureReason,
|
|
232
|
+
errorUpdateCount: newState.errorUpdateCount,
|
|
233
|
+
isFetched: query.isFetched(),
|
|
234
|
+
isFetchedAfterMount: newState.dataUpdateCount > queryInitialState.dataUpdateCount || newState.errorUpdateCount > queryInitialState.errorUpdateCount,
|
|
235
|
+
isFetching,
|
|
236
|
+
isRefetching: isFetching && !isPending,
|
|
237
|
+
isLoadingError: isError && !hasData,
|
|
238
|
+
isPaused: newState.fetchStatus === "paused",
|
|
239
|
+
isPlaceholderData,
|
|
240
|
+
isRefetchError: isError && hasData,
|
|
241
|
+
isStale: isStale(query, options),
|
|
242
|
+
refetch: this.refetch,
|
|
243
|
+
isEnabled: resolveQueryBoolean(options.enabled, query) !== false
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
updateResult() {
|
|
247
|
+
const prevResult = _classPrivateFieldGet2(_currentResult, this);
|
|
248
|
+
const nextResult = this.createResult(_classPrivateFieldGet2(_currentQuery, this), this.options);
|
|
249
|
+
_classPrivateFieldSet2(_currentResultState, this, _classPrivateFieldGet2(_currentQuery, this).state);
|
|
250
|
+
_classPrivateFieldSet2(_currentResultOptions, this, this.options);
|
|
251
|
+
if (_classPrivateFieldGet2(_currentResultState, this).data !== void 0) _classPrivateFieldSet2(_lastQueryWithDefinedData, this, _classPrivateFieldGet2(_currentQuery, this));
|
|
252
|
+
if (shallowEqualObjects(nextResult, prevResult)) return;
|
|
253
|
+
_classPrivateFieldSet2(_currentResult, this, nextResult);
|
|
254
|
+
const shouldNotifyListeners = () => {
|
|
255
|
+
if (!prevResult) return true;
|
|
256
|
+
const { notifyOnChangeProps } = this.options;
|
|
257
|
+
const notifyOnChangePropsValue = typeof notifyOnChangeProps === "function" ? notifyOnChangeProps() : notifyOnChangeProps;
|
|
258
|
+
if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !_classPrivateFieldGet2(_trackedProps, this).size) return true;
|
|
259
|
+
const includedProps = new Set(notifyOnChangePropsValue ?? _classPrivateFieldGet2(_trackedProps, this));
|
|
260
|
+
if (this.options.throwOnError) includedProps.add("error");
|
|
261
|
+
return Object.keys(_classPrivateFieldGet2(_currentResult, this)).some((key) => {
|
|
262
|
+
const typedKey = key;
|
|
263
|
+
return _classPrivateFieldGet2(_currentResult, this)[typedKey] !== prevResult[typedKey] && includedProps.has(typedKey);
|
|
264
|
+
});
|
|
265
|
+
};
|
|
266
|
+
_assertClassBrand(_QueryObserver_brand, this, _notify).call(this, { listeners: shouldNotifyListeners() });
|
|
267
|
+
}
|
|
268
|
+
onQueryUpdate() {
|
|
269
|
+
this.updateResult();
|
|
270
|
+
if (this.hasListeners()) _assertClassBrand(_QueryObserver_brand, this, _updateTimers).call(this);
|
|
271
|
+
}
|
|
469
272
|
};
|
|
273
|
+
function _executeFetch(fetchOptions) {
|
|
274
|
+
_assertClassBrand(_QueryObserver_brand, this, _updateQuery).call(this);
|
|
275
|
+
let promise = _classPrivateFieldGet2(_currentQuery, this).fetch(this.options, fetchOptions);
|
|
276
|
+
if (!(fetchOptions === null || fetchOptions === void 0 ? void 0 : fetchOptions.throwOnError)) promise = promise.catch(noop);
|
|
277
|
+
return promise;
|
|
278
|
+
}
|
|
279
|
+
function _updateStaleTimeout() {
|
|
280
|
+
_assertClassBrand(_QueryObserver_brand, this, _clearStaleTimeout).call(this);
|
|
281
|
+
const staleTime = resolveStaleTime(this.options.staleTime, _classPrivateFieldGet2(_currentQuery, this));
|
|
282
|
+
if (environmentManager.isServer() || _classPrivateFieldGet2(_currentResult, this).isStale || !isValidTimeout(staleTime)) return;
|
|
283
|
+
const timeout = timeUntilStale(_classPrivateFieldGet2(_currentResult, this).dataUpdatedAt, staleTime) + 1;
|
|
284
|
+
_classPrivateFieldSet2(_staleTimeoutId, this, timeoutManager.setTimeout(() => {
|
|
285
|
+
if (!_classPrivateFieldGet2(_currentResult, this).isStale) this.updateResult();
|
|
286
|
+
}, timeout));
|
|
287
|
+
}
|
|
288
|
+
function _computeRefetchInterval() {
|
|
289
|
+
return (typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(_classPrivateFieldGet2(_currentQuery, this)) : this.options.refetchInterval) ?? false;
|
|
290
|
+
}
|
|
291
|
+
function _updateRefetchInterval(nextInterval) {
|
|
292
|
+
_assertClassBrand(_QueryObserver_brand, this, _clearRefetchInterval).call(this);
|
|
293
|
+
_classPrivateFieldSet2(_currentRefetchInterval, this, nextInterval);
|
|
294
|
+
if (environmentManager.isServer() || resolveQueryBoolean(this.options.enabled, _classPrivateFieldGet2(_currentQuery, this)) === false || !isValidTimeout(_classPrivateFieldGet2(_currentRefetchInterval, this)) || _classPrivateFieldGet2(_currentRefetchInterval, this) === 0) return;
|
|
295
|
+
_classPrivateFieldSet2(_refetchIntervalId, this, timeoutManager.setInterval(() => {
|
|
296
|
+
if (this.options.refetchIntervalInBackground || focusManager.isFocused()) _assertClassBrand(_QueryObserver_brand, this, _executeFetch).call(this);
|
|
297
|
+
}, _classPrivateFieldGet2(_currentRefetchInterval, this)));
|
|
298
|
+
}
|
|
299
|
+
function _updateTimers() {
|
|
300
|
+
_assertClassBrand(_QueryObserver_brand, this, _updateStaleTimeout).call(this);
|
|
301
|
+
_assertClassBrand(_QueryObserver_brand, this, _updateRefetchInterval).call(this, _assertClassBrand(_QueryObserver_brand, this, _computeRefetchInterval).call(this));
|
|
302
|
+
}
|
|
303
|
+
function _clearStaleTimeout() {
|
|
304
|
+
if (_classPrivateFieldGet2(_staleTimeoutId, this) !== void 0) {
|
|
305
|
+
timeoutManager.clearTimeout(_classPrivateFieldGet2(_staleTimeoutId, this));
|
|
306
|
+
_classPrivateFieldSet2(_staleTimeoutId, this, void 0);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
function _clearRefetchInterval() {
|
|
310
|
+
if (_classPrivateFieldGet2(_refetchIntervalId, this) !== void 0) {
|
|
311
|
+
timeoutManager.clearInterval(_classPrivateFieldGet2(_refetchIntervalId, this));
|
|
312
|
+
_classPrivateFieldSet2(_refetchIntervalId, this, void 0);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
function _updateQuery() {
|
|
316
|
+
const query = _classPrivateFieldGet2(_client, this).getQueryCache().build(_classPrivateFieldGet2(_client, this), this.options);
|
|
317
|
+
if (query === _classPrivateFieldGet2(_currentQuery, this)) return;
|
|
318
|
+
const prevQuery = _classPrivateFieldGet2(_currentQuery, this);
|
|
319
|
+
_classPrivateFieldSet2(_currentQuery, this, query);
|
|
320
|
+
_classPrivateFieldSet2(_currentQueryInitialState, this, query.state);
|
|
321
|
+
if (this.hasListeners()) {
|
|
322
|
+
prevQuery === null || prevQuery === void 0 || prevQuery.removeObserver(this);
|
|
323
|
+
query.addObserver(this);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
function _notify(notifyOptions) {
|
|
327
|
+
notifyManager.batch(() => {
|
|
328
|
+
if (notifyOptions.listeners) this.listeners.forEach((listener) => {
|
|
329
|
+
listener(_classPrivateFieldGet2(_currentResult, this));
|
|
330
|
+
});
|
|
331
|
+
_classPrivateFieldGet2(_client, this).getQueryCache().notify({
|
|
332
|
+
query: _classPrivateFieldGet2(_currentQuery, this),
|
|
333
|
+
type: "observerResultsUpdated"
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
}
|
|
470
337
|
function shouldLoadOnMount(query, options) {
|
|
471
|
-
|
|
338
|
+
return resolveQueryBoolean(options.enabled, query) !== false && query.state.data === void 0 && !(query.state.status === "error" && resolveQueryBoolean(options.retryOnMount, query) === false);
|
|
472
339
|
}
|
|
473
340
|
function shouldFetchOnMount(query, options) {
|
|
474
|
-
|
|
341
|
+
return shouldLoadOnMount(query, options) || query.state.data !== void 0 && shouldFetchOn(query, options, options.refetchOnMount);
|
|
475
342
|
}
|
|
476
343
|
function shouldFetchOn(query, options, field) {
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
344
|
+
if (resolveQueryBoolean(options.enabled, query) !== false && resolveStaleTime(options.staleTime, query) !== "static") {
|
|
345
|
+
const value = typeof field === "function" ? field(query) : field;
|
|
346
|
+
return value === "always" || value !== false && isStale(query, options);
|
|
347
|
+
}
|
|
348
|
+
return false;
|
|
482
349
|
}
|
|
483
350
|
function shouldFetchOptionally(query, prevQuery, options, prevOptions) {
|
|
484
|
-
|
|
351
|
+
return (query !== prevQuery || resolveQueryBoolean(prevOptions.enabled, query) === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options);
|
|
485
352
|
}
|
|
486
353
|
function isStale(query, options) {
|
|
487
|
-
|
|
354
|
+
return resolveQueryBoolean(options.enabled, query) !== false && query.isStaleByTime(resolveStaleTime(options.staleTime, query));
|
|
488
355
|
}
|
|
489
356
|
function shouldAssignObserverCurrentProperties(observer, optimisticResult) {
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
}
|
|
493
|
-
return false;
|
|
357
|
+
if (!shallowEqualObjects(observer.getCurrentResult(), optimisticResult)) return true;
|
|
358
|
+
return false;
|
|
494
359
|
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
360
|
+
//#endregion
|
|
361
|
+
export { QueryObserver };
|
|
362
|
+
|
|
498
363
|
//# sourceMappingURL=queryObserver.js.map
|