@tanstack/vue-query 5.104.0 → 5.104.2
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/devtools/devtools.cjs +6 -0
- package/build/legacy/devtools/devtools.cjs.map +1 -1
- package/build/legacy/devtools/devtools.d.cts +7 -1
- package/build/legacy/devtools/devtools.d.cts.map +1 -1
- package/build/legacy/devtools/devtools.d.ts +7 -1
- package/build/legacy/devtools/devtools.d.ts.map +1 -1
- package/build/legacy/devtools/devtools.js +6 -0
- package/build/legacy/devtools/devtools.js.map +1 -1
- package/build/legacy/devtools/utils.cjs +21 -0
- package/build/legacy/devtools/utils.cjs.map +1 -1
- package/build/legacy/devtools/utils.d.cts +21 -0
- package/build/legacy/devtools/utils.d.cts.map +1 -1
- package/build/legacy/devtools/utils.d.ts +21 -0
- package/build/legacy/devtools/utils.d.ts.map +1 -1
- package/build/legacy/devtools/utils.js +21 -0
- package/build/legacy/devtools/utils.js.map +1 -1
- package/build/legacy/index.d.cts +6 -6
- package/build/legacy/index.d.ts +6 -6
- package/build/legacy/{infiniteQueryOptions-NucMX_M_.d.ts → infiniteQueryOptions-BaoKhSzb.d.ts} +26 -27
- package/build/legacy/infiniteQueryOptions-BaoKhSzb.d.ts.map +1 -0
- package/build/legacy/{infiniteQueryOptions-CnTRbIP5.d.cts → infiniteQueryOptions-ClNe2-FB.d.cts} +26 -27
- package/build/legacy/infiniteQueryOptions-ClNe2-FB.d.cts.map +1 -0
- package/build/legacy/infiniteQueryOptions.cjs.map +1 -1
- package/build/legacy/infiniteQueryOptions.d.cts +1 -1
- package/build/legacy/infiniteQueryOptions.d.ts +1 -1
- package/build/legacy/infiniteQueryOptions.js.map +1 -1
- package/build/legacy/mutationCache.cjs.map +1 -1
- package/build/legacy/mutationCache.d.cts +1 -1
- package/build/legacy/mutationCache.d.cts.map +1 -1
- package/build/legacy/mutationCache.d.ts +1 -1
- package/build/legacy/mutationCache.d.ts.map +1 -1
- package/build/legacy/mutationCache.js.map +1 -1
- package/build/legacy/mutationOptions.cjs.map +1 -1
- package/build/legacy/mutationOptions.d.cts +5 -13
- package/build/legacy/mutationOptions.d.cts.map +1 -1
- package/build/legacy/mutationOptions.d.ts +5 -13
- package/build/legacy/mutationOptions.d.ts.map +1 -1
- package/build/legacy/mutationOptions.js.map +1 -1
- package/build/legacy/queryCache.cjs.map +1 -1
- package/build/legacy/queryCache.d.cts +1 -1
- package/build/legacy/queryCache.d.cts.map +1 -1
- package/build/legacy/queryCache.d.ts +1 -1
- package/build/legacy/queryCache.d.ts.map +1 -1
- package/build/legacy/queryCache.js.map +1 -1
- package/build/legacy/{queryClient-Bn2Ql_Lu.d.cts → queryClient-BK9W57Qu.d.cts} +3 -3
- package/build/legacy/queryClient-BK9W57Qu.d.cts.map +1 -0
- package/build/legacy/{queryClient-B6mLtXOj.d.ts → queryClient-BoBzDWAZ.d.ts} +3 -3
- package/build/legacy/queryClient-BoBzDWAZ.d.ts.map +1 -0
- package/build/legacy/queryClient.cjs.map +1 -1
- package/build/legacy/queryClient.d.cts +1 -1
- package/build/legacy/queryClient.d.ts +1 -1
- package/build/legacy/queryClient.js.map +1 -1
- package/build/{modern/queryOptions-CwqQgQmQ.d.cts → legacy/queryOptions-BvmZtmiU.d.cts} +14 -19
- package/build/legacy/queryOptions-BvmZtmiU.d.cts.map +1 -0
- package/build/{modern/queryOptions-CsM5TXD2.d.ts → legacy/queryOptions-gpn5D4rf.d.ts} +14 -19
- package/build/legacy/queryOptions-gpn5D4rf.d.ts.map +1 -0
- package/build/legacy/queryOptions.cjs.map +1 -1
- package/build/legacy/queryOptions.d.cts +1 -1
- package/build/legacy/queryOptions.d.ts +1 -1
- package/build/legacy/queryOptions.js.map +1 -1
- package/build/{modern/types-JpJB72CS.d.cts → legacy/types-sdZdiLgo.d.cts} +48 -3
- package/build/legacy/types-sdZdiLgo.d.cts.map +1 -0
- package/build/legacy/{types-JpJB72CS.d.cts → types-sdZdiLgo.d.ts} +48 -3
- package/build/legacy/types-sdZdiLgo.d.ts.map +1 -0
- package/build/legacy/types.d.cts +1 -1
- package/build/legacy/types.d.ts +1 -1
- package/build/legacy/useBaseQuery.cjs +1 -1
- package/build/legacy/useBaseQuery.cjs.map +1 -1
- package/build/legacy/useBaseQuery.d.cts +1 -1
- package/build/legacy/useBaseQuery.d.ts +1 -1
- package/build/legacy/useBaseQuery.js +1 -1
- package/build/legacy/useBaseQuery.js.map +1 -1
- package/build/legacy/useInfiniteQuery.cjs.map +1 -1
- package/build/legacy/useInfiniteQuery.d.cts +1 -1
- package/build/legacy/useInfiniteQuery.d.ts +1 -1
- package/build/legacy/useInfiniteQuery.js.map +1 -1
- package/build/legacy/useIsFetching.cjs +0 -3
- package/build/legacy/useIsFetching.cjs.map +1 -1
- package/build/legacy/useIsFetching.d.cts +6 -5
- package/build/legacy/useIsFetching.d.cts.map +1 -1
- package/build/legacy/useIsFetching.d.ts +6 -5
- package/build/legacy/useIsFetching.d.ts.map +1 -1
- package/build/legacy/useIsFetching.js +0 -3
- package/build/legacy/useIsFetching.js.map +1 -1
- package/build/legacy/useMutation.cjs +2 -8
- package/build/legacy/useMutation.cjs.map +1 -1
- package/build/legacy/useMutation.d.cts +17 -11
- package/build/legacy/useMutation.d.cts.map +1 -1
- package/build/legacy/useMutation.d.ts +17 -11
- package/build/legacy/useMutation.d.ts.map +1 -1
- package/build/legacy/useMutation.js +2 -8
- package/build/legacy/useMutation.js.map +1 -1
- package/build/legacy/useMutationState.cjs +7 -6
- package/build/legacy/useMutationState.cjs.map +1 -1
- package/build/legacy/useMutationState.d.cts +16 -8
- package/build/legacy/useMutationState.d.cts.map +1 -1
- package/build/legacy/useMutationState.d.ts +16 -8
- package/build/legacy/useMutationState.d.ts.map +1 -1
- package/build/legacy/useMutationState.js +7 -6
- package/build/legacy/useMutationState.js.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.cjs +5 -3
- package/build/legacy/usePrefetchInfiniteQuery.cjs.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.d.cts +6 -5
- package/build/legacy/usePrefetchInfiniteQuery.d.cts.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.d.ts +6 -5
- package/build/legacy/usePrefetchInfiniteQuery.d.ts.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.js +5 -3
- package/build/legacy/usePrefetchInfiniteQuery.js.map +1 -1
- package/build/legacy/usePrefetchQuery.cjs +5 -3
- package/build/legacy/usePrefetchQuery.cjs.map +1 -1
- package/build/legacy/usePrefetchQuery.d.cts +6 -5
- package/build/legacy/usePrefetchQuery.d.cts.map +1 -1
- package/build/legacy/usePrefetchQuery.d.ts +6 -5
- package/build/legacy/usePrefetchQuery.d.ts.map +1 -1
- package/build/legacy/usePrefetchQuery.js +5 -3
- package/build/legacy/usePrefetchQuery.js.map +1 -1
- package/build/legacy/useQueries.cjs +1 -4
- package/build/legacy/useQueries.cjs.map +1 -1
- package/build/legacy/useQueries.d.cts +4 -7
- package/build/legacy/useQueries.d.cts.map +1 -1
- package/build/legacy/useQueries.d.ts +4 -7
- package/build/legacy/useQueries.d.ts.map +1 -1
- package/build/legacy/useQueries.js +1 -4
- package/build/legacy/useQueries.js.map +1 -1
- package/build/legacy/useQuery.cjs.map +1 -1
- package/build/legacy/useQuery.d.cts +12 -15
- package/build/legacy/useQuery.d.cts.map +1 -1
- package/build/legacy/useQuery.d.ts +12 -15
- package/build/legacy/useQuery.d.ts.map +1 -1
- package/build/legacy/useQuery.js.map +1 -1
- package/build/legacy/useQueryClient.cjs +3 -3
- package/build/legacy/useQueryClient.cjs.map +1 -1
- package/build/legacy/useQueryClient.d.cts +4 -4
- package/build/legacy/useQueryClient.d.ts +4 -4
- package/build/legacy/useQueryClient.js +3 -3
- package/build/legacy/useQueryClient.js.map +1 -1
- package/build/legacy/utils.cjs +54 -6
- package/build/legacy/utils.cjs.map +1 -1
- package/build/legacy/utils.d.cts +34 -7
- package/build/legacy/utils.d.cts.map +1 -1
- package/build/legacy/utils.d.ts +34 -7
- package/build/legacy/utils.d.ts.map +1 -1
- package/build/legacy/utils.js +54 -6
- package/build/legacy/utils.js.map +1 -1
- package/build/legacy/vueQueryPlugin.cjs +0 -3
- package/build/legacy/vueQueryPlugin.cjs.map +1 -1
- package/build/legacy/vueQueryPlugin.d.cts +6 -5
- package/build/legacy/vueQueryPlugin.d.cts.map +1 -1
- package/build/legacy/vueQueryPlugin.d.ts +6 -5
- package/build/legacy/vueQueryPlugin.d.ts.map +1 -1
- package/build/legacy/vueQueryPlugin.js +0 -3
- package/build/legacy/vueQueryPlugin.js.map +1 -1
- package/build/modern/devtools/devtools.cjs +6 -0
- package/build/modern/devtools/devtools.cjs.map +1 -1
- package/build/modern/devtools/devtools.d.cts +7 -1
- package/build/modern/devtools/devtools.d.cts.map +1 -1
- package/build/modern/devtools/devtools.d.ts +7 -1
- package/build/modern/devtools/devtools.d.ts.map +1 -1
- package/build/modern/devtools/devtools.js +6 -0
- package/build/modern/devtools/devtools.js.map +1 -1
- package/build/modern/devtools/utils.cjs +21 -0
- package/build/modern/devtools/utils.cjs.map +1 -1
- package/build/modern/devtools/utils.d.cts +21 -0
- package/build/modern/devtools/utils.d.cts.map +1 -1
- package/build/modern/devtools/utils.d.ts +21 -0
- package/build/modern/devtools/utils.d.ts.map +1 -1
- package/build/modern/devtools/utils.js +21 -0
- package/build/modern/devtools/utils.js.map +1 -1
- package/build/modern/index.d.cts +6 -6
- package/build/modern/index.d.ts +6 -6
- package/build/modern/{infiniteQueryOptions-NucMX_M_.d.ts → infiniteQueryOptions-BaoKhSzb.d.ts} +26 -27
- package/build/modern/infiniteQueryOptions-BaoKhSzb.d.ts.map +1 -0
- package/build/modern/{infiniteQueryOptions-CnTRbIP5.d.cts → infiniteQueryOptions-ClNe2-FB.d.cts} +26 -27
- package/build/modern/infiniteQueryOptions-ClNe2-FB.d.cts.map +1 -0
- package/build/modern/infiniteQueryOptions.cjs.map +1 -1
- package/build/modern/infiniteQueryOptions.d.cts +1 -1
- package/build/modern/infiniteQueryOptions.d.ts +1 -1
- package/build/modern/infiniteQueryOptions.js.map +1 -1
- package/build/modern/mutationCache.cjs.map +1 -1
- package/build/modern/mutationCache.d.cts +1 -1
- package/build/modern/mutationCache.d.cts.map +1 -1
- package/build/modern/mutationCache.d.ts +1 -1
- package/build/modern/mutationCache.d.ts.map +1 -1
- package/build/modern/mutationCache.js.map +1 -1
- package/build/modern/mutationOptions.cjs.map +1 -1
- package/build/modern/mutationOptions.d.cts +5 -13
- package/build/modern/mutationOptions.d.cts.map +1 -1
- package/build/modern/mutationOptions.d.ts +5 -13
- package/build/modern/mutationOptions.d.ts.map +1 -1
- package/build/modern/mutationOptions.js.map +1 -1
- package/build/modern/queryCache.cjs.map +1 -1
- package/build/modern/queryCache.d.cts +1 -1
- package/build/modern/queryCache.d.cts.map +1 -1
- package/build/modern/queryCache.d.ts +1 -1
- package/build/modern/queryCache.d.ts.map +1 -1
- package/build/modern/queryCache.js.map +1 -1
- package/build/modern/{queryClient-Bn2Ql_Lu.d.cts → queryClient-BK9W57Qu.d.cts} +3 -3
- package/build/modern/queryClient-BK9W57Qu.d.cts.map +1 -0
- package/build/modern/{queryClient-B6mLtXOj.d.ts → queryClient-BoBzDWAZ.d.ts} +3 -3
- package/build/modern/queryClient-BoBzDWAZ.d.ts.map +1 -0
- package/build/modern/queryClient.cjs.map +1 -1
- package/build/modern/queryClient.d.cts +1 -1
- package/build/modern/queryClient.d.ts +1 -1
- package/build/modern/queryClient.js.map +1 -1
- package/build/{legacy/queryOptions-CwqQgQmQ.d.cts → modern/queryOptions-BvmZtmiU.d.cts} +14 -19
- package/build/modern/queryOptions-BvmZtmiU.d.cts.map +1 -0
- package/build/{legacy/queryOptions-CsM5TXD2.d.ts → modern/queryOptions-gpn5D4rf.d.ts} +14 -19
- package/build/modern/queryOptions-gpn5D4rf.d.ts.map +1 -0
- package/build/modern/queryOptions.cjs.map +1 -1
- package/build/modern/queryOptions.d.cts +1 -1
- package/build/modern/queryOptions.d.ts +1 -1
- package/build/modern/queryOptions.js.map +1 -1
- package/build/modern/{types-JpJB72CS.d.ts → types-sdZdiLgo.d.cts} +48 -3
- package/build/modern/types-sdZdiLgo.d.cts.map +1 -0
- package/build/{legacy/types-JpJB72CS.d.ts → modern/types-sdZdiLgo.d.ts} +48 -3
- package/build/modern/types-sdZdiLgo.d.ts.map +1 -0
- package/build/modern/types.d.cts +1 -1
- package/build/modern/types.d.ts +1 -1
- package/build/modern/useBaseQuery.cjs +1 -1
- package/build/modern/useBaseQuery.cjs.map +1 -1
- package/build/modern/useBaseQuery.d.cts +1 -1
- package/build/modern/useBaseQuery.d.ts +1 -1
- package/build/modern/useBaseQuery.js +1 -1
- package/build/modern/useBaseQuery.js.map +1 -1
- package/build/modern/useInfiniteQuery.cjs.map +1 -1
- package/build/modern/useInfiniteQuery.d.cts +1 -1
- package/build/modern/useInfiniteQuery.d.ts +1 -1
- package/build/modern/useInfiniteQuery.js.map +1 -1
- package/build/modern/useIsFetching.cjs +0 -3
- package/build/modern/useIsFetching.cjs.map +1 -1
- package/build/modern/useIsFetching.d.cts +6 -5
- package/build/modern/useIsFetching.d.cts.map +1 -1
- package/build/modern/useIsFetching.d.ts +6 -5
- package/build/modern/useIsFetching.d.ts.map +1 -1
- package/build/modern/useIsFetching.js +0 -3
- package/build/modern/useIsFetching.js.map +1 -1
- package/build/modern/useMutation.cjs +2 -8
- package/build/modern/useMutation.cjs.map +1 -1
- package/build/modern/useMutation.d.cts +17 -11
- package/build/modern/useMutation.d.cts.map +1 -1
- package/build/modern/useMutation.d.ts +17 -11
- package/build/modern/useMutation.d.ts.map +1 -1
- package/build/modern/useMutation.js +2 -8
- package/build/modern/useMutation.js.map +1 -1
- package/build/modern/useMutationState.cjs +7 -6
- package/build/modern/useMutationState.cjs.map +1 -1
- package/build/modern/useMutationState.d.cts +16 -8
- package/build/modern/useMutationState.d.cts.map +1 -1
- package/build/modern/useMutationState.d.ts +16 -8
- package/build/modern/useMutationState.d.ts.map +1 -1
- package/build/modern/useMutationState.js +7 -6
- package/build/modern/useMutationState.js.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.cjs +5 -3
- package/build/modern/usePrefetchInfiniteQuery.cjs.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.d.cts +6 -5
- package/build/modern/usePrefetchInfiniteQuery.d.cts.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.d.ts +6 -5
- package/build/modern/usePrefetchInfiniteQuery.d.ts.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.js +5 -3
- package/build/modern/usePrefetchInfiniteQuery.js.map +1 -1
- package/build/modern/usePrefetchQuery.cjs +5 -3
- package/build/modern/usePrefetchQuery.cjs.map +1 -1
- package/build/modern/usePrefetchQuery.d.cts +6 -5
- package/build/modern/usePrefetchQuery.d.cts.map +1 -1
- package/build/modern/usePrefetchQuery.d.ts +6 -5
- package/build/modern/usePrefetchQuery.d.ts.map +1 -1
- package/build/modern/usePrefetchQuery.js +5 -3
- package/build/modern/usePrefetchQuery.js.map +1 -1
- package/build/modern/useQueries.cjs +1 -4
- package/build/modern/useQueries.cjs.map +1 -1
- package/build/modern/useQueries.d.cts +4 -7
- package/build/modern/useQueries.d.cts.map +1 -1
- package/build/modern/useQueries.d.ts +4 -7
- package/build/modern/useQueries.d.ts.map +1 -1
- package/build/modern/useQueries.js +1 -4
- package/build/modern/useQueries.js.map +1 -1
- package/build/modern/useQuery.cjs.map +1 -1
- package/build/modern/useQuery.d.cts +12 -15
- package/build/modern/useQuery.d.cts.map +1 -1
- package/build/modern/useQuery.d.ts +12 -15
- package/build/modern/useQuery.d.ts.map +1 -1
- package/build/modern/useQuery.js.map +1 -1
- package/build/modern/useQueryClient.cjs +3 -3
- package/build/modern/useQueryClient.cjs.map +1 -1
- package/build/modern/useQueryClient.d.cts +4 -4
- package/build/modern/useQueryClient.d.ts +4 -4
- package/build/modern/useQueryClient.js +3 -3
- package/build/modern/useQueryClient.js.map +1 -1
- package/build/modern/utils.cjs +54 -6
- package/build/modern/utils.cjs.map +1 -1
- package/build/modern/utils.d.cts +34 -7
- package/build/modern/utils.d.cts.map +1 -1
- package/build/modern/utils.d.ts +34 -7
- package/build/modern/utils.d.ts.map +1 -1
- package/build/modern/utils.js +54 -6
- package/build/modern/utils.js.map +1 -1
- package/build/modern/vueQueryPlugin.cjs +0 -3
- package/build/modern/vueQueryPlugin.cjs.map +1 -1
- package/build/modern/vueQueryPlugin.d.cts +6 -5
- package/build/modern/vueQueryPlugin.d.cts.map +1 -1
- package/build/modern/vueQueryPlugin.d.ts +6 -5
- package/build/modern/vueQueryPlugin.d.ts.map +1 -1
- package/build/modern/vueQueryPlugin.js +0 -3
- package/build/modern/vueQueryPlugin.js.map +1 -1
- package/package.json +6 -6
- package/src/devtools/devtools.ts +6 -0
- package/src/devtools/utils.ts +21 -0
- package/src/index.ts +5 -1
- package/src/infiniteQueryOptions.ts +2 -8
- package/src/mutationCache.ts +4 -2
- package/src/mutationOptions.ts +4 -12
- package/src/queryCache.ts +6 -2
- package/src/queryClient.ts +55 -52
- package/src/queryOptions.ts +22 -25
- package/src/types.ts +47 -2
- package/src/useBaseQuery.ts +8 -2
- package/src/useInfiniteQuery.ts +15 -14
- package/src/useIsFetching.ts +6 -4
- package/src/useMutation.ts +15 -9
- package/src/useMutationState.ts +23 -7
- package/src/usePrefetchInfiniteQuery.ts +9 -3
- package/src/usePrefetchQuery.ts +9 -3
- package/src/useQueries.ts +1 -4
- package/src/useQuery.ts +10 -12
- package/src/useQueryClient.ts +3 -3
- package/src/utils.ts +55 -9
- package/src/vueQueryPlugin.ts +4 -3
- package/build/legacy/infiniteQueryOptions-CnTRbIP5.d.cts.map +0 -1
- package/build/legacy/infiniteQueryOptions-NucMX_M_.d.ts.map +0 -1
- package/build/legacy/queryClient-B6mLtXOj.d.ts.map +0 -1
- package/build/legacy/queryClient-Bn2Ql_Lu.d.cts.map +0 -1
- package/build/legacy/queryOptions-CsM5TXD2.d.ts.map +0 -1
- package/build/legacy/queryOptions-CwqQgQmQ.d.cts.map +0 -1
- package/build/legacy/types-JpJB72CS.d.cts.map +0 -1
- package/build/legacy/types-JpJB72CS.d.ts.map +0 -1
- package/build/modern/infiniteQueryOptions-CnTRbIP5.d.cts.map +0 -1
- package/build/modern/infiniteQueryOptions-NucMX_M_.d.ts.map +0 -1
- package/build/modern/queryClient-B6mLtXOj.d.ts.map +0 -1
- package/build/modern/queryClient-Bn2Ql_Lu.d.cts.map +0 -1
- package/build/modern/queryOptions-CsM5TXD2.d.ts.map +0 -1
- package/build/modern/queryOptions-CwqQgQmQ.d.cts.map +0 -1
- package/build/modern/types-JpJB72CS.d.cts.map +0 -1
- package/build/modern/types-JpJB72CS.d.ts.map +0 -1
package/build/legacy/utils.js
CHANGED
|
@@ -1,18 +1,41 @@
|
|
|
1
1
|
import { isRef, unref } from "vue-demi";
|
|
2
2
|
//#region src/utils.ts
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Base Vue injection key `VueQueryPlugin` provides the `QueryClient` under.
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
4
7
|
const VUE_QUERY_CLIENT = "VUE_QUERY_CLIENT";
|
|
5
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Builds the injection key `useQueryClient`/`VueQueryPlugin` use for a given `queryClientKey`.
|
|
10
|
+
* @internal
|
|
11
|
+
* @param key - The `queryClientKey`. Without it, the base key is used.
|
|
12
|
+
* @returns The injection key.
|
|
13
|
+
*/
|
|
6
14
|
function getClientKey(key) {
|
|
7
15
|
const suffix = key ? `:${key}` : "";
|
|
8
16
|
return `${VUE_QUERY_CLIENT}${suffix}`;
|
|
9
17
|
}
|
|
10
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Copies each property from `update` onto `state`, in place, for every key already on `state`.
|
|
20
|
+
* @internal
|
|
21
|
+
* @param state - The object to update.
|
|
22
|
+
* @param update - The object to copy the values from.
|
|
23
|
+
*/
|
|
11
24
|
function updateState(state, update) {
|
|
12
25
|
Object.keys(state).forEach((key) => {
|
|
13
26
|
state[key] = update[key];
|
|
14
27
|
});
|
|
15
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Recursive implementation of {@link cloneDeep}, which also tracks the key and nesting level of
|
|
31
|
+
* the current node for `customize`.
|
|
32
|
+
* @param value - The value to clone.
|
|
33
|
+
* @param customize - Called for every node with its key and nesting level. If it returns a value
|
|
34
|
+
* other than `undefined`, that value is used instead of recursing.
|
|
35
|
+
* @param currentKey - The key of the current node.
|
|
36
|
+
* @param currentLevel - The nesting level of the current node.
|
|
37
|
+
* @returns The cloned value.
|
|
38
|
+
*/
|
|
16
39
|
function _cloneDeep(value, customize, currentKey = "", currentLevel = 0) {
|
|
17
40
|
if (customize) {
|
|
18
41
|
const result = customize(value, currentKey, currentLevel);
|
|
@@ -27,18 +50,27 @@ function _cloneDeep(value, customize, currentKey = "", currentLevel = 0) {
|
|
|
27
50
|
return value;
|
|
28
51
|
}
|
|
29
52
|
/**
|
|
30
|
-
*
|
|
53
|
+
* Deep-clones `value`, recursing into arrays and plain objects. `customize`, if provided, can
|
|
31
54
|
* intercept any node (by key and nesting level) and substitute its own return value instead of recursing
|
|
32
55
|
* further.
|
|
56
|
+
* @internal
|
|
57
|
+
* @param value - The value to clone.
|
|
58
|
+
* @param customize - Called for every node with its key and nesting level. If it returns a value
|
|
59
|
+
* other than `undefined`, that value is used instead of recursing.
|
|
60
|
+
* @returns The cloned value.
|
|
33
61
|
*/
|
|
34
62
|
function cloneDeep(value, customize) {
|
|
35
63
|
return _cloneDeep(value, customize);
|
|
36
64
|
}
|
|
37
65
|
/**
|
|
38
|
-
*
|
|
66
|
+
* Deep-clones `value` like {@link cloneDeep}, additionally unwrapping any `ref`s it encounters (and,
|
|
39
67
|
* if `unrefGetters` is `true`, calling any functions it encounters and unwrapping their result too). Always
|
|
40
68
|
* resolves `queryKey` this way, regardless of `unrefGetters` — this is what lets a `queryKey` containing `ref`s
|
|
41
69
|
* be passed straight through to `@tanstack/query-core`.
|
|
70
|
+
* @internal
|
|
71
|
+
* @param obj - The value to clone.
|
|
72
|
+
* @param unrefGetters - Whether to also call functions and unwrap their result.
|
|
73
|
+
* @returns The cloned value, with `ref`s unwrapped.
|
|
42
74
|
*/
|
|
43
75
|
function cloneDeepUnref(obj, unrefGetters = false) {
|
|
44
76
|
return cloneDeep(obj, (val, key, level) => {
|
|
@@ -47,15 +79,31 @@ function cloneDeepUnref(obj, unrefGetters = false) {
|
|
|
47
79
|
if (isRef(val)) return cloneDeepUnref(unref(val), unrefGetters);
|
|
48
80
|
});
|
|
49
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Checks whether a value is a plain object, created with an object literal or
|
|
84
|
+
* `Object.create(null)`.
|
|
85
|
+
* @param value - The value to check.
|
|
86
|
+
* @returns `true` if `value` is a plain object.
|
|
87
|
+
*/
|
|
50
88
|
function isPlainObject(value) {
|
|
51
89
|
if (Object.prototype.toString.call(value) !== "[object Object]") return false;
|
|
52
90
|
const prototype = Object.getPrototypeOf(value);
|
|
53
91
|
return prototype === null || prototype === Object.prototype;
|
|
54
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Checks whether a value is a function.
|
|
95
|
+
* @param value - The value to check.
|
|
96
|
+
* @returns `true` if `value` is a function.
|
|
97
|
+
*/
|
|
55
98
|
function isFunction(value) {
|
|
56
99
|
return typeof value === "function";
|
|
57
100
|
}
|
|
58
|
-
/**
|
|
101
|
+
/**
|
|
102
|
+
* Resolves `source` to a plain value — calls it if it's a function, otherwise deep-unwraps it.
|
|
103
|
+
* @internal
|
|
104
|
+
* @param source - A getter, or a value that may contain `ref`s.
|
|
105
|
+
* @returns The resolved plain value.
|
|
106
|
+
*/
|
|
59
107
|
function toValueDeep(source) {
|
|
60
108
|
return isFunction(source) ? source() : cloneDeepUnref(source);
|
|
61
109
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../../src/utils.ts"],"sourcesContent":["import { isRef, unref } from 'vue-demi'\nimport type { MaybeRefDeep } from './types'\n\n
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../src/utils.ts"],"sourcesContent":["import { isRef, unref } from 'vue-demi'\nimport type { MaybeRefDeep } from './types'\n\n/**\n * Base Vue injection key `VueQueryPlugin` provides the `QueryClient` under.\n * @internal\n */\nexport const VUE_QUERY_CLIENT = 'VUE_QUERY_CLIENT'\n\n/**\n * Builds the injection key `useQueryClient`/`VueQueryPlugin` use for a given `queryClientKey`.\n * @internal\n * @param key - The `queryClientKey`. Without it, the base key is used.\n * @returns The injection key.\n */\nexport function getClientKey(key?: string) {\n const suffix = key ? `:${key}` : ''\n return `${VUE_QUERY_CLIENT}${suffix}`\n}\n\n/**\n * Copies each property from `update` onto `state`, in place, for every key already on `state`.\n * @internal\n * @param state - The object to update.\n * @param update - The object to copy the values from.\n */\nexport function updateState(\n state: Record<string, any>,\n update: Record<string, any>,\n): void {\n Object.keys(state).forEach((key) => {\n state[key] = update[key]\n })\n}\n\n/**\n * Recursive implementation of {@link cloneDeep}, which also tracks the key and nesting level of\n * the current node for `customize`.\n * @param value - The value to clone.\n * @param customize - Called for every node with its key and nesting level. If it returns a value\n * other than `undefined`, that value is used instead of recursing.\n * @param currentKey - The key of the current node.\n * @param currentLevel - The nesting level of the current node.\n * @returns The cloned value.\n */\nfunction _cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customize?: (\n val: MaybeRefDeep<T>,\n key: string,\n level: number,\n ) => T | undefined,\n currentKey: string = '',\n currentLevel: number = 0,\n): T {\n if (customize) {\n const result = customize(value, currentKey, currentLevel)\n if (result === undefined && isRef(value)) {\n return result as T\n }\n if (result !== undefined) {\n return result\n }\n }\n\n if (Array.isArray(value)) {\n return value.map((val, index) =>\n _cloneDeep(val, customize, String(index), currentLevel + 1),\n ) as unknown as T\n }\n\n if (typeof value === 'object' && isPlainObject(value)) {\n const entries = Object.entries(value).map(([key, val]) => [\n key,\n _cloneDeep(val, customize, key, currentLevel + 1),\n ])\n return Object.fromEntries(entries)\n }\n\n return value as T\n}\n\n/**\n * Deep-clones `value`, recursing into arrays and plain objects. `customize`, if provided, can\n * intercept any node (by key and nesting level) and substitute its own return value instead of recursing\n * further.\n * @internal\n * @param value - The value to clone.\n * @param customize - Called for every node with its key and nesting level. If it returns a value\n * other than `undefined`, that value is used instead of recursing.\n * @returns The cloned value.\n */\nexport function cloneDeep<T>(\n value: MaybeRefDeep<T>,\n customize?: (\n val: MaybeRefDeep<T>,\n key: string,\n level: number,\n ) => T | undefined,\n): T {\n return _cloneDeep(value, customize)\n}\n\n/**\n * Deep-clones `value` like {@link cloneDeep}, additionally unwrapping any `ref`s it encounters (and,\n * if `unrefGetters` is `true`, calling any functions it encounters and unwrapping their result too). Always\n * resolves `queryKey` this way, regardless of `unrefGetters` — this is what lets a `queryKey` containing `ref`s\n * be passed straight through to `@tanstack/query-core`.\n * @internal\n * @param obj - The value to clone.\n * @param unrefGetters - Whether to also call functions and unwrap their result.\n * @returns The cloned value, with `ref`s unwrapped.\n */\nexport function cloneDeepUnref<T>(\n obj: MaybeRefDeep<T>,\n unrefGetters = false,\n): T {\n return cloneDeep(obj, (val, key, level) => {\n // Check if we're at the top level and the key is 'queryKey'\n //\n // If so, take the recursive descent where we resolve\n // getters to values as well as refs.\n if (level === 1 && key === 'queryKey') {\n return cloneDeepUnref(val, true)\n }\n\n // Resolve getters to values if specified.\n if (unrefGetters && isFunction(val)) {\n // Cast due to older TS versions not allowing calling\n // on certain intersection types.\n return cloneDeepUnref((val as Function)(), unrefGetters)\n }\n\n // Unref refs and continue to recurse into the value.\n if (isRef(val)) {\n return cloneDeepUnref(unref(val), unrefGetters)\n }\n\n return undefined\n })\n}\n\n/**\n * Checks whether a value is a plain object, created with an object literal or\n * `Object.create(null)`.\n * @param value - The value to check.\n * @returns `true` if `value` is a plain object.\n */\n// oxlint-disable-next-line typescript/no-wrapper-object-types\nfunction isPlainObject(value: unknown): value is Object {\n if (Object.prototype.toString.call(value) !== '[object Object]') {\n return false\n }\n\n const prototype = Object.getPrototypeOf(value)\n return prototype === null || prototype === Object.prototype\n}\n\n/**\n * Checks whether a value is a function.\n * @param value - The value to check.\n * @returns `true` if `value` is a function.\n */\nfunction isFunction(value: unknown): value is Function {\n return typeof value === 'function'\n}\n\n/**\n * Resolves `source` to a plain value — calls it if it's a function, otherwise deep-unwraps it.\n * @internal\n * @param source - A getter, or a value that may contain `ref`s.\n * @returns The resolved plain value.\n */\nexport function toValueDeep<T>(source: (() => T) | MaybeRefDeep<T>): T {\n return isFunction(source) ? source() : cloneDeepUnref(source)\n}\n"],"mappings":";;;;;;AAOA,MAAa,mBAAmB;;;;;;;AAQhC,SAAgB,aAAa,KAAc;CACzC,MAAM,SAAS,MAAM,IAAI,QAAQ;CACjC,OAAO,GAAG,mBAAmB;AAC/B;;;;;;;AAQA,SAAgB,YACd,OACA,QACM;CACN,OAAO,KAAK,KAAK,CAAC,CAAC,SAAS,QAAQ;EAClC,MAAM,OAAO,OAAO;CACtB,CAAC;AACH;;;;;;;;;;;AAYA,SAAS,WACP,OACA,WAKA,aAAqB,IACrB,eAAuB,GACpB;CACH,IAAI,WAAW;EACb,MAAM,SAAS,UAAU,OAAO,YAAY,YAAY;EACxD,IAAI,WAAW,KAAA,KAAa,MAAM,KAAK,GACrC,OAAO;EAET,IAAI,WAAW,KAAA,GACb,OAAO;CAEX;CAEA,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,KAAK,KAAK,UACrB,WAAW,KAAK,WAAW,OAAO,KAAK,GAAG,eAAe,CAAC,CAC5D;CAGF,IAAI,OAAO,UAAU,YAAY,cAAc,KAAK,GAAG;EACrD,MAAM,UAAU,OAAO,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,SAAS,CACxD,KACA,WAAW,KAAK,WAAW,KAAK,eAAe,CAAC,CAClD,CAAC;EACD,OAAO,OAAO,YAAY,OAAO;CACnC;CAEA,OAAO;AACT;;;;;;;;;;;AAYA,SAAgB,UACd,OACA,WAKG;CACH,OAAO,WAAW,OAAO,SAAS;AACpC;;;;;;;;;;;AAYA,SAAgB,eACd,KACA,eAAe,OACZ;CACH,OAAO,UAAU,MAAM,KAAK,KAAK,UAAU;EAKzC,IAAI,UAAU,KAAK,QAAQ,YACzB,OAAO,eAAe,KAAK,IAAI;EAIjC,IAAI,gBAAgB,WAAW,GAAG,GAGhC,OAAO,eAAgB,IAAiB,GAAG,YAAY;EAIzD,IAAI,MAAM,GAAG,GACX,OAAO,eAAe,MAAM,GAAG,GAAG,YAAY;CAIlD,CAAC;AACH;;;;;;;AASA,SAAS,cAAc,OAAiC;CACtD,IAAI,OAAO,UAAU,SAAS,KAAK,KAAK,MAAM,mBAC5C,OAAO;CAGT,MAAM,YAAY,OAAO,eAAe,KAAK;CAC7C,OAAO,cAAc,QAAQ,cAAc,OAAO;AACpD;;;;;;AAOA,SAAS,WAAW,OAAmC;CACrD,OAAO,OAAO,UAAU;AAC1B;;;;;;;AAQA,SAAgB,YAAe,QAAwC;CACrE,OAAO,WAAW,MAAM,IAAI,OAAO,IAAI,eAAe,MAAM;AAC9D"}
|
|
@@ -9,7 +9,6 @@ let vue_demi = require("vue-demi");
|
|
|
9
9
|
* Installs a `QueryClient` on the Vue app, making it available to every descendant component through
|
|
10
10
|
* `useQueryClient` — the Vue equivalent of React's `QueryClientProvider`, but wired up as an app-level plugin
|
|
11
11
|
* instead of a wrapping component.
|
|
12
|
-
*
|
|
13
12
|
* @example
|
|
14
13
|
* ```ts
|
|
15
14
|
* import { createApp } from 'vue'
|
|
@@ -18,7 +17,6 @@ let vue_demi = require("vue-demi");
|
|
|
18
17
|
* const app = createApp(App)
|
|
19
18
|
* app.use(VueQueryPlugin)
|
|
20
19
|
* ```
|
|
21
|
-
*
|
|
22
20
|
* @example
|
|
23
21
|
* Pass a `queryClient` you constructed yourself — useful for SSR, where you need a fresh `QueryClient` per
|
|
24
22
|
* request, or when the same instance also needs to be used outside of Vue components:
|
|
@@ -28,7 +26,6 @@ let vue_demi = require("vue-demi");
|
|
|
28
26
|
* const queryClient = new QueryClient()
|
|
29
27
|
* app.use(VueQueryPlugin, { queryClient })
|
|
30
28
|
* ```
|
|
31
|
-
*
|
|
32
29
|
* @example
|
|
33
30
|
* Or pass `queryClientConfig` to let the plugin construct the `QueryClient` for you, with your own defaults:
|
|
34
31
|
* ```ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vueQueryPlugin.cjs","names":["getClientKey","QueryClient","environmentManager","isVue2"],"sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport { environmentManager } from '@tanstack/query-core'\n\nimport { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\nimport { setupDevtools } from './devtools/devtools'\nimport type { QueryClientConfig } from './types'\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n /** Enables the legacy Vue Devtools v6 plugin panel. Prefer `@tanstack/vue-query-devtools` for Vue 3 apps. */\n enableDevtoolsV6Plugin?: boolean\n /**\n * Distinguishes multiple `QueryClient`s provided in the same app — pass the same key to `useQueryClient` to\n * pick this one. Only needed when installing more than one client.\n */\n queryClientKey?: string\n /**\n * Restores a persisted cache before the app mounts. While it runs, `queryClient.isRestoring` is `true`, which\n * suppresses fetches — see `usePersistQueryClient` in `@tanstack/query-persist-client-core` for building one.\n */\n clientPersister?: ClientPersister\n /** Called once `clientPersister`'s returned promise resolves and the cache has finished restoring. */\n clientPersisterOnSuccess?: (client: QueryClient) => void\n}\n\ninterface ConfigOptions extends CommonOptions {\n /** Options for the `QueryClient` the plugin constructs. Ignored if `queryClient` is also set. */\n queryClientConfig?: QueryClientConfig\n}\n\ninterface ClientOptions extends CommonOptions {\n /** Use your own `QueryClient` instance instead of having the plugin construct one from `queryClientConfig`. */\n queryClient?: QueryClient\n}\n\nexport type VueQueryPluginOptions = ConfigOptions | ClientOptions\n\n/**\n * Installs a `QueryClient` on the Vue app, making it available to every descendant component through\n * `useQueryClient` — the Vue equivalent of React's `QueryClientProvider`, but wired up as an app-level plugin\n * instead of a wrapping component.\n
|
|
1
|
+
{"version":3,"file":"vueQueryPlugin.cjs","names":["getClientKey","QueryClient","environmentManager","isVue2"],"sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport { environmentManager } from '@tanstack/query-core'\n\nimport { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\nimport { setupDevtools } from './devtools/devtools'\nimport type { QueryClientConfig } from './types'\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n /** Enables the legacy Vue Devtools v6 plugin panel. Prefer `@tanstack/vue-query-devtools` for Vue 3 apps. */\n enableDevtoolsV6Plugin?: boolean\n /**\n * Distinguishes multiple `QueryClient`s provided in the same app — pass the same key to `useQueryClient` to\n * pick this one. Only needed when installing more than one client.\n */\n queryClientKey?: string\n /**\n * Restores a persisted cache before the app mounts. While it runs, `queryClient.isRestoring` is `true`, which\n * suppresses fetches — see `usePersistQueryClient` in `@tanstack/query-persist-client-core` for building one.\n */\n clientPersister?: ClientPersister\n /** Called once `clientPersister`'s returned promise resolves and the cache has finished restoring. */\n clientPersisterOnSuccess?: (client: QueryClient) => void\n}\n\ninterface ConfigOptions extends CommonOptions {\n /** Options for the `QueryClient` the plugin constructs. Ignored if `queryClient` is also set. */\n queryClientConfig?: QueryClientConfig\n}\n\ninterface ClientOptions extends CommonOptions {\n /** Use your own `QueryClient` instance instead of having the plugin construct one from `queryClientConfig`. */\n queryClient?: QueryClient\n}\n\n/**\n * The options accepted by `VueQueryPlugin`: either a `queryClient` to install, or a `queryClientConfig` for the\n * client the plugin creates, plus the shared options.\n */\nexport type VueQueryPluginOptions = ConfigOptions | ClientOptions\n\n/**\n * Installs a `QueryClient` on the Vue app, making it available to every descendant component through\n * `useQueryClient` — the Vue equivalent of React's `QueryClientProvider`, but wired up as an app-level plugin\n * instead of a wrapping component.\n * @example\n * ```ts\n * import { createApp } from 'vue'\n * import { VueQueryPlugin } from '@tanstack/vue-query'\n *\n * const app = createApp(App)\n * app.use(VueQueryPlugin)\n * ```\n * @example\n * Pass a `queryClient` you constructed yourself — useful for SSR, where you need a fresh `QueryClient` per\n * request, or when the same instance also needs to be used outside of Vue components:\n * ```ts\n * import { QueryClient, VueQueryPlugin } from '@tanstack/vue-query'\n *\n * const queryClient = new QueryClient()\n * app.use(VueQueryPlugin, { queryClient })\n * ```\n * @example\n * Or pass `queryClientConfig` to let the plugin construct the `QueryClient` for you, with your own defaults:\n * ```ts\n * app.use(VueQueryPlugin, {\n * queryClientConfig: {\n * defaultOptions: { queries: { staleTime: 5 * 1000 } },\n * },\n * })\n * ```\n */\nexport const VueQueryPlugin = {\n install: (app: any, options: VueQueryPluginOptions = {}) => {\n const clientKey = getClientKey(options.queryClientKey)\n let client: QueryClient\n\n if ('queryClient' in options && options.queryClient) {\n client = options.queryClient\n } else {\n const clientConfig =\n 'queryClientConfig' in options ? options.queryClientConfig : undefined\n client = new QueryClient(clientConfig)\n }\n\n if (!environmentManager.isServer()) {\n client.mount()\n }\n\n let persisterUnmount = () => {\n // noop\n }\n\n if (options.clientPersister) {\n if (client.isRestoring) {\n client.isRestoring.value = true\n }\n const [unmount, promise] = options.clientPersister(client)\n persisterUnmount = unmount\n promise.then(() => {\n if (client.isRestoring) {\n client.isRestoring.value = false\n }\n options.clientPersisterOnSuccess?.(client)\n })\n }\n\n const cleanup = () => {\n client.unmount()\n persisterUnmount()\n }\n\n if (app.onUnmount) {\n app.onUnmount(cleanup)\n } else {\n const originalUnmount = app.unmount\n app.unmount = function vueQueryUnmount() {\n cleanup()\n originalUnmount()\n }\n }\n\n if (isVue2) {\n app.mixin({\n beforeCreate() {\n // HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/master/src/apis/inject.ts#L30\n if (!this._provided) {\n const provideCache = {}\n Object.defineProperty(this, '_provided', {\n get: () => provideCache,\n set: (v) => Object.assign(provideCache, v),\n })\n }\n\n this._provided[clientKey] = client\n\n if (process.env.NODE_ENV === 'development') {\n if (this === this.$root && options.enableDevtoolsV6Plugin) {\n setupDevtools(this, client)\n }\n }\n },\n })\n } else {\n app.provide(clientKey, client)\n\n if (process.env.NODE_ENV === 'development') {\n if (options.enableDevtoolsV6Plugin) {\n setupDevtools(app, client)\n }\n }\n }\n },\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0EA,MAAa,iBAAiB,EAC5B,UAAU,KAAU,UAAiC,CAAC,MAAM;CAC1D,MAAM,YAAYA,cAAAA,aAAa,QAAQ,cAAc;CACrD,IAAI;CAEJ,IAAI,iBAAiB,WAAW,QAAQ,aACtC,SAAS,QAAQ;MACZ;EACL,MAAM,eACJ,uBAAuB,UAAU,QAAQ,oBAAoB,KAAA;EAC/D,SAAS,IAAIC,oBAAAA,YAAY,YAAY;CACvC;CAEA,IAAI,CAACC,qBAAAA,mBAAmB,SAAS,GAC/B,OAAO,MAAM;CAGf,IAAI,yBAAyB,CAE7B;CAEA,IAAI,QAAQ,iBAAiB;EAC3B,IAAI,OAAO,aACT,OAAO,YAAY,QAAQ;EAE7B,MAAM,CAAC,SAAS,WAAW,QAAQ,gBAAgB,MAAM;EACzD,mBAAmB;EACnB,QAAQ,WAAW;;GACjB,IAAI,OAAO,aACT,OAAO,YAAY,QAAQ;GAE7B,CAAA,wBAAA,QAAQ,8BAAA,QAAA,0BAAA,KAAA,KAAA,sBAAA,KAAA,SAA2B,MAAM;EAC3C,CAAC;CACH;CAEA,MAAM,gBAAgB;EACpB,OAAO,QAAQ;EACf,iBAAiB;CACnB;CAEA,IAAI,IAAI,WACN,IAAI,UAAU,OAAO;MAChB;EACL,MAAM,kBAAkB,IAAI;EAC5B,IAAI,UAAU,SAAS,kBAAkB;GACvC,QAAQ;GACR,gBAAgB;EAClB;CACF;CAEA,IAAIC,SAAAA,QACF,IAAI,MAAM,EACR,eAAe;EAEb,IAAI,CAAC,KAAK,WAAW;GACnB,MAAM,eAAe,CAAC;GACtB,OAAO,eAAe,MAAM,aAAa;IACvC,WAAW;IACX,MAAM,MAAM,OAAO,OAAO,cAAc,CAAC;GAC3C,CAAC;EACH;EAEA,KAAK,UAAU,aAAa;EAE5B,IAAI,QAAQ,IAAI,aAAa,eACvB;OAAA,SAAS,KAAK,SAAS,QAAQ,wBACjC,0BAAA,cAAc,MAAM,MAAM;EAAA;CAGhC,EACF,CAAC;MACI;EACL,IAAI,QAAQ,WAAW,MAAM;EAE7B,IAAI,QAAQ,IAAI,aAAa,eACvB;OAAA,QAAQ,wBACV,0BAAA,cAAc,KAAK,MAAM;EAAA;CAG/B;AACF,EACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { u as QueryClientConfig } from "./types-
|
|
2
|
-
import { t as QueryClient } from "./queryClient-
|
|
1
|
+
import { u as QueryClientConfig } from "./types-sdZdiLgo.cjs";
|
|
2
|
+
import { t as QueryClient } from "./queryClient-BK9W57Qu.cjs";
|
|
3
3
|
//#region src/vueQueryPlugin.d.ts
|
|
4
4
|
type ClientPersister = (client: QueryClient) => [() => void, Promise<void>];
|
|
5
5
|
interface CommonOptions {
|
|
@@ -26,12 +26,15 @@ interface ClientOptions extends CommonOptions {
|
|
|
26
26
|
/** Use your own `QueryClient` instance instead of having the plugin construct one from `queryClientConfig`. */
|
|
27
27
|
queryClient?: QueryClient;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* The options accepted by `VueQueryPlugin`: either a `queryClient` to install, or a `queryClientConfig` for the
|
|
31
|
+
* client the plugin creates, plus the shared options.
|
|
32
|
+
*/
|
|
29
33
|
export type VueQueryPluginOptions = ConfigOptions | ClientOptions;
|
|
30
34
|
/**
|
|
31
35
|
* Installs a `QueryClient` on the Vue app, making it available to every descendant component through
|
|
32
36
|
* `useQueryClient` — the Vue equivalent of React's `QueryClientProvider`, but wired up as an app-level plugin
|
|
33
37
|
* instead of a wrapping component.
|
|
34
|
-
*
|
|
35
38
|
* @example
|
|
36
39
|
* ```ts
|
|
37
40
|
* import { createApp } from 'vue'
|
|
@@ -40,7 +43,6 @@ export type VueQueryPluginOptions = ConfigOptions | ClientOptions;
|
|
|
40
43
|
* const app = createApp(App)
|
|
41
44
|
* app.use(VueQueryPlugin)
|
|
42
45
|
* ```
|
|
43
|
-
*
|
|
44
46
|
* @example
|
|
45
47
|
* Pass a `queryClient` you constructed yourself — useful for SSR, where you need a fresh `QueryClient` per
|
|
46
48
|
* request, or when the same instance also needs to be used outside of Vue components:
|
|
@@ -50,7 +52,6 @@ export type VueQueryPluginOptions = ConfigOptions | ClientOptions;
|
|
|
50
52
|
* const queryClient = new QueryClient()
|
|
51
53
|
* app.use(VueQueryPlugin, { queryClient })
|
|
52
54
|
* ```
|
|
53
|
-
*
|
|
54
55
|
* @example
|
|
55
56
|
* Or pass `queryClientConfig` to let the plugin construct the `QueryClient` for you, with your own defaults:
|
|
56
57
|
* ```ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vueQueryPlugin.d.cts","names":[],"sources":["../../src/vueQueryPlugin.ts"],"mappings":";;;KAQK,mBAAmB,QAAQ,6BAA6B;UAEnD;;EAER;;;;;EAKA;;;;;EAKA,kBAAkB;;EAElB,4BAA4B,QAAQ;;UAG5B,sBAAsB;;EAE9B,oBAAoB;;UAGZ,sBAAsB;;EAE9B,cAAc
|
|
1
|
+
{"version":3,"file":"vueQueryPlugin.d.cts","names":[],"sources":["../../src/vueQueryPlugin.ts"],"mappings":";;;KAQK,mBAAmB,QAAQ,6BAA6B;UAEnD;;EAER;;;;;EAKA;;;;;EAKA,kBAAkB;;EAElB,4BAA4B,QAAQ;;UAG5B,sBAAsB;;EAE9B,oBAAoB;;UAGZ,sBAAsB;;EAE9B,cAAc;;;;;;YAOJ,wBAAwB,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAiCvC;EACI,UAAA,UAAG,UAAW"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { u as QueryClientConfig } from "./types-
|
|
2
|
-
import { t as QueryClient } from "./queryClient-
|
|
1
|
+
import { u as QueryClientConfig } from "./types-sdZdiLgo.js";
|
|
2
|
+
import { t as QueryClient } from "./queryClient-BoBzDWAZ.js";
|
|
3
3
|
//#region src/vueQueryPlugin.d.ts
|
|
4
4
|
type ClientPersister = (client: QueryClient) => [() => void, Promise<void>];
|
|
5
5
|
interface CommonOptions {
|
|
@@ -26,12 +26,15 @@ interface ClientOptions extends CommonOptions {
|
|
|
26
26
|
/** Use your own `QueryClient` instance instead of having the plugin construct one from `queryClientConfig`. */
|
|
27
27
|
queryClient?: QueryClient;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* The options accepted by `VueQueryPlugin`: either a `queryClient` to install, or a `queryClientConfig` for the
|
|
31
|
+
* client the plugin creates, plus the shared options.
|
|
32
|
+
*/
|
|
29
33
|
export type VueQueryPluginOptions = ConfigOptions | ClientOptions;
|
|
30
34
|
/**
|
|
31
35
|
* Installs a `QueryClient` on the Vue app, making it available to every descendant component through
|
|
32
36
|
* `useQueryClient` — the Vue equivalent of React's `QueryClientProvider`, but wired up as an app-level plugin
|
|
33
37
|
* instead of a wrapping component.
|
|
34
|
-
*
|
|
35
38
|
* @example
|
|
36
39
|
* ```ts
|
|
37
40
|
* import { createApp } from 'vue'
|
|
@@ -40,7 +43,6 @@ export type VueQueryPluginOptions = ConfigOptions | ClientOptions;
|
|
|
40
43
|
* const app = createApp(App)
|
|
41
44
|
* app.use(VueQueryPlugin)
|
|
42
45
|
* ```
|
|
43
|
-
*
|
|
44
46
|
* @example
|
|
45
47
|
* Pass a `queryClient` you constructed yourself — useful for SSR, where you need a fresh `QueryClient` per
|
|
46
48
|
* request, or when the same instance also needs to be used outside of Vue components:
|
|
@@ -50,7 +52,6 @@ export type VueQueryPluginOptions = ConfigOptions | ClientOptions;
|
|
|
50
52
|
* const queryClient = new QueryClient()
|
|
51
53
|
* app.use(VueQueryPlugin, { queryClient })
|
|
52
54
|
* ```
|
|
53
|
-
*
|
|
54
55
|
* @example
|
|
55
56
|
* Or pass `queryClientConfig` to let the plugin construct the `QueryClient` for you, with your own defaults:
|
|
56
57
|
* ```ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vueQueryPlugin.d.ts","names":[],"sources":["../../src/vueQueryPlugin.ts"],"mappings":";;;KAQK,mBAAmB,QAAQ,6BAA6B;UAEnD;;EAER;;;;;EAKA;;;;;EAKA,kBAAkB;;EAElB,4BAA4B,QAAQ;;UAG5B,sBAAsB;;EAE9B,oBAAoB;;UAGZ,sBAAsB;;EAE9B,cAAc
|
|
1
|
+
{"version":3,"file":"vueQueryPlugin.d.ts","names":[],"sources":["../../src/vueQueryPlugin.ts"],"mappings":";;;KAQK,mBAAmB,QAAQ,6BAA6B;UAEnD;;EAER;;;;;EAKA;;;;;EAKA,kBAAkB;;EAElB,4BAA4B,QAAQ;;UAG5B,sBAAsB;;EAE9B,oBAAoB;;UAGZ,sBAAsB;;EAE9B,cAAc;;;;;;YAOJ,wBAAwB,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAiCvC;EACI,UAAA,UAAG,UAAW"}
|
|
@@ -8,7 +8,6 @@ import { isVue2 } from "vue-demi";
|
|
|
8
8
|
* Installs a `QueryClient` on the Vue app, making it available to every descendant component through
|
|
9
9
|
* `useQueryClient` — the Vue equivalent of React's `QueryClientProvider`, but wired up as an app-level plugin
|
|
10
10
|
* instead of a wrapping component.
|
|
11
|
-
*
|
|
12
11
|
* @example
|
|
13
12
|
* ```ts
|
|
14
13
|
* import { createApp } from 'vue'
|
|
@@ -17,7 +16,6 @@ import { isVue2 } from "vue-demi";
|
|
|
17
16
|
* const app = createApp(App)
|
|
18
17
|
* app.use(VueQueryPlugin)
|
|
19
18
|
* ```
|
|
20
|
-
*
|
|
21
19
|
* @example
|
|
22
20
|
* Pass a `queryClient` you constructed yourself — useful for SSR, where you need a fresh `QueryClient` per
|
|
23
21
|
* request, or when the same instance also needs to be used outside of Vue components:
|
|
@@ -27,7 +25,6 @@ import { isVue2 } from "vue-demi";
|
|
|
27
25
|
* const queryClient = new QueryClient()
|
|
28
26
|
* app.use(VueQueryPlugin, { queryClient })
|
|
29
27
|
* ```
|
|
30
|
-
*
|
|
31
28
|
* @example
|
|
32
29
|
* Or pass `queryClientConfig` to let the plugin construct the `QueryClient` for you, with your own defaults:
|
|
33
30
|
* ```ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vueQueryPlugin.js","names":["QueryClient"],"sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport { environmentManager } from '@tanstack/query-core'\n\nimport { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\nimport { setupDevtools } from './devtools/devtools'\nimport type { QueryClientConfig } from './types'\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n /** Enables the legacy Vue Devtools v6 plugin panel. Prefer `@tanstack/vue-query-devtools` for Vue 3 apps. */\n enableDevtoolsV6Plugin?: boolean\n /**\n * Distinguishes multiple `QueryClient`s provided in the same app — pass the same key to `useQueryClient` to\n * pick this one. Only needed when installing more than one client.\n */\n queryClientKey?: string\n /**\n * Restores a persisted cache before the app mounts. While it runs, `queryClient.isRestoring` is `true`, which\n * suppresses fetches — see `usePersistQueryClient` in `@tanstack/query-persist-client-core` for building one.\n */\n clientPersister?: ClientPersister\n /** Called once `clientPersister`'s returned promise resolves and the cache has finished restoring. */\n clientPersisterOnSuccess?: (client: QueryClient) => void\n}\n\ninterface ConfigOptions extends CommonOptions {\n /** Options for the `QueryClient` the plugin constructs. Ignored if `queryClient` is also set. */\n queryClientConfig?: QueryClientConfig\n}\n\ninterface ClientOptions extends CommonOptions {\n /** Use your own `QueryClient` instance instead of having the plugin construct one from `queryClientConfig`. */\n queryClient?: QueryClient\n}\n\nexport type VueQueryPluginOptions = ConfigOptions | ClientOptions\n\n/**\n * Installs a `QueryClient` on the Vue app, making it available to every descendant component through\n * `useQueryClient` — the Vue equivalent of React's `QueryClientProvider`, but wired up as an app-level plugin\n * instead of a wrapping component.\n
|
|
1
|
+
{"version":3,"file":"vueQueryPlugin.js","names":["QueryClient"],"sources":["../../src/vueQueryPlugin.ts"],"sourcesContent":["import { isVue2 } from 'vue-demi'\nimport { environmentManager } from '@tanstack/query-core'\n\nimport { QueryClient } from './queryClient'\nimport { getClientKey } from './utils'\nimport { setupDevtools } from './devtools/devtools'\nimport type { QueryClientConfig } from './types'\n\ntype ClientPersister = (client: QueryClient) => [() => void, Promise<void>]\n\ninterface CommonOptions {\n /** Enables the legacy Vue Devtools v6 plugin panel. Prefer `@tanstack/vue-query-devtools` for Vue 3 apps. */\n enableDevtoolsV6Plugin?: boolean\n /**\n * Distinguishes multiple `QueryClient`s provided in the same app — pass the same key to `useQueryClient` to\n * pick this one. Only needed when installing more than one client.\n */\n queryClientKey?: string\n /**\n * Restores a persisted cache before the app mounts. While it runs, `queryClient.isRestoring` is `true`, which\n * suppresses fetches — see `usePersistQueryClient` in `@tanstack/query-persist-client-core` for building one.\n */\n clientPersister?: ClientPersister\n /** Called once `clientPersister`'s returned promise resolves and the cache has finished restoring. */\n clientPersisterOnSuccess?: (client: QueryClient) => void\n}\n\ninterface ConfigOptions extends CommonOptions {\n /** Options for the `QueryClient` the plugin constructs. Ignored if `queryClient` is also set. */\n queryClientConfig?: QueryClientConfig\n}\n\ninterface ClientOptions extends CommonOptions {\n /** Use your own `QueryClient` instance instead of having the plugin construct one from `queryClientConfig`. */\n queryClient?: QueryClient\n}\n\n/**\n * The options accepted by `VueQueryPlugin`: either a `queryClient` to install, or a `queryClientConfig` for the\n * client the plugin creates, plus the shared options.\n */\nexport type VueQueryPluginOptions = ConfigOptions | ClientOptions\n\n/**\n * Installs a `QueryClient` on the Vue app, making it available to every descendant component through\n * `useQueryClient` — the Vue equivalent of React's `QueryClientProvider`, but wired up as an app-level plugin\n * instead of a wrapping component.\n * @example\n * ```ts\n * import { createApp } from 'vue'\n * import { VueQueryPlugin } from '@tanstack/vue-query'\n *\n * const app = createApp(App)\n * app.use(VueQueryPlugin)\n * ```\n * @example\n * Pass a `queryClient` you constructed yourself — useful for SSR, where you need a fresh `QueryClient` per\n * request, or when the same instance also needs to be used outside of Vue components:\n * ```ts\n * import { QueryClient, VueQueryPlugin } from '@tanstack/vue-query'\n *\n * const queryClient = new QueryClient()\n * app.use(VueQueryPlugin, { queryClient })\n * ```\n * @example\n * Or pass `queryClientConfig` to let the plugin construct the `QueryClient` for you, with your own defaults:\n * ```ts\n * app.use(VueQueryPlugin, {\n * queryClientConfig: {\n * defaultOptions: { queries: { staleTime: 5 * 1000 } },\n * },\n * })\n * ```\n */\nexport const VueQueryPlugin = {\n install: (app: any, options: VueQueryPluginOptions = {}) => {\n const clientKey = getClientKey(options.queryClientKey)\n let client: QueryClient\n\n if ('queryClient' in options && options.queryClient) {\n client = options.queryClient\n } else {\n const clientConfig =\n 'queryClientConfig' in options ? options.queryClientConfig : undefined\n client = new QueryClient(clientConfig)\n }\n\n if (!environmentManager.isServer()) {\n client.mount()\n }\n\n let persisterUnmount = () => {\n // noop\n }\n\n if (options.clientPersister) {\n if (client.isRestoring) {\n client.isRestoring.value = true\n }\n const [unmount, promise] = options.clientPersister(client)\n persisterUnmount = unmount\n promise.then(() => {\n if (client.isRestoring) {\n client.isRestoring.value = false\n }\n options.clientPersisterOnSuccess?.(client)\n })\n }\n\n const cleanup = () => {\n client.unmount()\n persisterUnmount()\n }\n\n if (app.onUnmount) {\n app.onUnmount(cleanup)\n } else {\n const originalUnmount = app.unmount\n app.unmount = function vueQueryUnmount() {\n cleanup()\n originalUnmount()\n }\n }\n\n if (isVue2) {\n app.mixin({\n beforeCreate() {\n // HACK: taken from provide(): https://github.com/vuejs/composition-api/blob/master/src/apis/inject.ts#L30\n if (!this._provided) {\n const provideCache = {}\n Object.defineProperty(this, '_provided', {\n get: () => provideCache,\n set: (v) => Object.assign(provideCache, v),\n })\n }\n\n this._provided[clientKey] = client\n\n if (process.env.NODE_ENV === 'development') {\n if (this === this.$root && options.enableDevtoolsV6Plugin) {\n setupDevtools(this, client)\n }\n }\n },\n })\n } else {\n app.provide(clientKey, client)\n\n if (process.env.NODE_ENV === 'development') {\n if (options.enableDevtoolsV6Plugin) {\n setupDevtools(app, client)\n }\n }\n }\n },\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0EA,MAAa,iBAAiB,EAC5B,UAAU,KAAU,UAAiC,CAAC,MAAM;CAC1D,MAAM,YAAY,aAAa,QAAQ,cAAc;CACrD,IAAI;CAEJ,IAAI,iBAAiB,WAAW,QAAQ,aACtC,SAAS,QAAQ;MACZ;EACL,MAAM,eACJ,uBAAuB,UAAU,QAAQ,oBAAoB,KAAA;EAC/D,SAAS,IAAIA,cAAY,YAAY;CACvC;CAEA,IAAI,CAAC,mBAAmB,SAAS,GAC/B,OAAO,MAAM;CAGf,IAAI,yBAAyB,CAE7B;CAEA,IAAI,QAAQ,iBAAiB;EAC3B,IAAI,OAAO,aACT,OAAO,YAAY,QAAQ;EAE7B,MAAM,CAAC,SAAS,WAAW,QAAQ,gBAAgB,MAAM;EACzD,mBAAmB;EACnB,QAAQ,WAAW;;GACjB,IAAI,OAAO,aACT,OAAO,YAAY,QAAQ;GAE7B,CAAA,wBAAA,QAAQ,8BAAA,QAAA,0BAAA,KAAA,KAAA,sBAAA,KAAA,SAA2B,MAAM;EAC3C,CAAC;CACH;CAEA,MAAM,gBAAgB;EACpB,OAAO,QAAQ;EACf,iBAAiB;CACnB;CAEA,IAAI,IAAI,WACN,IAAI,UAAU,OAAO;MAChB;EACL,MAAM,kBAAkB,IAAI;EAC5B,IAAI,UAAU,SAAS,kBAAkB;GACvC,QAAQ;GACR,gBAAgB;EAClB;CACF;CAEA,IAAI,QACF,IAAI,MAAM,EACR,eAAe;EAEb,IAAI,CAAC,KAAK,WAAW;GACnB,MAAM,eAAe,CAAC;GACtB,OAAO,eAAe,MAAM,aAAa;IACvC,WAAW;IACX,MAAM,MAAM,OAAO,OAAO,cAAc,CAAC;GAC3C,CAAC;EACH;EAEA,KAAK,UAAU,aAAa;EAE5B,IAAI,QAAQ,IAAI,aAAa,eACvB;OAAA,SAAS,KAAK,SAAS,QAAQ,wBACjC,cAAc,MAAM,MAAM;EAAA;CAGhC,EACF,CAAC;MACI;EACL,IAAI,QAAQ,WAAW,MAAM;EAE7B,IAAI,QAAQ,IAAI,aAAa,eACvB;OAAA,QAAQ,wBACV,cAAc,KAAK,MAAM;EAAA;CAG/B;AACF,EACF"}
|
|
@@ -6,6 +6,12 @@ let _tanstack_match_sorter_utils = require("@tanstack/match-sorter-utils");
|
|
|
6
6
|
//#region src/devtools/devtools.ts
|
|
7
7
|
const pluginId = "vue-query";
|
|
8
8
|
const pluginName = "Vue Query";
|
|
9
|
+
/**
|
|
10
|
+
* Registers the Vue Query plugin with the Vue devtools, adding a query inspector and a timeline
|
|
11
|
+
* layer for query cache events.
|
|
12
|
+
* @param app - The Vue app instance.
|
|
13
|
+
* @param queryClient - The client whose query cache is shown in the devtools.
|
|
14
|
+
*/
|
|
9
15
|
function setupDevtools(app, queryClient) {
|
|
10
16
|
(0, _vue_devtools_api.setupDevtoolsPlugin)({
|
|
11
17
|
id: pluginId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devtools.cjs","names":["sortFns","rankItem","getQueryStateLabel","getQueryStatusFg","getQueryStatusBg"],"sources":["../../../src/devtools/devtools.ts"],"sourcesContent":["import { setupDevtoolsPlugin } from '@vue/devtools-api'\nimport { rankItem } from '@tanstack/match-sorter-utils'\nimport { onlineManager } from '@tanstack/query-core'\nimport {\n getQueryStateLabel,\n getQueryStatusBg,\n getQueryStatusFg,\n sortFns,\n} from './utils'\nimport type { CustomInspectorNode } from '@vue/devtools-api'\nimport type { Query, QueryCacheNotifyEvent } from '@tanstack/query-core'\nimport type { QueryClient } from '../queryClient'\n\nconst pluginId = 'vue-query'\nconst pluginName = 'Vue Query'\n\nexport function setupDevtools(app: any, queryClient: QueryClient) {\n setupDevtoolsPlugin(\n {\n id: pluginId,\n label: pluginName,\n packageName: 'vue-query',\n homepage: 'https://tanstack.com/query/latest',\n logo: 'https://raw.githubusercontent.com/TanStack/query/main/packages/vue-query/media/vue-query.svg',\n app,\n settings: {\n baseSort: {\n type: 'choice',\n component: 'button-group',\n label: 'Sort Cache Entries',\n options: [\n {\n label: 'ASC',\n value: 1,\n },\n {\n label: 'DESC',\n value: -1,\n },\n ],\n defaultValue: 1,\n },\n sortFn: {\n type: 'choice',\n label: 'Sort Function',\n options: Object.keys(sortFns).map((key) => ({\n label: key,\n value: key,\n })),\n defaultValue: Object.keys(sortFns)[0]!,\n },\n onlineMode: {\n type: 'choice',\n component: 'button-group',\n label: 'Online mode',\n options: [\n {\n label: 'Online',\n value: 1,\n },\n {\n label: 'Offline',\n value: 0,\n },\n ],\n defaultValue: 1,\n },\n },\n },\n (api) => {\n const initialSettings = api.getSettings()\n onlineManager.setOnline(Boolean(initialSettings.onlineMode.valueOf()))\n\n const queryCache = queryClient.getQueryCache()\n\n api.addInspector({\n id: pluginId,\n label: pluginName,\n icon: 'api',\n nodeActions: [\n {\n icon: 'file_download',\n tooltip: 'Refetch',\n action: (queryHash: string) => {\n queryCache.get(queryHash)?.fetch()\n },\n },\n {\n icon: 'alarm',\n tooltip: 'Invalidate',\n action: (queryHash: string) => {\n const query = queryCache.get(queryHash) as Query\n queryClient.invalidateQueries({\n queryKey: query.queryKey,\n exact: true,\n })\n },\n },\n {\n icon: 'settings_backup_restore',\n tooltip: 'Reset',\n action: (queryHash: string) => {\n queryCache.get(queryHash)?.reset()\n },\n },\n {\n icon: 'delete',\n tooltip: 'Remove',\n action: (queryHash: string) => {\n const query = queryCache.get(queryHash) as Query\n queryCache.remove(query)\n },\n },\n {\n icon: 'hourglass_empty',\n tooltip: 'Force loading',\n action: (queryHash: string) => {\n const query = queryCache.get(queryHash) as Query\n\n query.setState({\n data: undefined,\n status: 'pending',\n })\n },\n },\n {\n icon: 'error_outline',\n tooltip: 'Force error',\n action: (queryHash: string) => {\n const query = queryCache.get(queryHash) as Query\n\n query.setState({\n data: undefined,\n status: 'error',\n error: new Error('Unknown error from devtools'),\n })\n },\n },\n ],\n })\n\n api.addTimelineLayer({\n id: pluginId,\n label: pluginName,\n color: 0xffd94c,\n })\n\n queryCache.subscribe((event) => {\n api.sendInspectorTree(pluginId)\n api.sendInspectorState(pluginId)\n\n const queryEvents: Array<QueryCacheNotifyEvent['type']> = [\n 'added',\n 'removed',\n 'updated',\n ]\n\n if (queryEvents.includes(event.type)) {\n api.addTimelineEvent({\n layerId: pluginId,\n event: {\n title: event.type,\n subtitle: event.query.queryHash,\n time: api.now(),\n data: {\n queryHash: event.query.queryHash,\n ...event,\n },\n },\n })\n }\n })\n\n api.on.setPluginSettings((payload) => {\n if (payload.key === 'onlineMode') {\n onlineManager.setOnline(Boolean(payload.newValue))\n }\n })\n\n api.on.getInspectorTree((payload) => {\n if (payload.inspectorId === pluginId) {\n const queries = queryCache.getAll()\n const settings = api.getSettings()\n\n const filtered = payload.filter\n ? queries.filter(\n (item) => rankItem(item.queryHash, payload.filter).passed,\n )\n : [...queries]\n\n const sorted = filtered.sort(\n (a, b) => sortFns[settings.sortFn]!(a, b) * settings.baseSort,\n )\n\n const nodes: Array<CustomInspectorNode> = sorted.map((query) => {\n const stateLabel = getQueryStateLabel(query)\n\n return {\n id: query.queryHash,\n label: query.queryHash,\n tags: [\n {\n label: `${stateLabel} [${query.getObserversCount()}]`,\n textColor: getQueryStatusFg(query),\n backgroundColor: getQueryStatusBg(query),\n },\n ],\n }\n })\n payload.rootNodes = nodes\n }\n })\n\n api.on.getInspectorState((payload) => {\n if (payload.inspectorId === pluginId) {\n const query = queryCache.get(payload.nodeId)\n\n if (!query) {\n return\n }\n\n payload.state = {\n ' Query Details': [\n {\n key: 'Query key',\n value: query.queryHash,\n },\n {\n key: 'Query status',\n value: getQueryStateLabel(query),\n },\n {\n key: 'Observers',\n value: query.getObserversCount(),\n },\n {\n key: 'Last Updated',\n value: new Date(query.state.dataUpdatedAt).toLocaleTimeString(),\n },\n ],\n 'Data Explorer': [\n {\n key: 'Data',\n value: query.state.data,\n },\n ],\n 'Query Explorer': [\n {\n key: 'Query',\n value: query,\n },\n ],\n }\n }\n })\n },\n )\n}\n"],"mappings":";;;;;;AAaA,MAAM,WAAW;AACjB,MAAM,aAAa;AAEnB,SAAgB,cAAc,KAAU,aAA0B;CAChE,CAAA,GAAA,kBAAA,oBAAA,CACE;EACE,IAAI;EACJ,OAAO;EACP,aAAa;EACb,UAAU;EACV,MAAM;EACN;EACA,UAAU;GACR,UAAU;IACR,MAAM;IACN,WAAW;IACX,OAAO;IACP,SAAS,CACP;KACE,OAAO;KACP,OAAO;IACT,GACA;KACE,OAAO;KACP,OAAO;IACT,CACF;IACA,cAAc;GAChB;GACA,QAAQ;IACN,MAAM;IACN,OAAO;IACP,SAAS,OAAO,KAAKA,uBAAAA,OAAO,CAAC,CAAC,KAAK,SAAS;KAC1C,OAAO;KACP,OAAO;IACT,EAAE;IACF,cAAc,OAAO,KAAKA,uBAAAA,OAAO,CAAC,CAAC;GACrC;GACA,YAAY;IACV,MAAM;IACN,WAAW;IACX,OAAO;IACP,SAAS,CACP;KACE,OAAO;KACP,OAAO;IACT,GACA;KACE,OAAO;KACP,OAAO;IACT,CACF;IACA,cAAc;GAChB;EACF;CACF,IACC,QAAQ;EACP,MAAM,kBAAkB,IAAI,YAAY;EACxC,qBAAA,cAAc,UAAU,QAAQ,gBAAgB,WAAW,QAAQ,CAAC,CAAC;EAErE,MAAM,aAAa,YAAY,cAAc;EAE7C,IAAI,aAAa;GACf,IAAI;GACJ,OAAO;GACP,MAAM;GACN,aAAa;IACX;KACE,MAAM;KACN,SAAS;KACT,SAAS,cAAsB;MAC7B,WAAW,IAAI,SAAS,CAAC,EAAE,MAAM;KACnC;IACF;IACA;KACE,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Fns","rankItem","getQueryStateLabel","getQueryStatusFg","getQueryStatusBg"],"sources":["../../../src/devtools/devtools.ts"],"sourcesContent":["import { setupDevtoolsPlugin } from '@vue/devtools-api'\nimport { rankItem } from '@tanstack/match-sorter-utils'\nimport { onlineManager } from '@tanstack/query-core'\nimport {\n getQueryStateLabel,\n getQueryStatusBg,\n getQueryStatusFg,\n sortFns,\n} from './utils'\nimport type { CustomInspectorNode } from '@vue/devtools-api'\nimport type { Query, QueryCacheNotifyEvent } from '@tanstack/query-core'\nimport type { QueryClient } from '../queryClient'\n\nconst pluginId = 'vue-query'\nconst pluginName = 'Vue Query'\n\n/**\n * Registers the Vue Query plugin with the Vue devtools, adding a query inspector and a timeline\n * layer for query cache events.\n * @param app - The Vue app instance.\n * @param queryClient - The client whose query cache is shown in the devtools.\n */\nexport function setupDevtools(app: any, queryClient: QueryClient) {\n setupDevtoolsPlugin(\n {\n id: pluginId,\n label: pluginName,\n packageName: 'vue-query',\n homepage: 'https://tanstack.com/query/latest',\n logo: 'https://raw.githubusercontent.com/TanStack/query/main/packages/vue-query/media/vue-query.svg',\n app,\n settings: {\n baseSort: {\n type: 'choice',\n component: 'button-group',\n label: 'Sort Cache Entries',\n options: [\n {\n label: 'ASC',\n value: 1,\n },\n {\n label: 'DESC',\n value: -1,\n },\n ],\n defaultValue: 1,\n },\n sortFn: {\n type: 'choice',\n label: 'Sort Function',\n options: Object.keys(sortFns).map((key) => ({\n label: key,\n value: key,\n })),\n defaultValue: Object.keys(sortFns)[0]!,\n },\n onlineMode: {\n type: 'choice',\n component: 'button-group',\n label: 'Online mode',\n options: [\n {\n label: 'Online',\n value: 1,\n },\n {\n label: 'Offline',\n value: 0,\n },\n ],\n defaultValue: 1,\n },\n },\n },\n (api) => {\n const initialSettings = api.getSettings()\n onlineManager.setOnline(Boolean(initialSettings.onlineMode.valueOf()))\n\n const queryCache = queryClient.getQueryCache()\n\n api.addInspector({\n id: pluginId,\n label: pluginName,\n icon: 'api',\n nodeActions: [\n {\n icon: 'file_download',\n tooltip: 'Refetch',\n action: (queryHash: string) => {\n queryCache.get(queryHash)?.fetch()\n },\n },\n {\n icon: 'alarm',\n tooltip: 'Invalidate',\n action: (queryHash: string) => {\n const query = queryCache.get(queryHash) as Query\n queryClient.invalidateQueries({\n queryKey: query.queryKey,\n exact: true,\n })\n },\n },\n {\n icon: 'settings_backup_restore',\n tooltip: 'Reset',\n action: (queryHash: string) => {\n queryCache.get(queryHash)?.reset()\n },\n },\n {\n icon: 'delete',\n tooltip: 'Remove',\n action: (queryHash: string) => {\n const query = queryCache.get(queryHash) as Query\n queryCache.remove(query)\n },\n },\n {\n icon: 'hourglass_empty',\n tooltip: 'Force loading',\n action: (queryHash: string) => {\n const query = queryCache.get(queryHash) as Query\n\n query.setState({\n data: undefined,\n status: 'pending',\n })\n },\n },\n {\n icon: 'error_outline',\n tooltip: 'Force error',\n action: (queryHash: string) => {\n const query = queryCache.get(queryHash) as Query\n\n query.setState({\n data: undefined,\n status: 'error',\n error: new Error('Unknown error from devtools'),\n })\n },\n },\n ],\n })\n\n api.addTimelineLayer({\n id: pluginId,\n label: pluginName,\n color: 0xffd94c,\n })\n\n queryCache.subscribe((event) => {\n api.sendInspectorTree(pluginId)\n api.sendInspectorState(pluginId)\n\n const queryEvents: Array<QueryCacheNotifyEvent['type']> = [\n 'added',\n 'removed',\n 'updated',\n ]\n\n if (queryEvents.includes(event.type)) {\n api.addTimelineEvent({\n layerId: pluginId,\n event: {\n title: event.type,\n subtitle: event.query.queryHash,\n time: api.now(),\n data: {\n queryHash: event.query.queryHash,\n ...event,\n },\n },\n })\n }\n })\n\n api.on.setPluginSettings((payload) => {\n if (payload.key === 'onlineMode') {\n onlineManager.setOnline(Boolean(payload.newValue))\n }\n })\n\n api.on.getInspectorTree((payload) => {\n if (payload.inspectorId === pluginId) {\n const queries = queryCache.getAll()\n const settings = api.getSettings()\n\n const filtered = payload.filter\n ? queries.filter(\n (item) => rankItem(item.queryHash, payload.filter).passed,\n )\n : [...queries]\n\n const sorted = filtered.sort(\n (a, b) => sortFns[settings.sortFn]!(a, b) * settings.baseSort,\n )\n\n const nodes: Array<CustomInspectorNode> = sorted.map((query) => {\n const stateLabel = getQueryStateLabel(query)\n\n return {\n id: query.queryHash,\n label: query.queryHash,\n tags: [\n {\n label: `${stateLabel} [${query.getObserversCount()}]`,\n textColor: getQueryStatusFg(query),\n backgroundColor: getQueryStatusBg(query),\n },\n ],\n }\n })\n payload.rootNodes = nodes\n }\n })\n\n api.on.getInspectorState((payload) => {\n if (payload.inspectorId === pluginId) {\n const query = queryCache.get(payload.nodeId)\n\n if (!query) {\n return\n }\n\n payload.state = {\n ' Query Details': [\n {\n key: 'Query key',\n value: query.queryHash,\n },\n {\n key: 'Query status',\n value: getQueryStateLabel(query),\n },\n {\n key: 'Observers',\n value: query.getObserversCount(),\n },\n {\n key: 'Last Updated',\n value: new Date(query.state.dataUpdatedAt).toLocaleTimeString(),\n },\n ],\n 'Data Explorer': [\n {\n key: 'Data',\n value: query.state.data,\n },\n ],\n 'Query Explorer': [\n {\n key: 'Query',\n value: query,\n },\n ],\n }\n }\n })\n },\n )\n}\n"],"mappings":";;;;;;AAaA,MAAM,WAAW;AACjB,MAAM,aAAa;;;;;;;AAQnB,SAAgB,cAAc,KAAU,aAA0B;CAChE,CAAA,GAAA,kBAAA,oBAAA,CACE;EACE,IAAI;EACJ,OAAO;EACP,aAAa;EACb,UAAU;EACV,MAAM;EACN;EACA,UAAU;GACR,UAAU;IACR,MAAM;IACN,WAAW;IACX,OAAO;IACP,SAAS,CACP;KACE,OAAO;KACP,OAAO;IACT,GACA;KACE,OAAO;KACP,OAAO;IACT,CACF;IACA,cAAc;GAChB;GACA,QAAQ;IACN,MAAM;IACN,OAAO;IACP,SAAS,OAAO,KAAKA,uBAAAA,OAAO,CAAC,CAAC,KAAK,SAAS;KAC1C,OAAO;KACP,OAAO;IACT,EAAE;IACF,cAAc,OAAO,KAAKA,uBAAAA,OAAO,CAAC,CAAC;GACrC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C,OACH;IAGF,QAAQ,QAAQ;KACd,kBAAkB;MAChB;OACE,KAAK;OACL,OAAO,MAAM;MACf;MACA;OACE,KAAK;OACL,OAAOF,uBAAAA,mBAAmB,KAAK;MACjC;MACA;OACE,KAAK;OACL,OAAO,MAAM,kBAAkB;MACjC;MACA;OACE,KAAK;OACL,OAAO,IAAI,KAAK,MAAM,MAAM,aAAa,CAAC,CAAC,mBAAmB;MAChE;KACF;KACA,iBAAiB,CACf;MACE,KAAK;MACL,OAAO,MAAM,MAAM;KACrB,CACF;KACA,kBAAkB,CAChB;MACE,KAAK;MACL,OAAO;KACT,CACF;IACF;GACF;EACF,CAAC;CACH,CACF;AACF"}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import { t as QueryClient } from "../queryClient-
|
|
1
|
+
import { t as QueryClient } from "../queryClient-BK9W57Qu.cjs";
|
|
2
2
|
//#region src/devtools/devtools.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Registers the Vue Query plugin with the Vue devtools, adding a query inspector and a timeline
|
|
5
|
+
* layer for query cache events.
|
|
6
|
+
* @param app - The Vue app instance.
|
|
7
|
+
* @param queryClient - The client whose query cache is shown in the devtools.
|
|
8
|
+
*/
|
|
3
9
|
export declare function setupDevtools(app: any, queryClient: QueryClient): void;
|
|
4
10
|
//#endregion
|
|
5
11
|
//# sourceMappingURL=devtools.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devtools.d.cts","names":[],"sources":["../../../src/devtools/devtools.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"devtools.d.cts","names":[],"sources":["../../../src/devtools/devtools.ts"],"mappings":";;;;;;;;wBAsBgB,cAAc,UAAU,aAAa"}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import { t as QueryClient } from "../queryClient-
|
|
1
|
+
import { t as QueryClient } from "../queryClient-BoBzDWAZ.js";
|
|
2
2
|
//#region src/devtools/devtools.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Registers the Vue Query plugin with the Vue devtools, adding a query inspector and a timeline
|
|
5
|
+
* layer for query cache events.
|
|
6
|
+
* @param app - The Vue app instance.
|
|
7
|
+
* @param queryClient - The client whose query cache is shown in the devtools.
|
|
8
|
+
*/
|
|
3
9
|
export declare function setupDevtools(app: any, queryClient: QueryClient): void;
|
|
4
10
|
//#endregion
|
|
5
11
|
//# sourceMappingURL=devtools.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devtools.d.ts","names":[],"sources":["../../../src/devtools/devtools.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"devtools.d.ts","names":[],"sources":["../../../src/devtools/devtools.ts"],"mappings":";;;;;;;;wBAsBgB,cAAc,UAAU,aAAa"}
|
|
@@ -5,6 +5,12 @@ import { rankItem } from "@tanstack/match-sorter-utils";
|
|
|
5
5
|
//#region src/devtools/devtools.ts
|
|
6
6
|
const pluginId = "vue-query";
|
|
7
7
|
const pluginName = "Vue Query";
|
|
8
|
+
/**
|
|
9
|
+
* Registers the Vue Query plugin with the Vue devtools, adding a query inspector and a timeline
|
|
10
|
+
* layer for query cache events.
|
|
11
|
+
* @param app - The Vue app instance.
|
|
12
|
+
* @param queryClient - The client whose query cache is shown in the devtools.
|
|
13
|
+
*/
|
|
8
14
|
function setupDevtools(app, queryClient) {
|
|
9
15
|
setupDevtoolsPlugin({
|
|
10
16
|
id: pluginId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devtools.js","names":[],"sources":["../../../src/devtools/devtools.ts"],"sourcesContent":["import { setupDevtoolsPlugin } from '@vue/devtools-api'\nimport { rankItem } from '@tanstack/match-sorter-utils'\nimport { onlineManager } from '@tanstack/query-core'\nimport {\n getQueryStateLabel,\n getQueryStatusBg,\n getQueryStatusFg,\n sortFns,\n} from './utils'\nimport type { CustomInspectorNode } from '@vue/devtools-api'\nimport type { Query, QueryCacheNotifyEvent } from '@tanstack/query-core'\nimport type { QueryClient } from '../queryClient'\n\nconst pluginId = 'vue-query'\nconst pluginName = 'Vue Query'\n\nexport function setupDevtools(app: any, queryClient: QueryClient) {\n setupDevtoolsPlugin(\n {\n id: pluginId,\n label: pluginName,\n packageName: 'vue-query',\n homepage: 'https://tanstack.com/query/latest',\n logo: 'https://raw.githubusercontent.com/TanStack/query/main/packages/vue-query/media/vue-query.svg',\n app,\n settings: {\n baseSort: {\n type: 'choice',\n component: 'button-group',\n label: 'Sort Cache Entries',\n options: [\n {\n label: 'ASC',\n value: 1,\n },\n {\n label: 'DESC',\n value: -1,\n },\n ],\n defaultValue: 1,\n },\n sortFn: {\n type: 'choice',\n label: 'Sort Function',\n options: Object.keys(sortFns).map((key) => ({\n label: key,\n value: key,\n })),\n defaultValue: Object.keys(sortFns)[0]!,\n },\n onlineMode: {\n type: 'choice',\n component: 'button-group',\n label: 'Online mode',\n options: [\n {\n label: 'Online',\n value: 1,\n },\n {\n label: 'Offline',\n value: 0,\n },\n ],\n defaultValue: 1,\n },\n },\n },\n (api) => {\n const initialSettings = api.getSettings()\n onlineManager.setOnline(Boolean(initialSettings.onlineMode.valueOf()))\n\n const queryCache = queryClient.getQueryCache()\n\n api.addInspector({\n id: pluginId,\n label: pluginName,\n icon: 'api',\n nodeActions: [\n {\n icon: 'file_download',\n tooltip: 'Refetch',\n action: (queryHash: string) => {\n queryCache.get(queryHash)?.fetch()\n },\n },\n {\n icon: 'alarm',\n tooltip: 'Invalidate',\n action: (queryHash: string) => {\n const query = queryCache.get(queryHash) as Query\n queryClient.invalidateQueries({\n queryKey: query.queryKey,\n exact: true,\n })\n },\n },\n {\n icon: 'settings_backup_restore',\n tooltip: 'Reset',\n action: (queryHash: string) => {\n queryCache.get(queryHash)?.reset()\n },\n },\n {\n icon: 'delete',\n tooltip: 'Remove',\n action: (queryHash: string) => {\n const query = queryCache.get(queryHash) as Query\n queryCache.remove(query)\n },\n },\n {\n icon: 'hourglass_empty',\n tooltip: 'Force loading',\n action: (queryHash: string) => {\n const query = queryCache.get(queryHash) as Query\n\n query.setState({\n data: undefined,\n status: 'pending',\n })\n },\n },\n {\n icon: 'error_outline',\n tooltip: 'Force error',\n action: (queryHash: string) => {\n const query = queryCache.get(queryHash) as Query\n\n query.setState({\n data: undefined,\n status: 'error',\n error: new Error('Unknown error from devtools'),\n })\n },\n },\n ],\n })\n\n api.addTimelineLayer({\n id: pluginId,\n label: pluginName,\n color: 0xffd94c,\n })\n\n queryCache.subscribe((event) => {\n api.sendInspectorTree(pluginId)\n api.sendInspectorState(pluginId)\n\n const queryEvents: Array<QueryCacheNotifyEvent['type']> = [\n 'added',\n 'removed',\n 'updated',\n ]\n\n if (queryEvents.includes(event.type)) {\n api.addTimelineEvent({\n layerId: pluginId,\n event: {\n title: event.type,\n subtitle: event.query.queryHash,\n time: api.now(),\n data: {\n queryHash: event.query.queryHash,\n ...event,\n },\n },\n })\n }\n })\n\n api.on.setPluginSettings((payload) => {\n if (payload.key === 'onlineMode') {\n onlineManager.setOnline(Boolean(payload.newValue))\n }\n })\n\n api.on.getInspectorTree((payload) => {\n if (payload.inspectorId === pluginId) {\n const queries = queryCache.getAll()\n const settings = api.getSettings()\n\n const filtered = payload.filter\n ? queries.filter(\n (item) => rankItem(item.queryHash, payload.filter).passed,\n )\n : [...queries]\n\n const sorted = filtered.sort(\n (a, b) => sortFns[settings.sortFn]!(a, b) * settings.baseSort,\n )\n\n const nodes: Array<CustomInspectorNode> = sorted.map((query) => {\n const stateLabel = getQueryStateLabel(query)\n\n return {\n id: query.queryHash,\n label: query.queryHash,\n tags: [\n {\n label: `${stateLabel} [${query.getObserversCount()}]`,\n textColor: getQueryStatusFg(query),\n backgroundColor: getQueryStatusBg(query),\n },\n ],\n }\n })\n payload.rootNodes = nodes\n }\n })\n\n api.on.getInspectorState((payload) => {\n if (payload.inspectorId === pluginId) {\n const query = queryCache.get(payload.nodeId)\n\n if (!query) {\n return\n }\n\n payload.state = {\n ' Query Details': [\n {\n key: 'Query key',\n value: query.queryHash,\n },\n {\n key: 'Query status',\n value: getQueryStateLabel(query),\n },\n {\n key: 'Observers',\n value: query.getObserversCount(),\n },\n {\n key: 'Last Updated',\n value: new Date(query.state.dataUpdatedAt).toLocaleTimeString(),\n },\n ],\n 'Data Explorer': [\n {\n key: 'Data',\n value: query.state.data,\n },\n ],\n 'Query Explorer': [\n {\n key: 'Query',\n value: query,\n },\n ],\n }\n }\n })\n },\n )\n}\n"],"mappings":";;;;;AAaA,MAAM,WAAW;AACjB,MAAM,aAAa;AAEnB,SAAgB,cAAc,KAAU,aAA0B;CAChE,oBACE;EACE,IAAI;EACJ,OAAO;EACP,aAAa;EACb,UAAU;EACV,MAAM;EACN;EACA,UAAU;GACR,UAAU;IACR,MAAM;IACN,WAAW;IACX,OAAO;IACP,SAAS,CACP;KACE,OAAO;KACP,OAAO;IACT,GACA;KACE,OAAO;KACP,OAAO;IACT,CACF;IACA,cAAc;GAChB;GACA,QAAQ;IACN,MAAM;IACN,OAAO;IACP,SAAS,OAAO,KAAK,OAAO,CAAC,CAAC,KAAK,SAAS;KAC1C,OAAO;KACP,OAAO;IACT,EAAE;IACF,cAAc,OAAO,KAAK,OAAO,CAAC,CAAC;GACrC;GACA,YAAY;IACV,MAAM;IACN,WAAW;IACX,OAAO;IACP,SAAS,CACP;KACE,OAAO;KACP,OAAO;IACT,GACA;KACE,OAAO;KACP,OAAO;IACT,CACF;IACA,cAAc;GAChB;EACF;CACF,IACC,QAAQ;EACP,MAAM,kBAAkB,IAAI,YAAY;EACxC,cAAc,UAAU,QAAQ,gBAAgB,WAAW,QAAQ,CAAC,CAAC;EAErE,MAAM,aAAa,YAAY,cAAc;EAE7C,IAAI,aAAa;GACf,IAAI;GACJ,OAAO;GACP,MAAM;GACN,aAAa;IACX;KACE,MAAM;KACN,SAAS;KACT,SAAS,cAAsB;MAC7B,WAAW,IAAI,SAAS,CAAC,EAAE,MAAM;KACnC;IACF;IACA;KACE,MAAM;KACN,SAAS;KACT,SAAS,cAAsB;MAC7B,MAAM,QAAQ,WAAW,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AAO;IAClC,MAAM,WAAW,IAAI,YAAY;IA2BjC,QAAQ,aAzBS,QAAQ,SACrB,QAAQ,QACL,SAAS,SAAS,KAAK,WAAW,QAAQ,MAAM,CAAC,CAAC,MACrD,IACA,CAAC,GAAG,OAAO,EAAA,CAES,MACrB,GAAG,MAAM,QAAQ,SAAS,OAAO,CAAE,GAAG,CAAC,IAAI,SAAS,QAGR,CAAC,CAAC,KAAK,UAAU;KAC9D,MAAM,aAAa,mBAAmB,KAAK;KAE3C,OAAO;MACL,IAAI,MAAM;MACV,OAAO,MAAM;MACb,MAAM,CACJ;OACE,OAAO,GAAG,WAAW,IAAI,MAAM,kBAAkB,EAAE;OACnD,WAAW,iBAAiB,KAAK;OACjC,iBAAiB,iBAAiB,KAAK;MACzC,CACF;KACF;IACF,CACwB;GAC1B;EACF,CAAC;EAED,IAAI,GAAG,mBAAmB,YAAY;GACpC,IAAI,QAAQ,gBAAgB,UAAU;IACpC,MAAM,QAAQ,WAAW,IAAI,QAAQ,MAAM;IAE3C,IAAI,CAAC,OACH;IAGF,QAAQ,QAAQ;KACd,kBAAkB;MAChB;OACE,KAAK;OACL,OAAO,MAAM;MACf;MACA;OACE,KAAK;OACL,OAAO,mBAAmB,KAAK;MACjC;MACA;OACE,KAAK;OACL,OAAO,MAAM,kBAAkB;MACjC;MACA;OACE,KAAK;OACL,OAAO,IAAI,KAAK,MAAM,MAAM,aAAa,CAAC,CAAC,mBAAmB;MAChE;KACF;KACA,iBAAiB,CACf;MACE,KAAK;MACL,OAAO,MAAM,MAAM;KACrB,CACF;KACA,kBAAkB,CAChB;MACE,KAAK;MACL,OAAO;KACT,CACF;IACF;GACF;EACF,CAAC;CACH,CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"devtools.js","names":[],"sources":["../../../src/devtools/devtools.ts"],"sourcesContent":["import { setupDevtoolsPlugin } from '@vue/devtools-api'\nimport { rankItem } from '@tanstack/match-sorter-utils'\nimport { onlineManager } from '@tanstack/query-core'\nimport {\n getQueryStateLabel,\n getQueryStatusBg,\n getQueryStatusFg,\n sortFns,\n} from './utils'\nimport type { CustomInspectorNode } from '@vue/devtools-api'\nimport type { Query, QueryCacheNotifyEvent } from '@tanstack/query-core'\nimport type { QueryClient } from '../queryClient'\n\nconst pluginId = 'vue-query'\nconst pluginName = 'Vue Query'\n\n/**\n * Registers the Vue Query plugin with the Vue devtools, adding a query inspector and a timeline\n * layer for query cache events.\n * @param app - The Vue app instance.\n * @param queryClient - The client whose query cache is shown in the devtools.\n */\nexport function setupDevtools(app: any, queryClient: QueryClient) {\n setupDevtoolsPlugin(\n {\n id: pluginId,\n label: pluginName,\n packageName: 'vue-query',\n homepage: 'https://tanstack.com/query/latest',\n logo: 'https://raw.githubusercontent.com/TanStack/query/main/packages/vue-query/media/vue-query.svg',\n app,\n settings: {\n baseSort: {\n type: 'choice',\n component: 'button-group',\n label: 'Sort Cache Entries',\n options: [\n {\n label: 'ASC',\n value: 1,\n },\n {\n label: 'DESC',\n value: -1,\n },\n ],\n defaultValue: 1,\n },\n sortFn: {\n type: 'choice',\n label: 'Sort Function',\n options: Object.keys(sortFns).map((key) => ({\n label: key,\n value: key,\n })),\n defaultValue: Object.keys(sortFns)[0]!,\n },\n onlineMode: {\n type: 'choice',\n component: 'button-group',\n label: 'Online mode',\n options: [\n {\n label: 'Online',\n value: 1,\n },\n {\n label: 'Offline',\n value: 0,\n },\n ],\n defaultValue: 1,\n },\n },\n },\n (api) => {\n const initialSettings = api.getSettings()\n onlineManager.setOnline(Boolean(initialSettings.onlineMode.valueOf()))\n\n const queryCache = queryClient.getQueryCache()\n\n api.addInspector({\n id: pluginId,\n label: pluginName,\n icon: 'api',\n nodeActions: [\n {\n icon: 'file_download',\n tooltip: 'Refetch',\n action: (queryHash: string) => {\n queryCache.get(queryHash)?.fetch()\n },\n },\n {\n icon: 'alarm',\n tooltip: 'Invalidate',\n action: (queryHash: string) => {\n const query = queryCache.get(queryHash) as Query\n queryClient.invalidateQueries({\n queryKey: query.queryKey,\n exact: true,\n })\n },\n },\n {\n icon: 'settings_backup_restore',\n tooltip: 'Reset',\n action: (queryHash: string) => {\n queryCache.get(queryHash)?.reset()\n },\n },\n {\n icon: 'delete',\n tooltip: 'Remove',\n action: (queryHash: string) => {\n const query = queryCache.get(queryHash) as Query\n queryCache.remove(query)\n },\n },\n {\n icon: 'hourglass_empty',\n tooltip: 'Force loading',\n action: (queryHash: string) => {\n const query = queryCache.get(queryHash) as Query\n\n query.setState({\n data: undefined,\n status: 'pending',\n })\n },\n },\n {\n icon: 'error_outline',\n tooltip: 'Force error',\n action: (queryHash: string) => {\n const query = queryCache.get(queryHash) as Query\n\n query.setState({\n data: undefined,\n status: 'error',\n error: new Error('Unknown error from devtools'),\n })\n },\n },\n ],\n })\n\n api.addTimelineLayer({\n id: pluginId,\n label: pluginName,\n color: 0xffd94c,\n })\n\n queryCache.subscribe((event) => {\n api.sendInspectorTree(pluginId)\n api.sendInspectorState(pluginId)\n\n const queryEvents: Array<QueryCacheNotifyEvent['type']> = [\n 'added',\n 'removed',\n 'updated',\n ]\n\n if (queryEvents.includes(event.type)) {\n api.addTimelineEvent({\n layerId: pluginId,\n event: {\n title: event.type,\n subtitle: event.query.queryHash,\n time: api.now(),\n data: {\n queryHash: event.query.queryHash,\n ...event,\n },\n },\n })\n }\n })\n\n api.on.setPluginSettings((payload) => {\n if (payload.key === 'onlineMode') {\n onlineManager.setOnline(Boolean(payload.newValue))\n }\n })\n\n api.on.getInspectorTree((payload) => {\n if (payload.inspectorId === pluginId) {\n const queries = queryCache.getAll()\n const settings = api.getSettings()\n\n const filtered = payload.filter\n ? queries.filter(\n (item) => rankItem(item.queryHash, payload.filter).passed,\n )\n : [...queries]\n\n const sorted = filtered.sort(\n (a, b) => sortFns[settings.sortFn]!(a, b) * settings.baseSort,\n )\n\n const nodes: Array<CustomInspectorNode> = sorted.map((query) => {\n const stateLabel = getQueryStateLabel(query)\n\n return {\n id: query.queryHash,\n label: query.queryHash,\n tags: [\n {\n label: `${stateLabel} [${query.getObserversCount()}]`,\n textColor: getQueryStatusFg(query),\n backgroundColor: getQueryStatusBg(query),\n },\n ],\n }\n })\n payload.rootNodes = nodes\n }\n })\n\n api.on.getInspectorState((payload) => {\n if (payload.inspectorId === pluginId) {\n const query = queryCache.get(payload.nodeId)\n\n if (!query) {\n return\n }\n\n payload.state = {\n ' Query Details': [\n {\n key: 'Query key',\n value: query.queryHash,\n },\n {\n key: 'Query status',\n value: getQueryStateLabel(query),\n },\n {\n key: 'Observers',\n value: query.getObserversCount(),\n },\n {\n key: 'Last Updated',\n value: new Date(query.state.dataUpdatedAt).toLocaleTimeString(),\n },\n ],\n 'Data Explorer': [\n {\n key: 'Data',\n value: query.state.data,\n },\n ],\n 'Query Explorer': [\n {\n key: 'Query',\n value: query,\n },\n ],\n }\n }\n })\n },\n )\n}\n"],"mappings":";;;;;AAaA,MAAM,WAAW;AACjB,MAAM,aAAa;;;;;;;AAQnB,SAAgB,cAAc,KAAU,aAA0B;CAChE,oBACE;EACE,IAAI;EACJ,OAAO;EACP,aAAa;EACb,UAAU;EACV,MAAM;EACN;EACA,UAAU;GACR,UAAU;IACR,MAAM;IACN,WAAW;IACX,OAAO;IACP,SAAS,CACP;KACE,OAAO;KACP,OAAO;IACT,GACA;KACE,OAAO;KACP,OAAO;IACT,CACF;IACA,cAAc;GAChB;GACA,QAAQ;IACN,MAAM;IACN,OAAO;IACP,SAAS,OAAO,KAAK,OAAO,CAAC,CAAC,KAAK,SAAS;KAC1C,OAAO;KACP,OAAO;IACT,EAAE;IACF,cAAc,OAAO,KAAK,OAAO,CAAC,CAAC;GACrC;GACA,YAAY;IACV,MAAM;IACN,WAAW;IACX,OAAO;IACP,SAAS,CACP;KACE,OAAO;KACP,OAAO;IACT,GACA;KACE,OAAO;KACP,OAAO;IACT,CACF;IACA,cAAc;GAChB;EACF;CACF,IACC,QAAQ;EACP,MAAM,kBAAkB,IAAI,YAAY;EACxC,cAAc,UAAU,QAAQ,gBAAgB,WAAW,QA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AM;KACrB,CACF;KACA,kBAAkB,CAChB;MACE,KAAK;MACL,OAAO;KACT,CACF;IACF;GACF;EACF,CAAC;CACH,CACF;AACF"}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region src/devtools/utils.ts
|
|
3
|
+
/**
|
|
4
|
+
* Returns the devtools state of a query: fetching, paused, inactive (no observers), stale, or fresh,
|
|
5
|
+
* checked in that order.
|
|
6
|
+
* @param query - The query to check.
|
|
7
|
+
* @returns A `QueryState` value, used to label, color, and sort the query.
|
|
8
|
+
*/
|
|
3
9
|
function getQueryState(query) {
|
|
4
10
|
if (query.state.fetchStatus === "fetching") return 0;
|
|
5
11
|
if (query.state.fetchStatus === "paused") return 4;
|
|
@@ -7,6 +13,11 @@ function getQueryState(query) {
|
|
|
7
13
|
if (query.isStale()) return 2;
|
|
8
14
|
return 1;
|
|
9
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Returns the label of a query's devtools state, shown in the inspector.
|
|
18
|
+
* @param query - The query to label.
|
|
19
|
+
* @returns `'fetching'`, `'paused'`, `'stale'`, `'inactive'`, or `'fresh'`.
|
|
20
|
+
*/
|
|
10
21
|
function getQueryStateLabel(query) {
|
|
11
22
|
const queryState = getQueryState(query);
|
|
12
23
|
if (queryState === 0) return "fetching";
|
|
@@ -15,10 +26,20 @@ function getQueryStateLabel(query) {
|
|
|
15
26
|
if (queryState === 3) return "inactive";
|
|
16
27
|
return "fresh";
|
|
17
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Returns the text color of a query's state label in the inspector.
|
|
31
|
+
* @param query - The query to get the color for.
|
|
32
|
+
* @returns Black for stale queries, otherwise white, as a hex number.
|
|
33
|
+
*/
|
|
18
34
|
function getQueryStatusFg(query) {
|
|
19
35
|
if (getQueryState(query) === 2) return 0;
|
|
20
36
|
return 16777215;
|
|
21
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Returns the background color of a query's state label in the inspector.
|
|
40
|
+
* @param query - The query to get the color for.
|
|
41
|
+
* @returns The color for the query's state, as a hex number.
|
|
42
|
+
*/
|
|
22
43
|
function getQueryStatusBg(query) {
|
|
23
44
|
const queryState = getQueryState(query);
|
|
24
45
|
if (queryState === 0) return 27647;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","names":[],"sources":["../../../src/devtools/utils.ts"],"sourcesContent":["import type { Query } from '@tanstack/query-core'\n\ntype SortFn = (a: Query, b: Query) => number\n\nenum QueryState {\n Fetching = 0,\n Fresh,\n Stale,\n Inactive,\n Paused,\n}\n\nexport function getQueryState(query: Query): QueryState {\n if (query.state.fetchStatus === 'fetching') {\n return QueryState.Fetching\n }\n if (query.state.fetchStatus === 'paused') {\n return QueryState.Paused\n }\n if (!query.getObserversCount()) {\n return QueryState.Inactive\n }\n if (query.isStale()) {\n return QueryState.Stale\n }\n\n return QueryState.Fresh\n}\n\nexport function getQueryStateLabel(query: Query): string {\n const queryState = getQueryState(query)\n\n if (queryState === QueryState.Fetching) {\n return 'fetching'\n }\n if (queryState === QueryState.Paused) {\n return 'paused'\n }\n if (queryState === QueryState.Stale) {\n return 'stale'\n }\n if (queryState === QueryState.Inactive) {\n return 'inactive'\n }\n\n return 'fresh'\n}\n\nexport function getQueryStatusFg(query: Query): number {\n const queryState = getQueryState(query)\n\n if (queryState === QueryState.Stale) {\n return 0x000000\n }\n\n return 0xffffff\n}\n\nexport function getQueryStatusBg(query: Query): number {\n const queryState = getQueryState(query)\n\n if (queryState === QueryState.Fetching) {\n return 0x006bff\n }\n if (queryState === QueryState.Paused) {\n return 0x8c49eb\n }\n if (queryState === QueryState.Stale) {\n return 0xffb200\n }\n if (queryState === QueryState.Inactive) {\n return 0x3f4e60\n }\n\n return 0x008327\n}\n\nconst queryHashSort: SortFn = (a, b) => a.queryHash.localeCompare(b.queryHash)\n\nconst dateSort: SortFn = (a, b) =>\n a.state.dataUpdatedAt < b.state.dataUpdatedAt ? 1 : -1\n\nconst statusAndDateSort: SortFn = (a, b) => {\n if (getQueryState(a) === getQueryState(b)) {\n return dateSort(a, b)\n }\n\n return getQueryState(a) > getQueryState(b) ? 1 : -1\n}\n\nexport const sortFns: Record<string, SortFn> = {\n 'Status > Last Updated': statusAndDateSort,\n 'Query Hash': queryHashSort,\n 'Last Updated': dateSort,\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.cjs","names":[],"sources":["../../../src/devtools/utils.ts"],"sourcesContent":["import type { Query } from '@tanstack/query-core'\n\ntype SortFn = (a: Query, b: Query) => number\n\nenum QueryState {\n Fetching = 0,\n Fresh,\n Stale,\n Inactive,\n Paused,\n}\n\n/**\n * Returns the devtools state of a query: fetching, paused, inactive (no observers), stale, or fresh,\n * checked in that order.\n * @param query - The query to check.\n * @returns A `QueryState` value, used to label, color, and sort the query.\n */\nexport function getQueryState(query: Query): QueryState {\n if (query.state.fetchStatus === 'fetching') {\n return QueryState.Fetching\n }\n if (query.state.fetchStatus === 'paused') {\n return QueryState.Paused\n }\n if (!query.getObserversCount()) {\n return QueryState.Inactive\n }\n if (query.isStale()) {\n return QueryState.Stale\n }\n\n return QueryState.Fresh\n}\n\n/**\n * Returns the label of a query's devtools state, shown in the inspector.\n * @param query - The query to label.\n * @returns `'fetching'`, `'paused'`, `'stale'`, `'inactive'`, or `'fresh'`.\n */\nexport function getQueryStateLabel(query: Query): string {\n const queryState = getQueryState(query)\n\n if (queryState === QueryState.Fetching) {\n return 'fetching'\n }\n if (queryState === QueryState.Paused) {\n return 'paused'\n }\n if (queryState === QueryState.Stale) {\n return 'stale'\n }\n if (queryState === QueryState.Inactive) {\n return 'inactive'\n }\n\n return 'fresh'\n}\n\n/**\n * Returns the text color of a query's state label in the inspector.\n * @param query - The query to get the color for.\n * @returns Black for stale queries, otherwise white, as a hex number.\n */\nexport function getQueryStatusFg(query: Query): number {\n const queryState = getQueryState(query)\n\n if (queryState === QueryState.Stale) {\n return 0x000000\n }\n\n return 0xffffff\n}\n\n/**\n * Returns the background color of a query's state label in the inspector.\n * @param query - The query to get the color for.\n * @returns The color for the query's state, as a hex number.\n */\nexport function getQueryStatusBg(query: Query): number {\n const queryState = getQueryState(query)\n\n if (queryState === QueryState.Fetching) {\n return 0x006bff\n }\n if (queryState === QueryState.Paused) {\n return 0x8c49eb\n }\n if (queryState === QueryState.Stale) {\n return 0xffb200\n }\n if (queryState === QueryState.Inactive) {\n return 0x3f4e60\n }\n\n return 0x008327\n}\n\nconst queryHashSort: SortFn = (a, b) => a.queryHash.localeCompare(b.queryHash)\n\nconst dateSort: SortFn = (a, b) =>\n a.state.dataUpdatedAt < b.state.dataUpdatedAt ? 1 : -1\n\nconst statusAndDateSort: SortFn = (a, b) => {\n if (getQueryState(a) === getQueryState(b)) {\n return dateSort(a, b)\n }\n\n return getQueryState(a) > getQueryState(b) ? 1 : -1\n}\n\nexport const sortFns: Record<string, SortFn> = {\n 'Status > Last Updated': statusAndDateSort,\n 'Query Hash': queryHashSort,\n 'Last Updated': dateSort,\n}\n"],"mappings":";;;;;;;;AAkBA,SAAgB,cAAc,OAA0B;CACtD,IAAI,MAAM,MAAM,gBAAgB,YAC9B,OAAA;CAEF,IAAI,MAAM,MAAM,gBAAgB,UAC9B,OAAA;CAEF,IAAI,CAAC,MAAM,kBAAkB,GAC3B,OAAA;CAEF,IAAI,MAAM,QAAQ,GAChB,OAAA;CAGF,OAAA;AACF;;;;;;AAOA,SAAgB,mBAAmB,OAAsB;CACvD,MAAM,aAAa,cAAc,KAAK;CAEtC,IAAI,eAAA,GACF,OAAO;CAET,IAAI,eAAA,GACF,OAAO;CAET,IAAI,eAAA,GACF,OAAO;CAET,IAAI,eAAA,GACF,OAAO;CAGT,OAAO;AACT;;;;;;AAOA,SAAgB,iBAAiB,OAAsB;CAGrD,IAFmB,cAAc,KAEpB,MAAA,GACX,OAAO;CAGT,OAAO;AACT;;;;;;AAOA,SAAgB,iBAAiB,OAAsB;CACrD,MAAM,aAAa,cAAc,KAAK;CAEtC,IAAI,eAAA,GACF,OAAO;CAET,IAAI,eAAA,GACF,OAAO;CAET,IAAI,eAAA,GACF,OAAO;CAET,IAAI,eAAA,GACF,OAAO;CAGT,OAAO;AACT;AAEA,MAAM,iBAAyB,GAAG,MAAM,EAAE,UAAU,cAAc,EAAE,SAAS;AAE7E,MAAM,YAAoB,GAAG,MAC3B,EAAE,MAAM,gBAAgB,EAAE,MAAM,gBAAgB,IAAI;AAEtD,MAAM,qBAA6B,GAAG,MAAM;CAC1C,IAAI,cAAc,CAAC,MAAM,cAAc,CAAC,GACtC,OAAO,SAAS,GAAG,CAAC;CAGtB,OAAO,cAAc,CAAC,IAAI,cAAc,CAAC,IAAI,IAAI;AACnD;AAEA,MAAa,UAAkC;CAC7C,yBAAyB;CACzB,cAAc;CACd,gBAAgB;AAClB"}
|