@tanstack/query-core 5.0.0-alpha.86 → 5.0.0-alpha.87
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/focusManager.cjs +116 -0
- package/build/legacy/focusManager.cjs.map +1 -0
- package/build/legacy/focusManager.d.cts +16 -0
- package/build/{lib → legacy}/focusManager.d.ts +6 -5
- package/build/legacy/focusManager.js +91 -0
- package/build/legacy/focusManager.js.map +1 -0
- package/build/legacy/hydration.cjs +109 -0
- package/build/legacy/hydration.cjs.map +1 -0
- package/build/legacy/hydration.d.cts +35 -0
- package/build/legacy/hydration.d.ts +35 -0
- package/build/legacy/hydration.js +82 -0
- package/build/legacy/hydration.js.map +1 -0
- package/build/legacy/index.cjs +85 -0
- package/build/legacy/index.cjs.map +1 -0
- package/build/legacy/index.d.cts +9 -0
- package/build/legacy/index.d.ts +9 -0
- package/build/legacy/index.js +50 -0
- package/build/legacy/index.js.map +1 -0
- package/build/legacy/infiniteQueryBehavior.cjs +141 -0
- package/build/legacy/infiniteQueryBehavior.cjs.map +1 -0
- package/build/legacy/infiniteQueryBehavior.d.cts +15 -0
- package/build/legacy/infiniteQueryBehavior.d.ts +15 -0
- package/build/legacy/infiniteQueryBehavior.js +115 -0
- package/build/legacy/infiniteQueryBehavior.js.map +1 -0
- package/build/legacy/infiniteQueryObserver.cjs +88 -0
- package/build/legacy/infiniteQueryObserver.cjs.map +1 -0
- package/build/legacy/infiniteQueryObserver.d.cts +19 -0
- package/build/{lib → legacy}/infiniteQueryObserver.d.ts +7 -8
- package/build/{lib/infiniteQueryObserver.legacy.js → legacy/infiniteQueryObserver.js} +24 -32
- package/build/legacy/infiniteQueryObserver.js.map +1 -0
- package/build/legacy/mutation.cjs +297 -0
- package/build/legacy/mutation.cjs.map +1 -0
- package/build/legacy/mutation.d.cts +3 -0
- package/build/legacy/mutation.d.ts +3 -0
- package/build/legacy/mutation.js +272 -0
- package/build/legacy/mutation.js.map +1 -0
- package/build/legacy/mutationCache.cjs +133 -0
- package/build/legacy/mutationCache.cjs.map +1 -0
- package/build/legacy/mutationCache.d.cts +3 -0
- package/build/legacy/mutationCache.d.ts +3 -0
- package/build/legacy/mutationCache.js +109 -0
- package/build/legacy/mutationCache.js.map +1 -0
- package/build/legacy/mutationObserver.cjs +171 -0
- package/build/legacy/mutationObserver.cjs.map +1 -0
- package/build/legacy/mutationObserver.d.cts +3 -0
- package/build/legacy/mutationObserver.d.ts +3 -0
- package/build/legacy/mutationObserver.js +147 -0
- package/build/legacy/mutationObserver.js.map +1 -0
- package/build/legacy/notifyManager.cjs +97 -0
- package/build/legacy/notifyManager.cjs.map +1 -0
- package/build/legacy/notifyManager.d.cts +20 -0
- package/build/{lib → legacy}/notifyManager.d.ts +4 -4
- package/build/{lib → legacy}/notifyManager.js +14 -31
- package/build/legacy/notifyManager.js.map +1 -0
- package/build/legacy/onlineManager.cjs +106 -0
- package/build/legacy/onlineManager.cjs.map +1 -0
- package/build/legacy/onlineManager.d.cts +16 -0
- package/build/{lib → legacy}/onlineManager.d.ts +6 -5
- package/build/legacy/onlineManager.js +81 -0
- package/build/legacy/onlineManager.js.map +1 -0
- package/build/legacy/queriesObserver.cjs +242 -0
- package/build/legacy/queriesObserver.cjs.map +1 -0
- package/build/legacy/queriesObserver.d.cts +26 -0
- package/build/{lib → legacy}/queriesObserver.d.ts +10 -11
- package/build/legacy/queriesObserver.js +218 -0
- package/build/legacy/queriesObserver.js.map +1 -0
- package/build/legacy/query.cjs +423 -0
- package/build/legacy/query.cjs.map +1 -0
- package/build/legacy/query.d.cts +3 -0
- package/build/legacy/query.d.ts +3 -0
- package/build/legacy/query.js +399 -0
- package/build/legacy/query.js.map +1 -0
- package/build/legacy/queryCache.cjs +140 -0
- package/build/legacy/queryCache.cjs.map +1 -0
- package/build/legacy/queryCache.d.cts +3 -0
- package/build/legacy/queryCache.d.ts +3 -0
- package/build/legacy/queryCache.js +116 -0
- package/build/legacy/queryCache.js.map +1 -0
- package/build/legacy/queryClient-4ba6364e.d.ts +916 -0
- package/build/legacy/queryClient-d615ed9f.d.ts +916 -0
- package/build/legacy/queryClient.cjs +322 -0
- package/build/legacy/queryClient.cjs.map +1 -0
- package/build/legacy/queryClient.d.cts +3 -0
- package/build/legacy/queryClient.d.ts +3 -0
- package/build/legacy/queryClient.js +304 -0
- package/build/legacy/queryClient.js.map +1 -0
- package/build/legacy/queryObserver.cjs +501 -0
- package/build/legacy/queryObserver.cjs.map +1 -0
- package/build/legacy/queryObserver.d.cts +3 -0
- package/build/legacy/queryObserver.d.ts +3 -0
- package/build/legacy/queryObserver.js +484 -0
- package/build/legacy/queryObserver.js.map +1 -0
- package/build/legacy/removable.cjs +77 -0
- package/build/legacy/removable.cjs.map +1 -0
- package/build/legacy/removable.d.cts +11 -0
- package/build/{lib → legacy}/removable.d.ts +3 -2
- package/build/legacy/removable.js +53 -0
- package/build/legacy/removable.js.map +1 -0
- package/build/legacy/retryer.cjs +169 -0
- package/build/legacy/retryer.cjs.map +1 -0
- package/build/legacy/retryer.d.cts +3 -0
- package/build/legacy/retryer.d.ts +3 -0
- package/build/{lib/retryer.legacy.js → legacy/retryer.js} +37 -48
- package/build/legacy/retryer.js.map +1 -0
- package/build/legacy/subscribable.cjs +49 -0
- package/build/legacy/subscribable.cjs.map +1 -0
- package/build/legacy/subscribable.d.cts +11 -0
- package/build/{lib → legacy}/subscribable.d.ts +3 -3
- package/build/{lib → legacy}/subscribable.js +5 -6
- package/build/legacy/subscribable.js.map +1 -0
- package/build/legacy/types.cjs +17 -0
- package/build/legacy/types.cjs.map +1 -0
- package/build/legacy/types.d.cts +3 -0
- package/build/legacy/types.d.ts +3 -0
- package/build/legacy/types.js +1 -0
- package/build/legacy/types.js.map +1 -0
- package/build/{lib/utils.legacy.cjs → legacy/utils.cjs} +92 -93
- package/build/legacy/utils.cjs.map +1 -0
- package/build/legacy/utils.d.cts +3 -0
- package/build/legacy/utils.d.ts +3 -0
- package/build/{lib/utils.legacy.js → legacy/utils.js} +49 -72
- package/build/legacy/utils.js.map +1 -0
- package/build/modern/focusManager.cjs +91 -0
- package/build/modern/focusManager.cjs.map +1 -0
- package/build/modern/focusManager.d.cts +16 -0
- package/build/modern/focusManager.d.ts +16 -0
- package/build/modern/focusManager.js +66 -0
- package/build/modern/focusManager.js.map +1 -0
- package/build/modern/hydration.cjs +107 -0
- package/build/modern/hydration.cjs.map +1 -0
- package/build/modern/hydration.d.cts +35 -0
- package/build/modern/hydration.d.ts +35 -0
- package/build/modern/hydration.js +80 -0
- package/build/modern/hydration.js.map +1 -0
- package/build/modern/index.cjs +85 -0
- package/build/modern/index.cjs.map +1 -0
- package/build/modern/index.d.cts +9 -0
- package/build/modern/index.d.ts +9 -0
- package/build/modern/index.js +50 -0
- package/build/modern/index.js.map +1 -0
- package/build/modern/infiniteQueryBehavior.cjs +138 -0
- package/build/modern/infiniteQueryBehavior.cjs.map +1 -0
- package/build/modern/infiniteQueryBehavior.d.cts +15 -0
- package/build/modern/infiniteQueryBehavior.d.ts +15 -0
- package/build/{lib → modern}/infiniteQueryBehavior.js +46 -53
- package/build/modern/infiniteQueryBehavior.js.map +1 -0
- package/build/modern/infiniteQueryObserver.cjs +87 -0
- package/build/modern/infiniteQueryObserver.cjs.map +1 -0
- package/build/modern/infiniteQueryObserver.d.cts +19 -0
- package/build/modern/infiniteQueryObserver.d.ts +19 -0
- package/build/{lib → modern}/infiniteQueryObserver.js +23 -31
- package/build/modern/infiniteQueryObserver.js.map +1 -0
- package/build/modern/mutation.cjs +259 -0
- package/build/modern/mutation.cjs.map +1 -0
- package/build/modern/mutation.d.cts +3 -0
- package/build/modern/mutation.d.ts +3 -0
- package/build/{lib → modern}/mutation.js +86 -86
- package/build/modern/mutation.js.map +1 -0
- package/build/modern/mutationCache.cjs +103 -0
- package/build/modern/mutationCache.cjs.map +1 -0
- package/build/modern/mutationCache.d.cts +3 -0
- package/build/modern/mutationCache.d.ts +3 -0
- package/build/modern/mutationCache.js +79 -0
- package/build/modern/mutationCache.js.map +1 -0
- package/build/modern/mutationObserver.cjs +132 -0
- package/build/modern/mutationObserver.cjs.map +1 -0
- package/build/modern/mutationObserver.d.cts +3 -0
- package/build/modern/mutationObserver.d.ts +3 -0
- package/build/{lib → modern}/mutationObserver.js +44 -32
- package/build/modern/mutationObserver.js.map +1 -0
- package/build/modern/notifyManager.cjs +97 -0
- package/build/modern/notifyManager.cjs.map +1 -0
- package/build/modern/notifyManager.d.cts +20 -0
- package/build/modern/notifyManager.d.ts +20 -0
- package/build/{lib/notifyManager.legacy.js → modern/notifyManager.js} +14 -31
- package/build/modern/notifyManager.js.map +1 -0
- package/build/modern/onlineManager.cjs +82 -0
- package/build/modern/onlineManager.cjs.map +1 -0
- package/build/modern/onlineManager.d.cts +16 -0
- package/build/modern/onlineManager.d.ts +16 -0
- package/build/{lib → modern}/onlineManager.js +14 -17
- package/build/modern/onlineManager.js.map +1 -0
- package/build/modern/queriesObserver.cjs +202 -0
- package/build/modern/queriesObserver.cjs.map +1 -0
- package/build/modern/queriesObserver.d.cts +26 -0
- package/build/modern/queriesObserver.d.ts +26 -0
- package/build/{lib → modern}/queriesObserver.js +69 -50
- package/build/modern/queriesObserver.js.map +1 -0
- package/build/{lib → modern}/query.cjs +143 -186
- package/build/modern/query.cjs.map +1 -0
- package/build/modern/query.d.cts +3 -0
- package/build/modern/query.d.ts +3 -0
- package/build/{lib → modern}/query.js +110 -175
- package/build/modern/query.js.map +1 -0
- package/build/modern/queryCache.cjs +120 -0
- package/build/modern/queryCache.cjs.map +1 -0
- package/build/modern/queryCache.d.cts +3 -0
- package/build/modern/queryCache.d.ts +3 -0
- package/build/{lib → modern}/queryCache.js +21 -29
- package/build/modern/queryCache.js.map +1 -0
- package/build/modern/queryClient-4ba6364e.d.ts +916 -0
- package/build/modern/queryClient-d615ed9f.d.ts +916 -0
- package/build/modern/queryClient.cjs +284 -0
- package/build/modern/queryClient.cjs.map +1 -0
- package/build/modern/queryClient.d.cts +3 -0
- package/build/modern/queryClient.d.ts +3 -0
- package/build/{lib → modern}/queryClient.js +77 -94
- package/build/modern/queryClient.js.map +1 -0
- package/build/{lib → modern}/queryObserver.cjs +133 -149
- package/build/modern/queryObserver.cjs.map +1 -0
- package/build/modern/queryObserver.d.cts +3 -0
- package/build/modern/queryObserver.d.ts +3 -0
- package/build/{lib → modern}/queryObserver.js +107 -138
- package/build/modern/queryObserver.js.map +1 -0
- package/build/modern/removable.cjs +55 -0
- package/build/modern/removable.cjs.map +1 -0
- package/build/modern/removable.d.cts +11 -0
- package/build/modern/removable.d.ts +11 -0
- package/build/{lib → modern}/removable.js +10 -8
- package/build/modern/removable.js.map +1 -0
- package/build/{lib → modern}/retryer.cjs +50 -44
- package/build/modern/retryer.cjs.map +1 -0
- package/build/modern/retryer.d.cts +3 -0
- package/build/modern/retryer.d.ts +3 -0
- package/build/{lib → modern}/retryer.js +23 -39
- package/build/modern/retryer.js.map +1 -0
- package/build/modern/subscribable.cjs +49 -0
- package/build/modern/subscribable.cjs.map +1 -0
- package/build/modern/subscribable.d.cts +11 -0
- package/build/modern/subscribable.d.ts +11 -0
- package/build/{lib/subscribable.legacy.js → modern/subscribable.js} +5 -6
- package/build/modern/subscribable.js.map +1 -0
- package/build/modern/types.cjs +17 -0
- package/build/modern/types.cjs.map +1 -0
- package/build/modern/types.d.cts +3 -0
- package/build/modern/types.d.ts +3 -0
- package/build/modern/types.js +1 -0
- package/build/modern/types.js.map +1 -0
- package/build/{lib → modern}/utils.cjs +92 -93
- package/build/modern/utils.cjs.map +1 -0
- package/build/modern/utils.d.cts +3 -0
- package/build/modern/utils.d.ts +3 -0
- package/build/{lib → modern}/utils.js +49 -72
- package/build/modern/utils.js.map +1 -0
- package/package.json +15 -13
- package/build/lib/_virtual/_rollupPluginBabelHelpers.legacy.cjs +0 -16
- package/build/lib/_virtual/_rollupPluginBabelHelpers.legacy.cjs.map +0 -1
- package/build/lib/_virtual/_rollupPluginBabelHelpers.legacy.js +0 -13
- package/build/lib/_virtual/_rollupPluginBabelHelpers.legacy.js.map +0 -1
- package/build/lib/focusManager.cjs +0 -75
- package/build/lib/focusManager.cjs.map +0 -1
- package/build/lib/focusManager.d.ts.map +0 -1
- package/build/lib/focusManager.js +0 -72
- package/build/lib/focusManager.js.map +0 -1
- package/build/lib/focusManager.legacy.cjs +0 -91
- package/build/lib/focusManager.legacy.cjs.map +0 -1
- package/build/lib/focusManager.legacy.js +0 -88
- package/build/lib/focusManager.legacy.js.map +0 -1
- package/build/lib/hydration.cjs +0 -97
- package/build/lib/hydration.cjs.map +0 -1
- package/build/lib/hydration.d.ts +0 -35
- package/build/lib/hydration.d.ts.map +0 -1
- package/build/lib/hydration.js +0 -92
- package/build/lib/hydration.js.map +0 -1
- package/build/lib/hydration.legacy.cjs +0 -100
- package/build/lib/hydration.legacy.cjs.map +0 -1
- package/build/lib/hydration.legacy.js +0 -95
- package/build/lib/hydration.legacy.js.map +0 -1
- package/build/lib/index.cjs +0 -40
- package/build/lib/index.cjs.map +0 -1
- package/build/lib/index.d.ts +0 -22
- package/build/lib/index.d.ts.map +0 -1
- package/build/lib/index.js +0 -14
- package/build/lib/index.js.map +0 -1
- package/build/lib/index.legacy.cjs +0 -40
- package/build/lib/index.legacy.cjs.map +0 -1
- package/build/lib/index.legacy.js +0 -14
- package/build/lib/index.legacy.js.map +0 -1
- package/build/lib/infiniteQueryBehavior.cjs +0 -123
- package/build/lib/infiniteQueryBehavior.cjs.map +0 -1
- package/build/lib/infiniteQueryBehavior.d.ts +0 -12
- package/build/lib/infiniteQueryBehavior.d.ts.map +0 -1
- package/build/lib/infiniteQueryBehavior.js.map +0 -1
- package/build/lib/infiniteQueryBehavior.legacy.cjs +0 -125
- package/build/lib/infiniteQueryBehavior.legacy.cjs.map +0 -1
- package/build/lib/infiniteQueryBehavior.legacy.js +0 -121
- package/build/lib/infiniteQueryBehavior.legacy.js.map +0 -1
- package/build/lib/infiniteQueryObserver.cjs +0 -77
- package/build/lib/infiniteQueryObserver.cjs.map +0 -1
- package/build/lib/infiniteQueryObserver.d.ts.map +0 -1
- package/build/lib/infiniteQueryObserver.js.map +0 -1
- package/build/lib/infiniteQueryObserver.legacy.cjs +0 -78
- package/build/lib/infiniteQueryObserver.legacy.cjs.map +0 -1
- package/build/lib/infiniteQueryObserver.legacy.js.map +0 -1
- package/build/lib/mutation.cjs +0 -237
- package/build/lib/mutation.cjs.map +0 -1
- package/build/lib/mutation.d.ts +0 -64
- package/build/lib/mutation.d.ts.map +0 -1
- package/build/lib/mutation.js.map +0 -1
- package/build/lib/mutation.legacy.cjs +0 -262
- package/build/lib/mutation.legacy.cjs.map +0 -1
- package/build/lib/mutation.legacy.js +0 -259
- package/build/lib/mutation.legacy.js.map +0 -1
- package/build/lib/mutationCache.cjs +0 -85
- package/build/lib/mutationCache.cjs.map +0 -1
- package/build/lib/mutationCache.d.ts +0 -59
- package/build/lib/mutationCache.d.ts.map +0 -1
- package/build/lib/mutationCache.js +0 -83
- package/build/lib/mutationCache.js.map +0 -1
- package/build/lib/mutationCache.legacy.cjs +0 -98
- package/build/lib/mutationCache.legacy.cjs.map +0 -1
- package/build/lib/mutationCache.legacy.js +0 -96
- package/build/lib/mutationCache.legacy.js.map +0 -1
- package/build/lib/mutationObserver.cjs +0 -98
- package/build/lib/mutationObserver.cjs.map +0 -1
- package/build/lib/mutationObserver.d.ts +0 -19
- package/build/lib/mutationObserver.d.ts.map +0 -1
- package/build/lib/mutationObserver.js.map +0 -1
- package/build/lib/mutationObserver.legacy.cjs +0 -128
- package/build/lib/mutationObserver.legacy.cjs.map +0 -1
- package/build/lib/mutationObserver.legacy.js +0 -126
- package/build/lib/mutationObserver.legacy.js.map +0 -1
- package/build/lib/notifyManager.cjs +0 -92
- package/build/lib/notifyManager.cjs.map +0 -1
- package/build/lib/notifyManager.d.ts.map +0 -1
- package/build/lib/notifyManager.js.map +0 -1
- package/build/lib/notifyManager.legacy.cjs +0 -92
- package/build/lib/notifyManager.legacy.cjs.map +0 -1
- package/build/lib/notifyManager.legacy.js.map +0 -1
- package/build/lib/onlineManager.cjs +0 -63
- package/build/lib/onlineManager.cjs.map +0 -1
- package/build/lib/onlineManager.d.ts.map +0 -1
- package/build/lib/onlineManager.js.map +0 -1
- package/build/lib/onlineManager.legacy.cjs +0 -78
- package/build/lib/onlineManager.legacy.cjs.map +0 -1
- package/build/lib/onlineManager.legacy.js +0 -75
- package/build/lib/onlineManager.legacy.js.map +0 -1
- package/build/lib/queriesObserver.cjs +0 -161
- package/build/lib/queriesObserver.cjs.map +0 -1
- package/build/lib/queriesObserver.d.ts.map +0 -1
- package/build/lib/queriesObserver.js.map +0 -1
- package/build/lib/queriesObserver.legacy.cjs +0 -207
- package/build/lib/queriesObserver.legacy.cjs.map +0 -1
- package/build/lib/queriesObserver.legacy.js +0 -205
- package/build/lib/queriesObserver.legacy.js.map +0 -1
- package/build/lib/query.cjs.map +0 -1
- package/build/lib/query.d.ts +0 -115
- package/build/lib/query.d.ts.map +0 -1
- package/build/lib/query.js.map +0 -1
- package/build/lib/query.legacy.cjs +0 -471
- package/build/lib/query.legacy.cjs.map +0 -1
- package/build/lib/query.legacy.js +0 -469
- package/build/lib/query.legacy.js.map +0 -1
- package/build/lib/queryCache.cjs +0 -106
- package/build/lib/queryCache.cjs.map +0 -1
- package/build/lib/queryCache.d.ts +0 -71
- package/build/lib/queryCache.d.ts.map +0 -1
- package/build/lib/queryCache.js.map +0 -1
- package/build/lib/queryCache.legacy.cjs +0 -111
- package/build/lib/queryCache.legacy.cjs.map +0 -1
- package/build/lib/queryCache.legacy.js +0 -109
- package/build/lib/queryCache.legacy.js.map +0 -1
- package/build/lib/queryClient.cjs +0 -285
- package/build/lib/queryClient.cjs.map +0 -1
- package/build/lib/queryClient.d.ts +0 -41
- package/build/lib/queryClient.d.ts.map +0 -1
- package/build/lib/queryClient.js.map +0 -1
- package/build/lib/queryClient.legacy.cjs +0 -322
- package/build/lib/queryClient.legacy.cjs.map +0 -1
- package/build/lib/queryClient.legacy.js +0 -320
- package/build/lib/queryClient.legacy.js.map +0 -1
- package/build/lib/queryObserver.cjs.map +0 -1
- package/build/lib/queryObserver.d.ts +0 -35
- package/build/lib/queryObserver.d.ts.map +0 -1
- package/build/lib/queryObserver.js.map +0 -1
- package/build/lib/queryObserver.legacy.cjs +0 -561
- package/build/lib/queryObserver.legacy.cjs.map +0 -1
- package/build/lib/queryObserver.legacy.js +0 -559
- package/build/lib/queryObserver.legacy.js.map +0 -1
- package/build/lib/removable.cjs +0 -31
- package/build/lib/removable.cjs.map +0 -1
- package/build/lib/removable.d.ts.map +0 -1
- package/build/lib/removable.js.map +0 -1
- package/build/lib/removable.legacy.cjs +0 -38
- package/build/lib/removable.legacy.cjs.map +0 -1
- package/build/lib/removable.legacy.js +0 -36
- package/build/lib/removable.legacy.js.map +0 -1
- package/build/lib/retryer.cjs.map +0 -1
- package/build/lib/retryer.d.ts +0 -34
- package/build/lib/retryer.d.ts.map +0 -1
- package/build/lib/retryer.js.map +0 -1
- package/build/lib/retryer.legacy.cjs +0 -158
- package/build/lib/retryer.legacy.cjs.map +0 -1
- package/build/lib/retryer.legacy.js.map +0 -1
- package/build/lib/subscribable.cjs +0 -28
- package/build/lib/subscribable.cjs.map +0 -1
- package/build/lib/subscribable.d.ts.map +0 -1
- package/build/lib/subscribable.js.map +0 -1
- package/build/lib/subscribable.legacy.cjs +0 -28
- package/build/lib/subscribable.legacy.cjs.map +0 -1
- package/build/lib/subscribable.legacy.js.map +0 -1
- package/build/lib/tests/focusManager.test.d.ts +0 -2
- package/build/lib/tests/focusManager.test.d.ts.map +0 -1
- package/build/lib/tests/hydration.test.d.ts +0 -2
- package/build/lib/tests/hydration.test.d.ts.map +0 -1
- package/build/lib/tests/infiniteQueryBehavior.test.d.ts +0 -2
- package/build/lib/tests/infiniteQueryBehavior.test.d.ts.map +0 -1
- package/build/lib/tests/infiniteQueryObserver.test.d.ts +0 -2
- package/build/lib/tests/infiniteQueryObserver.test.d.ts.map +0 -1
- package/build/lib/tests/mutationCache.test.d.ts +0 -2
- package/build/lib/tests/mutationCache.test.d.ts.map +0 -1
- package/build/lib/tests/mutationObserver.test.d.ts +0 -2
- package/build/lib/tests/mutationObserver.test.d.ts.map +0 -1
- package/build/lib/tests/mutations.test.d.ts +0 -2
- package/build/lib/tests/mutations.test.d.ts.map +0 -1
- package/build/lib/tests/notifyManager.test.d.ts +0 -2
- package/build/lib/tests/notifyManager.test.d.ts.map +0 -1
- package/build/lib/tests/onlineManager.test.d.ts +0 -2
- package/build/lib/tests/onlineManager.test.d.ts.map +0 -1
- package/build/lib/tests/queriesObserver.test.d.ts +0 -2
- package/build/lib/tests/queriesObserver.test.d.ts.map +0 -1
- package/build/lib/tests/query.test.d.ts +0 -2
- package/build/lib/tests/query.test.d.ts.map +0 -1
- package/build/lib/tests/queryCache.test.d.ts +0 -2
- package/build/lib/tests/queryCache.test.d.ts.map +0 -1
- package/build/lib/tests/queryClient.test.d.ts +0 -2
- package/build/lib/tests/queryClient.test.d.ts.map +0 -1
- package/build/lib/tests/queryObserver.test.d.ts +0 -2
- package/build/lib/tests/queryObserver.test.d.ts.map +0 -1
- package/build/lib/tests/utils.d.ts +0 -17
- package/build/lib/tests/utils.d.ts.map +0 -1
- package/build/lib/tests/utils.test.d.ts +0 -2
- package/build/lib/tests/utils.test.d.ts.map +0 -1
- package/build/lib/types.d.ts +0 -437
- package/build/lib/types.d.ts.map +0 -1
- package/build/lib/utils.cjs.map +0 -1
- package/build/lib/utils.d.ts +0 -90
- package/build/lib/utils.d.ts.map +0 -1
- package/build/lib/utils.js.map +0 -1
- package/build/lib/utils.legacy.cjs.map +0 -1
- package/build/lib/utils.legacy.js.map +0 -1
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
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
|
+
var __accessCheck = (obj, member, msg) => {
|
|
20
|
+
if (!member.has(obj))
|
|
21
|
+
throw TypeError("Cannot " + msg);
|
|
22
|
+
};
|
|
23
|
+
var __privateGet = (obj, member, getter) => {
|
|
24
|
+
__accessCheck(obj, member, "read from private field");
|
|
25
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
26
|
+
};
|
|
27
|
+
var __privateAdd = (obj, member, value) => {
|
|
28
|
+
if (member.has(obj))
|
|
29
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
30
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
31
|
+
};
|
|
32
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
33
|
+
__accessCheck(obj, member, "write to private field");
|
|
34
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
35
|
+
return value;
|
|
36
|
+
};
|
|
37
|
+
var __privateWrapper = (obj, member, setter, getter) => ({
|
|
38
|
+
set _(value) {
|
|
39
|
+
__privateSet(obj, member, value, setter);
|
|
40
|
+
},
|
|
41
|
+
get _() {
|
|
42
|
+
return __privateGet(obj, member, getter);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
var mutationCache_exports = {};
|
|
46
|
+
__export(mutationCache_exports, {
|
|
47
|
+
MutationCache: () => MutationCache
|
|
48
|
+
});
|
|
49
|
+
module.exports = __toCommonJS(mutationCache_exports);
|
|
50
|
+
var import_notifyManager = require("./notifyManager");
|
|
51
|
+
var import_mutation = require("./mutation");
|
|
52
|
+
var import_utils = require("./utils");
|
|
53
|
+
var import_subscribable = require("./subscribable");
|
|
54
|
+
var _mutations, _mutationId, _resuming;
|
|
55
|
+
class MutationCache extends import_subscribable.Subscribable {
|
|
56
|
+
constructor(config = {}) {
|
|
57
|
+
super();
|
|
58
|
+
this.config = config;
|
|
59
|
+
__privateAdd(this, _mutations, void 0);
|
|
60
|
+
__privateAdd(this, _mutationId, void 0);
|
|
61
|
+
__privateAdd(this, _resuming, void 0);
|
|
62
|
+
__privateSet(this, _mutations, []);
|
|
63
|
+
__privateSet(this, _mutationId, 0);
|
|
64
|
+
}
|
|
65
|
+
build(client, options, state) {
|
|
66
|
+
const mutation = new import_mutation.Mutation({
|
|
67
|
+
mutationCache: this,
|
|
68
|
+
mutationId: ++__privateWrapper(this, _mutationId)._,
|
|
69
|
+
options: client.defaultMutationOptions(options),
|
|
70
|
+
state
|
|
71
|
+
});
|
|
72
|
+
this.add(mutation);
|
|
73
|
+
return mutation;
|
|
74
|
+
}
|
|
75
|
+
add(mutation) {
|
|
76
|
+
__privateGet(this, _mutations).push(mutation);
|
|
77
|
+
this.notify({ type: "added", mutation });
|
|
78
|
+
}
|
|
79
|
+
remove(mutation) {
|
|
80
|
+
__privateSet(this, _mutations, __privateGet(this, _mutations).filter((x) => x !== mutation));
|
|
81
|
+
this.notify({ type: "removed", mutation });
|
|
82
|
+
}
|
|
83
|
+
clear() {
|
|
84
|
+
import_notifyManager.notifyManager.batch(() => {
|
|
85
|
+
__privateGet(this, _mutations).forEach((mutation) => {
|
|
86
|
+
this.remove(mutation);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
getAll() {
|
|
91
|
+
return __privateGet(this, _mutations);
|
|
92
|
+
}
|
|
93
|
+
find(filters) {
|
|
94
|
+
const defaultedFilters = { exact: true, ...filters };
|
|
95
|
+
return __privateGet(this, _mutations).find(
|
|
96
|
+
(mutation) => (0, import_utils.matchMutation)(defaultedFilters, mutation)
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
findAll(filters = {}) {
|
|
100
|
+
return __privateGet(this, _mutations).filter(
|
|
101
|
+
(mutation) => (0, import_utils.matchMutation)(filters, mutation)
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
notify(event) {
|
|
105
|
+
import_notifyManager.notifyManager.batch(() => {
|
|
106
|
+
this.listeners.forEach((listener) => {
|
|
107
|
+
listener(event);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
resumePausedMutations() {
|
|
112
|
+
__privateSet(this, _resuming, (__privateGet(this, _resuming) ?? Promise.resolve()).then(() => {
|
|
113
|
+
const pausedMutations = __privateGet(this, _mutations).filter((x) => x.state.isPaused);
|
|
114
|
+
return import_notifyManager.notifyManager.batch(
|
|
115
|
+
() => pausedMutations.reduce(
|
|
116
|
+
(promise, mutation) => promise.then(() => mutation.continue().catch(import_utils.noop)),
|
|
117
|
+
Promise.resolve()
|
|
118
|
+
)
|
|
119
|
+
);
|
|
120
|
+
}).then(() => {
|
|
121
|
+
__privateSet(this, _resuming, void 0);
|
|
122
|
+
}));
|
|
123
|
+
return __privateGet(this, _resuming);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
_mutations = new WeakMap();
|
|
127
|
+
_mutationId = new WeakMap();
|
|
128
|
+
_resuming = new WeakMap();
|
|
129
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
130
|
+
0 && (module.exports = {
|
|
131
|
+
MutationCache
|
|
132
|
+
});
|
|
133
|
+
//# sourceMappingURL=mutationCache.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/mutationCache.ts"],"sourcesContent":["import { notifyManager } from './notifyManager'\nimport { Mutation } from './mutation'\nimport { matchMutation, noop } from './utils'\nimport { Subscribable } from './subscribable'\nimport type { MutationObserver } from './mutationObserver'\nimport type { DefaultError, MutationOptions, NotifyEvent } from './types'\nimport type { QueryClient } from './queryClient'\nimport type { Action, MutationState } from './mutation'\nimport type { MutationFilters } from './utils'\n\n// TYPES\n\ninterface MutationCacheConfig {\n onError?: (\n error: DefaultError,\n variables: unknown,\n context: unknown,\n mutation: Mutation<unknown, unknown, unknown>,\n ) => Promise<unknown> | unknown\n onSuccess?: (\n data: unknown,\n variables: unknown,\n context: unknown,\n mutation: Mutation<unknown, unknown, unknown>,\n ) => Promise<unknown> | unknown\n onMutate?: (\n variables: unknown,\n mutation: Mutation<unknown, unknown, unknown>,\n ) => Promise<unknown> | unknown\n onSettled?: (\n data: unknown | undefined,\n error: DefaultError | null,\n variables: unknown,\n context: unknown,\n mutation: Mutation<unknown, unknown, unknown>,\n ) => Promise<unknown> | unknown\n}\n\ninterface NotifyEventMutationAdded extends NotifyEvent {\n type: 'added'\n mutation: Mutation<any, any, any, any>\n}\ninterface NotifyEventMutationRemoved extends NotifyEvent {\n type: 'removed'\n mutation: Mutation<any, any, any, any>\n}\n\ninterface NotifyEventMutationObserverAdded extends NotifyEvent {\n type: 'observerAdded'\n mutation: Mutation<any, any, any, any>\n observer: MutationObserver<any, any, any>\n}\n\ninterface NotifyEventMutationObserverRemoved extends NotifyEvent {\n type: 'observerRemoved'\n mutation: Mutation<any, any, any, any>\n observer: MutationObserver<any, any, any>\n}\n\ninterface NotifyEventMutationObserverOptionsUpdated extends NotifyEvent {\n type: 'observerOptionsUpdated'\n mutation?: Mutation<any, any, any, any>\n observer: MutationObserver<any, any, any, any>\n}\n\ninterface NotifyEventMutationUpdated extends NotifyEvent {\n type: 'updated'\n mutation: Mutation<any, any, any, any>\n action: Action<any, any, any, any>\n}\n\ntype MutationCacheNotifyEvent =\n | NotifyEventMutationAdded\n | NotifyEventMutationRemoved\n | NotifyEventMutationObserverAdded\n | NotifyEventMutationObserverRemoved\n | NotifyEventMutationObserverOptionsUpdated\n | NotifyEventMutationUpdated\n\ntype MutationCacheListener = (event: MutationCacheNotifyEvent) => void\n\n// CLASS\n\nexport class MutationCache extends Subscribable<MutationCacheListener> {\n #mutations: Mutation<any, any, any, any>[]\n #mutationId: number\n #resuming: Promise<unknown> | undefined\n\n constructor(public config: MutationCacheConfig = {}) {\n super()\n this.#mutations = []\n this.#mutationId = 0\n }\n\n build<TData, TError, TVariables, TContext>(\n client: QueryClient,\n options: MutationOptions<TData, TError, TVariables, TContext>,\n state?: MutationState<TData, TError, TVariables, TContext>,\n ): Mutation<TData, TError, TVariables, TContext> {\n const mutation = new Mutation({\n mutationCache: this,\n mutationId: ++this.#mutationId,\n options: client.defaultMutationOptions(options),\n state,\n })\n\n this.add(mutation)\n\n return mutation\n }\n\n add(mutation: Mutation<any, any, any, any>): void {\n this.#mutations.push(mutation)\n this.notify({ type: 'added', mutation })\n }\n\n remove(mutation: Mutation<any, any, any, any>): void {\n this.#mutations = this.#mutations.filter((x) => x !== mutation)\n this.notify({ type: 'removed', mutation })\n }\n\n clear(): void {\n notifyManager.batch(() => {\n this.#mutations.forEach((mutation) => {\n this.remove(mutation)\n })\n })\n }\n\n getAll(): Mutation[] {\n return this.#mutations\n }\n\n find<\n TData = unknown,\n TError = DefaultError,\n TVariables = any,\n TContext = unknown,\n >(\n filters: MutationFilters,\n ): Mutation<TData, TError, TVariables, TContext> | undefined {\n const defaultedFilters = { exact: true, ...filters }\n\n return this.#mutations.find((mutation) =>\n matchMutation(defaultedFilters, mutation),\n )\n }\n\n findAll(filters: MutationFilters = {}): Mutation[] {\n return this.#mutations.filter((mutation) =>\n matchMutation(filters, mutation),\n )\n }\n\n notify(event: MutationCacheNotifyEvent) {\n notifyManager.batch(() => {\n this.listeners.forEach((listener) => {\n listener(event)\n })\n })\n }\n\n resumePausedMutations(): Promise<unknown> {\n this.#resuming = (this.#resuming ?? Promise.resolve())\n .then(() => {\n const pausedMutations = this.#mutations.filter((x) => x.state.isPaused)\n return notifyManager.batch(() =>\n pausedMutations.reduce(\n (promise, mutation) =>\n promise.then(() => mutation.continue().catch(noop)),\n Promise.resolve() as Promise<unknown>,\n ),\n )\n })\n .then(() => {\n this.#resuming = undefined\n })\n\n return this.#resuming\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAA8B;AAC9B,sBAAyB;AACzB,mBAAoC;AACpC,0BAA6B;AAH7B;AAmFO,MAAM,sBAAsB,iCAAoC;AAAA,EAKrE,YAAmB,SAA8B,CAAC,GAAG;AACnD,UAAM;AADW;AAJnB;AACA;AACA;AAIE,uBAAK,YAAa,CAAC;AACnB,uBAAK,aAAc;AAAA,EACrB;AAAA,EAEA,MACE,QACA,SACA,OAC+C;AAC/C,UAAM,WAAW,IAAI,yBAAS;AAAA,MAC5B,eAAe;AAAA,MACf,YAAmB,EAAL,uBAAK,aAAL;AAAA,MACd,SAAS,OAAO,uBAAuB,OAAO;AAAA,MAC9C;AAAA,IACF,CAAC;AAED,SAAK,IAAI,QAAQ;AAEjB,WAAO;AAAA,EACT;AAAA,EAEA,IAAI,UAA8C;AAChD,uBAAK,YAAW,KAAK,QAAQ;AAC7B,SAAK,OAAO,EAAE,MAAM,SAAS,SAAS,CAAC;AAAA,EACzC;AAAA,EAEA,OAAO,UAA8C;AACnD,uBAAK,YAAa,mBAAK,YAAW,OAAO,CAAC,MAAM,MAAM,QAAQ;AAC9D,SAAK,OAAO,EAAE,MAAM,WAAW,SAAS,CAAC;AAAA,EAC3C;AAAA,EAEA,QAAc;AACZ,uCAAc,MAAM,MAAM;AACxB,yBAAK,YAAW,QAAQ,CAAC,aAAa;AACpC,aAAK,OAAO,QAAQ;AAAA,MACtB,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAAA,EAEA,SAAqB;AACnB,WAAO,mBAAK;AAAA,EACd;AAAA,EAEA,KAME,SAC2D;AAC3D,UAAM,mBAAmB,EAAE,OAAO,MAAM,GAAG,QAAQ;AAEnD,WAAO,mBAAK,YAAW;AAAA,MAAK,CAAC,iBAC3B,4BAAc,kBAAkB,QAAQ;AAAA,IAC1C;AAAA,EACF;AAAA,EAEA,QAAQ,UAA2B,CAAC,GAAe;AACjD,WAAO,mBAAK,YAAW;AAAA,MAAO,CAAC,iBAC7B,4BAAc,SAAS,QAAQ;AAAA,IACjC;AAAA,EACF;AAAA,EAEA,OAAO,OAAiC;AACtC,uCAAc,MAAM,MAAM;AACxB,WAAK,UAAU,QAAQ,CAAC,aAAa;AACnC,iBAAS,KAAK;AAAA,MAChB,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAAA,EAEA,wBAA0C;AACxC,uBAAK,YAAa,mBAAK,cAAa,QAAQ,QAAQ,GACjD,KAAK,MAAM;AACV,YAAM,kBAAkB,mBAAK,YAAW,OAAO,CAAC,MAAM,EAAE,MAAM,QAAQ;AACtE,aAAO,mCAAc;AAAA,QAAM,MACzB,gBAAgB;AAAA,UACd,CAAC,SAAS,aACR,QAAQ,KAAK,MAAM,SAAS,SAAS,EAAE,MAAM,iBAAI,CAAC;AAAA,UACpD,QAAQ,QAAQ;AAAA,QAClB;AAAA,MACF;AAAA,IACF,CAAC,EACA,KAAK,MAAM;AACV,yBAAK,WAAY;AAAA,IACnB,CAAC;AAEH,WAAO,mBAAK;AAAA,EACd;AACF;AAhGE;AACA;AACA;","names":[]}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
var __accessCheck = (obj, member, msg) => {
|
|
2
|
+
if (!member.has(obj))
|
|
3
|
+
throw TypeError("Cannot " + msg);
|
|
4
|
+
};
|
|
5
|
+
var __privateGet = (obj, member, getter) => {
|
|
6
|
+
__accessCheck(obj, member, "read from private field");
|
|
7
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
8
|
+
};
|
|
9
|
+
var __privateAdd = (obj, member, value) => {
|
|
10
|
+
if (member.has(obj))
|
|
11
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
12
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
13
|
+
};
|
|
14
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
15
|
+
__accessCheck(obj, member, "write to private field");
|
|
16
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
17
|
+
return value;
|
|
18
|
+
};
|
|
19
|
+
var __privateWrapper = (obj, member, setter, getter) => ({
|
|
20
|
+
set _(value) {
|
|
21
|
+
__privateSet(obj, member, value, setter);
|
|
22
|
+
},
|
|
23
|
+
get _() {
|
|
24
|
+
return __privateGet(obj, member, getter);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
var _mutations, _mutationId, _resuming;
|
|
28
|
+
import { notifyManager } from "./notifyManager";
|
|
29
|
+
import { Mutation } from "./mutation";
|
|
30
|
+
import { matchMutation, noop } from "./utils";
|
|
31
|
+
import { Subscribable } from "./subscribable";
|
|
32
|
+
class MutationCache extends Subscribable {
|
|
33
|
+
constructor(config = {}) {
|
|
34
|
+
super();
|
|
35
|
+
this.config = config;
|
|
36
|
+
__privateAdd(this, _mutations, void 0);
|
|
37
|
+
__privateAdd(this, _mutationId, void 0);
|
|
38
|
+
__privateAdd(this, _resuming, void 0);
|
|
39
|
+
__privateSet(this, _mutations, []);
|
|
40
|
+
__privateSet(this, _mutationId, 0);
|
|
41
|
+
}
|
|
42
|
+
build(client, options, state) {
|
|
43
|
+
const mutation = new Mutation({
|
|
44
|
+
mutationCache: this,
|
|
45
|
+
mutationId: ++__privateWrapper(this, _mutationId)._,
|
|
46
|
+
options: client.defaultMutationOptions(options),
|
|
47
|
+
state
|
|
48
|
+
});
|
|
49
|
+
this.add(mutation);
|
|
50
|
+
return mutation;
|
|
51
|
+
}
|
|
52
|
+
add(mutation) {
|
|
53
|
+
__privateGet(this, _mutations).push(mutation);
|
|
54
|
+
this.notify({ type: "added", mutation });
|
|
55
|
+
}
|
|
56
|
+
remove(mutation) {
|
|
57
|
+
__privateSet(this, _mutations, __privateGet(this, _mutations).filter((x) => x !== mutation));
|
|
58
|
+
this.notify({ type: "removed", mutation });
|
|
59
|
+
}
|
|
60
|
+
clear() {
|
|
61
|
+
notifyManager.batch(() => {
|
|
62
|
+
__privateGet(this, _mutations).forEach((mutation) => {
|
|
63
|
+
this.remove(mutation);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
getAll() {
|
|
68
|
+
return __privateGet(this, _mutations);
|
|
69
|
+
}
|
|
70
|
+
find(filters) {
|
|
71
|
+
const defaultedFilters = { exact: true, ...filters };
|
|
72
|
+
return __privateGet(this, _mutations).find(
|
|
73
|
+
(mutation) => matchMutation(defaultedFilters, mutation)
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
findAll(filters = {}) {
|
|
77
|
+
return __privateGet(this, _mutations).filter(
|
|
78
|
+
(mutation) => matchMutation(filters, mutation)
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
notify(event) {
|
|
82
|
+
notifyManager.batch(() => {
|
|
83
|
+
this.listeners.forEach((listener) => {
|
|
84
|
+
listener(event);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
resumePausedMutations() {
|
|
89
|
+
__privateSet(this, _resuming, (__privateGet(this, _resuming) ?? Promise.resolve()).then(() => {
|
|
90
|
+
const pausedMutations = __privateGet(this, _mutations).filter((x) => x.state.isPaused);
|
|
91
|
+
return notifyManager.batch(
|
|
92
|
+
() => pausedMutations.reduce(
|
|
93
|
+
(promise, mutation) => promise.then(() => mutation.continue().catch(noop)),
|
|
94
|
+
Promise.resolve()
|
|
95
|
+
)
|
|
96
|
+
);
|
|
97
|
+
}).then(() => {
|
|
98
|
+
__privateSet(this, _resuming, void 0);
|
|
99
|
+
}));
|
|
100
|
+
return __privateGet(this, _resuming);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
_mutations = new WeakMap();
|
|
104
|
+
_mutationId = new WeakMap();
|
|
105
|
+
_resuming = new WeakMap();
|
|
106
|
+
export {
|
|
107
|
+
MutationCache
|
|
108
|
+
};
|
|
109
|
+
//# sourceMappingURL=mutationCache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/mutationCache.ts"],"sourcesContent":["import { notifyManager } from './notifyManager'\nimport { Mutation } from './mutation'\nimport { matchMutation, noop } from './utils'\nimport { Subscribable } from './subscribable'\nimport type { MutationObserver } from './mutationObserver'\nimport type { DefaultError, MutationOptions, NotifyEvent } from './types'\nimport type { QueryClient } from './queryClient'\nimport type { Action, MutationState } from './mutation'\nimport type { MutationFilters } from './utils'\n\n// TYPES\n\ninterface MutationCacheConfig {\n onError?: (\n error: DefaultError,\n variables: unknown,\n context: unknown,\n mutation: Mutation<unknown, unknown, unknown>,\n ) => Promise<unknown> | unknown\n onSuccess?: (\n data: unknown,\n variables: unknown,\n context: unknown,\n mutation: Mutation<unknown, unknown, unknown>,\n ) => Promise<unknown> | unknown\n onMutate?: (\n variables: unknown,\n mutation: Mutation<unknown, unknown, unknown>,\n ) => Promise<unknown> | unknown\n onSettled?: (\n data: unknown | undefined,\n error: DefaultError | null,\n variables: unknown,\n context: unknown,\n mutation: Mutation<unknown, unknown, unknown>,\n ) => Promise<unknown> | unknown\n}\n\ninterface NotifyEventMutationAdded extends NotifyEvent {\n type: 'added'\n mutation: Mutation<any, any, any, any>\n}\ninterface NotifyEventMutationRemoved extends NotifyEvent {\n type: 'removed'\n mutation: Mutation<any, any, any, any>\n}\n\ninterface NotifyEventMutationObserverAdded extends NotifyEvent {\n type: 'observerAdded'\n mutation: Mutation<any, any, any, any>\n observer: MutationObserver<any, any, any>\n}\n\ninterface NotifyEventMutationObserverRemoved extends NotifyEvent {\n type: 'observerRemoved'\n mutation: Mutation<any, any, any, any>\n observer: MutationObserver<any, any, any>\n}\n\ninterface NotifyEventMutationObserverOptionsUpdated extends NotifyEvent {\n type: 'observerOptionsUpdated'\n mutation?: Mutation<any, any, any, any>\n observer: MutationObserver<any, any, any, any>\n}\n\ninterface NotifyEventMutationUpdated extends NotifyEvent {\n type: 'updated'\n mutation: Mutation<any, any, any, any>\n action: Action<any, any, any, any>\n}\n\ntype MutationCacheNotifyEvent =\n | NotifyEventMutationAdded\n | NotifyEventMutationRemoved\n | NotifyEventMutationObserverAdded\n | NotifyEventMutationObserverRemoved\n | NotifyEventMutationObserverOptionsUpdated\n | NotifyEventMutationUpdated\n\ntype MutationCacheListener = (event: MutationCacheNotifyEvent) => void\n\n// CLASS\n\nexport class MutationCache extends Subscribable<MutationCacheListener> {\n #mutations: Mutation<any, any, any, any>[]\n #mutationId: number\n #resuming: Promise<unknown> | undefined\n\n constructor(public config: MutationCacheConfig = {}) {\n super()\n this.#mutations = []\n this.#mutationId = 0\n }\n\n build<TData, TError, TVariables, TContext>(\n client: QueryClient,\n options: MutationOptions<TData, TError, TVariables, TContext>,\n state?: MutationState<TData, TError, TVariables, TContext>,\n ): Mutation<TData, TError, TVariables, TContext> {\n const mutation = new Mutation({\n mutationCache: this,\n mutationId: ++this.#mutationId,\n options: client.defaultMutationOptions(options),\n state,\n })\n\n this.add(mutation)\n\n return mutation\n }\n\n add(mutation: Mutation<any, any, any, any>): void {\n this.#mutations.push(mutation)\n this.notify({ type: 'added', mutation })\n }\n\n remove(mutation: Mutation<any, any, any, any>): void {\n this.#mutations = this.#mutations.filter((x) => x !== mutation)\n this.notify({ type: 'removed', mutation })\n }\n\n clear(): void {\n notifyManager.batch(() => {\n this.#mutations.forEach((mutation) => {\n this.remove(mutation)\n })\n })\n }\n\n getAll(): Mutation[] {\n return this.#mutations\n }\n\n find<\n TData = unknown,\n TError = DefaultError,\n TVariables = any,\n TContext = unknown,\n >(\n filters: MutationFilters,\n ): Mutation<TData, TError, TVariables, TContext> | undefined {\n const defaultedFilters = { exact: true, ...filters }\n\n return this.#mutations.find((mutation) =>\n matchMutation(defaultedFilters, mutation),\n )\n }\n\n findAll(filters: MutationFilters = {}): Mutation[] {\n return this.#mutations.filter((mutation) =>\n matchMutation(filters, mutation),\n )\n }\n\n notify(event: MutationCacheNotifyEvent) {\n notifyManager.batch(() => {\n this.listeners.forEach((listener) => {\n listener(event)\n })\n })\n }\n\n resumePausedMutations(): Promise<unknown> {\n this.#resuming = (this.#resuming ?? Promise.resolve())\n .then(() => {\n const pausedMutations = this.#mutations.filter((x) => x.state.isPaused)\n return notifyManager.batch(() =>\n pausedMutations.reduce(\n (promise, mutation) =>\n promise.then(() => mutation.continue().catch(noop)),\n Promise.resolve() as Promise<unknown>,\n ),\n )\n })\n .then(() => {\n this.#resuming = undefined\n })\n\n return this.#resuming\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AACzB,SAAS,eAAe,YAAY;AACpC,SAAS,oBAAoB;AAgFtB,MAAM,sBAAsB,aAAoC;AAAA,EAKrE,YAAmB,SAA8B,CAAC,GAAG;AACnD,UAAM;AADW;AAJnB;AACA;AACA;AAIE,uBAAK,YAAa,CAAC;AACnB,uBAAK,aAAc;AAAA,EACrB;AAAA,EAEA,MACE,QACA,SACA,OAC+C;AAC/C,UAAM,WAAW,IAAI,SAAS;AAAA,MAC5B,eAAe;AAAA,MACf,YAAmB,EAAL,uBAAK,aAAL;AAAA,MACd,SAAS,OAAO,uBAAuB,OAAO;AAAA,MAC9C;AAAA,IACF,CAAC;AAED,SAAK,IAAI,QAAQ;AAEjB,WAAO;AAAA,EACT;AAAA,EAEA,IAAI,UAA8C;AAChD,uBAAK,YAAW,KAAK,QAAQ;AAC7B,SAAK,OAAO,EAAE,MAAM,SAAS,SAAS,CAAC;AAAA,EACzC;AAAA,EAEA,OAAO,UAA8C;AACnD,uBAAK,YAAa,mBAAK,YAAW,OAAO,CAAC,MAAM,MAAM,QAAQ;AAC9D,SAAK,OAAO,EAAE,MAAM,WAAW,SAAS,CAAC;AAAA,EAC3C;AAAA,EAEA,QAAc;AACZ,kBA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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
|
+
var __accessCheck = (obj, member, msg) => {
|
|
20
|
+
if (!member.has(obj))
|
|
21
|
+
throw TypeError("Cannot " + msg);
|
|
22
|
+
};
|
|
23
|
+
var __privateGet = (obj, member, getter) => {
|
|
24
|
+
__accessCheck(obj, member, "read from private field");
|
|
25
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
26
|
+
};
|
|
27
|
+
var __privateAdd = (obj, member, value) => {
|
|
28
|
+
if (member.has(obj))
|
|
29
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
30
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
31
|
+
};
|
|
32
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
33
|
+
__accessCheck(obj, member, "write to private field");
|
|
34
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
35
|
+
return value;
|
|
36
|
+
};
|
|
37
|
+
var __privateMethod = (obj, member, method) => {
|
|
38
|
+
__accessCheck(obj, member, "access private method");
|
|
39
|
+
return method;
|
|
40
|
+
};
|
|
41
|
+
var mutationObserver_exports = {};
|
|
42
|
+
__export(mutationObserver_exports, {
|
|
43
|
+
MutationObserver: () => MutationObserver
|
|
44
|
+
});
|
|
45
|
+
module.exports = __toCommonJS(mutationObserver_exports);
|
|
46
|
+
var import_mutation = require("./mutation");
|
|
47
|
+
var import_notifyManager = require("./notifyManager");
|
|
48
|
+
var import_subscribable = require("./subscribable");
|
|
49
|
+
var import_utils = require("./utils");
|
|
50
|
+
var _client, _currentResult, _currentMutation, _mutateOptions, _updateResult, updateResult_fn, _notify, notify_fn;
|
|
51
|
+
class MutationObserver extends import_subscribable.Subscribable {
|
|
52
|
+
constructor(client, options) {
|
|
53
|
+
super();
|
|
54
|
+
__privateAdd(this, _updateResult);
|
|
55
|
+
__privateAdd(this, _notify);
|
|
56
|
+
__privateAdd(this, _client, void 0);
|
|
57
|
+
__privateAdd(this, _currentResult, void 0);
|
|
58
|
+
__privateAdd(this, _currentMutation, void 0);
|
|
59
|
+
__privateAdd(this, _mutateOptions, void 0);
|
|
60
|
+
__privateSet(this, _client, client);
|
|
61
|
+
this.setOptions(options);
|
|
62
|
+
this.bindMethods();
|
|
63
|
+
__privateMethod(this, _updateResult, updateResult_fn).call(this);
|
|
64
|
+
}
|
|
65
|
+
bindMethods() {
|
|
66
|
+
this.mutate = this.mutate.bind(this);
|
|
67
|
+
this.reset = this.reset.bind(this);
|
|
68
|
+
}
|
|
69
|
+
setOptions(options) {
|
|
70
|
+
var _a;
|
|
71
|
+
const prevOptions = this.options;
|
|
72
|
+
this.options = __privateGet(this, _client).defaultMutationOptions(options);
|
|
73
|
+
if (!(0, import_utils.shallowEqualObjects)(prevOptions, this.options)) {
|
|
74
|
+
__privateGet(this, _client).getMutationCache().notify({
|
|
75
|
+
type: "observerOptionsUpdated",
|
|
76
|
+
mutation: __privateGet(this, _currentMutation),
|
|
77
|
+
observer: this
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
(_a = __privateGet(this, _currentMutation)) == null ? void 0 : _a.setOptions(this.options);
|
|
81
|
+
}
|
|
82
|
+
onUnsubscribe() {
|
|
83
|
+
var _a;
|
|
84
|
+
if (!this.hasListeners()) {
|
|
85
|
+
(_a = __privateGet(this, _currentMutation)) == null ? void 0 : _a.removeObserver(this);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
onMutationUpdate(action) {
|
|
89
|
+
__privateMethod(this, _updateResult, updateResult_fn).call(this);
|
|
90
|
+
__privateMethod(this, _notify, notify_fn).call(this, action);
|
|
91
|
+
}
|
|
92
|
+
getCurrentResult() {
|
|
93
|
+
return __privateGet(this, _currentResult);
|
|
94
|
+
}
|
|
95
|
+
reset() {
|
|
96
|
+
__privateSet(this, _currentMutation, void 0);
|
|
97
|
+
__privateMethod(this, _updateResult, updateResult_fn).call(this);
|
|
98
|
+
__privateMethod(this, _notify, notify_fn).call(this);
|
|
99
|
+
}
|
|
100
|
+
mutate(variables, options) {
|
|
101
|
+
var _a;
|
|
102
|
+
__privateSet(this, _mutateOptions, options);
|
|
103
|
+
(_a = __privateGet(this, _currentMutation)) == null ? void 0 : _a.removeObserver(this);
|
|
104
|
+
__privateSet(this, _currentMutation, __privateGet(this, _client).getMutationCache().build(__privateGet(this, _client), this.options));
|
|
105
|
+
__privateGet(this, _currentMutation).addObserver(this);
|
|
106
|
+
return __privateGet(this, _currentMutation).execute(variables);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
_client = new WeakMap();
|
|
110
|
+
_currentResult = new WeakMap();
|
|
111
|
+
_currentMutation = new WeakMap();
|
|
112
|
+
_mutateOptions = new WeakMap();
|
|
113
|
+
_updateResult = new WeakSet();
|
|
114
|
+
updateResult_fn = function() {
|
|
115
|
+
var _a;
|
|
116
|
+
const state = ((_a = __privateGet(this, _currentMutation)) == null ? void 0 : _a.state) ?? (0, import_mutation.getDefaultState)();
|
|
117
|
+
__privateSet(this, _currentResult, {
|
|
118
|
+
...state,
|
|
119
|
+
isPending: state.status === "pending",
|
|
120
|
+
isSuccess: state.status === "success",
|
|
121
|
+
isError: state.status === "error",
|
|
122
|
+
isIdle: state.status === "idle",
|
|
123
|
+
mutate: this.mutate,
|
|
124
|
+
reset: this.reset
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
_notify = new WeakSet();
|
|
128
|
+
notify_fn = function(action) {
|
|
129
|
+
import_notifyManager.notifyManager.batch(() => {
|
|
130
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
131
|
+
if (__privateGet(this, _mutateOptions) && this.hasListeners()) {
|
|
132
|
+
if ((action == null ? void 0 : action.type) === "success") {
|
|
133
|
+
(_b = (_a = __privateGet(this, _mutateOptions)).onSuccess) == null ? void 0 : _b.call(
|
|
134
|
+
_a,
|
|
135
|
+
action.data,
|
|
136
|
+
__privateGet(this, _currentResult).variables,
|
|
137
|
+
__privateGet(this, _currentResult).context
|
|
138
|
+
);
|
|
139
|
+
(_d = (_c = __privateGet(this, _mutateOptions)).onSettled) == null ? void 0 : _d.call(
|
|
140
|
+
_c,
|
|
141
|
+
action.data,
|
|
142
|
+
null,
|
|
143
|
+
__privateGet(this, _currentResult).variables,
|
|
144
|
+
__privateGet(this, _currentResult).context
|
|
145
|
+
);
|
|
146
|
+
} else if ((action == null ? void 0 : action.type) === "error") {
|
|
147
|
+
(_f = (_e = __privateGet(this, _mutateOptions)).onError) == null ? void 0 : _f.call(
|
|
148
|
+
_e,
|
|
149
|
+
action.error,
|
|
150
|
+
__privateGet(this, _currentResult).variables,
|
|
151
|
+
__privateGet(this, _currentResult).context
|
|
152
|
+
);
|
|
153
|
+
(_h = (_g = __privateGet(this, _mutateOptions)).onSettled) == null ? void 0 : _h.call(
|
|
154
|
+
_g,
|
|
155
|
+
void 0,
|
|
156
|
+
action.error,
|
|
157
|
+
__privateGet(this, _currentResult).variables,
|
|
158
|
+
__privateGet(this, _currentResult).context
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
this.listeners.forEach((listener) => {
|
|
163
|
+
listener(__privateGet(this, _currentResult));
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
168
|
+
0 && (module.exports = {
|
|
169
|
+
MutationObserver
|
|
170
|
+
});
|
|
171
|
+
//# sourceMappingURL=mutationObserver.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/mutationObserver.ts"],"sourcesContent":["import { getDefaultState } from './mutation'\nimport { notifyManager } from './notifyManager'\nimport { Subscribable } from './subscribable'\nimport { shallowEqualObjects } from './utils'\nimport type { QueryClient } from './queryClient'\nimport type {\n DefaultError,\n MutateOptions,\n MutationObserverOptions,\n MutationObserverResult,\n} from './types'\nimport type { Action, Mutation } from './mutation'\n\n// TYPES\n\ntype MutationObserverListener<TData, TError, TVariables, TContext> = (\n result: MutationObserverResult<TData, TError, TVariables, TContext>,\n) => void\n\n// CLASS\n\nexport class MutationObserver<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> extends Subscribable<\n MutationObserverListener<TData, TError, TVariables, TContext>\n> {\n options!: MutationObserverOptions<TData, TError, TVariables, TContext>\n\n #client: QueryClient\n #currentResult: MutationObserverResult<TData, TError, TVariables, TContext> =\n undefined!\n #currentMutation?: Mutation<TData, TError, TVariables, TContext>\n #mutateOptions?: MutateOptions<TData, TError, TVariables, TContext>\n\n constructor(\n client: QueryClient,\n options: MutationObserverOptions<TData, TError, TVariables, TContext>,\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<TData, TError, TVariables, TContext>,\n ) {\n const prevOptions = this.options\n this.options = this.#client.defaultMutationOptions(options)\n if (!shallowEqualObjects(prevOptions, this.options)) {\n this.#client.getMutationCache().notify({\n type: 'observerOptionsUpdated',\n mutation: this.#currentMutation,\n observer: this,\n })\n }\n this.#currentMutation?.setOptions(this.options)\n }\n\n protected onUnsubscribe(): void {\n if (!this.hasListeners()) {\n this.#currentMutation?.removeObserver(this)\n }\n }\n\n onMutationUpdate(action: Action<TData, TError, TVariables, TContext>): void {\n this.#updateResult()\n\n this.#notify(action)\n }\n\n getCurrentResult(): MutationObserverResult<\n TData,\n TError,\n TVariables,\n TContext\n > {\n return this.#currentResult\n }\n\n reset(): void {\n this.#currentMutation = undefined\n this.#updateResult()\n this.#notify()\n }\n\n mutate(\n variables: TVariables,\n options?: MutateOptions<TData, TError, TVariables, TContext>,\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, TContext>()\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, TContext>\n }\n\n #notify(action?: Action<TData, TError, TVariables, TContext>): void {\n notifyManager.batch(() => {\n // First trigger the mutate callbacks\n if (this.#mutateOptions && this.hasListeners()) {\n if (action?.type === 'success') {\n this.#mutateOptions.onSuccess?.(\n action.data,\n this.#currentResult.variables!,\n this.#currentResult.context!,\n )\n this.#mutateOptions.onSettled?.(\n action.data,\n null,\n this.#currentResult.variables!,\n this.#currentResult.context,\n )\n } else if (action?.type === 'error') {\n this.#mutateOptions.onError?.(\n action.error,\n this.#currentResult.variables!,\n this.#currentResult.context,\n )\n this.#mutateOptions.onSettled?.(\n undefined,\n action.error,\n this.#currentResult.variables!,\n this.#currentResult.context,\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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AC;AACH;","names":[]}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
var __accessCheck = (obj, member, msg) => {
|
|
2
|
+
if (!member.has(obj))
|
|
3
|
+
throw TypeError("Cannot " + msg);
|
|
4
|
+
};
|
|
5
|
+
var __privateGet = (obj, member, getter) => {
|
|
6
|
+
__accessCheck(obj, member, "read from private field");
|
|
7
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
8
|
+
};
|
|
9
|
+
var __privateAdd = (obj, member, value) => {
|
|
10
|
+
if (member.has(obj))
|
|
11
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
12
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
13
|
+
};
|
|
14
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
15
|
+
__accessCheck(obj, member, "write to private field");
|
|
16
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
17
|
+
return value;
|
|
18
|
+
};
|
|
19
|
+
var __privateMethod = (obj, member, method) => {
|
|
20
|
+
__accessCheck(obj, member, "access private method");
|
|
21
|
+
return method;
|
|
22
|
+
};
|
|
23
|
+
var _client, _currentResult, _currentMutation, _mutateOptions, _updateResult, updateResult_fn, _notify, notify_fn;
|
|
24
|
+
import { getDefaultState } from "./mutation";
|
|
25
|
+
import { notifyManager } from "./notifyManager";
|
|
26
|
+
import { Subscribable } from "./subscribable";
|
|
27
|
+
import { shallowEqualObjects } from "./utils";
|
|
28
|
+
class MutationObserver extends Subscribable {
|
|
29
|
+
constructor(client, options) {
|
|
30
|
+
super();
|
|
31
|
+
__privateAdd(this, _updateResult);
|
|
32
|
+
__privateAdd(this, _notify);
|
|
33
|
+
__privateAdd(this, _client, void 0);
|
|
34
|
+
__privateAdd(this, _currentResult, void 0);
|
|
35
|
+
__privateAdd(this, _currentMutation, void 0);
|
|
36
|
+
__privateAdd(this, _mutateOptions, void 0);
|
|
37
|
+
__privateSet(this, _client, client);
|
|
38
|
+
this.setOptions(options);
|
|
39
|
+
this.bindMethods();
|
|
40
|
+
__privateMethod(this, _updateResult, updateResult_fn).call(this);
|
|
41
|
+
}
|
|
42
|
+
bindMethods() {
|
|
43
|
+
this.mutate = this.mutate.bind(this);
|
|
44
|
+
this.reset = this.reset.bind(this);
|
|
45
|
+
}
|
|
46
|
+
setOptions(options) {
|
|
47
|
+
var _a;
|
|
48
|
+
const prevOptions = this.options;
|
|
49
|
+
this.options = __privateGet(this, _client).defaultMutationOptions(options);
|
|
50
|
+
if (!shallowEqualObjects(prevOptions, this.options)) {
|
|
51
|
+
__privateGet(this, _client).getMutationCache().notify({
|
|
52
|
+
type: "observerOptionsUpdated",
|
|
53
|
+
mutation: __privateGet(this, _currentMutation),
|
|
54
|
+
observer: this
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
(_a = __privateGet(this, _currentMutation)) == null ? void 0 : _a.setOptions(this.options);
|
|
58
|
+
}
|
|
59
|
+
onUnsubscribe() {
|
|
60
|
+
var _a;
|
|
61
|
+
if (!this.hasListeners()) {
|
|
62
|
+
(_a = __privateGet(this, _currentMutation)) == null ? void 0 : _a.removeObserver(this);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
onMutationUpdate(action) {
|
|
66
|
+
__privateMethod(this, _updateResult, updateResult_fn).call(this);
|
|
67
|
+
__privateMethod(this, _notify, notify_fn).call(this, action);
|
|
68
|
+
}
|
|
69
|
+
getCurrentResult() {
|
|
70
|
+
return __privateGet(this, _currentResult);
|
|
71
|
+
}
|
|
72
|
+
reset() {
|
|
73
|
+
__privateSet(this, _currentMutation, void 0);
|
|
74
|
+
__privateMethod(this, _updateResult, updateResult_fn).call(this);
|
|
75
|
+
__privateMethod(this, _notify, notify_fn).call(this);
|
|
76
|
+
}
|
|
77
|
+
mutate(variables, options) {
|
|
78
|
+
var _a;
|
|
79
|
+
__privateSet(this, _mutateOptions, options);
|
|
80
|
+
(_a = __privateGet(this, _currentMutation)) == null ? void 0 : _a.removeObserver(this);
|
|
81
|
+
__privateSet(this, _currentMutation, __privateGet(this, _client).getMutationCache().build(__privateGet(this, _client), this.options));
|
|
82
|
+
__privateGet(this, _currentMutation).addObserver(this);
|
|
83
|
+
return __privateGet(this, _currentMutation).execute(variables);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
_client = new WeakMap();
|
|
87
|
+
_currentResult = new WeakMap();
|
|
88
|
+
_currentMutation = new WeakMap();
|
|
89
|
+
_mutateOptions = new WeakMap();
|
|
90
|
+
_updateResult = new WeakSet();
|
|
91
|
+
updateResult_fn = function() {
|
|
92
|
+
var _a;
|
|
93
|
+
const state = ((_a = __privateGet(this, _currentMutation)) == null ? void 0 : _a.state) ?? getDefaultState();
|
|
94
|
+
__privateSet(this, _currentResult, {
|
|
95
|
+
...state,
|
|
96
|
+
isPending: state.status === "pending",
|
|
97
|
+
isSuccess: state.status === "success",
|
|
98
|
+
isError: state.status === "error",
|
|
99
|
+
isIdle: state.status === "idle",
|
|
100
|
+
mutate: this.mutate,
|
|
101
|
+
reset: this.reset
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
_notify = new WeakSet();
|
|
105
|
+
notify_fn = function(action) {
|
|
106
|
+
notifyManager.batch(() => {
|
|
107
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
108
|
+
if (__privateGet(this, _mutateOptions) && this.hasListeners()) {
|
|
109
|
+
if ((action == null ? void 0 : action.type) === "success") {
|
|
110
|
+
(_b = (_a = __privateGet(this, _mutateOptions)).onSuccess) == null ? void 0 : _b.call(
|
|
111
|
+
_a,
|
|
112
|
+
action.data,
|
|
113
|
+
__privateGet(this, _currentResult).variables,
|
|
114
|
+
__privateGet(this, _currentResult).context
|
|
115
|
+
);
|
|
116
|
+
(_d = (_c = __privateGet(this, _mutateOptions)).onSettled) == null ? void 0 : _d.call(
|
|
117
|
+
_c,
|
|
118
|
+
action.data,
|
|
119
|
+
null,
|
|
120
|
+
__privateGet(this, _currentResult).variables,
|
|
121
|
+
__privateGet(this, _currentResult).context
|
|
122
|
+
);
|
|
123
|
+
} else if ((action == null ? void 0 : action.type) === "error") {
|
|
124
|
+
(_f = (_e = __privateGet(this, _mutateOptions)).onError) == null ? void 0 : _f.call(
|
|
125
|
+
_e,
|
|
126
|
+
action.error,
|
|
127
|
+
__privateGet(this, _currentResult).variables,
|
|
128
|
+
__privateGet(this, _currentResult).context
|
|
129
|
+
);
|
|
130
|
+
(_h = (_g = __privateGet(this, _mutateOptions)).onSettled) == null ? void 0 : _h.call(
|
|
131
|
+
_g,
|
|
132
|
+
void 0,
|
|
133
|
+
action.error,
|
|
134
|
+
__privateGet(this, _currentResult).variables,
|
|
135
|
+
__privateGet(this, _currentResult).context
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
this.listeners.forEach((listener) => {
|
|
140
|
+
listener(__privateGet(this, _currentResult));
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
export {
|
|
145
|
+
MutationObserver
|
|
146
|
+
};
|
|
147
|
+
//# sourceMappingURL=mutationObserver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/mutationObserver.ts"],"sourcesContent":["import { getDefaultState } from './mutation'\nimport { notifyManager } from './notifyManager'\nimport { Subscribable } from './subscribable'\nimport { shallowEqualObjects } from './utils'\nimport type { QueryClient } from './queryClient'\nimport type {\n DefaultError,\n MutateOptions,\n MutationObserverOptions,\n MutationObserverResult,\n} from './types'\nimport type { Action, Mutation } from './mutation'\n\n// TYPES\n\ntype MutationObserverListener<TData, TError, TVariables, TContext> = (\n result: MutationObserverResult<TData, TError, TVariables, TContext>,\n) => void\n\n// CLASS\n\nexport class MutationObserver<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> extends Subscribable<\n MutationObserverListener<TData, TError, TVariables, TContext>\n> {\n options!: MutationObserverOptions<TData, TError, TVariables, TContext>\n\n #client: QueryClient\n #currentResult: MutationObserverResult<TData, TError, TVariables, TContext> =\n undefined!\n #currentMutation?: Mutation<TData, TError, TVariables, TContext>\n #mutateOptions?: MutateOptions<TData, TError, TVariables, TContext>\n\n constructor(\n client: QueryClient,\n options: MutationObserverOptions<TData, TError, TVariables, TContext>,\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<TData, TError, TVariables, TContext>,\n ) {\n const prevOptions = this.options\n this.options = this.#client.defaultMutationOptions(options)\n if (!shallowEqualObjects(prevOptions, this.options)) {\n this.#client.getMutationCache().notify({\n type: 'observerOptionsUpdated',\n mutation: this.#currentMutation,\n observer: this,\n })\n }\n this.#currentMutation?.setOptions(this.options)\n }\n\n protected onUnsubscribe(): void {\n if (!this.hasListeners()) {\n this.#currentMutation?.removeObserver(this)\n }\n }\n\n onMutationUpdate(action: Action<TData, TError, TVariables, TContext>): void {\n this.#updateResult()\n\n this.#notify(action)\n }\n\n getCurrentResult(): MutationObserverResult<\n TData,\n TError,\n TVariables,\n TContext\n > {\n return this.#currentResult\n }\n\n reset(): void {\n this.#currentMutation = undefined\n this.#updateResult()\n this.#notify()\n }\n\n mutate(\n variables: TVariables,\n options?: MutateOptions<TData, TError, TVariables, TContext>,\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, TContext>()\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, TContext>\n }\n\n #notify(action?: Action<TData, TError, TVariables, TContext>): void {\n notifyManager.batch(() => {\n // First trigger the mutate callbacks\n if (this.#mutateOptions && this.hasListeners()) {\n if (action?.type === 'success') {\n this.#mutateOptions.onSuccess?.(\n action.data,\n this.#currentResult.variables!,\n this.#currentResult.context!,\n )\n this.#mutateOptions.onSettled?.(\n action.data,\n null,\n this.#currentResult.variables!,\n this.#currentResult.context,\n )\n } else if (action?.type === 'error') {\n this.#mutateOptions.onError?.(\n action.error,\n this.#currentResult.variables!,\n this.#currentResult.context,\n )\n this.#mutateOptions.onSettled?.(\n undefined,\n action.error,\n this.#currentResult.variables!,\n this.#currentResult.context,\n )\n }\n }\n\n // Then trigger the listeners\n this.listeners.forEach((listener) => {\n listener(this.#currentResult)\n })\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,SAAS,uBAAuB;AAChC,SAAS,qBAAqB;AAC9B,SAAS,oBAAoB;AAC7B,SAAS,2BAA2B;AAkB7B,MAAM,yBAKH,aAER;AAAA,EASA,YACE,QACA,SACA;AACA,UAAM;AAwER;AAgBA;AAlGA;AACA,uCACE;AACF;AACA;AAQE,uBAAK,SAAU;AACf,SAAK,WAAW,OAAO;AACvB,SAAK,YAAY;AACjB,0BAAK,gCAAL;AAAA,EACF;AAAA,EAEU,cAAoB;AAC5B,SAAK,SAAS,KAAK,OAAO,KAAK,IAAI;AACnC,SAAK,QAAQ,KAAK,MAAM,KAAK,IAAI;AAAA,EACnC;AAAA,EAEA,WACE,SACA;AAxDJ;AAyDI,UAAM,cAAc,KAAK;AACzB,SAAK,UAAU,mBAAK,SAAQ,uBAAuB,OAAO;AAC1D,QAAI,CAAC,oBAAoB,aAAa,KAAK,OAAO,GAAG;AACnD,yBAAK,SAAQ,iBAAiB,EAAE,OAAO;AAAA,QACrC,MAAM;AAAA,QACN,UAAU,mBAAK;AAAA,QACf,UAAU;AAAA,MACZ,CAAC;AAAA,IACH;AACA,6BAAK,sBAAL,mBAAuB,WAAW,KAAK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