@tanstack/react-query 5.0.0-alpha.86 → 5.0.0-alpha.88
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/HydrationBoundary.cjs +58 -0
- package/build/legacy/HydrationBoundary.cjs.map +1 -0
- package/build/legacy/HydrationBoundary.d.cts +12 -0
- package/build/legacy/HydrationBoundary.d.ts +12 -0
- package/build/legacy/HydrationBoundary.js +24 -0
- package/build/legacy/HydrationBoundary.js.map +1 -0
- package/build/legacy/QueryClientProvider.cjs +69 -0
- package/build/legacy/QueryClientProvider.cjs.map +1 -0
- package/build/legacy/QueryClientProvider.d.cts +12 -0
- package/build/legacy/QueryClientProvider.d.ts +12 -0
- package/build/legacy/QueryClientProvider.js +33 -0
- package/build/legacy/QueryClientProvider.js.map +1 -0
- package/build/legacy/QueryErrorResetBoundary.cjs +64 -0
- package/build/legacy/QueryErrorResetBoundary.cjs.map +1 -0
- package/build/legacy/QueryErrorResetBoundary.d.cts +14 -0
- package/build/legacy/QueryErrorResetBoundary.d.ts +14 -0
- package/build/legacy/QueryErrorResetBoundary.js +29 -0
- package/build/legacy/QueryErrorResetBoundary.js.map +1 -0
- package/build/legacy/errorBoundaryUtils.cjs +65 -0
- package/build/legacy/errorBoundaryUtils.cjs.map +1 -0
- package/build/legacy/errorBoundaryUtils.d.cts +14 -0
- package/build/legacy/errorBoundaryUtils.d.ts +14 -0
- package/build/{lib → legacy}/errorBoundaryUtils.js +10 -9
- package/build/legacy/errorBoundaryUtils.js.map +1 -0
- package/build/legacy/index.cjs +74 -0
- package/build/legacy/index.cjs.map +1 -0
- package/build/legacy/index.d.cts +14 -0
- package/build/legacy/index.d.ts +14 -0
- package/build/legacy/index.js +39 -0
- package/build/legacy/index.js.map +1 -0
- package/build/legacy/isRestoring.cjs +45 -0
- package/build/legacy/isRestoring.cjs.map +1 -0
- package/build/legacy/isRestoring.d.cts +6 -0
- package/build/legacy/isRestoring.d.ts +6 -0
- package/build/legacy/isRestoring.js +10 -0
- package/build/legacy/isRestoring.js.map +1 -0
- package/build/legacy/queryOptions.cjs +31 -0
- package/build/legacy/queryOptions.cjs.map +1 -0
- package/build/legacy/queryOptions.d.cts +13 -0
- package/build/legacy/queryOptions.d.ts +13 -0
- package/build/legacy/queryOptions.js +7 -0
- package/build/legacy/queryOptions.js.map +1 -0
- package/build/legacy/suspense.cjs +46 -0
- package/build/legacy/suspense.cjs.map +1 -0
- package/build/legacy/suspense.d.cts +10 -0
- package/build/legacy/suspense.d.ts +10 -0
- package/build/{lib/suspense.legacy.js → legacy/suspense.js} +10 -8
- package/build/legacy/suspense.js.map +1 -0
- package/build/legacy/types.cjs +17 -0
- package/build/legacy/types.cjs.map +1 -0
- package/build/legacy/types.d.cts +28 -0
- package/build/legacy/types.d.ts +28 -0
- package/build/legacy/types.js +1 -0
- package/build/legacy/types.js.map +1 -0
- package/build/legacy/useBaseQuery.cjs +90 -0
- package/build/legacy/useBaseQuery.cjs.map +1 -0
- package/build/legacy/useBaseQuery.d.cts +92 -0
- package/build/legacy/useBaseQuery.d.ts +92 -0
- package/build/legacy/useBaseQuery.js +60 -0
- package/build/legacy/useBaseQuery.js.map +1 -0
- package/build/legacy/useInfiniteQuery.cjs +39 -0
- package/build/legacy/useInfiniteQuery.cjs.map +1 -0
- package/build/legacy/useInfiniteQuery.d.cts +6 -0
- package/build/legacy/useInfiniteQuery.d.ts +6 -0
- package/build/legacy/useInfiniteQuery.js +15 -0
- package/build/legacy/useInfiniteQuery.js.map +1 -0
- package/build/legacy/useIsFetching.cjs +54 -0
- package/build/legacy/useIsFetching.cjs.map +1 -0
- package/build/legacy/useIsFetching.d.cts +5 -0
- package/build/legacy/useIsFetching.d.ts +5 -0
- package/build/legacy/useIsFetching.js +20 -0
- package/build/legacy/useIsFetching.js.map +1 -0
- package/build/legacy/useMutation.cjs +75 -0
- package/build/legacy/useMutation.cjs.map +1 -0
- package/build/legacy/useMutation.d.cts +6 -0
- package/build/legacy/useMutation.d.ts +6 -0
- package/build/legacy/useMutation.js +41 -0
- package/build/legacy/useMutation.js.map +1 -0
- package/build/legacy/useMutationState.cjs +86 -0
- package/build/legacy/useMutationState.cjs.map +1 -0
- package/build/legacy/useMutationState.d.cts +10 -0
- package/build/legacy/useMutationState.d.ts +10 -0
- package/build/legacy/useMutationState.js +51 -0
- package/build/legacy/useMutationState.js.map +1 -0
- package/build/legacy/useQueries.cjs +126 -0
- package/build/legacy/useQueries.cjs.map +1 -0
- package/build/legacy/useQueries.d.cts +53 -0
- package/build/{lib → legacy}/useQueries.d.ts +8 -7
- package/build/legacy/useQueries.js +101 -0
- package/build/legacy/useQueries.js.map +1 -0
- package/build/legacy/useQuery.cjs +34 -0
- package/build/legacy/useQuery.cjs.map +1 -0
- package/build/legacy/useQuery.d.cts +8 -0
- package/build/legacy/useQuery.d.ts +8 -0
- package/build/legacy/useQuery.js +10 -0
- package/build/legacy/useQuery.js.map +1 -0
- package/build/legacy/utils.cjs +34 -0
- package/build/legacy/utils.cjs.map +1 -0
- package/build/legacy/utils.d.cts +3 -0
- package/build/legacy/utils.d.ts +3 -0
- package/build/legacy/utils.js +10 -0
- package/build/legacy/utils.js.map +1 -0
- package/build/modern/HydrationBoundary.cjs +58 -0
- package/build/modern/HydrationBoundary.cjs.map +1 -0
- package/build/modern/HydrationBoundary.d.cts +12 -0
- package/build/modern/HydrationBoundary.d.ts +12 -0
- package/build/modern/HydrationBoundary.js +24 -0
- package/build/modern/HydrationBoundary.js.map +1 -0
- package/build/modern/QueryClientProvider.cjs +69 -0
- package/build/modern/QueryClientProvider.cjs.map +1 -0
- package/build/modern/QueryClientProvider.d.cts +12 -0
- package/build/modern/QueryClientProvider.d.ts +12 -0
- package/build/modern/QueryClientProvider.js +33 -0
- package/build/modern/QueryClientProvider.js.map +1 -0
- package/build/modern/QueryErrorResetBoundary.cjs +64 -0
- package/build/modern/QueryErrorResetBoundary.cjs.map +1 -0
- package/build/modern/QueryErrorResetBoundary.d.cts +14 -0
- package/build/modern/QueryErrorResetBoundary.d.ts +14 -0
- package/build/modern/QueryErrorResetBoundary.js +29 -0
- package/build/modern/QueryErrorResetBoundary.js.map +1 -0
- package/build/modern/errorBoundaryUtils.cjs +65 -0
- package/build/modern/errorBoundaryUtils.cjs.map +1 -0
- package/build/modern/errorBoundaryUtils.d.cts +14 -0
- package/build/modern/errorBoundaryUtils.d.ts +14 -0
- package/build/{lib/errorBoundaryUtils.legacy.js → modern/errorBoundaryUtils.js} +10 -9
- package/build/modern/errorBoundaryUtils.js.map +1 -0
- package/build/modern/index.cjs +74 -0
- package/build/modern/index.cjs.map +1 -0
- package/build/modern/index.d.cts +14 -0
- package/build/modern/index.d.ts +14 -0
- package/build/modern/index.js +39 -0
- package/build/modern/index.js.map +1 -0
- package/build/modern/isRestoring.cjs +45 -0
- package/build/modern/isRestoring.cjs.map +1 -0
- package/build/modern/isRestoring.d.cts +6 -0
- package/build/modern/isRestoring.d.ts +6 -0
- package/build/modern/isRestoring.js +10 -0
- package/build/modern/isRestoring.js.map +1 -0
- package/build/modern/queryOptions.cjs +31 -0
- package/build/modern/queryOptions.cjs.map +1 -0
- package/build/modern/queryOptions.d.cts +13 -0
- package/build/modern/queryOptions.d.ts +13 -0
- package/build/modern/queryOptions.js +7 -0
- package/build/modern/queryOptions.js.map +1 -0
- package/build/modern/suspense.cjs +46 -0
- package/build/modern/suspense.cjs.map +1 -0
- package/build/modern/suspense.d.cts +10 -0
- package/build/modern/suspense.d.ts +10 -0
- package/build/{lib → modern}/suspense.js +10 -8
- package/build/modern/suspense.js.map +1 -0
- package/build/modern/types.cjs +17 -0
- package/build/modern/types.cjs.map +1 -0
- package/build/modern/types.d.cts +28 -0
- package/build/modern/types.d.ts +28 -0
- package/build/modern/types.js +1 -0
- package/build/modern/types.js.map +1 -0
- package/build/modern/useBaseQuery.cjs +90 -0
- package/build/modern/useBaseQuery.cjs.map +1 -0
- package/build/modern/useBaseQuery.d.cts +92 -0
- package/build/modern/useBaseQuery.d.ts +92 -0
- package/build/modern/useBaseQuery.js +60 -0
- package/build/modern/useBaseQuery.js.map +1 -0
- package/build/modern/useInfiniteQuery.cjs +39 -0
- package/build/modern/useInfiniteQuery.cjs.map +1 -0
- package/build/modern/useInfiniteQuery.d.cts +6 -0
- package/build/modern/useInfiniteQuery.d.ts +6 -0
- package/build/modern/useInfiniteQuery.js +15 -0
- package/build/modern/useInfiniteQuery.js.map +1 -0
- package/build/modern/useIsFetching.cjs +54 -0
- package/build/modern/useIsFetching.cjs.map +1 -0
- package/build/modern/useIsFetching.d.cts +5 -0
- package/build/modern/useIsFetching.d.ts +5 -0
- package/build/modern/useIsFetching.js +20 -0
- package/build/modern/useIsFetching.js.map +1 -0
- package/build/modern/useMutation.cjs +75 -0
- package/build/modern/useMutation.cjs.map +1 -0
- package/build/modern/useMutation.d.cts +6 -0
- package/build/modern/useMutation.d.ts +6 -0
- package/build/modern/useMutation.js +41 -0
- package/build/modern/useMutation.js.map +1 -0
- package/build/modern/useMutationState.cjs +86 -0
- package/build/modern/useMutationState.cjs.map +1 -0
- package/build/modern/useMutationState.d.cts +10 -0
- package/build/modern/useMutationState.d.ts +10 -0
- package/build/modern/useMutationState.js +51 -0
- package/build/modern/useMutationState.js.map +1 -0
- package/build/modern/useQueries.cjs +123 -0
- package/build/modern/useQueries.cjs.map +1 -0
- package/build/modern/useQueries.d.cts +53 -0
- package/build/modern/useQueries.d.ts +53 -0
- package/build/modern/useQueries.js +98 -0
- package/build/modern/useQueries.js.map +1 -0
- package/build/modern/useQuery.cjs +34 -0
- package/build/modern/useQuery.cjs.map +1 -0
- package/build/modern/useQuery.d.cts +8 -0
- package/build/modern/useQuery.d.ts +8 -0
- package/build/modern/useQuery.js +10 -0
- package/build/modern/useQuery.js.map +1 -0
- package/build/modern/utils.cjs +34 -0
- package/build/modern/utils.cjs.map +1 -0
- package/build/modern/utils.d.cts +3 -0
- package/build/modern/utils.d.ts +3 -0
- package/build/modern/utils.js +10 -0
- package/build/modern/utils.js.map +1 -0
- package/package.json +19 -17
- package/build/codemods/__testfixtures__/default-import.input.tsx +0 -94
- package/build/codemods/__testfixtures__/default-import.output.tsx +0 -96
- package/build/codemods/__testfixtures__/named-import.input.tsx +0 -96
- package/build/codemods/__testfixtures__/named-import.output.tsx +0 -98
- package/build/codemods/__testfixtures__/namespaced-import.input.tsx +0 -86
- package/build/codemods/__testfixtures__/namespaced-import.output.tsx +0 -88
- package/build/codemods/__testfixtures__/parameter-is-identifier.input.tsx +0 -49
- package/build/codemods/__testfixtures__/parameter-is-identifier.output.tsx +0 -49
- package/build/codemods/__testfixtures__/parameter-is-object-expression.input.tsx +0 -128
- package/build/codemods/__testfixtures__/parameter-is-object-expression.output.tsx +0 -175
- package/build/codemods/__testfixtures__/replace-import-specifier.input.tsx +0 -10
- package/build/codemods/__testfixtures__/replace-import-specifier.output.tsx +0 -10
- package/build/codemods/__testfixtures__/type-arguments.input.tsx +0 -25
- package/build/codemods/__testfixtures__/type-arguments.output.tsx +0 -31
- package/build/codemods/__tests__/key-transformation.test.js +0 -32
- package/build/codemods/__tests__/replace-import-specifier.test.js +0 -12
- package/build/codemods/remove-overloads/__testfixtures__/default-import.input.tsx +0 -199
- package/build/codemods/remove-overloads/__testfixtures__/default-import.output.tsx +0 -484
- package/build/codemods/remove-overloads/__tests__/remove-overloads.test.js +0 -6
- package/build/lib/HydrationBoundary.cjs +0 -50
- package/build/lib/HydrationBoundary.cjs.map +0 -1
- package/build/lib/HydrationBoundary.d.ts +0 -10
- package/build/lib/HydrationBoundary.d.ts.map +0 -1
- package/build/lib/HydrationBoundary.js +0 -29
- package/build/lib/HydrationBoundary.js.map +0 -1
- package/build/lib/HydrationBoundary.legacy.cjs +0 -50
- package/build/lib/HydrationBoundary.legacy.cjs.map +0 -1
- package/build/lib/HydrationBoundary.legacy.js +0 -29
- package/build/lib/HydrationBoundary.legacy.js.map +0 -1
- package/build/lib/QueryClientProvider.cjs +0 -54
- package/build/lib/QueryClientProvider.cjs.map +0 -1
- package/build/lib/QueryClientProvider.d.ts +0 -10
- package/build/lib/QueryClientProvider.d.ts.map +0 -1
- package/build/lib/QueryClientProvider.js +0 -31
- package/build/lib/QueryClientProvider.js.map +0 -1
- package/build/lib/QueryClientProvider.legacy.cjs +0 -54
- package/build/lib/QueryClientProvider.legacy.cjs.map +0 -1
- package/build/lib/QueryClientProvider.legacy.js +0 -31
- package/build/lib/QueryClientProvider.legacy.js.map +0 -1
- package/build/lib/QueryErrorResetBoundary.cjs +0 -60
- package/build/lib/QueryErrorResetBoundary.cjs.map +0 -1
- package/build/lib/QueryErrorResetBoundary.d.ts +0 -12
- package/build/lib/QueryErrorResetBoundary.d.ts.map +0 -1
- package/build/lib/QueryErrorResetBoundary.js +0 -38
- package/build/lib/QueryErrorResetBoundary.js.map +0 -1
- package/build/lib/QueryErrorResetBoundary.legacy.cjs +0 -60
- package/build/lib/QueryErrorResetBoundary.legacy.cjs.map +0 -1
- package/build/lib/QueryErrorResetBoundary.legacy.js +0 -38
- package/build/lib/QueryErrorResetBoundary.legacy.js.map +0 -1
- package/build/lib/__tests__/HydrationBoundary.test.d.ts +0 -2
- package/build/lib/__tests__/HydrationBoundary.test.d.ts.map +0 -1
- package/build/lib/__tests__/QueryClientProvider.test.d.ts +0 -2
- package/build/lib/__tests__/QueryClientProvider.test.d.ts.map +0 -1
- package/build/lib/__tests__/QueryResetErrorBoundary.test.d.ts +0 -7
- package/build/lib/__tests__/QueryResetErrorBoundary.test.d.ts.map +0 -1
- package/build/lib/__tests__/ssr-hydration.test.d.ts +0 -2
- package/build/lib/__tests__/ssr-hydration.test.d.ts.map +0 -1
- package/build/lib/__tests__/ssr.test.d.ts +0 -2
- package/build/lib/__tests__/ssr.test.d.ts.map +0 -1
- package/build/lib/__tests__/suspense.test.d.ts +0 -2
- package/build/lib/__tests__/suspense.test.d.ts.map +0 -1
- package/build/lib/__tests__/useInfiniteQuery.test.d.ts +0 -2
- package/build/lib/__tests__/useInfiniteQuery.test.d.ts.map +0 -1
- package/build/lib/__tests__/useInfiniteQuery.type.test.d.ts +0 -2
- package/build/lib/__tests__/useInfiniteQuery.type.test.d.ts.map +0 -1
- package/build/lib/__tests__/useIsFetching.test.d.ts +0 -2
- package/build/lib/__tests__/useIsFetching.test.d.ts.map +0 -1
- package/build/lib/__tests__/useMutation.test.d.ts +0 -2
- package/build/lib/__tests__/useMutation.test.d.ts.map +0 -1
- package/build/lib/__tests__/useMutationState.test.d.ts +0 -2
- package/build/lib/__tests__/useMutationState.test.d.ts.map +0 -1
- package/build/lib/__tests__/useQueries.test.d.ts +0 -2
- package/build/lib/__tests__/useQueries.test.d.ts.map +0 -1
- package/build/lib/__tests__/useQuery.test.d.ts +0 -2
- package/build/lib/__tests__/useQuery.test.d.ts.map +0 -1
- package/build/lib/__tests__/useQuery.types.test.d.ts +0 -2
- package/build/lib/__tests__/useQuery.types.test.d.ts.map +0 -1
- package/build/lib/__tests__/utils.d.ts +0 -30
- package/build/lib/__tests__/utils.d.ts.map +0 -1
- package/build/lib/errorBoundaryUtils.cjs +0 -51
- package/build/lib/errorBoundaryUtils.cjs.map +0 -1
- package/build/lib/errorBoundaryUtils.d.ts +0 -11
- package/build/lib/errorBoundaryUtils.d.ts.map +0 -1
- package/build/lib/errorBoundaryUtils.js.map +0 -1
- package/build/lib/errorBoundaryUtils.legacy.cjs +0 -51
- package/build/lib/errorBoundaryUtils.legacy.cjs.map +0 -1
- package/build/lib/errorBoundaryUtils.legacy.js.map +0 -1
- package/build/lib/index.cjs +0 -40
- package/build/lib/index.cjs.map +0 -1
- package/build/lib/index.d.ts +0 -18
- package/build/lib/index.d.ts.map +0 -1
- package/build/lib/index.js +0 -13
- package/build/lib/index.js.map +0 -1
- package/build/lib/index.legacy.cjs +0 -40
- package/build/lib/index.legacy.cjs.map +0 -1
- package/build/lib/index.legacy.js +0 -13
- package/build/lib/index.legacy.js.map +0 -1
- package/build/lib/isRestoring.cjs +0 -31
- package/build/lib/isRestoring.cjs.map +0 -1
- package/build/lib/isRestoring.d.ts +0 -4
- package/build/lib/isRestoring.d.ts.map +0 -1
- package/build/lib/isRestoring.js +0 -9
- package/build/lib/isRestoring.js.map +0 -1
- package/build/lib/isRestoring.legacy.cjs +0 -31
- package/build/lib/isRestoring.legacy.cjs.map +0 -1
- package/build/lib/isRestoring.legacy.js +0 -9
- package/build/lib/isRestoring.legacy.js.map +0 -1
- package/build/lib/queryOptions.cjs +0 -8
- package/build/lib/queryOptions.cjs.map +0 -1
- package/build/lib/queryOptions.d.ts +0 -11
- package/build/lib/queryOptions.d.ts.map +0 -1
- package/build/lib/queryOptions.js +0 -6
- package/build/lib/queryOptions.js.map +0 -1
- package/build/lib/queryOptions.legacy.cjs +0 -8
- package/build/lib/queryOptions.legacy.cjs.map +0 -1
- package/build/lib/queryOptions.legacy.js +0 -6
- package/build/lib/queryOptions.legacy.js.map +0 -1
- package/build/lib/suspense.cjs +0 -22
- package/build/lib/suspense.cjs.map +0 -1
- package/build/lib/suspense.d.ts +0 -7
- package/build/lib/suspense.d.ts.map +0 -1
- package/build/lib/suspense.js.map +0 -1
- package/build/lib/suspense.legacy.cjs +0 -22
- package/build/lib/suspense.legacy.cjs.map +0 -1
- package/build/lib/suspense.legacy.js.map +0 -1
- package/build/lib/types.d.ts +0 -27
- package/build/lib/types.d.ts.map +0 -1
- package/build/lib/useBaseQuery.cjs +0 -80
- package/build/lib/useBaseQuery.cjs.map +0 -1
- package/build/lib/useBaseQuery.d.ts +0 -4
- package/build/lib/useBaseQuery.d.ts.map +0 -1
- package/build/lib/useBaseQuery.js +0 -59
- package/build/lib/useBaseQuery.js.map +0 -1
- package/build/lib/useBaseQuery.legacy.cjs +0 -80
- package/build/lib/useBaseQuery.legacy.cjs.map +0 -1
- package/build/lib/useBaseQuery.legacy.js +0 -59
- package/build/lib/useBaseQuery.legacy.js.map +0 -1
- package/build/lib/useInfiniteQuery.cjs +0 -15
- package/build/lib/useInfiniteQuery.cjs.map +0 -1
- package/build/lib/useInfiniteQuery.d.ts +0 -4
- package/build/lib/useInfiniteQuery.d.ts.map +0 -1
- package/build/lib/useInfiniteQuery.js +0 -13
- package/build/lib/useInfiniteQuery.js.map +0 -1
- package/build/lib/useInfiniteQuery.legacy.cjs +0 -15
- package/build/lib/useInfiniteQuery.legacy.cjs.map +0 -1
- package/build/lib/useInfiniteQuery.legacy.js +0 -13
- package/build/lib/useInfiniteQuery.legacy.js.map +0 -1
- package/build/lib/useIsFetching.cjs +0 -34
- package/build/lib/useIsFetching.cjs.map +0 -1
- package/build/lib/useIsFetching.d.ts +0 -3
- package/build/lib/useIsFetching.d.ts.map +0 -1
- package/build/lib/useIsFetching.js +0 -13
- package/build/lib/useIsFetching.js.map +0 -1
- package/build/lib/useIsFetching.legacy.cjs +0 -34
- package/build/lib/useIsFetching.legacy.cjs.map +0 -1
- package/build/lib/useIsFetching.legacy.js +0 -13
- package/build/lib/useIsFetching.legacy.js.map +0 -1
- package/build/lib/useMutation.cjs +0 -54
- package/build/lib/useMutation.cjs.map +0 -1
- package/build/lib/useMutation.d.ts +0 -4
- package/build/lib/useMutation.d.ts.map +0 -1
- package/build/lib/useMutation.js +0 -33
- package/build/lib/useMutation.js.map +0 -1
- package/build/lib/useMutation.legacy.cjs +0 -54
- package/build/lib/useMutation.legacy.cjs.map +0 -1
- package/build/lib/useMutation.legacy.js +0 -33
- package/build/lib/useMutation.legacy.js.map +0 -1
- package/build/lib/useMutationState.cjs +0 -60
- package/build/lib/useMutationState.cjs.map +0 -1
- package/build/lib/useMutationState.d.ts +0 -9
- package/build/lib/useMutationState.d.ts.map +0 -1
- package/build/lib/useMutationState.js +0 -38
- package/build/lib/useMutationState.js.map +0 -1
- package/build/lib/useMutationState.legacy.cjs +0 -60
- package/build/lib/useMutationState.legacy.cjs.map +0 -1
- package/build/lib/useMutationState.legacy.js +0 -38
- package/build/lib/useMutationState.legacy.js.map +0 -1
- package/build/lib/useQueries.cjs +0 -99
- package/build/lib/useQueries.cjs.map +0 -1
- package/build/lib/useQueries.d.ts.map +0 -1
- package/build/lib/useQueries.js +0 -78
- package/build/lib/useQueries.js.map +0 -1
- package/build/lib/useQueries.legacy.cjs +0 -102
- package/build/lib/useQueries.legacy.cjs.map +0 -1
- package/build/lib/useQueries.legacy.js +0 -81
- package/build/lib/useQueries.legacy.js.map +0 -1
- package/build/lib/useQuery.cjs +0 -14
- package/build/lib/useQuery.cjs.map +0 -1
- package/build/lib/useQuery.d.ts +0 -6
- package/build/lib/useQuery.d.ts.map +0 -1
- package/build/lib/useQuery.js +0 -12
- package/build/lib/useQuery.js.map +0 -1
- package/build/lib/useQuery.legacy.cjs +0 -14
- package/build/lib/useQuery.legacy.cjs.map +0 -1
- package/build/lib/useQuery.legacy.js +0 -12
- package/build/lib/useQuery.legacy.js.map +0 -1
- package/build/lib/utils.cjs +0 -12
- package/build/lib/utils.cjs.map +0 -1
- package/build/lib/utils.d.ts +0 -2
- package/build/lib/utils.d.ts.map +0 -1
- package/build/lib/utils.js +0 -10
- package/build/lib/utils.js.map +0 -1
- package/build/lib/utils.legacy.cjs +0 -12
- package/build/lib/utils.legacy.cjs.map +0 -1
- package/build/lib/utils.legacy.js +0 -10
- package/build/lib/utils.legacy.js.map +0 -1
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { UseBaseQueryOptions } from './types.cjs';
|
|
2
|
+
import { QueryKey, QueryObserver, QueryClient } from '@tanstack/query-core';
|
|
3
|
+
|
|
4
|
+
interface Register {
|
|
5
|
+
}
|
|
6
|
+
type DefaultError = Register extends {
|
|
7
|
+
defaultError: infer TError;
|
|
8
|
+
} ? TError : Error;
|
|
9
|
+
interface ResultOptions {
|
|
10
|
+
throwOnError?: boolean;
|
|
11
|
+
}
|
|
12
|
+
interface RefetchOptions extends ResultOptions {
|
|
13
|
+
cancelRefetch?: boolean;
|
|
14
|
+
}
|
|
15
|
+
type QueryStatus = 'pending' | 'error' | 'success';
|
|
16
|
+
type FetchStatus = 'fetching' | 'paused' | 'idle';
|
|
17
|
+
interface QueryObserverBaseResult<TData = unknown, TError = DefaultError> {
|
|
18
|
+
data: TData | undefined;
|
|
19
|
+
dataUpdatedAt: number;
|
|
20
|
+
error: TError | null;
|
|
21
|
+
errorUpdatedAt: number;
|
|
22
|
+
failureCount: number;
|
|
23
|
+
failureReason: TError | null;
|
|
24
|
+
errorUpdateCount: number;
|
|
25
|
+
isError: boolean;
|
|
26
|
+
isFetched: boolean;
|
|
27
|
+
isFetchedAfterMount: boolean;
|
|
28
|
+
isFetching: boolean;
|
|
29
|
+
isLoading: boolean;
|
|
30
|
+
isPending: boolean;
|
|
31
|
+
isLoadingError: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated isInitialLoading is being deprecated in favor of isLoading
|
|
34
|
+
* and will be removed in the next major version.
|
|
35
|
+
*/
|
|
36
|
+
isInitialLoading: boolean;
|
|
37
|
+
isPaused: boolean;
|
|
38
|
+
isPlaceholderData: boolean;
|
|
39
|
+
isRefetchError: boolean;
|
|
40
|
+
isRefetching: boolean;
|
|
41
|
+
isStale: boolean;
|
|
42
|
+
isSuccess: boolean;
|
|
43
|
+
refetch: (options?: RefetchOptions) => Promise<QueryObserverResult<TData, TError>>;
|
|
44
|
+
status: QueryStatus;
|
|
45
|
+
fetchStatus: FetchStatus;
|
|
46
|
+
}
|
|
47
|
+
interface QueryObserverLoadingResult<TData = unknown, TError = DefaultError> extends QueryObserverBaseResult<TData, TError> {
|
|
48
|
+
data: undefined;
|
|
49
|
+
error: null;
|
|
50
|
+
isError: false;
|
|
51
|
+
isPending: true;
|
|
52
|
+
isLoadingError: false;
|
|
53
|
+
isRefetchError: false;
|
|
54
|
+
isSuccess: false;
|
|
55
|
+
status: 'pending';
|
|
56
|
+
}
|
|
57
|
+
interface QueryObserverLoadingErrorResult<TData = unknown, TError = DefaultError> extends QueryObserverBaseResult<TData, TError> {
|
|
58
|
+
data: undefined;
|
|
59
|
+
error: TError;
|
|
60
|
+
isError: true;
|
|
61
|
+
isPending: false;
|
|
62
|
+
isLoadingError: true;
|
|
63
|
+
isRefetchError: false;
|
|
64
|
+
isSuccess: false;
|
|
65
|
+
status: 'error';
|
|
66
|
+
}
|
|
67
|
+
interface QueryObserverRefetchErrorResult<TData = unknown, TError = DefaultError> extends QueryObserverBaseResult<TData, TError> {
|
|
68
|
+
data: TData;
|
|
69
|
+
error: TError;
|
|
70
|
+
isError: true;
|
|
71
|
+
isPending: false;
|
|
72
|
+
isLoadingError: false;
|
|
73
|
+
isRefetchError: true;
|
|
74
|
+
isSuccess: false;
|
|
75
|
+
status: 'error';
|
|
76
|
+
}
|
|
77
|
+
interface QueryObserverSuccessResult<TData = unknown, TError = DefaultError> extends QueryObserverBaseResult<TData, TError> {
|
|
78
|
+
data: TData;
|
|
79
|
+
error: null;
|
|
80
|
+
isError: false;
|
|
81
|
+
isPending: false;
|
|
82
|
+
isLoadingError: false;
|
|
83
|
+
isRefetchError: false;
|
|
84
|
+
isSuccess: true;
|
|
85
|
+
status: 'success';
|
|
86
|
+
}
|
|
87
|
+
type DefinedQueryObserverResult<TData = unknown, TError = DefaultError> = QueryObserverRefetchErrorResult<TData, TError> | QueryObserverSuccessResult<TData, TError>;
|
|
88
|
+
type QueryObserverResult<TData = unknown, TError = DefaultError> = DefinedQueryObserverResult<TData, TError> | QueryObserverLoadingErrorResult<TData, TError> | QueryObserverLoadingResult<TData, TError>;
|
|
89
|
+
|
|
90
|
+
declare function useBaseQuery<TQueryFnData, TError, TData, TQueryData, TQueryKey extends QueryKey>(options: UseBaseQueryOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>, Observer: typeof QueryObserver, queryClient?: QueryClient): QueryObserverResult<TData, TError>;
|
|
91
|
+
|
|
92
|
+
export { useBaseQuery };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { UseBaseQueryOptions } from './types.js';
|
|
2
|
+
import { QueryKey, QueryObserver, QueryClient } from '@tanstack/query-core';
|
|
3
|
+
|
|
4
|
+
interface Register {
|
|
5
|
+
}
|
|
6
|
+
type DefaultError = Register extends {
|
|
7
|
+
defaultError: infer TError;
|
|
8
|
+
} ? TError : Error;
|
|
9
|
+
interface ResultOptions {
|
|
10
|
+
throwOnError?: boolean;
|
|
11
|
+
}
|
|
12
|
+
interface RefetchOptions extends ResultOptions {
|
|
13
|
+
cancelRefetch?: boolean;
|
|
14
|
+
}
|
|
15
|
+
type QueryStatus = 'pending' | 'error' | 'success';
|
|
16
|
+
type FetchStatus = 'fetching' | 'paused' | 'idle';
|
|
17
|
+
interface QueryObserverBaseResult<TData = unknown, TError = DefaultError> {
|
|
18
|
+
data: TData | undefined;
|
|
19
|
+
dataUpdatedAt: number;
|
|
20
|
+
error: TError | null;
|
|
21
|
+
errorUpdatedAt: number;
|
|
22
|
+
failureCount: number;
|
|
23
|
+
failureReason: TError | null;
|
|
24
|
+
errorUpdateCount: number;
|
|
25
|
+
isError: boolean;
|
|
26
|
+
isFetched: boolean;
|
|
27
|
+
isFetchedAfterMount: boolean;
|
|
28
|
+
isFetching: boolean;
|
|
29
|
+
isLoading: boolean;
|
|
30
|
+
isPending: boolean;
|
|
31
|
+
isLoadingError: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated isInitialLoading is being deprecated in favor of isLoading
|
|
34
|
+
* and will be removed in the next major version.
|
|
35
|
+
*/
|
|
36
|
+
isInitialLoading: boolean;
|
|
37
|
+
isPaused: boolean;
|
|
38
|
+
isPlaceholderData: boolean;
|
|
39
|
+
isRefetchError: boolean;
|
|
40
|
+
isRefetching: boolean;
|
|
41
|
+
isStale: boolean;
|
|
42
|
+
isSuccess: boolean;
|
|
43
|
+
refetch: (options?: RefetchOptions) => Promise<QueryObserverResult<TData, TError>>;
|
|
44
|
+
status: QueryStatus;
|
|
45
|
+
fetchStatus: FetchStatus;
|
|
46
|
+
}
|
|
47
|
+
interface QueryObserverLoadingResult<TData = unknown, TError = DefaultError> extends QueryObserverBaseResult<TData, TError> {
|
|
48
|
+
data: undefined;
|
|
49
|
+
error: null;
|
|
50
|
+
isError: false;
|
|
51
|
+
isPending: true;
|
|
52
|
+
isLoadingError: false;
|
|
53
|
+
isRefetchError: false;
|
|
54
|
+
isSuccess: false;
|
|
55
|
+
status: 'pending';
|
|
56
|
+
}
|
|
57
|
+
interface QueryObserverLoadingErrorResult<TData = unknown, TError = DefaultError> extends QueryObserverBaseResult<TData, TError> {
|
|
58
|
+
data: undefined;
|
|
59
|
+
error: TError;
|
|
60
|
+
isError: true;
|
|
61
|
+
isPending: false;
|
|
62
|
+
isLoadingError: true;
|
|
63
|
+
isRefetchError: false;
|
|
64
|
+
isSuccess: false;
|
|
65
|
+
status: 'error';
|
|
66
|
+
}
|
|
67
|
+
interface QueryObserverRefetchErrorResult<TData = unknown, TError = DefaultError> extends QueryObserverBaseResult<TData, TError> {
|
|
68
|
+
data: TData;
|
|
69
|
+
error: TError;
|
|
70
|
+
isError: true;
|
|
71
|
+
isPending: false;
|
|
72
|
+
isLoadingError: false;
|
|
73
|
+
isRefetchError: true;
|
|
74
|
+
isSuccess: false;
|
|
75
|
+
status: 'error';
|
|
76
|
+
}
|
|
77
|
+
interface QueryObserverSuccessResult<TData = unknown, TError = DefaultError> extends QueryObserverBaseResult<TData, TError> {
|
|
78
|
+
data: TData;
|
|
79
|
+
error: null;
|
|
80
|
+
isError: false;
|
|
81
|
+
isPending: false;
|
|
82
|
+
isLoadingError: false;
|
|
83
|
+
isRefetchError: false;
|
|
84
|
+
isSuccess: true;
|
|
85
|
+
status: 'success';
|
|
86
|
+
}
|
|
87
|
+
type DefinedQueryObserverResult<TData = unknown, TError = DefaultError> = QueryObserverRefetchErrorResult<TData, TError> | QueryObserverSuccessResult<TData, TError>;
|
|
88
|
+
type QueryObserverResult<TData = unknown, TError = DefaultError> = DefinedQueryObserverResult<TData, TError> | QueryObserverLoadingErrorResult<TData, TError> | QueryObserverLoadingResult<TData, TError>;
|
|
89
|
+
|
|
90
|
+
declare function useBaseQuery<TQueryFnData, TError, TData, TQueryData, TQueryKey extends QueryKey>(options: UseBaseQueryOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>, Observer: typeof QueryObserver, queryClient?: QueryClient): QueryObserverResult<TData, TError>;
|
|
91
|
+
|
|
92
|
+
export { useBaseQuery };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { notifyManager } from "@tanstack/query-core";
|
|
4
|
+
import { useQueryErrorResetBoundary } from "./QueryErrorResetBoundary";
|
|
5
|
+
import { useQueryClient } from "./QueryClientProvider";
|
|
6
|
+
import { useIsRestoring } from "./isRestoring";
|
|
7
|
+
import {
|
|
8
|
+
ensurePreventErrorBoundaryRetry,
|
|
9
|
+
getHasError,
|
|
10
|
+
useClearResetErrorBoundary
|
|
11
|
+
} from "./errorBoundaryUtils";
|
|
12
|
+
import { ensureStaleTime, fetchOptimistic, shouldSuspend } from "./suspense";
|
|
13
|
+
function useBaseQuery(options, Observer, queryClient) {
|
|
14
|
+
const client = useQueryClient(queryClient);
|
|
15
|
+
const isRestoring = useIsRestoring();
|
|
16
|
+
const errorResetBoundary = useQueryErrorResetBoundary();
|
|
17
|
+
const defaultedOptions = client.defaultQueryOptions(options);
|
|
18
|
+
defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : "optimistic";
|
|
19
|
+
ensureStaleTime(defaultedOptions);
|
|
20
|
+
ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary);
|
|
21
|
+
useClearResetErrorBoundary(errorResetBoundary);
|
|
22
|
+
const [observer] = React.useState(
|
|
23
|
+
() => new Observer(
|
|
24
|
+
client,
|
|
25
|
+
defaultedOptions
|
|
26
|
+
)
|
|
27
|
+
);
|
|
28
|
+
const result = observer.getOptimisticResult(defaultedOptions);
|
|
29
|
+
React.useSyncExternalStore(
|
|
30
|
+
React.useCallback(
|
|
31
|
+
(onStoreChange) => {
|
|
32
|
+
const unsubscribe = isRestoring ? () => void 0 : observer.subscribe(notifyManager.batchCalls(onStoreChange));
|
|
33
|
+
observer.updateResult();
|
|
34
|
+
return unsubscribe;
|
|
35
|
+
},
|
|
36
|
+
[observer, isRestoring]
|
|
37
|
+
),
|
|
38
|
+
() => observer.getCurrentResult(),
|
|
39
|
+
() => observer.getCurrentResult()
|
|
40
|
+
);
|
|
41
|
+
React.useEffect(() => {
|
|
42
|
+
observer.setOptions(defaultedOptions, { listeners: false });
|
|
43
|
+
}, [defaultedOptions, observer]);
|
|
44
|
+
if (shouldSuspend(defaultedOptions, result, isRestoring)) {
|
|
45
|
+
throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary);
|
|
46
|
+
}
|
|
47
|
+
if (getHasError({
|
|
48
|
+
result,
|
|
49
|
+
errorResetBoundary,
|
|
50
|
+
throwOnError: defaultedOptions.throwOnError,
|
|
51
|
+
query: observer.getCurrentQuery()
|
|
52
|
+
})) {
|
|
53
|
+
throw result.error;
|
|
54
|
+
}
|
|
55
|
+
return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result;
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
useBaseQuery
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=useBaseQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/useBaseQuery.ts"],"sourcesContent":["'use client'\nimport * as React from 'react'\n\nimport { notifyManager } from '@tanstack/query-core'\nimport { useQueryErrorResetBoundary } from './QueryErrorResetBoundary'\nimport { useQueryClient } from './QueryClientProvider'\nimport { useIsRestoring } from './isRestoring'\nimport {\n ensurePreventErrorBoundaryRetry,\n getHasError,\n useClearResetErrorBoundary,\n} from './errorBoundaryUtils'\nimport { ensureStaleTime, fetchOptimistic, shouldSuspend } from './suspense'\nimport type { UseBaseQueryOptions } from './types'\nimport type { QueryClient, QueryKey, QueryObserver } from '@tanstack/query-core'\n\nexport function useBaseQuery<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n>(\n options: UseBaseQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n Observer: typeof QueryObserver,\n queryClient?: QueryClient,\n) {\n const client = useQueryClient(queryClient)\n const isRestoring = useIsRestoring()\n const errorResetBoundary = useQueryErrorResetBoundary()\n const defaultedOptions = client.defaultQueryOptions(options)\n\n // Make sure results are optimistically set in fetching state before subscribing or updating options\n defaultedOptions._optimisticResults = isRestoring\n ? 'isRestoring'\n : 'optimistic'\n\n ensureStaleTime(defaultedOptions)\n ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary)\n\n useClearResetErrorBoundary(errorResetBoundary)\n\n const [observer] = React.useState(\n () =>\n new Observer<TQueryFnData, TError, TData, TQueryData, TQueryKey>(\n client,\n defaultedOptions,\n ),\n )\n\n const result = observer.getOptimisticResult(defaultedOptions)\n\n React.useSyncExternalStore(\n React.useCallback(\n (onStoreChange) => {\n const unsubscribe = isRestoring\n ? () => undefined\n : observer.subscribe(notifyManager.batchCalls(onStoreChange))\n\n // Update result to make sure we did not miss any query updates\n // between creating the observer and subscribing to it.\n observer.updateResult()\n\n return unsubscribe\n },\n [observer, isRestoring],\n ),\n () => observer.getCurrentResult(),\n () => observer.getCurrentResult(),\n )\n\n React.useEffect(() => {\n // Do not notify on updates because of changes in the options because\n // these changes should already be reflected in the optimistic result.\n observer.setOptions(defaultedOptions, { listeners: false })\n }, [defaultedOptions, observer])\n\n // Handle suspense\n if (shouldSuspend(defaultedOptions, result, isRestoring)) {\n throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary)\n }\n\n // Handle error boundary\n if (\n getHasError({\n result,\n errorResetBoundary,\n throwOnError: defaultedOptions.throwOnError,\n query: observer.getCurrentQuery(),\n })\n ) {\n throw result.error\n }\n\n // Handle result property usage tracking\n return !defaultedOptions.notifyOnChangeProps\n ? observer.trackResult(result)\n : result\n}\n"],"mappings":";AACA,YAAY,WAAW;AAEvB,SAAS,qBAAqB;AAC9B,SAAS,kCAAkC;AAC3C,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,iBAAiB,iBAAiB,qBAAqB;AAIzD,SAAS,aAOd,SAOA,UACA,aACA;AACA,QAAM,SAAS,eAAe,WAAW;AACzC,QAAM,cAAc,eAAe;AACnC,QAAM,qBAAqB,2BAA2B;AACtD,QAAM,mBAAmB,OAAO,oBAAoB,OAAO;AAG3D,mBAAiB,qBAAqB,cAClC,gBACA;AAEJ,kBAAgB,gBAAgB;AAChC,kCAAgC,kBAAkB,kBAAkB;AAEpE,6BAA2B,kBAAkB;AAE7C,QAAM,CAAC,QAAQ,IAAI,MAAM;AAAA,IACvB,MACE,IAAI;AAAA,MACF;AAAA,MACA;AAAA,IACF;AAAA,EACJ;AAEA,QAAM,SAAS,SAAS,oBAAoB,gBAAgB;AAE5D,QAAM;AAAA,IACJ,MAAM;AAAA,MACJ,CAAC,kBAAkB;AACjB,cAAM,cAAc,cAChB,MAAM,SACN,SAAS,UAAU,cAAc,WAAW,aAAa,CAAC;AAI9D,iBAAS,aAAa;AAEtB,eAAO;AAAA,MACT;AAAA,MACA,CAAC,UAAU,WAAW;AAAA,IACxB;AAAA,IACA,MAAM,SAAS,iBAAiB;AAAA,IAChC,MAAM,SAAS,iBAAiB;AAAA,EAClC;AAEA,QAAM,UAAU,MAAM;AAGpB,aAAS,WAAW,kBAAkB,EAAE,WAAW,MAAM,CAAC;AAAA,EAC5D,GAAG,CAAC,kBAAkB,QAAQ,CAAC;AAG/B,MAAI,cAAc,kBAAkB,QAAQ,WAAW,GAAG;AACxD,UAAM,gBAAgB,kBAAkB,UAAU,kBAAkB;AAAA,EACtE;AAGA,MACE,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA,cAAc,iBAAiB;AAAA,IAC/B,OAAO,SAAS,gBAAgB;AAAA,EAClC,CAAC,GACD;AACA,UAAM,OAAO;AAAA,EACf;AAGA,SAAO,CAAC,iBAAiB,sBACrB,SAAS,YAAY,MAAM,IAC3B;AACN;","names":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var useInfiniteQuery_exports = {};
|
|
21
|
+
__export(useInfiniteQuery_exports, {
|
|
22
|
+
useInfiniteQuery: () => useInfiniteQuery
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useInfiniteQuery_exports);
|
|
25
|
+
var import_query_core = require("@tanstack/query-core");
|
|
26
|
+
var import_useBaseQuery = require("./useBaseQuery");
|
|
27
|
+
function useInfiniteQuery(options, queryClient) {
|
|
28
|
+
return (0, import_useBaseQuery.useBaseQuery)(
|
|
29
|
+
options,
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
31
|
+
import_query_core.InfiniteQueryObserver,
|
|
32
|
+
queryClient
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
useInfiniteQuery
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=useInfiniteQuery.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/useInfiniteQuery.ts"],"sourcesContent":["'use client'\nimport { InfiniteQueryObserver } from '@tanstack/query-core'\nimport { useBaseQuery } from './useBaseQuery'\nimport type {\n DefaultError,\n InfiniteData,\n QueryClient,\n QueryKey,\n QueryObserver,\n} from '@tanstack/query-core'\nimport type { UseInfiniteQueryOptions, UseInfiniteQueryResult } from './types'\n\n// HOOK\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryFnData,\n TQueryKey,\n TPageParam\n >,\n queryClient?: QueryClient,\n): UseInfiniteQueryResult<TData, TError> {\n return useBaseQuery(\n options,\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n InfiniteQueryObserver as typeof QueryObserver,\n queryClient,\n ) as UseInfiniteQueryResult<TData, TError>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,wBAAsC;AACtC,0BAA6B;AAWtB,SAAS,iBAOd,SAQA,aACuC;AACvC,aAAO;AAAA,IACL;AAAA;AAAA,IAEA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DefaultError, InfiniteData, QueryKey, QueryClient } from '@tanstack/query-core';
|
|
2
|
+
import { UseInfiniteQueryOptions, UseInfiniteQueryResult } from './types.cjs';
|
|
3
|
+
|
|
4
|
+
declare function useInfiniteQuery<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey, TPageParam>, queryClient?: QueryClient): UseInfiniteQueryResult<TData, TError>;
|
|
5
|
+
|
|
6
|
+
export { useInfiniteQuery };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DefaultError, InfiniteData, QueryKey, QueryClient } from '@tanstack/query-core';
|
|
2
|
+
import { UseInfiniteQueryOptions, UseInfiniteQueryResult } from './types.js';
|
|
3
|
+
|
|
4
|
+
declare function useInfiniteQuery<TQueryFnData, TError = DefaultError, TData = InfiniteData<TQueryFnData>, TQueryKey extends QueryKey = QueryKey, TPageParam = unknown>(options: UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey, TPageParam>, queryClient?: QueryClient): UseInfiniteQueryResult<TData, TError>;
|
|
5
|
+
|
|
6
|
+
export { useInfiniteQuery };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { InfiniteQueryObserver } from "@tanstack/query-core";
|
|
3
|
+
import { useBaseQuery } from "./useBaseQuery";
|
|
4
|
+
function useInfiniteQuery(options, queryClient) {
|
|
5
|
+
return useBaseQuery(
|
|
6
|
+
options,
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
8
|
+
InfiniteQueryObserver,
|
|
9
|
+
queryClient
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
useInfiniteQuery
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=useInfiniteQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/useInfiniteQuery.ts"],"sourcesContent":["'use client'\nimport { InfiniteQueryObserver } from '@tanstack/query-core'\nimport { useBaseQuery } from './useBaseQuery'\nimport type {\n DefaultError,\n InfiniteData,\n QueryClient,\n QueryKey,\n QueryObserver,\n} from '@tanstack/query-core'\nimport type { UseInfiniteQueryOptions, UseInfiniteQueryResult } from './types'\n\n// HOOK\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UseInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryFnData,\n TQueryKey,\n TPageParam\n >,\n queryClient?: QueryClient,\n): UseInfiniteQueryResult<TData, TError> {\n return useBaseQuery(\n options,\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n InfiniteQueryObserver as typeof QueryObserver,\n queryClient,\n ) as UseInfiniteQueryResult<TData, TError>\n}\n"],"mappings":";AACA,SAAS,6BAA6B;AACtC,SAAS,oBAAoB;AAWtB,SAAS,iBAOd,SAQA,aACuC;AACvC,SAAO;AAAA,IACL;AAAA;AAAA,IAEA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var useIsFetching_exports = {};
|
|
31
|
+
__export(useIsFetching_exports, {
|
|
32
|
+
useIsFetching: () => useIsFetching
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(useIsFetching_exports);
|
|
35
|
+
var React = __toESM(require("react"), 1);
|
|
36
|
+
var import_query_core = require("@tanstack/query-core");
|
|
37
|
+
var import_QueryClientProvider = require("./QueryClientProvider");
|
|
38
|
+
function useIsFetching(filters, queryClient) {
|
|
39
|
+
const client = (0, import_QueryClientProvider.useQueryClient)(queryClient);
|
|
40
|
+
const queryCache = client.getQueryCache();
|
|
41
|
+
return React.useSyncExternalStore(
|
|
42
|
+
React.useCallback(
|
|
43
|
+
(onStoreChange) => queryCache.subscribe(import_query_core.notifyManager.batchCalls(onStoreChange)),
|
|
44
|
+
[queryCache]
|
|
45
|
+
),
|
|
46
|
+
() => client.isFetching(filters),
|
|
47
|
+
() => client.isFetching(filters)
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
useIsFetching
|
|
53
|
+
});
|
|
54
|
+
//# sourceMappingURL=useIsFetching.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/useIsFetching.ts"],"sourcesContent":["'use client'\nimport * as React from 'react'\nimport { notifyManager } from '@tanstack/query-core'\n\nimport { useQueryClient } from './QueryClientProvider'\nimport type { QueryClient, QueryFilters } from '@tanstack/query-core'\n\nexport function useIsFetching(\n filters?: QueryFilters,\n queryClient?: QueryClient,\n): number {\n const client = useQueryClient(queryClient)\n const queryCache = client.getQueryCache()\n\n return React.useSyncExternalStore(\n React.useCallback(\n (onStoreChange) =>\n queryCache.subscribe(notifyManager.batchCalls(onStoreChange)),\n [queryCache],\n ),\n () => client.isFetching(filters),\n () => client.isFetching(filters),\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,YAAuB;AACvB,wBAA8B;AAE9B,iCAA+B;AAGxB,SAAS,cACd,SACA,aACQ;AACR,QAAM,aAAS,2CAAe,WAAW;AACzC,QAAM,aAAa,OAAO,cAAc;AAExC,SAAO,MAAM;AAAA,IACX,MAAM;AAAA,MACJ,CAAC,kBACC,WAAW,UAAU,gCAAc,WAAW,aAAa,CAAC;AAAA,MAC9D,CAAC,UAAU;AAAA,IACb;AAAA,IACA,MAAM,OAAO,WAAW,OAAO;AAAA,IAC/B,MAAM,OAAO,WAAW,OAAO;AAAA,EACjC;AACF;","names":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { notifyManager } from "@tanstack/query-core";
|
|
4
|
+
import { useQueryClient } from "./QueryClientProvider";
|
|
5
|
+
function useIsFetching(filters, queryClient) {
|
|
6
|
+
const client = useQueryClient(queryClient);
|
|
7
|
+
const queryCache = client.getQueryCache();
|
|
8
|
+
return React.useSyncExternalStore(
|
|
9
|
+
React.useCallback(
|
|
10
|
+
(onStoreChange) => queryCache.subscribe(notifyManager.batchCalls(onStoreChange)),
|
|
11
|
+
[queryCache]
|
|
12
|
+
),
|
|
13
|
+
() => client.isFetching(filters),
|
|
14
|
+
() => client.isFetching(filters)
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
useIsFetching
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=useIsFetching.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/useIsFetching.ts"],"sourcesContent":["'use client'\nimport * as React from 'react'\nimport { notifyManager } from '@tanstack/query-core'\n\nimport { useQueryClient } from './QueryClientProvider'\nimport type { QueryClient, QueryFilters } from '@tanstack/query-core'\n\nexport function useIsFetching(\n filters?: QueryFilters,\n queryClient?: QueryClient,\n): number {\n const client = useQueryClient(queryClient)\n const queryCache = client.getQueryCache()\n\n return React.useSyncExternalStore(\n React.useCallback(\n (onStoreChange) =>\n queryCache.subscribe(notifyManager.batchCalls(onStoreChange)),\n [queryCache],\n ),\n () => client.isFetching(filters),\n () => client.isFetching(filters),\n )\n}\n"],"mappings":";AACA,YAAY,WAAW;AACvB,SAAS,qBAAqB;AAE9B,SAAS,sBAAsB;AAGxB,SAAS,cACd,SACA,aACQ;AACR,QAAM,SAAS,eAAe,WAAW;AACzC,QAAM,aAAa,OAAO,cAAc;AAExC,SAAO,MAAM;AAAA,IACX,MAAM;AAAA,MACJ,CAAC,kBACC,WAAW,UAAU,cAAc,WAAW,aAAa,CAAC;AAAA,MAC9D,CAAC,UAAU;AAAA,IACb;AAAA,IACA,MAAM,OAAO,WAAW,OAAO;AAAA,IAC/B,MAAM,OAAO,WAAW,OAAO;AAAA,EACjC;AACF;","names":[]}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var useMutation_exports = {};
|
|
31
|
+
__export(useMutation_exports, {
|
|
32
|
+
useMutation: () => useMutation
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(useMutation_exports);
|
|
35
|
+
var React = __toESM(require("react"), 1);
|
|
36
|
+
var import_query_core = require("@tanstack/query-core");
|
|
37
|
+
var import_QueryClientProvider = require("./QueryClientProvider");
|
|
38
|
+
var import_utils = require("./utils");
|
|
39
|
+
function useMutation(options, queryClient) {
|
|
40
|
+
const client = (0, import_QueryClientProvider.useQueryClient)(queryClient);
|
|
41
|
+
const [observer] = React.useState(
|
|
42
|
+
() => new import_query_core.MutationObserver(
|
|
43
|
+
client,
|
|
44
|
+
options
|
|
45
|
+
)
|
|
46
|
+
);
|
|
47
|
+
React.useEffect(() => {
|
|
48
|
+
observer.setOptions(options);
|
|
49
|
+
}, [observer, options]);
|
|
50
|
+
const result = React.useSyncExternalStore(
|
|
51
|
+
React.useCallback(
|
|
52
|
+
(onStoreChange) => observer.subscribe(import_query_core.notifyManager.batchCalls(onStoreChange)),
|
|
53
|
+
[observer]
|
|
54
|
+
),
|
|
55
|
+
() => observer.getCurrentResult(),
|
|
56
|
+
() => observer.getCurrentResult()
|
|
57
|
+
);
|
|
58
|
+
const mutate = React.useCallback(
|
|
59
|
+
(variables, mutateOptions) => {
|
|
60
|
+
observer.mutate(variables, mutateOptions).catch(noop);
|
|
61
|
+
},
|
|
62
|
+
[observer]
|
|
63
|
+
);
|
|
64
|
+
if (result.error && (0, import_utils.shouldThrowError)(observer.options.throwOnError, [result.error])) {
|
|
65
|
+
throw result.error;
|
|
66
|
+
}
|
|
67
|
+
return { ...result, mutate, mutateAsync: result.mutate };
|
|
68
|
+
}
|
|
69
|
+
function noop() {
|
|
70
|
+
}
|
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
+
0 && (module.exports = {
|
|
73
|
+
useMutation
|
|
74
|
+
});
|
|
75
|
+
//# sourceMappingURL=useMutation.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/useMutation.ts"],"sourcesContent":["'use client'\nimport * as React from 'react'\nimport { MutationObserver, notifyManager } from '@tanstack/query-core'\nimport { useQueryClient } from './QueryClientProvider'\nimport { shouldThrowError } from './utils'\nimport type {\n UseMutateFunction,\n UseMutationOptions,\n UseMutationResult,\n} from './types'\nimport type { DefaultError, QueryClient } from '@tanstack/query-core'\n\n// HOOK\n\nexport function useMutation<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n>(\n options: UseMutationOptions<TData, TError, TVariables, TContext>,\n queryClient?: QueryClient,\n): UseMutationResult<TData, TError, TVariables, TContext> {\n const client = useQueryClient(queryClient)\n\n const [observer] = React.useState(\n () =>\n new MutationObserver<TData, TError, TVariables, TContext>(\n client,\n options,\n ),\n )\n\n React.useEffect(() => {\n observer.setOptions(options)\n }, [observer, options])\n\n const result = React.useSyncExternalStore(\n React.useCallback(\n (onStoreChange) =>\n observer.subscribe(notifyManager.batchCalls(onStoreChange)),\n [observer],\n ),\n () => observer.getCurrentResult(),\n () => observer.getCurrentResult(),\n )\n\n const mutate = React.useCallback<\n UseMutateFunction<TData, TError, TVariables, TContext>\n >(\n (variables, mutateOptions) => {\n observer.mutate(variables, mutateOptions).catch(noop)\n },\n [observer],\n )\n\n if (\n result.error &&\n shouldThrowError(observer.options.throwOnError, [result.error])\n ) {\n throw result.error\n }\n\n return { ...result, mutate, mutateAsync: result.mutate }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nfunction noop() {}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,YAAuB;AACvB,wBAAgD;AAChD,iCAA+B;AAC/B,mBAAiC;AAU1B,SAAS,YAMd,SACA,aACwD;AACxD,QAAM,aAAS,2CAAe,WAAW;AAEzC,QAAM,CAAC,QAAQ,IAAI,MAAM;AAAA,IACvB,MACE,IAAI;AAAA,MACF;AAAA,MACA;AAAA,IACF;AAAA,EACJ;AAEA,QAAM,UAAU,MAAM;AACpB,aAAS,WAAW,OAAO;AAAA,EAC7B,GAAG,CAAC,UAAU,OAAO,CAAC;AAEtB,QAAM,SAAS,MAAM;AAAA,IACnB,MAAM;AAAA,MACJ,CAAC,kBACC,SAAS,UAAU,gCAAc,WAAW,aAAa,CAAC;AAAA,MAC5D,CAAC,QAAQ;AAAA,IACX;AAAA,IACA,MAAM,SAAS,iBAAiB;AAAA,IAChC,MAAM,SAAS,iBAAiB;AAAA,EAClC;AAEA,QAAM,SAAS,MAAM;AAAA,IAGnB,CAAC,WAAW,kBAAkB;AAC5B,eAAS,OAAO,WAAW,aAAa,EAAE,MAAM,IAAI;AAAA,IACtD;AAAA,IACA,CAAC,QAAQ;AAAA,EACX;AAEA,MACE,OAAO,aACP,+BAAiB,SAAS,QAAQ,cAAc,CAAC,OAAO,KAAK,CAAC,GAC9D;AACA,UAAM,OAAO;AAAA,EACf;AAEA,SAAO,EAAE,GAAG,QAAQ,QAAQ,aAAa,OAAO,OAAO;AACzD;AAGA,SAAS,OAAO;AAAC;","names":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { UseMutationOptions, UseMutationResult } from './types.cjs';
|
|
2
|
+
import { DefaultError, QueryClient } from '@tanstack/query-core';
|
|
3
|
+
|
|
4
|
+
declare function useMutation<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown>(options: UseMutationOptions<TData, TError, TVariables, TContext>, queryClient?: QueryClient): UseMutationResult<TData, TError, TVariables, TContext>;
|
|
5
|
+
|
|
6
|
+
export { useMutation };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { UseMutationOptions, UseMutationResult } from './types.js';
|
|
2
|
+
import { DefaultError, QueryClient } from '@tanstack/query-core';
|
|
3
|
+
|
|
4
|
+
declare function useMutation<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown>(options: UseMutationOptions<TData, TError, TVariables, TContext>, queryClient?: QueryClient): UseMutationResult<TData, TError, TVariables, TContext>;
|
|
5
|
+
|
|
6
|
+
export { useMutation };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { MutationObserver, notifyManager } from "@tanstack/query-core";
|
|
4
|
+
import { useQueryClient } from "./QueryClientProvider";
|
|
5
|
+
import { shouldThrowError } from "./utils";
|
|
6
|
+
function useMutation(options, queryClient) {
|
|
7
|
+
const client = useQueryClient(queryClient);
|
|
8
|
+
const [observer] = React.useState(
|
|
9
|
+
() => new MutationObserver(
|
|
10
|
+
client,
|
|
11
|
+
options
|
|
12
|
+
)
|
|
13
|
+
);
|
|
14
|
+
React.useEffect(() => {
|
|
15
|
+
observer.setOptions(options);
|
|
16
|
+
}, [observer, options]);
|
|
17
|
+
const result = React.useSyncExternalStore(
|
|
18
|
+
React.useCallback(
|
|
19
|
+
(onStoreChange) => observer.subscribe(notifyManager.batchCalls(onStoreChange)),
|
|
20
|
+
[observer]
|
|
21
|
+
),
|
|
22
|
+
() => observer.getCurrentResult(),
|
|
23
|
+
() => observer.getCurrentResult()
|
|
24
|
+
);
|
|
25
|
+
const mutate = React.useCallback(
|
|
26
|
+
(variables, mutateOptions) => {
|
|
27
|
+
observer.mutate(variables, mutateOptions).catch(noop);
|
|
28
|
+
},
|
|
29
|
+
[observer]
|
|
30
|
+
);
|
|
31
|
+
if (result.error && shouldThrowError(observer.options.throwOnError, [result.error])) {
|
|
32
|
+
throw result.error;
|
|
33
|
+
}
|
|
34
|
+
return { ...result, mutate, mutateAsync: result.mutate };
|
|
35
|
+
}
|
|
36
|
+
function noop() {
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
useMutation
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=useMutation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/useMutation.ts"],"sourcesContent":["'use client'\nimport * as React from 'react'\nimport { MutationObserver, notifyManager } from '@tanstack/query-core'\nimport { useQueryClient } from './QueryClientProvider'\nimport { shouldThrowError } from './utils'\nimport type {\n UseMutateFunction,\n UseMutationOptions,\n UseMutationResult,\n} from './types'\nimport type { DefaultError, QueryClient } from '@tanstack/query-core'\n\n// HOOK\n\nexport function useMutation<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n>(\n options: UseMutationOptions<TData, TError, TVariables, TContext>,\n queryClient?: QueryClient,\n): UseMutationResult<TData, TError, TVariables, TContext> {\n const client = useQueryClient(queryClient)\n\n const [observer] = React.useState(\n () =>\n new MutationObserver<TData, TError, TVariables, TContext>(\n client,\n options,\n ),\n )\n\n React.useEffect(() => {\n observer.setOptions(options)\n }, [observer, options])\n\n const result = React.useSyncExternalStore(\n React.useCallback(\n (onStoreChange) =>\n observer.subscribe(notifyManager.batchCalls(onStoreChange)),\n [observer],\n ),\n () => observer.getCurrentResult(),\n () => observer.getCurrentResult(),\n )\n\n const mutate = React.useCallback<\n UseMutateFunction<TData, TError, TVariables, TContext>\n >(\n (variables, mutateOptions) => {\n observer.mutate(variables, mutateOptions).catch(noop)\n },\n [observer],\n )\n\n if (\n result.error &&\n shouldThrowError(observer.options.throwOnError, [result.error])\n ) {\n throw result.error\n }\n\n return { ...result, mutate, mutateAsync: result.mutate }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nfunction noop() {}\n"],"mappings":";AACA,YAAY,WAAW;AACvB,SAAS,kBAAkB,qBAAqB;AAChD,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AAU1B,SAAS,YAMd,SACA,aACwD;AACxD,QAAM,SAAS,eAAe,WAAW;AAEzC,QAAM,CAAC,QAAQ,IAAI,MAAM;AAAA,IACvB,MACE,IAAI;AAAA,MACF;AAAA,MACA;AAAA,IACF;AAAA,EACJ;AAEA,QAAM,UAAU,MAAM;AACpB,aAAS,WAAW,OAAO;AAAA,EAC7B,GAAG,CAAC,UAAU,OAAO,CAAC;AAEtB,QAAM,SAAS,MAAM;AAAA,IACnB,MAAM;AAAA,MACJ,CAAC,kBACC,SAAS,UAAU,cAAc,WAAW,aAAa,CAAC;AAAA,MAC5D,CAAC,QAAQ;AAAA,IACX;AAAA,IACA,MAAM,SAAS,iBAAiB;AAAA,IAChC,MAAM,SAAS,iBAAiB;AAAA,EAClC;AAEA,QAAM,SAAS,MAAM;AAAA,IAGnB,CAAC,WAAW,kBAAkB;AAC5B,eAAS,OAAO,WAAW,aAAa,EAAE,MAAM,IAAI;AAAA,IACtD;AAAA,IACA,CAAC,QAAQ;AAAA,EACX;AAEA,MACE,OAAO,SACP,iBAAiB,SAAS,QAAQ,cAAc,CAAC,OAAO,KAAK,CAAC,GAC9D;AACA,UAAM,OAAO;AAAA,EACf;AAEA,SAAO,EAAE,GAAG,QAAQ,QAAQ,aAAa,OAAO,OAAO;AACzD;AAGA,SAAS,OAAO;AAAC;","names":[]}
|