@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 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,25 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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 utils_exports = {};
|
|
20
|
+
__export(utils_exports, {
|
|
21
|
+
addToEnd: () => addToEnd,
|
|
22
|
+
addToStart: () => addToStart,
|
|
23
|
+
functionalUpdate: () => functionalUpdate,
|
|
24
|
+
hashKey: () => hashKey,
|
|
25
|
+
hashQueryKeyByOptions: () => hashQueryKeyByOptions,
|
|
26
|
+
isPlainArray: () => isPlainArray,
|
|
27
|
+
isPlainObject: () => isPlainObject,
|
|
28
|
+
isServer: () => isServer,
|
|
29
|
+
isValidTimeout: () => isValidTimeout,
|
|
30
|
+
keepPreviousData: () => keepPreviousData,
|
|
31
|
+
matchMutation: () => matchMutation,
|
|
32
|
+
matchQuery: () => matchQuery,
|
|
33
|
+
noop: () => noop,
|
|
34
|
+
partialMatchKey: () => partialMatchKey,
|
|
35
|
+
replaceData: () => replaceData,
|
|
36
|
+
replaceEqualDeep: () => replaceEqualDeep,
|
|
37
|
+
scheduleMicrotask: () => scheduleMicrotask,
|
|
38
|
+
shallowEqualObjects: () => shallowEqualObjects,
|
|
39
|
+
sleep: () => sleep,
|
|
40
|
+
timeUntilStale: () => timeUntilStale
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(utils_exports);
|
|
43
|
+
const isServer = typeof window === "undefined" || "Deno" in window;
|
|
8
44
|
function noop() {
|
|
9
|
-
return
|
|
45
|
+
return void 0;
|
|
10
46
|
}
|
|
11
47
|
function functionalUpdate(updater, input) {
|
|
12
|
-
return typeof updater ===
|
|
48
|
+
return typeof updater === "function" ? updater(input) : updater;
|
|
13
49
|
}
|
|
14
50
|
function isValidTimeout(value) {
|
|
15
|
-
return typeof value ===
|
|
51
|
+
return typeof value === "number" && value >= 0 && value !== Infinity;
|
|
16
52
|
}
|
|
17
53
|
function timeUntilStale(updatedAt, staleTime) {
|
|
18
54
|
return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0);
|
|
19
55
|
}
|
|
20
56
|
function matchQuery(filters, query) {
|
|
21
57
|
const {
|
|
22
|
-
type =
|
|
58
|
+
type = "all",
|
|
23
59
|
exact,
|
|
24
60
|
fetchStatus,
|
|
25
61
|
predicate,
|
|
@@ -35,19 +71,19 @@ function matchQuery(filters, query) {
|
|
|
35
71
|
return false;
|
|
36
72
|
}
|
|
37
73
|
}
|
|
38
|
-
if (type !==
|
|
74
|
+
if (type !== "all") {
|
|
39
75
|
const isActive = query.isActive();
|
|
40
|
-
if (type ===
|
|
76
|
+
if (type === "active" && !isActive) {
|
|
41
77
|
return false;
|
|
42
78
|
}
|
|
43
|
-
if (type ===
|
|
79
|
+
if (type === "inactive" && isActive) {
|
|
44
80
|
return false;
|
|
45
81
|
}
|
|
46
82
|
}
|
|
47
|
-
if (typeof stale ===
|
|
83
|
+
if (typeof stale === "boolean" && query.isStale() !== stale) {
|
|
48
84
|
return false;
|
|
49
85
|
}
|
|
50
|
-
if (typeof fetchStatus !==
|
|
86
|
+
if (typeof fetchStatus !== "undefined" && fetchStatus !== query.state.fetchStatus) {
|
|
51
87
|
return false;
|
|
52
88
|
}
|
|
53
89
|
if (predicate && !predicate(query)) {
|
|
@@ -56,12 +92,7 @@ function matchQuery(filters, query) {
|
|
|
56
92
|
return true;
|
|
57
93
|
}
|
|
58
94
|
function matchMutation(filters, mutation) {
|
|
59
|
-
const {
|
|
60
|
-
exact,
|
|
61
|
-
status,
|
|
62
|
-
predicate,
|
|
63
|
-
mutationKey
|
|
64
|
-
} = filters;
|
|
95
|
+
const { exact, status, predicate, mutationKey } = filters;
|
|
65
96
|
if (mutationKey) {
|
|
66
97
|
if (!mutation.options.mutationKey) {
|
|
67
98
|
return false;
|
|
@@ -86,22 +117,15 @@ function hashQueryKeyByOptions(queryKey, options) {
|
|
|
86
117
|
const hashFn = (options == null ? void 0 : options.queryKeyHashFn) || hashKey;
|
|
87
118
|
return hashFn(queryKey);
|
|
88
119
|
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Default query & mutation keys hash function.
|
|
92
|
-
* Hashes the value into a stable hash.
|
|
93
|
-
*/
|
|
94
120
|
function hashKey(queryKey) {
|
|
95
|
-
return JSON.stringify(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
*/
|
|
104
|
-
|
|
121
|
+
return JSON.stringify(
|
|
122
|
+
queryKey,
|
|
123
|
+
(_, val) => isPlainObject(val) ? Object.keys(val).sort().reduce((result, key) => {
|
|
124
|
+
result[key] = val[key];
|
|
125
|
+
return result;
|
|
126
|
+
}, {}) : val
|
|
127
|
+
);
|
|
128
|
+
}
|
|
105
129
|
function partialMatchKey(a, b) {
|
|
106
130
|
if (a === b) {
|
|
107
131
|
return true;
|
|
@@ -109,18 +133,11 @@ function partialMatchKey(a, b) {
|
|
|
109
133
|
if (typeof a !== typeof b) {
|
|
110
134
|
return false;
|
|
111
135
|
}
|
|
112
|
-
if (a && b && typeof a ===
|
|
113
|
-
return !Object.keys(b).some(key => !partialMatchKey(a[key], b[key]));
|
|
136
|
+
if (a && b && typeof a === "object" && typeof b === "object") {
|
|
137
|
+
return !Object.keys(b).some((key) => !partialMatchKey(a[key], b[key]));
|
|
114
138
|
}
|
|
115
139
|
return false;
|
|
116
140
|
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* This function returns `a` if `b` is deeply equal.
|
|
120
|
-
* If not, it will replace any deeply equal children of `b` with those of `a`.
|
|
121
|
-
* This can be used for structural sharing between JSON values for example.
|
|
122
|
-
*/
|
|
123
|
-
|
|
124
141
|
function replaceEqualDeep(a, b) {
|
|
125
142
|
if (a === b) {
|
|
126
143
|
return a;
|
|
@@ -143,10 +160,6 @@ function replaceEqualDeep(a, b) {
|
|
|
143
160
|
}
|
|
144
161
|
return b;
|
|
145
162
|
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Shallow compare objects. Only works with objects that always have the same properties.
|
|
149
|
-
*/
|
|
150
163
|
function shallowEqualObjects(a, b) {
|
|
151
164
|
if (a && !b || b && !a) {
|
|
152
165
|
return false;
|
|
@@ -161,54 +174,38 @@ function shallowEqualObjects(a, b) {
|
|
|
161
174
|
function isPlainArray(value) {
|
|
162
175
|
return Array.isArray(value) && value.length === Object.keys(value).length;
|
|
163
176
|
}
|
|
164
|
-
|
|
165
|
-
// Copied from: https://github.com/jonschlinkert/is-plain-object
|
|
166
177
|
function isPlainObject(o) {
|
|
167
178
|
if (!hasObjectPrototype(o)) {
|
|
168
179
|
return false;
|
|
169
180
|
}
|
|
170
|
-
|
|
171
|
-
// If has modified constructor
|
|
172
181
|
const ctor = o.constructor;
|
|
173
|
-
if (typeof ctor ===
|
|
182
|
+
if (typeof ctor === "undefined") {
|
|
174
183
|
return true;
|
|
175
184
|
}
|
|
176
|
-
|
|
177
|
-
// If has modified prototype
|
|
178
185
|
const prot = ctor.prototype;
|
|
179
186
|
if (!hasObjectPrototype(prot)) {
|
|
180
187
|
return false;
|
|
181
188
|
}
|
|
182
|
-
|
|
183
|
-
// If constructor does not have an Object-specific method
|
|
184
|
-
if (!prot.hasOwnProperty('isPrototypeOf')) {
|
|
189
|
+
if (!prot.hasOwnProperty("isPrototypeOf")) {
|
|
185
190
|
return false;
|
|
186
191
|
}
|
|
187
|
-
|
|
188
|
-
// Most likely a plain Object
|
|
189
192
|
return true;
|
|
190
193
|
}
|
|
191
194
|
function hasObjectPrototype(o) {
|
|
192
|
-
return Object.prototype.toString.call(o) ===
|
|
195
|
+
return Object.prototype.toString.call(o) === "[object Object]";
|
|
193
196
|
}
|
|
194
197
|
function sleep(timeout) {
|
|
195
|
-
return new Promise(resolve => {
|
|
198
|
+
return new Promise((resolve) => {
|
|
196
199
|
setTimeout(resolve, timeout);
|
|
197
200
|
});
|
|
198
201
|
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Schedules a microtask.
|
|
202
|
-
* This can be useful to schedule state updates after rendering.
|
|
203
|
-
*/
|
|
204
202
|
function scheduleMicrotask(callback) {
|
|
205
203
|
sleep(0).then(callback);
|
|
206
204
|
}
|
|
207
205
|
function replaceData(prevData, data, options) {
|
|
208
|
-
if (typeof options.structuralSharing ===
|
|
206
|
+
if (typeof options.structuralSharing === "function") {
|
|
209
207
|
return options.structuralSharing(prevData, data);
|
|
210
208
|
} else if (options.structuralSharing !== false) {
|
|
211
|
-
// Structurally share data between prev and new data if needed
|
|
212
209
|
return replaceEqualDeep(prevData, data);
|
|
213
210
|
}
|
|
214
211
|
return data;
|
|
@@ -224,25 +221,27 @@ function addToStart(items, item, max = 0) {
|
|
|
224
221
|
const newItems = [item, ...items];
|
|
225
222
|
return max && newItems.length > max ? newItems.slice(0, -1) : newItems;
|
|
226
223
|
}
|
|
227
|
-
|
|
228
|
-
exports
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
224
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
225
|
+
0 && (module.exports = {
|
|
226
|
+
addToEnd,
|
|
227
|
+
addToStart,
|
|
228
|
+
functionalUpdate,
|
|
229
|
+
hashKey,
|
|
230
|
+
hashQueryKeyByOptions,
|
|
231
|
+
isPlainArray,
|
|
232
|
+
isPlainObject,
|
|
233
|
+
isServer,
|
|
234
|
+
isValidTimeout,
|
|
235
|
+
keepPreviousData,
|
|
236
|
+
matchMutation,
|
|
237
|
+
matchQuery,
|
|
238
|
+
noop,
|
|
239
|
+
partialMatchKey,
|
|
240
|
+
replaceData,
|
|
241
|
+
replaceEqualDeep,
|
|
242
|
+
scheduleMicrotask,
|
|
243
|
+
shallowEqualObjects,
|
|
244
|
+
sleep,
|
|
245
|
+
timeUntilStale
|
|
246
|
+
});
|
|
247
|
+
//# sourceMappingURL=utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils.ts"],"sourcesContent":["import type { Mutation } from './mutation'\nimport type { Query } from './query'\nimport type {\n FetchStatus,\n MutationKey,\n MutationStatus,\n QueryKey,\n QueryOptions,\n} from './types'\n\n// TYPES\n\nexport interface QueryFilters {\n /**\n * Filter to active queries, inactive queries or all queries\n */\n type?: QueryTypeFilter\n /**\n * Match query key exactly\n */\n exact?: boolean\n /**\n * Include queries matching this predicate function\n */\n predicate?: (query: Query) => boolean\n /**\n * Include queries matching this query key\n */\n queryKey?: QueryKey\n /**\n * Include or exclude stale queries\n */\n stale?: boolean\n /**\n * Include queries matching their fetchStatus\n */\n fetchStatus?: FetchStatus\n}\n\nexport interface MutationFilters {\n /**\n * Match mutation key exactly\n */\n exact?: boolean\n /**\n * Include mutations matching this predicate function\n */\n predicate?: (mutation: Mutation<any, any, any>) => boolean\n /**\n * Include mutations matching this mutation key\n */\n mutationKey?: MutationKey\n /**\n * Filter by mutation status\n */\n status?: MutationStatus\n}\n\nexport type DataUpdateFunction<TInput, TOutput> = (input: TInput) => TOutput\n\nexport type Updater<TInput, TOutput> =\n | TOutput\n | DataUpdateFunction<TInput, TOutput>\n\nexport type QueryTypeFilter = 'all' | 'active' | 'inactive'\n\n// UTILS\n\nexport const isServer = typeof window === 'undefined' || 'Deno' in window\n\nexport function noop(): undefined {\n return undefined\n}\n\nexport function functionalUpdate<TInput, TOutput>(\n updater: Updater<TInput, TOutput>,\n input: TInput,\n): TOutput {\n return typeof updater === 'function'\n ? (updater as DataUpdateFunction<TInput, TOutput>)(input)\n : updater\n}\n\nexport function isValidTimeout(value: unknown): value is number {\n return typeof value === 'number' && value >= 0 && value !== Infinity\n}\n\nexport function timeUntilStale(updatedAt: number, staleTime?: number): number {\n return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0)\n}\n\nexport function matchQuery(\n filters: QueryFilters,\n query: Query<any, any, any, any>,\n): boolean {\n const {\n type = 'all',\n exact,\n fetchStatus,\n predicate,\n queryKey,\n stale,\n } = filters\n\n if (queryKey) {\n if (exact) {\n if (query.queryHash !== hashQueryKeyByOptions(queryKey, query.options)) {\n return false\n }\n } else if (!partialMatchKey(query.queryKey, queryKey)) {\n return false\n }\n }\n\n if (type !== 'all') {\n const isActive = query.isActive()\n if (type === 'active' && !isActive) {\n return false\n }\n if (type === 'inactive' && isActive) {\n return false\n }\n }\n\n if (typeof stale === 'boolean' && query.isStale() !== stale) {\n return false\n }\n\n if (\n typeof fetchStatus !== 'undefined' &&\n fetchStatus !== query.state.fetchStatus\n ) {\n return false\n }\n\n if (predicate && !predicate(query)) {\n return false\n }\n\n return true\n}\n\nexport function matchMutation(\n filters: MutationFilters,\n mutation: Mutation<any, any>,\n): boolean {\n const { exact, status, predicate, mutationKey } = filters\n if (mutationKey) {\n if (!mutation.options.mutationKey) {\n return false\n }\n if (exact) {\n if (hashKey(mutation.options.mutationKey) !== hashKey(mutationKey)) {\n return false\n }\n } else if (!partialMatchKey(mutation.options.mutationKey, mutationKey)) {\n return false\n }\n }\n\n if (status && mutation.state.status !== status) {\n return false\n }\n\n if (predicate && !predicate(mutation)) {\n return false\n }\n\n return true\n}\n\nexport function hashQueryKeyByOptions<TQueryKey extends QueryKey = QueryKey>(\n queryKey: TQueryKey,\n options?: QueryOptions<any, any, any, TQueryKey>,\n): string {\n const hashFn = options?.queryKeyHashFn || hashKey\n return hashFn(queryKey)\n}\n\n/**\n * Default query & mutation keys hash function.\n * Hashes the value into a stable hash.\n */\nexport function hashKey(queryKey: QueryKey | MutationKey): string {\n return JSON.stringify(queryKey, (_, val) =>\n isPlainObject(val)\n ? Object.keys(val)\n .sort()\n .reduce((result, key) => {\n result[key] = val[key]\n return result\n }, {} as any)\n : val,\n )\n}\n\n/**\n * Checks if key `b` partially matches with key `a`.\n */\nexport function partialMatchKey(a: QueryKey, b: QueryKey): boolean\nexport function partialMatchKey(a: any, b: any): boolean {\n if (a === b) {\n return true\n }\n\n if (typeof a !== typeof b) {\n return false\n }\n\n if (a && b && typeof a === 'object' && typeof b === 'object') {\n return !Object.keys(b).some((key) => !partialMatchKey(a[key], b[key]))\n }\n\n return false\n}\n\n/**\n * This function returns `a` if `b` is deeply equal.\n * If not, it will replace any deeply equal children of `b` with those of `a`.\n * This can be used for structural sharing between JSON values for example.\n */\nexport function replaceEqualDeep<T>(a: unknown, b: T): T\nexport function replaceEqualDeep(a: any, b: any): any {\n if (a === b) {\n return a\n }\n\n const array = isPlainArray(a) && isPlainArray(b)\n\n if (array || (isPlainObject(a) && isPlainObject(b))) {\n const aSize = array ? a.length : Object.keys(a).length\n const bItems = array ? b : Object.keys(b)\n const bSize = bItems.length\n const copy: any = array ? [] : {}\n\n let equalItems = 0\n\n for (let i = 0; i < bSize; i++) {\n const key = array ? i : bItems[i]\n copy[key] = replaceEqualDeep(a[key], b[key])\n if (copy[key] === a[key]) {\n equalItems++\n }\n }\n\n return aSize === bSize && equalItems === aSize ? a : copy\n }\n\n return b\n}\n\n/**\n * Shallow compare objects. Only works with objects that always have the same properties.\n */\nexport function shallowEqualObjects<T>(a: T, b: T): boolean {\n if ((a && !b) || (b && !a)) {\n return false\n }\n\n for (const key in a) {\n if (a[key] !== b[key]) {\n return false\n }\n }\n\n return true\n}\n\nexport function isPlainArray(value: unknown) {\n return Array.isArray(value) && value.length === Object.keys(value).length\n}\n\n// Copied from: https://github.com/jonschlinkert/is-plain-object\nexport function isPlainObject(o: any): o is Object {\n if (!hasObjectPrototype(o)) {\n return false\n }\n\n // If has modified constructor\n const ctor = o.constructor\n if (typeof ctor === 'undefined') {\n return true\n }\n\n // If has modified prototype\n const prot = ctor.prototype\n if (!hasObjectPrototype(prot)) {\n return false\n }\n\n // If constructor does not have an Object-specific method\n if (!prot.hasOwnProperty('isPrototypeOf')) {\n return false\n }\n\n // Most likely a plain Object\n return true\n}\n\nfunction hasObjectPrototype(o: any): boolean {\n return Object.prototype.toString.call(o) === '[object Object]'\n}\n\nexport function sleep(timeout: number): Promise<void> {\n return new Promise((resolve) => {\n setTimeout(resolve, timeout)\n })\n}\n\n/**\n * Schedules a microtask.\n * This can be useful to schedule state updates after rendering.\n */\nexport function scheduleMicrotask(callback: () => void) {\n sleep(0).then(callback)\n}\n\nexport function replaceData<\n TData,\n TOptions extends QueryOptions<any, any, any, any>,\n>(prevData: TData | undefined, data: TData, options: TOptions): TData {\n if (typeof options.structuralSharing === 'function') {\n return options.structuralSharing(prevData, data)\n } else if (options.structuralSharing !== false) {\n // Structurally share data between prev and new data if needed\n return replaceEqualDeep(prevData, data)\n }\n return data\n}\n\nexport function keepPreviousData<T>(\n previousData: T | undefined,\n): T | undefined {\n return previousData\n}\n\nexport function addToEnd<T>(items: T[], item: T, max = 0): T[] {\n const newItems = [...items, item]\n return max && newItems.length > max ? newItems.slice(1) : newItems\n}\n\nexport function addToStart<T>(items: T[], item: T, max = 0): T[] {\n const newItems = [item, ...items]\n return max && newItems.length > max ? newItems.slice(0, -1) : newItems\n}\n"],"mappings":";;;;;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mBAAmB,IAAI,GAAG;AAC7B,WAAO;AAAA,EACT;AAGA,MAAI,CAAC,KAAK,eAAe,eAAe,GAAG;AACzC,WAAO;AAAA,EACT;AAGA,SAAO;AACT;AAEA,SAAS,mBAAmB,GAAiB;AAC3C,SAAO,OAAO,UAAU,SAAS,KAAK,CAAC,MAAM;AAC/C;AAEO,SAAS,MAAM,SAAgC;AACpD,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,eAAW,SAAS,OAAO;AAAA,EAC7B,CAAC;AACH;AAMO,SAAS,kBAAkB,UAAsB;AACtD,QAAM,CAAC,EAAE,KAAK,QAAQ;AACxB;AAEO,SAAS,YAGd,UAA6B,MAAa,SAA0B;AACpE,MAAI,OAAO,QAAQ,sBAAsB,YAAY;AACnD,WAAO,QAAQ,kBAAkB,UAAU,IAAI;AAAA,EACjD,WAAW,QAAQ,sBAAsB,OAAO;AAE9C,WAAO,iBAAiB,UAAU,IAAI;AAAA,EACxC;AACA,SAAO;AACT;AAEO,SAAS,iBACd,cACe;AACf,SAAO;AACT;AAEO,SAAS,SAAY,OAAY,MAAS,MAAM,GAAQ;AAC7D,QAAM,WAAW,CAAC,GAAG,OAAO,IAAI;AAChC,SAAO,OAAO,SAAS,SAAS,MAAM,SAAS,MAAM,CAAC,IAAI;AAC5D;AAEO,SAAS,WAAc,OAAY,MAAS,MAAM,GAAQ;AAC/D,QAAM,WAAW,CAAC,MAAM,GAAG,KAAK;AAChC,SAAO,OAAO,SAAS,SAAS,MAAM,SAAS,MAAM,GAAG,EAAE,IAAI;AAChE;","names":[]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { aB as DataUpdateFunction, e as MutationFilters, f as QueryFilters, aC as QueryTypeFilter, U as Updater, aQ as addToEnd, aR as addToStart, aE as functionalUpdate, h as hashKey, aI as hashQueryKeyByOptions, aL as isPlainArray, aM as isPlainObject, i as isServer, aF as isValidTimeout, k as keepPreviousData, aH as matchMutation, m as matchQuery, aD as noop, aJ as partialMatchKey, aP as replaceData, r as replaceEqualDeep, aO as scheduleMicrotask, aK as shallowEqualObjects, aN as sleep, aG as timeUntilStale } from './queryClient-4ba6364e.js';
|
|
2
|
+
import './removable.cjs';
|
|
3
|
+
import './subscribable.cjs';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { aB as DataUpdateFunction, e as MutationFilters, f as QueryFilters, aC as QueryTypeFilter, U as Updater, aQ as addToEnd, aR as addToStart, aE as functionalUpdate, h as hashKey, aI as hashQueryKeyByOptions, aL as isPlainArray, aM as isPlainObject, i as isServer, aF as isValidTimeout, k as keepPreviousData, aH as matchMutation, m as matchQuery, aD as noop, aJ as partialMatchKey, aP as replaceData, r as replaceEqualDeep, aO as scheduleMicrotask, aK as shallowEqualObjects, aN as sleep, aG as timeUntilStale } from './queryClient-d615ed9f.js';
|
|
2
|
+
import './removable.js';
|
|
3
|
+
import './subscribable.js';
|
|
@@ -1,23 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
// UTILS
|
|
4
|
-
|
|
5
|
-
const isServer = typeof window === 'undefined' || 'Deno' in window;
|
|
1
|
+
const isServer = typeof window === "undefined" || "Deno" in window;
|
|
6
2
|
function noop() {
|
|
7
|
-
return
|
|
3
|
+
return void 0;
|
|
8
4
|
}
|
|
9
5
|
function functionalUpdate(updater, input) {
|
|
10
|
-
return typeof updater ===
|
|
6
|
+
return typeof updater === "function" ? updater(input) : updater;
|
|
11
7
|
}
|
|
12
8
|
function isValidTimeout(value) {
|
|
13
|
-
return typeof value ===
|
|
9
|
+
return typeof value === "number" && value >= 0 && value !== Infinity;
|
|
14
10
|
}
|
|
15
11
|
function timeUntilStale(updatedAt, staleTime) {
|
|
16
12
|
return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0);
|
|
17
13
|
}
|
|
18
14
|
function matchQuery(filters, query) {
|
|
19
15
|
const {
|
|
20
|
-
type =
|
|
16
|
+
type = "all",
|
|
21
17
|
exact,
|
|
22
18
|
fetchStatus,
|
|
23
19
|
predicate,
|
|
@@ -33,19 +29,19 @@ function matchQuery(filters, query) {
|
|
|
33
29
|
return false;
|
|
34
30
|
}
|
|
35
31
|
}
|
|
36
|
-
if (type !==
|
|
32
|
+
if (type !== "all") {
|
|
37
33
|
const isActive = query.isActive();
|
|
38
|
-
if (type ===
|
|
34
|
+
if (type === "active" && !isActive) {
|
|
39
35
|
return false;
|
|
40
36
|
}
|
|
41
|
-
if (type ===
|
|
37
|
+
if (type === "inactive" && isActive) {
|
|
42
38
|
return false;
|
|
43
39
|
}
|
|
44
40
|
}
|
|
45
|
-
if (typeof stale ===
|
|
41
|
+
if (typeof stale === "boolean" && query.isStale() !== stale) {
|
|
46
42
|
return false;
|
|
47
43
|
}
|
|
48
|
-
if (typeof fetchStatus !==
|
|
44
|
+
if (typeof fetchStatus !== "undefined" && fetchStatus !== query.state.fetchStatus) {
|
|
49
45
|
return false;
|
|
50
46
|
}
|
|
51
47
|
if (predicate && !predicate(query)) {
|
|
@@ -54,12 +50,7 @@ function matchQuery(filters, query) {
|
|
|
54
50
|
return true;
|
|
55
51
|
}
|
|
56
52
|
function matchMutation(filters, mutation) {
|
|
57
|
-
const {
|
|
58
|
-
exact,
|
|
59
|
-
status,
|
|
60
|
-
predicate,
|
|
61
|
-
mutationKey
|
|
62
|
-
} = filters;
|
|
53
|
+
const { exact, status, predicate, mutationKey } = filters;
|
|
63
54
|
if (mutationKey) {
|
|
64
55
|
if (!mutation.options.mutationKey) {
|
|
65
56
|
return false;
|
|
@@ -84,22 +75,15 @@ function hashQueryKeyByOptions(queryKey, options) {
|
|
|
84
75
|
const hashFn = (options == null ? void 0 : options.queryKeyHashFn) || hashKey;
|
|
85
76
|
return hashFn(queryKey);
|
|
86
77
|
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Default query & mutation keys hash function.
|
|
90
|
-
* Hashes the value into a stable hash.
|
|
91
|
-
*/
|
|
92
78
|
function hashKey(queryKey) {
|
|
93
|
-
return JSON.stringify(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
*/
|
|
102
|
-
|
|
79
|
+
return JSON.stringify(
|
|
80
|
+
queryKey,
|
|
81
|
+
(_, val) => isPlainObject(val) ? Object.keys(val).sort().reduce((result, key) => {
|
|
82
|
+
result[key] = val[key];
|
|
83
|
+
return result;
|
|
84
|
+
}, {}) : val
|
|
85
|
+
);
|
|
86
|
+
}
|
|
103
87
|
function partialMatchKey(a, b) {
|
|
104
88
|
if (a === b) {
|
|
105
89
|
return true;
|
|
@@ -107,18 +91,11 @@ function partialMatchKey(a, b) {
|
|
|
107
91
|
if (typeof a !== typeof b) {
|
|
108
92
|
return false;
|
|
109
93
|
}
|
|
110
|
-
if (a && b && typeof a ===
|
|
111
|
-
return !Object.keys(b).some(key => !partialMatchKey(a[key], b[key]));
|
|
94
|
+
if (a && b && typeof a === "object" && typeof b === "object") {
|
|
95
|
+
return !Object.keys(b).some((key) => !partialMatchKey(a[key], b[key]));
|
|
112
96
|
}
|
|
113
97
|
return false;
|
|
114
98
|
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* This function returns `a` if `b` is deeply equal.
|
|
118
|
-
* If not, it will replace any deeply equal children of `b` with those of `a`.
|
|
119
|
-
* This can be used for structural sharing between JSON values for example.
|
|
120
|
-
*/
|
|
121
|
-
|
|
122
99
|
function replaceEqualDeep(a, b) {
|
|
123
100
|
if (a === b) {
|
|
124
101
|
return a;
|
|
@@ -141,10 +118,6 @@ function replaceEqualDeep(a, b) {
|
|
|
141
118
|
}
|
|
142
119
|
return b;
|
|
143
120
|
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Shallow compare objects. Only works with objects that always have the same properties.
|
|
147
|
-
*/
|
|
148
121
|
function shallowEqualObjects(a, b) {
|
|
149
122
|
if (a && !b || b && !a) {
|
|
150
123
|
return false;
|
|
@@ -159,54 +132,38 @@ function shallowEqualObjects(a, b) {
|
|
|
159
132
|
function isPlainArray(value) {
|
|
160
133
|
return Array.isArray(value) && value.length === Object.keys(value).length;
|
|
161
134
|
}
|
|
162
|
-
|
|
163
|
-
// Copied from: https://github.com/jonschlinkert/is-plain-object
|
|
164
135
|
function isPlainObject(o) {
|
|
165
136
|
if (!hasObjectPrototype(o)) {
|
|
166
137
|
return false;
|
|
167
138
|
}
|
|
168
|
-
|
|
169
|
-
// If has modified constructor
|
|
170
139
|
const ctor = o.constructor;
|
|
171
|
-
if (typeof ctor ===
|
|
140
|
+
if (typeof ctor === "undefined") {
|
|
172
141
|
return true;
|
|
173
142
|
}
|
|
174
|
-
|
|
175
|
-
// If has modified prototype
|
|
176
143
|
const prot = ctor.prototype;
|
|
177
144
|
if (!hasObjectPrototype(prot)) {
|
|
178
145
|
return false;
|
|
179
146
|
}
|
|
180
|
-
|
|
181
|
-
// If constructor does not have an Object-specific method
|
|
182
|
-
if (!prot.hasOwnProperty('isPrototypeOf')) {
|
|
147
|
+
if (!prot.hasOwnProperty("isPrototypeOf")) {
|
|
183
148
|
return false;
|
|
184
149
|
}
|
|
185
|
-
|
|
186
|
-
// Most likely a plain Object
|
|
187
150
|
return true;
|
|
188
151
|
}
|
|
189
152
|
function hasObjectPrototype(o) {
|
|
190
|
-
return Object.prototype.toString.call(o) ===
|
|
153
|
+
return Object.prototype.toString.call(o) === "[object Object]";
|
|
191
154
|
}
|
|
192
155
|
function sleep(timeout) {
|
|
193
|
-
return new Promise(resolve => {
|
|
156
|
+
return new Promise((resolve) => {
|
|
194
157
|
setTimeout(resolve, timeout);
|
|
195
158
|
});
|
|
196
159
|
}
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Schedules a microtask.
|
|
200
|
-
* This can be useful to schedule state updates after rendering.
|
|
201
|
-
*/
|
|
202
160
|
function scheduleMicrotask(callback) {
|
|
203
161
|
sleep(0).then(callback);
|
|
204
162
|
}
|
|
205
163
|
function replaceData(prevData, data, options) {
|
|
206
|
-
if (typeof options.structuralSharing ===
|
|
164
|
+
if (typeof options.structuralSharing === "function") {
|
|
207
165
|
return options.structuralSharing(prevData, data);
|
|
208
166
|
} else if (options.structuralSharing !== false) {
|
|
209
|
-
// Structurally share data between prev and new data if needed
|
|
210
167
|
return replaceEqualDeep(prevData, data);
|
|
211
168
|
}
|
|
212
169
|
return data;
|
|
@@ -222,6 +179,26 @@ function addToStart(items, item, max = 0) {
|
|
|
222
179
|
const newItems = [item, ...items];
|
|
223
180
|
return max && newItems.length > max ? newItems.slice(0, -1) : newItems;
|
|
224
181
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
182
|
+
export {
|
|
183
|
+
addToEnd,
|
|
184
|
+
addToStart,
|
|
185
|
+
functionalUpdate,
|
|
186
|
+
hashKey,
|
|
187
|
+
hashQueryKeyByOptions,
|
|
188
|
+
isPlainArray,
|
|
189
|
+
isPlainObject,
|
|
190
|
+
isServer,
|
|
191
|
+
isValidTimeout,
|
|
192
|
+
keepPreviousData,
|
|
193
|
+
matchMutation,
|
|
194
|
+
matchQuery,
|
|
195
|
+
noop,
|
|
196
|
+
partialMatchKey,
|
|
197
|
+
replaceData,
|
|
198
|
+
replaceEqualDeep,
|
|
199
|
+
scheduleMicrotask,
|
|
200
|
+
shallowEqualObjects,
|
|
201
|
+
sleep,
|
|
202
|
+
timeUntilStale
|
|
203
|
+
};
|
|
204
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils.ts"],"sourcesContent":["import type { Mutation } from './mutation'\nimport type { Query } from './query'\nimport type {\n FetchStatus,\n MutationKey,\n MutationStatus,\n QueryKey,\n QueryOptions,\n} from './types'\n\n// TYPES\n\nexport interface QueryFilters {\n /**\n * Filter to active queries, inactive queries or all queries\n */\n type?: QueryTypeFilter\n /**\n * Match query key exactly\n */\n exact?: boolean\n /**\n * Include queries matching this predicate function\n */\n predicate?: (query: Query) => boolean\n /**\n * Include queries matching this query key\n */\n queryKey?: QueryKey\n /**\n * Include or exclude stale queries\n */\n stale?: boolean\n /**\n * Include queries matching their fetchStatus\n */\n fetchStatus?: FetchStatus\n}\n\nexport interface MutationFilters {\n /**\n * Match mutation key exactly\n */\n exact?: boolean\n /**\n * Include mutations matching this predicate function\n */\n predicate?: (mutation: Mutation<any, any, any>) => boolean\n /**\n * Include mutations matching this mutation key\n */\n mutationKey?: MutationKey\n /**\n * Filter by mutation status\n */\n status?: MutationStatus\n}\n\nexport type DataUpdateFunction<TInput, TOutput> = (input: TInput) => TOutput\n\nexport type Updater<TInput, TOutput> =\n | TOutput\n | DataUpdateFunction<TInput, TOutput>\n\nexport type QueryTypeFilter = 'all' | 'active' | 'inactive'\n\n// UTILS\n\nexport const isServer = typeof window === 'undefined' || 'Deno' in window\n\nexport function noop(): undefined {\n return undefined\n}\n\nexport function functionalUpdate<TInput, TOutput>(\n updater: Updater<TInput, TOutput>,\n input: TInput,\n): TOutput {\n return typeof updater === 'function'\n ? (updater as DataUpdateFunction<TInput, TOutput>)(input)\n : updater\n}\n\nexport function isValidTimeout(value: unknown): value is number {\n return typeof value === 'number' && value >= 0 && value !== Infinity\n}\n\nexport function timeUntilStale(updatedAt: number, staleTime?: number): number {\n return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0)\n}\n\nexport function matchQuery(\n filters: QueryFilters,\n query: Query<any, any, any, any>,\n): boolean {\n const {\n type = 'all',\n exact,\n fetchStatus,\n predicate,\n queryKey,\n stale,\n } = filters\n\n if (queryKey) {\n if (exact) {\n if (query.queryHash !== hashQueryKeyByOptions(queryKey, query.options)) {\n return false\n }\n } else if (!partialMatchKey(query.queryKey, queryKey)) {\n return false\n }\n }\n\n if (type !== 'all') {\n const isActive = query.isActive()\n if (type === 'active' && !isActive) {\n return false\n }\n if (type === 'inactive' && isActive) {\n return false\n }\n }\n\n if (typeof stale === 'boolean' && query.isStale() !== stale) {\n return false\n }\n\n if (\n typeof fetchStatus !== 'undefined' &&\n fetchStatus !== query.state.fetchStatus\n ) {\n return false\n }\n\n if (predicate && !predicate(query)) {\n return false\n }\n\n return true\n}\n\nexport function matchMutation(\n filters: MutationFilters,\n mutation: Mutation<any, any>,\n): boolean {\n const { exact, status, predicate, mutationKey } = filters\n if (mutationKey) {\n if (!mutation.options.mutationKey) {\n return false\n }\n if (exact) {\n if (hashKey(mutation.options.mutationKey) !== hashKey(mutationKey)) {\n return false\n }\n } else if (!partialMatchKey(mutation.options.mutationKey, mutationKey)) {\n return false\n }\n }\n\n if (status && mutation.state.status !== status) {\n return false\n }\n\n if (predicate && !predicate(mutation)) {\n return false\n }\n\n return true\n}\n\nexport function hashQueryKeyByOptions<TQueryKey extends QueryKey = QueryKey>(\n queryKey: TQueryKey,\n options?: QueryOptions<any, any, any, TQueryKey>,\n): string {\n const hashFn = options?.queryKeyHashFn || hashKey\n return hashFn(queryKey)\n}\n\n/**\n * Default query & mutation keys hash function.\n * Hashes the value into a stable hash.\n */\nexport function hashKey(queryKey: QueryKey | MutationKey): string {\n return JSON.stringify(queryKey, (_, val) =>\n isPlainObject(val)\n ? Object.keys(val)\n .sort()\n .reduce((result, key) => {\n result[key] = val[key]\n return result\n }, {} as any)\n : val,\n )\n}\n\n/**\n * Checks if key `b` partially matches with key `a`.\n */\nexport function partialMatchKey(a: QueryKey, b: QueryKey): boolean\nexport function partialMatchKey(a: any, b: any): boolean {\n if (a === b) {\n return true\n }\n\n if (typeof a !== typeof b) {\n return false\n }\n\n if (a && b && typeof a === 'object' && typeof b === 'object') {\n return !Object.keys(b).some((key) => !partialMatchKey(a[key], b[key]))\n }\n\n return false\n}\n\n/**\n * This function returns `a` if `b` is deeply equal.\n * If not, it will replace any deeply equal children of `b` with those of `a`.\n * This can be used for structural sharing between JSON values for example.\n */\nexport function replaceEqualDeep<T>(a: unknown, b: T): T\nexport function replaceEqualDeep(a: any, b: any): any {\n if (a === b) {\n return a\n }\n\n const array = isPlainArray(a) && isPlainArray(b)\n\n if (array || (isPlainObject(a) && isPlainObject(b))) {\n const aSize = array ? a.length : Object.keys(a).length\n const bItems = array ? b : Object.keys(b)\n const bSize = bItems.length\n const copy: any = array ? [] : {}\n\n let equalItems = 0\n\n for (let i = 0; i < bSize; i++) {\n const key = array ? i : bItems[i]\n copy[key] = replaceEqualDeep(a[key], b[key])\n if (copy[key] === a[key]) {\n equalItems++\n }\n }\n\n return aSize === bSize && equalItems === aSize ? a : copy\n }\n\n return b\n}\n\n/**\n * Shallow compare objects. Only works with objects that always have the same properties.\n */\nexport function shallowEqualObjects<T>(a: T, b: T): boolean {\n if ((a && !b) || (b && !a)) {\n return false\n }\n\n for (const key in a) {\n if (a[key] !== b[key]) {\n return false\n }\n }\n\n return true\n}\n\nexport function isPlainArray(value: unknown) {\n return Array.isArray(value) && value.length === Object.keys(value).length\n}\n\n// Copied from: https://github.com/jonschlinkert/is-plain-object\nexport function isPlainObject(o: any): o is Object {\n if (!hasObjectPrototype(o)) {\n return false\n }\n\n // If has modified constructor\n const ctor = o.constructor\n if (typeof ctor === 'undefined') {\n return true\n }\n\n // If has modified prototype\n const prot = ctor.prototype\n if (!hasObjectPrototype(prot)) {\n return false\n }\n\n // If constructor does not have an Object-specific method\n if (!prot.hasOwnProperty('isPrototypeOf')) {\n return false\n }\n\n // Most likely a plain Object\n return true\n}\n\nfunction hasObjectPrototype(o: any): boolean {\n return Object.prototype.toString.call(o) === '[object Object]'\n}\n\nexport function sleep(timeout: number): Promise<void> {\n return new Promise((resolve) => {\n setTimeout(resolve, timeout)\n })\n}\n\n/**\n * Schedules a microtask.\n * This can be useful to schedule state updates after rendering.\n */\nexport function scheduleMicrotask(callback: () => void) {\n sleep(0).then(callback)\n}\n\nexport function replaceData<\n TData,\n TOptions extends QueryOptions<any, any, any, any>,\n>(prevData: TData | undefined, data: TData, options: TOptions): TData {\n if (typeof options.structuralSharing === 'function') {\n return options.structuralSharing(prevData, data)\n } else if (options.structuralSharing !== false) {\n // Structurally share data between prev and new data if needed\n return replaceEqualDeep(prevData, data)\n }\n return data\n}\n\nexport function keepPreviousData<T>(\n previousData: T | undefined,\n): T | undefined {\n return previousData\n}\n\nexport function addToEnd<T>(items: T[], item: T, max = 0): T[] {\n const newItems = [...items, item]\n return max && newItems.length > max ? newItems.slice(1) : newItems\n}\n\nexport function addToStart<T>(items: T[], item: T, max = 0): T[] {\n const newItems = [item, ...items]\n return max && newItems.length > max ? newItems.slice(0, -1) : newItems\n}\n"],"mappings":"AAoEO,MAAM,WAAW,OAAO,WAAW,eAAe,UAAU;AAE5D,SAAS,OAAkB;AAChC,SAAO;AACT;AAEO,SAAS,iBACd,SACA,OACS;AACT,SAAO,OAAO,YAAY,aACrB,QAAgD,KAAK,IACtD;AACN;AAEO,SAAS,eAAe,OAAiC;AAC9D,SAAO,OAAO,UAAU,YAAY,SAAS,KAAK,UAAU;AAC9D;AAEO,SAAS,eAAe,WAAmB,WAA4B;AAC5E,SAAO,KAAK,IAAI,aAAa,aAAa,KAAK,KAAK,IAAI,GAAG,CAAC;AAC9D;AAEO,SAAS,WACd,SACA,OACS;AACT,QAAM;AAAA,IACJ,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,MAAI,UAAU;AACZ,QAAI,OAAO;AACT,UAAI,MAAM,cAAc,sBAAsB,UAAU,MAAM,OAAO,GAAG;AACtE,eAAO;AAAA,MACT;AAAA,IACF,WAAW,CAAC,gBAAgB,MAAM,UAAU,QAAQ,GAAG;AACrD,aAAO;AAAA,IACT;AAAA,EACF;AAEA,MAAI,SAAS,OAAO;AAClB,UAAM,WAAW,MAAM,SAAS;AAChC,QAAI,SAAS,YAAY,CAAC,UAAU;AAClC,aAAO;AAAA,IACT;AACA,QAAI,SAAS,cAAc,UAAU;AACnC,aAAO;AAAA,IACT;AAAA,EACF;AAEA,MAAI,OAAO,UAAU,aAAa,MAAM,QAAQ,MAAM,OAAO;AAC3D,WAAO;AAAA,EACT;AAEA,MACE,OAAO,gBAAgB,e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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 focusManager_exports = {};
|
|
20
|
+
__export(focusManager_exports, {
|
|
21
|
+
FocusManager: () => FocusManager,
|
|
22
|
+
focusManager: () => focusManager
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(focusManager_exports);
|
|
25
|
+
var import_subscribable = require("./subscribable");
|
|
26
|
+
var import_utils = require("./utils");
|
|
27
|
+
class FocusManager extends import_subscribable.Subscribable {
|
|
28
|
+
#focused;
|
|
29
|
+
#cleanup;
|
|
30
|
+
#setup;
|
|
31
|
+
constructor() {
|
|
32
|
+
super();
|
|
33
|
+
this.#setup = (onFocus) => {
|
|
34
|
+
if (!import_utils.isServer && window.addEventListener) {
|
|
35
|
+
const listener = () => onFocus();
|
|
36
|
+
window.addEventListener("visibilitychange", listener, false);
|
|
37
|
+
return () => {
|
|
38
|
+
window.removeEventListener("visibilitychange", listener);
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
onSubscribe() {
|
|
45
|
+
if (!this.#cleanup) {
|
|
46
|
+
this.setEventListener(this.#setup);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
onUnsubscribe() {
|
|
50
|
+
if (!this.hasListeners()) {
|
|
51
|
+
this.#cleanup?.();
|
|
52
|
+
this.#cleanup = void 0;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
setEventListener(setup) {
|
|
56
|
+
this.#setup = setup;
|
|
57
|
+
this.#cleanup?.();
|
|
58
|
+
this.#cleanup = setup((focused) => {
|
|
59
|
+
if (typeof focused === "boolean") {
|
|
60
|
+
this.setFocused(focused);
|
|
61
|
+
} else {
|
|
62
|
+
this.onFocus();
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
setFocused(focused) {
|
|
67
|
+
const changed = this.#focused !== focused;
|
|
68
|
+
if (changed) {
|
|
69
|
+
this.#focused = focused;
|
|
70
|
+
this.onFocus();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
onFocus() {
|
|
74
|
+
this.listeners.forEach((listener) => {
|
|
75
|
+
listener();
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
isFocused() {
|
|
79
|
+
if (typeof this.#focused === "boolean") {
|
|
80
|
+
return this.#focused;
|
|
81
|
+
}
|
|
82
|
+
return globalThis.document?.visibilityState !== "hidden";
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const focusManager = new FocusManager();
|
|
86
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
87
|
+
0 && (module.exports = {
|
|
88
|
+
FocusManager,
|
|
89
|
+
focusManager
|
|
90
|
+
});
|
|
91
|
+
//# sourceMappingURL=focusManager.cjs.map
|