@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,164 +1,136 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__privateAdd,
|
|
3
|
-
__privateGet,
|
|
4
|
-
__privateMethod,
|
|
5
|
-
__privateSet
|
|
6
|
-
} from "./chunk-PXG64RU4.js";
|
|
7
|
-
|
|
8
|
-
// src/mutationObserver.ts
|
|
9
|
-
import { getDefaultState } from "./mutation.js";
|
|
10
|
-
import { notifyManager } from "./notifyManager.js";
|
|
11
|
-
import { Subscribable } from "./subscribable.js";
|
|
1
|
+
import { i as _classPrivateFieldInitSpec, n as _classPrivateFieldGet2, r as _assertClassBrand, t as _classPrivateFieldSet2 } from "./classPrivateFieldSet2-CV7wyte-.js";
|
|
12
2
|
import { hashKey, shallowEqualObjects } from "./utils.js";
|
|
13
|
-
|
|
3
|
+
import { Subscribable } from "./subscribable.js";
|
|
4
|
+
import { notifyManager } from "./notifyManager.js";
|
|
5
|
+
import { t as _classPrivateMethodInitSpec } from "./classPrivateMethodInitSpec-CBwa_Y7C.js";
|
|
6
|
+
import { getDefaultState } from "./mutation.js";
|
|
7
|
+
//#region src/mutationObserver.ts
|
|
8
|
+
var _client = /* @__PURE__ */ new WeakMap();
|
|
9
|
+
var _currentResult = /* @__PURE__ */ new WeakMap();
|
|
10
|
+
var _currentMutation = /* @__PURE__ */ new WeakMap();
|
|
11
|
+
var _mutateOptions = /* @__PURE__ */ new WeakMap();
|
|
12
|
+
var _MutationObserver_brand = /* @__PURE__ */ new WeakSet();
|
|
14
13
|
var MutationObserver = class extends Subscribable {
|
|
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
|
-
_client = new WeakMap();
|
|
78
|
-
_currentResult = new WeakMap();
|
|
79
|
-
_currentMutation = new WeakMap();
|
|
80
|
-
_mutateOptions = new WeakMap();
|
|
81
|
-
_MutationObserver_instances = new WeakSet();
|
|
82
|
-
updateResult_fn = function() {
|
|
83
|
-
var _a;
|
|
84
|
-
const state = ((_a = __privateGet(this, _currentMutation)) == null ? void 0 : _a.state) ?? getDefaultState();
|
|
85
|
-
__privateSet(this, _currentResult, {
|
|
86
|
-
...state,
|
|
87
|
-
isPending: state.status === "pending",
|
|
88
|
-
isSuccess: state.status === "success",
|
|
89
|
-
isError: state.status === "error",
|
|
90
|
-
isIdle: state.status === "idle",
|
|
91
|
-
mutate: this.mutate,
|
|
92
|
-
reset: this.reset
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
|
-
notify_fn = function(action) {
|
|
96
|
-
notifyManager.batch(() => {
|
|
97
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
98
|
-
if (__privateGet(this, _mutateOptions) && this.hasListeners()) {
|
|
99
|
-
const variables = __privateGet(this, _currentResult).variables;
|
|
100
|
-
const onMutateResult = __privateGet(this, _currentResult).context;
|
|
101
|
-
const context = {
|
|
102
|
-
client: __privateGet(this, _client),
|
|
103
|
-
meta: this.options.meta,
|
|
104
|
-
mutationKey: this.options.mutationKey
|
|
105
|
-
};
|
|
106
|
-
if ((action == null ? void 0 : action.type) === "success") {
|
|
107
|
-
try {
|
|
108
|
-
(_b = (_a = __privateGet(this, _mutateOptions)).onSuccess) == null ? void 0 : _b.call(
|
|
109
|
-
_a,
|
|
110
|
-
action.data,
|
|
111
|
-
variables,
|
|
112
|
-
onMutateResult,
|
|
113
|
-
context
|
|
114
|
-
);
|
|
115
|
-
} catch (e) {
|
|
116
|
-
void Promise.reject(e);
|
|
117
|
-
}
|
|
118
|
-
try {
|
|
119
|
-
(_d = (_c = __privateGet(this, _mutateOptions)).onSettled) == null ? void 0 : _d.call(
|
|
120
|
-
_c,
|
|
121
|
-
action.data,
|
|
122
|
-
null,
|
|
123
|
-
variables,
|
|
124
|
-
onMutateResult,
|
|
125
|
-
context
|
|
126
|
-
);
|
|
127
|
-
} catch (e) {
|
|
128
|
-
void Promise.reject(e);
|
|
129
|
-
}
|
|
130
|
-
} else if ((action == null ? void 0 : action.type) === "error") {
|
|
131
|
-
try {
|
|
132
|
-
(_f = (_e = __privateGet(this, _mutateOptions)).onError) == null ? void 0 : _f.call(
|
|
133
|
-
_e,
|
|
134
|
-
action.error,
|
|
135
|
-
variables,
|
|
136
|
-
onMutateResult,
|
|
137
|
-
context
|
|
138
|
-
);
|
|
139
|
-
} catch (e) {
|
|
140
|
-
void Promise.reject(e);
|
|
141
|
-
}
|
|
142
|
-
try {
|
|
143
|
-
(_h = (_g = __privateGet(this, _mutateOptions)).onSettled) == null ? void 0 : _h.call(
|
|
144
|
-
_g,
|
|
145
|
-
void 0,
|
|
146
|
-
action.error,
|
|
147
|
-
variables,
|
|
148
|
-
onMutateResult,
|
|
149
|
-
context
|
|
150
|
-
);
|
|
151
|
-
} catch (e) {
|
|
152
|
-
void Promise.reject(e);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
this.listeners.forEach((listener) => {
|
|
157
|
-
listener(__privateGet(this, _currentResult));
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
};
|
|
161
|
-
export {
|
|
162
|
-
MutationObserver
|
|
14
|
+
constructor(client, options) {
|
|
15
|
+
super();
|
|
16
|
+
_classPrivateMethodInitSpec(this, _MutationObserver_brand);
|
|
17
|
+
_classPrivateFieldInitSpec(this, _client, void 0);
|
|
18
|
+
_classPrivateFieldInitSpec(this, _currentResult, void 0);
|
|
19
|
+
_classPrivateFieldInitSpec(this, _currentMutation, void 0);
|
|
20
|
+
_classPrivateFieldInitSpec(this, _mutateOptions, void 0);
|
|
21
|
+
_classPrivateFieldSet2(_client, this, client);
|
|
22
|
+
this.setOptions(options);
|
|
23
|
+
this.bindMethods();
|
|
24
|
+
_assertClassBrand(_MutationObserver_brand, this, _updateResult).call(this);
|
|
25
|
+
}
|
|
26
|
+
bindMethods() {
|
|
27
|
+
this.mutate = this.mutate.bind(this);
|
|
28
|
+
this.reset = this.reset.bind(this);
|
|
29
|
+
}
|
|
30
|
+
setOptions(options) {
|
|
31
|
+
var _classPrivateFieldGet2$1;
|
|
32
|
+
const prevOptions = this.options;
|
|
33
|
+
this.options = _classPrivateFieldGet2(_client, this).defaultMutationOptions(options);
|
|
34
|
+
if (!shallowEqualObjects(this.options, prevOptions)) _classPrivateFieldGet2(_client, this).getMutationCache().notify({
|
|
35
|
+
type: "observerOptionsUpdated",
|
|
36
|
+
mutation: _classPrivateFieldGet2(_currentMutation, this),
|
|
37
|
+
observer: this
|
|
38
|
+
});
|
|
39
|
+
if ((prevOptions === null || prevOptions === void 0 ? void 0 : prevOptions.mutationKey) && this.options.mutationKey && hashKey(prevOptions.mutationKey) !== hashKey(this.options.mutationKey)) this.reset();
|
|
40
|
+
else if (((_classPrivateFieldGet2$1 = _classPrivateFieldGet2(_currentMutation, this)) === null || _classPrivateFieldGet2$1 === void 0 ? void 0 : _classPrivateFieldGet2$1.state.status) === "pending") _classPrivateFieldGet2(_currentMutation, this).setOptions(this.options);
|
|
41
|
+
}
|
|
42
|
+
onSubscribe() {
|
|
43
|
+
if (this.listeners.size === 1 && _classPrivateFieldGet2(_currentMutation, this)) {
|
|
44
|
+
_classPrivateFieldGet2(_currentMutation, this).addObserver(this);
|
|
45
|
+
_assertClassBrand(_MutationObserver_brand, this, _updateResult).call(this);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
onUnsubscribe() {
|
|
49
|
+
if (!this.hasListeners()) {
|
|
50
|
+
var _classPrivateFieldGet3;
|
|
51
|
+
(_classPrivateFieldGet3 = _classPrivateFieldGet2(_currentMutation, this)) === null || _classPrivateFieldGet3 === void 0 || _classPrivateFieldGet3.removeObserver(this);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
onMutationUpdate(action) {
|
|
55
|
+
_assertClassBrand(_MutationObserver_brand, this, _updateResult).call(this);
|
|
56
|
+
_assertClassBrand(_MutationObserver_brand, this, _notify).call(this, action);
|
|
57
|
+
}
|
|
58
|
+
getCurrentResult() {
|
|
59
|
+
return _classPrivateFieldGet2(_currentResult, this);
|
|
60
|
+
}
|
|
61
|
+
reset() {
|
|
62
|
+
var _classPrivateFieldGet4;
|
|
63
|
+
(_classPrivateFieldGet4 = _classPrivateFieldGet2(_currentMutation, this)) === null || _classPrivateFieldGet4 === void 0 || _classPrivateFieldGet4.removeObserver(this);
|
|
64
|
+
_classPrivateFieldSet2(_currentMutation, this, void 0);
|
|
65
|
+
_assertClassBrand(_MutationObserver_brand, this, _updateResult).call(this);
|
|
66
|
+
_assertClassBrand(_MutationObserver_brand, this, _notify).call(this);
|
|
67
|
+
}
|
|
68
|
+
mutate(variables, options) {
|
|
69
|
+
var _classPrivateFieldGet5;
|
|
70
|
+
_classPrivateFieldSet2(_mutateOptions, this, options);
|
|
71
|
+
(_classPrivateFieldGet5 = _classPrivateFieldGet2(_currentMutation, this)) === null || _classPrivateFieldGet5 === void 0 || _classPrivateFieldGet5.removeObserver(this);
|
|
72
|
+
_classPrivateFieldSet2(_currentMutation, this, _classPrivateFieldGet2(_client, this).getMutationCache().build(_classPrivateFieldGet2(_client, this), this.options));
|
|
73
|
+
_classPrivateFieldGet2(_currentMutation, this).addObserver(this);
|
|
74
|
+
return _classPrivateFieldGet2(_currentMutation, this).execute(variables);
|
|
75
|
+
}
|
|
163
76
|
};
|
|
77
|
+
function _updateResult() {
|
|
78
|
+
var _classPrivateFieldGet6;
|
|
79
|
+
const state = ((_classPrivateFieldGet6 = _classPrivateFieldGet2(_currentMutation, this)) === null || _classPrivateFieldGet6 === void 0 ? void 0 : _classPrivateFieldGet6.state) ?? getDefaultState();
|
|
80
|
+
_classPrivateFieldSet2(_currentResult, this, {
|
|
81
|
+
...state,
|
|
82
|
+
isPending: state.status === "pending",
|
|
83
|
+
isSuccess: state.status === "success",
|
|
84
|
+
isError: state.status === "error",
|
|
85
|
+
isIdle: state.status === "idle",
|
|
86
|
+
mutate: this.mutate,
|
|
87
|
+
reset: this.reset
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function _notify(action) {
|
|
91
|
+
notifyManager.batch(() => {
|
|
92
|
+
if (_classPrivateFieldGet2(_mutateOptions, this) && this.hasListeners()) {
|
|
93
|
+
const variables = _classPrivateFieldGet2(_currentResult, this).variables;
|
|
94
|
+
const onMutateResult = _classPrivateFieldGet2(_currentResult, this).context;
|
|
95
|
+
const context = {
|
|
96
|
+
client: _classPrivateFieldGet2(_client, this),
|
|
97
|
+
meta: this.options.meta,
|
|
98
|
+
mutationKey: this.options.mutationKey
|
|
99
|
+
};
|
|
100
|
+
if ((action === null || action === void 0 ? void 0 : action.type) === "success") {
|
|
101
|
+
try {
|
|
102
|
+
var _classPrivateFieldGet7, _classPrivateFieldGet8;
|
|
103
|
+
(_classPrivateFieldGet7 = (_classPrivateFieldGet8 = _classPrivateFieldGet2(_mutateOptions, this)).onSuccess) === null || _classPrivateFieldGet7 === void 0 || _classPrivateFieldGet7.call(_classPrivateFieldGet8, action.data, variables, onMutateResult, context);
|
|
104
|
+
} catch (e) {
|
|
105
|
+
Promise.reject(e);
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
var _classPrivateFieldGet9, _classPrivateFieldGet10;
|
|
109
|
+
(_classPrivateFieldGet9 = (_classPrivateFieldGet10 = _classPrivateFieldGet2(_mutateOptions, this)).onSettled) === null || _classPrivateFieldGet9 === void 0 || _classPrivateFieldGet9.call(_classPrivateFieldGet10, action.data, null, variables, onMutateResult, context);
|
|
110
|
+
} catch (e) {
|
|
111
|
+
Promise.reject(e);
|
|
112
|
+
}
|
|
113
|
+
} else if ((action === null || action === void 0 ? void 0 : action.type) === "error") {
|
|
114
|
+
try {
|
|
115
|
+
var _classPrivateFieldGet11, _classPrivateFieldGet12;
|
|
116
|
+
(_classPrivateFieldGet11 = (_classPrivateFieldGet12 = _classPrivateFieldGet2(_mutateOptions, this)).onError) === null || _classPrivateFieldGet11 === void 0 || _classPrivateFieldGet11.call(_classPrivateFieldGet12, action.error, variables, onMutateResult, context);
|
|
117
|
+
} catch (e) {
|
|
118
|
+
Promise.reject(e);
|
|
119
|
+
}
|
|
120
|
+
try {
|
|
121
|
+
var _classPrivateFieldGet13, _classPrivateFieldGet14;
|
|
122
|
+
(_classPrivateFieldGet13 = (_classPrivateFieldGet14 = _classPrivateFieldGet2(_mutateOptions, this)).onSettled) === null || _classPrivateFieldGet13 === void 0 || _classPrivateFieldGet13.call(_classPrivateFieldGet14, void 0, action.error, variables, onMutateResult, context);
|
|
123
|
+
} catch (e) {
|
|
124
|
+
Promise.reject(e);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
this.listeners.forEach((listener) => {
|
|
129
|
+
listener(_classPrivateFieldGet2(_currentResult, this));
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
//#endregion
|
|
134
|
+
export { MutationObserver };
|
|
135
|
+
|
|
164
136
|
//# sourceMappingURL=mutationObserver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mutationObserver.ts"],"sourcesContent":["import { getDefaultState } from './mutation'\nimport { notifyManager } from './notifyManager'\nimport { Subscribable } from './subscribable'\nimport { hashKey, shallowEqualObjects } from './utils'\nimport type { QueryClient } from './queryClient'\nimport type {\n DefaultError,\n MutateOptions,\n MutationFunctionContext,\n MutationObserverOptions,\n MutationObserverResult,\n} from './types'\nimport type { Action, Mutation } from './mutation'\n\n// TYPES\n\ntype MutationObserverListener<TData, TError, TVariables, TOnMutateResult> = (\n result: MutationObserverResult<TData, TError, TVariables, TOnMutateResult>,\n) => void\n\n// CLASS\n\nexport class MutationObserver<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n> extends Subscribable<\n MutationObserverListener<TData, TError, TVariables, TOnMutateResult>\n> {\n options!: MutationObserverOptions<TData, TError, TVariables, TOnMutateResult>\n\n #client: QueryClient\n #currentResult: MutationObserverResult<\n TData,\n TError,\n TVariables,\n TOnMutateResult\n > = undefined!\n #currentMutation?: Mutation<TData, TError, TVariables, TOnMutateResult>\n #mutateOptions?: MutateOptions<TData, TError, TVariables, TOnMutateResult>\n\n constructor(\n client: QueryClient,\n options: MutationObserverOptions<\n TData,\n TError,\n TVariables,\n TOnMutateResult\n >,\n ) {\n super()\n\n this.#client = client\n this.setOptions(options)\n this.bindMethods()\n this.#updateResult()\n }\n\n protected bindMethods(): void {\n this.mutate = this.mutate.bind(this)\n this.reset = this.reset.bind(this)\n }\n\n setOptions(\n options: MutationObserverOptions<\n TData,\n TError,\n TVariables,\n TOnMutateResult\n >,\n ) {\n const prevOptions = this.options as\n | MutationObserverOptions<TData, TError, TVariables, TOnMutateResult>\n | undefined\n this.options = this.#client.defaultMutationOptions(options)\n if (!shallowEqualObjects(this.options, prevOptions)) {\n this.#client.getMutationCache().notify({\n type: 'observerOptionsUpdated',\n mutation: this.#currentMutation,\n observer: this,\n })\n }\n\n if (\n prevOptions?.mutationKey &&\n this.options.mutationKey &&\n hashKey(prevOptions.mutationKey) !== hashKey(this.options.mutationKey)\n ) {\n this.reset()\n } else if (this.#currentMutation?.state.status === 'pending') {\n this.#currentMutation.setOptions(this.options)\n }\n }\n\n protected onUnsubscribe(): void {\n if (!this.hasListeners()) {\n this.#currentMutation?.removeObserver(this)\n }\n }\n\n onMutationUpdate(\n action: Action<TData, TError, TVariables, TOnMutateResult>,\n ): void {\n this.#updateResult()\n\n this.#notify(action)\n }\n\n getCurrentResult(): MutationObserverResult<\n TData,\n TError,\n TVariables,\n TOnMutateResult\n > {\n return this.#currentResult\n }\n\n reset(): void {\n // reset needs to remove the observer from the mutation because there is no way to \"get it back\"\n // another mutate call will yield a new mutation!\n this.#currentMutation?.removeObserver(this)\n this.#currentMutation = undefined\n this.#updateResult()\n this.#notify()\n }\n\n mutate(\n variables: TVariables,\n options?: MutateOptions<TData, TError, TVariables, TOnMutateResult>,\n ): Promise<TData> {\n this.#mutateOptions = options\n\n this.#currentMutation?.removeObserver(this)\n\n this.#currentMutation = this.#client\n .getMutationCache()\n .build(this.#client, this.options)\n\n this.#currentMutation.addObserver(this)\n\n return this.#currentMutation.execute(variables)\n }\n\n #updateResult(): void {\n const state =\n this.#currentMutation?.state ??\n getDefaultState<TData, TError, TVariables, TOnMutateResult>()\n\n this.#currentResult = {\n ...state,\n isPending: state.status === 'pending',\n isSuccess: state.status === 'success',\n isError: state.status === 'error',\n isIdle: state.status === 'idle',\n mutate: this.mutate,\n reset: this.reset,\n } as MutationObserverResult<TData, TError, TVariables, TOnMutateResult>\n }\n\n #notify(action?: Action<TData, TError, TVariables, TOnMutateResult>): void {\n notifyManager.batch(() => {\n // First trigger the mutate callbacks\n if (this.#mutateOptions && this.hasListeners()) {\n const variables = this.#currentResult.variables!\n const onMutateResult = this.#currentResult.context\n\n const context = {\n client: this.#client,\n meta: this.options.meta,\n mutationKey: this.options.mutationKey,\n } satisfies MutationFunctionContext\n\n if (action?.type === 'success') {\n try {\n this.#mutateOptions.onSuccess?.(\n action.data,\n variables,\n onMutateResult,\n context,\n )\n } catch (e) {\n void Promise.reject(e)\n }\n try {\n this.#mutateOptions.onSettled?.(\n action.data,\n null,\n variables,\n onMutateResult,\n context,\n )\n } catch (e) {\n void Promise.reject(e)\n }\n } else if (action?.type === 'error') {\n try {\n this.#mutateOptions.onError?.(\n action.error,\n variables,\n onMutateResult,\n context,\n )\n } catch (e) {\n void Promise.reject(e)\n }\n try {\n this.#mutateOptions.onSettled?.(\n undefined,\n action.error,\n variables,\n onMutateResult,\n context,\n )\n } catch (e) {\n void Promise.reject(e)\n }\n }\n }\n\n // Then trigger the listeners\n this.listeners.forEach((listener) => {\n listener(this.#currentResult)\n })\n })\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"mutationObserver.js","names":[],"sources":["../../src/mutationObserver.ts"],"sourcesContent":["import { getDefaultState } from './mutation'\nimport { notifyManager } from './notifyManager'\nimport { Subscribable } from './subscribable'\nimport { hashKey, shallowEqualObjects } from './utils'\nimport type { QueryClient } from './queryClient'\nimport type {\n DefaultError,\n MutateOptions,\n MutationFunctionContext,\n MutationObserverOptions,\n MutationObserverResult,\n} from './types'\nimport type { Action, Mutation } from './mutation'\n\n// TYPES\n\ntype MutationObserverListener<TData, TError, TVariables, TOnMutateResult> = (\n result: MutationObserverResult<TData, TError, TVariables, TOnMutateResult>,\n) => void\n\n// CLASS\n\nexport class MutationObserver<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n> extends Subscribable<\n MutationObserverListener<TData, TError, TVariables, TOnMutateResult>\n> {\n options!: MutationObserverOptions<TData, TError, TVariables, TOnMutateResult>\n\n #client: QueryClient\n #currentResult: MutationObserverResult<\n TData,\n TError,\n TVariables,\n TOnMutateResult\n > = undefined!\n #currentMutation?: Mutation<TData, TError, TVariables, TOnMutateResult>\n #mutateOptions?: MutateOptions<TData, TError, TVariables, TOnMutateResult>\n\n constructor(\n client: QueryClient,\n options: MutationObserverOptions<\n TData,\n TError,\n TVariables,\n TOnMutateResult\n >,\n ) {\n super()\n\n this.#client = client\n this.setOptions(options)\n this.bindMethods()\n this.#updateResult()\n }\n\n protected bindMethods(): void {\n this.mutate = this.mutate.bind(this)\n this.reset = this.reset.bind(this)\n }\n\n setOptions(\n options: MutationObserverOptions<\n TData,\n TError,\n TVariables,\n TOnMutateResult\n >,\n ) {\n const prevOptions = this.options as\n | MutationObserverOptions<TData, TError, TVariables, TOnMutateResult>\n | undefined\n this.options = this.#client.defaultMutationOptions(options)\n if (!shallowEqualObjects(this.options, prevOptions)) {\n this.#client.getMutationCache().notify({\n type: 'observerOptionsUpdated',\n mutation: this.#currentMutation,\n observer: this,\n })\n }\n\n if (\n prevOptions?.mutationKey &&\n this.options.mutationKey &&\n hashKey(prevOptions.mutationKey) !== hashKey(this.options.mutationKey)\n ) {\n this.reset()\n } else if (this.#currentMutation?.state.status === 'pending') {\n this.#currentMutation.setOptions(this.options)\n }\n }\n\n protected onSubscribe(): void {\n if (this.listeners.size === 1 && this.#currentMutation) {\n this.#currentMutation.addObserver(this)\n\n this.#updateResult()\n }\n }\n\n protected onUnsubscribe(): void {\n if (!this.hasListeners()) {\n this.#currentMutation?.removeObserver(this)\n }\n }\n\n onMutationUpdate(\n action: Action<TData, TError, TVariables, TOnMutateResult>,\n ): void {\n this.#updateResult()\n\n this.#notify(action)\n }\n\n getCurrentResult(): MutationObserverResult<\n TData,\n TError,\n TVariables,\n TOnMutateResult\n > {\n return this.#currentResult\n }\n\n reset(): void {\n // reset needs to remove the observer from the mutation because there is no way to \"get it back\"\n // another mutate call will yield a new mutation!\n this.#currentMutation?.removeObserver(this)\n this.#currentMutation = undefined\n this.#updateResult()\n this.#notify()\n }\n\n mutate(\n variables: TVariables,\n options?: MutateOptions<TData, TError, TVariables, TOnMutateResult>,\n ): Promise<TData> {\n this.#mutateOptions = options\n\n this.#currentMutation?.removeObserver(this)\n\n this.#currentMutation = this.#client\n .getMutationCache()\n .build(this.#client, this.options)\n\n this.#currentMutation.addObserver(this)\n\n return this.#currentMutation.execute(variables)\n }\n\n #updateResult(): void {\n const state =\n this.#currentMutation?.state ??\n getDefaultState<TData, TError, TVariables, TOnMutateResult>()\n\n this.#currentResult = {\n ...state,\n isPending: state.status === 'pending',\n isSuccess: state.status === 'success',\n isError: state.status === 'error',\n isIdle: state.status === 'idle',\n mutate: this.mutate,\n reset: this.reset,\n } as MutationObserverResult<TData, TError, TVariables, TOnMutateResult>\n }\n\n #notify(action?: Action<TData, TError, TVariables, TOnMutateResult>): void {\n notifyManager.batch(() => {\n // First trigger the mutate callbacks\n if (this.#mutateOptions && this.hasListeners()) {\n const variables = this.#currentResult.variables!\n const onMutateResult = this.#currentResult.context\n\n const context = {\n client: this.#client,\n meta: this.options.meta,\n mutationKey: this.options.mutationKey,\n } satisfies MutationFunctionContext\n\n if (action?.type === 'success') {\n try {\n this.#mutateOptions.onSuccess?.(\n action.data,\n variables,\n onMutateResult,\n context,\n )\n } catch (e) {\n void Promise.reject(e)\n }\n try {\n this.#mutateOptions.onSettled?.(\n action.data,\n null,\n variables,\n onMutateResult,\n context,\n )\n } catch (e) {\n void Promise.reject(e)\n }\n } else if (action?.type === 'error') {\n try {\n this.#mutateOptions.onError?.(\n action.error,\n variables,\n onMutateResult,\n context,\n )\n } catch (e) {\n void Promise.reject(e)\n }\n try {\n this.#mutateOptions.onSettled?.(\n undefined,\n action.error,\n variables,\n onMutateResult,\n context,\n )\n } catch (e) {\n void Promise.reject(e)\n }\n }\n }\n\n // Then trigger the listeners\n this.listeners.forEach((listener) => {\n listener(this.#currentResult)\n })\n })\n }\n}\n"],"mappings":"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"}
|
|
@@ -1,113 +1,79 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/notifyManager.ts
|
|
21
|
-
var notifyManager_exports = {};
|
|
22
|
-
__export(notifyManager_exports, {
|
|
23
|
-
createNotifyManager: () => createNotifyManager,
|
|
24
|
-
defaultScheduler: () => defaultScheduler,
|
|
25
|
-
notifyManager: () => notifyManager
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(notifyManager_exports);
|
|
28
|
-
var import_timeoutManager = require("./timeoutManager.cjs");
|
|
29
|
-
var defaultScheduler = import_timeoutManager.systemSetTimeoutZero;
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/notifyManager.ts
|
|
3
|
+
const defaultScheduler = require("./timeoutManager.cjs").systemSetTimeoutZero;
|
|
30
4
|
function createNotifyManager() {
|
|
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
|
-
setBatchNotifyFunction: (fn) => {
|
|
99
|
-
batchNotifyFn = fn;
|
|
100
|
-
},
|
|
101
|
-
setScheduler: (fn) => {
|
|
102
|
-
scheduleFn = fn;
|
|
103
|
-
}
|
|
104
|
-
};
|
|
5
|
+
let queue = [];
|
|
6
|
+
let transactions = 0;
|
|
7
|
+
let notifyFn = (callback) => {
|
|
8
|
+
callback();
|
|
9
|
+
};
|
|
10
|
+
let batchNotifyFn = (callback) => {
|
|
11
|
+
callback();
|
|
12
|
+
};
|
|
13
|
+
let scheduleFn = defaultScheduler;
|
|
14
|
+
const schedule = (callback) => {
|
|
15
|
+
if (transactions) queue.push(callback);
|
|
16
|
+
else scheduleFn(() => {
|
|
17
|
+
notifyFn(callback);
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
const flush = () => {
|
|
21
|
+
const originalQueue = queue;
|
|
22
|
+
queue = [];
|
|
23
|
+
if (originalQueue.length) scheduleFn(() => {
|
|
24
|
+
batchNotifyFn(() => {
|
|
25
|
+
originalQueue.forEach((callback) => {
|
|
26
|
+
notifyFn(callback);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
return {
|
|
32
|
+
batch: (callback) => {
|
|
33
|
+
let result;
|
|
34
|
+
transactions++;
|
|
35
|
+
try {
|
|
36
|
+
result = callback();
|
|
37
|
+
} finally {
|
|
38
|
+
transactions--;
|
|
39
|
+
if (!transactions) flush();
|
|
40
|
+
}
|
|
41
|
+
return result;
|
|
42
|
+
},
|
|
43
|
+
/**
|
|
44
|
+
* All calls to the wrapped function will be batched.
|
|
45
|
+
*/
|
|
46
|
+
batchCalls: (callback) => {
|
|
47
|
+
return (...args) => {
|
|
48
|
+
schedule(() => {
|
|
49
|
+
callback(...args);
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
schedule,
|
|
54
|
+
/**
|
|
55
|
+
* Use this method to set a custom notify function.
|
|
56
|
+
* This can be used to for example wrap notifications with `React.act` while running tests.
|
|
57
|
+
*/
|
|
58
|
+
setNotifyFunction: (fn) => {
|
|
59
|
+
notifyFn = fn;
|
|
60
|
+
},
|
|
61
|
+
/**
|
|
62
|
+
* Use this method to set a custom function to batch notifications together into a single tick.
|
|
63
|
+
* By default React Query will use the batch function provided by ReactDOM or React Native.
|
|
64
|
+
*/
|
|
65
|
+
setBatchNotifyFunction: (fn) => {
|
|
66
|
+
batchNotifyFn = fn;
|
|
67
|
+
},
|
|
68
|
+
setScheduler: (fn) => {
|
|
69
|
+
scheduleFn = fn;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
105
72
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
});
|
|
73
|
+
const notifyManager = createNotifyManager();
|
|
74
|
+
//#endregion
|
|
75
|
+
exports.createNotifyManager = createNotifyManager;
|
|
76
|
+
exports.defaultScheduler = defaultScheduler;
|
|
77
|
+
exports.notifyManager = notifyManager;
|
|
78
|
+
|
|
113
79
|
//# sourceMappingURL=notifyManager.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/notifyManager.ts"],"sourcesContent":["// TYPES\n\nimport { systemSetTimeoutZero } from './timeoutManager'\n\ntype NotifyCallback = () => void\n\ntype NotifyFunction = (callback: () => void) => void\n\ntype BatchNotifyFunction = (callback: () => void) => void\n\ntype BatchCallsCallback<T extends Array<unknown>> = (...args: T) => void\n\ntype ScheduleFunction = (callback: () => void) => void\n\nexport const defaultScheduler: ScheduleFunction = systemSetTimeoutZero\n\nexport function createNotifyManager() {\n let queue: Array<NotifyCallback> = []\n let transactions = 0\n let notifyFn: NotifyFunction = (callback) => {\n callback()\n }\n let batchNotifyFn: BatchNotifyFunction = (callback: () => void) => {\n callback()\n }\n let scheduleFn = defaultScheduler\n\n const schedule = (callback: NotifyCallback): void => {\n if (transactions) {\n queue.push(callback)\n } else {\n scheduleFn(() => {\n notifyFn(callback)\n })\n }\n }\n const flush = (): void => {\n const originalQueue = queue\n queue = []\n if (originalQueue.length) {\n scheduleFn(() => {\n batchNotifyFn(() => {\n originalQueue.forEach((callback) => {\n notifyFn(callback)\n })\n })\n })\n }\n }\n\n return {\n batch: <T>(callback: () => T): T => {\n let result\n transactions++\n try {\n result = callback()\n } finally {\n transactions--\n if (!transactions) {\n flush()\n }\n }\n return result\n },\n /**\n * All calls to the wrapped function will be batched.\n */\n batchCalls: <T extends Array<unknown>>(\n callback: BatchCallsCallback<T>,\n ): BatchCallsCallback<T> => {\n return (...args) => {\n schedule(() => {\n callback(...args)\n })\n }\n },\n schedule,\n /**\n * Use this method to set a custom notify function.\n * This can be used to for example wrap notifications with `React.act` while running tests.\n */\n setNotifyFunction: (fn: NotifyFunction) => {\n notifyFn = fn\n },\n /**\n * Use this method to set a custom function to batch notifications together into a single tick.\n * By default React Query will use the batch function provided by ReactDOM or React Native.\n */\n setBatchNotifyFunction: (fn: BatchNotifyFunction) => {\n batchNotifyFn = fn\n },\n setScheduler: (fn: ScheduleFunction) => {\n scheduleFn = fn\n },\n } as const\n}\n\n// SINGLETON\nexport const notifyManager = createNotifyManager()\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"notifyManager.cjs","names":["systemSetTimeoutZero"],"sources":["../../src/notifyManager.ts"],"sourcesContent":["// TYPES\n\nimport { systemSetTimeoutZero } from './timeoutManager'\n\ntype NotifyCallback = () => void\n\ntype NotifyFunction = (callback: () => void) => void\n\ntype BatchNotifyFunction = (callback: () => void) => void\n\ntype BatchCallsCallback<T extends Array<unknown>> = (...args: T) => void\n\ntype ScheduleFunction = (callback: () => void) => void\n\nexport const defaultScheduler: ScheduleFunction = systemSetTimeoutZero\n\nexport function createNotifyManager() {\n let queue: Array<NotifyCallback> = []\n let transactions = 0\n let notifyFn: NotifyFunction = (callback) => {\n callback()\n }\n let batchNotifyFn: BatchNotifyFunction = (callback: () => void) => {\n callback()\n }\n let scheduleFn = defaultScheduler\n\n const schedule = (callback: NotifyCallback): void => {\n if (transactions) {\n queue.push(callback)\n } else {\n scheduleFn(() => {\n notifyFn(callback)\n })\n }\n }\n const flush = (): void => {\n const originalQueue = queue\n queue = []\n if (originalQueue.length) {\n scheduleFn(() => {\n batchNotifyFn(() => {\n originalQueue.forEach((callback) => {\n notifyFn(callback)\n })\n })\n })\n }\n }\n\n return {\n batch: <T>(callback: () => T): T => {\n let result\n transactions++\n try {\n result = callback()\n } finally {\n transactions--\n if (!transactions) {\n flush()\n }\n }\n return result\n },\n /**\n * All calls to the wrapped function will be batched.\n */\n batchCalls: <T extends Array<unknown>>(\n callback: BatchCallsCallback<T>,\n ): BatchCallsCallback<T> => {\n return (...args) => {\n schedule(() => {\n callback(...args)\n })\n }\n },\n schedule,\n /**\n * Use this method to set a custom notify function.\n * This can be used to for example wrap notifications with `React.act` while running tests.\n */\n setNotifyFunction: (fn: NotifyFunction) => {\n notifyFn = fn\n },\n /**\n * Use this method to set a custom function to batch notifications together into a single tick.\n * By default React Query will use the batch function provided by ReactDOM or React Native.\n */\n setBatchNotifyFunction: (fn: BatchNotifyFunction) => {\n batchNotifyFn = fn\n },\n setScheduler: (fn: ScheduleFunction) => {\n scheduleFn = fn\n },\n } as const\n}\n\n// SINGLETON\nexport const notifyManager = createNotifyManager()\n"],"mappings":";;AAcA,MAAa,iDAAqCA,CAAAA,CAAAA;AAElD,SAAgB,sBAAsB;CACpC,IAAI,QAA+B,CAAC;CACpC,IAAI,eAAe;CACnB,IAAI,YAA4B,aAAa;EAC3C,SAAS;CACX;CACA,IAAI,iBAAsC,aAAyB;EACjE,SAAS;CACX;CACA,IAAI,aAAa;CAEjB,MAAM,YAAY,aAAmC;EACnD,IAAI,cACF,MAAM,KAAK,QAAQ;OAEnB,iBAAiB;GACf,SAAS,QAAQ;EACnB,CAAC;CAEL;CACA,MAAM,cAAoB;EACxB,MAAM,gBAAgB;EACtB,QAAQ,CAAC;EACT,IAAI,cAAc,QAChB,iBAAiB;GACf,oBAAoB;IAClB,cAAc,SAAS,aAAa;KAClC,SAAS,QAAQ;IACnB,CAAC;GACH,CAAC;EACH,CAAC;CAEL;CAEA,OAAO;EACL,QAAW,aAAyB;GAClC,IAAI;GACJ;GACA,IAAI;IACF,SAAS,SAAS;GACpB,UAAU;IACR;IACA,IAAI,CAAC,cACH,MAAM;GAEV;GACA,OAAO;EACT;;;;EAIA,aACE,aAC0B;GAC1B,QAAQ,GAAG,SAAS;IAClB,eAAe;KACb,SAAS,GAAG,IAAI;IAClB,CAAC;GACH;EACF;EACA;;;;;EAKA,oBAAoB,OAAuB;GACzC,WAAW;EACb;;;;;EAKA,yBAAyB,OAA4B;GACnD,gBAAgB;EAClB;EACA,eAAe,OAAyB;GACtC,aAAa;EACf;CACF;AACF;AAGA,MAAa,gBAAgB,oBAAoB"}
|
|
@@ -1,3 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
//#region src/notifyManager.d.ts
|
|
2
|
+
type NotifyCallback = () => void;
|
|
3
|
+
type NotifyFunction = (callback: () => void) => void;
|
|
4
|
+
type BatchNotifyFunction = (callback: () => void) => void;
|
|
5
|
+
type BatchCallsCallback<T extends Array<unknown>> = (...args: T) => void;
|
|
6
|
+
type ScheduleFunction = (callback: () => void) => void;
|
|
7
|
+
declare const defaultScheduler: ScheduleFunction;
|
|
8
|
+
declare function createNotifyManager(): {
|
|
9
|
+
readonly batch: <T>(callback: () => T) => T;
|
|
10
|
+
/**
|
|
11
|
+
* All calls to the wrapped function will be batched.
|
|
12
|
+
*/
|
|
13
|
+
readonly batchCalls: <T extends Array<unknown>>(callback: BatchCallsCallback<T>) => BatchCallsCallback<T>;
|
|
14
|
+
readonly schedule: (callback: NotifyCallback) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Use this method to set a custom notify function.
|
|
17
|
+
* This can be used to for example wrap notifications with `React.act` while running tests.
|
|
18
|
+
*/
|
|
19
|
+
readonly setNotifyFunction: (fn: NotifyFunction) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Use this method to set a custom function to batch notifications together into a single tick.
|
|
22
|
+
* By default React Query will use the batch function provided by ReactDOM or React Native.
|
|
23
|
+
*/
|
|
24
|
+
readonly setBatchNotifyFunction: (fn: BatchNotifyFunction) => void;
|
|
25
|
+
readonly setScheduler: (fn: ScheduleFunction) => void;
|
|
26
|
+
};
|
|
27
|
+
declare const notifyManager: {
|
|
28
|
+
readonly batch: <T>(callback: () => T) => T;
|
|
29
|
+
/**
|
|
30
|
+
* All calls to the wrapped function will be batched.
|
|
31
|
+
*/
|
|
32
|
+
readonly batchCalls: <T extends Array<unknown>>(callback: BatchCallsCallback<T>) => BatchCallsCallback<T>;
|
|
33
|
+
readonly schedule: (callback: NotifyCallback) => void;
|
|
34
|
+
/**
|
|
35
|
+
* Use this method to set a custom notify function.
|
|
36
|
+
* This can be used to for example wrap notifications with `React.act` while running tests.
|
|
37
|
+
*/
|
|
38
|
+
readonly setNotifyFunction: (fn: NotifyFunction) => void;
|
|
39
|
+
/**
|
|
40
|
+
* Use this method to set a custom function to batch notifications together into a single tick.
|
|
41
|
+
* By default React Query will use the batch function provided by ReactDOM or React Native.
|
|
42
|
+
*/
|
|
43
|
+
readonly setBatchNotifyFunction: (fn: BatchNotifyFunction) => void;
|
|
44
|
+
readonly setScheduler: (fn: ScheduleFunction) => void;
|
|
45
|
+
};
|
|
46
|
+
//#endregion
|
|
47
|
+
export { createNotifyManager, defaultScheduler, notifyManager };
|
|
48
|
+
//# sourceMappingURL=notifyManager.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifyManager.d.cts","names":[],"sources":["../../src/notifyManager.ts"],"mappings":";KAIK;KAEA,kBAAkB;KAElB,uBAAuB;KAEvB,mBAAmB,UAAU,sBAAsB,MAAM;KAEzD,oBAAoB;cAEZ,kBAAkB;iBAEf;WAmCJ,QAAA,GAAC,gBAAkB,MAAI;;;;WAgBlB,aAAA,UAAU,gBAAc,UACzB,mBAAmB,OAC5B,mBAAmB;WA1CI,WAAA,UAAA;;;;;WAsDF,oBAAA,IAAA;;;;;WAOK,yBAAA,IAAA;WAGV,eAAA,IAAA;;cAOV;WA/CD,QAAA,GAAC,gBAAkB,MAAI;;;;WAgBlB,aAAA,UAAU,gBAAc,UACzB,mBAAmB,OAC5B,mBAAmB;WA1CI,WAAA,UAAA;;;;;WAsDF,oBAAA,IAAA;;;;;WAOK,yBAAA,IAAA;WAGV,eAAA,IAAA"}
|