@payloadcms/tanstack-start 4.0.0-internal.688c4d0 → 4.0.0-internal.811e0a4
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/LICENSE.md +1 -1
- package/dist/exports/client.d.ts +3 -0
- package/dist/exports/client.d.ts.map +1 -1
- package/dist/exports/client.js +3 -0
- package/dist/exports/client.js.map +1 -1
- package/dist/exports/layouts.d.ts +1 -0
- package/dist/exports/layouts.d.ts.map +1 -1
- package/dist/exports/layouts.js +1 -0
- package/dist/exports/layouts.js.map +1 -1
- package/dist/exports/server.d.ts +2 -1
- package/dist/exports/server.d.ts.map +1 -1
- package/dist/exports/server.js +2 -1
- package/dist/exports/server.js.map +1 -1
- package/dist/exports/vite.d.ts +12 -2
- package/dist/exports/vite.d.ts.map +1 -1
- package/dist/exports/vite.js +8 -1
- package/dist/exports/vite.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/layouts/Root/getLayoutData.js.map +1 -1
- package/dist/layouts/Root/index.d.ts +2 -2
- package/dist/layouts/Root/index.d.ts.map +1 -1
- package/dist/layouts/Root/index.js.map +1 -1
- package/dist/layouts/Root/withPayloadRoot.d.ts +1 -1
- package/dist/layouts/Root/withPayloadRoot.js +1 -1
- package/dist/layouts/Root/withPayloadRoot.js.map +1 -1
- package/dist/routes/adminRoutes.d.ts +111 -0
- package/dist/routes/adminRoutes.d.ts.map +1 -0
- package/dist/routes/adminRoutes.js +108 -0
- package/dist/routes/adminRoutes.js.map +1 -0
- package/dist/routes/apiRoute.d.ts +29 -0
- package/dist/routes/apiRoute.d.ts.map +1 -0
- package/dist/routes/apiRoute.js +38 -0
- package/dist/routes/apiRoute.js.map +1 -0
- package/dist/routes/layoutRoute.d.ts +26 -0
- package/dist/routes/layoutRoute.d.ts.map +1 -0
- package/dist/routes/layoutRoute.js +57 -0
- package/dist/routes/layoutRoute.js.map +1 -0
- package/dist/utilities/handleAPIRoute.d.ts +11 -0
- package/dist/utilities/handleAPIRoute.d.ts.map +1 -0
- package/dist/utilities/handleAPIRoute.js +17 -0
- package/dist/utilities/handleAPIRoute.js.map +1 -0
- package/dist/utilities/importMap.server.d.ts +4 -5
- package/dist/utilities/importMap.server.d.ts.map +1 -1
- package/dist/utilities/importMap.server.js +5 -6
- package/dist/utilities/importMap.server.js.map +1 -1
- package/dist/utilities/loadAdminPage.d.ts +54 -0
- package/dist/utilities/loadAdminPage.d.ts.map +1 -0
- package/dist/utilities/loadAdminPage.js +230 -0
- package/dist/utilities/loadAdminPage.js.map +1 -0
- package/dist/utilities/loadLayoutData.d.ts +15 -0
- package/dist/utilities/loadLayoutData.d.ts.map +1 -0
- package/dist/utilities/loadLayoutData.js +23 -0
- package/dist/utilities/loadLayoutData.js.map +1 -0
- package/dist/utilities/serverFunctionClient.d.ts +29 -0
- package/dist/utilities/serverFunctionClient.d.ts.map +1 -0
- package/dist/utilities/serverFunctionClient.js +109 -0
- package/dist/utilities/serverFunctionClient.js.map +1 -0
- package/dist/vite/config/external.d.ts +11 -0
- package/dist/vite/config/external.d.ts.map +1 -0
- package/dist/vite/config/external.js +48 -0
- package/dist/vite/config/external.js.map +1 -0
- package/dist/vite/config/optimizeDeps.d.ts +25 -0
- package/dist/vite/config/optimizeDeps.d.ts.map +1 -0
- package/dist/vite/{constants.js → config/optimizeDeps.js} +23 -57
- package/dist/vite/config/optimizeDeps.js.map +1 -0
- package/dist/vite/config/scss.d.ts +14 -0
- package/dist/vite/config/scss.d.ts.map +1 -0
- package/dist/vite/config/scss.js +28 -0
- package/dist/vite/config/scss.js.map +1 -0
- package/dist/vite/index.d.ts +55 -0
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/{plugin.js → index.js} +104 -46
- package/dist/vite/index.js.map +1 -0
- package/dist/vite/workarounds/clientModuleResolution.d.ts.map +1 -0
- package/dist/vite/workarounds/clientModuleResolution.js.map +1 -0
- package/dist/vite/workarounds/devTransforms.d.ts.map +1 -0
- package/dist/vite/workarounds/devTransforms.js.map +1 -0
- package/dist/vite/workarounds/reactDomServerInRsc.d.ts.map +1 -0
- package/dist/vite/workarounds/reactDomServerInRsc.js.map +1 -0
- package/dist/vite/workarounds/stripDistStyleImports.d.ts.map +1 -0
- package/dist/vite/{plugins → workarounds}/stripDistStyleImports.js +37 -4
- package/dist/vite/workarounds/stripDistStyleImports.js.map +1 -0
- package/dist/vite/workarounds/stubPrettierInClient.d.ts +21 -0
- package/dist/vite/workarounds/stubPrettierInClient.d.ts.map +1 -0
- package/dist/vite/workarounds/stubPrettierInClient.js +39 -0
- package/dist/vite/workarounds/stubPrettierInClient.js.map +1 -0
- package/dist/vite/workarounds/wrapCjsForClient.d.ts.map +1 -0
- package/dist/vite/workarounds/wrapCjsForClient.js.map +1 -0
- package/package.json +10 -12
- package/dist/@types/assets.d.js +0 -2
- package/dist/@types/assets.d.js.map +0 -1
- package/dist/auth/switchLanguage.d.ts +0 -6
- package/dist/auth/switchLanguage.d.ts.map +0 -1
- package/dist/auth/switchLanguage.js +0 -11
- package/dist/auth/switchLanguage.js.map +0 -1
- package/dist/vite/constants.d.ts +0 -37
- package/dist/vite/constants.d.ts.map +0 -1
- package/dist/vite/constants.js.map +0 -1
- package/dist/vite/plugin.d.ts +0 -38
- package/dist/vite/plugin.d.ts.map +0 -1
- package/dist/vite/plugin.js.map +0 -1
- package/dist/vite/plugins/clientModuleResolution.d.ts.map +0 -1
- package/dist/vite/plugins/clientModuleResolution.js.map +0 -1
- package/dist/vite/plugins/devTransforms.d.ts.map +0 -1
- package/dist/vite/plugins/devTransforms.js.map +0 -1
- package/dist/vite/plugins/reactDomServerInRsc.d.ts.map +0 -1
- package/dist/vite/plugins/reactDomServerInRsc.js.map +0 -1
- package/dist/vite/plugins/stripDistStyleImports.d.ts.map +0 -1
- package/dist/vite/plugins/stripDistStyleImports.js.map +0 -1
- package/dist/vite/plugins/wrapCjsForClient.d.ts.map +0 -1
- package/dist/vite/plugins/wrapCjsForClient.js.map +0 -1
- /package/dist/vite/{plugins → workarounds}/clientModuleResolution.d.ts +0 -0
- /package/dist/vite/{plugins → workarounds}/clientModuleResolution.js +0 -0
- /package/dist/vite/{plugins → workarounds}/devTransforms.d.ts +0 -0
- /package/dist/vite/{plugins → workarounds}/devTransforms.js +0 -0
- /package/dist/vite/{plugins → workarounds}/reactDomServerInRsc.d.ts +0 -0
- /package/dist/vite/{plugins → workarounds}/reactDomServerInRsc.js +0 -0
- /package/dist/vite/{plugins → workarounds}/stripDistStyleImports.d.ts +0 -0
- /package/dist/vite/{plugins → workarounds}/wrapCjsForClient.d.ts +0 -0
- /package/dist/vite/{plugins → workarounds}/wrapCjsForClient.js +0 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { SanitizedConfig } from 'payload';
|
|
2
|
+
type ApiRouteHandler = (ctx: {
|
|
3
|
+
request: Request;
|
|
4
|
+
}) => Promise<Response>;
|
|
5
|
+
/**
|
|
6
|
+
* Builds the method handlers for the Payload REST/GraphQL catch-all
|
|
7
|
+
* (`/_payload/api/$`). The app supplies `getConfig` (an `@payload-config`
|
|
8
|
+
* import) since the package cannot resolve the consumer's config.
|
|
9
|
+
*
|
|
10
|
+
* Spread the result into a literal `server.handlers` key so TanStack Start's
|
|
11
|
+
* client compiler can statically see — and prune — the server-only route:
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* export const Route = createFileRoute('/_payload/api/$')({
|
|
15
|
+
* server: {
|
|
16
|
+
* handlers: payloadApiHandlers({ getConfig: async () => (await import('@payload-config')).default }),
|
|
17
|
+
* },
|
|
18
|
+
* })
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* The compiler only strips a literal `server:` key from a route-options object
|
|
22
|
+
* expression; wrapping the whole options object in a factory call hides the
|
|
23
|
+
* key, leaking the config graph into the client bundle.
|
|
24
|
+
*/
|
|
25
|
+
export declare function payloadApiHandlers({ getConfig, }: {
|
|
26
|
+
getConfig: () => Promise<SanitizedConfig>;
|
|
27
|
+
}): Record<'DELETE' | 'GET' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT', ApiRouteHandler>;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=apiRoute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiRoute.d.ts","sourceRoot":"","sources":["../../src/routes/apiRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,KAAK,eAAe,GAAG,CAAC,GAAG,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEvE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,SAAS,GACV,EAAE;IACD,SAAS,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAA;CAC1C,GAAG,MAAM,CAAC,QAAQ,GAAG,KAAK,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,EAAE,eAAe,CAAC,CAcnF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the method handlers for the Payload REST/GraphQL catch-all
|
|
3
|
+
* (`/_payload/api/$`). The app supplies `getConfig` (an `@payload-config`
|
|
4
|
+
* import) since the package cannot resolve the consumer's config.
|
|
5
|
+
*
|
|
6
|
+
* Spread the result into a literal `server.handlers` key so TanStack Start's
|
|
7
|
+
* client compiler can statically see — and prune — the server-only route:
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* export const Route = createFileRoute('/_payload/api/$')({
|
|
11
|
+
* server: {
|
|
12
|
+
* handlers: payloadApiHandlers({ getConfig: async () => (await import('@payload-config')).default }),
|
|
13
|
+
* },
|
|
14
|
+
* })
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* The compiler only strips a literal `server:` key from a route-options object
|
|
18
|
+
* expression; wrapping the whole options object in a factory call hides the
|
|
19
|
+
* key, leaking the config graph into the client bundle.
|
|
20
|
+
*/ export function payloadApiHandlers({ getConfig }) {
|
|
21
|
+
const handler = async ({ request })=>{
|
|
22
|
+
const { handleAPIRoute } = await import('../utilities/handleAPIRoute.js');
|
|
23
|
+
return handleAPIRoute({
|
|
24
|
+
config: await getConfig(),
|
|
25
|
+
request
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
DELETE: handler,
|
|
30
|
+
GET: handler,
|
|
31
|
+
OPTIONS: handler,
|
|
32
|
+
PATCH: handler,
|
|
33
|
+
POST: handler,
|
|
34
|
+
PUT: handler
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=apiRoute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/routes/apiRoute.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\ntype ApiRouteHandler = (ctx: { request: Request }) => Promise<Response>\n\n/**\n * Builds the method handlers for the Payload REST/GraphQL catch-all\n * (`/_payload/api/$`). The app supplies `getConfig` (an `@payload-config`\n * import) since the package cannot resolve the consumer's config.\n *\n * Spread the result into a literal `server.handlers` key so TanStack Start's\n * client compiler can statically see — and prune — the server-only route:\n *\n * ```ts\n * export const Route = createFileRoute('/_payload/api/$')({\n * server: {\n * handlers: payloadApiHandlers({ getConfig: async () => (await import('@payload-config')).default }),\n * },\n * })\n * ```\n *\n * The compiler only strips a literal `server:` key from a route-options object\n * expression; wrapping the whole options object in a factory call hides the\n * key, leaking the config graph into the client bundle.\n */\nexport function payloadApiHandlers({\n getConfig,\n}: {\n getConfig: () => Promise<SanitizedConfig>\n}): Record<'DELETE' | 'GET' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT', ApiRouteHandler> {\n const handler: ApiRouteHandler = async ({ request }) => {\n const { handleAPIRoute } = await import('../utilities/handleAPIRoute.js')\n return handleAPIRoute({ config: await getConfig(), request })\n }\n\n return {\n DELETE: handler,\n GET: handler,\n OPTIONS: handler,\n PATCH: handler,\n POST: handler,\n PUT: handler,\n }\n}\n"],"names":["payloadApiHandlers","getConfig","handler","request","handleAPIRoute","config","DELETE","GET","OPTIONS","PATCH","POST","PUT"],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,SAASA,mBAAmB,EACjCC,SAAS,EAGV;IACC,MAAMC,UAA2B,OAAO,EAAEC,OAAO,EAAE;QACjD,MAAM,EAAEC,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC;QACxC,OAAOA,eAAe;YAAEC,QAAQ,MAAMJ;YAAaE;QAAQ;IAC7D;IAEA,OAAO;QACLG,QAAQJ;QACRK,KAAKL;QACLM,SAASN;QACTO,OAAOP;QACPQ,MAAMR;QACNS,KAAKT;IACP;AACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
|
+
import { RootProvider } from '@payloadcms/ui';
|
|
3
|
+
/**
|
|
4
|
+
* Loader supplied by the app — a TanStack Start `createServerFn` that delegates
|
|
5
|
+
* to `loadLayoutData`. Typed loosely because the server-fn's call signature is
|
|
6
|
+
* generated by the Start compiler.
|
|
7
|
+
*/
|
|
8
|
+
export type LayoutLoad = () => Promise<Record<string, unknown>>;
|
|
9
|
+
/**
|
|
10
|
+
* Route options for the Payload admin layout (`/_payload`). Maps the layout
|
|
11
|
+
* loader data onto `RootProvider` and renders the admin chrome (progress bar,
|
|
12
|
+
* custom-provider tree or router `<Outlet />`, portal mount). The app supplies
|
|
13
|
+
* `load` (the layout-data server fn) and `serverFunction` (the server-function
|
|
14
|
+
* client wired into `RootProvider`); everything else is adapter-owned.
|
|
15
|
+
*/
|
|
16
|
+
export declare function payloadLayoutRoute({ load, serverFunction, }: {
|
|
17
|
+
load: LayoutLoad;
|
|
18
|
+
serverFunction: ComponentProps<typeof RootProvider>['serverFunction'];
|
|
19
|
+
}): {
|
|
20
|
+
component: () => import("react").JSX.Element;
|
|
21
|
+
loader: {
|
|
22
|
+
handler: () => Promise<Record<string, unknown>>;
|
|
23
|
+
staleReloadMode: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=layoutRoute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layoutRoute.d.ts","sourceRoot":"","sources":["../../src/routes/layoutRoute.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAE3C,OAAO,EAAe,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAK1D;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;AAE/D;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,IAAI,EACJ,cAAc,GACf,EAAE;IACD,IAAI,EAAE,UAAU,CAAA;IAChB,cAAc,EAAE,cAAc,CAAC,OAAO,YAAY,CAAC,CAAC,gBAAgB,CAAC,CAAA;CACtE;;;;;;EAwCA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { ProgressBar, RootProvider } from '@payloadcms/ui';
|
|
4
|
+
import { Outlet, useLoaderData } from '@tanstack/react-router';
|
|
5
|
+
import { TanStackRouterAdapter } from '../elements/RouterAdapter/index.js';
|
|
6
|
+
/**
|
|
7
|
+
* Route options for the Payload admin layout (`/_payload`). Maps the layout
|
|
8
|
+
* loader data onto `RootProvider` and renders the admin chrome (progress bar,
|
|
9
|
+
* custom-provider tree or router `<Outlet />`, portal mount). The app supplies
|
|
10
|
+
* `load` (the layout-data server fn) and `serverFunction` (the server-function
|
|
11
|
+
* client wired into `RootProvider`); everything else is adapter-owned.
|
|
12
|
+
*/ export function payloadLayoutRoute({ load, serverFunction }) {
|
|
13
|
+
function PayloadLayout() {
|
|
14
|
+
const data = useLoaderData({
|
|
15
|
+
strict: false
|
|
16
|
+
});
|
|
17
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
18
|
+
children: [
|
|
19
|
+
/*#__PURE__*/ _jsxs(RootProvider, {
|
|
20
|
+
config: data.clientConfig,
|
|
21
|
+
dateFNSKey: data.dateFNSKey,
|
|
22
|
+
fallbackLang: data.fallbackLang,
|
|
23
|
+
highContrastMode: false,
|
|
24
|
+
isNavOpen: data.isNavOpen,
|
|
25
|
+
languageCode: data.languageCode,
|
|
26
|
+
languageOptions: data.languageOptions,
|
|
27
|
+
locale: data.locale,
|
|
28
|
+
permissions: data.user ? data.permissions : null,
|
|
29
|
+
RouterAdapter: TanStackRouterAdapter,
|
|
30
|
+
serverFunction: serverFunction,
|
|
31
|
+
theme: data.theme,
|
|
32
|
+
translations: data.translations,
|
|
33
|
+
user: data.user,
|
|
34
|
+
children: [
|
|
35
|
+
/*#__PURE__*/ _jsx(ProgressBar, {}),
|
|
36
|
+
data.providers ?? /*#__PURE__*/ _jsx(Outlet, {})
|
|
37
|
+
]
|
|
38
|
+
}),
|
|
39
|
+
/*#__PURE__*/ _jsx("div", {
|
|
40
|
+
id: "portal"
|
|
41
|
+
})
|
|
42
|
+
]
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
// `staleReloadMode` lives on the loader *object* — router-core only reads it
|
|
46
|
+
// off a non-function loader — so stale-match revalidation blocks on the fresh
|
|
47
|
+
// loader instead of flashing stale layout data via the default background SWR.
|
|
48
|
+
return {
|
|
49
|
+
component: PayloadLayout,
|
|
50
|
+
loader: {
|
|
51
|
+
handler: ()=>load(),
|
|
52
|
+
staleReloadMode: 'blocking'
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=layoutRoute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/routes/layoutRoute.tsx"],"sourcesContent":["'use client'\n\nimport type { ComponentProps } from 'react'\n\nimport { ProgressBar, RootProvider } from '@payloadcms/ui'\nimport { Outlet, useLoaderData } from '@tanstack/react-router'\n\nimport { TanStackRouterAdapter } from '../elements/RouterAdapter/index.js'\n\n/**\n * Loader supplied by the app — a TanStack Start `createServerFn` that delegates\n * to `loadLayoutData`. Typed loosely because the server-fn's call signature is\n * generated by the Start compiler.\n */\nexport type LayoutLoad = () => Promise<Record<string, unknown>>\n\n/**\n * Route options for the Payload admin layout (`/_payload`). Maps the layout\n * loader data onto `RootProvider` and renders the admin chrome (progress bar,\n * custom-provider tree or router `<Outlet />`, portal mount). The app supplies\n * `load` (the layout-data server fn) and `serverFunction` (the server-function\n * client wired into `RootProvider`); everything else is adapter-owned.\n */\nexport function payloadLayoutRoute({\n load,\n serverFunction,\n}: {\n load: LayoutLoad\n serverFunction: ComponentProps<typeof RootProvider>['serverFunction']\n}) {\n function PayloadLayout() {\n const data = useLoaderData({ strict: false })\n\n return (\n <>\n <RootProvider\n config={data.clientConfig}\n dateFNSKey={data.dateFNSKey}\n fallbackLang={data.fallbackLang}\n highContrastMode={false}\n isNavOpen={data.isNavOpen}\n languageCode={data.languageCode}\n languageOptions={data.languageOptions}\n locale={data.locale}\n permissions={data.user ? data.permissions : null}\n RouterAdapter={TanStackRouterAdapter}\n serverFunction={serverFunction}\n theme={data.theme}\n translations={data.translations}\n user={data.user}\n >\n <ProgressBar />\n {/* `data.providers` is the custom-provider tree (config.admin.components.providers)\n already wrapping the router <Outlet />; falls back to a bare <Outlet /> when\n no custom providers are configured. */}\n {data.providers ?? <Outlet />}\n </RootProvider>\n <div id=\"portal\" />\n </>\n )\n }\n\n // `staleReloadMode` lives on the loader *object* — router-core only reads it\n // off a non-function loader — so stale-match revalidation blocks on the fresh\n // loader instead of flashing stale layout data via the default background SWR.\n return {\n component: PayloadLayout,\n loader: { handler: () => load(), staleReloadMode: 'blocking' },\n }\n}\n"],"names":["ProgressBar","RootProvider","Outlet","useLoaderData","TanStackRouterAdapter","payloadLayoutRoute","load","serverFunction","PayloadLayout","data","strict","config","clientConfig","dateFNSKey","fallbackLang","highContrastMode","isNavOpen","languageCode","languageOptions","locale","permissions","user","RouterAdapter","theme","translations","providers","div","id","component","loader","handler","staleReloadMode"],"mappings":"AAAA;;AAIA,SAASA,WAAW,EAAEC,YAAY,QAAQ,iBAAgB;AAC1D,SAASC,MAAM,EAAEC,aAAa,QAAQ,yBAAwB;AAE9D,SAASC,qBAAqB,QAAQ,qCAAoC;AAS1E;;;;;;CAMC,GACD,OAAO,SAASC,mBAAmB,EACjCC,IAAI,EACJC,cAAc,EAIf;IACC,SAASC;QACP,MAAMC,OAAON,cAAc;YAAEO,QAAQ;QAAM;QAE3C,qBACE;;8BACE,MAACT;oBACCU,QAAQF,KAAKG,YAAY;oBACzBC,YAAYJ,KAAKI,UAAU;oBAC3BC,cAAcL,KAAKK,YAAY;oBAC/BC,kBAAkB;oBAClBC,WAAWP,KAAKO,SAAS;oBACzBC,cAAcR,KAAKQ,YAAY;oBAC/BC,iBAAiBT,KAAKS,eAAe;oBACrCC,QAAQV,KAAKU,MAAM;oBACnBC,aAAaX,KAAKY,IAAI,GAAGZ,KAAKW,WAAW,GAAG;oBAC5CE,eAAelB;oBACfG,gBAAgBA;oBAChBgB,OAAOd,KAAKc,KAAK;oBACjBC,cAAcf,KAAKe,YAAY;oBAC/BH,MAAMZ,KAAKY,IAAI;;sCAEf,KAACrB;wBAIAS,KAAKgB,SAAS,kBAAI,KAACvB;;;8BAEtB,KAACwB;oBAAIC,IAAG;;;;IAGd;IAEA,6EAA6E;IAC7E,8EAA8E;IAC9E,+EAA+E;IAC/E,OAAO;QACLC,WAAWpB;QACXqB,QAAQ;YAAEC,SAAS,IAAMxB;YAAQyB,iBAAiB;QAAW;IAC/D;AACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SanitizedConfig } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Routes a TanStack Start API request (`/api/*`) to Payload's REST/GraphQL
|
|
4
|
+
* endpoint handler. The framework adapter wires this into the `/api/$` route's
|
|
5
|
+
* server handlers, supplying the app's resolved `config`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function handleAPIRoute({ config, request, }: {
|
|
8
|
+
config: SanitizedConfig;
|
|
9
|
+
request: Request;
|
|
10
|
+
}): Promise<Response>;
|
|
11
|
+
//# sourceMappingURL=handleAPIRoute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleAPIRoute.d.ts","sourceRoot":"","sources":["../../src/utilities/handleAPIRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9C;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,EACnC,MAAM,EACN,OAAO,GACR,EAAE;IACD,MAAM,EAAE,eAAe,CAAA;IACvB,OAAO,EAAE,OAAO,CAAA;CACjB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAapB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { handleEndpoints } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Routes a TanStack Start API request (`/api/*`) to Payload's REST/GraphQL
|
|
4
|
+
* endpoint handler. The framework adapter wires this into the `/api/$` route's
|
|
5
|
+
* server handlers, supplying the app's resolved `config`.
|
|
6
|
+
*/ export async function handleAPIRoute({ config, request }) {
|
|
7
|
+
const url = new URL(request.url);
|
|
8
|
+
const slugParts = url.pathname.replace(/^\/api\/?/, '').split('/').filter(Boolean);
|
|
9
|
+
const path = slugParts.length ? `/api/${slugParts.join('/')}` : '/api';
|
|
10
|
+
return handleEndpoints({
|
|
11
|
+
config,
|
|
12
|
+
path,
|
|
13
|
+
request
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=handleAPIRoute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/handleAPIRoute.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload'\n\nimport { handleEndpoints } from 'payload'\n\n/**\n * Routes a TanStack Start API request (`/api/*`) to Payload's REST/GraphQL\n * endpoint handler. The framework adapter wires this into the `/api/$` route's\n * server handlers, supplying the app's resolved `config`.\n */\nexport async function handleAPIRoute({\n config,\n request,\n}: {\n config: SanitizedConfig\n request: Request\n}): Promise<Response> {\n const url = new URL(request.url)\n const slugParts = url.pathname\n .replace(/^\\/api\\/?/, '')\n .split('/')\n .filter(Boolean)\n const path = slugParts.length ? `/api/${slugParts.join('/')}` : '/api'\n\n return handleEndpoints({\n config,\n path,\n request,\n })\n}\n"],"names":["handleEndpoints","handleAPIRoute","config","request","url","URL","slugParts","pathname","replace","split","filter","Boolean","path","length","join"],"mappings":"AAEA,SAASA,eAAe,QAAQ,UAAS;AAEzC;;;;CAIC,GACD,OAAO,eAAeC,eAAe,EACnCC,MAAM,EACNC,OAAO,EAIR;IACC,MAAMC,MAAM,IAAIC,IAAIF,QAAQC,GAAG;IAC/B,MAAME,YAAYF,IAAIG,QAAQ,CAC3BC,OAAO,CAAC,aAAa,IACrBC,KAAK,CAAC,KACNC,MAAM,CAACC;IACV,MAAMC,OAAON,UAAUO,MAAM,GAAG,CAAC,KAAK,EAAEP,UAAUQ,IAAI,CAAC,MAAM,GAAG;IAEhE,OAAOd,gBAAgB;QACrBE;QACAU;QACAT;IACF;AACF"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Returns the default output path for the generated import map file
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* so the import map is placed there.
|
|
2
|
+
* Returns the default output path for the generated import map file in a
|
|
3
|
+
* TanStack Start project. Matches the `app/_payload/` convention that Payload's
|
|
4
|
+
* import map auto-discovery probes, so the file is found without a custom
|
|
5
|
+
* `admin.importMap.importMapFile` override.
|
|
7
6
|
*/
|
|
8
7
|
export declare function getImportMapOutputPath(rootDir?: string): string;
|
|
9
8
|
//# sourceMappingURL=importMap.server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"importMap.server.d.ts","sourceRoot":"","sources":["../../src/utilities/importMap.server.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"importMap.server.d.ts","sourceRoot":"","sources":["../../src/utilities/importMap.server.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAE/D"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
/**
|
|
3
|
-
* Returns the default output path for the generated import map file
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* so the import map is placed there.
|
|
3
|
+
* Returns the default output path for the generated import map file in a
|
|
4
|
+
* TanStack Start project. Matches the `app/_payload/` convention that Payload's
|
|
5
|
+
* import map auto-discovery probes, so the file is found without a custom
|
|
6
|
+
* `admin.importMap.importMapFile` override.
|
|
8
7
|
*/ export function getImportMapOutputPath(rootDir) {
|
|
9
|
-
return path.resolve(rootDir || process.cwd(), '
|
|
8
|
+
return path.resolve(rootDir || process.cwd(), 'app', '_payload', 'importMap.js');
|
|
10
9
|
}
|
|
11
10
|
|
|
12
11
|
//# sourceMappingURL=importMap.server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/importMap.server.ts"],"sourcesContent":["import path from 'node:path'\n\n/**\n * Returns the default output path for the generated import map file
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/importMap.server.ts"],"sourcesContent":["import path from 'node:path'\n\n/**\n * Returns the default output path for the generated import map file in a\n * TanStack Start project. Matches the `app/_payload/` convention that Payload's\n * import map auto-discovery probes, so the file is found without a custom\n * `admin.importMap.importMapFile` override.\n */\nexport function getImportMapOutputPath(rootDir?: string): string {\n return path.resolve(rootDir || process.cwd(), 'app', '_payload', 'importMap.js')\n}\n"],"names":["path","getImportMapOutputPath","rootDir","resolve","process","cwd"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAE5B;;;;;CAKC,GACD,OAAO,SAASC,uBAAuBC,OAAgB;IACrD,OAAOF,KAAKG,OAAO,CAACD,WAAWE,QAAQC,GAAG,IAAI,OAAO,YAAY;AACnE"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { ImportMap, SanitizedConfig } from 'payload';
|
|
2
|
+
import type { AdminPageMetadata } from './meta.js';
|
|
3
|
+
export type LoadAdminPageArgs = {
|
|
4
|
+
config: SanitizedConfig;
|
|
5
|
+
importMap: ImportMap;
|
|
6
|
+
search?: Record<string, string | string[]>;
|
|
7
|
+
splat?: string;
|
|
8
|
+
};
|
|
9
|
+
export type LoadAdminPageResult = {
|
|
10
|
+
_notFound: true;
|
|
11
|
+
routeKey?: string;
|
|
12
|
+
rscPayload?: React.ReactNode;
|
|
13
|
+
} | {
|
|
14
|
+
_redirect: string;
|
|
15
|
+
} | {
|
|
16
|
+
metadata: AdminPageMetadata;
|
|
17
|
+
/**
|
|
18
|
+
* Stable identity for this rendered route (the splat, i.e. the path
|
|
19
|
+
* after `/admin/`). The client keys the rendered subtree by this so the
|
|
20
|
+
* view remounts exactly when a new payload arrives. Keying by
|
|
21
|
+
* `location.pathname` instead races: the pathname updates before
|
|
22
|
+
* `useLoaderData()` during a transition, so the subtree would remount
|
|
23
|
+
* with the *previous* payload and then reconcile the fresh payload in
|
|
24
|
+
* place — leaving client providers (DocumentInfo, etc.) holding stale
|
|
25
|
+
* `useState` values from the prior document. Search params are excluded
|
|
26
|
+
* so search-only changes (e.g. list-view filtering) reconcile in place.
|
|
27
|
+
*/
|
|
28
|
+
routeKey: string;
|
|
29
|
+
rscPayload: React.ReactNode;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Renders an admin page for TanStack Start and returns a serializable loader
|
|
33
|
+
* result. The framework adapter wraps this in a `createServerFn` that supplies
|
|
34
|
+
* the app's `config` and generated `importMap`.
|
|
35
|
+
*
|
|
36
|
+
* 1. Initializes the Payload request via the shared `renderRoot` orchestrator
|
|
37
|
+
* from `@payloadcms/ui`, passing a TanStack-bound `initReq`. The injected
|
|
38
|
+
* page-render `ServerAdapter` records navigation intent and throws the
|
|
39
|
+
* framework-agnostic error contract.
|
|
40
|
+
* 2. Pipes the resulting React server tree through `renderServerComponent`
|
|
41
|
+
* to produce a Flight payload the client consumes directly.
|
|
42
|
+
* 3. Resolves page metadata via the same shared `generatePageMetadata`
|
|
43
|
+
* Next.js uses, returning plain serializable strings for `head()`.
|
|
44
|
+
*
|
|
45
|
+
* Navigation surfaces two ways and both become a `_notFound` / `_redirect`
|
|
46
|
+
* sentinel the route loader re-throws as native TanStack nav:
|
|
47
|
+
* - thrown during `renderRoot` orchestration (e.g. the login redirect) → caught
|
|
48
|
+
* by the try/catch below;
|
|
49
|
+
* - thrown deep inside a streamed view component (e.g. `DocumentView` access
|
|
50
|
+
* denied, `LoginView` already-authenticated) → swallowed into the RSC stream,
|
|
51
|
+
* so it's read from the `nav` holder after `renderServerComponent` resolves.
|
|
52
|
+
*/
|
|
53
|
+
export declare function loadAdminPage({ config, importMap, search, splat, }: LoadAdminPageArgs): Promise<LoadAdminPageResult>;
|
|
54
|
+
//# sourceMappingURL=loadAdminPage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadAdminPage.d.ts","sourceRoot":"","sources":["../../src/utilities/loadAdminPage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAc,eAAe,EAAE,MAAM,SAAS,CAAA;AAIrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAMlD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,eAAe,CAAA;IACvB,SAAS,EAAE,SAAS,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAA;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,mBAAmB,GAC3B;IAAE,SAAS,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,GACpE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GACrB;IACE,QAAQ,EAAE,iBAAiB,CAAA;IAC3B;;;;;;;;;;OAUG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,KAAK,CAAC,SAAS,CAAA;CAC5B,CAAA;AA0FL;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,aAAa,CAAC,EAClC,MAAM,EACN,SAAS,EACT,MAAM,EACN,KAAK,GACN,EAAE,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAoJlD"}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { renderServerComponent } from '@tanstack/react-start/rsc';
|
|
2
|
+
import { getRequestI18n } from './getRequestI18n.server.js';
|
|
3
|
+
import { initReq } from './initReq.server.js';
|
|
4
|
+
import { createPageRenderServerAdapter } from './serverAdapter.server.js';
|
|
5
|
+
const resolveTitle = (title)=>{
|
|
6
|
+
if (!title) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
if (typeof title === 'string') {
|
|
10
|
+
return title;
|
|
11
|
+
}
|
|
12
|
+
if ('absolute' in title) {
|
|
13
|
+
return title.absolute;
|
|
14
|
+
}
|
|
15
|
+
return title.default;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Flattens the framework-agnostic `MetaConfig` (Next.js `Metadata` shape) into
|
|
19
|
+
* the plain, serializable `AdminPageMetadata` the route loader ships to the
|
|
20
|
+
* client. The full `MetaConfig` carries a `URL` `metadataBase`, functions and
|
|
21
|
+
* other non-serializable values that seroval cannot cross the wire, so only the
|
|
22
|
+
* fields `getAdminMeta` renders are extracted.
|
|
23
|
+
*/ const toAdminPageMetadata = (meta)=>{
|
|
24
|
+
const og = meta.openGraph;
|
|
25
|
+
const rawImages = og?.images;
|
|
26
|
+
const imagesArray = rawImages ? Array.isArray(rawImages) ? rawImages : [
|
|
27
|
+
rawImages
|
|
28
|
+
] : [];
|
|
29
|
+
const images = imagesArray.map((image)=>typeof image === 'string' ? {
|
|
30
|
+
url: image
|
|
31
|
+
} : image?.url ? {
|
|
32
|
+
alt: image.alt,
|
|
33
|
+
height: image.height,
|
|
34
|
+
url: String(image.url),
|
|
35
|
+
width: image.width
|
|
36
|
+
} : undefined).filter(Boolean);
|
|
37
|
+
const rawIcons = meta.icons;
|
|
38
|
+
const iconList = Array.isArray(rawIcons) ? rawIcons : rawIcons && typeof rawIcons === 'object' && Array.isArray(rawIcons.icon) ? rawIcons.icon : [];
|
|
39
|
+
const icons = iconList.map((icon)=>typeof icon === 'string' ? {
|
|
40
|
+
rel: 'icon',
|
|
41
|
+
url: icon
|
|
42
|
+
} : icon?.url ? {
|
|
43
|
+
type: icon.type,
|
|
44
|
+
media: icon.media,
|
|
45
|
+
rel: icon.rel ?? 'icon',
|
|
46
|
+
sizes: icon.sizes,
|
|
47
|
+
url: String(icon.url)
|
|
48
|
+
} : undefined).filter(Boolean);
|
|
49
|
+
const keywords = meta.keywords;
|
|
50
|
+
return {
|
|
51
|
+
description: typeof meta.description === 'string' ? meta.description : undefined,
|
|
52
|
+
icons: icons?.length ? icons : undefined,
|
|
53
|
+
keywords: typeof keywords === 'string' ? keywords : Array.isArray(keywords) ? keywords.join(', ') : undefined,
|
|
54
|
+
openGraph: og ? {
|
|
55
|
+
description: typeof og.description === 'string' ? og.description : undefined,
|
|
56
|
+
images: images?.length ? images : undefined,
|
|
57
|
+
siteName: typeof og.siteName === 'string' ? og.siteName : undefined,
|
|
58
|
+
title: typeof og.title === 'string' ? og.title : undefined
|
|
59
|
+
} : undefined,
|
|
60
|
+
robots: typeof meta.robots === 'string' ? meta.robots : undefined,
|
|
61
|
+
title: resolveTitle(meta.title)
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Renders an admin page for TanStack Start and returns a serializable loader
|
|
66
|
+
* result. The framework adapter wraps this in a `createServerFn` that supplies
|
|
67
|
+
* the app's `config` and generated `importMap`.
|
|
68
|
+
*
|
|
69
|
+
* 1. Initializes the Payload request via the shared `renderRoot` orchestrator
|
|
70
|
+
* from `@payloadcms/ui`, passing a TanStack-bound `initReq`. The injected
|
|
71
|
+
* page-render `ServerAdapter` records navigation intent and throws the
|
|
72
|
+
* framework-agnostic error contract.
|
|
73
|
+
* 2. Pipes the resulting React server tree through `renderServerComponent`
|
|
74
|
+
* to produce a Flight payload the client consumes directly.
|
|
75
|
+
* 3. Resolves page metadata via the same shared `generatePageMetadata`
|
|
76
|
+
* Next.js uses, returning plain serializable strings for `head()`.
|
|
77
|
+
*
|
|
78
|
+
* Navigation surfaces two ways and both become a `_notFound` / `_redirect`
|
|
79
|
+
* sentinel the route loader re-throws as native TanStack nav:
|
|
80
|
+
* - thrown during `renderRoot` orchestration (e.g. the login redirect) → caught
|
|
81
|
+
* by the try/catch below;
|
|
82
|
+
* - thrown deep inside a streamed view component (e.g. `DocumentView` access
|
|
83
|
+
* denied, `LoginView` already-authenticated) → swallowed into the RSC stream,
|
|
84
|
+
* so it's read from the `nav` holder after `renderServerComponent` resolves.
|
|
85
|
+
*/ export async function loadAdminPage({ config, importMap, search, splat }) {
|
|
86
|
+
const { renderRoot } = await import('@payloadcms/ui/views/Root');
|
|
87
|
+
const { defaultAdminViews } = await import('@payloadcms/ui/views/Root/adminViews');
|
|
88
|
+
const { generatePageMetadata } = await import('@payloadcms/ui/views/Root/generatePageMetadata');
|
|
89
|
+
const splatSegments = splat ? splat.split('/').filter(Boolean) : [];
|
|
90
|
+
// Match Next's optional-catch-all behavior: the admin root (`/admin`) has no
|
|
91
|
+
// segments. Passing an empty array makes the shared `renderRoot` build
|
|
92
|
+
// `currentRoute` as `/admin/` (trailing slash), which no longer equals
|
|
93
|
+
// `adminRoute` and causes `handleAuthRedirect` to append `?redirect=/admin/`.
|
|
94
|
+
// Passing `undefined` yields `currentRoute = /admin`, so the unauthenticated
|
|
95
|
+
// redirect lands on a clean `/admin/login`.
|
|
96
|
+
const segments = splatSegments.length > 0 ? splatSegments : undefined;
|
|
97
|
+
const searchParams = search ?? {};
|
|
98
|
+
// Records navigation requested via `req.server.*` (including throws swallowed
|
|
99
|
+
// by RSC streaming deep inside view components). Read after the render.
|
|
100
|
+
const nav = {};
|
|
101
|
+
const pageServerAdapter = createPageRenderServerAdapter(nav);
|
|
102
|
+
// `renderRoot` calls `initReq` itself with its own overrides (query
|
|
103
|
+
// re-nesting, `urlSuffix`, `fallbackLocale`). Forward them, injecting the
|
|
104
|
+
// page-render `ServerAdapter` so `req.server.redirect()` / `.notFound()`
|
|
105
|
+
// is recorded + thrown rather than escaping as raw TanStack nav.
|
|
106
|
+
const boundInitReq = (args)=>initReq({
|
|
107
|
+
configPromise: args.configPromise,
|
|
108
|
+
importMap: args.importMap,
|
|
109
|
+
overrides: args.overrides,
|
|
110
|
+
serverAdapter: pageServerAdapter
|
|
111
|
+
});
|
|
112
|
+
const notFound = ()=>{
|
|
113
|
+
nav.type = 'notFound';
|
|
114
|
+
throw new Error('not-found');
|
|
115
|
+
};
|
|
116
|
+
const redirect = (url)=>{
|
|
117
|
+
nav.type = 'redirect';
|
|
118
|
+
nav.url = url;
|
|
119
|
+
throw new Error(`redirect:${url}`);
|
|
120
|
+
};
|
|
121
|
+
// Build the 404 result the route loader re-throws as TanStack `notFound()`.
|
|
122
|
+
//
|
|
123
|
+
// Throwing `notFound()` is the only way to set the SSR document status to 404
|
|
124
|
+
// (it's read from `router.stores.statusCode`, set by a not-found match — NOT
|
|
125
|
+
// from `setResponseStatus`, which only affects the RSC RPC response). But the
|
|
126
|
+
// matching `notFoundComponent` is a client component with no access to the
|
|
127
|
+
// Payload `req`, so it can't build the admin chrome on its own. To match Next
|
|
128
|
+
// (whose not-found route renders the full admin layout — nav sidebar, etc. —
|
|
129
|
+
// around the NotFound body, see `renderNotFoundPage`), we render that same
|
|
130
|
+
// shared `renderNotFoundPage` tree here, server-side, and ship its Flight
|
|
131
|
+
// payload through the `notFound()` error so the client renders it verbatim.
|
|
132
|
+
// For users without admin access `renderNotFoundPage` returns the bare
|
|
133
|
+
// `NotFoundClient`, preserving the access-denied behavior.
|
|
134
|
+
const renderNotFound = async ()=>{
|
|
135
|
+
const { renderNotFoundPage } = await import('@payloadcms/ui/views/NotFound/page');
|
|
136
|
+
const notFoundNode = await renderNotFoundPage({
|
|
137
|
+
config: Promise.resolve(config),
|
|
138
|
+
importMap,
|
|
139
|
+
initReq: (args)=>initReq({
|
|
140
|
+
configPromise: args.configPromise,
|
|
141
|
+
importMap: args.importMap,
|
|
142
|
+
overrides: args.overrides
|
|
143
|
+
}),
|
|
144
|
+
params: Promise.resolve({
|
|
145
|
+
segments: splatSegments
|
|
146
|
+
}),
|
|
147
|
+
searchParams: Promise.resolve(searchParams)
|
|
148
|
+
});
|
|
149
|
+
const rscPayload = await renderServerComponent(notFoundNode);
|
|
150
|
+
return {
|
|
151
|
+
_notFound: true,
|
|
152
|
+
routeKey: splat ?? '',
|
|
153
|
+
rscPayload
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
try {
|
|
157
|
+
const node = await renderRoot({
|
|
158
|
+
adminViews: defaultAdminViews,
|
|
159
|
+
config: Promise.resolve(config),
|
|
160
|
+
importMap,
|
|
161
|
+
initReq: boundInitReq,
|
|
162
|
+
notFound,
|
|
163
|
+
// `segments` is intentionally `undefined` for the admin root (`/admin`),
|
|
164
|
+
// matching Next's optional catch-all; `renderRoot` handles it at runtime.
|
|
165
|
+
params: Promise.resolve({
|
|
166
|
+
segments
|
|
167
|
+
}),
|
|
168
|
+
redirect,
|
|
169
|
+
searchParams: Promise.resolve(searchParams)
|
|
170
|
+
});
|
|
171
|
+
const rscPayload = await renderServerComponent(node);
|
|
172
|
+
// The server-function (client-nav RPC) path returns the flight stream unread —
|
|
173
|
+
// unlike the router/SSR path, which awaits a decode that drives the render to
|
|
174
|
+
// completion. So streamed side effects (e.g. DocumentView's autosave-create
|
|
175
|
+
// `server.redirect()`) haven't run yet and `nav` is empty. Buffer the stream to
|
|
176
|
+
// completion to force the render (populating `nav`), then hand the client a fresh
|
|
177
|
+
// replayable stream from that buffer.
|
|
178
|
+
if (!nav.type) {
|
|
179
|
+
const wrapper = rscPayload[Symbol.for('tanstack.rsc.stream')];
|
|
180
|
+
if (typeof wrapper?.createReplayStream === 'function') {
|
|
181
|
+
const buffer = await new Response(wrapper.createReplayStream()).arrayBuffer();
|
|
182
|
+
wrapper.createReplayStream = ()=>new Response(buffer).body;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
// Navigation thrown deep inside a streamed view component (e.g. access
|
|
186
|
+
// denied → notFound, already-authenticated → redirect) is swallowed into
|
|
187
|
+
// the RSC stream and never rejects the render. Honor it from the holder,
|
|
188
|
+
// discarding the (broken) payload from the aborted render.
|
|
189
|
+
if (nav.type === 'redirect' && nav.url) {
|
|
190
|
+
return {
|
|
191
|
+
_redirect: nav.url
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
if (nav.type === 'notFound') {
|
|
195
|
+
return await renderNotFound();
|
|
196
|
+
}
|
|
197
|
+
// Resolve metadata through the same shared generator Next.js uses. Only
|
|
198
|
+
// plain strings cross the wire (the full `MetaConfig` carries a `URL`
|
|
199
|
+
// `metadataBase` and icons that seroval cannot serialize).
|
|
200
|
+
const i18n = await getRequestI18n({
|
|
201
|
+
config
|
|
202
|
+
});
|
|
203
|
+
const meta = await generatePageMetadata({
|
|
204
|
+
adminViews: defaultAdminViews,
|
|
205
|
+
config,
|
|
206
|
+
i18n,
|
|
207
|
+
params: {
|
|
208
|
+
segments
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
return {
|
|
212
|
+
metadata: toAdminPageMetadata(meta),
|
|
213
|
+
routeKey: splat ?? '',
|
|
214
|
+
rscPayload
|
|
215
|
+
};
|
|
216
|
+
} catch (err) {
|
|
217
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
218
|
+
if (nav.type === 'notFound' || message === 'not-found') {
|
|
219
|
+
return await renderNotFound();
|
|
220
|
+
}
|
|
221
|
+
if (nav.type === 'redirect' || message.startsWith('redirect:')) {
|
|
222
|
+
return {
|
|
223
|
+
_redirect: nav.url ?? message.slice('redirect:'.length)
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
throw err;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
//# sourceMappingURL=loadAdminPage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/loadAdminPage.tsx"],"sourcesContent":["import type { ImportMap, MetaConfig, SanitizedConfig } from 'payload'\n\nimport { renderServerComponent } from '@tanstack/react-start/rsc'\n\nimport type { AdminPageMetadata } from './meta.js'\n\nimport { getRequestI18n } from './getRequestI18n.server.js'\nimport { initReq } from './initReq.server.js'\nimport { createPageRenderServerAdapter } from './serverAdapter.server.js'\n\nexport type LoadAdminPageArgs = {\n config: SanitizedConfig\n importMap: ImportMap\n search?: Record<string, string | string[]>\n splat?: string\n}\n\nexport type LoadAdminPageResult =\n | { _notFound: true; routeKey?: string; rscPayload?: React.ReactNode }\n | { _redirect: string }\n | {\n metadata: AdminPageMetadata\n /**\n * Stable identity for this rendered route (the splat, i.e. the path\n * after `/admin/`). The client keys the rendered subtree by this so the\n * view remounts exactly when a new payload arrives. Keying by\n * `location.pathname` instead races: the pathname updates before\n * `useLoaderData()` during a transition, so the subtree would remount\n * with the *previous* payload and then reconcile the fresh payload in\n * place — leaving client providers (DocumentInfo, etc.) holding stale\n * `useState` values from the prior document. Search params are excluded\n * so search-only changes (e.g. list-view filtering) reconcile in place.\n */\n routeKey: string\n rscPayload: React.ReactNode\n }\n\nconst resolveTitle = (title: MetaConfig['title']): string | undefined => {\n if (!title) {\n return undefined\n }\n if (typeof title === 'string') {\n return title\n }\n if ('absolute' in title) {\n return title.absolute\n }\n return title.default\n}\n\n/**\n * Flattens the framework-agnostic `MetaConfig` (Next.js `Metadata` shape) into\n * the plain, serializable `AdminPageMetadata` the route loader ships to the\n * client. The full `MetaConfig` carries a `URL` `metadataBase`, functions and\n * other non-serializable values that seroval cannot cross the wire, so only the\n * fields `getAdminMeta` renders are extracted.\n */\nconst toAdminPageMetadata = (meta: MetaConfig): AdminPageMetadata => {\n const og = meta.openGraph as\n | {\n description?: unknown\n images?: unknown\n siteName?: unknown\n title?: unknown\n }\n | undefined\n\n const rawImages = og?.images\n const imagesArray = rawImages ? (Array.isArray(rawImages) ? rawImages : [rawImages]) : []\n const images = imagesArray\n .map((image: any) =>\n typeof image === 'string'\n ? { url: image }\n : image?.url\n ? { alt: image.alt, height: image.height, url: String(image.url), width: image.width }\n : undefined,\n )\n .filter(Boolean) as NonNullable<AdminPageMetadata['openGraph']>['images']\n\n const rawIcons = meta.icons as any\n const iconList = Array.isArray(rawIcons)\n ? rawIcons\n : rawIcons && typeof rawIcons === 'object' && Array.isArray(rawIcons.icon)\n ? rawIcons.icon\n : []\n const icons = iconList\n .map((icon: any) =>\n typeof icon === 'string'\n ? { rel: 'icon', url: icon }\n : icon?.url\n ? {\n type: icon.type,\n media: icon.media,\n rel: icon.rel ?? 'icon',\n sizes: icon.sizes,\n url: String(icon.url),\n }\n : undefined,\n )\n .filter(Boolean) as AdminPageMetadata['icons']\n\n const keywords = meta.keywords\n\n return {\n description: typeof meta.description === 'string' ? meta.description : undefined,\n icons: icons?.length ? icons : undefined,\n keywords:\n typeof keywords === 'string'\n ? keywords\n : Array.isArray(keywords)\n ? keywords.join(', ')\n : undefined,\n openGraph: og\n ? {\n description: typeof og.description === 'string' ? og.description : undefined,\n images: images?.length ? images : undefined,\n siteName: typeof og.siteName === 'string' ? og.siteName : undefined,\n title: typeof og.title === 'string' ? og.title : undefined,\n }\n : undefined,\n robots: typeof meta.robots === 'string' ? meta.robots : undefined,\n title: resolveTitle(meta.title),\n }\n}\n\n/**\n * Renders an admin page for TanStack Start and returns a serializable loader\n * result. The framework adapter wraps this in a `createServerFn` that supplies\n * the app's `config` and generated `importMap`.\n *\n * 1. Initializes the Payload request via the shared `renderRoot` orchestrator\n * from `@payloadcms/ui`, passing a TanStack-bound `initReq`. The injected\n * page-render `ServerAdapter` records navigation intent and throws the\n * framework-agnostic error contract.\n * 2. Pipes the resulting React server tree through `renderServerComponent`\n * to produce a Flight payload the client consumes directly.\n * 3. Resolves page metadata via the same shared `generatePageMetadata`\n * Next.js uses, returning plain serializable strings for `head()`.\n *\n * Navigation surfaces two ways and both become a `_notFound` / `_redirect`\n * sentinel the route loader re-throws as native TanStack nav:\n * - thrown during `renderRoot` orchestration (e.g. the login redirect) → caught\n * by the try/catch below;\n * - thrown deep inside a streamed view component (e.g. `DocumentView` access\n * denied, `LoginView` already-authenticated) → swallowed into the RSC stream,\n * so it's read from the `nav` holder after `renderServerComponent` resolves.\n */\nexport async function loadAdminPage({\n config,\n importMap,\n search,\n splat,\n}: LoadAdminPageArgs): Promise<LoadAdminPageResult> {\n const { renderRoot } = await import('@payloadcms/ui/views/Root')\n const { defaultAdminViews } = await import('@payloadcms/ui/views/Root/adminViews')\n const { generatePageMetadata } = await import('@payloadcms/ui/views/Root/generatePageMetadata')\n\n const splatSegments = splat ? splat.split('/').filter(Boolean) : []\n // Match Next's optional-catch-all behavior: the admin root (`/admin`) has no\n // segments. Passing an empty array makes the shared `renderRoot` build\n // `currentRoute` as `/admin/` (trailing slash), which no longer equals\n // `adminRoute` and causes `handleAuthRedirect` to append `?redirect=/admin/`.\n // Passing `undefined` yields `currentRoute = /admin`, so the unauthenticated\n // redirect lands on a clean `/admin/login`.\n const segments = splatSegments.length > 0 ? splatSegments : undefined\n const searchParams = search ?? {}\n\n // Records navigation requested via `req.server.*` (including throws swallowed\n // by RSC streaming deep inside view components). Read after the render.\n const nav: { type?: 'notFound' | 'redirect'; url?: string } = {}\n const pageServerAdapter = createPageRenderServerAdapter(nav)\n\n // `renderRoot` calls `initReq` itself with its own overrides (query\n // re-nesting, `urlSuffix`, `fallbackLocale`). Forward them, injecting the\n // page-render `ServerAdapter` so `req.server.redirect()` / `.notFound()`\n // is recorded + thrown rather than escaping as raw TanStack nav.\n const boundInitReq: Parameters<typeof renderRoot>[0]['initReq'] = (args) =>\n initReq({\n configPromise: args.configPromise,\n importMap: args.importMap,\n overrides: args.overrides,\n serverAdapter: pageServerAdapter,\n })\n\n const notFound = (): never => {\n nav.type = 'notFound'\n throw new Error('not-found')\n }\n const redirect = (url: string): never => {\n nav.type = 'redirect'\n nav.url = url\n throw new Error(`redirect:${url}`)\n }\n\n // Build the 404 result the route loader re-throws as TanStack `notFound()`.\n //\n // Throwing `notFound()` is the only way to set the SSR document status to 404\n // (it's read from `router.stores.statusCode`, set by a not-found match — NOT\n // from `setResponseStatus`, which only affects the RSC RPC response). But the\n // matching `notFoundComponent` is a client component with no access to the\n // Payload `req`, so it can't build the admin chrome on its own. To match Next\n // (whose not-found route renders the full admin layout — nav sidebar, etc. —\n // around the NotFound body, see `renderNotFoundPage`), we render that same\n // shared `renderNotFoundPage` tree here, server-side, and ship its Flight\n // payload through the `notFound()` error so the client renders it verbatim.\n // For users without admin access `renderNotFoundPage` returns the bare\n // `NotFoundClient`, preserving the access-denied behavior.\n const renderNotFound = async (): Promise<LoadAdminPageResult> => {\n const { renderNotFoundPage } = await import('@payloadcms/ui/views/NotFound/page')\n\n const notFoundNode = await renderNotFoundPage({\n config: Promise.resolve(config),\n importMap,\n initReq: (args) =>\n initReq({\n configPromise: args.configPromise,\n importMap: args.importMap,\n overrides: args.overrides,\n }),\n params: Promise.resolve({ segments: splatSegments }),\n searchParams: Promise.resolve(searchParams),\n })\n\n const rscPayload = await renderServerComponent(notFoundNode as React.ReactElement)\n\n return { _notFound: true, routeKey: splat ?? '', rscPayload }\n }\n\n try {\n const node = await renderRoot({\n adminViews: defaultAdminViews,\n config: Promise.resolve(config),\n importMap,\n initReq: boundInitReq,\n notFound,\n // `segments` is intentionally `undefined` for the admin root (`/admin`),\n // matching Next's optional catch-all; `renderRoot` handles it at runtime.\n params: Promise.resolve({ segments }) as Parameters<typeof renderRoot>[0]['params'],\n redirect,\n searchParams: Promise.resolve(searchParams),\n })\n\n const rscPayload = await renderServerComponent(node as React.ReactElement)\n\n // The server-function (client-nav RPC) path returns the flight stream unread —\n // unlike the router/SSR path, which awaits a decode that drives the render to\n // completion. So streamed side effects (e.g. DocumentView's autosave-create\n // `server.redirect()`) haven't run yet and `nav` is empty. Buffer the stream to\n // completion to force the render (populating `nav`), then hand the client a fresh\n // replayable stream from that buffer.\n if (!nav.type) {\n const wrapper = (\n rscPayload as unknown as Record<\n symbol,\n { createReplayStream?: () => ReadableStream<Uint8Array> } | undefined\n >\n )[Symbol.for('tanstack.rsc.stream')]\n if (typeof wrapper?.createReplayStream === 'function') {\n const buffer = await new Response(wrapper.createReplayStream()).arrayBuffer()\n wrapper.createReplayStream = () => new Response(buffer).body as ReadableStream<Uint8Array>\n }\n }\n\n // Navigation thrown deep inside a streamed view component (e.g. access\n // denied → notFound, already-authenticated → redirect) is swallowed into\n // the RSC stream and never rejects the render. Honor it from the holder,\n // discarding the (broken) payload from the aborted render.\n if (nav.type === 'redirect' && nav.url) {\n return { _redirect: nav.url }\n }\n if (nav.type === 'notFound') {\n return await renderNotFound()\n }\n\n // Resolve metadata through the same shared generator Next.js uses. Only\n // plain strings cross the wire (the full `MetaConfig` carries a `URL`\n // `metadataBase` and icons that seroval cannot serialize).\n const i18n = await getRequestI18n({ config })\n const meta = await generatePageMetadata({\n adminViews: defaultAdminViews as Parameters<typeof generatePageMetadata>[0]['adminViews'],\n config,\n i18n,\n params: { segments },\n })\n\n return {\n metadata: toAdminPageMetadata(meta),\n routeKey: splat ?? '',\n rscPayload,\n }\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n if (nav.type === 'notFound' || message === 'not-found') {\n return await renderNotFound()\n }\n if (nav.type === 'redirect' || message.startsWith('redirect:')) {\n return { _redirect: nav.url ?? message.slice('redirect:'.length) }\n }\n throw err\n }\n}\n"],"names":["renderServerComponent","getRequestI18n","initReq","createPageRenderServerAdapter","resolveTitle","title","undefined","absolute","default","toAdminPageMetadata","meta","og","openGraph","rawImages","images","imagesArray","Array","isArray","map","image","url","alt","height","String","width","filter","Boolean","rawIcons","icons","iconList","icon","rel","type","media","sizes","keywords","description","length","join","siteName","robots","loadAdminPage","config","importMap","search","splat","renderRoot","defaultAdminViews","generatePageMetadata","splatSegments","split","segments","searchParams","nav","pageServerAdapter","boundInitReq","args","configPromise","overrides","serverAdapter","notFound","Error","redirect","renderNotFound","renderNotFoundPage","notFoundNode","Promise","resolve","params","rscPayload","_notFound","routeKey","node","adminViews","wrapper","Symbol","for","createReplayStream","buffer","Response","arrayBuffer","body","_redirect","i18n","metadata","err","message","startsWith","slice"],"mappings":"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"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ImportMap, SanitizedConfig } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves the admin layout data for TanStack Start and returns a serializable
|
|
4
|
+
* payload for the `/_payload` route loader. The framework adapter wraps this in
|
|
5
|
+
* a `createServerFn` that supplies the app's `config` and generated `importMap`.
|
|
6
|
+
*
|
|
7
|
+
* `toSerializable` strips React elements, so the custom-providers element tree
|
|
8
|
+
* (`config.admin.components.providers`) is rendered to an RSC payload separately
|
|
9
|
+
* and re-attached.
|
|
10
|
+
*/
|
|
11
|
+
export declare function loadLayoutData({ config, importMap, }: {
|
|
12
|
+
config: SanitizedConfig;
|
|
13
|
+
importMap: ImportMap;
|
|
14
|
+
}): Promise<Record<string, unknown>>;
|
|
15
|
+
//# sourceMappingURL=loadLayoutData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadLayoutData.d.ts","sourceRoot":"","sources":["../../src/utilities/loadLayoutData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAOzD;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAAC,EACnC,MAAM,EACN,SAAS,GACV,EAAE;IACD,MAAM,EAAE,eAAe,CAAA;IACvB,SAAS,EAAE,SAAS,CAAA;CACrB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAOnC"}
|