@trpc/next 11.22.1 → 11.22.2-canary.6.9959a177b

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/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
- import { a as WithTRPCSSROptions, i as WithTRPCNoSSROptions, n as TRPCPrepassProps, o as withTRPC, r as WithTRPCConfig, t as TRPCPrepassHelper } from "./withTRPC-DywCxFfq.cjs";
1
+ import { a as WithTRPCSSROptions, i as WithTRPCNoSSROptions, n as TRPCPrepassProps, o as withTRPC, r as WithTRPCConfig, t as TRPCPrepassHelper } from "./withTRPC-Cr10aYRv.cjs";
2
2
  import { AnyRouter, ProtectedIntersection } from "@trpc/server/unstable-core-do-not-import";
3
3
  import { CreateReactUtils, DecorateRouterRecord, TRPCUseQueries, TRPCUseSuspenseQueries } from "@trpc/react-query/shared";
4
- import { NextPageContext } from "next/types";
4
+ import { NextPageContext } from "next/types.js";
5
5
  //#region src/createTRPCNext.d.ts
6
6
  /**
7
7
  * @internal
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
- import { a as WithTRPCSSROptions, i as WithTRPCNoSSROptions, n as TRPCPrepassProps, o as withTRPC, r as WithTRPCConfig, t as TRPCPrepassHelper } from "./withTRPC-BchtyodQ.mjs";
1
+ import { a as WithTRPCSSROptions, i as WithTRPCNoSSROptions, n as TRPCPrepassProps, o as withTRPC, r as WithTRPCConfig, t as TRPCPrepassHelper } from "./withTRPC-CxGgngCY.mjs";
2
2
  import { CreateReactUtils, DecorateRouterRecord, TRPCUseQueries, TRPCUseSuspenseQueries } from "@trpc/react-query/shared";
3
3
  import { AnyRouter, ProtectedIntersection } from "@trpc/server/unstable-core-do-not-import";
4
- import { NextPageContext } from "next/types";
4
+ import { NextPageContext } from "next/types.js";
5
5
  //#region src/createTRPCNext.d.ts
6
6
  /**
7
7
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/withTRPC.tsx","../src/createTRPCNext.tsx"],"sourcesContent":["/**\n * Heavily based on urql's ssr\n * https://github.com/FormidableLabs/urql/blob/main/packages/next-urql/src/with-urql-client.ts\n */\nimport type { DehydratedState, QueryClient } from '@tanstack/react-query';\nimport { HydrationBoundary, QueryClientProvider } from '@tanstack/react-query';\nimport type {\n CreateTRPCClientOptions,\n TRPCClient,\n TRPCClientError,\n TRPCUntypedClient,\n} from '@trpc/client';\nimport type { CoercedTransformerParameters } from '@trpc/client/unstable-internals';\nimport {\n getTransformer,\n type TransformerOptions,\n} from '@trpc/client/unstable-internals';\nimport type {\n CreateTRPCReactOptions,\n CreateTRPCReactQueryClientConfig,\n} from '@trpc/react-query/shared';\nimport { createRootHooks, getQueryClient } from '@trpc/react-query/shared';\nimport type {\n AnyRouter,\n Dict,\n inferClientTypes,\n ResponseMeta,\n} from '@trpc/server/unstable-core-do-not-import';\nimport type {\n AppContextType,\n AppPropsType,\n NextComponentType,\n NextPageContext,\n} from 'next/dist/shared/lib/utils';\nimport type { NextRouter } from 'next/router';\nimport React, { useState } from 'react';\n\nexport type WithTRPCConfig<TRouter extends AnyRouter> =\n CreateTRPCClientOptions<TRouter> &\n CreateTRPCReactQueryClientConfig & {\n abortOnUnmount?: boolean;\n };\n\ntype WithTRPCOptions<TRouter extends AnyRouter> =\n CreateTRPCReactOptions<TRouter> & {\n config: (info: { ctx?: NextPageContext }) => WithTRPCConfig<TRouter>;\n } & TransformerOptions<inferClientTypes<TRouter>>;\n\nexport type TRPCPrepassHelper = (opts: {\n parent: WithTRPCSSROptions<AnyRouter>;\n WithTRPC: NextComponentType<any, any, any>;\n AppOrPage: NextComponentType<any, any, any>;\n}) => void;\nexport type WithTRPCSSROptions<TRouter extends AnyRouter> =\n WithTRPCOptions<TRouter> & {\n /**\n * If you enable this, you also need to add a `ssrPrepass`-prop\n * @see https://trpc.io/docs/client/nextjs/ssr\n */\n ssr:\n true | ((opts: { ctx: NextPageContext }) => boolean | Promise<boolean>);\n responseMeta?: (opts: {\n ctx: NextPageContext;\n clientErrors: TRPCClientError<TRouter>[];\n }) => ResponseMeta;\n /**\n * use `import { ssrPrepass } from '@trpc/next/ssrPrepass'`\n * @see https://trpc.io/docs/client/nextjs/ssr\n */\n ssrPrepass: TRPCPrepassHelper;\n };\n\nexport type WithTRPCNoSSROptions<TRouter extends AnyRouter> =\n WithTRPCOptions<TRouter> & {\n ssr?: false;\n };\n\nexport type TRPCPrepassProps<\n TRouter extends AnyRouter,\n TSSRContext extends NextPageContext = NextPageContext,\n> = {\n config: WithTRPCConfig<TRouter>;\n queryClient: QueryClient;\n trpcClient: TRPCUntypedClient<TRouter> | TRPCClient<TRouter>;\n ssrState: 'prepass';\n ssrContext: TSSRContext;\n};\n\nexport function withTRPC<\n TRouter extends AnyRouter,\n TSSRContext extends NextPageContext = NextPageContext,\n>(opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>) {\n const { config: getClientConfig } = opts;\n const transformer = getTransformer(\n (opts as CoercedTransformerParameters).transformer,\n );\n\n type $PrepassProps = TRPCPrepassProps<TRouter, TSSRContext>;\n return (AppOrPage: NextComponentType<any, any, any>): NextComponentType => {\n const trpc = createRootHooks<TRouter, TSSRContext>(opts);\n\n const WithTRPC = (\n props: AppPropsType<NextRouter, any> & {\n trpc?: $PrepassProps;\n },\n ) => {\n const [prepassProps] = useState(() => {\n if (props.trpc) {\n return props.trpc;\n }\n\n const config = getClientConfig({});\n const queryClient = getQueryClient(config);\n const trpcClient = trpc.createClient(config);\n\n return {\n abortOnUnmount: config.abortOnUnmount,\n queryClient,\n trpcClient,\n ssrState: opts.ssr ? ('mounting' as const) : (false as const),\n ssrContext: null,\n };\n });\n\n const { queryClient, trpcClient, ssrState, ssrContext } = prepassProps;\n\n // allow normal components to be wrapped, not just app/pages\n const trpcState = props.pageProps?.trpcState;\n\n const hydratedState: DehydratedState | undefined = React.useMemo(() => {\n if (!trpcState) {\n return trpcState;\n }\n\n return transformer.input.deserialize(trpcState);\n }, [trpcState]);\n\n return (\n <trpc.Provider\n abortOnUnmount={(prepassProps as any).abortOnUnmount ?? false}\n client={trpcClient}\n queryClient={queryClient}\n ssrState={ssrState}\n ssrContext={ssrContext}\n >\n <QueryClientProvider client={queryClient}>\n <HydrationBoundary state={hydratedState}>\n <AppOrPage {...props} />\n </HydrationBoundary>\n </QueryClientProvider>\n </trpc.Provider>\n );\n };\n\n if (opts.ssr) {\n opts.ssrPrepass({\n parent: opts,\n AppOrPage,\n WithTRPC,\n });\n } else if (AppOrPage.getInitialProps) {\n // Allow combining `getServerSideProps` and `getInitialProps`\n\n WithTRPC.getInitialProps = async (appOrPageCtx: AppContextType) => {\n // Determine if we are wrapping an App component or a Page component.\n const isApp = !!appOrPageCtx.Component;\n\n // Run the wrapped component's getInitialProps function.\n let pageProps: Dict<unknown> = {};\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const originalProps = await AppOrPage.getInitialProps!(\n appOrPageCtx as any,\n );\n const originalPageProps = isApp\n ? (originalProps.pageProps ?? {})\n : originalProps;\n\n pageProps = {\n ...originalPageProps,\n ...pageProps,\n };\n const getAppTreeProps = (props: Dict<unknown>) =>\n isApp ? { pageProps: props } : props;\n\n return getAppTreeProps(pageProps);\n };\n }\n\n const displayName = AppOrPage.displayName ?? AppOrPage.name ?? 'Component';\n WithTRPC.displayName = `withTRPC(${displayName})`;\n\n return WithTRPC as any;\n };\n}\n","/* istanbul ignore file -- @preserve */\n// We're testing this through E2E-testing\nimport type {\n CreateReactUtils,\n DecorateRouterRecord,\n TRPCUseQueries,\n TRPCUseSuspenseQueries,\n} from '@trpc/react-query/shared';\nimport {\n createReactDecoration,\n createReactQueryUtils,\n createRootHooks,\n} from '@trpc/react-query/shared';\nimport type {\n AnyRouter,\n ProtectedIntersection,\n} from '@trpc/server/unstable-core-do-not-import';\nimport { createFlatProxy } from '@trpc/server/unstable-core-do-not-import';\nimport type { NextPageContext } from 'next/types';\nimport { useMemo } from 'react';\nimport type { WithTRPCNoSSROptions, WithTRPCSSROptions } from './withTRPC';\nimport { withTRPC } from './withTRPC';\n\n/**\n * @internal\n */\nexport interface CreateTRPCNextBase<\n TRouter extends AnyRouter,\n TSSRContext extends NextPageContext,\n> {\n /**\n * @deprecated renamed to `useUtils` and will be removed in a future tRPC version\n *\n * @see https://trpc.io/docs/v11/client/react/useUtils\n */\n useContext(): CreateReactUtils<TRouter, TSSRContext>;\n /**\n * @see https://trpc.io/docs/v11/client/react/useUtils\n */\n useUtils(): CreateReactUtils<TRouter, TSSRContext>;\n withTRPC: ReturnType<typeof withTRPC<TRouter, TSSRContext>>;\n useQueries: TRPCUseQueries<TRouter>;\n useSuspenseQueries: TRPCUseSuspenseQueries<TRouter>;\n}\n\n/**\n * @internal\n */\nexport type CreateTRPCNext<\n TRouter extends AnyRouter,\n TSSRContext extends NextPageContext,\n> = ProtectedIntersection<\n CreateTRPCNextBase<TRouter, TSSRContext>,\n DecorateRouterRecord<\n TRouter['_def']['_config']['$types'],\n TRouter['_def']['record']\n >\n>;\n\nexport function createTRPCNext<\n TRouter extends AnyRouter,\n TSSRContext extends NextPageContext = NextPageContext,\n>(\n opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>,\n): CreateTRPCNext<TRouter, TSSRContext> {\n const hooks = createRootHooks<TRouter, TSSRContext>(opts);\n\n // TODO: maybe set TSSRContext to `never` when using `WithTRPCNoSSROptions`\n const _withTRPC = withTRPC(opts);\n\n const proxy = createReactDecoration(hooks) as DecorateRouterRecord<\n TRouter['_def']['_config']['$types'],\n TRouter['_def']['record']\n >;\n\n return createFlatProxy((key) => {\n if (key === 'useContext' || key === 'useUtils') {\n return () => {\n const context = hooks.useUtils();\n // create a stable reference of the utils context\n return useMemo(() => {\n return (createReactQueryUtils as any)(context);\n }, [context]);\n };\n }\n\n if (key === 'useQueries') {\n return hooks.useQueries;\n }\n\n if (key === 'useSuspenseQueries') {\n return hooks.useSuspenseQueries;\n }\n\n if (key === 'withTRPC') {\n return _withTRP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AAM,gBAAgB,MAAM,UAAU,gBACpC,YACF;GACA,MAAM,oBAAoB,SAAA,wBACrB,cAAc,eAAA,QAAA,0BAAA,KAAA,IAAA,wBAAa,CAAC,IAC7B;GAEJ,YAAA,eAAA,eAAA,CAAA,GACK,iBAAA,GACA,SACL;GACA,MAAM,mBAAmB,UACvB,QAAQ,EAAE,WAAW,MAAM,IAAI;GAEjC,OAAO,gBAAgB,SAAS;EAClC;EAIF,SAAS,cAAc,aAAA,QAAA,wBADH,UAAU,iBAAA,QAAA,0BAAA,KAAA,IAAA,wBAAe,UAAU,UAAA,QAAA,SAAA,KAAA,IAAA,OAAQ,YAChB;EAE/C,OAAO;CACT;AACF;;;;ACtIA,SAAgB,eAId,MACsC;CACtC,MAAM,QAAQ,gBAAsC,IAAI;CAGxD,MAAM,YAAY,SAAS,IAAI;CAE/B,MAAM,QAAQ,sBAAsB,KAAK;CAKzC,OAAO,iBAAiB,QAAQ;EAC9B,IAAI,QAAQ,gBAAgB,QAAQ,YAClC,aAAa;GACX,MAAM,UAAU,MAAM,SAAS;GAE/B,OAAO,cAAc;IACnB,OAAQ,sBAA8B,OAAO;GAC/C,GAAG,CAAC,OAAO,CAAC;EACd;EAGF,IAAI,QAAQ,cACV,OAAO,MAAM;EAGf,IAAI,QAAQ,sBACV,OAAO,MAAM;EAGf,IAAI,QAAQ,YACV,OAAO;EAGT,OAAO,MAAM;CACf,CAAC;AACH"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/withTRPC.tsx","../src/createTRPCNext.tsx"],"sourcesContent":["/**\n * Heavily based on urql's ssr\n * https://github.com/FormidableLabs/urql/blob/main/packages/next-urql/src/with-urql-client.ts\n */\nimport type { DehydratedState, QueryClient } from '@tanstack/react-query';\nimport { HydrationBoundary, QueryClientProvider } from '@tanstack/react-query';\nimport type {\n CreateTRPCClientOptions,\n TRPCClient,\n TRPCClientError,\n TRPCUntypedClient,\n} from '@trpc/client';\nimport type { CoercedTransformerParameters } from '@trpc/client/unstable-internals';\nimport {\n getTransformer,\n type TransformerOptions,\n} from '@trpc/client/unstable-internals';\nimport type {\n CreateTRPCReactOptions,\n CreateTRPCReactQueryClientConfig,\n} from '@trpc/react-query/shared';\nimport { createRootHooks, getQueryClient } from '@trpc/react-query/shared';\nimport type {\n AnyRouter,\n Dict,\n inferClientTypes,\n ResponseMeta,\n} from '@trpc/server/unstable-core-do-not-import';\nimport type {\n AppContextType,\n AppPropsType,\n NextComponentType,\n NextPageContext,\n} from 'next/dist/shared/lib/utils.js';\nimport type { NextRouter } from 'next/router';\nimport React, { useState } from 'react';\n\nexport type WithTRPCConfig<TRouter extends AnyRouter> =\n CreateTRPCClientOptions<TRouter> &\n CreateTRPCReactQueryClientConfig & {\n abortOnUnmount?: boolean;\n };\n\ntype WithTRPCOptions<TRouter extends AnyRouter> =\n CreateTRPCReactOptions<TRouter> & {\n config: (info: { ctx?: NextPageContext }) => WithTRPCConfig<TRouter>;\n } & TransformerOptions<inferClientTypes<TRouter>>;\n\nexport type TRPCPrepassHelper = (opts: {\n parent: WithTRPCSSROptions<AnyRouter>;\n WithTRPC: NextComponentType<any, any, any>;\n AppOrPage: NextComponentType<any, any, any>;\n}) => void;\nexport type WithTRPCSSROptions<TRouter extends AnyRouter> =\n WithTRPCOptions<TRouter> & {\n /**\n * If you enable this, you also need to add a `ssrPrepass`-prop\n * @see https://trpc.io/docs/client/nextjs/ssr\n */\n ssr:\n true | ((opts: { ctx: NextPageContext }) => boolean | Promise<boolean>);\n responseMeta?: (opts: {\n ctx: NextPageContext;\n clientErrors: TRPCClientError<TRouter>[];\n }) => ResponseMeta;\n /**\n * use `import { ssrPrepass } from '@trpc/next/ssrPrepass'`\n * @see https://trpc.io/docs/client/nextjs/ssr\n */\n ssrPrepass: TRPCPrepassHelper;\n };\n\nexport type WithTRPCNoSSROptions<TRouter extends AnyRouter> =\n WithTRPCOptions<TRouter> & {\n ssr?: false;\n };\n\nexport type TRPCPrepassProps<\n TRouter extends AnyRouter,\n TSSRContext extends NextPageContext = NextPageContext,\n> = {\n config: WithTRPCConfig<TRouter>;\n queryClient: QueryClient;\n trpcClient: TRPCUntypedClient<TRouter> | TRPCClient<TRouter>;\n ssrState: 'prepass';\n ssrContext: TSSRContext;\n};\n\nexport function withTRPC<\n TRouter extends AnyRouter,\n TSSRContext extends NextPageContext = NextPageContext,\n>(opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>) {\n const { config: getClientConfig } = opts;\n const transformer = getTransformer(\n (opts as CoercedTransformerParameters).transformer,\n );\n\n type $PrepassProps = TRPCPrepassProps<TRouter, TSSRContext>;\n return (AppOrPage: NextComponentType<any, any, any>): NextComponentType => {\n const trpc = createRootHooks<TRouter, TSSRContext>(opts);\n\n const WithTRPC = (\n props: AppPropsType<NextRouter, any> & {\n trpc?: $PrepassProps;\n },\n ) => {\n const [prepassProps] = useState(() => {\n if (props.trpc) {\n return props.trpc;\n }\n\n const config = getClientConfig({});\n const queryClient = getQueryClient(config);\n const trpcClient = trpc.createClient(config);\n\n return {\n abortOnUnmount: config.abortOnUnmount,\n queryClient,\n trpcClient,\n ssrState: opts.ssr ? ('mounting' as const) : (false as const),\n ssrContext: null,\n };\n });\n\n const { queryClient, trpcClient, ssrState, ssrContext } = prepassProps;\n\n // allow normal components to be wrapped, not just app/pages\n const trpcState = props.pageProps?.trpcState;\n\n const hydratedState: DehydratedState | undefined = React.useMemo(() => {\n if (!trpcState) {\n return trpcState;\n }\n\n return transformer.input.deserialize(trpcState);\n }, [trpcState]);\n\n return (\n <trpc.Provider\n abortOnUnmount={(prepassProps as any).abortOnUnmount ?? false}\n client={trpcClient}\n queryClient={queryClient}\n ssrState={ssrState}\n ssrContext={ssrContext}\n >\n <QueryClientProvider client={queryClient}>\n <HydrationBoundary state={hydratedState}>\n <AppOrPage {...props} />\n </HydrationBoundary>\n </QueryClientProvider>\n </trpc.Provider>\n );\n };\n\n if (opts.ssr) {\n opts.ssrPrepass({\n parent: opts,\n AppOrPage,\n WithTRPC,\n });\n } else if (AppOrPage.getInitialProps) {\n // Allow combining `getServerSideProps` and `getInitialProps`\n\n WithTRPC.getInitialProps = async (appOrPageCtx: AppContextType) => {\n // Determine if we are wrapping an App component or a Page component.\n const isApp = !!appOrPageCtx.Component;\n\n // Run the wrapped component's getInitialProps function.\n let pageProps: Dict<unknown> = {};\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const originalProps = await AppOrPage.getInitialProps!(\n appOrPageCtx as any,\n );\n const originalPageProps = isApp\n ? (originalProps.pageProps ?? {})\n : originalProps;\n\n pageProps = {\n ...originalPageProps,\n ...pageProps,\n };\n const getAppTreeProps = (props: Dict<unknown>) =>\n isApp ? { pageProps: props } : props;\n\n return getAppTreeProps(pageProps);\n };\n }\n\n const displayName = AppOrPage.displayName ?? AppOrPage.name ?? 'Component';\n WithTRPC.displayName = `withTRPC(${displayName})`;\n\n return WithTRPC as any;\n };\n}\n","/* istanbul ignore file -- @preserve */\n// We're testing this through E2E-testing\nimport type {\n CreateReactUtils,\n DecorateRouterRecord,\n TRPCUseQueries,\n TRPCUseSuspenseQueries,\n} from '@trpc/react-query/shared';\nimport {\n createReactDecoration,\n createReactQueryUtils,\n createRootHooks,\n} from '@trpc/react-query/shared';\nimport type {\n AnyRouter,\n ProtectedIntersection,\n} from '@trpc/server/unstable-core-do-not-import';\nimport { createFlatProxy } from '@trpc/server/unstable-core-do-not-import';\nimport type { NextPageContext } from 'next/types.js';\nimport { useMemo } from 'react';\nimport type { WithTRPCNoSSROptions, WithTRPCSSROptions } from './withTRPC';\nimport { withTRPC } from './withTRPC';\n\n/**\n * @internal\n */\nexport interface CreateTRPCNextBase<\n TRouter extends AnyRouter,\n TSSRContext extends NextPageContext,\n> {\n /**\n * @deprecated renamed to `useUtils` and will be removed in a future tRPC version\n *\n * @see https://trpc.io/docs/v11/client/react/useUtils\n */\n useContext(): CreateReactUtils<TRouter, TSSRContext>;\n /**\n * @see https://trpc.io/docs/v11/client/react/useUtils\n */\n useUtils(): CreateReactUtils<TRouter, TSSRContext>;\n withTRPC: ReturnType<typeof withTRPC<TRouter, TSSRContext>>;\n useQueries: TRPCUseQueries<TRouter>;\n useSuspenseQueries: TRPCUseSuspenseQueries<TRouter>;\n}\n\n/**\n * @internal\n */\nexport type CreateTRPCNext<\n TRouter extends AnyRouter,\n TSSRContext extends NextPageContext,\n> = ProtectedIntersection<\n CreateTRPCNextBase<TRouter, TSSRContext>,\n DecorateRouterRecord<\n TRouter['_def']['_config']['$types'],\n TRouter['_def']['record']\n >\n>;\n\nexport function createTRPCNext<\n TRouter extends AnyRouter,\n TSSRContext extends NextPageContext = NextPageContext,\n>(\n opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>,\n): CreateTRPCNext<TRouter, TSSRContext> {\n const hooks = createRootHooks<TRouter, TSSRContext>(opts);\n\n // TODO: maybe set TSSRContext to `never` when using `WithTRPCNoSSROptions`\n const _withTRPC = withTRPC(opts);\n\n const proxy = createReactDecoration(hooks) as DecorateRouterRecord<\n TRouter['_def']['_config']['$types'],\n TRouter['_def']['record']\n >;\n\n return createFlatProxy((key) => {\n if (key === 'useContext' || key === 'useUtils') {\n return () => {\n const context = hooks.useUtils();\n // create a stable reference of the utils context\n return useMemo(() => {\n return (createReactQueryUtils as any)(context);\n }, [context]);\n };\n }\n\n if (key === 'useQueries') {\n return hooks.useQueries;\n }\n\n if (key === 'useSuspenseQueries') {\n return hooks.useSuspenseQueries;\n }\n\n if (key === 'withTRPC') {\n return _withTRPC;\n }\n\n return proxy[key];\n });\n}\n"],"mappings":";;;;;;;AAwFA,SAAgB,SAGd,MAAmE;CACnE,MAAM,EAAE,QAAQ,oBAAoB;CACpC,MAAM,cAAc,eACjB,KAAsC,WACzC;CAGA,QAAQ,cAAmE;;EACzE,MAAM,OAAO,gBAAsC,IAAI;EAEvD,MAAM,YACJ,UAGG;;GACH,MAAM,CAAC,gBAAgB,eAAe;IACpC,IAAI,MAAM,MACR,OAAO,MAAM;IAGf,MAA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wBADH,UAAU,iBAAA,QAAA,0BAAA,KAAA,IAAA,wBAAe,UAAU,UAAA,QAAA,SAAA,KAAA,IAAA,OAAQ,YAChB;EAE/C,OAAO;CACT;AACF;;;;ACtIA,SAAgB,eAId,MACsC;CACtC,MAAM,QAAQ,gBAAsC,IAAI;CAGxD,MAAM,YAAY,SAAS,IAAI;CAE/B,MAAM,QAAQ,sBAAsB,KAAK;CAKzC,OAAO,iBAAiB,QAAQ;EAC9B,IAAI,QAAQ,gBAAgB,QAAQ,YAClC,aAAa;GACX,MAAM,UAAU,MAAM,SAAS;GAE/B,OAAO,cAAc;IACnB,OAAQ,sBAA8B,OAAO;GAC/C,GAAG,CAAC,OAAO,CAAC;EACd;EAGF,IAAI,QAAQ,cACV,OAAO,MAAM;EAGf,IAAI,QAAQ,sBACV,OAAO,MAAM;EAGf,IAAI,QAAQ,YACV,OAAO;EAGT,OAAO,MAAM;CACf,CAAC;AACH"}
@@ -1,4 +1,4 @@
1
- import { t as TRPCPrepassHelper } from "./withTRPC-DywCxFfq.cjs";
1
+ import { t as TRPCPrepassHelper } from "./withTRPC-Cr10aYRv.cjs";
2
2
  //#region src/ssrPrepass.d.ts
3
3
  export declare const ssrPrepass: TRPCPrepassHelper;
4
4
  //#endregion
@@ -1,4 +1,4 @@
1
- import { t as TRPCPrepassHelper } from "./withTRPC-BchtyodQ.mjs";
1
+ import { t as TRPCPrepassHelper } from "./withTRPC-CxGgngCY.mjs";
2
2
  //#region src/ssrPrepass.d.ts
3
3
  export declare const ssrPrepass: TRPCPrepassHelper;
4
4
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"ssrPrepass.mjs","names":[],"sources":["../src/ssrPrepass.ts"],"sourcesContent":["/**\n * Heavily based on urql's ssr\n * https://github.com/FormidableLabs/urql/blob/main/packages/next-urql/src/with-urql-client.ts\n */\nimport type { DehydratedState } from '@tanstack/react-query';\nimport { dehydrate } from '@tanstack/react-query';\nimport { createTRPCUntypedClient } from '@trpc/client';\nimport type { TRPCClientError, TRPCClientErrorLike } from '@trpc/client';\nimport type { CoercedTransformerParameters } from '@trpc/client/unstable-internals';\nimport { getTransformer } from '@trpc/client/unstable-internals';\nimport { getQueryClient } from '@trpc/react-query/shared';\nimport type {\n AnyRouter,\n Dict,\n Maybe,\n} from '@trpc/server/unstable-core-do-not-import';\nimport type {\n AppContextType,\n NextPageContext,\n} from 'next/dist/shared/lib/utils';\nimport { createElement } from 'react';\nimport type { TRPCPrepassHelper, TRPCPrepassProps } from './withTRPC';\n\nfunction transformQueryOrMutationCacheErrors<\n TState extends\n DehydratedState['mutations'][0] | DehydratedState['queries'][0],\n>(result: TState): TState {\n const error = result.state.error as Maybe<TRPCClientError<any>>;\n if (error instanceof Error && error.name === 'TRPCClientError') {\n const newError: TRPCClientErrorLike<any> = {\n message: error.message,\n data: error.data,\n shape: error.shape,\n };\n return {\n ...result,\n state: {\n ...result.state,\n error: newError,\n },\n };\n }\n return result;\n}\n\nexport const ssrPrepass: TRPCPrepassHelper = (opts) => {\n const { parent, WithTRPC, AppOrPage } = opts;\n type $PrepassProps = TRPCPrepassProps<AnyRouter, any>;\n\n const transformer = getTransformer(\n (parent as CoercedTransformerParameters).transformer,\n );\n WithTRPC.getInitialProps = async (appOrPageCtx: AppContextType) => {\n const shouldSsr = async () => {\n if (typeof window !== 'undefined') {\n return false;\n }\n if (typeof parent.ssr === 'function') {\n try {\n return await parent.ssr({ ctx: appOrPageCtx.ctx });\n } catch {\n return false;\n }\n }\n return parent.ssr;\n };\n const ssrEnabled = await shouldSsr();\n const AppTree = appOrPageCtx.AppTree;\n\n // Determine if we are wrapping an App component or a Page component.\n const isApp = !!appOrPageCtx.Component;\n const ctx: NextPageContext = isApp\n ? appOrPageCtx.ctx\n : (appOrPageCtx as any as NextPageContext);\n\n // Run the wrapped component's getInitialProps function.\n let pageProps: Dict<unknown> = {};\n if (AppOrPage.getInitialProps) {\n const originalProps = await AppOrPage.getInitialProps(\n appOrPageCtx as any,\n );\n const originalPageProps = isApp\n ? (originalProps.pageProps ?? {})\n : originalProps;\n\n pageProps = {\n ...originalPageProps,\n ...pageProps,\n };\n }\n const getAppTreeProps = (props: Record<string, unknown>) =>\n isApp ? { pageProps: props } : props;\n\n if (typeof window !== 'undefined' || !ssrEnabled) {\n return getAppTreeProps(pageProps);\n }\n\n const config = parent.config({ ctx });\n const trpcClient = createTRPCUntypedClient(config);\n const queryClient = getQueryClient(config);\n\n const trpcProp: $PrepassProps = {\n config,\n trpcClient,\n queryClient,\n ssrState: 'prepass',\n ssrContext: ctx,\n };\n const prepassProps = {\n pageProps,\n trpc: trpcProp,\n };\n\n const reactDomServer = await import('react-dom/server');\n\n // Run the prepass step on AppTree. This will run all trpc queries on the server.\n // multiple prepass ensures that we can do batching on the server\n while (true) {\n // render full tree\n reactDomServer.renderToString(createElement(AppTree, prepassProps));\n if (!queryClient.isFetching()) {\n // the render didn't cause the queryClient to fetch anything\n break;\n }\n\n // wait until the query cache has settled it's promises\n await new Promise<void>((resolve) => {\n const unsub = queryClient.getQueryCache().subscribe((event) => {\n if (event?.query.getObserversCount() === 0) {\n resolve();\n unsub();\n }\n });\n });\n }\n const dehydratedCache = dehydrate(queryClient, {\n shouldDehydrateQuery(query) {\n // filter out queries that are marked as trpc: { ssr: false } or are not enabled, but make sure errors are dehydrated\n const isExcludedFromSSr =\n query.state.fetchStatus === 'idle' &&\n query.state.status === 'pending';\n return !isExcludedFromSSr;\n },\n });\n // since error instances can't be serialized, let's make them into `TRPCClientErrorLike`-objects\n const dehydratedCacheWithErrors = {\n ...dehydratedCache,\n queries: dehydratedCache.queries.map(transformQueryOrMutationCacheErrors),\n mutations: dehydratedCache.mutations.map(\n transformQueryOrMutationCacheErrors,\n ),\n };\n\n // dehydrate query client's state and add it to the props\n pageProps['trpcState'] = transformer.input.serialize(\n dehydratedCacheWithErrors,\n );\n\n const appTreeProps = getAppTreeProps(pageProps);\n\n const meta =\n parent.responseMeta?.({\n ctx,\n clientErrors: [...dehydratedCache.queries, ...dehydratedCache.mutations]\n .map((v) => v.state.error)\n .flatMap((err) =>\n err instanceof Error && err.name === 'TRPCClientError'\n ? [err as TRPCClientError<AnyRouter>]\n : [],\n ),\n }) ?? {};\n\n for (const [key, value] of Object.entries(meta.headers ?? {})) {\n if (typeof value === 'string') {\n ctx.res?.setHeader(key, value);\n }\n }\n if (meta.status && ctx.res) {\n ctx.res.statusCode = meta.status;\n }\n\n return appTreeProps;\n };\n};\n"],"mappings":";;;;;;;AAuBA,SAAS,oCAGP,QAAwB;CACxB,MAAM,QAAQ,OAAO,MAAM;CAC3B,IAAI,iBAAiB,SAAS,MAAM,SAAS,mBAAmB;EAC9D,MAAM,WAAqC;GACzC,SAAS,MAAM;GACf,MAAM,MAAM;GACZ,OAAO,MAAM;EACf;EACA,OAAA,eAAA,eAAA,CAAA,GACK,MAAA,GAAA,CAAA,GAAA,EACH,OAAA,eAAA,eAAA,CAAA,GACK,OAAO,KAAA,GAAA,CAAA,GAAA,EACV,OAAO,SAAA,CACT,EAAA,CACF;CACF;CACA,OAAO;AACT;AAEA,MAAa,cAAiC,SAAS;CACrD,MAAM,EAAE,QAAQ,UAAU,cAAc;CAGxC,MAAM,cAAc,eACjB,OAAwC,WAC3C;CACA,SAAS,kBAAkB,OAAO,iBAAiC;;EACjE,MAAM,YAAY,YAAY;GAC5B,IAAI,OAAO,WAAW,aACpB,OAAO;GAET,IAAI,OAAO,OAAO,QAAQ,YACxB,IAAI;IACF,OAAO,MAAM,OAAO,IAAI,EAAE,KAAK,aAAa,IAAI,CAAC;GACnD,SAAA,SAAQ;IACN,OAAO;GACT;GAEF,OAAO,OAAO;EAChB;EACA,MAAM,aAAa,MAAM,UAAU;EACnC,MAAM,UAAU,aAAa;EAG7B,MAAM,QAAQ,CAAC,CAAC,aAAa;EAC7B,MAAM,MAAuB,QACzB,aAAa,MACZ;EAGL,IAAI,YAA2B,CAAC;EAChC,IAAI,UAAU,iBAAiB;;GAC7B,MAAM,gBAAgB,MAAM,UAAU,gBACpC,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,kBAAA,QAAA,0BAAA,KAAA,IAAA,KAAA,IAAA,sBAAA,KAAA,QAAe;GACpB;GACA,cAAc,CAAC,GAAG,gBAAgB,SAAS,GAAG,gBAAgB,SAAS,CAAC,CACrE,KAAK,MAAM,EAAE,MAAM,KAAK,CAAC,CACzB,SAAS,QACR,eAAe,SAAS,IAAI,SAAS,oBACjC,CAAC,GAAiC,IAClC,CAAC,CACP;EACJ,CAAC,OAAA,QAAA,yBAAA,KAAA,IAAA,uBAAK,CAAC;EAET,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,SAAA,gBAAQ,KAAK,aAAA,QAAA,kBAAA,KAAA,IAAA,gBAAW,CAAC,CAAC,GAC1D,IAAI,OAAO,UAAU,UAAU;;GAC7B,CAAA,WAAA,IAAI,SAAA,QAAA,aAAA,KAAA,KAAA,SAAK,UAAU,KAAK,KAAK;EAC/B;EAEF,IAAI,KAAK,UAAU,IAAI,KACrB,IAAI,IAAI,aAAa,KAAK;EAG5B,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"ssrPrepass.mjs","names":[],"sources":["../src/ssrPrepass.ts"],"sourcesContent":["/**\n * Heavily based on urql's ssr\n * https://github.com/FormidableLabs/urql/blob/main/packages/next-urql/src/with-urql-client.ts\n */\nimport type { DehydratedState } from '@tanstack/react-query';\nimport { dehydrate } from '@tanstack/react-query';\nimport { createTRPCUntypedClient } from '@trpc/client';\nimport type { TRPCClientError, TRPCClientErrorLike } from '@trpc/client';\nimport type { CoercedTransformerParameters } from '@trpc/client/unstable-internals';\nimport { getTransformer } from '@trpc/client/unstable-internals';\nimport { getQueryClient } from '@trpc/react-query/shared';\nimport type {\n AnyRouter,\n Dict,\n Maybe,\n} from '@trpc/server/unstable-core-do-not-import';\nimport type {\n AppContextType,\n NextPageContext,\n} from 'next/dist/shared/lib/utils.js';\nimport { createElement } from 'react';\nimport type { TRPCPrepassHelper, TRPCPrepassProps } from './withTRPC';\n\nfunction transformQueryOrMutationCacheErrors<\n TState extends\n DehydratedState['mutations'][0] | DehydratedState['queries'][0],\n>(result: TState): TState {\n const error = result.state.error as Maybe<TRPCClientError<any>>;\n if (error instanceof Error && error.name === 'TRPCClientError') {\n const newError: TRPCClientErrorLike<any> = {\n message: error.message,\n data: error.data,\n shape: error.shape,\n };\n return {\n ...result,\n state: {\n ...result.state,\n error: newError,\n },\n };\n }\n return result;\n}\n\nexport const ssrPrepass: TRPCPrepassHelper = (opts) => {\n const { parent, WithTRPC, AppOrPage } = opts;\n type $PrepassProps = TRPCPrepassProps<AnyRouter, any>;\n\n const transformer = getTransformer(\n (parent as CoercedTransformerParameters).transformer,\n );\n WithTRPC.getInitialProps = async (appOrPageCtx: AppContextType) => {\n const shouldSsr = async () => {\n if (typeof window !== 'undefined') {\n return false;\n }\n if (typeof parent.ssr === 'function') {\n try {\n return await parent.ssr({ ctx: appOrPageCtx.ctx });\n } catch {\n return false;\n }\n }\n return parent.ssr;\n };\n const ssrEnabled = await shouldSsr();\n const AppTree = appOrPageCtx.AppTree;\n\n // Determine if we are wrapping an App component or a Page component.\n const isApp = !!appOrPageCtx.Component;\n const ctx: NextPageContext = isApp\n ? appOrPageCtx.ctx\n : (appOrPageCtx as any as NextPageContext);\n\n // Run the wrapped component's getInitialProps function.\n let pageProps: Dict<unknown> = {};\n if (AppOrPage.getInitialProps) {\n const originalProps = await AppOrPage.getInitialProps(\n appOrPageCtx as any,\n );\n const originalPageProps = isApp\n ? (originalProps.pageProps ?? {})\n : originalProps;\n\n pageProps = {\n ...originalPageProps,\n ...pageProps,\n };\n }\n const getAppTreeProps = (props: Record<string, unknown>) =>\n isApp ? { pageProps: props } : props;\n\n if (typeof window !== 'undefined' || !ssrEnabled) {\n return getAppTreeProps(pageProps);\n }\n\n const config = parent.config({ ctx });\n const trpcClient = createTRPCUntypedClient(config);\n const queryClient = getQueryClient(config);\n\n const trpcProp: $PrepassProps = {\n config,\n trpcClient,\n queryClient,\n ssrState: 'prepass',\n ssrContext: ctx,\n };\n const prepassProps = {\n pageProps,\n trpc: trpcProp,\n };\n\n const reactDomServer = await import('react-dom/server');\n\n // Run the prepass step on AppTree. This will run all trpc queries on the server.\n // multiple prepass ensures that we can do batching on the server\n while (true) {\n // render full tree\n reactDomServer.renderToString(createElement(AppTree, prepassProps));\n if (!queryClient.isFetching()) {\n // the render didn't cause the queryClient to fetch anything\n break;\n }\n\n // wait until the query cache has settled it's promises\n await new Promise<void>((resolve) => {\n const unsub = queryClient.getQueryCache().subscribe((event) => {\n if (event?.query.getObserversCount() === 0) {\n resolve();\n unsub();\n }\n });\n });\n }\n const dehydratedCache = dehydrate(queryClient, {\n shouldDehydrateQuery(query) {\n // filter out queries that are marked as trpc: { ssr: false } or are not enabled, but make sure errors are dehydrated\n const isExcludedFromSSr =\n query.state.fetchStatus === 'idle' &&\n query.state.status === 'pending';\n return !isExcludedFromSSr;\n },\n });\n // since error instances can't be serialized, let's make them into `TRPCClientErrorLike`-objects\n const dehydratedCacheWithErrors = {\n ...dehydratedCache,\n queries: dehydratedCache.queries.map(transformQueryOrMutationCacheErrors),\n mutations: dehydratedCache.mutations.map(\n transformQueryOrMutationCacheErrors,\n ),\n };\n\n // dehydrate query client's state and add it to the props\n pageProps['trpcState'] = transformer.input.serialize(\n dehydratedCacheWithErrors,\n );\n\n const appTreeProps = getAppTreeProps(pageProps);\n\n const meta =\n parent.responseMeta?.({\n ctx,\n clientErrors: [...dehydratedCache.queries, ...dehydratedCache.mutations]\n .map((v) => v.state.error)\n .flatMap((err) =>\n err instanceof Error && err.name === 'TRPCClientError'\n ? [err as TRPCClientError<AnyRouter>]\n : [],\n ),\n }) ?? {};\n\n for (const [key, value] of Object.entries(meta.headers ?? {})) {\n if (typeof value === 'string') {\n ctx.res?.setHeader(key, value);\n }\n }\n if (meta.status && ctx.res) {\n ctx.res.statusCode = meta.status;\n }\n\n return appTreeProps;\n };\n};\n"],"mappings":";;;;;;;AAuBA,SAAS,oCAGP,QAAwB;CACxB,MAAM,QAAQ,OAAO,MAAM;CAC3B,I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,gBAAQ,KAAK,aAAA,QAAA,kBAAA,KAAA,IAAA,gBAAW,CAAC,CAAC,GAC1D,IAAI,OAAO,UAAU,UAAU;;GAC7B,CAAA,WAAA,IAAI,SAAA,QAAA,aAAA,KAAA,KAAA,SAAK,UAAU,KAAK,KAAK;EAC/B;EAEF,IAAI,KAAK,UAAU,IAAI,KACrB,IAAI,IAAI,aAAa,KAAK;EAG5B,OAAO;CACT;AACF"}
@@ -1,9 +1,9 @@
1
- import { QueryClient } from "@tanstack/react-query";
1
+ import { CreateTRPCClientOptions, TRPCClient, TRPCClientError, TRPCUntypedClient } from "@trpc/client";
2
+ import { AnyRouter, ResponseMeta, inferClientTypes } from "@trpc/server/unstable-core-do-not-import";
2
3
  import { TransformerOptions } from "@trpc/client/unstable-internals";
4
+ import { QueryClient } from "@tanstack/react-query";
3
5
  import { CreateTRPCReactOptions, CreateTRPCReactQueryClientConfig } from "@trpc/react-query/shared";
4
- import { AnyRouter, ResponseMeta, inferClientTypes } from "@trpc/server/unstable-core-do-not-import";
5
- import { CreateTRPCClientOptions, TRPCClient, TRPCClientError, TRPCUntypedClient } from "@trpc/client";
6
- import { NextComponentType, NextPageContext } from "next/dist/shared/lib/utils";
6
+ import { NextComponentType, NextPageContext } from "next/dist/shared/lib/utils.js";
7
7
  //#region src/withTRPC.d.ts
8
8
  type WithTRPCConfig<TRouter extends AnyRouter> = CreateTRPCClientOptions<TRouter> & CreateTRPCReactQueryClientConfig & {
9
9
  abortOnUnmount?: boolean;
@@ -49,4 +49,4 @@ type TRPCPrepassProps<TRouter extends AnyRouter, TSSRContext extends NextPageCon
49
49
  declare function withTRPC<TRouter extends AnyRouter, TSSRContext extends NextPageContext = NextPageContext>(opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>): (AppOrPage: NextComponentType<any, any, any>) => NextComponentType;
50
50
  //#endregion
51
51
  export { WithTRPCSSROptions as a, WithTRPCNoSSROptions as i, TRPCPrepassProps as n, withTRPC as o, WithTRPCConfig as r, TRPCPrepassHelper as t };
52
- //# sourceMappingURL=withTRPC-BchtyodQ.d.mts.map
52
+ //# sourceMappingURL=withTRPC-Cr10aYRv.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"withTRPC-BchtyodQ.d.mts","names":[],"sources":["../src/withTRPC.tsx"],"mappings":";;;;;;;KAqCY,eAAe,gBAAgB,aACzC,wBAAwB,WACtB;EACE;;KAGD,gBAAgB,gBAAgB,aACnC,uBAAuB;EACrB,SAAS;IAAQ,MAAM;QAAsB,eAAe;IAC1D,mBAAmB,iBAAiB;KAE9B,qBAAqB;EAC/B,QAAQ,mBAAmB;EAC3B,UAAU;EACV,WAAW;;KAED,mBAAmB,gBAAgB,aAC7C,gBAAgB;;;;;EAKd,cACW;IAAQ,KAAK;kBAAgC;EACxD,gBAAgB;IACd,KAAK;IACL,cAAc,gBAAgB;QAC1B;;;;;EAKN,YAAY;;KAGJ,qBAAqB,gBAAgB,aAC/C,gBAAgB;EACd;;KAGQ,iBACV,gBAAgB,WAChB,oBAAoB,kBAAkB;EAEtC,QAAQ,eAAe;EACvB,aAAa;EACb,YAAY,kBAAkB,WAAW,WAAW;EACpD;EACA,YAAY;;iBAGE,SACd,gBAAgB,WAChB,oBAAoB,kBAAkB,iBACtC,MAAM,qBAAqB,WAAW,mBAAmB,YAAQ,WAO9C,qCAAmC"}
1
+ {"version":3,"file":"withTRPC-Cr10aYRv.d.cts","names":[],"sources":["../src/withTRPC.tsx"],"mappings":";;;;;;;KAqCY,eAAe,gBAAgB,aACzC,wBAAwB,WACtB;EACE;;KAGD,gBAAgB,gBAAgB,aACnC,uBAAuB;EACrB,SAAS;IAAQ,MAAM;QAAsB,eAAe;IAC1D,mBAAmB,iBAAiB;KAE9B,qBAAqB;EAC/B,QAAQ,mBAAmB;EAC3B,UAAU;EACV,WAAW;;KAED,mBAAmB,gBAAgB,aAC7C,gBAAgB;;;;;EAKd,cACW;IAAQ,KAAK;kBAAgC;EACxD,gBAAgB;IACd,KAAK;IACL,cAAc,gBAAgB;QAC1B;;;;;EAKN,YAAY;;KAGJ,qBAAqB,gBAAgB,aAC/C,gBAAgB;EACd;;KAGQ,iBACV,gBAAgB,WAChB,oBAAoB,kBAAkB;EAEtC,QAAQ,eAAe;EACvB,aAAa;EACb,YAAY,kBAAkB,WAAW,WAAW;EACpD;EACA,YAAY;;iBAGE,SACd,gBAAgB,WAChB,oBAAoB,kBAAkB,iBACtC,MAAM,qBAAqB,WAAW,mBAAmB,YAAQ,WAO9C,qCAAmC"}
@@ -1,9 +1,9 @@
1
- import { CreateTRPCClientOptions, TRPCClient, TRPCClientError, TRPCUntypedClient } from "@trpc/client";
2
- import { AnyRouter, ResponseMeta, inferClientTypes } from "@trpc/server/unstable-core-do-not-import";
3
- import { TransformerOptions } from "@trpc/client/unstable-internals";
4
1
  import { QueryClient } from "@tanstack/react-query";
2
+ import { TransformerOptions } from "@trpc/client/unstable-internals";
5
3
  import { CreateTRPCReactOptions, CreateTRPCReactQueryClientConfig } from "@trpc/react-query/shared";
6
- import { NextComponentType, NextPageContext } from "next/dist/shared/lib/utils";
4
+ import { AnyRouter, ResponseMeta, inferClientTypes } from "@trpc/server/unstable-core-do-not-import";
5
+ import { CreateTRPCClientOptions, TRPCClient, TRPCClientError, TRPCUntypedClient } from "@trpc/client";
6
+ import { NextComponentType, NextPageContext } from "next/dist/shared/lib/utils.js";
7
7
  //#region src/withTRPC.d.ts
8
8
  type WithTRPCConfig<TRouter extends AnyRouter> = CreateTRPCClientOptions<TRouter> & CreateTRPCReactQueryClientConfig & {
9
9
  abortOnUnmount?: boolean;
@@ -49,4 +49,4 @@ type TRPCPrepassProps<TRouter extends AnyRouter, TSSRContext extends NextPageCon
49
49
  declare function withTRPC<TRouter extends AnyRouter, TSSRContext extends NextPageContext = NextPageContext>(opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>): (AppOrPage: NextComponentType<any, any, any>) => NextComponentType;
50
50
  //#endregion
51
51
  export { WithTRPCSSROptions as a, WithTRPCNoSSROptions as i, TRPCPrepassProps as n, withTRPC as o, WithTRPCConfig as r, TRPCPrepassHelper as t };
52
- //# sourceMappingURL=withTRPC-DywCxFfq.d.cts.map
52
+ //# sourceMappingURL=withTRPC-CxGgngCY.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"withTRPC-DywCxFfq.d.cts","names":[],"sources":["../src/withTRPC.tsx"],"mappings":";;;;;;;KAqCY,eAAe,gBAAgB,aACzC,wBAAwB,WACtB;EACE;;KAGD,gBAAgB,gBAAgB,aACnC,uBAAuB;EACrB,SAAS;IAAQ,MAAM;QAAsB,eAAe;IAC1D,mBAAmB,iBAAiB;KAE9B,qBAAqB;EAC/B,QAAQ,mBAAmB;EAC3B,UAAU;EACV,WAAW;;KAED,mBAAmB,gBAAgB,aAC7C,gBAAgB;;;;;EAKd,cACW;IAAQ,KAAK;kBAAgC;EACxD,gBAAgB;IACd,KAAK;IACL,cAAc,gBAAgB;QAC1B;;;;;EAKN,YAAY;;KAGJ,qBAAqB,gBAAgB,aAC/C,gBAAgB;EACd;;KAGQ,iBACV,gBAAgB,WAChB,oBAAoB,kBAAkB;EAEtC,QAAQ,eAAe;EACvB,aAAa;EACb,YAAY,kBAAkB,WAAW,WAAW;EACpD;EACA,YAAY;;iBAGE,SACd,gBAAgB,WAChB,oBAAoB,kBAAkB,iBACtC,MAAM,qBAAqB,WAAW,mBAAmB,YAAQ,WAO9C,qCAAmC"}
1
+ {"version":3,"file":"withTRPC-CxGgngCY.d.mts","names":[],"sources":["../src/withTRPC.tsx"],"mappings":";;;;;;;KAqCY,eAAe,gBAAgB,aACzC,wBAAwB,WACtB;EACE;;KAGD,gBAAgB,gBAAgB,aACnC,uBAAuB;EACrB,SAAS;IAAQ,MAAM;QAAsB,eAAe;IAC1D,mBAAmB,iBAAiB;KAE9B,qBAAqB;EAC/B,QAAQ,mBAAmB;EAC3B,UAAU;EACV,WAAW;;KAED,mBAAmB,gBAAgB,aAC7C,gBAAgB;;;;;EAKd,cACW;IAAQ,KAAK;kBAAgC;EACxD,gBAAgB;IACd,KAAK;IACL,cAAc,gBAAgB;QAC1B;;;;;EAKN,YAAY;;KAGJ,qBAAqB,gBAAgB,aAC/C,gBAAgB;EACd;;KAGQ,iBACV,gBAAgB,WAChB,oBAAoB,kBAAkB;EAEtC,QAAQ,eAAe;EACvB,aAAa;EACb,YAAY,kBAAkB,WAAW,WAAW;EACpD;EACA,YAAY;;iBAGE,SACd,gBAAgB,WAChB,oBAAoB,kBAAkB,iBACtC,MAAM,qBAAqB,WAAW,mBAAmB,YAAQ,WAO9C,qCAAmC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@trpc/next",
4
- "version": "11.22.1",
4
+ "version": "11.22.2-canary.6.9959a177b",
5
5
  "description": "The tRPC Next.js library",
6
6
  "author": "KATT",
7
7
  "license": "MIT",
@@ -107,9 +107,9 @@
107
107
  ],
108
108
  "peerDependencies": {
109
109
  "@tanstack/react-query": "^5.59.15",
110
- "@trpc/client": "11.22.1",
111
- "@trpc/react-query": "11.22.1",
112
- "@trpc/server": "11.22.1",
110
+ "@trpc/client": "11.22.2-canary.6.9959a177b",
111
+ "@trpc/react-query": "11.22.2-canary.6.9959a177b",
112
+ "@trpc/server": "11.22.2-canary.6.9959a177b",
113
113
  "next": "*",
114
114
  "react": ">=16.8.0",
115
115
  "react-dom": ">=16.8.0",
@@ -126,9 +126,9 @@
126
126
  "devDependencies": {
127
127
  "@tanstack/intent": "^0.0.27",
128
128
  "@tanstack/react-query": "^5.80.3",
129
- "@trpc/client": "11.22.1",
130
- "@trpc/react-query": "11.22.1",
131
- "@trpc/server": "11.22.1",
129
+ "@trpc/client": "11.22.2-canary.6.9959a177b",
130
+ "@trpc/react-query": "11.22.2-canary.6.9959a177b",
131
+ "@trpc/server": "11.22.2-canary.6.9959a177b",
132
132
  "@types/express": "^5.0.0",
133
133
  "@types/node": "^24.13.4",
134
134
  "@types/react": "^19.1.0",
@@ -155,5 +155,5 @@
155
155
  "bin": {
156
156
  "intent": "./bin/intent.js"
157
157
  },
158
- "gitHead": "708753ff1383c47c5f765694978db1000a86ee36"
158
+ "gitHead": "9959a177b324249335d224bca5ec5ef549636199"
159
159
  }
@@ -16,7 +16,7 @@ import type {
16
16
  ProtectedIntersection,
17
17
  } from '@trpc/server/unstable-core-do-not-import';
18
18
  import { createFlatProxy } from '@trpc/server/unstable-core-do-not-import';
19
- import type { NextPageContext } from 'next/types';
19
+ import type { NextPageContext } from 'next/types.js';
20
20
  import { useMemo } from 'react';
21
21
  import type { WithTRPCNoSSROptions, WithTRPCSSROptions } from './withTRPC';
22
22
  import { withTRPC } from './withTRPC';
package/src/ssrPrepass.ts CHANGED
@@ -17,7 +17,7 @@ import type {
17
17
  import type {
18
18
  AppContextType,
19
19
  NextPageContext,
20
- } from 'next/dist/shared/lib/utils';
20
+ } from 'next/dist/shared/lib/utils.js';
21
21
  import { createElement } from 'react';
22
22
  import type { TRPCPrepassHelper, TRPCPrepassProps } from './withTRPC';
23
23
 
package/src/withTRPC.tsx CHANGED
@@ -31,7 +31,7 @@ import type {
31
31
  AppPropsType,
32
32
  NextComponentType,
33
33
  NextPageContext,
34
- } from 'next/dist/shared/lib/utils';
34
+ } from 'next/dist/shared/lib/utils.js';
35
35
  import type { NextRouter } from 'next/router';
36
36
  import React, { useState } from 'react';
37
37