{"ast":null,"code":"\"use client\";\n\n// src/useSuspenseQueries.ts\nimport { skipToken } from \"@tanstack/query-core\";\nimport { useQueries } from \"./useQueries.js\";\nimport { defaultThrowOnError } from \"./suspense.js\";\nfunction useSuspenseQueries(options, queryClient) {\n return useQueries({\n ...options,\n queries: options.queries.map(query => {\n if (process.env.NODE_ENV !== \"production\") {\n if (query.queryFn === skipToken) {\n console.error(\"skipToken is not allowed for useSuspenseQueries\");\n }\n }\n return {\n ...query,\n suspense: true,\n throwOnError: defaultThrowOnError,\n enabled: true,\n placeholderData: void 0\n };\n })\n }, queryClient);\n}\nexport { useSuspenseQueries };","map":{"version":3,"names":["skipToken","useQueries","defaultThrowOnError","useSuspenseQueries","options","queryClient","queries","map","query","process","env","NODE_ENV","queryFn","console","error","suspense","throwOnError","enabled","placeholderData"],"sources":["/Users/shoofle/Projects/the-forest/node_modules/@tanstack/react-query/src/useSuspenseQueries.ts"],"sourcesContent":["'use client'\nimport { skipToken } from '@tanstack/query-core'\nimport { useQueries } from './useQueries'\nimport { defaultThrowOnError } from './suspense'\nimport type { UseSuspenseQueryOptions, UseSuspenseQueryResult } from './types'\nimport type {\n DefaultError,\n QueryClient,\n QueryFunction,\n ThrowOnError,\n} from '@tanstack/query-core'\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 GetUseSuspenseQueryOptions =\n // Part 1: 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 ? UseSuspenseQueryOptions\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? UseSuspenseQueryOptions\n : T extends { data: infer TData; error?: infer TError }\n ? UseSuspenseQueryOptions\n : // Part 2: responsible for applying explicit type parameter to function arguments, if tuple [TQueryFnData, TError, TData]\n T extends [infer TQueryFnData, infer TError, infer TData]\n ? UseSuspenseQueryOptions\n : T extends [infer TQueryFnData, infer TError]\n ? UseSuspenseQueryOptions\n : T extends [infer TQueryFnData]\n ? UseSuspenseQueryOptions\n : // Part 3: responsible for inferring and enforcing type if no explicit parameter was provided\n T extends {\n queryFn?:\n | QueryFunction\n | SkipTokenForUseQueries\n select?: (data: any) => infer TData\n throwOnError?: ThrowOnError\n }\n ? UseSuspenseQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey\n >\n : T extends {\n queryFn?:\n | QueryFunction\n | SkipTokenForUseQueries\n throwOnError?: ThrowOnError\n }\n ? UseSuspenseQueryOptions<\n TQueryFnData,\n TError,\n TQueryFnData,\n TQueryKey\n >\n : // Fallback\n UseSuspenseQueryOptions\n\ntype GetUseSuspenseQueryResult =\n // Part 1: responsible for mapping explicit type parameter to function result, if object\n T extends { queryFnData: any; error?: infer TError; data: infer TData }\n ? UseSuspenseQueryResult\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? UseSuspenseQueryResult\n : T extends { data: infer TData; error?: infer TError }\n ? UseSuspenseQueryResult\n : // Part 2: responsible for mapping explicit type parameter to function result, if tuple\n T extends [any, infer TError, infer TData]\n ? UseSuspenseQueryResult\n : T extends [infer TQueryFnData, infer TError]\n ? UseSuspenseQueryResult\n : T extends [infer TQueryFnData]\n ? UseSuspenseQueryResult\n : // Part 3: responsible for mapping inferred type to results, if no explicit parameter was provided\n T extends {\n queryFn?:\n | QueryFunction\n | SkipTokenForUseQueries\n select?: (data: any) => infer TData\n throwOnError?: ThrowOnError\n }\n ? UseSuspenseQueryResult<\n unknown extends TData ? TQueryFnData : TData,\n unknown extends TError ? DefaultError : TError\n >\n : T extends {\n queryFn?:\n | QueryFunction\n | SkipTokenForUseQueries\n throwOnError?: ThrowOnError\n }\n ? UseSuspenseQueryResult<\n TQueryFnData,\n unknown extends TError ? DefaultError : TError\n >\n : // Fallback\n UseSuspenseQueryResult\n\n/**\n * SuspenseQueriesOptions reducer recursively unwraps function arguments to infer/enforce type param\n */\nexport type SuspenseQueriesOptions<\n T extends Array,\n TResults extends Array = [],\n TDepth extends ReadonlyArray = [],\n> = TDepth['length'] extends MAXIMUM_DEPTH\n ? Array\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...TResults, GetUseSuspenseQueryOptions]\n : T extends [infer Head, ...infer Tails]\n ? SuspenseQueriesOptions<\n [...Tails],\n [...TResults, GetUseSuspenseQueryOptions],\n [...TDepth, 1]\n >\n : Array extends T\n ? T\n : // If T is *some* array but we couldn't assign unknown[] to it, then it must hold some known/homogenous type!\n // use this to infer the param types in the case of Array.map() argument\n T extends Array<\n UseSuspenseQueryOptions<\n infer TQueryFnData,\n infer TError,\n infer TData,\n infer TQueryKey\n >\n >\n ? Array<\n UseSuspenseQueryOptions\n >\n : // Fallback\n Array\n\n/**\n * SuspenseQueriesResults reducer recursively maps type param to results\n */\nexport type SuspenseQueriesResults<\n T extends Array,\n TResults extends Array = [],\n TDepth extends ReadonlyArray = [],\n> = TDepth['length'] extends MAXIMUM_DEPTH\n ? Array\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...TResults, GetUseSuspenseQueryResult]\n : T extends [infer Head, ...infer Tails]\n ? SuspenseQueriesResults<\n [...Tails],\n [...TResults, GetUseSuspenseQueryResult],\n [...TDepth, 1]\n >\n : T extends Array<\n UseSuspenseQueryOptions<\n infer TQueryFnData,\n infer TError,\n infer TData,\n any\n >\n >\n ? // Dynamic-size (homogenous) UseQueryOptions array: map directly to array of results\n Array<\n UseSuspenseQueryResult<\n unknown extends TData ? TQueryFnData : TData,\n unknown extends TError ? DefaultError : TError\n >\n >\n : // Fallback\n Array\n\nexport function useSuspenseQueries<\n T extends Array,\n TCombinedResult = SuspenseQueriesResults,\n>(\n options: {\n queries: readonly [...SuspenseQueriesOptions]\n combine?: (result: SuspenseQueriesResults) => TCombinedResult\n },\n queryClient?: QueryClient,\n): TCombinedResult {\n return useQueries(\n {\n ...options,\n queries: options.queries.map((query) => {\n if (process.env.NODE_ENV !== 'production') {\n if (query.queryFn === skipToken) {\n console.error('skipToken is not allowed for useSuspenseQueries')\n }\n }\n\n return {\n ...query,\n suspense: true,\n throwOnError: defaultThrowOnError,\n enabled: true,\n placeholderData: undefined,\n }\n }),\n } as any,\n queryClient,\n )\n}\n"],"mappings":";;;AACA,SAASA,SAAA,QAAiB;AAC1B,SAASC,UAAA,QAAkB;AAC3B,SAASC,mBAAA,QAA2B;AAiL7B,SAASC,mBAIdC,OAAA,EAIAC,WAAA,EACiB;EACjB,OAAOJ,UAAA,CACL;IACE,GAAGG,OAAA;IACHE,OAAA,EAASF,OAAA,CAAQE,OAAA,CAAQC,GAAA,CAAKC,KAAA,IAAU;MACtC,IAAIC,OAAA,CAAQC,GAAA,CAAIC,QAAA,KAAa,cAAc;QACzC,IAAIH,KAAA,CAAMI,OAAA,KAAYZ,SAAA,EAAW;UAC/Ba,OAAA,CAAQC,KAAA,CAAM,iDAAiD;QACjE;MACF;MAEA,OAAO;QACL,GAAGN,KAAA;QACHO,QAAA,EAAU;QACVC,YAAA,EAAcd,mBAAA;QACde,OAAA,EAAS;QACTC,eAAA,EAAiB;MACnB;IACF,CAAC;EACH,GACAb,WACF;AACF","ignoreList":[]},"metadata":{},"sourceType":"module","externalDependencies":[]}