@trpc/react-query 11.8.1-canary.13 → 11.8.1-canary.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/rsc.mjs +0 -1
- package/dist/rsc.mjs.map +1 -1
- package/package.json +6 -6
package/dist/rsc.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { __toESM, getQueryKeyInternal, require_objectSpread2 } from "./getQueryKey-BY58RNzP.mjs";
|
|
2
2
|
import { HydrationBoundary, dehydrate } from "@tanstack/react-query";
|
|
3
3
|
import { createRecursiveProxy } from "@trpc/server/unstable-core-do-not-import";
|
|
4
|
-
import "react";
|
|
5
4
|
import { jsx } from "react/jsx-runtime";
|
|
6
5
|
|
|
7
6
|
//#region src/rsc.tsx
|
package/dist/rsc.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rsc.mjs","names":["caller: AnyRouter extends TRouter\n ? TypeError<'Generic parameter missing in `createHydrationHelpers<HERE>`'>\n : Caller<TRouter>","getQueryClient: () => QueryClient","props: { children: React.ReactNode }"],"sources":["../src/rsc.tsx"],"sourcesContent":["/// <reference types=\"react/canary\" />\n\nimport {\n dehydrate,\n HydrationBoundary,\n type QueryClient,\n} from '@tanstack/react-query';\nimport type { TRPCClientError } from '@trpc/client';\nimport type { inferTransformedProcedureOutput } from '@trpc/server';\nimport {\n createRecursiveProxy,\n type AnyRouter,\n type inferProcedureInput,\n type RouterRecord,\n} from '@trpc/server/unstable-core-do-not-import';\nimport type {\n AnyProcedure,\n AnyRootTypes,\n inferProcedureOutput,\n inferRouterRootTypes,\n Maybe,\n RouterCaller,\n TypeError,\n} from '@trpc/server/unstable-core-do-not-import';\nimport * as React from 'react';\nimport { getQueryKeyInternal } from './internals/getQueryKey';\nimport type {\n TRPCFetchInfiniteQueryOptions,\n TRPCFetchQueryOptions,\n} from './shared';\n\nconst HELPERS = ['prefetch', 'prefetchInfinite'];\n\ntype DecorateProcedure<\n TRoot extends AnyRootTypes,\n TProcedure extends AnyProcedure,\n> = {\n (\n input: inferProcedureInput<TProcedure>,\n ): Promise<inferProcedureOutput<TProcedure>>;\n prefetch: (\n input: inferProcedureInput<TProcedure>,\n opts?: TRPCFetchQueryOptions<\n inferTransformedProcedureOutput<TRoot, TProcedure>,\n TRPCClientError<TRoot>\n >,\n ) => Promise<void>;\n prefetchInfinite: (\n input: inferProcedureInput<TProcedure>,\n opts?: TRPCFetchInfiniteQueryOptions<\n inferProcedureInput<TProcedure>,\n inferTransformedProcedureOutput<TRoot, TProcedure>,\n TRPCClientError<TRoot>\n >,\n ) => Promise<void>;\n};\n\ntype DecorateRouterRecord<\n TRoot extends AnyRootTypes,\n TRecord extends RouterRecord,\n> = {\n [TKey in keyof TRecord]: TRecord[TKey] extends infer $Value\n ? $Value extends AnyProcedure\n ? DecorateProcedure<TRoot, $Value>\n : $Value extends RouterRecord\n ? DecorateRouterRecord<TRoot, $Value>\n : never\n : never;\n};\n\ntype Caller<TRouter extends AnyRouter> = ReturnType<\n RouterCaller<inferRouterRootTypes<TRouter>, TRouter['_def']['record']>\n>;\n\n// ts-prune-ignore-next\n/**\n * @note This requires `@tanstack/react-query@^5.49.0`\n * @note Make sure to have `dehydrate.serializeData` and `hydrate.deserializeData`\n * set to your data transformer in your `QueryClient` factory.\n * @example\n * ```ts\n * export const createQueryClient = () =>\n * new QueryClient({\n * defaultOptions: {\n * dehydrate: {\n * serializeData: transformer.serialize,\n * },\n * hydrate: {\n * deserializeData: transformer.deserialize,\n * },\n * },\n * });\n * ```\n */\nexport function createHydrationHelpers<TRouter extends AnyRouter>(\n caller: AnyRouter extends TRouter\n ? TypeError<'Generic parameter missing in `createHydrationHelpers<HERE>`'>\n : Caller<TRouter>,\n getQueryClient: () => QueryClient,\n) {\n type RootTypes = inferRouterRootTypes<TRouter>;\n\n const wrappedProxy = createRecursiveProxy<\n DecorateRouterRecord<RootTypes, TRouter['_def']['record']>\n >(async (opts) => {\n const path = [...opts.path];\n const args = [...opts.args];\n const proc = path.reduce(\n (acc, key) =>\n // @ts-expect-error - ??\n HELPERS.includes(key) ? acc : acc[key],\n caller,\n ) as unknown as DecorateProcedure<RootTypes, AnyProcedure>;\n\n const input = args[0];\n const promise = proc(input);\n\n const helper = path.pop();\n if (helper === 'prefetch') {\n const args1 = args[1] as Maybe<\n TRPCFetchInfiniteQueryOptions<any, any, any>\n >;\n\n return getQueryClient().prefetchQuery({\n ...args1,\n queryKey: getQueryKeyInternal(path, input, 'query'),\n queryFn: () => promise,\n });\n }\n if (helper === 'prefetchInfinite') {\n const args1 = args[1] as Maybe<\n TRPCFetchInfiniteQueryOptions<any, any, any>\n >;\n\n return getQueryClient().prefetchInfiniteQuery({\n ...args1,\n queryKey: getQueryKeyInternal(path, input, 'infinite'),\n queryFn: () => promise,\n initialPageParam: args1?.initialCursor ?? null,\n });\n }\n\n return promise;\n });\n\n function HydrateClient(props: { children: React.ReactNode }) {\n const dehydratedState = dehydrate(getQueryClient());\n\n return (\n <HydrationBoundary state={dehydratedState}>\n {props.children}\n </HydrationBoundary>\n );\n }\n\n return {\n /***\n * Wrapped caller with prefetch helpers\n * Can be used as a regular [server-side caller](https://trpc.io/docs/server/server-side-calls)\n * or using prefetch helpers to put the promise into the QueryClient cache\n * @example\n * ```ts\n * const data = await trpc.post.get(\"postId\");\n *\n * // or\n * void trpc.post.get.prefetch(\"postId\");\n * ```\n */\n trpc: wrappedProxy,\n /**\n * HoC to hydrate the query client for a client component\n * to pick up the prefetched promise and skip an initial\n * client-side fetch.\n * @example\n * ```tsx\n * // MyRSC.tsx\n * const MyRSC = ({ params }) => {\n * void trpc.post.get.prefetch(params.postId);\n *\n * return (\n * <HydrateClient>\n * <MyCC postId={params.postId} />\n * </HydrateClient>\n * );\n * };\n *\n * // MyCC.tsx\n * \"use client\"\n * const MyCC = ({ postId }) => {\n * const { data: post } = trpc.post.get.useQuery(postId);\n * return <div>{post.title}</div>;\n * };\n * ```\n */\n HydrateClient,\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"rsc.mjs","names":["caller: AnyRouter extends TRouter\n ? TypeError<'Generic parameter missing in `createHydrationHelpers<HERE>`'>\n : Caller<TRouter>","getQueryClient: () => QueryClient","props: { children: React.ReactNode }"],"sources":["../src/rsc.tsx"],"sourcesContent":["/// <reference types=\"react/canary\" />\n\nimport {\n dehydrate,\n HydrationBoundary,\n type QueryClient,\n} from '@tanstack/react-query';\nimport type { TRPCClientError } from '@trpc/client';\nimport type { inferTransformedProcedureOutput } from '@trpc/server';\nimport {\n createRecursiveProxy,\n type AnyRouter,\n type inferProcedureInput,\n type RouterRecord,\n} from '@trpc/server/unstable-core-do-not-import';\nimport type {\n AnyProcedure,\n AnyRootTypes,\n inferProcedureOutput,\n inferRouterRootTypes,\n Maybe,\n RouterCaller,\n TypeError,\n} from '@trpc/server/unstable-core-do-not-import';\nimport * as React from 'react';\nimport { getQueryKeyInternal } from './internals/getQueryKey';\nimport type {\n TRPCFetchInfiniteQueryOptions,\n TRPCFetchQueryOptions,\n} from './shared';\n\nconst HELPERS = ['prefetch', 'prefetchInfinite'];\n\ntype DecorateProcedure<\n TRoot extends AnyRootTypes,\n TProcedure extends AnyProcedure,\n> = {\n (\n input: inferProcedureInput<TProcedure>,\n ): Promise<inferProcedureOutput<TProcedure>>;\n prefetch: (\n input: inferProcedureInput<TProcedure>,\n opts?: TRPCFetchQueryOptions<\n inferTransformedProcedureOutput<TRoot, TProcedure>,\n TRPCClientError<TRoot>\n >,\n ) => Promise<void>;\n prefetchInfinite: (\n input: inferProcedureInput<TProcedure>,\n opts?: TRPCFetchInfiniteQueryOptions<\n inferProcedureInput<TProcedure>,\n inferTransformedProcedureOutput<TRoot, TProcedure>,\n TRPCClientError<TRoot>\n >,\n ) => Promise<void>;\n};\n\ntype DecorateRouterRecord<\n TRoot extends AnyRootTypes,\n TRecord extends RouterRecord,\n> = {\n [TKey in keyof TRecord]: TRecord[TKey] extends infer $Value\n ? $Value extends AnyProcedure\n ? DecorateProcedure<TRoot, $Value>\n : $Value extends RouterRecord\n ? DecorateRouterRecord<TRoot, $Value>\n : never\n : never;\n};\n\ntype Caller<TRouter extends AnyRouter> = ReturnType<\n RouterCaller<inferRouterRootTypes<TRouter>, TRouter['_def']['record']>\n>;\n\n// ts-prune-ignore-next\n/**\n * @note This requires `@tanstack/react-query@^5.49.0`\n * @note Make sure to have `dehydrate.serializeData` and `hydrate.deserializeData`\n * set to your data transformer in your `QueryClient` factory.\n * @example\n * ```ts\n * export const createQueryClient = () =>\n * new QueryClient({\n * defaultOptions: {\n * dehydrate: {\n * serializeData: transformer.serialize,\n * },\n * hydrate: {\n * deserializeData: transformer.deserialize,\n * },\n * },\n * });\n * ```\n */\nexport function createHydrationHelpers<TRouter extends AnyRouter>(\n caller: AnyRouter extends TRouter\n ? TypeError<'Generic parameter missing in `createHydrationHelpers<HERE>`'>\n : Caller<TRouter>,\n getQueryClient: () => QueryClient,\n) {\n type RootTypes = inferRouterRootTypes<TRouter>;\n\n const wrappedProxy = createRecursiveProxy<\n DecorateRouterRecord<RootTypes, TRouter['_def']['record']>\n >(async (opts) => {\n const path = [...opts.path];\n const args = [...opts.args];\n const proc = path.reduce(\n (acc, key) =>\n // @ts-expect-error - ??\n HELPERS.includes(key) ? acc : acc[key],\n caller,\n ) as unknown as DecorateProcedure<RootTypes, AnyProcedure>;\n\n const input = args[0];\n const promise = proc(input);\n\n const helper = path.pop();\n if (helper === 'prefetch') {\n const args1 = args[1] as Maybe<\n TRPCFetchInfiniteQueryOptions<any, any, any>\n >;\n\n return getQueryClient().prefetchQuery({\n ...args1,\n queryKey: getQueryKeyInternal(path, input, 'query'),\n queryFn: () => promise,\n });\n }\n if (helper === 'prefetchInfinite') {\n const args1 = args[1] as Maybe<\n TRPCFetchInfiniteQueryOptions<any, any, any>\n >;\n\n return getQueryClient().prefetchInfiniteQuery({\n ...args1,\n queryKey: getQueryKeyInternal(path, input, 'infinite'),\n queryFn: () => promise,\n initialPageParam: args1?.initialCursor ?? null,\n });\n }\n\n return promise;\n });\n\n function HydrateClient(props: { children: React.ReactNode }) {\n const dehydratedState = dehydrate(getQueryClient());\n\n return (\n <HydrationBoundary state={dehydratedState}>\n {props.children}\n </HydrationBoundary>\n );\n }\n\n return {\n /***\n * Wrapped caller with prefetch helpers\n * Can be used as a regular [server-side caller](https://trpc.io/docs/server/server-side-calls)\n * or using prefetch helpers to put the promise into the QueryClient cache\n * @example\n * ```ts\n * const data = await trpc.post.get(\"postId\");\n *\n * // or\n * void trpc.post.get.prefetch(\"postId\");\n * ```\n */\n trpc: wrappedProxy,\n /**\n * HoC to hydrate the query client for a client component\n * to pick up the prefetched promise and skip an initial\n * client-side fetch.\n * @example\n * ```tsx\n * // MyRSC.tsx\n * const MyRSC = ({ params }) => {\n * void trpc.post.get.prefetch(params.postId);\n *\n * return (\n * <HydrateClient>\n * <MyCC postId={params.postId} />\n * </HydrateClient>\n * );\n * };\n *\n * // MyCC.tsx\n * \"use client\"\n * const MyCC = ({ postId }) => {\n * const { data: post } = trpc.post.get.useQuery(postId);\n * return <div>{post.title}</div>;\n * };\n * ```\n */\n HydrateClient,\n };\n}\n"],"mappings":";;;;;;;AA+BA,MAAM,UAAU,CAAC,YAAY,kBAAmB;;;;;;;;;;;;;;;;;;;;AA+DhD,SAAgB,uBACdA,QAGAC,gBACA;CAGA,MAAM,eAAe,qBAEnB,OAAO,SAAS;EAChB,MAAM,OAAO,CAAC,GAAG,KAAK,IAAK;EAC3B,MAAM,OAAO,CAAC,GAAG,KAAK,IAAK;EAC3B,MAAM,OAAO,KAAK,OAChB,CAAC,KAAK,QAEJ,QAAQ,SAAS,IAAI,GAAG,MAAM,IAAI,MACpC,OACD;EAED,MAAM,QAAQ,KAAK;EACnB,MAAM,UAAU,KAAK,MAAM;EAE3B,MAAM,SAAS,KAAK,KAAK;AACzB,MAAI,WAAW,YAAY;GACzB,MAAM,QAAQ,KAAK;AAInB,UAAO,gBAAgB,CAAC,sFACnB;IACH,UAAU,oBAAoB,MAAM,OAAO,QAAQ;IACnD,SAAS,MAAM;MACf;EACH;AACD,MAAI,WAAW,oBAAoB;;GACjC,MAAM,QAAQ,KAAK;AAInB,UAAO,gBAAgB,CAAC,8FACnB;IACH,UAAU,oBAAoB,MAAM,OAAO,WAAW;IACtD,SAAS,MAAM;IACf,wFAAkB,MAAO,oFAAiB;MAC1C;EACH;AAED,SAAO;CACR,EAAC;CAEF,SAAS,cAAcC,OAAsC;EAC3D,MAAM,kBAAkB,UAAU,gBAAgB,CAAC;AAEnD,yBACE,IAAC;GAAkB,OAAO;aACvB,MAAM;IACW;CAEvB;AAED,QAAO;EAaL,MAAM;EA0BN;CACD;AACF"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/react-query",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "11.8.1-canary.
|
|
4
|
+
"version": "11.8.1-canary.14+599a99217",
|
|
5
5
|
"description": "The tRPC React library",
|
|
6
6
|
"author": "KATT",
|
|
7
7
|
"license": "MIT",
|
|
@@ -85,8 +85,8 @@
|
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|
|
87
87
|
"@tanstack/react-query": "^5.80.3",
|
|
88
|
-
"@trpc/client": "11.8.1-canary.
|
|
89
|
-
"@trpc/server": "11.8.1-canary.
|
|
88
|
+
"@trpc/client": "11.8.1-canary.14+599a99217",
|
|
89
|
+
"@trpc/server": "11.8.1-canary.14+599a99217",
|
|
90
90
|
"react": ">=18.2.0",
|
|
91
91
|
"react-dom": ">=18.2.0",
|
|
92
92
|
"typescript": ">=5.7.2"
|
|
@@ -99,8 +99,8 @@
|
|
|
99
99
|
"@testing-library/jest-dom": "^6.0.0",
|
|
100
100
|
"@testing-library/react": "^16.1.0",
|
|
101
101
|
"@testing-library/user-event": "^14.4.3",
|
|
102
|
-
"@trpc/client": "11.8.1-canary.
|
|
103
|
-
"@trpc/server": "11.8.1-canary.
|
|
102
|
+
"@trpc/client": "11.8.1-canary.14+599a99217",
|
|
103
|
+
"@trpc/server": "11.8.1-canary.14+599a99217",
|
|
104
104
|
"@types/express": "^5.0.0",
|
|
105
105
|
"@types/node": "^22.13.5",
|
|
106
106
|
"@types/react": "^19.1.0",
|
|
@@ -121,5 +121,5 @@
|
|
|
121
121
|
"funding": [
|
|
122
122
|
"https://trpc.io/sponsor"
|
|
123
123
|
],
|
|
124
|
-
"gitHead": "
|
|
124
|
+
"gitHead": "599a99217946b247f31de040da778b222dd949a5"
|
|
125
125
|
}
|