@payloadcms/tanstack-start 4.0.0-internal.bc5cf8c → 4.0.0-internal.cd69eef

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.
Files changed (92) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/elements/RouterAdapter/index.d.ts.map +1 -1
  3. package/dist/elements/RouterAdapter/index.js +18 -2
  4. package/dist/elements/RouterAdapter/index.js.map +1 -1
  5. package/dist/exports/vite.d.ts +2 -2
  6. package/dist/exports/vite.d.ts.map +1 -1
  7. package/dist/exports/vite.js +1 -1
  8. package/dist/exports/vite.js.map +1 -1
  9. package/dist/layouts/Root/getLayoutData.js.map +1 -1
  10. package/dist/layouts/Root/index.d.ts +2 -2
  11. package/dist/layouts/Root/index.d.ts.map +1 -1
  12. package/dist/layouts/Root/index.js.map +1 -1
  13. package/dist/layouts/Root/withPayloadRoot.d.ts.map +1 -1
  14. package/dist/node/cssLoader.d.mts +24 -2
  15. package/dist/node/cssLoader.d.mts.map +1 -1
  16. package/dist/routes/adminRoutes.d.ts +13 -7
  17. package/dist/routes/adminRoutes.d.ts.map +1 -1
  18. package/dist/routes/adminRoutes.js +31 -20
  19. package/dist/routes/adminRoutes.js.map +1 -1
  20. package/dist/routes/layoutRoute.d.ts +4 -1
  21. package/dist/routes/layoutRoute.d.ts.map +1 -1
  22. package/dist/routes/layoutRoute.js +7 -1
  23. package/dist/routes/layoutRoute.js.map +1 -1
  24. package/dist/utilities/graphqlHandler.server.d.ts.map +1 -1
  25. package/dist/utilities/loadAdminPage.d.ts.map +1 -1
  26. package/dist/utilities/loadAdminPage.js +24 -2
  27. package/dist/utilities/loadAdminPage.js.map +1 -1
  28. package/dist/utilities/meta.d.ts +1 -0
  29. package/dist/utilities/meta.d.ts.map +1 -1
  30. package/dist/utilities/meta.js +2 -1
  31. package/dist/utilities/meta.js.map +1 -1
  32. package/dist/utilities/serverAdapter.server.d.ts.map +1 -1
  33. package/dist/vite/config/external.d.ts +11 -0
  34. package/dist/vite/config/external.d.ts.map +1 -0
  35. package/dist/vite/config/external.js +48 -0
  36. package/dist/vite/config/external.js.map +1 -0
  37. package/dist/vite/config/optimizeDeps.d.ts +25 -0
  38. package/dist/vite/config/optimizeDeps.d.ts.map +1 -0
  39. package/dist/vite/{constants.js → config/optimizeDeps.js} +9 -63
  40. package/dist/vite/config/optimizeDeps.js.map +1 -0
  41. package/dist/vite/config/scss.d.ts +14 -0
  42. package/dist/vite/config/scss.d.ts.map +1 -0
  43. package/dist/vite/config/scss.js +28 -0
  44. package/dist/vite/config/scss.js.map +1 -0
  45. package/dist/vite/index.d.ts +99 -0
  46. package/dist/vite/index.d.ts.map +1 -0
  47. package/dist/vite/index.js +258 -0
  48. package/dist/vite/index.js.map +1 -0
  49. package/dist/vite/workarounds/clientModuleResolution.d.ts.map +1 -0
  50. package/dist/vite/workarounds/clientModuleResolution.js.map +1 -0
  51. package/dist/vite/workarounds/devTransforms.d.ts.map +1 -0
  52. package/dist/vite/{plugins → workarounds}/devTransforms.js +5 -0
  53. package/dist/vite/workarounds/devTransforms.js.map +1 -0
  54. package/dist/vite/workarounds/reactDomServerInRsc.d.ts.map +1 -0
  55. package/dist/vite/workarounds/reactDomServerInRsc.js.map +1 -0
  56. package/dist/vite/workarounds/stripDistStyleImports.d.ts.map +1 -0
  57. package/dist/vite/workarounds/stripDistStyleImports.js.map +1 -0
  58. package/dist/vite/workarounds/stubPrettierInClient.d.ts +13 -0
  59. package/dist/vite/workarounds/stubPrettierInClient.d.ts.map +1 -0
  60. package/dist/vite/workarounds/stubPrettierInClient.js +32 -0
  61. package/dist/vite/workarounds/stubPrettierInClient.js.map +1 -0
  62. package/dist/vite/workarounds/wrapCjsForClient.d.ts.map +1 -0
  63. package/dist/vite/workarounds/wrapCjsForClient.js.map +1 -0
  64. package/package.json +10 -5
  65. package/dist/@types/assets.d.js +0 -2
  66. package/dist/@types/assets.d.js.map +0 -1
  67. package/dist/vite/constants.d.ts +0 -42
  68. package/dist/vite/constants.d.ts.map +0 -1
  69. package/dist/vite/constants.js.map +0 -1
  70. package/dist/vite/plugin.d.ts +0 -38
  71. package/dist/vite/plugin.d.ts.map +0 -1
  72. package/dist/vite/plugin.js +0 -179
  73. package/dist/vite/plugin.js.map +0 -1
  74. package/dist/vite/plugins/clientModuleResolution.d.ts.map +0 -1
  75. package/dist/vite/plugins/clientModuleResolution.js.map +0 -1
  76. package/dist/vite/plugins/devTransforms.d.ts.map +0 -1
  77. package/dist/vite/plugins/devTransforms.js.map +0 -1
  78. package/dist/vite/plugins/reactDomServerInRsc.d.ts.map +0 -1
  79. package/dist/vite/plugins/reactDomServerInRsc.js.map +0 -1
  80. package/dist/vite/plugins/stripDistStyleImports.d.ts.map +0 -1
  81. package/dist/vite/plugins/stripDistStyleImports.js.map +0 -1
  82. package/dist/vite/plugins/wrapCjsForClient.d.ts.map +0 -1
  83. package/dist/vite/plugins/wrapCjsForClient.js.map +0 -1
  84. /package/dist/vite/{plugins → workarounds}/clientModuleResolution.d.ts +0 -0
  85. /package/dist/vite/{plugins → workarounds}/clientModuleResolution.js +0 -0
  86. /package/dist/vite/{plugins → workarounds}/devTransforms.d.ts +0 -0
  87. /package/dist/vite/{plugins → workarounds}/reactDomServerInRsc.d.ts +0 -0
  88. /package/dist/vite/{plugins → workarounds}/reactDomServerInRsc.js +0 -0
  89. /package/dist/vite/{plugins → workarounds}/stripDistStyleImports.d.ts +0 -0
  90. /package/dist/vite/{plugins → workarounds}/stripDistStyleImports.js +0 -0
  91. /package/dist/vite/{plugins → workarounds}/wrapCjsForClient.d.ts +0 -0
  92. /package/dist/vite/{plugins → workarounds}/wrapCjsForClient.js +0 -0
@@ -1 +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 // 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","_redirect","i18n","metadata","err","message","startsWith","slice"],"mappings":"AAEA,SAASA,qBAAqB,QAAQ,4BAA2B;AAIjE,SAASC,cAAc,QAAQ,6BAA4B;AAC3D,SAASC,OAAO,QAAQ,sBAAqB;AAC7C,SAASC,6BAA6B,QAAQ,4BAA2B;AA6BzE,MAAMC,eAAe,CAACC;IACpB,IAAI,CAACA,OAAO;QACV,OAAOC;IACT;IACA,IAAI,OAAOD,UAAU,UAAU;QAC7B,OAAOA;IACT;IACA,IAAI,cAAcA,OAAO;QACvB,OAAOA,MAAME,QAAQ;IACvB;IACA,OAAOF,MAAMG,OAAO;AACtB;AAEA;;;;;;CAMC,GACD,MAAMC,sBAAsB,CAACC;IAC3B,MAAMC,KAAKD,KAAKE,SAAS;IASzB,MAAMC,YAAYF,IAAIG;IACtB,MAAMC,cAAcF,YAAaG,MAAMC,OAAO,CAACJ,aAAaA,YAAY;QAACA;K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AAY;YAC3B,OAAO,MAAM+B;QACf;QAEA,wEAAwE;QACxE,sEAAsE;QACtE,2DAA2D;QAC3D,MAAMY,OAAO,MAAM1E,eAAe;YAAEyC;QAAO;QAC3C,MAAMhC,OAAO,MAAMsC,qBAAqB;YACtCyB,YAAY1B;YACZL;YACAiC;YACAP,QAAQ;gBAAEjB;YAAS;QACrB;QAEA,OAAO;YACLyB,UAAUnE,oBAAoBC;YAC9B6D,UAAU1B,SAAS;YACnBwB;QACF;IACF,EAAE,OAAOQ,KAAK;QACZ,MAAMC,UAAUD,eAAehB,QAAQgB,IAAIC,OAAO,GAAGvD,OAAOsD;QAC5D,IAAIxB,IAAIrB,IAAI,KAAK,cAAc8C,YAAY,aAAa;YACtD,OAAO,MAAMf;QACf;QACA,IAAIV,IAAIrB,IAAI,KAAK,cAAc8C,QAAQC,UAAU,CAAC,cAAc;YAC9D,OAAO;gBAAEL,WAAWrB,IAAIjC,GAAG,IAAI0D,QAAQE,KAAK,CAAC,YAAY3C,MAAM;YAAE;QACnE;QACA,MAAMwC;IACR;AACF"}
1
+ {"version":3,"sources":["../../src/utilities/loadAdminPage.tsx"],"sourcesContent":["import type { ImportMap, MetaConfig, SanitizedConfig } from 'payload'\n\nimport { getViewportContent } from '@payloadcms/ui/layouts'\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 let userAgent: string | undefined\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'] = async (args) => {\n const result = await initReq({\n configPromise: args.configPromise,\n importMap: args.importMap,\n overrides: args.overrides,\n serverAdapter: pageServerAdapter,\n })\n userAgent = result.headers.get('user-agent') ?? undefined\n return result\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: {\n ...toAdminPageMetadata(meta),\n viewport: getViewportContent(userAgent),\n },\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":["getViewportContent","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","userAgent","boundInitReq","args","result","configPromise","overrides","serverAdapter","headers","get","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","viewport","err","message","startsWith","slice"],"mappings":"AAEA,SAASA,kBAAkB,QAAQ,yBAAwB;AAC3D,SAASC,qBAAqB,QAAQ,4BAA2B;AAIjE,SAASC,cAAc,QAAQ,6BAA4B;AAC3D,SAASC,OAAO,QAAQ,sBAAqB;AAC7C,SAASC,6BAA6B,QAAQ,4BAA2B;AA6BzE,MAAMC,eAAe,CAACC;IACpB,IAAI,CAACA,OAAO;QACV,OAAOC;IACT;IACA,IAAI,OAAOD,UAAU,UAA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E;QAC5D,IAAIrC,IAAIrB,IAAI,KAAK,cAAc2D,YAAY,aAAa;YACtD,OAAO,MAAMxB;QACf;QACA,IAAId,IAAIrB,IAAI,KAAK,cAAc2D,QAAQC,UAAU,CAAC,cAAc;YAC9D,OAAO;gBAAEN,WAAWjC,IAAIjC,GAAG,IAAIuE,QAAQE,KAAK,CAAC,YAAYxD,MAAM;YAAE;QACnE;QACA,MAAMqD;IACR;AACF"}
@@ -49,6 +49,7 @@ export type AdminPageMetadata = {
49
49
  };
50
50
  robots?: string;
51
51
  title?: string;
52
+ viewport?: string;
52
53
  };
53
54
  /**
54
55
  * Builds TanStack Router `head()` `meta` + `links` entries for an admin page
@@ -1 +1 @@
1
- {"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../src/utilities/meta.ts"],"names":[],"mappings":"AAAA,KAAK,SAAS,GACV;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GACnB;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACrC;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAErB,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAED,KAAK,aAAa,GAAG;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,KAAK,gBAAgB,GAAG;IACtB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,M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A;AAED,KAAK,aAAa,GAAG;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,KAAK,gBAAgB,GAAG;IACtB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,aAAa,EAAE,CAAA;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE;QACV,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,MAAM,CAAC,EAAE,gBAAgB,EAAE,CAAA;QAC3B,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,KAAK,CAAC,EAAE,MAAM,CAAA;KACf,CAAA;IACD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,QAAQ,CAAC,EAAE,iBAAiB,GAAG;IAC1D,KAAK,EAAE,SAAS,EAAE,CAAA;IAClB,IAAI,EAAE,SAAS,EAAE,CAAA;CAClB,CA0EA"}
@@ -1,3 +1,4 @@
1
+ import { getViewportContent } from '@payloadcms/ui/layouts';
1
2
  /**
2
3
  * Builds TanStack Router `head()` `meta` + `links` entries for an admin page
3
4
  * from the resolved `AdminPageMetadata`, mirroring the tags Next.js renders
@@ -16,7 +17,7 @@
16
17
  },
17
18
  {
18
19
  name: 'viewport',
19
- content: 'width=device-width, initial-scale=1'
20
+ content: metadata?.viewport ?? getViewportContent()
20
21
  }
21
22
  ];
22
23
  const links = [];
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/meta.ts"],"sourcesContent":["type MetaEntry =\n | { charSet: string }\n | { content: string; name: string }\n | { content: string; property: string }\n | { title: string }\n\ntype LinkEntry = {\n href: string\n media?: string\n rel: string\n sizes?: string\n type?: string\n}\n\ntype AdminPageIcon = {\n media?: string\n rel?: string\n sizes?: string\n type?: string\n url: string\n}\n\ntype AdminPageOGImage = {\n alt?: string\n height?: number\n url: string\n width?: number\n}\n\n/**\n * Resolved admin-page metadata produced by the admin-page server function.\n *\n * The server function resolves the framework-agnostic `MetaConfig` (via the\n * shared `generatePageMetadata` in `@payloadcms/ui`) down to plain serializable\n * values, so the route loader can ship it across the wire and feed it to\n * `getAdminMeta` in `head()`.\n */\nexport type AdminPageMetadata = {\n description?: string\n icons?: AdminPageIcon[]\n keywords?: string\n openGraph?: {\n description?: string\n images?: AdminPageOGImage[]\n siteName?: string\n title?: string\n }\n robots?: string\n title?: string\n}\n\n/**\n * Builds TanStack Router `head()` `meta` + `links` entries for an admin page\n * from the resolved `AdminPageMetadata`, mirroring the tags Next.js renders\n * natively from the same `MetaConfig` (title, description, robots, keywords,\n * OpenGraph, Twitter — derived from OpenGraph — and icon links).\n *\n * ```ts\n * export const Route = createFileRoute('/admin/$')({\n * head: ({ loaderData }) => getAdminMeta(loaderData?.metadata),\n * })\n * ```\n */\nexport function getAdminMeta(metadata?: AdminPageMetadata): {\n links: LinkEntry[]\n meta: MetaEntry[]\n} {\n const meta: MetaEntry[] = [\n { charSet: 'utf-8' },\n { name: 'viewport', content: 'width=device-width, initial-scale=1' },\n ]\n const links: LinkEntry[] = []\n\n if (!metadata) {\n return { links, meta }\n }\n\n if (metadata.title) {\n meta.push({ title: metadata.title })\n }\n if (metadata.description) {\n meta.push({ name: 'description', content: metadata.description })\n }\n if (metadata.keywords) {\n meta.push({ name: 'keywords', content: metadata.keywords })\n }\n if (metadata.robots) {\n meta.push({ name: 'robots', content: metadata.robots })\n }\n\n const og = metadata.openGraph\n if (og) {\n if (og.title) {\n meta.push({ content: og.title, property: 'og:title' })\n }\n if (og.description) {\n meta.push({ content: og.description, property: 'og:description' })\n }\n if (og.siteName) {\n meta.push({ content: og.siteName, property: 'og:site_name' })\n }\n\n for (const image of og.images ?? []) {\n meta.push({ content: image.url, property: 'og:image' })\n if (image.width) {\n meta.push({ content: String(image.width), property: 'og:image:width' })\n }\n if (image.height) {\n meta.push({ content: String(image.height), property: 'og:image:height' })\n }\n if (image.alt) {\n meta.push({ content: image.alt, property: 'og:image:alt' })\n }\n }\n\n // Twitter card is inherited from OpenGraph (matches Next.js metadata resolution).\n const firstImage = og.images?.[0]\n if (firstImage) {\n meta.push({ name: 'twitter:card', content: 'summary_large_image' })\n meta.push({ name: 'twitter:image', content: firstImage.url })\n }\n if (og.title) {\n meta.push({ name: 'twitter:title', content: og.title })\n }\n if (og.description) {\n meta.push({ name: 'twitter:description', content: og.description })\n }\n }\n\n for (const icon of metadata.icons ?? []) {\n links.push({\n href: icon.url,\n rel: icon.rel ?? 'icon',\n ...(icon.media ? { media: icon.media } : {}),\n ...(icon.sizes ? { sizes: icon.sizes } : {}),\n ...(icon.type ? { type: icon.type } : {}),\n })\n }\n\n return { links, meta }\n}\n"],"names":["getAdminMeta","metadata","meta","charSet","name","content","links","title","push","description","keywords","robots","og","openGraph","property","siteName","image","images","url","width","String","height","alt","firstImage","icon","icons","href","rel","media","sizes","type"],"mappings":"AAmDA;;;;;;;;;;;CAWC,GACD,OAAO,SAASA,aAAaC,QAA4B;IAIvD,MAAMC,OAAoB;QACxB;YAAEC,SAAS;QAAQ;QACnB;YAAEC,MAAM;YAAYC,SAAS;QAAsC;KACpE;IACD,MAAMC,QAAqB,EAAE;IAE7B,IAAI,CAACL,UAAU;QACb,OAAO;YAAEK;YAAOJ;QAAK;IACvB;IAEA,IAAID,SAASM,KAAK,EAA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AEH,SAASW,MAAMM,GAAG;oBAAER,UAAU;gBAAe;YAC3D;QACF;QAEA,kFAAkF;QAClF,MAAMS,aAAaX,GAAGK,MAAM,EAAE,CAAC,EAAE;QACjC,IAAIM,YAAY;YACdrB,KAAKM,IAAI,CAAC;gBAAEJ,MAAM;gBAAgBC,SAAS;YAAsB;YACjEH,KAAKM,IAAI,CAAC;gBAAEJ,MAAM;gBAAiBC,SAASkB,WAAWL,GAAG;YAAC;QAC7D;QACA,IAAIN,GAAGL,KAAK,EAAE;YACZL,KAAKM,IAAI,CAAC;gBAAEJ,MAAM;gBAAiBC,SAASO,GAAGL,KAAK;YAAC;QACvD;QACA,IAAIK,GAAGH,WAAW,EAAE;YAClBP,KAAKM,IAAI,CAAC;gBAAEJ,MAAM;gBAAuBC,SAASO,GAAGH,WAAW;YAAC;QACnE;IACF;IAEA,KAAK,MAAMe,QAAQvB,SAASwB,KAAK,IAAI,EAAE,CAAE;QACvCnB,MAAME,IAAI,CAAC;YACTkB,MAAMF,KAAKN,GAAG;YACdS,KAAKH,KAAKG,GAAG,IAAI;YACjB,GAAIH,KAAKI,KAAK,GAAG;gBAAEA,OAAOJ,KAAKI,KAAK;YAAC,IAAI,CAAC,CAAC;YAC3C,GAAIJ,KAAKK,KAAK,GAAG;gBAAEA,OAAOL,KAAKK,KAAK;YAAC,IAAI,CAAC,CAAC;YAC3C,GAAIL,KAAKM,IAAI,GAAG;gBAAEA,MAAMN,KAAKM,IAAI;YAAC,IAAI,CAAC,CAAC;QAC1C;IACF;IAEA,OAAO;QAAExB;QAAOJ;IAAK;AACvB"}
1
+ {"version":3,"sources":["../../src/utilities/meta.ts"],"sourcesContent":["import { getViewportContent } from '@payloadcms/ui/layouts'\n\ntype MetaEntry =\n | { charSet: string }\n | { content: string; name: string }\n | { content: string; property: string }\n | { title: string }\n\ntype LinkEntry = {\n href: string\n media?: string\n rel: string\n sizes?: string\n type?: string\n}\n\ntype AdminPageIcon = {\n media?: string\n rel?: string\n sizes?: string\n type?: string\n url: string\n}\n\ntype AdminPageOGImage = {\n alt?: string\n height?: number\n url: string\n width?: number\n}\n\n/**\n * Resolved admin-page metadata produced by the admin-page server function.\n *\n * The server function resolves the framework-agnostic `MetaConfig` (via the\n * shared `generatePageMetadata` in `@payloadcms/ui`) down to plain serializable\n * values, so the route loader can ship it across the wire and feed it to\n * `getAdminMeta` in `head()`.\n */\nexport type AdminPageMetadata = {\n description?: string\n icons?: AdminPageIcon[]\n keywords?: string\n openGraph?: {\n description?: string\n images?: AdminPageOGImage[]\n siteName?: string\n title?: string\n }\n robots?: string\n title?: string\n viewport?: string\n}\n\n/**\n * Builds TanStack Router `head()` `meta` + `links` entries for an admin page\n * from the resolved `AdminPageMetadata`, mirroring the tags Next.js renders\n * natively from the same `MetaConfig` (title, description, robots, keywords,\n * OpenGraph, Twitter — derived from OpenGraph — and icon links).\n *\n * ```ts\n * export const Route = createFileRoute('/admin/$')({\n * head: ({ loaderData }) => getAdminMeta(loaderData?.metadata),\n * })\n * ```\n */\nexport function getAdminMeta(metadata?: AdminPageMetadata): {\n links: LinkEntry[]\n meta: MetaEntry[]\n} {\n const meta: MetaEntry[] = [\n { charSet: 'utf-8' },\n { name: 'viewport', content: metadata?.viewport ?? getViewportContent() },\n ]\n const links: LinkEntry[] = []\n\n if (!metadata) {\n return { links, meta }\n }\n\n if (metadata.title) {\n meta.push({ title: metadata.title })\n }\n if (metadata.description) {\n meta.push({ name: 'description', content: metadata.description })\n }\n if (metadata.keywords) {\n meta.push({ name: 'keywords', content: metadata.keywords })\n }\n if (metadata.robots) {\n meta.push({ name: 'robots', content: metadata.robots })\n }\n\n const og = metadata.openGraph\n if (og) {\n if (og.title) {\n meta.push({ content: og.title, property: 'og:title' })\n }\n if (og.description) {\n meta.push({ content: og.description, property: 'og:description' })\n }\n if (og.siteName) {\n meta.push({ content: og.siteName, property: 'og:site_name' })\n }\n\n for (const image of og.images ?? []) {\n meta.push({ content: image.url, property: 'og:image' })\n if (image.width) {\n meta.push({ content: String(image.width), property: 'og:image:width' })\n }\n if (image.height) {\n meta.push({ content: String(image.height), property: 'og:image:height' })\n }\n if (image.alt) {\n meta.push({ content: image.alt, property: 'og:image:alt' })\n }\n }\n\n // Twitter card is inherited from OpenGraph (matches Next.js metadata resolution).\n const firstImage = og.images?.[0]\n if (firstImage) {\n meta.push({ name: 'twitter:card', content: 'summary_large_image' })\n meta.push({ name: 'twitter:image', content: firstImage.url })\n }\n if (og.title) {\n meta.push({ name: 'twitter:title', content: og.title })\n }\n if (og.description) {\n meta.push({ name: 'twitter:description', content: og.description })\n }\n }\n\n for (const icon of metadata.icons ?? []) {\n links.push({\n href: icon.url,\n rel: icon.rel ?? 'icon',\n ...(icon.media ? { media: icon.media } : {}),\n ...(icon.sizes ? { sizes: icon.sizes } : {}),\n ...(icon.type ? { type: icon.type } : {}),\n })\n }\n\n return { links, meta }\n}\n"],"names":["getViewportContent","getAdminMeta","metadata","meta","charSet","name","content","viewport","links","title","push","description","keywords","robots","og","openGraph","property","siteName","image","images","url","width","String","height","alt","firstImage","icon","icons","href","rel","media","sizes","type"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,yBAAwB;AAsD3D;;;;;;;;;;;CAWC,GACD,OAAO,SAASC,aAAaC,QAA4B;IAIvD,MAAMC,OAAoB;QACxB;YAAEC,SAAS;QAAQ;QACnB;YAAEC,MAAM;YAAYC,SAASJ,UAAUK,YAAYP;QAAqB;KACzE;IACD,MAAMQ,QAAqB,EAAE;IAE7B,IAAI,CAACN,UAAU;QACb,OAAO;YAAEM;YAAOL;QAAK;IACvB;IAEA,IAAID,SAASO,KAAK,EAAE;QAClBN,KAAKO,IAAI,CAAC;YAAED,OAAOP,SAASO,KAAK;QAAC;IACpC;IACA,IAAIP,SAASS,WAAW,EAAE;QACxBR,KAAKO,IAAI,CAAC;YAAEL,MAAM;YAAeC,SAASJ,SAASS,WAAW;QAAC;IACjE;IACA,IAAIT,SAASU,QAAQ,EAAE;QACrBT,KAAKO,IAAI,CAA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IAAI,CAAC;gBAAEL,MAAM;gBAAiBC,SAASmB,WAAWL,GAAG;YAAC;QAC7D;QACA,IAAIN,GAAGL,KAAK,EAAE;YACZN,KAAKO,IAAI,CAAC;gBAAEL,MAAM;gBAAiBC,SAASQ,GAAGL,KAAK;YAAC;QACvD;QACA,IAAIK,GAAGH,WAAW,EAAE;YAClBR,KAAKO,IAAI,CAAC;gBAAEL,MAAM;gBAAuBC,SAASQ,GAAGH,WAAW;YAAC;QACnE;IACF;IAEA,KAAK,MAAMe,QAAQxB,SAASyB,KAAK,IAAI,EAAE,CAAE;QACvCnB,MAAME,IAAI,CAAC;YACTkB,MAAMF,KAAKN,GAAG;YACdS,KAAKH,KAAKG,GAAG,IAAI;YACjB,GAAIH,KAAKI,KAAK,GAAG;gBAAEA,OAAOJ,KAAKI,KAAK;YAAC,IAAI,CAAC,CAAC;YAC3C,GAAIJ,KAAKK,KAAK,GAAG;gBAAEA,OAAOL,KAAKK,KAAK;YAAC,IAAI,CAAC,CAAC;YAC3C,GAAIL,KAAKM,IAAI,GAAG;gBAAEA,MAAMN,KAAKM,IAAI;YAAC,IAAI,CAAC,CAAC;QAC1C;IACF;IAEA,OAAO;QAAExB;QAAOL;IAAK;AACvB"}
@@ -1 +1 @@
1
- {"version":3,"file":"serverAdapter.server.d.ts","sourceRoot":"","sources":["../../src/utilities/serverAdapter.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA8B,aAAa,EAAE,MAAM,SAAS,CAAA;AAsDxE;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,aA8CnC,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,CAAC,EAAE,UAAU,GAAG,UAAU,CAAA;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,6BAA6B,GAAI,KAAK,aAAa,KAAG,aAgBjE,CAAA"}
1
+ {"version":3,"file":"serverAdapter.server.d.ts","sourceRoot":"","sources":["../../src/utilities/serverAdapter.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA8B,aAAa,EAAE,MAAM,SAAS,CAAA;AAsDxE;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,aA8CnC,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,CAAC,EAAE,UAAU,GAAG,UAAU,CAAA;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,6BAA6B,QAAS,aAAa,KAAG,aAgBjE,CAAA"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * SSR/RSC externalization config used by `withPayload`. Kept separate from the
3
+ * client optimizer config (`./optimizeDeps.ts`) so each concern stays small.
4
+ */
5
+ /**
6
+ * Server-only packages (Node-only or only ever used by the server bundle).
7
+ * These are the Vite equivalent of Next.js's `serverExternalPackages`.
8
+ */
9
+ export declare const ssrExternalPackages: string[];
10
+ export declare const payloadNoExternalPatterns: Array<RegExp | string>;
11
+ //# sourceMappingURL=external.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"external.d.ts","sourceRoot":"","sources":["../../../src/vite/config/external.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,EA+BvC,CAAA;AAED,eAAO,MAAM,yBAAyB,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAO5D,CAAA"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * SSR/RSC externalization config used by `withPayload`. Kept separate from the
3
+ * client optimizer config (`./optimizeDeps.ts`) so each concern stays small.
4
+ */ /**
5
+ * Server-only packages (Node-only or only ever used by the server bundle).
6
+ * These are the Vite equivalent of Next.js's `serverExternalPackages`.
7
+ */ export const ssrExternalPackages = [
8
+ 'ajv',
9
+ 'fast-uri',
10
+ 'drizzle-kit',
11
+ 'drizzle-kit/api',
12
+ 'drizzle-orm',
13
+ 'sharp',
14
+ 'require-in-the-middle',
15
+ 'json-schema-to-typescript',
16
+ 'pino',
17
+ 'pino-pretty',
18
+ 'graphql',
19
+ 'nodemailer',
20
+ 'aws4',
21
+ 'pluralize',
22
+ 'console-table-printer',
23
+ '@azure/storage-blob',
24
+ '@aws-sdk/client-s3',
25
+ '@aws-sdk/s3-request-presigner',
26
+ '@google-cloud/storage',
27
+ // Database drivers + their lazily-required companions, one group per adapter.
28
+ // Postgres (`@payloadcms/db-postgres`, `@payloadcms/db-vercel-postgres`)
29
+ 'pg',
30
+ 'pg-native',
31
+ 'pg-cloudflare',
32
+ // SQLite (`@payloadcms/db-sqlite`)
33
+ 'better-sqlite3',
34
+ 'libsql',
35
+ // Mongo (`@payloadcms/db-mongodb`)
36
+ 'mongodb',
37
+ 'mongoose'
38
+ ];
39
+ export const payloadNoExternalPatterns = [
40
+ '@payloadcms/ui',
41
+ '@payloadcms/translations',
42
+ '@payloadcms/tanstack-start',
43
+ /^@payloadcms\/richtext-lexical/,
44
+ /^@payloadcms\/plugin-/,
45
+ /^@payloadcms\/storage-/
46
+ ];
47
+
48
+ //# sourceMappingURL=external.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/vite/config/external.ts"],"sourcesContent":["/**\n * SSR/RSC externalization config used by `withPayload`. Kept separate from the\n * client optimizer config (`./optimizeDeps.ts`) so each concern stays small.\n */\n\n/**\n * Server-only packages (Node-only or only ever used by the server bundle).\n * These are the Vite equivalent of Next.js's `serverExternalPackages`.\n */\nexport const ssrExternalPackages: string[] = [\n 'ajv',\n 'fast-uri',\n 'drizzle-kit',\n 'drizzle-kit/api',\n 'drizzle-orm',\n 'sharp',\n 'require-in-the-middle',\n 'json-schema-to-typescript',\n 'pino',\n 'pino-pretty',\n 'graphql',\n 'nodemailer',\n 'aws4',\n 'pluralize',\n 'console-table-printer',\n '@azure/storage-blob',\n '@aws-sdk/client-s3',\n '@aws-sdk/s3-request-presigner',\n '@google-cloud/storage',\n // Database drivers + their lazily-required companions, one group per adapter.\n // Postgres (`@payloadcms/db-postgres`, `@payloadcms/db-vercel-postgres`)\n 'pg',\n 'pg-native',\n 'pg-cloudflare',\n // SQLite (`@payloadcms/db-sqlite`)\n 'better-sqlite3',\n 'libsql',\n // Mongo (`@payloadcms/db-mongodb`)\n 'mongodb',\n 'mongoose',\n]\n\nexport const payloadNoExternalPatterns: Array<RegExp | string> = [\n '@payloadcms/ui',\n '@payloadcms/translations',\n '@payloadcms/tanstack-start',\n /^@payloadcms\\/richtext-lexical/,\n /^@payloadcms\\/plugin-/,\n /^@payloadcms\\/storage-/,\n]\n"],"names":["ssrExternalPackages","payloadNoExternalPatterns"],"mappings":"AAAA;;;CAGC,GAED;;;CAGC,GACD,OAAO,MAAMA,sBAAgC;IAC3C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,8EAA8E;IAC9E,yEAAyE;IACzE;IACA;IACA;IACA,mCAAmC;IACnC;IACA;IACA,mCAAmC;IACnC;IACA;CACD,CAAA;AAED,OAAO,MAAMC,4BAAoD;IAC/D;IACA;IACA;IACA;IACA;IACA;CACD,CAAA"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Client dep-optimizer config used by `withPayload`. Kept separate from the
3
+ * SSR/RSC externalization config (`./external.ts`) so each concern stays small.
4
+ */
5
+ /**
6
+ * Packages we know contain Node-only code or top-level side effects requiring
7
+ * Node APIs. Excluding them from the client optimizer prevents Vite from
8
+ * walking into their main entries and trying to bundle server-only imports
9
+ * for the browser.
10
+ */
11
+ export declare const optimizeDepsExcludeDefaults: string[];
12
+ /**
13
+ * Transitive dependencies of `@payloadcms/ui` and `payload` that need to be
14
+ * pre-bundled for the client. Vite's auto-discovery doesn't reliably pick
15
+ * these up because their parent packages are in `optimizeDeps.exclude`, so we
16
+ * list them explicitly using the `parent > child` syntax.
17
+ *
18
+ * Each entry below fixes a specific late-discovery re-optimization: without it,
19
+ * Vite discovers the dep *after* its initial crawl, forcing a full dep
20
+ * re-optimization mid-session that 404s in-flight `.vite/deps/*` chunks and
21
+ * remounts the admin (dropping client state). This is why the list can't simply
22
+ * be deleted — it is the "complete first pass" for the admin's dep graph.
23
+ */
24
+ export declare const optimizeDepsIncludeDefaults: string[];
25
+ //# sourceMappingURL=optimizeDeps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optimizeDeps.d.ts","sourceRoot":"","sources":["../../../src/vite/config/optimizeDeps.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,EAAE,MAAM,EAsB/C,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,2BAA2B,EAAE,MAAM,EA8E/C,CAAA"}
@@ -1,67 +1,7 @@
1
1
  /**
2
- * Vite-level configuration constants used by `payloadPlugin`. Kept separate so
3
- * `plugin.ts` stays focused on wiring.
2
+ * Client dep-optimizer config used by `withPayload`. Kept separate from the
3
+ * SSR/RSC externalization config (`./external.ts`) so each concern stays small.
4
4
  */ /**
5
- * Server-only packages (Node-only or only ever used by the server bundle).
6
- * These are the Vite equivalent of Next.js's `serverExternalPackages`.
7
- */ export const ssrExternalPackages = [
8
- 'ajv',
9
- 'fast-uri',
10
- 'drizzle-kit',
11
- 'drizzle-kit/api',
12
- 'drizzle-orm',
13
- 'sharp',
14
- 'libsql',
15
- 'require-in-the-middle',
16
- 'json-schema-to-typescript',
17
- 'pino',
18
- 'pino-pretty',
19
- 'graphql',
20
- 'mongodb',
21
- 'mongoose',
22
- 'better-sqlite3',
23
- 'pg',
24
- 'pg-native',
25
- 'nodemailer',
26
- 'aws4',
27
- 'pluralize',
28
- 'console-table-printer',
29
- '@azure/storage-blob',
30
- '@aws-sdk/client-s3',
31
- '@aws-sdk/s3-request-presigner',
32
- '@google-cloud/storage'
33
- ];
34
- /**
35
- * Payload packages whose source must be processed by Vite even on the server
36
- * (because they are workspace `.ts` files in dev). Server-only adapters
37
- * (`@payloadcms/db-*`, `@payloadcms/email-*`, `@payloadcms/next`, etc.) are
38
- * intentionally not included — those should stay external on the SSR side.
39
- */ export const payloadNoExternalPatterns = [
40
- '@payloadcms/ui',
41
- '@payloadcms/translations',
42
- '@payloadcms/tanstack-start',
43
- /^@payloadcms\/richtext-lexical/,
44
- /^@payloadcms\/plugin-/,
45
- /^@payloadcms\/storage-/
46
- ];
47
- /**
48
- * The subset of `payloadNoExternalPatterns` that needs to participate in the
49
- * RSC environment. Plugins and storage adapters must be included: they register
50
- * custom providers/components (e.g. `plugin-multi-tenant`'s `'use client'`
51
- * `TenantSelectionProvider`) that render in the RSC graph via
52
- * `RenderServerComponent`. If the package stays external to RSC, `plugin-rsc`
53
- * never transforms its `'use client'` modules into client references, so the
54
- * component executes server-side and crashes on the first hook
55
- * (`Cannot read properties of null (reading 'useState')`).
56
- */ export const payloadRscNoExternalPatterns = [
57
- '@payloadcms/ui',
58
- '@payloadcms/translations',
59
- '@payloadcms/tanstack-start',
60
- /^@payloadcms\/richtext-lexical/,
61
- /^@payloadcms\/plugin-/,
62
- /^@payloadcms\/storage-/
63
- ];
64
- /**
65
5
  * Packages we know contain Node-only code or top-level side effects requiring
66
6
  * Node APIs. Excluding them from the client optimizer prevents Vite from
67
7
  * walking into their main entries and trying to bundle server-only imports
@@ -94,6 +34,12 @@
94
34
  * pre-bundled for the client. Vite's auto-discovery doesn't reliably pick
95
35
  * these up because their parent packages are in `optimizeDeps.exclude`, so we
96
36
  * list them explicitly using the `parent > child` syntax.
37
+ *
38
+ * Each entry below fixes a specific late-discovery re-optimization: without it,
39
+ * Vite discovers the dep *after* its initial crawl, forcing a full dep
40
+ * re-optimization mid-session that 404s in-flight `.vite/deps/*` chunks and
41
+ * remounts the admin (dropping client state). This is why the list can't simply
42
+ * be deleted — it is the "complete first pass" for the admin's dep graph.
97
43
  */ export const optimizeDepsIncludeDefaults = [
98
44
  '@payloadcms/ui > sonner',
99
45
  '@payloadcms/ui > @faceless-ui/modal',
@@ -174,4 +120,4 @@
174
120
  'payload > sanitize-filename'
175
121
  ];
176
122
 
177
- //# sourceMappingURL=constants.js.map
123
+ //# sourceMappingURL=optimizeDeps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/vite/config/optimizeDeps.ts"],"sourcesContent":["/**\n * Client dep-optimizer config used by `withPayload`. Kept separate from the\n * SSR/RSC externalization config (`./external.ts`) so each concern stays small.\n */\n\n/**\n * Packages we know contain Node-only code or top-level side effects requiring\n * Node APIs. Excluding them from the client optimizer prevents Vite from\n * walking into their main entries and trying to bundle server-only imports\n * for the browser.\n */\nexport const optimizeDepsExcludeDefaults: string[] = [\n 'sharp',\n '@payloadcms/ui',\n '@payloadcms/tanstack-start',\n 'payload',\n 'pino',\n 'pino-pretty',\n 'busboy',\n 'get-tsconfig',\n 'ws',\n 'croner',\n 'prompts',\n 'file-type',\n // Server-only SDKs used by `@payloadcms/storage-*` adapters. Vite\n // sometimes walks these from the main package entry while scanning\n // workspace deps, and the browser sub-bundles do not expose the\n // server-only APIs (e.g. `BlobSASPermissions`), which crashes the dev\n // server with a `MISSING_EXPORT` error before any test runs.\n '@azure/storage-blob',\n '@aws-sdk/client-s3',\n '@aws-sdk/s3-request-presigner',\n '@google-cloud/storage',\n]\n\n/**\n * Transitive dependencies of `@payloadcms/ui` and `payload` that need to be\n * pre-bundled for the client. Vite's auto-discovery doesn't reliably pick\n * these up because their parent packages are in `optimizeDeps.exclude`, so we\n * list them explicitly using the `parent > child` syntax.\n *\n * Each entry below fixes a specific late-discovery re-optimization: without it,\n * Vite discovers the dep *after* its initial crawl, forcing a full dep\n * re-optimization mid-session that 404s in-flight `.vite/deps/*` chunks and\n * remounts the admin (dropping client state). This is why the list can't simply\n * be deleted — it is the \"complete first pass\" for the admin's dep graph.\n */\nexport const optimizeDepsIncludeDefaults: string[] = [\n '@payloadcms/ui > sonner',\n '@payloadcms/ui > @faceless-ui/modal',\n '@payloadcms/ui > @faceless-ui/window-info',\n '@payloadcms/ui > @faceless-ui/scroll-info',\n '@payloadcms/ui > @dnd-kit/core',\n '@payloadcms/ui > @dnd-kit/sortable',\n '@payloadcms/ui > @dnd-kit/utilities',\n '@payloadcms/ui > react-datepicker',\n '@payloadcms/ui > react-select',\n '@payloadcms/ui > react-select/creatable',\n '@payloadcms/ui > react-image-crop',\n '@payloadcms/ui > @monaco-editor/react',\n '@payloadcms/ui > date-fns',\n '@payloadcms/ui > date-fns/transpose',\n '@payloadcms/ui > @date-fns/tz/date/mini',\n '@payloadcms/ui > uuid',\n '@payloadcms/ui > use-context-selector',\n '@payloadcms/ui > bson-objectid',\n '@payloadcms/ui > dequal',\n '@payloadcms/ui > object-to-formdata',\n '@payloadcms/ui > md5',\n 'payload > deepmerge',\n 'payload > pluralize',\n // `scheduler` is a transitive dep of `react-dom`, not a direct dependency of\n // the app, so a bare `'scheduler'` specifier fails to resolve from an isolated\n // install (`test/node_modules` built with `pnpm i --ignore-workspace`), where\n // it isn't hoisted to the top level. Path it through `react-dom` so the\n // optimizer resolves the exact copy the runtime loads.\n 'react-dom > scheduler',\n // `@payloadcms/ui` (in `optimizeDeps.exclude`) ships compiled output that the\n // React Compiler rewrote to `import { c } from 'react/compiler-runtime'`.\n // Because its parent is excluded, the optimizer never crawls in to discover\n // this entry, so Vite serves `react/compiler-runtime` raw. That file is\n // CommonJS (`module.exports = require(...)`), so the named `c` export can't be\n // statically extracted and every client component throws \"does not provide an\n // export named 'c'\". Pre-bundling it lets esbuild synthesize the named export.\n 'react/compiler-runtime',\n // Transitive deps that Vite otherwise discovers *after* the initial crawl\n // (react-select pulls in @floating-ui at runtime; react-is is reached via\n // react-transition-group/prop-types; the default date-fns locale is loaded\n // through a dynamic `date-fns/locale/${key}` import). A late discovery forces\n // a full dep re-optimization mid-session, which 404s every in-flight\n // `.vite/deps/*` chunk (\"Pre-transform error: file does not exist in the\n // optimize deps directory\") and breaks the admin UI in CI cold starts.\n // Pre-bundling them keeps the first optimization pass complete.\n '@payloadcms/ui > react-select > @floating-ui/dom',\n '@payloadcms/ui > react-select > @floating-ui/dom > @floating-ui/core',\n '@payloadcms/ui > react-select > prop-types > react-is',\n '@payloadcms/ui > date-fns/locale/en-US',\n // Further late discoveries observed re-optimizing mid-run in CI cold starts\n // (see CI logs: \"✨ new dependencies optimized: @dnd-kit/modifiers / ajv /\n // dequal/lite\"). The modular dashboard pulls in `@dnd-kit/modifiers` on first\n // render; form-state diffing reaches `dequal/lite` (a distinct entry point\n // from the already-listed `dequal`); client-side field validation reaches\n // `ajv` *through `payload`* — it is `ssrExternal` server-side but still\n // bundled into the client, and must be pathed via `payload` so the optimizer\n // pre-bundles the exact copy the runtime loads.\n '@payloadcms/ui > @dnd-kit/modifiers',\n '@payloadcms/ui > dequal/lite',\n 'payload > ajv',\n // The storage client-upload suites (esp. vercel-blob) crawl part of the\n // `payload` server runtime into the client bundle and discover these late,\n // triggering several \"optimized dependencies changed. reloading\" waves that\n // reload the page mid-test (the bulk-upload drawer's Create New button /\n // dropzone vanish and the direct-to-bucket PUT never fires). Pre-bundle the\n // whole observed set so the first pass is complete.\n 'payload > undici',\n 'payload > jose',\n 'payload > dataloader',\n 'payload > path-to-regexp',\n 'payload > console-table-printer',\n 'payload > ci-info',\n 'payload > image-size',\n 'payload > image-size/fromFile',\n 'payload > ipaddr.js',\n 'payload > range-parser',\n 'payload > sanitize-filename',\n]\n"],"names":["optimizeDepsExcludeDefaults","optimizeDepsIncludeDefaults"],"mappings":"AAAA;;;CAGC,GAED;;;;;CAKC,GACD,OAAO,MAAMA,8BAAwC;IACnD;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,kEAAkE;IAClE,mEAAmE;IACnE,gEAAgE;IAChE,sEAAsE;IACtE,6DAA6D;IAC7D;IACA;IACA;IACA;CACD,CAAA;AAED;;;;;;;;;;;CAWC,GACD,OAAO,MAAMC,8BAAwC;IACnD;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,6EAA6E;IAC7E,+EAA+E;IAC/E,8EAA8E;IAC9E,wEAAwE;IACxE,uDAAuD;IACvD;IACA,8EAA8E;IAC9E,0EAA0E;IAC1E,4EAA4E;IAC5E,wEAAwE;IACxE,+EAA+E;IAC/E,8EAA8E;IAC9E,+EAA+E;IAC/E;IACA,0EAA0E;IAC1E,0EAA0E;IAC1E,2EAA2E;IAC3E,8EAA8E;IAC9E,qEAAqE;IACrE,yEAAyE;IACzE,uEAAuE;IACvE,gEAAgE;IAChE;IACA;IACA;IACA;IACA,4EAA4E;IAC5E,0EAA0E;IAC1E,8EAA8E;IAC9E,2EAA2E;IAC3E,0EAA0E;IAC1E,wEAAwE;IACxE,6EAA6E;IAC7E,gDAAgD;IAChD;IACA;IACA;IACA,wEAAwE;IACxE,2EAA2E;IAC3E,4EAA4E;IAC5E,yEAAyE;IACzE,4EAA4E;IAC5E,oDAAoD;IACpD;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAA"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * SCSS `@import`/`@use` importers applied for every Payload consumer.
3
+ *
4
+ * Resolves webpack-style `~@payloadcms/...` tilde specifiers (emitted by
5
+ * first-party Payload package styles, e.g. `@payloadcms/richtext-slate`) to the
6
+ * installed package via Node resolution. Because it goes through the package's
7
+ * `exports` map, it picks the workspace `src` scss in the monorepo and the
8
+ * published `dist` scss in a consumer install automatically — no per-app
9
+ * `findFileUrl` shim needed.
10
+ */
11
+ export declare const payloadScssImporters: {
12
+ findFileUrl(url: string): null | URL;
13
+ }[];
14
+ //# sourceMappingURL=scss.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scss.d.ts","sourceRoot":"","sources":["../../../src/vite/config/scss.ts"],"names":[],"mappings":"AAKA;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB;qBAEZ,MAAM,GAAG,IAAI,GAAG,GAAG;GAWvC,CAAA"}
@@ -0,0 +1,28 @@
1
+ import { createRequire } from 'node:module';
2
+ import { pathToFileURL } from 'node:url';
3
+ const require = createRequire(import.meta.url);
4
+ /**
5
+ * SCSS `@import`/`@use` importers applied for every Payload consumer.
6
+ *
7
+ * Resolves webpack-style `~@payloadcms/...` tilde specifiers (emitted by
8
+ * first-party Payload package styles, e.g. `@payloadcms/richtext-slate`) to the
9
+ * installed package via Node resolution. Because it goes through the package's
10
+ * `exports` map, it picks the workspace `src` scss in the monorepo and the
11
+ * published `dist` scss in a consumer install automatically — no per-app
12
+ * `findFileUrl` shim needed.
13
+ */ export const payloadScssImporters = [
14
+ {
15
+ findFileUrl (url) {
16
+ if (!url.startsWith('~@payloadcms/')) {
17
+ return null;
18
+ }
19
+ try {
20
+ return pathToFileURL(require.resolve(url.slice(1)));
21
+ } catch {
22
+ return null;
23
+ }
24
+ }
25
+ }
26
+ ];
27
+
28
+ //# sourceMappingURL=scss.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/vite/config/scss.ts"],"sourcesContent":["import { createRequire } from 'node:module'\nimport { pathToFileURL } from 'node:url'\n\nconst require = createRequire(import.meta.url)\n\n/**\n * SCSS `@import`/`@use` importers applied for every Payload consumer.\n *\n * Resolves webpack-style `~@payloadcms/...` tilde specifiers (emitted by\n * first-party Payload package styles, e.g. `@payloadcms/richtext-slate`) to the\n * installed package via Node resolution. Because it goes through the package's\n * `exports` map, it picks the workspace `src` scss in the monorepo and the\n * published `dist` scss in a consumer install automatically — no per-app\n * `findFileUrl` shim needed.\n */\nexport const payloadScssImporters = [\n {\n findFileUrl(url: string): null | URL {\n if (!url.startsWith('~@payloadcms/')) {\n return null\n }\n try {\n return pathToFileURL(require.resolve(url.slice(1)))\n } catch {\n return null\n }\n },\n },\n]\n"],"names":["createRequire","pathToFileURL","require","url","payloadScssImporters","findFileUrl","startsWith","resolve","slice"],"mappings":"AAAA,SAASA,aAAa,QAAQ,cAAa;AAC3C,SAASC,aAAa,QAAQ,WAAU;AAExC,MAAMC,UAAUF,cAAc,YAAYG,GAAG;AAE7C;;;;;;;;;CASC,GACD,OAAO,MAAMC,uBAAuB;IAClC;QACEC,aAAYF,GAAW;YACrB,IAAI,CAACA,IAAIG,UAAU,CAAC,kBAAkB;gBACpC,OAAO;YACT;YACA,IAAI;gBACF,OAAOL,cAAcC,QAAQK,OAAO,CAACJ,IAAIK,KAAK,CAAC;YACjD,EAAE,OAAM;gBACN,OAAO;YACT;QACF;IACF;CACD,CAAA"}
@@ -0,0 +1,99 @@
1
+ import type { ConfigEnv, UserConfig, UserConfigFnObject } from 'vite';
2
+ import { tanstackStart } from '@tanstack/react-start/plugin/vite';
3
+ import viteReact from '@vitejs/plugin-react';
4
+ import rsc from '@vitejs/plugin-rsc';
5
+ export type WithPayloadOptions = {
6
+ /** Extra import-protection `ignoreImporters` patterns for the TanStack Start plugin. */
7
+ additionalIgnoreImporters?: RegExp[];
8
+ /** Route id of Payload's admin layout, eager-loaded instead of code-split. Defaults to `'/_payload'`. */
9
+ adminRouteId?: string;
10
+ /** Extra globs exempted from the `.client.*` SSR denial (beyond the default node_modules exemption). */
11
+ clientDenialExcludeFiles?: string[];
12
+ /** Path to the user's `payload.config.ts` (required) */
13
+ payloadConfigPath: string;
14
+ /** TanStack router routes directory relative to `srcDirectory`. Defaults to `'app'` */
15
+ routesDirectory?: string;
16
+ /** Silence Vite warnings about third-party dependency sourcemaps. Defaults to `true`. */
17
+ silenceDependencyWarnings?: boolean;
18
+ /** TanStack source directory. Defaults to `'src'` */
19
+ srcDirectory?: string;
20
+ /** Extra Vite config deep-merged over the Payload defaults. Ignored in `build` mode. */
21
+ vite?: UserConfig;
22
+ };
23
+ /** The options Payload's admin requires for each third-party plugin. */
24
+ export type PayloadPluginOptions = {
25
+ react: NonNullable<Parameters<typeof viteReact>[0]>;
26
+ rsc: NonNullable<Parameters<typeof rsc>[0]>;
27
+ tanstackStart: NonNullable<Parameters<typeof tanstackStart>[0]>;
28
+ };
29
+ export type WithPayloadBuilderContext = {
30
+ env: ConfigEnv;
31
+ /** Options to pass to the `viteReact`/`rsc`/`tanstackStart` factories you import. */
32
+ pluginOptions: PayloadPluginOptions;
33
+ };
34
+ /**
35
+ * Returns the extra Vite config — the plugins you instantiate plus any overrides.
36
+ * `withPayload` deep-merges it onto Payload's base config, so you don't spread or
37
+ * merge the base yourself.
38
+ */
39
+ export type WithPayloadBuilder = (context: WithPayloadBuilderContext) => UserConfig;
40
+ /**
41
+ * Vite config helper for Payload + TanStack Start; the counterpart to Next.js'
42
+ * `withPayload`.
43
+ *
44
+ * Zero-config — Payload instantiates the RSC, React, and TanStack Start plugins:
45
+ *
46
+ * ```ts
47
+ * export default withPayload(undefined, { payloadConfigPath: './src/payload.config.ts' })
48
+ * ```
49
+ *
50
+ * Guest mode — pass a `build` callback to instantiate them yourself (one copy of
51
+ * each; `@vitejs/plugin-rsc` is a hard singleton). Return only your additions;
52
+ * `withPayload` deep-merges them onto Payload's base config:
53
+ *
54
+ * ```ts
55
+ * export default withPayload(
56
+ * ({ pluginOptions }) => ({
57
+ * plugins: [
58
+ * rsc(pluginOptions.rsc),
59
+ * tanstackStart(pluginOptions.tanstackStart),
60
+ * viteReact(pluginOptions.react),
61
+ * ],
62
+ * // ...other config options
63
+ * }),
64
+ * { payloadConfigPath: './src/payload.config.ts' },
65
+ * )
66
+ * ```
67
+ */
68
+ export declare function withPayload(build: undefined | WithPayloadBuilder, options: WithPayloadOptions): UserConfigFnObject;
69
+ /** `@vitejs/plugin-rsc` options for Payload: `serverHandler: false` (TanStack owns the handler). */
70
+ export declare function payloadRscOptions(): NonNullable<Parameters<typeof rsc>[0]>;
71
+ /** `@vitejs/plugin-react` options for Payload: transform every `.[jt]sx?` file. */
72
+ export declare function payloadReactOptions(): NonNullable<Parameters<typeof viteReact>[0]>;
73
+ export type PayloadTanstackStartOptionsArgs = {
74
+ /** Additional import-protection `ignoreImporters` patterns. */
75
+ additionalIgnoreImporters?: RegExp[];
76
+ /**
77
+ * Route id of Payload's admin layout route, eager-loaded (not code-split) so it
78
+ * hydrates on first paint. It and its children skip splitting; host routes keep
79
+ * TanStack's default. Defaults to `'/_payload'` (the `_payload.tsx` convention).
80
+ */
81
+ adminRouteId?: string;
82
+ /**
83
+ * Extra globs exempted from TanStack's `.client.*` SSR denial, on top of the
84
+ * default node_modules exemption. Needed only when Payload's own `.client.*`
85
+ * files resolve outside node_modules (e.g. the monorepo's `packages` sources).
86
+ */
87
+ clientDenialExcludeFiles?: string[];
88
+ /** TanStack router routes directory relative to `srcDirectory`. Defaults to `'app'`. */
89
+ routesDirectory?: string;
90
+ /** TanStack source directory. Defaults to `'src'`. */
91
+ srcDirectory?: string;
92
+ };
93
+ /**
94
+ * The `tanstackStart` options Payload's admin requires (import-protection and
95
+ * code-splitting). TanStack Start is one-per-app, so a host that already runs it
96
+ * should merge these into its single `tanstackStart` call.
97
+ */
98
+ export declare function payloadTanstackStartOptions(args?: PayloadTanstackStartOptionsArgs): NonNullable<Parameters<typeof tanstackStart>[0]>;
99
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAwB,UAAU,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAA;AAI3F,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAA;AACjE,OAAO,SAAS,MAAM,sBAAsB,CAAA;AAC5C,OAAO,GAAG,MAAM,oBAAoB,CAAA;AA0DpC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,wFAAwF;IACxF,yBAAyB,CAAC,EAAE,MAAM,EAAE,CAAA;IACpC,yGAAyG;IACzG,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,wGAAwG;IACxG,wBAAwB,CAAC,EAAE,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