@tanstack/vue-query 5.102.8 → 5.103.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/legacy/devtools/devtools.d.cts +1 -1
- package/build/legacy/devtools/devtools.d.ts +1 -1
- package/build/legacy/index.d.cts +8 -6
- package/build/legacy/index.d.ts +8 -6
- package/build/legacy/infiniteQueryOptions-CEDiLwh5.d.ts +365 -0
- package/build/legacy/infiniteQueryOptions-CEDiLwh5.d.ts.map +1 -0
- package/build/legacy/infiniteQueryOptions-qN6sOJM-.d.cts +365 -0
- package/build/legacy/infiniteQueryOptions-qN6sOJM-.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 +5 -0
- package/build/legacy/mutationCache.cjs.map +1 -1
- package/build/legacy/mutationCache.d.cts +6 -1
- package/build/legacy/mutationCache.d.cts.map +1 -1
- package/build/legacy/mutationCache.d.ts +6 -1
- package/build/legacy/mutationCache.d.ts.map +1 -1
- package/build/legacy/mutationCache.js +5 -0
- package/build/legacy/mutationCache.js.map +1 -1
- package/build/legacy/mutationOptions.cjs.map +1 -1
- package/build/legacy/mutationOptions.d.cts +121 -1
- package/build/legacy/mutationOptions.d.cts.map +1 -1
- package/build/legacy/mutationOptions.d.ts +121 -1
- package/build/legacy/mutationOptions.d.ts.map +1 -1
- package/build/legacy/mutationOptions.js.map +1 -1
- package/build/legacy/queryCache.cjs +5 -0
- package/build/legacy/queryCache.cjs.map +1 -1
- package/build/legacy/queryCache.d.cts +6 -1
- package/build/legacy/queryCache.d.cts.map +1 -1
- package/build/legacy/queryCache.d.ts +6 -1
- package/build/legacy/queryCache.d.ts.map +1 -1
- package/build/legacy/queryCache.js +5 -0
- package/build/legacy/queryCache.js.map +1 -1
- package/build/legacy/queryClient-CZeNAt68.d.cts +71 -0
- package/build/legacy/queryClient-CZeNAt68.d.cts.map +1 -0
- package/build/legacy/queryClient-Cv73nzNT.d.ts +71 -0
- package/build/legacy/queryClient-Cv73nzNT.d.ts.map +1 -0
- package/build/legacy/queryClient.cjs +7 -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 +7 -0
- package/build/legacy/queryClient.js.map +1 -1
- package/build/legacy/queryOptions-DPDwdVBu.d.ts +227 -0
- package/build/legacy/queryOptions-DPDwdVBu.d.ts.map +1 -0
- package/build/legacy/queryOptions-rkZ3sk6g.d.cts +227 -0
- package/build/legacy/queryOptions-rkZ3sk6g.d.cts.map +1 -0
- package/build/legacy/queryOptions.cjs.map +1 -1
- package/build/legacy/queryOptions.d.cts +2 -19
- package/build/legacy/queryOptions.d.ts +2 -19
- package/build/legacy/queryOptions.js.map +1 -1
- package/build/{modern/types-BzZi3_rS.d.cts → legacy/types-JpJB72CS.d.cts} +19 -1
- package/build/legacy/types-JpJB72CS.d.cts.map +1 -0
- package/build/legacy/{types-BzZi3_rS.d.cts → types-JpJB72CS.d.ts} +19 -1
- package/build/legacy/types-JpJB72CS.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 +8 -0
- 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 +8 -0
- 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 +41 -0
- package/build/legacy/useIsFetching.cjs.map +1 -1
- package/build/legacy/useIsFetching.d.cts +47 -6
- package/build/legacy/useIsFetching.d.cts.map +1 -1
- package/build/legacy/useIsFetching.d.ts +47 -6
- package/build/legacy/useIsFetching.d.ts.map +1 -1
- package/build/legacy/useIsFetching.js +41 -0
- package/build/legacy/useIsFetching.js.map +1 -1
- package/build/legacy/useMutation.cjs +170 -9
- package/build/legacy/useMutation.cjs.map +1 -1
- package/build/legacy/useMutation.d.cts +164 -3
- package/build/legacy/useMutation.d.cts.map +1 -1
- package/build/legacy/useMutation.d.ts +164 -3
- package/build/legacy/useMutation.d.ts.map +1 -1
- package/build/legacy/useMutation.js +170 -9
- package/build/legacy/useMutation.js.map +1 -1
- package/build/legacy/useMutationState.cjs +103 -0
- package/build/legacy/useMutationState.cjs.map +1 -1
- package/build/legacy/useMutationState.d.cts +111 -7
- package/build/legacy/useMutationState.d.cts.map +1 -1
- package/build/legacy/useMutationState.d.ts +111 -7
- package/build/legacy/useMutationState.d.ts.map +1 -1
- package/build/legacy/useMutationState.js +103 -0
- package/build/legacy/useMutationState.js.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.cjs +46 -0
- package/build/legacy/usePrefetchInfiniteQuery.cjs.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.d.cts +48 -2
- package/build/legacy/usePrefetchInfiniteQuery.d.cts.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.d.ts +48 -2
- package/build/legacy/usePrefetchInfiniteQuery.d.ts.map +1 -1
- package/build/legacy/usePrefetchInfiniteQuery.js +46 -0
- package/build/legacy/usePrefetchInfiniteQuery.js.map +1 -1
- package/build/legacy/usePrefetchQuery.cjs +37 -0
- package/build/legacy/usePrefetchQuery.cjs.map +1 -1
- package/build/legacy/usePrefetchQuery.d.cts +39 -2
- package/build/legacy/usePrefetchQuery.d.cts.map +1 -1
- package/build/legacy/usePrefetchQuery.d.ts +39 -2
- package/build/legacy/usePrefetchQuery.d.ts.map +1 -1
- package/build/legacy/usePrefetchQuery.js +37 -0
- package/build/legacy/usePrefetchQuery.js.map +1 -1
- package/build/legacy/useQueries.cjs +123 -0
- package/build/legacy/useQueries.cjs.map +1 -1
- package/build/legacy/useQueries.d.cts +126 -2
- package/build/legacy/useQueries.d.cts.map +1 -1
- package/build/legacy/useQueries.d.ts +126 -2
- package/build/legacy/useQueries.d.ts.map +1 -1
- package/build/legacy/useQueries.js +123 -0
- package/build/legacy/useQueries.js.map +1 -1
- package/build/legacy/useQuery.cjs.map +1 -1
- package/build/legacy/useQuery.d.cts +248 -2
- package/build/legacy/useQuery.d.cts.map +1 -0
- package/build/legacy/useQuery.d.ts +248 -2
- package/build/legacy/useQuery.d.ts.map +1 -0
- package/build/legacy/useQuery.js.map +1 -1
- package/build/legacy/useQueryClient.cjs +21 -0
- package/build/legacy/useQueryClient.cjs.map +1 -1
- package/build/legacy/useQueryClient.d.cts +22 -1
- package/build/legacy/useQueryClient.d.cts.map +1 -1
- package/build/legacy/useQueryClient.d.ts +22 -1
- package/build/legacy/useQueryClient.d.ts.map +1 -1
- package/build/legacy/useQueryClient.js +21 -0
- package/build/legacy/useQueryClient.js.map +1 -1
- package/build/legacy/utils.cjs +15 -0
- package/build/legacy/utils.cjs.map +1 -1
- package/build/legacy/utils.d.cts +16 -1
- package/build/legacy/utils.d.cts.map +1 -1
- package/build/legacy/utils.d.ts +16 -1
- package/build/legacy/utils.d.ts.map +1 -1
- package/build/legacy/utils.js +15 -0
- package/build/legacy/utils.js.map +1 -1
- package/build/legacy/vueQueryPlugin.cjs +34 -0
- package/build/legacy/vueQueryPlugin.cjs.map +1 -1
- package/build/legacy/vueQueryPlugin.d.cts +48 -2
- package/build/legacy/vueQueryPlugin.d.cts.map +1 -1
- package/build/legacy/vueQueryPlugin.d.ts +48 -2
- package/build/legacy/vueQueryPlugin.d.ts.map +1 -1
- package/build/legacy/vueQueryPlugin.js +34 -0
- package/build/legacy/vueQueryPlugin.js.map +1 -1
- package/build/modern/devtools/devtools.d.cts +1 -1
- package/build/modern/devtools/devtools.d.ts +1 -1
- package/build/modern/index.d.cts +8 -6
- package/build/modern/index.d.ts +8 -6
- package/build/modern/infiniteQueryOptions-CEDiLwh5.d.ts +365 -0
- package/build/modern/infiniteQueryOptions-CEDiLwh5.d.ts.map +1 -0
- package/build/modern/infiniteQueryOptions-qN6sOJM-.d.cts +365 -0
- package/build/modern/infiniteQueryOptions-qN6sOJM-.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 +5 -0
- package/build/modern/mutationCache.cjs.map +1 -1
- package/build/modern/mutationCache.d.cts +6 -1
- package/build/modern/mutationCache.d.cts.map +1 -1
- package/build/modern/mutationCache.d.ts +6 -1
- package/build/modern/mutationCache.d.ts.map +1 -1
- package/build/modern/mutationCache.js +5 -0
- package/build/modern/mutationCache.js.map +1 -1
- package/build/modern/mutationOptions.cjs.map +1 -1
- package/build/modern/mutationOptions.d.cts +121 -1
- package/build/modern/mutationOptions.d.cts.map +1 -1
- package/build/modern/mutationOptions.d.ts +121 -1
- package/build/modern/mutationOptions.d.ts.map +1 -1
- package/build/modern/mutationOptions.js.map +1 -1
- package/build/modern/queryCache.cjs +5 -0
- package/build/modern/queryCache.cjs.map +1 -1
- package/build/modern/queryCache.d.cts +6 -1
- package/build/modern/queryCache.d.cts.map +1 -1
- package/build/modern/queryCache.d.ts +6 -1
- package/build/modern/queryCache.d.ts.map +1 -1
- package/build/modern/queryCache.js +5 -0
- package/build/modern/queryCache.js.map +1 -1
- package/build/modern/queryClient-CZeNAt68.d.cts +71 -0
- package/build/modern/queryClient-CZeNAt68.d.cts.map +1 -0
- package/build/modern/queryClient-Cv73nzNT.d.ts +71 -0
- package/build/modern/queryClient-Cv73nzNT.d.ts.map +1 -0
- package/build/modern/queryClient.cjs +7 -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 +7 -0
- package/build/modern/queryClient.js.map +1 -1
- package/build/modern/queryOptions-DPDwdVBu.d.ts +227 -0
- package/build/modern/queryOptions-DPDwdVBu.d.ts.map +1 -0
- package/build/modern/queryOptions-rkZ3sk6g.d.cts +227 -0
- package/build/modern/queryOptions-rkZ3sk6g.d.cts.map +1 -0
- package/build/modern/queryOptions.cjs.map +1 -1
- package/build/modern/queryOptions.d.cts +2 -19
- package/build/modern/queryOptions.d.ts +2 -19
- package/build/modern/queryOptions.js.map +1 -1
- package/build/modern/{types-BzZi3_rS.d.ts → types-JpJB72CS.d.cts} +19 -1
- package/build/modern/types-JpJB72CS.d.cts.map +1 -0
- package/build/{legacy/types-BzZi3_rS.d.ts → modern/types-JpJB72CS.d.ts} +19 -1
- package/build/modern/types-JpJB72CS.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 +8 -0
- 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 +8 -0
- 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 +41 -0
- package/build/modern/useIsFetching.cjs.map +1 -1
- package/build/modern/useIsFetching.d.cts +47 -6
- package/build/modern/useIsFetching.d.cts.map +1 -1
- package/build/modern/useIsFetching.d.ts +47 -6
- package/build/modern/useIsFetching.d.ts.map +1 -1
- package/build/modern/useIsFetching.js +41 -0
- package/build/modern/useIsFetching.js.map +1 -1
- package/build/modern/useMutation.cjs +170 -9
- package/build/modern/useMutation.cjs.map +1 -1
- package/build/modern/useMutation.d.cts +164 -3
- package/build/modern/useMutation.d.cts.map +1 -1
- package/build/modern/useMutation.d.ts +164 -3
- package/build/modern/useMutation.d.ts.map +1 -1
- package/build/modern/useMutation.js +170 -9
- package/build/modern/useMutation.js.map +1 -1
- package/build/modern/useMutationState.cjs +103 -0
- package/build/modern/useMutationState.cjs.map +1 -1
- package/build/modern/useMutationState.d.cts +111 -7
- package/build/modern/useMutationState.d.cts.map +1 -1
- package/build/modern/useMutationState.d.ts +111 -7
- package/build/modern/useMutationState.d.ts.map +1 -1
- package/build/modern/useMutationState.js +103 -0
- package/build/modern/useMutationState.js.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.cjs +46 -0
- package/build/modern/usePrefetchInfiniteQuery.cjs.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.d.cts +48 -2
- package/build/modern/usePrefetchInfiniteQuery.d.cts.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.d.ts +48 -2
- package/build/modern/usePrefetchInfiniteQuery.d.ts.map +1 -1
- package/build/modern/usePrefetchInfiniteQuery.js +46 -0
- package/build/modern/usePrefetchInfiniteQuery.js.map +1 -1
- package/build/modern/usePrefetchQuery.cjs +37 -0
- package/build/modern/usePrefetchQuery.cjs.map +1 -1
- package/build/modern/usePrefetchQuery.d.cts +39 -2
- package/build/modern/usePrefetchQuery.d.cts.map +1 -1
- package/build/modern/usePrefetchQuery.d.ts +39 -2
- package/build/modern/usePrefetchQuery.d.ts.map +1 -1
- package/build/modern/usePrefetchQuery.js +37 -0
- package/build/modern/usePrefetchQuery.js.map +1 -1
- package/build/modern/useQueries.cjs +123 -0
- package/build/modern/useQueries.cjs.map +1 -1
- package/build/modern/useQueries.d.cts +126 -2
- package/build/modern/useQueries.d.cts.map +1 -1
- package/build/modern/useQueries.d.ts +126 -2
- package/build/modern/useQueries.d.ts.map +1 -1
- package/build/modern/useQueries.js +123 -0
- package/build/modern/useQueries.js.map +1 -1
- package/build/modern/useQuery.cjs.map +1 -1
- package/build/modern/useQuery.d.cts +248 -2
- package/build/modern/useQuery.d.cts.map +1 -0
- package/build/modern/useQuery.d.ts +248 -2
- package/build/modern/useQuery.d.ts.map +1 -0
- package/build/modern/useQuery.js.map +1 -1
- package/build/modern/useQueryClient.cjs +21 -0
- package/build/modern/useQueryClient.cjs.map +1 -1
- package/build/modern/useQueryClient.d.cts +22 -1
- package/build/modern/useQueryClient.d.cts.map +1 -1
- package/build/modern/useQueryClient.d.ts +22 -1
- package/build/modern/useQueryClient.d.ts.map +1 -1
- package/build/modern/useQueryClient.js +21 -0
- package/build/modern/useQueryClient.js.map +1 -1
- package/build/modern/utils.cjs +15 -0
- package/build/modern/utils.cjs.map +1 -1
- package/build/modern/utils.d.cts +16 -1
- package/build/modern/utils.d.cts.map +1 -1
- package/build/modern/utils.d.ts +16 -1
- package/build/modern/utils.d.ts.map +1 -1
- package/build/modern/utils.js +15 -0
- package/build/modern/utils.js.map +1 -1
- package/build/modern/vueQueryPlugin.cjs +34 -0
- package/build/modern/vueQueryPlugin.cjs.map +1 -1
- package/build/modern/vueQueryPlugin.d.cts +48 -2
- package/build/modern/vueQueryPlugin.d.cts.map +1 -1
- package/build/modern/vueQueryPlugin.d.ts +48 -2
- package/build/modern/vueQueryPlugin.d.ts.map +1 -1
- package/build/modern/vueQueryPlugin.js +34 -0
- package/build/modern/vueQueryPlugin.js.map +1 -1
- package/package.json +10 -10
- package/src/index.ts +9 -9
- package/src/infiniteQueryOptions.ts +86 -0
- package/src/mutationCache.ts +5 -0
- package/src/mutationOptions.ts +123 -0
- package/src/queryCache.ts +5 -0
- package/src/queryClient.ts +17 -1
- package/src/queryOptions.ts +276 -10
- package/src/types.ts +18 -0
- package/src/useBaseQuery.ts +9 -1
- package/src/useInfiniteQuery.ts +240 -0
- package/src/useIsFetching.ts +46 -3
- package/src/useMutation.ts +170 -17
- package/src/useMutationState.ts +111 -4
- package/src/usePrefetchInfiniteQuery.ts +46 -0
- package/src/usePrefetchQuery.ts +37 -0
- package/src/useQueries.ts +124 -1
- package/src/useQuery.ts +240 -79
- package/src/useQueryClient.ts +21 -0
- package/src/utils.ts +15 -0
- package/src/vueQueryPlugin.ts +46 -0
- package/build/legacy/queryClient-C07d0chJ.d.cts +0 -97
- package/build/legacy/queryClient-C07d0chJ.d.cts.map +0 -1
- package/build/legacy/queryClient-hf6i_vCa.d.ts +0 -97
- package/build/legacy/queryClient-hf6i_vCa.d.ts.map +0 -1
- package/build/legacy/queryOptions.d.cts.map +0 -1
- package/build/legacy/queryOptions.d.ts.map +0 -1
- package/build/legacy/types-BzZi3_rS.d.cts.map +0 -1
- package/build/legacy/types-BzZi3_rS.d.ts.map +0 -1
- package/build/modern/queryClient-C07d0chJ.d.cts +0 -97
- package/build/modern/queryClient-C07d0chJ.d.cts.map +0 -1
- package/build/modern/queryClient-hf6i_vCa.d.ts +0 -97
- package/build/modern/queryClient-hf6i_vCa.d.ts.map +0 -1
- package/build/modern/queryOptions.d.cts.map +0 -1
- package/build/modern/queryOptions.d.ts.map +0 -1
- package/build/modern/types-BzZi3_rS.d.cts.map +0 -1
- package/build/modern/types-BzZi3_rS.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMutation.cjs","names":["getCurrentScope","useQueryClient","computed","cloneDeepUnref","MutationObserver","shallowReactive","reactive","shallowReadonly","readonly","toRefs","shouldThrowError"],"sources":["../../src/useMutation.ts"],"sourcesContent":["import {\n computed,\n getCurrentScope,\n onScopeDispose,\n reactive,\n readonly,\n shallowReactive,\n shallowReadonly,\n toRefs,\n watch,\n} from 'vue-demi'\nimport { MutationObserver, shouldThrowError } from '@tanstack/query-core'\nimport { cloneDeepUnref, updateState } from './utils'\nimport { useQueryClient } from './useQueryClient'\nimport type { ToRefs } from 'vue-demi'\nimport type {\n DefaultError,\n DistributiveOmit,\n MutateFunction,\n MutationObserverResult,\n} from '@tanstack/query-core'\nimport type { MaybeRefDeep, MutationOptions } from './types'\nimport type { QueryClient } from './queryClient'\n\ntype MutationResult<TData, TError, TVariables, TOnMutateResult> =\n DistributiveOmit<\n MutationObserverResult<TData, TError, TVariables, TOnMutateResult>,\n 'mutate' | 'reset'\n >\n\nexport type UseMutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n> =\n | MaybeRefDeep<MutationOptions<TData, TError, TVariables, TOnMutateResult>>\n | (() => MaybeRefDeep<\n MutationOptions<TData, TError, TVariables, TOnMutateResult>\n >)\n\ntype MutateSyncFunction<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n> = (\n ...options: Parameters<\n MutateFunction<TData, TError, TVariables, TOnMutateResult>\n >\n) => void\n\nexport type UseMutationReturnType<\n TData,\n TError,\n TVariables,\n TOnMutateResult,\n TResult = MutationResult<TData, TError, TVariables, TOnMutateResult>,\n> = ToRefs<Readonly<TResult>> & {\n mutate: MutateSyncFunction<TData, TError, TVariables, TOnMutateResult>\n mutateAsync: MutateFunction<TData, TError, TVariables, TOnMutateResult>\n reset: MutationObserverResult<\n TData,\n TError,\n TVariables,\n TOnMutateResult\n >['reset']\n}\n\nexport function useMutation<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n>(\n mutationOptions: UseMutationOptions<\n TData,\n TError,\n TVariables,\n TOnMutateResult\n >,\n queryClient?: QueryClient,\n): UseMutationReturnType<TData, TError, TVariables, TOnMutateResult> {\n if (process.env.NODE_ENV === 'development') {\n if (!getCurrentScope()) {\n console.warn(\n 'vue-query composable like \"useQuery()\" should only be used inside a \"setup()\" function or a running effect scope. They might otherwise lead to memory leaks.',\n )\n }\n }\n\n const client = queryClient || useQueryClient()\n const options = computed(() => {\n const resolvedOptions =\n typeof mutationOptions === 'function'\n ? mutationOptions()\n : mutationOptions\n return client.defaultMutationOptions(cloneDeepUnref(resolvedOptions))\n })\n const observer = new MutationObserver(client, options.value)\n const state = options.value.shallow\n ? shallowReactive(observer.getCurrentResult())\n : reactive(observer.getCurrentResult())\n\n const unsubscribe = observer.subscribe((result) => {\n updateState(state, result)\n })\n\n const mutate = (\n ...args: Parameters<\n MutateFunction<TData, TError, TVariables, TOnMutateResult>\n >\n ) => {\n observer.mutate(args[0] as TVariables, args[1]).catch(() => {\n // This is intentional\n })\n }\n\n watch(options, () => {\n observer.setOptions(options.value)\n })\n\n onScopeDispose(() => {\n unsubscribe()\n })\n\n const readonlyState = options.value.shallow\n ? shallowReadonly(state)\n : readonly(state)\n\n const resultRefs = toRefs(readonlyState) as ToRefs<\n Readonly<MutationResult<TData, TError, TVariables, TOnMutateResult>>\n >\n\n watch(\n () => state.error,\n (error) => {\n if (\n error &&\n shouldThrowError(options.value.throwOnError, [error as TError])\n ) {\n throw error\n }\n },\n )\n\n return {\n ...resultRefs,\n mutate,\n mutateAsync: state.mutate,\n reset: state.reset,\n }\n}\n"],"mappings":";;;;;;AAqEA,SAAgB,YAMd,iBAMA,aACmE;CACnE,IAAI,QAAQ,IAAI,aAAa,eACvB;MAAA,EAAA,GAACA,SAAAA,gBAAAA,CAAgB,GACnB,QAAQ,KACN,kKACF;CAAA;CAIJ,MAAM,SAAS,eAAeC,uBAAAA,eAAe;CAC7C,MAAM,WAAA,GAAUC,SAAAA,SAAAA,OAAe;EAC7B,MAAM,kBACJ,OAAO,oBAAoB,aACvB,gBAAgB,IAChB;EACN,OAAO,OAAO,uBAAuBC,cAAAA,eAAe,eAAe,CAAC;CACtE,CAAC;CACD,MAAM,WAAW,IAAIC,qBAAAA,iBAAiB,QAAQ,QAAQ,KAAK;CAC3D,MAAM,QAAQ,QAAQ,MAAM,WAAA,GACxBC,SAAAA,gBAAAA,CAAgB,SAAS,iBAAiB,CAAC,KAAA,GAC3CC,SAAAA,SAAAA,CAAS,SAAS,iBAAiB,CAAC;CAExC,MAAM,cAAc,SAAS,WAAW,WAAW;EACjD,cAAA,YAAY,OAAO,MAAM;CAC3B,CAAC;CAED,MAAM,UACJ,GAAG,SAGA;EACH,SAAS,OAAO,KAAK,IAAkB,KAAK,EAAE,CAAC,CAAC,YAAY,CAE5D,CAAC;CACH;CAEA,CAAA,GAAA,SAAA,MAAA,CAAM,eAAe;EACnB,SAAS,WAAW,QAAQ,KAAK;CACnC,CAAC;CAED,CAAA,GAAA,SAAA,eAAA,OAAqB;EACnB,YAAY;CACd,CAAC;CAED,MAAM,gBAAgB,QAAQ,MAAM,WAAA,GAChCC,SAAAA,gBAAAA,CAAgB,KAAK,KAAA,GACrBC,SAAAA,SAAAA,CAAS,KAAK;CAElB,MAAM,cAAA,GAAaC,SAAAA,OAAAA,CAAO,aAAa;CAIvC,CAAA,GAAA,SAAA,MAAA,OACQ,MAAM,QACX,UAAU;EACT,IACE,UAAA,GACAC,qBAAAA,iBAAAA,CAAiB,QAAQ,MAAM,cAAc,CAAC,KAAe,CAAC,GAE9D,MAAM;CAEV,CACF;CAEA,OAAO;EACL,GAAG;EACH;EACA,aAAa,MAAM;EACnB,OAAO,MAAM;CACf;AACF"}
|
|
1
|
+
{"version":3,"file":"useMutation.cjs","names":["getCurrentScope","useQueryClient","computed","cloneDeepUnref","MutationObserver","shallowReactive","reactive","shallowReadonly","readonly","toRefs","shouldThrowError"],"sources":["../../src/useMutation.ts"],"sourcesContent":["import {\n computed,\n getCurrentScope,\n onScopeDispose,\n reactive,\n readonly,\n shallowReactive,\n shallowReadonly,\n toRefs,\n watch,\n} from 'vue-demi'\nimport { MutationObserver, shouldThrowError } from '@tanstack/query-core'\nimport { cloneDeepUnref, updateState } from './utils'\nimport { useQueryClient } from './useQueryClient'\nimport type { ToRefs } from 'vue-demi'\nimport type {\n DefaultError,\n DistributiveOmit,\n MutateFunction,\n MutationObserverResult,\n} from '@tanstack/query-core'\nimport type { MaybeRefDeep, MutationOptions } from './types'\nimport type { QueryClient } from './queryClient'\n\ntype MutationResult<TData, TError, TVariables, TOnMutateResult> =\n DistributiveOmit<\n MutationObserverResult<TData, TError, TVariables, TOnMutateResult>,\n 'mutate' | 'reset'\n >\n\nexport type UseMutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n> =\n | MaybeRefDeep<MutationOptions<TData, TError, TVariables, TOnMutateResult>>\n | (() => MaybeRefDeep<\n MutationOptions<TData, TError, TVariables, TOnMutateResult>\n >)\n\ntype MutateSyncFunction<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n> = (\n ...options: Parameters<\n MutateFunction<TData, TError, TVariables, TOnMutateResult>\n >\n) => void\n\nexport type UseMutationReturnType<\n TData,\n TError,\n TVariables,\n TOnMutateResult,\n TResult = MutationResult<TData, TError, TVariables, TOnMutateResult>,\n> = ToRefs<Readonly<TResult>> & {\n mutate: MutateSyncFunction<TData, TError, TVariables, TOnMutateResult>\n mutateAsync: MutateFunction<TData, TError, TVariables, TOnMutateResult>\n reset: MutationObserverResult<\n TData,\n TError,\n TVariables,\n TOnMutateResult\n >['reset']\n}\n\n/**\n * Unlike queries, mutations are typically used to create/update/delete data or perform server side-effects.\n * `useMutation` is the composable for that.\n *\n * `options` may be a plain object, a `ref`, or a reactive getter (`() => ({ ... })`) — pass a getter\n * if the options themselves depend on other reactive state.\n *\n * @see {@link mutationOptions} to share these options across multiple `useMutation` call sites, or to look\n * the mutation up elsewhere via its `mutationKey` (e.g. with `useMutationState`).\n * @param options - The {@link UseMutationOptions} to use — everything you can pass to `useMutation`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns `mutate`/`mutateAsync` also accept per-call `onSuccess`/`onError`/`onSettled` callbacks as a second\n * argument, useful for triggering call-site side effects (e.g. navigation) without coupling them to the shared\n * mutation definition. Hook-level callbacks (passed to `options`) fire for every mutation; per-call\n * callbacks fire only for the latest call you've made.\n *\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { useMutation, useQueryClient } from '@tanstack/vue-query'\n *\n * const queryClient = useQueryClient()\n *\n * const addMutation = useMutation({\n * mutationFn: addTodo,\n * onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n * })\n *\n * function onAdd() {\n * addMutation.mutate('Item', {\n * onError: (error) => console.error('Failed to add item:', error),\n * })\n * }\n * </script>\n *\n * <template>\n * <button @click=\"onAdd\">Add</button>\n * </template>\n * ```\n *\n * @example\n * Rendering the mutation's own state, rather than just firing it off:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useMutation, useQueryClient } from '@tanstack/vue-query'\n *\n * const queryClient = useQueryClient()\n *\n * const addMutation = useMutation({\n * mutationFn: addTodo,\n * onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n * })\n * </script>\n *\n * <template>\n * <div v-if=\"addMutation.isPending.value\">Adding todo...</div>\n * <div v-else>\n * <div v-if=\"addMutation.isError.value\">An error occurred: {{ addMutation.error.value.message }}</div>\n * <button @click=\"addMutation.mutate('Item')\">Add</button>\n * </div>\n * </template>\n * ```\n *\n * @example\n * Optimistic update via `onMutate`, rolling back on `onError`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useMutation, useQueryClient } from '@tanstack/vue-query'\n *\n * const queryClient = useQueryClient()\n *\n * const addMutation = useMutation({\n * mutationFn: addTodo,\n * onMutate: async (newTodo: string) => {\n * await queryClient.cancelQueries({ queryKey: ['todos'] })\n * const previousTodos = queryClient.getQueryData<Array<string>>(['todos'])\n *\n * queryClient.setQueryData<Array<string>>(['todos'], (old) => [\n * ...(old ?? []),\n * newTodo,\n * ])\n *\n * // Passed to `onError` as `onMutateResult` if the mutation fails.\n * return { previousTodos }\n * },\n * onError: (_err, _newTodo, onMutateResult) => {\n * queryClient.setQueryData(['todos'], onMutateResult?.previousTodos)\n * },\n * onSettled: () => {\n * queryClient.invalidateQueries({ queryKey: ['todos'] })\n * },\n * })\n * </script>\n *\n * <template>\n * <button @click=\"addMutation.mutate('Item')\">Add</button>\n * </template>\n * ```\n *\n * @example\n * Callbacks passed per call to `mutate` only fire for the last call — `mutateAsync` gives you a\n * promise per call instead, so you can wait for all of them when they succeed:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useMutation, useQueryClient } from '@tanstack/vue-query'\n *\n * const queryClient = useQueryClient()\n *\n * const addMutation = useMutation({\n * mutationFn: addTodo,\n * onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n * })\n *\n * async function handleAddAll(todos: Array<string>) {\n * try {\n * await Promise.all(todos.map((todo) => addMutation.mutateAsync(todo)))\n * } catch (error) {\n * console.error('Failed to add todos:', error)\n * }\n * }\n * </script>\n *\n * <template>\n * <button @click=\"handleAddAll(['Todo 1', 'Todo 2', 'Todo 3'])\">Add all</button>\n * </template>\n * ```\n *\n * @example\n * If some of the mutations above can fail independently of the others, and you want to know which ones\n * did — rather than losing that information the moment the first one rejects — swap `Promise.all` for\n * `Promise.allSettled`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useMutation, useQueryClient } from '@tanstack/vue-query'\n *\n * const queryClient = useQueryClient()\n *\n * const addMutation = useMutation({\n * mutationFn: addTodo,\n * onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n * })\n *\n * async function handleAddAll(todos: Array<string>) {\n * const addResults = await Promise.allSettled(\n * todos.map((todo) => addMutation.mutateAsync(todo)),\n * )\n *\n * addResults.forEach((addResult, index) => {\n * if (addResult.status === 'rejected') {\n * console.error(`Failed to add \"${todos[index]}\":`, addResult.reason)\n * }\n * })\n * }\n * </script>\n *\n * <template>\n * <button @click=\"handleAddAll(['Todo 1', 'Todo 2', 'Todo 3'])\">Add all</button>\n * </template>\n * ```\n */\nexport function useMutation<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n>(\n options: UseMutationOptions<TData, TError, TVariables, TOnMutateResult>,\n queryClient?: QueryClient,\n): UseMutationReturnType<TData, TError, TVariables, TOnMutateResult> {\n if (process.env.NODE_ENV === 'development') {\n if (!getCurrentScope()) {\n console.warn(\n 'vue-query composable like \"useQuery()\" should only be used inside a \"setup()\" function or a running effect scope. They might otherwise lead to memory leaks.',\n )\n }\n }\n\n const client = queryClient || useQueryClient()\n const defaultedOptions = computed(() => {\n const resolvedOptions = typeof options === 'function' ? options() : options\n return client.defaultMutationOptions(cloneDeepUnref(resolvedOptions))\n })\n const observer = new MutationObserver(client, defaultedOptions.value)\n const state = defaultedOptions.value.shallow\n ? shallowReactive(observer.getCurrentResult())\n : reactive(observer.getCurrentResult())\n\n const unsubscribe = observer.subscribe((result) => {\n updateState(state, result)\n })\n\n const mutate = (\n ...args: Parameters<\n MutateFunction<TData, TError, TVariables, TOnMutateResult>\n >\n ) => {\n observer.mutate(args[0] as TVariables, args[1]).catch(() => {\n // This is intentional\n })\n }\n\n watch(defaultedOptions, () => {\n observer.setOptions(defaultedOptions.value)\n })\n\n onScopeDispose(() => {\n unsubscribe()\n })\n\n const readonlyState = defaultedOptions.value.shallow\n ? shallowReadonly(state)\n : readonly(state)\n\n const resultRefs = toRefs(readonlyState) as ToRefs<\n Readonly<MutationResult<TData, TError, TVariables, TOnMutateResult>>\n >\n\n watch(\n () => state.error,\n (error) => {\n if (\n error &&\n shouldThrowError(defaultedOptions.value.throwOnError, [error as TError])\n ) {\n throw error\n }\n },\n )\n\n return {\n ...resultRefs,\n mutate,\n mutateAsync: state.mutate,\n reset: state.reset,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsOA,SAAgB,YAMd,SACA,aACmE;CACnE,IAAI,QAAQ,IAAI,aAAa,eACvB;MAAA,EAAA,GAACA,SAAAA,gBAAAA,CAAgB,GACnB,QAAQ,KACN,kKACF;CAAA;CAIJ,MAAM,SAAS,eAAeC,uBAAAA,eAAe;CAC7C,MAAM,oBAAA,GAAmBC,SAAAA,SAAAA,OAAe;EACtC,MAAM,kBAAkB,OAAO,YAAY,aAAa,QAAQ,IAAI;EACpE,OAAO,OAAO,uBAAuBC,cAAAA,eAAe,eAAe,CAAC;CACtE,CAAC;CACD,MAAM,WAAW,IAAIC,qBAAAA,iBAAiB,QAAQ,iBAAiB,KAAK;CACpE,MAAM,QAAQ,iBAAiB,MAAM,WAAA,GACjCC,SAAAA,gBAAAA,CAAgB,SAAS,iBAAiB,CAAC,KAAA,GAC3CC,SAAAA,SAAAA,CAAS,SAAS,iBAAiB,CAAC;CAExC,MAAM,cAAc,SAAS,WAAW,WAAW;EACjD,cAAA,YAAY,OAAO,MAAM;CAC3B,CAAC;CAED,MAAM,UACJ,GAAG,SAGA;EACH,SAAS,OAAO,KAAK,IAAkB,KAAK,EAAE,CAAC,CAAC,YAAY,CAE5D,CAAC;CACH;CAEA,CAAA,GAAA,SAAA,MAAA,CAAM,wBAAwB;EAC5B,SAAS,WAAW,iBAAiB,KAAK;CAC5C,CAAC;CAED,CAAA,GAAA,SAAA,eAAA,OAAqB;EACnB,YAAY;CACd,CAAC;CAED,MAAM,gBAAgB,iBAAiB,MAAM,WAAA,GACzCC,SAAAA,gBAAAA,CAAgB,KAAK,KAAA,GACrBC,SAAAA,SAAAA,CAAS,KAAK;CAElB,MAAM,cAAA,GAAaC,SAAAA,OAAAA,CAAO,aAAa;CAIvC,CAAA,GAAA,SAAA,MAAA,OACQ,MAAM,QACX,UAAU;EACT,IACE,UAAA,GACAC,qBAAAA,iBAAAA,CAAiB,iBAAiB,MAAM,cAAc,CAAC,KAAe,CAAC,GAEvE,MAAM;CAEV,CACF;CAEA,OAAO;EACL,GAAG;EACH;EACA,aAAa,MAAM;EACnB,OAAO,MAAM;CACf;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { c as MutationOptions, o as MaybeRefDeep } from "./types-JpJB72CS.cjs";
|
|
2
|
+
import { t as QueryClient$1 } from "./queryClient-CZeNAt68.cjs";
|
|
3
3
|
import { DefaultError, DistributiveOmit, MutateFunction, MutationObserverResult } from "@tanstack/query-core";
|
|
4
4
|
import { ToRefs } from "vue-demi";
|
|
5
5
|
//#region src/useMutation.d.ts
|
|
@@ -11,7 +11,168 @@ type UseMutationReturnType<TData, TError, TVariables, TOnMutateResult, TResult =
|
|
|
11
11
|
mutateAsync: MutateFunction<TData, TError, TVariables, TOnMutateResult>;
|
|
12
12
|
reset: MutationObserverResult<TData, TError, TVariables, TOnMutateResult>['reset'];
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Unlike queries, mutations are typically used to create/update/delete data or perform server side-effects.
|
|
16
|
+
* `useMutation` is the composable for that.
|
|
17
|
+
*
|
|
18
|
+
* `options` may be a plain object, a `ref`, or a reactive getter (`() => ({ ... })`) — pass a getter
|
|
19
|
+
* if the options themselves depend on other reactive state.
|
|
20
|
+
*
|
|
21
|
+
* @see {@link mutationOptions} to share these options across multiple `useMutation` call sites, or to look
|
|
22
|
+
* the mutation up elsewhere via its `mutationKey` (e.g. with `useMutationState`).
|
|
23
|
+
* @param options - The {@link UseMutationOptions} to use — everything you can pass to `useMutation`.
|
|
24
|
+
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`
|
|
25
|
+
* will be used.
|
|
26
|
+
* @returns `mutate`/`mutateAsync` also accept per-call `onSuccess`/`onError`/`onSettled` callbacks as a second
|
|
27
|
+
* argument, useful for triggering call-site side effects (e.g. navigation) without coupling them to the shared
|
|
28
|
+
* mutation definition. Hook-level callbacks (passed to `options`) fire for every mutation; per-call
|
|
29
|
+
* callbacks fire only for the latest call you've made.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```vue
|
|
33
|
+
* <script setup lang="ts">
|
|
34
|
+
* import { useMutation, useQueryClient } from '@tanstack/vue-query'
|
|
35
|
+
*
|
|
36
|
+
* const queryClient = useQueryClient()
|
|
37
|
+
*
|
|
38
|
+
* const addMutation = useMutation({
|
|
39
|
+
* mutationFn: addTodo,
|
|
40
|
+
* onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),
|
|
41
|
+
* })
|
|
42
|
+
*
|
|
43
|
+
* function onAdd() {
|
|
44
|
+
* addMutation.mutate('Item', {
|
|
45
|
+
* onError: (error) => console.error('Failed to add item:', error),
|
|
46
|
+
* })
|
|
47
|
+
* }
|
|
48
|
+
* </script>
|
|
49
|
+
*
|
|
50
|
+
* <template>
|
|
51
|
+
* <button @click="onAdd">Add</button>
|
|
52
|
+
* </template>
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* Rendering the mutation's own state, rather than just firing it off:
|
|
57
|
+
* ```vue
|
|
58
|
+
* <script setup lang="ts">
|
|
59
|
+
* import { useMutation, useQueryClient } from '@tanstack/vue-query'
|
|
60
|
+
*
|
|
61
|
+
* const queryClient = useQueryClient()
|
|
62
|
+
*
|
|
63
|
+
* const addMutation = useMutation({
|
|
64
|
+
* mutationFn: addTodo,
|
|
65
|
+
* onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),
|
|
66
|
+
* })
|
|
67
|
+
* </script>
|
|
68
|
+
*
|
|
69
|
+
* <template>
|
|
70
|
+
* <div v-if="addMutation.isPending.value">Adding todo...</div>
|
|
71
|
+
* <div v-else>
|
|
72
|
+
* <div v-if="addMutation.isError.value">An error occurred: {{ addMutation.error.value.message }}</div>
|
|
73
|
+
* <button @click="addMutation.mutate('Item')">Add</button>
|
|
74
|
+
* </div>
|
|
75
|
+
* </template>
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* Optimistic update via `onMutate`, rolling back on `onError`:
|
|
80
|
+
* ```vue
|
|
81
|
+
* <script setup lang="ts">
|
|
82
|
+
* import { useMutation, useQueryClient } from '@tanstack/vue-query'
|
|
83
|
+
*
|
|
84
|
+
* const queryClient = useQueryClient()
|
|
85
|
+
*
|
|
86
|
+
* const addMutation = useMutation({
|
|
87
|
+
* mutationFn: addTodo,
|
|
88
|
+
* onMutate: async (newTodo: string) => {
|
|
89
|
+
* await queryClient.cancelQueries({ queryKey: ['todos'] })
|
|
90
|
+
* const previousTodos = queryClient.getQueryData<Array<string>>(['todos'])
|
|
91
|
+
*
|
|
92
|
+
* queryClient.setQueryData<Array<string>>(['todos'], (old) => [
|
|
93
|
+
* ...(old ?? []),
|
|
94
|
+
* newTodo,
|
|
95
|
+
* ])
|
|
96
|
+
*
|
|
97
|
+
* // Passed to `onError` as `onMutateResult` if the mutation fails.
|
|
98
|
+
* return { previousTodos }
|
|
99
|
+
* },
|
|
100
|
+
* onError: (_err, _newTodo, onMutateResult) => {
|
|
101
|
+
* queryClient.setQueryData(['todos'], onMutateResult?.previousTodos)
|
|
102
|
+
* },
|
|
103
|
+
* onSettled: () => {
|
|
104
|
+
* queryClient.invalidateQueries({ queryKey: ['todos'] })
|
|
105
|
+
* },
|
|
106
|
+
* })
|
|
107
|
+
* </script>
|
|
108
|
+
*
|
|
109
|
+
* <template>
|
|
110
|
+
* <button @click="addMutation.mutate('Item')">Add</button>
|
|
111
|
+
* </template>
|
|
112
|
+
* ```
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* Callbacks passed per call to `mutate` only fire for the last call — `mutateAsync` gives you a
|
|
116
|
+
* promise per call instead, so you can wait for all of them when they succeed:
|
|
117
|
+
* ```vue
|
|
118
|
+
* <script setup lang="ts">
|
|
119
|
+
* import { useMutation, useQueryClient } from '@tanstack/vue-query'
|
|
120
|
+
*
|
|
121
|
+
* const queryClient = useQueryClient()
|
|
122
|
+
*
|
|
123
|
+
* const addMutation = useMutation({
|
|
124
|
+
* mutationFn: addTodo,
|
|
125
|
+
* onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),
|
|
126
|
+
* })
|
|
127
|
+
*
|
|
128
|
+
* async function handleAddAll(todos: Array<string>) {
|
|
129
|
+
* try {
|
|
130
|
+
* await Promise.all(todos.map((todo) => addMutation.mutateAsync(todo)))
|
|
131
|
+
* } catch (error) {
|
|
132
|
+
* console.error('Failed to add todos:', error)
|
|
133
|
+
* }
|
|
134
|
+
* }
|
|
135
|
+
* </script>
|
|
136
|
+
*
|
|
137
|
+
* <template>
|
|
138
|
+
* <button @click="handleAddAll(['Todo 1', 'Todo 2', 'Todo 3'])">Add all</button>
|
|
139
|
+
* </template>
|
|
140
|
+
* ```
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* If some of the mutations above can fail independently of the others, and you want to know which ones
|
|
144
|
+
* did — rather than losing that information the moment the first one rejects — swap `Promise.all` for
|
|
145
|
+
* `Promise.allSettled`:
|
|
146
|
+
* ```vue
|
|
147
|
+
* <script setup lang="ts">
|
|
148
|
+
* import { useMutation, useQueryClient } from '@tanstack/vue-query'
|
|
149
|
+
*
|
|
150
|
+
* const queryClient = useQueryClient()
|
|
151
|
+
*
|
|
152
|
+
* const addMutation = useMutation({
|
|
153
|
+
* mutationFn: addTodo,
|
|
154
|
+
* onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),
|
|
155
|
+
* })
|
|
156
|
+
*
|
|
157
|
+
* async function handleAddAll(todos: Array<string>) {
|
|
158
|
+
* const addResults = await Promise.allSettled(
|
|
159
|
+
* todos.map((todo) => addMutation.mutateAsync(todo)),
|
|
160
|
+
* )
|
|
161
|
+
*
|
|
162
|
+
* addResults.forEach((addResult, index) => {
|
|
163
|
+
* if (addResult.status === 'rejected') {
|
|
164
|
+
* console.error(`Failed to add "${todos[index]}":`, addResult.reason)
|
|
165
|
+
* }
|
|
166
|
+
* })
|
|
167
|
+
* }
|
|
168
|
+
* </script>
|
|
169
|
+
*
|
|
170
|
+
* <template>
|
|
171
|
+
* <button @click="handleAddAll(['Todo 1', 'Todo 2', 'Todo 3'])">Add all</button>
|
|
172
|
+
* </template>
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
declare function useMutation<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown>(options: UseMutationOptions<TData, TError, TVariables, TOnMutateResult>, queryClient?: QueryClient$1): UseMutationReturnType<TData, TError, TVariables, TOnMutateResult>;
|
|
15
176
|
//#endregion
|
|
16
177
|
export { UseMutationOptions, UseMutationReturnType, useMutation };
|
|
17
178
|
//# sourceMappingURL=useMutation.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMutation.d.cts","names":[],"sources":["../../src/useMutation.ts"],"mappings":";;;;;KAwBK,eAAe,OAAO,QAAQ,YAAY,mBAC7C,iBACE,uBAAuB,OAAO,QAAQ,YAAY;KAI1C,mBACV,iBACA,SAAS,cACT,mBACA,6BAEE,aAAa,gBAAgB,OAAO,QAAQ,YAAY,2BACjD,aACL,gBAAgB,OAAO,QAAQ,YAAY;KAG5C,mBACH,iBACA,SAAS,cACT,mBACA,iCAEG,SAAS,WACV,eAAe,OAAO,QAAQ,YAAY;KAIlC,sBACV,OACA,QACA,YACA,iBACA,UAAU,eAAe,OAAO,QAAQ,YAAY,oBAClD,OAAO,SAAS;EAClB,QAAQ,mBAAmB,OAAO,QAAQ,YAAY;EACtD,aAAa,eAAe,OAAO,QAAQ,YAAY;EACvD,OAAO,uBACL,OACA,QACA,YACA
|
|
1
|
+
{"version":3,"file":"useMutation.d.cts","names":[],"sources":["../../src/useMutation.ts"],"mappings":";;;;;KAwBK,eAAe,OAAO,QAAQ,YAAY,mBAC7C,iBACE,uBAAuB,OAAO,QAAQ,YAAY;KAI1C,mBACV,iBACA,SAAS,cACT,mBACA,6BAEE,aAAa,gBAAgB,OAAO,QAAQ,YAAY,2BACjD,aACL,gBAAgB,OAAO,QAAQ,YAAY;KAG5C,mBACH,iBACA,SAAS,cACT,mBACA,iCAEG,SAAS,WACV,eAAe,OAAO,QAAQ,YAAY;KAIlC,sBACV,OACA,QACA,YACA,iBACA,UAAU,eAAe,OAAO,QAAQ,YAAY,oBAClD,OAAO,SAAS;EAClB,QAAQ,mBAAmB,OAAO,QAAQ,YAAY;EACtD,aAAa,eAAe,OAAO,QAAQ,YAAY;EACvD,OAAO,uBACL,OACA,QACA,YACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqKY,YACd,iBACA,SAAS,cACT,mBACA,2BAEA,SAAS,mBAAmB,OAAO,QAAQ,YAAY,kBACvD,cAAc,gBACb,sBAAsB,OAAO,QAAQ,YAAY"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { c as MutationOptions, o as MaybeRefDeep } from "./types-JpJB72CS.js";
|
|
2
|
+
import { t as QueryClient$1 } from "./queryClient-Cv73nzNT.js";
|
|
3
3
|
import { DefaultError, DistributiveOmit, MutateFunction, MutationObserverResult } from "@tanstack/query-core";
|
|
4
4
|
import { ToRefs } from "vue-demi";
|
|
5
5
|
//#region src/useMutation.d.ts
|
|
@@ -11,7 +11,168 @@ type UseMutationReturnType<TData, TError, TVariables, TOnMutateResult, TResult =
|
|
|
11
11
|
mutateAsync: MutateFunction<TData, TError, TVariables, TOnMutateResult>;
|
|
12
12
|
reset: MutationObserverResult<TData, TError, TVariables, TOnMutateResult>['reset'];
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Unlike queries, mutations are typically used to create/update/delete data or perform server side-effects.
|
|
16
|
+
* `useMutation` is the composable for that.
|
|
17
|
+
*
|
|
18
|
+
* `options` may be a plain object, a `ref`, or a reactive getter (`() => ({ ... })`) — pass a getter
|
|
19
|
+
* if the options themselves depend on other reactive state.
|
|
20
|
+
*
|
|
21
|
+
* @see {@link mutationOptions} to share these options across multiple `useMutation` call sites, or to look
|
|
22
|
+
* the mutation up elsewhere via its `mutationKey` (e.g. with `useMutationState`).
|
|
23
|
+
* @param options - The {@link UseMutationOptions} to use — everything you can pass to `useMutation`.
|
|
24
|
+
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`
|
|
25
|
+
* will be used.
|
|
26
|
+
* @returns `mutate`/`mutateAsync` also accept per-call `onSuccess`/`onError`/`onSettled` callbacks as a second
|
|
27
|
+
* argument, useful for triggering call-site side effects (e.g. navigation) without coupling them to the shared
|
|
28
|
+
* mutation definition. Hook-level callbacks (passed to `options`) fire for every mutation; per-call
|
|
29
|
+
* callbacks fire only for the latest call you've made.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```vue
|
|
33
|
+
* <script setup lang="ts">
|
|
34
|
+
* import { useMutation, useQueryClient } from '@tanstack/vue-query'
|
|
35
|
+
*
|
|
36
|
+
* const queryClient = useQueryClient()
|
|
37
|
+
*
|
|
38
|
+
* const addMutation = useMutation({
|
|
39
|
+
* mutationFn: addTodo,
|
|
40
|
+
* onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),
|
|
41
|
+
* })
|
|
42
|
+
*
|
|
43
|
+
* function onAdd() {
|
|
44
|
+
* addMutation.mutate('Item', {
|
|
45
|
+
* onError: (error) => console.error('Failed to add item:', error),
|
|
46
|
+
* })
|
|
47
|
+
* }
|
|
48
|
+
* </script>
|
|
49
|
+
*
|
|
50
|
+
* <template>
|
|
51
|
+
* <button @click="onAdd">Add</button>
|
|
52
|
+
* </template>
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* Rendering the mutation's own state, rather than just firing it off:
|
|
57
|
+
* ```vue
|
|
58
|
+
* <script setup lang="ts">
|
|
59
|
+
* import { useMutation, useQueryClient } from '@tanstack/vue-query'
|
|
60
|
+
*
|
|
61
|
+
* const queryClient = useQueryClient()
|
|
62
|
+
*
|
|
63
|
+
* const addMutation = useMutation({
|
|
64
|
+
* mutationFn: addTodo,
|
|
65
|
+
* onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),
|
|
66
|
+
* })
|
|
67
|
+
* </script>
|
|
68
|
+
*
|
|
69
|
+
* <template>
|
|
70
|
+
* <div v-if="addMutation.isPending.value">Adding todo...</div>
|
|
71
|
+
* <div v-else>
|
|
72
|
+
* <div v-if="addMutation.isError.value">An error occurred: {{ addMutation.error.value.message }}</div>
|
|
73
|
+
* <button @click="addMutation.mutate('Item')">Add</button>
|
|
74
|
+
* </div>
|
|
75
|
+
* </template>
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* Optimistic update via `onMutate`, rolling back on `onError`:
|
|
80
|
+
* ```vue
|
|
81
|
+
* <script setup lang="ts">
|
|
82
|
+
* import { useMutation, useQueryClient } from '@tanstack/vue-query'
|
|
83
|
+
*
|
|
84
|
+
* const queryClient = useQueryClient()
|
|
85
|
+
*
|
|
86
|
+
* const addMutation = useMutation({
|
|
87
|
+
* mutationFn: addTodo,
|
|
88
|
+
* onMutate: async (newTodo: string) => {
|
|
89
|
+
* await queryClient.cancelQueries({ queryKey: ['todos'] })
|
|
90
|
+
* const previousTodos = queryClient.getQueryData<Array<string>>(['todos'])
|
|
91
|
+
*
|
|
92
|
+
* queryClient.setQueryData<Array<string>>(['todos'], (old) => [
|
|
93
|
+
* ...(old ?? []),
|
|
94
|
+
* newTodo,
|
|
95
|
+
* ])
|
|
96
|
+
*
|
|
97
|
+
* // Passed to `onError` as `onMutateResult` if the mutation fails.
|
|
98
|
+
* return { previousTodos }
|
|
99
|
+
* },
|
|
100
|
+
* onError: (_err, _newTodo, onMutateResult) => {
|
|
101
|
+
* queryClient.setQueryData(['todos'], onMutateResult?.previousTodos)
|
|
102
|
+
* },
|
|
103
|
+
* onSettled: () => {
|
|
104
|
+
* queryClient.invalidateQueries({ queryKey: ['todos'] })
|
|
105
|
+
* },
|
|
106
|
+
* })
|
|
107
|
+
* </script>
|
|
108
|
+
*
|
|
109
|
+
* <template>
|
|
110
|
+
* <button @click="addMutation.mutate('Item')">Add</button>
|
|
111
|
+
* </template>
|
|
112
|
+
* ```
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* Callbacks passed per call to `mutate` only fire for the last call — `mutateAsync` gives you a
|
|
116
|
+
* promise per call instead, so you can wait for all of them when they succeed:
|
|
117
|
+
* ```vue
|
|
118
|
+
* <script setup lang="ts">
|
|
119
|
+
* import { useMutation, useQueryClient } from '@tanstack/vue-query'
|
|
120
|
+
*
|
|
121
|
+
* const queryClient = useQueryClient()
|
|
122
|
+
*
|
|
123
|
+
* const addMutation = useMutation({
|
|
124
|
+
* mutationFn: addTodo,
|
|
125
|
+
* onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),
|
|
126
|
+
* })
|
|
127
|
+
*
|
|
128
|
+
* async function handleAddAll(todos: Array<string>) {
|
|
129
|
+
* try {
|
|
130
|
+
* await Promise.all(todos.map((todo) => addMutation.mutateAsync(todo)))
|
|
131
|
+
* } catch (error) {
|
|
132
|
+
* console.error('Failed to add todos:', error)
|
|
133
|
+
* }
|
|
134
|
+
* }
|
|
135
|
+
* </script>
|
|
136
|
+
*
|
|
137
|
+
* <template>
|
|
138
|
+
* <button @click="handleAddAll(['Todo 1', 'Todo 2', 'Todo 3'])">Add all</button>
|
|
139
|
+
* </template>
|
|
140
|
+
* ```
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* If some of the mutations above can fail independently of the others, and you want to know which ones
|
|
144
|
+
* did — rather than losing that information the moment the first one rejects — swap `Promise.all` for
|
|
145
|
+
* `Promise.allSettled`:
|
|
146
|
+
* ```vue
|
|
147
|
+
* <script setup lang="ts">
|
|
148
|
+
* import { useMutation, useQueryClient } from '@tanstack/vue-query'
|
|
149
|
+
*
|
|
150
|
+
* const queryClient = useQueryClient()
|
|
151
|
+
*
|
|
152
|
+
* const addMutation = useMutation({
|
|
153
|
+
* mutationFn: addTodo,
|
|
154
|
+
* onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),
|
|
155
|
+
* })
|
|
156
|
+
*
|
|
157
|
+
* async function handleAddAll(todos: Array<string>) {
|
|
158
|
+
* const addResults = await Promise.allSettled(
|
|
159
|
+
* todos.map((todo) => addMutation.mutateAsync(todo)),
|
|
160
|
+
* )
|
|
161
|
+
*
|
|
162
|
+
* addResults.forEach((addResult, index) => {
|
|
163
|
+
* if (addResult.status === 'rejected') {
|
|
164
|
+
* console.error(`Failed to add "${todos[index]}":`, addResult.reason)
|
|
165
|
+
* }
|
|
166
|
+
* })
|
|
167
|
+
* }
|
|
168
|
+
* </script>
|
|
169
|
+
*
|
|
170
|
+
* <template>
|
|
171
|
+
* <button @click="handleAddAll(['Todo 1', 'Todo 2', 'Todo 3'])">Add all</button>
|
|
172
|
+
* </template>
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
declare function useMutation<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown>(options: UseMutationOptions<TData, TError, TVariables, TOnMutateResult>, queryClient?: QueryClient$1): UseMutationReturnType<TData, TError, TVariables, TOnMutateResult>;
|
|
15
176
|
//#endregion
|
|
16
177
|
export { UseMutationOptions, UseMutationReturnType, useMutation };
|
|
17
178
|
//# sourceMappingURL=useMutation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMutation.d.ts","names":[],"sources":["../../src/useMutation.ts"],"mappings":";;;;;KAwBK,eAAe,OAAO,QAAQ,YAAY,mBAC7C,iBACE,uBAAuB,OAAO,QAAQ,YAAY;KAI1C,mBACV,iBACA,SAAS,cACT,mBACA,6BAEE,aAAa,gBAAgB,OAAO,QAAQ,YAAY,2BACjD,aACL,gBAAgB,OAAO,QAAQ,YAAY;KAG5C,mBACH,iBACA,SAAS,cACT,mBACA,iCAEG,SAAS,WACV,eAAe,OAAO,QAAQ,YAAY;KAIlC,sBACV,OACA,QACA,YACA,iBACA,UAAU,eAAe,OAAO,QAAQ,YAAY,oBAClD,OAAO,SAAS;EAClB,QAAQ,mBAAmB,OAAO,QAAQ,YAAY;EACtD,aAAa,eAAe,OAAO,QAAQ,YAAY;EACvD,OAAO,uBACL,OACA,QACA,YACA
|
|
1
|
+
{"version":3,"file":"useMutation.d.ts","names":[],"sources":["../../src/useMutation.ts"],"mappings":";;;;;KAwBK,eAAe,OAAO,QAAQ,YAAY,mBAC7C,iBACE,uBAAuB,OAAO,QAAQ,YAAY;KAI1C,mBACV,iBACA,SAAS,cACT,mBACA,6BAEE,aAAa,gBAAgB,OAAO,QAAQ,YAAY,2BACjD,aACL,gBAAgB,OAAO,QAAQ,YAAY;KAG5C,mBACH,iBACA,SAAS,cACT,mBACA,iCAEG,SAAS,WACV,eAAe,OAAO,QAAQ,YAAY;KAIlC,sBACV,OACA,QACA,YACA,iBACA,UAAU,eAAe,OAAO,QAAQ,YAAY,oBAClD,OAAO,SAAS;EAClB,QAAQ,mBAAmB,OAAO,QAAQ,YAAY;EACtD,aAAa,eAAe,OAAO,QAAQ,YAAY;EACvD,OAAO,uBACL,OACA,QACA,YACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqKY,YACd,iBACA,SAAS,cACT,mBACA,2BAEA,SAAS,mBAAmB,OAAO,QAAQ,YAAY,kBACvD,cAAc,gBACb,sBAAsB,OAAO,QAAQ,YAAY"}
|
|
@@ -3,33 +3,194 @@ import { useQueryClient } from "./useQueryClient.js";
|
|
|
3
3
|
import { MutationObserver, shouldThrowError } from "@tanstack/query-core";
|
|
4
4
|
import { computed, getCurrentScope, onScopeDispose, reactive, readonly, shallowReactive, shallowReadonly, toRefs, watch } from "vue-demi";
|
|
5
5
|
//#region src/useMutation.ts
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Unlike queries, mutations are typically used to create/update/delete data or perform server side-effects.
|
|
8
|
+
* `useMutation` is the composable for that.
|
|
9
|
+
*
|
|
10
|
+
* `options` may be a plain object, a `ref`, or a reactive getter (`() => ({ ... })`) — pass a getter
|
|
11
|
+
* if the options themselves depend on other reactive state.
|
|
12
|
+
*
|
|
13
|
+
* @see {@link mutationOptions} to share these options across multiple `useMutation` call sites, or to look
|
|
14
|
+
* the mutation up elsewhere via its `mutationKey` (e.g. with `useMutationState`).
|
|
15
|
+
* @param options - The {@link UseMutationOptions} to use — everything you can pass to `useMutation`.
|
|
16
|
+
* @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`
|
|
17
|
+
* will be used.
|
|
18
|
+
* @returns `mutate`/`mutateAsync` also accept per-call `onSuccess`/`onError`/`onSettled` callbacks as a second
|
|
19
|
+
* argument, useful for triggering call-site side effects (e.g. navigation) without coupling them to the shared
|
|
20
|
+
* mutation definition. Hook-level callbacks (passed to `options`) fire for every mutation; per-call
|
|
21
|
+
* callbacks fire only for the latest call you've made.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```vue
|
|
25
|
+
* <script setup lang="ts">
|
|
26
|
+
* import { useMutation, useQueryClient } from '@tanstack/vue-query'
|
|
27
|
+
*
|
|
28
|
+
* const queryClient = useQueryClient()
|
|
29
|
+
*
|
|
30
|
+
* const addMutation = useMutation({
|
|
31
|
+
* mutationFn: addTodo,
|
|
32
|
+
* onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),
|
|
33
|
+
* })
|
|
34
|
+
*
|
|
35
|
+
* function onAdd() {
|
|
36
|
+
* addMutation.mutate('Item', {
|
|
37
|
+
* onError: (error) => console.error('Failed to add item:', error),
|
|
38
|
+
* })
|
|
39
|
+
* }
|
|
40
|
+
* <\/script>
|
|
41
|
+
*
|
|
42
|
+
* <template>
|
|
43
|
+
* <button @click="onAdd">Add</button>
|
|
44
|
+
* </template>
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* Rendering the mutation's own state, rather than just firing it off:
|
|
49
|
+
* ```vue
|
|
50
|
+
* <script setup lang="ts">
|
|
51
|
+
* import { useMutation, useQueryClient } from '@tanstack/vue-query'
|
|
52
|
+
*
|
|
53
|
+
* const queryClient = useQueryClient()
|
|
54
|
+
*
|
|
55
|
+
* const addMutation = useMutation({
|
|
56
|
+
* mutationFn: addTodo,
|
|
57
|
+
* onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),
|
|
58
|
+
* })
|
|
59
|
+
* <\/script>
|
|
60
|
+
*
|
|
61
|
+
* <template>
|
|
62
|
+
* <div v-if="addMutation.isPending.value">Adding todo...</div>
|
|
63
|
+
* <div v-else>
|
|
64
|
+
* <div v-if="addMutation.isError.value">An error occurred: {{ addMutation.error.value.message }}</div>
|
|
65
|
+
* <button @click="addMutation.mutate('Item')">Add</button>
|
|
66
|
+
* </div>
|
|
67
|
+
* </template>
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* Optimistic update via `onMutate`, rolling back on `onError`:
|
|
72
|
+
* ```vue
|
|
73
|
+
* <script setup lang="ts">
|
|
74
|
+
* import { useMutation, useQueryClient } from '@tanstack/vue-query'
|
|
75
|
+
*
|
|
76
|
+
* const queryClient = useQueryClient()
|
|
77
|
+
*
|
|
78
|
+
* const addMutation = useMutation({
|
|
79
|
+
* mutationFn: addTodo,
|
|
80
|
+
* onMutate: async (newTodo: string) => {
|
|
81
|
+
* await queryClient.cancelQueries({ queryKey: ['todos'] })
|
|
82
|
+
* const previousTodos = queryClient.getQueryData<Array<string>>(['todos'])
|
|
83
|
+
*
|
|
84
|
+
* queryClient.setQueryData<Array<string>>(['todos'], (old) => [
|
|
85
|
+
* ...(old ?? []),
|
|
86
|
+
* newTodo,
|
|
87
|
+
* ])
|
|
88
|
+
*
|
|
89
|
+
* // Passed to `onError` as `onMutateResult` if the mutation fails.
|
|
90
|
+
* return { previousTodos }
|
|
91
|
+
* },
|
|
92
|
+
* onError: (_err, _newTodo, onMutateResult) => {
|
|
93
|
+
* queryClient.setQueryData(['todos'], onMutateResult?.previousTodos)
|
|
94
|
+
* },
|
|
95
|
+
* onSettled: () => {
|
|
96
|
+
* queryClient.invalidateQueries({ queryKey: ['todos'] })
|
|
97
|
+
* },
|
|
98
|
+
* })
|
|
99
|
+
* <\/script>
|
|
100
|
+
*
|
|
101
|
+
* <template>
|
|
102
|
+
* <button @click="addMutation.mutate('Item')">Add</button>
|
|
103
|
+
* </template>
|
|
104
|
+
* ```
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* Callbacks passed per call to `mutate` only fire for the last call — `mutateAsync` gives you a
|
|
108
|
+
* promise per call instead, so you can wait for all of them when they succeed:
|
|
109
|
+
* ```vue
|
|
110
|
+
* <script setup lang="ts">
|
|
111
|
+
* import { useMutation, useQueryClient } from '@tanstack/vue-query'
|
|
112
|
+
*
|
|
113
|
+
* const queryClient = useQueryClient()
|
|
114
|
+
*
|
|
115
|
+
* const addMutation = useMutation({
|
|
116
|
+
* mutationFn: addTodo,
|
|
117
|
+
* onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),
|
|
118
|
+
* })
|
|
119
|
+
*
|
|
120
|
+
* async function handleAddAll(todos: Array<string>) {
|
|
121
|
+
* try {
|
|
122
|
+
* await Promise.all(todos.map((todo) => addMutation.mutateAsync(todo)))
|
|
123
|
+
* } catch (error) {
|
|
124
|
+
* console.error('Failed to add todos:', error)
|
|
125
|
+
* }
|
|
126
|
+
* }
|
|
127
|
+
* <\/script>
|
|
128
|
+
*
|
|
129
|
+
* <template>
|
|
130
|
+
* <button @click="handleAddAll(['Todo 1', 'Todo 2', 'Todo 3'])">Add all</button>
|
|
131
|
+
* </template>
|
|
132
|
+
* ```
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* If some of the mutations above can fail independently of the others, and you want to know which ones
|
|
136
|
+
* did — rather than losing that information the moment the first one rejects — swap `Promise.all` for
|
|
137
|
+
* `Promise.allSettled`:
|
|
138
|
+
* ```vue
|
|
139
|
+
* <script setup lang="ts">
|
|
140
|
+
* import { useMutation, useQueryClient } from '@tanstack/vue-query'
|
|
141
|
+
*
|
|
142
|
+
* const queryClient = useQueryClient()
|
|
143
|
+
*
|
|
144
|
+
* const addMutation = useMutation({
|
|
145
|
+
* mutationFn: addTodo,
|
|
146
|
+
* onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),
|
|
147
|
+
* })
|
|
148
|
+
*
|
|
149
|
+
* async function handleAddAll(todos: Array<string>) {
|
|
150
|
+
* const addResults = await Promise.allSettled(
|
|
151
|
+
* todos.map((todo) => addMutation.mutateAsync(todo)),
|
|
152
|
+
* )
|
|
153
|
+
*
|
|
154
|
+
* addResults.forEach((addResult, index) => {
|
|
155
|
+
* if (addResult.status === 'rejected') {
|
|
156
|
+
* console.error(`Failed to add "${todos[index]}":`, addResult.reason)
|
|
157
|
+
* }
|
|
158
|
+
* })
|
|
159
|
+
* }
|
|
160
|
+
* <\/script>
|
|
161
|
+
*
|
|
162
|
+
* <template>
|
|
163
|
+
* <button @click="handleAddAll(['Todo 1', 'Todo 2', 'Todo 3'])">Add all</button>
|
|
164
|
+
* </template>
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
function useMutation(options, queryClient) {
|
|
7
168
|
if (process.env.NODE_ENV === "development") {
|
|
8
169
|
if (!getCurrentScope()) console.warn("vue-query composable like \"useQuery()\" should only be used inside a \"setup()\" function or a running effect scope. They might otherwise lead to memory leaks.");
|
|
9
170
|
}
|
|
10
171
|
const client = queryClient || useQueryClient();
|
|
11
|
-
const
|
|
12
|
-
const resolvedOptions = typeof
|
|
172
|
+
const defaultedOptions = computed(() => {
|
|
173
|
+
const resolvedOptions = typeof options === "function" ? options() : options;
|
|
13
174
|
return client.defaultMutationOptions(cloneDeepUnref(resolvedOptions));
|
|
14
175
|
});
|
|
15
|
-
const observer = new MutationObserver(client,
|
|
16
|
-
const state =
|
|
176
|
+
const observer = new MutationObserver(client, defaultedOptions.value);
|
|
177
|
+
const state = defaultedOptions.value.shallow ? shallowReactive(observer.getCurrentResult()) : reactive(observer.getCurrentResult());
|
|
17
178
|
const unsubscribe = observer.subscribe((result) => {
|
|
18
179
|
updateState(state, result);
|
|
19
180
|
});
|
|
20
181
|
const mutate = (...args) => {
|
|
21
182
|
observer.mutate(args[0], args[1]).catch(() => {});
|
|
22
183
|
};
|
|
23
|
-
watch(
|
|
24
|
-
observer.setOptions(
|
|
184
|
+
watch(defaultedOptions, () => {
|
|
185
|
+
observer.setOptions(defaultedOptions.value);
|
|
25
186
|
});
|
|
26
187
|
onScopeDispose(() => {
|
|
27
188
|
unsubscribe();
|
|
28
189
|
});
|
|
29
|
-
const readonlyState =
|
|
190
|
+
const readonlyState = defaultedOptions.value.shallow ? shallowReadonly(state) : readonly(state);
|
|
30
191
|
const resultRefs = toRefs(readonlyState);
|
|
31
192
|
watch(() => state.error, (error) => {
|
|
32
|
-
if (error && shouldThrowError(
|
|
193
|
+
if (error && shouldThrowError(defaultedOptions.value.throwOnError, [error])) throw error;
|
|
33
194
|
});
|
|
34
195
|
return {
|
|
35
196
|
...resultRefs,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMutation.js","names":[],"sources":["../../src/useMutation.ts"],"sourcesContent":["import {\n computed,\n getCurrentScope,\n onScopeDispose,\n reactive,\n readonly,\n shallowReactive,\n shallowReadonly,\n toRefs,\n watch,\n} from 'vue-demi'\nimport { MutationObserver, shouldThrowError } from '@tanstack/query-core'\nimport { cloneDeepUnref, updateState } from './utils'\nimport { useQueryClient } from './useQueryClient'\nimport type { ToRefs } from 'vue-demi'\nimport type {\n DefaultError,\n DistributiveOmit,\n MutateFunction,\n MutationObserverResult,\n} from '@tanstack/query-core'\nimport type { MaybeRefDeep, MutationOptions } from './types'\nimport type { QueryClient } from './queryClient'\n\ntype MutationResult<TData, TError, TVariables, TOnMutateResult> =\n DistributiveOmit<\n MutationObserverResult<TData, TError, TVariables, TOnMutateResult>,\n 'mutate' | 'reset'\n >\n\nexport type UseMutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n> =\n | MaybeRefDeep<MutationOptions<TData, TError, TVariables, TOnMutateResult>>\n | (() => MaybeRefDeep<\n MutationOptions<TData, TError, TVariables, TOnMutateResult>\n >)\n\ntype MutateSyncFunction<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n> = (\n ...options: Parameters<\n MutateFunction<TData, TError, TVariables, TOnMutateResult>\n >\n) => void\n\nexport type UseMutationReturnType<\n TData,\n TError,\n TVariables,\n TOnMutateResult,\n TResult = MutationResult<TData, TError, TVariables, TOnMutateResult>,\n> = ToRefs<Readonly<TResult>> & {\n mutate: MutateSyncFunction<TData, TError, TVariables, TOnMutateResult>\n mutateAsync: MutateFunction<TData, TError, TVariables, TOnMutateResult>\n reset: MutationObserverResult<\n TData,\n TError,\n TVariables,\n TOnMutateResult\n >['reset']\n}\n\nexport function useMutation<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n>(\n mutationOptions: UseMutationOptions<\n TData,\n TError,\n TVariables,\n TOnMutateResult\n >,\n queryClient?: QueryClient,\n): UseMutationReturnType<TData, TError, TVariables, TOnMutateResult> {\n if (process.env.NODE_ENV === 'development') {\n if (!getCurrentScope()) {\n console.warn(\n 'vue-query composable like \"useQuery()\" should only be used inside a \"setup()\" function or a running effect scope. They might otherwise lead to memory leaks.',\n )\n }\n }\n\n const client = queryClient || useQueryClient()\n const options = computed(() => {\n const resolvedOptions =\n typeof mutationOptions === 'function'\n ? mutationOptions()\n : mutationOptions\n return client.defaultMutationOptions(cloneDeepUnref(resolvedOptions))\n })\n const observer = new MutationObserver(client, options.value)\n const state = options.value.shallow\n ? shallowReactive(observer.getCurrentResult())\n : reactive(observer.getCurrentResult())\n\n const unsubscribe = observer.subscribe((result) => {\n updateState(state, result)\n })\n\n const mutate = (\n ...args: Parameters<\n MutateFunction<TData, TError, TVariables, TOnMutateResult>\n >\n ) => {\n observer.mutate(args[0] as TVariables, args[1]).catch(() => {\n // This is intentional\n })\n }\n\n watch(options, () => {\n observer.setOptions(options.value)\n })\n\n onScopeDispose(() => {\n unsubscribe()\n })\n\n const readonlyState = options.value.shallow\n ? shallowReadonly(state)\n : readonly(state)\n\n const resultRefs = toRefs(readonlyState) as ToRefs<\n Readonly<MutationResult<TData, TError, TVariables, TOnMutateResult>>\n >\n\n watch(\n () => state.error,\n (error) => {\n if (\n error &&\n shouldThrowError(options.value.throwOnError, [error as TError])\n ) {\n throw error\n }\n },\n )\n\n return {\n ...resultRefs,\n mutate,\n mutateAsync: state.mutate,\n reset: state.reset,\n }\n}\n"],"mappings":";;;;;AAqEA,SAAgB,YAMd,iBAMA,aACmE;CACnE,IAAI,QAAQ,IAAI,aAAa,eACvB;MAAA,CAAC,gBAAgB,GACnB,QAAQ,KACN,kKACF;CAAA;CAIJ,MAAM,SAAS,eAAe,eAAe;CAC7C,MAAM,UAAU,eAAe;EAC7B,MAAM,kBACJ,OAAO,oBAAoB,aACvB,gBAAgB,IAChB;EACN,OAAO,OAAO,uBAAuB,eAAe,eAAe,CAAC;CACtE,CAAC;CACD,MAAM,WAAW,IAAI,iBAAiB,QAAQ,QAAQ,KAAK;CAC3D,MAAM,QAAQ,QAAQ,MAAM,UACxB,gBAAgB,SAAS,iBAAiB,CAAC,IAC3C,SAAS,SAAS,iBAAiB,CAAC;CAExC,MAAM,cAAc,SAAS,WAAW,WAAW;EACjD,YAAY,OAAO,MAAM;CAC3B,CAAC;CAED,MAAM,UACJ,GAAG,SAGA;EACH,SAAS,OAAO,KAAK,IAAkB,KAAK,EAAE,CAAC,CAAC,YAAY,CAE5D,CAAC;CACH;CAEA,MAAM,eAAe;EACnB,SAAS,WAAW,QAAQ,KAAK;CACnC,CAAC;CAED,qBAAqB;EACnB,YAAY;CACd,CAAC;CAED,MAAM,gBAAgB,QAAQ,MAAM,UAChC,gBAAgB,KAAK,IACrB,SAAS,KAAK;CAElB,MAAM,aAAa,OAAO,aAAa;CAIvC,YACQ,MAAM,QACX,UAAU;EACT,IACE,SACA,iBAAiB,QAAQ,MAAM,cAAc,CAAC,KAAe,CAAC,GAE9D,MAAM;CAEV,CACF;CAEA,OAAO;EACL,GAAG;EACH;EACA,aAAa,MAAM;EACnB,OAAO,MAAM;CACf;AACF"}
|
|
1
|
+
{"version":3,"file":"useMutation.js","names":[],"sources":["../../src/useMutation.ts"],"sourcesContent":["import {\n computed,\n getCurrentScope,\n onScopeDispose,\n reactive,\n readonly,\n shallowReactive,\n shallowReadonly,\n toRefs,\n watch,\n} from 'vue-demi'\nimport { MutationObserver, shouldThrowError } from '@tanstack/query-core'\nimport { cloneDeepUnref, updateState } from './utils'\nimport { useQueryClient } from './useQueryClient'\nimport type { ToRefs } from 'vue-demi'\nimport type {\n DefaultError,\n DistributiveOmit,\n MutateFunction,\n MutationObserverResult,\n} from '@tanstack/query-core'\nimport type { MaybeRefDeep, MutationOptions } from './types'\nimport type { QueryClient } from './queryClient'\n\ntype MutationResult<TData, TError, TVariables, TOnMutateResult> =\n DistributiveOmit<\n MutationObserverResult<TData, TError, TVariables, TOnMutateResult>,\n 'mutate' | 'reset'\n >\n\nexport type UseMutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n> =\n | MaybeRefDeep<MutationOptions<TData, TError, TVariables, TOnMutateResult>>\n | (() => MaybeRefDeep<\n MutationOptions<TData, TError, TVariables, TOnMutateResult>\n >)\n\ntype MutateSyncFunction<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n> = (\n ...options: Parameters<\n MutateFunction<TData, TError, TVariables, TOnMutateResult>\n >\n) => void\n\nexport type UseMutationReturnType<\n TData,\n TError,\n TVariables,\n TOnMutateResult,\n TResult = MutationResult<TData, TError, TVariables, TOnMutateResult>,\n> = ToRefs<Readonly<TResult>> & {\n mutate: MutateSyncFunction<TData, TError, TVariables, TOnMutateResult>\n mutateAsync: MutateFunction<TData, TError, TVariables, TOnMutateResult>\n reset: MutationObserverResult<\n TData,\n TError,\n TVariables,\n TOnMutateResult\n >['reset']\n}\n\n/**\n * Unlike queries, mutations are typically used to create/update/delete data or perform server side-effects.\n * `useMutation` is the composable for that.\n *\n * `options` may be a plain object, a `ref`, or a reactive getter (`() => ({ ... })`) — pass a getter\n * if the options themselves depend on other reactive state.\n *\n * @see {@link mutationOptions} to share these options across multiple `useMutation` call sites, or to look\n * the mutation up elsewhere via its `mutationKey` (e.g. with `useMutationState`).\n * @param options - The {@link UseMutationOptions} to use — everything you can pass to `useMutation`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns `mutate`/`mutateAsync` also accept per-call `onSuccess`/`onError`/`onSettled` callbacks as a second\n * argument, useful for triggering call-site side effects (e.g. navigation) without coupling them to the shared\n * mutation definition. Hook-level callbacks (passed to `options`) fire for every mutation; per-call\n * callbacks fire only for the latest call you've made.\n *\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { useMutation, useQueryClient } from '@tanstack/vue-query'\n *\n * const queryClient = useQueryClient()\n *\n * const addMutation = useMutation({\n * mutationFn: addTodo,\n * onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n * })\n *\n * function onAdd() {\n * addMutation.mutate('Item', {\n * onError: (error) => console.error('Failed to add item:', error),\n * })\n * }\n * </script>\n *\n * <template>\n * <button @click=\"onAdd\">Add</button>\n * </template>\n * ```\n *\n * @example\n * Rendering the mutation's own state, rather than just firing it off:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useMutation, useQueryClient } from '@tanstack/vue-query'\n *\n * const queryClient = useQueryClient()\n *\n * const addMutation = useMutation({\n * mutationFn: addTodo,\n * onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n * })\n * </script>\n *\n * <template>\n * <div v-if=\"addMutation.isPending.value\">Adding todo...</div>\n * <div v-else>\n * <div v-if=\"addMutation.isError.value\">An error occurred: {{ addMutation.error.value.message }}</div>\n * <button @click=\"addMutation.mutate('Item')\">Add</button>\n * </div>\n * </template>\n * ```\n *\n * @example\n * Optimistic update via `onMutate`, rolling back on `onError`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useMutation, useQueryClient } from '@tanstack/vue-query'\n *\n * const queryClient = useQueryClient()\n *\n * const addMutation = useMutation({\n * mutationFn: addTodo,\n * onMutate: async (newTodo: string) => {\n * await queryClient.cancelQueries({ queryKey: ['todos'] })\n * const previousTodos = queryClient.getQueryData<Array<string>>(['todos'])\n *\n * queryClient.setQueryData<Array<string>>(['todos'], (old) => [\n * ...(old ?? []),\n * newTodo,\n * ])\n *\n * // Passed to `onError` as `onMutateResult` if the mutation fails.\n * return { previousTodos }\n * },\n * onError: (_err, _newTodo, onMutateResult) => {\n * queryClient.setQueryData(['todos'], onMutateResult?.previousTodos)\n * },\n * onSettled: () => {\n * queryClient.invalidateQueries({ queryKey: ['todos'] })\n * },\n * })\n * </script>\n *\n * <template>\n * <button @click=\"addMutation.mutate('Item')\">Add</button>\n * </template>\n * ```\n *\n * @example\n * Callbacks passed per call to `mutate` only fire for the last call — `mutateAsync` gives you a\n * promise per call instead, so you can wait for all of them when they succeed:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useMutation, useQueryClient } from '@tanstack/vue-query'\n *\n * const queryClient = useQueryClient()\n *\n * const addMutation = useMutation({\n * mutationFn: addTodo,\n * onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n * })\n *\n * async function handleAddAll(todos: Array<string>) {\n * try {\n * await Promise.all(todos.map((todo) => addMutation.mutateAsync(todo)))\n * } catch (error) {\n * console.error('Failed to add todos:', error)\n * }\n * }\n * </script>\n *\n * <template>\n * <button @click=\"handleAddAll(['Todo 1', 'Todo 2', 'Todo 3'])\">Add all</button>\n * </template>\n * ```\n *\n * @example\n * If some of the mutations above can fail independently of the others, and you want to know which ones\n * did — rather than losing that information the moment the first one rejects — swap `Promise.all` for\n * `Promise.allSettled`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useMutation, useQueryClient } from '@tanstack/vue-query'\n *\n * const queryClient = useQueryClient()\n *\n * const addMutation = useMutation({\n * mutationFn: addTodo,\n * onSuccess: () => queryClient.invalidateQueries({ queryKey: ['todos'] }),\n * })\n *\n * async function handleAddAll(todos: Array<string>) {\n * const addResults = await Promise.allSettled(\n * todos.map((todo) => addMutation.mutateAsync(todo)),\n * )\n *\n * addResults.forEach((addResult, index) => {\n * if (addResult.status === 'rejected') {\n * console.error(`Failed to add \"${todos[index]}\":`, addResult.reason)\n * }\n * })\n * }\n * </script>\n *\n * <template>\n * <button @click=\"handleAddAll(['Todo 1', 'Todo 2', 'Todo 3'])\">Add all</button>\n * </template>\n * ```\n */\nexport function useMutation<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TOnMutateResult = unknown,\n>(\n options: UseMutationOptions<TData, TError, TVariables, TOnMutateResult>,\n queryClient?: QueryClient,\n): UseMutationReturnType<TData, TError, TVariables, TOnMutateResult> {\n if (process.env.NODE_ENV === 'development') {\n if (!getCurrentScope()) {\n console.warn(\n 'vue-query composable like \"useQuery()\" should only be used inside a \"setup()\" function or a running effect scope. They might otherwise lead to memory leaks.',\n )\n }\n }\n\n const client = queryClient || useQueryClient()\n const defaultedOptions = computed(() => {\n const resolvedOptions = typeof options === 'function' ? options() : options\n return client.defaultMutationOptions(cloneDeepUnref(resolvedOptions))\n })\n const observer = new MutationObserver(client, defaultedOptions.value)\n const state = defaultedOptions.value.shallow\n ? shallowReactive(observer.getCurrentResult())\n : reactive(observer.getCurrentResult())\n\n const unsubscribe = observer.subscribe((result) => {\n updateState(state, result)\n })\n\n const mutate = (\n ...args: Parameters<\n MutateFunction<TData, TError, TVariables, TOnMutateResult>\n >\n ) => {\n observer.mutate(args[0] as TVariables, args[1]).catch(() => {\n // This is intentional\n })\n }\n\n watch(defaultedOptions, () => {\n observer.setOptions(defaultedOptions.value)\n })\n\n onScopeDispose(() => {\n unsubscribe()\n })\n\n const readonlyState = defaultedOptions.value.shallow\n ? shallowReadonly(state)\n : readonly(state)\n\n const resultRefs = toRefs(readonlyState) as ToRefs<\n Readonly<MutationResult<TData, TError, TVariables, TOnMutateResult>>\n >\n\n watch(\n () => state.error,\n (error) => {\n if (\n error &&\n shouldThrowError(defaultedOptions.value.throwOnError, [error as TError])\n ) {\n throw error\n }\n },\n )\n\n return {\n ...resultRefs,\n mutate,\n mutateAsync: state.mutate,\n reset: state.reset,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsOA,SAAgB,YAMd,SACA,aACmE;CACnE,IAAI,QAAQ,IAAI,aAAa,eACvB;MAAA,CAAC,gBAAgB,GACnB,QAAQ,KACN,kKACF;CAAA;CAIJ,MAAM,SAAS,eAAe,eAAe;CAC7C,MAAM,mBAAmB,eAAe;EACtC,MAAM,kBAAkB,OAAO,YAAY,aAAa,QAAQ,IAAI;EACpE,OAAO,OAAO,uBAAuB,eAAe,eAAe,CAAC;CACtE,CAAC;CACD,MAAM,WAAW,IAAI,iBAAiB,QAAQ,iBAAiB,KAAK;CACpE,MAAM,QAAQ,iBAAiB,MAAM,UACjC,gBAAgB,SAAS,iBAAiB,CAAC,IAC3C,SAAS,SAAS,iBAAiB,CAAC;CAExC,MAAM,cAAc,SAAS,WAAW,WAAW;EACjD,YAAY,OAAO,MAAM;CAC3B,CAAC;CAED,MAAM,UACJ,GAAG,SAGA;EACH,SAAS,OAAO,KAAK,IAAkB,KAAK,EAAE,CAAC,CAAC,YAAY,CAE5D,CAAC;CACH;CAEA,MAAM,wBAAwB;EAC5B,SAAS,WAAW,iBAAiB,KAAK;CAC5C,CAAC;CAED,qBAAqB;EACnB,YAAY;CACd,CAAC;CAED,MAAM,gBAAgB,iBAAiB,MAAM,UACzC,gBAAgB,KAAK,IACrB,SAAS,KAAK;CAElB,MAAM,aAAa,OAAO,aAAa;CAIvC,YACQ,MAAM,QACX,UAAU;EACT,IACE,SACA,iBAAiB,iBAAiB,MAAM,cAAc,CAAC,KAAe,CAAC,GAEvE,MAAM;CAEV,CACF;CAEA,OAAO;EACL,GAAG;EACH;EACA,aAAa,MAAM;EACnB,OAAO,MAAM;CACf;AACF"}
|