@trpc/next 11.4.1 → 11.4.2
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/app-dir/client.cjs +15 -18
- package/dist/app-dir/client.d.mts +1 -1
- package/dist/app-dir/client.mjs +14 -17
- package/dist/app-dir/client.mjs.map +1 -1
- package/dist/app-dir/links/nextCache.cjs +4 -3
- package/dist/app-dir/links/nextCache.mjs +3 -2
- package/dist/app-dir/links/nextCache.mjs.map +1 -1
- package/dist/app-dir/links/nextHttp.cjs +11 -17
- package/dist/app-dir/links/nextHttp.mjs +10 -16
- package/dist/app-dir/links/nextHttp.mjs.map +1 -1
- package/dist/app-dir/server.cjs +7 -5
- package/dist/app-dir/server.d.mts +1 -1
- package/dist/app-dir/server.mjs +6 -4
- package/dist/app-dir/server.mjs.map +1 -1
- package/dist/{chunk-CUT6urMc.cjs → chunk-DWy1uDak.cjs} +9 -0
- package/dist/index.cjs +12 -10
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +11 -9
- package/dist/index.mjs.map +1 -1
- package/dist/objectSpread2-3tHFGdJc.mjs +114 -0
- package/dist/objectSpread2-3tHFGdJc.mjs.map +1 -0
- package/dist/objectSpread2-CGXFkI72.cjs +94 -0
- package/dist/{server.d-BXv5jwlB.d.mts → server.d-C5p0ZwB7.d.mts} +1 -1
- package/dist/{server.d-BXv5jwlB.d.mts.map → server.d-C5p0ZwB7.d.mts.map} +1 -1
- package/dist/{shared-FEQznZ-6.mjs → shared-Bco66qhk.mjs} +1 -1
- package/dist/{shared-FEQznZ-6.mjs.map → shared-Bco66qhk.mjs.map} +1 -1
- package/dist/{shared-C9SS-IYg.cjs → shared-COdt67yK.cjs} +1 -1
- package/dist/ssrPrepass.cjs +18 -21
- package/dist/ssrPrepass.d.mts +1 -1
- package/dist/ssrPrepass.mjs +17 -20
- package/dist/ssrPrepass.mjs.map +1 -1
- package/dist/{withTRPC.d-BY6FsDWi.d.mts → withTRPC.d-B3f3A0sf.d.mts} +1 -1
- package/dist/{withTRPC.d-BY6FsDWi.d.mts.map → withTRPC.d-B3f3A0sf.d.mts.map} +1 -1
- package/package.json +8 -8
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __toESM, require_objectSpread2 } from "./objectSpread2-3tHFGdJc.mjs";
|
|
1
2
|
import { HydrationBoundary, QueryClientProvider } from "@tanstack/react-query";
|
|
2
3
|
import { getTransformer } from "@trpc/client/unstable-internals";
|
|
3
4
|
import { createReactDecoration, createReactQueryUtils, createRootHooks, getQueryClient } from "@trpc/react-query/shared";
|
|
@@ -6,12 +7,15 @@ import { jsx } from "react/jsx-runtime";
|
|
|
6
7
|
import { createFlatProxy } from "@trpc/server/unstable-core-do-not-import";
|
|
7
8
|
|
|
8
9
|
//#region src/withTRPC.tsx
|
|
10
|
+
var import_objectSpread2 = __toESM(require_objectSpread2());
|
|
9
11
|
function withTRPC(opts) {
|
|
10
12
|
const { config: getClientConfig } = opts;
|
|
11
13
|
const transformer = getTransformer(opts.transformer);
|
|
12
14
|
return (AppOrPage) => {
|
|
15
|
+
var _ref, _AppOrPage$displayNam;
|
|
13
16
|
const trpc = createRootHooks(opts);
|
|
14
17
|
const WithTRPC = (props) => {
|
|
18
|
+
var _props$pageProps, _abortOnUnmount;
|
|
15
19
|
const [prepassProps] = useState(() => {
|
|
16
20
|
if (props.trpc) return props.trpc;
|
|
17
21
|
const config = getClientConfig({});
|
|
@@ -26,13 +30,13 @@ function withTRPC(opts) {
|
|
|
26
30
|
};
|
|
27
31
|
});
|
|
28
32
|
const { queryClient, trpcClient, ssrState, ssrContext } = prepassProps;
|
|
29
|
-
const trpcState = props.pageProps
|
|
33
|
+
const trpcState = (_props$pageProps = props.pageProps) === null || _props$pageProps === void 0 ? void 0 : _props$pageProps.trpcState;
|
|
30
34
|
const hydratedState = React.useMemo(() => {
|
|
31
35
|
if (!trpcState) return trpcState;
|
|
32
36
|
return transformer.input.deserialize(trpcState);
|
|
33
37
|
}, [trpcState]);
|
|
34
38
|
return /* @__PURE__ */ jsx(trpc.Provider, {
|
|
35
|
-
abortOnUnmount: prepassProps.abortOnUnmount
|
|
39
|
+
abortOnUnmount: (_abortOnUnmount = prepassProps.abortOnUnmount) !== null && _abortOnUnmount !== void 0 ? _abortOnUnmount : false,
|
|
36
40
|
client: trpcClient,
|
|
37
41
|
queryClient,
|
|
38
42
|
ssrState,
|
|
@@ -41,7 +45,7 @@ function withTRPC(opts) {
|
|
|
41
45
|
client: queryClient,
|
|
42
46
|
children: /* @__PURE__ */ jsx(HydrationBoundary, {
|
|
43
47
|
state: hydratedState,
|
|
44
|
-
children: /* @__PURE__ */ jsx(AppOrPage, {
|
|
48
|
+
children: /* @__PURE__ */ jsx(AppOrPage, (0, import_objectSpread2.default)({}, props))
|
|
45
49
|
})
|
|
46
50
|
})
|
|
47
51
|
});
|
|
@@ -52,18 +56,16 @@ function withTRPC(opts) {
|
|
|
52
56
|
WithTRPC
|
|
53
57
|
});
|
|
54
58
|
else if (AppOrPage.getInitialProps) WithTRPC.getInitialProps = async (appOrPageCtx) => {
|
|
59
|
+
var _originalProps$pagePr;
|
|
55
60
|
const isApp = !!appOrPageCtx.Component;
|
|
56
61
|
let pageProps = {};
|
|
57
62
|
const originalProps = await AppOrPage.getInitialProps(appOrPageCtx);
|
|
58
|
-
const originalPageProps = isApp ? originalProps.pageProps
|
|
59
|
-
pageProps = {
|
|
60
|
-
...originalPageProps,
|
|
61
|
-
...pageProps
|
|
62
|
-
};
|
|
63
|
+
const originalPageProps = isApp ? (_originalProps$pagePr = originalProps.pageProps) !== null && _originalProps$pagePr !== void 0 ? _originalProps$pagePr : {} : originalProps;
|
|
64
|
+
pageProps = (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, originalPageProps), pageProps);
|
|
63
65
|
const getAppTreeProps = (props) => isApp ? { pageProps: props } : props;
|
|
64
66
|
return getAppTreeProps(pageProps);
|
|
65
67
|
};
|
|
66
|
-
const displayName = AppOrPage.displayName
|
|
68
|
+
const displayName = (_ref = (_AppOrPage$displayNam = AppOrPage.displayName) !== null && _AppOrPage$displayNam !== void 0 ? _AppOrPage$displayNam : AppOrPage.name) !== null && _ref !== void 0 ? _ref : "Component";
|
|
67
69
|
WithTRPC.displayName = `withTRPC(${displayName})`;
|
|
68
70
|
return WithTRPC;
|
|
69
71
|
};
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>","AppOrPage: NextComponentType<any, any, any>","props: AppPropsType<NextRouter, any> & {\n trpc?: $PrepassProps;\n }","queryClient","trpcClient","hydratedState: DehydratedState | undefined","appOrPageCtx: AppContextType","pageProps: Dict<unknown>","props: Dict<unknown>","opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>"],"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\n | ((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 _withTRPC;\n }\n\n return proxy[key];\n });\n}\n"],"mappings":";;;;;;;;AAyFA,SAAgB,SAGdA,MAAmE;CACnE,MAAM,EAAE,QAAQ,iBAAiB,GAAG;CACpC,MAAM,cAAc,eACjB,KAAsC,YACxC;AAGD,QAAO,CAACC,cAAmE;EACzE,MAAM,OAAO,gBAAsC,KAAK;EAExD,MAAM,WAAW,CACfC,UAGG;GACH,MAAM,CAAC,aAAa,GAAG,SAAS,MAAM;AACpC,QAAI,MAAM,KACR,QAAO,MAAM;IAGf,MAAM,SAAS,gBAAgB,CAAE,EAAC;IAClC,MAAMC,gBAAc,eAAe,OAAO;IAC1C,MAAMC,eAAa,KAAK,aAAa,OAAO;AAE5C,WAAO;KACL,gBAAgB,OAAO;KACvB;KACA;KACA,UAAU,KAAK,MAAO,aAAwB;KAC9C,YAAY;IACb;GACF,EAAC;GAEF,MAAM,EAAE,aAAa,YAAY,UAAU,YAAY,GAAG;GAG1D,MAAM,YAAY,MAAM,WAAW;GAEnC,MAAMC,gBAA6C,MAAM,QAAQ,MAAM;AACrE,SAAK,UACH,QAAO;AAGT,WAAO,YAAY,MAAM,YAAY,UAAU;GAChD,GAAE,CAAC,SAAU,EAAC;AAEf,0BACE,IAAC,KAAK;IACJ,gBAAiB,aAAqB,kBAAkB;IACxD,QAAQ;IACK;IACH;IACE;8BAEZ,IAAC;KAAoB,QAAQ;+BAC3B,IAAC;MAAkB,OAAO;gCACxB,IAAC,aAAU,GAAI,QAAS;OACN;MACA;KACR;EAEnB;AAED,MAAI,KAAK,IACP,MAAK,WAAW;GACd,QAAQ;GACR;GACA;EACD,EAAC;WACO,UAAU,gBAGnB,UAAS,kBAAkB,OAAOC,iBAAiC;GAEjE,MAAM,UAAU,aAAa;GAG7B,IAAIC,YAA2B,CAAE;GAEjC,MAAM,gBAAgB,MAAM,UAAU,gBACpC,aACD;GACD,MAAM,oBAAoB,QACrB,cAAc,aAAa,CAAE,IAC9B;AAEJ,eAAY;IACV,GAAG;IACH,GAAG;GACJ;GACD,MAAM,kBAAkB,CAACC,UACvB,QAAQ,EAAE,WAAW,MAAO,IAAG;AAEjC,UAAO,gBAAgB,UAAU;EAClC;EAGH,MAAM,cAAc,UAAU,eAAe,UAAU,QAAQ;AAC/D,WAAS,eAAe,WAAW,YAAY;AAE/C,SAAO;CACR;AACF;;;;ACvID,SAAgB,eAIdC,MACsC;CACtC,MAAM,QAAQ,gBAAsC,KAAK;CAGzD,MAAM,YAAY,SAAS,KAAK;CAEhC,MAAM,QAAQ,sBAAsB,MAAM;AAK1C,QAAO,gBAAgB,CAAC,QAAQ;AAC9B,MAAI,QAAQ,gBAAgB,QAAQ,WAClC,QAAO,MAAM;GACX,MAAM,UAAU,MAAM,UAAU;AAEhC,UAAO,QAAQ,MAAM;AACnB,WAAO,AAAC,sBAA8B,QAAQ;GAC/C,GAAE,CAAC,OAAQ,EAAC;EACd;AAGH,MAAI,QAAQ,aACV,QAAO,MAAM;AAGf,MAAI,QAAQ,qBACV,QAAO,MAAM;AAGf,MAAI,QAAQ,WACV,QAAO;AAGT,SAAO,MAAM;CACd,EAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>","AppOrPage: NextComponentType<any, any, any>","props: AppPropsType<NextRouter, any> & {\n trpc?: $PrepassProps;\n }","queryClient","trpcClient","hydratedState: DehydratedState | undefined","appOrPageCtx: AppContextType","pageProps: Dict<unknown>","props: Dict<unknown>","opts: WithTRPCNoSSROptions<TRouter> | WithTRPCSSROptions<TRouter>"],"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\n | ((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 _withTRPC;\n }\n\n return proxy[key];\n });\n}\n"],"mappings":";;;;;;;;;;AAyFA,SAAgB,SAGdA,MAAmE;CACnE,MAAM,EAAE,QAAQ,iBAAiB,GAAG;CACpC,MAAM,cAAc,eACjB,KAAsC,YACxC;AAGD,QAAO,CAACC,cAAmE;;EACzE,MAAM,OAAO,gBAAsC,KAAK;EAExD,MAAM,WAAW,CACfC,UAGG;;GACH,MAAM,CAAC,aAAa,GAAG,SAAS,MAAM;AACpC,QAAI,MAAM,KACR,QAAO,MAAM;IAGf,MAAM,SAAS,gBAAgB,CAAE,EAAC;IAClC,MAAMC,gBAAc,eAAe,OAAO;IAC1C,MAAMC,eAAa,KAAK,aAAa,OAAO;AAE5C,WAAO;KACL,gBAAgB,OAAO;KACvB;KACA;KACA,UAAU,KAAK,MAAO,aAAwB;KAC9C,YAAY;IACb;GACF,EAAC;GAEF,MAAM,EAAE,aAAa,YAAY,UAAU,YAAY,GAAG;GAG1D,MAAM,gCAAY,MAAM,+EAAW;GAEnC,MAAMC,gBAA6C,MAAM,QAAQ,MAAM;AACrE,SAAK,UACH,QAAO;AAGT,WAAO,YAAY,MAAM,YAAY,UAAU;GAChD,GAAE,CAAC,SAAU,EAAC;AAEf,0BACE,IAAC,KAAK;IACJ,mCAAiB,aAAqB,2EAAkB;IACxD,QAAQ;IACK;IACH;IACE;8BAEZ,IAAC;KAAoB,QAAQ;+BAC3B,IAAC;MAAkB,OAAO;gCACxB,IAAC,iDAAc,OAAS;OACN;MACA;KACR;EAEnB;AAED,MAAI,KAAK,IACP,MAAK,WAAW;GACd,QAAQ;GACR;GACA;EACD,EAAC;WACO,UAAU,gBAGnB,UAAS,kBAAkB,OAAOC,iBAAiC;;GAEjE,MAAM,UAAU,aAAa;GAG7B,IAAIC,YAA2B,CAAE;GAEjC,MAAM,gBAAgB,MAAM,UAAU,gBACpC,aACD;GACD,MAAM,oBAAoB,iCACrB,cAAc,kFAAa,CAAE,IAC9B;AAEJ,uFACK,oBACA;GAEL,MAAM,kBAAkB,CAACC,UACvB,QAAQ,EAAE,WAAW,MAAO,IAAG;AAEjC,UAAO,gBAAgB,UAAU;EAClC;EAGH,MAAM,+CAAc,UAAU,oFAAe,UAAU,2CAAQ;AAC/D,WAAS,eAAe,WAAW,YAAY;AAE/C,SAAO;CACR;AACF;;;;ACvID,SAAgB,eAIdC,MACsC;CACtC,MAAM,QAAQ,gBAAsC,KAAK;CAGzD,MAAM,YAAY,SAAS,KAAK;CAEhC,MAAM,QAAQ,sBAAsB,MAAM;AAK1C,QAAO,gBAAgB,CAAC,QAAQ;AAC9B,MAAI,QAAQ,gBAAgB,QAAQ,WAClC,QAAO,MAAM;GACX,MAAM,UAAU,MAAM,UAAU;AAEhC,UAAO,QAAQ,MAAM;AACnB,WAAO,AAAC,sBAA8B,QAAQ;GAC/C,GAAE,CAAC,OAAQ,EAAC;EACd;AAGH,MAAI,QAAQ,aACV,QAAO,MAAM;AAGf,MAAI,QAAQ,qBACV,QAAO,MAAM;AAGf,MAAI,QAAQ,WACV,QAAO;AAGT,SAAO,MAAM;CACd,EAAC;AACH"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
13
|
+
key = keys[i];
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
|
+
get: ((k) => from[k]).bind(null, key),
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
22
|
+
value: mod,
|
|
23
|
+
enumerable: true
|
|
24
|
+
}) : target, mod));
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js
|
|
28
|
+
var require_typeof = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(exports, module) {
|
|
29
|
+
function _typeof$2(o) {
|
|
30
|
+
"@babel/helpers - typeof";
|
|
31
|
+
return module.exports = _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
|
|
32
|
+
return typeof o$1;
|
|
33
|
+
} : function(o$1) {
|
|
34
|
+
return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
|
|
35
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof$2(o);
|
|
36
|
+
}
|
|
37
|
+
module.exports = _typeof$2, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
38
|
+
} });
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js
|
|
42
|
+
var require_toPrimitive = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(exports, module) {
|
|
43
|
+
var _typeof$1 = require_typeof()["default"];
|
|
44
|
+
function toPrimitive$1(t, r) {
|
|
45
|
+
if ("object" != _typeof$1(t) || !t) return t;
|
|
46
|
+
var e = t[Symbol.toPrimitive];
|
|
47
|
+
if (void 0 !== e) {
|
|
48
|
+
var i = e.call(t, r || "default");
|
|
49
|
+
if ("object" != _typeof$1(i)) return i;
|
|
50
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
51
|
+
}
|
|
52
|
+
return ("string" === r ? String : Number)(t);
|
|
53
|
+
}
|
|
54
|
+
module.exports = toPrimitive$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
55
|
+
} });
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js
|
|
59
|
+
var require_toPropertyKey = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(exports, module) {
|
|
60
|
+
var _typeof = require_typeof()["default"];
|
|
61
|
+
var toPrimitive = require_toPrimitive();
|
|
62
|
+
function toPropertyKey$1(t) {
|
|
63
|
+
var i = toPrimitive(t, "string");
|
|
64
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
65
|
+
}
|
|
66
|
+
module.exports = toPropertyKey$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
67
|
+
} });
|
|
68
|
+
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js
|
|
71
|
+
var require_defineProperty = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(exports, module) {
|
|
72
|
+
var toPropertyKey = require_toPropertyKey();
|
|
73
|
+
function _defineProperty(e, r, t) {
|
|
74
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
75
|
+
value: t,
|
|
76
|
+
enumerable: !0,
|
|
77
|
+
configurable: !0,
|
|
78
|
+
writable: !0
|
|
79
|
+
}) : e[r] = t, e;
|
|
80
|
+
}
|
|
81
|
+
module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
82
|
+
} });
|
|
83
|
+
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js
|
|
86
|
+
var require_objectSpread2 = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(exports, module) {
|
|
87
|
+
var defineProperty = require_defineProperty();
|
|
88
|
+
function ownKeys(e, r) {
|
|
89
|
+
var t = Object.keys(e);
|
|
90
|
+
if (Object.getOwnPropertySymbols) {
|
|
91
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
92
|
+
r && (o = o.filter(function(r$1) {
|
|
93
|
+
return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
|
|
94
|
+
})), t.push.apply(t, o);
|
|
95
|
+
}
|
|
96
|
+
return t;
|
|
97
|
+
}
|
|
98
|
+
function _objectSpread2(e) {
|
|
99
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
100
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
101
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) {
|
|
102
|
+
defineProperty(e, r$1, t[r$1]);
|
|
103
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
|
|
104
|
+
Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return e;
|
|
108
|
+
}
|
|
109
|
+
module.exports = _objectSpread2, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
110
|
+
} });
|
|
111
|
+
|
|
112
|
+
//#endregion
|
|
113
|
+
export { __toESM, require_objectSpread2 };
|
|
114
|
+
//# sourceMappingURL=objectSpread2-3tHFGdJc.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objectSpread2-3tHFGdJc.mjs","names":["_typeof","o","_typeof","toPrimitive","toPropertyKey","r"],"sources":["../../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js","../../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js","../../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js","../../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js","../../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"],"sourcesContent":["function _typeof(o) {\n \"@babel/helpers - typeof\";\n\n return module.exports = _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) {\n return typeof o;\n } : function (o) {\n return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o;\n }, module.exports.__esModule = true, module.exports[\"default\"] = module.exports, _typeof(o);\n}\nmodule.exports = _typeof, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","var _typeof = require(\"./typeof.js\")[\"default\"];\nfunction toPrimitive(t, r) {\n if (\"object\" != _typeof(t) || !t) return t;\n var e = t[Symbol.toPrimitive];\n if (void 0 !== e) {\n var i = e.call(t, r || \"default\");\n if (\"object\" != _typeof(i)) return i;\n throw new TypeError(\"@@toPrimitive must return a primitive value.\");\n }\n return (\"string\" === r ? String : Number)(t);\n}\nmodule.exports = toPrimitive, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","var _typeof = require(\"./typeof.js\")[\"default\"];\nvar toPrimitive = require(\"./toPrimitive.js\");\nfunction toPropertyKey(t) {\n var i = toPrimitive(t, \"string\");\n return \"symbol\" == _typeof(i) ? i : i + \"\";\n}\nmodule.exports = toPropertyKey, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","var toPropertyKey = require(\"./toPropertyKey.js\");\nfunction _defineProperty(e, r, t) {\n return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {\n value: t,\n enumerable: !0,\n configurable: !0,\n writable: !0\n }) : e[r] = t, e;\n}\nmodule.exports = _defineProperty, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","var defineProperty = require(\"./defineProperty.js\");\nfunction ownKeys(e, r) {\n var t = Object.keys(e);\n if (Object.getOwnPropertySymbols) {\n var o = Object.getOwnPropertySymbols(e);\n r && (o = o.filter(function (r) {\n return Object.getOwnPropertyDescriptor(e, r).enumerable;\n })), t.push.apply(t, o);\n }\n return t;\n}\nfunction _objectSpread2(e) {\n for (var r = 1; r < arguments.length; r++) {\n var t = null != arguments[r] ? arguments[r] : {};\n r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {\n defineProperty(e, r, t[r]);\n }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {\n Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));\n });\n }\n return e;\n}\nmodule.exports = _objectSpread2, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;"],"x_google_ignoreList":[0,1,2,3,4],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAA,SAASA,UAAQ,GAAG;AAClB;AAEA,SAAO,OAAO,UAAUA,YAAU,qBAAqB,UAAU,mBAAmB,OAAO,WAAW,SAAUC,KAAG;AACjH,iBAAcA;EACf,IAAG,SAAUA,KAAG;AACf,UAAOA,OAAK,qBAAqB,UAAUA,IAAE,gBAAgB,UAAUA,QAAM,OAAO,YAAY,kBAAkBA;EACnH,GAAE,OAAO,QAAQ,aAAa,MAAM,OAAO,QAAQ,aAAa,OAAO,SAAS,UAAQ,EAAE;CAC5F;AACD,QAAO,UAAUD,WAAS,OAAO,QAAQ,aAAa,MAAM,OAAO,QAAQ,aAAa,OAAO;;;;;;CCT/F,IAAIE,6BAAiC;CACrC,SAASC,cAAY,GAAG,GAAG;AACzB,MAAI,YAAY,UAAQ,EAAE,KAAK,EAAG,QAAO;EACzC,IAAI,IAAI,EAAE,OAAO;AACjB,WAAS,MAAM,GAAG;GAChB,IAAI,IAAI,EAAE,KAAK,GAAG,KAAK,UAAU;AACjC,OAAI,YAAY,UAAQ,EAAE,CAAE,QAAO;AACnC,SAAM,IAAI,UAAU;EACrB;AACD,SAAO,CAAC,aAAa,IAAI,SAAS,QAAQ,EAAE;CAC7C;AACD,QAAO,UAAUA,eAAa,OAAO,QAAQ,aAAa,MAAM,OAAO,QAAQ,aAAa,OAAO;;;;;;CCXnG,IAAI,2BAAiC;CACrC,IAAI;CACJ,SAASC,gBAAc,GAAG;EACxB,IAAI,IAAI,YAAY,GAAG,SAAS;AAChC,SAAO,YAAY,QAAQ,EAAE,GAAG,IAAI,IAAI;CACzC;AACD,QAAO,UAAUA,iBAAe,OAAO,QAAQ,aAAa,MAAM,OAAO,QAAQ,aAAa,OAAO;;;;;;CCNrG,IAAI;CACJ,SAAS,gBAAgB,GAAG,GAAG,GAAG;AAChC,UAAQ,IAAI,cAAc,EAAE,KAAK,IAAI,OAAO,eAAe,GAAG,GAAG;GAC/D,OAAO;GACP,aAAa;GACb,eAAe;GACf,WAAW;EACZ,EAAC,GAAG,EAAE,KAAK,GAAG;CAChB;AACD,QAAO,UAAU,iBAAiB,OAAO,QAAQ,aAAa,MAAM,OAAO,QAAQ,aAAa,OAAO;;;;;;CCTvG,IAAI;CACJ,SAAS,QAAQ,GAAG,GAAG;EACrB,IAAI,IAAI,OAAO,KAAK,EAAE;AACtB,MAAI,OAAO,uBAAuB;GAChC,IAAI,IAAI,OAAO,sBAAsB,EAAE;AACvC,SAAM,IAAI,EAAE,OAAO,SAAUC,KAAG;AAC9B,WAAO,OAAO,yBAAyB,GAAGA,IAAE,CAAC;GAC9C,EAAC,GAAG,EAAE,KAAK,MAAM,GAAG,EAAE;EACxB;AACD,SAAO;CACR;CACD,SAAS,eAAe,GAAG;AACzB,OAAK,IAAI,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK;GACzC,IAAI,IAAI,QAAQ,UAAU,KAAK,UAAU,KAAK,CAAE;AAChD,OAAI,IAAI,QAAQ,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,SAAUA,KAAG;AAClD,mBAAe,GAAGA,KAAG,EAAEA,KAAG;GAC3B,EAAC,GAAG,OAAO,4BAA4B,OAAO,iBAAiB,GAAG,OAAO,0BAA0B,EAAE,CAAC,GAAG,QAAQ,OAAO,EAAE,CAAC,CAAC,QAAQ,SAAUA,KAAG;AAChJ,WAAO,eAAe,GAAGA,KAAG,OAAO,yBAAyB,GAAGA,IAAE,CAAC;GACnE,EAAC;EACH;AACD,SAAO;CACR;AACD,QAAO,UAAU,gBAAgB,OAAO,QAAQ,aAAa,MAAM,OAAO,QAAQ,aAAa,OAAO"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-DWy1uDak.cjs');
|
|
2
|
+
|
|
3
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js
|
|
4
|
+
var require_typeof = require_chunk.__commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(exports, module) {
|
|
5
|
+
function _typeof$2(o) {
|
|
6
|
+
"@babel/helpers - typeof";
|
|
7
|
+
return module.exports = _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
|
|
8
|
+
return typeof o$1;
|
|
9
|
+
} : function(o$1) {
|
|
10
|
+
return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
|
|
11
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof$2(o);
|
|
12
|
+
}
|
|
13
|
+
module.exports = _typeof$2, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
14
|
+
} });
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js
|
|
18
|
+
var require_toPrimitive = require_chunk.__commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(exports, module) {
|
|
19
|
+
var _typeof$1 = require_typeof()["default"];
|
|
20
|
+
function toPrimitive$1(t, r) {
|
|
21
|
+
if ("object" != _typeof$1(t) || !t) return t;
|
|
22
|
+
var e = t[Symbol.toPrimitive];
|
|
23
|
+
if (void 0 !== e) {
|
|
24
|
+
var i = e.call(t, r || "default");
|
|
25
|
+
if ("object" != _typeof$1(i)) return i;
|
|
26
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
27
|
+
}
|
|
28
|
+
return ("string" === r ? String : Number)(t);
|
|
29
|
+
}
|
|
30
|
+
module.exports = toPrimitive$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
31
|
+
} });
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js
|
|
35
|
+
var require_toPropertyKey = require_chunk.__commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(exports, module) {
|
|
36
|
+
var _typeof = require_typeof()["default"];
|
|
37
|
+
var toPrimitive = require_toPrimitive();
|
|
38
|
+
function toPropertyKey$1(t) {
|
|
39
|
+
var i = toPrimitive(t, "string");
|
|
40
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
41
|
+
}
|
|
42
|
+
module.exports = toPropertyKey$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
43
|
+
} });
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js
|
|
47
|
+
var require_defineProperty = require_chunk.__commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(exports, module) {
|
|
48
|
+
var toPropertyKey = require_toPropertyKey();
|
|
49
|
+
function _defineProperty(e, r, t) {
|
|
50
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
51
|
+
value: t,
|
|
52
|
+
enumerable: !0,
|
|
53
|
+
configurable: !0,
|
|
54
|
+
writable: !0
|
|
55
|
+
}) : e[r] = t, e;
|
|
56
|
+
}
|
|
57
|
+
module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
58
|
+
} });
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region ../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js
|
|
62
|
+
var require_objectSpread2 = require_chunk.__commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(exports, module) {
|
|
63
|
+
var defineProperty = require_defineProperty();
|
|
64
|
+
function ownKeys(e, r) {
|
|
65
|
+
var t = Object.keys(e);
|
|
66
|
+
if (Object.getOwnPropertySymbols) {
|
|
67
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
68
|
+
r && (o = o.filter(function(r$1) {
|
|
69
|
+
return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
|
|
70
|
+
})), t.push.apply(t, o);
|
|
71
|
+
}
|
|
72
|
+
return t;
|
|
73
|
+
}
|
|
74
|
+
function _objectSpread2(e) {
|
|
75
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
76
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
77
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) {
|
|
78
|
+
defineProperty(e, r$1, t[r$1]);
|
|
79
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
|
|
80
|
+
Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return e;
|
|
84
|
+
}
|
|
85
|
+
module.exports = _objectSpread2, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
86
|
+
} });
|
|
87
|
+
|
|
88
|
+
//#endregion
|
|
89
|
+
Object.defineProperty(exports, 'require_objectSpread2', {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
get: function () {
|
|
92
|
+
return require_objectSpread2;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
@@ -87,4 +87,4 @@ declare function experimental_revalidateEndpoint(req: Request): Promise<Response
|
|
|
87
87
|
|
|
88
88
|
//#endregion
|
|
89
89
|
export { ActionHandlerDef, CreateTRPCNextAppRouterOptions, TRPCActionHandler, experimental_createServerActionHandler, experimental_createTRPCNextAppDirServer, experimental_revalidateEndpoint };
|
|
90
|
-
//# sourceMappingURL=server.d-
|
|
90
|
+
//# sourceMappingURL=server.d-C5p0ZwB7.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d-
|
|
1
|
+
{"version":3,"file":"server.d-C5p0ZwB7.d.mts","names":[],"sources":["../src/app-dir/shared.ts","../src/app-dir/types.ts","../src/app-dir/server.ts"],"sourcesContent":[],"mappings":";;;;;;ACiBA;;;AAEe,UD2EE,8BC3EF,CAAA,gBD2EiD,SC3EjD,CAAA,CAAA;EAAW,MACtB,EAAA,GAAA,GD2EY,uBC3EZ,CD2EoC,OC3EpC,CAAA;;;;;;;;;AAeiB,UDmFJ,gBAAA,CCnFI;EAAQ,KAAA,CAAA,EAAA,GAAA;EAIjB,MAAA,CAAA,EAAA,GAAA;EAA8B,UAAA,EAAA,GAAA;;;;;AAIP,KDqFvB,cCrFuB,CAAA,cDsFnB,cCtFmB,EAAA,cDuFnB,YCvFmB,CAAA,GAAA;EAAI,KACjC,EDwFG,mBCxFH,CDwFuB,KCxFvB,CAAA;EAAM,MAAS,EDyFX,oBCzFW,CDyFU,KCzFV,CAAA;EAAY,UAEvB,EDwFI,KCxFJ,CAAA,YAAA,CAAA;CAAM;;;KApCX,WAAA;;;EDoFY,WAAA,EAAA,OAAA;EAA8B,UAAA,EAAA,GAAA;CAAA;AACP,KC9E5B,uBD8E4B,CAAA,cC7ExB,aD6EwB,EAAA,aC5EzB,WD4EyB,CAAA,GC3EpC,KD2EoC,SAAA,OAAA,GAAA;EAAO,KAA/B,ECzEH,QDyEG,CCzEM,IDyEN,CAAA;EAAuB,UAAA,EAAA,CAAA,KAAA,CAAA,ECvEvB,IDuEuB,CAAA,OAAA,CAAA,EAAA,GCtE5B,ODsE4B,CAAA;IAuBtB,WAAA,EAAA,KAAgB;IAUrB,KAAA,EAAA,MAAc;EAAA,CAAA,GAAA;IACV,WAAA,EAAA,IAAA;EAAc,CAAA,CAAA;CACF,GCrGxB,KDuGyB,SAAA,UAAA,GAAA;EAAK,MAAzB,ECrGO,QDqGP,CCrGgB,IDqGhB,CAAA;CAAmB,GCnGtB,KDoGyB,SAAA,cAAA,GAAA;EAAK,SAA1B,EClGW,QDkGX,CClGoB,IDkGpB,CAAA;CAAoB,GAAA,KAChB;AAAK,KC/FP,8BD+FO,CAAA,cC9FH,YD8FG,EAAA,gBC7FD,YD6FC,CAAA,GAAA,iBC3FF,UAAU,QAAQ,6BAC7B,eAAe,eACb,wBACE;SAES,oBAAoB;UACnB,gCAAgC,OAAO;EAvCtD,UAAW,EAwCQ,KAxCR,CAAA,YAAA,CAAA;EAOJ,WAAA,EAkCa,KAlCb,CAAA,aAAuB,CAAA;AAAA,CAAA,CAAA,GAqC3B,MArC2B,SAqCZ,YArCY,GAsCzB,8BAtCyB,CAsCM,KAtCN,EAsCa,MAtCb,CAAA,GAAA,KAAA,GAAA,KAAA,EAAA;;;AD6ElB,iBEtDD,uCFsD+B,CAAA,gBErD7B,SFqD6B,CAAA,CAAA,IAAA,EEpDvC,8BFoDuC,CEpDR,OFoDQ,CAAA,CAAA,EEpDA,8BFoDA,CEpDA,OFoDA,CAAA,MAAA,CAAA,CAAA,SAAA,CAAA,CAAA,QAAA,CAAA,EEpDA,OFoDA,CAAA,MAAA,CAAA,CAAA,QAAA,CAAA,CAAA;;;;AAC/B,KEnBJ,iBFmBI,CAAA,aEnB2B,gBFmB3B,CAAA,GAAA,CAAA,KAAA,EElBP,QFkBO,GElBI,IFkBJ,CAAA,OAAA,CAAA,EAAA,GEjBX,OFiBW,CEjBH,YFiBG,CEjBU,IFiBV,CAAA,QAAA,CAAA,EEjB0B,IFiB1B,CAAA,YAAA,CAAA,CAAA,CAAA;AAAuB,iBEfvB,sCFeuB,CAAA,kBAAA;EAuBtB,OAAA,EEpCJ,UFoCoB,CEpCT,YFoCS,CAAA;AAUjC,CAAA,CAAA,CAAA,CAAY,EE3CP,SF2CO,EAAA,IAAc,EE1ClB,qBF0CkB,CEzCtB,SFyCsB,CAAA,SAAA,CAAA,CAAA,QAAA,CAAA,CAAA,KAAA,CAAA,EAAA,GAAA,GExChB,YFwCgB,CExCH,SFwCG,CAAA,SAAA,CAAA,CAAA,QAAA,CAAA,CAAA,KAAA,CAAA,CAAA,CAAA,GAAA;EAAA;;;;EAIQ,iBAAzB,CAAA,EAAA,OAAA;EAAmB;;;EAET,OAAA,CAAA,EAAA,CAAA,IAAA,EEnCP,mBFmCO,CEnCa,SFmCb,CAAA,SAAA,CAAA,CAAA,QAAA,CAAA,CAAA,KAAA,CAAA,CAAA,EAAA,GAAA,IAAA;;;;AC9H+B;EAStC,iBAAA,CAAA,EAAA,OAAuB;CAAA,CAAA,EAAA,CAAA,cCsGgB,YDtGhB,CAAA,CAAA,IAAA,ECuGzB,KDvGyB,EAAA,GCwG9B,iBDxG8B,CCyG/B,QDzG+B,CCyGtB,cDzGsB,CCyGP,gBDzGO,CCyGU,SDzGV,CAAA,ECyGsB,KDzGtB,CAAA,CAAA,CAAA;AACnB,iBCmLM,+BAAA,CDnLN,GAAA,ECmL2C,ODnL3C,CAAA,ECmLkD,ODnLlD,CCmLkD,QDnLlD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-
|
|
1
|
+
{"version":3,"file":"shared-Bco66qhk.mjs","names":["procedurePath: string","input: any","value: unknown"],"sources":["../src/app-dir/shared.ts"],"sourcesContent":["import type {\n CreateTRPCClientOptions,\n Resolver,\n TRPCClient,\n} from '@trpc/client';\nimport { getUntypedClient, TRPCUntypedClient } from '@trpc/client';\nimport type { inferProcedureOutput } from '@trpc/server';\nimport type {\n AnyClientTypes,\n AnyProcedure,\n AnyQueryProcedure,\n AnyRootTypes,\n AnyRouter,\n inferProcedureInput,\n inferTransformedProcedureOutput,\n ProtectedIntersection,\n RouterRecord,\n} from '@trpc/server/unstable-core-do-not-import';\nimport { createRecursiveProxy } from '@trpc/server/unstable-core-do-not-import';\n\n/**\n * @internal\n */\nexport type UseProcedureRecord<\n TRoot extends AnyRootTypes,\n TRecord extends RouterRecord,\n> = {\n [TKey in keyof TRecord]: TRecord[TKey] extends infer $Value\n ? $Value extends AnyQueryProcedure\n ? Resolver<{\n input: inferProcedureInput<$Value>;\n output: inferTransformedProcedureOutput<TRoot, $Value>;\n errorShape: TRoot['errorShape'];\n transformer: TRoot['transformer'];\n }>\n : $Value extends RouterRecord\n ? UseProcedureRecord<TRoot, $Value>\n : never\n : never;\n};\n\nexport function createUseProxy<TRouter extends AnyRouter>(\n client: TRPCUntypedClient<TRouter> | TRPCClient<TRouter>,\n) {\n const untypedClient: TRPCUntypedClient<TRouter> =\n client instanceof TRPCUntypedClient ? client : getUntypedClient(client);\n\n return createRecursiveProxy<\n UseProcedureRecord<\n TRouter['_def']['_config']['$types'],\n TRouter['_def']['record']\n >\n >((opts) => {\n const path = opts.path.join('.');\n\n return untypedClient.query(path, ...opts.args);\n });\n}\n\ntype NextAppRouterUse<TRouter extends AnyRouter> = {\n <TData extends Promise<unknown>[]>(\n cb: (\n t: UseProcedureRecord<\n TRouter['_def']['_config']['$types'],\n TRouter['_def']['record']\n >,\n ) => [...TData],\n ): {\n [TKey in keyof TData]: Awaited<TData[TKey]>;\n };\n <TData extends Promise<unknown>>(\n cb: (\n t: UseProcedureRecord<\n TRouter['_def']['_config']['$types'],\n TRouter['_def']['record']\n >,\n ) => TData,\n ): Awaited<TData>;\n};\ntype CreateTRPCNextAppRouterBase<TRouter extends AnyRouter> = {\n use: NextAppRouterUse<TRouter>;\n};\nexport type CreateTRPCNextAppRouter<TRouter extends AnyRouter> =\n ProtectedIntersection<\n CreateTRPCNextAppRouterBase<TRouter>,\n UseProcedureRecord<\n TRouter['_def']['_config']['$types'],\n TRouter['_def']['record']\n >\n >;\n\n/**\n * @internal\n */\nexport interface CreateTRPCNextAppRouterOptions<TRouter extends AnyRouter> {\n config: () => CreateTRPCClientOptions<TRouter>;\n}\n\n/**\n * @internal\n */\nexport function generateCacheTag(procedurePath: string, input: any) {\n return input\n ? `${procedurePath}?input=${JSON.stringify(input)}`\n : procedurePath;\n}\n\nexport function isFormData(value: unknown): value is FormData {\n if (typeof FormData === 'undefined') {\n // FormData is not supported\n return false;\n }\n return value instanceof FormData;\n}\n\n/**\n * @internal\n */\nexport interface ActionHandlerDef {\n input?: any;\n output?: any;\n errorShape: any;\n}\n\n// ts-prune-ignore-next\n/**\n * @internal\n */\nexport type inferActionDef<\n TRoot extends AnyClientTypes,\n TProc extends AnyProcedure,\n> = {\n input: inferProcedureInput<TProc>;\n output: inferProcedureOutput<TProc>;\n errorShape: TRoot['errorShape'];\n};\n"],"mappings":";;;;;;;AAqGA,SAAgB,iBAAiBA,eAAuBC,OAAY;AAClE,QAAO,SACF,EAAE,cAAc,SAAS,KAAK,UAAU,MAAM,CAAC,IAChD;AACL;AAED,SAAgB,WAAWC,OAAmC;AAC5D,YAAW,aAAa,YAEtB,QAAO;AAET,QAAO,iBAAiB;AACzB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-
|
|
1
|
+
const require_chunk = require('./chunk-DWy1uDak.cjs');
|
|
2
2
|
const __trpc_server_unstable_core_do_not_import = require_chunk.__toESM(require("@trpc/server/unstable-core-do-not-import"));
|
|
3
3
|
const __trpc_client = require_chunk.__toESM(require("@trpc/client"));
|
|
4
4
|
|
package/dist/ssrPrepass.cjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
const require_chunk = require('./chunk-
|
|
1
|
+
const require_chunk = require('./chunk-DWy1uDak.cjs');
|
|
2
|
+
const require_objectSpread2$1 = require('./objectSpread2-CGXFkI72.cjs');
|
|
2
3
|
const __tanstack_react_query = require_chunk.__toESM(require("@tanstack/react-query"));
|
|
3
4
|
const __trpc_client_unstable_internals = require_chunk.__toESM(require("@trpc/client/unstable-internals"));
|
|
4
5
|
const __trpc_react_query_shared = require_chunk.__toESM(require("@trpc/react-query/shared"));
|
|
@@ -6,6 +7,7 @@ const react = require_chunk.__toESM(require("react"));
|
|
|
6
7
|
const __trpc_client = require_chunk.__toESM(require("@trpc/client"));
|
|
7
8
|
|
|
8
9
|
//#region src/ssrPrepass.ts
|
|
10
|
+
var import_objectSpread2 = require_chunk.__toESM(require_objectSpread2$1.require_objectSpread2(), 1);
|
|
9
11
|
function transformQueryOrMutationCacheErrors(result) {
|
|
10
12
|
const error = result.state.error;
|
|
11
13
|
if (error instanceof Error && error.name === "TRPCClientError") {
|
|
@@ -14,13 +16,7 @@ function transformQueryOrMutationCacheErrors(result) {
|
|
|
14
16
|
data: error.data,
|
|
15
17
|
shape: error.shape
|
|
16
18
|
};
|
|
17
|
-
return {
|
|
18
|
-
...result,
|
|
19
|
-
state: {
|
|
20
|
-
...result.state,
|
|
21
|
-
error: newError
|
|
22
|
-
}
|
|
23
|
-
};
|
|
19
|
+
return (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, result), {}, { state: (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, result.state), {}, { error: newError }) });
|
|
24
20
|
}
|
|
25
21
|
return result;
|
|
26
22
|
}
|
|
@@ -28,11 +24,12 @@ const ssrPrepass = (opts) => {
|
|
|
28
24
|
const { parent, WithTRPC, AppOrPage } = opts;
|
|
29
25
|
const transformer = (0, __trpc_client_unstable_internals.getTransformer)(parent.transformer);
|
|
30
26
|
WithTRPC.getInitialProps = async (appOrPageCtx) => {
|
|
27
|
+
var _parent$responseMeta, _parent$responseMeta2, _meta$headers;
|
|
31
28
|
const shouldSsr = async () => {
|
|
32
29
|
if (typeof window !== "undefined") return false;
|
|
33
30
|
if (typeof parent.ssr === "function") try {
|
|
34
31
|
return await parent.ssr({ ctx: appOrPageCtx.ctx });
|
|
35
|
-
} catch {
|
|
32
|
+
} catch (_unused) {
|
|
36
33
|
return false;
|
|
37
34
|
}
|
|
38
35
|
return parent.ssr;
|
|
@@ -43,12 +40,10 @@ const ssrPrepass = (opts) => {
|
|
|
43
40
|
const ctx = isApp ? appOrPageCtx.ctx : appOrPageCtx;
|
|
44
41
|
let pageProps = {};
|
|
45
42
|
if (AppOrPage.getInitialProps) {
|
|
43
|
+
var _originalProps$pagePr;
|
|
46
44
|
const originalProps = await AppOrPage.getInitialProps(appOrPageCtx);
|
|
47
|
-
const originalPageProps = isApp ? originalProps.pageProps
|
|
48
|
-
pageProps = {
|
|
49
|
-
...originalPageProps,
|
|
50
|
-
...pageProps
|
|
51
|
-
};
|
|
45
|
+
const originalPageProps = isApp ? (_originalProps$pagePr = originalProps.pageProps) !== null && _originalProps$pagePr !== void 0 ? _originalProps$pagePr : {} : originalProps;
|
|
46
|
+
pageProps = (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, originalPageProps), pageProps);
|
|
52
47
|
}
|
|
53
48
|
const getAppTreeProps = (props) => isApp ? { pageProps: props } : props;
|
|
54
49
|
if (typeof window !== "undefined" || !ssrEnabled) return getAppTreeProps(pageProps);
|
|
@@ -72,7 +67,7 @@ const ssrPrepass = (opts) => {
|
|
|
72
67
|
if (!queryClient.isFetching()) break;
|
|
73
68
|
await new Promise((resolve) => {
|
|
74
69
|
const unsub = queryClient.getQueryCache().subscribe((event) => {
|
|
75
|
-
if (event
|
|
70
|
+
if ((event === null || event === void 0 ? void 0 : event.query.getObserversCount()) === 0) {
|
|
76
71
|
resolve();
|
|
77
72
|
unsub();
|
|
78
73
|
}
|
|
@@ -83,18 +78,20 @@ const ssrPrepass = (opts) => {
|
|
|
83
78
|
const isExcludedFromSSr = query.state.fetchStatus === "idle" && query.state.status === "pending";
|
|
84
79
|
return !isExcludedFromSSr;
|
|
85
80
|
} });
|
|
86
|
-
const dehydratedCacheWithErrors = {
|
|
87
|
-
...dehydratedCache,
|
|
81
|
+
const dehydratedCacheWithErrors = (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, dehydratedCache), {}, {
|
|
88
82
|
queries: dehydratedCache.queries.map(transformQueryOrMutationCacheErrors),
|
|
89
83
|
mutations: dehydratedCache.mutations.map(transformQueryOrMutationCacheErrors)
|
|
90
|
-
};
|
|
84
|
+
});
|
|
91
85
|
pageProps["trpcState"] = transformer.input.serialize(dehydratedCacheWithErrors);
|
|
92
86
|
const appTreeProps = getAppTreeProps(pageProps);
|
|
93
|
-
const meta = parent.responseMeta
|
|
87
|
+
const meta = (_parent$responseMeta = (_parent$responseMeta2 = parent.responseMeta) === null || _parent$responseMeta2 === void 0 ? void 0 : _parent$responseMeta2.call(parent, {
|
|
94
88
|
ctx,
|
|
95
89
|
clientErrors: [...dehydratedCache.queries, ...dehydratedCache.mutations].map((v) => v.state.error).flatMap((err) => err instanceof Error && err.name === "TRPCClientError" ? [err] : [])
|
|
96
|
-
})
|
|
97
|
-
for (const [key, value] of Object.entries(meta.headers
|
|
90
|
+
})) !== null && _parent$responseMeta !== void 0 ? _parent$responseMeta : {};
|
|
91
|
+
for (const [key, value] of Object.entries((_meta$headers = meta.headers) !== null && _meta$headers !== void 0 ? _meta$headers : {})) if (typeof value === "string") {
|
|
92
|
+
var _ctx$res;
|
|
93
|
+
(_ctx$res = ctx.res) === null || _ctx$res === void 0 || _ctx$res.setHeader(key, value);
|
|
94
|
+
}
|
|
98
95
|
if (meta.status && ctx.res) ctx.res.statusCode = meta.status;
|
|
99
96
|
return appTreeProps;
|
|
100
97
|
};
|
package/dist/ssrPrepass.d.mts
CHANGED
package/dist/ssrPrepass.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __toESM, require_objectSpread2 } from "./objectSpread2-3tHFGdJc.mjs";
|
|
1
2
|
import { dehydrate } from "@tanstack/react-query";
|
|
2
3
|
import { getTransformer } from "@trpc/client/unstable-internals";
|
|
3
4
|
import { getQueryClient } from "@trpc/react-query/shared";
|
|
@@ -5,6 +6,7 @@ import { createElement } from "react";
|
|
|
5
6
|
import { createTRPCUntypedClient } from "@trpc/client";
|
|
6
7
|
|
|
7
8
|
//#region src/ssrPrepass.ts
|
|
9
|
+
var import_objectSpread2 = __toESM(require_objectSpread2(), 1);
|
|
8
10
|
function transformQueryOrMutationCacheErrors(result) {
|
|
9
11
|
const error = result.state.error;
|
|
10
12
|
if (error instanceof Error && error.name === "TRPCClientError") {
|
|
@@ -13,13 +15,7 @@ function transformQueryOrMutationCacheErrors(result) {
|
|
|
13
15
|
data: error.data,
|
|
14
16
|
shape: error.shape
|
|
15
17
|
};
|
|
16
|
-
return {
|
|
17
|
-
...result,
|
|
18
|
-
state: {
|
|
19
|
-
...result.state,
|
|
20
|
-
error: newError
|
|
21
|
-
}
|
|
22
|
-
};
|
|
18
|
+
return (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, result), {}, { state: (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, result.state), {}, { error: newError }) });
|
|
23
19
|
}
|
|
24
20
|
return result;
|
|
25
21
|
}
|
|
@@ -27,11 +23,12 @@ const ssrPrepass = (opts) => {
|
|
|
27
23
|
const { parent, WithTRPC, AppOrPage } = opts;
|
|
28
24
|
const transformer = getTransformer(parent.transformer);
|
|
29
25
|
WithTRPC.getInitialProps = async (appOrPageCtx) => {
|
|
26
|
+
var _parent$responseMeta, _parent$responseMeta2, _meta$headers;
|
|
30
27
|
const shouldSsr = async () => {
|
|
31
28
|
if (typeof window !== "undefined") return false;
|
|
32
29
|
if (typeof parent.ssr === "function") try {
|
|
33
30
|
return await parent.ssr({ ctx: appOrPageCtx.ctx });
|
|
34
|
-
} catch {
|
|
31
|
+
} catch (_unused) {
|
|
35
32
|
return false;
|
|
36
33
|
}
|
|
37
34
|
return parent.ssr;
|
|
@@ -42,12 +39,10 @@ const ssrPrepass = (opts) => {
|
|
|
42
39
|
const ctx = isApp ? appOrPageCtx.ctx : appOrPageCtx;
|
|
43
40
|
let pageProps = {};
|
|
44
41
|
if (AppOrPage.getInitialProps) {
|
|
42
|
+
var _originalProps$pagePr;
|
|
45
43
|
const originalProps = await AppOrPage.getInitialProps(appOrPageCtx);
|
|
46
|
-
const originalPageProps = isApp ? originalProps.pageProps
|
|
47
|
-
pageProps = {
|
|
48
|
-
...originalPageProps,
|
|
49
|
-
...pageProps
|
|
50
|
-
};
|
|
44
|
+
const originalPageProps = isApp ? (_originalProps$pagePr = originalProps.pageProps) !== null && _originalProps$pagePr !== void 0 ? _originalProps$pagePr : {} : originalProps;
|
|
45
|
+
pageProps = (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, originalPageProps), pageProps);
|
|
51
46
|
}
|
|
52
47
|
const getAppTreeProps = (props) => isApp ? { pageProps: props } : props;
|
|
53
48
|
if (typeof window !== "undefined" || !ssrEnabled) return getAppTreeProps(pageProps);
|
|
@@ -71,7 +66,7 @@ const ssrPrepass = (opts) => {
|
|
|
71
66
|
if (!queryClient.isFetching()) break;
|
|
72
67
|
await new Promise((resolve) => {
|
|
73
68
|
const unsub = queryClient.getQueryCache().subscribe((event) => {
|
|
74
|
-
if (event
|
|
69
|
+
if ((event === null || event === void 0 ? void 0 : event.query.getObserversCount()) === 0) {
|
|
75
70
|
resolve();
|
|
76
71
|
unsub();
|
|
77
72
|
}
|
|
@@ -82,18 +77,20 @@ const ssrPrepass = (opts) => {
|
|
|
82
77
|
const isExcludedFromSSr = query.state.fetchStatus === "idle" && query.state.status === "pending";
|
|
83
78
|
return !isExcludedFromSSr;
|
|
84
79
|
} });
|
|
85
|
-
const dehydratedCacheWithErrors = {
|
|
86
|
-
...dehydratedCache,
|
|
80
|
+
const dehydratedCacheWithErrors = (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, dehydratedCache), {}, {
|
|
87
81
|
queries: dehydratedCache.queries.map(transformQueryOrMutationCacheErrors),
|
|
88
82
|
mutations: dehydratedCache.mutations.map(transformQueryOrMutationCacheErrors)
|
|
89
|
-
};
|
|
83
|
+
});
|
|
90
84
|
pageProps["trpcState"] = transformer.input.serialize(dehydratedCacheWithErrors);
|
|
91
85
|
const appTreeProps = getAppTreeProps(pageProps);
|
|
92
|
-
const meta = parent.responseMeta
|
|
86
|
+
const meta = (_parent$responseMeta = (_parent$responseMeta2 = parent.responseMeta) === null || _parent$responseMeta2 === void 0 ? void 0 : _parent$responseMeta2.call(parent, {
|
|
93
87
|
ctx,
|
|
94
88
|
clientErrors: [...dehydratedCache.queries, ...dehydratedCache.mutations].map((v) => v.state.error).flatMap((err) => err instanceof Error && err.name === "TRPCClientError" ? [err] : [])
|
|
95
|
-
})
|
|
96
|
-
for (const [key, value] of Object.entries(meta.headers
|
|
89
|
+
})) !== null && _parent$responseMeta !== void 0 ? _parent$responseMeta : {};
|
|
90
|
+
for (const [key, value] of Object.entries((_meta$headers = meta.headers) !== null && _meta$headers !== void 0 ? _meta$headers : {})) if (typeof value === "string") {
|
|
91
|
+
var _ctx$res;
|
|
92
|
+
(_ctx$res = ctx.res) === null || _ctx$res === void 0 || _ctx$res.setHeader(key, value);
|
|
93
|
+
}
|
|
97
94
|
if (meta.status && ctx.res) ctx.res.statusCode = meta.status;
|
|
98
95
|
return appTreeProps;
|
|
99
96
|
};
|