@tanstack/vue-query 5.107.0 → 5.107.1

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.
Files changed (135) hide show
  1. package/build/legacy/devtools/devtools.d.cts +1 -1
  2. package/build/legacy/devtools/devtools.d.ts +1 -1
  3. package/build/legacy/index.d.cts +4 -4
  4. package/build/legacy/index.d.ts +4 -4
  5. package/build/legacy/{infiniteQueryOptions-lJ_zR-As.d.cts → infiniteQueryOptions-BSwO8rvy.d.cts} +41 -5
  6. package/build/legacy/infiniteQueryOptions-BSwO8rvy.d.cts.map +1 -0
  7. package/build/legacy/{infiniteQueryOptions-CN37iZvc.d.ts → infiniteQueryOptions-Bq8UQFvj.d.ts} +41 -5
  8. package/build/legacy/infiniteQueryOptions-Bq8UQFvj.d.ts.map +1 -0
  9. package/build/legacy/infiniteQueryOptions.d.cts +1 -1
  10. package/build/legacy/infiniteQueryOptions.d.ts +1 -1
  11. package/build/{modern/queryClient-BGn8uIej.d.cts → legacy/queryClient-BSSPWSvX.d.cts} +2 -2
  12. package/build/legacy/{queryClient-BGn8uIej.d.cts.map → queryClient-BSSPWSvX.d.cts.map} +1 -1
  13. package/build/{modern/queryClient-Ba4HSFnn.d.ts → legacy/queryClient-Bgw9hMbf.d.ts} +2 -2
  14. package/build/legacy/{queryClient-Ba4HSFnn.d.ts.map → queryClient-Bgw9hMbf.d.ts.map} +1 -1
  15. package/build/legacy/queryClient.d.cts +1 -1
  16. package/build/legacy/queryClient.d.ts +1 -1
  17. package/build/{modern/queryOptions-BuZEBLtg.d.cts → legacy/queryOptions-B-eHjgaY.d.cts} +12 -4
  18. package/build/legacy/queryOptions-B-eHjgaY.d.cts.map +1 -0
  19. package/build/{modern/queryOptions-dXiBZnGk.d.ts → legacy/queryOptions-D1-foH1W.d.ts} +12 -4
  20. package/build/legacy/queryOptions-D1-foH1W.d.ts.map +1 -0
  21. package/build/legacy/queryOptions.cjs.map +1 -1
  22. package/build/legacy/queryOptions.d.cts +2 -2
  23. package/build/legacy/queryOptions.d.ts +2 -2
  24. package/build/legacy/queryOptions.js.map +1 -1
  25. package/build/legacy/useBaseQuery.cjs +11 -5
  26. package/build/legacy/useBaseQuery.cjs.map +1 -1
  27. package/build/legacy/useBaseQuery.d.cts +1 -1
  28. package/build/legacy/useBaseQuery.d.ts +1 -1
  29. package/build/legacy/useBaseQuery.js +11 -5
  30. package/build/legacy/useBaseQuery.js.map +1 -1
  31. package/build/legacy/useInfiniteQuery.cjs.map +1 -1
  32. package/build/legacy/useInfiniteQuery.d.cts +1 -1
  33. package/build/legacy/useInfiniteQuery.d.ts +1 -1
  34. package/build/legacy/useInfiniteQuery.js.map +1 -1
  35. package/build/legacy/useIsFetching.d.cts +1 -1
  36. package/build/legacy/useIsFetching.d.ts +1 -1
  37. package/build/legacy/useMutation.d.cts +1 -1
  38. package/build/legacy/useMutation.d.ts +1 -1
  39. package/build/legacy/useMutationState.d.cts +1 -1
  40. package/build/legacy/useMutationState.d.ts +1 -1
  41. package/build/legacy/usePrefetchInfiniteQuery.d.cts +1 -1
  42. package/build/legacy/usePrefetchInfiniteQuery.d.ts +1 -1
  43. package/build/legacy/usePrefetchQuery.d.cts +1 -1
  44. package/build/legacy/usePrefetchQuery.d.ts +1 -1
  45. package/build/legacy/useQueries.cjs +1 -1
  46. package/build/legacy/useQueries.cjs.map +1 -1
  47. package/build/legacy/useQueries.d.cts +2 -2
  48. package/build/legacy/useQueries.d.ts +2 -2
  49. package/build/legacy/useQueries.js +1 -1
  50. package/build/legacy/useQueries.js.map +1 -1
  51. package/build/legacy/useQuery.cjs.map +1 -1
  52. package/build/legacy/useQuery.d.cts +25 -4
  53. package/build/legacy/useQuery.d.cts.map +1 -1
  54. package/build/legacy/useQuery.d.ts +25 -4
  55. package/build/legacy/useQuery.d.ts.map +1 -1
  56. package/build/legacy/useQuery.js.map +1 -1
  57. package/build/legacy/useQueryClient.d.cts +1 -1
  58. package/build/legacy/useQueryClient.d.ts +1 -1
  59. package/build/legacy/vueQueryPlugin.d.cts +1 -1
  60. package/build/legacy/vueQueryPlugin.d.ts +1 -1
  61. package/build/modern/devtools/devtools.d.cts +1 -1
  62. package/build/modern/devtools/devtools.d.ts +1 -1
  63. package/build/modern/index.d.cts +4 -4
  64. package/build/modern/index.d.ts +4 -4
  65. package/build/modern/{infiniteQueryOptions-lJ_zR-As.d.cts → infiniteQueryOptions-BSwO8rvy.d.cts} +41 -5
  66. package/build/modern/infiniteQueryOptions-BSwO8rvy.d.cts.map +1 -0
  67. package/build/modern/{infiniteQueryOptions-CN37iZvc.d.ts → infiniteQueryOptions-Bq8UQFvj.d.ts} +41 -5
  68. package/build/modern/infiniteQueryOptions-Bq8UQFvj.d.ts.map +1 -0
  69. package/build/modern/infiniteQueryOptions.d.cts +1 -1
  70. package/build/modern/infiniteQueryOptions.d.ts +1 -1
  71. package/build/{legacy/queryClient-BGn8uIej.d.cts → modern/queryClient-BSSPWSvX.d.cts} +2 -2
  72. package/build/modern/{queryClient-BGn8uIej.d.cts.map → queryClient-BSSPWSvX.d.cts.map} +1 -1
  73. package/build/{legacy/queryClient-Ba4HSFnn.d.ts → modern/queryClient-Bgw9hMbf.d.ts} +2 -2
  74. package/build/modern/{queryClient-Ba4HSFnn.d.ts.map → queryClient-Bgw9hMbf.d.ts.map} +1 -1
  75. package/build/modern/queryClient.d.cts +1 -1
  76. package/build/modern/queryClient.d.ts +1 -1
  77. package/build/{legacy/queryOptions-BuZEBLtg.d.cts → modern/queryOptions-B-eHjgaY.d.cts} +12 -4
  78. package/build/modern/queryOptions-B-eHjgaY.d.cts.map +1 -0
  79. package/build/{legacy/queryOptions-dXiBZnGk.d.ts → modern/queryOptions-D1-foH1W.d.ts} +12 -4
  80. package/build/modern/queryOptions-D1-foH1W.d.ts.map +1 -0
  81. package/build/modern/queryOptions.cjs.map +1 -1
  82. package/build/modern/queryOptions.d.cts +2 -2
  83. package/build/modern/queryOptions.d.ts +2 -2
  84. package/build/modern/queryOptions.js.map +1 -1
  85. package/build/modern/useBaseQuery.cjs +11 -5
  86. package/build/modern/useBaseQuery.cjs.map +1 -1
  87. package/build/modern/useBaseQuery.d.cts +1 -1
  88. package/build/modern/useBaseQuery.d.ts +1 -1
  89. package/build/modern/useBaseQuery.js +11 -5
  90. package/build/modern/useBaseQuery.js.map +1 -1
  91. package/build/modern/useInfiniteQuery.cjs.map +1 -1
  92. package/build/modern/useInfiniteQuery.d.cts +1 -1
  93. package/build/modern/useInfiniteQuery.d.ts +1 -1
  94. package/build/modern/useInfiniteQuery.js.map +1 -1
  95. package/build/modern/useIsFetching.d.cts +1 -1
  96. package/build/modern/useIsFetching.d.ts +1 -1
  97. package/build/modern/useMutation.d.cts +1 -1
  98. package/build/modern/useMutation.d.ts +1 -1
  99. package/build/modern/useMutationState.d.cts +1 -1
  100. package/build/modern/useMutationState.d.ts +1 -1
  101. package/build/modern/usePrefetchInfiniteQuery.d.cts +1 -1
  102. package/build/modern/usePrefetchInfiniteQuery.d.ts +1 -1
  103. package/build/modern/usePrefetchQuery.d.cts +1 -1
  104. package/build/modern/usePrefetchQuery.d.ts +1 -1
  105. package/build/modern/useQueries.cjs +1 -1
  106. package/build/modern/useQueries.cjs.map +1 -1
  107. package/build/modern/useQueries.d.cts +2 -2
  108. package/build/modern/useQueries.d.ts +2 -2
  109. package/build/modern/useQueries.js +1 -1
  110. package/build/modern/useQueries.js.map +1 -1
  111. package/build/modern/useQuery.cjs.map +1 -1
  112. package/build/modern/useQuery.d.cts +25 -4
  113. package/build/modern/useQuery.d.cts.map +1 -1
  114. package/build/modern/useQuery.d.ts +25 -4
  115. package/build/modern/useQuery.d.ts.map +1 -1
  116. package/build/modern/useQuery.js.map +1 -1
  117. package/build/modern/useQueryClient.d.cts +1 -1
  118. package/build/modern/useQueryClient.d.ts +1 -1
  119. package/build/modern/vueQueryPlugin.d.cts +1 -1
  120. package/build/modern/vueQueryPlugin.d.ts +1 -1
  121. package/package.json +2 -2
  122. package/src/index.ts +1 -0
  123. package/src/queryOptions.ts +23 -9
  124. package/src/useBaseQuery.ts +68 -8
  125. package/src/useInfiniteQuery.ts +6 -8
  126. package/src/useQueries.ts +7 -2
  127. package/src/useQuery.ts +22 -1
  128. package/build/legacy/infiniteQueryOptions-CN37iZvc.d.ts.map +0 -1
  129. package/build/legacy/infiniteQueryOptions-lJ_zR-As.d.cts.map +0 -1
  130. package/build/legacy/queryOptions-BuZEBLtg.d.cts.map +0 -1
  131. package/build/legacy/queryOptions-dXiBZnGk.d.ts.map +0 -1
  132. package/build/modern/infiniteQueryOptions-CN37iZvc.d.ts.map +0 -1
  133. package/build/modern/infiniteQueryOptions-lJ_zR-As.d.cts.map +0 -1
  134. package/build/modern/queryOptions-BuZEBLtg.d.cts.map +0 -1
  135. package/build/modern/queryOptions-dXiBZnGk.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useBaseQuery.cjs","names":["getCurrentScope","useQueryClient","computed","cloneDeepUnref","shallowReactive","reactive","shouldThrowError","watch","shallowReadonly","readonly","toRefs"],"sources":["../../src/useBaseQuery.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 { shouldThrowError } from '@tanstack/query-core'\nimport { useQueryClient } from './useQueryClient'\nimport { cloneDeepUnref, updateState } from './utils'\nimport type { Ref } from 'vue-demi'\nimport type {\n DefaultedQueryObserverOptions,\n QueryKey,\n QueryObserver,\n QueryObserverResult,\n} from '@tanstack/query-core'\nimport type { QueryClient } from './queryClient'\nimport type { UseQueryOptions } from './queryOptions'\nimport type { UseInfiniteQueryOptions } from './useInfiniteQuery'\nimport type { MaybeRefOrGetter } from './types'\n\n/**\n * The result of the query composables: every property of the observer result wrapped in a `Ref`, except\n * the `refetch`, `fetchNextPage`, and `fetchPreviousPage` functions, plus `suspense`.\n */\nexport type UseBaseQueryReturnType<\n TData,\n TError,\n TResult = QueryObserverResult<TData, TError>,\n> = {\n [K in keyof TResult]: K extends\n | 'fetchNextPage'\n | 'fetchPreviousPage'\n | 'refetch'\n ? TResult[K]\n : Ref<Readonly<TResult>[K]>\n} & {\n /**\n * Returns a promise for use with Vue's `Suspense` or `onServerPrefetch`. It fetches the query if it has no\n * data or its data is stale and resolves with the result once that fetch resolves (usually when the query\n * function finishes, but earlier after the first chunk of a streamed query or when data is set during the\n * fetch), or resolves immediately if the data is fresh. While the query is disabled, it waits until the query\n * is enabled. If the fetch fails, it resolves with the error result, unless `throwOnError` is (or returns)\n * `true`, in which case it rejects.\n */\n suspense: () => Promise<TResult>\n}\n\ntype UseQueryOptionsGeneric<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> =\n | UseQueryOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>\n | UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>\n\n/**\n * Base implementation shared by `useQuery` and `useInfiniteQuery`.\n * @param Observer - The observer class from query-core (`QueryObserver` or `InfiniteQueryObserver`).\n * @param options - A `ref`, plain value, or reactive getter resolving to the query options.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The query result as `ref`s, plus the `suspense` function.\n */\nexport function useBaseQuery<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n TPageParam,\n>(\n Observer: typeof QueryObserver,\n options: MaybeRefOrGetter<\n UseQueryOptionsGeneric<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey,\n TPageParam\n >\n >,\n queryClient?: QueryClient,\n): UseBaseQueryReturnType<TData, TError> {\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\n const defaultedOptions = computed(() => {\n let resolvedOptions = options\n if (typeof resolvedOptions === 'function') {\n resolvedOptions = resolvedOptions()\n }\n const clonedOptions = cloneDeepUnref(resolvedOptions as any)\n\n if (typeof clonedOptions.enabled === 'function') {\n clonedOptions.enabled = clonedOptions.enabled()\n }\n\n const defaulted: DefaultedQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n > = client.defaultQueryOptions(clonedOptions)\n\n defaulted._optimisticResults = client.isRestoring?.value\n ? 'isRestoring'\n : 'optimistic'\n\n return defaulted\n })\n\n const observer = new Observer(client, defaultedOptions.value)\n // @ts-expect-error\n const state = defaultedOptions.value.shallow\n ? shallowReactive(observer.getCurrentResult())\n : reactive(observer.getCurrentResult())\n\n let unsubscribe = () => {\n // noop\n }\n\n if (client.isRestoring) {\n watch(\n client.isRestoring,\n (isRestoring) => {\n if (!isRestoring) {\n unsubscribe()\n unsubscribe = observer.subscribe((result) => {\n updateState(state, result)\n })\n }\n },\n { immediate: true },\n )\n }\n\n const updater = () => {\n observer.setOptions(defaultedOptions.value)\n updateState(state, observer.getCurrentResult())\n }\n\n watch(defaultedOptions, updater)\n\n onScopeDispose(() => {\n unsubscribe()\n })\n\n // fix #5910\n const refetch = (...args: Parameters<(typeof state)['refetch']>) => {\n updater()\n return state.refetch(...args)\n }\n\n const suspense = () => {\n return new Promise<QueryObserverResult<TData, TError>>(\n (resolve, reject) => {\n let stopWatch = () => {\n // noop\n }\n const run = () => {\n if (defaultedOptions.value.enabled !== false) {\n // fix #6133\n observer.setOptions(defaultedOptions.value)\n const optimisticResult = observer.getOptimisticResult(\n defaultedOptions.value,\n )\n if (optimisticResult.isStale) {\n stopWatch()\n observer\n .fetchOptimistic(defaultedOptions.value)\n .then(resolve, (error: TError) => {\n if (\n shouldThrowError(defaultedOptions.value.throwOnError, [\n error,\n observer.getCurrentQuery(),\n ])\n ) {\n reject(error)\n } else {\n resolve(observer.getCurrentResult())\n }\n })\n } else {\n stopWatch()\n resolve(optimisticResult)\n }\n }\n }\n\n run()\n\n stopWatch = watch(defaultedOptions, run)\n },\n )\n }\n\n // Handle error boundary\n watch(\n () => state.error,\n (error) => {\n if (\n state.isError &&\n !state.isFetching &&\n shouldThrowError(defaultedOptions.value.throwOnError, [\n error as TError,\n observer.getCurrentQuery(),\n ])\n ) {\n throw error\n }\n },\n )\n\n // @ts-expect-error\n const readonlyState = defaultedOptions.value.shallow\n ? shallowReadonly(state)\n : readonly(state)\n\n const object: any = toRefs(readonlyState)\n for (const key in state) {\n if (typeof state[key as keyof typeof state] === 'function') {\n object[key] = state[key as keyof typeof state]\n }\n }\n\n object.suspense = suspense\n object.refetch = refetch\n\n return object as UseBaseQueryReturnType<TData, TError>\n}\n"],"mappings":";;;;;;;;;;;;;;AAwEA,SAAgB,aAQd,UACA,SAUA,aACuC;CACvC,IAAI,QAAQ,IAAI,aAAa,eACvB;MAAA,EAAA,GAACA,SAAAA,gBAAAA,CAAgB,GACnB,QAAQ,KACN,kKACF;CAAA;CAIJ,MAAM,SAAS,eAAeC,uBAAAA,eAAe;CAE7C,MAAM,oBAAA,GAAmBC,SAAAA,SAAAA,OAAe;EACtC,IAAI,kBAAkB;EACtB,IAAI,OAAO,oBAAoB,YAC7B,kBAAkB,gBAAgB;EAEpC,MAAM,gBAAgBC,cAAAA,eAAe,eAAsB;EAE3D,IAAI,OAAO,cAAc,YAAY,YACnC,cAAc,UAAU,cAAc,QAAQ;EAGhD,MAAM,YAMF,OAAO,oBAAoB,aAAa;EAE5C,UAAU,qBAAqB,OAAO,aAAa,QAC/C,gBACA;EAEJ,OAAO;CACT,CAAC;CAED,MAAM,WAAW,IAAI,SAAS,QAAQ,iBAAiB,KAAK;CAE5D,MAAM,QAAQ,iBAAiB,MAAM,WAAA,GACjCC,SAAAA,gBAAAA,CAAgB,SAAS,iBAAiB,CAAC,KAAA,GAC3CC,SAAAA,SAAAA,CAAS,SAAS,iBAAiB,CAAC;CAExC,IAAI,oBAAoB,CAExB;CAEA,IAAI,OAAO,aACT,CAAA,GAAA,SAAA,MAAA,CACE,OAAO,cACN,gBAAgB;EACf,IAAI,CAAC,aAAa;GAChB,YAAY;GACZ,cAAc,SAAS,WAAW,WAAW;IAC3C,cAAA,YAAY,OAAO,MAAM;GAC3B,CAAC;EACH;CACF,GACA,EAAE,WAAW,KAAK,CACpB;CAGF,MAAM,gBAAgB;EACpB,SAAS,WAAW,iBAAiB,KAAK;EAC1C,cAAA,YAAY,OAAO,SAAS,iBAAiB,CAAC;CAChD;CAEA,CAAA,GAAA,SAAA,MAAA,CAAM,kBAAkB,OAAO;CAE/B,CAAA,GAAA,SAAA,eAAA,OAAqB;EACnB,YAAY;CACd,CAAC;CAGD,MAAM,WAAW,GAAG,SAAgD;EAClE,QAAQ;EACR,OAAO,MAAM,QAAQ,GAAG,IAAI;CAC9B;CAEA,MAAM,iBAAiB;EACrB,OAAO,IAAI,SACR,SAAS,WAAW;GACnB,IAAI,kBAAkB,CAEtB;GACA,MAAM,YAAY;IAChB,IAAI,iBAAiB,MAAM,YAAY,OAAO;KAE5C,SAAS,WAAW,iBAAiB,KAAK;KAC1C,MAAM,mBAAmB,SAAS,oBAChC,iBAAiB,KACnB;KACA,IAAI,iBAAiB,SAAS;MAC5B,UAAU;MACV,SACG,gBAAgB,iBAAiB,KAAK,CAAC,CACvC,KAAK,UAAU,UAAkB;OAChC,KAAA,GACEC,qBAAAA,iBAAAA,CAAiB,iBAAiB,MAAM,cAAc,CACpD,OACA,SAAS,gBAAgB,CAC3B,CAAC,GAED,OAAO,KAAK;YAEZ,QAAQ,SAAS,iBAAiB,CAAC;MAEvC,CAAC;KACL,OAAO;MACL,UAAU;MACV,QAAQ,gBAAgB;KAC1B;IACF;GACF;GAEA,IAAI;GAEJ,aAAA,GAAYC,SAAAA,MAAAA,CAAM,kBAAkB,GAAG;EACzC,CACF;CACF;CAGA,CAAA,GAAA,SAAA,MAAA,OACQ,MAAM,QACX,UAAU;EACT,IACE,MAAM,WACN,CAAC,MAAM,eAAA,GACPD,qBAAAA,iBAAAA,CAAiB,iBAAiB,MAAM,cAAc,CACpD,OACA,SAAS,gBAAgB,CAC3B,CAAC,GAED,MAAM;CAEV,CACF;CAGA,MAAM,gBAAgB,iBAAiB,MAAM,WAAA,GACzCE,SAAAA,gBAAAA,CAAgB,KAAK,KAAA,GACrBC,SAAAA,SAAAA,CAAS,KAAK;CAElB,MAAM,UAAA,GAAcC,SAAAA,OAAAA,CAAO,aAAa;CACxC,KAAK,MAAM,OAAO,OAChB,IAAI,OAAO,MAAM,SAA+B,YAC9C,OAAO,OAAO,MAAM;CAIxB,OAAO,WAAW;CAClB,OAAO,UAAU;CAEjB,OAAO;AACT"}
1
+ {"version":3,"file":"useBaseQuery.cjs","names":["getCurrentScope","useQueryClient","computed","cloneDeepUnref","shallowReactive","reactive","shouldThrowError","watch","shallowReadonly","readonly","toRefs"],"sources":["../../src/useBaseQuery.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 { shouldThrowError } from '@tanstack/query-core'\nimport { useQueryClient } from './useQueryClient'\nimport { cloneDeepUnref, updateState } from './utils'\nimport type { Ref } from 'vue-demi'\nimport type {\n DefaultedQueryObserverOptions,\n QueryKey,\n QueryObserver,\n QueryObserverResult,\n} from '@tanstack/query-core'\nimport type { QueryClient } from './queryClient'\nimport type { UseQueryOptions } from './queryOptions'\nimport type { UseInfiniteQueryOptions } from './useInfiniteQuery'\nimport type { MaybeRefOrGetter } from './types'\n\n/**\n * Readonly view of a union that stays a union. A single `Readonly<Union>` collapses the members, which\n * drops the `status` / `isSuccess` / `isPending` discriminants.\n */\ntype ReadonlyQueryState<T> = T extends any\n ? { readonly [K in keyof T]: T[K] }\n : never\n\n/**\n * The result of the query composables: every property of the observer result wrapped in a `Ref`, except\n * the `refetch`, `fetchNextPage`, and `fetchPreviousPage` functions, plus `suspense` and `state`.\n */\nexport type UseBaseQueryReturnType<\n TData,\n TError,\n TResult = QueryObserverResult<TData, TError>,\n> = {\n [K in keyof TResult]: K extends\n | 'fetchNextPage'\n | 'fetchPreviousPage'\n | 'refetch'\n ? TResult[K]\n : Ref<Readonly<TResult>[K]>\n} & {\n /**\n * Returns a promise for use with Vue's `Suspense` or `onServerPrefetch`. It fetches the query if it has no\n * data or its data is stale and resolves with the result once that fetch resolves (usually when the query\n * function finishes, but earlier after the first chunk of a streamed query or when data is set during the\n * fetch), or resolves immediately if the data is fresh. While the query is disabled, it waits until the query\n * is enabled. If the fetch fails, it resolves with the error result, unless `throwOnError` is (or returns)\n * `true`, in which case it rejects.\n */\n suspense: () => Promise<TResult>\n /**\n * The query result as one readonly reactive object. `data`, `error`, `status`, `isPending`, and the other\n * fields are plain values — read `state.data`, not `state.data.value`.\n *\n * The object is a discriminated union, so a check on `status`, `isSuccess`, `isPending`, or `isError`\n * narrows the other fields. When `status` is `'success'` (or `isSuccess` is `true`), `data` is `TData`.\n * When `status` is `'pending'` (or `isPending` is `true`), `data` is `undefined` and `error` is `null`.\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const { state } = useQuery({\n * queryKey: ['post'],\n * queryFn: fetchPost,\n * })\n *\n * if (state.status === 'success') {\n * // `state.data` is `Post`, not `Post | undefined`\n * console.log(state.data.title)\n * }\n * </script>\n *\n * <template>\n * <span v-if=\"state.status === 'pending'\">Loading...</span>\n * <span v-else-if=\"state.status === 'error'\">Error: {{ state.error.message }}</span>\n * <h1 v-else>{{ state.data.title }}</h1>\n * </template>\n * ```\n */\n state: ReadonlyQueryState<TResult>\n}\n\ntype UseQueryOptionsGeneric<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> =\n | UseQueryOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>\n | UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>\n\n/**\n * Base implementation shared by `useQuery` and `useInfiniteQuery`.\n * @param Observer - The observer class from query-core (`QueryObserver` or `InfiniteQueryObserver`).\n * @param options - A `ref`, plain value, or reactive getter resolving to the query options.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The query result as `ref`s, plus the `suspense` function.\n */\nexport function useBaseQuery<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n TPageParam,\n>(\n Observer: typeof QueryObserver,\n options: MaybeRefOrGetter<\n UseQueryOptionsGeneric<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey,\n TPageParam\n >\n >,\n queryClient?: QueryClient,\n): UseBaseQueryReturnType<TData, TError> {\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\n const defaultedOptions = computed(() => {\n let resolvedOptions = options\n if (typeof resolvedOptions === 'function') {\n resolvedOptions = resolvedOptions()\n }\n const clonedOptions = cloneDeepUnref(resolvedOptions as any)\n\n // A zero-arg function is a Vue getter and must run here so its refs are tracked.\n // `(query) => boolean` is query-core's callback and is left for core to call.\n if (\n typeof clonedOptions.enabled === 'function' &&\n clonedOptions.enabled.length === 0\n ) {\n clonedOptions.enabled = clonedOptions.enabled()\n }\n\n const defaulted: DefaultedQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n > = client.defaultQueryOptions(clonedOptions)\n\n defaulted._optimisticResults = client.isRestoring?.value\n ? 'isRestoring'\n : 'optimistic'\n\n return defaulted\n })\n\n const observer = new Observer(client, defaultedOptions.value)\n // @ts-expect-error\n const state = defaultedOptions.value.shallow\n ? shallowReactive(observer.getCurrentResult())\n : reactive(observer.getCurrentResult())\n\n let unsubscribe = () => {\n // noop\n }\n\n // Replaced below with the wrapper. Declared here so the subscriber can put it\n // back after `updateState` copies the observer's own `refetch` onto `state`.\n let refetch: (typeof state)['refetch'] = (...args) =>\n observer.refetch(...args)\n\n if (client.isRestoring) {\n watch(\n client.isRestoring,\n (isRestoring) => {\n if (!isRestoring) {\n unsubscribe()\n unsubscribe = observer.subscribe((result) => {\n updateState(state, result)\n state.refetch = refetch\n })\n }\n },\n { immediate: true },\n )\n }\n\n const updater = () => {\n observer.setOptions(defaultedOptions.value)\n updateState(state, observer.getCurrentResult())\n state.refetch = refetch\n }\n\n watch(defaultedOptions, updater)\n\n onScopeDispose(() => {\n unsubscribe()\n })\n\n // fix #5910. Call `observer.refetch`: `state.refetch` is this wrapper, so\n // calling it would recurse.\n refetch = (...args) => {\n updater()\n return observer.refetch(...args)\n }\n state.refetch = refetch\n\n const suspense = () => {\n return new Promise<QueryObserverResult<TData, TError>>(\n (resolve, reject) => {\n let stopWatch = () => {\n // noop\n }\n const run = () => {\n // Apply the latest options before resolving `enabled`, so a query callback sees the current query.\n // fix #6133\n observer.setOptions(defaultedOptions.value)\n const { enabled } = defaultedOptions.value\n if (\n (typeof enabled === 'function'\n ? enabled(observer.getCurrentQuery())\n : enabled) !== false\n ) {\n const optimisticResult = observer.getOptimisticResult(\n defaultedOptions.value,\n )\n if (optimisticResult.isStale) {\n stopWatch()\n observer\n .fetchOptimistic(defaultedOptions.value)\n .then(resolve, (error: TError) => {\n if (\n shouldThrowError(defaultedOptions.value.throwOnError, [\n error,\n observer.getCurrentQuery(),\n ])\n ) {\n reject(error)\n } else {\n resolve(observer.getCurrentResult())\n }\n })\n } else {\n stopWatch()\n resolve(optimisticResult)\n }\n }\n }\n\n run()\n\n stopWatch = watch(defaultedOptions, run)\n },\n )\n }\n\n // Handle error boundary\n watch(\n () => state.error,\n (error) => {\n if (\n state.isError &&\n !state.isFetching &&\n shouldThrowError(defaultedOptions.value.throwOnError, [\n error as TError,\n observer.getCurrentQuery(),\n ])\n ) {\n throw error\n }\n },\n )\n\n // @ts-expect-error\n const readonlyState = defaultedOptions.value.shallow\n ? shallowReadonly(state)\n : readonly(state)\n\n const object: any = toRefs(readonlyState)\n for (const key in state) {\n if (typeof state[key as keyof typeof state] === 'function') {\n object[key] = state[key as keyof typeof state]\n }\n }\n\n object.suspense = suspense\n object.refetch = refetch\n object.state = readonlyState\n\n return object as UseBaseQueryReturnType<TData, TError>\n}\n"],"mappings":";;;;;;;;;;;;;;AA+GA,SAAgB,aAQd,UACA,SAUA,aACuC;CACvC,IAAI,QAAQ,IAAI,aAAa,eACvB;MAAA,EAAA,GAACA,SAAAA,gBAAAA,CAAgB,GACnB,QAAQ,KACN,kKACF;CAAA;CAIJ,MAAM,SAAS,eAAeC,uBAAAA,eAAe;CAE7C,MAAM,oBAAA,GAAmBC,SAAAA,SAAAA,OAAe;EACtC,IAAI,kBAAkB;EACtB,IAAI,OAAO,oBAAoB,YAC7B,kBAAkB,gBAAgB;EAEpC,MAAM,gBAAgBC,cAAAA,eAAe,eAAsB;EAI3D,IACE,OAAO,cAAc,YAAY,cACjC,cAAc,QAAQ,WAAW,GAEjC,cAAc,UAAU,cAAc,QAAQ;EAGhD,MAAM,YAMF,OAAO,oBAAoB,aAAa;EAE5C,UAAU,qBAAqB,OAAO,aAAa,QAC/C,gBACA;EAEJ,OAAO;CACT,CAAC;CAED,MAAM,WAAW,IAAI,SAAS,QAAQ,iBAAiB,KAAK;CAE5D,MAAM,QAAQ,iBAAiB,MAAM,WAAA,GACjCC,SAAAA,gBAAAA,CAAgB,SAAS,iBAAiB,CAAC,KAAA,GAC3CC,SAAAA,SAAAA,CAAS,SAAS,iBAAiB,CAAC;CAExC,IAAI,oBAAoB,CAExB;CAIA,IAAI,WAAsC,GAAG,SAC3C,SAAS,QAAQ,GAAG,IAAI;CAE1B,IAAI,OAAO,aACT,CAAA,GAAA,SAAA,MAAA,CACE,OAAO,cACN,gBAAgB;EACf,IAAI,CAAC,aAAa;GAChB,YAAY;GACZ,cAAc,SAAS,WAAW,WAAW;IAC3C,cAAA,YAAY,OAAO,MAAM;IACzB,MAAM,UAAU;GAClB,CAAC;EACH;CACF,GACA,EAAE,WAAW,KAAK,CACpB;CAGF,MAAM,gBAAgB;EACpB,SAAS,WAAW,iBAAiB,KAAK;EAC1C,cAAA,YAAY,OAAO,SAAS,iBAAiB,CAAC;EAC9C,MAAM,UAAU;CAClB;CAEA,CAAA,GAAA,SAAA,MAAA,CAAM,kBAAkB,OAAO;CAE/B,CAAA,GAAA,SAAA,eAAA,OAAqB;EACnB,YAAY;CACd,CAAC;CAID,WAAW,GAAG,SAAS;EACrB,QAAQ;EACR,OAAO,SAAS,QAAQ,GAAG,IAAI;CACjC;CACA,MAAM,UAAU;CAEhB,MAAM,iBAAiB;EACrB,OAAO,IAAI,SACR,SAAS,WAAW;GACnB,IAAI,kBAAkB,CAEtB;GACA,MAAM,YAAY;IAGhB,SAAS,WAAW,iBAAiB,KAAK;IAC1C,MAAM,EAAE,YAAY,iBAAiB;IACrC,KACG,OAAO,YAAY,aAChB,QAAQ,SAAS,gBAAgB,CAAC,IAClC,aAAa,OACjB;KACA,MAAM,mBAAmB,SAAS,oBAChC,iBAAiB,KACnB;KACA,IAAI,iBAAiB,SAAS;MAC5B,UAAU;MACV,SACG,gBAAgB,iBAAiB,KAAK,CAAC,CACvC,KAAK,UAAU,UAAkB;OAChC,KAAA,GACEC,qBAAAA,iBAAAA,CAAiB,iBAAiB,MAAM,cAAc,CACpD,OACA,SAAS,gBAAgB,CAC3B,CAAC,GAED,OAAO,KAAK;YAEZ,QAAQ,SAAS,iBAAiB,CAAC;MAEvC,CAAC;KACL,OAAO;MACL,UAAU;MACV,QAAQ,gBAAgB;KAC1B;IACF;GACF;GAEA,IAAI;GAEJ,aAAA,GAAYC,SAAAA,MAAAA,CAAM,kBAAkB,GAAG;EACzC,CACF;CACF;CAGA,CAAA,GAAA,SAAA,MAAA,OACQ,MAAM,QACX,UAAU;EACT,IACE,MAAM,WACN,CAAC,MAAM,eAAA,GACPD,qBAAAA,iBAAAA,CAAiB,iBAAiB,MAAM,cAAc,CACpD,OACA,SAAS,gBAAgB,CAC3B,CAAC,GAED,MAAM;CAEV,CACF;CAGA,MAAM,gBAAgB,iBAAiB,MAAM,WAAA,GACzCE,SAAAA,gBAAAA,CAAgB,KAAK,KAAA,GACrBC,SAAAA,SAAAA,CAAS,KAAK;CAElB,MAAM,UAAA,GAAcC,SAAAA,OAAAA,CAAO,aAAa;CACxC,KAAK,MAAM,OAAO,OAChB,IAAI,OAAO,MAAM,SAA+B,YAC9C,OAAO,OAAO,MAAM;CAIxB,OAAO,WAAW;CAClB,OAAO,UAAU;CACjB,OAAO,QAAQ;CAEf,OAAO;AACT"}
@@ -1,2 +1,2 @@
1
- import { c as UseBaseQueryReturnType, l as useBaseQuery } from "./infiniteQueryOptions-lJ_zR-As.cjs";
1
+ import { c as UseBaseQueryReturnType, l as useBaseQuery } from "./infiniteQueryOptions-BSwO8rvy.cjs";
2
2
  export { UseBaseQueryReturnType, useBaseQuery };
@@ -1,2 +1,2 @@
1
- import { c as UseBaseQueryReturnType, l as useBaseQuery } from "./infiniteQueryOptions-CN37iZvc.js";
1
+ import { c as UseBaseQueryReturnType, l as useBaseQuery } from "./infiniteQueryOptions-Bq8UQFvj.js";
2
2
  export { UseBaseQueryReturnType, useBaseQuery };
@@ -20,7 +20,7 @@ function useBaseQuery(Observer, options, queryClient) {
20
20
  let resolvedOptions = options;
21
21
  if (typeof resolvedOptions === "function") resolvedOptions = resolvedOptions();
22
22
  const clonedOptions = cloneDeepUnref(resolvedOptions);
23
- if (typeof clonedOptions.enabled === "function") clonedOptions.enabled = clonedOptions.enabled();
23
+ if (typeof clonedOptions.enabled === "function" && clonedOptions.enabled.length === 0) clonedOptions.enabled = clonedOptions.enabled();
24
24
  const defaulted = client.defaultQueryOptions(clonedOptions);
25
25
  defaulted._optimisticResults = client.isRestoring?.value ? "isRestoring" : "optimistic";
26
26
  return defaulted;
@@ -28,32 +28,37 @@ function useBaseQuery(Observer, options, queryClient) {
28
28
  const observer = new Observer(client, defaultedOptions.value);
29
29
  const state = defaultedOptions.value.shallow ? shallowReactive(observer.getCurrentResult()) : reactive(observer.getCurrentResult());
30
30
  let unsubscribe = () => {};
31
+ let refetch = (...args) => observer.refetch(...args);
31
32
  if (client.isRestoring) watch(client.isRestoring, (isRestoring) => {
32
33
  if (!isRestoring) {
33
34
  unsubscribe();
34
35
  unsubscribe = observer.subscribe((result) => {
35
36
  updateState(state, result);
37
+ state.refetch = refetch;
36
38
  });
37
39
  }
38
40
  }, { immediate: true });
39
41
  const updater = () => {
40
42
  observer.setOptions(defaultedOptions.value);
41
43
  updateState(state, observer.getCurrentResult());
44
+ state.refetch = refetch;
42
45
  };
43
46
  watch(defaultedOptions, updater);
44
47
  onScopeDispose(() => {
45
48
  unsubscribe();
46
49
  });
47
- const refetch = (...args) => {
50
+ refetch = (...args) => {
48
51
  updater();
49
- return state.refetch(...args);
52
+ return observer.refetch(...args);
50
53
  };
54
+ state.refetch = refetch;
51
55
  const suspense = () => {
52
56
  return new Promise((resolve, reject) => {
53
57
  let stopWatch = () => {};
54
58
  const run = () => {
55
- if (defaultedOptions.value.enabled !== false) {
56
- observer.setOptions(defaultedOptions.value);
59
+ observer.setOptions(defaultedOptions.value);
60
+ const { enabled } = defaultedOptions.value;
61
+ if ((typeof enabled === "function" ? enabled(observer.getCurrentQuery()) : enabled) !== false) {
57
62
  const optimisticResult = observer.getOptimisticResult(defaultedOptions.value);
58
63
  if (optimisticResult.isStale) {
59
64
  stopWatch();
@@ -79,6 +84,7 @@ function useBaseQuery(Observer, options, queryClient) {
79
84
  for (const key in state) if (typeof state[key] === "function") object[key] = state[key];
80
85
  object.suspense = suspense;
81
86
  object.refetch = refetch;
87
+ object.state = readonlyState;
82
88
  return object;
83
89
  }
84
90
  export { useBaseQuery };
@@ -1 +1 @@
1
- {"version":3,"file":"useBaseQuery.js","names":[],"sources":["../../src/useBaseQuery.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 { shouldThrowError } from '@tanstack/query-core'\nimport { useQueryClient } from './useQueryClient'\nimport { cloneDeepUnref, updateState } from './utils'\nimport type { Ref } from 'vue-demi'\nimport type {\n DefaultedQueryObserverOptions,\n QueryKey,\n QueryObserver,\n QueryObserverResult,\n} from '@tanstack/query-core'\nimport type { QueryClient } from './queryClient'\nimport type { UseQueryOptions } from './queryOptions'\nimport type { UseInfiniteQueryOptions } from './useInfiniteQuery'\nimport type { MaybeRefOrGetter } from './types'\n\n/**\n * The result of the query composables: every property of the observer result wrapped in a `Ref`, except\n * the `refetch`, `fetchNextPage`, and `fetchPreviousPage` functions, plus `suspense`.\n */\nexport type UseBaseQueryReturnType<\n TData,\n TError,\n TResult = QueryObserverResult<TData, TError>,\n> = {\n [K in keyof TResult]: K extends\n | 'fetchNextPage'\n | 'fetchPreviousPage'\n | 'refetch'\n ? TResult[K]\n : Ref<Readonly<TResult>[K]>\n} & {\n /**\n * Returns a promise for use with Vue's `Suspense` or `onServerPrefetch`. It fetches the query if it has no\n * data or its data is stale and resolves with the result once that fetch resolves (usually when the query\n * function finishes, but earlier after the first chunk of a streamed query or when data is set during the\n * fetch), or resolves immediately if the data is fresh. While the query is disabled, it waits until the query\n * is enabled. If the fetch fails, it resolves with the error result, unless `throwOnError` is (or returns)\n * `true`, in which case it rejects.\n */\n suspense: () => Promise<TResult>\n}\n\ntype UseQueryOptionsGeneric<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> =\n | UseQueryOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>\n | UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>\n\n/**\n * Base implementation shared by `useQuery` and `useInfiniteQuery`.\n * @param Observer - The observer class from query-core (`QueryObserver` or `InfiniteQueryObserver`).\n * @param options - A `ref`, plain value, or reactive getter resolving to the query options.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The query result as `ref`s, plus the `suspense` function.\n */\nexport function useBaseQuery<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n TPageParam,\n>(\n Observer: typeof QueryObserver,\n options: MaybeRefOrGetter<\n UseQueryOptionsGeneric<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey,\n TPageParam\n >\n >,\n queryClient?: QueryClient,\n): UseBaseQueryReturnType<TData, TError> {\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\n const defaultedOptions = computed(() => {\n let resolvedOptions = options\n if (typeof resolvedOptions === 'function') {\n resolvedOptions = resolvedOptions()\n }\n const clonedOptions = cloneDeepUnref(resolvedOptions as any)\n\n if (typeof clonedOptions.enabled === 'function') {\n clonedOptions.enabled = clonedOptions.enabled()\n }\n\n const defaulted: DefaultedQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n > = client.defaultQueryOptions(clonedOptions)\n\n defaulted._optimisticResults = client.isRestoring?.value\n ? 'isRestoring'\n : 'optimistic'\n\n return defaulted\n })\n\n const observer = new Observer(client, defaultedOptions.value)\n // @ts-expect-error\n const state = defaultedOptions.value.shallow\n ? shallowReactive(observer.getCurrentResult())\n : reactive(observer.getCurrentResult())\n\n let unsubscribe = () => {\n // noop\n }\n\n if (client.isRestoring) {\n watch(\n client.isRestoring,\n (isRestoring) => {\n if (!isRestoring) {\n unsubscribe()\n unsubscribe = observer.subscribe((result) => {\n updateState(state, result)\n })\n }\n },\n { immediate: true },\n )\n }\n\n const updater = () => {\n observer.setOptions(defaultedOptions.value)\n updateState(state, observer.getCurrentResult())\n }\n\n watch(defaultedOptions, updater)\n\n onScopeDispose(() => {\n unsubscribe()\n })\n\n // fix #5910\n const refetch = (...args: Parameters<(typeof state)['refetch']>) => {\n updater()\n return state.refetch(...args)\n }\n\n const suspense = () => {\n return new Promise<QueryObserverResult<TData, TError>>(\n (resolve, reject) => {\n let stopWatch = () => {\n // noop\n }\n const run = () => {\n if (defaultedOptions.value.enabled !== false) {\n // fix #6133\n observer.setOptions(defaultedOptions.value)\n const optimisticResult = observer.getOptimisticResult(\n defaultedOptions.value,\n )\n if (optimisticResult.isStale) {\n stopWatch()\n observer\n .fetchOptimistic(defaultedOptions.value)\n .then(resolve, (error: TError) => {\n if (\n shouldThrowError(defaultedOptions.value.throwOnError, [\n error,\n observer.getCurrentQuery(),\n ])\n ) {\n reject(error)\n } else {\n resolve(observer.getCurrentResult())\n }\n })\n } else {\n stopWatch()\n resolve(optimisticResult)\n }\n }\n }\n\n run()\n\n stopWatch = watch(defaultedOptions, run)\n },\n )\n }\n\n // Handle error boundary\n watch(\n () => state.error,\n (error) => {\n if (\n state.isError &&\n !state.isFetching &&\n shouldThrowError(defaultedOptions.value.throwOnError, [\n error as TError,\n observer.getCurrentQuery(),\n ])\n ) {\n throw error\n }\n },\n )\n\n // @ts-expect-error\n const readonlyState = defaultedOptions.value.shallow\n ? shallowReadonly(state)\n : readonly(state)\n\n const object: any = toRefs(readonlyState)\n for (const key in state) {\n if (typeof state[key as keyof typeof state] === 'function') {\n object[key] = state[key as keyof typeof state]\n }\n }\n\n object.suspense = suspense\n object.refetch = refetch\n\n return object as UseBaseQueryReturnType<TData, TError>\n}\n"],"mappings":";;;;;;;;;;;;;AAwEA,SAAgB,aAQd,UACA,SAUA,aACuC;CACvC,IAAI,QAAQ,IAAI,aAAa,eACvB;MAAA,CAAC,gBAAgB,GACnB,QAAQ,KACN,kKACF;CAAA;CAIJ,MAAM,SAAS,eAAe,eAAe;CAE7C,MAAM,mBAAmB,eAAe;EACtC,IAAI,kBAAkB;EACtB,IAAI,OAAO,oBAAoB,YAC7B,kBAAkB,gBAAgB;EAEpC,MAAM,gBAAgB,eAAe,eAAsB;EAE3D,IAAI,OAAO,cAAc,YAAY,YACnC,cAAc,UAAU,cAAc,QAAQ;EAGhD,MAAM,YAMF,OAAO,oBAAoB,aAAa;EAE5C,UAAU,qBAAqB,OAAO,aAAa,QAC/C,gBACA;EAEJ,OAAO;CACT,CAAC;CAED,MAAM,WAAW,IAAI,SAAS,QAAQ,iBAAiB,KAAK;CAE5D,MAAM,QAAQ,iBAAiB,MAAM,UACjC,gBAAgB,SAAS,iBAAiB,CAAC,IAC3C,SAAS,SAAS,iBAAiB,CAAC;CAExC,IAAI,oBAAoB,CAExB;CAEA,IAAI,OAAO,aACT,MACE,OAAO,cACN,gBAAgB;EACf,IAAI,CAAC,aAAa;GAChB,YAAY;GACZ,cAAc,SAAS,WAAW,WAAW;IAC3C,YAAY,OAAO,MAAM;GAC3B,CAAC;EACH;CACF,GACA,EAAE,WAAW,KAAK,CACpB;CAGF,MAAM,gBAAgB;EACpB,SAAS,WAAW,iBAAiB,KAAK;EAC1C,YAAY,OAAO,SAAS,iBAAiB,CAAC;CAChD;CAEA,MAAM,kBAAkB,OAAO;CAE/B,qBAAqB;EACnB,YAAY;CACd,CAAC;CAGD,MAAM,WAAW,GAAG,SAAgD;EAClE,QAAQ;EACR,OAAO,MAAM,QAAQ,GAAG,IAAI;CAC9B;CAEA,MAAM,iBAAiB;EACrB,OAAO,IAAI,SACR,SAAS,WAAW;GACnB,IAAI,kBAAkB,CAEtB;GACA,MAAM,YAAY;IAChB,IAAI,iBAAiB,MAAM,YAAY,OAAO;KAE5C,SAAS,WAAW,iBAAiB,KAAK;KAC1C,MAAM,mBAAmB,SAAS,oBAChC,iBAAiB,KACnB;KACA,IAAI,iBAAiB,SAAS;MAC5B,UAAU;MACV,SACG,gBAAgB,iBAAiB,KAAK,CAAC,CACvC,KAAK,UAAU,UAAkB;OAChC,IACE,iBAAiB,iBAAiB,MAAM,cAAc,CACpD,OACA,SAAS,gBAAgB,CAC3B,CAAC,GAED,OAAO,KAAK;YAEZ,QAAQ,SAAS,iBAAiB,CAAC;MAEvC,CAAC;KACL,OAAO;MACL,UAAU;MACV,QAAQ,gBAAgB;KAC1B;IACF;GACF;GAEA,IAAI;GAEJ,YAAY,MAAM,kBAAkB,GAAG;EACzC,CACF;CACF;CAGA,YACQ,MAAM,QACX,UAAU;EACT,IACE,MAAM,WACN,CAAC,MAAM,cACP,iBAAiB,iBAAiB,MAAM,cAAc,CACpD,OACA,SAAS,gBAAgB,CAC3B,CAAC,GAED,MAAM;CAEV,CACF;CAGA,MAAM,gBAAgB,iBAAiB,MAAM,UACzC,gBAAgB,KAAK,IACrB,SAAS,KAAK;CAElB,MAAM,SAAc,OAAO,aAAa;CACxC,KAAK,MAAM,OAAO,OAChB,IAAI,OAAO,MAAM,SAA+B,YAC9C,OAAO,OAAO,MAAM;CAIxB,OAAO,WAAW;CAClB,OAAO,UAAU;CAEjB,OAAO;AACT"}
1
+ {"version":3,"file":"useBaseQuery.js","names":[],"sources":["../../src/useBaseQuery.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 { shouldThrowError } from '@tanstack/query-core'\nimport { useQueryClient } from './useQueryClient'\nimport { cloneDeepUnref, updateState } from './utils'\nimport type { Ref } from 'vue-demi'\nimport type {\n DefaultedQueryObserverOptions,\n QueryKey,\n QueryObserver,\n QueryObserverResult,\n} from '@tanstack/query-core'\nimport type { QueryClient } from './queryClient'\nimport type { UseQueryOptions } from './queryOptions'\nimport type { UseInfiniteQueryOptions } from './useInfiniteQuery'\nimport type { MaybeRefOrGetter } from './types'\n\n/**\n * Readonly view of a union that stays a union. A single `Readonly<Union>` collapses the members, which\n * drops the `status` / `isSuccess` / `isPending` discriminants.\n */\ntype ReadonlyQueryState<T> = T extends any\n ? { readonly [K in keyof T]: T[K] }\n : never\n\n/**\n * The result of the query composables: every property of the observer result wrapped in a `Ref`, except\n * the `refetch`, `fetchNextPage`, and `fetchPreviousPage` functions, plus `suspense` and `state`.\n */\nexport type UseBaseQueryReturnType<\n TData,\n TError,\n TResult = QueryObserverResult<TData, TError>,\n> = {\n [K in keyof TResult]: K extends\n | 'fetchNextPage'\n | 'fetchPreviousPage'\n | 'refetch'\n ? TResult[K]\n : Ref<Readonly<TResult>[K]>\n} & {\n /**\n * Returns a promise for use with Vue's `Suspense` or `onServerPrefetch`. It fetches the query if it has no\n * data or its data is stale and resolves with the result once that fetch resolves (usually when the query\n * function finishes, but earlier after the first chunk of a streamed query or when data is set during the\n * fetch), or resolves immediately if the data is fresh. While the query is disabled, it waits until the query\n * is enabled. If the fetch fails, it resolves with the error result, unless `throwOnError` is (or returns)\n * `true`, in which case it rejects.\n */\n suspense: () => Promise<TResult>\n /**\n * The query result as one readonly reactive object. `data`, `error`, `status`, `isPending`, and the other\n * fields are plain values — read `state.data`, not `state.data.value`.\n *\n * The object is a discriminated union, so a check on `status`, `isSuccess`, `isPending`, or `isError`\n * narrows the other fields. When `status` is `'success'` (or `isSuccess` is `true`), `data` is `TData`.\n * When `status` is `'pending'` (or `isPending` is `true`), `data` is `undefined` and `error` is `null`.\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQuery } from '@tanstack/vue-query'\n *\n * const { state } = useQuery({\n * queryKey: ['post'],\n * queryFn: fetchPost,\n * })\n *\n * if (state.status === 'success') {\n * // `state.data` is `Post`, not `Post | undefined`\n * console.log(state.data.title)\n * }\n * </script>\n *\n * <template>\n * <span v-if=\"state.status === 'pending'\">Loading...</span>\n * <span v-else-if=\"state.status === 'error'\">Error: {{ state.error.message }}</span>\n * <h1 v-else>{{ state.data.title }}</h1>\n * </template>\n * ```\n */\n state: ReadonlyQueryState<TResult>\n}\n\ntype UseQueryOptionsGeneric<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> =\n | UseQueryOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>\n | UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>\n\n/**\n * Base implementation shared by `useQuery` and `useInfiniteQuery`.\n * @param Observer - The observer class from query-core (`QueryObserver` or `InfiniteQueryObserver`).\n * @param options - A `ref`, plain value, or reactive getter resolving to the query options.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The query result as `ref`s, plus the `suspense` function.\n */\nexport function useBaseQuery<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n TPageParam,\n>(\n Observer: typeof QueryObserver,\n options: MaybeRefOrGetter<\n UseQueryOptionsGeneric<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey,\n TPageParam\n >\n >,\n queryClient?: QueryClient,\n): UseBaseQueryReturnType<TData, TError> {\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\n const defaultedOptions = computed(() => {\n let resolvedOptions = options\n if (typeof resolvedOptions === 'function') {\n resolvedOptions = resolvedOptions()\n }\n const clonedOptions = cloneDeepUnref(resolvedOptions as any)\n\n // A zero-arg function is a Vue getter and must run here so its refs are tracked.\n // `(query) => boolean` is query-core's callback and is left for core to call.\n if (\n typeof clonedOptions.enabled === 'function' &&\n clonedOptions.enabled.length === 0\n ) {\n clonedOptions.enabled = clonedOptions.enabled()\n }\n\n const defaulted: DefaultedQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n > = client.defaultQueryOptions(clonedOptions)\n\n defaulted._optimisticResults = client.isRestoring?.value\n ? 'isRestoring'\n : 'optimistic'\n\n return defaulted\n })\n\n const observer = new Observer(client, defaultedOptions.value)\n // @ts-expect-error\n const state = defaultedOptions.value.shallow\n ? shallowReactive(observer.getCurrentResult())\n : reactive(observer.getCurrentResult())\n\n let unsubscribe = () => {\n // noop\n }\n\n // Replaced below with the wrapper. Declared here so the subscriber can put it\n // back after `updateState` copies the observer's own `refetch` onto `state`.\n let refetch: (typeof state)['refetch'] = (...args) =>\n observer.refetch(...args)\n\n if (client.isRestoring) {\n watch(\n client.isRestoring,\n (isRestoring) => {\n if (!isRestoring) {\n unsubscribe()\n unsubscribe = observer.subscribe((result) => {\n updateState(state, result)\n state.refetch = refetch\n })\n }\n },\n { immediate: true },\n )\n }\n\n const updater = () => {\n observer.setOptions(defaultedOptions.value)\n updateState(state, observer.getCurrentResult())\n state.refetch = refetch\n }\n\n watch(defaultedOptions, updater)\n\n onScopeDispose(() => {\n unsubscribe()\n })\n\n // fix #5910. Call `observer.refetch`: `state.refetch` is this wrapper, so\n // calling it would recurse.\n refetch = (...args) => {\n updater()\n return observer.refetch(...args)\n }\n state.refetch = refetch\n\n const suspense = () => {\n return new Promise<QueryObserverResult<TData, TError>>(\n (resolve, reject) => {\n let stopWatch = () => {\n // noop\n }\n const run = () => {\n // Apply the latest options before resolving `enabled`, so a query callback sees the current query.\n // fix #6133\n observer.setOptions(defaultedOptions.value)\n const { enabled } = defaultedOptions.value\n if (\n (typeof enabled === 'function'\n ? enabled(observer.getCurrentQuery())\n : enabled) !== false\n ) {\n const optimisticResult = observer.getOptimisticResult(\n defaultedOptions.value,\n )\n if (optimisticResult.isStale) {\n stopWatch()\n observer\n .fetchOptimistic(defaultedOptions.value)\n .then(resolve, (error: TError) => {\n if (\n shouldThrowError(defaultedOptions.value.throwOnError, [\n error,\n observer.getCurrentQuery(),\n ])\n ) {\n reject(error)\n } else {\n resolve(observer.getCurrentResult())\n }\n })\n } else {\n stopWatch()\n resolve(optimisticResult)\n }\n }\n }\n\n run()\n\n stopWatch = watch(defaultedOptions, run)\n },\n )\n }\n\n // Handle error boundary\n watch(\n () => state.error,\n (error) => {\n if (\n state.isError &&\n !state.isFetching &&\n shouldThrowError(defaultedOptions.value.throwOnError, [\n error as TError,\n observer.getCurrentQuery(),\n ])\n ) {\n throw error\n }\n },\n )\n\n // @ts-expect-error\n const readonlyState = defaultedOptions.value.shallow\n ? shallowReadonly(state)\n : readonly(state)\n\n const object: any = toRefs(readonlyState)\n for (const key in state) {\n if (typeof state[key as keyof typeof state] === 'function') {\n object[key] = state[key as keyof typeof state]\n }\n }\n\n object.suspense = suspense\n object.refetch = refetch\n object.state = readonlyState\n\n return object as UseBaseQueryReturnType<TData, TError>\n}\n"],"mappings":";;;;;;;;;;;;;AA+GA,SAAgB,aAQd,UACA,SAUA,aACuC;CACvC,IAAI,QAAQ,IAAI,aAAa,eACvB;MAAA,CAAC,gBAAgB,GACnB,QAAQ,KACN,kKACF;CAAA;CAIJ,MAAM,SAAS,eAAe,eAAe;CAE7C,MAAM,mBAAmB,eAAe;EACtC,IAAI,kBAAkB;EACtB,IAAI,OAAO,oBAAoB,YAC7B,kBAAkB,gBAAgB;EAEpC,MAAM,gBAAgB,eAAe,eAAsB;EAI3D,IACE,OAAO,cAAc,YAAY,cACjC,cAAc,QAAQ,WAAW,GAEjC,cAAc,UAAU,cAAc,QAAQ;EAGhD,MAAM,YAMF,OAAO,oBAAoB,aAAa;EAE5C,UAAU,qBAAqB,OAAO,aAAa,QAC/C,gBACA;EAEJ,OAAO;CACT,CAAC;CAED,MAAM,WAAW,IAAI,SAAS,QAAQ,iBAAiB,KAAK;CAE5D,MAAM,QAAQ,iBAAiB,MAAM,UACjC,gBAAgB,SAAS,iBAAiB,CAAC,IAC3C,SAAS,SAAS,iBAAiB,CAAC;CAExC,IAAI,oBAAoB,CAExB;CAIA,IAAI,WAAsC,GAAG,SAC3C,SAAS,QAAQ,GAAG,IAAI;CAE1B,IAAI,OAAO,aACT,MACE,OAAO,cACN,gBAAgB;EACf,IAAI,CAAC,aAAa;GAChB,YAAY;GACZ,cAAc,SAAS,WAAW,WAAW;IAC3C,YAAY,OAAO,MAAM;IACzB,MAAM,UAAU;GAClB,CAAC;EACH;CACF,GACA,EAAE,WAAW,KAAK,CACpB;CAGF,MAAM,gBAAgB;EACpB,SAAS,WAAW,iBAAiB,KAAK;EAC1C,YAAY,OAAO,SAAS,iBAAiB,CAAC;EAC9C,MAAM,UAAU;CAClB;CAEA,MAAM,kBAAkB,OAAO;CAE/B,qBAAqB;EACnB,YAAY;CACd,CAAC;CAID,WAAW,GAAG,SAAS;EACrB,QAAQ;EACR,OAAO,SAAS,QAAQ,GAAG,IAAI;CACjC;CACA,MAAM,UAAU;CAEhB,MAAM,iBAAiB;EACrB,OAAO,IAAI,SACR,SAAS,WAAW;GACnB,IAAI,kBAAkB,CAEtB;GACA,MAAM,YAAY;IAGhB,SAAS,WAAW,iBAAiB,KAAK;IAC1C,MAAM,EAAE,YAAY,iBAAiB;IACrC,KACG,OAAO,YAAY,aAChB,QAAQ,SAAS,gBAAgB,CAAC,IAClC,aAAa,OACjB;KACA,MAAM,mBAAmB,SAAS,oBAChC,iBAAiB,KACnB;KACA,IAAI,iBAAiB,SAAS;MAC5B,UAAU;MACV,SACG,gBAAgB,iBAAiB,KAAK,CAAC,CACvC,KAAK,UAAU,UAAkB;OAChC,IACE,iBAAiB,iBAAiB,MAAM,cAAc,CACpD,OACA,SAAS,gBAAgB,CAC3B,CAAC,GAED,OAAO,KAAK;YAEZ,QAAQ,SAAS,iBAAiB,CAAC;MAEvC,CAAC;KACL,OAAO;MACL,UAAU;MACV,QAAQ,gBAAgB;KAC1B;IACF;GACF;GAEA,IAAI;GAEJ,YAAY,MAAM,kBAAkB,GAAG;EACzC,CACF;CACF;CAGA,YACQ,MAAM,QACX,UAAU;EACT,IACE,MAAM,WACN,CAAC,MAAM,cACP,iBAAiB,iBAAiB,MAAM,cAAc,CACpD,OACA,SAAS,gBAAgB,CAC3B,CAAC,GAED,MAAM;CAEV,CACF;CAGA,MAAM,gBAAgB,iBAAiB,MAAM,UACzC,gBAAgB,KAAK,IACrB,SAAS,KAAK;CAElB,MAAM,SAAc,OAAO,aAAa;CACxC,KAAK,MAAM,OAAO,OAChB,IAAI,OAAO,MAAM,SAA+B,YAC9C,OAAO,OAAO,MAAM;CAIxB,OAAO,WAAW;CAClB,OAAO,UAAU;CACjB,OAAO,QAAQ;CAEf,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"useInfiniteQuery.cjs","names":["useBaseQuery","InfiniteQueryObserver"],"sources":["../../src/useInfiniteQuery.ts"],"sourcesContent":["import { InfiniteQueryObserver } from '@tanstack/query-core'\nimport { useBaseQuery } from './useBaseQuery'\nimport type {\n DefinedInitialDataInfiniteOptions,\n UndefinedInitialDataInfiniteOptions,\n} from './infiniteQueryOptions'\nimport type {\n DefaultError,\n DefinedInfiniteQueryObserverResult,\n InfiniteData,\n InfiniteQueryObserverOptions,\n InfiniteQueryObserverResult,\n QueryKey,\n QueryObserver,\n} from '@tanstack/query-core'\n\nimport type { UseBaseQueryReturnType } from './useBaseQuery'\n\nimport type {\n DeepUnwrapRef,\n MaybeRef,\n MaybeRefDeep,\n MaybeRefOrGetter,\n ShallowOption,\n} from './types'\nimport type { QueryClient } from './queryClient'\n\n/**\n * The options accepted by `useInfiniteQuery`. Same as {@link InfiniteQueryObserverOptions} from\n * `@tanstack/query-core`, plus the `shallow` option. Each option except `shallow` can also be a `ref` (and\n * `enabled` a reactive getter).\n */\nexport type UseInfiniteQueryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = MaybeRef<\n {\n [\n Property in keyof InfiniteQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >\n ]: Property extends 'enabled'\n ? MaybeRefOrGetter<\n InfiniteQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n DeepUnwrapRef<TQueryKey>,\n TPageParam\n >[Property]\n >\n : MaybeRefDeep<\n InfiniteQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n DeepUnwrapRef<TQueryKey>,\n TPageParam\n >[Property]\n >\n } & ShallowOption\n>\n\n/**\n * The result of `useInfiniteQuery`: {@link InfiniteQueryObserverResult} from `@tanstack/query-core`, with\n * its properties wrapped in `Ref`s as in {@link UseBaseQueryReturnType}.\n */\nexport type UseInfiniteQueryReturnType<TData, TError> = UseBaseQueryReturnType<\n TData,\n TError,\n InfiniteQueryObserverResult<TData, TError>\n>\n\n/**\n * The result of `useInfiniteQuery` when `initialData` is set — `data` is never `undefined` (unless a `select`\n * changes `TData` to include `undefined`).\n */\nexport type UseInfiniteQueryDefinedReturnType<TData, TError> =\n UseBaseQueryReturnType<\n TData,\n TError,\n DefinedInfiniteQueryObserverResult<TData, TError>\n >\n\n/**\n * The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of\n * `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`.\n *\n * This overload is selected when `initialData` is known to be defined, so the resulting `data` is never\n * `undefined` (unless a `select` changes `TData` to include `undefined`).\n *\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` for the array itself, or `ref`s and reactive getters as\n * individual entries — the array itself can't be a bare getter.\n * @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to\n * `useInfiniteQuery`, with `initialData` known to be defined.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The same properties as `useQuery`, with the addition of `fetchNextPage`, `fetchPreviousPage`,\n * `hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and `isFetchingPreviousPage`. `data.value.pages` and\n * `data.value.pageParams` are also added, as long as a `select` doesn't change `TData` away from its default\n * `InfiniteData<TQueryFnData>` shape.\n * @remarks Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default\n * refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user\n * actions, or add conditions like `hasNextPage && !isFetching`.\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { useInfiniteQuery } from '@tanstack/vue-query'\n *\n * // `data` is never `undefined`, thanks to `initialData` — even if a refetch fails, so the\n * // list stays visible alongside the error.\n * const { data, isError, error } = useInfiniteQuery({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * initialData: { pages: [], pageParams: [] },\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <ul>\n * <template v-for=\"page in data.pages\" :key=\"page.nextId\">\n * <li v-for=\"project in page.projects\" :key=\"project.id\">{{ project.name }}</li>\n * </template>\n * </ul>\n * </template>\n * ```\n */\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: MaybeRefOrGetter<\n DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >\n >,\n queryClient?: QueryClient,\n): UseInfiniteQueryDefinedReturnType<TData, TError>\n\n/**\n * The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of\n * `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`.\n *\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` for the array itself, or `ref`s and reactive getters as\n * individual entries — the array itself can't be a bare getter.\n * @param options - The {@link UndefinedInitialDataInfiniteOptions} to use — everything you can pass to\n * `useInfiniteQuery`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The same properties as `useQuery`, with the addition of `fetchNextPage`, `fetchPreviousPage`,\n * `hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and `isFetchingPreviousPage`. `data.value.pages` and\n * `data.value.pageParams` are also added, as long as a `select` doesn't change `TData` away from its default\n * `InfiniteData<TQueryFnData>` shape.\n * @remarks Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default\n * refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user\n * actions, or add conditions like `hasNextPage && !isFetching`.\n * @example\n * Fetching the next page from a \"Load More\" button click:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useInfiniteQuery } from '@tanstack/vue-query'\n *\n * const {\n * data,\n * isPending,\n * isError,\n * error,\n * fetchNextPage,\n * hasNextPage,\n * isFetching,\n * isFetchingNextPage,\n * } = useInfiniteQuery({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isPending\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <template v-else>\n * <ul>\n * <template v-for=\"page in data.pages\" :key=\"page.nextId\">\n * <li v-for=\"project in page.projects\" :key=\"project.id\">{{ project.name }}</li>\n * </template>\n * </ul>\n * <button @click=\"fetchNextPage()\" :disabled=\"!hasNextPage || isFetching\">\n * {{ isFetchingNextPage ? 'Loading more...' : hasNextPage ? 'Load More' : 'Nothing more to load' }}\n * </button>\n * </template>\n * </template>\n * ```\n * @example\n * Fetching the next page automatically as the user scrolls, using an `IntersectionObserver` on a\n * sentinel element after the list:\n * ```vue\n * <script setup lang=\"ts\">\n * import { onUnmounted, ref, watch } from 'vue'\n * import { useInfiniteQuery } from '@tanstack/vue-query'\n *\n * const {\n * data,\n * isPending,\n * isError,\n * error,\n * fetchNextPage,\n * hasNextPage,\n * isFetching,\n * isFetchingNextPage,\n * } = useInfiniteQuery({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * const sentinel = ref<HTMLElement>()\n * let observer: IntersectionObserver | undefined\n *\n * watch(sentinel, (el) => {\n * observer?.disconnect()\n * if (el == null) return\n *\n * observer = new IntersectionObserver(([entry]) => {\n * if (entry?.isIntersecting && hasNextPage.value && !isFetching.value) {\n * fetchNextPage()\n * }\n * })\n * observer.observe(el)\n * })\n *\n * onUnmounted(() => observer?.disconnect())\n * </script>\n *\n * <template>\n * <span v-if=\"isPending\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <template v-else>\n * <ul>\n * <template v-for=\"page in data.pages\" :key=\"page.nextId\">\n * <li v-for=\"project in page.projects\" :key=\"project.id\">{{ project.name }}</li>\n * </template>\n * </ul>\n * <div ref=\"sentinel\">{{ isFetchingNextPage ? 'Loading more...' : '' }}</div>\n * </template>\n * </template>\n * ```\n */\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: MaybeRefOrGetter<\n UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >\n >,\n queryClient?: QueryClient,\n): UseInfiniteQueryReturnType<TData, TError>\n\n/**\n * Fallback overload for options whose `initialData` presence isn't statically known — for example, a\n * `ref`/reactive object built up conditionally, rather than a plain object literal. Prefer one of the other\n * overloads when possible, since they infer whether `data` can be `undefined` from `initialData` directly.\n *\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` for the array itself, or `ref`s and reactive getters as\n * individual entries — the array itself can't be a bare getter.\n * @param options - A `ref`, plain value, or reactive getter resolving to the {@link UseInfiniteQueryOptions} to\n * use.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The same properties as `useQuery`, with the addition of `fetchNextPage`, `fetchPreviousPage`,\n * `hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and `isFetchingPreviousPage`.\n * @example\n * Passing a whole-options getter so `maxPages` reacts to a setting stored elsewhere, not just `queryKey`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useInfiniteQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ projectId: number; maxPages: number }>()\n *\n * const { data } = useInfiniteQuery(() => ({\n * queryKey: ['project', props.projectId, 'issues'],\n * queryFn: ({ pageParam }) => fetchIssues(props.projectId, pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * maxPages: props.maxPages,\n * }))\n * </script>\n *\n * <template>\n * <template v-for=\"page in data?.pages\" :key=\"page.nextId\">\n * <li v-for=\"issue in page.issues\" :key=\"issue.id\">{{ issue.title }}</li>\n * </template>\n * </template>\n * ```\n * @example\n * A query that's disabled, type-safe, until `postId` is set — pass `skipToken` as `queryFn` instead of\n * setting `enabled: false`. This requires a whole-options getter: `queryFn` isn't itself reactive, so the\n * getter is what re-evaluates it on every change to `props.postId`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { skipToken, useInfiniteQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: string | undefined }>()\n *\n * // Use `isLoading`, not `isPending`, so the loading state doesn't show while the query is disabled.\n * const { data, isLoading, isError, error } = useInfiniteQuery(() => {\n * const postId = props.postId\n * return {\n * queryKey: ['post', postId, 'comments'],\n * queryFn:\n * postId != null\n * ? ({ pageParam }) => fetchComments(postId, pageParam)\n * : skipToken,\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * }\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"props.postId == null\">Select a post</span>\n * <span v-else-if=\"isLoading\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <ul v-else>\n * <template v-for=\"page in data.pages\" :key=\"page.nextId\">\n * <li v-for=\"comment in page.comments\" :key=\"comment.id\">{{ comment.text }}</li>\n * </template>\n * </ul>\n * </template>\n * ```\n */\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: MaybeRefOrGetter<\n UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>\n >,\n queryClient?: QueryClient,\n): UseInfiniteQueryReturnType<TData, TError>\n\nexport function useInfiniteQuery(\n options: MaybeRefOrGetter<UseInfiniteQueryOptions>,\n queryClient?: QueryClient,\n) {\n return useBaseQuery(\n InfiniteQueryObserver as typeof QueryObserver,\n options,\n queryClient,\n )\n}\n"],"mappings":";;;;AAuXA,SAAgB,iBACd,SACA,aACA;CACA,OAAOA,qBAAAA,aACLC,qBAAAA,uBACA,SACA,WACF;AACF"}
1
+ {"version":3,"file":"useInfiniteQuery.cjs","names":["useBaseQuery","InfiniteQueryObserver"],"sources":["../../src/useInfiniteQuery.ts"],"sourcesContent":["import { InfiniteQueryObserver } from '@tanstack/query-core'\nimport { useBaseQuery } from './useBaseQuery'\nimport type {\n DefinedInitialDataInfiniteOptions,\n UndefinedInitialDataInfiniteOptions,\n} from './infiniteQueryOptions'\nimport type { VueQueryEnabledOption } from './queryOptions'\nimport type {\n DefaultError,\n DefinedInfiniteQueryObserverResult,\n InfiniteData,\n InfiniteQueryObserverOptions,\n InfiniteQueryObserverResult,\n QueryKey,\n QueryObserver,\n} from '@tanstack/query-core'\n\nimport type { UseBaseQueryReturnType } from './useBaseQuery'\n\nimport type {\n DeepUnwrapRef,\n MaybeRef,\n MaybeRefDeep,\n MaybeRefOrGetter,\n ShallowOption,\n} from './types'\nimport type { QueryClient } from './queryClient'\n\n/**\n * The options accepted by `useInfiniteQuery`. Same as {@link InfiniteQueryObserverOptions} from\n * `@tanstack/query-core`, plus the `shallow` option. Each option except `shallow` can also be a `ref` (and\n * `enabled` a reactive getter).\n */\nexport type UseInfiniteQueryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = MaybeRef<\n {\n [\n Property in keyof InfiniteQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >\n ]: Property extends 'enabled'\n ? VueQueryEnabledOption<\n TQueryFnData,\n TError,\n InfiniteData<TQueryFnData, TPageParam>,\n DeepUnwrapRef<TQueryKey>\n >\n : MaybeRefDeep<\n InfiniteQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n DeepUnwrapRef<TQueryKey>,\n TPageParam\n >[Property]\n >\n } & ShallowOption\n>\n\n/**\n * The result of `useInfiniteQuery`: {@link InfiniteQueryObserverResult} from `@tanstack/query-core`, with\n * its properties wrapped in `Ref`s as in {@link UseBaseQueryReturnType}.\n */\nexport type UseInfiniteQueryReturnType<TData, TError> = UseBaseQueryReturnType<\n TData,\n TError,\n InfiniteQueryObserverResult<TData, TError>\n>\n\n/**\n * The result of `useInfiniteQuery` when `initialData` is set — `data` is never `undefined` (unless a `select`\n * changes `TData` to include `undefined`).\n */\nexport type UseInfiniteQueryDefinedReturnType<TData, TError> =\n UseBaseQueryReturnType<\n TData,\n TError,\n DefinedInfiniteQueryObserverResult<TData, TError>\n >\n\n/**\n * The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of\n * `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`.\n *\n * This overload is selected when `initialData` is known to be defined, so the resulting `data` is never\n * `undefined` (unless a `select` changes `TData` to include `undefined`).\n *\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` for the array itself, or `ref`s and reactive getters as\n * individual entries — the array itself can't be a bare getter.\n * @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to\n * `useInfiniteQuery`, with `initialData` known to be defined.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The same properties as `useQuery`, with the addition of `fetchNextPage`, `fetchPreviousPage`,\n * `hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and `isFetchingPreviousPage`. `data.value.pages` and\n * `data.value.pageParams` are also added, as long as a `select` doesn't change `TData` away from its default\n * `InfiniteData<TQueryFnData>` shape.\n * @remarks Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default\n * refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user\n * actions, or add conditions like `hasNextPage && !isFetching`.\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { useInfiniteQuery } from '@tanstack/vue-query'\n *\n * // `data` is never `undefined`, thanks to `initialData` — even if a refetch fails, so the\n * // list stays visible alongside the error.\n * const { data, isError, error } = useInfiniteQuery({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * initialData: { pages: [], pageParams: [] },\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <ul>\n * <template v-for=\"page in data.pages\" :key=\"page.nextId\">\n * <li v-for=\"project in page.projects\" :key=\"project.id\">{{ project.name }}</li>\n * </template>\n * </ul>\n * </template>\n * ```\n */\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: MaybeRefOrGetter<\n DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >\n >,\n queryClient?: QueryClient,\n): UseInfiniteQueryDefinedReturnType<TData, TError>\n\n/**\n * The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of\n * `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`.\n *\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` for the array itself, or `ref`s and reactive getters as\n * individual entries — the array itself can't be a bare getter.\n * @param options - The {@link UndefinedInitialDataInfiniteOptions} to use — everything you can pass to\n * `useInfiniteQuery`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The same properties as `useQuery`, with the addition of `fetchNextPage`, `fetchPreviousPage`,\n * `hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and `isFetchingPreviousPage`. `data.value.pages` and\n * `data.value.pageParams` are also added, as long as a `select` doesn't change `TData` away from its default\n * `InfiniteData<TQueryFnData>` shape.\n * @remarks Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default\n * refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user\n * actions, or add conditions like `hasNextPage && !isFetching`.\n * @example\n * Fetching the next page from a \"Load More\" button click:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useInfiniteQuery } from '@tanstack/vue-query'\n *\n * const {\n * data,\n * isPending,\n * isError,\n * error,\n * fetchNextPage,\n * hasNextPage,\n * isFetching,\n * isFetchingNextPage,\n * } = useInfiniteQuery({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isPending\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <template v-else>\n * <ul>\n * <template v-for=\"page in data.pages\" :key=\"page.nextId\">\n * <li v-for=\"project in page.projects\" :key=\"project.id\">{{ project.name }}</li>\n * </template>\n * </ul>\n * <button @click=\"fetchNextPage()\" :disabled=\"!hasNextPage || isFetching\">\n * {{ isFetchingNextPage ? 'Loading more...' : hasNextPage ? 'Load More' : 'Nothing more to load' }}\n * </button>\n * </template>\n * </template>\n * ```\n * @example\n * Fetching the next page automatically as the user scrolls, using an `IntersectionObserver` on a\n * sentinel element after the list:\n * ```vue\n * <script setup lang=\"ts\">\n * import { onUnmounted, ref, watch } from 'vue'\n * import { useInfiniteQuery } from '@tanstack/vue-query'\n *\n * const {\n * data,\n * isPending,\n * isError,\n * error,\n * fetchNextPage,\n * hasNextPage,\n * isFetching,\n * isFetchingNextPage,\n * } = useInfiniteQuery({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * const sentinel = ref<HTMLElement>()\n * let observer: IntersectionObserver | undefined\n *\n * watch(sentinel, (el) => {\n * observer?.disconnect()\n * if (el == null) return\n *\n * observer = new IntersectionObserver(([entry]) => {\n * if (entry?.isIntersecting && hasNextPage.value && !isFetching.value) {\n * fetchNextPage()\n * }\n * })\n * observer.observe(el)\n * })\n *\n * onUnmounted(() => observer?.disconnect())\n * </script>\n *\n * <template>\n * <span v-if=\"isPending\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <template v-else>\n * <ul>\n * <template v-for=\"page in data.pages\" :key=\"page.nextId\">\n * <li v-for=\"project in page.projects\" :key=\"project.id\">{{ project.name }}</li>\n * </template>\n * </ul>\n * <div ref=\"sentinel\">{{ isFetchingNextPage ? 'Loading more...' : '' }}</div>\n * </template>\n * </template>\n * ```\n */\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: MaybeRefOrGetter<\n UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >\n >,\n queryClient?: QueryClient,\n): UseInfiniteQueryReturnType<TData, TError>\n\n/**\n * Fallback overload for options whose `initialData` presence isn't statically known — for example, a\n * `ref`/reactive object built up conditionally, rather than a plain object literal. Prefer one of the other\n * overloads when possible, since they infer whether `data` can be `undefined` from `initialData` directly.\n *\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` for the array itself, or `ref`s and reactive getters as\n * individual entries — the array itself can't be a bare getter.\n * @param options - A `ref`, plain value, or reactive getter resolving to the {@link UseInfiniteQueryOptions} to\n * use.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The same properties as `useQuery`, with the addition of `fetchNextPage`, `fetchPreviousPage`,\n * `hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and `isFetchingPreviousPage`.\n * @example\n * Passing a whole-options getter so `maxPages` reacts to a setting stored elsewhere, not just `queryKey`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useInfiniteQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ projectId: number; maxPages: number }>()\n *\n * const { data } = useInfiniteQuery(() => ({\n * queryKey: ['project', props.projectId, 'issues'],\n * queryFn: ({ pageParam }) => fetchIssues(props.projectId, pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * maxPages: props.maxPages,\n * }))\n * </script>\n *\n * <template>\n * <template v-for=\"page in data?.pages\" :key=\"page.nextId\">\n * <li v-for=\"issue in page.issues\" :key=\"issue.id\">{{ issue.title }}</li>\n * </template>\n * </template>\n * ```\n * @example\n * A query that's disabled, type-safe, until `postId` is set — pass `skipToken` as `queryFn` instead of\n * setting `enabled: false`. This requires a whole-options getter: `queryFn` isn't itself reactive, so the\n * getter is what re-evaluates it on every change to `props.postId`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { skipToken, useInfiniteQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: string | undefined }>()\n *\n * // Use `isLoading`, not `isPending`, so the loading state doesn't show while the query is disabled.\n * const { data, isLoading, isError, error } = useInfiniteQuery(() => {\n * const postId = props.postId\n * return {\n * queryKey: ['post', postId, 'comments'],\n * queryFn:\n * postId != null\n * ? ({ pageParam }) => fetchComments(postId, pageParam)\n * : skipToken,\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * }\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"props.postId == null\">Select a post</span>\n * <span v-else-if=\"isLoading\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <ul v-else>\n * <template v-for=\"page in data.pages\" :key=\"page.nextId\">\n * <li v-for=\"comment in page.comments\" :key=\"comment.id\">{{ comment.text }}</li>\n * </template>\n * </ul>\n * </template>\n * ```\n */\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: MaybeRefOrGetter<\n UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>\n >,\n queryClient?: QueryClient,\n): UseInfiniteQueryReturnType<TData, TError>\n\nexport function useInfiniteQuery(\n options: MaybeRefOrGetter<UseInfiniteQueryOptions>,\n queryClient?: QueryClient,\n) {\n return useBaseQuery(\n InfiniteQueryObserver as typeof QueryObserver,\n options,\n queryClient,\n )\n}\n"],"mappings":";;;;AAqXA,SAAgB,iBACd,SACA,aACA;CACA,OAAOA,qBAAAA,aACLC,qBAAAA,uBACA,SACA,WACF;AACF"}
@@ -1,2 +1,2 @@
1
- import { a as UseInfiniteQueryOptions, i as UseInfiniteQueryDefinedReturnType, o as UseInfiniteQueryReturnType, s as useInfiniteQuery } from "./infiniteQueryOptions-lJ_zR-As.cjs";
1
+ import { a as UseInfiniteQueryOptions, i as UseInfiniteQueryDefinedReturnType, o as UseInfiniteQueryReturnType, s as useInfiniteQuery } from "./infiniteQueryOptions-BSwO8rvy.cjs";
2
2
  export { UseInfiniteQueryDefinedReturnType, UseInfiniteQueryOptions, UseInfiniteQueryReturnType, useInfiniteQuery };
@@ -1,2 +1,2 @@
1
- import { a as UseInfiniteQueryOptions, i as UseInfiniteQueryDefinedReturnType, o as UseInfiniteQueryReturnType, s as useInfiniteQuery } from "./infiniteQueryOptions-CN37iZvc.js";
1
+ import { a as UseInfiniteQueryOptions, i as UseInfiniteQueryDefinedReturnType, o as UseInfiniteQueryReturnType, s as useInfiniteQuery } from "./infiniteQueryOptions-Bq8UQFvj.js";
2
2
  export { UseInfiniteQueryDefinedReturnType, UseInfiniteQueryOptions, UseInfiniteQueryReturnType, useInfiniteQuery };
@@ -1 +1 @@
1
- {"version":3,"file":"useInfiniteQuery.js","names":[],"sources":["../../src/useInfiniteQuery.ts"],"sourcesContent":["import { InfiniteQueryObserver } from '@tanstack/query-core'\nimport { useBaseQuery } from './useBaseQuery'\nimport type {\n DefinedInitialDataInfiniteOptions,\n UndefinedInitialDataInfiniteOptions,\n} from './infiniteQueryOptions'\nimport type {\n DefaultError,\n DefinedInfiniteQueryObserverResult,\n InfiniteData,\n InfiniteQueryObserverOptions,\n InfiniteQueryObserverResult,\n QueryKey,\n QueryObserver,\n} from '@tanstack/query-core'\n\nimport type { UseBaseQueryReturnType } from './useBaseQuery'\n\nimport type {\n DeepUnwrapRef,\n MaybeRef,\n MaybeRefDeep,\n MaybeRefOrGetter,\n ShallowOption,\n} from './types'\nimport type { QueryClient } from './queryClient'\n\n/**\n * The options accepted by `useInfiniteQuery`. Same as {@link InfiniteQueryObserverOptions} from\n * `@tanstack/query-core`, plus the `shallow` option. Each option except `shallow` can also be a `ref` (and\n * `enabled` a reactive getter).\n */\nexport type UseInfiniteQueryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = MaybeRef<\n {\n [\n Property in keyof InfiniteQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >\n ]: Property extends 'enabled'\n ? MaybeRefOrGetter<\n InfiniteQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n DeepUnwrapRef<TQueryKey>,\n TPageParam\n >[Property]\n >\n : MaybeRefDeep<\n InfiniteQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n DeepUnwrapRef<TQueryKey>,\n TPageParam\n >[Property]\n >\n } & ShallowOption\n>\n\n/**\n * The result of `useInfiniteQuery`: {@link InfiniteQueryObserverResult} from `@tanstack/query-core`, with\n * its properties wrapped in `Ref`s as in {@link UseBaseQueryReturnType}.\n */\nexport type UseInfiniteQueryReturnType<TData, TError> = UseBaseQueryReturnType<\n TData,\n TError,\n InfiniteQueryObserverResult<TData, TError>\n>\n\n/**\n * The result of `useInfiniteQuery` when `initialData` is set — `data` is never `undefined` (unless a `select`\n * changes `TData` to include `undefined`).\n */\nexport type UseInfiniteQueryDefinedReturnType<TData, TError> =\n UseBaseQueryReturnType<\n TData,\n TError,\n DefinedInfiniteQueryObserverResult<TData, TError>\n >\n\n/**\n * The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of\n * `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`.\n *\n * This overload is selected when `initialData` is known to be defined, so the resulting `data` is never\n * `undefined` (unless a `select` changes `TData` to include `undefined`).\n *\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` for the array itself, or `ref`s and reactive getters as\n * individual entries — the array itself can't be a bare getter.\n * @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to\n * `useInfiniteQuery`, with `initialData` known to be defined.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The same properties as `useQuery`, with the addition of `fetchNextPage`, `fetchPreviousPage`,\n * `hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and `isFetchingPreviousPage`. `data.value.pages` and\n * `data.value.pageParams` are also added, as long as a `select` doesn't change `TData` away from its default\n * `InfiniteData<TQueryFnData>` shape.\n * @remarks Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default\n * refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user\n * actions, or add conditions like `hasNextPage && !isFetching`.\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { useInfiniteQuery } from '@tanstack/vue-query'\n *\n * // `data` is never `undefined`, thanks to `initialData` — even if a refetch fails, so the\n * // list stays visible alongside the error.\n * const { data, isError, error } = useInfiniteQuery({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * initialData: { pages: [], pageParams: [] },\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <ul>\n * <template v-for=\"page in data.pages\" :key=\"page.nextId\">\n * <li v-for=\"project in page.projects\" :key=\"project.id\">{{ project.name }}</li>\n * </template>\n * </ul>\n * </template>\n * ```\n */\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: MaybeRefOrGetter<\n DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >\n >,\n queryClient?: QueryClient,\n): UseInfiniteQueryDefinedReturnType<TData, TError>\n\n/**\n * The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of\n * `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`.\n *\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` for the array itself, or `ref`s and reactive getters as\n * individual entries — the array itself can't be a bare getter.\n * @param options - The {@link UndefinedInitialDataInfiniteOptions} to use — everything you can pass to\n * `useInfiniteQuery`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The same properties as `useQuery`, with the addition of `fetchNextPage`, `fetchPreviousPage`,\n * `hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and `isFetchingPreviousPage`. `data.value.pages` and\n * `data.value.pageParams` are also added, as long as a `select` doesn't change `TData` away from its default\n * `InfiniteData<TQueryFnData>` shape.\n * @remarks Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default\n * refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user\n * actions, or add conditions like `hasNextPage && !isFetching`.\n * @example\n * Fetching the next page from a \"Load More\" button click:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useInfiniteQuery } from '@tanstack/vue-query'\n *\n * const {\n * data,\n * isPending,\n * isError,\n * error,\n * fetchNextPage,\n * hasNextPage,\n * isFetching,\n * isFetchingNextPage,\n * } = useInfiniteQuery({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isPending\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <template v-else>\n * <ul>\n * <template v-for=\"page in data.pages\" :key=\"page.nextId\">\n * <li v-for=\"project in page.projects\" :key=\"project.id\">{{ project.name }}</li>\n * </template>\n * </ul>\n * <button @click=\"fetchNextPage()\" :disabled=\"!hasNextPage || isFetching\">\n * {{ isFetchingNextPage ? 'Loading more...' : hasNextPage ? 'Load More' : 'Nothing more to load' }}\n * </button>\n * </template>\n * </template>\n * ```\n * @example\n * Fetching the next page automatically as the user scrolls, using an `IntersectionObserver` on a\n * sentinel element after the list:\n * ```vue\n * <script setup lang=\"ts\">\n * import { onUnmounted, ref, watch } from 'vue'\n * import { useInfiniteQuery } from '@tanstack/vue-query'\n *\n * const {\n * data,\n * isPending,\n * isError,\n * error,\n * fetchNextPage,\n * hasNextPage,\n * isFetching,\n * isFetchingNextPage,\n * } = useInfiniteQuery({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * const sentinel = ref<HTMLElement>()\n * let observer: IntersectionObserver | undefined\n *\n * watch(sentinel, (el) => {\n * observer?.disconnect()\n * if (el == null) return\n *\n * observer = new IntersectionObserver(([entry]) => {\n * if (entry?.isIntersecting && hasNextPage.value && !isFetching.value) {\n * fetchNextPage()\n * }\n * })\n * observer.observe(el)\n * })\n *\n * onUnmounted(() => observer?.disconnect())\n * </script>\n *\n * <template>\n * <span v-if=\"isPending\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <template v-else>\n * <ul>\n * <template v-for=\"page in data.pages\" :key=\"page.nextId\">\n * <li v-for=\"project in page.projects\" :key=\"project.id\">{{ project.name }}</li>\n * </template>\n * </ul>\n * <div ref=\"sentinel\">{{ isFetchingNextPage ? 'Loading more...' : '' }}</div>\n * </template>\n * </template>\n * ```\n */\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: MaybeRefOrGetter<\n UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >\n >,\n queryClient?: QueryClient,\n): UseInfiniteQueryReturnType<TData, TError>\n\n/**\n * Fallback overload for options whose `initialData` presence isn't statically known — for example, a\n * `ref`/reactive object built up conditionally, rather than a plain object literal. Prefer one of the other\n * overloads when possible, since they infer whether `data` can be `undefined` from `initialData` directly.\n *\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` for the array itself, or `ref`s and reactive getters as\n * individual entries — the array itself can't be a bare getter.\n * @param options - A `ref`, plain value, or reactive getter resolving to the {@link UseInfiniteQueryOptions} to\n * use.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The same properties as `useQuery`, with the addition of `fetchNextPage`, `fetchPreviousPage`,\n * `hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and `isFetchingPreviousPage`.\n * @example\n * Passing a whole-options getter so `maxPages` reacts to a setting stored elsewhere, not just `queryKey`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useInfiniteQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ projectId: number; maxPages: number }>()\n *\n * const { data } = useInfiniteQuery(() => ({\n * queryKey: ['project', props.projectId, 'issues'],\n * queryFn: ({ pageParam }) => fetchIssues(props.projectId, pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * maxPages: props.maxPages,\n * }))\n * </script>\n *\n * <template>\n * <template v-for=\"page in data?.pages\" :key=\"page.nextId\">\n * <li v-for=\"issue in page.issues\" :key=\"issue.id\">{{ issue.title }}</li>\n * </template>\n * </template>\n * ```\n * @example\n * A query that's disabled, type-safe, until `postId` is set — pass `skipToken` as `queryFn` instead of\n * setting `enabled: false`. This requires a whole-options getter: `queryFn` isn't itself reactive, so the\n * getter is what re-evaluates it on every change to `props.postId`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { skipToken, useInfiniteQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: string | undefined }>()\n *\n * // Use `isLoading`, not `isPending`, so the loading state doesn't show while the query is disabled.\n * const { data, isLoading, isError, error } = useInfiniteQuery(() => {\n * const postId = props.postId\n * return {\n * queryKey: ['post', postId, 'comments'],\n * queryFn:\n * postId != null\n * ? ({ pageParam }) => fetchComments(postId, pageParam)\n * : skipToken,\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * }\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"props.postId == null\">Select a post</span>\n * <span v-else-if=\"isLoading\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <ul v-else>\n * <template v-for=\"page in data.pages\" :key=\"page.nextId\">\n * <li v-for=\"comment in page.comments\" :key=\"comment.id\">{{ comment.text }}</li>\n * </template>\n * </ul>\n * </template>\n * ```\n */\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: MaybeRefOrGetter<\n UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>\n >,\n queryClient?: QueryClient,\n): UseInfiniteQueryReturnType<TData, TError>\n\nexport function useInfiniteQuery(\n options: MaybeRefOrGetter<UseInfiniteQueryOptions>,\n queryClient?: QueryClient,\n) {\n return useBaseQuery(\n InfiniteQueryObserver as typeof QueryObserver,\n options,\n queryClient,\n )\n}\n"],"mappings":";;;AAuXA,SAAgB,iBACd,SACA,aACA;CACA,OAAO,aACL,uBACA,SACA,WACF;AACF"}
1
+ {"version":3,"file":"useInfiniteQuery.js","names":[],"sources":["../../src/useInfiniteQuery.ts"],"sourcesContent":["import { InfiniteQueryObserver } from '@tanstack/query-core'\nimport { useBaseQuery } from './useBaseQuery'\nimport type {\n DefinedInitialDataInfiniteOptions,\n UndefinedInitialDataInfiniteOptions,\n} from './infiniteQueryOptions'\nimport type { VueQueryEnabledOption } from './queryOptions'\nimport type {\n DefaultError,\n DefinedInfiniteQueryObserverResult,\n InfiniteData,\n InfiniteQueryObserverOptions,\n InfiniteQueryObserverResult,\n QueryKey,\n QueryObserver,\n} from '@tanstack/query-core'\n\nimport type { UseBaseQueryReturnType } from './useBaseQuery'\n\nimport type {\n DeepUnwrapRef,\n MaybeRef,\n MaybeRefDeep,\n MaybeRefOrGetter,\n ShallowOption,\n} from './types'\nimport type { QueryClient } from './queryClient'\n\n/**\n * The options accepted by `useInfiniteQuery`. Same as {@link InfiniteQueryObserverOptions} from\n * `@tanstack/query-core`, plus the `shallow` option. Each option except `shallow` can also be a `ref` (and\n * `enabled` a reactive getter).\n */\nexport type UseInfiniteQueryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = MaybeRef<\n {\n [\n Property in keyof InfiniteQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >\n ]: Property extends 'enabled'\n ? VueQueryEnabledOption<\n TQueryFnData,\n TError,\n InfiniteData<TQueryFnData, TPageParam>,\n DeepUnwrapRef<TQueryKey>\n >\n : MaybeRefDeep<\n InfiniteQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n DeepUnwrapRef<TQueryKey>,\n TPageParam\n >[Property]\n >\n } & ShallowOption\n>\n\n/**\n * The result of `useInfiniteQuery`: {@link InfiniteQueryObserverResult} from `@tanstack/query-core`, with\n * its properties wrapped in `Ref`s as in {@link UseBaseQueryReturnType}.\n */\nexport type UseInfiniteQueryReturnType<TData, TError> = UseBaseQueryReturnType<\n TData,\n TError,\n InfiniteQueryObserverResult<TData, TError>\n>\n\n/**\n * The result of `useInfiniteQuery` when `initialData` is set — `data` is never `undefined` (unless a `select`\n * changes `TData` to include `undefined`).\n */\nexport type UseInfiniteQueryDefinedReturnType<TData, TError> =\n UseBaseQueryReturnType<\n TData,\n TError,\n DefinedInfiniteQueryObserverResult<TData, TError>\n >\n\n/**\n * The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of\n * `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`.\n *\n * This overload is selected when `initialData` is known to be defined, so the resulting `data` is never\n * `undefined` (unless a `select` changes `TData` to include `undefined`).\n *\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` for the array itself, or `ref`s and reactive getters as\n * individual entries — the array itself can't be a bare getter.\n * @param options - The {@link DefinedInitialDataInfiniteOptions} to use — everything you can pass to\n * `useInfiniteQuery`, with `initialData` known to be defined.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The same properties as `useQuery`, with the addition of `fetchNextPage`, `fetchPreviousPage`,\n * `hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and `isFetchingPreviousPage`. `data.value.pages` and\n * `data.value.pageParams` are also added, as long as a `select` doesn't change `TData` away from its default\n * `InfiniteData<TQueryFnData>` shape.\n * @remarks Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default\n * refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user\n * actions, or add conditions like `hasNextPage && !isFetching`.\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { useInfiniteQuery } from '@tanstack/vue-query'\n *\n * // `data` is never `undefined`, thanks to `initialData` — even if a refetch fails, so the\n * // list stays visible alongside the error.\n * const { data, isError, error } = useInfiniteQuery({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * initialData: { pages: [], pageParams: [] },\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isError\">Error: {{ error.message }}</span>\n * <ul>\n * <template v-for=\"page in data.pages\" :key=\"page.nextId\">\n * <li v-for=\"project in page.projects\" :key=\"project.id\">{{ project.name }}</li>\n * </template>\n * </ul>\n * </template>\n * ```\n */\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: MaybeRefOrGetter<\n DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >\n >,\n queryClient?: QueryClient,\n): UseInfiniteQueryDefinedReturnType<TData, TError>\n\n/**\n * The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of\n * `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`.\n *\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` for the array itself, or `ref`s and reactive getters as\n * individual entries — the array itself can't be a bare getter.\n * @param options - The {@link UndefinedInitialDataInfiniteOptions} to use — everything you can pass to\n * `useInfiniteQuery`.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The same properties as `useQuery`, with the addition of `fetchNextPage`, `fetchPreviousPage`,\n * `hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and `isFetchingPreviousPage`. `data.value.pages` and\n * `data.value.pageParams` are also added, as long as a `select` doesn't change `TData` away from its default\n * `InfiniteData<TQueryFnData>` shape.\n * @remarks Keep in mind that imperative fetch calls, such as `fetchNextPage`, may interfere with the default\n * refetch behavior, resulting in outdated data. Make sure to call these functions only in response to user\n * actions, or add conditions like `hasNextPage && !isFetching`.\n * @example\n * Fetching the next page from a \"Load More\" button click:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useInfiniteQuery } from '@tanstack/vue-query'\n *\n * const {\n * data,\n * isPending,\n * isError,\n * error,\n * fetchNextPage,\n * hasNextPage,\n * isFetching,\n * isFetchingNextPage,\n * } = useInfiniteQuery({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"isPending\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <template v-else>\n * <ul>\n * <template v-for=\"page in data.pages\" :key=\"page.nextId\">\n * <li v-for=\"project in page.projects\" :key=\"project.id\">{{ project.name }}</li>\n * </template>\n * </ul>\n * <button @click=\"fetchNextPage()\" :disabled=\"!hasNextPage || isFetching\">\n * {{ isFetchingNextPage ? 'Loading more...' : hasNextPage ? 'Load More' : 'Nothing more to load' }}\n * </button>\n * </template>\n * </template>\n * ```\n * @example\n * Fetching the next page automatically as the user scrolls, using an `IntersectionObserver` on a\n * sentinel element after the list:\n * ```vue\n * <script setup lang=\"ts\">\n * import { onUnmounted, ref, watch } from 'vue'\n * import { useInfiniteQuery } from '@tanstack/vue-query'\n *\n * const {\n * data,\n * isPending,\n * isError,\n * error,\n * fetchNextPage,\n * hasNextPage,\n * isFetching,\n * isFetchingNextPage,\n * } = useInfiniteQuery({\n * queryKey: ['projects'],\n * queryFn: ({ pageParam }) => fetchProjects(pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * })\n *\n * const sentinel = ref<HTMLElement>()\n * let observer: IntersectionObserver | undefined\n *\n * watch(sentinel, (el) => {\n * observer?.disconnect()\n * if (el == null) return\n *\n * observer = new IntersectionObserver(([entry]) => {\n * if (entry?.isIntersecting && hasNextPage.value && !isFetching.value) {\n * fetchNextPage()\n * }\n * })\n * observer.observe(el)\n * })\n *\n * onUnmounted(() => observer?.disconnect())\n * </script>\n *\n * <template>\n * <span v-if=\"isPending\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <template v-else>\n * <ul>\n * <template v-for=\"page in data.pages\" :key=\"page.nextId\">\n * <li v-for=\"project in page.projects\" :key=\"project.id\">{{ project.name }}</li>\n * </template>\n * </ul>\n * <div ref=\"sentinel\">{{ isFetchingNextPage ? 'Loading more...' : '' }}</div>\n * </template>\n * </template>\n * ```\n */\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: MaybeRefOrGetter<\n UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >\n >,\n queryClient?: QueryClient,\n): UseInfiniteQueryReturnType<TData, TError>\n\n/**\n * Fallback overload for options whose `initialData` presence isn't statically known — for example, a\n * `ref`/reactive object built up conditionally, rather than a plain object literal. Prefer one of the other\n * overloads when possible, since they infer whether `data` can be `undefined` from `initialData` directly.\n *\n * `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter\n * (`() => ...`). `queryKey` reacts through a `ref` for the array itself, or `ref`s and reactive getters as\n * individual entries — the array itself can't be a bare getter.\n * @param options - A `ref`, plain value, or reactive getter resolving to the {@link UseInfiniteQueryOptions} to\n * use.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns The same properties as `useQuery`, with the addition of `fetchNextPage`, `fetchPreviousPage`,\n * `hasNextPage`, `hasPreviousPage`, `isFetchingNextPage`, and `isFetchingPreviousPage`.\n * @example\n * Passing a whole-options getter so `maxPages` reacts to a setting stored elsewhere, not just `queryKey`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useInfiniteQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ projectId: number; maxPages: number }>()\n *\n * const { data } = useInfiniteQuery(() => ({\n * queryKey: ['project', props.projectId, 'issues'],\n * queryFn: ({ pageParam }) => fetchIssues(props.projectId, pageParam),\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * maxPages: props.maxPages,\n * }))\n * </script>\n *\n * <template>\n * <template v-for=\"page in data?.pages\" :key=\"page.nextId\">\n * <li v-for=\"issue in page.issues\" :key=\"issue.id\">{{ issue.title }}</li>\n * </template>\n * </template>\n * ```\n * @example\n * A query that's disabled, type-safe, until `postId` is set — pass `skipToken` as `queryFn` instead of\n * setting `enabled: false`. This requires a whole-options getter: `queryFn` isn't itself reactive, so the\n * getter is what re-evaluates it on every change to `props.postId`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { skipToken, useInfiniteQuery } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ postId: string | undefined }>()\n *\n * // Use `isLoading`, not `isPending`, so the loading state doesn't show while the query is disabled.\n * const { data, isLoading, isError, error } = useInfiniteQuery(() => {\n * const postId = props.postId\n * return {\n * queryKey: ['post', postId, 'comments'],\n * queryFn:\n * postId != null\n * ? ({ pageParam }) => fetchComments(postId, pageParam)\n * : skipToken,\n * initialPageParam: 0,\n * getNextPageParam: (lastPage) => lastPage.nextId,\n * }\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"props.postId == null\">Select a post</span>\n * <span v-else-if=\"isLoading\">Loading...</span>\n * <span v-else-if=\"isError\">Error: {{ error.message }}</span>\n * <ul v-else>\n * <template v-for=\"page in data.pages\" :key=\"page.nextId\">\n * <li v-for=\"comment in page.comments\" :key=\"comment.id\">{{ comment.text }}</li>\n * </template>\n * </ul>\n * </template>\n * ```\n */\nexport function useInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: MaybeRefOrGetter<\n UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>\n >,\n queryClient?: QueryClient,\n): UseInfiniteQueryReturnType<TData, TError>\n\nexport function useInfiniteQuery(\n options: MaybeRefOrGetter<UseInfiniteQueryOptions>,\n queryClient?: QueryClient,\n) {\n return useBaseQuery(\n InfiniteQueryObserver as typeof QueryObserver,\n options,\n queryClient,\n )\n}\n"],"mappings":";;;AAqXA,SAAgB,iBACd,SACA,aACA;CACA,OAAO,aACL,uBACA,SACA,WACF;AACF"}
@@ -1,5 +1,5 @@
1
1
  import { o as MaybeRefDeep } from "./types-u_Tu5Ybs.cjs";
2
- import { t as QueryClient$1 } from "./queryClient-BGn8uIej.cjs";
2
+ import { t as QueryClient$1 } from "./queryClient-BSSPWSvX.cjs";
3
3
  import { QueryFilters } from "@tanstack/query-core";
4
4
  import { Ref } from "vue-demi";
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { o as MaybeRefDeep } from "./types-u_Tu5Ybs.js";
2
- import { t as QueryClient$1 } from "./queryClient-Ba4HSFnn.js";
2
+ import { t as QueryClient$1 } from "./queryClient-Bgw9hMbf.js";
3
3
  import { QueryFilters } from "@tanstack/query-core";
4
4
  import { Ref } from "vue-demi";
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { c as MutationOptions, o as MaybeRefDeep } from "./types-u_Tu5Ybs.cjs";
2
- import { t as QueryClient$1 } from "./queryClient-BGn8uIej.cjs";
2
+ import { t as QueryClient$1 } from "./queryClient-BSSPWSvX.cjs";
3
3
  import { DefaultError, DistributiveOmit, MutateFunction, MutationObserverResult } from "@tanstack/query-core";
4
4
  import { ToRefs } from "vue-demi";
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { c as MutationOptions, o as MaybeRefDeep } from "./types-u_Tu5Ybs.js";
2
- import { t as QueryClient$1 } from "./queryClient-Ba4HSFnn.js";
2
+ import { t as QueryClient$1 } from "./queryClient-Bgw9hMbf.js";
3
3
  import { DefaultError, DistributiveOmit, MutateFunction, MutationObserverResult } from "@tanstack/query-core";
4
4
  import { ToRefs } from "vue-demi";
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { o as MaybeRefDeep } from "./types-u_Tu5Ybs.cjs";
2
- import { t as QueryClient$1 } from "./queryClient-BGn8uIej.cjs";
2
+ import { t as QueryClient$1 } from "./queryClient-BSSPWSvX.cjs";
3
3
  import { Mutation, MutationFilters, MutationState } from "@tanstack/query-core";
4
4
  import { Ref } from "vue-demi";
5
5
  type VueMutationFilters = MaybeRefDeep<MutationFilters>;
@@ -1,5 +1,5 @@
1
1
  import { o as MaybeRefDeep } from "./types-u_Tu5Ybs.js";
2
- import { t as QueryClient$1 } from "./queryClient-Ba4HSFnn.js";
2
+ import { t as QueryClient$1 } from "./queryClient-Bgw9hMbf.js";
3
3
  import { Mutation, MutationFilters, MutationState } from "@tanstack/query-core";
4
4
  import { Ref } from "vue-demi";
5
5
  type VueMutationFilters = MaybeRefDeep<MutationFilters>;
@@ -1,5 +1,5 @@
1
1
  import { o as MaybeRefDeep, s as MaybeRefOrGetter } from "./types-u_Tu5Ybs.cjs";
2
- import { t as QueryClient$1 } from "./queryClient-BGn8uIej.cjs";
2
+ import { t as QueryClient$1 } from "./queryClient-BSSPWSvX.cjs";
3
3
  import { DefaultError, DistributiveOmit, InfiniteData, InfiniteQueryExecuteOptions, QueryKey, SkipToken } from "@tanstack/query-core";
4
4
  /**
5
5
  * The options accepted by `usePrefetchInfiniteQuery` — everything you can pass to `queryClient.infiniteQuery`,
@@ -1,5 +1,5 @@
1
1
  import { o as MaybeRefDeep, s as MaybeRefOrGetter } from "./types-u_Tu5Ybs.js";
2
- import { t as QueryClient$1 } from "./queryClient-Ba4HSFnn.js";
2
+ import { t as QueryClient$1 } from "./queryClient-Bgw9hMbf.js";
3
3
  import { DefaultError, DistributiveOmit, InfiniteData, InfiniteQueryExecuteOptions, QueryKey, SkipToken } from "@tanstack/query-core";
4
4
  /**
5
5
  * The options accepted by `usePrefetchInfiniteQuery` — everything you can pass to `queryClient.infiniteQuery`,
@@ -1,5 +1,5 @@
1
1
  import { o as MaybeRefDeep, s as MaybeRefOrGetter } from "./types-u_Tu5Ybs.cjs";
2
- import { t as QueryClient$1 } from "./queryClient-BGn8uIej.cjs";
2
+ import { t as QueryClient$1 } from "./queryClient-BSSPWSvX.cjs";
3
3
  import { DefaultError, OmitKeyof, QueryExecuteOptions, QueryKey, SkipToken } from "@tanstack/query-core";
4
4
  /**
5
5
  * The options accepted by `usePrefetchQuery` — everything you can pass to `queryClient.query`, except that
@@ -1,5 +1,5 @@
1
1
  import { o as MaybeRefDeep, s as MaybeRefOrGetter } from "./types-u_Tu5Ybs.js";
2
- import { t as QueryClient$1 } from "./queryClient-Ba4HSFnn.js";
2
+ import { t as QueryClient$1 } from "./queryClient-Bgw9hMbf.js";
3
3
  import { DefaultError, OmitKeyof, QueryExecuteOptions, QueryKey, SkipToken } from "@tanstack/query-core";
4
4
  /**
5
5
  * The options accepted by `usePrefetchQuery` — everything you can pass to `queryClient.query`, except that
@@ -133,7 +133,7 @@ function useQueries({ queries, ...options }, queryClient) {
133
133
  const resolvedQueries = typeof queries === "function" ? queries() : queries;
134
134
  return (0, vue_demi.unref)(resolvedQueries).map((queryOptions) => {
135
135
  const clonedOptions = require_utils.cloneDeepUnref(queryOptions);
136
- if (typeof clonedOptions.enabled === "function") clonedOptions.enabled = queryOptions.enabled();
136
+ if (typeof clonedOptions.enabled === "function" && clonedOptions.enabled.length === 0) clonedOptions.enabled = clonedOptions.enabled();
137
137
  const defaulted = client.defaultQueryOptions(clonedOptions);
138
138
  defaulted._optimisticResults = client.isRestoring?.value ? "isRestoring" : "optimistic";
139
139
  return defaulted;
@@ -1 +1 @@
1
- {"version":3,"file":"useQueries.cjs","names":["getCurrentScope","useQueryClient","computed","unref","cloneDeepUnref","QueriesObserver","shallowRef","shallowReadonly","readonly"],"sources":["../../src/useQueries.ts"],"sourcesContent":["import { QueriesObserver } from '@tanstack/query-core'\nimport {\n computed,\n getCurrentScope,\n onScopeDispose,\n readonly,\n shallowReadonly,\n shallowRef,\n unref,\n watch,\n} from 'vue-demi'\n\nimport { useQueryClient } from './useQueryClient'\nimport { cloneDeepUnref } from './utils'\nimport type { Ref } from 'vue-demi'\nimport type {\n DefaultError,\n DefinedQueryObserverResult,\n QueriesObserverOptions,\n QueryFunction,\n QueryKey,\n QueryObserverResult,\n ThrowOnError,\n} from '@tanstack/query-core'\nimport type { UseQueryOptions } from './queryOptions'\nimport type { QueryClient } from './queryClient'\nimport type { DeepUnwrapRef, MaybeRefDeep, ShallowOption } from './types'\n\n// This defines the `UseQueryOptions` that are accepted in `QueriesOptions` & `GetOptions`.\n// `placeholderData` function does not have a parameter\ntype UseQueryOptionsForUseQueries<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = UseQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>\n\n// Avoid TS depth-limit error in case of large array literal\ntype MAXIMUM_DEPTH = 20\n\n// Widen the type of the symbol to enable type inference even if skipToken is not immutable.\ntype SkipTokenForUseQueries = symbol\n\ntype GetUseQueryOptionsForUseQueries<T> =\n // Part 1: if UseQueryOptions are already being sent through, then just return T\n T extends UseQueryOptions\n ? DeepUnwrapRef<T>\n : // Part 2: responsible for applying explicit type parameter to function arguments, if object { queryFnData: TQueryFnData, error: TError, data: TData }\n T extends {\n queryFnData: infer TQueryFnData\n error?: infer TError\n data: infer TData\n }\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError, TData>\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError>\n : T extends { data: infer TData; error?: infer TError }\n ? UseQueryOptionsForUseQueries<unknown, TError, TData>\n : // Part 3: responsible for applying explicit type parameter to function arguments, if tuple [TQueryFnData, TError, TData]\n T extends [infer TQueryFnData, infer TError, infer TData]\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError, TData>\n : T extends [infer TQueryFnData, infer TError]\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError>\n : T extends [infer TQueryFnData]\n ? UseQueryOptionsForUseQueries<TQueryFnData>\n : // Part 4: responsible for inferring and enforcing type if no explicit parameter was provided\n T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, infer TQueryKey>\n | SkipTokenForUseQueries\n select?: (data: any) => infer TData\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? UseQueryOptionsForUseQueries<\n TQueryFnData,\n unknown extends TError ? DefaultError : TError,\n unknown extends TData ? TQueryFnData : TData,\n TQueryKey\n >\n : T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, infer TQueryKey>\n | SkipTokenForUseQueries\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? UseQueryOptionsForUseQueries<\n TQueryFnData,\n TError,\n TQueryFnData,\n TQueryKey\n >\n : // Fallback\n UseQueryOptionsForUseQueries\n\n// A defined initialData setting should return a DefinedQueryObserverResult rather than QueryObserverResult\ntype GetDefinedOrUndefinedQueryResult<T, TData, TError = unknown> = T extends {\n initialData?: infer TInitialData\n}\n ? unknown extends TInitialData\n ? QueryObserverResult<TData, TError>\n : TInitialData extends TData\n ? DefinedQueryObserverResult<TData, TError>\n : TInitialData extends () => infer TInitialDataResult\n ? unknown extends TInitialDataResult\n ? QueryObserverResult<TData, TError>\n : TInitialDataResult extends TData\n ? DefinedQueryObserverResult<TData, TError>\n : QueryObserverResult<TData, TError>\n : QueryObserverResult<TData, TError>\n : QueryObserverResult<TData, TError>\n\ntype GetUseQueryResult<T> =\n // Part 1: if using UseQueryOptions then the types are already set\n T extends UseQueryOptions<\n infer TQueryFnData,\n infer TError,\n infer TData,\n any,\n any\n >\n ? GetDefinedOrUndefinedQueryResult<\n T,\n undefined extends TData ? TQueryFnData : TData,\n unknown extends TError ? DefaultError : TError\n >\n : // Part 2: responsible for mapping explicit type parameter to function result, if object\n T extends { queryFnData: any; error?: infer TError; data: infer TData }\n ? GetDefinedOrUndefinedQueryResult<T, TData, TError>\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? GetDefinedOrUndefinedQueryResult<T, TQueryFnData, TError>\n : T extends { data: infer TData; error?: infer TError }\n ? GetDefinedOrUndefinedQueryResult<T, TData, TError>\n : // Part 3: responsible for mapping explicit type parameter to function result, if tuple\n T extends [any, infer TError, infer TData]\n ? GetDefinedOrUndefinedQueryResult<T, TData, TError>\n : T extends [infer TQueryFnData, infer TError]\n ? GetDefinedOrUndefinedQueryResult<T, TQueryFnData, TError>\n : T extends [infer TQueryFnData]\n ? GetDefinedOrUndefinedQueryResult<T, TQueryFnData>\n : // Part 4: responsible for mapping inferred type to results, if no explicit parameter was provided\n T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, any>\n | SkipTokenForUseQueries\n select?: (data: any) => infer TData\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? GetDefinedOrUndefinedQueryResult<\n T,\n unknown extends TData ? TQueryFnData : TData,\n unknown extends TError ? DefaultError : TError\n >\n : T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, any>\n | SkipTokenForUseQueries\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? GetDefinedOrUndefinedQueryResult<\n T,\n TQueryFnData,\n unknown extends TError ? DefaultError : TError\n >\n : // Fallback\n QueryObserverResult\n\n/**\n * UseQueriesOptions reducer recursively unwraps function arguments to infer/enforce type param\n */\nexport type UseQueriesOptions<\n T extends Array<any>,\n TResults extends Array<any> = [],\n TDepth extends ReadonlyArray<number> = [],\n> = TDepth['length'] extends MAXIMUM_DEPTH\n ? Array<UseQueryOptionsForUseQueries>\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...TResults, GetUseQueryOptionsForUseQueries<Head>]\n : T extends [infer Head, ...infer Tails]\n ? UseQueriesOptions<\n [...Tails],\n [...TResults, GetUseQueryOptionsForUseQueries<Head>],\n [...TDepth, 1]\n >\n : ReadonlyArray<unknown> extends T\n ? T\n : // If T is *some* array but we couldn't assign unknown[] to it, then it must hold some known/homogeneous type!\n // use this to infer the param types in the case of Array.map() argument\n T extends Array<\n UseQueryOptionsForUseQueries<\n infer TQueryFnData,\n infer TError,\n infer TData,\n infer TQueryKey\n >\n >\n ? Array<\n UseQueryOptionsForUseQueries<\n TQueryFnData,\n TError,\n TData,\n TQueryKey\n >\n >\n : // Fallback\n Array<UseQueryOptionsForUseQueries>\n\n/**\n * UseQueriesResults reducer recursively maps type param to results\n */\nexport type UseQueriesResults<\n T extends Array<any>,\n TResults extends Array<any> = [],\n TDepth extends ReadonlyArray<number> = [],\n> = TDepth['length'] extends MAXIMUM_DEPTH\n ? Array<QueryObserverResult>\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...TResults, GetUseQueryResult<Head>]\n : T extends [infer Head, ...infer Tails]\n ? UseQueriesResults<\n [...Tails],\n [...TResults, GetUseQueryResult<Head>],\n [...TDepth, 1]\n >\n : { [K in keyof T]: GetUseQueryResult<T[K]> }\n\ntype UseQueriesOptionsArg<T extends Array<any>> = readonly [\n ...UseQueriesOptions<T>,\n]\n\n/**\n * The `useQueries` composable can be used to fetch a variable number of queries.\n *\n * The `queries` option accepts an array of query option objects mostly identical to `useQuery`'s. It may be a\n * plain array, a `ref`/reactive array (each entry tracked individually), or a getter function — pass a getter\n * if the array itself (its length, or which queries are in it) depends on other reactive state.\n *\n * Having the same query key more than once in the array of query objects may cause some data to be shared\n * between queries. To avoid this, consider de-duplicating the queries and map the results back to the desired\n * structure.\n *\n * The `combine` option can be used to combine the results of the queries into a single value. The result will\n * be structurally shared to be as referentially stable as possible.\n *\n * `placeholderData` is supported here too, but unlike `useQuery`, it doesn't receive information from\n * previously rendered queries, because the number of queries can differ between renders.\n * @param options - The `queries` array to run, and the optional `combine` and `shallow` options.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns A `ref` to the combined result. Without `combine`, this is an array with all the query results, in\n * the same order as the input. When `combine` is provided, this is the value returned by `combine` instead.\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQueries } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ ids: Array<number> }>()\n *\n * const postQueries = useQueries({\n * queries: () =>\n * props.ids.map((id) => ({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * staleTime: Infinity,\n * })),\n * })\n * </script>\n *\n * <template>\n * <ul>\n * <li v-for=\"(query, index) in postQueries\" :key=\"props.ids[index]\">\n * <span v-if=\"query.isPending\">Loading...</span>\n * <span v-else-if=\"query.isError\">Error: {{ query.error.message }}</span>\n * <span v-else>{{ query.data.title }}</span>\n * </li>\n * </ul>\n * </template>\n * ```\n * @example\n * Combining results into a single value:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQueries } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ ids: Array<number> }>()\n *\n * const combined = useQueries({\n * queries: () =>\n * props.ids.map((id) => ({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })),\n * combine: (postQueries) => ({\n * data: postQueries.map((query) => query.data),\n * isPending: postQueries.some((query) => query.isPending),\n * isError: postQueries.some((query) => query.isError),\n * }),\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"combined.isPending\">Loading...</span>\n * <span v-else-if=\"combined.isError\">Error!</span>\n * <ul v-else>\n * <li v-for=\"post in combined.data\" :key=\"post.id\">{{ post.title }}</li>\n * </ul>\n * </template>\n * ```\n * @example\n * Typing `select` via {@link queryOptions}. Note that spreading a `queryOptions` result and overriding\n * `select` inline still falls back to `unknown` — wrap the spread in `queryOptions` again so the override is\n * resolved before it reaches `useQueries`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { queryOptions, useQueries } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ id: number }>()\n *\n * const postOptions = (id: number) =>\n * queryOptions({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })\n *\n * const [{ data: broken }] = useQueries({\n * queries: () => [\n * {\n * ...postOptions(props.id),\n * // ❌ `data` is `unknown` here\n * select: (data) => data.title,\n * },\n * ],\n * })\n *\n * const [{ data: fixed }] = useQueries({\n * queries: () => [\n * queryOptions({\n * ...postOptions(props.id),\n * // ✅ `data` is `Post`\n * select: (data) => data.title,\n * }),\n * ],\n * })\n * </script>\n *\n * <template>\n * <h1>{{ fixed }}</h1>\n * </template>\n * ```\n */\nexport function useQueries<\n T extends Array<any>,\n TCombinedResult = UseQueriesResults<T>,\n>(\n {\n queries,\n ...options\n }: ShallowOption & {\n queries:\n | (() => MaybeRefDeep<UseQueriesOptionsArg<T>>)\n | MaybeRefDeep<UseQueriesOptionsArg<T>>\n | MaybeRefDeep<\n readonly [\n ...{ [K in keyof T]: GetUseQueryOptionsForUseQueries<T[K]> },\n ]\n >\n combine?: (result: UseQueriesResults<T>) => TCombinedResult\n },\n queryClient?: QueryClient,\n): Readonly<Ref<TCombinedResult>> {\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\n const defaultedQueries = computed(() => {\n const resolvedQueries =\n typeof queries === 'function'\n ? (queries as () => MaybeRefDeep<UseQueriesOptionsArg<T>>)()\n : queries\n // Only unref the top level array.\n const queriesRaw = unref(resolvedQueries) as ReadonlyArray<any>\n\n // Unref the rest for each element in the top level array.\n return queriesRaw.map((queryOptions) => {\n const clonedOptions = cloneDeepUnref(queryOptions)\n\n if (typeof clonedOptions.enabled === 'function') {\n clonedOptions.enabled = queryOptions.enabled()\n }\n\n const defaulted = client.defaultQueryOptions(clonedOptions)\n defaulted._optimisticResults = client.isRestoring?.value\n ? 'isRestoring'\n : 'optimistic'\n\n return defaulted\n })\n })\n\n const observer = new QueriesObserver<TCombinedResult>(\n client,\n defaultedQueries.value,\n options as QueriesObserverOptions<TCombinedResult>,\n )\n\n const getOptimisticResult = () => {\n const [results, getCombinedResult] = observer.getOptimisticResult(\n defaultedQueries.value,\n (options as QueriesObserverOptions<TCombinedResult>).combine,\n )\n\n return getCombinedResult(\n results.map((result, index) => {\n return {\n ...result,\n refetch: async (...args: Array<any>) => {\n const [{ [index]: query }] = observer.getOptimisticResult(\n defaultedQueries.value,\n (options as QueriesObserverOptions<TCombinedResult>).combine,\n )\n\n return query!.refetch(...args)\n },\n }\n }),\n )\n }\n\n const state = shallowRef(getOptimisticResult())\n\n let unsubscribe = () => {\n // noop\n }\n\n if (client.isRestoring) {\n watch(\n client.isRestoring,\n (isRestoring) => {\n if (!isRestoring) {\n unsubscribe()\n unsubscribe = observer.subscribe(() => {\n state.value = getOptimisticResult()\n })\n\n state.value = getOptimisticResult()\n }\n },\n { immediate: true },\n )\n }\n\n watch(defaultedQueries, (queriesValue) => {\n observer.setQueries(\n queriesValue,\n options as QueriesObserverOptions<TCombinedResult>,\n )\n state.value = getOptimisticResult()\n })\n\n onScopeDispose(() => {\n unsubscribe()\n })\n\n return options.shallow\n ? shallowReadonly(state)\n : (readonly(state) as Readonly<Ref<TCombinedResult>>)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiWA,SAAgB,WAId,EACE,SACA,GAAG,WAYL,aACgC;CAChC,IAAI,QAAQ,IAAI,aAAa,eACvB;MAAA,EAAA,GAACA,SAAAA,gBAAAA,CAAgB,GACnB,QAAQ,KACN,kKACF;CAAA;CAIJ,MAAM,SAAS,eAAeC,uBAAAA,eAAe;CAE7C,MAAM,oBAAA,GAAmBC,SAAAA,SAAAA,OAAe;EACtC,MAAM,kBACJ,OAAO,YAAY,aACd,QAAwD,IACzD;EAKN,QAAA,GAHmBC,SAAAA,MAAAA,CAAM,eAGT,CAAC,CAAC,KAAK,iBAAiB;GACtC,MAAM,gBAAgBC,cAAAA,eAAe,YAAY;GAEjD,IAAI,OAAO,cAAc,YAAY,YACnC,cAAc,UAAU,aAAa,QAAQ;GAG/C,MAAM,YAAY,OAAO,oBAAoB,aAAa;GAC1D,UAAU,qBAAqB,OAAO,aAAa,QAC/C,gBACA;GAEJ,OAAO;EACT,CAAC;CACH,CAAC;CAED,MAAM,WAAW,IAAIC,qBAAAA,gBACnB,QACA,iBAAiB,OACjB,OACF;CAEA,MAAM,4BAA4B;EAChC,MAAM,CAAC,SAAS,qBAAqB,SAAS,oBAC5C,iBAAiB,OAChB,QAAoD,OACvD;EAEA,OAAO,kBACL,QAAQ,KAAK,QAAQ,UAAU;GAC7B,OAAO;IACL,GAAG;IACH,SAAS,OAAO,GAAG,SAAqB;KACtC,MAAM,CAAC,GAAG,QAAQ,WAAW,SAAS,oBACpC,iBAAiB,OAChB,QAAoD,OACvD;KAEA,OAAO,MAAO,QAAQ,GAAG,IAAI;IAC/B;GACF;EACF,CAAC,CACH;CACF;CAEA,MAAM,SAAA,GAAQC,SAAAA,WAAAA,CAAW,oBAAoB,CAAC;CAE9C,IAAI,oBAAoB,CAExB;CAEA,IAAI,OAAO,aACT,CAAA,GAAA,SAAA,MAAA,CACE,OAAO,cACN,gBAAgB;EACf,IAAI,CAAC,aAAa;GAChB,YAAY;GACZ,cAAc,SAAS,gBAAgB;IACrC,MAAM,QAAQ,oBAAoB;GACpC,CAAC;GAED,MAAM,QAAQ,oBAAoB;EACpC;CACF,GACA,EAAE,WAAW,KAAK,CACpB;CAGF,CAAA,GAAA,SAAA,MAAA,CAAM,mBAAmB,iBAAiB;EACxC,SAAS,WACP,cACA,OACF;EACA,MAAM,QAAQ,oBAAoB;CACpC,CAAC;CAED,CAAA,GAAA,SAAA,eAAA,OAAqB;EACnB,YAAY;CACd,CAAC;CAED,OAAO,QAAQ,WAAA,GACXC,SAAAA,gBAAAA,CAAgB,KAAK,KAAA,GACpBC,SAAAA,SAAAA,CAAS,KAAK;AACrB"}
1
+ {"version":3,"file":"useQueries.cjs","names":["getCurrentScope","useQueryClient","computed","unref","cloneDeepUnref","QueriesObserver","shallowRef","shallowReadonly","readonly"],"sources":["../../src/useQueries.ts"],"sourcesContent":["import { QueriesObserver } from '@tanstack/query-core'\nimport {\n computed,\n getCurrentScope,\n onScopeDispose,\n readonly,\n shallowReadonly,\n shallowRef,\n unref,\n watch,\n} from 'vue-demi'\n\nimport { useQueryClient } from './useQueryClient'\nimport { cloneDeepUnref } from './utils'\nimport type { Ref } from 'vue-demi'\nimport type {\n DefaultError,\n DefinedQueryObserverResult,\n QueriesObserverOptions,\n QueryFunction,\n QueryKey,\n QueryObserverResult,\n ThrowOnError,\n} from '@tanstack/query-core'\nimport type { UseQueryOptions } from './queryOptions'\nimport type { QueryClient } from './queryClient'\nimport type { DeepUnwrapRef, MaybeRefDeep, ShallowOption } from './types'\n\n// This defines the `UseQueryOptions` that are accepted in `QueriesOptions` & `GetOptions`.\n// `placeholderData` function does not have a parameter\ntype UseQueryOptionsForUseQueries<\n TQueryFnData = unknown,\n TError = unknown,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = UseQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>\n\n// Avoid TS depth-limit error in case of large array literal\ntype MAXIMUM_DEPTH = 20\n\n// Widen the type of the symbol to enable type inference even if skipToken is not immutable.\ntype SkipTokenForUseQueries = symbol\n\ntype GetUseQueryOptionsForUseQueries<T> =\n // Part 1: if UseQueryOptions are already being sent through, then just return T\n T extends UseQueryOptions\n ? DeepUnwrapRef<T>\n : // Part 2: responsible for applying explicit type parameter to function arguments, if object { queryFnData: TQueryFnData, error: TError, data: TData }\n T extends {\n queryFnData: infer TQueryFnData\n error?: infer TError\n data: infer TData\n }\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError, TData>\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError>\n : T extends { data: infer TData; error?: infer TError }\n ? UseQueryOptionsForUseQueries<unknown, TError, TData>\n : // Part 3: responsible for applying explicit type parameter to function arguments, if tuple [TQueryFnData, TError, TData]\n T extends [infer TQueryFnData, infer TError, infer TData]\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError, TData>\n : T extends [infer TQueryFnData, infer TError]\n ? UseQueryOptionsForUseQueries<TQueryFnData, TError>\n : T extends [infer TQueryFnData]\n ? UseQueryOptionsForUseQueries<TQueryFnData>\n : // Part 4: responsible for inferring and enforcing type if no explicit parameter was provided\n T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, infer TQueryKey>\n | SkipTokenForUseQueries\n select?: (data: any) => infer TData\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? UseQueryOptionsForUseQueries<\n TQueryFnData,\n unknown extends TError ? DefaultError : TError,\n unknown extends TData ? TQueryFnData : TData,\n TQueryKey\n >\n : T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, infer TQueryKey>\n | SkipTokenForUseQueries\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? UseQueryOptionsForUseQueries<\n TQueryFnData,\n TError,\n TQueryFnData,\n TQueryKey\n >\n : // Fallback\n UseQueryOptionsForUseQueries\n\n// A defined initialData setting should return a DefinedQueryObserverResult rather than QueryObserverResult\ntype GetDefinedOrUndefinedQueryResult<T, TData, TError = unknown> = T extends {\n initialData?: infer TInitialData\n}\n ? unknown extends TInitialData\n ? QueryObserverResult<TData, TError>\n : TInitialData extends TData\n ? DefinedQueryObserverResult<TData, TError>\n : TInitialData extends () => infer TInitialDataResult\n ? unknown extends TInitialDataResult\n ? QueryObserverResult<TData, TError>\n : TInitialDataResult extends TData\n ? DefinedQueryObserverResult<TData, TError>\n : QueryObserverResult<TData, TError>\n : QueryObserverResult<TData, TError>\n : QueryObserverResult<TData, TError>\n\ntype GetUseQueryResult<T> =\n // Part 1: if using UseQueryOptions then the types are already set\n T extends UseQueryOptions<\n infer TQueryFnData,\n infer TError,\n infer TData,\n any,\n any\n >\n ? GetDefinedOrUndefinedQueryResult<\n T,\n undefined extends TData ? TQueryFnData : TData,\n unknown extends TError ? DefaultError : TError\n >\n : // Part 2: responsible for mapping explicit type parameter to function result, if object\n T extends { queryFnData: any; error?: infer TError; data: infer TData }\n ? GetDefinedOrUndefinedQueryResult<T, TData, TError>\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? GetDefinedOrUndefinedQueryResult<T, TQueryFnData, TError>\n : T extends { data: infer TData; error?: infer TError }\n ? GetDefinedOrUndefinedQueryResult<T, TData, TError>\n : // Part 3: responsible for mapping explicit type parameter to function result, if tuple\n T extends [any, infer TError, infer TData]\n ? GetDefinedOrUndefinedQueryResult<T, TData, TError>\n : T extends [infer TQueryFnData, infer TError]\n ? GetDefinedOrUndefinedQueryResult<T, TQueryFnData, TError>\n : T extends [infer TQueryFnData]\n ? GetDefinedOrUndefinedQueryResult<T, TQueryFnData>\n : // Part 4: responsible for mapping inferred type to results, if no explicit parameter was provided\n T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, any>\n | SkipTokenForUseQueries\n select?: (data: any) => infer TData\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? GetDefinedOrUndefinedQueryResult<\n T,\n unknown extends TData ? TQueryFnData : TData,\n unknown extends TError ? DefaultError : TError\n >\n : T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, any>\n | SkipTokenForUseQueries\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? GetDefinedOrUndefinedQueryResult<\n T,\n TQueryFnData,\n unknown extends TError ? DefaultError : TError\n >\n : // Fallback\n QueryObserverResult\n\n/**\n * UseQueriesOptions reducer recursively unwraps function arguments to infer/enforce type param\n */\nexport type UseQueriesOptions<\n T extends Array<any>,\n TResults extends Array<any> = [],\n TDepth extends ReadonlyArray<number> = [],\n> = TDepth['length'] extends MAXIMUM_DEPTH\n ? Array<UseQueryOptionsForUseQueries>\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...TResults, GetUseQueryOptionsForUseQueries<Head>]\n : T extends [infer Head, ...infer Tails]\n ? UseQueriesOptions<\n [...Tails],\n [...TResults, GetUseQueryOptionsForUseQueries<Head>],\n [...TDepth, 1]\n >\n : ReadonlyArray<unknown> extends T\n ? T\n : // If T is *some* array but we couldn't assign unknown[] to it, then it must hold some known/homogeneous type!\n // use this to infer the param types in the case of Array.map() argument\n T extends Array<\n UseQueryOptionsForUseQueries<\n infer TQueryFnData,\n infer TError,\n infer TData,\n infer TQueryKey\n >\n >\n ? Array<\n UseQueryOptionsForUseQueries<\n TQueryFnData,\n TError,\n TData,\n TQueryKey\n >\n >\n : // Fallback\n Array<UseQueryOptionsForUseQueries>\n\n/**\n * UseQueriesResults reducer recursively maps type param to results\n */\nexport type UseQueriesResults<\n T extends Array<any>,\n TResults extends Array<any> = [],\n TDepth extends ReadonlyArray<number> = [],\n> = TDepth['length'] extends MAXIMUM_DEPTH\n ? Array<QueryObserverResult>\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...TResults, GetUseQueryResult<Head>]\n : T extends [infer Head, ...infer Tails]\n ? UseQueriesResults<\n [...Tails],\n [...TResults, GetUseQueryResult<Head>],\n [...TDepth, 1]\n >\n : { [K in keyof T]: GetUseQueryResult<T[K]> }\n\ntype UseQueriesOptionsArg<T extends Array<any>> = readonly [\n ...UseQueriesOptions<T>,\n]\n\n/**\n * The `useQueries` composable can be used to fetch a variable number of queries.\n *\n * The `queries` option accepts an array of query option objects mostly identical to `useQuery`'s. It may be a\n * plain array, a `ref`/reactive array (each entry tracked individually), or a getter function — pass a getter\n * if the array itself (its length, or which queries are in it) depends on other reactive state.\n *\n * Having the same query key more than once in the array of query objects may cause some data to be shared\n * between queries. To avoid this, consider de-duplicating the queries and map the results back to the desired\n * structure.\n *\n * The `combine` option can be used to combine the results of the queries into a single value. The result will\n * be structurally shared to be as referentially stable as possible.\n *\n * `placeholderData` is supported here too, but unlike `useQuery`, it doesn't receive information from\n * previously rendered queries, because the number of queries can differ between renders.\n * @param options - The `queries` array to run, and the optional `combine` and `shallow` options.\n * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one provided by `VueQueryPlugin`\n * will be used.\n * @returns A `ref` to the combined result. Without `combine`, this is an array with all the query results, in\n * the same order as the input. When `combine` is provided, this is the value returned by `combine` instead.\n * @example\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQueries } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ ids: Array<number> }>()\n *\n * const postQueries = useQueries({\n * queries: () =>\n * props.ids.map((id) => ({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * staleTime: Infinity,\n * })),\n * })\n * </script>\n *\n * <template>\n * <ul>\n * <li v-for=\"(query, index) in postQueries\" :key=\"props.ids[index]\">\n * <span v-if=\"query.isPending\">Loading...</span>\n * <span v-else-if=\"query.isError\">Error: {{ query.error.message }}</span>\n * <span v-else>{{ query.data.title }}</span>\n * </li>\n * </ul>\n * </template>\n * ```\n * @example\n * Combining results into a single value:\n * ```vue\n * <script setup lang=\"ts\">\n * import { useQueries } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ ids: Array<number> }>()\n *\n * const combined = useQueries({\n * queries: () =>\n * props.ids.map((id) => ({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })),\n * combine: (postQueries) => ({\n * data: postQueries.map((query) => query.data),\n * isPending: postQueries.some((query) => query.isPending),\n * isError: postQueries.some((query) => query.isError),\n * }),\n * })\n * </script>\n *\n * <template>\n * <span v-if=\"combined.isPending\">Loading...</span>\n * <span v-else-if=\"combined.isError\">Error!</span>\n * <ul v-else>\n * <li v-for=\"post in combined.data\" :key=\"post.id\">{{ post.title }}</li>\n * </ul>\n * </template>\n * ```\n * @example\n * Typing `select` via {@link queryOptions}. Note that spreading a `queryOptions` result and overriding\n * `select` inline still falls back to `unknown` — wrap the spread in `queryOptions` again so the override is\n * resolved before it reaches `useQueries`:\n * ```vue\n * <script setup lang=\"ts\">\n * import { queryOptions, useQueries } from '@tanstack/vue-query'\n *\n * const props = defineProps<{ id: number }>()\n *\n * const postOptions = (id: number) =>\n * queryOptions({\n * queryKey: ['post', id],\n * queryFn: () => fetchPost(id),\n * })\n *\n * const [{ data: broken }] = useQueries({\n * queries: () => [\n * {\n * ...postOptions(props.id),\n * // ❌ `data` is `unknown` here\n * select: (data) => data.title,\n * },\n * ],\n * })\n *\n * const [{ data: fixed }] = useQueries({\n * queries: () => [\n * queryOptions({\n * ...postOptions(props.id),\n * // ✅ `data` is `Post`\n * select: (data) => data.title,\n * }),\n * ],\n * })\n * </script>\n *\n * <template>\n * <h1>{{ fixed }}</h1>\n * </template>\n * ```\n */\nexport function useQueries<\n T extends Array<any>,\n TCombinedResult = UseQueriesResults<T>,\n>(\n {\n queries,\n ...options\n }: ShallowOption & {\n queries:\n | (() => MaybeRefDeep<UseQueriesOptionsArg<T>>)\n | MaybeRefDeep<UseQueriesOptionsArg<T>>\n | MaybeRefDeep<\n readonly [\n ...{ [K in keyof T]: GetUseQueryOptionsForUseQueries<T[K]> },\n ]\n >\n combine?: (result: UseQueriesResults<T>) => TCombinedResult\n },\n queryClient?: QueryClient,\n): Readonly<Ref<TCombinedResult>> {\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\n const defaultedQueries = computed(() => {\n const resolvedQueries =\n typeof queries === 'function'\n ? (queries as () => MaybeRefDeep<UseQueriesOptionsArg<T>>)()\n : queries\n // Only unref the top level array.\n const queriesRaw = unref(resolvedQueries) as ReadonlyArray<any>\n\n // Unref the rest for each element in the top level array.\n return queriesRaw.map((queryOptions) => {\n const clonedOptions = cloneDeepUnref(queryOptions)\n\n // A zero-arg function is a Vue getter and must run here so its refs are tracked.\n // `(query) => boolean` is query-core's callback and is left for core to call.\n if (\n typeof clonedOptions.enabled === 'function' &&\n clonedOptions.enabled.length === 0\n ) {\n clonedOptions.enabled = clonedOptions.enabled()\n }\n\n const defaulted = client.defaultQueryOptions(clonedOptions)\n defaulted._optimisticResults = client.isRestoring?.value\n ? 'isRestoring'\n : 'optimistic'\n\n return defaulted\n })\n })\n\n const observer = new QueriesObserver<TCombinedResult>(\n client,\n defaultedQueries.value,\n options as QueriesObserverOptions<TCombinedResult>,\n )\n\n const getOptimisticResult = () => {\n const [results, getCombinedResult] = observer.getOptimisticResult(\n defaultedQueries.value,\n (options as QueriesObserverOptions<TCombinedResult>).combine,\n )\n\n return getCombinedResult(\n results.map((result, index) => {\n return {\n ...result,\n refetch: async (...args: Array<any>) => {\n const [{ [index]: query }] = observer.getOptimisticResult(\n defaultedQueries.value,\n (options as QueriesObserverOptions<TCombinedResult>).combine,\n )\n\n return query!.refetch(...args)\n },\n }\n }),\n )\n }\n\n const state = shallowRef(getOptimisticResult())\n\n let unsubscribe = () => {\n // noop\n }\n\n if (client.isRestoring) {\n watch(\n client.isRestoring,\n (isRestoring) => {\n if (!isRestoring) {\n unsubscribe()\n unsubscribe = observer.subscribe(() => {\n state.value = getOptimisticResult()\n })\n\n state.value = getOptimisticResult()\n }\n },\n { immediate: true },\n )\n }\n\n watch(defaultedQueries, (queriesValue) => {\n observer.setQueries(\n queriesValue,\n options as QueriesObserverOptions<TCombinedResult>,\n )\n state.value = getOptimisticResult()\n })\n\n onScopeDispose(() => {\n unsubscribe()\n })\n\n return options.shallow\n ? shallowReadonly(state)\n : (readonly(state) as Readonly<Ref<TCombinedResult>>)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiWA,SAAgB,WAId,EACE,SACA,GAAG,WAYL,aACgC;CAChC,IAAI,QAAQ,IAAI,aAAa,eACvB;MAAA,EAAA,GAACA,SAAAA,gBAAAA,CAAgB,GACnB,QAAQ,KACN,kKACF;CAAA;CAIJ,MAAM,SAAS,eAAeC,uBAAAA,eAAe;CAE7C,MAAM,oBAAA,GAAmBC,SAAAA,SAAAA,OAAe;EACtC,MAAM,kBACJ,OAAO,YAAY,aACd,QAAwD,IACzD;EAKN,QAAA,GAHmBC,SAAAA,MAAAA,CAAM,eAGT,CAAC,CAAC,KAAK,iBAAiB;GACtC,MAAM,gBAAgBC,cAAAA,eAAe,YAAY;GAIjD,IACE,OAAO,cAAc,YAAY,cACjC,cAAc,QAAQ,WAAW,GAEjC,cAAc,UAAU,cAAc,QAAQ;GAGhD,MAAM,YAAY,OAAO,oBAAoB,aAAa;GAC1D,UAAU,qBAAqB,OAAO,aAAa,QAC/C,gBACA;GAEJ,OAAO;EACT,CAAC;CACH,CAAC;CAED,MAAM,WAAW,IAAIC,qBAAAA,gBACnB,QACA,iBAAiB,OACjB,OACF;CAEA,MAAM,4BAA4B;EAChC,MAAM,CAAC,SAAS,qBAAqB,SAAS,oBAC5C,iBAAiB,OAChB,QAAoD,OACvD;EAEA,OAAO,kBACL,QAAQ,KAAK,QAAQ,UAAU;GAC7B,OAAO;IACL,GAAG;IACH,SAAS,OAAO,GAAG,SAAqB;KACtC,MAAM,CAAC,GAAG,QAAQ,WAAW,SAAS,oBACpC,iBAAiB,OAChB,QAAoD,OACvD;KAEA,OAAO,MAAO,QAAQ,GAAG,IAAI;IAC/B;GACF;EACF,CAAC,CACH;CACF;CAEA,MAAM,SAAA,GAAQC,SAAAA,WAAAA,CAAW,oBAAoB,CAAC;CAE9C,IAAI,oBAAoB,CAExB;CAEA,IAAI,OAAO,aACT,CAAA,GAAA,SAAA,MAAA,CACE,OAAO,cACN,gBAAgB;EACf,IAAI,CAAC,aAAa;GAChB,YAAY;GACZ,cAAc,SAAS,gBAAgB;IACrC,MAAM,QAAQ,oBAAoB;GACpC,CAAC;GAED,MAAM,QAAQ,oBAAoB;EACpC;CACF,GACA,EAAE,WAAW,KAAK,CACpB;CAGF,CAAA,GAAA,SAAA,MAAA,CAAM,mBAAmB,iBAAiB;EACxC,SAAS,WACP,cACA,OACF;EACA,MAAM,QAAQ,oBAAoB;CACpC,CAAC;CAED,CAAA,GAAA,SAAA,eAAA,OAAqB;EACnB,YAAY;CACd,CAAC;CAED,OAAO,QAAQ,WAAA,GACXC,SAAAA,gBAAAA,CAAgB,KAAK,KAAA,GACpBC,SAAAA,SAAAA,CAAS,KAAK;AACrB"}
@@ -1,6 +1,6 @@
1
1
  import { d as ShallowOption, o as MaybeRefDeep, t as DeepUnwrapRef } from "./types-u_Tu5Ybs.cjs";
2
- import { o as UseQueryOptions } from "./queryOptions-BuZEBLtg.cjs";
3
- import { t as QueryClient$1 } from "./queryClient-BGn8uIej.cjs";
2
+ import { o as UseQueryOptions } from "./queryOptions-B-eHjgaY.cjs";
3
+ import { t as QueryClient$1 } from "./queryClient-BSSPWSvX.cjs";
4
4
  import { DefaultError, DefinedQueryObserverResult, QueryFunction, QueryKey, QueryObserverResult, ThrowOnError } from "@tanstack/query-core";
5
5
  import { Ref } from "vue-demi";
6
6
  type UseQueryOptionsForUseQueries<TQueryFnData = unknown, TError = unknown, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = UseQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>;
@@ -1,6 +1,6 @@
1
1
  import { d as ShallowOption, o as MaybeRefDeep, t as DeepUnwrapRef } from "./types-u_Tu5Ybs.js";
2
- import { o as UseQueryOptions } from "./queryOptions-dXiBZnGk.js";
3
- import { t as QueryClient$1 } from "./queryClient-Ba4HSFnn.js";
2
+ import { o as UseQueryOptions } from "./queryOptions-D1-foH1W.js";
3
+ import { t as QueryClient$1 } from "./queryClient-Bgw9hMbf.js";
4
4
  import { DefaultError, DefinedQueryObserverResult, QueryFunction, QueryKey, QueryObserverResult, ThrowOnError } from "@tanstack/query-core";
5
5
  import { Ref } from "vue-demi";
6
6
  type UseQueryOptionsForUseQueries<TQueryFnData = unknown, TError = unknown, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = UseQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>;
@@ -132,7 +132,7 @@ function useQueries({ queries, ...options }, queryClient) {
132
132
  const resolvedQueries = typeof queries === "function" ? queries() : queries;
133
133
  return unref(resolvedQueries).map((queryOptions) => {
134
134
  const clonedOptions = cloneDeepUnref(queryOptions);
135
- if (typeof clonedOptions.enabled === "function") clonedOptions.enabled = queryOptions.enabled();
135
+ if (typeof clonedOptions.enabled === "function" && clonedOptions.enabled.length === 0) clonedOptions.enabled = clonedOptions.enabled();
136
136
  const defaulted = client.defaultQueryOptions(clonedOptions);
137
137
  defaulted._optimisticResults = client.isRestoring?.value ? "isRestoring" : "optimistic";
138
138
  return defaulted;