@payloadcms/tanstack-start 4.0.0-internal.078835b → 4.0.0-internal.164164a

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 (193) hide show
  1. package/dist/auth/login.d.ts +3 -16
  2. package/dist/auth/login.d.ts.map +1 -1
  3. package/dist/auth/login.js +6 -46
  4. package/dist/auth/login.js.map +1 -1
  5. package/dist/auth/logout.d.ts +2 -5
  6. package/dist/auth/logout.d.ts.map +1 -1
  7. package/dist/auth/logout.js +6 -47
  8. package/dist/auth/logout.js.map +1 -1
  9. package/dist/auth/refresh.d.ts +2 -4
  10. package/dist/auth/refresh.d.ts.map +1 -1
  11. package/dist/auth/refresh.js +6 -49
  12. package/dist/auth/refresh.js.map +1 -1
  13. package/dist/exports/client.d.ts +1 -2
  14. package/dist/exports/client.d.ts.map +1 -1
  15. package/dist/exports/client.js +1 -2
  16. package/dist/exports/client.js.map +1 -1
  17. package/dist/exports/layouts.d.ts +1 -3
  18. package/dist/exports/layouts.d.ts.map +1 -1
  19. package/dist/exports/layouts.js +0 -1
  20. package/dist/exports/layouts.js.map +1 -1
  21. package/dist/exports/rsc.browser.d.ts +4 -1
  22. package/dist/exports/rsc.browser.d.ts.map +1 -1
  23. package/dist/exports/rsc.browser.js +4 -1
  24. package/dist/exports/rsc.browser.js.map +1 -1
  25. package/dist/exports/rsc.d.ts +0 -1
  26. package/dist/exports/rsc.d.ts.map +1 -1
  27. package/dist/exports/rsc.js +0 -1
  28. package/dist/exports/rsc.js.map +1 -1
  29. package/dist/exports/server.d.ts +3 -3
  30. package/dist/exports/server.d.ts.map +1 -1
  31. package/dist/exports/server.js +3 -3
  32. package/dist/exports/server.js.map +1 -1
  33. package/dist/exports/shared.d.ts +2 -0
  34. package/dist/exports/shared.d.ts.map +1 -0
  35. package/dist/exports/shared.js +3 -0
  36. package/dist/exports/shared.js.map +1 -0
  37. package/dist/index.d.ts +1 -6
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +1 -6
  40. package/dist/index.js.map +1 -1
  41. package/dist/layouts/Root/getLayoutData.d.ts +24 -2
  42. package/dist/layouts/Root/getLayoutData.d.ts.map +1 -1
  43. package/dist/layouts/Root/getLayoutData.js +7 -1
  44. package/dist/layouts/Root/getLayoutData.js.map +1 -1
  45. package/dist/layouts/Root/withPayloadRoot.d.ts +7 -31
  46. package/dist/layouts/Root/withPayloadRoot.d.ts.map +1 -1
  47. package/dist/layouts/Root/withPayloadRoot.js +33 -34
  48. package/dist/layouts/Root/withPayloadRoot.js.map +1 -1
  49. package/dist/routes/adminRoutes.d.ts +13 -3
  50. package/dist/routes/adminRoutes.d.ts.map +1 -1
  51. package/dist/routes/adminRoutes.js +45 -37
  52. package/dist/routes/adminRoutes.js.map +1 -1
  53. package/dist/routes/apiRoute.d.ts +5 -0
  54. package/dist/routes/apiRoute.d.ts.map +1 -1
  55. package/dist/routes/apiRoute.js +6 -1
  56. package/dist/routes/apiRoute.js.map +1 -1
  57. package/dist/routes/layoutRoute.d.ts.map +1 -1
  58. package/dist/routes/layoutRoute.js +1 -0
  59. package/dist/routes/layoutRoute.js.map +1 -1
  60. package/dist/utilities/getRequestLocale.d.ts.map +1 -1
  61. package/dist/utilities/getRequestLocale.js +1 -2
  62. package/dist/utilities/getRequestLocale.js.map +1 -1
  63. package/dist/utilities/{handleAPIRoute.d.ts → handleAPIRoute.server.d.ts} +1 -1
  64. package/dist/utilities/handleAPIRoute.server.d.ts.map +1 -0
  65. package/dist/utilities/{handleAPIRoute.js → handleAPIRoute.server.js} +1 -1
  66. package/dist/utilities/handleAPIRoute.server.js.map +1 -0
  67. package/dist/utilities/handleServerFunctions.d.ts +1 -19
  68. package/dist/utilities/handleServerFunctions.d.ts.map +1 -1
  69. package/dist/utilities/handleServerFunctions.js +8 -56
  70. package/dist/utilities/handleServerFunctions.js.map +1 -1
  71. package/dist/utilities/loadAdminPage.d.ts.map +1 -1
  72. package/dist/utilities/loadAdminPage.js +4 -12
  73. package/dist/utilities/loadAdminPage.js.map +1 -1
  74. package/dist/utilities/meta.js +1 -1
  75. package/dist/utilities/meta.js.map +1 -1
  76. package/dist/utilities/routerSearch.d.ts +1 -1
  77. package/dist/utilities/routerSearch.js +1 -1
  78. package/dist/utilities/routerSearch.js.map +1 -1
  79. package/dist/withPayload/config/external.d.ts +36 -0
  80. package/dist/withPayload/config/external.d.ts.map +1 -0
  81. package/dist/withPayload/config/external.js +82 -0
  82. package/dist/withPayload/config/external.js.map +1 -0
  83. package/dist/withPayload/config/optimizeDeps.d.ts.map +1 -0
  84. package/dist/withPayload/config/optimizeDeps.js.map +1 -0
  85. package/dist/withPayload/config/scss.d.ts.map +1 -0
  86. package/dist/withPayload/config/scss.js.map +1 -0
  87. package/dist/withPayload/importProtection.d.ts.map +1 -0
  88. package/dist/{vite → withPayload}/importProtection.js +2 -2
  89. package/dist/withPayload/importProtection.js.map +1 -0
  90. package/dist/withPayload/index.d.ts.map +1 -0
  91. package/dist/{vite → withPayload}/index.js +26 -7
  92. package/dist/withPayload/index.js.map +1 -0
  93. package/dist/withPayload/workarounds/clientModuleResolution.d.ts.map +1 -0
  94. package/dist/withPayload/workarounds/clientModuleResolution.js.map +1 -0
  95. package/dist/withPayload/workarounds/devTransforms.d.ts.map +1 -0
  96. package/dist/withPayload/workarounds/devTransforms.js.map +1 -0
  97. package/dist/withPayload/workarounds/reactDomServerInRsc.d.ts.map +1 -0
  98. package/dist/withPayload/workarounds/reactDomServerInRsc.js.map +1 -0
  99. package/dist/withPayload/workarounds/stripDistStyleImports.d.ts.map +1 -0
  100. package/dist/{vite → withPayload}/workarounds/stripDistStyleImports.js +1 -1
  101. package/dist/withPayload/workarounds/stripDistStyleImports.js.map +1 -0
  102. package/dist/withPayload/workarounds/stubPrettierInClient.d.ts.map +1 -0
  103. package/dist/withPayload/workarounds/stubPrettierInClient.js.map +1 -0
  104. package/dist/withPayload/workarounds/wrapCjsForClient.d.ts.map +1 -0
  105. package/dist/withPayload/workarounds/wrapCjsForClient.js.map +1 -0
  106. package/package.json +10 -10
  107. package/dist/elements/DocumentHeaderClient/index.d.ts +0 -16
  108. package/dist/elements/DocumentHeaderClient/index.d.ts.map +0 -1
  109. package/dist/elements/DocumentHeaderClient/index.js +0 -116
  110. package/dist/elements/DocumentHeaderClient/index.js.map +0 -1
  111. package/dist/elements/RenderComponent/index.d.ts +0 -10
  112. package/dist/elements/RenderComponent/index.d.ts.map +0 -1
  113. package/dist/elements/RenderComponent/index.js +0 -12
  114. package/dist/elements/RenderComponent/index.js.map +0 -1
  115. package/dist/exports/vite.d.ts +0 -3
  116. package/dist/exports/vite.d.ts.map +0 -1
  117. package/dist/exports/vite.js +0 -3
  118. package/dist/exports/vite.js.map +0 -1
  119. package/dist/layouts/Root/index.d.ts +0 -32
  120. package/dist/layouts/Root/index.d.ts.map +0 -1
  121. package/dist/layouts/Root/index.js +0 -51
  122. package/dist/layouts/Root/index.js.map +0 -1
  123. package/dist/rsc/renderPayloadRSC.d.ts +0 -6
  124. package/dist/rsc/renderPayloadRSC.d.ts.map +0 -1
  125. package/dist/rsc/renderPayloadRSC.js +0 -6
  126. package/dist/rsc/renderPayloadRSC.js.map +0 -1
  127. package/dist/utilities/getExistingAuthToken.d.ts +0 -7
  128. package/dist/utilities/getExistingAuthToken.d.ts.map +0 -1
  129. package/dist/utilities/getExistingAuthToken.js +0 -18
  130. package/dist/utilities/getExistingAuthToken.js.map +0 -1
  131. package/dist/utilities/getPreferences.d.ts +0 -10
  132. package/dist/utilities/getPreferences.d.ts.map +0 -1
  133. package/dist/utilities/getPreferences.js +0 -33
  134. package/dist/utilities/getPreferences.js.map +0 -1
  135. package/dist/utilities/getRequestTheme.d.ts +0 -10
  136. package/dist/utilities/getRequestTheme.d.ts.map +0 -1
  137. package/dist/utilities/getRequestTheme.js +0 -25
  138. package/dist/utilities/getRequestTheme.js.map +0 -1
  139. package/dist/utilities/handleAPIRoute.d.ts.map +0 -1
  140. package/dist/utilities/handleAPIRoute.js.map +0 -1
  141. package/dist/utilities/importMap.server.d.ts +0 -8
  142. package/dist/utilities/importMap.server.d.ts.map +0 -1
  143. package/dist/utilities/importMap.server.js +0 -11
  144. package/dist/utilities/importMap.server.js.map +0 -1
  145. package/dist/utilities/serverFunctionHandlers.d.ts +0 -18
  146. package/dist/utilities/serverFunctionHandlers.d.ts.map +0 -1
  147. package/dist/utilities/serverFunctionHandlers.js +0 -17
  148. package/dist/utilities/serverFunctionHandlers.js.map +0 -1
  149. package/dist/utilities/setPayloadAuthCookie.d.ts +0 -9
  150. package/dist/utilities/setPayloadAuthCookie.d.ts.map +0 -1
  151. package/dist/utilities/setPayloadAuthCookie.js +0 -31
  152. package/dist/utilities/setPayloadAuthCookie.js.map +0 -1
  153. package/dist/vite/config/external.d.ts +0 -11
  154. package/dist/vite/config/external.d.ts.map +0 -1
  155. package/dist/vite/config/external.js +0 -48
  156. package/dist/vite/config/external.js.map +0 -1
  157. package/dist/vite/config/optimizeDeps.d.ts.map +0 -1
  158. package/dist/vite/config/optimizeDeps.js.map +0 -1
  159. package/dist/vite/config/scss.d.ts.map +0 -1
  160. package/dist/vite/config/scss.js.map +0 -1
  161. package/dist/vite/importProtection.d.ts.map +0 -1
  162. package/dist/vite/importProtection.js.map +0 -1
  163. package/dist/vite/index.d.ts.map +0 -1
  164. package/dist/vite/index.js.map +0 -1
  165. package/dist/vite/workarounds/clientModuleResolution.d.ts.map +0 -1
  166. package/dist/vite/workarounds/clientModuleResolution.js.map +0 -1
  167. package/dist/vite/workarounds/devTransforms.d.ts.map +0 -1
  168. package/dist/vite/workarounds/devTransforms.js.map +0 -1
  169. package/dist/vite/workarounds/reactDomServerInRsc.d.ts.map +0 -1
  170. package/dist/vite/workarounds/reactDomServerInRsc.js.map +0 -1
  171. package/dist/vite/workarounds/stripDistStyleImports.d.ts.map +0 -1
  172. package/dist/vite/workarounds/stripDistStyleImports.js.map +0 -1
  173. package/dist/vite/workarounds/stubPrettierInClient.d.ts.map +0 -1
  174. package/dist/vite/workarounds/stubPrettierInClient.js.map +0 -1
  175. package/dist/vite/workarounds/wrapCjsForClient.d.ts.map +0 -1
  176. package/dist/vite/workarounds/wrapCjsForClient.js.map +0 -1
  177. /package/dist/{vite → withPayload}/config/optimizeDeps.d.ts +0 -0
  178. /package/dist/{vite → withPayload}/config/optimizeDeps.js +0 -0
  179. /package/dist/{vite → withPayload}/config/scss.d.ts +0 -0
  180. /package/dist/{vite → withPayload}/config/scss.js +0 -0
  181. /package/dist/{vite → withPayload}/importProtection.d.ts +0 -0
  182. /package/dist/{vite → withPayload}/index.d.ts +0 -0
  183. /package/dist/{vite → withPayload}/workarounds/clientModuleResolution.d.ts +0 -0
  184. /package/dist/{vite → withPayload}/workarounds/clientModuleResolution.js +0 -0
  185. /package/dist/{vite → withPayload}/workarounds/devTransforms.d.ts +0 -0
  186. /package/dist/{vite → withPayload}/workarounds/devTransforms.js +0 -0
  187. /package/dist/{vite → withPayload}/workarounds/reactDomServerInRsc.d.ts +0 -0
  188. /package/dist/{vite → withPayload}/workarounds/reactDomServerInRsc.js +0 -0
  189. /package/dist/{vite → withPayload}/workarounds/stripDistStyleImports.d.ts +0 -0
  190. /package/dist/{vite → withPayload}/workarounds/stubPrettierInClient.d.ts +0 -0
  191. /package/dist/{vite → withPayload}/workarounds/stubPrettierInClient.js +0 -0
  192. /package/dist/{vite → withPayload}/workarounds/wrapCjsForClient.d.ts +0 -0
  193. /package/dist/{vite → withPayload}/workarounds/wrapCjsForClient.js +0 -0
@@ -1,10 +1,11 @@
1
1
  import { getNavPrefs } from '@payloadcms/ui/elements/Nav/getNavPrefs';
2
2
  import { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent';
3
3
  import { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig';
4
+ import { getRequestEmbed } from '@payloadcms/ui/utilities/getRequestEmbed';
5
+ import { getRequestTheme } from '@payloadcms/ui/utilities/getRequestTheme';
4
6
  import { Outlet } from '@tanstack/react-router';
5
7
  import { applyLocaleFiltering } from 'payload/shared';
6
8
  import { createElement } from 'react';
7
- import { getRequestTheme } from '../../utilities/getRequestTheme.js';
8
9
  import { initReq } from '../../utilities/initReq.server.js';
9
10
  /**
10
11
  * Fetches all data needed by the root admin layout.
@@ -19,6 +20,10 @@ import { initReq } from '../../utilities/initReq.server.js';
19
20
  cookies,
20
21
  headers
21
22
  });
23
+ const isEmbedded = getRequestEmbed({
24
+ config,
25
+ cookies
26
+ });
22
27
  const languageOptions = Object.entries(config.i18n.supportedLanguages || {}).reduce((acc, [language, languageConfig])=>{
23
28
  if (Object.keys(config.i18n.supportedLanguages).includes(language)) {
24
29
  acc.push({
@@ -76,6 +81,7 @@ import { initReq } from '../../utilities/initReq.server.js';
76
81
  clientConfig,
77
82
  dateFNSKey: req.i18n.dateFNSKey,
78
83
  fallbackLang: config.i18n.fallbackLanguage,
84
+ isEmbedded,
79
85
  isNavOpen: navPrefs?.open ?? true,
80
86
  languageCode,
81
87
  languageOptions,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/layouts/Root/getLayoutData.ts"],"sourcesContent":["import type { AcceptedLanguages } from '@payloadcms/translations'\nimport type { ImportMap, LanguageOptions, SanitizedConfig, ServerProps } from 'payload'\n\nimport { getNavPrefs } from '@payloadcms/ui/elements/Nav/getNavPrefs'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport { Outlet } from '@tanstack/react-router'\nimport { applyLocaleFiltering } from 'payload/shared'\nimport { createElement } from 'react'\n\nimport type { RootLayoutData } from './index.js'\n\nimport { getRequestTheme } from '../../utilities/getRequestTheme.js'\nimport { initReq } from '../../utilities/initReq.server.js'\n\nexport type GetLayoutDataArgs = {\n configPromise: Promise<SanitizedConfig> | SanitizedConfig\n importMap: ImportMap\n}\n\n/**\n * Fetches all data needed by the root admin layout.\n * Call this in your TanStack Start root route loader.\n */\nexport async function getLayoutData({\n configPromise,\n importMap,\n}: GetLayoutDataArgs): Promise<RootLayoutData> {\n const {\n cookies,\n headers,\n languageCode,\n permissions,\n req,\n req: {\n payload: { config },\n },\n } = await initReq({ configPromise, importMap })\n\n const theme = getRequestTheme({ config, cookies, headers })\n\n const languageOptions: LanguageOptions = Object.entries(\n config.i18n.supportedLanguages || {},\n ).reduce((acc, [language, languageConfig]) => {\n if (Object.keys(config.i18n.supportedLanguages).includes(language)) {\n acc.push({\n label: languageConfig.translations.general.thisLanguage,\n value: language as AcceptedLanguages,\n })\n }\n return acc\n }, [] as LanguageOptions)\n\n const navPrefs = await getNavPrefs(req)\n\n const clientConfig = getClientConfig({\n config,\n i18n: req.i18n,\n importMap,\n user: req.user ?? true,\n })\n\n await applyLocaleFiltering({ clientConfig, config, req })\n\n // Build the custom admin provider tree (`config.admin.components.providers`)\n // nested around the router `<Outlet />`, mirroring the Next adapter's\n // `NestProviders`. Returned as an unrendered element; the caller's server\n // function renders it to an RSC payload (so server-component providers run\n // server-side and client providers wrap the live Outlet). `undefined` when\n // no custom providers are configured — the caller falls back to `<Outlet />`.\n const providerPaths = config.admin?.components?.providers\n let providers: React.ReactNode = undefined\n if (Array.isArray(providerPaths) && providerPaths.length > 0) {\n const serverProps: ServerProps = {\n i18n: req.i18n,\n params: {},\n payload: req.payload,\n permissions,\n searchParams: {},\n server: req.server!,\n user: req.user ?? undefined,\n }\n // Mirror the Next adapter's `NestProviders`: render each configured provider\n // via `RenderServerComponent` so the entry's own `clientProps`/`serverProps`\n // (e.g. plugin-multi-tenant's `userHasAccessToAllTenants`) are merged in, and\n // server components receive `serverProps` while client components get only\n // `clientProps`. Nested around the router `<Outlet />` instead of `children`.\n providers = providerPaths.reduceRight<React.ReactNode>(\n (children, provider) =>\n RenderServerComponent({\n clientProps: { children },\n Component: provider,\n importMap,\n serverProps,\n }),\n createElement(Outlet),\n )\n }\n\n return {\n clientConfig,\n dateFNSKey: req.i18n.dateFNSKey,\n fallbackLang: config.i18n.fallbackLanguage,\n isNavOpen: navPrefs?.open ?? true,\n languageCode,\n languageOptions,\n locale: req.locale ?? undefined,\n permissions,\n providers,\n theme,\n translations: req.i18n.translations,\n user: req.user,\n }\n}\n"],"names":["getNavPrefs","RenderServerComponent","getClientConfig","Outlet","applyLocaleFiltering","createElement","getRequestTheme","initReq","getLayoutData","configPromise","importMap","cookies","headers","languageCode","permissions","req","payload","config","theme","languageOptions","Object","entries","i18n","supportedLanguages","reduce","acc","language","languageConfig","keys","includes","push","label","translations","general","thisLanguage","value","navPrefs","clientConfig","user","providerPaths","admin","components","providers","undefined","Array","isArray","length","serverProps","params","searchParams","server","reduceRight","children","provider","clientProps","Component","dateFNSKey","fallbackLang","fallbackLanguage","isNavOpen","open","locale"],"mappings":"AAGA,SAASA,WAAW,QAAQ,0CAAyC;AACrE,SAASC,qBAAqB,QAAQ,gDAA+C;AACrF,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,MAAM,QAAQ,yBAAwB;AAC/C,SAASC,oBAAoB,QAAQ,iBAAgB;AACrD,SAASC,aAAa,QAAQ,QAAO;AAIrC,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,OAAO,QAAQ,oCAAmC;AAO3D;;;CAGC,GACD,OAAO,eAAeC,cAAc,EAClCC,aAAa,EACbC,SAAS,EACS;IAClB,MAAM,EACJC,OAAO,EACPC,OAAO,EACPC,YAAY,EACZC,WAAW,EACXC,GAAG,EACHA,KAAK,EACHC,SAAS,EAAEC,MAAM,EAAE,EACpB,EACF,GAAG,MAAMV,QAAQ;QAAEE;QAAeC;IAAU;IAE7C,MAAMQ,QAAQZ,gBAAgB;QAAEW;QAAQN;QAASC;IAAQ;IAEzD,MAAMO,kBAAmCC,OAAOC,OAAO,CACrDJ,OAAOK,IAAI,CAACC,kBAAkB,IAAI,CAAC,GACnCC,MAAM,CAAC,CAACC,KAAK,CAACC,UAAUC,eAAe;QACvC,IAAIP,OAAOQ,IAAI,CAACX,OAAOK,IAAI,CAACC,kBAAkB,EAAEM,QAAQ,CAACH,WAAW;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IO,IAAI,CAACU,YAAY;QACnCM,MAAMvB,IAAIuB,IAAI;IAChB;AACF"}
1
+ {"version":3,"sources":["../../../src/layouts/Root/getLayoutData.ts"],"sourcesContent":["import type { AcceptedLanguages, I18nClient } from '@payloadcms/translations'\nimport type { Theme } from '@payloadcms/ui'\nimport type {\n ClientConfig,\n ImportMap,\n LanguageOptions,\n SanitizedConfig,\n SanitizedPermissions,\n ServerProps,\n User,\n} from 'payload'\n\nimport { getNavPrefs } from '@payloadcms/ui/elements/Nav/getNavPrefs'\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig'\nimport { getRequestEmbed } from '@payloadcms/ui/utilities/getRequestEmbed'\nimport { getRequestTheme } from '@payloadcms/ui/utilities/getRequestTheme'\nimport { Outlet } from '@tanstack/react-router'\nimport { applyLocaleFiltering } from 'payload/shared'\nimport { createElement } from 'react'\n\nimport { initReq } from '../../utilities/initReq.server.js'\n\nexport type RootLayoutData = {\n clientConfig: ClientConfig\n dateFNSKey: I18nClient['dateFNSKey']\n fallbackLang: string\n isEmbedded: boolean\n isNavOpen: boolean\n languageCode: string\n languageOptions: LanguageOptions\n locale?: string\n permissions: SanitizedPermissions\n /**\n * Custom admin provider tree (`config.admin.components.providers`) nested\n * around the router `<Outlet />`. Built unrendered by `getLayoutData`; the\n * layout server function renders it to an RSC payload before it reaches the\n * client. `undefined` when no custom providers are configured.\n */\n providers?: React.ReactNode\n theme: Theme\n translations: I18nClient['translations']\n user: null | User\n}\n\nexport type GetLayoutDataArgs = {\n configPromise: Promise<SanitizedConfig> | SanitizedConfig\n importMap: ImportMap\n}\n\n/**\n * Fetches all data needed by the root admin layout.\n * Call this in your TanStack Start root route loader.\n */\nexport async function getLayoutData({\n configPromise,\n importMap,\n}: GetLayoutDataArgs): Promise<RootLayoutData> {\n const {\n cookies,\n headers,\n languageCode,\n permissions,\n req,\n req: {\n payload: { config },\n },\n } = await initReq({ configPromise, importMap })\n\n const theme = getRequestTheme({ config, cookies, headers })\n const isEmbedded = getRequestEmbed({ config, cookies })\n\n const languageOptions: LanguageOptions = Object.entries(\n config.i18n.supportedLanguages || {},\n ).reduce((acc, [language, languageConfig]) => {\n if (Object.keys(config.i18n.supportedLanguages).includes(language)) {\n acc.push({\n label: languageConfig.translations.general.thisLanguage,\n value: language as AcceptedLanguages,\n })\n }\n return acc\n }, [] as LanguageOptions)\n\n const navPrefs = await getNavPrefs(req)\n\n const clientConfig = getClientConfig({\n config,\n i18n: req.i18n,\n importMap,\n user: req.user ?? true,\n })\n\n await applyLocaleFiltering({ clientConfig, config, req })\n\n // Build the custom admin provider tree (`config.admin.components.providers`)\n // nested around the router `<Outlet />`, mirroring the Next adapter's\n // `NestProviders`. Returned as an unrendered element; the caller's server\n // function renders it to an RSC payload (so server-component providers run\n // server-side and client providers wrap the live Outlet). `undefined` when\n // no custom providers are configured — the caller falls back to `<Outlet />`.\n const providerPaths = config.admin?.components?.providers\n let providers: React.ReactNode = undefined\n if (Array.isArray(providerPaths) && providerPaths.length > 0) {\n const serverProps: ServerProps = {\n i18n: req.i18n,\n params: {},\n payload: req.payload,\n permissions,\n searchParams: {},\n server: req.server!,\n user: req.user ?? undefined,\n }\n // Mirror the Next adapter's `NestProviders`: render each configured provider\n // via `RenderServerComponent` so the entry's own `clientProps`/`serverProps`\n // (e.g. plugin-multi-tenant's `userHasAccessToAllTenants`) are merged in, and\n // server components receive `serverProps` while client components get only\n // `clientProps`. Nested around the router `<Outlet />` instead of `children`.\n providers = providerPaths.reduceRight<React.ReactNode>(\n (children, provider) =>\n RenderServerComponent({\n clientProps: { children },\n Component: provider,\n importMap,\n serverProps,\n }),\n createElement(Outlet),\n )\n }\n\n return {\n clientConfig,\n dateFNSKey: req.i18n.dateFNSKey,\n fallbackLang: config.i18n.fallbackLanguage,\n isEmbedded,\n isNavOpen: navPrefs?.open ?? true,\n languageCode,\n languageOptions,\n locale: req.locale ?? undefined,\n permissions,\n providers,\n theme,\n translations: req.i18n.translations,\n user: req.user,\n }\n}\n"],"names":["getNavPrefs","RenderServerComponent","getClientConfig","getRequestEmbed","getRequestTheme","Outlet","applyLocaleFiltering","createElement","initReq","getLayoutData","configPromise","importMap","cookies","headers","languageCode","permissions","req","payload","config","theme","isEmbedded","languageOptions","Object","entries","i18n","supportedLanguages","reduce","acc","language","languageConfig","keys","includes","push","label","translations","general","thisLanguage","value","navPrefs","clientConfig","user","providerPaths","admin","components","providers","undefined","Array","isArray","length","serverProps","params","searchParams","server","reduceRight","children","provider","clientProps","Component","dateFNSKey","fallbackLang","fallbackLanguage","isNavOpen","open","locale"],"mappings":"AAYA,SAASA,WAAW,QAAQ,0CAAyC;AACrE,SAASC,qBAAqB,QAAQ,gDAA+C;AACrF,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,MAAM,QAAQ,yBAAwB;AAC/C,SAASC,oBAAoB,QAAQ,iBAAgB;AACrD,SAASC,aAAa,QAAQ,QAAO;AAErC,SAASC,OAAO,QAAQ,oCAAmC;AA6B3D;;;CAGC,GACD,OAAO,eAAeC,cAAc,EAClCC,aAAa,EACbC,SAAS,EACS;IAClB,MAAM,EACJC,OAAO,EACPC,OAAO,EACPC,YAAY,EACZC,WAAW,EACXC,GAAG,EACHA,KAAK,EACHC,SAAS,EAAEC,MAAM,EAAE,EACpB,EACF,GAAG,MAAMV,QAAQ;QAAEE;QAAeC;IAAU;IAE7C,MAAMQ,QAAQf,gBAAgB;QAAEc;QAAQN;QAASC;IAAQ;IACzD,MAAMO,aAAajB,gBAAgB;QAAEe;QAAQN;IAAQ;IAErD,MAAMS,kBAAmCC,OAAOC,OAAO,CACrDL,OAAOM,IAAI,CAACC,kBAAkB,IAAI,CAAC,GACnCC,MAAM,CAAC,CAACC,KAAK,CAACC,UAAUC,eAAe;QACvC,IAAIP,OAAOQ,IAAI,CAACZ,OA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C,IAAI+C,MAAM,IAAIlB;QACtB9B;QACA6B;QACAzB;QACAe,cAAclB,IAAIQ,IAAI,CAACU,YAAY;QACnCM,MAAMxB,IAAIwB,IAAI;IAChB;AACF"}
@@ -1,36 +1,17 @@
1
1
  import React from 'react';
2
- /**
3
- * Builds the blocking inline script that sets `data-theme`, `lang`, and `dir`
4
- * on `<html>` synchronously, before first paint, from Payload's theme and
5
- * language cookies. This is the no-flash equivalent of what `RootProvider`'s
6
- * `ThemeProvider` does in a post-hydration effect, hoisted into the SSR'd
7
- * document head so the admin panel never flashes light mode (or LTR for RTL
8
- * locales) on the first render. Mirrors `detectTheme` in
9
- * `@payloadcms/ui`'s `ThemeProvider`.
10
- */
11
- export declare function buildThemeInitScript(cookiePrefix?: string): string;
12
- /**
13
- * The no-flash theme bootstrap script for the default (`payload`) cookie
14
- * prefix. Inline this in a `<script dangerouslySetInnerHTML>` inside the
15
- * document `<head>` to set `data-theme`/`lang`/`dir` before first paint.
16
- */
17
- export declare const THEME_INIT_SCRIPT: string;
18
2
  export type PayloadAdminShellProps = {
19
3
  readonly children: React.ReactNode;
20
- /**
21
- * The `config.cookiePrefix` used to read the theme/language cookies in the
22
- * no-flash bootstrap script. Defaults to `'payload'`.
23
- */
24
- readonly cookiePrefix?: string;
25
4
  };
26
5
  /**
27
6
  * The `<html>` document shell for Payload admin routes — the TanStack Start
28
- * equivalent of `@payloadcms/next`'s root layout `<html>`. Owns the no-flash
29
- * theme script, the `@layer` ordering style, `@payloadcms/ui` styles,
30
- * `<HeadContent />`, and `<Scripts />`. Render `RootProvider` (and the rest of
31
- * the admin tree) as `children`.
7
+ * equivalent of `@payloadcms/next`'s root layout `<html>`. Sets
8
+ * `data-theme`/`lang`/`dir` on `<html>` from the server-computed layout data
9
+ * (`getLayoutData`, exposed on the `/_payload` route loader), so the admin
10
+ * panel renders themed with the correct text direction on the first paint with no
11
+ * client bootstrap script — the same server-side path Next's `RootLayout`
12
+ * uses, sharing `getRequestTheme`/`getLanguageDir` from `@payloadcms/ui`.
32
13
  */
33
- export declare function PayloadAdminShell({ children, cookiePrefix }: PayloadAdminShellProps): React.JSX.Element;
14
+ export declare function PayloadAdminShell({ children }: PayloadAdminShellProps): React.JSX.Element;
34
15
  export type WithPayloadRootOptions = {
35
16
  /**
36
17
  * Path prefix that mounts the Payload admin panel (`config.routes.admin`).
@@ -38,11 +19,6 @@ export type WithPayloadRootOptions = {
38
19
  * renders your own shell. Defaults to `'/admin'`.
39
20
  */
40
21
  adminRoute?: string;
41
- /**
42
- * The `config.cookiePrefix` used by the no-flash theme bootstrap script.
43
- * Defaults to `'payload'`.
44
- */
45
- cookiePrefix?: string;
46
22
  };
47
23
  /**
48
24
  * Wraps your application's root document shell so Payload owns its own
@@ -1 +1 @@
1
- {"version":3,"file":"withPayloadRoot.d.ts","sourceRoot":"","sources":["../../../src/layouts/Root/withPayloadRoot.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,GAAE,MAAkB,GAAG,MAAM,CAG7E;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAA+B,CAAA;AAE/D,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IAClC;;;OAGG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAC/B,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,EAAE,sBAAsB,qBAmBnF;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CAAC,EAC7D,OAAO,GAAE,sBAA2B,kBAIW;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,uBAc7E"}
1
+ {"version":3,"file":"withPayloadRoot.d.ts","sourceRoot":"","sources":["../../../src/layouts/Root/withPayloadRoot.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,OAAO,CAAA;AAQzB,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CACnC,CAAA;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAAE,EAAE,sBAAsB,qBAmCrE;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CAAC,EAC7D,OAAO,GAAE,sBAA2B,kBAIW;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,uBAc7E"}
@@ -1,46 +1,46 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { rtlLanguages } from '@payloadcms/translations';
3
+ import { getLanguageDir } from '@payloadcms/ui/utilities/getLanguageDir';
4
4
  import { HeadContent, Scripts, useRouterState } from '@tanstack/react-router';
5
5
  import React from 'react';
6
- /**
7
- * Builds the blocking inline script that sets `data-theme`, `lang`, and `dir`
8
- * on `<html>` synchronously, before first paint, from Payload's theme and
9
- * language cookies. This is the no-flash equivalent of what `RootProvider`'s
10
- * `ThemeProvider` does in a post-hydration effect, hoisted into the SSR'd
11
- * document head so the admin panel never flashes light mode (or LTR for RTL
12
- * locales) on the first render. Mirrors `detectTheme` in
13
- * `@payloadcms/ui`'s `ThemeProvider`.
14
- */ export function buildThemeInitScript(cookiePrefix = 'payload') {
15
- const rtl = JSON.stringify(rtlLanguages);
16
- return `(function(){try{var d=document.documentElement;var c=document.cookie.split('; ');function r(n){var row=c.find(function(x){return x.indexOf(n+'=')===0});return row?row.split('=')[1]:null}var t=r('${cookiePrefix}-theme');if(t!=='light'&&t!=='dark'){t=window.matchMedia&&window.matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light'}d.setAttribute('data-theme',t);var l=r('${cookiePrefix}-lng');if(l){d.setAttribute('lang',l);d.setAttribute('dir',${rtl}.indexOf(l)!==-1?'rtl':'ltr')}}catch(e){}})()`;
17
- }
18
- /**
19
- * The no-flash theme bootstrap script for the default (`payload`) cookie
20
- * prefix. Inline this in a `<script dangerouslySetInnerHTML>` inside the
21
- * document `<head>` to set `data-theme`/`lang`/`dir` before first paint.
22
- */ export const THEME_INIT_SCRIPT = buildThemeInitScript();
23
6
  /**
24
7
  * The `<html>` document shell for Payload admin routes — the TanStack Start
25
- * equivalent of `@payloadcms/next`'s root layout `<html>`. Owns the no-flash
26
- * theme script, the `@layer` ordering style, `@payloadcms/ui` styles,
27
- * `<HeadContent />`, and `<Scripts />`. Render `RootProvider` (and the rest of
28
- * the admin tree) as `children`.
29
- */ export function PayloadAdminShell({ children, cookiePrefix }) {
30
- const themeInitScript = cookiePrefix ? buildThemeInitScript(cookiePrefix) : THEME_INIT_SCRIPT;
31
- return(// `lang`/`dir` are set on `<html>` by `themeInitScript` before first paint
32
- // from the `*-lng` cookie, so a static `lang` here would be incorrect.
33
- // eslint-disable-next-line jsx-a11y/html-has-lang -- set dynamically by the inline bootstrap script
8
+ * equivalent of `@payloadcms/next`'s root layout `<html>`. Sets
9
+ * `data-theme`/`lang`/`dir` on `<html>` from the server-computed layout data
10
+ * (`getLayoutData`, exposed on the `/_payload` route loader), so the admin
11
+ * panel renders themed with the correct text direction on the first paint with no
12
+ * client bootstrap script — the same server-side path Next's `RootLayout`
13
+ * uses, sharing `getRequestTheme`/`getLanguageDir` from `@payloadcms/ui`.
14
+ */ export function PayloadAdminShell({ children }) {
15
+ const htmlProps = useRouterState({
16
+ select: (state)=>{
17
+ for (const match of state.matches){
18
+ const data = match.loaderData;
19
+ if (data?.theme && data?.languageCode) {
20
+ return {
21
+ 'data-theme': data.theme,
22
+ dir: getLanguageDir({
23
+ languageCode: data.languageCode
24
+ }),
25
+ lang: data.languageCode
26
+ };
27
+ }
28
+ }
29
+ // No layout data yet (fresh session before the loader resolves): default
30
+ // to `ltr` so the `[dir='ltr']`-scoped admin layout rules (e.g. the
31
+ // document sidebar divider) still match, matching Next's `ltr` default.
32
+ return {
33
+ dir: 'ltr'
34
+ };
35
+ }
36
+ });
37
+ return(// eslint-disable-next-line jsx-a11y/html-has-lang -- `lang` is set from server-computed layout data when available
34
38
  /*#__PURE__*/ _jsxs("html", {
39
+ ...htmlProps,
35
40
  suppressHydrationWarning: true,
36
41
  children: [
37
42
  /*#__PURE__*/ _jsxs("head", {
38
43
  children: [
39
- /*#__PURE__*/ _jsx("script", {
40
- dangerouslySetInnerHTML: {
41
- __html: themeInitScript
42
- }
43
- }),
44
44
  /*#__PURE__*/ _jsx("style", {
45
45
  children: `@layer payload-default, payload;`
46
46
  }),
@@ -69,7 +69,7 @@ import React from 'react';
69
69
  * })
70
70
  * ```
71
71
  */ export function withPayloadRoot(RootShell, options = {}) {
72
- const { adminRoute = '/admin', cookiePrefix } = options;
72
+ const { adminRoute = '/admin' } = options;
73
73
  return function PayloadRootShell({ children }) {
74
74
  const isAdminRoute = useRouterState({
75
75
  select: (s)=>{
@@ -79,7 +79,6 @@ import React from 'react';
79
79
  });
80
80
  if (isAdminRoute) {
81
81
  return /*#__PURE__*/ _jsx(PayloadAdminShell, {
82
- cookiePrefix: cookiePrefix,
83
82
  children: children
84
83
  });
85
84
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/layouts/Root/withPayloadRoot.tsx"],"sourcesContent":["'use client'\nimport { rtlLanguages } from '@payloadcms/translations'\nimport { HeadContent, Scripts, useRouterState } from '@tanstack/react-router'\nimport React from 'react'\n\n/**\n * Builds the blocking inline script that sets `data-theme`, `lang`, and `dir`\n * on `<html>` synchronously, before first paint, from Payload's theme and\n * language cookies. This is the no-flash equivalent of what `RootProvider`'s\n * `ThemeProvider` does in a post-hydration effect, hoisted into the SSR'd\n * document head so the admin panel never flashes light mode (or LTR for RTL\n * locales) on the first render. Mirrors `detectTheme` in\n * `@payloadcms/ui`'s `ThemeProvider`.\n */\nexport function buildThemeInitScript(cookiePrefix: string = 'payload'): string {\n const rtl = JSON.stringify(rtlLanguages)\n return `(function(){try{var d=document.documentElement;var c=document.cookie.split('; ');function r(n){var row=c.find(function(x){return x.indexOf(n+'=')===0});return row?row.split('=')[1]:null}var t=r('${cookiePrefix}-theme');if(t!=='light'&&t!=='dark'){t=window.matchMedia&&window.matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light'}d.setAttribute('data-theme',t);var l=r('${cookiePrefix}-lng');if(l){d.setAttribute('lang',l);d.setAttribute('dir',${rtl}.indexOf(l)!==-1?'rtl':'ltr')}}catch(e){}})()`\n}\n\n/**\n * The no-flash theme bootstrap script for the default (`payload`) cookie\n * prefix. Inline this in a `<script dangerouslySetInnerHTML>` inside the\n * document `<head>` to set `data-theme`/`lang`/`dir` before first paint.\n */\nexport const THEME_INIT_SCRIPT: string = buildThemeInitScript()\n\nexport type PayloadAdminShellProps = {\n readonly children: React.ReactNode\n /**\n * The `config.cookiePrefix` used to read the theme/language cookies in the\n * no-flash bootstrap script. Defaults to `'payload'`.\n */\n readonly cookiePrefix?: string\n}\n\n/**\n * The `<html>` document shell for Payload admin routes — the TanStack Start\n * equivalent of `@payloadcms/next`'s root layout `<html>`. Owns the no-flash\n * theme script, the `@layer` ordering style, `@payloadcms/ui` styles,\n * `<HeadContent />`, and `<Scripts />`. Render `RootProvider` (and the rest of\n * the admin tree) as `children`.\n */\nexport function PayloadAdminShell({ children, cookiePrefix }: PayloadAdminShellProps) {\n const themeInitScript = cookiePrefix ? buildThemeInitScript(cookiePrefix) : THEME_INIT_SCRIPT\n\n return (\n // `lang`/`dir` are set on `<html>` by `themeInitScript` before first paint\n // from the `*-lng` cookie, so a static `lang` here would be incorrect.\n // eslint-disable-next-line jsx-a11y/html-has-lang -- set dynamically by the inline bootstrap script\n <html suppressHydrationWarning>\n <head>\n <script dangerouslySetInnerHTML={{ __html: themeInitScript }} />\n <style>{`@layer payload-default, payload;`}</style>\n <HeadContent />\n </head>\n <body>\n {children}\n <Scripts />\n </body>\n </html>\n )\n}\n\nexport type WithPayloadRootOptions = {\n /**\n * Path prefix that mounts the Payload admin panel (`config.routes.admin`).\n * Routes under it render the Payload admin document shell; everything else\n * renders your own shell. Defaults to `'/admin'`.\n */\n adminRoute?: string\n /**\n * The `config.cookiePrefix` used by the no-flash theme bootstrap script.\n * Defaults to `'payload'`.\n */\n cookiePrefix?: string\n}\n\n/**\n * Wraps your application's root document shell so Payload owns its own\n * `<html>` chrome on admin routes while your shell renders everywhere else.\n *\n * Attach the result to the root route's `shellComponent`; it is the single\n * integration touch point — no root loader and no manual data threading:\n *\n * ```tsx\n * export const Route = createRootRoute({\n * shellComponent: withPayloadRoot(MarketingRoot),\n * })\n * ```\n */\nexport function withPayloadRoot(\n RootShell: React.ComponentType<{ children: React.ReactNode }>,\n options: WithPayloadRootOptions = {},\n) {\n const { adminRoute = '/admin', cookiePrefix } = options\n\n return function PayloadRootShell({ children }: { children: React.ReactNode }) {\n const isAdminRoute = useRouterState({\n select: (s) => {\n const { pathname } = s.location\n return pathname === adminRoute || pathname.startsWith(`${adminRoute}/`)\n },\n })\n\n if (isAdminRoute) {\n return <PayloadAdminShell cookiePrefix={cookiePrefix}>{children}</PayloadAdminShell>\n }\n\n return <RootShell>{children}</RootShell>\n }\n}\n"],"names":["rtlLanguages","HeadContent","Scripts","useRouterState","React","buildThemeInitScript","cookiePrefix","rtl","JSON","stringify","THEME_INIT_SCRIPT","PayloadAdminShell","children","themeInitScript","html","suppressHydrationWarning","head","script","dangerouslySetInnerHTML","__html","style","body","withPayloadRoot","RootShell","options","adminRoute","PayloadRootShell","isAdminRoute","select","s","pathname","location","startsWith"],"mappings":"AAAA;;AACA,SAASA,YAAY,QAAQ,2BAA0B;AACvD,SAASC,WAAW,EAAEC,OAAO,EAAEC,cAAc,QAAQ,yBAAwB;AAC7E,OAAOC,WAAW,QAAO;AAEzB;;;;;;;;CAQC,GACD,OAAO,SAASC,qBAAqBC,eAAuB,SAAS;IACnE,MAAMC,MAAMC,KAAKC,SAAS,CAACT;IAC3B,OAAO,CAAC,mMAAmM,EAAEM,aAAa,2KAA2K,EAAEA,aAAa,2DAA2D,EAAEC,IAAI,6CAA6C,CAAC;AACrgB;AAEA;;;;CAIC,GACD,OAAO,MAAMG,oBAA4BL,uBAAsB;AAW/D;;;;;;CAMC,GACD,OAAO,SAASM,kBAAkB,EAAEC,QAAQ,EAAEN,YAAY,EAA0B;IAClF,MAAMO,kBAAkBP,eAAeD,qBAAqBC,gBAAgBI;IAE5E,OACE,2EAA2E;IAC3E,uEAAuE;IACvE,oGAAoG;kBACpG,MAACI;QAAKC,wBAAwB;;0BAC5B,MAACC;;kCACC,KAACC;wBAAOC,yBAAyB;4BAAEC,QAAQN;wBAAgB;;kCAC3D,KAACO;kCAAO,CAAC,gCAAgC,CAAC;;kCAC1C,KAACnB;;;0BAEH,MAACoB;;oBACET;kCACD,KAACV;;;;;AAIT;AAgBA;;;;;;;;;;;;CAYC,GACD,OAAO,SAASoB,gBACdC,SAA6D,EAC7DC,UAAkC,CAAC,CAAC;IAEpC,MAAM,EAAEC,aAAa,QAAQ,EAAEnB,YAAY,EAAE,GAAGkB;IAEhD,OAAO,SAASE,iBAAiB,EAAEd,QAAQ,EAAiC;QAC1E,MAAMe,eAAexB,eAAe;YAClCyB,QAAQ,CAACC;gBACP,MAAM,EAAEC,QAAQ,EAAE,GAAGD,EAAEE,QAAQ;gBAC/B,OAAOD,aAAaL,cAAcK,SAASE,UAAU,CAAC,GAAGP,WAAW,CAAC,CAAC;YACxE;QACF;QAEA,IAAIE,cAAc;YAChB,qBAAO,KAAChB;gBAAkBL,cAAcA;0BAAeM;;QACzD;QAEA,qBAAO,KAACW;sBAAWX;;IACrB;AACF"}
1
+ {"version":3,"sources":["../../../src/layouts/Root/withPayloadRoot.tsx"],"sourcesContent":["'use client'\nimport type { Theme } from '@payloadcms/ui'\n\nimport { getLanguageDir } from '@payloadcms/ui/utilities/getLanguageDir'\nimport { HeadContent, Scripts, useRouterState } from '@tanstack/react-router'\nimport React from 'react'\n\ntype AdminHTMLProps = {\n 'data-theme'?: Theme\n dir: 'ltr' | 'rtl'\n lang?: string\n}\n\nexport type PayloadAdminShellProps = {\n readonly children: React.ReactNode\n}\n\n/**\n * The `<html>` document shell for Payload admin routes — the TanStack Start\n * equivalent of `@payloadcms/next`'s root layout `<html>`. Sets\n * `data-theme`/`lang`/`dir` on `<html>` from the server-computed layout data\n * (`getLayoutData`, exposed on the `/_payload` route loader), so the admin\n * panel renders themed with the correct text direction on the first paint with no\n * client bootstrap script — the same server-side path Next's `RootLayout`\n * uses, sharing `getRequestTheme`/`getLanguageDir` from `@payloadcms/ui`.\n */\nexport function PayloadAdminShell({ children }: PayloadAdminShellProps) {\n const htmlProps = useRouterState({\n select: (state): AdminHTMLProps => {\n for (const match of state.matches) {\n const data = match.loaderData as { languageCode?: string; theme?: Theme } | undefined\n\n if (data?.theme && data?.languageCode) {\n return {\n 'data-theme': data.theme,\n dir: getLanguageDir({ languageCode: data.languageCode }),\n lang: data.languageCode,\n }\n }\n }\n\n // No layout data yet (fresh session before the loader resolves): default\n // to `ltr` so the `[dir='ltr']`-scoped admin layout rules (e.g. the\n // document sidebar divider) still match, matching Next's `ltr` default.\n return { dir: 'ltr' }\n },\n })\n\n return (\n // eslint-disable-next-line jsx-a11y/html-has-lang -- `lang` is set from server-computed layout data when available\n <html {...htmlProps} suppressHydrationWarning>\n <head>\n <style>{`@layer payload-default, payload;`}</style>\n <HeadContent />\n </head>\n <body>\n {children}\n <Scripts />\n </body>\n </html>\n )\n}\n\nexport type WithPayloadRootOptions = {\n /**\n * Path prefix that mounts the Payload admin panel (`config.routes.admin`).\n * Routes under it render the Payload admin document shell; everything else\n * renders your own shell. Defaults to `'/admin'`.\n */\n adminRoute?: string\n}\n\n/**\n * Wraps your application's root document shell so Payload owns its own\n * `<html>` chrome on admin routes while your shell renders everywhere else.\n *\n * Attach the result to the root route's `shellComponent`; it is the single\n * integration touch point — no root loader and no manual data threading:\n *\n * ```tsx\n * export const Route = createRootRoute({\n * shellComponent: withPayloadRoot(MarketingRoot),\n * })\n * ```\n */\nexport function withPayloadRoot(\n RootShell: React.ComponentType<{ children: React.ReactNode }>,\n options: WithPayloadRootOptions = {},\n) {\n const { adminRoute = '/admin' } = options\n\n return function PayloadRootShell({ children }: { children: React.ReactNode }) {\n const isAdminRoute = useRouterState({\n select: (s) => {\n const { pathname } = s.location\n return pathname === adminRoute || pathname.startsWith(`${adminRoute}/`)\n },\n })\n\n if (isAdminRoute) {\n return <PayloadAdminShell>{children}</PayloadAdminShell>\n }\n\n return <RootShell>{children}</RootShell>\n }\n}\n"],"names":["getLanguageDir","HeadContent","Scripts","useRouterState","React","PayloadAdminShell","children","htmlProps","select","state","match","matches","data","loaderData","theme","languageCode","dir","lang","html","suppressHydrationWarning","head","style","body","withPayloadRoot","RootShell","options","adminRoute","PayloadRootShell","isAdminRoute","s","pathname","location","startsWith"],"mappings":"AAAA;;AAGA,SAASA,cAAc,QAAQ,0CAAyC;AACxE,SAASC,WAAW,EAAEC,OAAO,EAAEC,cAAc,QAAQ,yBAAwB;AAC7E,OAAOC,WAAW,QAAO;AAYzB;;;;;;;;CAQC,GACD,OAAO,SAASC,kBAAkB,EAAEC,QAAQ,EAA0B;IACpE,MAAMC,YAAYJ,eAAe;QAC/BK,QAAQ,CAACC;YACP,KAAK,MAAMC,SAASD,MAAME,OAAO,CAAE;gBACjC,MAAMC,OAAOF,MAAMG,UAAU;gBAE7B,IAAID,MAAME,SAASF,MAAMG,cAAc;oBACrC,OAAO;wBACL,cAAcH,KAAKE,KAAK;wBACxBE,KAAKhB,eAAe;4BAAEe,cAAcH,KAAKG,YAAY;wBAAC;wBACtDE,MAAML,KAAKG,YAAY;oBACzB;gBACF;YACF;YAEA,yEAAyE;YACzE,oEAAoE;YACpE,wEAAwE;YACxE,OAAO;gBAAEC,KAAK;YAAM;QACtB;IACF;IAEA,OACE,mHAAmH;kBACnH,MAACE;QAAM,GAAGX,SAAS;QAAEY,wBAAwB;;0BAC3C,MAACC;;kCACC,KAACC;kCAAO,CAAC,gCAAgC,CAAC;;kCAC1C,KAACpB;;;0BAEH,MAACqB;;oBACEhB;kCACD,KAACJ;;;;;AAIT;AAWA;;;;;;;;;;;;CAYC,GACD,OAAO,SAASqB,gBACdC,SAA6D,EAC7DC,UAAkC,CAAC,CAAC;IAEpC,MAAM,EAAEC,aAAa,QAAQ,EAAE,GAAGD;IAElC,OAAO,SAASE,iBAAiB,EAAErB,QAAQ,EAAiC;QAC1E,MAAMsB,eAAezB,eAAe;YAClCK,QAAQ,CAACqB;gBACP,MAAM,EAAEC,QAAQ,EAAE,GAAGD,EAAEE,QAAQ;gBAC/B,OAAOD,aAAaJ,cAAcI,SAASE,UAAU,CAAC,GAAGN,WAAW,CAAC,CAAC;YACxE;QACF;QAEA,IAAIE,cAAc;YAChB,qBAAO,KAACvB;0BAAmBC;;QAC7B;QAEA,qBAAO,KAACkB;sBAAWlB;;IACrB;AACF"}
@@ -61,12 +61,20 @@ export declare function payloadAdminSplatRoute({ load }: {
61
61
  }) => {
62
62
  searchKey: string;
63
63
  };
64
- notFoundComponent: typeof AdminNotFound;
65
64
  validateSearch: (search: Record<string, unknown>) => Record<string, unknown>;
65
+ notFoundComponent: typeof AdminNotFound;
66
66
  };
67
67
  /**
68
68
  * Route options for the admin index route (`/_payload/admin/`). Same loader as the
69
- * splat route but throws a bare `notFound()` (no rscPayload) on miss.
69
+ * splat route but throws a bare `notFound()` (no rscPayload) on miss, so
70
+ * `AdminNotFound` falls through to the bare client view.
71
+ *
72
+ * `notFoundComponent` must be set here even though the payload is never forwarded:
73
+ * TanStack picks the boundary component from its presence (`routeNotFoundComponent ?
74
+ * CatchNotFound : SafeFragment`), so leaving it off gives this route a different
75
+ * component type than the splat route at the same position in the tree. Navigating
76
+ * between the two would then unmount the whole admin subtree and remount it —
77
+ * blanking the page for as long as the new view takes to render.
70
78
  */
71
79
  export declare function payloadAdminIndexRoute({ load }: {
72
80
  load: AdminLoad;
@@ -95,8 +103,9 @@ export declare function payloadAdminIndexRoute({ load }: {
95
103
  })[];
96
104
  };
97
105
  loader: {
98
- handler: ({ location }: {
106
+ handler: ({ location, params }: {
99
107
  location: any;
108
+ params: any;
100
109
  }) => Promise<any>;
101
110
  staleReloadMode: string;
102
111
  };
@@ -106,6 +115,7 @@ export declare function payloadAdminIndexRoute({ load }: {
106
115
  searchKey: string;
107
116
  };
108
117
  validateSearch: (search: Record<string, unknown>) => Record<string, unknown>;
118
+ notFoundComponent: typeof AdminNotFound;
109
119
  };
110
120
  export {};
111
121
  //# sourceMappingURL=adminRoutes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"adminRoutes.d.ts","sourceRoot":"","sources":["../../src/routes/adminRoutes.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAIhD;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE;IAC7B,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAA;KAAE,CAAA;CACpE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;AAclB,iBAAS,SAAS,gCAQjB;AAED,iBAAS,aAAa,CAAC,KAAK,EAAE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,MAAM,EAAE,OAAO,CAAC;;EAyCjD"}
@@ -2,7 +2,7 @@
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { NotFoundClient } from '@payloadcms/ui';
4
4
  import { notFound, redirect, useLoaderData } from '@tanstack/react-router';
5
- import { Fragment } from 'react';
5
+ import { Fragment, useDeferredValue } from 'react';
6
6
  import { getAdminMeta } from '../utilities/meta.js';
7
7
  const searchToRecord = (searchStr)=>Object.fromEntries(new URLSearchParams(searchStr));
8
8
  const runLoader = async (load, splat, searchStr)=>{
@@ -21,17 +21,21 @@ const runLoader = async (load, splat, searchStr)=>{
21
21
  return data;
22
22
  };
23
23
  function AdminPage() {
24
- // RSC Flight payload — render directly. Key by the loader-derived `routeKey`
25
- // (not `location.pathname`, which updates before `useLoaderData` during a
26
- // transition and would remount with the previous payload) so navigating to a
27
- // different admin page remounts the view, mirroring Next route-segment
28
- // semantics. Search params are excluded so search-only changes reconcile in place.
24
+ // Note: React key intentionally omitted here so the persistent template (nav, header) doesn't remount and flash on navigation.
25
+ // The per-route view key is attached server-side to the view subtree instead, via `renderRoot`'s `key` in `loadAdminPage`.
29
26
  const data = useLoaderData({
30
27
  strict: false
31
28
  });
29
+ // The loader resolves as soon as the RSC wire data lands, but rendering the payload then
30
+ // suspends while its client references are imported — code-split chunks in a production build.
31
+ // Router state lives in an external store, so the transition TanStack wraps the commit in
32
+ // de-opts to a synchronous render and that suspension hits the nearest fallback, which is
33
+ // `null` unless a `pendingComponent` is configured — blanking the page. Deferring the payload
34
+ // keeps the previous view painted until the new one is renderable, then swaps.
35
+ const rscPayload = useDeferredValue(data?.rscPayload);
32
36
  return /*#__PURE__*/ _jsx(Fragment, {
33
- children: data?.rscPayload
34
- }, data?.routeKey);
37
+ children: rscPayload
38
+ });
35
39
  }
36
40
  function AdminNotFound(props) {
37
41
  const rscPayload = props?.data?.rscPayload;
@@ -42,13 +46,7 @@ function AdminNotFound(props) {
42
46
  children: rscPayload
43
47
  }, props?.data?.routeKey);
44
48
  }
45
- /**
46
- * Route options for the admin splat route (`/_payload/admin/$`). Renders Payload's
47
- * server-built NotFound page (shipped via the `notFound()` error's
48
- * `data.rscPayload`) for unknown/access-denied routes, falling back to the bare
49
- * client view.
50
- */ export function payloadAdminSplatRoute({ load }) {
51
- return {
49
+ const adminRouteOptions = ({ forwardNotFoundPayload, load, resolveSplat })=>({
52
50
  component: AdminPage,
53
51
  head: ({ loaderData })=>getAdminMeta(loaderData?.metadata),
54
52
  // `staleReloadMode: 'blocking'` (a property of the loader *object*, not a
@@ -58,15 +56,15 @@ function AdminNotFound(props) {
58
56
  // (e.g. a just-created doc missing) until the reload lands.
59
57
  loader: {
60
58
  handler: async ({ location, params })=>{
61
- const data = await runLoader(load, params._splat ?? '', location.searchStr);
59
+ const data = await runLoader(load, resolveSplat(params), location.searchStr);
62
60
  if (data?._notFound) {
63
61
  // eslint-disable-next-line @typescript-eslint/only-throw-error -- TanStack Router requires throwing notFound objects
64
- throw notFound({
62
+ throw notFound(forwardNotFoundPayload ? {
65
63
  data: {
66
64
  routeKey: data.routeKey,
67
65
  rscPayload: data.rscPayload
68
66
  }
69
- });
67
+ } : undefined);
70
68
  }
71
69
  return data;
72
70
  },
@@ -76,32 +74,42 @@ function AdminNotFound(props) {
76
74
  loaderDeps: ({ search })=>({
77
75
  searchKey: JSON.stringify(search)
78
76
  }),
79
- notFoundComponent: AdminNotFound,
80
77
  validateSearch: (search)=>search
78
+ });
79
+ /**
80
+ * Route options for the admin splat route (`/_payload/admin/$`). Renders Payload's
81
+ * server-built NotFound page (shipped via the `notFound()` error's
82
+ * `data.rscPayload`) for unknown/access-denied routes, falling back to the bare
83
+ * client view.
84
+ */ export function payloadAdminSplatRoute({ load }) {
85
+ return {
86
+ ...adminRouteOptions({
87
+ forwardNotFoundPayload: true,
88
+ load,
89
+ resolveSplat: (params)=>params._splat ?? ''
90
+ }),
91
+ notFoundComponent: AdminNotFound
81
92
  };
82
93
  }
83
94
  /**
84
95
  * Route options for the admin index route (`/_payload/admin/`). Same loader as the
85
- * splat route but throws a bare `notFound()` (no rscPayload) on miss.
96
+ * splat route but throws a bare `notFound()` (no rscPayload) on miss, so
97
+ * `AdminNotFound` falls through to the bare client view.
98
+ *
99
+ * `notFoundComponent` must be set here even though the payload is never forwarded:
100
+ * TanStack picks the boundary component from its presence (`routeNotFoundComponent ?
101
+ * CatchNotFound : SafeFragment`), so leaving it off gives this route a different
102
+ * component type than the splat route at the same position in the tree. Navigating
103
+ * between the two would then unmount the whole admin subtree and remount it —
104
+ * blanking the page for as long as the new view takes to render.
86
105
  */ export function payloadAdminIndexRoute({ load }) {
87
106
  return {
88
- component: AdminPage,
89
- head: ({ loaderData })=>getAdminMeta(loaderData?.metadata),
90
- loader: {
91
- handler: async ({ location })=>{
92
- const data = await runLoader(load, '', location.searchStr);
93
- if (data?._notFound) {
94
- // eslint-disable-next-line @typescript-eslint/only-throw-error -- TanStack Router requires throwing notFound objects
95
- throw notFound();
96
- }
97
- return data;
98
- },
99
- staleReloadMode: 'blocking'
100
- },
101
- loaderDeps: ({ search })=>({
102
- searchKey: JSON.stringify(search)
103
- }),
104
- validateSearch: (search)=>search
107
+ ...adminRouteOptions({
108
+ forwardNotFoundPayload: false,
109
+ load,
110
+ resolveSplat: ()=>''
111
+ }),
112
+ notFoundComponent: AdminNotFound
105
113
  };
106
114
  }
107
115
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/routes/adminRoutes.tsx"],"sourcesContent":["'use client'\n\nimport { NotFoundClient } from '@payloadcms/ui'\nimport { notFound, redirect, useLoaderData } from '@tanstack/react-router'\nimport { Fragment, type ReactNode } from 'react'\n\nimport { getAdminMeta } from '../utilities/meta.js'\n\n/**\n * Loader supplied by the app — a TanStack Start `createServerFn` that delegates\n * to `loadAdminPage`. Typed loosely because the server-fn's call signature is\n * generated by the Start compiler.\n */\nexport type AdminLoad = (opts: {\n data: { _splat: string; search: Record<string, string | string[]> }\n}) => Promise<any>\n\nconst searchToRecord = (searchStr: string): Record<string, string | string[]> =>\n Object.fromEntries(new URLSearchParams(searchStr)) as Record<string, string | string[]>\n\nconst runLoader = async (load: AdminLoad, splat: string, searchStr: string) => {\n const data = await load({ data: { _splat: splat, search: searchToRecord(searchStr) } })\n if (data?._redirect) {\n // eslint-disable-next-line @typescript-eslint/only-throw-error -- TanStack Router requires throwing redirect objects\n throw redirect({ to: data._redirect })\n }\n return data\n}\n\nfunction AdminPage() {\n // RSC Flight payload — render directly. Key by the loader-derived `routeKey`\n // (not `location.pathname`, which updates before `useLoaderData` during a\n // transition and would remount with the previous payload) so navigating to a\n // different admin page remounts the view, mirroring Next route-segment\n // semantics. Search params are excluded so search-only changes reconcile in place.\n const data = useLoaderData({ strict: false })\n return <Fragment key={data?.routeKey}>{data?.rscPayload}</Fragment>\n}\n\nfunction AdminNotFound(props: { data?: { routeKey?: string; rscPayload?: ReactNode } }) {\n const rscPayload = props?.data?.rscPayload\n if (!rscPayload) {\n return <NotFoundClient />\n }\n return <Fragment key={props?.data?.routeKey}>{rscPayload}</Fragment>\n}\n\n/**\n * Route options for the admin splat route (`/_payload/admin/$`). Renders Payload's\n * server-built NotFound page (shipped via the `notFound()` error's\n * `data.rscPayload`) for unknown/access-denied routes, falling back to the bare\n * client view.\n */\nexport function payloadAdminSplatRoute({ load }: { load: AdminLoad }) {\n return {\n component: AdminPage,\n head: ({ loaderData }: { loaderData?: any }) => getAdminMeta(loaderData?.metadata),\n // `staleReloadMode: 'blocking'` (a property of the loader *object*, not a\n // sibling route option — router-core only reads it off a non-function loader)\n // makes stale-match revalidation await the fresh loader before committing,\n // instead of the default background SWR that flashes the pre-navigation list\n // (e.g. a just-created doc missing) until the reload lands.\n loader: {\n handler: async ({ location, params }: { location: any; params: any }) => {\n const data = await runLoader(load, params._splat ?? '', location.searchStr)\n if (data?._notFound) {\n // eslint-disable-next-line @typescript-eslint/only-throw-error -- TanStack Router requires throwing notFound objects\n throw notFound({ data: { routeKey: data.routeKey, rscPayload: data.rscPayload } })\n }\n return data\n },\n staleReloadMode: 'blocking',\n },\n // Surface query params in `loaderDeps` so `?locale=es` re-runs the loader.\n loaderDeps: ({ search }: { search: Record<string, unknown> }) => ({\n searchKey: JSON.stringify(search),\n }),\n notFoundComponent: AdminNotFound,\n validateSearch: (search: Record<string, unknown>) => search,\n }\n}\n\n/**\n * Route options for the admin index route (`/_payload/admin/`). Same loader as the\n * splat route but throws a bare `notFound()` (no rscPayload) on miss.\n */\nexport function payloadAdminIndexRoute({ load }: { load: AdminLoad }) {\n return {\n component: AdminPage,\n head: ({ loaderData }: { loaderData?: any }) => getAdminMeta(loaderData?.metadata),\n loader: {\n handler: async ({ location }: { location: any }) => {\n const data = await runLoader(load, '', location.searchStr)\n if (data?._notFound) {\n // eslint-disable-next-line @typescript-eslint/only-throw-error -- TanStack Router requires throwing notFound objects\n throw notFound()\n }\n return data\n },\n staleReloadMode: 'blocking',\n },\n loaderDeps: ({ search }: { search: Record<string, unknown> }) => ({\n searchKey: JSON.stringify(search),\n }),\n validateSearch: (search: Record<string, unknown>) => search,\n }\n}\n"],"names":["NotFoundClient","notFound","redirect","useLoaderData","Fragment","getAdminMeta","searchToRecord","searchStr","Object","fromEntries","URLSearchParams","runLoader","load","splat","data","_splat","search","_redirect","to","AdminPage","strict","rscPayload","routeKey","AdminNotFound","props","payloadAdminSplatRoute","component","head","loaderData","metadata","loader","handler","location","params","_notFound","staleReloadMode","loaderDeps","searchKey","JSON","stringify","notFoundComponent","validateSearch","payloadAdminIndexRoute"],"mappings":"AAAA;;AAEA,SAASA,cAAc,QAAQ,iBAAgB;AAC/C,SAASC,QAAQ,EAAEC,QAAQ,EAAEC,aAAa,QAAQ,yBAAwB;AAC1E,SAASC,QAAQ,QAAwB,QAAO;AAEhD,SAASC,YAAY,QAAQ,uBAAsB;AAWnD,MAAMC,iBAAiB,CAACC,YACtBC,OAAOC,WAAW,CAAC,IAAIC,gBAAgBH;AAEzC,MAAMI,YAAY,OAAOC,MAAiBC,OAAeN;IACvD,MAAM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AWC,KAAKC,SAAS,CAACvB;YAC5B,CAAA;QACAwB,mBAAmBjB;QACnBkB,gBAAgB,CAACzB,SAAoCA;IACvD;AACF;AAEA;;;CAGC,GACD,OAAO,SAAS0B,uBAAuB,EAAE9B,IAAI,EAAuB;IAClE,OAAO;QACLc,WAAWP;QACXQ,MAAM,CAAC,EAAEC,UAAU,EAAwB,GAAKvB,aAAauB,YAAYC;QACzEC,QAAQ;YACNC,SAAS,OAAO,EAAEC,QAAQ,EAAqB;gBAC7C,MAAMlB,OAAO,MAAMH,UAAUC,MAAM,IAAIoB,SAASzB,SAAS;gBACzD,IAAIO,MAAMoB,WAAW;oBACnB,qHAAqH;oBACrH,MAAMjC;gBACR;gBACA,OAAOa;YACT;YACAqB,iBAAiB;QACnB;QACAC,YAAY,CAAC,EAAEpB,MAAM,EAAuC,GAAM,CAAA;gBAChEqB,WAAWC,KAAKC,SAAS,CAACvB;YAC5B,CAAA;QACAyB,gBAAgB,CAACzB,SAAoCA;IACvD;AACF"}
1
+ {"version":3,"sources":["../../src/routes/adminRoutes.tsx"],"sourcesContent":["'use client'\n\nimport { NotFoundClient } from '@payloadcms/ui'\nimport { notFound, redirect, useLoaderData } from '@tanstack/react-router'\nimport { Fragment, type ReactNode, useDeferredValue } from 'react'\n\nimport { getAdminMeta } from '../utilities/meta.js'\n\n/**\n * Loader supplied by the app — a TanStack Start `createServerFn` that delegates\n * to `loadAdminPage`. Typed loosely because the server-fn's call signature is\n * generated by the Start compiler.\n */\nexport type AdminLoad = (opts: {\n data: { _splat: string; search: Record<string, string | string[]> }\n}) => Promise<any>\n\nconst searchToRecord = (searchStr: string): Record<string, string | string[]> =>\n Object.fromEntries(new URLSearchParams(searchStr)) as Record<string, string | string[]>\n\nconst runLoader = async (load: AdminLoad, splat: string, searchStr: string) => {\n const data = await load({ data: { _splat: splat, search: searchToRecord(searchStr) } })\n if (data?._redirect) {\n // eslint-disable-next-line @typescript-eslint/only-throw-error -- TanStack Router requires throwing redirect objects\n throw redirect({ to: data._redirect })\n }\n return data\n}\n\nfunction AdminPage() {\n // Note: React key intentionally omitted here so the persistent template (nav, header) doesn't remount and flash on navigation.\n // The per-route view key is attached server-side to the view subtree instead, via `renderRoot`'s `key` in `loadAdminPage`.\n const data = useLoaderData({ strict: false })\n\n // The loader resolves as soon as the RSC wire data lands, but rendering the payload then\n // suspends while its client references are imported — code-split chunks in a production build.\n // Router state lives in an external store, so the transition TanStack wraps the commit in\n // de-opts to a synchronous render and that suspension hits the nearest fallback, which is\n // `null` unless a `pendingComponent` is configured — blanking the page. Deferring the payload\n // keeps the previous view painted until the new one is renderable, then swaps.\n const rscPayload = useDeferredValue(data?.rscPayload)\n\n return <Fragment>{rscPayload}</Fragment>\n}\n\nfunction AdminNotFound(props: { data?: { routeKey?: string; rscPayload?: ReactNode } }) {\n const rscPayload = props?.data?.rscPayload\n if (!rscPayload) {\n return <NotFoundClient />\n }\n return <Fragment key={props?.data?.routeKey}>{rscPayload}</Fragment>\n}\n\nconst adminRouteOptions = ({\n forwardNotFoundPayload,\n load,\n resolveSplat,\n}: {\n /**\n * Ships the server-rendered NotFound tree through `notFound()`'s `data` so a\n * `notFoundComponent` can render it with the full admin chrome. Routes without\n * one throw bare.\n */\n forwardNotFoundPayload: boolean\n load: AdminLoad\n /** The route's splat, i.e. the path after `/admin/`. */\n resolveSplat: (params: any) => string\n}) => ({\n component: AdminPage,\n head: ({ loaderData }: { loaderData?: any }) => getAdminMeta(loaderData?.metadata),\n // `staleReloadMode: 'blocking'` (a property of the loader *object*, not a\n // sibling route option — router-core only reads it off a non-function loader)\n // makes stale-match revalidation await the fresh loader before committing,\n // instead of the default background SWR that flashes the pre-navigation list\n // (e.g. a just-created doc missing) until the reload lands.\n loader: {\n handler: async ({ location, params }: { location: any; params: any }) => {\n const data = await runLoader(load, resolveSplat(params), location.searchStr)\n if (data?._notFound) {\n // eslint-disable-next-line @typescript-eslint/only-throw-error -- TanStack Router requires throwing notFound objects\n throw notFound(\n forwardNotFoundPayload\n ? { data: { routeKey: data.routeKey, rscPayload: data.rscPayload } }\n : undefined,\n )\n }\n return data\n },\n staleReloadMode: 'blocking',\n },\n // Surface query params in `loaderDeps` so `?locale=es` re-runs the loader.\n loaderDeps: ({ search }: { search: Record<string, unknown> }) => ({\n searchKey: JSON.stringify(search),\n }),\n validateSearch: (search: Record<string, unknown>) => search,\n})\n\n/**\n * Route options for the admin splat route (`/_payload/admin/$`). Renders Payload's\n * server-built NotFound page (shipped via the `notFound()` error's\n * `data.rscPayload`) for unknown/access-denied routes, falling back to the bare\n * client view.\n */\nexport function payloadAdminSplatRoute({ load }: { load: AdminLoad }) {\n return {\n ...adminRouteOptions({\n forwardNotFoundPayload: true,\n load,\n resolveSplat: (params) => params._splat ?? '',\n }),\n notFoundComponent: AdminNotFound,\n }\n}\n\n/**\n * Route options for the admin index route (`/_payload/admin/`). Same loader as the\n * splat route but throws a bare `notFound()` (no rscPayload) on miss, so\n * `AdminNotFound` falls through to the bare client view.\n *\n * `notFoundComponent` must be set here even though the payload is never forwarded:\n * TanStack picks the boundary component from its presence (`routeNotFoundComponent ?\n * CatchNotFound : SafeFragment`), so leaving it off gives this route a different\n * component type than the splat route at the same position in the tree. Navigating\n * between the two would then unmount the whole admin subtree and remount it —\n * blanking the page for as long as the new view takes to render.\n */\nexport function payloadAdminIndexRoute({ load }: { load: AdminLoad }) {\n return {\n ...adminRouteOptions({\n forwardNotFoundPayload: false,\n load,\n resolveSplat: () => '',\n }),\n notFoundComponent: AdminNotFound,\n }\n}\n"],"names":["NotFoundClient","notFound","redirect","useLoaderData","Fragment","useDeferredValue","getAdminMeta","searchToRecord","searchStr","Object","fromEntries","URLSearchParams","runLoader","load","splat","data","_splat","search","_redirect","to","AdminPage","strict","rscPayload","AdminNotFound","props","routeKey","adminRouteOptions","forwardNotFoundPayload","resolveSplat","component","head","loaderData","metadata","loader","handler","location","params","_notFound","undefined","staleReloadMode","loaderDeps","searchKey","JSON","stringify","validateSearch","payloadAdminSplatRoute","notF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ACNC,SAAS,OAAO,EAAEC,QAAQ,EAAEC,MAAM,EAAkC;gBAClE,MAAMrB,OAAO,MAAMH,UAAUC,MAAMe,aAAaQ,SAASD,SAAS3B,SAAS;gBAC3E,IAAIO,MAAMsB,WAAW;oBACnB,qHAAqH;oBACrH,MAAMpC,SACJ0B,yBACI;wBAAEZ,MAAM;4BAAEU,UAAUV,KAAKU,QAAQ;4BAAEH,YAAYP,KAAKO,UAAU;wBAAC;oBAAE,IACjEgB;gBAER;gBACA,OAAOvB;YACT;YACAwB,iBAAiB;QACnB;QACA,2EAA2E;QAC3EC,YAAY,CAAC,EAAEvB,MAAM,EAAuC,GAAM,CAAA;gBAChEwB,WAAWC,KAAKC,SAAS,CAAC1B;YAC5B,CAAA;QACA2B,gBAAgB,CAAC3B,SAAoCA;IACvD,CAAA;AAEA;;;;;CAKC,GACD,OAAO,SAAS4B,uBAAuB,EAAEhC,IAAI,EAAuB;IAClE,OAAO;QACL,GAAGa,kBAAkB;YACnBC,wBAAwB;YACxBd;YACAe,cAAc,CAACQ,SAAWA,OAAOpB,MAAM,IAAI;QAC7C,EAAE;QACF8B,mBAAmBvB;IACrB;AACF;AAEA;;;;;;;;;;;CAWC,GACD,OAAO,SAASwB,uBAAuB,EAAElC,IAAI,EAAuB;IAClE,OAAO;QACL,GAAGa,kBAAkB;YACnBC,wBAAwB;YACxBd;YACAe,cAAc,IAAM;QACtB,EAAE;QACFkB,mBAAmBvB;IACrB;AACF"}
@@ -7,10 +7,15 @@ type ApiRouteHandler = (ctx: {
7
7
  * (`/_payload/api/$`). The app supplies `getConfig` (an `@payload-config`
8
8
  * import) since the package cannot resolve the consumer's config.
9
9
  *
10
+ * Imported from `@payloadcms/tanstack-start/server` (not the root barrel) so
11
+ * the server-only `handleAPIRoute` graph never reaches the client bundle.
12
+ *
10
13
  * Spread the result into a literal `server.handlers` key so TanStack Start's
11
14
  * client compiler can statically see — and prune — the server-only route:
12
15
  *
13
16
  * ```ts
17
+ * import { payloadApiHandlers } from '@payloadcms/tanstack-start/server'
18
+ *
14
19
  * export const Route = createFileRoute('/_payload/api/$')({
15
20
  * server: {
16
21
  * handlers: payloadApiHandlers({ getConfig: async () => (await import('@payload-config')).default }),
@@ -1 +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"}
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;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;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"}
@@ -3,10 +3,15 @@
3
3
  * (`/_payload/api/$`). The app supplies `getConfig` (an `@payload-config`
4
4
  * import) since the package cannot resolve the consumer's config.
5
5
  *
6
+ * Imported from `@payloadcms/tanstack-start/server` (not the root barrel) so
7
+ * the server-only `handleAPIRoute` graph never reaches the client bundle.
8
+ *
6
9
  * Spread the result into a literal `server.handlers` key so TanStack Start's
7
10
  * client compiler can statically see — and prune — the server-only route:
8
11
  *
9
12
  * ```ts
13
+ * import { payloadApiHandlers } from '@payloadcms/tanstack-start/server'
14
+ *
10
15
  * export const Route = createFileRoute('/_payload/api/$')({
11
16
  * server: {
12
17
  * handlers: payloadApiHandlers({ getConfig: async () => (await import('@payload-config')).default }),
@@ -19,7 +24,7 @@
19
24
  * key, leaking the config graph into the client bundle.
20
25
  */ export function payloadApiHandlers({ getConfig }) {
21
26
  const handler = async ({ request })=>{
22
- const { handleAPIRoute } = await import('../utilities/handleAPIRoute.js');
27
+ const { handleAPIRoute } = await import('../utilities/handleAPIRoute.server.js');
23
28
  return handleAPIRoute({
24
29
  config: await getConfig(),
25
30
  request
@@ -1 +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"}
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 * Imported from `@payloadcms/tanstack-start/server` (not the root barrel) so\n * the server-only `handleAPIRoute` graph never reaches the client bundle.\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 * import { payloadApiHandlers } from '@payloadcms/tanstack-start/server'\n *\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.server.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;;;;;;;;;;;;;;;;;;;;;;;;CAwBC,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"}
@@ -1 +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;IAqCG,SAAS;IACT,MAAM;QAAI,OAAO;QAAgB,eAAe;;EAEnD"}
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;IAsCG,SAAS;IACT,MAAM;QAAI,OAAO;QAAgB,eAAe;;EAEnD"}
@@ -19,6 +19,7 @@ import { TanStackRouterAdapter } from '../elements/RouterAdapter/index.js';
19
19
  /*#__PURE__*/ _jsxs(RootProvider, {
20
20
  config: data.clientConfig,
21
21
  dateFNSKey: data.dateFNSKey,
22
+ embed: data.isEmbedded,
22
23
  fallbackLang: data.fallbackLang,
23
24
  highContrastMode: false,
24
25
  isNavOpen: data.isNavOpen,