@tanstack/query-core 5.101.3 → 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
package/build/legacy/query.cjs
CHANGED
|
@@ -1,499 +1,417 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
abortController.abort();
|
|
304
|
-
},
|
|
305
|
-
onFail: (failureCount, error) => {
|
|
306
|
-
__privateMethod(this, _Query_instances, dispatch_fn).call(this, { type: "failed", failureCount, error });
|
|
307
|
-
},
|
|
308
|
-
onPause: () => {
|
|
309
|
-
__privateMethod(this, _Query_instances, dispatch_fn).call(this, { type: "pause" });
|
|
310
|
-
},
|
|
311
|
-
onContinue: () => {
|
|
312
|
-
__privateMethod(this, _Query_instances, dispatch_fn).call(this, { type: "continue" });
|
|
313
|
-
},
|
|
314
|
-
retry: context.options.retry,
|
|
315
|
-
retryDelay: context.options.retryDelay,
|
|
316
|
-
networkMode: context.options.networkMode,
|
|
317
|
-
canRun: () => true
|
|
318
|
-
}));
|
|
319
|
-
try {
|
|
320
|
-
const data = await __privateGet(this, _retryer).start();
|
|
321
|
-
if (data === void 0) {
|
|
322
|
-
if (process.env.NODE_ENV !== "production") {
|
|
323
|
-
console.error(
|
|
324
|
-
`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`
|
|
325
|
-
);
|
|
326
|
-
}
|
|
327
|
-
throw new Error(`${this.queryHash} data is undefined`);
|
|
328
|
-
}
|
|
329
|
-
this.setData(data);
|
|
330
|
-
(_e = (_d = __privateGet(this, _cache).config).onSuccess) == null ? void 0 : _e.call(_d, data, this);
|
|
331
|
-
(_g = (_f = __privateGet(this, _cache).config).onSettled) == null ? void 0 : _g.call(
|
|
332
|
-
_f,
|
|
333
|
-
data,
|
|
334
|
-
this.state.error,
|
|
335
|
-
this
|
|
336
|
-
);
|
|
337
|
-
return data;
|
|
338
|
-
} catch (error) {
|
|
339
|
-
if (error instanceof import_retryer.CancelledError) {
|
|
340
|
-
if (error.silent) {
|
|
341
|
-
return __privateGet(this, _retryer).promise;
|
|
342
|
-
} else if (error.revert) {
|
|
343
|
-
if (this.state.data === void 0) {
|
|
344
|
-
throw error;
|
|
345
|
-
}
|
|
346
|
-
return this.state.data;
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
__privateMethod(this, _Query_instances, dispatch_fn).call(this, {
|
|
350
|
-
type: "error",
|
|
351
|
-
error
|
|
352
|
-
});
|
|
353
|
-
(_i = (_h = __privateGet(this, _cache).config).onError) == null ? void 0 : _i.call(
|
|
354
|
-
_h,
|
|
355
|
-
error,
|
|
356
|
-
this
|
|
357
|
-
);
|
|
358
|
-
(_k = (_j = __privateGet(this, _cache).config).onSettled) == null ? void 0 : _k.call(
|
|
359
|
-
_j,
|
|
360
|
-
this.state.data,
|
|
361
|
-
error,
|
|
362
|
-
this
|
|
363
|
-
);
|
|
364
|
-
throw error;
|
|
365
|
-
} finally {
|
|
366
|
-
this.scheduleGc();
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
};
|
|
370
|
-
_queryType = new WeakMap();
|
|
371
|
-
_initialState = new WeakMap();
|
|
372
|
-
_revertState = new WeakMap();
|
|
373
|
-
_cache = new WeakMap();
|
|
374
|
-
_client = new WeakMap();
|
|
375
|
-
_retryer = new WeakMap();
|
|
376
|
-
_defaultOptions = new WeakMap();
|
|
377
|
-
_abortSignalConsumed = new WeakMap();
|
|
378
|
-
_Query_instances = new WeakSet();
|
|
379
|
-
isInitialPausedFetch_fn = function() {
|
|
380
|
-
return this.state.fetchStatus === "paused" && this.state.status === "pending";
|
|
381
|
-
};
|
|
382
|
-
dispatch_fn = function(action) {
|
|
383
|
-
const reducer = (state) => {
|
|
384
|
-
switch (action.type) {
|
|
385
|
-
case "failed":
|
|
386
|
-
return {
|
|
387
|
-
...state,
|
|
388
|
-
fetchFailureCount: action.failureCount,
|
|
389
|
-
fetchFailureReason: action.error
|
|
390
|
-
};
|
|
391
|
-
case "pause":
|
|
392
|
-
return {
|
|
393
|
-
...state,
|
|
394
|
-
fetchStatus: "paused"
|
|
395
|
-
};
|
|
396
|
-
case "continue":
|
|
397
|
-
return {
|
|
398
|
-
...state,
|
|
399
|
-
fetchStatus: "fetching"
|
|
400
|
-
};
|
|
401
|
-
case "fetch":
|
|
402
|
-
return {
|
|
403
|
-
...state,
|
|
404
|
-
...fetchState(state.data, this.options),
|
|
405
|
-
fetchMeta: action.meta ?? null
|
|
406
|
-
};
|
|
407
|
-
case "success":
|
|
408
|
-
const newState = {
|
|
409
|
-
...state,
|
|
410
|
-
...successState(action.data, action.dataUpdatedAt),
|
|
411
|
-
dataUpdateCount: state.dataUpdateCount + 1,
|
|
412
|
-
...!action.manual && {
|
|
413
|
-
fetchStatus: "idle",
|
|
414
|
-
fetchFailureCount: 0,
|
|
415
|
-
fetchFailureReason: null
|
|
416
|
-
}
|
|
417
|
-
};
|
|
418
|
-
__privateSet(this, _revertState, action.manual ? newState : void 0);
|
|
419
|
-
return newState;
|
|
420
|
-
case "error":
|
|
421
|
-
const error = action.error;
|
|
422
|
-
return {
|
|
423
|
-
...state,
|
|
424
|
-
error,
|
|
425
|
-
errorUpdateCount: state.errorUpdateCount + 1,
|
|
426
|
-
errorUpdatedAt: Date.now(),
|
|
427
|
-
fetchFailureCount: state.fetchFailureCount + 1,
|
|
428
|
-
fetchFailureReason: error,
|
|
429
|
-
fetchStatus: "idle",
|
|
430
|
-
status: "error",
|
|
431
|
-
// flag existing data as invalidated if we get a background error
|
|
432
|
-
// note that "no data" always means stale so we can set unconditionally here
|
|
433
|
-
isInvalidated: true
|
|
434
|
-
};
|
|
435
|
-
case "invalidate":
|
|
436
|
-
return {
|
|
437
|
-
...state,
|
|
438
|
-
isInvalidated: true
|
|
439
|
-
};
|
|
440
|
-
case "setState":
|
|
441
|
-
return {
|
|
442
|
-
...state,
|
|
443
|
-
...action.state
|
|
444
|
-
};
|
|
445
|
-
}
|
|
446
|
-
};
|
|
447
|
-
this.state = reducer(this.state);
|
|
448
|
-
import_notifyManager.notifyManager.batch(() => {
|
|
449
|
-
this.observers.forEach((observer) => {
|
|
450
|
-
observer.onQueryUpdate();
|
|
451
|
-
});
|
|
452
|
-
__privateGet(this, _cache).notify({ query: this, type: "updated", action });
|
|
453
|
-
});
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_classPrivateFieldSet2 = require("./classPrivateFieldSet2-Bo0ZyOIv.cjs");
|
|
3
|
+
const require_utils = require("./utils.cjs");
|
|
4
|
+
const require_notifyManager = require("./notifyManager.cjs");
|
|
5
|
+
const require_retryer = require("./retryer.cjs");
|
|
6
|
+
const require_removable = require("./removable.cjs");
|
|
7
|
+
const require_infiniteQueryBehavior = require("./infiniteQueryBehavior.cjs");
|
|
8
|
+
const require_classPrivateMethodInitSpec = require("./classPrivateMethodInitSpec-DVhcLejn.cjs");
|
|
9
|
+
//#region src/query.ts
|
|
10
|
+
var _queryType = /* @__PURE__ */ new WeakMap();
|
|
11
|
+
var _initialState = /* @__PURE__ */ new WeakMap();
|
|
12
|
+
var _revertState = /* @__PURE__ */ new WeakMap();
|
|
13
|
+
var _cache = /* @__PURE__ */ new WeakMap();
|
|
14
|
+
var _client = /* @__PURE__ */ new WeakMap();
|
|
15
|
+
var _retryer = /* @__PURE__ */ new WeakMap();
|
|
16
|
+
var _defaultOptions = /* @__PURE__ */ new WeakMap();
|
|
17
|
+
var _abortSignalConsumed = /* @__PURE__ */ new WeakMap();
|
|
18
|
+
var _Query_brand = /* @__PURE__ */ new WeakSet();
|
|
19
|
+
var Query = class extends require_removable.Removable {
|
|
20
|
+
constructor(config) {
|
|
21
|
+
super();
|
|
22
|
+
require_classPrivateMethodInitSpec._classPrivateMethodInitSpec(this, _Query_brand);
|
|
23
|
+
require_classPrivateFieldSet2._classPrivateFieldInitSpec(this, _queryType, void 0);
|
|
24
|
+
require_classPrivateFieldSet2._classPrivateFieldInitSpec(this, _initialState, void 0);
|
|
25
|
+
require_classPrivateFieldSet2._classPrivateFieldInitSpec(this, _revertState, void 0);
|
|
26
|
+
require_classPrivateFieldSet2._classPrivateFieldInitSpec(this, _cache, void 0);
|
|
27
|
+
require_classPrivateFieldSet2._classPrivateFieldInitSpec(this, _client, void 0);
|
|
28
|
+
require_classPrivateFieldSet2._classPrivateFieldInitSpec(this, _retryer, void 0);
|
|
29
|
+
require_classPrivateFieldSet2._classPrivateFieldInitSpec(this, _defaultOptions, void 0);
|
|
30
|
+
require_classPrivateFieldSet2._classPrivateFieldInitSpec(this, _abortSignalConsumed, void 0);
|
|
31
|
+
require_classPrivateFieldSet2._classPrivateFieldSet2(_abortSignalConsumed, this, false);
|
|
32
|
+
require_classPrivateFieldSet2._classPrivateFieldSet2(_defaultOptions, this, config.defaultOptions);
|
|
33
|
+
this.setOptions(config.options);
|
|
34
|
+
this.observers = [];
|
|
35
|
+
require_classPrivateFieldSet2._classPrivateFieldSet2(_client, this, config.client);
|
|
36
|
+
require_classPrivateFieldSet2._classPrivateFieldSet2(_cache, this, require_classPrivateFieldSet2._classPrivateFieldGet2(_client, this).getQueryCache());
|
|
37
|
+
this.queryKey = config.queryKey;
|
|
38
|
+
this.queryHash = config.queryHash;
|
|
39
|
+
require_classPrivateFieldSet2._classPrivateFieldSet2(_initialState, this, getDefaultState(this.options));
|
|
40
|
+
this.state = config.state ?? require_classPrivateFieldSet2._classPrivateFieldGet2(_initialState, this);
|
|
41
|
+
this.scheduleGc();
|
|
42
|
+
}
|
|
43
|
+
get meta() {
|
|
44
|
+
return this.options.meta;
|
|
45
|
+
}
|
|
46
|
+
get queryType() {
|
|
47
|
+
return require_classPrivateFieldSet2._classPrivateFieldGet2(_queryType, this);
|
|
48
|
+
}
|
|
49
|
+
get promise() {
|
|
50
|
+
var _classPrivateFieldGet2$1;
|
|
51
|
+
return (_classPrivateFieldGet2$1 = require_classPrivateFieldSet2._classPrivateFieldGet2(_retryer, this)) === null || _classPrivateFieldGet2$1 === void 0 ? void 0 : _classPrivateFieldGet2$1.promise;
|
|
52
|
+
}
|
|
53
|
+
setOptions(options) {
|
|
54
|
+
this.options = {
|
|
55
|
+
...require_classPrivateFieldSet2._classPrivateFieldGet2(_defaultOptions, this),
|
|
56
|
+
...options
|
|
57
|
+
};
|
|
58
|
+
if (options === null || options === void 0 ? void 0 : options._type) require_classPrivateFieldSet2._classPrivateFieldSet2(_queryType, this, options._type);
|
|
59
|
+
this.updateGcTime(this.options.gcTime);
|
|
60
|
+
if (this.state && this.state.data === void 0) {
|
|
61
|
+
const defaultState = getDefaultState(this.options);
|
|
62
|
+
if (defaultState.data !== void 0) {
|
|
63
|
+
this.setState(successState(defaultState.data, defaultState.dataUpdatedAt));
|
|
64
|
+
require_classPrivateFieldSet2._classPrivateFieldSet2(_initialState, this, defaultState);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
optionalRemove() {
|
|
69
|
+
if (!this.observers.length && this.state.fetchStatus === "idle") require_classPrivateFieldSet2._classPrivateFieldGet2(_cache, this).remove(this);
|
|
70
|
+
}
|
|
71
|
+
setData(newData, options) {
|
|
72
|
+
const data = require_utils.replaceData(this.state.data, newData, this.options);
|
|
73
|
+
require_classPrivateFieldSet2._assertClassBrand(_Query_brand, this, _dispatch).call(this, {
|
|
74
|
+
data,
|
|
75
|
+
type: "success",
|
|
76
|
+
dataUpdatedAt: options === null || options === void 0 ? void 0 : options.updatedAt,
|
|
77
|
+
manual: options === null || options === void 0 ? void 0 : options.manual
|
|
78
|
+
});
|
|
79
|
+
return data;
|
|
80
|
+
}
|
|
81
|
+
setState(state) {
|
|
82
|
+
require_classPrivateFieldSet2._assertClassBrand(_Query_brand, this, _dispatch).call(this, {
|
|
83
|
+
type: "setState",
|
|
84
|
+
state
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
cancel(options) {
|
|
88
|
+
var _classPrivateFieldGet3, _classPrivateFieldGet4;
|
|
89
|
+
const promise = (_classPrivateFieldGet3 = require_classPrivateFieldSet2._classPrivateFieldGet2(_retryer, this)) === null || _classPrivateFieldGet3 === void 0 ? void 0 : _classPrivateFieldGet3.promise;
|
|
90
|
+
(_classPrivateFieldGet4 = require_classPrivateFieldSet2._classPrivateFieldGet2(_retryer, this)) === null || _classPrivateFieldGet4 === void 0 || _classPrivateFieldGet4.cancel(options);
|
|
91
|
+
return promise ? promise.then(require_utils.noop).catch(require_utils.noop) : Promise.resolve();
|
|
92
|
+
}
|
|
93
|
+
destroy() {
|
|
94
|
+
super.destroy();
|
|
95
|
+
this.cancel({ silent: true });
|
|
96
|
+
}
|
|
97
|
+
get resetState() {
|
|
98
|
+
return require_classPrivateFieldSet2._classPrivateFieldGet2(_initialState, this);
|
|
99
|
+
}
|
|
100
|
+
reset() {
|
|
101
|
+
this.destroy();
|
|
102
|
+
this.setState(this.resetState);
|
|
103
|
+
}
|
|
104
|
+
isActive() {
|
|
105
|
+
return this.observers.some((observer) => require_utils.resolveQueryBoolean(observer.options.enabled, this) !== false);
|
|
106
|
+
}
|
|
107
|
+
isDisabled() {
|
|
108
|
+
if (this.getObserversCount() > 0) return !this.isActive();
|
|
109
|
+
return this.options.queryFn === require_utils.skipToken || !this.isFetched();
|
|
110
|
+
}
|
|
111
|
+
isFetched() {
|
|
112
|
+
return this.state.dataUpdateCount + this.state.errorUpdateCount > 0;
|
|
113
|
+
}
|
|
114
|
+
isStatic() {
|
|
115
|
+
if (this.getObserversCount() > 0) return this.observers.some((observer) => require_utils.resolveStaleTime(observer.options.staleTime, this) === "static");
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
isStale() {
|
|
119
|
+
if (this.getObserversCount() > 0) return this.observers.some((observer) => observer.getCurrentResult().isStale);
|
|
120
|
+
return this.state.data === void 0 || this.state.isInvalidated;
|
|
121
|
+
}
|
|
122
|
+
isStaleByTime(staleTime = 0) {
|
|
123
|
+
if (this.state.data === void 0) return true;
|
|
124
|
+
if (staleTime === "static") return false;
|
|
125
|
+
if (this.state.isInvalidated) return true;
|
|
126
|
+
return !require_utils.timeUntilStale(this.state.dataUpdatedAt, staleTime);
|
|
127
|
+
}
|
|
128
|
+
onFocus() {
|
|
129
|
+
var _classPrivateFieldGet5;
|
|
130
|
+
const observer = this.observers.find((x) => x.shouldFetchOnWindowFocus());
|
|
131
|
+
observer === null || observer === void 0 || observer.refetch({ cancelRefetch: false });
|
|
132
|
+
(_classPrivateFieldGet5 = require_classPrivateFieldSet2._classPrivateFieldGet2(_retryer, this)) === null || _classPrivateFieldGet5 === void 0 || _classPrivateFieldGet5.continue();
|
|
133
|
+
}
|
|
134
|
+
onOnline() {
|
|
135
|
+
var _classPrivateFieldGet6;
|
|
136
|
+
const observer = this.observers.find((x) => x.shouldFetchOnReconnect());
|
|
137
|
+
observer === null || observer === void 0 || observer.refetch({ cancelRefetch: false });
|
|
138
|
+
(_classPrivateFieldGet6 = require_classPrivateFieldSet2._classPrivateFieldGet2(_retryer, this)) === null || _classPrivateFieldGet6 === void 0 || _classPrivateFieldGet6.continue();
|
|
139
|
+
}
|
|
140
|
+
addObserver(observer) {
|
|
141
|
+
if (!this.observers.includes(observer)) {
|
|
142
|
+
this.observers.push(observer);
|
|
143
|
+
this.clearGcTimeout();
|
|
144
|
+
require_classPrivateFieldSet2._classPrivateFieldGet2(_cache, this).notify({
|
|
145
|
+
type: "observerAdded",
|
|
146
|
+
query: this,
|
|
147
|
+
observer
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
removeObserver(observer) {
|
|
152
|
+
const index = this.observers.indexOf(observer);
|
|
153
|
+
if (index !== -1) {
|
|
154
|
+
this.observers.splice(index, 1);
|
|
155
|
+
if (!this.observers.length) {
|
|
156
|
+
if (require_classPrivateFieldSet2._classPrivateFieldGet2(_retryer, this)) {
|
|
157
|
+
if (require_classPrivateFieldSet2._classPrivateFieldGet2(_abortSignalConsumed, this) || require_classPrivateFieldSet2._assertClassBrand(_Query_brand, this, _isInitialPausedFetch).call(this)) require_classPrivateFieldSet2._classPrivateFieldGet2(_retryer, this).cancel({ revert: true });
|
|
158
|
+
else require_classPrivateFieldSet2._classPrivateFieldGet2(_retryer, this).cancelRetry();
|
|
159
|
+
}
|
|
160
|
+
this.scheduleGc();
|
|
161
|
+
}
|
|
162
|
+
require_classPrivateFieldSet2._classPrivateFieldGet2(_cache, this).notify({
|
|
163
|
+
type: "observerRemoved",
|
|
164
|
+
query: this,
|
|
165
|
+
observer
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
getObserversCount() {
|
|
170
|
+
return this.observers.length;
|
|
171
|
+
}
|
|
172
|
+
invalidate() {
|
|
173
|
+
if (!this.state.isInvalidated) require_classPrivateFieldSet2._assertClassBrand(_Query_brand, this, _dispatch).call(this, { type: "invalidate" });
|
|
174
|
+
}
|
|
175
|
+
async fetch(options, fetchOptions) {
|
|
176
|
+
var _classPrivateFieldGet7, _context$fetchOptions;
|
|
177
|
+
if (this.state.fetchStatus !== "idle" && ((_classPrivateFieldGet7 = require_classPrivateFieldSet2._classPrivateFieldGet2(_retryer, this)) === null || _classPrivateFieldGet7 === void 0 ? void 0 : _classPrivateFieldGet7.status()) !== "rejected") {
|
|
178
|
+
if (this.state.data !== void 0 && (fetchOptions === null || fetchOptions === void 0 ? void 0 : fetchOptions.cancelRefetch)) this.cancel({ silent: true });
|
|
179
|
+
else if (require_classPrivateFieldSet2._classPrivateFieldGet2(_retryer, this)) {
|
|
180
|
+
require_classPrivateFieldSet2._classPrivateFieldGet2(_retryer, this).continueRetry();
|
|
181
|
+
return require_classPrivateFieldSet2._classPrivateFieldGet2(_retryer, this).promise;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (options) this.setOptions(options);
|
|
185
|
+
if (!this.options.queryFn) {
|
|
186
|
+
const observer = this.observers.find((x) => x.options.queryFn);
|
|
187
|
+
if (observer) this.setOptions(observer.options);
|
|
188
|
+
}
|
|
189
|
+
if (process.env.NODE_ENV !== "production") {
|
|
190
|
+
if (!Array.isArray(this.options.queryKey)) console.error(`As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']`);
|
|
191
|
+
}
|
|
192
|
+
const abortController = new AbortController();
|
|
193
|
+
const addSignalProperty = (object) => {
|
|
194
|
+
Object.defineProperty(object, "signal", {
|
|
195
|
+
enumerable: true,
|
|
196
|
+
get: () => {
|
|
197
|
+
require_classPrivateFieldSet2._classPrivateFieldSet2(_abortSignalConsumed, this, true);
|
|
198
|
+
return abortController.signal;
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
const fetchFn = () => {
|
|
203
|
+
const queryFn = require_utils.ensureQueryFn(this.options, fetchOptions);
|
|
204
|
+
const createQueryFnContext = () => {
|
|
205
|
+
const queryFnContext = {
|
|
206
|
+
client: require_classPrivateFieldSet2._classPrivateFieldGet2(_client, this),
|
|
207
|
+
queryKey: this.queryKey,
|
|
208
|
+
meta: this.meta
|
|
209
|
+
};
|
|
210
|
+
addSignalProperty(queryFnContext);
|
|
211
|
+
return queryFnContext;
|
|
212
|
+
};
|
|
213
|
+
const queryFnContext = createQueryFnContext();
|
|
214
|
+
require_classPrivateFieldSet2._classPrivateFieldSet2(_abortSignalConsumed, this, false);
|
|
215
|
+
if (this.options.persister) return this.options.persister(queryFn, queryFnContext, this);
|
|
216
|
+
return queryFn(queryFnContext);
|
|
217
|
+
};
|
|
218
|
+
const createFetchContext = () => {
|
|
219
|
+
const context = {
|
|
220
|
+
fetchOptions,
|
|
221
|
+
options: this.options,
|
|
222
|
+
queryKey: this.queryKey,
|
|
223
|
+
client: require_classPrivateFieldSet2._classPrivateFieldGet2(_client, this),
|
|
224
|
+
state: this.state,
|
|
225
|
+
fetchFn
|
|
226
|
+
};
|
|
227
|
+
addSignalProperty(context);
|
|
228
|
+
return context;
|
|
229
|
+
};
|
|
230
|
+
const context = createFetchContext();
|
|
231
|
+
const behavior = require_classPrivateFieldSet2._classPrivateFieldGet2(_queryType, this) === "infinite" ? require_infiniteQueryBehavior.infiniteQueryBehavior(this.options.pages) : this.options.behavior;
|
|
232
|
+
behavior === null || behavior === void 0 || behavior.onFetch(context, this);
|
|
233
|
+
require_classPrivateFieldSet2._classPrivateFieldSet2(_revertState, this, this.state);
|
|
234
|
+
if (this.state.fetchStatus === "idle" || this.state.fetchMeta !== ((_context$fetchOptions = context.fetchOptions) === null || _context$fetchOptions === void 0 ? void 0 : _context$fetchOptions.meta)) {
|
|
235
|
+
var _context$fetchOptions2;
|
|
236
|
+
require_classPrivateFieldSet2._assertClassBrand(_Query_brand, this, _dispatch).call(this, {
|
|
237
|
+
type: "fetch",
|
|
238
|
+
meta: (_context$fetchOptions2 = context.fetchOptions) === null || _context$fetchOptions2 === void 0 ? void 0 : _context$fetchOptions2.meta
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
const retryer = require_classPrivateFieldSet2._classPrivateFieldSet2(_retryer, this, require_retryer.createRetryer({
|
|
242
|
+
initialPromise: fetchOptions === null || fetchOptions === void 0 ? void 0 : fetchOptions.initialPromise,
|
|
243
|
+
fn: context.fetchFn,
|
|
244
|
+
onCancel: (error) => {
|
|
245
|
+
if (error instanceof require_retryer.CancelledError && error.revert) this.setState({
|
|
246
|
+
...require_classPrivateFieldSet2._classPrivateFieldGet2(_revertState, this),
|
|
247
|
+
fetchStatus: "idle"
|
|
248
|
+
});
|
|
249
|
+
abortController.abort();
|
|
250
|
+
},
|
|
251
|
+
onFail: (failureCount, error) => {
|
|
252
|
+
require_classPrivateFieldSet2._assertClassBrand(_Query_brand, this, _dispatch).call(this, {
|
|
253
|
+
type: "failed",
|
|
254
|
+
failureCount,
|
|
255
|
+
error
|
|
256
|
+
});
|
|
257
|
+
},
|
|
258
|
+
onPause: () => {
|
|
259
|
+
require_classPrivateFieldSet2._assertClassBrand(_Query_brand, this, _dispatch).call(this, { type: "pause" });
|
|
260
|
+
},
|
|
261
|
+
onContinue: () => {
|
|
262
|
+
require_classPrivateFieldSet2._assertClassBrand(_Query_brand, this, _dispatch).call(this, { type: "continue" });
|
|
263
|
+
},
|
|
264
|
+
retry: context.options.retry,
|
|
265
|
+
retryDelay: context.options.retryDelay,
|
|
266
|
+
networkMode: context.options.networkMode,
|
|
267
|
+
canRun: () => true
|
|
268
|
+
}));
|
|
269
|
+
try {
|
|
270
|
+
var _classPrivateFieldGet8, _classPrivateFieldGet9, _classPrivateFieldGet10, _classPrivateFieldGet11;
|
|
271
|
+
const data = await retryer.start();
|
|
272
|
+
if (data === void 0) {
|
|
273
|
+
if (process.env.NODE_ENV !== "production") console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`);
|
|
274
|
+
throw new Error(`${this.queryHash} data is undefined`);
|
|
275
|
+
}
|
|
276
|
+
this.setData(data);
|
|
277
|
+
(_classPrivateFieldGet8 = (_classPrivateFieldGet9 = require_classPrivateFieldSet2._classPrivateFieldGet2(_cache, this).config).onSuccess) === null || _classPrivateFieldGet8 === void 0 || _classPrivateFieldGet8.call(_classPrivateFieldGet9, data, this);
|
|
278
|
+
(_classPrivateFieldGet10 = (_classPrivateFieldGet11 = require_classPrivateFieldSet2._classPrivateFieldGet2(_cache, this).config).onSettled) === null || _classPrivateFieldGet10 === void 0 || _classPrivateFieldGet10.call(_classPrivateFieldGet11, data, this.state.error, this);
|
|
279
|
+
return data;
|
|
280
|
+
} catch (error) {
|
|
281
|
+
var _classPrivateFieldGet12, _classPrivateFieldGet13, _classPrivateFieldGet14, _classPrivateFieldGet15;
|
|
282
|
+
if (error instanceof require_retryer.CancelledError) {
|
|
283
|
+
if (error.silent) return require_classPrivateFieldSet2._classPrivateFieldGet2(_retryer, this).promise;
|
|
284
|
+
else if (error.revert) {
|
|
285
|
+
if (this.state.data === void 0) throw error;
|
|
286
|
+
return this.state.data;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
require_classPrivateFieldSet2._assertClassBrand(_Query_brand, this, _dispatch).call(this, {
|
|
290
|
+
type: "error",
|
|
291
|
+
error
|
|
292
|
+
});
|
|
293
|
+
(_classPrivateFieldGet12 = (_classPrivateFieldGet13 = require_classPrivateFieldSet2._classPrivateFieldGet2(_cache, this).config).onError) === null || _classPrivateFieldGet12 === void 0 || _classPrivateFieldGet12.call(_classPrivateFieldGet13, error, this);
|
|
294
|
+
(_classPrivateFieldGet14 = (_classPrivateFieldGet15 = require_classPrivateFieldSet2._classPrivateFieldGet2(_cache, this).config).onSettled) === null || _classPrivateFieldGet14 === void 0 || _classPrivateFieldGet14.call(_classPrivateFieldGet15, this.state.data, error, this);
|
|
295
|
+
throw error;
|
|
296
|
+
} finally {
|
|
297
|
+
if (require_classPrivateFieldSet2._classPrivateFieldGet2(_retryer, this) === retryer) require_classPrivateFieldSet2._classPrivateFieldSet2(_retryer, this, void 0);
|
|
298
|
+
this.scheduleGc();
|
|
299
|
+
}
|
|
300
|
+
}
|
|
454
301
|
};
|
|
302
|
+
function _isInitialPausedFetch() {
|
|
303
|
+
return this.state.fetchStatus === "paused" && this.state.status === "pending";
|
|
304
|
+
}
|
|
305
|
+
function _dispatch(action) {
|
|
306
|
+
const reducer = (state) => {
|
|
307
|
+
switch (action.type) {
|
|
308
|
+
case "failed": return {
|
|
309
|
+
...state,
|
|
310
|
+
fetchFailureCount: action.failureCount,
|
|
311
|
+
fetchFailureReason: action.error
|
|
312
|
+
};
|
|
313
|
+
case "pause": return {
|
|
314
|
+
...state,
|
|
315
|
+
fetchStatus: "paused"
|
|
316
|
+
};
|
|
317
|
+
case "continue": return {
|
|
318
|
+
...state,
|
|
319
|
+
fetchStatus: "fetching"
|
|
320
|
+
};
|
|
321
|
+
case "fetch": return {
|
|
322
|
+
...state,
|
|
323
|
+
...fetchState(state.data, this.options),
|
|
324
|
+
fetchMeta: action.meta ?? null
|
|
325
|
+
};
|
|
326
|
+
case "success":
|
|
327
|
+
const newState = {
|
|
328
|
+
...state,
|
|
329
|
+
...successState(action.data, action.dataUpdatedAt),
|
|
330
|
+
dataUpdateCount: state.dataUpdateCount + 1,
|
|
331
|
+
...!action.manual && {
|
|
332
|
+
fetchStatus: "idle",
|
|
333
|
+
fetchFailureCount: 0,
|
|
334
|
+
fetchFailureReason: null
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
require_classPrivateFieldSet2._classPrivateFieldSet2(_revertState, this, action.manual ? newState : void 0);
|
|
338
|
+
return newState;
|
|
339
|
+
case "error":
|
|
340
|
+
const error = action.error;
|
|
341
|
+
return {
|
|
342
|
+
...state,
|
|
343
|
+
error,
|
|
344
|
+
errorUpdateCount: state.errorUpdateCount + 1,
|
|
345
|
+
errorUpdatedAt: Date.now(),
|
|
346
|
+
fetchFailureCount: state.fetchFailureCount + 1,
|
|
347
|
+
fetchFailureReason: error,
|
|
348
|
+
fetchStatus: "idle",
|
|
349
|
+
status: "error",
|
|
350
|
+
isInvalidated: true
|
|
351
|
+
};
|
|
352
|
+
case "invalidate": return {
|
|
353
|
+
...state,
|
|
354
|
+
isInvalidated: true
|
|
355
|
+
};
|
|
356
|
+
case "setState": return {
|
|
357
|
+
...state,
|
|
358
|
+
...action.state
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
this.state = reducer(this.state);
|
|
363
|
+
require_notifyManager.notifyManager.batch(() => {
|
|
364
|
+
this.observers.slice().forEach((observer) => {
|
|
365
|
+
observer.onQueryUpdate();
|
|
366
|
+
});
|
|
367
|
+
require_classPrivateFieldSet2._classPrivateFieldGet2(_cache, this).notify({
|
|
368
|
+
query: this,
|
|
369
|
+
type: "updated",
|
|
370
|
+
action
|
|
371
|
+
});
|
|
372
|
+
});
|
|
373
|
+
}
|
|
455
374
|
function fetchState(data, options) {
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
375
|
+
return {
|
|
376
|
+
fetchFailureCount: 0,
|
|
377
|
+
fetchFailureReason: null,
|
|
378
|
+
fetchStatus: require_retryer.canFetch(options.networkMode) ? "fetching" : "paused",
|
|
379
|
+
...data === void 0 && {
|
|
380
|
+
error: null,
|
|
381
|
+
status: "pending"
|
|
382
|
+
}
|
|
383
|
+
};
|
|
465
384
|
}
|
|
466
385
|
function successState(data, dataUpdatedAt) {
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
386
|
+
return {
|
|
387
|
+
data,
|
|
388
|
+
dataUpdatedAt: dataUpdatedAt ?? Date.now(),
|
|
389
|
+
error: null,
|
|
390
|
+
isInvalidated: false,
|
|
391
|
+
status: "success"
|
|
392
|
+
};
|
|
474
393
|
}
|
|
475
394
|
function getDefaultState(options) {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
395
|
+
const data = typeof options.initialData === "function" ? options.initialData() : options.initialData;
|
|
396
|
+
const hasData = data !== void 0;
|
|
397
|
+
const initialDataUpdatedAt = hasData ? typeof options.initialDataUpdatedAt === "function" ? options.initialDataUpdatedAt() : options.initialDataUpdatedAt : 0;
|
|
398
|
+
return {
|
|
399
|
+
data,
|
|
400
|
+
dataUpdateCount: 0,
|
|
401
|
+
dataUpdatedAt: hasData ? initialDataUpdatedAt ?? Date.now() : 0,
|
|
402
|
+
error: null,
|
|
403
|
+
errorUpdateCount: 0,
|
|
404
|
+
errorUpdatedAt: 0,
|
|
405
|
+
fetchFailureCount: 0,
|
|
406
|
+
fetchFailureReason: null,
|
|
407
|
+
fetchMeta: null,
|
|
408
|
+
isInvalidated: false,
|
|
409
|
+
status: hasData ? "success" : "pending",
|
|
410
|
+
fetchStatus: "idle"
|
|
411
|
+
};
|
|
493
412
|
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
});
|
|
413
|
+
//#endregion
|
|
414
|
+
exports.Query = Query;
|
|
415
|
+
exports.fetchState = fetchState;
|
|
416
|
+
|
|
499
417
|
//# sourceMappingURL=query.cjs.map
|